Skip to content

test: pin what a bound-slot update costs a run's teardown certification - #253

Merged
Huxpro merged 3 commits into
new-lynxfrom
test/lynx-e3-run-slot-update-certification
Aug 31, 2026
Merged

Huxpro merged 3 commits into
new-lynxfrom
test/lynx-e3-run-slot-update-certification

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

E3's opener. It makes the target executable before any of the delicate work in host-driver.ts starts, and it names a cliff that was not previously written down anywhere.

A mount-template-run earns direct teardown by staying exactly the run it was declared as. prepareDirectFullTeardown (packages/lynx/src/core/host-driver.ts:940) refuses a dense store whose mutated flag is set — "the store was created from one frozen program and loses this eligibility on every logical set/delete" — and LynxDenseHostRecordStore.set sets that flag on its first call, unconditionally.

An {op:'update'} to a bound slot routes through writeRecord, which clones the accepted record into stagedRecords; at apply, state.records.set(id, record) lands that clone in the dense store and trips mutated. So replacing one value the program already reserved a place for — no topology, no new host, nothing the certification actually checks — costs the whole run its fast teardown.

Consequence: a table whose author touched a single cell pays the expansion fallback for every row on the next clear. At 10,000 rows that is the entire run.

Why this shape

The test is checked in as it.fails. That states the contract E3 owes rather than pinning today's behaviour as expected, and it inverts by itself: when a slot update stops spending the certification, the test starts passing and it.fails turns red to say the marker should come off. Committing it green-as-status-quo would have enshrined the defect; leaving it red would have broken CI.

It observes the fallback the same way the neighbouring certified-teardown regression does — a Proxy on the sole destroy-run that throws when Symbol.iterator is read, so entering the expansion is a hard failure at the batch boundary rather than an inferred one.

It also reaches the teardown before failing, which is itself informative: the slot writes already work. The failure is entirely about what they cost. The assertions cover a non-root node and the second row, so a run that wrote the right value at the wrong offset fails here rather than passing on a single-row coincidence.

What E3 still owes

Not in this PR — it is the implementation, and it belongs in its own change with the octane-core-extend treatment:

  • a driver-owned copy-on-write value overlay on LynxDenseHostRecordStore, so the peer's frozen values array is never written (the freeze at :6957 is a deliberate ownership boundary: "a mutable array would let the peer rewrite hosts it already mounted", and E3 must preserve that, not remove it);
  • slot detection in the update handler — take the slot path only when every name in the patch is a binding the program declared and no static prop moved;
  • re-derivation rather than materialization, so an updated row stays free rather than retaining a record;
  • promotion on second touch, so a later command in the same batch that writes the same host still gets an ordinary record.

Per #246 §6.4 this needs no wire change: slot kinds live receiver-side, and LynxSetDelta is a compact encoding of update, not new applier capability.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted tests: npx vitest run --project lynx — 734 passed | 1 expected fail (735), 48 files. The expected fail is this test.
  • pnpm format:files packages/lynx/tests/host-driver.test.ts
  • pnpm sync clean.

pnpm typecheck:files packages/lynx/tests/host-driver.test.ts reports 46 errors — the same 46 with and without this diff, and none inside the added range. They are the scoped-runner-versus-tsconfig.testing.json issue already reported on #236, not this change's.

Not run repo-wide: test-only diff in one package, so typecheck/test were left to CI.

Risk / follow-ups

  • Test-only. No package source touched, so no changeset.
  • The it.fails marker is load-bearing: whoever lands E3 must remove it in the same change, and the test will fail loudly if they forget.
  • The characterization covers the dense/compact run. The deferred-run path (LynxTemplateRunDeclaration under a native <list>) has the same frozen-values shape and is not covered here.
  • Branch naming: the harness assigned claude/octane-issue-66-phase-a-7wz97z for this session, but create-a-pr requires a feat/|fix/|docs/|test/|perf/ topic branch so label-pr.yml can read the type. Topic branch used; flagging the conflict rather than resolving it unilaterally.

Provenance

  • An agent produced this diff (agent-authored)

Generated by Claude Code

Huxpro and others added 2 commits August 31, 2026 00:30
`heapMtsAfterClear` is one post-collection `Runtime.getHeapUsage` reading.
A scalar can say a 3.3 MB gap exists and can never say who owns it, which is
why E2 closed on clear cost and explicitly did not close on retention: a
named remainder nominates nobody.

`stages/heap-retention.mjs` folds V8 heap snapshots taken at four points on a
fresh page into named buckets, and `heap-retention-analyze.mjs` is the pure
half that decides the claim, tested without spending a measurement window.

The fourth capture is what makes the other three readable. A second
create-and-clear on the same page separates a bucket still holding rows from
one that grew a backing store for them and kept it -- a distinction no single
cycle can draw, and the difference between a leak and a high-water mark.

Three properties the tables are built to preserve, each with a test:

- the share column divides by the gap being attributed, never by the summed
  rows, so the shares do not total 100% and the unattributed part stays
  visible;
- shrinking buckets are kept, because a bucket that shrinks across
  create-then-clear is the evidence that its teardown ran;
- the tail past the top-N is a remainder named `(other growth)`, the same
  shape as `off_boundary` and under the same rule.

Column offsets are read from `snapshot.meta.node_fields` rather than
hardcoded, and a missing column is a hard failure rather than a silent
misread of the wrong column.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
A `mount-template-run` earns direct teardown by staying exactly the run it
was declared as. `prepareDirectFullTeardown` refuses a dense store whose
`mutated` flag is set, because a written host is no longer derivable from
its program, and `LynxDenseHostRecordStore.set` sets that flag on its first
call.

An `update` to a bound slot goes through `writeRecord`, whose staged clone
reaches the dense store at apply (`state.records.set`). So replacing one
value the program already reserved a place for -- no topology, no new host,
nothing the certification checks -- costs the whole run its fast teardown.
A table whose author touched a single cell pays the expansion fallback for
every row on the next clear.

The test is checked in as `it.fails`. That states the contract E3 owes
rather than pinning today's behaviour as expected, and it inverts by
itself: when a slot update stops spending the certification the test starts
passing, and `it.fails` turns red to say the marker should come off.

It reaches the teardown before failing, so it also shows the writes
themselves already land -- including on a non-root node and on the second
row, so a run that wrote the right value at the wrong offset fails here
rather than passing on a single-row coincidence.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
@Huxpro
Huxpro marked this pull request as ready for review August 31, 2026 04:41

Huxpro commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Live base merged in (dffae7d2f) and marked ready, which started run 33357972019. It is wedged: classify changeset release has been queued since 04:41 without starting, and every other job in ci.yml carries needs: release_change, so nothing else can begin.

Not this PR's. No ci.yml run anywhere in the repo has produced a pass or a fail since run 434 on 2026-08-27, and new-lynx's own push run has been queued for two hours. Full diagnosis and evidence in #257 rather than repeated here.

Local validation on the merged head: npx vitest run --project lynx — 48 files, 736 passed, 1 expected fail, which is this PR's it.fails contract test. pnpm sync clean.


Generated by Claude Code

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant