Skip to content

⏳ feat: End the Exemption of Schedules Their Owner Never Authorized - #18274

Merged
danny-avila merged 2 commits into
devfrom
danny-avila/consent-legacy-deadline
Nov 18, 2026
Merged

danny-avila merged 2 commits into
devfrom
danny-avila/consent-legacy-deadline

Conversation

@danny-avila

@danny-avila danny-avila commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

With interface.schedules.mcpConsent.enabled on, a scheduled chat is restricted to the MCP tools its owner allowed only if the owner opened the authorization dialog and confirmed. A schedule nobody confirmed keeps using every MCP tool its agent has, unattended, indefinitely. That covers schedules created before consent existed and every schedule created since, so turning consent on changes nothing until each owner acts.

This PR ends that exemption in two ways:

  • When the owner edits the schedule. Any edit other than pausing or resuming it marks the schedule as needing authorization.
  • When an operator deadline passes. interface.schedules.mcpConsent.requireAfter takes an ISO 8601 instant. Unset, there is no deadline and today's behaviour is unchanged.

From then on each MCP call of that schedule is refused with consent_missing, both at the readiness check and in a run, until the owner confirms. The run itself still starts, so a schedule that uses no MCP tools is unaffected. Nothing changes where consent is off.

The authorization dialog tells the owner which of the two applies, and a refused run now tells the owner to authorize the schedule where it used to say "Reconnect this MCP server".

Fifth step of the unattended-authority work, after #18058, #18255, #18260 and #18273. Related to #13824 and #16157.

How it works

interface:
  schedules:
    mcpConsent:
      enabled: true
      requireAfter: '2027-01-01T00:00:00Z'   # new; an instant with an offset
PATCH /api/schedules/:id                       # packages/api/src/schedules/handlers.ts
  consent on, no grant, edit is more than `enabled`
    -> $set mcpConsentRequired: true           # new Schedule field, never sent to the client

MCP call of a schedule with no grant           # authorization/execution.ts
  checkEnrollment()                            # unchanged
  requiresGrant(identity)                      # new; asked at the first MCP call, kept for the run
    consent on AND (mcpConsentRequired OR now >= requireAfter)   -> consent_missing
GET /api/schedules/:id/mcp-consent
  required        true when the schedule's MCP tools are refused until confirmed   # new
  requireAfterMs  the deadline, while it is still ahead and nothing is required    # new

Both the per-fire readiness check and a run resolve a schedule's authority through createScheduleMCPExecution, so the rule lives there once. It is evaluated lazily: a scheduled run that calls no MCP tool reads nothing extra, and one that does reads the owner and config once.

A lookup that fails is not treated as permission. The call is refused with dependency_unavailable and the next call looks again.

The question is asked with the configuration read fail-closed. The config service falls back to the deployment's base when it cannot read a tenant, role or user override, and the base may not require consent at all; asked fail-closed, that outage refuses the call instead of lifting the requirement.

The mark is not cleared by a grant; a schedule that has a grant is never asked the question. Revoking the grant is refused as consent_revoked, as before.

Type of change

  • Feature

Testing

Tested environments/configuration: WSL2, Node.js 24. Storage tests run against mongodb-memory-server. No external services.

Automated tests:

  • packages/api/src/schedules/authorization/runtime.spec.ts (a schedule its owner never authorized), through the real runtime host, limits resolver and readiness check: runs with no deadline and before one; refused from the deadline on, at readiness and in a run; refused once edited; left alone where consent is off; runs again once the owner confirms; the lookup happens once per run and not at all for a run with no MCP call; a failed lookup refuses the call without leaking the error, and the next call looks again; the configuration is read fail-closed, so an override outage cannot lift the requirement.
  • packages/api/src/schedules/authorization/service.spec.ts: only a schedule with no grant is ever "required".
  • packages/api/src/schedules/handlers.spec.ts: the mark is written on an edit; not on a pause or resume, not where consent is off or absent, not for a schedule that has a grant or is already marked; it is never sent to the client.
  • packages/data-schemas/src/methods/scheduleConsent.spec.ts: the mark persists through the fenced update and is reported in the consent snapshot.
  • packages/data-provider/src/types/scheduleConsent.spec.ts: requireAfter accepts an instant with an offset and rejects a bare date, a local time and a number.
  • client/src/components/SidePanel/Schedules/__tests__/Consent.spec.tsx: the dialog shows the deadline note, the refused note, or neither.
  • client/src/components/SidePanel/Schedules/__tests__/errors.spec.ts: a missing, expired, revoked or stale grant points the owner at the authorization dialog and no longer offers "Open agent to reconnect"; a rejected credential still does.

Each condition was broken in turn and a test confirmed to fail.

npx tsc --noEmit is clean in packages/api, packages/data-schemas, packages/data-provider and client.

Screenshots / recordings

The real Consent component under the app's stylesheet in Chromium, fed fixed consent data in place of the API. "Before" is the component from #18273 for the same schedule. The Cancel button shows its key because the capture does not initialise the shared package's i18n; the app does.

Before (#18273) Deadline ahead Refused until confirmed
before deadline ahead refused, light

Dark:

refused, dark

Risk / compatibility

Default is unchanged for the deadline. With requireAfter unset no schedule is stopped by date.

The edit rule applies as soon as this ships wherever consent is on. An owner who edits a never-authorized schedule will see its next run refuse MCP tools until they confirm. The edit itself succeeds; the readiness check that runs during the edit still sees the schedule as exempt.

A schedule that cannot be authorized stays stopped. If its agent uses an MCP server the operator has not declared under mcpConsent.resources, there is nothing to confirm. Declare every server scheduled agents rely on before setting the date. This is documented in packages/api/src/schedules/README.md.

New schedules are not marked at creation. A schedule created after this ships is exempt until its first edit or the deadline. Requiring authorization at creation needs a create flow that saves the schedule before it can be enabled, which I left out of this PR.

Mixed versions: a replica without this change ignores the mark and the deadline and keeps running such schedules unrestricted, which is today's behaviour.

The status line "Authorization required" for a schedule with no grant predates this PR and still shows when nothing is required yet.

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review 0e9e942

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e9e942832

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const { consent } = createEvaluation(deps.enrollment);
const execution = createScheduleMCPExecution({
storage: deps.methods,
requiresGrant: consent.service.requiresGrant,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve consent requirements with fail-closed configuration

When consent or its deadline is configured through a tenant/role/user override, an override-store failure can let an unauthorized schedule execute MCP tools. This callback uses the host created by createEvaluation, whose limits resolver calls enrollment.getAppConfig(options) without failClosed: true. The production config service catches override-resolution failures and returns the base config (packages/api/src/app/service.ts:1145–1148), potentially removing the consent requirement. requiresGrant then returns false and caches that permission for the run. Unlike the enrolled authorization path immediately below, this path never requests fail-closed configuration. Pass failClosed: true when resolving these limits so a lookup failure becomes dependency_unavailable rather than unrestricted access.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5c82336. requiresGrant is now taken from an evaluation whose getAppConfig always passes failClosed: true (createScheduleMCPRuntimeHost in packages/api/src/schedules/authorization/runtime.ts), so an override store that cannot be read throws instead of handing back the base configuration. The execution already turns a failed lookup into dependency_unavailable and asks again at the next call, so the outage refuses the MCP call instead of lifting the requirement.

Evidence: runtime.spec.ts › a schedule its owner never authorized › "reads the configuration fail-closed, so an override outage cannot lift the requirement". Passing the plain evaluation's requiresGrant again makes it fail.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T15:32:38.794120Z 5c82336 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from danny-avila/consent-definition-pins to dev November 18, 2026 15:21
@danny-avila
danny-avila force-pushed the danny-avila/consent-legacy-deadline branch from 0e9e942 to 5c82336 Compare November 18, 2026 15:30
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review 5c82336

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 5c823360de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila marked this pull request as ready for review November 18, 2026 15:47
@danny-avila

Copy link
Copy Markdown
Collaborator Author

/quality risk scopes=api

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Quality report

Gate: open. The selected checks completed. Scores and risk levels are advisory.

Status: completed (success). Actions run, attempt 1.

  • Commit: 5c823360de81d05c429f9bca157e8b072231f426
  • Requested by: @danny-avila
  • Check: risk
  • Scopes: api
  • Static mutants: off (not used by change risk)
  • Change risk: api
  • Mutation testing (experimental, data-schemas only): none

Change risk

Takeaway: 4 changed lines have no test. Highest CRAP among changed functions: updateSchedule at packages/api/src/schedules/handlers.ts:904, CRAP 151.4 with 73% coverage.

Workspace Files measured Incomplete Unavailable Changed lines with no test Highest CRAP
api 7 of 7 0 0 4 151.4

Changed lines with no test

packages/api/src/schedules/authorization/service.ts: 4 lines (api)

Lines 320-321

          required,
          requireAfterMs,

Lines 333-334

          required,
          requireAfterMs,

Refactor hints (highest CRAP first)

Function Complexity Coverage CRAP Location
updateSchedule 67 73% 151.4 packages/api/src/schedules/handlers.ts:904
view 39 89% 41.1 packages/api/src/schedules/authorization/service.ts:255
authorize 32 88% 33.9 packages/api/src/schedules/authorization/execution.ts:207
getLimits 26 100% 26.0 packages/api/src/schedules/service.ts:504
resolve 12 94% 12.0 packages/api/src/schedules/authorization/execution.ts:124
getLimits 8 80% 8.5 packages/api/src/schedules/authorization/host.ts:45
requiresGrant 4 100% 4.0 packages/api/src/schedules/authorization/execution.ts:163
requiresGrant 4 100% 4.0 packages/api/src/schedules/authorization/service.ts:28
requiresGrantFor 4 100% 4.0 packages/api/src/schedules/authorization/service.ts:425
createScheduleMCPConsentService 2 100% 2.0 packages/api/src/schedules/authorization/service.ts:239

4 more functions below the threshold (or cut for size) are in report.md.

CRAP = complexity² × (1 − coverage)³ + complexity

Jobs (1)
Check Result
Change risk (api) success

All data (quality-report artifact) · Run page

The gate opens only when the workflow, source selection, tooling verification, and every report job succeed. A report job fails on a failed test in its workspace's own Jest run, a tool error, a job timeout, or an incomplete mutation report, including a mutation shard that reaches its execution budget. A cancelled workflow keeps the gate closed. Scores are advisory. A change-risk file marked incomplete or unavailable, for example by a failed api/ source-alias suite, does not close the gate.

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