Repository navigation
fix(runtime): the action door and the declared flow endpoint refuse a self-triggered system flow to a non-system caller - #22424
Conversation
…low endpoint against elevated flows The before-table, measured on a real kernel before either door asks anything of the caller. A signed-in member with no grant on the target object starts a runAs-system flow of each self-triggered type (autolaunched, record_change, schedule) through an action of type flow (REST and the MCP run_action tool) and through a declared endpoint of type flow (authRequired true): every row answers 200 and the elevated write lands, while the member's own create is refused 403. screen and api flows, a runAs-user control and a screen parent calling the elevated child as a subflow are measured alongside. The assertions are the readings; the fix commit flips the refused rows. Claude-Session: https://claude.ai/code/session_01BmsuLyUeuG5CNpZFMH1jzS Co-authored-by: Claude <noreply@anthropic.com>
… entry The example application's authenticated flow endpoint starts an elevated janitor flow on demand. Under the type x caller rule that every door starting a flow by name now applies, an elevated flow of a self-triggered type is refused to any caller but the system principal, so the endpoint's target is declared type screen: the explicit, reviewable statement that signed-in callers may start this elevated work. Its nodes, run-as declaration and the endpoint's declaration are unchanged. Claude-Session: https://claude.ai/code/session_01BmsuLyUeuG5CNpZFMH1jzS Co-authored-by: Claude <noreply@anthropic.com>
… self-triggered system flow to a non-system caller The trigger door's type x caller rule now binds every door that starts a flow by name. An action of type flow (REST /actions and the MCP run_action bridge, which share one dispatch) and a declared endpoint of type flow refuse a caller that is not the system principal a flow declared runAs system whose type is autolaunched, record_change or schedule: 403 PERMISSION_DENIED, nothing dispatched. screen and api flows, flows not declared runAs system, a parent's subflow node and the system principal are unchanged. The predicate, the type set and the refusal move out of the trigger domain into one module all three doors call, so they cannot drift. The refusal's words lose the door's name so they read true at every door. Claude-Session: https://claude.ai/code/session_01BmsuLyUeuG5CNpZFMH1jzS Co-authored-by: Claude <noreply@anthropic.com>
… by name; changeset The elevated self-triggered start's isSystem read moves with the shared predicate, so its row anchors the new module and states the bypass at all three doors. Counts regenerated by gen:system-context-census. Claude-Session: https://claude.ai/code/session_01BmsuLyUeuG5CNpZFMH1jzS Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 16 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 4 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 26 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c91fc2d97280c635481ecde55c99c4dee55db825 && git checkout c91fc2d97280c635481ecde55c99c4dee55db825
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 27a8b33dec2eb98b73b3e5146e740067cdbd7806 d7b2170de0bff5326cc7142799dc80f1cdefcf0d && git checkout -B drift-repro 27a8b33dec2eb98b73b3e5146e740067cdbd7806 && git merge --no-ff d7b2170de0bff5326cc7142799dc80f1cdefcf0d
node scripts/docs-audit/affected-docs.mjs --json 27a8b33dec2eb98b73b3e5146e740067cdbd7806
|
…door answers an elevated self-triggered start The status table on the flows page gains the 403 PERMISSION_DENIED row for a non-system caller starting a runAs-system flow of a self-triggered type, the same at the trigger route, a flow action and a declared flow endpoint. Its lead sentence now says that row is the door's own admission check, not the engine's verdict, and the never-dispatched count moves from four to five. The actions page's flow row and the requiredPermissions bullet, and the declarative endpoints page's flow row, state the same refusal. Claude-Session: https://claude.ai/code/session_01BmsuLyUeuG5CNpZFMH1jzS Co-authored-by: Claude <noreply@anthropic.com>
…gh the action door (objectui#12037) (objectstack-ai#12046) Fixes objectstack-ai#12037 Clause-②: no Built on triage ruling B (card comment `6077692839`): a flow click goes through the action door exactly when it names a declared flow action; every other flow start stays on the trigger route. Ruling A landed in objectstack-ai/objectstack#22424. Implemented by session `https://claude.ai/code/session_01MgfduSkFrfM3eorB3UGfAU` (seat `domain:ui#2`). ## What changes Both console flow-launch handlers used to start every flow through `POST /api/v1/automation/:flow/trigger`: `flowHandler` in `useConsoleActionRuntime` (list, page and root runtime) and `flowHandler` in `RecordDetailView`. That route starts a flow by name, so a declared flow action's own server gates never ran for the click. Those gates are its `requiredPermissions` (ADR-0066 D4, whose console half only hides the button), its activation switch, its param contract and the caller-scoped load of its subject record. - **The route rule** lives in one module-internal launcher, `launchConsoleFlow` in the new `packages/app-shell/src/utils/flowLaunch.ts`, which both handlers call. A click goes through `POST /api/v1/actions/:object/:action` exactly when `findDeclaredFlowAction` finds, in the object metadata the console already holds, an action of the click's `name` on the click's object with `type: 'flow'` and the same `target`. Otherwise the click stays on the trigger route. Both handlers' docblocks record why: an undeclared flow start has no action gate to apply, and ruling A's elevation refusal already holds on the trigger route. Those starts are an inline page button with no or a non-matching `name`, and a dashboard header's synthesized `name: actionUrl`. - **Who owns the door's exchange.** The `/actions` request is built by core's `createServerActionHandler` (name-only identity, `{ recordId, params }`, `_rowRecord` stripped), so app-shell still names that route nowhere (`actions-envelope.ratchet.test.ts` stays green, unedited). The answer is the flow's `AutomationResult`, read by `interpretFlowResponse` / `judgeFlowLaunch` through an injected transport. So a paused screen still opens `FlowRunner`, a refused end still opens the Close-only notice, and `FLOW_FAILED` still prefers the author's `errorMessage`. Core's own `interpretActionResponse` has none of those arms. - **Ride-along, related-list toolbar.** `RecordDetailView`'s flow path no longer hands the parent page's record id to a child object's action that carries no row. A related list's toolbar flow action is now an object-level start; a row action still addresses the child row. - **Docs.** In `content/docs/guide/architecture-overview.md`, the *Supported Action Types* `flow` row now says what the type does and which endpoint each kind of click uses. - `flow-envelope.ratchet.test.ts` names the callers that are true now: `utils/flowLaunch.ts` (launch) and `views/FlowRunner.tsx` (resume). It also pins that both handlers delegate to `launchConsoleFlow`. Nothing published changes: no export, prop or `packages/i18n` key is added. `flowLaunch.ts` is reachable only through the two handlers. No spec change, and nameless flow buttons are not refused (ruling B, not A). ## Measured before building The door was read at objectstack origin/main `081e6a09`, which contains `c572fe2a36` (`git merge-base --is-ancestor` exit 0); the files read were `dispatchFlowAction` and the flow arm of `handleActionsRequest`. | The handlers read | Where the door's answer carries it | |---|---| | transport envelope | `deps.success(result)` / `deps.error(...)`, the same builders as the trigger route (ADR-0112) | | paused screen: `runId`, `screen`, `flowLabel` | the raw `AutomationResult` as `data`; a paused result is neither a refusal row nor caught by the residual `success === false` arm | | refused end: `status: 'refused'`, `refusalMessage` | passes through `deps.success` unchanged | | `successMessage` | unchanged | | ran and failed | `400` with `error.code` `FLOW_FAILED` and `error.details.errorMessage`, via `FlowActionRefusal` | | 404 / 409 / 422 / ruling A's 403 | the same shared table and admission rule at both doors | The door does not carry the flow name. `FlowRunner` resumes under the handler's flow, which on the door path is the declaration's `target`; the lookup requires the two to be equal. **Related-list row action on a child.** `RelatedRecordActionsBridge.runRowAction` dispatches the child object's declared action with `objectName` set to the child and `recordId` to the child row. At the door that is `POST /api/v1/actions/CHILD/CHILD_ACTION_NAME`. `resolveRouteActionDeclaration` resolves the declaration on the child. `loadActionSubjectRecord` loads the child row under the caller's scope, and `refuseDeniedSubjectLoad` answers 404 when that row cannot be read. **Where the lookup's metadata comes from.** It reads object metadata only. The runtime reads the caller's `objects` first, then the console store's `object` type, awaiting `ensureType('object')` before deciding, as the param dialog already does. The record page reads its `objects` prop. That metadata carries an object's own `actions[]`, which includes every `defineAction({ objectName })`: `defineStack`'s bound-action merge puts them there. The console's list row actions render from `objectDef.actions` alone; `e2e/live/screen-flow.spec.ts` clicks the bound `showcase_bulk_reassign` that way. The metadata does not carry an object-less declared action, nor a standalone authored action row that no object definition embeds. A click on either keeps the trigger route, as every flow click did before, so that is no regression; a pin holds it as a control. No click-time `action` metadata fetch was added. ## Pins - `useConsoleActionRuntime.flowActionDoor-12037.test.tsx` runs through the real `ConsoleActionRuntimeProvider`, runner and `FlowRunner`: - a declared flow action whose `requiredPermissions` the caller lacks is refused by the server with `403` `PERMISSION_DENIED`, and its message is the error toast; - control: an allowed click pauses, and Submit resumes at `/api/v1/automation/showcase_reassign_wizard/runs/run-1/resume`, the declaration's target; - the store is read (`ensureType('object')`) when the caller holds no objects; - an inline button with no name, a dashboard synthesized name, a name whose declaration has another target or type, and an object-less declared action (the control) all stay on the trigger route; - an elevated self-triggered target is refused there, and that refusal is the error toast. - `RecordDetailView.flowActionDoor-12037.test.tsx` runs through the real record page and `FlowRunner`: - a related-list row action on the child goes to `/api/v1/actions/lead_task/escalate_task` with `recordId` set to the child row, is refused `403`, and the refusal is shown; - the related list's toolbar action sends no parent id, on both doors; - control: a header click pauses and resumes under the declaration's target; - an undeclared header start stays on the trigger route, where the elevated refusal is shown. **Reverse leg.** The implementation was committed first (`66291b17c`). The trap-guarded script then checked out main's blobs (`47b1f0bb7`) of the two handler files and ran the two pin files plus the ratchet: `Tests 8 failed | 8 passed (16)`. The 8 failures were every door pin, the two parent-id pins and the delegation pin. The 8 that passed are the trigger-route controls, which hold on main too. After the restore, `git diff HEAD` showed 0 lines, and `git hash-object` equalled the HEAD blob for both files. Re-run on head: `Tests 16 passed (16)`. ## Gates, on head `66291b17c` - Every suite that mounts either handler, plus FlowRunner's suites, `flowResponse`, the app-shell ratchets, `column-identity.ratchet.test.ts` and `one-authority-per-exported-name-6273.test.ts`: 84 files. Run with repo-root `pnpm exec vitest run`, under the verify lock, after the final commit: `Test Files 84 passed (84)`, `Tests 596 passed (596)`. - `pnpm --filter @object-ui/app-shell type-check`, echoed `tsc --noEmit && tsc -p tsconfig.test.json`, gave VERDICT command-exit 0. The upstream closure was built first. `--listFilesOnly` on the test tsconfig lists all four new or edited files. - `check-changeset-presence` and `check-changeset-no-major` pass. `check:new-line-citations` reports `0 new citation(s)`. `check:control-bytes`, `docs:check-links`, `check:spec-symbols`, `check-vi-mock-override-shape`, `check-test-path-roots` and `check-lint-coverage` are all OK. - `pnpm exec eslint` on the 6 touched TS files (count from `--format json`) gives 0 errors. Warnings on the two handler files equal their base blobs: 110 and 38. The repo's `eslint.config.js` has no `projectService` / `parserOptions.project`, so linting is not type-aware and the diff cannot move an untouched file's verdict. The full `pnpm lint` and `pnpm test` are left to CI. ## First-load bytes Both handlers ship eagerly: the runtime's code is in the eager `DeclaredActionsBar` chunk, and the record page's is in the eager `RecordDetailView` chunk. A console `vite build` under the lock, from `apps/console/dist/eager-closure.json`, gives `eagerGzipBytes` 3,238,611 at base `47b1f0bb7` and 3,238,879 at head: **+268 B gzip**, with 289 eager chunks in both builds. ## Acceptance notes, not changed here - RecordDetailView's script handler has the same parent-id fallback for a related list's toolbar (its `resolveRecordId` override). It is outside the flow path this PR rewrites, so it is reported only. - `_rowRecord.id` against `_rowRecord[recordIdField]` was not aligned. The door treats the body's `recordId` as the subject row's primary id and seeds `recordIdParam` from `record[recordIdField]` itself (`seedFlowActionParams`; the spec describes `recordIdField` as "Row field whose value seeds recordIdParam"). So `_rowRecord.id` is the read the door wants. Core's `resolveServerActionRecordId` reads `_rowRecord[recordIdField]` as the record address; the only producer with a non-id `recordIdField` (`sys_session`'s `revoke_session`) is an `api` action that never reaches that reader. - An object-less declared flow action keeps the trigger route. A nav item does resolve one from `action` metadata, so seeing it would take a new provenance signal or a click-time fetch; neither was added. - The `packages/app-shell` README has no section on the flow launch, so nothing there became false. ## Surface The two handler files, the two new pin files, `flow-envelope.ratchet.test.ts`, the docs page and the changeset. One file outside the claim's literal list: the new module-internal `utils/flowLaunch.ts`, the shared call shape (H2) the build round asked to keep module-internal. `ObjectView.tsx` and everything in objectstack are untouched. --- _Generated by [Claude Code](https://claude.ai/code/session_01MgfduSkFrfM3eorB3UGfAU)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #22407
Clause-②: no
The maintainer's ruling on the card (letter A, ruling-ref
6074046403): the type × caller rule ruling B landed at the trigger door (PR #22404) binds every door that starts a flow by name. A caller that is not the system principal may not start a flow declaredrunAs: 'system'whosetypeisautolaunched,record_changeorschedule, through an action oftype: 'flow'(RESTPOST /api/v1/actions/:object/:actionand the MCPrun_actionbridge that reaches it) or a declared endpoint oftype: 'flow'.screenandapiflows stay the author's designed entries at every door. No spec key moves and no new error code is minted.What changed
packages/runtime/src/flow-start-admission.ts(new): the ONE home of the rule. It holds the self-triggered type set (compile-bound to the spec'sFlow.typeenum), the refusal (403PERMISSION_DENIED, ADR-0112) andrefusesElevatedSelfTriggeredStart(automation, flowName, executionContext). The predicate, the type set and the refusal are moved here out ofdomains/automation.ts, where PR fix(runtime): the trigger door refuses a self-triggered system flow to a non-system caller #22404 landed them module-private. No second copy exists.domains/automation.ts) calls the moved predicate. Its behaviour is unchanged except for the refusal's words: the message no longer names the trigger door, so the one message reads true at all three doors. It still names nothing of the flow.action-execution.ts,dispatchFlowAction): the check sits after the existence probe (an unknown target keeps its404) and beforeexecute. REST/actionsand MCPrun_actionboth reach this one line. The refusal is thrown withcode+status, so the envelope survives both entrances.endpoint-executor.ts,executeFlow): the same check at the same position, answered throughapiErrorResponse. The policy chain upstream is untouched.content/docs/permissions/system-context.mdx: row 56 now anchors the moved predicate in its new module and states the bypass at all three doors. Counts regenerated bypnpm gen:system-context-census(files 55 to 56, declarations 27 to 28; read sites stay 119). No other row is touched.type: 'screen', the explicit statement that it is an entry. Nodes,runAs, and the endpoint's declaration are unchanged, so its intended caller (an authenticated caller of that endpoint) gets the same run. Why this route and not a subflow parent: anapi-typed flow arms a signed inbound hook (ADR-0041, it registers only with a per-flow secret), which is a different door; ascreenparent with asubflownode would add a second flow, a second label and a new endpoint target for no behaviour the one-line declaration does not already give..changeset/22407-flow-door-elevated-start.md(@objectstack/runtimepatch), with the migration line for an author whose action or endpoint now answers403.6075084564).content/docs/automation/flows.mdx: the flow-dispatch status table gains the403 PERMISSION_DENIEDrow; its lead sentence now says that row is the door's own admission check, made before dispatch, not the engine's verdict; the never-dispatched count moves from four to five.content/docs/ui/actions.mdx: theflowrow of the action-type table states the refusal, and therequiredPermissionsbullet notes that leaving it unset does not open such a target.content/docs/api/declarative-endpoints.mdx: theflowrow's status list gains the403.The measured before-table
Measured first, on this branch at
c116ccb58(baseabd254508, before PR #22404 was on main), through the real kernel: a signed-in member with no grant on the target object (the member's own create there answers403 PERMISSION_DENIED). Each writer flow creates one ledger row named after itself; "row" is the elevated write, "run" is the run log.run_action, declared endpointautolaunched/record_change/schedule,runAs: 'system'200, row written, run recorded403 PERMISSION_DENIED, no row, no runautolaunched,runAs: 'system'200, row written403, no row, no run200, row written200, row writtenscreen/api,runAs: 'system'200, elevated rowautolaunched,runAs: 'user'400 FLOW_FAILED, no row, run recordedscreenparent (runAs: 'user') whosesubflownode calls the elevatedautolaunchedchild200, child's row writtenauthRequired: true401, no runThe pins carry the table as assertions, each row with its
beforereading:packages/verify/src/action-flow-elevated-door.test.ts(the action door with the system-principal rows) andpackages/qa/dogfood/test/flow-door-elevated-start.dogfood.test.ts(all three doors).Pins
packages/runtime/src/action-flow-elevated-door.test.ts: both entrances (REST andrun_action) for every refused type (code+status+ never dispatched); the refusal names nothing of the flow and equals the trigger door's refusal for the same declaration; the system principal,runAs: 'user'/ norunAs,screen/api, unknown target (404) and a service withoutgetFloware unchanged. The action'srequiredPermissionsgate (ADR-0066 D4): a member lacking it is refused by the gate first, and the flow is never read; a member holding it is still refused anautolaunchedsystem target and starts ascreenone.packages/runtime/src/endpoint-flow-elevated-door.test.ts: the same matrix at the declared endpoint, including the guest principal anauthRequired: falseendpoint admits, with the declared envelope checked.packages/verify/src/action-flow-elevated-door.test.tsandpackages/qa/dogfood/test/flow-door-elevated-start.dogfood.test.ts(above), plus a dogfood case that all three doors answer the trigger door's refusal word for word.The pin sweep
The ruling flips one meaning at two doors: a non-system caller starting an elevated self-triggered flow through a
type: 'flow'action or endpoint now answers403, not200. A repo-wide search over every test that drives either door (/actions/,run_action,runAction,invokeBusinessAction,dispatchFlowAction,handleActions,executeEndpointTarget,actions.run(, and declared paths under/apps/): 148 files acrosspackages/,examples/and the dogfood suite. Of those, 5 name arunAs: 'system'declaration at all: this PR's two new wire files, a CLI boot-warning formatter test and a spec pin test (neither drives a door), and one runtime action test whose scriptedgetFlowserves{ name }only (norunAs, so the rule never applies). The flow actions the example applications declare target twoscreen/runAs: 'user'flows, unchanged. The one in-repo producer is the example endpoint fixed above; its dogfood proof (an authenticated caller'sPOSTanswers200and runs the flow) stays green with the same subject. The refusal's code and its old words (through the trigger door) are pinned nowhere else in the repo.So no existing pin asserted the pre-ruling meaning at these two doors; the flipped pins are this branch's own before-table, each now asserting
403+PERMISSION_DENIED+ no row + no run.Ablation of the two new call sites (the shared predicate handed a system context at the action door and at the endpoint, markers present in
packages/runtime/dist/index.jsandindex.cjsbefore reading any result): runtime 18 failed / 62 passed, exactly the refusal pins of the two new files, while PR #22404's trigger-door file (the control: that door was not ablated) and every unchanged-path pin stayed green; verify 7 failed / 9 passed (the six member and admin rows and the wire envelope); dogfood 13 failed / 14 passed (the twelve member and admin rows across the three doors, and the word-for-word parity case). Restore: both blobs equalHEAD,git status --porcelainempty, runtime rebuilt,ablation-dist-preflight --absentreports both markers gone, and the re-run is 80 / 16 / 27 passed.Tests and gates (head
28fe10794)pnpm --filter @objectstack/runtime exec vitest run --project local: 344 files, 4868 passed, 19 skipped.pnpm --filter @objectstack/verify exec vitest run: 21 files, 170 passed.authz-conformance,flow-runas,schedule-acting-organization, the two declared-endpoint suites and the MCP identity suite): 225 passed.objectstack validate: exit 0, no finding on the changed flow.typecheckexit 0 for@objectstack/runtime(with its test layer),@objectstack/verify,@objectstack/dogfoodand the example application;--listFilesshows each new test file inside its program.pnpm lint(the full run): exit 0.node scripts/check-system-context-census.mjs: OK, 119 read sites across 56 files, 115 of 115 required symbols cited.check:skill-examplesandcheck:dual-build-cjs-loadsfirst answeredPREREQUISITE NOT METand went green after a full build.dispatch-gates --ran: 97 derived, 97 run, 0 NOT MEASURED.packages/cliis not touched by this diff.d7b2170de(docs only): the 40 gatesdispatch-gates --commandsderives for the three pages, then the remaining 57 of the no-path union, all exit 0.dispatch-gates --ran: 97 derived, 97 run, 0 NOT MEASURED. Production, tests and the changeset are unchanged since28fe10794.Acceptance notes
403, carried by this PR in patch round 1 (d7b2170de): the status table incontent/docs/automation/flows.mdx, theflowrow and therequiredPermissionsbullet ofcontent/docs/ui/actions.mdx, and theflowrow ofcontent/docs/api/declarative-endpoints.mdx. Three other pages still list the flow-dispatch codes without the403: thetype: 'flow'row ofcontent/docs/protocol/kernel/http-protocol.mdx, the trigger row ofcontent/docs/api/plugin-endpoints.mdx, and the error-handling sample incontent/docs/api/client-sdk.mdx. They are outside this PR and noted for their owner.run_actionbridge throws the action'srequiredPermissionsrefusal as a bare error, with nocodeorstatus, while REST answers it403. The new refusal carries both at both entrances. The bare throw is unchanged, and only the runtime door test measured it.run_actioncannot be reached on@objectstack/verify's lean boot (it composes noMetadataPlugin, which ownsmatchEndpoint, and does not depend on@objectstack/mcp), so their wire pins live in the dogfood package, which depends on both. The action door's wire pin, with the system-principal rows, is in@objectstack/verify.Generated by Claude Code