Skip to content

Resolve app-scope schedules by name in configure and run now - #56

Merged
shuv1337 merged 1 commit into
v2from
shuv/schedule-scope-20261022
Oct 23, 2026
Merged

shuv1337 merged 1 commit into
v2from
shuv/schedule-scope-20261022

Conversation

@shuv1337

Copy link
Copy Markdown
Owner

Post-cutover backlog, item (b):

  • schedules.runNow had no scope, so it returned ScheduleNotFound for app-scope schedules.
  • schedules.configure defaulted to user scope, which surprised Desk, whose schedules are app-scope.

Cause

The hosted and local route handlers chose the scope themselves:

  • runNow always looked up the caller's own copy.
  • configure used user scope unless scope was exactly "app".

Change

  • runNow takes an optional ?scope=app|user. It's a query parameter because existing callers send no body.
  • Scope resolution when omitted, in both configure and runNow, via a new SDK operation schedules.scope (GET /v1/apps/:app/schedules/:name/scope):
    1. If an app schedule and the caller's own copy are both saved under the name, it refuses with a new typed ScheduleScopeRequired (409) asking for scope. It never guesses.
    2. If only one is saved, that one is used.
    3. If neither is saved, it checks the app's declaration using only the app's linked accounts: app-declared means app; anything else falls back to user, the old behaviour.
  • Authorization is unchanged for each scope. App scope still requires app-manager rights. On hosted, the scope is only resolved for callers who can read the app; anyone else keeps the old user default.
  • Local uses the same resolution.
  • Docs: tool descriptions (hosted and local), the app-authoring workflows.md skill and its digest, error messages in both web apps, and a changeset.

Behaviour change: configure without a scope on an app-declared schedule now reaches the app schedule. A caller who doesn't manage the app gets 403 there, where they used to get 404 or an account error.

Tests

  • New hosted scenario hostedAppScheduleScope (self-host and Cloud):

    • user-scope configure and runNow with no scope;
    • configure with no scope reaching the app schedule;
    • runNow with and without scope=app;
    • scope=user returning 404 for someone with no copy;
    • a member getting 403 on app scope;
    • ScheduleScopeRequired when the names collide;
    • explicit scope=user still working.

    With resolution forced back to user scope, it fails as expected.

  • Extended local scenario localAppScheduleAppLinks covers the same paths on the local server.

  • Results: self-host 7 of 7 and local 4 of 4, including the existing hosted and local schedule scenarios. Cloud runs after merge.

  • bun run check passes.

app-schedules.spec.ts
local-app-account-app-links.spec.ts
hosted-schedules.spec.ts
hosted-account-scheduling.spec.ts
local-schedules.spec.ts
local-schedule-runs.spec.ts
local-schedule-accounts.spec.ts
app-accounts-tab.spec.ts

Run now looked a schedule up only in the caller's user scope, so an app
schedule was ScheduleNotFound, and configure without a scope always
targeted the caller's copy. Run now now takes an optional scope query, and
both routes resolve a missing scope through the SDK's new schedules.scope:
the schedule saved under the name, else the app's declaration evaluated as
the app schedule runs, else user. Both saved under the name fails with the
new ScheduleScopeRequired. App-scope authorization is unchanged (managers
only); hosted resolves only for callers who can read the app.
@shuv1337
shuv1337 merged commit cff076a into v2 Oct 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant