Skip to content
Merged
14 changes: 14 additions & 0 deletions .changeset/37766-approval-closed-states-authoring-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/lint': patch
---

feat(lint): an approval that cannot show itself in progress on a field its object closes on is refused where it is authored (ADR-0162 D5)

Clause-②: yes (widening)
Metadata-protocol: none

Widened: `@objectstack/lint` exports `validateApprovalClosedStates`, `approvalRootObjectsOf`, `APPROVAL_CLOSED_STATE_GAP` and the type `ApprovalClosedStateFinding`; the rule's sentences are registered in all 11 platform locales.

A new member of the reference-integrity suite, `validateApprovalClosedStates` (finding `approval-closed-state-gap`, at error), judges each flow of a stack as the root of an approval, on each object it can start on a record of, through the one judge the approvals plugin's first request asks (`judgeApprovalOpeningSync`, `@objectstack/metadata-core`). `os validate`, `os build` and `os lint` refuse the gap on a project's stack, and the runtime publish door (Studio, REST `/meta`, MCP) refuses it with `INVALID_METADATA` (422) on a `flow` or an `object` write: an active save, a draft's promotion, a restore and a package publish (a draft save is not refused). An `object` write judges the written package's live flows and is charged only with a gap it adds. In a package publish each draft is judged against the batch's objects, and a flow the batch redrafts is judged as its draft, so a package that declares `closedStates` and repairs its flow in the same publish passes. The rule refuses only what it has in view: a call to a flow the stack does not hold, a node type the spec does not ship and a host with no `job` service are not refused here, and are judged at the approval's first request, which stays the rule. An object that declares no `closedStates` is judged nowhere.

Why the protocol line reads none: the rule reads only `closedStates`, which this release adds. No object a released version accepts declares it, so nothing that could be published before is refused now.
10 changes: 10 additions & 0 deletions .changeset/37766-opening-judge-metadata-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/metadata-core': patch
---

feat(metadata-core): the judge of an approval's opening conditions on a closing field lives here, so every door asks one copy (ADR-0162 D5)

Clause-②: yes (widening)
Metadata-protocol: none

Widened: `@objectstack/metadata-core` exports the judge the approvals plugin's first-request check used to hold, `judgeApprovalOpening` (it awaits each flow it reads), with `judgeApprovalOpeningSync` (over a stack in hand: a flow read that answers a promise counts as a flow it cannot read), the walk both drive, `approvalFlowWalk`, and the helper and types they read (`closedValuesOf`, `OpeningCheckSource`, `OpeningFlow`, `OpeningFlowBody`, `OpeningGap`, `OpeningJudgement` and the rest). `OpeningCheckSource.calleeFlow` may answer a flow or a promise of one. The verdict and its gaps are unchanged; nothing an author writes changes.
10 changes: 10 additions & 0 deletions .changeset/37766-opening-judge-plugin-approvals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/plugin-approvals': patch
---

refactor(approvals): the first-request check asks the opening judge in `@objectstack/metadata-core` (ADR-0162 D5)

Clause-②: no
Metadata-protocol: none

The check an approval's first request makes on a field its object closes on now calls `judgeApprovalOpening` from `@objectstack/metadata-core`, the same judge the authoring rule `validateApprovalClosedStates` asks. `approval-opening-check.ts` re-exports it and its types under the names it exported before. Which approvals open, the refusal and its sentences are unchanged.
26 changes: 26 additions & 0 deletions content/docs/automation/approvals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,32 @@ Nothing in the message is the submitter's to fix: every gap is the app's
configuration or the host's. Whoever maintains the app fixes the field, the flow
or the host, and the submitter then submits again.

### Refused where the approval is authored

The same conditions are refused before anyone submits, wherever the flow and
the object are in view together. `os validate`, `os build` and `os lint` fail
on a project's stack with the finding `approval-closed-state-gap`, one per gap,
in the same words as the refused opening. Studio, the REST `/meta` API and MCP
refuse to save or publish a `flow` or an `object` that would leave a gap, with
`INVALID_METADATA` (422) and the same words: at an active save, when a draft is
promoted, at a restore, and in a package publish. A draft save is not refused;
its promotion is. A package that declares `closedStates` and fixes its flow in
the same publish passes.

An authoring door judges only what it has in view, so the refusal at the first
request stays the rule. These are left to the first request:

- a flow that a `subflow` or a `map` names and the project or the deployment
does not hold there. When one flow is saved on its own, the flows it calls and
the flows that call it are not in view;
- a node type that a plugin adds, between two steps. At authoring only the
spec's own pausing types, such as `wait` and `screen`, count as a pause;
- whether the host runs a `job` service;
- a flow that declares no object, with no `start` object and no record input,
started by an action or by name on a record. At authoring a flow is judged on
its `start` object, or where it declares none, on the object of each record
input; the first request judges on the record the run was started on.

### What an abandoned approval leaves

Three writers abandon a request: its submitter's recall, of a pending request or
Expand Down
Loading
Loading