Skip to content

test: judge a device round's correctness before it measures anything (#234 D1) - #237

Merged
Huxpro merged 2 commits into
new-lynxfrom
feat/lynx-device-correctness-gate
Aug 30, 2026
Merged

Huxpro merged 2 commits into
new-lynxfrom
feat/lynx-device-correctness-gate

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

#234 Part D, judgement half. A device round now opens with a gate that answers six correctness questions before any measurement window runs, and exits non-zero when one fails.

Rounds 1 and 2 of #194 both spent a device lease measuring milliseconds without establishing, on the device, that the tree being measured painted the right rows, routed a real tap to the right handler, or released what it claimed to release. A cost measured on a quietly wrong tree is worse than no cost — it reads as evidence. The web container cannot stand in for this: different renderer, different event path, no reference table.

Six steps, ordered so each one can end the round:

Step Question
first-screen did it paint the rows it was given, in order?
adoption did the background adopt that tree, rather than repair it?
native-tap does a real native tap reach the handler of the row it landed on?
slot-update does an update land on the rows it names, and no others?
clear-retention does clearing empty the tree, and repeating it retain nothing?
dispose after disposing the root, does anything still answer?

Three properties are what make this a gate rather than a report:

  • A missing observation FAILS its step. The evaluator never reads an absent observation as a pass. A gate that goes green because its oracle could not be read converts a collection bug into a correctness claim, which is strictly worse than having no gate. Fifteen distinct holes are covered for this reason.
  • Evaluation stops at the first failure, and later steps record as skipped — never as passes. A wrongly painted tree makes every later answer meaningless, and scoring them anyway would read as five-of-six rather than as stopped.
  • An absence needs a provocation. dispose does not pass because no ack arrived; it requires that at least one was provoked after the dispose and still did not arrive. Same reason clear-retention requires the residual to be identical across all N cycles rather than merely small once.

The judgement is pure and separate from the collection, so it runs in CI with no device attached, and a window whose collection went wrong can be re-judged from the observations it did produce without re-taking the lease.

Changes

  • stages/issue234-gate-oracles.mjs — the oracle table and evaluateDeviceGate. No I/O, no device.
  • stages/issue234-device-gate.mjs — the command: reads observations, writes one record via writeEvidenceJson, prints per-step pass|FAIL|skip, returns 0/1.
  • Two test files, 47 tests.
  • benchmarks/lynx-table/README.md — new §10 documenting the gate and stating what is not here yet.

Validation

  • pnpm format:check — not run repo-wide; pnpm format:files:check clean on all five changed files.
  • pnpm typecheck — not applicable, .mjs benchmark tooling with no TS surface.
  • pnpm test — not run; these files are node --test, outside the Vitest projects.
  • targeted tests: node --test stages/issue234-gate-oracles.test.mjs stages/issue234-device-gate.test.mjs → 47 pass, 0 fail.
  • full stages suite: node --test stages/*.test.mjs → 158 pass, 1 fail — stages/results/issue57-clear-teardown.json is not byte-identical to what writeEvidenceJson produces for it. Pre-existing and unrelated: that record is untouched by this branch (git diff HEAD -- stages/results/ is empty) and all four new files are additions.

Red-verified. A test that has never failed is not protecting anything, so nine command guards and four evaluator rules were each broken in turn and confirmed to go red — every one failed exactly one test, so the coverage is specific rather than overlapping:

Break Result
gate always exits zero 1 fail
a failing gate writes nothing 1 fail
no device invents a stamp 1 fail
adb failure ignored 1 fail
missing required args tolerated 1 fail
non-positive --scale accepted 1 fail
cycles default drifts off three 1 fail
skipped steps counted as failures 1 fail
observations dropped from the record 1 fail
missing observation passes 16 fail
provoked check removed 1 fail
residual drift accepted 1 fail
skipped steps read as pass 1 fail

One test wrote its record to os.tmpdir() and failed against writeEvidenceJson's own guardrail (no Prettier configuration resolved … the record would not be gate-clean). The guardrail is right — records are checked in — and the test was wrong, since the real command only ever writes under stages/results/. Fixed by staging the scratch under the existing gitignored .test-scratch/, which gives the test the same config resolution the command gets in earnest.

No changeset: octane-lynx-table-bench is private: true, so this is internal tooling.

Risk / follow-ups

The device half is not in this slice, and this is the one place the "branch off 8938c1260" instruction cannot hold. The app probe that produces the observations and the adb runner that drives it depend on the round-2 device branch's build wiring — BENCH_DISABLE_DEVTOOL=1 and BENCH_DEVICE_MESSAGECHANNEL_FALLBACK=1 (SDK 4.0 has no MessageChannel) — which is a 63-line scripts/build-app.mjs diff on the unmerged huxcx/perf-lynx-device-round2 @ 609f7b284. Both are prerequisites for any bundle to boot on the device, so a gate bundle built off 8938c1260 would have neither, and duplicating the wiring here would create a second home for the same workaround and conflict on merge.

So D1 lands off 8938c1260 as instructed and D2 needs your call: stack it on huxcx/perf-lynx-device-round2, or hold it until that branch merges. Until then the gate is exercised against observation fixtures, which is what these tests do.

Also unresolved from earlier slices: the harness assigned branch claude/octane-issue-66-phase-a-7wz97z, but create-a-pr mandates a feat/|fix/|docs/|test/|perf/ topic branch for the label bot. I read "照惯例" as endorsing the repo convention and used a topic branch; say if you want the assigned name instead.

Provenance

  • An agent produced this diff (agent-authored)

Generated by Claude Code

…234 D1)

Rounds 1 and 2 of #194 both spent a device lease measuring milliseconds
without establishing, on the device, that the tree being measured painted
the right rows, routed a real tap to the right handler, or released what
it claimed to release. A cost measured on a quietly wrong tree is worse
than no cost: it reads as evidence.

This is the judgement half of #234 Part D — the oracle table, the
evaluator, and the command that writes one verdict record and exits
non-zero when a step fails. Six steps, in the order that lets each one
end the round: first-screen, adoption, native-tap, slot-update,
clear-retention, dispose.

Three properties make it a gate rather than a report:

- A missing observation FAILS its step. A gate that goes green because
  its oracle could not be read converts a collection bug into a
  correctness claim.
- Evaluation stops at the first failure; later steps record as `skipped`,
  never as passes, because a wrongly painted tree makes them meaningless.
- An absence needs a provocation. `dispose` requires that at least one
  ack was provoked after the dispose and still did not arrive;
  `clear-retention` requires the residual to be identical across all N
  cycles, not merely small once.

Keeping the judgement pure and apart from the collection is what lets it
run in CI with no device attached, and lets a window whose collection
went wrong be re-judged from the observations it did produce without
re-taking the lease.

The device half (app probe + adb runner) is not in this slice: it depends
on the unmerged round-2 build wiring (BENCH_DISABLE_DEVTOOL,
BENCH_DEVICE_MESSAGECHANNEL_FALLBACK; SDK 4.0 has no MessageChannel), and
duplicating that here would create a second home for the same workaround.

47 tests across the two files. Nine command guards and four evaluator
rules were red-verified by breaking each in turn; every one failed
exactly one test.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
# Conflicts:
#	benchmarks/lynx-table/README.md
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.

2 participants