You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c77f8ca
Browse filesBrowse the repository at this point in the historyBrowse files
feat(runtime): dispatchActionResume resumes a handed-off resume_run as the person who approved it (#34492)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9T7a9Cf6D9HQLyMfF1wqqNX)_Fixes#34386
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:`@objectstack/runtime` 新导出
`dispatchActionResume`,宿主(cloud)在用户批准一条被交给人确认的 `resume_run`
后,用它以批准人的身份续跑那条暂停的流程。
- 为什么改:确认契约承诺"批准即续跑那条暂停的运行",但框架没有这个入口,cloud PR #4735 只能一直拒绝;cloud
自己重写一遍续跑门禁就成了第二份平台规则。
- 风险与回滚:只新增导出,MCP `resume_run` 和 `dispatchAction` 行为不变;回滚即撤掉这个 PR。
- 先看:`packages/runtime/src/domains/mcp.ts`(`resumeActionRunRequest` 与第 3
步确认门禁的宿主分支)、`packages/runtime/src/action-dispatch.ts`(导出入口)、`packages/runtime/src/action-confirmation-handoff-33690.test.ts`(新
describe)。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run
src/action-confirmation-handoff-33690.test.ts`,预期 7 条 `[#34386]` 用例全绿。
- 需要你做的:无,席位落地(新公开导出,先过契约复审)。
## What changes
The confirmation contract (`AI_ACTION_CONFIRMATION_CAPABILITY`, rule 4)
says that approving a handed-off `resume_run` resumes THAT parked run,
with the values the call carried, as the approver, who must be the run's
owner, every gate re-checked. The framework exported no seam for it:
`dispatchAction` only starts an action, and the MCP door's
`resumeActionRun` always hands a gated action off again.
- **`dispatchActionResume(kernel, { executionContext, environmentId?,
runId, values?, confirm? })`** (new export of `@objectstack/runtime`,
with its request type `ActionResumeRequest`). It runs the MCP
`resume_run` door's own steps 1 to 6 again as `executionContext`,
through `HttpDispatcher.resumeHostActionRun` → `resumeActionRunRequest`
(`domains/mcp.ts`) → `resumeActionRun`. The host keeps no copy of the
gates.
- Step 2: a run that is no longer paused, or that another person
started, gets the door's one not-found answer (`404
RESOURCE_NOT_FOUND`).
- Step 3: every `run_action` gate of the flow action that admits the
run. Its confirmation gate reads `confirm` as a host action door reads
it (`actionConfirmationRefusal`, the member gate `dispatchAction` asks):
a declared-gated action resumes on the person's `confirm: true`, and is
refused `428 ACTION_CONFIRMATION_REQUIRED` without it. Nothing is handed
off or elicited again. An AI service account is refused whatever it
carries (ADR-0151 D3 rule 3, `reason: 'service_account'`).
- Steps 4 and 5: the subject record is read again as the person; the run
must be paused on a screen (`409`). Step 6 resumes it.
- Step 2 refuses only a run that is no longer paused. A wizard the first
approval moved on to its next screen is still paused under the same run
id, so a second call with the same hand-off passes steps 2 to 5 and
resumes that next screen with the values given. Deciding a pending item
once, and voiding an item whose run has moved on, are the host's approve
door's job; binding an approval to one screen is not in this PR
(contract review S1, record 6932783796).
- Placement is the host action door's (`placeHostActionRequest`). The
answer is the REST envelope, as `dispatchAction`'s: `200` with
`resume_run`'s `{ ok, action, objectName, recordId?, result }` as
`data`, or the refusal's ADR-0112 envelope with its `details`. One
invocation row is written for a call that cleared steps 1 to 3, with no
surface (as the host action door's row).
- **`resumeActionRun` (internal)** gains a `wiring.hostDoor` member:
present only on the host path, it switches step 3's confirmation gate to
the member gate and drops the MCP surface from the invocation row. The
MCP tool path is unchanged.
- **`actionDeclarationReads`** (internal): the per-request metadata,
merged-listing, served-objects and served-actions reads moved out of
`buildMcpBridge` verbatim, so the bridge and the host resume door read
the same declarations. No line of the moved code changed.
- **Door refusals keep their envelope at the host door**:
`resumeDoorError` now records the envelope `deps.error` built for each
refusal, and the host door answers that envelope. The dispatcher's
generic thrown-value reader keeps `code` and `status` but drops
`details` (a confirmation refusal's `reason`). Anything else thrown is
answered by that reader as before.
- **Contract docblock** (`IActionConfirmationService`,
`@objectstack/spec/contracts`): names the two host doors of the approval
leg, `dispatchAction` for a handed-off `run_action` and
`dispatchActionResume` for a handed-off `resume_run`, and says the seam
refuses only a run that is no longer paused, so deciding a pending item
once is the host's.
- **Docs**: `content/docs/ui/actions.mdx` gains "Resume a handed-off run
as the person who approved it" under the host-code section.
- Changeset: `.changeset/34386-dispatch-action-resume.md`,
`@objectstack/runtime` patch.
- **Naming**: `dispatchActionResume` and its request type
`ActionResumeRequest` follow the precedent in the same file,
`dispatchAction` and `ActionDispatchRequest`
(`packages/runtime/src/action-dispatch.ts`), the host door that starts
an action.
- **System-context register**
(`content/docs/permissions/system-context.mdx`): the host resume door
opens with the anonymous-deny read `dispatchActionRequest` opens with,
so row 52 names `resumeActionRunRequest` beside it and the generated
site register is rewritten (`node
scripts/check-system-context-census.mjs --write`).
`check:system-context-census` refused the read without a row.
## Tests
New top-level `describe` in the shared harness file
`packages/runtime/src/action-confirmation-handoff-33690.test.ts` (seven
cases). Each starts from a real hand-off made through the MCP bridge's
`resumeRun`, and calls `dispatchActionResume` with the run and values
the hand-off carried:
- the approving person resumes THAT run with the hand-off's values
(`automation.resume` called once with `[runId, { variables }]`), no new
run, no second hand-off, and one invocation row with no `surface`;
- another person is refused `404 RESOURCE_NOT_FOUND`, the run stays
paused;
- a run that is no longer parked is refused: a run the first approval
completed is not resumed again;
- without `confirm` (absent, or `false`) the gated resume is refused
`428 ACTION_CONFIRMATION_REQUIRED` with the member gate's details (no
`reason`), never handed off again;
- an AI service account is refused `428`, `reason: service_account`,
with `confirm: true`;
- the subject record is re-read as the approver: one they can no longer
read is refused `404 RECORD_NOT_FOUND`;
- an anonymous caller is refused `401 UNAUTHENTICATED`
(`ANONYMOUS_DENY_CODE`) before the run is read.
No existing test was changed.
## Acceptance notes
- The route path the placement step hands the resolver is
`/mcp/resume_run/RUN_ID`: informational, as the host action door's is,
and no environment hint is derived from it. It names the door whose
steps run.
- What stays the host's before it calls, as for `dispatchAction`:
resolving the approver's envelope against the placed kernel, the
ADR-0069 authentication-policy gate, environment membership, and the
approve door's rule that only a person's signed-in session decides.
- The cloud follow-up (holding resume hand-offs and dispatching through
this seam) is the cloud seat's, after a pin move.
- Review S1, the structural half (binding an approval to the screen it
was given for, so a second resume of the same hand-off cannot reach a
later screen): filed #34515. This PR only states the seam's check
truthfully.
- Review N2 (the enforced-set docblock of `actionConfirmationRefusal` in
`action-execution.ts` does not name the host resume door): filed #34515.
## Verification
<details><summary>Local runs (runtime closure built first)</summary>
- `pnpm --filter @objectstack/runtime typecheck`: exit 0 (`tsc
--noEmit`, then `check:test-typecheck` OK, ledger held).
- `pnpm --filter @objectstack/runtime test`: Test Files 609 passed
(609), Tests 11278 passed, 19 skipped.
- Targeted: `vitest run src/action-confirmation-handoff-33690.test.ts
src/mcp-resume-run.test.ts src/action-dispatch.test.ts`: 131 passed.
- Ablation (`scripts/ablation-replace.mjs`, runtime tests import `src`,
no dist leg): step 3's host branch disabled (`if (hostConfirmation !==
undefined && false)`), the host call is handed off again. 3 of the 7 new
cases go red (resumes THAT run; resumes once, never twice; the member
gate's 428). The service-account case stays green, as expected: the MCP
path refuses an account too. Restored: blob equals HEAD, `git diff HEAD`
empty.
</details>
<details><summary>Derived gate round on 9c404cd</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 115 families; each run with stdin closed,
exit captured before any pipe. 115 of 115 `exit 0`.
- `dispatch-gates.mjs --ran`: 115 derived, 115 run, 0 NOT-MEASURED, 0
UNRUN.
- Local-only families (spec source touched): `check-dev-prereqs` exit 0,
`check:skill-frame-freshness` exit 0.
- The first CI head (94c8ee5) went red on
`check:system-context-census` (inside "Docs anchors resolve to real
headings"): the new door's anonymous-deny read had no row. Fixed in
9c404cd.
</details>
<details><summary>Rework round (L1 REWORK 6932718088, contract review S1
6932783796)</summary>
- 1313af8 (tests only): the anonymous case asserts the envelope code
`UNAUTHENTICATED`; the approver case asserts the one invocation row and
that its context carries no `surface`. Ablation: the host door's row
given the MCP surface (`context: withActionSurface(ec, 'mcp'),`), the
approver case goes red (1 of 39), restored blob equals HEAD. Runtime
typecheck exit 0; derived round 115 of 115 `exit 0`.
- f364cc0 (prose only, S1): the contract docblock, the
`dispatchActionResume` and `resumeActionRunRequest` docblocks, the docs
section and the changeset no longer say the run resumes once; they say
the seam refuses only a run that is no longer paused and that deciding a
pending item once is the host's. One test renamed to match.
- Final head f364cc0: spec and runtime rebuilt;
`action-confirmation-handoff-33690.test.ts` 39 of 39 passed; derived
round 115 of 115 `exit 0`, `--ran` 115 derived, 115 run, 0 NOT-MEASURED,
0 UNRUN.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmQC5YhoBASNPYbDXuQ)_
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRXuRn93HphKp7kXEz -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(runtime): `dispatchActionResume` resumes a handed-off `resume_run` as the person who approved it
6
+
7
+
Clause-②: yes (widening)
8
+
Metadata-protocol: none
9
+
10
+
The confirmation contract says that approving a handed-off `resume_run` resumes that parked run, with the values the call carried, as the approver. Until now the framework exported no way to do that: `dispatchAction` only starts an action, and the MCP `resume_run` door hands a gated action off again. A host that implements the pending-confirmation service (`ai.actionConfirmation`) could hold a handed-off `resume_run` but had to keep refusing it.
11
+
12
+
`dispatchActionResume(kernel, { executionContext, runId, values, confirm })` is the approval leg. It asks every `resume_run` gate again as the approving person: the run must still be paused and started by that person, the flow action that admits it must pass every `run_action` gate, the subject record is read again as the person, and the run must be paused on a screen. Then it resumes that run. Only a run that is no longer paused is refused: a wizard the approval moved on to its next screen is still paused under the same run id, so the host's approve door decides each pending item once and voids an item whose run has moved on. The confirmation gate reads `confirm` as `dispatchAction`'s does, so a declared-gated action resumes on the person's `confirm: true` and nothing is handed off again. An AI service account is refused whatever it carries. The answer is the REST envelope, as `dispatchAction`'s is.
Copy file name to clipboardExpand all lines: content/docs/permissions/system-context.mdx
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,7 +205,7 @@ One of the largest consumers of the flag;
205
205
| 50 |`manage_metadata` bypassed on metadata writes | runtime, rest | Get: schema writes without the capability (the permission-set clone door's save included) — and, because REST's save door and the stored-version read doors ask one save verdict, an app's full stored version on `/layers`, `?layers=true` and `/diff`, whatever its entry gates withhold |`handleMetadataRequest`, `registerMetaCollectionRoutes`, `registerMetaItemWriteRoutes`, `registerMetaItemHistoryRoutes`, `metaSaveVerdict`, `handlePermissionSetCloneWrite`|
206
206
| 50b |`setup.write` bypassed on the record-currency code backfill door | rest | Get: `POST /meta/_migrate-record-currency-codes` without the capability. The door still fills only the caller's current organization's rows: a system context with no organization is refused like any other caller |`registerMetaRecordCurrencyBackfillRoute`|
207
207
| 51 | The shared metadata-write verdict itself returns `allowed`| metadata-core | Get: the one function all of row 50's doors consult answers yes before any capability is examined |`metaWriteCapabilityVerdict`|
208
-
| 52 | Anonymous-deny seam satisfied on the domain dispatchers and the package/federation routes | runtime, rest | Get: passes with no `userId`|`handleActionsRequest`, `dispatchActionRequest`, `handleAIRequest`, `handleAutomationRequest`, `handleMetadataRequest`, `handleSecurityRequest`, `handlePackagesRequest`, `handleAnalyticsRequest`, `handleI18nRequest`, `registerExternalDatasourceRoutes`, `refusePackageRequest`|
208
+
| 52 | Anonymous-deny seam satisfied on the domain dispatchers and the package/federation routes | runtime, rest | Get: passes with no `userId`|`handleActionsRequest`, `dispatchActionRequest`, `resumeActionRunRequest`, `handleAIRequest`, `handleAutomationRequest`, `handleMetadataRequest`, `handleSecurityRequest`, `handlePackagesRequest`, `handleAnalyticsRequest`, `handleI18nRequest`, `registerExternalDatasourceRoutes`, `refusePackageRequest`|
209
209
| 53 | MCP principal check satisfied | runtime | Get: MCP surface reachable with no user |`handleMcpRequest`|
210
210
| 54 | Package REST route capability gate bypassed | rest | Get: a marketplace publish over REST (`POST /packages/publish`, the one route the REST registrar mounts since #14503) without `manage_metadata`; the package read cohort (`studio.access` / `setup.access`) is enforced by the dispatcher `/packages` domain's own read gate, where the reads are served |`refusePackageRequest`|
211
211
| 55 | Package domain capability gates bypassed | runtime | Get: package management and package-inventory reads without the capability |`requireManageMetadata`, `requireReadCapability`|
@@ -676,6 +676,7 @@ and CI refuses one that differs from what the tree produces.
0 commit comments