Repository navigation
perf(startup): fold the session tree in the background, claims fenced until it lands - #34901
chenmingwei23 wants to merge 5 commits into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/dashboard/server.py:1618 -- Pending creator verification bypasses quotas and loses approval cascades
[BLOCK-MERGE] f3e74cf Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — UPHOLD. I rated this HIGH. The failure is silent, and the PR introduces it: before this change the restore waited for the fold, so
False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: every reader of the unfolded tree fails closed, and the sweep after the restore catches slots published after the fold landed. Notes
[DESIGN-REVIEWED] f3e74cf Description read[DESCRIPTION-READ] d80aed49c714183217b4df55a5475dc7a1745eb91fde122f992275bc9b51e355 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 (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The PR removes a measured wait from the boot path, claims stay fenced until the fold lands, and the one leftover is dead code. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: a restarted gateway restores its tabs without waiting for the crew-log fold, and creator claims stay refused until the fold lands. This is a FIX (perf).
[FIRST-PRINCIPLES-REVIEWED] f3e74cf Description read[DESCRIPTION-READ] 54a5abf120f45bdc5e72edaa90a5ac3abfb197b2703b2752461c338b05bed3ec That sha256 names the PR description this verdict read. 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: |
2c82911 to
2d0801c
Compare
|
Fixed in 2d0801c. The boot fold now upgrades only a slot the restore itself marked as waiting on the fold ( |
2d0801c to
e29f329
Compare
e29f329 to
d64be1f
Compare
|
GPT 6.1 finding at test/test_crew_log_session_tree_spawned.py:338 fixed in d64be1f: both waits in the background-seed test are now bounded with asyncio.wait_for (the start handshake and the seed task), and the release event is set in a finally so a failure before the handshake cannot leave the fold thread parked. |
…hin the grace budget
d64be1f to
8e78b58
Compare
8e78b58 to
f3e74cf
Compare
|
Closing this unmerged by maintainer decision. Moving the session-tree seed to the background opened a window where creator-based checks (creator quota, approval cascade, a lowered Trust setting) pass unchecked for children whose creator is not yet confirmed, and the measured gain did not move first-turn time (only the socket bind came earlier). The seed's own cost is being made delta-only by the watermark replay for #34846 (#34882), which removes the reason to move it off the boot path. The branch is kept for reference. Refs #34847 |
Refs #34847
Stacks on #34866 and #34852 and must merge after them. The branch is based on the #34866 head, so the diff shown here includes their commits until they land; I will rebase onto main once after they merge.
Problem / Motivation
Goal: A restarted gateway restores its tabs without waiting for the crew-log session-tree fold, while creator claims stay refused until the fold lands.
The restore folds the whole crew log synchronously inside the first restored tab that carries
created_by, so one tab's read pays the full fold on the boot path (21 s of 31.7 s in a profile of the real prefetch on a home with about 100 tabs). No tab needs that fold to be built; only the creator check needs it.Why it matters
Every restart of a gateway with many tabs pays the fold before the socket-adjacent restore can finish. Anyone with a large home waits for it on each restart, and the wait grows with the crew log.
Not a goal
_seed_session_tree; it is left untouched and is now unused.What changed (motivation -> approach -> change)
Symptom: the restore blocks on
ensure_seeded()in the first prefetch that sees acreated_by. Cause: the restore compares each claim with the creation records, and an unfolded tree confirms nothing, so the restore folded first. Change:dashboard/session_tree_boot.py(new):start_background_seedfolds the tree off the loop as a tracked task, thenconfirm_creatorsupgrades each restored slot whose saved claim the creation records now back. It applies the same test the restore applies, so a claim the records do not back stays refused.dashboard/server.py: start that task right before the restore.slot_builders.py: drop the two blocking_seed_session_treecalls (call sites only) and the facade re-export inchat_persistence.py.chat_turn/crew_log_attribution.py: a first turn that already awaits the fold settles its own slot's claim, so it cannot race the boot sweep and lose the parent edge on its new log.Fail closed: before the fold lands, an unfolded tree answers "no creator", so a restored claim is
UNVERIFIED_CREATOR(non-empty, matches no caller) and session-control reads (creator_of, revive, status) refuse. A failed fold leaves claims refused until the next restart.Backwards compatibility
Compatible: nothing accepted today is newly refused after the fold; claims are refused for the seconds before it, and a claim the creation records back is accepted again once it lands.
Reader:
session_control_parts/session_revive.py:_creation_parent-- session_revive -- unseeded tree answers "" so the ownership check refuses (unchanged), test_a_boot_restore_keeps_only_the_creator_the_spawn_records.Reader:
slot_persistence/metadata_codec.py:_read_created_by-- restore -- storesUNVERIFIED_CREATORwhile unfolded, thenconfirm_creatorsrestores the claim, test_the_boot_seed_runs_in_the_background_and_confirms_after_the_fold.Reader:
chat_turn/crew_log_attribution.py:_crew_log_lineage-- chat turn -- awaits the fold and settles the slot's claim first, test_a_turn_that_waits_for_the_fold_settles_its_own_claim.Tests
test_a_boot_restore_keeps_only_the_creator_the_spawn_records(both restore drivers): the restore leaves the tree unfolded and every claim refused; after the fold, only the backed claim is confirmed.test_the_boot_seed_runs_in_the_background_and_confirms_after_the_fold: the loop is free while the fold is held in flight, the claim is refused, then passes once the fold lands.test_a_turn_that_waits_for_the_fold_settles_its_own_claim.Proof: not provable -- other: reverting the production hunks removes the new module the tests import, so the mutated run fails at collection; the restore test was run red against the base separately.
Manual verification
Measured on an isolated gateway bound to a loopback ephemeral port, with a temporary data home holding 100 synthetic tabs (90 with a creator claim) and a crew log of 60,000 session logs; the home and the process were removed afterwards. Method: start the service, open the dashboard with the test-mode flag, wait for the ready line, send one message to the newest tab, and record seconds from process start. 3 runs each, alternating, base = #34866 head vs this head.
Result: the boot path is about 3 s shorter. The first turn's progress is unchanged here because the cold fold on this synthetic home is only about 1.5 s and the turn is held by something else (memory preparation, covered by #34866 and #34852). A real home's fold was 21 s in the issue's profile, so a larger gain is expected there, but I did not measure it. A turn with no sandbox backend ends in an error message, which is the "progress" signal used.
Screenshots / video
N/A -- no user-visible UI change.
Related Issues
Refs #34847
Sibling sweep
Swept: git grep -n "_seed_session_tree|ensure_seeded" -- src/
Sibling: src/kiro_crew/dashboard/state_parts/slots_frame.py:364 -- not affected -- already seeds on the maintenance pool, not the boot path
Sibling: src/kiro_crew/dashboard/chat_turn/crew_log_attribution.py:187 -- changed here -- awaits the fold and now settles the claim
Sibling: src/kiro_crew/dashboard/session_memory.py:731 -- not affected -- runs on a page read, not the boot path
Pattern harvest
Not generalizable: a one-off blocking read on the restore path; the fail-closed fallback already existed as
UNVERIFIED_CREATOR.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.