Repository navigation
Description
Depends on: #2729 (phase 1: a scheduled run lists gateway tools with the grant its session holds)
Removes shortcut:
- Scheduled runs have no grant of their own, so their gateway calls fail closed (Phase 1: Signed-in users' agents call gateway tools with their own access #2451)
- A scheduled run's owner is its session's owner, the schedule's captured owner, recorded when the run starts (
newRunOwner), rather than the owner recorded with its schedule grant (Record an interactive run's owner from the request that starts it #2947)
Adds shortcut: - Schedule grants are held in memory. Removed by Durable broker state and recovery #2563.
- Deleting or revoking a schedule drops its grants at the broker but does not revoke them at AS-1, and signing out everywhere does not end them. Removed by Sign-out and revocation #2568.
- A lapsed or revoked schedule's run fails closed without the "needs owner action" outcome (
mcp_owner_action_required). Removed by Sign-out and revocation #2568. - A run longer than AS-1's ID-JAG cap loses gateway access partway through. Removed by Sign-out and revocation #2568, which decides whether a run's child grant needs its own cap.
Problem
A scheduled run happens with no one present, so it has no sign-in to open its broker session. A session's refresh token also ends when that session closes. Today every scheduled run, timer or manual, opens a broker session with no grant, so its gateway calls fail closed.
Implements
- credentials-and-lifecycle.md: Scheduled runs
- credentials-and-lifecycle.md: Schedule setup
- credentials-and-lifecycle.md: Scheduled-run session open: the owner check, AS-1 checks 1–4 and the failure table
- credentials-and-lifecycle.md: Error reasons:
schedule_ended,owner_action_requiredand the scheduled-run rule - credentials-and-lifecycle.md: Lifetimes and renewal: the schedule grant row
- credentials-and-lifecycle.md: Configuration: the horizon cap
- implementation.md: Grant record: the broker grant record for a schedule
- implementation.md: Session ownership and isolation: owner attribution for scheduled runs
Scope
- Definition: a schedule records the reference (source, name, revision) of the definition it runs, and each run's root instance registers with it (docs(agent-identity): keep a re-registered instance's revision, and pin a schedule's definition #2866). This adds a definition to the engine's schedule spec and the schedule-creation API.
- Setup: the broker stores the schedule grant in memory, behind a small store interface. Connectors are connected at setup through the connect link from "Connect provider accounts at the embedded gateway" (Connect provider accounts at the embedded gateway #2537), while the user is present: the provider connection.
- Broker calls: a handle per schedule, plus calls to set up, renew and revoke a schedule. Durable broker state and recovery #2563 and Sign-out and revocation #2568 keep this interface and add only storage, retries and revocation at AS-1.
- Runs: each run, timer or manual, opens its session from the schedule grant and closes it when the run ends.
- Horizon cap: AS-1's maximum for grants that issue refresh tokens, on the
mecatlclient. It is at most 720h, with a documented default, and is never taken from the ID-JAG cap (Identity broker settings #2813). - Uses ToolHive child grants (Refresh tokens through token exchange, as generic grants toolhive#6897, released in v0.62.0).
- Marking scheduled runs in the audit records is Audit records mark scheduled runs #2843.
- The interface additions are listed when the slice starts.
- This ticket supersedes Run scheduled tasks with bounded, revocable user authority #373. Run scheduled tasks with bounded, revocable user authority #373's criteria apply, with the schedule grant as the mechanism:
- An expired or revoked schedule never runs under a service or ownerless identity, and the run names the reason.
- A schedule cannot run as a different agent, integration or target, or with broader operations, than the one set up.
- Manual runs and timer runs take the same authority path.
- Provider credentials never enter Mecatl state or model-visible output.
- The model cannot create or change the consent setup.
- API compatibility: the PR includes the wire API compatibility statement.
Decide before starting
- Who notifies the owner to renew before the horizon, and who reconnects lapsed connections at renewal? The design requires both; the owner is either this ticket or Sign-out and revocation #2568.
Done when
-
A user sets up a schedule while signed in. Later, with no one present, each run opens its session from the schedule's grant and calls gateway tools as that user. A schedule can be renewed and revoked through the broker. The run of a revoked or expired schedule fails closed.
-
The run-open failures behave as specified, including:
- refusal past the horizon
session_ownedfor another owner's setup- the horizon capped at AS-1's maximum
schedule_endedafter deletion- renewal leaving runs from the old grant running
Stopping a running run on deletion (
parent_revoked) is Sign-out and revocation #2568's. -
Each Run scheduled tasks with bounded, revocable user authority #373 criterion has a test.
-
A horizon longer than the ID-JAG cap keeps runs going until the horizon. Each run's child grant expires no later than the earlier of the ID-JAG cap and the schedule grant.
Earlier notes: #2850 (closed, merged here).
Activity
[-]Scheduled runs: schedule grants[/-][+]Phase 2, Slice 3: Scheduled runs — A scheduled run calls gateway tools on its own grant, with no one present[/+]ChrisJBurns commentedon Nov 18, 2026
Design decision for this ticket: Does a schedule record the agent definition it runs, so each run registers its main agent with it? Schedule setup records only the schedule, its owner, and the source
jti, and a schedule cannot name a definition today. #2842's limit for scheduled runs and #373's "cannot run as a different agent" depend on the answer.Where it goes: credentials-and-lifecycle.md: Schedule setup.
Decide it when this ticket is picked up, and record the answer as a small design edit (reviewed by the design's author) before or with the ticket's first PR.
ChrisJBurns commentedon Nov 18, 2026
Decided: a schedule records the reference (source, name, and revision) of the definition it runs; each run's root instance registers with it, and running a newer revision needs a renewal while the owner is present. Recorded in design PR #2866.
refactor(identitybroker): tidy run checks after review
rdimitrov commentedon Nov 20, 2026
Run owner for scheduled runs after #2557
#2557 (PR #2930) checks every gateway call's run owner against the owner recorded with the grant. For now mecak8s reads the run owner from the session at each run entry (
rootedRunContextininternal/adapter/server/service.go). The code marks this as a shortcut that this ticket removes. Points for this ticket:run-owner.md, "The run owner"; Runs, delegations, and the run owner #2557's requirements). Once runs open from the schedule grant, set the run's owner from that grant and remove the shortcut. The broker already refuses a call whose run owner isn't the grant's owner, so a mismatch fails closed.EndScheduledRuncloses the broker session, which drops that session's run and delegation records. A delegation outliving the run is refused, as intended.rdimitrov commentedon Nov 25, 2026
#2985's grant provenance (
heldGrant.user, the open record reference,OpenKind) knows only session opens. A scheduled run's records need a typed reference to the schedule-setup record instead, so none presents the saved owner as a fresh sign-in (#2843).rdimitrov commentedon Nov 25, 2026
From #2984's write order: schedule setup waits for its record and fails as a converted session open when the sink does not accept it (nothing stored, the client refreshes). A scheduled run's open retries once as for a lost response; if the record is still not accepted, the run does not start and its fire fails as a retryable infrastructure error (
credentials-and-lifecycle.md, "Scheduled-run session open", "Failures").rdimitrov commentedon Nov 26, 2026
Correction to my earlier note: a scheduled run's open that cannot be recorded no longer "fails as a retryable infrastructure error". After #3000, the broker retries the open once; if the record is still not accepted, the run does not start, and the schedule's next fire runs as usual. What else such a fire does, and whether it is retried before the next fire, are left to #2843.