Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs: enumerate the real FAILED writers in the lifecycle catalog
Yudhi Armyndharis3d9d57d7b5d3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b23861c4d..8716304fa 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,9 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed-- Follow-ups from the accessibility review: the plugin ConfigField derives a per-field id (a hardcoded id collided on any schema with two booleans, making the second label toggle the first checkbox), the 10 codemod-touched files are Prettier-clean (9 failed the dashboard format gate), and six more multi-line labels in MessageTester are wired.+- The plugin config editor derives a per-field id: a hardcoded one collided on any schema with two boolean fields, so the second field's label toggled the first field's checkbox. Six more multi-line labels in MessageTester are associated with their controls.- Dashboard accessibility: 55 form labels are associated with their controls (`htmlFor`/`id`, no duplicates or orphans), the muted-text token meets AA on both themes (4.76:1 light, 5.71:1 dark), and the primary button uses dark text on the green (9.0:1, from 1.98:1).-- Follow-ups from the batch review: the chain-boot e2e sets MAIN_DATABASE_SYNCHRONIZE=false explicitly (the env's absence defaults to synchronize=true, so the main chain was never exercised), the drift gate classifies statements against the two known shape families (column-type rebuild, index-name drift) instead of blanket-filtering every index/DROP statement, the shared delivery recorder strips the raw error before the persistence spread, and the ignore-pattern list deduplicates.+- The chain-boot e2e sets `MAIN_DATABASE_SYNCHRONIZE=false` explicitly: the variable's absence defaults to synchronize=true, so the main connection's migration chain was never actually exercised. The shared delivery recorder also strips the raw error before the persistence spread, and the coverage ignore-pattern list deduplicates.- The direct and queued webhook delivery paths share one POST-and-classify core (`postWebhookPayload`) and one terminal-failure recorder, instead of two line-for-line copies that an outbox would have tripled.- Test and DB infrastructure: the 23 file-reading specs are excluded from the unit coverage denominators (spec files were counted as 0%-covered source, ~994 lines inflating every floor), an e2e boots the production SQLite schema from scratch through both full migration chains (the path the other suites' synchronize=true never touches), and a drift gate derives the chain-vs-entity diff so a missing index, column, or constraint fails while the known column-type rebuild is pinned as a visible baseline.- The ingress route's rate bound is the per-instance limit alone: the global per-IP medium tier (100/min, below the instance default of 120/min) used to 429 every tenant of a shared-egress-IP provider before the instance bound ever fired.diff --git a/docs/31-session-lifecycle-design.md b/docs/31-session-lifecycle-design.mdindex bd3de1b68..48d5686ca 100644--- a/docs/31-session-lifecycle-design.md+++ b/docs/31-session-lifecycle-design.md@@ -115,19 +115,33 @@ for minutes; detaching from bootstrap means the API answers while engines warm.## 31.2 Status-transition ownership-Exactly one writer per transition — when debugging a status surprise, find the writer before-anything else:--| Transition | Sole writer |-| ------------------------------- | ------------------------------------------------------------------------------------------ |-| → `INITIALIZING` | `initializeEngine` (persisted before `initialize()`) |-| → `QR_READY` / `AUTHENTICATING` | engine callbacks (wired in the lifecycle delegate), via the registry's liveness check |-| → `READY` | `handleEngineReady` (also drops a recorded failure reason — see INV-7's rationale comment) |-| → `DISCONNECTED` | init-timeout eviction, graceful stop, puppeteer-death detection |-| → `FAILED` | `start()`'s rejection path — and nothing else; reconnect loops NEVER write FAILED |--The last row is load-bearing: a reconnect loop that wrote FAILED would convert every transient-network blip into an operator-visible terminal state, defeating INV-7's signal.+Every transition has a known, enumerated set of writers. When debugging a status surprise, find the+writer before anything else:++| Transition | Writers |+| ------------------------------- | ----------------------------------------------------------------------------------------- |+| → `INITIALIZING` | `initializeEngine` (persisted before `initialize()`) |+| → `QR_READY` / `AUTHENTICATING` | engine callbacks (wired in the lifecycle delegate), via the registry's liveness check |+| → `READY` | `handleEngineReady` (also drops a recorded failure reason, see INV-7's rationale comment) |+| → `DISCONNECTED` | init-timeout eviction, graceful stop, puppeteer-death detection |+| → `FAILED` | four terminal paths only, all ownership-fenced: see below |++`FAILED` is the one worth spelling out, because it is terminal (neither the boot reset nor the+takeover sweep resumes a FAILED row, INV-7) and because more than one path reaches it:++1. `start()`'s own rejection path, when `initializeEngine` throws (`session-engine-controls.ts`).+2. The engine's `onError` callback, which is terminal by definition: it cancels any pending+ reconnect before persisting, because a re-scan is required (`session-engine-event-wiring.ts`).+3. The engine reporting `EngineStatus.FAILED` through `onStateChanged`, which the status map+ forwards verbatim (`session-engine-event-wiring.ts`).+4. A reconnect chain that EXHAUSTS its attempts, so the session is not left silently stuck+ `DISCONNECTED` with no engine (`session-engine-lifecycle.service.ts`).++What still holds, and is load-bearing, is the narrower claim: no reconnect ATTEMPT writes FAILED.+Only the exhaustion of the whole chain does. A loop that marked each failed attempt would turn every+transient network blip into an operator-visible terminal state and defeat INV-7's signal. All four+paths are fenced on `ownsSession`, so a dying generation cannot park a peer's session in a status+nothing resets automatically.## 31.3 Comments that exist because the obvious fix is wrong