Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .changeset/33905-disabled-sole-holder-flow.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
'@objectstack/service-automation': patch
---
Expand All @@ -18,11 +18,7 @@
- `getFlow(name)` answered the flow. It now answers `null`, so the bare HTTP doors that ask it first (`GET /automation/NAME`, `POST /automation/NAME/trigger`, `POST /automation/trigger/NAME`, `POST /automation/NAME/toggle`, `POST /automation/NAME/clone`, `GET /automation/NAME/runs`) answer `404`, which is what the namespaced address `/automation/NAMESPACE/NAME…` already answered.
- `toggleFlow(name, …)` switched the flow. It now rejects with `Flow 'NAME' not found`.

Three HTTP write doors ask `getFlow` whether the name is held, and move with it for such a flow. These answers were read from the runtime source; the engine's half of the clone answer was measured. Each holds only where the door's earlier checks, such as the packaged-base and authoring rules, let the request through.

- `POST /automation/SOURCE/clone`, with the flow's name as the new name: the taken-name probe refused the copy with `409`. It now finds no flow and lets the copy through. The engine files the copy's body in the disabled package's slot of the name, and once the package is enabled again its trigger runs the copy's body until the next re-sync. That is the answer the door already gives once the disable's re-sync has withdrawn the flow, so the door accepts nothing the normal path refuses.
- A definition write (`POST /automation`, `PUT /automation/NAME`) or a clone that the engine accepts and that is then refused (an unknown `notify` channel, a refused landing, a refused save) put back the definition the engine held. It now has nothing to put back, so it removes the name's registration. A `PUT` body that leaves out a stored credential no longer keeps the one the engine held.
- `DELETE /automation/NAME` answered a deletion. It still removes the engine's registration, but now answers `404` unless a stored row was removed.
The HTTP write doors that ask a lasting question of the name do not move with it: the clone door's taken-name check on the new name, the definition a refused `POST /automation` or `PUT /automation/NAME` puts back, the stored credential a `PUT /automation/NAME` body, or a `POST /automation` body onto a name the engine holds, keeps when it leaves it out, and the `DELETE /automation/NAME` existence check read the flow the engine holds whatever its package's enable state. For such a flow the clone's new name is refused `409`, the held definition is put back, the credential is kept and `DELETE` answers a deletion, as before this release. A name two packages hold is read at those doors on its served holder, as the bare entries read it.

Remedy: enable the package. Its flow runs on its trigger again with no re-arm, and the bare entries serve it again.

Expand Down
26 changes: 26 additions & 0 deletions .changeset/34145-write-doors-durable-read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/runtime': patch
'@objectstack/service-automation': patch
---

fix(runtime): the automation write doors keep a flow whose only package is disabled, whatever that package's enable state

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

**Added:** `AutomationEngine.getHeldFlow(name)` on `@objectstack/service-automation`: the flow the engine holds under a bare name, judged over every holder (a disabled package's included, `null` for a name it does not hold or a slot-key spelling); a name two packages hold is refused `409` naming every holder. Like `getFlow`, it settles the name first, so a lone qualified slot of a name one package holds again is re-keyed to the bare name.

Four `/automation` write doors ask a lasting question of a flow name: the clone door's taken-name check on the new name, the copy a refused definition write (`POST /`, `PUT /automation/NAME`) puts back, the credential `PUT /automation/NAME`, or `POST /automation` onto a name the engine already holds, keeps when the body leaves it out, and the `DELETE /automation/NAME` existence check. They read the engine's served view (`getFlow`), in which a flow whose one package is disabled is no flow. For a name one package holds they now read the flow the engine holds over every holder, through `getHeldFlow`, so their answers no longer depend on whether that package is enabled. For a flow whose only package is disabled while the engine still holds it:

- Clone with this flow's name as the new name: refused `409`, the door's name-taken answer, and nothing is registered. Before, the copy was admitted and filed in the disabled package's slot.
- A definition write the engine accepts and the store then refuses: the flow the engine held is registered again. Before, the name was withdrawn.
- `PUT`, or `POST /` onto the name, with a body that leaves out a stored credential: the stored credential is kept. Before, nothing was carried forward.
- `DELETE`: the flow is removed and the door answers a deletion. Before, the door removed it and answered `404`.

These are the answers the last release gave: the served view changed after it.

A name two packages hold is read at these doors on its served holder, as before: a refused definition write puts back the served holder's body, and a `PUT`, or a `POST /` onto the name, keeps the served holder's stored credential. With one holder disabled, a package-less `PUT /automation/NAME` or `POST /automation` onto such a name is admitted into the enabled holder, with or without a metadata store (the store's save, naming no package, writes the enabled holder's row), as before. While both holders are enabled, the definition writes and `DELETE` are refused `409` (`RESOURCE_CONFLICT`) naming every holder, as before.

The clone door's new name: a name two packages hold is taken. While one holder is disabled it gets the door's name-taken `409`, as before. While both are enabled, the engine's refusal used to leave the door thrown, naming every holder; the door now answers its own name-taken refusal, returned, with the same status and code (`409`, `RESOURCE_CONFLICT`), whose remedy is a new name. One exception, as before: a name two packages hold with both holders disabled is not taken at the clone door (no holder is served, so the door finds no flow there) and the copy is admitted.

A flow of an enabled package, and a name the engine does not hold, answer as before. The read and run doors (`GET`, trigger, toggle, runs, the clone's source) keep the served view.
Loading
Loading