Skip to content

test(063): increment 4b, store host-seam tests and a Valkey-shaped store double - #525

Merged
bartekus merged 7 commits into
mainfrom
impl/063-store-tests
Nov 6, 2026
Merged

bartekus merged 7 commits into
mainfrom
impl/063-store-tests

Conversation

@bartekus

@bartekus bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Spec 063 increment 4, part b (3.7, 3.13.3): host-seam tests for the store and a reference Valkey-shaped store double. Stacked on part a (the store seam); review only the commit after it. Test files only, plus the spec record sentence.

  • test/valkey-double.mjs: a Redis-shaped double that behaves like Valkey 8.1 with maxmemory-policy volatile-lru and primary-only reads, as the partner requires. No network access and no wall-clock time.
    • Keyspace: string and hash keys, PEXPIRE with lazy expiry on an injected clock, and Lua-script atomicity (a script runs with nothing in between).
    • Eviction: under maxmemory, only keys with a TTL are evicted; a write that cannot make room is refused with OOM, as Valkey refuses it.
    • Replication: a primary and an explicitly lagging reader endpoint.
  • ValkeyStore: the 3.7 Redis table as code. Keys sit under one hash tag per namespace ({rx:<ns>}:g, :g:<scope>, :e:<keyId> holding bytes and scope, :b, :b:<scope>).
    • get, put and delete are each one script on the primary.
    • invalidate is an INCR of a generation key with no TTL. Entry removal runs afterwards and is optional.
    • Entries carry a TTL. Generation and byte-counter keys have none, so volatile-lru cannot evict them.
  • Non-conforming variants (section 5):
    • readFrom: 'replica' breaks G2.
    • atomicGet: false breaks G3: entry and generations are read in two round trips, with a hook in the gap.
    • atomicPut: false breaks G4: check, hook, then write.
    • policy: 'allkeys-lru' breaks G1.
    • removeOnInvalidate: false.
  • test/store.test.mjs covers the store rows of section 5 and 3.13.3's host-seam cases:
    • Configuration: contract refusals (no erasure, an empty term, an unknown term, none), the queue bound, store_missing, store_contract_mismatch.
    • Restart: a restarted engine hits the same Valkey store with age_ms, and writes nothing more. Another engine's plan.invalidate makes the next one miss with generation_advanced.
    • Failure policy: a get failure under fail_closed is refused with nothing dispatched; under continue_without_cache it is a miss and nothing is written.
    • Bounds: a generation of 2^53 or 0.5, an unknown put answer, and non-Uint8Array bytes are each a store_failed miss, never a hit.
    • Queue and late settlement: a full queue is host_seam_queue_full at once. A get still unsettled at the decision deadline counts in abandonedPending, and its late settlement is discarded and counted.
    • Invalidation: a never-settling invalidate ends at timeoutMs on the manual clock as pending, complete: false, with the signal aborted and abandonedPending 1. The next decision is a miss with no store read ("unavailable until invalidation completes"). timeoutMs bounds are checked, and null comes back without an optimization namespace. A throwing invalidation stays pending; a later call completes it and the tier hits again.
    • Shutdown: shutdown with three pending gets reports abandonedPending 3, no slot held.
    • Conforming eviction: volatile-lru evicts only entries under memory pressure, never generation or counter keys, and an invalidated entry is never served.
    • Detectable versus undetectable:
      • allkeys-lru evicting a generation key, and a lagging reader endpoint, each serve a stale hit. Rustev cannot detect either; G1 and G2 forbid them.
      • Split reads only miss.
      • A check-then-write put racing an invalidation leaves an entry with old generations that is read and refused (generation_advanced), never served.

M5 note for the spec owner (no spec change here): G2 makes entry removal on invalidate optional, but under first-writer-wins put-if-absent (G4), an entry that is never removed answers every later put of its key with conflict. That key then stays a miss until the entry's TTL reclaims it. This is safe, never a stale hit, but the cache stays cold after an invalidation. ValkeyStore removes covered entries after the INCR by default, and the restart test opts out to show generation_advanced. A non-normative sentence in 3.7 may be worth adding.

Checks run locally: as part a, with node --test integrations/rustev-node/test/*.test.mjs passing, and store.test.mjs with source.test.mjs passing three runs in a row.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the three changed files: two new test-infrastructure files and a spec documentation update.

integrations/rustev-node/test/valkey-double.mjs

Write-before-room-check in ValkeyNode.set() and hset()

The comment at line 46–47 reads: "Make room before a write, as Valkey does." The implementation inverts this:

set() (line 64) writes the entry into this.keys and then calls #room() (line 65).
hset() (line 80) writes the entry into this.keys and then calls #room() (line 81).

Concrete failure path: under policy: 'volatile-lru', write any no-TTL key (a generation counter, a byte-budget counter) when used() + incoming_size > maxmemory and no volatile-key candidates exist. #room() at line 51 throws OOM — but the key is already resident in this.keys. The caller sees an exception; the double's keyspace retains the phantom entry. Subsequent used() calls overcount, and the byte-budget counters (${t}:b, ${t}:b:${scope}) accumulate phantom bytes that are never reclaimed, causing over-budget refusals for all subsequent put() calls to that namespace.

The fix is to compute required size before writing, check/evict, and only then write — matching real Valkey's pre-write OOM handling.

This does not fire in the current tests because maxmemory: 2_600 is sized to hold the generation keys before any volatile entries are present, but the invariant is fragile: a future test that sizes memory more tightly around entry count would trigger it.

integrations/rustev-node/test/store.test.mjs and specs/063-node-binding-parity/spec.md

No concrete defects found. The test logic correctly exercises the store seam, plan.invalidate, queue-full and late-settlement paths, and the non-conforming double variants (split reads, check-then-write, replica reads, allkeys-lru). The spec documentation addition is consistent with the "Decisions at approval" convention and makes no lifecycle or authority change.

{"head": "bd9e91109ce603cafdcac23236466ba9bbdbfd27", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/test/valkey-double.mjs", "line": 64, "severity": "medium", "category": "correctness", "summary": "ValkeyNode.set() and hset() write the entry into this.keys before calling #room(); if #room() throws OOM (volatile-lru, no evictable candidates, used() exceeds maxmemory after the write), the entry is permanently resident in the keyspace while the caller sees an exception, corrupting subsequent used() readings and byte-budget counters."}]}

Subject: 6862814...bd9e911, diff digest d629da4a7ffe33098c43a87425ada9231fdfb4cbf1568ad1dde35c70278997ad, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 6, 2026 01:30 — with GitHub Actions Inactive
bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus force-pushed the impl/063-store-tests branch from bd9e911 to 10c6331 Compare November 6, 2026 01:33
@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Review note: the finding is fixed in the latest commit. ValkeyNode now stores a write only after room is made; on OOM it restores the key's previous value (or removes the new key) before raising, and it never evicts the key being written. store.test.mjs asserts that a refused write leaves the keyspace unchanged.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed paths: a new test file, a new Valkey test double, and a spec documentation update.

integrations/rustev-node/test/valkey-double.mjs

  • ValkeyNode.#write restores old (fetched via this.keys.get(k) before the tentative write) on OOM. The eval path is synchronous, so no interleaving can alter old between save and restore. Correct.
  • incrby calls get, which returns a Buffer. Number(Buffer) falls through to Buffer.prototype.toString() (UTF-8 decode) and then numeric coercion—works correctly for the counter use case.
  • hset builds a fresh Map copy before #write, so a refused write leaves the original hash untouched. Correct.
  • delete reads bytes and scope from the same hash key in two sequential hget calls inside eval. Since eval is synchronous (simulating Lua atomicity) there is no interleaving. The LRU tick is updated twice, which is benign.
  • scope returned by hget is a Buffer; using it in a template literal (${t}:b:${scope}) invokes Buffer.prototype.toString() (UTF-8 decode), producing the same string that was written via hset. Consistent with the counter key written in put.
  • set preserves the old entry's expiresAt. Generation and byte-counter keys are never pexpire'd, so their expiresAt is always null; the preservation has no effect in this double. Entry keys have their TTL applied by an explicit pexpire call in write immediately after hset. Correct.
  • ValkeyStore.invalidate yields (await yieldNow()) between the INCR and the removal scan. The spec comment "G1, G2: the INCR is the invalidation, atomic alone; removing the covered entries runs afterwards … and is optional" matches the implementation.

integrations/rustev-node/test/store.test.mjs

  • scripted shares inner.calls by reference, so both the wrapper store and the underlying ValkeyStore increment the same counters. Correct.
  • until polls up to 2000 setImmediate ticks before failing. Appropriate for a manual-clock test with no wall-clock sleeps.
  • The every helper hard-codes a check for exactly 3 requests (outcomes(r).length === 3). This is coupled to the fixture plan having 3 requests (topic, frustration, deadline), which is consistent with the outputs object defined at the top of the file and the support-routing fixtures used throughout. Not a bug given the fixed fixtures.
  • The split-read test uses {rx:x}:unused to simulate gap activity without touching the namespace under test. once is captured in the closure and starts true; after the first decide it flips to false, so the gap action fires only once. Correct.
  • The check-then-write (G4) test sets invalidator before decide, causing the invalidation to fire inside the between callback during put. The racy write stores the entry with no embedded generation check; the runtime embeds the write-time generations in bytes and detects the mismatch on the next get. The test assertion generation_advanced is consistent with this design.

specs/063-node-binding-parity/spec.md

The change adds nine lines of prose to the acceptance section, describing what the two new files cover. No frontmatter (status, implementation) is altered, so there is no lifecycle change. The description accurately matches the implementation.

No concrete defects found in any of the three files.

{"head": "10c6331dc03c85883f6a746da7a50b9fdefd5c38", "verdict": "no-findings", "findings": []}

Subject: 8a05904...10c6331, diff digest 932cb9b26ee9c711cdfae4713fa0a2fb78e98d8d3f1bab6eb4f1de3404dc572e, 1 call(s). An AI comment is not an approval.

bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus force-pushed the impl/063-store-tests branch from 10c6331 to 5ccb63a Compare November 6, 2026 01:39
bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus force-pushed the impl/063-store-tests branch from 5ccb63a to 30e15da Compare November 6, 2026 01:39
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the three changed files: two new test files and a spec prose addition.

valkey-double.mjs

ValkeyNode.set (line 72) retrieves the old entry with this.keys.get(k) (direct map access) instead of this.#live(k) (lazy-expiry check):

set(k, v) {
  const old = this.keys.get(k);                             // bypasses #live
  this.#write(k, { ..., expiresAt: old?.expiresAt ?? null, ... });
}

If k holds an expired entry, old.expiresAt is a past timestamp that gets inherited by the replacement entry, making the replacement immediately expired on the next #live access. All other mutating methods (hset, pexpire) go through #live correctly. In the ValkeyStore as written, set is only called via incrby for generation keys ({rx:ns}:g) and byte-counter keys — none of which ever receive a pexpire call — so the latent bug produces no observable failure in the current tests. Were a future caller to run pexpire on a generation key, however, the next incrby would silently reset the generation to whatever value it was before expiry (since the expired key would re-appear in keys.get and pass its stale past timestamp along), allowing stale entries to pass the generation check.

store.test.mjs

Logic, fixture paths, clock manipulation, and assertions look self-consistent. The until polling and clock-advance patterns are used correctly. The scripted wrapper correctly delegates unoverridden methods to the inner ValkeyStore. No security concerns: all file access is via static fixture paths derived from import.meta.url.

specs/063-node-binding-parity/spec.md

Prose-only addition to the testing notes section. No frontmatter or lifecycle fields are modified.

{"head": "30e15da3e1700b76c8dc024fab1b43f9a474e795", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/test/valkey-double.mjs", "line": 72, "severity": "low", "category": "correctness", "summary": "ValkeyNode.set uses this.keys.get(k) instead of this.#live(k) to retrieve the old entry, so an expired string key's past expiresAt is inherited by its replacement, making the replacement immediately expired on the next live access."}]}

Subject: 5638821...30e15da, diff digest 932cb9b26ee9c711cdfae4713fa0a2fb78e98d8d3f1bab6eb4f1de3404dc572e, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 6, 2026 01:47 — with GitHub Actions Inactive
bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus force-pushed the impl/063-store-tests branch from 30e15da to 3e91c05 Compare November 6, 2026 01:48
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed files:

integrations/rustev-node/test/valkey-double.mjs

ValkeyNode.set() preserves the existing key's TTL (line ~65 in the new file, expiresAt: old?.expiresAt ?? null). The comment correctly notes this is INCR semantics, not SET semantics. Since set() is called only from incrby(), and incrby on a Valkey key correctly inherits the TTL, this is intentional and accurate. The method is public, but all direct calls in the test suite (full.primary.set('{rx:n}:g', '1')) target new keys so old is undefined and TTL is null. No defect.

The #write eviction loop is correctly bounded: it restores the old value and throws OOM when no candidates remain. The hset path creates a detached copy before passing to #write, so a refused write leaves the original hash untouched — consistent with the comment.

ValkeyStore.put()'s write closure calls hset then incrby for byte counters inside cluster.eval. If hset succeeds but an incrby OOM-throws, the entry is committed but the byte counters are understated. However, this matches real Valkey Lua-script behaviour (errors inside a script do not auto-rollback prior commands), and no test exercises this path at the configured maxmemory values. Not a concrete defect.

ValkeyStore.invalidate() does not forward the AbortSignal passed by the runtime, but the test for aborted invalidations uses a scripted override that captures the signal directly — the ValkeyStore implementation is never used in that test. No defect.

The for (const m of [...]) st[m] = over[m] ?? ((c) => inner[m](c)) construct in scripted() is safe: const in for…of creates a fresh binding each iteration, closures capture correctly, and inner[m](c) retains the receiver. ✓

integrations/rustev-node/test/store.test.mjs

Generation-key eviction invariant (volatile-lru test): only keys with a TTL are candidates for eviction in the double (policy === 'allkeys-lru' || e.expiresAt != null), so generation and byte-counter keys (no TTL) survive memory pressure. ✓

Split-read and check-then-write tests correctly distinguish between failures Rustev can detect (generation_advanced) and those it cannot (stale hit under allkeys-lru or lagging replica). The once flag in the split-read test ensures the between callback's side-effect touches only an unrelated hash tag ({rx:x}:unused), leaving the tested namespace's generation intact for the first decision. ✓

The until polling loop uses setImmediate, which is appropriate for a synthetic environment with a manual clock and no real I/O.

specs/063-node-binding-parity/spec.md

The added paragraph accurately describes the new test files — it matches the test file's own header comment and the ValkeyStore's option set. The change is purely additive acceptance documentation; it touches no frontmatter (status, implementation), no authority edges, and no normative claims. No governance issue.

No concrete defects found across all three files.

{"head": "3e91c0540554efffb5dd7f3692c10138901b2ac6", "verdict": "no-findings", "findings": []}

Subject: e85ffcf...3e91c05, diff digest 131bc9fd1ebb0d6edcd84297b24369ec0b307806e29492ae4340620700ffe600, 1 call(s). An AI comment is not an approval.

bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus force-pushed the impl/063-store-tests branch from 3e91c05 to fdacda6 Compare November 6, 2026 01:57
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the three changed files: two new test files and a spec documentation update.

integrations/rustev-node/test/valkey-double.mjs

The double is carefully written. One concrete modeling gap: in ValkeyStore.put, the write closure runs (conceptually) inside cluster.eval, which the double models as a synchronous, atomic Lua script. The sequence is:

  1. n.hset(entry key) — entry written, no TTL yet
  2. n.pexpire(entry key, ttlMs) — entry now carries a TTL, making it evictable by volatile-lru
  3. n.incrby(scope byte-counter key) — calls ValkeyNode.set → #write; if the counter key is new and memory is at capacity, #write scans for evictable candidates (expiresAt != null, key !== scope-counter-key); the just-written, just-TTL'd entry qualifies and may be evicted
  4. return 'stored'

If step 3 evicts the entry it returns 'stored' with the byte counter incremented but the entry absent — inconsistent state. ValkeyNode.#write rolls back the byte-counter key on OOM but not the entry that was already committed. No test in this PR exercises a memory budget tight enough to reach this code path (the maxmemory: 2_600 test adds pressure only after the initial puts complete), so no test currently misbehaves. But the double silently breaks its own stated "Lua-script atomicity" guarantee under that input, which could mislead a future test that uses a tighter budget.

File/line: integrations/rustev-node/test/valkey-double.mjs, write closure inside put (~line 190).

integrations/rustev-node/test/store.test.mjs

Logic, gauge assertions, and until-loop polling all look correct. Math.max(...e.clockDelays()) at line ~150 is safe because until already guarantees length > 0 before control reaches that call in Node.js's single-threaded model. The scripted helper correctly shares inner.calls for the passthrough methods and correctly leaves overridden methods uncounted.

specs/063-node-binding-parity/spec.md

The added paragraph accurately describes the coverage and the double's design. No lifecycle or authority issue.

{"head": "fdacda680799f471d268395b6ee2f8ae0a3c5416", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/test/valkey-double.mjs", "line": 190, "severity": "low", "category": "correctness", "summary": "In ValkeyStore.put's write closure, pexpire is called before the byte-counter incrby calls, so the just-written entry already carries a TTL and is a volatile-lru eviction candidate; under OOM during incrby, #write may evict that entry while the function still returns 'stored', producing inconsistent state without any test currently exercising this code path."}]}

Subject: e3de14f...fdacda6, diff digest 131bc9fd1ebb0d6edcd84297b24369ec0b307806e29492ae4340620700ffe600, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 6, 2026 02:02 — with GitHub Actions Inactive
bartekus added a commit that referenced this pull request Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed files: two new test files (store.test.mjs, valkey-double.mjs) and a spec documentation update.

valkey-double.mjs

  • LRU side effect in ValkeyNode: incrby calls get (which calls #live, bumping the LRU tick), then set (which also calls #live again). Every counter write bumps the tick twice. Counter keys have no TTL and are never evictable under volatile-lru, so this never affects eviction decisions in the tests. No observable defect.
  • Number(Buffer) via gen(): JavaScript's ToPrimitive calls Buffer.prototype.toString() before converting, so Number(Buffer.from('1')) correctly yields 1. The incrby → get path is sound.
  • OOM atomicity in eval: snapshot-and-restore on throw is correct; the first write in the eval script (not the second) fails under maxmemory: 40, so the rollback is exercised correctly.
  • hget returns a Buffer; using it in a template literal correctly calls .toString() for counter key lookup in delete and invalidate. Consistent throughout.

store.test.mjs

  • scripted uses if (over.queueCapacity) (truthy check) rather than a nullish check, so scripted({ queueCapacity: 0 }) would silently ignore the override. No test calls that combination; the queueCapacity: 0 refusal test passes the value via object spread ({ ...scripted(), queueCapacity: 0 }), not through scripted(). No defect in the tested paths.
  • The split-reads between callback uses {rx:x}:unused, a namespace unrelated to the actual namespace under test. The gap simulation is correctly inert for the first decision; after writer.p.invalidate() the generation is advanced regardless of the gap, producing the expected miss. ✓
  • G4 (check-then-write) test correctly captures the write-after-invalidation scenario: the entry is stored with old generations, the next atomic-store engine sees the advanced generation and returns generation_advanced. ✓
  • Shutdown test: decide(p, 'stuck').catch((err) => err) does not await before until; the promise rejection is correctly caught and r is awaited at the end. ✓

specs/063-node-binding-parity/spec.md

Adds nine lines of test-coverage prose to the existing acceptance section. No frontmatter or lifecycle fields changed; no authority or ratification change.

No concrete defects found on any path the evidence supports.

{"head": "8d5f1077fed5234041c4490cdc57c1fef1c93b4e", "verdict": "no-findings", "findings": []}

Subject: e3de14f...8d5f107, diff digest b95bab0a21c4c7e23d6dd86e761b8f916fc54e20feb332ee997ae512e2a8c123, 1 call(s). An AI comment is not an approval.

bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus had a problem deploying to statecraft-review-exception November 6, 2026 11:19 — with GitHub Actions Error
bartekus added a commit that referenced this pull request Nov 6, 2026
@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Review note: finding 3de31d62a5be on 531624e is fixed in 5ca0bac: engine() takes shutdown: false, and the shutdown test passes it, so its engine is shut down once, by the test. #526 is restacked on it.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (findings)

Review

Scope: New test file store.test.mjs, new test double valkey-double.mjs, and a 9-line documentation addition to spec 063.


integrations/rustev-node/test/valkey-double.mjs

ValkeyNode.snapshot() — shallow hash copy
The snapshot copies each hash entry's Map with new Map(e.value), but the Buffer values inside the Map are shared references. eval rollback sets node.keys = before, replacing the top-level Map. Because hset always writes a new entry object (never mutates an existing Buffer in place), the shared references are never a problem: a rolled-back snapshot correctly reflects pre-script state. No bug.

eval rollback does not restore node.tick
After a failed script, tick is higher than before the script ran. Entries in the restored snapshot have lru values that appear artificially older relative to future writes. This could affect LRU eviction ordering in a test that relies on specific eviction order after a failed script. In practice none of the tests do this—they only check whether volatile-keyed entries are evicted, not which specific key is chosen first. Low practical risk.

ValkeyNode.set and incrby — counter semantics
incrby delegates to set, which preserves the existing key's expiresAt. Generation counters and byte-budget counters have no TTL (never passed through pexpire), so they are never evicted under volatile-lru. Byte counters go negative on delete; this matches Valkey's behavior and is tracked symmetrically by put/delete. Consistent.

delete — scope key reconstruction
${t}:b:${scope} where scope is a Buffer returned by hget: template-literal coercion calls Buffer.prototype.toString(), recovering the original UTF-8 scope string. This matches the key written in put as ${t}:b:${terms.scope}. Consistent, though implicit.

OOM test comment is misleading
The comment "A script that fails part-way leaves nothing behind" in the volatile-lru test implies the first set inside eval succeeds and the second fails. With maxmemory: 40, the first set('{rx:n}:x', '1') (size ~25 bytes added to the existing ~24 bytes) already exceeds maxmemory with no volatile candidate to evict, so it throws OOM at the first operation, not mid-script. The eval rollback still runs and the assertion ['{rx:n}:g'] still passes, but the stated scenario (partial execution) is not what the test actually exercises.


integrations/rustev-node/test/store.test.mjs

Logic and flow look correct. The until / manual-clock pattern is consistent with how the runtime's clockDelays/advanceClock API is used elsewhere. The scripted helper correctly captures each m as a fresh const binding per for…of iteration (no closure-over-loop-variable bug). Store contract validation, queue-full, deadline abandonment, invalidation timeout, and non-conforming variant tests all align with the spec's stated guarantees.

fx path resolution
new URL('../../../tools/rustev-conformance/fixtures/${dir}/${n}', import.meta.url) from integrations/rustev-node/test/ correctly resolves to workspace-root tools/rustev-conformance/fixtures/. Fixture files are pre-existing (not changed by this PR).


specs/063-node-binding-parity/spec.md

The 9-line addition accurately describes the new test files and the Valkey double's configuration. No lifecycle, ownership, or authority changes.


Governance

Changes touch only integrations/rustev-node/test/ and spec 063 documentation. No managed files (statecraft-*.yml, scripts/statecraft/, CODEOWNERS) are modified. No spec lifecycle change. No amends or authority graph edits.


The misleading OOM comment is the only concrete inaccuracy, and it is low severity: the assertion passes correctly regardless, the wrong reason does not propagate to production behavior, and it is confined to a test comment.

{"head": "5ca0bacc497ad5cca65fd56eea5e43fd15128f21", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/test/valkey-double.mjs", "line": 83, "severity": "low", "category": "correctness", "summary": "The eval OOM test comment says 'fails part-way' but with maxmemory:40 the first set inside the script already exhausts memory with no volatile candidate, so the script fails at its first operation rather than partway through; the assertion still passes but the documented scenario is not what executes."}]}

Subject: 10815b9...5ca0bac, diff digest 11c227465858c4d58bbcd1e1563877306298aed94ac4e7e94fa5830b263cb417, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception November 6, 2026 11:28 — with GitHub Actions Error
bartekus added a commit that referenced this pull request Nov 6, 2026
@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Review note: finding 7144f102e9c7 on 5ca0bac is right and fixed in 348c18e: with maxmemory: 40 the script's first write already overflowed. The script test now has its own node with room for one more small key, asserts the first write landed, and the second write's OOM rolls both back. #526 is restacked on it.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed files for correctness, security, and consistency with governance.

valkey-double.mjs

ValkeyNode.incrby reads back the stored value via this.get(k) which returns a Buffer. Number(Buffer.from("5")) relies on the coercion path: valueOf() returns this (non-primitive), so the runtime falls back to Buffer.prototype.toString() (UTF-8 by default), producing Number("5") = 5. This is correct for all values stored by incrby (decimal strings), and no code mutates buffer content in place, so the coercion path is reliable throughout.

ValkeyNode.snapshot() makes a shallow copy of hash-entry Maps (new Map(e.value)), sharing Buffer references between the snapshot and the live keyspace. This is safe because every write path in hset constructs a fresh Map with fresh Buffers (Buffer.from(v)) rather than mutating existing ones; rollback via node.keys = before restores the correct Map object without risk of aliased mutation.

ValkeyCluster.eval() captures the pre-script keyspace and evicted-list length, then restores both on any exception. The delete and put write paths run inside eval, so partial writes (e.g. byte-counter increment followed by an OOM in hset) are rolled back atomically. The intentionally non-atomic paths (atomicGet: false, atomicPut: false) run outside eval, which is correct — they are the broken-conformance variants under test.

Byte-counter keys ({rx:ns}:b*) and generation keys ({rx:ns}:g*) are never given a TTL, so they are ineligible for volatile-lru eviction. Entry eviction in the volatile-lru test only evicts junk:i keys (which carry a TTL), leaving Rustev's accounting keys intact. After invalidate removes Rustev entries, the removal script properly decrements the counters, so no accounting inconsistency exists in any tested scenario.

ValkeyStore.invalidate does the INCR outside eval and then optionally removes covered entries inside eval. The INCR key has no TTL (kept by set's TTL-inheritance logic when the key is new: expiresAt: old?.expiresAt ?? null), so the generation key survives LRU eviction. ✓

store.test.mjs

The until poller loops up to 2000 setImmediate ticks — appropriate given the manual clock (no real-time waits). The scripted helper correctly captures inner in a closure for each delegated method. The engine helper's dir selection (plan.startsWith('support') ? 'runtime' : 'store') correctly routes fixture paths. All assert.rejects predicates check both the error class and err.code, making the error-code assertions specific. The non-conforming variants tests are clearly scoped to intentionally broken double configurations and document which failures Rustev detects vs. cannot detect.

specs/063-node-binding-parity/spec.md

The added paragraph correctly describes the two new test files, their scope (store rows of section 5 and 3.13.3 host-seam cases), and the double's key properties (volatile-lru, primary-only reads, one script per operation, no network/clock). No frontmatter (status, implementation) is changed. The edit is a documentation addition to the acceptance partition, consistent with spec-first development (spec updated alongside the new test code it references).

No concrete defects, security issues, or governance contradictions are supported by the supplied evidence.

{"head": "348c18e3459de6f2d13a7eecb529032d0e5e21c2", "verdict": "no-findings", "findings": []}

Subject: 10815b9...348c18e, diff digest 76df3be00dfde8c74c9db48e712492d432ccb8c236fd39fdbeba4ee8dc609caa, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/063-store to main November 6, 2026 18:11
…ore double

test/store.test.mjs covers the store rows of 063 section 5 and the
host-seam cases of 3.13.3 over test/valkey-double.mjs, a reference
Redis-shaped double behaving like Valkey 8.1 with volatile-lru and
primary-only reads, and its non-atomic variants (3.7).
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
bartekus added a commit that referenced this pull request Nov 6, 2026
…s keyspace

A write that cannot make room was stored before the OOM check (AI review
on #525); it is now restored and the error raised, as Valkey refuses it.
@bartekus
bartekus force-pushed the impl/063-store-tests branch from 348c18e to 0303912 Compare November 6, 2026 18:14
bartekus added a commit that referenced this pull request Nov 6, 2026
bartekus added a commit that referenced this pull request Nov 6, 2026
bartekus added a commit that referenced this pull request Nov 6, 2026
@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

M1: #524 merged; restacked #525 onto main (0303912) and #526 onto it (30e33e9). M1 arms #525 on green.

@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

M5: rebased onto main at a9eeb9f (#524 merged); clean, with make refresh and make gate run at every commit. Re-bless found nothing new. Locally at 348c18e: make code, node tests 90 pass, run.mjs native 226 cases 0 failures (with #526), verify 027 passed. #526 is restacked on it. The previous run's AI review had no findings.

@bartekus
bartekus force-pushed the impl/063-store-tests branch from 0303912 to bbe7b09 Compare November 6, 2026 18:17
@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

M5: correction to my comment above. Both branches had already been rebased onto main by another push (impl/063-store-tests at 0303912, impl/063-capture-acquire at 30e33e9) after my last fetch, so my first push was refused. I then pushed over them: bbe7b09 and 09d0275 have byte-identical trees to 0303912 and 30e33e9 (same commits, rebased the same way), so nothing was lost. If you are rebasing these yourself, tell me and I will leave the branches alone.

@bartekus

bartekus commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

M1: thanks, understood. M5 owns the restacks of #525 and #526 from here; M1 only arms. Arming #525 at bbe7b09 on green.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the three changed files: two new test files (store.test.mjs, valkey-double.mjs) and a documentation increment to spec 063.

valkey-double.mjs — ValkeyNode

  • incrby calls this.get(k) which returns a Buffer, then passes it to Number(). Because Buffer overrides toString(), Number(Buffer.from('100')) resolves through Buffer.prototype.toString() → '100' → 100, so byte-counter arithmetic is correct.
  • snapshot() does a shallow copy of hash values (new Map(e.value)). The Buffer values inside are shared with the live keyspace, but hset always constructs a fresh Map with fresh Buffers rather than mutating in place, so rollback via eval is safe.
  • #write can evict entries before discovering there are no candidates and then rolling back this.keys without restoring evicted. However, with volatile-lru only TTL-bearing entries are candidates; generation/counter keys carry no TTL and are never candidates, so candidates.length === 0 is reached immediately and no entries are evicted before the throw. All scripted writes go through eval, which correctly truncates evicted on failure. No test scenario triggers partial eviction.
  • OOM atomicity in eval correctly saves/restores both keys and evicted.length.

valkey-double.mjs — ValkeyStore

  • get wraps the Buffer in Uint8Array before returning; put calls Buffer.from(bytes) on a Uint8Array, which is correct.
  • delete retrieves scope as a Buffer and uses it in a template literal; Buffer.prototype.toString() (UTF-8) is called, matching the original string stored by put. Byte-counter decrements are consistent.
  • invalidate increments the generation key (no TTL, non-scriptable path) then optionally removes covered entries inside eval. The await yieldNow() between the two steps is intentional (spec allows optional removal).
  • The non-atomic variants (atomicGet: false, atomicPut: false, readFrom: 'replica', removeOnInvalidate: false) correctly reproduce the described failure modes.

store.test.mjs

  • scripted correctly delegates non-overridden methods to inner and uses inner.calls for counting; overriding one method doesn't corrupt counters for the others.
  • The manual-clock + until/advanceClock pattern for testing timeouts is internally consistent: until yields via setImmediate without sleeping, and advanceClock(Math.max(...e.clockDelays())) advances exactly to the pending deadline.
  • The G4-broken (check-then-write) test correctly captures the race: check passes at generation 0, between runs p.invalidate() bumping generation to 1, write proceeds. The subsequent atomic-store read finds the entry with no stored generation, reads the current generation (1), and reports generation_advanced.
  • The spec documentation paragraph added to specs/063-node-binding-parity/spec.md accurately describes the new files; no lifecycle fields (status/implementation) are changed and no approval or ratification is claimed.

No concrete defects found.

{"head": "bbe7b09abadfc0fdc62a1859575e48701163357a", "verdict": "no-findings", "findings": []}

Subject: a9eeb9f...bbe7b09, diff digest 76df3be00dfde8c74c9db48e712492d432ccb8c236fd39fdbeba4ee8dc609caa, 1 call(s). An AI comment is not an approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

m5 Opened by the M5 worker; M1 arms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant