Skip to content

fix(gateway): flush startup diagnostics before readiness - #192383

Merged
RomneyDa merged 4 commits into
mainfrom
fix/forward-port-1010-gateway
Nov 5, 2026
Merged

RomneyDa merged 4 commits into
mainfrom
fix/forward-port-1010-gateway

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Problem

Startup performance collectors can miss terminal timeline events when readiness becomes green before buffered evidence is flushed.

Solution

Flush diagnostics at request-runtime readiness and post-attach completion.

Independent split of #191830, directly against main; no sibling PR is required. Original release provenance is preserved in commit bodies. Scope excludes every other forward-port group.

Evidence

  • Original combined-branch evidence: minimal boot 4 tests passed. Timing-fix limitation retained: main readiness does not wait for post-attach, so the release discriminating test is not portable as-is.
  • Production changes cherry-picked cleanly; original evidence is retained evidence, not a new split-head run. The review-driven test repair snapshots the timeline synchronously after readiness to avoid adding another event-loop gap.
  • Local ClawSweeper review against main 34007820fa2c completed. Its async-read finding was addressed by using the already-imported readFileSync for the readiness snapshot; no test-side flush is added.
  • Fresh formatting, targeted oxlint --type-aware, and diff checks passed. Fresh node scripts/run-vitest.mjs src/gateway/server-startup-minimal-boot.test.ts --maxWorkers=1: 4/4 passed on the repaired head. Initial attempts failed dependency setup; matching package-local links resolved the setup failure.
  • Full declaration/type preparation is unavailable with this worktree’s shared dependency install; no bypass used. The selected main base has a 47-line inherited test-ratchet deficit; this split offsets its own 31 lines exactly.
  • Broad type/build/CI coverage is delegated to PR CI.

Reviewed candidate: 1ec9d31f55e4.

Split CI status

  • Test-line ratchet retains the pre-split 47-line deficit: baseline total 6,444,916 versus ceiling 6,444,869. This split’s dedicated allocation covers its exact positive test-line delta; inflating it would violate the allocation checker.
  • Ready for review does not mean green CI or ready to merge. Broad CI has completed with failures; no merge requested.

Additional broad Gateway CI failures: the Goal authority test still expects active (the independent correction is #192387), and the Template Add authority test rejects its downloaded package manifest. The Template Add failure is inherited fixture/schema drift, not caused by this startup split: src/gateway/server-templates-add-authority.e2e.test.ts:92 declares openclaw.template: "template.json", while src/templates/reader.ts:105 requires a package-relative CLAW.md. Executing the real readTemplateManifestFile owner with that fixture returns invalid_package_metadata; readVerifiedArtifactSource converts this into the exact CI error, Downloaded Template package manifest is invalid. The fixture, reader, and artifact-error owner are byte-identical between base 34007820fa2c and candidate 1ec9d31f55e4 (verified Git blob identities). No unrelated fixture repair is included. A fresh full Gateway replay was attempted but stopped before Vitest because declaration preparation rejects this worktree’s shared dependency install (Declaration input escapes checkout); no passing full replay is claimed. Focused startup verification remains 4/4.

Exact-head CI attribution audit

Audited 2026-11-04 at 1ec9d31f55e42638c3ef59a28572af67a4de37e0. Failed job logs were inspected individually, not inferred from their names.

The MCP failures are inherited from base 34007820fa2c: src/agents/mcp-metadata.ts, agent-bundle-mcp-materialize.ts, and agent-bundle-mcp-types.ts have identical Git blob IDs at base and PR head. The missing McpCatalogTool export and consequent optional-property errors propagate through SDK declarations into boundary/build/lint/type lanes.

The test-line ratchet is also inherited: this PR offsets its exact positive test-line delta, and its job still exceeds the adjusted ceiling by the same 47 lines already present at base (6,444,916 vs 6,444,869). No baseline increase or unrelated repair is included.

The changed-test shard also hits two inherited fixtures: the Goal cancellation expectation still says active instead of paused (independent correction #192387), and Template Add names template.json although the reader requires CLAW.md. The Template fixture, reader, and artifact-error owner are byte-identical to base; direct owner execution reproduces invalid_package_metadata, mapped to the exact CI error. Full Gateway replay was blocked during declaration preparation; no full passing replay is claimed.

Failed check Attribution
checks-fast-baseline-ratchets Inherited 47-line test-budget deficit
checks-node-changed-2 Inherited Goal expectation and Template manifest fixture failures (above)
check-additional-extension-package-boundary Inherited MCP declaration/type failure
check-prod-types Inherited MCP declaration/type failure
check-test-types Inherited MCP declaration/type failure
check-test-types-core-1 Inherited MCP declaration/type failure
check-test-types-core-2 Inherited MCP declaration/type failure
check-test-types-core-3 Inherited MCP declaration/type failure
check-test-types-core-4 Inherited MCP declaration/type failure
check-test-types-core-5 Inherited MCP declaration/type failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure

Cancelled dispatch jobs are orchestration cancellations, not passing tests or additional source defects. CI remains red; this section explains the failures rather than claiming green.

Rebase onto current main

Rebased onto a1f99240c8367a0e012b401bed71831a3cc65026, including merged Goal-test correction #192387. New candidate: 02fc9fbcf4faace8ae1f7b00b813f779f30a2f57. This PR still targets main independently.

Verified the complete rebased tree equals the previous PR patch integrated with that main snapshot. No new behavior was added during rebase. Prior test and CI attribution sections remain evidence for their named old revisions; fresh CI on this head is pending, not claimed green.

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Nov 3, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review November 3, 2026 23:38
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR flushes buffered startup diagnostics before dispatch readiness and after post-attach completion.

Example: A startup collector reads the diagnostics timeline immediately after /readyz returns HTTP 200.

  • Before: Completed startup spans can remain buffered until the scheduled flush.
  • After: Request-runtime spans are flushed before dispatch readiness, and non-deferred post-attach completion is flushed before sidecar readiness.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with useful boot-harness coverage, but no demonstrated failing negative control or shipped-entry-point proof.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate. Its body reports 4/4 focused boot tests on the reviewed head, exercising a real HTTP readiness probe in process. The four prepared images were inspected and show unrelated chat Details UI behavior; they provide no startup evidence. The previous review's requested negative-control demonstration remains unverified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Startup collectors can observe a ready Gateway while terminal startup diagnostics remain buffered.
Reason: This maintainer-authored direction repairs diagnostic visibility using existing owners and preserves the earlier readiness-ordering contract.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it supplies a useful diagnostics-visibility repair missing from current main, with no actionable correctness or security findings; required CI remains unresolved.

Priority: P2
Reviewed head: 1ec9d31f55e42638c3ef59a28572af67a4de37e0

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The retained evidence does not show the readiness observation failing without the production flushes and passing with them, or a shipped Gateway collector observing both affected boundaries.
Agent review details

How this fits together

Gateway startup prepares request handling and sidecars, emits diagnostic spans through a buffered process-wide writer, and publishes readiness consumed by health probes and startup collectors.

flowchart LR
  A[Gateway startup] --> B[Request runtime preparation]
  B --> C[Flush diagnostics writer]
  C --> D[Dispatch readiness]
  D --> E[Post attach completion]
  E --> F[Flush diagnostics writer]
  F --> G[Non deferred sidecar readiness]
Loading

Technical review

Best possible solution:

Retain the two existing-writer flushes at the startup publication boundaries without adding another lifecycle or buffering owner.

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

Source establishes that readiness can publish while previously emitted events await the scheduled writer flush; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing synchronous flush owner at the two relevant startup boundaries, preserves deferred readiness semantics, and adds no competing state or abstraction.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 44eaed3d95d7.

Provenance checked

  • Request-runtime readiness keeps the original intent (8f84b21: Overlap independent startup preparation while retaining complete request-runtime readiness, database activation ordering, and joined failure cleanup.)
  • Post-attach readiness keeps the original intent (f8fe586: Publish non-deferred readiness only after the post-attach span closes while preserving deferred behavior.)
  • Timeline test observation keeps the original intent (211989e: Read timeline records synchronously to avoid incomplete JSON while background diagnostics append.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +8, Tests +31, Other +2. Total +41 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 8 0 +8
Tests 1 32 1 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 42 1 +41

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Incomplete startup diagnostics affect performance collection and qualification with limited impact on normal Gateway operation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Demonstrate that the readiness observation fails without the production flushes and passes with them.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-04T00:11:46.836Z sha 1ec9d31 :: needs maintainer review before merge. :: none

Reviewed November 4, 2026, 5:10 PM ET / 22:10 UTC (Revision 2).

@RomneyDa

RomneyDa commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
Readiness is the performance collector's evidence boundary. Flush the batched
timeline events for request-runtime spans before dispatch readiness can make
/readyz green.

Forward-port of f617488 from release/2026.10.10.
The post-attach span ends inside startupTrace.measure(), but its timeline
event is batched. Flush it before sidecar readiness can make /readyz green.

The release regression test is not ported: main's minimal test Gateway starts
with sidecars ready (release-only 591153e gates /readyz on post-attach),
so its readiness can precede the post-attach span there.

Forward-port of 166d761 from release/2026.10.10.
@RomneyDa
RomneyDa force-pushed the fix/forward-port-1010-gateway branch from 1ec9d31 to 02fc9fb Compare November 5, 2026 01:49
@RomneyDa
RomneyDa merged commit cab71dc into main Nov 5, 2026
119 of 124 checks passed
@RomneyDa
RomneyDa deleted the fix/forward-port-1010-gateway branch November 5, 2026 03:03
RomneyDa added a commit that referenced this pull request Nov 5, 2026
Carry the final reviewed changes from #191830, #192378, #192379,
#192380, #192383, #192385, and #192386. Preserve #191838's existing
file-transfer import fix. Adapt Gateway readiness to the release owner
and include the narrow SQLite cold-admission prerequisite from #192586.

Do not carry #192387: its Goal expectation depends on main-only
Stop-to-paused behavior absent from this release.

Retain regression allocations without changing the shared baseline.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…2383)

* fix(gateway): flush startup evidence before readiness

Readiness is the performance collector's evidence boundary. Flush the batched
timeline events for request-runtime spans before dispatch readiness can make
/readyz green.

Forward-port of f617488 from release/2026.10.10.

* fix(gateway): flush startup timeline before readiness

The post-attach span ends inside startupTrace.measure(), but its timeline
event is batched. Flush it before sidecar readiness can make /readyz green.

The release regression test is not ported: main's minimal test Gateway starts
with sidecars ready (release-only 591153e gates /readyz on post-attach),
so its readiness can precede the post-attach span there.

Forward-port of 166d761 from release/2026.10.10.

* test(ci): scope startup forward-port regression allocation

* test(gateway): snapshot startup evidence without another async gap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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