Skip to content

feat(channels): record account lifecycle facts and retire inferred health vocabularies - #117300

Merged
steipete merged 4 commits into
mainfrom
feat/channel-lifecycle-fact
Aug 1, 2026
Merged

steipete merged 4 commits into
mainfrom
feat/channel-lifecycle-fact

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Channel health is largely inferred (timers, socket flags) instead of recorded, and the one state-ish field that exists — healthState — carries two conflicting vocabularies: policy verdicts written back by the gateway and channel-authored display strings that no core consumer reads. Concrete failures this produced: a Slack account with broken identity stayed "healthy" forever (fixed for identity specifically in #117253, but the state remained unrepresentable), operator surfaces and the health monitor could disagree, and Discord shipped its own duplicate interpretation layer over the shared verdict.

Why This Change Was Made

One recorded lifecycle fact, written where transitions happen, read everywhere:

  • lifecycle?: "starting" | "ready" | "recovering" | "blocked" | "stopped" on ChannelAccountSnapshot, surviving both projections. The gateway writes starting (unconditionally on every start, so a stale blocked cannot outlive its cause across the blind patch-merge), ready, recovering, and stopped; blocked is plugin-authored only — Slack's identity health is the first producer.
  • evaluateChannelHealth consumes the recorded fact above the inference waterfall: blocked is unhealthy and non-restarting; starting/recovering grant startup grace bounded by the connect-grace wall clock — past the bound (or with no start timestamp) evaluation falls through to disconnected/stale/stuck inference, so a channel hung in starting cannot evade monitoring (a defect caught and fixed in review of this PR itself).
  • healthState becomes derived-only (policy output at status boundaries); Slack's channel-authored writes migrate to lifecycle.
  • Named behavior change: Discord's runtime-health branch in collectDiscordStatusIssues string-matched gateway-derived healthState reasons — a duplicate of the shared collectChannelStatusIssues surface, and the only consumer of that vocabulary. It is deleted; parity tests prove stale-socket and running-but-disconnected Discord states remain operator-visible through the generic path. Discord-owned checks (application/intents/permissions) are untouched.

User Impact

channels status, doctor, readiness, the health monitor, and auto-recovery now agree on one recorded operational state. A blocked account says blocked — and is not futilely restarted. Existing external plugins that never publish lifecycle are unaffected (optional field; socketless tri-state connected semantics preserved and test-pinned).

Evidence

  • Mock-gateway boundary proof (mock channel + ephemeral gateway): PASS in 77.5s — a blocked Slack account surfaces lifecycle:"blocked" with derived healthState:"blocked" in channels.status, running:true, restartPending:false, and lastStartAt unchanged (health monitor did not restart it).
  • Focused suites: projection/policy/generic-status 81; gateway manager 81; monitor+readiness+status RPC 87; Slack monitor 93; health formatter/status/server-method 237; policy+monitor+readiness after the bounded-grace fix 198. SDK surface + API baseline gates green (baseline regenerated via plugin-sdk:api:gen).
  • Structured autoreview (Codex, gpt-5.6-sol, high): clean — after initial implementation and again after the bounded-grace fix.
  • Production LOC ≈ net 0 (+105/−95 by strict split) for a new recorded fact — paid for by the healthState/Discord dedup deletions; tests/QA +425.

🤖 Generated with Claude Code

Review correction (accepted ClawSweeper finding)

The original absorption dropped channel-authored healthState from projections — breaking WhatsApp's owner-specific QR-login/doctor guidance (logged-out, conflict, …) and silently narrowing a shipped public snapshot field. Restored to main's exact pass-through semantics: authored values survive both projections; the shared evaluator still never reads healthState; only the pre-existing unhealthy-boundary overwrite remains; bundled Slack/Discord stay migrated to lifecycle. WhatsApp fixtures now project logged-out/conflict through the real SDK helper and assert distinct guidance. Deprecating channel-authored healthState is named future SDK work, not this PR. Branch prod delta: +7 LOC (the restored pass-through), 1,166 tests across 56 files green.

@steipete
steipete marked this pull request as ready for review August 1, 2026 08:18
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: slack Channel integration: slack gateway Gateway runtime commands Command implementations extensions: qa-lab size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 5:37 AM ET / 09:37 UTC.

ClawSweeper review

What this changes

This PR adds an optional recorded lifecycle state to channel account status, uses it for Gateway health, readiness, and restart decisions, and migrates Slack while retaining WhatsApp-specific diagnostics.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for maintainer review. The latest head addresses the prior WhatsApp P1 by preserving channel-authored healthState diagnostics while adding the new lifecycle fact, but it intentionally expands the public channel-status contract and is protected by the maintainer label; that contract needs explicit acceptance and the current failed lint/type checks need resolution before merge.

Priority: P1
Reviewed head: 9dc40800e0f3d4197a8a8c76476ab52c363e4c1c
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has strong boundary proof and resolves the prior WhatsApp regression concern, while the new public status contract and current failed checks still need maintainer resolution.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR supplies a mock-channel plus ephemeral-Gateway boundary result demonstrating blocked status and no futile restart; the repository policy accepts that harness as channel-visible real-behavior proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR supplies a mock-channel plus ephemeral-Gateway boundary result demonstrating blocked status and no futile restart; the repository policy accepts that harness as channel-visible real-behavior proof.
Evidence reviewed 6 items Current main does not yet provide the lifecycle contract: Current main exposes healthState in ChannelAccountSnapshot and moves directly to ingress state, so the requested lifecycle field is not already implemented on main.
Branch adds an optional, typed lifecycle fact: The PR adds starting, ready, recovering, blocked, and stopped as a typed optional account snapshot field, making it visible across the plugin SDK boundary.
Previous WhatsApp blocker is addressed at the current head: WhatsApp still reads its channel-authored healthState vocabulary for logged-out, stale, reconnecting, conflict, and stopped guidance; the updated test builds a runtime snapshot that retains those values.
Findings None None.
Security None None.

How this fits together

Channel plugins publish account runtime facts to the Gateway, which projects them into channels status, health output, readiness checks, and the automatic restart monitor. The proposed lifecycle field makes one producer-owned operational fact available to those shared consumers.

flowchart LR
  A[Channel plugin runtime] --> B[Account status facts]
  B --> C[Gateway lifecycle state]
  C --> D[Shared health evaluation]
  D --> E[Status and readiness]
  D --> F[Restart monitor]
  E --> G[Operator guidance]
Loading

Decision needed

Question Recommendation
Should lifecycle become a supported ChannelAccountSnapshot contract for third-party channel plugins, with blocked explicitly suppressing Gateway auto-restart? Accept and document the lifecycle contract: Keep the typed optional field, document each state and the restart consequence of blocked, and retain the existing channel-specific diagnostic fields.

Why: This is not merely an internal refactor: an optional Plugin SDK field changes how plugin-authored status can control shared Gateway recovery behavior, so maintainers need to choose the permanent external contract and documentation level.

Before merge

  • Resolve merge risk (P1) - ChannelAccountSnapshot.lifecycle is a public plugin-facing semantic contract: setting blocked changes generic health and suppresses automatic restart, so its ownership and allowed meanings need explicit maintainer acceptance before external plugins rely on it.
  • Resolve merge risk (P1) - The current head has failed check-lint and check-test-types runs in the supplied status; their causes must be resolved or shown unrelated before merge.
Agent review details

Security

None.

PR surface

Source +21, Tests +355, Generated 0, Other +74. Total +450 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 20 105 84 +21
Tests 21 410 55 +355
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 3 3 0
Other 1 74 0 +74
Total 43 592 142 +450

Review metrics

Metric Value Why it matters
Plugin status contract 1 optional account-status field added The new field can alter shared health and restart behavior when emitted by a channel plugin, so its compatibility semantics matter before merge.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/whatsapp/src/status-issues.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept a documented lifecycle API (recommended)
    Confirm the five-state lifecycle contract, document its plugin-facing semantics and blocked restart behavior, then resolve the current-head lint and test-type failures before merge.
  2. Constrain lifecycle to internal ownership
    If third-party plugins should not influence restart policy, replace the public snapshot field with an internal Gateway-to-bundled-channel seam.

Technical review

Best possible solution:

Adopt lifecycle as a documented, narrow plugin status contract only if maintainers want external channel plugins to publish those five operational states; retain WhatsApp-specific healthState guidance as a separate projected diagnostic and merge only after the current-head checks pass.

Do we have a high-confidence way to reproduce the issue?

Yes for the covered boundary: the supplied mock Gateway scenario exercises a blocked Slack account through channels.status and the health monitor, and current source shows the previous WhatsApp diagnostic path remains distinct. I did not execute the harness because this review is read-only.

Is this the best way to solve the issue?

Mostly yes: recording lifecycle at the transition owner is a stronger design than inferring it downstream, and the latest head preserves the WhatsApp diagnostics previously at risk. The remaining question is whether that lifecycle should be a documented external plugin contract rather than an internal bundled-channel fact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against aa743c9f8186.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR supplies a mock-channel plus ephemeral-Gateway boundary result demonstrating blocked status and no futile restart; the repository policy accepts that harness as channel-visible real-behavior proof.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The change governs channel readiness and automatic recovery for broken runtime accounts, including the Slack identity path that can otherwise remain operationally misleading.
  • merge-risk: 🚨 compatibility: Adding lifecycle to the public account snapshot creates a new plugin-to-Gateway behavioral contract, including restart suppression for blocked.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR supplies a mock-channel plus ephemeral-Gateway boundary result demonstrating blocked status and no futile restart; the repository policy accepts that harness as channel-visible real-behavior proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies a mock-channel plus ephemeral-Gateway boundary result demonstrating blocked status and no futile restart; the repository policy accepts that harness as channel-visible real-behavior proof.

Evidence

What I checked:

  • Current main does not yet provide the lifecycle contract: Current main exposes healthState in ChannelAccountSnapshot and moves directly to ingress state, so the requested lifecycle field is not already implemented on main. (src/channels/plugins/types.core.ts:170, aa743c9f8186)
  • Branch adds an optional, typed lifecycle fact: The PR adds starting, ready, recovering, blocked, and stopped as a typed optional account snapshot field, making it visible across the plugin SDK boundary. (src/channels/plugins/types.core.ts:171, 9dc40800e0f3)
  • Previous WhatsApp blocker is addressed at the current head: WhatsApp still reads its channel-authored healthState vocabulary for logged-out, stale, reconnecting, conflict, and stopped guidance; the updated test builds a runtime snapshot that retains those values. (extensions/whatsapp/src/status-issues.ts:22, 9dc40800e0f3)
  • Head provenance: The latest commit is fix(channels): preserve authored health state, matching the previous ClawSweeper concern about retaining WhatsApp-specific operator guidance. (extensions/whatsapp/src/status-issues.ts:22, 9dc40800e0f3)
  • No intervening main rewrite of this decision surface: A focused comparison from the PR base to current main returned no changes in the lifecycle, shared-health, Slack, Discord, or WhatsApp status paths, so current main does not supersede this work. (src/gateway/channel-health-policy.ts:86, aa743c9f8186)
  • Real behavior evidence supplied by the PR: The PR body reports a mock-channel plus ephemeral-Gateway run showing a blocked Slack account in channels.status and no health-monitor restart; the repository policy recognizes this harness form as valid channel-visible proof. (qa/scenarios/channels/slack-blocked-lifecycle-no-restart.yaml:1, 9dc40800e0f3)

Likely related people:

  • steipete: Authored the merged Slack identity recovery work that exposed the status ambiguity and the current lifecycle proposal; the newest branch commit specifically restores authored health-state projection. (role: recent channel-health contributor; confidence: high; commits: 7aacd1314d71, 9dc40800e0f3; files: extensions/slack/src/monitor/provider-support.ts, src/gateway/channel-health-policy.ts, src/gateway/server-channels.ts)
  • Vincent Koc: Current-main blame attributes the WhatsApp-specific logged-out, stale, reconnecting, conflict, and stopped guidance to this area history, which this PR must preserve. (role: WhatsApp diagnostic behavior introducer; confidence: high; commits: 42c313976e; files: extensions/whatsapp/src/status-issues.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm and document whether external channel plugins may emit lifecycle states that control restart behavior.
  • Resolve or explain the current-head check-lint and check-test-types failures, then refresh review on the exact head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-01T08:24:31.826Z sha 491e0983f0a0c22e65fa3ec5c1c788d1598eb010 :: found issues before merge. :: [P1] Preserve the channel-specific diagnostics before dropping healthState
  • reviewed 2026-08-01T08:47:32.022Z sha a1b2629 :: found issues before merge. :: [P1] Preserve WhatsApp diagnostics before dropping healthState

@steipete
steipete force-pushed the feat/channel-lifecycle-fact branch from 491e098 to a1b2629 Compare August 1, 2026 08:38
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 1, 2026
@steipete steipete self-assigned this Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added the channel: whatsapp-web Channel integration: whatsapp-web label Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 1, 2026
@steipete
steipete merged commit aa2a5c9 into main Aug 1, 2026
130 checks passed
@steipete
steipete deleted the feat/channel-lifecycle-fact branch August 1, 2026 09:51
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Aug 1, 2026
* origin/main:
  fix(test/ui): prevent shared history pollution (openclaw#117348)
  fix(openrouter): apply image request transport policy (openclaw#117336)
  perf(gateway): skip clean transcript workers (openclaw#117342)
  test(testing): assert relay smoke readiness
  fix(testing): activate relay live smoke transport
  feat(channels): record account lifecycle facts and retire inferred health vocabularies (openclaw#117300)
  fix(canvas): remove unsupported snapshot delay hint (openclaw#117326)
  refactor(agents): fold cache TTL pruning into prompt projection (openclaw#117313)
  fix(canvas): honor paired-node invocation deadlines (openclaw#117316)
  fix(system-agent): make exit-and-run-a-terminal guidance surface-correct (openclaw#114633)
  fix(ai): assistant text blocks are run together on replay (openclaw#115743)
  refactor(agents): canonicalize subagent execution state (openclaw#117267)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…alth vocabularies (openclaw#117300)

* fix(channels): record account lifecycle facts

* fix(channels): bound recorded lifecycle grace

* fix(channels): preserve authored health state

* test: dedupe health snapshot type literal and fix spread order
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main:
  fix(test/ui): prevent shared history pollution (openclaw#117348)
  fix(openrouter): apply image request transport policy (openclaw#117336)
  perf(gateway): skip clean transcript workers (openclaw#117342)
  test(testing): assert relay smoke readiness
  fix(testing): activate relay live smoke transport
  feat(channels): record account lifecycle facts and retire inferred health vocabularies (openclaw#117300)
  fix(canvas): remove unsupported snapshot delay hint (openclaw#117326)
  refactor(agents): fold cache TTL pruning into prompt projection (openclaw#117313)
  fix(canvas): honor paired-node invocation deadlines (openclaw#117316)
  fix(system-agent): make exit-and-run-a-terminal guidance surface-correct (openclaw#114633)
  fix(ai): assistant text blocks are run together on replay (openclaw#115743)
  refactor(agents): canonicalize subagent execution state (openclaw#117267)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack channel: whatsapp-web Channel integration: whatsapp-web commands Command implementations docs Improvements or additions to documentation extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant