Skip to content

Commit 536d5a1

Browse files
committed
docs(spec): the toggle contract names the status-disarmed switch-on refusal; the changeset names refreshPackagedFlowDefaults
N1 of the contract review on #34810 (half B), carried here as half A edits packages/spec: the toggle door's contract prose listed only the customer-authored 409. It now also names the 409 for switching ON a packaged flow whose own status disables it, and that switching it off is accepted. JSDoc only; no schema moves. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX
1 parent 05656d7 commit 536d5a1

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎.changeset/34655-flow-default-active.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ Only a flow a package ships has the packaged-flow switch, so:
2323

2424
A name two packages ship is a package's flow too: each holder's body registers with the key, on every re-sync and upgrade, and the refusal above is only for a name no package ships.
2525

26-
For hosts that compose the engine themselves, `AutomationEngine.setPackagedFlowDefaultSource(source)` and its `PackagedFlowDefaultSource` type are new public API. The automation plugin attaches the reader (it asks the metadata protocol for the package's own body); it is how the engine reads the package's default while a declared `.custom` override is armed in the package's place, and it is asked once per registration, not on every enablement read. An engine composed without a reader reads the default only off an armed package body, so while an override is armed a flow its package ships off runs (fail-open): such an engine cannot see the package's body, and treating an unknown default as on keeps the behaviour every packaged flow had before this release instead of switching off a flow no package was seen to declare off.
26+
For hosts that compose the engine themselves, `AutomationEngine.setPackagedFlowDefaultSource(source)` and its `PackagedFlowDefaultSource` type are new public API. The automation plugin attaches the reader (it asks the metadata protocol for the package's own body); it is how the engine reads the package's default while a declared `.custom` override is armed in the package's place, and it is asked once per registration, not on every enablement read. `AutomationEngine.refreshPackagedFlowDefaults()` is new public API too: it asks the reader again for every armed body that is not the package's own, and re-arms or disarms each flow whose answer moved; the automation plugin calls it at every `metadata:reloaded` re-sync, so a hot upgrade that changes the declared default reaches a flow whose override body was not re-registered. A host composing the engine itself calls it after the set of installed packages changes. An engine composed without a reader reads the default only off an armed package body, so while an override is armed a flow its package ships off runs (fail-open): such an engine cannot see the package's body, and treating an unknown default as on keeps the behaviour every packaged flow had before this release instead of switching off a flow no package was seen to declare off.
2727

2828
ADR-0126 §4 carries an amendment note: "absence of a row means the packaged default" now reads the default a packaged flow declares; the ledger's shape is unchanged.

‎packages/spec/src/api/automation-api.zod.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ import { DroppedFieldsEventSchema } from '../data/data-engine.zod';
3333
* there. Its switch is its own `status`: `'obsolete'` disarms it and
3434
* `'active'` arms it, published with the complete definition through
3535
* `PUT /api/v1/automation/:name`. The toggle door refuses such a flow with
36-
* 409 `RESOURCE_CONFLICT`, names that switch, and changes nothing.
36+
* 409 `RESOURCE_CONFLICT`, names that switch, and changes nothing. It refuses
37+
* the same way a switch ON of a packaged flow whose own `status` disables it
38+
* (`'obsolete'` / `'invalid'`): the ledger row alone would leave the flow off
39+
* while the caller read it as on, so it answers 409 `RESOURCE_CONFLICT`,
40+
* names publishing the definition `'active'`, and writes nothing. A switch
41+
* OFF of such a flow is accepted and records the choice.
3742
*
3843
* @example Endpoints
3944
* ```

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,12 @@ export interface IAutomationService {
19741974
* (ADR-0126 §7.2). A flow authored in the deployment is not this switch's:
19751975
* the automation service refuses it with `RESOURCE_CONFLICT` / 409 and
19761976
* changes nothing. That flow's switch is its own `status` (`'obsolete'` /
1977-
* `'active'`), published through {@link registerFlow}.
1977+
* `'active'`), published through {@link registerFlow}. A packaged flow
1978+
* whose own `status` disables it (`'obsolete'` / `'invalid'`) is refused
1979+
* the same way when switched ON — `RESOURCE_CONFLICT` / 409, nothing
1980+
* written — because the ledger row alone would leave it off while the
1981+
* caller read it as on; publishing its definition `'active'` arms it.
1982+
* Switching such a flow OFF is accepted and records the choice.
19781983
*
19791984
* `caller` names who made the request, so the activation-ledger row the
19801985
* switch writes, and the audit row that write produces, attribute it to

0 commit comments

Comments
 (0)