Repository navigation
fix(startup): honor startup webhook decisions for channels Doctor left pending - #169778
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesMerge webhook migration completion decisions from config and machine state per channel, preserving config precedence. Example: Config records telegram, feishu, and nextcloud-talk completion, while SQLite records msteams: [].
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a documented startup behavior that remains broken on current main; no actionable correctness or security findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway startup and Doctor consume historical webhook completion records to decide whether channel listener migration is still required. flowchart TD
A[Config completion] --> C[Webhook migration owner]
B[SQLite completion] --> C
C --> D[Startup preflight]
C --> E[Doctor migration]
D --> F[Skip completed channels]
E --> G[Preserve listener decisions]
Technical reviewBest possible solution: Use the existing webhook migration owner to combine recorded channel decisions consistently across startup and Doctor. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the partial-record failure directly, and supplied stable-release Gateway traces reproduce repeated inspection and later Teams startup refusal; no target code was executed during this review. Is this the best way to solve the issue? The patch repairs both affected readers through one shared merge operation, preserves authored decisions and stored formats, and adds regressions for skipped startup inspection and permanent Teams completion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d1c0b1c15c65. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +23, Tests +36. Total +59 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 24, 2026, 3:34 PM ET / 19:34 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Confirming this still reproduces on 2026.10.5 (npm global install, Windows 11, Node 24.22.1). The config matched the case described in the PR body exactly — Doctor had completed three channels, and "meta": { "migrations": { "webhookListeners": {
"telegram": [], "feishu": [], "nextcloud-talk": []
} } }Startup phase log on that config: 41.75 s spent in the scan. This host only configures After manually adding One caveat on the number: this is a production gateway, so I did not run a controlled A/B (removing the key again for a fresh timed boot). The 41.7 s is a single measured start, not an average. +1 for landing this. It matters more than the raw seconds suggest: on this host total time-to-bind is already ~110 s (cf. #162211), so an unconditional extra scan is a meaningful share of the window where the gateway looks dead and a restart gets requested. |
ab045a8 to
1f306ba
Compare
|
Thanks for confirming. 2026.10.5 predates #177224, but that fix still uses |
1f306ba to
355a3d7
Compare
…ctor left pending Startup read the machine-state completion only when config had no marker. A partial Doctor record (telegram, feishu, nextcloud-talk) hid the msteams decision startup had recorded, so every boot rescanned Teams and adding Teams later could reopen its historical port. Merge both per channel; config wins.
355a3d7 to
b7a52b3
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@steipete since you landed #177224: this is the follow-up for the case it leaves open. #177224 reads the machine-state receipt only when config has no marker (
This PR merges the two records per channel (config wins) in both readers, Happy to adjust if you'd rather fold this in differently. |
|
Merged via squash.
|
…ctor left pending (openclaw#169778) Preserve startup's completed Teams webhook decision when Doctor left a partial completion record in config. Repeated startup skips completed migration work, and adding Teams later does not recreate its historical webhook pin. Merge decisions per channel in the existing legacy-webhook-pins owner. Explicit config decisions win, config true avoids machine lookup, and machine state fills only missing channels. Startup and Doctor use the same merge without changing stored formats, listener policy, SDK contracts, or authored config writes. Validation: startup regression RED on unchanged main ca26429 and GREEN on b7a52b3; 177 consumer tests plus two real SQLite/registered Teams boundary controls passed in secretless AWS isolation. Core and affected test types, touched-file lint/format passed. Fresh independent P0-P2 review was clean. Existing exact-head CI run 39811114314 passed on October 22; no new merge-head CI or authenticated Teams/upgrade result is claimed. Co-authored-by: htjworld <[email protected]> Co-authored-by: steipete <[email protected]>
Backport accepted fixes onto 2026.11.5-beta.2. Base: bc061f9 Canonical source tree before commit: e6c0c39 These are adapted/squashed backports; do not claim each is an exact Git cherry-pick. Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests): runtime-B: b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468) c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713) 6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495) 8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436) 00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827) c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865) e72b356 fix(anthropic): avoid token profile collisions (#187875) 807075d fix(anthropic): set API workspace at login (#186976) bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729) 9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919) 6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909) 4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979) de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432) e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271) provider-compaction: 1b43c2e fix(compaction): preserve active request provenance (#180214) 7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561) 9039ceb fix(ci): keep compaction attribution helpers internal d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395) fe0f8d1 fix(google): Gemini models ignore configured topP (#190695) history: c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690) 3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450) b195f61 fix(sessions): page oversized transcript history in both directions (#188483) b65482e fix(gateway): preserve older history across hidden message gaps (#188557) 3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284) 33e7baf fix(sessions): bound active accounting without blocking writers (#190182) 682ade7 fix: preserve chat history continuation metadata (#188612) runtime-C: 7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734) 15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664) b53a06b perf(update): read candidate state inventory without copying the shared database (#187921) 970fc4e fix: restore CLI message sends with agent tool policies (#188058) 73ad731 fix: stop model fallback when session capability metadata changes (#179312) 32305db fix: subagent turns fail after session metadata changes (#183501) d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005) e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982) 9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434) direct-auth-state: 1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014) 7d8dc60 fix: recover startup migration with retained worker index (#189023) capacity: 41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727) command-once-189369: 8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369) pg-board-189564: 7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564) queued-edit-189869: 92b32ca fix: hold queued messages through inline edits (#189869) Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line. Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json. No held136/native82 content adopted by this work. No release or full-candidate qualification claim. Additional original-source identities (exact adapted hunk scope is in frozen artifacts): release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258) UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372) obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203) webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778) schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391) backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976) canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846) matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272) provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059) unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868) replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672) Co-authored-by: RomneyDa <[email protected]>
Follow-up to #177224 for #169406. This PR covers only the partial-record case #177224 leaves open.
What Problem This Solves
#177224 made startup read the machine-state webhook completion when
openclaw.jsonhas no marker. It still reads it only in that case (config ?? machineState). When Doctor recorded some channels in config and left Teams pending (the documented Teams-without-credentials case), config holds{ telegram, feishu, nextcloud-talk }, so themsteamsdecision startup recorded in machine state is ignored:openclaw doctor --fixand Doctor pins historical port 3978.This is the config @JIRBOY reported below on 2026.10.5:
webhook-readinesstook 41.7 s on a host that configures only Feishu and QQ Bot, and the step disappeared after"msteams": []was added by hand.User Impact
After startup records a channel decision Doctor left pending, later starts skip the scan. Config bytes are unchanged. Adding Teams later does not reopen its historical port, as webhook migrations documents: "A startup without Teams credentials … completes that decision without a pin. Adding Teams later does not reopen its old port."
Why This Change Was Made
Both readers of the completion marker treated a partial config record as the whole answer: the startup gate (
startup-config-preflight.ts) andapplyHistoricalWebhookPins.Changes, in the existing owner
legacy-webhook-pins.ts:mergeWebhookCompletionmerges per channel: config decisions win, and machine-state decisions fill channels config has not recorded. A configtruestill wins outright and skips the machine-state read.readWebhookCompletion(replacesreadUnwrittenWebhookCompletion, whose only caller was the startup gate) returns that merged view for startup.applyHistoricalWebhookPinsuses the same merge.Not changed: what the scan does when it runs, the pin policy, Doctor's config writes, and both stored formats (config keeps
trueor a per-channel record; machine state keeps the same key and JSON value). A full config marker already skipped this scan, so skipping it when config and machine state together cover every channel is not a new bypass.Evidence
Independent validation, 2026-10-30: retained the contributor's unchanged head
b7a52b37878ec9df381510e99be7467c723fecc3; no rebase or source edits were needed. #177224 is merged, and unchanged main484cb468ccb7b3c85a35058d287c8b41e1400e24still exhibits this narrower partial-record defect.truewin, absent machine state works, and config-path/state-directory isolation holds. This is admission/Doctor proof, not authenticated Teams delivery or a new physical-listener/upgrade run. Boundary and checks run.git diff --checkpassed. An initial consumer command referenced the later main-onlydoctor-contract-registry.selection.test.ts; it ran no consumer tests. The corrected command above uses this head'sdoctor-contract-registry.test.tsand passed. All contributor execution used no-role, public-network AWS leases without Tailscale or hydration, forwarding only CI plus Crabbox's run identifiers, with an isolated HOME and pinned toolchain.f421a5e3ade01a9d60f3133b0852b1ceb6df948c..b7a52b37878ec9df381510e99be7467c723fecc3change and owner/consumer context completed scoped-clean for P0–P2. Its identified coverage gaps are covered by the additional boundary proof above.b7a52b37878ec9df381510e99be7467c723fecc3on October 22. This is existing exact-head evidence; it does not certify a newly constructed merge against today's main. The PR remains on the reviewed contributor head.Simplification review retained the existing owner and shared merge; the superseded reader has no remaining callers. Production delta: +38/-15; tests: +37/-1. No new store, format, policy, SDK surface, dependency, or config write was introduced. No operator Gateway or state was touched.
Contributor upgrade, Gateway, and regression evidence (source-qualified below)
Upgrade from latest stable
[email protected](npm) to this head (b7a52b37,pnpm build:runtime). macOS, Node 24.22.1, one isolatedHOME/OPENCLAW_HOME/OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH,OPENCLAW_GATEWAY_STARTUP_TRACE=1,OPENCLAW_NO_RESPAWN=1. Each boot isopenclaw gateway run --port 28789 --allow-unconfigured, waits for/readyz, then stops. Starting config is the partial Doctor record from the report above:{ "gateway": { "mode": "local", "auth": { "mode": "none" } }, "meta": { "migrations": { "webhookListeners": { "telegram": [], "feishu": [], "nextcloud-talk": [] } } } }msteamsdecision is ignored and the scan runs again.openclaw doctor --fix --non-interactive(the updater's step) exits 0. It backs up and migrates the existing databases (agent database schema 25 → 31) and writes its usual unrelated config migrations (lastTouchedVersion,modelPolicyAllowlist, and so on).meta.migrations.webhookListenersstays the three-channel Doctor record, 0legacyWebhookkeys, machine-state row unchanged.webhook-readinessstep in either trace; config bytes unchanged; the session created by 2026.10.7 is still listed.channels.msteams.appId/appPassword/tenantId), candidate boot 3. Ready, no scan, config bytes unchanged, 0legacyWebhookpins, nothing listening on 3978.Control: same flow on 2026.10.7 only (separate isolated home, same starting config). Boot 1 records the same
msteams: []row; after adding the same synthetic Teams credentials, the next boot refuses to start and would pin the historical port:Data-model compatibility. No stored format changes. Config keeps
trueor a per-channel record, and machine state keeps the samewebhookListeners:<config path>key and JSON value; only the read side merges them. The proof above reads the exact row 2026.10.7 wrote (step 1) without rewriting it, and the existing session and databases survive the upgrade (steps 3–4).Contributor regression run on
main(adda7fee), macOS, Node 24.22.1. Each new test fails with the two source files reverted tomainand passes with this PR:startup-config-preflight.recovery.test.ts"skips a channel startup completed after Doctor left it pending": a partial Doctor record in config plus startup'smsteams: []in machine state. Onmain:expected "applyPluginDoctorCompatibilityMigrations" to not be called at all, but actually been called 1 times.doctor-contract-registry.webhook-pins.test.ts"keeps a Teams decision startup recorded after Doctor left it pending": adding a Teams account returns{ config, changes: [] }(no pin). Onmainthe migration returns config changes instead.pnpm test src/commands/startup-config-preflight.recovery.test.ts src/commands/startup-config-preflight.availability.test.ts src/plugins/doctor-contract-registry.webhook-pins.test.ts --maxWorkers=2: 45/45 passed, 76 s wall.Real Gateway, documented Teams-pending flow (measured on the previous head against
mainc832c45a, before #177224). Doctor recordedtelegram/feishu/nextcloud-talkand left Teams pending; isolated home; Windows 11. #177224 did not change this path (its gate still takes the config record as-is), and the startup regression test above reproduces boot 2 on currentmain.main(c832c45a){"telegram":[],"feishu":[],"nextcloud-talk":[],"msteams":[]}webhook-readiness 1337.4ms)Gateway failed to start: Webhook listeners require config migration. Run openclaw doctor --fix. Running Doctor would pin port 3978legacyWebhookpinsContributor gates on this head:
oxfmt,oxlint(touched files),tsgo:core: pass. Please rely on CI for the remainingcheck:changedlanes.Out of scope: channels whose doctor contract never loads (for example a replacement plugin without a historical listener declaration) stay undecided and still rescan. Recording them as complete would require the product decision this migration intentionally avoids. #168955 and #162211 (other startup costs) are unrelated.
Original implementation and regression tests by @htjworld.
Co-authored-by: htjworld [email protected]
Co-authored-by: steipete [email protected]