Repository navigation
fix(cron): let a crew member manage its schedules from any of its sessions - #19359
akushonkamen wants to merge 2 commits into
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The fix depends on an unproven cause: the #19295 repro records no keys, and this change only joins the Watch
Suggestions
[DESIGN-REVIEWED] ff52061 Description read[DESCRIPTION-READ] ad7ce6f8f2702f4f0070d9c9ff41356ccbb253bee63c7a3ea54f7387d6fb714e 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, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The member arm only joins the Not justified as shipped
What this change shipsInventory (5 items) — 2 justifiedIntent: a crew member can manage the cron jobs it created from its later sessions. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ff52061 Description read[DESCRIPTION-READ] 8f437dc3e96efa9b728bd33c064568db4f2770ff90e8036c5ca2376222b95f47 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Response to the three BLOCK verdicts — fixed on push
|
|
Thanks for picking this up. I read the diff at
The description still says the arm reads |
|
Thanks for the careful correctness read, @bolichen97 — both points land. 1) Agreed: the member arm should not widen across memory-store slots; comparing the two keys after stripping only the |
|
[operator: bolichen97] Status check (2026-10-17 PT): the bug in #19295 still reproduces on main 8c4a3d9 ( |
|
Thanks for the status check. Agreed on both outstanding items: we'll rebase onto current main and push a revision that strips only the |
6ed1f8f to
36c7d60
Compare
|
Thanks for the status check, @bolichen97 — rebased onto current 1. The comparison now keeps the 2. The concrete key pair from the #19295 repro. The repro records no literal key strings (we checked the issue body and its full timeline), so here is the pair as current 3. Stale description text. The description's mechanism bullet now describes the member/slot match read off each key's own structure; Evidence on the rebased HEAD ( |
|
Holding at 36c7d60. No definite defect found, but this PR cannot be approved by an automated reviewer yet.
The store-suffix narrowing agreed on 2026-10-13 is in place and pinned by a test. A rebased head needs a fresh review. — crew-pr-reviewer (r111) |
…sions The MCP cron ownership gate matched a row's owner by exact session-key equality only, so a job a crew member created read as owned by a stranger from the member's own later sessions: `cron_list` omitted it and every mutating verb answered the shared "job not found" string. The job kept firing, manageable only from the CLI or the Schedule page - creating a cron and deleting it were reachable from different scopes. One field carried two meanings: `cron_job.session_key` is both the authorization owner and the delivery target. Delivery is genuinely per-session and stays untouched; authorization now also reads the crew-member binding the creation capture already records (`bind_cron_memory` -> `job.member_id`): - New `mcp_cron._authz_member_id` reads the member a vouched key names off the key's own structure (`member-<slug>` under the `dashboard_`/ `dashboard:` layer prefixes - the slug IS the member id, the same derivation `execution_context.revouch_at_verified_admission` trusts at gate-verified admission). No session record is consulted: the record is what the subject session writes, so it decides nothing here. - `_owned_by` (the ONE scope, reads and writes widening together) and `_check_cron_job_ownership` (all six mutating verbs) accept a second way to reach a row: a non-empty `member_id` naming the caller's own member. - Everything else stands verbatim. Exact-key matches still win; an ownerless row stays outside every session's scope in both directions even when it names a member it runs as (the CLI and the Schedule page remain its surface); an empty caller key still reaches nothing; the anti-enumeration refusal and its SEL audit lines are unchanged; delivery still posts to the creating session. The member arm requires a session owner to widen through, so a channel or Slack key, a `cron:` run key and an ordinary `chat-` slot - keys that name no member - gain nothing. Tested: test/test_mcp_cron_caller_identity.py (44 passed; the 7 new member-scope cases ran 2 failed / 5 passed before the fix, the failures being the issue's own shape - the member's later session could not list or sweep its earlier job), test/test_mcp_cron_security.py 534 passed, and the suite's cron-named subset 4947 passed / 34 skipped with 3 failures in test_app_cron_timeout_manifest.py that fail identically on pristine origin/main. flake8, isort, black, mypy (changed files), harness parity, brand name, subprocess encoding, sync-io-in-async and the comment-history gate all clean.
…t the runs-as member_id
The member arm of the cron ownership gate matched job.member_id, but that
field is the execution member cron_add lets the CALLER choose ("Crew Member
responsible for this schedule... Omit to inherit"); bind_cron_memory persists
that pick beside the creator's session. A caller-chosen label is no evidence
of who owns a row: Bob's or a dashboard chat session could create a row
labelled member_id="alice" and Alice's sessions would then reach it -- list,
update, remove, cron_remove_all.
Both authorization predicates (_owned_by, _check_cron_job_ownership) now
read the member off KEY structure on both sides: the caller's gateway-vouched
key and the row's recorded owner session_key, via _authz_member_id
(is_member_session_key + slug_from_dm_slot_key under the dashboard_
/dashboard: prefixes). job.member_id is never consulted for authorization.
Exact session-key access is unchanged, ownerless rows stay outside every
scope, and the issue's goal -- a member manages its own schedule from any of
its sessions -- is preserved: a row a member session created carries that
member in its own key.
Negative coverage: rows created by an ordinary chat session, another member's
session, and the other prefix spelling, each labelled member_id="alice" from
outside, stay unreachable from alice's session across cron_list, every
mutating verb and cron_remove_all, with the shared anti-enumeration refusal.
36c7d60 to
ff52061
Compare
|
Rebased onto Conflict resolution (both conflicts were in one spec bullet in Verification: Re: the 4 AI findings from crew-pr-reviewer — not addressed in this pass (kept this push to the rebase only); they still need per-item dispositions plus maintainer approval before the HOLD lifts. |
|
Thanks for the review, @iamwhatever — acknowledged on all three points at the current head (
Both of bolichen97's agreed items from 2026-10-13 are already in place on this head (store-suffix kept in the comparison with the pinning test, and the concrete key pair in the description). |
|
CI status at head
This looks like the same flaky/over-budget tree-scan test rather than our diff (the shard passed at the pre-rebase heads). We can't rerun the upstream run from the fork side, so: would a maintainer mind hitting "Re-run failed jobs" on run On @iamwhatever's policy point, no change from our 2026-10-21 note: the |
Problem / Motivation
Goal: A crew member can see and manage the cron schedules it created from any of its sessions, not only the one that happened to create them.
The bug (#19295): a crew member creates a cron job from its pinned-DM session. In any of the member's later sessions,
cron_listno longer shows the job, and every mutating verb answers the shared "job not found" refusal — while the job keeps firing on schedule. Creating a schedule and deleting the same schedule are therefore reachable from different scopes: only the CLI or the Schedule page can still manage it.Why it matters
Every pinned-DM conversation with a crew member presents a new session key, so this hits the common case, not an edge: the member's very next session loses sight of its own schedule while the schedule keeps firing. An agent on the MCP surface has no fallback surface (the CLI and the dashboard are outside its reach), so the member can neither audit nor clean up schedules it authored.
Not a goal
cron_job.session_keykeeps its delivery meaning untouched.kirocrew cron add, the onboarding importer): the CLI and the Schedule page remain their only management surface.What changed
Root cause: the MCP cron ownership gate authorized a row by exact
session_keyequality only —_owned_by(the one scope function gating BOTH reads and writes, pre-fixmcp_cron.py:3279) and_check_cron_job_ownership(all six mutating verbs, pre-fix:3099). One field carried two meanings:cron_job.session_keyis both the authorization owner and the delivery target. Delivery is genuinely per-session; authorization inherited that per-session narrowing, so a member's later session — a different key — was locked out of its own job.The fix adds a second arm to the gate:
mcp_cron._authz_member_id(src/kiro_crew/mcp_cron.py:2890) reads the member SLOT a vouched key names off the key's own structure (member-<slug>[.memory-<store>]under thedashboard_/dashboard:layer prefixes). The match is by SLOT, not slug: only the layer prefix is stripped, so the.memory-<store>suffix stays part of the compared identity and a different memory store of the same member stays out of scope (read_dm_binding_for_slotkeeps store generations apart on purpose). This is the same derivationexecution_context.revouch_at_verified_admissiontrusts at gate-verified admission, and it never consults a session record (the record is what the subject session writes, so it decides nothing here). The same derivation is applied on the row side to the row's recorded ownersession_key, so both sides of the member match are key structure the gateway authors — never a caller-writable field._owned_by(the ONE scope — reads and writes widen together) and_check_cron_job_ownership(all six verbs) accept a second way to reach a row: the member the ROW's own recordedsession_keynames —_authz_member_idapplied to the stored owner key — equal to the member the caller's vouched key names (src/kiro_crew/mcp_cron.py:3366,:3159).job.member_idis never consulted for authorization: it is the execution membercron_addlets the CALLER choose, so it records who a job RUNS AS, never who owns it.cron:run keys, ordinarychat-slots) gain nothing; the anti-enumeration refusal and its SEL audit lines are unchanged; delivery still posts to the creating session.Spec updated in the same commit:
docs/system-specs/modules/learn-cron-dashboard.md("Session scoping" bullet).Security review response (push 2,
6ed1f8fa)Three blocking reviews on the first push (Design, First-Principles, and the GPT security review) all made the same point, and they were right: the first cut matched the member arm on
job.member_id, but that field is the execution membercron_addlets the caller choose ("Crew Member responsible for this schedule… Omit to inherit",mcp_cron.py:2011;bind_cron_memorypersists that pick beside the creator's session). A field any creating session may fill is a "runs-as" label, not an ownership record — adashboard:chat-…session or another member's DM could create a row labelledmember_id="alice"and Alice's sessions would then reach it (cron_list, every mutating verb,cron_remove_all).The fix keeps the second arm but re-anchors both of its sides on key structure the gateway authors:
session_key(_authz_member_id(job.session_key)) instead of offjob.member_id. A member-created row carries that member in its own key, so the issue's goal is unchanged; a row created outside the member's sessions stays out of reach however it is labelled.job.member_idis never read for authorization anywhere; it keeps only its execution meaning.New negative coverage (the attack's own shape):
test_a_row_created_elsewhere_stays_out_of_the_member_it_namesseedsmember_id="alice"from OUTSIDE the creating session on rows created by an ordinary chat session, another member's session, and the other prefix spelling, and asserts Alice's session gets none of them — list, every mutating verb, and the bulk sweep, with the shared refusal text.test_the_row_reaches_the_member_on_its_own_key_not_the_labelled_fieldpins the positive half: the widening follows the row's key, not the labelled field.Revision for bolichen97's correctness review (2026-10-18,
36c7d60fb)All three points from the 2026-10-12 review are addressed:
slug_from_dm_slot_key, which drops the.memory-<store>suffix, so a job created frommember-alice.memory-alphawas reachable from any other store of the member. The comparison now strips only thedashboard_/dashboard:prefix and keeps the store suffix — a different store of the same member (and the storeless spelling) stays out of scope, both directions. New pinning test:test_a_different_store_of_the_same_member_stays_out_of_scope(creatordashboard:member-alice.memory-alphavs callersdashboard_member-alice.memory-betaanddashboard:member-alice;cron_list, every mutating verb,cron_remove_all, plus the reverse direction; verified to FAIL on the previous comparison and pass on this one).mainactually presents it: the pinned-DM slot is alwaysmember-<slug>[.memory-<store>](members.pydm_slot_key), traveling as the chat session keydashboard_member-<slug>and the canonical session-map aliasdashboard:member-<slug>. So the repro's creator key vs later caller key differ — when they differ — only by that layer-prefix spelling of the SAME slot; nothing in the repro turns on a.memory-<store>change (the store suffix is generation-scoped, and a resumed conversation keeps its slot). That puts the repro in the "only the prefix spelling" branch of the review's item 2, which is exactly what the narrowed comparison ships — and the store suffix stays in the comparison as hardening.job.member_idis read for authorization nowhere (kept only its "runs as" meaning), and the spec bullet ("Session scoping") was updated in the same commit.Evidence on the rebased HEAD (base
96c95887= currentorigin/main, rebase resolved one spec conflict in favor of main's "Job execution" bullet plus this PR's "Session scoping" bullet; branch stays at 2 commits):.venv/bin/pytest test/test_mcp_cron_caller_identity.py -q→ 48 passed (47 before + the new store test).test_mcp_cron_security.py test_cron_session_scope.py test_cron_owner_caveats.py test_cron_member_selection_capture.py test_r12_cron_owner_gate.py test_cron_adopt_ownerless.py test_mcp_cron.py test_cron_refactor_contract.py.flake8andisort --check-onlyon the changed Python files exit 0;scripts/check_black_formatting.pyPASS;mypy src/kiro_crew/mcp_cron.py src/kiro_crew/cron.py→ "Success: no issues found in 2 source files".markdown_ituntil it was installed — environment-only, not a diff failure.Backwards compatibility
Compatible: this only widens who may reach an existing row — a member reaching its own job. Nothing that works today stops working: exact-key matches keep winning, ownerless rows and unidentifiable callers keep today's refusals in both directions, and the stored
CronJobshape is untouched (member_idwas already recorded at creation; no field renamed, removed, or revalidated).Removes nothing: the diff widens two authorization predicates and their spec documentation; no key, field, path, or command is renamed, rejected, or taken away.
Tests
Seven new cases in
test/test_mcp_cron_caller_identity.py, one per contract edge:test_a_member_reaches_its_own_job_from_a_later_session— the issue's shape: a new session of the same member lists and manages the job a prior session created.test_cron_remove_all_sweeps_the_member_rows_from_any_of_its_sessions— the write-side sweep covers member-bound rows from any of the member's sessions.test_another_member_stays_outside_the_scope— a different member still sees nothing.test_a_key_that_names_no_member_gains_nothing— channel/Slack keys,cron:run keys and ordinarychat-slots gain no access.test_the_row_reaches_the_member_on_its_own_key_not_the_labelled_field— the widening follows the row's OWN session key: a row that records no execution member at all still belongs to the member whose session created it.test_a_row_created_elsewhere_stays_out_of_the_member_it_names(×3 creator spellings) — the security negative: a row created by an ordinary chat session, another member's session, or the other prefix spelling, labelledmember_id="alice"from OUTSIDE the creating session, stays out of Alice's scope forcron_list, every mutating verb andcron_remove_all, with the shared anti-enumeration refusal.test_an_ownerless_row_stays_out_of_scope_even_when_member_bound— an ownerless row is outside every session's scope in both directions even when it names a member.test_an_unidentifiable_caller_still_reaches_nothing— an empty caller key still reaches nothing.Evidence (re-run this session on HEAD
6ed1f8fa, base0a4702109= currentorigin/main; branch is 2 commits, within the checklist limit):timeout 240 .venv/bin/pytest test/test_mcp_cron_security.py -q --no-header→ 534 passed (7.51s)..venv/bin/pytest test/test_mcp_cron_caller_identity.py -q→ 47 passed on HEAD6ed1f8fa(44 on the first push + 4 new/reworked − 1 replaced). The new security negative,test_a_row_created_elsewhere_stays_out_of_the_member_it_names, ran failed before this commit under the first cut'sjob.member_idarm (Alice reached rows other sessions had labelled with her id) and passes now..venv/bin/pytest test/ -q -k 'cron and not slow'→ 4955 passed / 34 skipped / 1 failed (624.63s). The one failure (test_cron.py::TestCronService::test_mutation_after_deeply_nested_load_does_not_overwrite_the_store,DID NOT RAISE CronStoreUnreadable) reproduces identically on pristineorigin/main0a4702109(verified in a clean worktree of the base commit) — a pre-existing environment failure touching the store loader this diff never reads.test_mcp_cron_security.py test_cron_session_scope.py test_cron_owner_caveats.py test_cron_member_selection_capture.py test_r12_cron_owner_gate.py test_cron_adopt_ownerless.py test_mcp_cron.py test_cron_refactor_contract.py.BRAND_BASE_REF/COMMENT_HISTORY_BASE_REF/HARNESS_BASE_REF=0a470210903bf500a796e8bbf7bcca8bd3579803):check_black_formattingPASS ("nothing in scope is unformatted outside the baseline"),check_brand_namePASS ("no misspellings of 'Kiro Crew' in the lines added since ..."),check_comment_historyPASS ("no history narration on the lines this change adds", 3 changed files),check_harness_parityPASS ("Kiro identity tested positively in the lines added since ...").flake8on the three changed Python files exit 0;isortexit 0;scripts/check_black_formatting.pyexit 0;mypy src/kiro_crew/mcp_cron.py src/kiro_crew/cron.py→ "no issues found in 2 source files";scripts/check_harness_parity.py,scripts/check_subprocess_encoding.py,scripts/check_sync_io_in_async.py,scripts/check_brand_name.pyall exit 0;COMMENT_HISTORY_BASE_REF=origin/main scripts/check_comment_history.pyexit 0.scripts/local-gate.py(timeout 240) exceeds its wall-clock budget on this box (xdist worker budget: 1 worker; 666 related backend test files; exit 124) — the cron-named regression above (4953 tests) is the strictly larger equivalent coverage. Ruff: the repo pinsflake8==7.1.0+black+isortand carries no ruff dependency or configuration (pyproject.toml; no ruff step inci.yml), so the repo's own lint gates above are the lint signal.Manual verification
N/A — unit coverage sufficient: the gate is exercised end-to-end through the MCP tool inner dispatcher (
_call_tool_inner) with vouched caller keys, the same surface a chat session drives; this diff touches no UI surface.Related Issues
Fixes #19295
Pattern harvest
Rule candidate: review-prompt
Pattern: an authorization predicate must derive the principal from a field dedicated to identity; when one row field carries two meanings (here
cron_job.session_key— authz owner AND delivery target), every gate built on it silently narrows to the narrower meaning's scope.Checklist
fix(cron): ...)docs/system-specs/modules/learn-cron-dashboard.md"Session scoping")Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license (see the Licensing section of CONTRIBUTING.md); this contribution is made under those terms.
Transparency: this fix was authored with AI assistance (Claude, via an automated contributor workflow), reviewed and tested by me as recorded above — disclosed voluntarily; CONTRIBUTING.md sets no disclosure requirement.