Skip to content

Replace Inbox test records atomically so pushes never drop the selected row - #1351

Merged
JacobStephens2 merged 6 commits into
mainfrom
issue-1223
Oct 25, 2026
Merged

JacobStephens2 merged 6 commits into
mainfrom
issue-1223

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

The cause was a fixture-writing hazard in the tests. It was neither of the Brief's two candidates: the morph is not losing the selection, and the tests are not reading before the state settles. The Inbox tests rewrote Command records in place with fs.writeFile, which truncates the file and then writes. A push that read a record in between got an unparsable file. src/logs/reading/cache.rs:105 (serde_json::from_slice(...).ok()) treats that as no record, so that push's Inbox left the row out. morph() (src/console/assets/console.js:94-96) then had nothing to restore, cleared the selection and lost focus. The next push brought the row back unselected. The recorder never exposes a partial record: it writes a temp file and renames it (src/logs/effects.rs:85-87; Stop requests src/logs/stop.rs:93-95). So the product behaves correctly, and the fix is in the tests.

 test writes a fixture while the Inbox is open
-  writeFile(record)            # truncate … write: a push can read it empty
+  replaceRecord(record)        # temp file + rename, like the recorder
 push → server reads records → morph(row present) → selection and focus kept
console/tests/
├── records.cjs        # new: replaceRecord(path, text, { midway })
└── inbox.test.cjs     # every Command record / Stop-request write → replaceRecord,
                       # plus the regression below

The midway option exists so the regression can push the page while a replacement is in flight.

Diagnosis

The probe wrapped Idiomorph.morph in an init script. For each push it logged the row count, whether the replacement still contained the selected row, the active element and the selected row before and after, plus clicks and window errors. It ran on local Linux (RHEL 9, 8 CPUs), not the GitHub runner, using the full Inbox file. Local loops of the unmodified file did not reproduce the failure: 0 in 8 full-file runs, 10 runs on 2 CPUs, 12 runs as 4 parallel copies on 2 CPUs, and 3 full Console suites on 4 CPUs. One earlier first run did fail one test, but its output was not kept. Holding the truncated write open for 400 ms reproduced all three CI signatures exactly, on the first try:

Test CI failure Probe failure
a push keeps a Pass dispatch selected active row subject undefined, expected acme/widgets#303 same
selection survives a move into folded Done actual '', expected the row id same
keyboard selection and the open peek survive an Inbox push locator.waitFor 30 s timeout same

Morph log for "a push keeps a Pass dispatch selected" (times in ms after load):

morph 153..232  rows 12  (three start-up pushes; nothing selected yet)
click 258       LI acme/widgets#303 @needs you
morph 391       rows 10  hasSelected=false  before: active=#303 selected=#303  → after: active=BODY selected=null
morph 794       rows 12  (row back)                                             → after: active=BODY selected=null

The other two tests show the same pattern: one push has one row fewer (rows 9, hasSelected=false), then the active element is BODY and nothing is selected for good. Browser errors: none recorded in any probe run (pageerror and window error). Every push before the torn one kept selection and focus.

Evidence

  • Regression: "a push during a record replacement keeps the selected row selected and focused". It selects a row, then replaces that row's record. While the replacement is in flight (midway), it grows another row's log and waits for that push. It asserts that this push kept the row selected and focused with its earlier title, and that every later Inbox mutation did the same.
    Before: replaceRecord reverted to an in-place write fails it every time:

    • plain writeFile(p, t): 3/3 fail, pushedMidway false
    • push between truncate and write: 3/3 fail, ['row missing']
    • writeFile before the push: 1/1 fail, the push already shows the new title

    After: rename passes 3/3.

  • Acceptance, final head 7c51fa04: the whole Inbox file, cd console && node --test tests/inbox.test.cjs (35 tests, full preceding test sequence), passed 25 consecutive runs on Linux: 22 unrestricted, then 3 with taskset -c 0,1. The same count also passed on the first fix commit. The full Console suite (npm test) passed 86/86.

  • No retries are added, and the release CI requirement is unchanged. Only console/tests/ changes; scripts/release.sh, the workflows and the product code are untouched.

  • scripts/affected-tests origin/main selected the full Rust suite conservatively for console/** paths. cargo test --bin thirdshift: 1466 passed, 24 failed. All 24 are host setup on this machine: 21 sandbox::tests need socat, which isn't installed, and 3 worktree::synchronization_tests hit git tag … fatal: no tag message? from the global tag.gpgsign=true. cargo then stopped before the integration tests. This change touches no Rust, so CI's Linux Rust suite is the check here.

Merge Danger

Door: two-way

Test-only. Reverting restores the in-place fixture writes.

Blast Radius: tests

Only console/tests/inbox.test.cjs and the new console/tests/records.cjs. The temp name <record>.<pid>.tmp doesn't match the Console's *.command.json / *.child.json scan (src/logs/reading.rs:317).

Unaddressed findings

Standards

Spec

Addressed: Standards 1 and Spec (c)1 (the regression passed with an in-place write; it now fails every time, see Evidence), Standards 3 (replace → replaceRecord), and Spec (a)1–3 (above).

Review coverage: both changed files were read by both reviewers; none were left unread and nothing was excluded. Both reviewers read commit bf00d965. The follow-up commits 916c2492 and 7c51fa04 change only the regression test and the helper's name and midway option, in response to their findings, and were not re-reviewed.

Closes #1223

Built with claude · claude-opus-5-5 · high

Security review outcome

No unaddressed introduced findings.

…ed row

An in-place fixture write could be read truncated by a push. The Console
skips the unparsable record, so that morph omitted the row and cleared
its selection and focus; the next push restored the row unselected.
The recorder replaces records and Stop requests by rename, so Inbox tests
now do the same, with a regression that replaces the selected row's
record across pushes.

Closes #1223
Push the page from inside the replacement, so an in-place write is read
truncated every time rather than by chance, and name the helper
replaceRecord after the recorder's replace_record.
A plain in-place write never runs midway, so the regression now asserts
that its push happened and still showed the earlier record.
@JacobStephens2
JacobStephens2 merged commit 71c7a49 into main Oct 25, 2026
7 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-1223 branch October 25, 2026 20:33
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intermittent Inbox selection browser failures block releases

1 participant