|
| 1 | +--- |
| 2 | +"@objectstack/spec": minor |
| 3 | +"@objectstack/service-automation": minor |
| 4 | +"@objectstack/plugin-approvals": minor |
| 5 | +"@objectstack/rest": patch |
| 6 | +"@objectstack/runtime": patch |
| 7 | +--- |
| 8 | + |
| 9 | +fix(automation,approvals): an approval decision can no longer succeed while its flow stays parked (#4420) |
| 10 | + |
| 11 | +A flow paused at an `approval` node, a deploy, then an approver clicking |
| 12 | +Approve: the request row flipped to `approved`, the UI toasted success — and |
| 13 | +the flow never moved. No next-stage request, no error, the record's mirrored |
| 14 | +status frozen mid-workflow. Approval flows pause for days by design, so a |
| 15 | +restart mid-flight is the normal case: every release could quietly zombify |
| 16 | +every in-flight approval, with the approvers none the wiser. |
| 17 | + |
| 18 | +Durable suspended runs (#1518) had shipped and were not the missing piece. Two |
| 19 | +other things were. |
| 20 | + |
| 21 | +**The wiring could enable a store over a table nobody had created.** Object |
| 22 | +registration and store activation resolve different services in different |
| 23 | +phases — `manifest` at `init()`, `objectql` at `start()` — and the plugin |
| 24 | +declared no ordering. Composed ahead of ObjectQL, `init()` found no `manifest`, |
| 25 | +warned, and continued; `start()` then attached the DB-backed store anyway. Every |
| 26 | +suspend failed with `no such table: sys_automation_run` into a log line nobody |
| 27 | +read, pauses silently stayed in memory, and the next restart lost them all. |
| 28 | +Now: `AutomationServicePlugin` declares `optionalDependencies: |
| 29 | +['com.objectstack.engine.objectql']` (order-if-present, per ADR-0116 — an |
| 30 | +engine-less kernel must still boot); a registration missed at `init()` is |
| 31 | +retried at `start()`, which still lands before ObjectQL's schema sync; the |
| 32 | +store is never attached when registration did not happen, and says so at |
| 33 | +**error** level instead of warning; the table is probed once at boot so a |
| 34 | +broken setup surfaces there rather than one failed write at a time; and a |
| 35 | +failed durable write of a paused run is logged at error — it is data loss in |
| 36 | +waiting, not a warning. |
| 37 | + |
| 38 | +**A reported resume failure read as success.** `AutomationEngine.resume()` |
| 39 | +answers a lost run by *returning* `{ success: false }`, never by throwing. |
| 40 | +`ApprovalService` discarded that return value, and `decide()` counted only a |
| 41 | +thrown error as failure — so a decision against a dead run came back |
| 42 | +`resumed: true`, HTTP 200. Resume failures are now classified |
| 43 | +(`RUN_NOT_FOUND`, `STORE_UNAVAILABLE`, `RESUME_IN_PROGRESS`, joining |
| 44 | +`PERMISSION_DENIED` / `INVALID_SIGNAL`), so a run that is gone for good is |
| 45 | +distinguishable from a store that is merely unreachable, and the raw resume |
| 46 | +route maps them to 404 / 503 / 409. |
| 47 | + |
| 48 | +Approvals acts on them. A new `AutomationEngine.hasSuspendedRun(runId)` — which |
| 49 | +reads the suspension store, unlike `getRun()`, and throws rather than answering |
| 50 | +`false` when the store is unreadable — pre-flights every flow-advancing |
| 51 | +operation (`decide`, `sendBack`, `resubmit`) **before its first write**, so the |
| 52 | +zombie half-state is never created rather than merely reported: the decision |
| 53 | +fails with `RESUME_TARGET_LOST` (HTTP 409) and the request stays actionable. A |
| 54 | +resume that fails after the decision is durable can no longer be undone, but it |
| 55 | +now throws `RESUME_FAILED` (HTTP 500) naming the stranded run instead of |
| 56 | +reporting success. A concurrent duplicate resume stays benign — the engine's |
| 57 | +idempotency guard is doing its job — and reports through the new optional |
| 58 | +`resumeError` field. Recall and revise-window cancellation stay non-fatal by |
| 59 | +design (they abandon the request), but log at error with the reason instead of |
| 60 | +swallowing it. Compositions with no automation engine attached are unaffected. |
| 61 | + |
| 62 | +Existing zombie requests from affected deployments (already `approved`, run |
| 63 | +stranded) are not repaired by this change — `releaseDeadRunRequests` only |
| 64 | +sweeps requests that are still `pending`. |
0 commit comments