Repository navigation
test: settle detached autonudge writes before the restart in a reprobe test - #45124
Conversation
A timer tick re-arms through _persist_soon, whose store write lands after the tick returns. The restarted service could read the row before that write's rename and the digest record after its compaction, and then load the row stopped as unverified. Wait for the first service's detached writes before the restart loads the store.
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS The change only touches a test and a doc: it waits for the first service's detached writes before the restart, which fixes the actual race rather than the symptom. [DESIGN-REVIEWED] e8ee5b7 Description read[DESCRIPTION-READ] a9a14bde25044bd3edce25b1816328b7739e72877d91367e1f2783974b62ba93 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head e8ee5b7. It is a test and docs change: the reprobe test now waits for the first service's pending store writes before it starts a second service on the same data, and the testing conventions doc gets a matching flake class 3 example. I checked that the background persist writes through the store writer, not the patched snapshot writer, so the existing write-count assertions still hold. The wait is bounded and covers the same registries the shutdown drain covers. All CI checks pass on this head, including every backend shard and the new-test stability runs, and no review lane raised a finding, so nothing blocks.
Problem / Motivation
Goal: Stop
test_MUTATION_a_failed_holds_settlement_write_keeps_memory_store_and_restart_agreedfrom failing CI on unrelated pull requests.The test failed Backend Tests (Linux) on at least four PRs (#45040, #45014, #43525, #6823) with
AssertionError: assert False is Trueatassert restored.active is True. The captured log shows the restarted service loading the row stopped:loop 'monitor-terminal-holds-write-fails' was changed outside the gateway since its last save; loading it stopped(reasonunverified_row). Latest failing job: https://github.com/kirodotdev/KiroCrew/actions/runs/46488430582/job/142098497691Why it matters
A red Backend Tests shard blocks every PR it lands on and costs a rerun each time. Contributors cannot tell this red apart from a real regression.
Not a goal
What changed (motivation → approach → change)
Symptom: the restarted service loads the row as unverified and stopped.
Root cause: the first
service._timer(...)tick fails its settlement write (by design), then re-arms through_persist_soon. That detached store write is still running on an executor thread when the test builds a secondAutoNudgeServiceon the sametmp_path. The second service's_loadcan readautonudge.jsonbefore the first write's rename and.vault/autonudge-row-digests.jsonafter the first write compacts it to the new row's digest only. The old row's digest is gone from the record, so the load holds it as changed outside the gateway. Instrumenting the store write (which slows it) makes the failure deterministic on main.Change:
test/test_autonudge_shutdown_terminal_reprobe.py: add_settle_detached_writes(service), which awaits every not-done future in_inflight_addsand_inflight_persistence(the same registriesshutdown()drains, and the same patterntest_autonudge_shutdown_ledger_patrol.pyuses), and call it right after the first tick, before the stored-row assertions and the restart.docs/system-specs/common/testing-conventions.md: add the "restart beside a live instance" case to flake class 3 with a bad and a good example and the measured result.Backwards compatibility
Compatible: test and docs only.
Removes nothing: the diff only adds a wait in one test and a docs paragraph.
Tests
--count 50 -n 16under CPU load locally: 1200 passed.test/test_flake_pattern_ratchet.py: 81 passed. Comment-history and brand gates passed.scripts/docs-lint.shpassed.Proof: not provable -- test-only change
Manual verification
Local Linux host (32 vCPU, 32 busy loops,
-n 16 --count 1000): main 132 failed / 1000; branch 1000 passed / 1000. With a plugin that slowsLoopStore.write_state, main fails 1/1 and the branch passes 1/1.Real-machine verification
Machine: temporary cloud Linux VM, Amazon Linux 2023 (kernel 6.1), x86_64, 8 vCPU, Python 3.12 venv.
Before (main ba91042): 16 busy loops +
python -m pytest -p no:randomly -n 16 --count 3000 test/test_autonudge_shutdown_terminal_reprobe.py::test_MUTATION_a_failed_holds_settlement_write_keeps_memory_store_and_restart_agreed->176 failed, 2824 passed(5.9%).After (head d3db3e7, the test fix; the later commit is docs only): same command ->
3000 passed; whole file ->24 passed.Cleanup: the VM was deleted after the runs.
Related Issues
Fixes the flake reported on #45040, #45014, #43525, #6823.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.