Skip to content

perf(gateway): first message after startup stalls on lazy model-catalog and plugin-registry loads - #118465

Closed
zeroaltitude wants to merge 14 commits into
openclaw:mainfrom
zeroaltitude:perf/dispatch-prewarm-and-tracing
Closed

zeroaltitude wants to merge 14 commits into
openclaw:mainfrom
zeroaltitude:perf/dispatch-prewarm-and-tracing

Conversation

@zeroaltitude

@zeroaltitude zeroaltitude commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The branch was created after a production gateway's first inbound message paid roughly 16 seconds of lazy model-catalog and plugin-registry initialization. The stall was user-visible and the responsible stages were not attributed in logs.

Why This Change Was Made

It combines latency instrumentation with post-ready prewarming:

  • Discord records inbound-to-typing latency at the boundary that owns it.
  • Slow plugin-registry loads identify expensive plugins and their caller.
  • Startup work attempts to prebuild workspace registries and per-agent model catalogs before the first request.

User Impact

The diagnostics make first-turn stalls substantially easier to attribute. However, the prewarm portion no longer matches current-main ownership: current main already publishes the dispatch-equivalent registry, while provider catalogs are intentionally request-owned. The idle prewarm therefore bypasses lifecycle owners and does not meet the current upstream usefulness/safety bar.

Current recommendation: retire this draft rather than merge the prewarm design. If maintainers want the instrumentation independently, extract it into a smaller diagnostic-only change.

Evidence

The motivating Linux gateway recorded inbound-to-typing latency and slow registry work, and its cold before_agent_reply stage fell from roughly 10–16 seconds to about 1.8 seconds after deployment. Focused startup-prewarm coverage passed 7/7 on branch head e42f0d148ce377fee12d6e0eb5e9d91fb678e8b6.

The later portfolio review changed the recommendation: tracing current main showed that equivalent registry publication is already owned elsewhere and that the remaining catalog work should not be initiated from an idle startup task. That makes the observed historical speedup insufficient evidence for merging this implementation today.

🤖 Generated with Claude Code

Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude).

…yping latency

Two changes for the Discord presence-indicator latency investigation:

Ingress pruning moves from pruneIntervalMs: 0 (a legacy-behavior
carryover from the durable-ingress migration) to the standard hourly
cadence. The old setting ran a write transaction with unindexed
updated_at sorts on the shared state DB ahead of EVERY inbound Discord
message — pre-dispatch, pre-typing latency that grew with retained rows
(caps are 5,000 rows per status). Slack already prunes hourly; TTLs and
caps are unchanged.

First typing start per dispatch now logs one INFO line with
sinceMessageMs (Discord message creation → typing call: the
user-perceived gap, network + ingress + preflight included) and
sinceDispatchMs (dispatch → typing). Their difference isolates the
pre-dispatch share — the segment invisible to gateway-internal
prompt_build→first_llm timing, which measured p50 21ms while operators
observed multi-second indicator lag. Replaces the reverted
env-gated [oc-typing-lag] console timers with an always-on recorded
fact that needs no rebuild to consult.

Validation: node scripts/run-vitest.mjs extensions/discord/src/monitor
(988 passed); pnpm tsgo:extensions green; oxlint/oxfmt clean.
Per-agent runtime materialization re-runs the full plugin registry load
synchronously on the main thread; a slow one freezes the whole gateway
(observed: ~30s liveness stalls on each agent's first message, with all
in-flight dispatches' traces flushing together on recovery). The existing
aggregate timing is debug-level and unattributed.

When a registry load exceeds 1s, warn with per-plugin candidate timings
(top 10 >=50ms), discovery timing, cache key, subagent mode, and the
caller stack, so the next stall names its owner.
…r dispatch stage traces

Instrumentation from tonight's stall hunt showed each agent's FIRST
message paying a multi-second synchronous plugin registry load at
dispatch time (per-agent-workspace cache keys; observed 4s for 158
plugins, freezing the event loop and every concurrent dispatch).

- Prewarm every configured agent workspace's runtime plugin registry in
  the post-ready prewarm scheduler, one per event-loop turn, so the
  dispatch path always hits a warm cache key.
- Split the opaque attempt-workspace startup-stage span with sub-marks
  (compaction-runtime, runtime-snapshot, attempt-entry) so remaining
  cold-run cost names its owner.
- Route the discord inbound→typing latency line through the console
  logger: the pino child logger only reached the file log, which is why
  the line went unnoticed in journald all week.
…atter

The prior fix routed the inbound→typing latency line through `info` from
plugin-sdk/runtime-env — which is a ThemeFormatter (string colorizer),
not an emitter, so the line was formatted and discarded. Zero samples
landed anywhere since the pino path was removed in the same change.
Diagnosed by Tank (agent) tracing globals.ts:37. logInfo from
plugin-sdk/logging-core is the always-on console emitter sibling discord
files already use.
Upstream openclaw#116261 bounded prepared-runtime startup work, deferring model
catalog preparation to first use — measured cost on an agent's first
message: ~16s inside loadResolvedPublishedModelCatalogOwner (live
provider discovery with 5s/provider timeouts plus a manifest-model scan)
before the reply pipeline's first traced phase, with no typing indicator.

Warm each agent's catalog owner from the post-ready prewarm scheduler,
after the runtime plugin registries it depends on: boot stays bounded
(off the startup critical path) and first messages hit a warm catalog.
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord gateway Gateway runtime agents Agent runtime and tooling size: S labels Aug 3, 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: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 1, 2026, 6:48 PM ET / 22:48 UTC.

ClawSweeper review

What this changes

The branch adds Gateway/Discord latency diagnostics, changes Discord ingress pruning from per-admission to hourly, and prewarms agent plugin registries and full model catalogs after Gateway readiness.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 11 items remain

Keep this recently updated draft open for correction rather than stale cleanup. Its two post-ready prewarms reintroduce the event-loop and lifecycle hazards that current main deliberately avoids; the remaining diagnostics could be evaluated only after the unsafe work and inaccurate metrics are removed.

Priority: P1
Reviewed head: e42f0d148ce377fee12d6e0eb5e9d91fb678e8b6

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The draft has useful latency-investigation signal, but its central implementation conflicts with current lifecycle ownership and lacks direct current-head behavior proof.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The branch changes Gateway scheduling, catalog ownership, and Discord ingress behavior, but the supplied historical timing claim is not accompanied by a current-head redacted runtime trace; the focused prewarm test mocks both new loaders and only proves call order. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 4 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The branch changes Gateway scheduling, catalog ownership, and Discord ingress behavior, but the supplied historical timing claim is not accompanied by a current-head redacted runtime trace; the focused prewarm test mocks both new loaders and only proves call order. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Introduced full-catalog prewarm: The PR adds one idle task per agent which calls the writable published-catalog resolver. That resolver can materialize the full catalog rather than merely read static facts.
Current lifecycle boundary: Current main publishes configured/static model facts before sidecars and explicitly keeps live provider catalogs out of the Gateway lifecycle; its post-ready prewarm likewise states that provider catalogs remain request-driven.
Synchronous registry work in idle task: The introduced task calls the synchronous runtime-registry loader without a lifecycle generation or reusable registry. The loader invokes the plugin registry loader, whose discovery and candidate registration run synchronously.
Findings 4 actionable findings [P1] Remove full provider-catalog work from the idle queue
[P1] Remove the synchronous registry load from the idle task
[P2] Enforce Discord retention limits between hourly prunes
Security None None.

How this fits together

Gateway startup publishes bounded, lifecycle-owned agent runtime facts before live turns begin. Discord ingress then admits messages and agent dispatch consumes those facts; the proposed idle prewarm instead starts extra registry and catalog work after readiness.

flowchart LR
  A[Gateway startup] --> B[Published static runtime facts]
  B --> C[Agent turn admission]
  D[Discord ingress] --> C
  E[Post-ready idle task] --> F[Registry and catalog work]
  F --> C
  C --> G[Typing feedback]
  G --> H[Operator diagnostics]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The branch changes Gateway scheduling, catalog ownership, and Discord ingress behavior, but the supplied historical timing claim is not accompanied by a current-head redacted runtime trace; the focused prewarm test mocks both new loaders and only proves call order. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Remove full provider-catalog work from the idle queue (P1) - This introduced call uses the writable catalog path, which materializes a full catalog; current main explicitly keeps live provider catalogs out of the Gateway lifecycle. The idle check cannot prevent a request arriving after it from being delayed by this work.
  • Remove the synchronous registry load from the idle task (P1) - This creates a registry without the lifecycle generation that turn admission already consumes. Registry discovery and candidate loading are synchronous, so work begun after the idle check can still freeze the event loop for new requests.
  • Enforce Discord retention limits between hourly prunes (P2) - The 5,000-entry limits now run only during hourly prune work, so a busy hour can exceed both caps. The previous per-admission behavior enforced the bound before each enqueue.
  • Record typing latency only after a successful typing start (P2) - The metric is emitted before onReplyStart() begins its asynchronous typing request, which may fail. A log sample can therefore report typing latency when Discord never accepted typing; emit on successful start or label the measurement as request initiation.
  • Resolve merge risk (P1) - A newly arrived request can be blocked after the idle check by the introduced synchronous registry load or full provider-catalog work, delaying Gateway liveness and first-message feedback.
  • Resolve merge risk (P1) - Discord completed and failed ingress records can grow beyond the declared 5,000-entry limits until the next hourly prune.
  • Resolve merge risk (P1) - The bug-fix branch adds 127 net production lines while its central prewarm design conflicts with the current lifecycle owner.
  • Complete next step (P2) - The branch needs contributor-led redesign and real behavior proof; its remaining diagnostics should not be auto-repaired into a new product direction.
  • Improve patch quality - Remove the two idle runtime prewarms and repair the retention and typing-metric findings.
  • Improve patch quality - If retaining diagnostics, provide a redacted current-head Gateway trace proving the exact diagnostic behavior and no added request stall.

Findings

  • [P1] Remove full provider-catalog work from the idle queue — src/gateway/server-startup-handler-prewarm.ts:102-108
  • [P1] Remove the synchronous registry load from the idle task — src/gateway/server-startup-handler-prewarm.ts:90-96
  • [P2] Enforce Discord retention limits between hourly prunes — extensions/discord/src/monitor/ingress.ts:143-151
Agent review details

Security

None.

PR surface

Source +127, Tests +49. Total +176 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 6 131 4 +127
Tests 1 50 1 +49
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 181 5 +176

Review metrics

Metric Value Why it matters
Production versus test delta production +131/-4 (net +127); tests +50/-1 (net +49) The substantial production growth is not justified while the two central prewarm paths conflict with current lifecycle ownership.

Stored data model

Persistent data-model change detected: persistent cache schema: src/plugins/loader-runtime-load.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Remove the idle runtime prewarms (recommended)
    Delete the full-catalog and synchronous registry tasks, then repair the retention and typing-metric defects before considering any remaining diagnostics.
  2. Retire this draft
    Close the broad experiment and submit only a focused diagnostics proposal if maintainers still want the instrumentation.

Technical review

Best possible solution:

Keep lifecycle-owned static dispatch facts as the only startup preparation; remove the catalog and registry idle tasks, preserve ingress limits at admission, and evaluate any useful diagnostics as a narrow separately proven change.

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

Yes, from source: the introduced idle tasks call full-catalog and synchronous registry loaders after a one-time idle check. The PR does not include a current-head redacted runtime trace that demonstrates the claimed before/after behavior.

Is this the best way to solve the issue?

No. Current main already publishes static dispatch facts through the lifecycle and intentionally leaves live provider catalogs request-owned; moving those loads into an idle Gateway task is the wrong owner boundary.

Full review comments:

  • [P1] Remove full provider-catalog work from the idle queue — src/gateway/server-startup-handler-prewarm.ts:102-108
    This introduced call uses the writable catalog path, which materializes a full catalog; current main explicitly keeps live provider catalogs out of the Gateway lifecycle. The idle check cannot prevent a request arriving after it from being delayed by this work.
    Confidence: 0.99
  • [P1] Remove the synchronous registry load from the idle task — src/gateway/server-startup-handler-prewarm.ts:90-96
    This creates a registry without the lifecycle generation that turn admission already consumes. Registry discovery and candidate loading are synchronous, so work begun after the idle check can still freeze the event loop for new requests.
    Confidence: 0.98
  • [P2] Enforce Discord retention limits between hourly prunes — extensions/discord/src/monitor/ingress.ts:143-151
    The 5,000-entry limits now run only during hourly prune work, so a busy hour can exceed both caps. The previous per-admission behavior enforced the bound before each enqueue.
    Confidence: 0.98
  • [P2] Record typing latency only after a successful typing start — extensions/discord/src/monitor/message-handler.process-reply-runtime.ts:157-162
    The metric is emitted before onReplyStart() begins its asynchronous typing request, which may fail. A log sample can therefore report typing latency when Discord never accepted typing; emit on successful start or label the measurement as request initiation.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 availability: Full catalog discovery and synchronous plugin loading can stall liveness, typing, and newly arriving turns.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The branch changes Gateway scheduling, catalog ownership, and Discord ingress behavior, but the supplied historical timing claim is not accompanied by a current-head redacted runtime trace; the focused prewarm test mocks both new loaders and only proves call order. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The introduced idle tasks can again monopolize the Gateway event loop after readiness and delay live requests.
  • merge-risk: 🚨 availability: Full catalog discovery and synchronous plugin loading can stall liveness, typing, and newly arriving turns.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The branch changes Gateway scheduling, catalog ownership, and Discord ingress behavior, but the supplied historical timing claim is not accompanied by a current-head redacted runtime trace; the focused prewarm test mocks both new loaders and only proves call order. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-15T04:52:28.685Z sha f738ae5 :: needs real behavior proof before merge. :: [P1] Keep synchronous registry loading out of idle work | [P1] Keep full provider catalogs out of the Gateway idle queue | [P2] Preserve ingress caps between hourly prunes | [P2] Log typing only after Discord confirms it
  • reviewed 2026-08-15T05:26:55.920Z sha 59eb6ac :: needs real behavior proof before merge. :: [P1] Remove the non-dispatch registry warm-up | [P1] Keep full catalog builds out of Gateway idle work | [P2] Log typing after Discord accepts it | [P2] Enforce ingress caps between hourly prunes
  • reviewed 2026-08-17T14:55:11.116Z sha ceba117 :: needs real behavior proof before merge. :: [P1] Keep full catalog builds out of Gateway idle work | [P1] Keep synchronous registry loading off the idle task | [P2] Log typing latency only after Discord accepts it | [P2] Enforce ingress caps between hourly pruning
  • reviewed 2026-08-19T19:02:46.279Z sha 2fe4fa0 :: needs real behavior proof before merge. :: [P1] Remove the post-ready synchronous registry load | [P1] Keep full provider catalogs out of Gateway idle work | [P2] Log typing latency only after typing is accepted | [P2] Enforce Discord ingress caps between hourly prunes
  • reviewed 2026-08-23T15:52:46.871Z sha 2fe4fa0 :: needs real behavior proof before merge. :: [P1] Move registry warmup off the Gateway event loop | [P1] Warm the catalog that the first reply actually uses | [P2] Record latency only after Discord accepts typing | [P2] Maintain Discord ingress caps between hourly prunes
  • reviewed 2026-08-23T21:52:54.047Z sha 981b3f8 :: needs real behavior proof before merge. :: [P1] Keep registry warmup off the Gateway event loop | [P1] Warm the catalog the first reply actually reads | [P2] Log typing latency only after Discord accepts typing | [P2] Maintain Discord ingress caps between hourly prunes
  • reviewed 2026-08-24T22:36:17.475Z sha 981b3f8 :: needs real behavior proof before merge. :: [P1] Warm the dispatch-equivalent registry | [P1] Keep full catalog discovery request-owned | [P2] Record typing latency after acceptance | [P2] Preserve ingress caps between pruning passes
  • reviewed 2026-08-27T06:16:38.843Z sha d40676f :: needs real behavior proof before merge. :: [P1] Reuse the prepared dispatch registry | [P1] Invoke the full catalog loader or remove this prewarm | [P2] Log typing only after Discord accepts typing | [P2] Keep ingress caps enforced between pruning passes

The prewarm step imported `ensureRuntimePluginsLoaded` from
`../agents/runtime-plugins.js`. That symbol does not exist — the module's
only export is `loadAgentRuntimePluginRegistryHandle`, whose params type
(`{ config?, workspaceDir?, ... }`) already matches what this call site
passes. `pnpm tsgo:core` fails with TS2339 on the import, so any tree
carrying this commit does not typecheck; it reached `origin/integration`
and broke the build there.

Swapped to the real export. Behavior is the intended one either way:
`loadAgentRuntimePluginRegistryHandle` resolves the same per-workspace
registry cache key dispatch uses, so warming it here still moves the
multi-second cold load off an agent's first message.

Note this branch has a second, pre-existing typecheck failure that this
commit deliberately does not touch: `resolveConfiguredAgentWorkspaceDirs`
is imported from `agent-scope-config.js` but is only defined on
`fix/metadata-snapshot-reuse-and-gates`. The branch therefore cannot
typecheck standalone — it needs that branch merged, or the helper folded
in. Left for whoever owns the split, since fixing it here would duplicate
the definition and conflict on merge.

Validation: with this change, `pnpm tsgo:core` on integration (where the
workspace-dirs helper is present) is clean. oxlint clean on the touched
file.

Co-Authored-By: Claude Opus 5 <[email protected]>
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 3, 2026
…ting negative

First live sample of this metric read `sinceMessageMs=-347`, which says
typing fired 347ms before the message existed. Discord stamps the message
on its own clock and we read ours; the two are not synchronised, so a raw
negative means the real gap was smaller than the local/remote clock drift,
not that anything went backwards.

Left alone this is worse than cosmetic. `sinceMessageMs` is the field that
captures the whole user-perceived gap — network delivery plus ingress plus
preflight — so with ~350ms of drift every future sample silently
under-reports by that much, and a negative one is unusable outright.

Negative values now report `sinceMessageMs=0` with `sinceMessageClamped=true`
and the raw delta preserved as `rawSinceMessageMs`, plus an inline note that
the gap fell within clock drift. Clamping without keeping the raw value would
throw away the drift magnitude, which is the one thing that tells an operator
how much to distrust the unclamped samples. Non-negative values are
unchanged; `sinceDispatchMs` is computed from a single local clock and was
never affected.

Validation: oxlint and oxfmt --check clean on the touched file; git diff
--check clean. `pnpm tsgo:extensions` cannot pass on this branch standalone
for a reason unrelated to this change — `server-startup-handler-prewarm.ts`
imports `resolveConfiguredAgentWorkspaceDirs`, which only exists on
`fix/metadata-snapshot-reuse-and-gates` — so the typecheck was verified on
integration, where that helper is present.

Co-Authored-By: Claude Opus 5 <[email protected]>
…-and-tracing

Resolutions:
- run-loop.ts: main replaced the raw runLoopIterations counter with a retry
  budget, so the first-attempt instrumentation now keys off
  runRetryBudget.attemptsDispatched === 0.
- attempt-dispatch-preparation.ts: union of our attempt-entry stage mark and
  main's effectiveModel plumbing.

Fixed a branch-invariant violation found during the merge: this branch imported
resolveConfiguredAgentWorkspaceDirs from agent-scope-config, but that helper
exists only on a sibling branch, so this branch could not typecheck standalone
against origin/main and was only ever green inside integration. Replaced with a
local helper over listAgentIds + resolveAgentWorkspaceDir, so the branch builds
on its own; the sibling introduces the shared helper and whichever lands first
wins on merge.

Also fixed a mock that never intercepted anything: the prewarm test mocked
'ensureRuntimePluginsLoaded' on ../agents/runtime-plugins.js, which that module
does not export - the real symbol is loadAgentRuntimePluginRegistryHandle, which
the source has called since 653b9c4. The runtime-plugins prewarm assertions
were therefore running against the unmocked module. Corrected, and the
workspace-dir stub moved from the aggregate helper to resolveAgentWorkspaceDir
so it still intercepts after the inlining above.

Validation:
- pnpm tsgo:core -> exit 0, 0 errors
- pnpm vitest run server-startup-handler-prewarm.test.ts -> 7 passed
- oxlint clean; git diff --check clean
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper-recovery-stuck and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 23, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 23, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 1, 2026
@zeroaltitude

Copy link
Copy Markdown
Contributor Author

Closing this draft because current main assigns static preparation to the startup lifecycle, while the branch's idle catalog and synchronous-registry prewarm crosses that ownership boundary and can increase background work without proving a safe freshness contract.

The useful diagnostic portion has been rebuilt independently on instrument-perf/startup-latency-attribution: bounded first-attempt stage timing, bounded slow plugin-load attribution, and Discord inbound-to-typing latency emitted only after Discord accepts the typing request. That instrumentation-only branch is intentionally not proposed upstream. The exact retired head is preserved at archive/2026-09-02/perf-dispatch-prewarm-and-tracing.

Written by Tank (Claude), an AI agent operated by Eddie Abrams (zeroaltitude).

@zeroaltitude
zeroaltitude deleted the perf/dispatch-prewarm-and-tracing branch September 2, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant