Skip to content

perf(lynx): keep a run certifiable for direct teardown after a props write - #256

Merged
Huxpro merged 2 commits into
new-lynxfrom
feat/lynx-e3-run-slot-update
Aug 31, 2026
Merged

Huxpro merged 2 commits into
new-lynxfrom
feat/lynx-e3-run-slot-update

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

E3 (#81), stacked on #253 which checked in the contract as it.fails.
Sequence answer on #230: issuecomment-5473129307.

A mount-template-run earns a certified single-command teardown by staying the
run it was declared as, and LynxDenseHostRecordStore spent that certification
on any logical write. An update routes through writeRecord, whose staged
clone lands in the store at apply (state.records.set), so one touched cell
anywhere in a table sent the next clear through the per-host expansion for every
row.

mutated conflated two claims: the store is still derivable from its
declaration
, which a props write does break, and the store is still what the
teardown certified
, which it does not touch. prepareDirectFullTeardown is the
flag's only reader, and what it certifies is topology — the run's nodes, its
parent, its child order, and the node ownership those imply. It reads no prop. So
set now asks the narrower question: is this the host already at that offset
carrying different props?

The store still has to answer for that host afterwards, and it does: values no
longer derives the written props, but the written record stays in
materialized, and both paths that drop a materialization — delete and
clear — already disqualify the store by themselves. The first screen has
always settled it this way: there stagedRecords is the store, an update
writes record.props straight onto the materialized record and no set happens
at all, so an in-place props write never spent the certification. This is the
clone-and-set route agreeing with the route beside it.

The check is deliberately broader than the issue title's "slot update", and it
has to be. An update carries the whole next prop bag, so it can drop a name the
program declares statically — #253's test does exactly that, updating a row to
{ id: 'row-2*' } against a program whose node declares class: 'row' — and no
overlay onto values could express that state. Nothing in the teardown needs it
to.

Validation

  • pnpm format:files:check on the changed files
  • pnpm typecheck (exit 0)
  • pnpm test — 2447/2451 files, 26,778 passed, 4 failed, 1 skipped
  • targeted: npx vitest run --project lynx — 48 files, 737 tests, all passing

The four failures are outside this diff and none of them loads the record store:

failing test project why it is not this diff
emitted function entry serves requests through the bundled handler adapter-vercel zero occurrences of lynx in the file
should match previous one drei-adapted-browser zero occurrences of lynx in the file
restores focused input and its selected text after a keyed DOM reorder octane-events-browser zero occurrences of lynx in the file
escalates cleanup for a detached descendant after its leader exits rspeedy-plugin spawns two Node processes and asserts stopProcessTree kills the orphan within 100 ms; imports nothing from packages/lynx/src

The last one still fails when run alone on an otherwise idle box, so it is a
process-group capability of this container rather than load. I did not re-run
the four against the parent commit — reverting the tracked files was refused in
this environment — so this is an argument from what each test loads, not a
before/after run. Repository CI on the current head is the check that settles it.

Correctness evidence

Red before green, both directions:

  • The contract test checked in by test: pin what a bound-slot update costs a run's teardown certification #253 as it.fails now passes. Reverting the
    one-line change in set returns it to its exact recorded failure, sole destroy-run entered the expansion fallback. That test wraps the sole
    destroy-run command array in a Symbol.iterator-throwing Proxy, so
    entering the expansion is observable at the batch boundary rather than inferred
    from a timer — this is the deterministic, in-repo claim.
  • The new listener test fails when the events comparison is removed from
    isPropsOnlyWrite, so that clause is load-bearing rather than decorative.
  • The new invariant test pins that the store answers an updated host from what
    was written, not from the run's values: a repeat identical update makes no
    papi prop call, and restoring class afterwards touches only class.

Measurement — indicative, not certified

10,000 rows × 2 nodes, in-process fake PAPI, medians of 9 with interleaved arms,
timing prepareLynxHostBatch + apply of the sole destroy-run:

arm before after
clear a pristine run 10.5 ms 10.4 ms
clear a run with one host updated 17.9 ms 11.3 ms
updated / pristine 1.71× 1.09×

Before, every updated-arm sample (14.6–55.9 ms) sat above every pristine sample
except one GC outlier; after, the two arms interleave sample for sample.

These numbers came from a temporary probe added to the test file and then
removed, so their recipe is not in a repository.
Under #230's protocol that
disqualifies them as a metric, and I am not resting the claim on them — the
deterministic Proxy assertion above is the claim. They are recorded because
they are consistent with results/issue57-clear-teardown.md, which attributes
13.7 ms of destroy-run expansion plus 31.4 ms of dense validation at this size on
a real browser, and both are what an updated run was paying again. A fake PAPI
makes removal nearly free, so on device the fraction would be smaller and the
absolute saving larger.

Follow-up owed: an update-then-clear arm checked into the stage harness. That
runs into #255 (stage harnesses have no CI coverage), so it is queued rather than
smuggled in here.

The pristine arm is unchanged, as expected: set is not called on the
mount-then-clear path at all.

This also discharges, in principle, the caveat reported on #230
(issuecomment-5472327081) that E2's clear win was measured on create-then-clear
with no update between. On device it is still unmeasured; #241 owns that number.

Changes

  • packages/lynx/src/core/host-driver.ts — isPropsOnlyWrite on
    LynxDenseHostRecordStore; set consults it instead of setting mutated
    unconditionally; the mutated field and prepareDirectFullTeardown doc
    comments now say what the flag means.
  • packages/lynx/tests/host-driver.test.ts — it.fails marker removed from the
    E3 contract test and its comment rewritten from defect to contract; two new
    tests (the answers-from-what-was-written invariant, and the listener
    neighbour).
  • .changeset/lynx-run-slot-update-certification.md.

Risk / follow-ups

  • The check compares every non-prop field, and several of those are also caught
    by another line of prepareDirectFullTeardown — a recreate stages a
    generation, a removed root fails the child scan, a rebound node only happens
    under a native list. Removing those clauses individually breaks no test today.
    They stay because the method answers a question about the store, not about the
    one caller that currently asks it; the comment says so rather than implying
    each is load-bearing.
  • ensure-public-instance and visibility mutate the materialized record in
    place and never reach set, so they did not spend the certification before
    this change either. Unchanged here, noted because the flag's name suggests
    otherwise.
  • abandonCompact() iterates stagedRecords, and when that is a dense store —
    a batch that mounts a run and then issues a non-compact command against the
    same range — the iteration materializes every host in the run. I could not
    construct a sequence the universal core actually emits that reaches it, so this
    is a hypothesis about a reachable shape rather than an observed cost, recorded
    rather than chased here.
  • Deferred runs (stageDeclared) are a separate promotion path and are
    untouched. A written declared host still stops being free.
  • This changes no wire format and no command shape: the whole diff is inside one
    renderer-private record store. It therefore supplies no evidence either way for
    E1 design: how a background-originated mount names an MTS-resident program (#230) #246 §6.4.

Provenance

  • An agent produced this diff (agent-authored)

…write

A `mount-template-run` earns a certified single-command teardown by staying
the run it was declared as, and `LynxDenseHostRecordStore` spent that
certification on any logical write. An `update` routes through `writeRecord`,
whose staged clone lands in the store at apply, so one touched cell anywhere
in a table sent the next clear through the per-host expansion for every row.

What `prepareDirectFullTeardown` certifies is topology: the run's nodes, its
parent, its child order, and the node ownership those imply. It reads no prop.
`set` now asks whether the record it is handed is the host already at that
offset carrying different props, and only a write that changes more than props
spends the certification.

The store still answers for that host afterwards because the written record
stays materialized, and both paths that drop a materialization already
disqualify the store by themselves. The first screen has always settled it this
way: there the staged records *are* the store, an update writes `record.props`
straight onto the materialized record, and no `set` happens at all.

The check is broader than a slot write on purpose. An `update` carries the whole
next prop bag, so it can drop a name the program declares statically, and no
overlay onto the run's values could express that. Nothing in the teardown needs
it to.

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

Huxpro commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Note on CI, because the checks list here will look empty and that is not a draft
artifact.

.github/workflows/ci.yml filters on the base branch:

pull_request:
  branches: [main, new-lynx]

This PR's base is test/lynx-e3-run-slot-update-certification (#253's head), so
no pull_request event fires for it and CI does not run — ready or draft. I
briefly marked this ready to start CI on the assumption that the skip was the
draft guard, saw that no run appeared, and put it back to draft to match the rest
of the train. That is the condition #99 (ci: run pull-request CI regardless of
base branch
) exists to fix.

So the evidence for this head is the local run recorded in the body: pnpm test
at 26,778 passed / 4 failed (all four outside this diff, itemised above),
pnpm typecheck clean, npx vitest run --project lynx 737/737. Repository CI
will first see this diff when the stack lands on new-lynx, and I am not
claiming green CI before then.


Generated by Claude Code

@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

Base branch #253 caught up to live new-lynx and merged into this head (c26341327); marked ready.

CI cannot start on it. classify changeset release sits queued and every other ci.yml job carries needs: release_change, so the run is wedged. Not this PR's: no ci.yml run 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 hours. Full diagnosis and evidence in #257.

This also settles the one thing the body left open. It said pnpm test's four failures were "an argument from what each test loads, not a before/after run", because reverting the tracked files was refused at the time. That check has since been done properly on the sibling PR: with the diff stashed, each failure reproduces identically on the base. Three of the four (drei browser e2e, the octane hydration selection-range test, and rspeedy-plugin's stopProcessTree) recurred there too and are confirmed pre-existing and environmental.

Local validation on the merged head: npx vitest run --project lynx — 48 files, 739 passed, no expected-fail marker left. pnpm sync clean.


Generated by Claude Code

@Huxpro
Huxpro changed the base branch from test/lynx-e3-run-slot-update-certification to new-lynx August 31, 2026 15:17
@Huxpro
Huxpro merged commit 8ada670 into new-lynx Aug 31, 2026
1 check passed
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