Skip to content
Merged
Show file tree
Hide file tree
Changes from 127 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
7d31ccc
Add some helper methods to convert AnyList into typed arrays.
xeus2001 Aug 27, 2026
df8ca36
Fix tag-map queries to use index and fix that queries on `id` work fo…
xeus2001 Aug 27, 2026
eff5a33
Fix brackets in query builder and where builder.
xeus2001 Aug 31, 2026
040599f
Design new streaming API.
xeus2001 Sep 3, 2026
4e24d7a
Fix some rebase issues with Int64 to Long branch.
xeus2001 Sep 7, 2026
cddf7dc
Apply requested fixes, improved API design and added usage example.
xeus2001 Sep 11, 2026
45df10a
Increment version to beta.52, ensure auto-update of openapi.yaml
xeus2001 Sep 9, 2026
2175ff4
Add design document how to ensure index-only scan, minimal partition …
xeus2001 Sep 9, 2026
92f3159
Add int8_to_fn and fn_to_int8 function requirements.
xeus2001 Sep 10, 2026
7d6ef05
Add Id migration path after rebasing upon Streaming API
xeus2001 Sep 14, 2026
f28eaea
Adjust worklist to use new Id class.
xeus2001 Sep 14, 2026
041cce4
Improve documentation and some nuances of Id.
xeus2001 Sep 14, 2026
4845268
Switch storage implementations to Id.
xeus2001 Sep 14, 2026
c734347
Switch from Naksha static methods to Id methods as Id contains a fixe…
xeus2001 Sep 14, 2026
2e41916
Fix a bunch of tests, adjusting them to new Id class being used in St…
xeus2001 Sep 14, 2026
9c18deb
Add PgDatabase draft
xeus2001 Sep 23, 2026
19d44bf
Delete long deprecated code.
xeus2001 Sep 23, 2026
b5ac0f9
Update PgDatabase so it can be implemented.
xeus2001 Sep 23, 2026
cb2c26b
Refactor AbstractPgDatabase into PgDatabase and PgDatabase into PgDat…
xeus2001 Sep 24, 2026
0d75afc
Delete deprecated unused classes, delete unused accidentially exposed…
xeus2001 Oct 5, 2026
818cb74
Fix version number, replace map with array to avoid int boxing.
xeus2001 Oct 12, 2026
91213ef
Improve identifier comparing, so it matches database ordering.
xeus2001 Oct 12, 2026
493b34c
Add helper to convert string into a JSON string.
xeus2001 Oct 12, 2026
0935791
Add toList and toListNotNull to ListProxy
xeus2001 Oct 12, 2026
7f2a776
Add support to report catalog, collection, and feature that causes a …
xeus2001 Oct 12, 2026
3f503aa
Add support for notInitialized.
xeus2001 Oct 12, 2026
ff0d0d3
Add methods to get primary local IP, to yield, and for simple cross-p…
xeus2001 Oct 12, 2026
4add4a0
Only improved comments
xeus2001 Oct 12, 2026
693b909
Ensure that member getter/setter work upon any object, not just upon …
xeus2001 Oct 12, 2026
53ea34f
Add support for Id, adjust sortCompare to use the new standardized me…
xeus2001 Oct 12, 2026
831000a
Remove dataEncoding, not used anymore, add support for Id
xeus2001 Oct 12, 2026
cda72a4
Ensure that context uses primary ip for appName and appId as defaults.
xeus2001 Oct 12, 2026
158bf1b
Add support to NakshaError for the database that raised the error.
xeus2001 Oct 14, 2026
7d3a7dc
Minor skill adjustment for removing properties.
xeus2001 Oct 14, 2026
f4d547c
Improve table creations statement, add off-topic human discussion poi…
xeus2001 Oct 14, 2026
2a84e1e
Fix that by default there is no limit for queries.
xeus2001 Oct 14, 2026
80c473c
Make the session optional in member processor and allow any-object, w…
xeus2001 Oct 14, 2026
17835d3
Add NakshaDatabase, the main purpose is documentation so users can un…
xeus2001 Oct 14, 2026
c549d1c
Improve index, supporting ordering, allow declaration from members.
xeus2001 Oct 14, 2026
1f9c50e
Add support to members for retain and conditional properties. Add rea…
xeus2001 Oct 14, 2026
66f76d3
Minor improvements like opening functions for overloading, comments, …
xeus2001 Oct 16, 2026
bb267a2
Add new Kotlin specific infix function As to simplify and unify type …
xeus2001 Oct 16, 2026
eb632a0
Add intValue to simplify catalog and collection handling.
xeus2001 Oct 16, 2026
9170af3
Add version alias for simplified access, fix comments.
xeus2001 Oct 16, 2026
4fa2fc3
Refactor PostgreSQL storage and catalog management across JVM and PLV8.
xeus2001 Oct 26, 2026
b0e289d
Fix compilation errors.
xeus2001 Oct 26, 2026
1730e78
Document physical database operations and return nullable mutation er…
xeus2001 Oct 27, 2026
3ae6772
Rebase to latest v3
xeus2001 Oct 27, 2026
e0780e3
Pass physical collection creation settings to PgDatabase while leavin…
xeus2001 Oct 27, 2026
e5fd95d
Inbetween commit to change branch.
xeus2001 Oct 27, 2026
6759b1f
Updated plan.
xeus2001 Oct 28, 2026
e2146e3
Minor corrections to work plan by qwen.
xeus2001 Oct 28, 2026
72e0708
Make NAKSHA-33 markdown better human readable, add AGENTS.md
xeus2001 Oct 28, 2026
2a83e2b
Optimize ticket management, improve skills and agents markdowns.
xeus2001 Oct 28, 2026
188d789
Introduce an immutable NewTuple wrapper and remove the mutable previo…
xeus2001 Oct 28, 2026
529efc9
Replace row-buffer mutation signatures with immutable tuple inputs an…
xeus2001 Oct 29, 2026
e400f72
Add expected and actual error versions with tuple-number reconstructi…
xeus2001 Oct 29, 2026
8f2b9a0
Document mutation outcomes and history behavior for tuple persistence.
xeus2001 Oct 29, 2026
1c08334
Verify pg_partman HEAD topology with a rollback-only SQL spike.
xeus2001 Oct 29, 2026
4638f4a
Verify HEAD range boundaries, uniqueness and invalid next-version rej…
xeus2001 Oct 29, 2026
7ccf10d
Verify partition provisioning limits and prototype a Naksha-owned mai…
xeus2001 Oct 29, 2026
d6ec899
Remove test agent and one skill, add marker file for personal skill m…
xeus2001 Oct 29, 2026
94e7bbd
Archive completed database contract and partition-maintenance verific…
xeus2001 Oct 29, 2026
687597b
Validate collection creation options and add physical feature-number …
xeus2001 Oct 29, 2026
64f31bf
Keep feature identities logical and store feature-ordinals with align…
xeus2001 Oct 30, 2026
340f23d
Preserve non-null HEAD next-version values at the row boundary.
xeus2001 Oct 30, 2026
ef353f2
Unify identifier aliases and physical naming across storage boundaries.
xeus2001 Oct 30, 2026
0004706
Implement transactional schema lookup and creation with logical-name …
xeus2001 Nov 2, 2026
faef350
Reject unsupported index definitions before issuing DDL.
xeus2001 Nov 2, 2026
5cf66c0
Centralize index writes and enforce immutable collection schemas.
xeus2001 Nov 2, 2026
e7ea9a0
Updated skills and project files.
xeus2001 Nov 2, 2026
1a5e200
Implement shared Kotlin collection creation and partition maintenance.
xeus2001 Nov 3, 2026
912ca48
Attach PLV8 storage from schema comments and share Kotlin maintenance.
xeus2001 Nov 3, 2026
3c9b574
Install restricted PLV8 maintenance entry point.
xeus2001 Nov 3, 2026
bb57ce5
Verify maintenance permissions and concurrent JVM/PLV8 sweeps.
xeus2001 Nov 3, 2026
74db4ca
Resolve storage layouts and scope catalog and collection locking.
xeus2001 Nov 3, 2026
2357955
Prepare internal collections for catalog creation and cold lookup.
xeus2001 Nov 3, 2026
217bb78
Persist CREATE tuples through collection roots.
xeus2001 Nov 3, 2026
d2f6959
Add independent code and security review roles.
xeus2001 Nov 3, 2026
0012420
Restore root reads and centralize feature ordinal conversions.
xeus2001 Nov 3, 2026
4a17724
Added minor skill improvement about postgres.
xeus2001 Nov 3, 2026
d946b7a
Persist UPDATE, UPSERT and DELETE through PgDatabase.
xeus2001 Nov 4, 2026
228a90b
Reconstruct HEAD tuple-number and materialize XYZ fields on reads.
xeus2001 Nov 4, 2026
6847a66
Fix partition-count validation, upsert changeCount and history-read v…
xeus2001 Nov 4, 2026
7be18cc
Reject atomic writes without a version; map metadata misses correctly.
xeus2001 Nov 4, 2026
3fdc616
Order writes by catalog, collection, operation and id before executing.
xeus2001 Nov 4, 2026
101abe4
Harden history persistence and accelerate partitioned storage access.
xeus2001 Nov 5, 2026
dddd4c4
allow null catalogId to support Hub usage
gunplar Nov 13, 2026
d21242b
bump to beta 53, to release for perf test
gunplar Nov 13, 2026
cc00bcb
fix some tests
gunplar Nov 13, 2026
80858e2
fix some tests
gunplar Nov 16, 2026
c2079a6
fix some tests
gunplar Nov 16, 2026
92f4714
fix some tests
gunplar Nov 16, 2026
8c3a0f5
fix some tests
gunplar Nov 16, 2026
a0f1e4d
fix some tests
gunplar Nov 16, 2026
9500f23
fix some tests
gunplar Nov 17, 2026
84e3247
fix some tests
gunplar Nov 17, 2026
207b93a
fix some tests
gunplar Nov 17, 2026
0945a89
fix some tests
gunplar Nov 17, 2026
da7ee99
NakshaError Http error code mapping
gunplar Nov 17, 2026
87df4cc
Refactor partition maintenance around collection metadata
xeus2001 Nov 17, 2026
3ce884b
Fix JVM handler and hub regressions and document local test runs
xeus2001 Nov 17, 2026
2fa8580
Fix service JVM regressions and guard view PATCH copy-on-write
xeus2001 Nov 17, 2026
8f6849d
Add branch review findings for v3-naksha-33
xeus2001 Nov 18, 2026
8565aaa
Normalize collection layouts and restore streaming compatibility
xeus2001 Nov 18, 2026
e6b0925
Require metadata and fresh compilation gates before tests
xeus2001 Nov 18, 2026
20597bf
Fix AttributeMap common metadata and portable test compilation
xeus2001 Nov 18, 2026
4124141
disable V3StreamSmokeTest temporarily for artifact publishing, as it …
gunplar Nov 18, 2026
802f02b
Serialize admin bootstrap upgrades and release beta.54
xeus2001 Nov 19, 2026
26ab15b
make sure we can run tests against local DB through env vars, for CICD
gunplar Nov 19, 2026
19efc3f
Document UNNEST-based batched mutation implementation plan
xeus2001 Nov 20, 2026
a21289c
Implement UNNEST batched mutations and record performance baseline
xeus2001 Nov 20, 2026
1300d82
Optimize batched HEAD discovery and release beta.55
xeus2001 Nov 20, 2026
a84967e
Schedule eight-hour partition maintenance with orphan cleanup
xeus2001 Nov 23, 2026
0e6f648
Optimize tuple member validation and path routing
xeus2001 Nov 23, 2026
911879f
Add some hint about delegation.
xeus2001 Nov 23, 2026
00a065c
Encode member references natively with compact reusable plans
xeus2001 Nov 23, 2026
d4ffcd4
Reduce tuple encoding CPU with fused checks and bulk copies
xeus2001 Nov 23, 2026
ecad7bf
Compile collection member layouts and use array-backed books
xeus2001 Nov 23, 2026
1533e61
Prepare beta.56 for manual publication
xeus2001 Nov 23, 2026
2ad67f5
enable pg_cron by default
gunplar Nov 24, 2026
1dc70f3
Fix that NAKSHA_TEST_MAINTENANCE_JOBS env var works as well without N…
xeus2001 Nov 24, 2026
4abb74e
Keep the JBON string modification as a draft for now.
xeus2001 Nov 25, 2026
0df2ba7
Unify local and GitHub v3 test runs
xeus2001 Nov 25, 2026
6ad7d91
Merge remote-tracking branch 'origin/v3-naksha-33' into v3-naksha-33
xeus2001 Nov 25, 2026
62b8234
Prepare beta.57 and archive ticket working notes
xeus2001 Nov 25, 2026
f50ffbd
Isolate and retain numbered cleanAndTest databases
xeus2001 Nov 25, 2026
ff22913
Merge branch 'v3' into v3-naksha-33
gunplar Nov 26, 2026
243163d
Resolve merge conflicts
gunplar Nov 26, 2026
e089c37
NAKSHA-33: Address PostgreSQL batch write review feedback
xeus2001 Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
113 changes: 113 additions & 0 deletions .claude/skills/naksha-codestyle/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
name: naksha-codestyle
description: Instructions how to write code.
---

# Format
- Use two spaces instead of tabs.
- If a file uses a mixed or other amount of spaces per tab, or even tabs, modify the file to that it uses 2 spaces per tab.
- Do not modify files that you do not touch.
- Do the modification in two phases, first do the changes intended, ones approved, make the reformat on yourself in a second commit that states in the commit message that this is only a formatting. This simplifies reviews.

# General
Avoid using streaming APIs, prefer classic loops like:
```kotlin
for (v in array) ...

var i = -1
while (++i < array.size) ...

for (i in 0 until array.size) ...
```
Chose, dependent on use-case, but stay away from streaming API, unless there is a specific reason.
Try to avoid looping the same array or list multiple times, merge loops when possible.
Always copy variables to stack when used more than one time, example:
```kotlin
// Do not:
fun get(key: String, alternative: T): T {
return if (this[key] != null && alternative::class.isInstance(this[key])) this[key] else alternative
}
// Do instead:
fun get(key: String, alternative: T): T {
val value = this[key]
return if (value != null && alternative::class.isInstance(value)) value else alternative
}
```
Avoid nested functions when they can be normal functions or companion functions. If there is a reason for nesting, it is fine, but avoid not necessary nested functions.

# If-Else
Avoid `if-else` blocks, when a return can be used. For example instead of this:
```kotlin
fun ensureSameMeaning(a: String?, b: String?) {
if (a == null || b == null) {
if (a !== b) throw IllegalArgumentException("Not same")
} else {
// Some more code that is more complex
}
}
```
Rather do this:
```kotlin
fun ensureSameMeaning(a: String?, b: String?) {
if (a == null || b == null) {
if (a !== b) throw IllegalArgumentException("Not same")
return
}
// Some more code that is more complex
}
```

# Delegation
If delegating properties, do always add the type, so human review is more simple, so do not:
```kotlin
var maintenanceJobs by BOOLEAN_TRUE
var maintenanceSslMode by CRON_SSL_MODE
var foo by INT_OR_NULL
```

but do:

```kotlin
var maintenanceJobs: Boolean by BOOLEAN_TRUE
var maintenanceSslMode: String by CRON_SSL_MODE
var foo: Int? by INT_OR_NULL
```


# Comments and Markdown
Do not add line breaks within paragraphs of comments. For example:
```kotlin
/**
* This is comment with a first paragraph. We will not do any line-break to adjust for certain columns. This practise is from the last century, all modern IDEs are able to automatically add line breaks.
*
* However, we still want separate paragraphs for sure.
*/
```
Always keep documentation up-to-date.
Always add the current version as `@since {major}.{minor}` to methods documentation like:
```kotlin
/**
* Function documentation ...
*
* @since 3.0
*/
```

# Missing information
If you miss database credentials or other credentials: Ask the user for the missing credentials. Do not guess to make assumptions.

# Error handling
Do not use Kotlin's build in `require`, because in Naksha we explicitly want all exceptions to be `NakshaException` wrapping a JSON serializable `NakshaError`. Therefore, rather use if. Example:
```kotlin
// Do not:
require( foo == null ) { "Some message" }

// Do instead:
if (foo != null) throw illegalState("Some message")
```
Beware that `NakshaException` has a bunch of helper methods to auto-wrap all kind of errors. If some function is missing, just add it and use it. If you find existing `require` statements in code you anyway modify, treat them like spaces, fix them togehter with the space adjustment in a dedicated commit, so that it is clear that this is only syntactic sugar.

# PostgresQL database
Avoid at all cost to use SQL functions, except for build-in functions. This is especially true for all SQL functions that are using any other language than pure pl/SQL _(the native integrated language)_. Functions using PLv8 are purely intended for special purpose, for example to be used as background job from `pg_cron`. The reason is that starting the `PLv8` engine _(or most other custom language engines)_ is so expensive, compared to what they should archive, we **MUST** avoid this.

For example, we store feature-numbers in the database as feature-ordinals _(which are the feature-numbers byte-swapped, with the sign-bit flipped)_. When querying these numbers, turn the feature-number into a feature-ordinal in Java, then use the ordinal. We know that all `fn` columns store the ordinals, so we can perfectly fine do the convert in Java/JVM. DO NOT USE the SQL function that can do the same, it will cost microseconds, but they can be very valuable.
42 changes: 42 additions & 0 deletions .claude/skills/naksha-engineer-role/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: naksha-engineer-role
description: Instructions how to behave as senior software engineer.
---

# Role
You are a helpful senior software engineer.

# General Principles
Provide only the final answer.
Never include a chain of thought, analysis, or explanatory text.
Be as brief as possible. Examples:
- User: What is the capital of France?
- You: Paris
- User: Who wrote '1984'?
- You: George Orwell
- User: Solve 15*4.
- You: 60

Do not overthink. When being in doubt, ask the user, specially when assessing risks.

If a single task would become too large, split it into multiple steps. Let the user review if that is okay.
Propose task splits, even if between the steps the code would not compile or be broken. Sometimes it's still better to do it in multiple smaller steps. Ask the user.

# Coding style.
If the root of the project contains a `CODE_STYLE.md` file, follow this file. For everything unclear from `CODE_STYLE.md` file, or when no such file exists, follow the `codestyle` skill, so either `$PROJECT-codestyle` or `$USER-codestyle`.

# Git Principles
**NEVER** commit code into git, except explicitly asked for by the user — leave git usage to the user.
You may read from git, but do not add files or modify git.
If you think you should use git for any modification, ask the user explicitly for what you plan to do. Do this even if you think it was requested before. Always ask for explicit approval of any git usage that modifies the git repository!

# Tool Usage Principles
If you want to use tools, but they are not available (for example `rg`), ask the user if he likes to install it or if you should try an alternative.

# Execution Principle: Attempt Over Deliberation (Cheaply Reversible Actions)
If failure is cheap to recover from, attempt first — do not pre-verify success by reasoning. For actions with immediate error feedback and easy retry (e.g., file edit): just try the action, then use the actual error message as evidence for the next strategy.

- **No exact-match worry**: whitespace/tabs, unicode variants, full-width/half-width characters — these are things the tool reports on failure, not things to predict by inference before executing.
- **Try the simpler approach first**: when torn between two approaches (e.g., edit vs script splice), try the simpler one and switch only if it fails. If your conclusion is "try A, fall back to B", the deliberation spent reaching that conclusion must never be longer than the conclusion itself.
- **Reasoning budget goes to analysis** (reading code, finding bugs, design decisions), not execution mechanics (how exactly to match a string). Judge execution mechanics from tool-call results.
- **Checklist**: if you find yourself writing multiple paragraphs of "what if this fails?" — stop and just execute.
42 changes: 41 additions & 1 deletion .claude/skills/naksha-proxy/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This skill encodes the conventions for writing typed wrappers over `PlatformObje
- Proxies are **not thread-safe**; only one thread accesses a given instance at a time.
- An **enumeration** extends `naksha.base.JsEnum`. Values are registered statically through `def(...)` or `defIgnoreCase(...)`. They serialize as plain strings/ints in JSON.
- Both flavors are `@JsExport`-ed because the same code runs on JVM and JS.
- For every property, the canonical surface a caller can rely on is four methods: `has<Name>()`, `get<Name>()`, `set<Name>(value)`, `remove<Name>()`. Kotlin's `var name by DELEGATE` compiles to `getName`/`setName` automatically; `hasName`/`removeName` must be written explicitly. Generate all four for every property unless the user explicitly asks for a slimmer surface.
- Map-backed properties expose getters/setters through Kotlin delegated properties. Add `has<Name>()` / `remove<Name>()` for genuinely optional wire properties. Derived read-only virtual properties expose only a `val` getter; do not generate setters, fluent setters, presence checks or removal methods for them.

## When NOT to use

Expand Down Expand Up @@ -134,6 +134,46 @@ private val INDEXED = NotNullProperty<Foo, Boolean>(Boolean::class, name = "inde

If you do override the wire key, use the same string for both the `name =` argument *and* every `hasRaw("...")` / `removeRaw("...")` call — those bypass the delegate and need the raw map key.

### Derived Read-Only Virtual Properties

A derived read-only virtual property computes a value from an existing source property without adding an entry to the underlying map. Its cache belongs to the proxy instance, not the serialized data. Do not use a map-backed property delegate for the derived value or its cache.

For `val VNAME: T`, use these two private nullable cache fields:

- `_{VNAME}_org: O? = null` tracks the original source value of type `O`.
- `_{VNAME}_val: T? = null` holds the derived value of type `T`.

For example, `val id: Id` derived from `name: String` uses `_id_org: String?` and `_id_val: Id?`.

Read the source once in the getter. Reuse the cached result only when it is initialized and the current source matches the cached original. Use reference identity (`===`) when a new source instance must invalidate the cache, even if its contents are equal. For primitive/value dependencies, use the appropriate value comparison instead. Recompute and validate first, then update both cache fields; a failed computation must not publish a new cache state.

```kotlin
private var _id_org: String? = null
private var _id_val: Id? = null

/**
* Hidden virtual identifier derived from [name], excluded from serialized data. Reuses the cached identifier while the source string has the same identity.
* @since 3.0
*/
val id: Id
get() {
val original = name
val cached = _id_val
@Suppress("StringReferentialEquality")
if (cached != null && original === _id_org) return cached
val value = Id(original)
_id_org = original
_id_val = value
return value
}
```

Getter-side dependency checks are required because source properties can change through another proxy or raw-map access, bypassing a setter on this instance. Do not initialize the derived value in the constructor, and do not use `lazy` when the source can change. Identity comparison alone cannot detect in-place mutation of a mutable source; such a dependency needs a revision, snapshot or another explicit invalidation mechanism.

The two-field template assumes a non-null derived result. If `T` is nullable and `null` is a valid cached result, track initialization separately rather than treating `null` as both uninitialized and cached. For multiple dependencies, track every dependency or use a combined source snapshot. These caches follow the normal single-threaded proxy contract; they do not add thread safety.

Verify cache instance reuse, invalidation after source replacement (including raw-map changes), and exclusion of the derived value and cache fields from serialization. For identity-based caches, also test equal-content but distinct source instances on platforms where that distinction exists.

## List proxy template

Typed view over a `PlatformList` of homogeneous elements.
Expand Down
25 changes: 25 additions & 0 deletions .claude/skills/naksha-reviewer-role/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: naksha-reviewer-role
description: Reviews Naksha implementation increments independently for correctness, regressions, transaction semantics and meaningful test coverage before commits.
---

# Role
Act as an independent senior code reviewer, not the implementation author. Read the requested diff, surrounding callers, authoritative ticket contracts and relevant tests. Do not edit files or commit unless separately asked.

# Review Focus
- Identify concrete correctness defects, regressions, resource leaks, identity/ordinal mistakes, races and transaction-boundary violations.
- Check JVM and Kotlin/JS behavior, caller-owned transactions, immutable tuple inputs, root-table routing and result correlation.
- Verify tests exercise the changed behavior and do not bypass the path being claimed. Distinguish database assertions from cache observations.
- Respect explicitly deferred work such as db-11 cache isolation; report newly introduced violations without treating every known deferred issue as a new blocker.
- Do not approve solely because compilation or mocks pass. Check negative cases, rollback and concurrency where relevant.
- Check for not necessary resource allocation, e.g. repetitive `toByteArray()` calls or alike.
- If these calls are cached, they are fine, but check if the code creates lots of object instances.
- If methods are expected to be called seldom, be graceful _(compare change effort vs runtime cost)_.
- Ensure that arrays or lists are not unnecessarily looped multiple times.
- Recommend loop merging.

# Output
Return findings first, ordered by severity, with file/line references, a reproducible scenario and a minimal recommended correction. Separate confirmed defects from assumptions and unverified risks. If no findings remain, say so and identify meaningful verification gaps. Never invent issues to fill a quota or claim tests you did not run.

# Independence
Implementation agents must not review their own changes as the sole reviewer. The coordinating engineer resolves findings, reruns affected checks and requests follow-up review for substantial fixes before committing. A review is not human approval; commits follow the user's current authorization.
22 changes: 22 additions & 0 deletions .claude/skills/naksha-security-role/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: naksha-security-role
description: Reviews Naksha changes independently for SQL injection, privilege escalation, unsafe PLV8 execution, credential exposure and other exploitable security flaws before commits.
---

# Role
Act as an independent security engineer. Inspect the requested diff and its trust boundaries without modifying files, deploying changes, disclosing credentials or running destructive probes.

# Security Focus
- Trace untrusted catalog, collection, member and index names into SQL. Require identifier quoting, literal quoting or bound values as appropriate; parameters do not quote identifiers.
- Review dynamic DDL, operator/type fragments, search paths, extension lookup, module loading/evaluation and SQL wrapper volatility/security attributes.
- Check SECURITY INVOKER/DEFINER behavior, function ACLs, schema/object ownership, cross-database assumptions and authorization scope. SQL execution grants must not imply unintended escalation.
- Prevent credentials or unrestricted configuration from reaching schema comments, logs, errors, tests, commits or exported JavaScript.
- Assess transaction failure handling, denial-of-service through unbounded work/locks, race-sensitive ownership checks and malformed numeric/JSON inputs.
- Preserve JVM-only execution where required; PLV8 is an explicit database entry point, not an implicit Java fallback.
- Obtain authorization before runtime database writes, including disposable setup; use only isolated disposable databases and uniquely named temporary roles. Never clear existing databases or weaken server security to make a test pass.

# Output
Report concrete findings with severity, affected file/line, attacker-controlled input or required privileges, impact and minimal mitigation. Distinguish exploitable issues from defense-in-depth improvements. State when no confirmed issue is found and list relevant untested boundaries. Do not reproduce secrets in the report.

# Review Gate
The implementation author must address confirmed injection, credential exposure and privilege-escalation findings before committing. Request a second independent review after substantial security fixes. Do not silently relax validation, permissions or assertions for test success.
Loading
Loading