Repository navigation
feat(approvals): a decided request's step line says where the record's approval went next - #37148
Conversation
…proval stands now Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
…val stands now Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
📓 Docs Drift CheckThis PR changes 2 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 6 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 175 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 65d235af8fa086d83ecb38146f7df91856f71f1b && git checkout 65d235af8fa086d83ecb38146f7df91856f71f1b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bc3ec37a669f1b80c393e31393caea49fb4f7b09 ee6bb2fbc12512d2426b9007a51d58a6d7c01158 && git checkout -B drift-repro bc3ec37a669f1b80c393e31393caea49fb4f7b09 && git merge --no-ff ee6bb2fbc12512d2426b9007a51d58a6d7c01158
node scripts/docs-audit/affected-docs.mjs --json bc3ec37a669f1b80c393e31393caea49fb4f7b09
|
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
… collection Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 1f6480a · 2026-11-24T23:45Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract reviewServed-tier: Inputs read: card #35863 (body and all four comments: triage 7042462136, unblock 7042569075, claim 7146092596, dev report 7147715077; no ruling and no earlier record on the card), PR #37148 body and file list, the net diff ① Derived judgments
② Semver level
Clause-②: yes — declared identically in the PR body and the changeset body; the change is an additive widening of a published contract type, no ③ Boundary flags
④ Design judgment
M1 (must-fix) — S1 (should-fix) — the new member crosses the request-visibility boundary and neither the contract nor the service says so. Nits (no effect on the verdict):
Open on this head: M1 (must-fix), S1 (should-fix). Implemented-by: VERDICT: FAIL |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — REWORK · repo:objectstack#3 · head 1f6480a · 2026-11-24T23:51ZL1: REWORK (L1-w, zone wf-B) The L2 at Should-fix (L1)S2. Three texts say
Read and found right (head 1f6480a)
Path to ACCEPTThe card thread fixes L2 M1 (with a pin for an approval inside a |
…ord's approval; the outcome states its audience Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 99ab892 · 2026-11-25T02:27Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract reviewServed-tier: Delta review of the round-0 record on head ① Derived judgments
② Semver levelUnchanged and still right: the changeset moves Clause-②: yes — declared identically in the PR body and the changeset; an additive widening of a published contract type. Agreed. ③ Boundary flags
④ Design judgmentM1: closed
M2 (must-fix) — the mirror of M1 is still open: a root run's request is served the end of the approval, and its own status as the last decision, when a later approval ran in a child run. Nits (no effect on the verdict):
Open on this head: M2 (must-fix). Implemented-by: VERDICT: FAIL |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — REWORK · repo:objectstack#3 · head 99ab892 · 2026-11-25T02:32ZL1: REWORK (L1-w, delta read, zone wf-B) The L2 at Closed this round:
One new must-fix is open, so this is REWORK. Seat ruling on L2's round-0 escalation (recorded here as the seat asked)The owning seat (repo:objectstack#3) ruled that Must-fix (from the L2, adopted)
Nit
Read and found right on the delta
|
…d "ended" A request a subflow body or a map item opens is filed under the child run's own id, so the root run's request rows cannot show it. A decided request before such a step was served "the approval ended here" with its own decision once the root run completed, though the approval went on to the child's step and that step may have decided otherwise. "Ended" is now claimed only for a root run whose flow holds no subflow or map node anywhere, regions included (flowHostsChildRuns, read off the definition, not the compacted step log). The contract, changeset and approvals docs say so; the route docblock cites the seat's ruling on PR #37148. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head e264c10 · 2026-11-25T03:17Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract reviewServed-tier: Delta review under claim 7151775534, of the record on head ① Derived judgments
② Semver levelUnchanged and right: Clause-②: yes — as declared in the PR body and the changeset; an additive widening of a published contract type. Agreed. ③ Boundary flags
④ Design judgmentM1: closed
S3 (should-fix) — "its flow" is the definition armed when the request is read, not the version the run ran, and the difference fails toward "ended". Nits (no effect on the verdict):
Open on this head: S3 (should-fix). Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — REWORK · repo:objectstack#3 · head e264c10 · 2026-11-25T03:20ZL1: REWORK (L1-w, delta read, zone wf-B) The L2 at Closed this round:
Should-fix (from the L2, adopted)
NitsL2 N2, N3 and the new N5 ( Read and found right on the delta
|
…oday's The read holds only the flow body armed now. A run that started a subflow, whose flow was later edited to drop it, was judged by the edit and served "the approval ended here". "Ended" now also needs the run to have provably run the armed body: that body is the flow's newest registration (the engine's version history, the very object) and was registered strictly before the run started. An edit, a rollback or a restart's re-registration since the run started leaves "ended" unclaimed. The run's flowVersion is not the witness: an edit need not change the author's number. The contract, changeset and approvals docs say which body is judged; the child-run node list names the two executors that set $parentRunId. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
…the newer one Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
…'s own status Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 6080e34 · 2026-11-25T04:04Z |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs Contract reviewServed-tier: Delta review under claim 7152521595, of the record on head ① Derived judgments
② Semver levelUnchanged and right: Clause-②: yes — as declared in the PR body and the changeset; an additive widening of a published contract type. Agreed. ③ Boundary flags
④ Design judgmentM1: closed No must-fix, no should-fix.
Nits (no effect on the verdict):
Implemented-by: VERDICT: PASS |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs 席位核对 — ACCEPT · repo:objectstack#3 · head 6080e34 · 2026-11-25T04:10ZL1: ACCEPT (L1-w, delta read, zone wf-B) No must-fix, no should-fix. The L2 at Delta
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php Landing · 2026-11-25T04:49Z · head ee6bb2f
Verdicts: L1 ACCEPT 7152601812 and L2 ( State change: ready for review + auto-merge (merge queue). On merge, |
…ld by its own approval or by its master's (objectstack-ai#37191) repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBEaJzgBWzjWCNjBjkVoeRto)_ Fixes objectstack-ai#37151 Clause-②: yes (widening: both lock doors' published entry gains a field) Metadata-protocol: none Ruling-ref: 7148480184 (maintainer, option A, 2026-11-25T00:22Z; seat record 7148474531). Execution, not a decision. ## 维护者速读 - 列表页和单条记录的“查锁”接口现在多回答一项:被锁的记录是自己的审批锁住的,还是所属主记录的审批锁住的;页面上暂时无变化,表格据此隐藏删除按钮由另一张卡(表格行菜单)接着做。 - 按你选定的方案 A 落地,替审批中报销单、订单的明细行使用者解决“列表给了删除、点了却被拒”的问题。 - 出错时最坏情况是某行的锁类型标错,表格多藏或少藏一个删除按钮,不会写错任何数据;可直接撤回。 - 无 ## What changes - **Both lock doors answer the kind.** `IApprovalService.getRecordLock` and `getRecordLocks` (and their REST doors `GET /api/v1/approvals/records/:object/:recordId/lock`, `POST /api/v1/approvals/records/:object/locks`) answer a locked readable row `{ locked: true, lockSource: 'record' | 'master' }`, an unlocked one `{ locked: false }`; `null` (404 / `locked: null`) still means unreadable-or-missing, never told apart. - `'record'`: a pending request on the row itself under a locking node. Its delete is accepted and cancels the request. - `'master'`: the row is a `master_detail` line of a held record (`bindDetailRowLockHook` refuses insert, update and delete). It **wins when both hold** (a self-held line under a held master), because that is the delete the server refuses. - **One spelling of the answer:** `recordLockAnswer(heldByMaster, heldItself)` in `approval-service.ts` builds it for both doors. The single door asks the master's lock first (so a self-held line under a held master answers `'master'`); the page door now asks the detail-row lock of every readable row, not only of the rows its record lookup left unlocked. Read counts per page are unchanged (the two existing read-count pins hold byte for byte). - **Spec contract** (`packages/spec/src/contracts/approval-service.ts`): both return types gain the optional `lockSource?: 'record' | 'master'` (optional, so an implementation answering `{ locked }` alone still conforms — a pure widening; no exported type or const is added, as with the original member). The objectstack-ai#25934 ruling A sentence "What is answered: `locked` only." is revised to state the new answer and cites ruling 7148480184; the batch docblock's "exactly what `getRecordLock` answers for that id" now says "spelled as the engine spells it" and names the anchor difference. - **REST** (`approvals-routes.ts`): both doors serve the answer through one projection, `recordLockPayload`, field by field — `locked`, and `lockSource` only on a locked answer and only when it is `'record'` or `'master'`. Anything else an implementation hands back (a request id, `pending`, an unknown kind) is not served; a locked answer naming no kind is served `{ locked: true }`. The route comment's parity sentence ("Each entry is exactly the single-record door's answer for that id") now adds "as the engine spells it" and names the anchor difference. - **Readability anchors, unchanged at both doors** (item 7148285178; Round 2 below). The two doors keep different readability anchors on purpose: the single door counts any returned row, the batch door only the row whose id is the asked id; aligning them would narrow a published answer (seat ruling on PR objectstack-ai#37191). Pinned both ways: the single door answers the lock for a loosely spelled id, the batch door answers it `null`, and the two agree for every id spelled as the engine spells it. - Docs: `content/docs/automation/approvals.mdx` states `lockSource` where it states the lock answer, and the exact-spelling rule. - Changeset: spec, plugin-approvals, rest at `patch` (`Metadata-protocol: none` ⇒ patch under the changeset-level ruling; the widening is declared on the `Clause-②` line). **Disclosure bound (objectstack-ai#8652 ruling 5299823744).** The field adds one kind bit to an answer already served only to a caller who can read the row: no request id, node, participants, approver identity, `pending` flag or request content. A caller who can write the line already learns the kind from the `RECORD_LOCKED` sentence; a read-only line reader learns which of the row and its master holds it, where before they learned that one of the two does. **Field name, measured.** `lockSource`, as claimed: spec `api/protocol.zod.ts` `lockSource` ("Which layer asserted the lock", an enum beside the lock flag, `kernel/metadata-protection.zod.ts` `MetadataLockSourceSchema`). Other `lock*` keys measured in `packages/spec/src`: `lockedBy` (a user id, `ui/view.zod.ts`), `lockScope` (`automation/execution.zod.ts`: global / per_record / per_user, the scope a concurrency lock covers, not its origin), `lockState`, `lockReason`; `heldBy` in `packages/cli` names holder packages (a principal). None is closer. ### Read these first 1. `packages/plugins/plugin-approvals/src/approval-service.ts` — `getRecordLock` (master asked first) and `getRecordLocks` (detail lock over every readable row). Riskiest hunk: the master-first order in `getRecordLock`. 2. `packages/rest/src/approvals-routes.ts` — `recordLockPayload`, the disclosure projection. 3. `packages/spec/src/contracts/approval-service.ts` — the revised ruled sentence. ### Two-minute verification `pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/record-lock-read.integration.test.ts` — expect 20 tests passed, including the `lockSource` describe (self-held record `'record'`, line of a held master `'master'`, self-held line under a held master `'master'` and its delete refused `RECORD_LOCKED`, self-held line under an unheld master `'record'` and its delete accepted) and the describe pinning each door's own readability anchor for a loosely spelled id. ## Tests - `record-lock-read.integration.test.ts` (real ObjectQL + better-sqlite3 + `ApprovalsServicePlugin.start()`): existing pins re-expressed with the kind; new top-level describes — `lockSource` single/batch parity for a self-held record, a line of a held master, a self-held line under a held master, an unheld record and line, a self-held line under an unheld master, the decided state; each kind tied to the delete the server refuses or accepts; and the readability anchor: a case-insensitive-collation stand-in (a read middleware folding `id` predicates), with a CONTROL that the engine does hand the row back under the loose spelling; the single door answers the lock for it, the batch door `null`; parity for every caller on ids the engine echoes; and a read-count pin for a page with a missing id. - `client.test.ts`: both SDK answers carry and type `lockSource` (a typed assignment the test program compiles). - `rest-approvals-record-lock-route.test.ts`: both doors serve `lockSource` on a locked answer, drop it on an unlocked one, drop an unknown kind and extra fields. - `approval-record-lock-read.dogfood.test.ts`: the fixture's `LOCKED` body gains `lockSource: 'record'` (stale-fixture consequence of this change). <details><summary>Run readings (head 00e32ec)</summary> Union of the derived local families at a453d12; the two ratchet families re-run at the final head 00e32ec (its only change types two test-call option bags). - `pnpm --filter @objectstack/plugin-approvals test` (a453d12): `Test Files 128 passed (128)`, `Tests 1928 passed (1928)`, lock `VERDICT command-exit 0`. - `pnpm --filter @objectstack/plugin-approvals typecheck` + `vitest run src/record-lock-read.integration.test.ts` (00e32ec): `check:test-typecheck: OK ... 8 file(s) / 321 error(s)` (unchanged debt), `Tests 20 passed (20)`, `VERDICT command-exit 0`. - `pnpm --filter @objectstack/rest test` (a453d12): `Test Files 429 passed (429)`, `Tests 8819 passed | 351 skipped (9170)`, `VERDICT command-exit 0`; `pnpm --filter @objectstack/rest typecheck`: exit 0. - `pnpm --filter @objectstack/spec build && pnpm --filter @objectstack/spec check:generated`: `All 14 generated artifacts are up to date`, exit 0. - Dogfood, this file only (`pnpm --filter '@objectstack/dogfood^...' build`, then `vitest run test/approval-record-lock-read.dogfood.test.ts`): `Tests 1 passed (1)`, `VERDICT command-exit 0`. Full battery not owed (no `!`, widening arm). - `dispatch-gates --ran`: `119 derived famil(ies) accounted for — 116 run, 3 NOT-MEASURED`. NOT MEASURED (exit 3, PREREQUISITE NOT MET, all in CI): `check-plugin-teardown-shape --self-test` (shallow clone cannot reach its pinned fixture commit), `spec check:skill-examples` (`client-react` not built in this worktree), `check:dual-build-cjs-loads` (unbuilt packages). `check:query-options-erasure` was red at a453d12 (test surface 236 to 237, two new `as any` option bags) and green at 00e32ec (`ratchet holds`, `test surface: 236`). `check:nul-bytes` at 00e32ec: OK. - `overlap-check`: `VERDICT clean exit 0` (origin/main and objectstack-ai#37148). </details> ## Round 2 (seat ruling on PR objectstack-ai#37191), head e99cf2c - **Anchor: not narrowed.** The single door's readability anchor is restored byte for byte to `origin/main` (any returned row counts as readable); the batch door keeps its strict anchor. The two doors keep different readability anchors on purpose: the single door counts any returned row, the batch door only the row whose id is the asked id; aligning them would narrow a published answer (seat ruling on PR objectstack-ai#37191). I found no reason the single door cannot keep its anchor: the `lockSource` master check reads the row through the engine (`detailRowHeldByLockingApproval`, whose existing pin answers from the row it found, not from the engine's spelling), so a loosely spelled line of a held master answers `'master'` at the single door. The round-1 anchor-parity pin is replaced by pins for the two kept behaviours. Changeset, `approvals.mdx`, both docblocks, the plugin docblocks and the batch route comment now state the two anchors instead of an alignment. - **Client SDK:** `client.approvals.getRecordLock` and `getRecordLocks` (`packages/client/src/index.ts`) type the answer with the optional `lockSource?: 'record' | 'master'`; pinned in `client.test.ts` with a typed assignment. `@objectstack/client` patch added to the changeset. Still a widening under the declared `Clause-②`. - **Not touched:** `record-page-routes.ts` and the skills sentence (routed to triage by the seat). <details><summary>Round 2 run readings (head e99cf2c)</summary> - `pnpm --filter @objectstack/plugin-approvals test`: `Test Files 128 passed (128)`, `Tests 1928 passed (1928)`; `rest` `vitest run src/rest-approvals-record-lock-route.test.ts src/rest-write-response-internal-fields.tripwire.test.ts`: `Tests 36 passed (36)`; `pnpm --filter @objectstack/client test`: `Test Files 59 passed (59)`, `Tests 820 passed (820)`; one lock run, `VERDICT command-exit 0`. - Typecheck plugin-approvals (test-layer debt unchanged at 321), rest and client (test layer 0 errors): exit 0. `spec build && check:generated`: `All 14 generated artifacts are up to date`. - Reverse checks (fix committed, worktree-only restores, both files restored with `git checkout HEAD`, hashes equal to HEAD's): `approval-service.ts` from 00e32ec (the strict single-door anchor) makes the kept-anchor pin red (`1 failed | 19 passed`); `packages/client/src/index.ts` from `origin/main` makes the client test-layer typecheck red (`src/client.test.ts: 2 type error(s)`). - `dispatch-gates --ran`: `120 derived famil(ies) accounted for — 116 run, 4 NOT-MEASURED`. NOT MEASURED (exit 3, PREREQUISITE NOT MET; all run in CI): `check-plugin-teardown-shape --self-test` (shallow clone), `spec check:skill-examples` (client-react not built), `check:dual-build-cjs-loads` and `check:i18n` (workspace packages and the CLI not built in this fresh worktree). `check:query-options-erasure` and `check:nul-bytes`: exit 0. - `overlap-check`: `VERDICT clean exit 0` (origin/main 893eac8 and objectstack-ai#37148). </details> ## Round 3 (L1 7152634100, L2 PASS with S1 7152618670), head 030cd91 Wording only; no behaviour change. - **S1:** round 2 said the single door answers "the lock" for a loosely spelled id. That is only half true. Measured against the code: `getRecordLock` counts any returned row as readable. Its master half (`detailRowHeldByLockingApproval`) reads the row the engine found, so a loosely spelled line of a held master answers `'master'` (pinned in round 2). Its own half (`recordHeldByLockingApproval`) looks up the pending request by the id as asked, so a record held by its own request may answer `{ locked: false }` under another spelling. That is main's behaviour. The spec batch docblock, the changeset and `approvals.mdx` now say exactly this; the plugin's `getRecordLock` docblock says it too. - **S2:** the anchor ruling is cited by comment id: seat ruling 7152650156 on objectstack-ai#37151. It withdraws the "built with a parity pin" line of 7148480184. The citation is in the spec docblock, the changeset and `approvals.mdx`, and also in the plugin docblocks, the batch route comment and the test header, replacing "seat ruling on PR objectstack-ai#37191". Triage's anchor row 7148285178 is carried, not ticked: the seat asked triage to move it to a carrier (mailbox objectstack-ai#36743 comment 7152670747). - **Nits:** the spec `getRecordLock` docblock now says an implementation may omit `lockSource` on a locked answer (the REST doors then serve `{ locked: true }` alone); the changeset says the same. The broken sentence in the client `getRecordLock` docblock is joined. - **Routing:** the skills sentence is a row on objectstack-ai#35769 (triage 7151747767), and the record-page composite is objectstack-ai#37195 (Acceptance notes updated). <details><summary>Round 3 run readings (head 030cd91)</summary> - `overlap-check`: `VERDICT clean exit 0` (origin/main bc3ec37, objectstack-ai#37148), run before the push. - One lock run (`VERDICT command-exit 0`): closure build of client and plugin-approvals (spec rebuilt), `spec check:generated` `All 14 generated artifacts are up to date`, typecheck client / plugin-approvals (test debt 321, unchanged) / rest exit 0, `record-lock-read.integration.test.ts` `Tests 20 passed (20)` (test header text changed). - Text gates, exit 0: `check:doc-authoring`, `check:issue-citations`, `check:docs-transcript-drift`, `check:nul-bytes`, `spec check:docs`, `check-affected-docs`, `check-empty-changeset`, `check-changeset-no-major`, `check:spec-docblock-symbol-anchors`. </details> ## Acceptance notes - **Not changed, carried elsewhere:** the published skill sentence in `skills/objectstack-automation/references/state-machines-and-approvals.md` ("`locked` and nothing else") is carried as a row on the skills sweep card objectstack-ai#35769 (triage 7151747767); the record-page composite (`packages/rest/src/record-page-routes.ts`, which serves its `lock` as `{ locked }` alone) is objectstack-ai#37195. - **Read-only inference, not filed:** the record-lock write hook keys a by-id write on the id as the writer spells it; on a driver whose id column matches a spelling the request bookkeeping does not (a numeric id asked as `07`), the hook's request lookup and the driver's row match could disagree. No public entry was shown to send such an id; no reach measured. - `ui/packages/plugin-grid/**` untouched: hiding Delete on `lockSource: 'master'` is seat 4's half under objectstack-ai#36911. ## Verification - Reverse verification (fix committed first): `approval-service.ts` restored from `origin/main` (a10345a) into the worktree only, `record-lock-read.integration.test.ts` run: 11 failed / 9 passed (round 1, at db800fe: every new and kind-bearing pin red); restored with `git checkout HEAD --`, blob hash equal to HEAD's, `git diff HEAD` empty. - Cross-package type check: the plugin's `getRecordLock` return type widened to admit a third kind ⇒ `tsc --noEmit` red `TS2416 Property 'getRecordLock' in type 'ApprovalService' is not assignable to the same property in base type 'IApprovalService'` against the rebuilt spec `dist`; restored, hash verified. - `overlap-check --branch=claude/issue-37151-lock-source-field`: `VERDICT clean exit 0` — merges cleanly with origin/main and with objectstack-ai#37148 (shares both `approval-service.ts` files, different regions). --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…dio-design reads and writes send the stored bearer token (objectstack-ai#37185) Fixes objectstack-ai#37080 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:浏览器里只剩登录令牌(会话 Cookie 被替换、拦截或清掉)的用户,侧边栏、应用头部、命令面板和 Studio 入口里的应用包列表不再消失,AI 对话列表、建议权限绑定、提交历史、草稿面板等也正常加载;只用 Cookie 登录的用户看不到任何变化。 - 为什么做:控制台其它请求都会带上登录令牌,这一批读写漏带,属于"控制台登录状态体验"这一块的缺陷,替所有处于这种登录状态的用户解决,并加了一道测试防止以后再写出漏带令牌的请求。 - 出错会怎样:最坏情况是这些地方重新读不到数据,与修复前一样;不改服务端接受什么、不改登录方式,可以直接撤回。 - 要你做什么:无。 ## What changes Same-server `/api/` reads and writes in app-shell and the console that called the bare global `fetch` with `credentials: 'include'` (the session cookie and nothing else) now go through `createAuthenticatedFetch` from `@object-ui/auth`, exactly as objectstack-ai#37077 did for the Setup pages: built per call (`createAuthenticatedFetch()(input, init)`, a local `authFetch` in each module), `credentials: 'include'` kept on every call, so the cookie still rides along and a `401` now reaches the console's session-ended check. No second auth-fetch helper and no new export. Nothing changes in what the server accepts. The measured case: under a bearer-only session, `readPackagesPayload` (`GET /api/v1/packages`, the session's held package list read by the sidebar, the app header, the command palette and the Studio entries) sends the bearer and the list loads (pinned below). ### The family, measured at `origin/main` 63ab479 79 non-test files under `ui/packages/app-shell/src` and `ui/apps/console/src` contain `credentials: 'include'`. Read call by call (AST scan of every `credentials: 'include'` property and the call it is handed to): **Converted here: 64 calls in 39 files.** | File | Calls | |---|---| | `app-shell/.../studio-design/packages-io.ts` | `readPackagesPayload` (`GET /api/v1/packages`, the measured case), `ensureCustomizationPackage`, `duplicatePackage` | | `app-shell/.../studio-design/packageCustomizations-io.ts`, `PackageSwitcher.tsx`, `AutomationsPillar.tsx`, `FlowItemMoreMenu.tsx` | 1 each (customizations read, switcher list, automation status, flow clone) | | `app-shell/src/hooks/useConversationList.ts` | 4 (list, detail, rename, delete) | | `app-shell/src/hooks/useChatConversation.ts` | 3 (read, create, update) | | `app-shell/src/console/ai/buildDebugApi.ts` | 1 (build-debug report) | | `app-shell/src/hooks/useAiUsage.ts` | 1 | | `app-shell/src/services/suggestedBindingsApi.ts` | 4 (list, confirm, dismiss, reopen) | | `app-shell/src/preview/commitHistory.ts` | 2 (timeline, revert) | | `app-shell/src/preview/DraftChangesPanel.tsx`, `UnpublishedAppBar.tsx`, `usePendingDrafts.ts` | 2, 1, 1 | | `app-shell/src/preview/flowDraftChecks.ts` | the default transport (`opts.fetchImpl ?? createAuthenticatedFetch()`) | | `app-shell/src/views/changeOwner.ts` | the fallback transport (`apiFetch ?? createAuthenticatedFetch()`) | | `app-shell/src/views/metadata-admin/` `PackageFormDialog.tsx`, `catalog-activation.ts`, `permission-set-clone.ts`, `sharing-rule-catalog.ts` | 1, 2, 1, 1 | | `app-shell/src/views/metadata-admin/inspectors/` `FlowReferenceField.tsx`, `connector-input-fields.ts` | 2, 1 | | `app-shell/src/views/metadata-admin/previews/` `FlowRunsPanel.tsx`, `useFlowNodePalette.ts`, `PagePreview.tsx` | 1, 1, 2 | | `app-shell/src/views/setup/` `packagedActionLedger.ts`, `packagedFlowLedger.ts` | 2, 1 | | `app-shell/src/hooks/` `useRecordApprovals.ts`, `sharedUserFeeds.ts`, `useInboxBell.ts` | 1 each | | `app-shell/src/console/` `AppNoAccessEmptyState.tsx`, `connect/ConnectAgentWidget.tsx`, `deployment-notice/deploymentNoticeState.ts` | 1, 2, 2 | | `app-shell/src/console/marketplace/marketplaceApi.ts` | 5 same-server calls onto the existing `serverFetch` (`/cloud-connection/install`, `install-namespace`, `installation`, and on the control plane its own `install_package` action and installed-state route) | | `app-shell/src/layout/designModeMenuSave.ts` | 1 (`/api/v1/i18n/locales`) | | `app-shell/src/layout/ContextSelectors.tsx` | 1, with `{ sameOriginOnly: true }`: the endpoint is author-written (`optionsSource.endpoint`) and may name another host | | `console/src/pages/developer/` `AgentConnectSection.tsx`, `IntegrationsPage.tsx` | 2, 1 | | `console/src/pages/auth/DeviceAuthPage.tsx` | 3 (claim, approve, deny: a signed-in act) | Of the card's named ones: `packages-io.ts` `readPackagesPayload`, `useConversationList`, `useChatConversation`, `suggestedBindingsApi` and the studio-design writes (ensure-customization, duplicate, customizations, flow clone) are all converted. `suggestedBindingsApi`, `useRecordApprovals`, `sharedUserFeeds`, `useInboxBell`, `ConnectAgentWidget`, `deploymentNoticeState` and three `marketplaceApi` calls already set the bearer header by hand (`authHeaders` / `bearerAuthHeaders` / `withEnvAuth`), so those were not cookie-only; they are converted anyway for the session-ended check and the one mechanism, and their hand-rolled header is left in place (the wrapper sets the same value). **Already authenticated or injected (not the family): 24 files.** `settings/api.ts`, `AuditLogPage.tsx`, `approvalsApi.ts`, `studioEntry.ts`, `ExcelImportBar.tsx`, `CloudAiModelStatus.tsx`, `useEnvironmentEntitlements.ts`, `storageUsageEndpoint.ts`, `ImpersonationBanner.tsx`, `useImpersonationExit.ts`, `RecordAttachmentsPanel.tsx`, `RecordDetailView.tsx`, `useConsoleActionRuntime.tsx`, `AccessExplainPanel.tsx`, `MetadataTypeActions.tsx`, `PackagesPage.tsx`, `DatasourceResourcePage.tsx`, `personalViews.ts`, `connectorConnections.ts`, `connectorCredentials.ts`, and the injected transports of `myPreferences.ts`, `slackDoors.ts`, `orgEnvironments.ts`, `useLauncherApps.tsx`. `App.tsx` names the string in a comment only. **Left, on the pin's shrink-only list: 21 calls in 15 files**, each with its reason in the pin (`sameServerFetch.bearer.ratchet.test.ts`, `ALLOWED`): - `console/src/LocalizationFetchProvider.tsx` (1) and `console/src/languageSeed.ts` (not counted by the pin: it hands `sharedGetJson` a transport argument that may be `undefined`): the boot read of `/api/v1/auth/me/localization`, shared in flight by a key built from the init with the early request `index.html` sends. A session it cannot see reads `authenticated: false` and falls back to the browser language rather than failing. Its transport is its own decision (Acceptance notes). - `console/src/components/FormPage.tsx` (1): the bare channel is the public form route's on purpose. - `console/src/lib/auth-preflight.ts`, `console/src/lib/early-discovery.ts` (1 each): set the bearer header themselves on purpose. - `console/src/pages/auth/OAuthConsentPage.tsx` (3), `followAuthorize.ts` (1), `handoffClientName.ts` (1): the OAuth hand-off, whose authorize step is a top-level navigation that can only carry the cookie. - `console/src/pages/auth/SetupPage.tsx`, `app-shell/src/console/auth/bootstrapStatus.ts`, `console/src/pages/auth/VerifyEmailPage.tsx`, `app-shell/src/chrome/ConditionalAuthWrapper.tsx`, `app-shell/src/runtime-config.ts` (1 each): read before or without a session. - `app-shell/src/console/ai/AiChatPage.tsx` (1): an open PR (objectstack-ai#37123) edits this file; its call moves with that work. - `app-shell/src/console/marketplace/marketplaceApi.ts` (5): each targets `getCloudBase() || SERVER_URL`, the cloud control plane's own origin whenever one is configured, which must never see this runtime's bearer. - `app-shell/src/views/metadata-admin/previews/ActionPreview.tsx` (1): the test request of an `api` action preview, sent to the author-written target; its transport is not decided here. The other two fenced files hold no family call: `RecordDetailView.tsx` and `useConsoleActionRuntime.tsx` already route every `credentials: 'include'` call through their `authFetch`. Neither was edited. ## Tests - `ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts` (new, the enumeration pin; runs in **Test UI**, app-shell's `unit` project): parses every non-test source file of both trees with the TypeScript parser and refuses a bare cookie-only call (the transport is the global `fetch`, `window.fetch`, `globalThis.fetch`, `self.fetch`, one of those as a `??` / `||` fallback, or `sharedGetJson` without its transport argument; the init carries `credentials: 'include'`, inline or as a `const` of the file, `as const` included). The URL is not judged: a call that must stay bare is a counted row with its reason. Four cases: the scan reads both trees (more than 500 and 100 files); a 13-case detector battery (each bare spelling found, each authenticated one not); every bare call is a counted row; every row is still exact (a file that sheds a call must shrink its row). - `ui/packages/app-shell/src/views/studio-design/packages-io.bearerSession.test.ts` (new): against a server that refuses any request without the bearer, with a token stored, `fetchPackages` loads the list and its one request carries `Authorization: Bearer TOKEN` and `credentials: 'include'`; `fetchListedPackageIds` likewise; the duplicate write, the commit timeline and revert, suggested bindings and the build-debug report carry the bearer. Each with a cookie-only control (no token stored: no `Authorization`, `credentials: 'include'`). Test doubles that moved (118 files, no assertion weakened): - 102 files: hand-rolled `Response` doubles (`{ ok, status, json }`) gain `headers: new Headers()`, the headers a real `Response` carries and the authenticated fetch reads (`set-auth-token`), as objectstack-ai#37077 did. The 102nd, `StudioPaletteGroups.surfaceScope-36900` (the command-palette suite that reached `main` after round 0), doubles `GET /api/v1/packages`: without the headers the converted `readPackagesPayload` threw on the double and the palette drew no Packages group. For `fetchInstalledPackageRow-7881` and `StudioDesignSurface.readOnlyPosture-12453` the headers are added at the one stub instead of each answer. - 8 files whose `@object-ui/auth` mock answered `createAuthenticatedFetch: () => vi.fn()` (a transport that answers nothing) now hand the authenticated fetch's requests to the global `fetch` the file already stubs: the four `RecordApprovalsPanel` suites and `RecordDetailView` `editLockedByState-32756`, `phoneFace-27058`, `userActionPredicates`, `harness`. - 5 `RecordDetailView` approval suites whose `authFetchSpy` stands for the action door: approvals reads (now through the authenticated fetch too) are handed to the file's wire double, as before (`approvalRecallGate`, `accessEndedAfterDecision-26589`, `approvalDeclaredActions`, `approvalLock-12220`, `approvalLock-25934`). - `StudioRoute.searchPalette-11863` (console): its auth mock answers the Studio permissions read and hands every other request (the package list) to the wire double. - 3 assertions read the init the wire received (the last two files are also among the 101): `useConversationList` and `BuildDebugDrawer` assert `{ credentials: 'include', headers: expect.any(Headers) }` (exact keys, as before); `DraftChangesPanel.flowChecks-34818` reads `Accept-Language` off a `Headers`. - `RecordDetailView.headerApiInterpolation`: the flow-trigger case asserts exactly one call to the trigger door, filtered by its path, since the page's own reads now share that spy. ## Acceptance notes - Same defect family outside the two trees, not touched (the card scopes the `plugin-*` hooks out unless measured here): `credentials: 'include'` with the bare `fetch` remains in `ui/packages/plugin-chatbot` (`useAgents`, `useAiModels`, `useHitlInChat`, `usePendingActions`), `plugin-detail` (`queueClaim`, `stageChangeStarts`, `useRecordEditable`), `plugin-grid` (`useRecordCrudVerdicts`, `useRowApprovalLocks`), `plugin-dashboard` (`DatasetWidget`), `plugin-charts` (`ObjectChart`), `fields` (`ShareableObjectRefField`, `preferenceOptions`), `components` (`ShareDialog`) and `permissions` (`MePermissionsProvider`). Not each read call by call. - A bare `fetch('/api/…')` with no init at all is cookie-only as well (the default `same-origin` credentials) and is outside the pin's spelling: `views/metadata-admin/widgets.tsx` `fetchFieldSelectorOptions` (`GET /api/v1/objects/:name/fields`). - `LocalizationFetchProvider` and `languageSeed` read `/api/v1/auth/me/localization` cookie-only; under a bearer-only session that read answers anonymously and the console falls back to the browser language instead of the user's own locale. Not measured in a browser; left because the request key is shared with the early request `index.html` sends. - The hand-rolled bearer helpers left beside converted calls (`authHeaders` in `suggestedBindingsApi`, `bearerAuthHeaders`, `withEnvAuth`) are now redundant there; not removed here. ## Verification <details><summary>The measured case and the pins (green at the head)</summary> `packages-io.bearerSession.test.ts` and the ratchet are in the rerun below (all green). The ratchet's detector battery first went red on a real detector issue: at a script's top level `await (x)(…)` parses as a call of `await`, so the `(apiFetch ?? fetch)` case read 0; the cases now run inside an async function. </details> <details><summary>Ablation: one conversion reverted, both pins red</summary> Through `scripts/ablation-replace.mjs` on `packages-io.ts`: anchor `const res = await authFetch('/api/v1/packages', {` hit 1 → 0, blob `d3c93d771344` → `42f8862ba05e`; the ratchet and the bearer-session file run under the lock: ```text FAIL sameServerFetch.bearer.ratchet.test.ts > every bare cookie-only call is a counted row of the shrink-only allow-list + "packages/app-shell/src/views/studio-design/packages-io.ts:398 :: fetch('/api/v1/packages', …)" FAIL packages-io.bearerSession.test.ts > loads the package list, sending the stored bearer beside the cookie FAIL packages-io.bearerSession.test.ts > answers the listed-id read from the same authenticated request Test Files 2 failed (2) Tests 3 failed | 14 passed (17) ``` The cookie-only control stayed green. Restored: blob `d3c93d771344` equal to `HEAD`, `git diff HEAD` empty. </details> <details><summary>Suites</summary> The whole `@object-ui/app-shell` and `@object-ui/console` suites, under the shared verify lock, in six shards (`cd ui && pnpm exec vitest run --maxWorkers=3 --shard=k/6 packages/app-shell apps/console`) at `32505939` (the final source; only test files changed after it). These are the readings BEFORE the doubles moved, and they are how the moved doubles were found: ```text shard 1/6: Test Files 21 failed | 440 passed (461) · Tests 121 failed | 4304 passed (4425) shard 2/6: Test Files 16 failed | 446 passed (462) · Tests 64 failed | 4352 passed | 1 skipped (4417) shard 3/6: Test Files 23 failed | 439 passed (462) · Tests 104 failed | 4111 passed (4215) shard 4/6: Test Files 17 failed | 445 passed | 1 skipped (463) · Tests 87 failed | 4383 passed | 8 skipped (4478) shard 5/6: Test Files 26 failed | 436 passed (462) · Tests 116 failed | 4636 passed (4752) shard 6/6: Test Files 14 failed | 448 passed (462) · Tests 77 failed | 4286 passed (4363) ``` The 117 failing files are exactly the 117 moved doubles. Each was re-run after its fix (the two new pin files with them): `Test Files 116 passed | 3 failed (119)`, then the three fixed again `Test Files 3 passed (3)`. After the last two type fixes `Test Files 2 passed (2)`, and after the collection-time imports the 34 files that gained one `Test Files 34 passed (34)` / `Tests 319 passed (319)`, at `5dde589a8c`. The 2,655 files that passed in the shards were not edited. A full re-run after the fixes was not done locally (NOT MEASURED, reason: about 90 minutes of shared lock); Test UI runs the full affected set on this PR. Type-check through turbo (dependency closure built): `@object-ui/app-shell` and `@object-ui/console` `type-check` `Tasks: 77 successful, 77 total` at `3080a68173`; `@object-ui/app-shell` again at `5dde589a8c` after the last test edits, `Tasks: 69 successful, 69 total`. The first run found two type errors in my test edits (a typed tuple, an object literal against a declared parameter type), fixed in `3080a68173`. `pnpm --dir ui exec vitest run scripts/` after building the seven `@objectstack` packages as Test UI does: `Test Files 172 passed | 2 skipped (174)`, `Tests 5131 passed | 2 skipped (5133)`. </details> <details><summary>Gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` (no paths, merge base `63ab4794`): 39 families. All 39 run locally, each exit captured before any pipe; 37 lock-free families re-run at `5dde589a8c`, all exit 0; `pnpm check:type-check-debt` exit 0 (`0 raw tsc error(s) total, none above its recorded number`); the ui `scripts/` suite above exit 0. Reconciled: `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero)`. `check:test-source-alias` first went red on the edited suites (exit 1): 34 of them reach a dynamic `import('@objectstack/lint')`, `import('@objectstack/formula')` or `import('@object-ui/plugin-detail')` in the source under test with no collection-time load. Each gained the module-top side-effect import the gate prescribes (`5dde589a8c`), then exit 0. `overlap-check` before every push: at `4a990ef7` it merges cleanly with `origin/main` (`93bd4595`) and with objectstack-ai#37204, objectstack-ai#37188 and objectstack-ai#37148, and exits 1 on textual conflicts with three open Studio PRs that edit the same test files: objectstack-ai#37166, objectstack-ai#37168, objectstack-ai#37169 (in `StudioDesignSurface.*`, `BuilderLanding.*`, `CommandPalette.studioScope-11863`, `StudioRoute.searchPalette-11863`, and objectstack-ai#37166/objectstack-ai#37169 also in `PackageSwitcher.tsx`, `FlowItemMoreMenu.tsx`). Whichever lands second takes the merge. </details> <details><summary>Round 1: main merged at 3b4f0b9, re-measured at e055596</summary> CI at `5dde589a` was red on two causes, both from `main` moving (the ⌘K palette work): - `check:test-source-alias` exit 1: four edited suites (`StudioDesignSurface` `entryReadsOnce-11797`, `itemDraftLine-12725`, `notFound-26708`, `readOnlyPosture-12453`) now reach `import('@object-ui/plugin-detail')` through the surface's command palette and its record preview. Each gained the prescribed module-top `import '@object-ui/plugin-detail';` (38 files carry a collection-time import in all). Then exit 0. - `StudioPaletteGroups.surfaceScope-36900`: 3 failed, 8 passed; after its package-list double gained `headers` (above), 11 passed. No assertion changed. Readings at `e0555965`, under the shared verify lock: ```text ratchet + bearer-session pin + main's 35 incoming app-shell/console test files + the 5 edited files: Test Files 41 passed (41) · Tests 394 passed (394) whole @object-ui/app-shell + @object-ui/console (cd ui && pnpm exec vitest run --maxWorkers=3 packages/app-shell/ apps/console/): Test Files 1 failed | 2779 passed | 1 skipped (2781) · Tests 2 failed | 26745 passed | 9 skipped (26756) ``` The one failing file is `ReportNewPage-36692.test.tsx`, which this branch does not touch (nor its page); it passed 3 of 3 runs alone (`Tests 6 passed (6)` each). Its second failure received the first case's save call, late: its cases flush by `setTimeout(0)` rounds while the page loads its Han romanizer lazily, so on a loaded box the save can land after the case ends. `@object-ui/app-shell` `type-check` through turbo: `Tasks: 69 successful, 69 total`. `pnpm --dir ui exec vitest run scripts/`: `Test Files 172 passed | 2 skipped (174)`, `Tests 5131 passed | 2 skipped (5133)`. Gates: `dispatch-gates --commands` (merge base `3b4f0b98`): 39 families, all run, each exit captured before any pipe, all exit 0. `check:type-check-debt` first answered exit 3 (its closure build queued behind the suite above and never got the lock: not measured), then exit 0 under the lock (`0 raw tsc error(s) total, none above its recorded number`). `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)`. </details> ## Read first 1. `ui/packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts`: the detector and the `ALLOWED` rows (each reason is a claim about a call left bare). 2. `ui/packages/app-shell/src/layout/ContextSelectors.tsx`: the one conversion with `sameOriginOnly`, because its URL is author-written. 3. `ui/packages/app-shell/src/console/marketplace/marketplaceApi.ts`: which calls moved onto `serverFetch` and which stay bare because they may target the cloud origin. Two-minute check: `cd ui && pnpm exec vitest run packages/app-shell/src/sameServerFetch.bearer.ratchet.test.ts packages/app-shell/src/views/studio-design/packages-io.bearerSession.test.ts`, expect `Test Files 2 passed (2)`. <details><summary>Round 2: main merged at 93bd459, re-measured at 4a990ef</summary> - objectstack-ai#37089 landed on `main` after round 1 and left this PR conflicting in `StudioDesignSurface.notFound-26708` and `StudioDesignSurface.readOnlyPosture-12453`: both sides add the same `import '@object-ui/plugin-detail';` with a different comment. The merge (`48321c62`) keeps one import with `main`'s comment, so against `main` those two files differ only by round 0's doubles. - Main's ten new commits add no `credentials: 'include'` line under `ui/packages/app-shell/src` or `ui/apps/console/src`, and their one new hand-rolled Response double already carries `headers: new Headers()`. - The two changesets (`4a990ef7`) now name every converted door in user terms (flow clone, permission-set clone, page preview, the no-access state and the design-mode language list were missing) and claim only "the other same-server console requests", since the 21 listed calls stay cookie-only. Readings at `4a990ef7`, under the shared verify lock (`packages/spec` moved on `main`: the seven `@objectstack` packages Test UI builds were rebuilt first, and `pnpm --filter @objectstack/spec check:generated` reads `All 14 generated artifacts are up to date`): ```text the ratchet, the bearer-session pin, the 5 test files edited in round 1, every existing test file the merge touched in the two trees, and the suites named for each source file it touched: Test Files 311 passed (311) · Tests 2133 passed (2133) ``` `check:test-source-alias` exit 0. `@object-ui/app-shell` `type-check` through turbo: `Tasks: 69 successful, 69 total`. `dispatch-gates --commands` (merge base `93bd4595`): the same 39 families, all run, each exit captured before any pipe, all exit 0 (`check:type-check-debt`: `0 raw tsc error(s) total, none above its recorded number`; the ui `scripts/` suite `Test Files 172 passed | 2 skipped (174)`). `dispatch-gates --ran`: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero …)`. The whole app-shell and console suites were not re-run this round (NOT MEASURED, reason: about 70 minutes of shared lock for a merge that changed no source line of this PR); Test UI runs the affected set on this PR. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_ <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Yibo Wang · project thread
Fixes #35863
repo:objectstack#3 · os-support-ai · session_01WGufzg3ayWUHg9nLoybejn
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
Served shape (
@objectstack/spec/contracts,ApprovalRequestRow.flow_route). One optional member,outcome, served only besideahead: 'decided':step?: { id, label }: the run's latest request when it is a later one than this request (sameflow_run_id, opened after it, on any node, a later round of the same node included; a pending one wins over a decided one). Absent when no later request was opened.status: ApprovalStatus: that latest request's status, or this request's own whenstepis absent.pendingwith astep= the approval went on to that step and waits on its decision.ended: boolean: the record's approval is known to have stopped: a root run, whose own flow body starts no child run (subflow/map), that has stopped for good.false= not known (rounds 1 to 3 below).outcomeis absent when nothing past the request is known (no later request in the run and the approval not known to have ended, or several later requests are pending at once), so nothing is guessed. A pending request's route never carries it.Server (
@objectstack/plugin-approvals).routeOutcomeinapproval-route.tsis the rule, a pure function over the run's own request rows (the same rowspassedStepsalready reads) and whether the run has ended.flowRoutecalls it for decided rows only.ApprovalService.attachFlowRoutereads "ended" off the run itself throughautomation.getRun, judged by the dead-run sweep's ownTERMINAL_RUN_STATUSES(derived from the totalRUN_STATUS_LIVENESSmap), in the newrunHasEnded. An unreadable run reads as "not known to have ended", never as a failed read: the field is display-only like the rest of the route.Docs.
content/docs/automation/approvals.mdxgains the decided route'soutcome, beside the existingflow_routeexample (the docs drift check named that page).UI (
@object-ui/app-shell,@object-ui/i18n,@object-ui/console).ApprovalStepLinetakes anoutcomeprop and, withdecided, draws one line under the decided step, outside the ordered list so assistive tech never counts it as a step: "Went on to STEP, waiting for a decision", "Went on to STEP: DECISION", "Went on to STEP, then ended: DECISION", or "The approval ended here". The approval request page's decision panel hands it the served outcome on a decided route only. Four newapprovalsInboxrows in all eleven built-in locales. The console'sApprovalRequesttype and app-shell'sApprovalRequestLitemirror the member.Why this shape (card option 2, one outcome) and not option 1 (the steps after)
rejectedstep state: a widening of thestateenum every step-line consumer switches on, and it still needs a separate marker for "ended".Read first (by risk)
routeOutcomeinpackages/plugins/plugin-approvals/src/approval-route.ts: which later row is "the latest", the parallel-pending refusal, and the ended-at-this-request arm.outcomedoc onflow_routeinpackages/spec/src/contracts/approval-service.ts: the contract text the L2 read judges.outcomeTextinui/packages/app-shell/src/views/approval-progress/ApprovalStepLine.tsx: which status draws which sentence, and when it draws nothing.Two-minute verification
pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/flow-route.integration.test.ts: expect 14 passed, including "a request decided at step 1 of a two-step route: the outcome says step 2 is pending, then that the approval ended there".Tests
approval-route.test.ts: a newrouteOutcomedescribe (9 cases): later pending, ended at a later step (approved and rejected), ended at this request (approved, rejected, recalled, cancelled), not ended and nothing later (no outcome), a later round of the same node, pending wins over decided, parallel pending (no outcome), rows that are not later requests, andflowRoutecarrying it on decided rows only.flow-route.integration.test.ts(real ObjectQL over SQLite, real AutomationEngine and approval node): the existing decided pin now assertsoutcome: { status: 'approved', ended: true }at the last step; new pins for the card's two cases (decided at step 1 of a two-step route shows step 2pending, thenrejected, endedonce step 2 is rejected), a first-step rejection ending the approval, and a pending request carrying no outcome.ApprovalDecisionPanel.stepLine-12491.test.tsx(the existing harness, a new top-level describe, 7 cases): each sentence, no line without an outcome or with nothing to say, no line on a pending route, and every locale pack carrying the four rows.Acceptance notes
ended: truewithstatus: 'approved'reports the last decision; a root run that failed after that approval also reads "ended". The run's own status is not served here; that would be a second widening for a rare case.ui/packages/i18n/src/locales/*.ts(the four rows the line needs),ui/apps/console/src/services/approvalsApi.ts(the console's type mirror offlow_route) andcontent/docs/automation/approvals.mdx(the page that documentsflow_route).{ status, step? }; the landed shape addsended, because "the approval ended" is a fact about the run, not about any one request's status.Round 1 (L2 FAIL 7147867236, L1 REWORK 7147881964), head 99ab892
subflowbody,mapitem: the engine links those upward by$parentRunId), as__runRooton the config snapshot (precedent__round; no schema change).attachFlowRouteasks the run for "ended" only when the snapshot says root; a child run's request, a request opened before the stamp, or an unreadable run is never servedended: true. New pin inflow-route.integration.test.ts: an approval inside asubflowwhose child run completed while the root run went on to the general manager serves no outcome, and the root run's last request then served{ status: 'approved', ended: true }(round 2 withdraws that: its flow hosts asubflow); a second pin removes the stamp from a decided last-step request and the outcome disappears. Ablations: root-run read forcedtruegives 2 failed / 9 passed; executor stamp forcedtruegives 1 failed / 10 passed; both restored.outcomecontract doc and theattachFlowRoutedocblock state the disclosure: every reader of the request gets the later step's node id and label and that request's status, never its id, approvers, comments or field values, within the request-visibility bound of ruling record 5299823744 as the seat ruled for this card.endedis now defined as "known to have stopped" (false= not known, including an unreadable run), and the contract, the changeset andapprovals.mdxsay an outcome with a later request is served even when the run cannot be read. N1: the contract saysstatusis the last decision only when it is notpending.@objectstack/plugin-approvalsfull suite Test Files 128 passed (128), Tests 1934 passed (1934); plugin-approvals and spec typecheck exit 0; spec rebuilt andcheck:generatedall 14 up to date; overlap-check clean against main and the open PR heads, fix(plugin-approvals): the batch lock read answers a line of a held master as locked #37145 included. CI at 99ab892: 70 check-runs, 61 success, 9 skipped, 0 failed, every required context green; mergeable clean. The local re-run of the derived gate list at this head stopped at 9 of 121 (all exit 0) when the container restarted; CI ran the families.Round 2 (L2 FAIL 7150840780, L1 REWORK 7150863825), head e264c10
flowHostsChildRuns(approval-route.ts) says whether the flow holds asubflowormapnode anywhere, regions included (loopbody,parallelbranch,try_catch, every graphcollectFlowGraphswalks), andattachFlowRouteasks the run for "ended" only when it does not. Two choices inside it, stated so they can be judged:subflowon a branch the run never took also never says "ended"; the line is then left out, never wrong.steptoo, not only "ended with no later step": with manager → general manager → subflow legal → end, the manager's outcome would otherwise read{ step: gm, status: 'approved', ended: true }and name the general manager's decision as the last one while legal came after. With this rule it reads{ step: gm, status: 'approved', ended: false }, which is true.__runRoot, a yes/no), the engine serves no "children of a run" read, and walking$parentRunIdchains from the read side would need a new engine member, outside the claimed surface.flow_route: { steps: [manager done], ahead: 'decided' }with nooutcome. Pinned exactly inflow-route.integration.test.ts("a later step in a child run: the root run's end is not served as "ended here" for the request before it"). The round-1 hosted pin now asserts that the root run's own last request also gets no outcome, its flow hosting asubflow.approvals.mdx: "known to have stopped" now names "runs a flow that can start a child run" among thefalsecases, andstepsays a request a child run opened is not among the run's requests.attachFlowRoutedocblock reads "as the seat ruled on PR feat(approvals): a decided request's step line says where the record's approval went next #37148".flowHostsChildRunsdescribe (3 cases):subflowandmapat the top level; inside aloopbody, aparallelbranch, atry_catchcatch, and nested two deep; none anywhere (approvals, gateways, aloopof approvals, an empty flow).scripts/ablation-replace.mjs, restored to blob == HEAD each time): the gate inattachFlowRouteforced off gives Tests 2 failed / 10 passed (the new pin and the hosted pin);mapremoved from the child-run node types gives 2 failed / 26 passed; the region walk replaced by the top-level nodes gives 1 failed / 27 passed.approval-route.test.ts+flow-route.integration.test.tsTest Files 2 passed (2), Tests 40 passed (40);@objectstack/plugin-approvalsfull suite Test Files 128 passed (128), Tests 1938 passed (1938); plugin-approvals and spec typecheck exit 0; spec rebuilt andcheck:generatedall 14 up to date; overlap-check clean against origin/main and PR heads fix(app-shell,console): the shell package list, AI chat lists and studio-design reads and writes send the stored bearer token #37185, feat(ai): ai_context context packs and the get_record_context tool over MCP (ADR-0160 row 5) #37173, feat(studio): remove the Studio home; /studio opens the last package or Setup > Packages #37166. CI at e264c10: 70 check-runs, 61 success, 9 skipped, 0 failed, every required context green; mergeable clean.Round 3 (L2 PASS with S3 7151818256, L1 REWORK 7151830517), head 6080e34
ranArmedBody(approval-service.ts) holds when the armed body is the flow's newest registration in the engine's version history (getFlowVersionHistory, compared as the very object) and was registered strictly before the run started (the run log'sstartedAt, which a resume carries over unchanged). A run starts on the body armed at its start and resumes pinned to it, so with nothing registered since, that body is the one it ran.runHasEndednow requires it beside the terminal status.flowVersion: it is the author's number and an edit need not change it (the edit pin re-registers under the same version).getFlowVersionHistoryandstartedAtare declared on the plugin's automation surface as membersAutomationEnginealready implements and returns publicly, the existing precedent for that interface.flow-route.integration.test.ts): a run that started asubflow(legal rejects, the root completes), then its flow re-registered under the same version without the subflow: the manager's request still serves nooutcome; a run started on the edited body then ends at the manager,{ status: 'approved', ended: true }. A rollback: version 2 (with the subflow) runs,rollbackFlowre-arms version 1 (without): nooutcome.approvals.mdxnow say "the flow body the run ran" and when that body is known, and list "ran a body that is not known (its flow was registered again since it started)" among thefalsecases.CHILD_RUN_NODE_TYPESdocblock names the only two executors that set$parentRunId(builtin/subflow-node.ts,builtin/map-node.ts), saysloop,parallelandtry_catchstay in-run, and that a new child-run starter joins the set in the same change. A pin would have to readservice-automationsources from this package's tests, which the cross-package test-input gate refuses, so it is a comment.created_at, not the decision): a run opens its requests one after another, so the order they were opened in is the order the approval moved in; the only same-run overlap is parallel branches, whichrouteOutcomealready refuses to pick from. No reachable wrong case, so no change and no card needed in my view. N3, fixed after all: both UI mirrors now typeoutcome.statusas the row's ownstatus(ApprovalRequestRow['status']in the console,ApprovalRequestLite['status']in app-shell), the open union each already uses, rather than a barestring.scripts/ablation-replace.mjs, restored to blob == HEAD each time):ranArmedBodydropped fromrunHasEndedgives Tests 1 failed / 12 passed (the edit pin); the time test forced true gives 1 failed / 12 passed (the edit pin); the identity test dropped gives 1 failed / 13 passed (the rollback pin).approval-route.test.ts+flow-route.integration.test.tsTests 42 passed;@objectstack/plugin-approvalsfull suite Test Files 128 passed (128), Tests 1940 passed (1940) at bfff5d1 (6080e34 adds only the two UI type lines);ApprovalDecisionPanel.stepLine-12491.test.tsxTests 20 passed (20) at 6080e34; plugin-approvals and spec typecheck exit 0; spec rebuilt andcheck:generatedall 14 up to date; overlap-check clean against origin/main and the open PR heads before each push. Three pushes this round, not one: 30ec243 (S3), bfff5d1 (the rollback pin, once the identity ablation showed that branch unpinned), 6080e34 (N3); CI on the first two was cancelled by the next push. CI at 6080e34: 70 check-runs, 61 success, 9 skipped, 0 failed, every required context green; merges cleanly with main.Verification
Targeted tests (code at 19f57ef; later commits touch only the changeset, the docs page and one test import)
pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/approval-route.test.ts src/flow-route.integration.test.ts: VERDICT command-exit 0, Test Files 2 passed (2), Tests 34 passed (34).pnpm --dir ui exec vitest run packages/app-shell/src/views/approval-decision/ApprovalDecisionPanel.stepLine-12491.test.tsx packages/app-shell/src/views/RecordApprovalsPanel.stepProgressVertical.test.tsx packages/app-shell/src/views/RecordApprovalsPanel.servedRoute-26668.test.tsx: VERDICT command-exit 0, Test Files 3 passed (3), Tests 29 passed (29).pnpm --filter @objectstack/plugin-approvals typecheck && pnpm --filter @objectstack/spec typecheck: VERDICT command-exit 0.pnpm --filter @objectstack/spec check:generated: all 14 generated artifacts up to date (spec dist built after the contract edit).Ablations (each through scripts/ablation-replace.mjs, mutation proven on disk, restored, tree clean after)
flowRouteoutcome replaced byundefined: Tests 4 failed / 30 passed (theflowRouteunit case and the three integration outcome pins).runHasEndedforcedfalse: Tests 3 failed / 6 passed in the integration file (everyended: truepin).outcomehand-off deleted: Tests 4 failed / 16 passed (every drawn-line case).All three suites import source, not
dist/, so no rebuild leg applies.Local gates (dispatch-gates, derived at 19f57ef and again at 1f6480a)
Derived by
node scripts/pm/dispatch-gates.mjs --commands(120 families once the docs page joined the diff);--ranreconciliation: 120 of 120 accounted for. 117 exit 0. Exit 3 (prerequisite not met in this container, nothing measured; CI ran them green):node scripts/check-plugin-teardown-shape.mjs --self-test: exit 3 (shallow clone cannot reach the pinned positive control)pnpm check:dual-build-cjs-loads: exit 3 (reads built output of the whole workspace)pnpm check:i18n: exit 3 (needs its package build closure; nothing compared)Exit 0:
node scripts/check-adr-0087-registration.mjs --base origin/mainnode scripts/check-adr-0087-registration.mjs --self-testnode scripts/check-changeset-no-major.mjs --base origin/mainnode scripts/check-closing-keyword-parity.mjsnode scripts/check-closing-keyword-parity.mjs --self-testnode scripts/check-comment-mask-adoption.mjsnode scripts/check-comment-mask-adoption.mjs --self-testnode scripts/check-comment-mask-corpus.mjsnode scripts/check-dev-prereqs.mjs --self-testnode scripts/check-dts-emitted.mjs --self-testnode scripts/check-empty-changeset.mjs --base origin/mainnode scripts/check-empty-changeset.mjs --self-testnode scripts/check-issue-citations.mjsnode scripts/check-plugin-teardown-shape.mjsnode scripts/check-sdui-manifest.mjsnode scripts/check-sdui-manifest.mjs --self-testnode scripts/check-tenant-audit-census.mjsnode scripts/check-tenant-audit-census.mjs --self-testnode scripts/ci/assert-turbo-remote-cache.mjs --self-testnode scripts/ci/plan-test-core-shards.mjs --self-testnode scripts/ci/prune-turbo-cache.mjs --self-testnode scripts/ci/snapshot-next.mjs --self-testnode scripts/docs-audit/check-affected-docs.mjsnode scripts/docs-audit/check-drift-comment.mjsnode scripts/pm/check-governed-queue-guard.mjs --self-testnode scripts/pm/release-rehearsal-clone.mjs --self-testnode scripts/release-pending-publish.mjs --self-testpnpm --dir ui exec vitest run scripts/pnpm --filter @objectstack/lint run check:doc-formula-expressionspnpm --filter @objectstack/spec run check:api-surfacepnpm --filter @objectstack/spec run check:authorable-surfacepnpm --filter @objectstack/spec run check:browser-reachable-entriespnpm --filter @objectstack/spec run check:docspnpm --filter @objectstack/spec run check:dual-source-exportspnpm --filter @objectstack/spec run check:duration-unit-keyspnpm --filter @objectstack/spec run check:empty-statepnpm --filter @objectstack/spec run check:entry-nameabilitypnpm --filter @objectstack/spec run check:error-code-provenancepnpm --filter @objectstack/spec run check:export-originspnpm --filter @objectstack/spec run check:exported-anypnpm --filter @objectstack/spec run check:livenesspnpm --filter @objectstack/spec run check:llms-txtpnpm --filter @objectstack/spec run check:skill-refspnpm --filter @objectstack/spec run check:strictness-ledgerpnpm --filter @objectstack/spec run check:variant-docspnpm --filter @objectstack/spec run check:yaml-examplespnpm check:adr-anchorspnpm check:adr-symbol-anchorspnpm check:changeset-gate-self-testspnpm check:ci-filter-paritypnpm check:cli-command-idspnpm check:closed-ceremony-textpnpm check:cross-package-test-inputspnpm check:dispatcher-error-vocabularypnpm check:doc-authoringpnpm check:driver-memory-censuspnpm check:dts-closurepnpm check:engine-double-contractpnpm check:error-status-conformancepnpm check:gitlink-declaredpnpm check:i18n-stale-fillpnpm check:issue-citationspnpm check:keyed-text-boundspnpm check:lean-entry-closurepnpm check:logger-receiver-detachpnpm check:merge-driverpnpm check:nul-bytespnpm check:object-def-param-keyspnpm check:objectql-double-limitpnpm check:optional-error-sinkpnpm check:org-identifierpnpm check:page-declaration-shapepnpm check:platform-object-tenancy-censuspnpm check:pm-expected-skipspnpm check:pm-prior-rulingspnpm check:published-filespnpm check:query-options-erasurepnpm check:refd-timer-probepnpm check:registry-log-declaredpnpm check:rest-log-spy-declaredpnpm check:role-wordpnpm check:settings-bind-windowpnpm check:skill-identifier-livenesspnpm check:slot-lookuppnpm check:sourcemap-no-sources-contentpnpm check:spec-docblock-symbol-anchorspnpm check:spec-parsed-aliaspnpm check:system-context-censuspnpm check:test-source-aliaspnpm check:tier-file-adoptionpnpm check:type-check-coveragepnpm check:type-check-debtpnpm check:undeclared-dep-importspnpm check:vouch-for-reference-callerspnpm check:watch-hint-literalpnpm check:where-matchernode scripts/check-adr-links.mjsnode scripts/check-adr-links.mjs --self-testnode scripts/check-doc-route-spelling.mjs --advisorynode scripts/check-doc-route-spelling.mjs --self-testnode scripts/check-docs-section-name.mjsnode scripts/check-docs-section-name.mjs --self-testnode scripts/check-section-landing-index.mjsnode scripts/check-section-landing-index.mjs --self-testpnpm --filter @objectstack/lint run check:doc-security-posturepnpm --filter @objectstack/spec run check:skill-examplespnpm check:corpus-claim-driftpnpm check:doc-anchorspnpm check:doc-frontmatterpnpm check:docs-audit-scopepnpm check:docs-redirectspnpm check:docs-single-h1pnpm check:docs-spec-enumerationspnpm check:docs-transcript-driftpnpm check:published-readme-linkspnpm check:react-page-adapter-contractpnpm check:vendor-version-stampspnpm check:test-source-aliasexit 0 at 1f6480a (CI had flagged the decision panel harness reaching the lazy@object-ui/plugin-detailload without a module-top import; the harness now imports it at collection); the edited harness file re-run, Test Files 1 passed (1), Tests 20 passed (20).CI at head 1f6480a: 61 success, 9 skipped, 0 failed of 70 check-runs; every required context green (Lint & Repo Gates, TypeScript Type Check, Test Core, Build Core, Governed Surface Queue Guard, Lint UI, Type Check UI, Test UI, Build & E2E UI, Live E2E UI, Dogfood Regression Gate) and Check Changeset green. Mergeable: clean.
NOT MEASURED locally:
Type Check UI(@object-ui/app-shell type-checkneeds the UI package closure built; the local run stopped on missing-module errors only, none in a touched line). CI'sType Check UIis the reading.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGufzg3ayWUHg9nLoybejn