Repository navigation
fix(crew-log): fold the timeline over one succession unit, not a slot of them - #15852
iamwhatever merged 1 commit into
Conversation
… of them The timeline fold appends every moment and sorts by bare timestamp, and a slot-wide read folds the units a slot ran under back to back with each unit's seq restarting at 1. Fold two units into one timeline and their moments interleave by wall clock, so a clock rollback between units inverts their order -- the same latent defect the usage fold has. Nothing folds timeline over a slot today: it reaches readers only through a single session's log, and one session holds exactly one succession unit. So this is a guard, not a live bug. The day a slot-keyed reader folds timeline over a slot, it inherits the inversion silently because nothing in the fold rejects a multi-unit input. The timeline fold now tracks the seq of the newest moment and raises when a moment arrives at or below it -- the mark of a second unit's seq restart -- so a future slot-keyed reader fails loudly at the unit boundary instead of rendering a scrambled timeline. The fold state carries last_seq now, so its state_version is bumped to retire savepoints written in the old shape. Fixes kirodotdev#15591
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 0868b75 Description read[DESCRIPTION-READ] 1ddcb4e741346de5c293248ff1cea51474bfaed4840db05392ac69539bc2891b 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 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/crew_log/projection.py:1607 -- the invariant at |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The guard re-implements Not justified as shipped
What this change shipsInventory (3 items) — 1 justifiedIntent: make a future slot-wide read of the timeline fail loudly at a succession-unit boundary instead of silently concatenating units — a preventive guard (declared as such), not a live-bug FIX.
[FIRST-PRINCIPLES-REVIEWED] 0868b75 Description read[DESCRIPTION-READ] 8f899a5731617d290272b8ffb34cc5789bf16172a607e329d5ac81da13e7faf6 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNothing blocks; one advisory finding. FINDING — test/test_crew_log_checkpoint.py:208 — the block comment above the table (line 203: [OPUS-REVIEWED] 0868b75 |
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. fold_timeline carries last_seq and raises CrewLogError(CODE_BAD_DATA) when a moment's seq is at or below it, i.e. a second succession unit; the state version is bumped so an old savepoint is retired; the checkpoint hash pin is updated. One session holds one unit so the reachable path is unchanged (test pins it) and the guard case is pinned.
Problem / Motivation
Goal: Stop the crew-log
timelinefold from silently rendering two succession units as one scrambled timeline.The
timelinefold (crew_log/projection.py) appends every moment and orders bybare timestamp. A slot-wide read (
fold_slot_checkpoint) folds the units a slotran under back to back, re-basing the seq per unit so the second unit restarts at
a clock rollback between units inverts their order — the same latent defect the
usagefold carries. Reproduced before the fix: foldingtimelineover two unitsyields moment seqs
[1,2,3,4,5,1,2,3,4,5].Why it matters
Nothing folds
timelineover a slot today: it reaches readers only through asingle session's log (
fold_session), and one session holds exactly onesuccession unit. So this is a guard, not a live bug. But the day a slot-keyed
reader folds
timelineover a slot — a slot-wide activity view, a crew-leveltimeline — it inherits the inversion silently, because nothing in the fold rejects
a multi-unit input.
Not a goal
_usage_units_in_successionhelper, which is on an unmerged branch (feat(crew-log): serve the Context panel from the usage fold #15367) andhas zero occurrences on
main— there is nothing to reuse yet. This PR takes theissue's option 2 (the half independent of feat(crew-log): serve the Context panel from the usage fold #15367): fail loudly at the unit
boundary now, leaving the ordering implementation for after the reusable piece
lands.
What changed (motivation → approach → change)
Symptom: a slot-wide
timelinefold concatenates succession units into one listwhose seqs restart per unit, so a reader ordering by timestamp inverts units on a
clock rollback. Root cause:
_timeline_stepappends every moment and holds nonotion of the unit boundary. Change:
_timeline_startseedslast_seq(the seq of the newest moment folded, 0before the first).
_timeline_stepraisesCrewLogError(field="seq")when a moment arrives at aseq at or below
last_seq— the mark that a second unit's seq restart has begun— instead of appending it.
last_seqnow, so itsstate_versionis bumped(
_FOLD_STATE_VERSION_BASE + 1) to retire savepoints written in the old shape;the recorded pin in
test_crew_log_checkpoint.pyis updated.The single-session path (the only reader today) is unchanged: within one unit the
seq only ever climbs, so the guard never fires.
Backwards compatibility
Compatible: the only reader today folds a single session (one succession unit),
where the seq only ever climbs, so the new guard never fires. The guard adds a
refusal on an input path (multi-unit slot fold) that no caller takes yet. The
state_versionbump retires existingtimelinesavepoints to a cold refold —a one-time recompute, not a behavior change.
Tests
test_timeline_folds_one_session_unaffected_by_the_single_unit_guard— thereachable single-session path renders every moment as before.
test_timeline_refuses_rows_from_a_second_succession_unit— one unit foldscleanly; the join of a second raises
CrewLogError(field="seq").timelinepin intest_changing_what_a_fold_stores_forces_the_savepoint_version_to_move.test_crew_log_projection.py,test_crew_log_slot_folds.py,test_crew_log_checkpoint.py,test_crew_log_fold_eager.py,test_fold_catalogue.pygreen. black(py312)/isort/flake8/mypy and thecomment-history gate clean.
Manual verification
N/A — unit coverage is sufficient: the guard is a pure fold-state invariant with a
test exercising both the single-unit (pass) and multi-unit (raise) paths.
Related Issues
Fixes #15591
Pattern harvest
Rule candidate: review-prompt
Pattern: a fold that concatenates per-unit logs must reject (or succession-order)
multi-unit input rather than trust a per-unit seq/timestamp as if it were global.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
N/A — placeholder; CLA wording to be supplied by OSPO.