Skip to content

Commit 370833a

Browse files
feat(spec): ApprovalRequestRow declares current_step_label, the sys_approval_request column's own name for the step label (#24329)
Fixes #24309 Clause-②: yes ## What this changes `ApprovalRequestRow` (`packages/spec/src/contracts/approval-service.ts`) now declares an optional `current_step_label?: string` in its display-enrichment block, beside `step_label`. Its docblock says what it is: the declared `sys_approval_request.current_step_label` column under its own name, served so that a page bound to `sys_approval_request` can list the step by its label. Such a page names the object's declared fields, and `step_label` is not one of them, so today the request page's strip can list only `current_step`, the node's machine id. `step_label` stays, so no reader moves. This is the spec half of the split that triage took on the consumer card (option A). The services half serves the member from plugin-approvals' `rowFromRequest` and lists it on the strip. That half is the consumer card's own work: #24281 remains open, and this PR does not touch `packages/plugins/plugin-approvals/**` or the request page. ## Files - `packages/spec/src/contracts/approval-service.ts`: the member and its docblock. - `packages/spec/src/contracts/approval-service.test.ts`: four pins beside the existing `acted_as` and `organization_id` pins: - a `{} extends Pick` alias that turns red on a required member; - an exact `string | undefined` alias; - `step_label` at the same shape; - a runtime read-back on a row without the member and on a row with it. - `.changeset/24309-approval-current-step-label.md`: `minor` on `@objectstack/spec`, `Clause-②: yes (widening)`. No generated artefact moved. After a rebuild, `check:generated` reports all 14 artefacts up to date. `api-surface/` records that the interface exists, not its members. ## Premise, re-read on `origin/main` `52ff308b8` - `ApprovalRequestRow` is at `approval-service.ts:138`, and `step_label?: string` is at `:223`, with no `current_step_label`. - `sys_approval_request` declares the column `current_step_label` (`sys-approval-request.object.ts:330`, a readonly `Field.text`). - plugin-approvals' `rowFromRequest` serves the label only as `step_label` (`approval-service.ts:1183`). ## Who reads the type - **This repo** (`git grep ApprovalRequestRow`): - `@objectstack/spec`: the contract and its test; - `@objectstack/client`; - `@objectstack/plugin-approvals`: the producer, `action-link-pages.ts`, and seven test files. No `keyof ApprovalRequestRow` map or exhaustive `Record` over its keys exists, so an optional member breaks no reader. - **objectui**, read at both its pin before the merge (`5e15928b4631`) and its pin after it (`0707b4ae3712`): - `packages/app-shell/src/views/approval-decision/ApprovalDecisionPanel.tsx` imports the spec type, and only through a `Pick` of `payload` and `payload_display`; - the console inbox (`apps/console/src/services/approvalsApi.ts`) declares its own local `ApprovalRequestRow` and reads `step_label` from it. Neither is affected. ## Verification Final head `11acbc435` (the claim's commit `ef7bb1a93`, plus a merge of `origin/main` `2ce2e3699` made with `os-regen-merge.sh`). Every build and test ran through `os-verify-lock.sh`, except the one-file probe `tsc` below. - `pnpm --filter @objectstack/spec build`: VERDICT command-exit 0. The member reaches only `dist/contracts/index.d.ts` and `index.d.mts`; no emitted JS carries it. - `pnpm --filter @objectstack/spec check:generated`: exit 0, "All 14 generated artifacts are up to date". Nothing was regenerated. - `pnpm --filter @objectstack/spec typecheck`: VERDICT command-exit 0. This includes `check:test-typecheck`, which compiles the new pin file (counted with `--listFiles`): "52 file(s) / 242 error(s) / 132 pinned signature(s) held", unchanged from the ledger. - `pnpm --filter @objectstack/spec test`: VERDICT command-exit 0. "Test Files 694 passed (694)", "Tests 21042 passed, 1 todo". The pin file alone: 9 of 9 passed (8 before this PR). - Consumers. First `turbo run build --filter='@objectstack/plugin-approvals^...' --filter='@objectstack/client^...' --concurrency=2`: "34 successful, 34 total". Then `pnpm --filter @objectstack/plugin-approvals --filter @objectstack/client typecheck`: VERDICT command-exit 0, `tsc --noEmit` plus `check:test-typecheck` OK for both. The build filter is the two consumers' dependency closure, `@objectstack/spec` included. - Reverse verification, at `ef7bb1a93`: a probe file in plugin-approvals typed two rows as `ApprovalRequestRow`. With `current_step_label: 'Manager Review'` the row compiled clean. With `current_step_label: 42`, `tsc` printed exactly one error, TS2322 "Type 'number' is not assignable to type 'string'". A stale `.d.ts` would have answered TS2353 on both rows, so the consumer reads the rebuilt declaration. The probe was deleted, and `git status` is clean. - Ablation, at `11acbc435`, through `scripts/ablation-replace.mjs`: the anchor went from 1 hit to 0 and the blob from `e1e2e927` to `9515560b`. The member deleted, `check:test-typecheck` went red: "src/contracts/approval-service.test.ts: 7 type error(s)". Restored: the blob equals the HEAD blob `e1e2e927`, and `git diff HEAD` is empty. The pin is a compile-time pin: its teeth are `check:test-typecheck`, inside the spec `typecheck` that the required `TypeScript Type Check` job runs. - Gates: `dispatch-gates --commands` (no paths) derived 86 families at `11acbc435`. All 86 ran with exit 0. `dispatch-gates --ran`: "86 derived, 86 run, 0 NOT-MEASURED, 0 UNRUN". ## Acceptance notes - **Declared ahead of its producer.** Until #24281 lands, the approvals get does not carry `current_step_label`. The member is optional, and its docblock says it is served from #24281 on. That split and its order are triage's ruling on the consumer card. - **objectui typecheck: not run locally.** objectui resolves the published `@objectstack/spec`, not this worktree, so a local run would measure nothing about this diff. The one spec-type import is a `Pick` of two members this PR does not change. The full battery's `Console Pin Gate` builds objectui at its pin against `main`. - **Not run locally, left to CI.** `test:repo` (the vitest `repo` project): this diff touches none of its tests. The `check:dev-prereqs` scan: its self-test is green, but its existence half needs the whole workspace built, which this card does not need. `TypeScript Type Check`, `Test Core` and `Lint & Repo Gates` run the full set on this PR. - `origin/main` moved three commits after the merge (`2b7fc52c3`, `889bf122e`, `85be049d5`). None of them touches `packages/spec` or these files, so the branch was not merged again. --- _Generated by [Claude Code](https://claude.ai/code/session_019oFY6Hi35J7atvgVFnmoaK)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent ec749fb commit 370833a

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@objectstack/spec": minor
3+
---
4+
5+
feat(spec): `ApprovalRequestRow` declares `current_step_label`, the `sys_approval_request` column's own name for the step's label
6+
7+
Clause-②: yes (widening)
8+
9+
- **The member.** `ApprovalRequestRow` (`@objectstack/spec/contracts`) gains an optional `current_step_label?: string` beside `step_label`. It names the declared `sys_approval_request.current_step_label` column: the Approval node's authored label as it stood when the request reached the step. A page bound to `sys_approval_request` names the object's declared fields, and `step_label` is not one, so a served row that carries this member lets such a page list the step by its label instead of by `current_step`, the node's machine id.
10+
- **Nothing moves.** `step_label` stays, at the same shape and with the same value, so no reader changes. The member is optional, so every existing implementer and every row built without it still conforms. It is a member of a TypeScript interface: no Zod schema and no runtime accept set changes.
11+
- **Its producer.** `@objectstack/plugin-approvals`' request read mapping is the producer; serving the member there is that package's own change.

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,59 @@ describe('ApprovalActionRow.acted_as — the slot an approval action was taken a
110110
});
111111
});
112112

113+
// ---------------------------------------------------------------------------
114+
// [#24309] `ApprovalRequestRow.current_step_label` — the step's label under the
115+
// declared `sys_approval_request` column's own name, beside `step_label`.
116+
//
117+
// A page bound to `sys_approval_request` names the object's declared fields,
118+
// and `step_label` is not one, so the row declares the column's own name. The
119+
// pins hold what the card decided: the member is OPTIONAL and a STRING (the
120+
// column is a text field, and `step_label` carries the same value at the same
121+
// shape), and `step_label` stays, so no reader moves. Same optionality-alias
122+
// reasoning as the `acted_as` block above.
123+
// ---------------------------------------------------------------------------
124+
125+
/** Optional: a row may omit it. A required member turns this alias red. */
126+
export type CurrentStepLabelIsOptional = Assert<
127+
{} extends Pick<ApprovalRequestRow, 'current_step_label'> ? true : false
128+
>;
129+
130+
/** A plain string label — not nullable, not an object. */
131+
export type CurrentStepLabelIsAString = Assert<Eq<ApprovalRequestRow['current_step_label'], string | undefined>>;
132+
133+
/** `step_label` stays beside it, at the same shape: no reader moves. */
134+
export type StepLabelStays = Assert<Eq<ApprovalRequestRow['step_label'], ApprovalRequestRow['current_step_label']>>;
135+
136+
describe('ApprovalRequestRow.current_step_label — the step label under the declared column name', () => {
137+
it('is optional and string-typed: a row without it still conforms, and one with it reads back', () => {
138+
const read = (row: ApprovalRequestRow): string | undefined => row.current_step_label;
139+
140+
expectTypeOf<ApprovalRequestRow['current_step_label']>().toEqualTypeOf<string | undefined>();
141+
142+
// The shape a producer that does not serve it returns: no member at all.
143+
// This literal failing to compile is the regression.
144+
const withoutLabel: ApprovalRequestRow = {
145+
id: 'req_1',
146+
process_name: 'flow:expense_review',
147+
object_name: 'expense',
148+
record_id: 'rec_1',
149+
status: 'pending',
150+
current_step: 'approve_step',
151+
};
152+
expect(read(withoutLabel)).toBeUndefined();
153+
154+
// The machine id and both label spellings side by side, each in its own member.
155+
const withLabel: ApprovalRequestRow = {
156+
...withoutLabel,
157+
step_label: 'Manager Review',
158+
current_step_label: 'Manager Review',
159+
};
160+
expect(read(withLabel)).toBe('Manager Review');
161+
expect(withLabel.step_label).toBe('Manager Review');
162+
expect(withLabel.current_step).toBe('approve_step');
163+
});
164+
});
165+
113166
// ---------------------------------------------------------------------------
114167
// [#15389] `continueRestoredRun` — the approvals half of the operator repair
115168
// pair, declared on the contract.

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ export interface ApprovalRequestRow {
221221
process_label?: string;
222222
/** Human label of the approval step / node (e.g. "Manager Review"). */
223223
step_label?: string;
224+
/**
225+
* The step's label under the declared column's own name:
226+
* `sys_approval_request.current_step_label`, the Approval node's authored
227+
* label as it stood when the request reached the step (the value
228+
* {@link ApprovalRequestRow.step_label} carries). Served so a page bound to
229+
* `sys_approval_request` can list the step by its label. Such a page names
230+
* the object's declared fields, and `step_label` is not one, so without this
231+
* member it can list only `current_step`, the node's machine id.
232+
*
233+
* Declared ahead of its producer: plugin-approvals' `rowFromRequest` serves
234+
* it from #24281 on, the card this declaration unblocks. `step_label` stays
235+
* for its existing readers.
236+
*/
237+
current_step_label?: string;
224238
/** Display name of the target record (its name/title field), when resolvable. */
225239
record_title?: string;
226240
/** Display name of the submitter (`sys_user.name`), when resolvable. */

0 commit comments

Comments
 (0)