Skip to content

Commit c826e8a

Browse files
fix(spec): an action's operation: 'delete' refusal names the script and flow routes (#37794)
<!-- claude-projects-attribution: {"github_login":"hotlong"} --> _Requested by **Jack** · [project thread](https://claude.ai/code/project/chan_01EF41AQooqveF2DGD8nqPzS?thread=cmsg_01EF41AQooqveF2DGD8nqPzSEfdkEPm9YGfc3wYraC2vqA)_ Fixes #37775 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:搭建者(智能体或人)给动作写「删除当前记录」被拒时,拒绝信息里会说清该怎么做:用以操作者本人身份运行的流程动作。 - 为什么做:云端智能体效果专题的搭建线,发票场景里智能体被拒两次后放弃了「删明细行」动作,丢了分。 - 出错会怎样:只改了拒绝文字,拒绝本身和错误种类不变,可直接撤回。 - 要你做什么:无。 ## What changes `operation: 'delete'` on an action stays refused with the same issue code (`invalid_value`). The message now ends with the working route: a `type: 'flow'` action naming an autolaunched flow that deletes the record. The flow runs as the caller, so the caller's delete permission applies. The script route is deliberately not named: a script action body runs elevated (`isSystem`, see `packages/runtime/src/sandbox/script-runner.ts` and `body-doors.ts`), so a delete there would skip the caller's delete permission and sharing (L1 review). Premise check on `origin/main` 56c9cae: the refusal is at `packages/spec/src/ui/action.zod.ts:1698` and its assertion at `action-row-update.test.ts:287`, as the card says. No other file pins the sentence. Files to read first: `packages/spec/src/ui/action.zod.ts` (the `operation` error map), then the test. ## Tests - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/ui/action-row-update.test.ts`: 32 passed. The existing case keeps its `code` + first-sentence assertions, adds a `toContain` check for the flow route and a `not.toContain` check that no script route is suggested. - `pnpm --filter @objectstack/spec typecheck`: exit 0. - Whole `@objectstack/spec` suite on a fresh `--ignore-scripts` install: the first run had 117 files fail to load because the generated `src/migrations/registry.ts` did not exist yet (it is generated mid-run); re-running those 116 test files after `pnpm gen:migration-registry`: 115 passed, 1 failed. The one is `scripts/def-key-collisions.test.ts` (`Cannot find module …/restored-limb/node_modules/.pnpm/tsx…/cli.mjs`, a copied tree without tsx), unrelated to this diff; CI's `Test Core` is the verdict. ## Acceptance notes - The semantic upgrade entry `18.ui-page-action-row-operation-declared.ts` still says "A row delete is the object's own delete affordance" without the route. Left as is: it is shipped upgrade text, and this card is the refusal message only. ## Verification `node -e "import('@objectstack/spec').then(m=>console.log(m.ActionSchema.safeParse({name:'x',label:'X',operation:'delete'}).error.issues.find(i=>i.path[0]==='operation').message))"` after a spec build: the message ends with the flow route and names no script route. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q4EjjMuWk2AuaVuFhVepja <!-- signed: epic:#5027#1 · hotlong · session_01Q4EjjMUfmNYTem26rXLFUf --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2980483 commit c826e8a

3 files changed

Lines changed: 16 additions & 0 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+
fix(spec): an action's `operation: 'delete'` refusal names the flow route that deletes the current record as the caller
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`operation: 'delete'` on an action is refused, as before: a row delete is the object's own delete affordance, not a declarative action. The refusal now also says how to build the action an author wanted: a `type: 'flow'` action naming an autolaunched flow that deletes the record. The flow runs as the caller, so the caller's delete permission applies. A script action is deliberately not suggested: its body runs elevated and would skip that permission. An agent building a "delete this line" action used to stop after two refusals that named no way forward. Nothing else changes: the same input is refused with the same issue code.

‎packages/spec/src/ui/action-row-update.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ describe('mixing rule: one refusal per contradiction, at the contradicting key',
285285
const del = issueAt(ActionSchema.safeParse({ ...duly, operation: 'delete', patch: undefined }), 'operation');
286286
expect(del?.code).toBe('invalid_value');
287287
expect(del?.message).toMatch(/^`operation: 'delete'` is a bulk-def operation with no row-level form: a row delete is the object's own delete affordance/);
288+
// the refusal names the working route, so an author is not left guessing
289+
expect(del?.message).toContain("declare a `type: 'flow'` action naming an autolaunched flow that deletes the record: the flow runs as the caller, so the caller's delete permission applies.");
290+
// never the script route: a script body runs elevated and would skip the caller's delete permission
291+
expect(del?.message).not.toContain("type: 'script'");
288292
const custom = issueAt(ActionSchema.safeParse({ ...duly, operation: 'custom' }), 'operation');
289293
expect(custom?.code).toBe('invalid_value');
290294
expect(custom?.message).toMatch(/^`operation: 'custom'` is a bulk-def operation with no row-level form: on a bulk def `'custom'` dispatches the action the def NAMES/);

‎packages/spec/src/ui/action.zod.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,8 @@ const actionObject = () => strictObject({
16961696
? `\`operation: '${issue.input}'\` is a bulk-def operation with no row-level form: `
16971697
+ (issue.input === 'delete'
16981698
? 'a row delete is the object\'s own delete affordance, not a declarative action (and was not ruled for the row form). '
1699+
+ "To delete the current record from an action, declare a `type: 'flow'` action naming an autolaunched flow "
1700+
+ "that deletes the record: the flow runs as the caller, so the caller's delete permission applies. "
16991701
: "on a bulk def `'custom'` dispatches the action the def NAMES; on a row the action IS the action, so there is nothing to name. ")
17001702
+ "The one row-level operation is `'update'` (a static `patch` written to the current record)."
17011703
: undefined),

0 commit comments

Comments
 (0)