Skip to content

Phase 2, Slice 3: Scheduled runs — A scheduled run calls gateway tools on its own grant, with no one present #2569

Open

Description

@ChrisJBurns

Depends on: #2729 (phase 1: a scheduled run lists gateway tools with the grant its session holds)
Removes shortcut:

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

Scope

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_owned for another owner's setup
    • the horizon capped at AS-1's maximum
    • schedule_ended after 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

  1. changed the title [-]Scheduled runs: schedule grants[/-] [+]Phase 2, Slice 3: Scheduled runs — A scheduled run calls gateway tools on its own grant, with no one present[/+] on Nov 18, 2026
  2. ChrisJBurns commented on Nov 18, 2026

    @ChrisJBurns
    ContributorAuthor

    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.

  3. ChrisJBurns commented on Nov 18, 2026

    @ChrisJBurns
    ContributorAuthor

    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.

  4. rdimitrov commented on Nov 20, 2026

    @rdimitrov
    Member

    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 (rootedRunContext in internal/adapter/server/service.go). The code marks this as a shortcut that this ticket removes. Points for this ticket:

    • The run owner. A scheduled run's run owner is the owner recorded with the schedule grant (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.
    • Helpers in a scheduled run. They are delegated from the scheduled run as from any other run. Nothing new is needed, but the slice test should include one helper gateway call.
    • Ending the run. EndScheduledRun closes the broker session, which drops that session's run and delegation records. A delegation outliving the run is refused, as intended.
  5. rdimitrov commented on Nov 25, 2026

    @rdimitrov
    Member

    #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).

  6. rdimitrov commented on Nov 25, 2026

    @rdimitrov
    Member

    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").

  7. rdimitrov commented on Nov 26, 2026

    @rdimitrov
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions