Skip to content

test(lynx): pin the destroy-run mirror against the record-map fallback - #243

Merged
Huxpro merged 1 commit into
new-lynxfrom
test/lynx-teardown-mirror-differential
Aug 30, 2026
Merged

Huxpro merged 1 commit into
new-lynxfrom
test/lynx-teardown-mirror-differential

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

E2 slice 1 from the ruling on #230 (issuecomment-5465592015): "a red test that
observes the mirror's retention … then either the mirror earns its coverage or
the copy goes."
This slice gives it the coverage. Whether the copy goes is E2
proper, decided against #241's clear oracle.

What the mirror is. At the end of a compact mount-template-run,
host-driver.ts copies the whole record map into a LynxDenseHostRecordStore
and parks it on state.teardownRecords, so the run's later destroy-run can be
expanded from the run's own shape instead of by walking the map. The consumer
picks the route at :6359:

const teardownStore =
    state.records instanceof LynxDenseHostRecordStore ? state.records : state.teardownRecords;
teardownStore?.expandRunTeardown(state, command) ?? expandRecordsRunTeardown(state, command);

It is a pure fast path: same emitted commands, cheaper to produce.

Why nothing caught it. I suppressed teardownMirrorCandidate wholesale in a
clean worktree and all 728 lynx tests stayed green. That is not a fluke of
coverage — it follows from the mirror being observationally identical to the
fallback. No single-route correctness test can go red on it; only a
differential can.

The test. Paint the same three-row run twice. One arm keeps the mirror; the
other spends it first with an idempotent commit (any commit replaces
teardownRecords). Then compare the two destroy-run expansions: emitted
delta, host-API call log, and resulting tree all have to agree.

A marker host (id: 50) is load-bearing — it lifts state.maxExplicitId above
the run's firstId, so incremental compact declines and state.records stays a
Map, which is the only way the mirror branch is reached. A temporary route
probe confirmed arm 1 answers mirror and arm 2 records-fallback; without the
marker, arm 1 was silently taking prepareDirectFullTeardown's early return
instead.

Red-verified. Dropping the first row's listener-detach commands from
expandRunTeardown turns the test red with a + "setEvent" diff, then restored.
(An off-by-one in inRange does not go red — the
orderedRoots.length !== command.count fallback re-synthesizes the ids. Worth
knowing before writing the next mutant.)

Also: stages/results/issue57-clear-teardown marked historical. Called out
in the same ruling. Three defects, all addressed:

  1. The candidate it times (b04e488d) is not an ancestor of new-lynx, and
    dcf94cfc8 (perf(lynx): streamline dense clear teardown, perf(lynx): streamline dense clear teardown octanejs/octane#762) later
    rewrote the dense clear teardown these numbers measure.
  2. Its headline — clear@10k at 0.800x React — is contradicted by the live
    3-lane campaign (Huxpro/lynx-js-framework-benchmark#41: clear@10k 801 ms vs
    304 ms, 2.6x, regime-invariant). Left unlabelled it reads as a current
    claim.
  3. It was already failing the evidence round-trip oracle at base
    (stages/evidence.test.mjs:43, verified by stashing). Normalizing the JSON
    through formatEvidenceJson is what expands those single-line objects; that
    churn is the writer's canonical form, not a formatting preference.

Regenerating rather than annotating would need an app build, which is not
possible in this environment (npx rspeedy build → 404 from the proxy).
#241 owns the live number.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted tests:

Scoped to the changed surface rather than repo-wide:

  • npx vitest run --project lynx — 729 passed (base was 728; the new test is
    the +1).
  • node --test stages/*.test.mjs in benchmarks/lynx-table — 112 passed /
    112
    , including the round-trip oracle that was red at base.
  • pnpm format:files:check on all three changed files — clean.
  • pnpm typecheck:files packages/lynx/tests/host-driver.test.ts — 40 errors,
    byte-identical to base after stripping line/column (verified by stashing:
    40 before, 40 after, same message multiset). This file is pre-existing red
    under the scoped isolated typecheck; the diff adds nothing to it. Flagged
    rather than fixed, since fixing 40 unrelated type errors is not this slice.

Not run: pnpm format:check and pnpm test repo-wide.

Risk / follow-ups

  • The mirror's value is still unmeasured — mark it hypothesis, not
    verified.
    A full-suite census says the mirror is built 5 times and answers
    3 of 1,173 destroy-run expansions (1,144 take records-fallback, 26
    dense-records); the direct fast path was never once blocked by a live mirror.
    Its footprint is a full record-map copy plus duplicate node/generation arrays
    plus the run's whole values, held from paint until the next commit — a
    peak-heap cost, not a post-clear one, consistent with Order 3's o3tear
    arm (+31.64 MB retained peak, −2.12 MB released), which is precisely the arm
    where incremental compact is off and the mirror is the only survivor. Whether
    deleting the copy helps or hurts is E2 proper's call against Clear/teardown pays 2.6–4× the peers' JS volume, regime-invariant, family-wide — attribute and shrink it (E2's cost half) #241's oracle
    (clear@10k ≤ 1.15x react, clear-time events calls = 0, heapAfterClear ≤
    upstream). This PR deliberately changes no behavior.
  • Test-only plus an evidence-record annotation, so no changeset.
  • Branch-name deviation: the harness assigned
    claude/octane-issue-66-phase-a-7wz97z, but create-a-pr mandates a
    test/ topic branch so label-pr.yml can derive the type label. Topic branch
    used; flagging the conflict rather than silently picking a side.

Provenance

  • An agent produced this diff (agent-authored)

Generated by Claude Code

The teardown mirror built at the end of a compact `mount-template-run` copies
the whole record map into a dense store so the run's later `destroy-run` can be
expanded from the run's own shape instead of from the map. It is a pure fast
path: identical commands, cheaper to produce. Nothing compared the two routes,
so suppressing the mirror wholesale left all 728 lynx tests green.

Paint the same three-row run twice and spend the mirror on one arm with an
idempotent commit, then compare the two `destroy-run` expansions: emitted delta,
host-API calls, and the resulting tree all have to agree. Red-verified by
dropping the first row's listener detach, which surfaces as a `+ "setEvent"`
diff. A marker host keeps `maxExplicitId` above the run's `firstId` so
incremental compact declines and the mirror branch is actually reached; a route
probe confirmed arm 1 takes `mirror` and arm 2 `records-fallback`.

Also annotate `stages/results/issue57-clear-teardown` as historical: the
candidate it times (b04e488) is not an ancestor of new-lynx, dcf94cf (octanejs#762)
later rewrote the dense clear teardown it measures, and its headline
(clear@10k at 0.800x React) is contradicted by the live 3-lane campaign
(clear@10k 801 ms vs 304 ms, 2.6x). Normalizing the JSON through the evidence
writer also fixes a round-trip failure that predates this branch.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
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