Repository navigation
Replace Inbox test records atomically so pushes never drop the selected row - #1351
Merged
Merged
Conversation
…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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 requestssrc/logs/stop.rs:93-95). So the product behaves correctly, and the fix is in the tests.The
midwayoption exists so the regression can push the page while a replacement is in flight.Diagnosis
The probe wrapped
Idiomorph.morphin 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 andwindowerrors. 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:undefined, expectedacme/widgets#303'', expected the row idlocator.waitFor30 s timeoutMorph log for "a push keeps a Pass dispatch selected" (times in ms after load):
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 (pageerrorandwindowerror). 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:
replaceRecordreverted to an in-place write fails it every time:writeFile(p, t): 3/3 fail,pushedMidwayfalse['row missing']writeFilebefore the push: 1/1 fail, the push already shows the new titleAfter: 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 withtaskset -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/mainselected the full Rust suite conservatively forconsole/**paths.cargo test --bin thirdshift: 1466 passed, 24 failed. All 24 are host setup on this machine: 21sandbox::testsneedsocat, which isn't installed, and 3worktree::synchronization_testshitgit tag … fatal: no tag message?from the globaltag.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.cjsand the newconsole/tests/records.cjs. The temp name<record>.<pid>.tmpdoesn't match the Console's*.command.json/*.child.jsonscan (src/logs/reading.rs:317).Unaddressed findings
Standards
inbox.test.cjsuses the shared helper; other Console tests still rewrite records in place. Declined: Intermittent Inbox selection browser failures block releases #1223's Agent Brief scopes the work to "The Inbox browser tests", and no failure has been seen in those files. Filed Other Console browser tests rewrite Command records in place while a page is open #1350 (needs-triage) for the Day shift.Spec
stop,notifications,logs,time,waterfallandthemes-regressionstests. Declined for the same reason as Standards 2; filed Other Console browser tests rewrite Command records in place while a page is open #1350.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 commits916c2492and7c51fa04change only the regression test and the helper's name andmidwayoption, 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.