Skip to content

fix(monitor): preserve member directive self-arm provenance - #20169

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
rubencu:fix/member-directive-selfarm-provenance
Oct 29, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
rubencu:fix/member-directive-selfarm-provenance

Conversation

@rubencu

@rubencu rubencu commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A crew/member session can self-arm from positively attributed human or own-wake turns while restored, untagged, and injected turns remain refused.

A member conductor can receive a human-authored steer, bind a worker, and call monitor_start. If its running turn ends before consuming the steer, the message is requeued. The requeued turn previously lost its human-origin mark, so the existing authorization gate treated the monitor request as an outside arm and returned 409 after the tool had reported that the request was accepted.

Why it matters

A conductor can end its turn believing its patrol is armed while worker reports remain unread because no loop exists. A restored or untagged turn must not solve that symptom by gaining authority it never had.

Not a goal

  • Creating a third self-arm producer inferred from a missing actor tag.
  • Admitting a gateway-authored default patrol on a crew/member slot.
  • Adding a trust-record kind or changing the bind-route patrol.
  • Allowing cron, app, native sub-agent, restored, untagged, or peer-session turns to self-arm.
  • Relaxing the existing outside-arm 409.

What changed (motivation → approach → change)

A person's steer that the turn ends before consuming now keeps the human-origin mark, so the member conductor's own monitor_start is admitted as a self-arm instead of answering 409.

Turn provenance Self-arm result
Authenticated human origin, including a steer requeued before the turn consumed it Existing self-arm path receives the session binding
This slot's own monitor wake Existing self-arm path receives the session binding and wake id
Restored, untagged dispatcher (spec-builder app turns included), cron, app, native sub-agent, gateway or peer-session turn No positive mark, so the existing outside-arm 409 remains

The root cause was lost positive provenance, not a missing grant. A steer RPC that accepts the write has not consumed the text, yet steer_into_running_turn in dashboard/chat_delivery.py dropped the steer's admission and origin records as soon as the RPC returned. A turn that ended before the steering_consumed echo then requeued an entry with no _directive_user_origin. The records are now held while the steer is still registered. _settle_consumed_steers in dashboard/chat_turn/steer_queue.py releases them on consumption, the turn-end requeue copies and releases them, and a hard kill drops them with the text. A channel steer also keeps its narrowing, and a peer steer keeps its containment baseline and still carries no positive mark.

Turn-actor attribution is unchanged, so session_send turns keep the Jev routing #12871 gives conductor-delivered turns. Attribution gaps already on main are tracked in #21379.

The monitor-architecture spec states the positive-provenance rule and the steer hold, and the shielded-steer comment in session_control_parts/session_messaging.py now lists what the settle releases. The autonudge_authz trust record, SEL audit, stopped-loop, stale-wake and fire-time checks are unchanged. This replaces the withdrawn gateway-arm approach in #18592.

Backwards compatibility

Compatible: existing human-origin and own-monitor-wake self-arms keep their behavior, and requeued human messages retain the provenance they had when admitted.

Removes nothing: no route, monitor kind, trust record, refusal, or public capability is removed.

Tests

  • A composer, Discord or peer steer that the RPC accepts and the turn ends before consuming is requeued and emits monitor_watch. The composer's directive reaches the applier user-facing, the Discord one keeps its channel narrowing, and the peer one carries no mark. Restoring the old unconditional pops fails the composer and Discord variants and both hold tests below.
  • A peer steer requeued after an accepted RPC keeps its containment stamp and gains no user origin. A consumed steer releases its held records, and so does the shielded broadcast settle. A hard kill (force stop) releases them too; removing those pops from chat_api/turn_stop.py fails the extended test_steer_requeue_entry_meta.py pin.
  • At the applier, a human-started member turn writes the self-arm trust record and SEL events, and a directive with no positive mark keeps the outside-arm 409.
  • At the runner, untagged live dispatch and spec-builder dispatch reach the applier with no producer mark, and an untagged queue entry drains with none. Human-origin and own-wake turns stay positively marked.
  • Local, on this head: provenance, steer-requeue and every test_session_control* module 1542, session-directive 207, Slack gateway 1044, Issue Radar 2976, Jev model-route and decisions 481, contract and spec checks 6956, backend related set 2018. prove.py reports PROVEN.
  • Determinism: the six changed test files (261 tests) passed two serial runs, two parallel runs and shuffled orders with seeds 20169, 11 and 42. Seed 7 fails six test_steer_requeue_entry_meta.py requeue tests after test_session_broadcast.py::TestATargetThatNeverAnswers::test_a_consumed_steer_timing_out_in_containment_stop_is_not_safe_to_resend. The same order fails identically on main at 3d6cda4, so that order dependency is on main and not in this diff. test_flake_pattern_ratchet.py passed all 60 tests.
  • Black, isort, flake8, mypy, comment-history, brand, docs lint, file-line cap and the repository semgrep rules passed. The frontend related set could not run locally (npm registry 401), and this diff touches no website/ file.

Manual verification

N/A — unit coverage drives the steer hold across accept, consume and requeue, the directive producer flags, authorization, trust records, and SEL events.

Screenshots / video

N/A — backend-only authorization and queue-provenance change; no rendered surface changes.

Related Issues

Closes #17603

Withdrawn predecessor: #18592.

Pattern harvest

Rule candidate: review-prompt
Pattern: authorization requires a positive producer mark, while actor fallback and restored text remain non-authoritative attribution data.

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.

@rubencu
rubencu requested review from a team and KiroCrewCaptain as code owners October 14, 2026 06:57
@rubencu
rubencu requested a review from mbriones98 October 14, 2026 06:58
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 14, 2026
@rubencu
rubencu force-pushed the fix/member-directive-selfarm-provenance branch from 984953d to cdd8743 Compare October 14, 2026 07:47
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 14, 2026
@rubencu
rubencu force-pushed the fix/member-directive-selfarm-provenance branch from cdd8743 to f46f947 Compare October 15, 2026 00:08
@rubencu

rubencu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 10e53cc. Kept the new GatewayOrchestrator composition and relocated the work-ledger wake actor stamp to slack/gateway_runtime/nudge_dashboard_fire.py. Focused provenance (16), session-directive (300), Slack gateway (385), Black, isort, flake8, mypy, comment-history, and docs gates pass.

@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 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of e007f9ddd996483ea1c5a38dee5340b10a0daa88 via the fork AI-review pipeline — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix is at mechanism level: the steered tail threw away records that _requeue_unconsumed_steers already reads (steer_queue.py:277,337,343), and the new settle pop releases them on the consumed exit.

What this change ships

Inventory (6 items) — 6 justified

Intent: when a member conductor gets a person's steer and its turn ends before using it, its own monitor_start should still count as a self-arm instead of getting a 409. FIX.

  1. When a person's steer is accepted but not yet used and then requeued, it keeps its human-origin mark, so the member's self-arm is admitted. — justified
  2. A requeued Discord or other channel steer keeps its channel narrowing. — justified
  3. A requeued peer steer keeps its containment baseline and still gets no positive mark. — justified
  4. A steer the turn has used now releases its held admission and origin records. — justified
  5. The monitor-architecture spec now states the positive-provenance rule and the steer hold. — justified
  6. Two existing comments and test docstrings that listed what the settle pops now match the new behaviour. — justified

[FIRST-PRINCIPLES-REVIEWED] e007f9d

Description read

[DESCRIPTION-READ] fec77ba24e9d1024802cbe57aac5f447c8317aa6a6e209cae7551e2e52f48310

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of e007f9ddd996483ea1c5a38dee5340b10a0daa88 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The steer's provenance now lives exactly as long as its attachments do, and every place a pending steer leaves (settle, requeue, force-stop, failed RPC) releases it.

[DESIGN-REVIEWED] e007f9d

Description read

[DESCRIPTION-READ] e51df70bbdd2d2452eee098d6d593b6732db595283d221e9bbca00a74332cd28

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed e007f9ddd996483ea1c5a38dee5340b10a0daa88 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e007f9d

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed e007f9ddd996483ea1c5a38dee5340b10a0daa88 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e007f9d

@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 15, 2026
@rubencu
rubencu force-pushed the fix/member-directive-selfarm-provenance branch from f46f947 to 3fcfd24 Compare October 15, 2026 04:17
@rubencu

rubencu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author
  • Restored requests regain self-arm authority on redispatch span=db37e66c9e96 — fixed

The actor-absence own-agent producer was removed. Self-arm now requires authenticated-human origin or this slots own monitor-wake mark.
ORIGINAL recovery carries a process-local restored marker, /prompts get forwards restored provenance, and the drain re-derives actor other without trusting disk text.
Added restored peer retry, recursion, untagged dispatcher, human-origin, and own-wake regressions. Fixed in 3fcfd24738be.

@rubencu

rubencu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author
  • A peer message restored from disk and then retried gets the members own self-arm authority span=6dd7854a8bdf — fixed

_queue_recovery now carries the process-local restored marker and the queue drain keeps _turn_provenance_restored while assigning actor other.
The absence-derived own-agent producer is gone, so restored and untagged turns have no self-arm authority even if an actor fallback reads user.
The new ORIGINAL retry regression fails when either propagation edge is removed. Fixed in 3fcfd24738be.

@rubencu

rubencu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author
  • Item 1 — symptom-level span=669d7d5f1a0f — fixed

There is no third own-agent producer. The absence-derived producer was removed, and spec-builder app plus every untagged dispatcher now grants no authority.
The #17603 path is the existing human-origin producer: a human steer requeued before consumption retains its positive origin mark and may self-arm.
Tests pin spec-builder as unmarked, untagged dispatch as denied, and human-origin as admitted. Fixed in 3fcfd24738be.

@rubencu

rubencu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author
  • Item 2 — rides along, inherited span=726b39b31aed — fixed

producer_is_peer_narrowed and the peer-narrowing slot state were removed.
Human-started and own-monitor-wake self-arms keep base behavior; peer-session turns themselves remain outside arms.
Requeued peer and channel provenance is retained only for accurate attribution and fail-closed authorization. Fixed in 3fcfd24738be.

@rubencu

rubencu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author
  • Own-agent identity is inferred from absence span=a30a8005594e — fixed

The own-agent predicate and producer flag were deleted rather than replaced with another fallback.
Only authenticated-human origin and this slots own monitor-wake mark vouch for self-arm. Untagged dispatchers grant nothing.
Restored turns are re-derived as actor other from process-local markers and remain marked restored. Fixed in 3fcfd24738be.

@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 readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 17, 2026
mbriones98
mbriones98 previously approved these changes Oct 18, 2026

@mbriones98 mbriones98 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.

Checks green and readiness passed at 9d4c74d; no behavior change.

A steer the turn ends before consuming is requeued from its held
admission and origin marks, so a member conductor's own human steer
keeps the user origin that vouches for its monitor_start self-arm.
@rubencu
rubencu force-pushed the fix/member-directive-selfarm-provenance branch from 9d4c74d to e007f9d Compare October 22, 2026 03:08
@rubencu

rubencu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Every exit of a still-registered steer must release the three held provenance maps — fixed

Verified on main 3d6cda4: every exit pops _steer_admissions, _steer_user_origin and _steer_channel_origin. Those exits are the echo's settle (_settle_consumed_steers), the turn-end requeue (_requeue_unconsumed_steers), the hard-kill discard in chat_api/turn_stop.py, and the unwind and already-drained returns in steer_into_running_turn.
Settle and requeue were already pinned. This head extends test_a_hard_kill_drops_the_entry to seed and check the three maps, and deleting the turn_stop pops fails it. Fixed in e007f9ddd996.

@rubencu

rubencu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Every path that drops a pending steer without settling or requeueing must release the three held provenance records — fixed

The only such path on main 3d6cda4 is the hard kill in chat_api/turn_stop.py. It pops all three records, with every other per-text map, before it clears _pending_steers. No slot-reset path exists: init_ladder_fields runs only when a slot is constructed, and closing a slot drops the whole object.
This head extends test_a_hard_kill_drops_the_entry to seed the three records and check that the force stop releases them; deleting those pops fails it. Fixed in e007f9ddd996.

@rubencu

rubencu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 3d6cda4 to clear the merge conflict (head e007f9ddd996). The production hunks are unchanged and sit beside main's _steer_automation pops. The tests moved to main's split modules, test_discord_resumed_busy_after_handoff.py and test_session_control_send.py. A hard-kill pin answers the Design and First Principles notes. This push dismisses the earlier approval, so the PR needs a fresh review and a fork-run approval. Local gates pass: provenance and session-control 1542, session-directive 207, Slack 1044, Issue Radar 2976, model-route 481, contract and spec 6956, backend related set 2018, Black, isort, flake8, mypy, Comment History, docs lint, semgrep and prove.py (PROVEN).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Oct 22, 2026
@rubencu

rubencu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Requesting a maintainer re-run of Fork Security Scope Review run 39717435924.
Its runner's egress was refused (github.com:443), so the Security Scope Review check never posted for e007f9ddd9, and PR Readiness is waiting on that lane.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 28, 2026
@iamwhatever iamwhatever self-assigned this Oct 28, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for a human reviewer on head e007f9d.

This PR changes which requeued turns carry the authenticated-human mark that authorizes a member's monitor_start self-arm: a steer's admission and origin records are now held until it is consumed or requeued instead of being dropped when the RPC returns (chat_delivery.py#L807-L821). Changes to who an authorization gate admits are reserved for a human, so this is a policy hold, not a code objection.

I found no defect. The hold lasts exactly as long as the text is in _pending_steers, the one-per-text guard (L479) stops a second identical steer from sharing the record, a peer steer still stores user_origin=False, and the settle releases the records (steer_queue.py#L211-L215). All earlier AI findings were answered with fixes, the current-head lanes pass, and all checks are green.

What clears it: a maintainer review of the self-arm provenance change.

— crew-pr-reviewer (r133)

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit da85ec4 into kirodotdev:main Oct 29, 2026
102 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
@rubencu
rubencu deleted the fix/member-directive-selfarm-provenance branch November 4, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Member/crew conductors get no default patrol on bind

4 participants