Repository navigation
fix(plugin-detail): after a 409, the stage menu asks what the re-read record needs - #36296
Conversation
…fter a 409 Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5oLLK7uoxp33riiBJL Final green head for L1: |
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5ozidcgr4FYrKfmrjD 维护者速读
席位核对 — ACCEPT (L1-d) · repo:objectstack#4 · head
|
|
repo:objectstack#4 · os-project-manager · session_01FEkQ5oLLK7uoxp33riiBJL Landing · head
State: ready + auto-merge; on MERGED |
objectstack-ai#35928) (objectstack-ai#36316) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XTRdLmK9YYgMSCJ7NH2PuUY)_ repo:objectstack#7 · zhuangjianguo · session_01QsR2jVTYADzVWfarACx5j3 Fixes objectstack-ai#35928 Clause-②: yes (widening: one new public read, `POST /api/v1/automation/_record-starts`, and the UI exports that read it) Metadata-protocol: added Skills-docs: none — no skill under `skills/**` teaches the console's stage confirms; `content/docs/automation/flows.mdx` and `content/docs/frontend/plugins/plugin-grid.mdx` document the read and the list in this change. Ruling-ref: 7073655354 ## 维护者速读 - 用户在列表单元格或记录页改阶段时,确认框在原来那句话下面列出这次改动会启动的流程名称(按用户语言显示),带审批的流程标「发起审批」;以前只写「可能触发相关自动化」。 - 属于行内编辑专题,按维护者的裁定「能改这条记录的人都看到流程名称」,让用户确认前就知道保存后会发生什么。 - 出错时最多是清单少列或不显示,确认框退回今天那句话,保存本身不受影响;整个改动可以直接撤回。 - 无。 ## What changes **Server (one new read).** - `@objectstack/spec/api`: `RecordUpdateStartsRequestSchema` (`{ object, recordId, changes }`, strict), `RecordUpdateStartSchema` (`{ name, label, startsApproval }`), `RecordUpdateStartsResponseSchema`, and the contract entry `listRecordUpdateStarts` (`POST /api/v1/automation/_record-starts`). `_record-starts` joins the `/automation` domain's reserved position literals (underscore-led, so the package-namespace install gate is not narrowed). - `@objectstack/spec/contracts`: `RecordUpdateStartsInput` and the optional `IAutomationService.listRecordUpdateStarts`. - `@objectstack/spec/automation`: `recordChangeTriggerHookEvents` / `recordChangeTriggerFiresOnUpdate`, the record-change token grammar MOVED out of `@objectstack/trigger-record-change` (whose `triggerTypeToHookEvents` now delegates to it), so the trigger and the preview read one rule. - `@objectstack/service-automation`: `AutomationEngine.listRecordUpdateStarts` (`record-update-starts.ts`). A flow is asked only when it is enabled and armed on a `record_change` trigger for this object whose token binds an update; whether it starts is `startConditionHolds`, the one start-condition gate every run attempt passes, over the variables `seedRunVariables` seeds (`record`, its flattened fields, `previous`). The approval mark is the presence of an `APPROVAL_NODE_TYPE` node (ADR-0019). A condition that throws is not listed. Hooks are never listed (ADR-0077 §2). - `@objectstack/runtime`: the `/automation` domain's `_record-starts` door, mounted in the dispatcher plugin and recorded in the route ledger. Order: query parameters refused `400 VALIDATION_ERROR`; body parsed through the request schema (`400 VALIDATION_FAILED`); `501` when the engine has no preview; the record read AS THE CALLER through the `/data` door's own `get` (`callData`), so an unreadable record answers `404 RECORD_NOT_FOUND` exactly like an absent one and the engine is never asked; a read that answers no record is refused the same `404`; every `changes` key must be a declared field of the object (else `400 VALIDATION_FAILED` on `changes.KEY`, the engine never asked); then the engine is handed `previous` = the record read, `record` = that record with `changes` applied, and the caller's `userId` / `tenantId`. Anonymous `401`. - `@objectstack/client`: `client.automation.listRecordUpdateStarts(request)`. **UI (two confirms, one reader).** - `@object-ui/plugin-detail`: `stageChangeStarts.tsx` — `useRecordUpdateStarts(ask)` (asks the route once per pending move through the host's `apiFetch`, parses the answer through `RecordUpdateStartsResponseSchema`, answers `[]` while in flight, refused, failing, malformed or empty) and `StageChangeStarts` (the list under the sentence: each flow by its label translated through `activeFlowsBundle` + the spec's `translateFlow`, the flow runner's reading; an approval flow marked). Exported for the grid. - Record page: `recordPathStageChange.tsx` draws it in both confirmations (the path's `AlertDialog` and the header stage menu's `RequiredFieldsDialog`, via a new optional `notice` slot in `@object-ui/fields`). - List cell: `ObjectGrid`'s state-machine confirm draws it; `StateChangeConfirm` gains an optional `ask` (the row's record id and the move). - `@object-ui/i18n`: `activeFlowsBundle` moves here from `@object-ui/app-shell`'s module-internal `utils/flowsBundle` (its three app-shell importers repointed), since the confirms' packages do not depend on the console; two keys in all eleven packs: `detail.stageChangeStartsHeading`, `detail.stageChangeStartsApproval`. - The confirm's sentence is never replaced (not this card: objectstack-ai#35685 S3). A move that starts nothing, and a failed read, leave the confirm exactly as today. Docs: `content/docs/automation/flows.mdx` (§ Which flows a record update would start), `content/docs/frontend/plugins/plugin-grid.mdx` (the confirm now names the flows). Changesets: `35928-record-update-starts-read.md`, `35928-stage-confirm-names-flows.md`, both carrying the Clause-② and Metadata-protocol lines. ## Tests - Engine `record-update-starts.test.ts` (8): condition holds / does not hold; approval mark CONTROL (an approval flow and a plain flow side by side); no condition; create / delete / other object / obsolete never named while `record-before-write` is; an unevaluable condition not named; an unarmed engine answers nothing; `current_user` evaluated as the writer named. - Door `automation-record-update-starts.test.ts` (13): a member is answered (body parsed through the response schema) and the engine is handed exactly the record read as the caller; empty list; unreadable record `404 RECORD_NOT_FOUND` with the engine never asked; unreadable and absent answer alike; anonymous `401` before any read; malformed body `400 VALIDATION_FAILED`; query parameter `400 VALIDATION_ERROR`; `501` without the preview; a GET of the literal is not this door.; a change key that is not a field `400 VALIDATION_FAILED` on that key (an undeclared key, a key off the field-name grammar, an inherited member name), the engine never asked; a change on an object the registry does not declare refused alike; a read that answers no record `404 RECORD_NOT_FOUND`, never previewed; and the ledger row names `RecordUpdateStartsRequestSchema` / `RecordUpdateStartsResponseSchema`, as the clone and publish-drafts suites pin theirs. - Spec `automation-api.zod.test.ts`: contract count and the new entry's method/path; request strictness; a leaked `condition` / `nodes` dropped by the response parse. Each `changes` key is held to the field-name grammar (refused: a dotted, an upper-case, a digit-initial, a spaced and an empty key). - List cell, in its confirm's harness `ObjectGrid.autosave-35685.test.tsx` (new top-level describe, 3): list (request body pinned, labels, approval mark under the unchanged sentence), empty, failure (and Change still saves the move). - Record page, in each confirm's harness (new top-level describe in each, 3 + 3): `record-path.stageChange-28199.test.tsx` (the path's confirmation) and `RecordStageMenu-35891.test.tsx` (the header stage menu's dialog): list, empty, failure (a refused read, a network error and a malformed envelope each draw no list). - `stageChangeStarts-label-35928.test.tsx` (2): a flow named by its translation where the app's `flows` bundle has one, by its authored label where not; nothing drawn for no flows. - Ablation (one-shot under the verify lock, restored by trap, `git diff HEAD` on both sources empty): removing the `StageChangeStarts` render from `ObjectGrid.tsx` and from both confirmations in `recordPathStageChange.tsx` turns exactly the three `list:` pins red (`Tests 3 failed | 6 passed`); empty and failure pins stay green, as they should. ## Acceptance notes - Card acceptance: "Changing a stage that starts a flow shows that flow by name in both confirms" — pinned in both confirms (list cell, and both record-page confirmations) and measured live (below); "a stage with nothing attached shows no list" — the empty pins; "a read failure falls back to the generic sentence" — the failure pins. - Residual, stated in the contract docblocks and `flows.mdx`: the preview binds the caller's user id and tenant only, not their positions, request params or expand as a live run does, so for a condition reading those the preview can differ from the save in either direction (it can miss a flow, or list one a negated test of the writer would stop); the seat files the follow-up for positions. - Residual (not widened here): conditions are judged on the record as the CALLER reads it (field-level security applied), so a condition that reads a field the caller cannot see is judged on what they see, and one that throws on a missing field is not listed. The preview can therefore under-list for a caller with masked fields; it never reveals a masked value. Documented in `flows.mdx`. - Residual: the header stage menu's dialog asks with the stage alone; values typed into that dialog for required fields are not part of the preview's `changes`. - Two existing confirm suites (`RecordStageMenu-35891`, `record-path.stageChange-28199`) now stub `fetch` with a `501` answer in `beforeEach`, so the new read does not leave for the network under test; no existing assertion changed. Across the touched UI packages the run shows 0 `ECONNREFUSED`. - The approval mark is the ruling's test, "the flow contains an approval node". Measured live, showcase's `showcase_project_closure` reaches its sign-off approval through a `subflow` node (the approval node lives in `showcase_closure_signoff`), so the preview lists it with `startsApproval: false`. Following subflow references for the mark is a reading beyond the ruling: filed objectstack-ai#36322. - Overlap (`overlap-check.mjs` at the head below, exit 1, reported and not merged around): objectstack-ai#36296 and objectstack-ai#36236 have landed and are merged in. objectstack-ai#36335 (part of objectstack-ai#35979) moves `activeFlowsBundle` into `@object-ui/i18n` too and conflicts in `ui/packages/i18n/src/flowsBundle.ts`, `ui/packages/i18n/src/index.ts` and `ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx`; it lands after this PR and drops its copy of the move. Every other open PR that shares a file merges cleanly. - Declaration correction: the claim and ruling 7073655354 read `Metadata-protocol: none`, but the three new `@objectstack/spec/api` schemas enter the `api` authorable-surface shard (10 keys), which `Check Changeset` reads as `added` (`none-baseline-moved`). The line is `added` and `@objectstack/spec` is graded `minor`, as objectstack-ai#32251, objectstack-ai#35789 and objectstack-ai#31883 were for new api request/response schemas. No flow or other metadata key is added, so the ruling's "no new authorable key" still holds. ## Verification - Read first: `packages/runtime/src/domains/automation.ts` `respondToRecordUpdateStarts` (the order of refusals and the caller-scoped read that admits the engine), then `packages/services/service-automation/src/record-update-starts.ts` (which flows are asked and the one gate they pass). - Live, on a fresh showcase (`pnpm dev -- --fresh`), as a member created by the admin (`role: user`, not an admin): - `Website Relaunch` `status: active → completed`: `200 {"flows":[{"name":"showcase_project_closure","label":"Project Closure with Sign-off (nested pause)","startsApproval":false}]}` - same record `→ on_hold` (CONTROL): `200 {"flows":[]}` - same record `budget 150000 → 250000`: `200 {"flows":[{"name":"showcase_budget_approval","label":"Project Budget Approval","startsApproval":true}]}` - an absent record: `404 RECORD_NOT_FOUND`; anonymous: `401 UNAUTHENTICATED`; a body without `changes`: `400 VALIDATION_FAILED` naming `changes`. - Zone 2 premise, measured before any code: the same kind of member reads `GET /api/v1/meta/flow` (200, 33 flows with labels, the admin's set) and `GET /api/v1/meta/flow/showcase_closure_signoff` (200, its nodes). - The console itself was not driven in a browser (its dist is not built in this container); both confirms are pinned through the real components above. - Local, all under `scripts/pm/os-verify-lock.sh` (shared box): - touched UI packages (`plugin-detail`, `plugin-grid`, `fields`, `i18n`): `Test Files 1131 passed | 2 skipped` · `Tests 13186 passed | 38 skipped`; after folding the pins into their harness files the three files plus the label file: `Tests 77 passed (77)`. - type-check: `tsc --noEmit` (src and test projects) for `i18n`, `fields`, `plugin-detail`, `plugin-grid`, and src for `app-shell`; `service-automation`, `runtime`, `client` exit 0. - server: engine 8/8, door 9/9, `route-ledger.conformance` + `automation-api-contract-mounts` + `http-dispatcher` green, client conformance 11, spec `automation-api.zod` + `address-grammar` 87, `trigger-record-change` 122. - `dispatch-gates.mjs --commands` (129 families) run and reconciled with `--ran`: `129 run, 0 NOT-MEASURED`. First pass reds were all this diff's own owed artefacts, fixed and re-run green: spec `gen:api-surface` / `gen:docs` / `gen:export-origins` / `gen:declaration-map` / `gen:strictness-ledger` (api count 533 → 536: the three new schemas), the route-ledger census sentence (149 → 150), and `check:test-source-alias` (a spec/automation alias in the trigger package's vitest config; the door test pays `@objectstack/metadata` at collection). - Re-verified after the hand-over (seat 7), main `b3bcfefc` merged in at `472457d9`, the generated surfaces regenerated at `6bd111ff` (`gen:schema` → spec build → `gen:api-surface` → `gen:export-origins` → `gen:declaration-map` → `gen:docs` → `gen:strictness-ledger`; `check-regen-pending` clear), the changeset correction at `99bfd857`. Under the verify lock at `6bd111ff`: - type-check exit 0: `@object-ui/i18n`, `fields`, `plugin-detail` (src and test; the hand-over's stale-dist red is gone after the closure build), `plugin-grid`, `app-shell`; `@objectstack/spec`, `runtime` (src and test layer, after building `@objectstack/driver-turso`), `service-automation`, `client`, `trigger-record-change`. - tests: `runtime` Tests 11745 passed | 25 skipped; `service-automation` 4224 passed; `client` 820 passed; `trigger-record-change` 122 passed; spec `automation-api.zod` + `address-grammar` 87 passed; `plugin-detail` + `plugin-grid` + `fields` + `i18n` Test Files 1135 passed | 2 skipped, Tests 13300 passed | 38 skipped. - `dispatch-gates.mjs --commands` (129 families): run at `99bfd857` (the six that started before that commit re-run on it) and reconciled with `--ran`: `129 derived, 128 run, 1 NOT-MEASURED, 0 UNRUN`. The one NOT-MEASURED is `check:dual-build-cjs-loads` (exit 3, PREREQUISITE NOT MET: it needs every package's dist, which this container does not build); CI runs it in its Lint jobs, green at this head. - CI at `99bfd857`: every check-run green or skipped by design. Check Changeset shows two runs: the `synchronize` run (09:07Z, before the body said `added`) red, the `edited` run (09:08Z) green. - Contract review rework (L2 at `99bfd857`), at `3ba211dc` and `d2279e6c` (head): - the door refuses a change key that is not a declared field of the object and a read that answers no record; the request schema holds each change key to the field-name grammar; the ledger row is pinned; the preview's caller binding is stated in the contract docblocks and `flows.mdx`; `_record-starts` joins the address module's literal list. - ablation, one-shot under the verify lock (`ablation-replace.mjs`, restored by trap, blob == HEAD and `git diff HEAD` empty after each): the declared-field refusal disabled → `Tests 2 failed | 11 passed` (the two refusal pins); the no-record refusal disabled → `Tests 1 failed | 12 passed` (its pin). - local: `runtime` Test Files 637 passed, Tests 11749 passed | 25 skipped; door suite 13/13 at the head; spec `automation-api.zod` + `address-grammar` 88 passed; type-check exit 0 for `spec`, `runtime` (src and test layer, at `d2279e6c`), `service-automation`, `client`, `plugin-detail`. - `dispatch-gates.mjs --commands` at `3ba211dc`: `129 derived, 129 run, 0 NOT-MEASURED, 0 UNRUN`; the 37 families that read test files re-run at `d2279e6c` (a one-line test-type fix), all exit 0. - CI at `d2279e6c`: 70 check-runs, 61 success and 9 skipped by design, Check Changeset green. - Delta round (L1-d 7078831268, L2 nit N3 from 7078841748), at `41487226` (head): the 401 and 501 pins assert `body.error.code` (`UNAUTHENTICATED`, `NOT_IMPLEMENTED`) beside the status; the spec changeset names the undeclared-change-key `400 VALIDATION_FAILED` and the no-record `404` among the door's refusals; the caller-binding limit reads "can differ from the save in either direction" in the request schema's docblock, `RecordUpdateStartsInput` and `flows.mdx`. Door suite 13/13; type-check exit 0 for `spec` and `runtime` (src and test layer); `dispatch-gates.mjs --commands` at `41487226`: `129 derived, 129 run, 0 NOT-MEASURED, 0 UNRUN`; CI at `41487226`: 70 check-runs, 61 success and 9 skipped by design. https://claude.ai/code/session_01FEkQ5keqTTiV8ptWFNc6ZF https://claude.ai/code/session_01QsR2jVTYADzVWfarACx5j3 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jVTYADzVWfarACx5j3 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Leehom · project thread
Fixes #36036
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
useStageChange(ui/packages/plugin-detail/src/renderers/recordPathStageChange.tsx): the header stage menu's dialog no longer shows the field list frozen at the pick. Each render it askscollectRequiredWhenPromptFields(the one shared evaluator, unchanged, samefillable) against the record as it stands. After a 409 the re-read row arrives through the record context, so the list follows it: a field another writer filled leaves the dialog, and the dialog sends only the fields it shows, so the move no longer carries it.moreFields). Otherwise a typedloss_reason: otherwould still ask forloss_detailafter the other writer stored a different reason.RecordContext.refreshishandleManualRefresh, a synchronousnotifyDataChanged({ objectName: '*' })that returnsundefined.await ctx.refresh()resolves before the re-read lands, and the handler'srecordclosure is still the pre-409 row. A recompute inside the handler would read the stale row.Tests
New top-level
describe('#36036 …')in the component's existing harness fileRecordStageMenu-35891.test.tsx, which already holds the#35956block. Its host models the page's refresh: the notice returns at once and the re-read row lands on a later tick.loss_reason→ the field leaves, the description becomes the confirmation, no textbox. Move sends{ stage: 'closed_lost' }with the newifMatchand noloss_reason.loss_reasonand the typedPrice, and sends both with the new version.otherbrought inloss_detail; the other writer stored a different reason → both leave, Move sends the stage alone.Local runs (head 00948a7)
All under
scripts/pm/os-verify-lock.sh(shared box), head00948a77:pnpm exec turbo run build --filter='@object-ui/plugin-detail^...' --concurrency=2:Tasks: 52 successful, 52 totalpnpm --filter @object-ui/plugin-detail run type-check(tsc --noEmit && tsc -p tsconfig.test.json; the test project compiles the tests): exit 0pnpm --filter @object-ui/plugin-detail test:Test Files 403 passed | 1 skipped (404)·Tests 3729 passed | 18 skipped (3747)·VERDICT command-exit 0RecordStageMenu-35891.test.tsxalone:Tests 25 passed (25)(22 existing + 3 new)pnpm --dir ui exec vitest run --maxWorkers=2 scripts/:Test Files 172 passed | 2 skipped (174)·Tests 5122 passed | 2 skipped (5124)·VERDICT command-exit 0dispatch-gates --commands(38 families) run and reconciled with--ran: 38 derived, 37 run at exit 0, 1 NOT MEASURED.pnpm check:type-check-debtexited 3 (PREREQUISITE NOT MET: its whole-workspace re-measure never got a turn on the shared lock). This is a declared narrowing; CI runs it.overlap-check.mjs:VERDICT clean exit 0against origin/main a6756a2.Ablations (one-off, under the verify lock, via scripts/ablation-replace.mjs; restored, blob == HEAD, git diff HEAD empty)
fields={asked.map(label)}→fields={stage.fields.map(label)}(the pre-fix frozen list):Tests 2 failed | 1 passed | 22 skipped (25). Legs 1 and 3 red, the control green.{ ...sendable(values), [statusField]→{ ...values, [statusField]:Tests 1 failed | 2 passed | 22 skipped (25). Only the chained leg is red.@object-ui/*resolves to source through the ui vitest alias table, and the test imports../RecordStageMenurelatively, so nodist/sits in the path.Acceptance notes
RecordStageMenu-35891.test.tsxas a top-leveldescribeinstead, per AGENTS.md ("A new pin for a component that already has a shared harness file goes into that file as a top-leveldescribe, not a new file"). That file is where the#35956pin for this same dialog already lives.embeddedrecord view (list drawer, split preview),RecordDetailViewpassesrefresh={undefined}to the header'sRecordContextProvider. There the 409 branch'sctx?.refresh?.()re-reads nothing, so a second Move would carry the same staleifMatch. Not reproduced. Whether the stage menu renders in embedded mode was not measured.Verification
recordPathStageChange.tsxrenderFieldsDialog, theasked/noLongerAsked/sendablelines (the risk hunk: what the dialog shows and sends). (2) The#36036describe'smountReReadhost, which must model the page's refresh honestly (the row lands after the notice returns).pnpm --filter @object-ui/plugin-detail exec vitest run --root ../.. --maxWorkers=2 packages/plugin-detail/src/__tests__/RecordStageMenu-35891.test.tsx -t 36036. Expect 3 passed.Generated by Claude Code