Skip to content

feat(work-ledger): the work fold forgets closed items, so a board never fills - #19068

Merged
iamwhatever merged 2 commits into
mainfrom
feat/work-fold-forget-closed
Oct 13, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
feat/work-fold-forget-closed

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A conductor board keeps dispatching for as long as it lives, instead of stopping for good after 256 items.

A board refused its 257th create with item_store_full, even when only one item was still open. Closing items gave nothing back, and the only way out was a manual kirocrew ledger-sweep --purge, which skips a board that is still in use. A long-lived queue conductor therefore got stuck.

Why it matters

Queue conductors (one item per ticket) are meant to run for weeks. Today each one stops after 256 dispatches and needs a person to clean it up, and a board that is still busy cannot be cleaned up at all.

Not a goal

  • Changing the open fan-out cap (32 open items per board stays).
  • Changing the goal spend cap (item_cap, default 20) or how it is counted.
  • Fetching forgotten closed items back from the crew log on demand in the dashboard.
  • Changing ledger-sweep's purge rule.

What changed (motivation → approach → change)

Decision recorded in rfc-work-fold-forget-closed.md (#18982).

Root cause: the crew log's work fold kept every item it ever saw, closed ones included, so its memory grew with the board's lifetime. The fold capped itself at 256 items, and the writer capped lifetime creates at the same number so the fold never overflowed.

Change: the fold (crew_log/projection.py, window in work_vocab.py) now forgets a closed item once 32 newer closed items sit behind it. It keeps the item's id (a late worker report for it is dropped, not parked) and counts it per closing state in a new forgotten block. Creates and closes interleave in the conductor's log, so during a replay the fold holds only what is open plus that window. The writer drops the lifetime ceiling and the item_store_full code.

The store's cache keeps every record, so nothing on the board is deleted and every item stays listed. A rebuild keeps a closed record the fold does not hold instead of refusing (an open one the fold lacks is still refused), and sets created_total from the fold's count of every item it held. The crew status ("N of M items accepted") and the pipeline board (pipeline_board_contract.py) add the forgotten counts to every whole-board number: the progress total, the items tile and "+N in round" (the fold counts forgotten items of the current round in forgotten.in_round, zeroed when the round moves). The columns show what the fold holds. The goal-conductor skill (builtin_skills/goal-conductor/SKILL.md) reads spend from goal_items_used rather than counting items. The work fold's savepoint version moves, and the generated fold catalogue (dashboard-template/folds.json, FOLDS.md) is regenerated.

Rebuild, two further changes in work_ledger.py:_rebuild_locked. First, the pass over cache records the fold does not name reads each one with strict=True: a present-but-momentarily-unreadable record (an I/O error) raises and the rebuild's undo restores every file, instead of reading the record as absent and unlinking it. Torn content still reads as absent and is dropped, except on a board whose fold has forgotten closed items: there an unparsable record may be a forgotten item whose only whole copy is the cache, so the rebuild leaves its record and events files in place and does not count it. Second, that pass tells a legacy record from a forgotten one by recorded_at, not by stamp order alone: legacy means an UNRECORDED record from before the board's first recorded entry (the log never held its create, so it is added to the total); a recorded closed record the fold lacks is forgotten (the fold's forgotten.created already counts it). Stamp order alone loses a closed legacy record or counts the board's first item twice. The pipeline board's column heads (pipeline_board_contract.py:panel_card_data) take their numerator from the progress segment, which includes forgotten items, so a column reads the same share the progress bar does.

Docs: src/kiro_crew/docs/work-ledger.md, docs/system-specs/modules/crew-log-projection.md and the caps/errors lines of docs/request-for-change/rfc-conductor-work-ledger.md describe the open-bounded board. The RFC (docs/request-for-change/rfc-work-fold-forget-closed.md) and its README.md row carry an implementation note: the cache keeps every record, where the RFC had planned to trim it.

Backwards compatibility

Compatible: every create that worked before still works; the only refusal removed is item_store_full, and nothing else is tightened.

Reader: src/kiro_crew/dashboard/handlers/work_ledger.py:_CODE_STATUS -- chat -- the item_store_full mapping is gone with the code; test_every_store_code_maps_to_the_status_the_rfc_tabulates
Reader: src/kiro_crew/pipeline_board_contract.py:_derive_numbers -- crew page -- progress and "+N in round" add forgotten; columns show held items; test_forgotten_closed_items_join_the_progress_but_draw_no_cards, test_the_items_tile_and_added_this_round_count_forgotten_items
Reader: src/kiro_crew/pipeline_board_contract.py:_stats -- crew page -- the items tile adds forgotten.items; test_the_items_tile_and_added_this_round_count_forgotten_items
Reader: src/kiro_crew/crew_main_contract.py:_work_fields -- crew page -- totals add forgotten; test_forgotten_closed_items_still_count_toward_the_board_totals
Reader: src/kiro_crew/dashboard/handlers/agent_panel.py -- crew page -- reads the fold's items; recent closed items plus open ones
Reader: src/kiro_crew/work_ledger.py:rebuild_from_projection -- chat -- keeps closed records the fold forgot; test_a_rebuild_keeps_a_closed_record_the_fold_forgot
Reader: src/kiro_crew/work_ledger.py:_rebuild_locked -- chat -- an unreadable record aborts the rebuild instead of being deleted; a closed legacy record is added to the total; test_a_present_but_unreadable_record_is_not_deleted_by_a_rebuild, test_a_closed_unrecorded_legacy_record_is_added_not_folded_in_a_rebuild, test_a_recorded_first_item_the_fold_forgot_is_counted_once
Reader: src/kiro_crew/pipeline_board_contract.py:panel_card_data -- crew page -- column head numerator is the state's full share; test_the_column_head_shows_the_whole_state_share_not_just_held_cards
Reader: src/kiro_crew/builtin_skills/goal-conductor/SKILL.md -- chat -- counts goal spend from goal_items_used
Reader: src/kiro_crew/dashboard_templates/builtin/goal-board/template.html:drawLoop,drawStates -- crew page -- the manifest binds forgotten; accepted count, state bar and item count add it; test_the_whole_board_numbers_count_forgotten_items
Reader: src/kiro_crew/dashboard_templates/builtin/work-kanban/template.html:boardTally,boardTotal -- crew page -- the manifest binds forgotten; headline, strip, column counts and item count add it (round rows stay per-round, held items only); TestForgottenItemsCount

Tests

  • test/fixtures/dashboard_templates/pod_folds.json: the captured work fold gains the forgotten block (all zero, created 3) the fold now renders, so the path-resolution test covers the new binding.

In test/test_work_ledger_projection.py, test/test_work_ledger.py, test/test_work_ledger_tools.py, test/test_work_ledger_doc.py, test/test_crew_main_contract.py and test/test_pipeline_board_provider.py:

  • test_a_long_board_folds_to_its_open_items_plus_the_closed_window: 300 interleaved create/close fold with omitted == 0, peak held items ≤ window + open, correct forgotten counts.
  • test_a_late_report_for_a_forgotten_item_is_dropped_not_parked / ..._still_in_the_window_still_applies, test_a_create_reusing_a_forgotten_id_is_a_new_item, test_the_tombstone_set_is_capped.
  • Rebuild: test_a_rebuild_keeps_a_closed_record_the_fold_forgot, test_a_rebuild_still_refuses_an_open_item_the_fold_does_not_hold, test_a_rebuild_sets_the_create_counter_to_what_the_record_holds, test_a_present_but_unreadable_record_is_not_deleted_by_a_rebuild, test_a_closed_unrecorded_legacy_record_is_added_not_folded_in_a_rebuild, test_a_recorded_first_item_the_fold_forgot_is_counted_once (each fails under one of the two stamp-order rules), test_a_torn_record_on_a_board_that_forgot_items_keeps_its_files.
  • test_a_board_keeps_dispatching_past_256_lifetime_creates, test_forgotten_closed_items_still_count_toward_the_board_totals, test_forgotten_closed_items_join_the_progress_but_draw_no_cards.
  • Pipeline board numbers: test_the_column_head_shows_the_whole_state_share_not_just_held_cards, test_the_items_tile_and_added_this_round_count_forgotten_items; fold counter: test_forgotten_items_count_toward_added_this_round_until_the_round_moves.
  • Removed the tests that pinned the item_store_full refusal.

Determinism: no new test orders on a clock stamp, ids are fixed or come from the store, and nothing sleeps. The related-test set passes (25,043); every failure is environment-only on this host and fails the same way on clean main: a missing markdown_it module in the local venv, and test_a_worker_edit_of_its_own_item_file_is_refused_and_the_store_still_writes.

Manual verification

N/A — the fold and rebuild paths are pure file/state logic covered end to end by the tests above.

Related Issues

Closes #18583

Supersedes #18584 (generation archive), which closes once this lands.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 11, 2026 08:14
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Before merge, check one cost: the cache now keeps every record, so list_work_items reads every record file under the board lock on each create, with no bound.

What this change ships

Inventory (10 items) — 10 justified

Intent: let a long-running conductor board keep dispatching after its 256th item (FIX, under accepted rfc-work-fold-forget-closed.md and tracking issue #18583).

  1. A board no longer refuses its 257th create, and item_store_full and its 409 mapping are gone — justified
  2. The work fold keeps only open items plus the 32 newest closed ones; older closed ids become capped tombstones — justified
  3. The fold view gains a forgotten block (per-state counts, created, in_round) — justified
  4. The crew status, pipeline progress, items tile and "+N in round" add the forgotten counts — justified
  5. The goal-board and work-kanban templates bind forgotten and add it to their whole-board numbers — justified
  6. Pipeline column heads take their numerator from the progress segment, so they match the bar — justified
  7. A rebuild keeps closed records the fold forgot, and created_total comes from forgotten.created — justified
  8. A rebuild reads records with strict=True, so an unreadable record aborts the rebuild instead of being deleted — justified
  9. Legacy records are told apart from forgotten ones by recorded_at; baseline_ids carries the forgotten baseline items into the rebuild — justified
  10. The goal-conductor skill reads spend from goal_items_used; the fold savepoint version moves and the fold catalogue is regenerated — justified

[FIRST-PRINCIPLES-REVIEWED] cbfe739

Description read

[DESCRIPTION-READ] 09a3064fa64ba8492fe3abf7165b3e0fc017fc6b1fa7451546615adc6ee16e1c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Only the fold is bounded now: the writer's cache keeps every record, so each create still costs more over the board's lifetime, and the cache disagrees with the fold for good.

Watch

  • Each create still slows as the board ages. The PR's own note says the cache keeps every record and "list_work_items still reads every record file under the board lock, so a board in the thousands of items reads more on each create." _rebuild_footprint also snapshots every present record's bytes. Queue conductors are the goal's target and run for weeks, so the "board never fills" limit turns into a create, and a rebuild, that keep getting slower while holding the lock. The follow-up ("a trim or an open-count index") has no issue or number.
    Clears when: a measured create/rebuild latency at roughly 5k records is in the PR, or the follow-up issue is filed and linked from RFC §4.2.
  • The cache now holds data the fold no longer has. For forgotten items the cache is the only whole copy, so _rebuild_locked needs special rules. It uses recorded_at to tell legacy from forgotten, keeps torn records forever on boards that forgot items, and uses strict=True reads. Every later rebuild change has to keep these rules, and a torn forgotten record cannot be repaired from anywhere.
    Clears when: work-ledger.md / crew-log-projection.md state that the cache is authoritative for forgotten closed items, and give a recovery path for a torn one, or explicitly accept that it is lost.

[DESIGN-REVIEWED] cbfe739

Description read

[DESCRIPTION-READ] 9b602ca8a0e5777e2b89bde3eb754d50bd099a654ca288890b6f87a3aa3e8e42

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] cbfe739

Verdict parsed from the review's SHA-scoped output markers for commit cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40.

False positive or not applicable? A repository writer can comment:
/ai-review override fable cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- test/test_work_ledger_projection.py:1489 -- An eager-folder lock collision makes on-loop wl.rebuild_from_projection(CONDUCTOR) satisfy pytest.raises(OSError) before reaching the injected read failure, falsely passing the rollback check -> Fix: call await asyncio.to_thread(wl.rebuild_from_projection, CONDUCTOR) (origin: validation)
[GPT-REVIEWED] cbfe739

False positive or not applicable? A repository writer can comment:
/ai-review override gpt cbfe739fa4b267c1032b14d0d73f3a74dfd5fe40: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the feat/work-fold-forget-closed branch from 71f6bb0 to d3dea23 Compare October 11, 2026 08:42
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 11, 2026
@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=2d1b4f630a03

  • A board-wide forgotten count bypasses item-specific completeness protection

fixed in d3dea23: the rebuild no longer trusts the board-wide count. _fold_forgot accepts a cached closed item as forgotten only when the fold holds a full window and the item closed no later than every close the fold holds.
A cached close newer than the fold's window (a lost newer unit) is refused: test_a_rebuild_refuses_a_cached_close_newer_than_the_folds_window.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=2d1b4f630a03

  • A create acknowledgement permits deletion of an unrecorded close

fixed in d3dea23: the trim no longer keys on recorded_at. It reads the fold and removes a record only when the fold forgot that item, which needs the item's own close in the log plus a full window of newer ones.
A close that never landed leaves the fold holding the item open, so it is never trimmed; same-second ties are kept (strict=True). Tests: test_trim_keeps_a_closed_item_newer_than_the_folds_window, test_trim_does_nothing_without_a_full_window.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=edc024cbb4a9

  • Eviction allows accepted creates that the fold rejects as duplicates

fixed in d3dea23: a create naming a tombstoned id now starts a new item and drops the tombstone. The writer mints an id only when no record holds it and the log holds each entry once, so such a create is always a re-mint, never a replay.
Test: test_a_create_reusing_a_forgotten_id_is_a_new_item.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=1ed8a0d06001

  • Trim assertions depend on uncontrolled timestamp ordering

fixed in d3dea23: every close stamp the trim and rebuild tests order on is pinned one minute apart (_closed_items, _pin_close, _closed_cached); the mtime tie-break is gone.
The new tests passed 5 repeated xdist runs.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=078d85b83cac

  • The pipeline board now under-counts a long board's items

fixed in d3dea23: _derive_numbers adds the fold's forgotten per-state counts to the segments and forgotten.items to the total; columns still show only held items.
Test: test_forgotten_closed_items_join_the_progress_but_draw_no_cards.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=4a1d6dd514d9

fixed in d3dea23: the pipeline board's progress total and closed-state segments now add the fold's forgotten counts (pipeline_board_contract._forgotten_counts), matching crew_main_contract; the docstring at the old line 1255 now describes the closed window.
Test: test_forgotten_closed_items_join_the_progress_but_draw_no_cards.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=400beb1272eb

fixed in d3dea23: the pipeline board's progress total and closed-state segments now add the fold's forgotten counts (pipeline_board_contract._forgotten_counts), matching crew_main_contract; the docstring at the old line 1255 now describes the closed window.
Test: test_forgotten_closed_items_join_the_progress_but_draw_no_cards.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=9c3fdf6125fc

fixed in d3dea23: the pipeline board's progress total and closed-state segments now add the fold's forgotten counts (pipeline_board_contract._forgotten_counts), matching crew_main_contract; the docstring at the old line 1255 now describes the closed window.
Test: test_forgotten_closed_items_join_the_progress_but_draw_no_cards.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=f6626ae6e86b

fixed in d3dea23: the pipeline board's progress total and closed-state segments now add the fold's forgotten counts (pipeline_board_contract._forgotten_counts), matching crew_main_contract; the docstring at the old line 1255 now describes the closed window.
Test: test_forgotten_closed_items_join_the_progress_but_draw_no_cards.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=ab4416405989

rebutted: the route is the only close path. apply_conductor_action has one production caller (dashboard/handlers/work_ledger.py, the work_ledger_record route), and _write_item_action is the only place that sets a terminal state.
A missed trim is also harmless: the cache only holds extra closed records until the next close or a rebuild, which applies the same per-item test.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=c794979e0d5e

rebutted: the route is the only close path. apply_conductor_action has one production caller (dashboard/handlers/work_ledger.py, the work_ledger_record route), and _write_item_action is the only place that sets a terminal state.
A missed trim is also harmless: the cache only holds extra closed records until the next close or a rebuild, which applies the same per-item test.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=3e6cfcccfdf4

fixed in d3dea23: late_entries is removed. rejected and abandoned now have a non-test reader: the pipeline board's per-state segments (pipeline_board_contract._derive_numbers).

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=8b575b521776

fixed in d3dea23: the CLOSED_ITEMS_KEPT alias is deleted; the writer reads work_vocab.WORK_CLOSED_WINDOW directly.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=06ae6337753a

needs-a-decision: the decision is recorded in rfc-work-fold-forget-closed.md, merged to main in #18982, which amends rfc-conductor-work-ledger.md's 'stay on the board' rule. Its status on main is still draft.
A maintainer clears this by flipping that RFC to accepted on main (then this PR rebases), or with /ai-review override first-principles <head>.

@iamwhatever

iamwhatever commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

span=1560236d6b9b

needs-a-decision: the decision is recorded in rfc-work-fold-forget-closed.md, merged to main in #18982, which amends rfc-conductor-work-ledger.md's 'stay on the board' rule. Its status on main is still draft.
A maintainer clears this by flipping that RFC to accepted on main (then this PR rebases), or with /ai-review override first-principles <head>.

@iamwhatever
iamwhatever force-pushed the feat/work-fold-forget-closed branch from d3dea23 to 126588e Compare October 11, 2026 09:22
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 12, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

@buluoray thanks for the review at 8cf35f6a69. Answered point by point; the fixes are in bfacc27c703669a88066aa1ed46a5eedbe197094 (rebased on current main).

Blocking: items tile and +N in round -- fixed.

  • _stats: the items tile is held + forgotten.items, the same sum as progress.total.
  • added_since: the fold counts forgotten items created in the current round in a new forgotten.in_round (bumped in _work_forget when item.round >= state.round, zeroed by _work_set_round whenever a goal entry or baseline moves the round). _derive_numbers adds it.
  • Tests: test_the_items_tile_and_added_this_round_count_forgotten_items (your 300 / 298 / 2 fixture: tile 300, legend +300 in round 1) and test_forgotten_items_count_toward_added_this_round_until_the_round_moves (counter counts, then a round move zeroes it).

Non-blocking

  • RFC vs implementation -- fixed. rfc-work-fold-forget-closed.md gets an implementation note under §4.2 (the cache keeps every record; §5's trim is not done), implementation-prs: [19068], and its README row no longer says "Nothing."
  • list_work_items reads every record -- accepted-and-deferred to a follow-up. The implementation note records it as the known cost, with a trim or an open-count index as the fix once boards reach the thousands. Out of this PR's goal (no board can reach that size before it lands, since today's ceiling is 256).
  • goal-conductor/SKILL.md -- fixed. The sentence now says why to read goal_items_used (it is the goal's own total, re-plans included) and no longer claims what work_ledger_read lists.
  • WorkBoardForgotten.created name -- rebutted. Its docstring already says it counts every item the board has held and seeds the store's create counter; the rebuild reads it under that name, so renaming it would churn the fold's shape and catalogue for no behavior change.

Could you take another look when CI finishes?

@iamwhatever

Copy link
Copy Markdown
Contributor Author

For whoever drives this PR, one gap at bfacc27c70:

forgotten gained in_round, but the work fold still stores under state_version=_FOLD_STATE_VERSION_BASE + 1 (projection.py:9057), the same number 8cf35f6a69 used. load_slot admits a savepoint by that number (checkpoint.py:784), and _state_matches_fold checks top-level keys only (projection.py:564). So a savepoint the old head wrote resumes without in_round:

  • If the tail it folds forgets an item, forgotten["in_round"] += 1 (projection.py:6450) raises KeyError. The resume path catches it, discards the file and folds cold.
  • If it forgets nothing, the state resumes: +N in round leaves out the forgotten share, and the next forget on that state raises the same KeyError.

Only a machine that ran the old head has such a file. Suggested fix: move the work fold to _FOLD_STATE_VERSION_BASE + 2, as the rule at projection.py:283 asks; that retires those files to a cold fold. Reading forgotten.get("in_round", 0) in _work_forget would stop the KeyError but would still resume the undercount.

My claim above is withdrawn: bfacc27c70 covers the review, and I am not pushing here.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 12, 2026
@iamwhatever
iamwhatever force-pushed the feat/work-fold-forget-closed branch from bfacc27 to d6eec1e Compare October 13, 2026 06:32
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 13, 2026
cixuuz and others added 2 commits October 13, 2026 06:55
…, counts and binds them

A forgotten item a later baseline can name -- one born from a baseline,
or a created item whose recorded stamp failed, so its conductor bind and
a worker's report after it carry baselines -- keeps its tombstone past
the cap: the cap evicts other ids first. The worker's unit folds after
the conductor's, and with the tombstone gone that report brought the
item back as open and counted its create twice.

The fold names those protected ids in its forgotten block, so a rebuild
keeps a legacy record whose baseline the fold already counted as
forgotten instead of adding it again as legacy.

A recorded record older than the board's first surviving entry (its
create's unit pruned) is kept as the cache holds it, never unlinked.

A rebuild keeps the binding of every forgotten record it keeps, as it
does for legacy ones, so a worker bound to such an item is not answered
not_bound afterwards.

The rebuilt create total sums pieces that can overlap without one
holding the other (a pruned unit's create, a torn forgotten record), so
it could come out short and let a goal at its cap create one more item.
A trusted cache header's count is now a floor for it.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 13, 2026
@iamwhatever
iamwhatever force-pushed the feat/work-fold-forget-closed branch from d6eec1e to cbfe739 Compare October 13, 2026 06:55
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 13, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE at head cbfe739fa4.

What it fixes

A conductor board stopped dispatching after 256 lifetime items. Now the work fold forgets closed items once 32 newer closed ones sit behind them. It keeps their per-state counts in forgotten, and every record stays in the store. My previous review blocked one display regression: the board card's items tile and its "+N in round" line counted only the items the fold still held, so they disagreed with the whole-board total on the same card.

What I verified

  • pipeline_board_contract.py:589: the items tile is now held + forgotten.items, the same sum as progress.total (:540).
  • pipeline_board_contract.py:518-520: added_since adds forgotten.in_round.
  • crew_log/projection.py:6450-6451: _work_forget bumps in_round for an item from the current round. :6466-6474 _work_set_round zeroes it when the round moves, and both round writers (:6499 goal header, :6511 baseline board_round) go through it. A queue board that never bumps its round keeps the whole board in "in round 0", which is the pre-PR behaviour.
  • I ran panel_card_data on the 300/298/2 fixture. It now prints stat_items=300 and 299 of 300 settled · +300 in round 1. Before, the tile read 2.
  • The non-blocking points from last round are addressed: the RFC §4.2 implementation note, implementation-prs: [19068], the README row (now accepted), and the goal-conductor/SKILL.md wording.
  • 526 tests pass across test_pipeline_board_provider.py, test_pipeline_board_card_publisher.py, test_work_ledger_projection.py, test_work_ledger.py and test_work_ledger_board.py.

Mutations (one at a time, tree clean between them):

  • Tile back to len(view["items"]): test_the_items_tile_and_added_this_round_count_forgotten_items fails.
  • Dropping added += forgotten.get("in_round", 0): the same test fails.
  • Dropping the in_round increment in _work_forget: test_forgotten_items_count_toward_added_this_round_until_the_round_moves and test_a_long_board_folds_to_its_open_items_plus_the_closed_window fail.
  • Dropping the reset in _work_set_round: test_forgotten_items_count_toward_added_this_round_until_the_round_moves fails.

Blocking

None.

Non-blocking follow-ups

  • crew-log-projection.md around line 947 describes forgotten only as "its closing state". A one-line list of its keys (created, items, the per-state counts, in_round, baseline_ids) would help the next reader.
  • Carried over: list_work_items still reads every record file under the board lock. The RFC note now records this as an accepted cost, so a trim or an open-count index is the follow-up once boards reach thousands of items.

Not verified

  • I did not open the HTML templates (goal-board, work-kanban) in a browser. Their whole-board sums were checked from source only.
  • I did not check CI status on this head.

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.

Work ledger: a spent queue board blocks on the stored bound and needs a manual sweep

3 participants