Skip to content

fix(work-ledger): dispatch (bind, session_create) always arms or reports a patrol - #19742

Merged
chenmingwei23 merged 2 commits into
mainfrom
fix/bind-always-arms-patrol
Oct 14, 2026
Merged

chenmingwei23 merged 2 commits into
mainfrom
fix/bind-always-arms-patrol

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a session that dispatches work always ends up with a patrol reading its workers, or is told in the same reply why it has none.

A conductor's own monitor_start loop (watch="work-ledger") stopped with monitor_terminal when every ledger item closed. The conductor then created and bound new items. Each work_ledger_record action=bind reply read Recorded bind. item=... state=open verdict=(none) and nothing more. No patrol was re-armed, so the new workers' reports went unread until a person noticed.

Why it matters

The maintainer rule is: whenever a conductor or crewmate dispatches work, the dispatching session MUST have a monitor running, on every backend. Today a conductor whose loop finished one round dispatches the next round with nobody watching, and the tool reply hides it.

Not a goal

  • Letting the gateway arm a loop on a crew/member slot. That needs turn-level provenance on the bind and create routes, which they do not have (see What changed).
  • Changing how the patrol itself runs (interval, budget, message flow, gating).
  • Arming anything for a caller that holds no work ledger.

What changed (motivation → approach → change)

Symptom → cause, both reproduced by failing tests before the fix (test/test_bind_patrol_rearm.py):

  1. conductor_patrol.ensure_patrol re-armed a stopped loop only when it was the gateway's own default_patrol. A conductor's own loop stopped monitor_terminal answered existing, and no arm was attempted.
  2. mcp_work built the bind reply from item alone, so the route's patrol / patrol_note never reached the agent, though the tool description promised them.

Change:

  • ensure_patrol returns (outcome, reason):
    • caller holds no work ledger → nothing armed, unsupported (no-ledger)
    • no loop → armed (no-loop)
    • inactive, system-stopped (the _stopped_row_is_replaceable allowlist a directive re-arm already uses) → replaced, armed (replaced-system-stopped)
    • inactive, stopped by a person → kept, refused (user-stopped)
    • active → left alone, existing (active-work-ledger | active-other-watch)
    • crew/member slot → refused (outside-arm-refused), gate unchanged
  • The bind route returns patrol_reason next to patrol. session_create (POST /api/session-control/create, not a dry run) is a dispatch too and runs the same ensure_patrol on its caller, with the same fields.
  • Both MCP replies end with patrol=<outcome> (<reason>) plus a note when no work-ledger watch is active (conductor_patrol.reply_line, patrol_note). A reply missing the field reads patrol=unknown with the note.
  • Guidance: one short "Dispatch means monitor" paragraph in the goal-conductor skill Patrol section, and one clause in the member operating-mode block saying the gateway cannot arm a loop on that thread. Spec (monitor-architecture.md) updated to match; the RFC text is main's.

Why a member cannot be self-armed from these routes: the member-slot gate admits only a SELF-arm, proven by initiator_slot_key. Only session_directive_apply supplies it, for a human-started turn or the slot's own loop wake. The bind and create routes see the kernel-verified session KEY, not the turn, and a cron injection, an app-driven turn or a sub-agent on a member slot sends the same key. Reaching the directive path from bind/create would mean adding work_ledger_record / session_create to session_directive.DIRECTIVE_TOOLS (pinned to CORE_MCP_SERVER) and teaching mcp_core.derive_directive to derive without re-running the call, since today it re-runs the tool, which would replay a side-effecting bind or create. That is a change to the directive provenance gate, so it is left out.

Product shape: implements phase 2 (section 9) of docs/request-for-change/rfc-conductor-default-patrol.md, revision v2, status partial, merged on main by #19893. That RFC records the system-stopped re-arm, arming on session_create when the caller holds a ledger, the no-ledger note, the reply reason, and option D as out of scope (section 9.6). This PR does not edit the RFC.

Backwards compatibility

Compatible: the bind and create replies gain fields and a trailing line; no field is removed or renamed, and every request main accepts is still accepted.

Removes nothing: no route, field, record or capability is taken away. A person-stopped loop is still never revived; only its reported outcome moves from existing to refused (user-stopped).

Tests

  • test/test_bind_patrol_rearm.py (new): a system-stopped own loop is replaced on bind; a user-stopped loop is refused, not re-armed; an active loop is left alone; no loop arms one; a crew/member slot refuses the outside arm with its reason; the real AutoNudgeService admits the default over a finished own loop; the bind MCP reply always carries the outcome, including a reply missing the field.
  • test/test_session_create_patrol.py (new): the create route arms for a ledger-holding caller, replaces a system-stopped loop, leaves an active one alone, refuses a crew/member caller and writes no loop on it, arms nothing for a ledger-less caller and keeps its stopped row, arms nothing on a dry run; the create MCP reply ends with the outcome.
  • test/test_conductor_patrol.py: person-stopped rows now answer refused (user-stopped).
  • test/test_context_composition_contract.py: member-mode golden re-pinned for the one added clause.

Manual verification

N/A — unit coverage drives the real route handlers, the real authorizer and the real loop store. The arm path reads the slot key, mode and memory mode only, never the backend, so the result is the same for every backend.

Related Issues

Fixes #19741

Pattern harvest

Rule candidate: review-prompt
Pattern: an MCP tool reply formatted from a subset of the route's response silently drops fields the tool description promises; assert every documented reply field reaches the rendered text.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 13, 2026 06:41
@iamwhatever iamwhatever changed the title fix(work-ledger): bind re-arms a system-stopped patrol and reports it fix(work-ledger): dispatch (bind, session_create) always arms or reports a patrol Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 62852e7

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

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 62852e7baad5d309b03df437dc5845d34c5f26f7 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 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that a terminal-stopped loop someone else armed on the slot, such as a channel or dashboard PR watch, should be silently replaced by the default patrol.

[DESIGN-REVIEWED] 62852e7

Description read

[DESCRIPTION-READ] 6c1797c411e2cbf0887b25e5de35c2b04089cb359080a4623b636316a3eeb964

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 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 62852e7baad5d309b03df437dc5845d34c5f26f7 — 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

Nothing to check.

What this change ships

Inventory (10 items) — 10 justified

Intent: a conductor that dispatches more work (by bind or session_create) always ends up with a patrol reading its workers, or the same reply tells it why there isn't one. This is a FIX (#19741), plus phase-2 additions that rfc-conductor-default-patrol.md records as accepted (status partial on base, §9.2 decisions 1–5).

  1. A bind after the conductor's own loop was stopped by the system (subject went terminal, budget ran out) now arms a fresh default patrol. Before, it answered existing. — justified
  2. A loop a person stopped is now reported as refused (user-stopped) instead of existing, and it is still never revived. — justified
  3. session_create from a non-member caller that holds a ledger now arms the default work-ledger patrol. A dry run arms nothing. — justified
  4. session_create from a caller with no ledger arms nothing and returns a "no-ledger" note saying what loop to arm. — justified
  5. The bind and create route responses gain patrol_reason next to patrol. — justified
  6. The bind MCP reply now ends with patrol=<outcome> (<reason>) plus a note. Before, the route's patrol and patrol_note never reached the agent, though the tool description promised them. — justified
  7. The session_create MCP reply ends with the same patrol line, or patrol=unknown when the route sent no outcome. — justified
  8. The goal-conductor skill's Patrol section gains a "Dispatch means monitor" paragraph. — justified
  9. The member operating-mode block gains a clause: the gateway cannot arm a loop on this thread, so arm your own. — justified
  10. The patrol message and the work_ledger_record tool description are reworded from "bound a worker / no loop" to "dispatched work / no active loop". — justified

[FIRST-PRINCIPLES-REVIEWED] 62852e7

Description read

[DESCRIPTION-READ] 6c237ca7bde40948f62fbba3566283e27c653d9af48c5b51753e62342fe92216

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 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 62852e7

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

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

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 13, 2026
@iamwhatever
iamwhatever force-pushed the fix/bind-always-arms-patrol branch from a50c998 to b1bb640 Compare October 13, 2026 07:30
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 13, 2026
@iamwhatever
iamwhatever force-pushed the fix/bind-always-arms-patrol branch from b1bb640 to 9910885 Compare October 13, 2026 08:03
@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 13, 2026
@iamwhatever
iamwhatever force-pushed the fix/bind-always-arms-patrol branch from 9910885 to 9f51d5d Compare October 13, 2026 08:04
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for the review lanes on b1bb6409c6, addressed in 9f51d5d065:

  • Backend Tests (shard 2) — test_only_the_phase_2_seams_import_the_module: fixed. conductor_patrol no longer imports the work-ledger store. The create route asks dashboard/handlers/work_ledger.holds_ledger (the store's permitted seam) and passes has_ledger to ensure_patrol.
  • Opus advisory — no-ledger caller with an active loop got the "No patrol runs" note: fixed. ensure_patrol checks for an active loop before the ledger, so that caller answers existing (active-other-watch) with no note. Test: test_a_caller_with_no_ledger_and_an_active_loop_is_told_nothing.
  • Design — re-arm replaces a system-stopped loop on another watch: intended. A slot holds one loop; a finished PR watch has nothing left to watch, and the new bind is work nobody reads without a patrol. Pinned by test_a_finished_pr_watch_is_replaced_on_bind. A person's stop is still never replaced.
  • Design / First Principles — session_create arming without an RFC: this is the maintainer's dispatch-means-monitor rule applied to the create route. It needs the maintainer's recorded decision (override or RFC); this PR does not claim one.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for Design CONCERNS on 9f51d5d065 (advisory, no push):

  • Create-route arm without a recorded decision: agreed it needs one. It is the maintainer's dispatch-means-monitor rule applied to session_create; the decision is the maintainer's to record (First Principles override or RFC). Not claimed here.
  • What the conductor does on replaced-system-stopped: the default is enough. Its fixed message runs the full patrol cycle (compact ledger read, accept_eval.py on done items, answers to question/blocked, autonudge_stop when all items are terminal), and the conductor's own monitor_start still replaces it at any time without a 409. The skill paragraph tells the conductor to arm only when the outcome is not armed or existing (active-work-ledger).

@iamwhatever
iamwhatever force-pushed the fix/bind-always-arms-patrol branch from 9f51d5d to b9bf536 Compare October 13, 2026 08:38
@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
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 13, 2026
…orts it

A bind arms the default work-ledger patrol when the conductor holds no
ACTIVE loop. An inactive loop the system stopped (its subject went
terminal, a bound ran out) counts as none and is replaced, whoever armed
it. A loop a person stopped is kept and the arm is refused with reason
user-stopped. An active loop is left alone. The member-slot outside-arm
refusal is unchanged.

The bind route now returns patrol_reason next to patrol, and the MCP
reply renders patrol=<outcome> (<reason>) plus the arm-yourself note on
every bind. A reply missing the field reads patrol=unknown with the note.

The goal-conductor skill and the member operating-mode block state the
rule once: dispatch means monitor, default watch="work-ledger".

Fixes #19741
@iamwhatever
iamwhatever force-pushed the fix/bind-always-arms-patrol branch from b9bf536 to 7f2a169 Compare October 14, 2026 01:07
@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 14, 2026
A create is a dispatch. After a create commits (not a dry run), the
route runs the same conductor_patrol.ensure_patrol on its caller and
returns patrol, patrol_reason and patrol_note. The session_create MCP
reply ends with patrol=<outcome> (<reason>), shared with the bind reply
through conductor_patrol.reply_line.

A caller that holds no work ledger gets nothing armed (no-ledger): a
work-ledger watch would read nothing and fire on its timer, so the reply
tells it to arm a loop on the session it opened instead.

A crew/member caller is still refused as an outside arm: the route has
the session key, not the turn, so it cannot tell the member's own turn
from a cron, app or sub-agent turn on the same key. The member arms its
own loop with monitor_start, as its operating-mode block says.

Refs #19741
@iamwhatever
iamwhatever force-pushed the fix/bind-always-arms-patrol branch from 7f2a169 to 62852e7 Compare October 14, 2026 01:39
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for the lanes on 7f2a169013, addressed in 62852e7baa:

  • Opus advisory — create arm audited as work-ledger-bind: fixed. ensure_patrol takes a source keyword; the create route passes session-create. Test: test_the_create_arm_is_audited_as_a_session_create.
  • Design PASS note — bind replaces the conductor's own system-stopped monitor_start loop, cadence and message included: intended. RFC section 9 item 1 says an inactive system-stopped loop counts as no loop, whoever armed it. The conductor's own monitor_start still replaces the default at any time.
  • First Principles PASS note — "test: fail a test that leaves a patched module global behind #19964 test-tripwire hunks": not in this diff. git diff origin/main...HEAD lists only the 13 files this PR owns, rebased on current main.
  • Backend Tests (Windows) (1): infra. setup-python pip download timed out before any test ran; this push reruns it.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 14, 2026
@chenmingwei23
chenmingwei23 merged commit de0390f into main Oct 14, 2026
102 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/bind-always-arms-patrol branch October 14, 2026 05:47
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 14, 2026
@bolichen97 bolichen97 mentioned this pull request Oct 17, 2026
5 tasks done
iamwhatever pushed a commit to JiaDe-Wu/KiroCrew that referenced this pull request Nov 14, 2026
…erged

Six RFC index rows describe an implementation PR that has since
merged or died. Merged: consolidation-fresh-conversation (kirodotdev#22207),
crewmate-dashboard-upkeep-skill (kirodotdev#19069, kirodotdev#19866),
conductor-default-patrol (kirodotdev#19742, kirodotdev#27948) and terminal-exit-closes-tab
(kirodotdev#14511). Closed unmerged: conversation-trust-follows-founder (kirodotdev#13109)
and workflow-library-removal (kirodotdev#19040), whose rows still call them open.

Merged rows lead with what landed and relabel the old "Verified at"
sentence as the baseline. For the two closed PRs the row keeps its
original text behind an update line that says the PR is closed and
that the feature is still not on main, since only a maintainer can
re-judge the in-progress status. Only one symbol per row was
re-checked, at d775742, and the row says which. Two documents now
list their PRs in implementation-prs.
iamwhatever pushed a commit to JiaDe-Wu/KiroCrew that referenced this pull request Nov 14, 2026
…erged

Six RFC index rows describe an implementation PR that has since
merged or died. Merged: consolidation-fresh-conversation (kirodotdev#22207),
crewmate-dashboard-upkeep-skill (kirodotdev#19069, kirodotdev#19866),
conductor-default-patrol (kirodotdev#19742, kirodotdev#27948) and terminal-exit-closes-tab
(kirodotdev#14511). Closed unmerged: conversation-trust-follows-founder (kirodotdev#13109)
and workflow-library-removal (kirodotdev#19040), whose rows still call them open.

Merged rows lead with what landed and relabel the old "Verified at"
sentence as the baseline. For the two closed PRs the row keeps its
original text behind an update line that says the PR is closed and
that the feature is still not on main, since only a maintainer can
re-judge the in-progress status. Only one symbol per row was
re-checked, at d775742, and the row says which. Two documents now
list their PRs in implementation-prs.
iamwhatever pushed a commit to JiaDe-Wu/KiroCrew that referenced this pull request Nov 14, 2026
…erged

Six RFC index rows describe an implementation PR that has since
merged or died. Merged: consolidation-fresh-conversation (kirodotdev#22207),
crewmate-dashboard-upkeep-skill (kirodotdev#19069, kirodotdev#19866),
conductor-default-patrol (kirodotdev#19742, kirodotdev#27948) and terminal-exit-closes-tab
(kirodotdev#14511). Closed unmerged: conversation-trust-follows-founder (kirodotdev#13109)
and workflow-library-removal (kirodotdev#19040), whose rows still call them open.

Merged rows lead with what landed and relabel the old "Verified at"
sentence as the baseline. For the two closed PRs the row keeps its
original text behind an update line that says the PR is closed and
that the feature is still not on main, since only a maintainer can
re-judge the in-progress status. Only one symbol per row was
re-checked, at d775742, and the row says which. Two documents now
list their PRs in implementation-prs.
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.

Bind does not re-arm the conductor patrol after its own loop went terminal, and the reply drops the patrol outcome

2 participants