Repository navigation
fix(work-ledger): one depth predicate for the three guards, so no sterile conductor - #19715
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that no existing caller opens a ledger at [DESIGN-REVIEWED] 3d5a7b7 Description read[DESCRIPTION-READ] facb2b5ad9aa081002aaddd9adf7a3bcd845ceec7327d674f1f14eb58342747a 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 The new What this change shipsInventory (7 items) — 7 justifiedIntent: when a conductor dispatches a conductor that is not allowed to conduct, the dispatch is refused straight away instead of leaving a child with a ledger it can do nothing in. This is a FIX (#18127).
[FIRST-PRINCIPLES-REVIEWED] 3d5a7b7 Description read[DESCRIPTION-READ] 6bb7f1e9ad51a0c4b7a891309d3f94a184f47b49283c70678859bd4ebd460d8b 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: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 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: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
80db6d7 to
1aecca9
Compare
|
…rile conductor The three depth guards read MAX_DEPTH with three hand-spelled comparisons and disagreed about depth 2: child_depth(1) returned 2 and ensure_conductor opened a ledger there, while _create_item refused every item at it. A conductor dispatched by a depth-1 conductor therefore came up with a live ledger it could do nothing in, and its parent read the branch as a slow child, not a refused dispatch. may_conduct(depth) is now the single reading of the cap (depth < MAX_DEPTH), and all three guards ask it. The refusal lands at child_depth, on the parent's side, so the grandchild's ledger never opens; _create_item keeps asking for a header a crew-log rebuild restored at a depth no entry guard admitted. Fixes #18127
1aecca9 to
3d5a7b7
Compare
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (5 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: makes the three work-ledger depth guards read one predicate so a conductor past the cap is refused at its first ledger call instead of opening a ledger that can create nothing; updates the two skill texts and adds tests.
Problem / Motivation
Goal: A conductor that may not conduct is refused the moment it is dispatched, never left alive with a ledger it can do nothing in.
A conductor dispatched by a depth-1 conductor comes up sterile. Its ledger opens with a 200, it looks healthy on its parent's board, and then every
createit tries is refused withdepth_exceeded. The parent sees a child thinking, not a child that cannot start.Why it matters
Nested dispatch is how a fleet absorbs work it did not know the size of. When the branch is a dead end, the parent should learn at the dispatch, not two patrol cycles later after reading a tail that says nothing happened. The team-lead skill shipped with a paragraph warning leads about this exact trap, which is the cost of leaving it.
Not a goal
Intended? / Repro
Intended? No. Every design source says a depth-2 session may only work:
docs/request-for-change/rfc-conductor-work-ledger.md§ Two-level conductors: "a root conductor may dispatch a conductor, and that child's workers may not conduct."src/kiro_crew/builtin_skills/goal-conductor/SKILL.md: "Depth is capped at 2, so your own children may be workers only — adepth_exceededoncreatemeans flatten, not retry."src/kiro_crew/docs/work-ledger.md: "A conductor may dispatch a conductor only once — depth is capped at 2, so a second-level conductor's own children are workers."src/kiro_crew/dashboard/handlers/work_ledger.py_bootstrapdocstring: the refusal "surfaces asdepth_exceeded(409) at the moment the child tries to open a ledger, rather than later when it tries to create an item."src/kiro_crew/builtin_skills/team-lead/SKILL.md(merged by the maintainer in feat(agent): ship kirocrew-team-lead as one of the default agents that leads and works #18128) names the disagreement as tracked by work ledger: the three depth guards disagree, so a depth-2 conductor is born sterile #18127.All three guards landed together in #8855; the test pinning the sterile depth-2 ledger landed in #9152 next to the handler comment that says the opposite.
Repro on
origin/main@ 04b59c0. A standalone script against the store with an isolatedKIROCREW_HOME:Same script on this branch:
What changed (motivation → approach → change)
Symptom: a depth-2 ledger opens and then refuses every create. Root cause:
MAX_DEPTHwas read by three hand-spelled comparisons.child_depthuseddepth + 1 > MAX_DEPTH,ensure_conductoruseddepth > MAX_DEPTH,_create_itemuseddepth >= MAX_DEPTH. Two let depth 2 in; one kept it out.Change:
may_conduct(depth)is the one reading of the cap (depth < MAX_DEPTH), and all three guards ask it. The refusal now lands inchild_depth, at the grandchild's first ledger call and before any ledger exists for it, so the grandchild's ledger never opens.ensure_conductorand_create_itemkeep asking the same question for depths that did not arrive throughchild_depth: a direct call, or a header a crew-log rebuild restored at a depth no entry guard admitted. TheMAX_DEPTHcomment now says what the number counts and that onlymay_conductreads it. The team-lead and goal-conductor skills no longer describe the sterile state or a refusal "atcreate": they say the child's first ledger call (goalorcreate) answersdepth_exceeded, which is the signal to flatten.Backwards compatibility
Breaking: a session bound to a depth-1 conductor's item gets
409 depth_exceededonwork_ledger_record action=goalwhere it got200and an empty ledger; itscreateanswers the same409it always did. Writer sweep on origin/main @ 1f6f5af:work_ledger.child_depthandwork_ledger.ensure_conductorhave one caller each,dashboard/handlers/work_ledger.py::_bootstrap, which already mapsdepth_exceededto 409 and whose docstring describes this behaviour. No CLI, cron or app code passes a depth.Reader:
src/kiro_crew/dashboard/handlers/work_ledger.py:_bootstrap-- subagent (bound conductor session) -- refusal path already handled;test_a_third_level_conductor_is_refused_at_the_depth_capReader:
src/kiro_crew/dashboard/handlers/work_ledger.py:api_work_ledger_get-- crew page, subagent -- a grandchild with no ledger answers404 no_ledger, the same answer any unopened ledger gives;test_a_third_level_conductor_is_refused_at_the_depth_capReader:
src/kiro_crew/work_ledger.py:rebuild_from_projection-- release (crew-log rebuild) -- a stored depth-2 header still rebuilds and still refuses create;test_the_three_depth_guards_agree_at_every_depthTests
test_child_depth_advances_one_level_and_refuses_the_last_conducting_level—child_depth(1)refuses withdepth_exceeded. Red on main (it returned 2).test_ensure_conductor_refuses_the_first_depth_that_may_not_conduct—ensure_conductor(depth=MAX_DEPTH)refuses and writes no record. Red on main.test_create_is_refused_when_a_stored_header_sits_at_a_depth_that_may_not_conduct— a header rewritten to depth 2 on disk still cannot create.test_the_three_depth_guards_agree_at_every_depth(depth 0..3) — for every depth, dispatch, open and create agree withmay_conduct.test_a_third_level_conductor_is_refused_at_the_depth_cap(routes) — the grandchild'sgoalis409 depth_exceeded, its read is404 no_ledger, and it can still report as a worker. Red on main (it asserted a200and a depth-2 ledger).Determinism: the tests are pure store calls on a per-test temp home with no clocks, threads or sleeps; CI runs them in both shards' order.
Manual verification
The standalone repro above, run against main and against this branch with the same isolated home. Static gates run locally: black, isort, flake8, mypy, comment-history, builtin-skill-scope, docs-lint, brand, decisions, changelog, feature-map, sync-io, loop-bound-locks, cwd-relative reads — all green. Tests are CI's run.
Related Issues
Fixes #18127
Pattern harvest
Rule candidate: review-prompt
Pattern: one cap constant compared by hand at more than one site (
>here,>=there) instead of through one named predicate.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)