Skip to content

Commit 471add3

Browse files
docs(approvals): say how a request with no submitter leaves the returned state (#30137)
<!-- claude-projects-attribution: {"github_login":"marchtian"} --> _Requested by **田騏** · [project thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSiNjyvCdXYygFqntMNR7S2dW)_ Fixes #29910 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:审批指南和 `IApprovalService` 的 `recall` / `sendBack` / `resubmit` 注释写明「没有提交人的审批单」被退回后怎么走出来:退回后谁也撤不回,唯一出路是服务端代码以系统上下文 `resubmit`,新一轮 `pending` 仍无提交人,系统或管理员覆盖可撤回。指南还告诉作者:由无用户触发器启动的流程,只有在服务端代码会做这次重提时才声明 `revise` 边,否则不声明,让审批人改用驳回。 - 为什么改:维护者在「第三批 同意」中选了 D(行为不变,把出路写清楚);此前文档没有说过这种审批单退回后的去向。 - 风险与回滚:只改注释和文档,外加一个 `@objectstack/spec` patch changeset;非注释的 token 前后完全一致(见 Verification),行为不变。回滚即 revert。 - 先看:`packages/spec/src/contracts/approval-service.ts` 的 `recall` 与 `sendBack` 注释;`content/docs/automation/approvals.mdx` 的「A request with no submitter」段。 - 两分钟验证:`git diff origin/main -- packages/spec/src/contracts/approval-service.ts`,应只看到 `*` 开头的注释行变化。 - 需要你做的:无,席位落地(spec 包改动,落地前席位做一次独立复审)。 ## What changes - `content/docs/automation/approvals.mdx`, under **Send-back → resubmit**: a new paragraph, **A request with no submitter**. It says that a run whose trigger resolved no user opens its request with no submitter; that an approver can still send it back, but nobody can recall it once it is `returned` and no viewer sees Resubmit or Recall; that its one way out is a system-context `resubmit` from server-side code, which opens the next round `pending`, again with no submitter, where the system or the admin override can recall it. It also says what an author should do on such a flow: keep the `revise` edge into its `approval_revise` node only when server-side code will make that resubmit, and otherwise leave the edge off, so send-back is refused and approvers reject instead. `content/docs/capabilities/approvals.mdx` only names send-back in one line and does not teach recall or resubmit, so it is unchanged. - `packages/spec/src/contracts/approval-service.ts`, comments only: - `recall`: a closing paragraph saying the `returned` arm has no one for a request with no submitter, and stating the way out above. - `sendBack`: a closing paragraph saying such a request is sent back the same way, that only a system-context `resubmit` moves it on, and that a flow whose trigger resolves no user declares `revise` only when server-side code will make that call. - `resubmit`: "submitter-only" now reads "by the submitter or a system context (the system context alone on a request with no submitter)". The code already admits the system context, and `ApprovalResubmitInput.actorId` already said so. - `.changeset/29910-no-submitter-returned-docs.md`: `'@objectstack/spec': patch`. The docblock text ships: after a build it is in `packages/spec/dist/contracts/index.d.ts` and `index.d.mts` (positive control: the existing sentence "refused there exactly as any other non-submitter" is found in the same two files). So this is a published, comment-only change, which takes a patch changeset rather than `skip-changeset`. ### The documented path, read from code at `987ff33b` - No submitter: `packages/plugins/plugin-approvals/src/approval-node.ts:107-111` (`runTriggerUser`, `null` when the trigger resolved no user) feeds `submitterId` at `approval-node.ts:199`. - Send-back is allowed and lands on the window: `approval-service.ts:6041` (pending approver or system, no submitter test) and `assertReviseEdge` at `approval-service.ts:6278-6312` (the `revise` edge must exist and must target an `approval_revise` node). `approval-revise-node.ts:89-98`: the window arms nothing, and only `resubmit` or a recall ends it. - Nobody recalls it on `returned`: `approval-service.ts:5613-5618` (`overrideAdmits` requires `status === 'pending'`; `actsAsSubmitter` at `approval-service.ts:1114-1117` answers false for every actor when `submitter_id` is null). - A system-context resubmit is admitted: `approval-service.ts:6202` (`if (!context.isSystem && !actsAsSubmitter(raw, actorId))`), pinned at `approval-service.test.ts:6418-6423`. Its resume carries no `resumedBy` (`approval-service.ts:6241-6248`), so the run context is not switched (`service-automation/src/run-resume.ts:326-328`). The re-entered approval node opens round N+1 through `approval-node.ts:199` again, with no submitter (also pinned for a later step by `later-step-original-submitter.integration.test.ts:322`). - The new `pending` round is recalled by the system or the override actor: `approval-service.ts:5613-5614` with `isOverrideActor` at `approval-service.ts:2111-2113` (`context.isSystem` always passes). Pinned at `approval-service.test.ts:6403-6416`. - No console door: `sys-approval-request.object.ts:766-778` shows Resubmit only to `viewer.is_submitter`, and Recall on `returned` only to the submitter (`can_override` is pending-only). The REST `/resubmit` route (`packages/rest/src/approvals-routes.ts:518-523`) passes the caller's own resolved context. ## Tests No test was added: nothing a test can pin changed. The behaviour documented here is already pinned by the `approval-service.test.ts` battery cited above. ## Acceptance notes - A system-context `resubmit` is reachable only from server-side code. The console offers no button for it, and the REST route acts as its caller. The guide says "server-side code in a system context" and does not name any other door. - Comments-only proof: `packages/spec/src/contracts/approval-service.ts` was tokenised with the TypeScript scanner (comments skipped) at `987ff33b` and at this branch. Both give 1420 tokens and the streams are identical. Control: changing one `actorId: string` to `number` makes the comparison report `false`. So no `.d.ts` statement other than a comment can move. `api-surface/contracts.json` records only the interface names, and the spec build regenerated nothing (clean `git status` afterwards). ## Verification Head `74870830` (`630966a2`, then one merge of `origin/main` at `a52761fd`). The diff is 3 files, +37 / -1. <details><summary>Local gates on 7487083: 95 derived, 95 run, all exit 0, 0 NOT MEASURED (`dispatch-gates --ran`, exit codes recorded)</summary> - `pnpm install --frozen-lockfile` (exit 0), then `pnpm --filter @objectstack/spec build` under the verify lock (`VERDICT command-exit 0`). After that, every command from `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, each with its exit code captured before any pipe. - On the first pass 88 commands exited 0 and 7 exited 3 (PREREQUISITE NOT MET): `check-plugin-teardown-shape --self-test` (shallow clone), `check:doc-formula-expressions`, `check:doc-security-posture`, `check:skill-examples`, `check:docs-transcript-drift`, `check:dual-build-cjs-loads` and `check:lean-entry-closure` (unbuilt workspace packages). I unshallowed the clone and ran `turbo run build --concurrency=2 --filter='!@objectstack/docs'` under the lock (`VERDICT command-exit 0`, 119/119 tasks). All 7 then exited 0. - `--ran` with `COMMAND :: exit N` records: `95 derived famil(ies) accounted for — 95 run, 0 NOT-MEASURED (a DERIVED zero — all 95 recorded an exit code and none of them is 3)`. - `NODE_OPTIONS=--max-old-space-size=4096 pnpm --filter @objectstack/spec check:generated`: exit 0, `All 14 generated artifacts are up to date`. A first run at the default heap went red only because `check:test-typecheck`'s `tsc` ran out of memory ("failed without diagnostics", heap OOM), not because an artifact was stale. - `pnpm --filter @objectstack/spec typecheck`: exit 0. `node scripts/check-dev-prereqs.mjs`: exit 0. `node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD`: exit 0. - Not run locally: `@objectstack/spec`'s vitest suite. Every non-comment token is unchanged (see Acceptance notes), so it is left to CI's `Test Core`. - Writes: `git push` (empty branch, `630966a2`, `74870830`); one relay `pr_create`; no GitHub MCP call. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_017ihL2ebbZkr2QAEG1x7UC8)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent dcb5fb3 commit 471add3

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
docs(approvals): say how a request with no submitter leaves the `returned` state
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **`@objectstack/spec`: comment text only.** The `IApprovalService` docblocks on `recall`, `sendBack` and `resubmit` now state the path for a request with no submitter (its run's trigger resolved no user): nobody can recall it once it is `returned`, a system-context `resubmit` is its way out, and the next round opens `pending` with no submitter, where the system or the override actor may recall it. The `resubmit` docblock now names the system context it already admits. No key, type, schema or behaviour changes.

‎content/docs/automation/approvals.mdx‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,26 @@ over approval items), the recall also wakes the batch, which records the item's
773773
slot as the cancelled marker `{ $status: 'cancelled', $itemRunId }` and moves on
774774
to its next item or its end.
775775

776+
**A request with no submitter.** A run whose trigger resolved no user (a
777+
schedule, time-relative or api trigger, or a record-change fired by a system
778+
write) opens its request with no submitter. An approver can still send it back,
779+
but once it is `returned` nobody can recall it: `recall` reaches a `returned`
780+
request for its submitter alone, never the system or the admin override, and no
781+
viewer sees Resubmit or Recall. Its one way out is a `resubmit` made by
782+
server-side code in a system context (`IApprovalService.resubmit` with
783+
`isSystem: true`, and an `actorId` naming the acting identity, which a system
784+
caller must supply). That opens the next round `pending`, again with no
785+
submitter, where the system or the admin override can recall it. On a flow whose
786+
trigger never carries a user (schedule, time-relative or api), keep the `revise`
787+
edge into its `approval_revise` node only when server-side code will make that
788+
resubmit: the window is the only shape send-back accepts, and nothing in the run
789+
can end it. Otherwise leave the `revise` edge off, so send-back is refused and
790+
approvers reject instead. A record-change flow has no submitter only when a
791+
system write fired it; such a round, once sent back, waits in the window for
792+
that server-side resubmit, or a platform operator's
793+
`POST /api/v1/automation/:name/runs/:runId/cancel` discards the run and leaves
794+
the request `returned`.
795+
776796
The window is deliberately **not** an ordinary `wait`: `resubmit` is what
777797
authorizes (submitter-only), orders (latest round) and records (an audit row) the
778798
continuation, and refuses when another request is already pending on the record —

‎packages/spec/src/contracts/approval-service.ts‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,9 +1035,16 @@ export interface IApprovalService {
10351035
* - `returned` (ADR-0044) — the submitter ALONE, and only on the LATEST
10361036
* `returned` request of its (run, node): they abandon the revision window
10371037
* instead of resubmitting, the request flips `returned → recalled`, and
1038-
* the run resumes down `reject` the same way. Neither the override nor the
1038+
* the run is cancelled (the revise window has no `reject` edge to resume
1039+
* down). Neither the override nor the
10391040
* system arm reaches a `returned` request (#12775); an override actor is
10401041
* refused there exactly as any other non-submitter.
1042+
*
1043+
* A request with no submitter (its run's trigger resolved no user) has no
1044+
* one on the `returned` arm. Its way out of `returned` is a system-context
1045+
* {@link resubmit}, which opens the next round `pending`, again with no
1046+
* submitter, where the `pending` arm's system context or override actor may
1047+
* recall it.
10411048
*/
10421049
recall(requestId: string, input: ApprovalRecallInput, context: ExecutionContext): Promise<ApprovalRecallResult>;
10431050

@@ -1048,6 +1055,14 @@ export interface IApprovalService {
10481055
* {@link resubmit}s). Requires the approval node to declare a `revise`
10491056
* out-edge; past the node's `maxRevisions` budget the request auto-rejects
10501057
* instead. Audited as `revise`.
1058+
*
1059+
* A request with no submitter is sent back the same way, but only a
1060+
* system-context {@link resubmit} moves it on from `returned` (see
1061+
* {@link recall}): a flow whose trigger never carries a user (schedule,
1062+
* time-relative, api) declares the `revise` edge only when server-side code
1063+
* will make that call. A record-change flow has no submitter only when a
1064+
* system write fired it; that round, sent back, waits for the call, or an
1065+
* operator's `cancelRun` discards the run and leaves the request `returned`.
10511066
*/
10521067
sendBack(
10531068
requestId: string,
@@ -1057,7 +1072,8 @@ export interface IApprovalService {
10571072

10581073
/**
10591074
* ADR-0044 resubmit after rework. Valid on the LATEST `returned` request of
1060-
* its (run, node), submitter-only. Resumes the suspended run from the wait
1075+
* its (run, node), by the submitter or a system context (the system context
1076+
* alone on a request with no submitter). Resumes the suspended run from the wait
10611077
* point; traversal re-enters the approval node via the declared back-edge
10621078
* and opens the next round's request (fresh approver slate, record
10631079
* re-locks). Audited as `resubmit` on the returned request.
@@ -1132,8 +1148,8 @@ export interface IApprovalService {
11321148
* call left the row where none of them can issue the continuation it owes.
11331149
* ⚠️ Not because the row is never `returned`: a stranded send-back leaves
11341150
* it exactly there, and {@link resubmit} is still no way back — it is
1135-
* submitter-only, and it owes the `resubmit` edge where the stranded
1136-
* continuation was the `revise` one. Meanwhile a generic engine resume is
1151+
* by the submitter or a system context only, and it owes the `resubmit`
1152+
* edge where the stranded continuation was the `revise` one. Meanwhile a generic engine resume is
11371153
* refused at a node declaring `resumeAuthority: 'service'`. The only verb
11381154
* left was cancel, which discards the branch's downstream work. This is the
11391155
* issuer that exits that dead end.

0 commit comments

Comments
 (0)