Repository navigation
fix(crew): a crewmate's worker follows its Profile and record - #23567
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. Both items fix the mechanism that caused the defect: the seed is re-read once the record exists, and the one writer of the worker set now also removes keys. Each fix has a test that drives it. What this change shipsInventory (6 items) — 6 justifiedIntent: a crewmate's worker always runs under the Permissions and backend its Profile and record say. FIX.
[FIRST-PRINCIPLES-REVIEWED] a844150 Description read[DESCRIPTION-READ] 9729896931284259335a47bf924589a2726b555addf765d3ed6495582dd88246 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. Both fixes follow the existing seams: the worker is seeded from the Profile once its record exists, and the worker key set now tracks the record in both directions. If seeding is skipped, the worker stays untrusted. Notes
[DESIGN-REVIEWED] a844150 Description read[DESCRIPTION-READ] 5673cec0d623a781cc6cffc1b4af2ca1610f7786538177aa634e2a1cd0487fab 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 |
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: |
cruisercohen
left a comment
There was a problem hiding this comment.
Commenting at ff65c63, not approving: this changes how a crewmate's worker gets its auto-approve posture, so the sign-off is a maintainer's. I found no code defect.
What I checked, on the PR merged with current main:
- Seed timing. A Profile worker now starts with
_trustand_trust_readsoff and is seeded only afterbind_session_executionhas written its record, from a fresh config read. If the crewmate can't be named, it keeps the old inherit-from-caller path. A failed birth, or a config that loads as defaults, leaves the worker untrusted. - Races with a Profile save. I traced each ordering. A save written before the fresh read is seen by the read. A save written after it reaches the worker through
apply_to_live_sessions, because the record is already on disk. The remaining case is a save whose apply runs while the fresh read is still in flight, so the read is stale. That case is covered by the once-per-slot_member_approval_seededflag: the apply sets it, so the stale seed skips, and if the seed ran first, the apply overwrites it. I checked this with a scratch test that does a stale read, then the save and its apply, then the seed. Trust→Normal ends untrusted and Normal→Trust ends trusted. - Worker key.
note_worker_sessionnow drops the key for any non-worker record.read_session_executionreturnsNoneonly for no record or a plain record: an unreadable record, or a member record missing its identity, raises. So a real worker can't lose its key to a transient read. - Tests. 395 pass across the worker, approval, dispatch, agent-switch and create-path suites. With the six source files put back to main, all 4 new cases fail.
One optional suggestion, not blocking: the seed_new_worker comment credits the no-await gap between the read and the seed. The read itself runs in a thread, though, so the in-flight case above is actually covered by _member_approval_seeded. A sentence saying so, plus a case like my scratch test, would keep a later change to that flag from reopening the window.
|
HOLD (policy-sensitive) at ff65c63. I found no defect. A Profile worker now starts untrusted and is seeded once its record is on disk, so a Trust to Normal save made while the worker is being opened reaches it; the stale-read window is closed by the once-per-slot I am not approving because the diff changes a crewmate worker's auto-approve posture ( — crew-pr-reviewer (r123) |
A worker took its crewmate's approval mode from a config read before the create's awaits, and a Profile save in that window skipped it because it had no record yet. It now starts untrusted and is seeded once its record is on disk, so a save from then on reaches it through the live apply.
… one The crewmate-worker key set only grew, so a session whose record moved off the worker template kept the crewmate's member backend. A read of a record that is no longer the worker now removes the key.
ff65c63 to
a844150
Compare
|
Maintainer sign-off (buluoray) at |
Problem / Motivation
Goal: A crewmate's worker runs under the Permissions and backend its crewmate's Profile and record say, even when the Profile is saved while the worker is being opened or the worker's slot is made again on an ordinary template.
Two follow-ups from #23010:
create_sessionseeded the worker from a config it read before its suspensions, and the Profile save's own pass over live workers (crewmate_approval.apply_to_live_sessions) skipped the child because it had no execution record yet. The worker then kept auto-approving after the owner revoked trust._CREWMATE_WORKER_SLOTS) after its slot is made again on an ordinary template, so that template runs on the crewmate's member backend, and its model is judged against that backend.Why it matters
Permissions are the owner's control over what a crewmate's worker may run unasked. A revocation that does not reach a worker opened in the same moment leaves a trusted session the owner believes is untrusted. The backend leak sends an ordinary chat to a harness the owner did not choose for it.
Not a goal
What changed (motivation → approach → change)
crewmate_approval.seed_new_worker, called fromsession_create). A save after that point reaches the worker throughapply_to_live_sessions, which can now see its record; there is no await between the fresh read and the seed. A worker whose crewmate cannot be named keeps the old inherit-from-caller path.mate_worker.note_worker_sessionnow drops the key when the record is not a worker (members.forget_crewmate_worker_session). It runs on every read before an allocation and, new, at an explicit selection's commit (slot_guards._record_explicit_agent_selection), so the key leaves before the next turn, the eager start or the model picker read it.crew-mode.md(Permissions paragraph, worker backend bullet) andsession-control.md(approval posture).Note:
POST /api/chat/slots/{slot}/agenton a live worker is refused withmember_session_pinned, and a provider-side switch on a worker is vetoed. The reachable path is a worker's slot made again under the same key on an ordinary template (POST /api/chat/slots), which is what the route test drives.Backwards compatibility
Compatible: a worker still ends up with its crewmate's Profile mode, and an ordinary session's backend selection is unchanged; only a stale mode and a stale worker key are corrected.
Removes nothing: no field, route, validator or record is removed; one in-memory key is dropped when the session's own record no longer names the worker.
Tests
test_crewmate_worker_approval.py::test_a_profile_change_during_the_workers_creation_reaches_it(both directions, Trust→Normal and Normal→Trust): the Profile is saved after the create read its config and before the worker's record lands.test_crewmate_worker_approval.py::test_a_profile_save_applied_during_the_seeds_read_wins(both directions): the seed's config read is stale, the save and its live apply land before the seed; the once-per-slot_member_approval_seededflag keeps the saved mode.test_mate_worker_dispatch.py::test_a_worker_switched_to_another_template_leaves_its_crewmates_backend: a record moved off the worker template takes the key off the member backend at the next read.test_mate_worker_dispatch.py::test_a_worker_slot_made_again_on_an_ordinary_template_leaves_at_the_commit: the route commit drops the key before any turn.Proof: PROVEN test/test_crewmate_worker_approval.py::test_a_profile_change_during_the_workers_creation_reaches_it[trust-normal-False], test/test_crewmate_worker_approval.py::test_a_profile_change_during_the_workers_creation_reaches_it[normal-trust-True], test/test_mate_worker_dispatch.py::test_a_worker_switched_to_another_template_leaves_its_crewmates_backend, test/test_mate_worker_dispatch.py::test_a_worker_slot_made_again_on_an_ordinary_template_leaves_at_the_commit (head ff65c63)
Local gate: the related backend set ran 29,326 tests; 16 failed, every one either fails the same way on the base commit or passes when rerun alone (load timeouts on a shared host).
Manual verification
N/A — unit coverage drives the real
create_sessionand the real/api/chat/slotsroute; no live gateway run.Related Issues
Refs #23010
Sibling sweep
Swept:
git grep -n "note_worker_session\|seed_for_turn(" -- src/Sibling: src/kiro_crew/session_agent_selection.py -- not affected -- already calls note_worker_session on every read before allocation
Sibling: src/kiro_crew/slack/gateway_runtime/cron_fire.py -- not affected -- binds a worker record and notes it, never a non-worker
Sibling: src/kiro_crew/dashboard/chat_turn/turn_admission.py -- not affected -- seeds at turn start from the config loaded for that turn
Pattern harvest
Not generalizable: both are one in-memory mirror (slot trust, worker key set) read from config or a record at a moment the record did not exist yet or had changed; no shared shape beyond these two seams.
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.