Repository navigation
fix(schedules): a schedule says what tier its runs get, the owner can take it over, and a restricted run is named, marked and alerted (#4281) - #4648
Draft
AndriiPasternak31 wants to merge 9 commits into
Conversation
… take it over, and a restricted run is named, marked and alerted (#4281) A schedule created by someone who is neither an admin nor the agent's owner runs every time as a shared person: no shell, no owner-added MCP servers. Nothing said so, and the run still ended `success`. - Every schedule read (list, get, create, PUT, enable, disable and GET /api/ops/schedules) carries runs_as, runs_as_reason, created_by_you, created_by and can_take_over, from one rule, turn_tier_service.schedule_run_tier, which turn_actor also reads. - The turn-tier answer names the cause, schedule, creator and remedy, and the hook and the Gemini/Codex refusals say the run is a scheduled task, not a chat. - Each restricted schedule run records turn_integrity.restricted_turn; one schedule_runs_restricted operator-queue row per agent and creator. - POST /api/agents/{name}/schedules/{id}/take-over lets the owner or an admin adopt the schedule in place, human-only. - A shared-person schedule is refused at create and enable on Gemini and Codex agents (409 schedule_cannot_run_for_creator_on_runtime). - The Schedules tab shows the run tier and the take-over review; the Tasks list and execution page mark a restricted run. No schema change.
- The frozen turn_actor matrix pins the project_steward trigger, which dev added to OWNER_CONFIGURED_TRIGGERS (trinity-enterprise#1236). - The operator-queue package's __init__.py stays at 800 lines with the schedule-restricted- prefix in its three tuples. - The take-over race tests patch the module the live db method resolves its globals in, so they still fire after a test that evicts sys.modules entries (test_1595 ran first: 2 failed, now 72 passed).
…e schedule and is stamped (#4281) A continuation turn (caller_wake, operator_response, operator_ending, skill_gate) is rated as the turn it continues (trinity-enterprise#1225). When that turn is a share holder's schedule run, the turn-tier answer must carry the same cause, schedule, creator and remedy, and the continuation's run must record restricted_turn. Red: the answer's cause is null and the run carries no stamp.
…he run it continues (#4281) trinity-enterprise#1225 rates a continuation turn (caller_wake, operator_response, operator_ending, skill_gate) as the turn it continues, but the turn-tier answer's schedule fields and the run's restricted_turn stamp read the continuation row itself. Such a turn got the old "shared with" refusal text and no stamp. turn_tier_service.rated_turn returns the row the chain leads to, the same chain _rate follows; run_schedule and turn_schedule_detail read it, and run_restriction names that row's schedule. A link that cannot be followed names no schedule, as before.
…by Vector (#4281) The _log docstring said /logs/guardrails.jsonl reaches Vector. Vector's only source is docker_logs (container stdout and stderr), and /logs is not mounted out of the agent container, so nothing collects the file.
… docs and comments describe behaviour only (#4281) - feature-flows.md gets a row for the schedule run tier, take-over and the restricted-run marker and alert. - Requirement status for §2.12.1 moves to implemented. - Docs, comments, test docstrings and registry descriptions drop cross-references that only made sense while the change was in progress, and the scheduling flow drops a "not yet wired" note the take-over write already covers. No behaviour change.
…n both don't fit (#4281) The row's text column can't be narrower than its widest unbreakable piece, and the "Runs without shell" badge never wraps. In DejaVu Sans, the CI runner's sans-serif, the badge is 131px. At 390px in light mode, Linux Chromium's 15px scrollbar leaves 109px beside the action icons, so the column held its 131px and pushed Delete 5px past the card. Dark mode's 8px scrollbar left just enough room, and macOS (SF, overlay scrollbars) passed, which is why only the light run failed. The row now wraps: the icons stay beside the text while both fit and move onto their own line, right-aligned, when they don't. The decision follows the content's width, not a breakpoint, so it holds at any width and for any font. A name with no break opportunity breaks anywhere instead of holding the column open. The narrow-row spec now also covers 320px and a long unbroken name, and checks that each row's name stays inside the row. Before this change it fails on macOS as well as Linux.
…son, not 'try again' (#4281) A named refusal ({code, message}) is the server declining on purpose, such as the 409 for a schedule whose runs this agent's runtime cannot give, so retrying cannot succeed. The row's error bar now leads with the refusal's own message. Failures with no named refusal (network, 5xx) keep the 'Nothing was changed - try again' headline.
|
Resolve by merging |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4281.
Draft until the manual UI sign-off is given. The Schedules tab's run-tier badge, the take-over review, the Run-now confirm, the share holder's create notice and the restricted-run marker have not been visually accepted in a browser on this branch, in either theme or at phone width. This PR stays a draft until that sign-off.
This replaces #4427, which was stacked on #4425. It carries the same schedule change, on
devalone, without the per-run refusal count: that count reads #4425's guardrail event store, so it lands as its own PR after #4425 merges (#4647). Nothing here imports, migrates or documents #4425's code.0124_execution_continues_execution_id.devat0134633ce; the one conflict was a line inarchitecture/backend.mdwhere both sides added a clause, and both are kept.Why
A schedule is rated by its creator. When the creator is neither an admin nor the agent's owner, every run is a shared person's turn (no shell, no owner-added MCP servers), and nothing said so: not the schedule, not the run, not the hook's message, which told the model the turn was "for a person the agent is shared with". The run still ended
success; the issue's case was 78 hook denials over about 25 hours with every execution readingsuccess. A share holder's schedule could not be fixed in place either: its runs kept the creator's access until someone re-created it.This PR gives one answer to "what tier will this schedule's runs get, and why", shows it on every schedule read and in every refusal, records it on the run, tells the owner once per creator, and lets the owner (or an admin) take the schedule over after reading exactly what it does.
What changes
One run-tier rule, visible on every schedule read
services/turn_tier_service.turn_actorrates the turn as a shared person's turn with no person attached,(share, person, None). Through the existing functions:shell_allowedis False;restricts_standing_workis True, so the agent key's owner-tier, resource and standing-work routes are fenced for the rest of that run; the key's reads narrow to the no-rows id.(share, person, None)is already a value on the wire, so the turn-tier reply contract is unchanged. Live, readable schedules, the no-recorded-creator rule (the owner's) and channel and public-link visitors are unchanged. The stated cost: an owner whose own schedule disappears mid-run loses the shell for the rest of that run.schedule_run_tier(db, agent_name, schedule) -> RunTier(tier, kind, cause, creator_id).turn_actor's schedule branch calls the same tier half and projects it, so the rule does not move; a frozen matrix pinsturn_actor's output, includingdev'sproject_stewardtrigger. A recorded creator is rated through_person_tier, so a registered member creator rates(owner, member, creator)exactly as the member's own turn does.creator_owner_tier,no_recorded_creator,creator_not_owner_tier,agent_has_no_owner,creator_missing,schedule_unreadable,unknown. The cause is total and never raises, is never on the fence path, and answersunknownrather than contradict the tier when two reads of the schedule disagree.creator_not_owner_tierandcreator_missing→take_over;agent_has_no_owner→repair_agent_owner; otherwise none.turn_tier_answer, moved into the service so the router does no execution read) addscause,schedule,creatorandremedyfor a schedule-backed shared turn, all null on any other turn. Labels have control and format characters stripped; the schedule name is cut to 80 characters and the creator label to 64 (display name, else username, anything after@dropped). Worst case ≤2048 bytes.devrates a continuation turn (caller_wake,operator_response,operator_ending,skill_gate; trinity-enterprise#1225) as the turn it continues. The schedule fields and the run stamp now read the same row, throughturn_tier_service.rated_turn, so a continuation of a share holder's schedule run gets the schedule text and is stamped with that run's schedule. A link that cannot be followed names no schedule.ScheduleResponse(list, get, create, PUT), the enable and disable bodies, andGET /api/ops/schedules— carriesruns_as(owner|shared_person| null when it could not be computed),runs_as_reason {code, message},created_by_you,created_byandcan_take_over(a person at owner tier, not the creator,runs_as == shared_person, causecreator_not_owner_tierorcreator_missing).created_byis shown only to the owner tier and to the agent's own key (not while that key acts for a shared person); the creator's id is not exposed. No N+1: a per-requestRunTierLookupsmemo; the fleet read preloads it with two bulk reads (db.get_agent_owners,db.get_users_by_ids) and falls back to per-row reads if they fail.enabled,POST …/enable, a PUT that enables) on an agent whose runtime is not Claude Code is refused with 409schedule_cannot_run_for_creator_on_runtime({code, message, runtime, cause}), because such a run can never start there. Every Claude Code runtime spelling (claude-code,claude) is Claude Code; a Docker fault falls back to Claude Code, so it warns rather than refuses. On Claude Code the schedule is created and flagged.Scheduletype and thelist_agent_schedules/get_agent_scheduledescriptions cover the new fields (pass-through).A refusal caused by a schedule's creator names the schedule
hooks/turn-tier-guard.py).ask_turnreturns(tier, shell, kind, schedule);scheduleis the reply's detail for ashareanswer whosecausematches the event-code shape, withremedykept only if it is a known key. Labels are bounded again on the agent side (80 / 64 characters, non-printable characters replaced, an email's domain dropped).unreachablebranch and before today's branches, which are unchanged. The text keys oncause, never onkind.creator_not_owner_tier), "an account that no longer exists" (creator_missing), "This agent has no owner on record…" (agent_has_no_owner), or a generic line forunknownand any newer cause; what is not available; and "say in your answer that this schedule needs ".schedule_unreadablehas its own text.shell: truestill allows first./logs/guardrails.jsonlcarrycode="schedule_creator_tier"orcode="schedule_unreadable", pluscause=andturn_kind=, throughdev'slib.deny(message, **log_fields).agent_server/services/turn_scope.py), the refusal path for runtimes other than Claude Code:fetch_turnreturns the same 4-tuple andrequire_owner_tieruses the schedule texts when there is a detail; neither mentions switching runtime. Status 403 anderror_code: turn_refusedare unchanged.take_over,recreate,repair_agent_owner, and a fallback.causegets today's four hook texts and today's refusals byte for byte (pinned literally). Six runtime test files that stubturn_scope.fetch_turngain the fourth element./logs/guardrails.jsonlreaches Vector: the file stays in the container, and Vector reads container stdout and stderr only.A restricted run is recorded on the run and raised to the owner once per creator
apply_resultrates the run once, before either branch, throughschedule_tier_alerts.run_restriction_by_id(which usesturn_tier_service.schedule_backed_run_tier: the same "schedule-backed" testturn_actorapplies, thenschedule_run_tier). A run whose tier is not owner writesturn_integrity.restricted_turn = {tier, kind, cause, schedule_id, creator_id, shell: false}into the existing Background task killed at CLI exit leaves no trace — execution records clean success while the work is lost #2467 column, merged beside the Background task killed at CLI exit leaves no trace — execution records clean success while the work is lost #2467 keys. The rating is total: a lookup that raises records nothing and never changes the outcome. Success and failure branches are both stamped (a refused run on another runtime is a failure), and so are the pull sink's two writes. Owner-tier and non-schedule runs write exactly what they wrote before; a manual "Run now" carries its clicker and is not stamped. No status change.schedule_runs_restricted(priority medium) on the existing seam: one operator-queue row per agent × creator, subjectschedule_runs_restricted:<creator id>. Its text names the creator (display name, else username; "an account that no longer exists" for a missing one), the cause, the remedy and up to 5 schedule names; its context carries ids and codes only (≤20 schedule ids plus a count).causeis the only material key, and a person's ending is final. The id prefix is reserved (an agent cannot pre-create the row), and the row is owner-only and about a person: the owner and admins see it; other share holders, the creator and every machine key do not.operator_queue_service/__init__.pystays at its 800-line threshold.schedule_tier_alerts.sync(agent, creator_id): it reads that creator's live, enabled schedules on the agent and rates them in one memo; any shared-person schedule observes the row, none clears it. A rating that raises, or a set whose every cause isunknown, decides nothing, so a transient lookup failure never re-files a row a person ended. It never raises./api/internal/execute-taskafter the idempotency gate (so a replay does not sync); andapply_resulton the status-CAS-winning branch only. Re-reading the live schedules is what makes a run that ends after a disable file nothing. Rows go with the agent (operator_queueCASCADE) and follow a rename. No background loop, so one reading has one writer; racing readings meet the seam's per-agent lock and partial unique index. An existing restricted schedule is flagged at its next write or dispatch; there is no sweep at boot.The owner takes a share holder's schedule over in place
POST /api/agents/{name}/schedules/{schedule_id}/take-over(take_over_schedule).require_person(agent, system and connector keys and the loopback get 403person_required) plusOwnedAgent(owner or admin, uniform 404); a Workspace-only person is refused at the operator floor.{expected_updated_at, reviewed: {message, allowed_tools, model, validation_enabled, validation_prompt}, delivery?: "clear"|"keep", keep_delivery_to?}; everyreviewedfield is required and echoed from the read.db.reassign_schedule_creatorcomparesowner_id,updated_at(as an instant), every reviewed field and the delivery, then makes one UPDATE whoseWHEREpins every one of those columns (IS NOT DISTINCT FROM),deleted_at IS NULLand the absence of aqueued/running/pending_retryrun of the schedule. Zero rows → 409schedule_run_in_progress,schedule_changed_since_reviewor 404schedule_not_found. The same UPDATE sets the new creator, revokes the schedule's webhook and clears the delivery when asked. Already the creator → 200, no write. Rated owner tier → 409schedule_not_restricted. A rating that raises propagates (500), so a schedule that cannot be rated is never changed.clear, orkeepwithkeep_delivery_torepeating the address (trimmed, case-insensitive); otherwise 409schedule_delivers_to_another_personnaming it.update_scheduleanddelete_scheduleaddowner_id = <caller>for a non-admin, and a share-tier webhook mint is bound to the creator (a 0-row mint is 403webhook_owner_or_creator), so a former creator's in-flight write cannot land after a take-over.schedule_runs_as_shared_personbefore the scheduler is called.trigger_agent_schedulereportsalready_runningonly for the real running-lock 409 ({"detail": "Schedule is already executing"}); any other 409 reaches the calling agent as{status: "refused", code, message, retryable: false}with the backend's code and message. The backend's scheduler relay likewise passes the lock text only for the scheduler'salready_runningand otherwise relays{code, message}(scheduler_conflictwhen the scheduler sent no code).schedule_taken_overwith the schedule, both creator ids, webhook revoked and delivery cleared.agent_route_tiers.jsonlists the route as owner tier with standing work;routers/schedules.pygains its first-line# mcp:header (take-over is a human-only grant, refused to agent keys);test_ent164_self_change_grants.pyclassifies the route as person-only.The Schedules tab shows the run tier, offers take-over and marks a restricted run
runs_as === 'shared_person'(ownerandnullshow nothing;nullmeans "not computed" and never reads as owner), with the server's reason and a creator line (created_by, else "You created this schedule"). The title row wraps, so the badge does not push the action icons off a 390 px screen.can_take_over === true) opensScheduleTakeOverDialog.vueon a deep copy of the read, so a list refetch while it is open cannot change what is sent. It shows the full prompt, allowed tools, model, validation and its prompt, the Workspace delivery, the webhook state (live, none, or "couldn't read; taking over revokes any webhook URL either way") and what the creator loses.stores/schedules.js→utils/scheduleRunTier.js::takeOverBody) echoes the reviewed copy verbatim, withclearorkeep+ the address for another person's delivery; with no decision it throws rather than send an undecided request.can_take_over. Backdrop and Esc are blocked while the request is in flight.schedule_changed_since_review,schedule_not_restricted,schedule_delivers_to_another_person, or the schedule deleted — reloads the list and shows the current version (or disables Confirm when nothing is left to adopt); if that reload fails, the dialog says so instead of presenting the old version as current. Each code has words; a raw code is never shown. For a creator account that no longer exists, the review says so.apiErrorMessage) instead of the raw object.RestrictedRunMarker.vue, badge or line, each surface with its own requiredtestid) on the Schedules history and execution modal, the Tasks list and the execution page, read fromturn_integrity.restricted_turnwith a sentence by cause. A malformed record or an inherited key (toString,constructor) renders nothing rather than throwing in a list.{code, message}, such as the 409 above on enable), the row's error bar leads with that message instead of "Nothing was changed — try again", since retrying cannot succeed. Failures with no named refusal (network, 5xx) keep the old headline and their technical detail.ownerTierprop onSchedulesPanelfromagent.can_share(the flag the owner-only tabs use), defaulting to true so no false warning appears. Design-system tokens only; the ratchets are unchanged.Docs
requirements/auth.md§2.12 and §2.12.1 (the run tier, the refusal texts, continuations, the stamp and alert, take-over, the UI) andrequirements/scheduling.md;architecture/security.md§5g,api-endpoints.md,backend.md,execution.md,frontend.mdandmcp-server.md; the operating-room, scheduling, task-execution, Tasks-tab and execution-detail feature flows and a row in the feature-flows index; the user docautomation/scheduling.md.Tests
test_ent926_turn_tier.pyreplaces the two tests that covered the unreadable-schedule rows withtest_a_schedule_backed_turn_whose_schedule_cannot_be_read_is_never_owner_capable(15 cases) andtest_the_route_answers_no_shell_for_a_turn_whose_schedule_cannot_be_read(3, with a channel-visitor control);test_ent926_agent_key_turn_scope.pyaddstest_a_schedule_backed_turn_whose_schedule_cannot_be_read_is_fenced_through_auth(2). Newtest_4281_turn_actor_frozen_matrix.py(rows ×visitor_shellon/off over a spec'd fake that mirrors the real joins),test_4281_schedule_run_tier.pyandtest_4281_schedule_read_fields.py(real routers,get_current_user, JWTs and an agent key on the unit SQLite: the cause per row, the disclosure rules, the runtime refusal, query counts — a 20-row list costs what a 2-row list does, the fleet read the same on 3 and 30 agents — and a member creator).test_ent926_turn_tier_hook.pyandtest_ent926_runtime_turn_scope.pygain each cause (includingschedule_unreadablefed with bothkind: personandkind: visitor, proving the text keys oncause), the deny record'scodeandturn_kind, the shell-allowed guard, the label bounds and the hook/agent-server table parity.test_4281_restricted_run_stamp.py(the realapply_resultand the pull sink on the unit SQLite) andtest_4281_restricted_schedule_condition.py(the real schedules, ops and operator-queue routers, the internal handler, real JWTs and agent key, the real seam; four threads behind a barrier callingsync→ exactly one row; a failing alert never failing a committed write; the take-over cases). Edited guards:test_2372_platform_alert_ack.py(the prefix is reserved) andtest_3254_unended_kinds.py(the final kinds).test_4281_restricted_run_stamp.pyaddstest_a_continuation_of_a_restricted_run_gets_the_schedule_text(×4, one per continuation trigger: the answer equals the continued run's),test_a_continuation_of_a_restricted_run_is_stamped(through the realapply_result, naming the continued run's schedule), and three controls: a continuation of an owner-tier run, of a person's chat, and of a turn that cannot be read. Red before the fix: 5 failed, 24 passed (the three controls among the passes).test_4281_schedule_take_over.py(61; only the scheduler hop and the audit sink replaced): the edited prompt after the review, a prompt changed without touchingupdated_at, each echoed field differing, and a write landing between the snapshot and the UPDATE (each 409, the new prompt not adopted); the delivery rules; the bound creator writes, each race test asserting that its hook fired inside the targeted DB method — the race tests patch the module dict the livedbmethod resolves its globals in, so they hold after a test that evictssys.modulesentries (test_1595first: 2 failed before, 72 passed after); Run now for agent and system keys; the relay's three conflict shapes; the lock detail pinned to the MCP server's constant. Newsrc/mcp-server/src/tools/schedules.trigger-conflict.test.ts(7).scheduleRunTier4281.spec.js,schedulesPanelRunTier4281.mount.spec.js(mounts the realSchedulesPanel),restrictedRunMarker4281.mount.spec.js(the marker plus the realTasksPanelandExecutionDetail).Validation on this branch, after merging
devat0134633ce(macOS, Python 3.12, backend tests in fixed order unless a seed is named):test_1595_*,test_ent1225_continuation_tier.py,test_ent926_turn_tier*.py, and the 18 test filesdevchanged since the branch was first cut): 2318 passed, 39 failed. The same files on untoucheddev(38 present; the six new A schedule created by a non-owner-tier person silently loses the shell on every run, and the run still reports success #4281 files are absent there): 1908 passed, 39 failed. The 39 are the same ids on both trees, all intest_ent926_turn_tier_hook.py: on macOS/homeresolves under/System/Volumes/Data, so the path rules never match. Nothing fails only on this branch.test_ent926_turn_tier_hook.pypasses in full (167), the 39 included. Fourtest_ent986cases failed only because that container had nogitbinary; they pass on macOS.test_1595_sync_health_signals.py,test_ent1225_continuation_tier.pyandtest_ent926_turn_tier.py: 485 passed each.8a4a5b654ondev7767f4f2b), a wider set of 256 files (every test that reads the route census, the turn-tier world,turn_tier_service, the schedules router, the route tiers, the operator queue, platform alerts or the other touched services): every failure ondevalso failed on the branch; the only extra failures were intest_ent926_turn_tier_hook.py, the macOS class above, which a cross-file interaction on macOS enlarges on both trees.npm run test:unit: 552 files, 8238 tests passed (the three A schedule created by a non-owner-tier person silently loses the shell on every run, and the run still reports success #4281 specs and the raw-colour and loading-gate ratchets included).npm test: 1473 passed;tsc --noEmitclean.scripts/ci/check_alembic_heads.py: 125 revisions, 1 head (0124_execution_continues_execution_id), PASS.check_alembic_parity.py: pass (no schema change).check_sqlite_upgrade_parity.pyfrom0134633ce: PASS.test_schema_parity.py,test_alembic_parity_guard.py,test_sqlite_upgrade_parity_guard.py: 59 passed (the same 59 ondev).tests/lint_sys_modules.py: no new violations.ruff check --select Fon the 48 changed Python files: no finding thatdevdoes not already have.python-code-scanningsuite, the 48 changed Python files against the same paths ondev): 0 results on both. The same setup run onguard002-smoke.pyas it was before feat(guardrails): guardrail events reach the platform with fleet counts, and credentials in tool output are hidden from the model (abilityai/trinity-enterprise#165) #4425's68bb9cd82reportspy/clear-text-storage-sensitive-dataat line 203, the finding fix(schedules): a schedule says what tier its runs get, the owner can take it over, and a restricted run is named, marked, alerted and counted (#4281) #4427 carried, so the run can see that class. This PR does not touchguard002-smoke.py(identical todev).Mutation: the continuation fix was written test-first:
test_a_continuation_of_a_restricted_run_gets_the_schedule_text×4 andtest_a_continuation_of_a_restricted_run_is_stampedare red without it (the answer'scauseis null; the run carries no stamp) and green with it. A first version of the fix that read the continued run for the rating but not for the record'sschedule_idstamped__manual__, andtest_a_continuation_of_a_restricted_run_is_stampedcaught it. The rest of the change's tests were mutation-checked when it was first built: withturn_tier_service.pyrestored to the base, the 20 new run-tier cases go red; with the hook andturn_scope.pyrestored and the new tests kept, 44 fail on the behaviour (the 22 that pass are the skew guards); the stamp, alert, take-over and UI tests were red on the base. Those mutation runs were not repeated on this branch.Unverified: the manual UI sign-off (pending, below); the full unit suite and the CI matrix (CI); CodeQL over the whole tree and over JavaScript/TypeScript (CI's CodeQL is the check; the local run covered the changed Python files only); PostgreSQL-parametrized unit tests for
get_agent_owners,get_users_by_ids,reassign_schedule_creatorand the bound creator writes; a live stack on this branch (see below); an agent image from this PR against a backend without the run-tier answer fields (the byte-for-byte skew is pinned by unit tests); a continuation of a restricted run end to end on a live stack (unit-tested through the realapply_resultonly).Earlier live run
The change was run on a production-image stack (PostgreSQL 16, Redis with ACL users, two backend workers, real agent containers on Claude Code CLI 2.1.281) when it was first built, on a tree that also held #4425's change. It has not been re-run on this branch. What that run showed, for the parts this PR keeps:
runs_as: shared_personandcreated_by: nullin their own view; the owner's view showedcreated_by;/api/ops/schedulesand MCPlist_agent_schedules(user key) carried the fields. During a share holder's cron run the turn-tier answer carriedcause: creator_not_owner_tier, the schedule name, the creator label and the remedy, in 142 bytes. For a schedule-backed run whose schedule could no longer be read, the turn-tier route answered{"tier":"share","kind":"person","shell":false,"cause":"schedule_unreadable",…}and the agent key got 403 on an owner-tier route during that run. On a Gemini agent an enabled create and a switch-on were refused 409schedule_cannot_run_for_creator_on_runtime; the same create on a Claude Code agent was 201.Write ~/CLAUDE.mdwere refused with "This run is the scheduled task 'p-sched-1', not a chat …", naming the creator; none said "shared with". A Gemini agent's share-rated cron run failed with the schedule, creator and take-over text. An owner chat or task kept the shell; a shared person's chat still got the "shared with" text.successwithturn_integrity.restricted_turn.cause = creator_not_owner_tier; the owner's own schedule run keptturn_integritynull. Disabling both schedules ended the row; re-enabling filed a new one; an admin's pause and resume did the same.can_take_over: truefor the owner; take-over → 200,runs_as: owner, webhook revoked; an agent key → 403person_required. REST Run now with the agent key and the system key → 409schedule_runs_as_shared_person; MCPtrigger_agent_schedulewith the agent key →{"status":"refused","code":"schedule_runs_as_shared_person",…,"retryable":false}.reassign_schedule_creator's outcomes and the share holder's update, delete and webhook mint ran on PostgreSQL. Take-over ended the alert row; taking one of two schedules kept the row for the other. An edit between open and confirm → 409schedule_changed_since_review; an in-flight run → 409schedule_run_in_progress; a deleted schedule → 404; a delivery to the share holder's Workspace → 409schedule_delivers_to_another_person, thenclear→ 200.Pending
Unfiled follow-ups
runs_as: ownerwith causecreator_owner_tier, whose message says "created by the agent's owner or an admin" — the tier is right, the text is not.turn_tier_answerreads the schedule twice per hook call — one read would save a query on every guarded tool call of a shared-person schedule run.recreateremedy entries in the hook, the agent server and the alert texts are never sent by the backend now that the remedy istake_over.contextis built and then dropped before the scheduler call (routers/webhooks.py).OWNER_ONLY/SEARCH_OWNER_ONLYsay "a person the agent is shared with" to a channel visitor whose path is denied — predates this PR.routers/admin_recovery.pyrecover_schedule) does not decide the alert — it heals at the next dispatch.syncthat read before a disable can file after the disable's clear — the row then stays until the next write for that creator.person_ending_is_finalconsults only the newest person ending per subject, and retention prunes final endings — shared by every final kind on the seam.get_executionper terminal on every run, schedule or not (cost nit).already_runningonly fires inside the short dispatch window (src/scheduleris unchanged here).already_running(routers/webhooks.py).userkeys._is_personin the schedules router duplicates the person half ofdependencies.person_or_capability_admits.SchedulesPanel.vuestill makes its other calls through raw axios (predates this PR).test_ent926_agent_key_turn_scope.pydefinestest_an_unreadable_ledger_fails_closedtwice, so the first definition never runs — predates this PR.Type of Change
Checklist
git commit -s) — required for contributors outside the core teamJourney Impact
Journey Impact: extends: J05