docs(ops): record why the ledger cursor's lenient read is safe (#7789) - #8428
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Doc-only diff verified against the code it describes: the union write ( Design-Verdict: PASS Doc-only change whose every claim (union write, 80-char prefix dedupe, never-raises path) is verifiably true in the code it annotates. [DESIGN-REVIEWED] eed2475 |
Opus 4.8 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: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of All factual claims in the docstring check out against the code: the dedupe is First-Principles-Verdict: PASS Records a decision issue #7789 explicitly asked to be recorded, and corrects a comment the code proves false — nothing rides along. What this change shipsIntent: close the ledger_index half of issue #7789 by writing down why
Both items are declared in the description; neither changes behavior, adds surface, a config key, or a public symbol (0 new consumers to count — the diff is two comment hunks). Verification against the tree: the write is a union ( [FIRST-PRINCIPLES-REVIEWED] eed2475 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
bolichen97
left a comment
There was a problem hiding this comment.
Comment-only change with zero behaviour delta: the _read_cursor docstring now records why its lenient read is safe here (the write at ledger_index.py:172 is a union, _write_cursor(cursor | newly), so an empty base only forces a harmless re-check rather than publishing an empty rewrite), and the inline comment is corrected from "exact-text check" to "prefix-dedup check" — which matches the actual guard, LOWER(SUBSTR(text, 1, 80)) in vector_memory.write_episodic. Both claims verified against the code.
What
Documentation-only: records in
_read_cursor's docstring (ops_mission_controlledger_index.py) WHY its lenient read is deliberately safe despite feeding awrite, and corrects a factual misnomer in the neighbouring inline comment.
Refs #7789 (resolves the backup.py site and documents ledger_index.py; the ratchet proposal stays open)
no linked issue closing keyword: #7789 deliberately stays open — its third part
(an AST-based ratchet closing the lenient-read-feeding-rewrite class) is design
discussion that outlives both code sites.
Why the scope is comment-only
Issue #7789 lists two sites:
aws_control/backend/backup.py— already fixed on main by fix(aws-control): never publish backup state over a read that failed #7618(
f8b3203c0, merged 2026-09-03):_read_state_for_updatewhere only amissing file reads as
{},_StateUnreadablenaming which half failed, and~400 lines of tests covering the transient-read-failure / missing-file /
corruption / lost-write matrix. Nothing left to change there.
ops_mission_control/backend/ledger_index.py— the issue itself saysthe likely resolution is "a comment recording why leniency is correct here,
not a code change". This PR is that comment.
What the comment records
_read_cursoris lenient (any fault reads as an empty set) and its resultfeeds
_write_cursor(cursor | newly). Elsewhere that shape is a data-loss bug(#7618, #7620, #7788) because the downstream write is a whole-file rewrite that
publishes the empty base over state it never read. Here the write is a UNION,
so an empty base drops previously recorded ids from the cursor while deleting
nothing the cursor points at: the next import re-checks the dropped ids and the
store's dedupe absorbs the repeats. A strict-for-update split would add failure
modes (
_read_cursoris called outsideimport_pending's only try block, andthat function documents "Never raises") without protecting anything.
Both review lanes flagged the same factual error in my first draft: the store's
guard is a case-insensitive 80-char-prefix check
(
vector_memory.write_episodic,LOWER(SUBSTR(text, 1, 80))), not the"exact-text check" the pre-existing inline comment called it. The docstring
names the real mechanism, and the inline comment at the
write_episodiccallsite is corrected to match.
Testing
Doc-only change (docstring + one comment line, 0 behaviour). Local gates:
isort --check-only,flake8,mypy src/kiro_crew/(1281 files clean),diff-scoped black gate, brand gate — all green. No UI changes, no screenshots
applicable.
Pre-push review
Two model-pinned lanes reviewed the staged diff: GPT lane (BLOCK, Medium:
dedupe misnomer + "only shrink" phrasing) and Opus lane (PASS, Low: same
misnomer, verified every other docstring claim against the code). Both findings
fixed before opening this PR.