Repository navigation
feat(crew-log): make the conductor pull-forward a keyed bus subscriber - #16076
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify loop-table emits always run on the service loop — [DESIGN-REVIEWED] c279226 Description read[DESCRIPTION-READ] f532793f6f0a0a98a5ff2ed71533be10fa48b59b23ac6eda1c85fc3bab2c3214 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 |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: deliver the already-shipped conductor pull-forward through the crew-log bus instead of a consumer hard-wired into the eager drain — a MOVE of an existing capability (RFC
[FIRST-PRINCIPLES-REVIEWED] c279226 Description read[DESCRIPTION-READ] 3edce8fb6c0f6533e0e78248d38d630259abd2a29297ddcc9f3681102a23c3cc That sha256 names the PR description this verdict read. Recompute it with |
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: |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsOne advisory finding: a baseline-materialised item's first appearance in the board is read as a worker report, so a conductor's own write pulls its own loop forward. FINDING — src/kiro_crew/conductor_wake.py:158 — [OPUS-REVIEWED] c279226 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
57d6d7a to
889cf7d
Compare
889cf7d to
825cd8d
Compare
|
Ownership: this PR is driven by session chat-2372 (conductor chat-1875). Head: 825cd8d. Please do not push to this branch. |
825cd8d to
c2ef33f
Compare
c2ef33f to
afa9251
Compare
|
|
The crew-log eager drain had a hard-wired second consumer: `_push_conductor_wakes` imported `conductor_wake`, read the work-ledger binding file for every `work/recorded` wake, and fired the bound conductor's loop. That put a consumer's name in the producer and needed a store-import allowlist entry the work ledger had to argue for. `crew_log.bus` now publishes every advanced fold as `FoldAdvanced(scope, key, fold, revision, value, seq)`, and the `work` fold's key is the conductor's own board, so `conductor_wake` subscribes to that event at `AutoNudgeService.start` instead. It keeps the last board it saw per key and diffs each item's `last_report_at`: an item whose stamp moved is a worker that reported and names the item for the pull-forward cap; a board whose stamps are unchanged moved on a conductor's own write and pushes nothing, which also keeps a nested conductor's bookkeeping off its parent's budget. The same registry answers the close and turn-end triggers in reverse (worker slot -> board, item) from the `worker_session_key` each item carries; a worker it has not seen primes the registry once from the `work` fold's read path, bounded by the active loops. `eager.py` loses the hook and names no conductor; `conductor_wake.py` reads no store and leaves `_PERMITTED_STORE_IMPORTERS`. The RFC and the crew-log projection spec describe the subscriber.
One keyed subscription per board an active work-ledger loop watches, (slot, <board>, work), joined with baseline=True and disposed when the loop ends or the service stops. The subscriptions follow the AutoNudge loop table through its observer hook. Replaces the once-per-process unkeyed subscription and the store-read prime; the fold name comes from work_vocab instead of a local spelling.
afa9251 to
c279226
Compare
|
|
|
buluoray
left a comment
There was a problem hiding this comment.
Approving at c279226c12. CI at this head: 82 success, 12 skipped, 0 failing. I did not run the suite locally.
Verified against source
- Every
_emitcall site in the loop table runs inside an async method, and the one sync function (remove_sync) is only reached from async callers, so the Design lane's worry that emits can happen off the service loop does not apply.
Non-blocking follow-ups
- One-time spurious pull-forward per pre-existing item. When the conductor first runs
close/decideon an item that existed before the projection, it writes abaseline: Truerow that carrieslast_report_at(dashboard/handlers/work_ledger.py~L838 ->projection.py~L5261). The item looks new to the registry and its stamp is non-empty, so_firespends one pull-forward. Opus's suggested fix (never fire for baseline-materialized items) would also swallow a worker's real first report on an old item, because that report takes the same baseline path. A narrower condition: fire for a newly seen item only when its event tail haskind == "report". This costs at most one extra pull-forward per old item, so it does not gate this PR. _REPORT_FIELDSduplicatesprojection._WORK_WORKER_FIELDS(both("status","summary","artifacts","pr")), and only a test keeps them in sync. Importing the single definition inside the function would remove the drift risk.
Problem / Motivation
Goal: A conductor is pulled forward when its worker reports because the work ledger -- a crew-log fold -- published that it moved, through the same bus every other consumer of a fold will use.
#12781 landed the pull-forward as a consumer hard-wired into the crew-log eager drain:
eager.py_push_conductor_wakesimportedconductor_wakeand read the work-ledger binding file for everywork/recordedwake. That named one consumer inside the producer, and it needed a store-import allowlist entry (_PERMITTED_STORE_IMPORTERS) the work ledger had to argue for. A second consumer of the same news (a dynamic dashboard, a card trigger) would have meant a second hook ineager.py. #15781 then shippedcrew_log.bus, which publishes every advanced fold asFoldAdvanced(scope, key, fold, revision, value, seq); theworkfold's key is the conductor's own board.Why it matters
Left as is, the crew log carries a hand-wired exception to its own bus, and the next fold consumer either copies the hook or waits for this swap. The decision recorded on 2026-10-01 was to wait for #15781 and swap, rather than land the hook on main and change
eager.pytwice.Not a goal
probes/work_ledger.py,ledger_wake.py, both caps and the slow poll are untouched.workfold, so they stay as direct hooks and read the binding file, as before.What changed (motivation → approach → change)
Symptom:
eager.pyknew the conductor existed. Root cause: the pull-forward was wired as a second consumer of the eager drain, before the bus existed. Why this matters for the fix: an unkeyed subscriber would be handed every fold event the folder publishes, for every board and session, and #16149 has since given the bus keyed filters, a disposer andbaseline=True. Change:crew_log/eager.py_push_conductor_wakesper batchconductor_wake(slot, <board>, "work"),baseline=TrueAutoNudgeService.startand on every loop-table change (the service's observer hook); disposed when the loop ends or the service stopslast_report_atplus a digest of what the report wrote) against the last board seenread_bindingread_binding, unchangedconductor_wake.sync_subscriptions(svc)walks the loop table once, disposes boards whose work-ledger loop ended, and starts a join for each new one. The join runsbus.subscribe(..., baseline=True)on a worker thread (the baseline read is file I/O). The baseline is the board's first sight and pushes nothing: what landed before it is the loop's own tick's to read, and at bootstart()already arms every work-ledger loop at delay zero for that. A join that completes afterstopsees a bumped generation and disposes what it got. The registry and the subscriptions are bounded by the same predicate, the live work-ledger loops. The fold name comes fromwork_vocab.WORK_FOLD_NAMEinstead of a local spelling.The report stamp joins
last_report_atwith a digest of every field a report writes (status,summary,artifacts,pr) and the newestreportevent id.last_report_athas whole-second resolution and a report event id is content-addressed over status and summary, so either alone can stay unchanged across two reports in one second.Earlier review findings:
Opus BLOCKING on
57d6d7a8(registry unbounded): every loop-table change sweeps the registry and disposes the subscription of any board whose loop ended.test_a_disposed_subscription_wakes_nothing,test_a_board_whose_loop_ended_is_swept_on_the_next_observation.Opus finding on
57d6d7a8(closed item reclaims a worker): the worker map it described is gone;read_bindingis repointed on every bind.GPT 5.6 BLOCKING on
825cd8db43(stale fold redirects a direct wake): the fold-fed worker map is gone; close and turn end readread_binding, the one authoritative record.GPT 5.6 findings on
c2ef33f95fandafa9251456(two reports in one second push once): the stamp digests every report field plus the newest report event id.test_two_reports_in_one_second_each_push,test_a_same_second_report_with_the_same_event_id_still_pushes_on_new_fields.First Principles item 8 on
afa9251456(sync_subscriptionsreturned join tasks no caller awaited): it returns nothing; the tests read the pending joins from_subscriptions.joining.Opus finding on
825cd8db43(the baseline's first-sight push lands in the boot tick and buys a second cycle): first sight pushes nothing.test_the_first_board_seen_records_and_pushes_nothing.First Principles item 6 (
WORK_FOLDduplicate): deleted;work_vocab.WORK_FOLD_NAMEis imported.First Principles item 4 on
889cf7d5and item 3 onc2ef33f95f(worker map duplicatesread_binding): the map, the prime and_read_board_itemsare deleted; triggers 2 and 3 callread_bindingagain, andconductor_wake.pyis back on_PERMITTED_STORE_IMPORTERSfor that one read.src/kiro_crew/conductor_wake.py: per-board keyed subscriptions, report-stamp registry,read_bindingfor the loop-side triggerssrc/kiro_crew/crew_log/eager.py:_push_conductor_wakesremovedsrc/kiro_crew/autonudge.py:installatstart(),dispose_allatstop()test/test_work_ledger.py: the_PERMITTED_STORE_IMPORTERSentry forconductor_wake.pynow names the close and turn-end lookup onlydocs/request-for-change/rfc-crew-log-wake.md,docs/system-specs/modules/crew-log-projection.mdBackwards compatibility
Compatible: nothing main accepts is rejected or renamed at any external surface.
conductor_wake.fire_for_worker_slot_from_threadandeager._push_conductor_wakesare removed; the only caller of the first was the second.Reader: src/kiro_crew/crew_log/eager.py:_push_conductor_wakes -- chat -- removed with it; the bus subscription replaces the call (test_a_workers_report_wakes_its_conductor_through_the_bus)
Tests
test/test_conductor_wake.pyruns the real path for the bus side: a crew log on disk, the real append, the eager folder's own thread folding and publishing, the bus routing by key, and the callback scheduling onto a real event loop. Only the service is a stub.test_a_workers_report_wakes_its_conductor_through_the_bus: a workerwork_reportappend wakes the bound conductor's loop within the one eager batch that folds it.test_only_the_watched_boards_work_fold_reaches_the_subscriber: another board's report, and every session-scoped fold the same writes advance, never reach the module; one wake for the watched board only.test_a_disposed_subscription_wakes_nothing: loop ends, sync disposes, the bus has 0 subscribers, a later report wakes nothing.test_the_first_board_seen_records_and_pushes_nothing,test_two_reports_in_one_second_each_push,test_a_same_second_report_with_the_same_event_id_still_pushes_on_new_fields,test_the_report_fields_this_module_digests_are_the_folds.test_the_service_stop_disposes_every_subscription,test_a_join_that_lands_after_stop_keeps_nothing,test_the_service_start_installs_one_observer.test_the_eager_folder_names_no_conductor: the folder's source imports and references noconductor_wake.Mutations, each run against the file and reverted:
scope/key/fold/baseline): 3 failed.conductor_wakecall inside the eager batch loop: 1 failed (test_the_eager_folder_names_no_conductor).last_report_atalone: 1 failed (test_two_reports_in_one_second_each_push).test_a_same_second_report_with_the_same_event_id_still_pushes_on_new_fields).Local, on this head:
test_conductor_wake.py,test_work_ledger.py,test_crew_log_bus.py,test_probe_work_ledger.py,test_autonudge.py,test_autonudge_reconciler.py,test_autonudge_start_failures.py,test_autonudge_refactor_contract.py,test_autonudge_dashboard_fire.py,test_monitor_controller.py: 1084 passed. mypy (Success: no issues found in 3 source files), flake8, isort, black check, comment-history, sync-io-in-async and loop-bound-locks checks exit 0.Manual verification
The pod QA run (S1-S8 x3, from the #12781 / #15691 work) was on the earlier unkeyed head and is not repeated on this one. The bus side is covered end to end by the real-path tests above; the gate and caps are unchanged.
Related Issues
Follow-ups, not in this PR:
close_slotindashboard/chat_handlers.py, worker turn end throughnotify_turn_completeinautonudge_service/timers.py) are still direct calls intoconductor_wake. Moving them onto the bus needs a fold or event those paths publish.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement