Skip to content

test(daemon): stabilize singleton fixture readiness and timing - #348

Merged
steipete merged 1 commit into
mainfrom
triage/20260905-relay-fixture-budget
Sep 5, 2026
Merged

test(daemon): stabilize singleton fixture readiness and timing#348
steipete merged 1 commit into
mainfrom
triage/20260905-relay-fixture-budget

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

The singleton daemon fixtures have two readiness/timing races: the Chrome-relay case can exceed the global ten-second timeout on Windows, and the migration fixture can observe a metadata file before the child finishes writing its JSON.

Use the existing platform-scaled test budget for the relay file and wait for the migration child's bounded IPC readiness message after its metadata write. Production behavior and timeouts are unchanged.

Validation: pnpm check; full pnpm test (217 files, 1,861 tests passed); focused real relay fixture cases; built CLI list/call against a synthetic loopback MCP server. Independent local autoreview through P2 is clean. The original Windows failure is https://github.com/openclaw/mcporter/actions/runs/33986588630; the migration race was reproduced locally as an empty JSON read.

@clawsweeper

clawsweeper Bot commented Sep 5, 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.

process.on('message',stop);
const server=net.createServer(s=>s.on('data',chunk=>{const r=JSON.parse(chunk);s.end(JSON.stringify({id:r.id,ok:true,result:r.method==='status'?{pid:process.pid,socketPath:${JSON.stringify(socket)},protocolVersion:1,servers:[]}:true}));if(r.method==='stop')setTimeout(stop,250);}));
server.listen(${JSON.stringify(socket)},()=>fs.writeFileSync(${JSON.stringify(metadata)},JSON.stringify({pid:process.pid,socketPath:${JSON.stringify(socket)}}),{mode:384}));`,
server.listen(${JSON.stringify(socket)},()=>{fs.writeFileSync(${JSON.stringify(metadata)},JSON.stringify({pid:process.pid,socketPath:${JSON.stringify(socket)}}),{mode:384});process.send('ready');});`,
process.on('message',stop);
const server=net.createServer(s=>s.on('data',chunk=>{const r=JSON.parse(chunk);s.end(JSON.stringify({id:r.id,ok:true,result:r.method==='status'?{pid:process.pid,socketPath:${JSON.stringify(socket)},protocolVersion:1,servers:[]}:true}));if(r.method==='stop')setTimeout(stop,250);}));
server.listen(${JSON.stringify(socket)},()=>fs.writeFileSync(${JSON.stringify(metadata)},JSON.stringify({pid:process.pid,socketPath:${JSON.stringify(socket)}}),{mode:384}));`,
server.listen(${JSON.stringify(socket)},()=>{fs.writeFileSync(${JSON.stringify(metadata)},JSON.stringify({pid:process.pid,socketPath:${JSON.stringify(socket)}}),{mode:384});process.send('ready');});`,
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 3:47 PM ET / 19:47 UTC.

ClawSweeper review

What this changes

The PR scales relay test timeouts on Windows and waits for an explicit child-process readiness message before inspecting migration metadata.

Merge readiness

Ready for maintainer review

The PR remains useful: current main and v0.13.9 retain both fixture weaknesses. The focused test changes introduce no blocking defect, and collaborator-authored work is protected from automatic closure.

Priority: P3
Reviewed head: 0d69238fea1c97423ba7aa6e928e4ef6c9e989a3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, maintainable test repair with reported full-suite validation and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The collaborator-authored PR changes fixture scheduling only, so the external-contributor proof gate does not apply; reported suite and loopback runs provide supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The collaborator-authored PR changes fixture scheduling only, so the external-contributor proof gate does not apply; reported suite and loopback runs provide supplemental validation.
Evidence reviewed 7 items Repository policy: Read the complete root AGENTS.md and VISION.md. Only the root AGENTS.md applies; no tracked nested policy or maintainer-note directory was found. The patch follows the preference for focused, verifiable fixes.
Introduced scope: The verified base-to-head change contains two test files, with 10 insertions and 5 deletions; production code, dependencies, and workflows are unchanged.
Readiness ordering: The child sends ready after synchronous metadata writing completes. The parent installs its bounded IPC listener immediately after spawn, before yielding, and retains the existing migration and retirement assertions. Previously, file existence alone allowed the JSON read to race the child write.
Findings None None.
Security None None.

How this fits together

MCPorter's daemon shares retained MCP server connections across clients. These integration fixtures exercise authenticated Chrome relay reuse and safe retirement of older daemon processes.

flowchart TD
  A[Test runner] --> B[Platform timing budget]
  B --> C[Chrome relay fixture]
  A --> D[Legacy daemon child]
  D --> E[Write metadata and signal ready]
  E --> F[Migration assertions]
  C --> G[Connection reuse assertions]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

None.

Technical review

Best possible solution:

Keep readiness tied to completed fixture initialization and use the existing platform budget for process-heavy test deadlines.

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

Yes, source establishes the metadata race: main polls file existence before reading JSON while a separate process writes it. The Windows timeout failure is reported in the PR; neither failure was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Explicit readiness removes the initialization race, and the existing platform helper supplies narrowly scoped timeout headroom without weakening daemon assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9957bd1e233c.

Labels

Label changes:

  • add P3: This is a focused test reliability improvement with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a focused test reliability improvement with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md and VISION.md. Only the root AGENTS.md applies; no tracked nested policy or maintainer-note directory was found. The patch follows the preference for focused, verifiable fixes. (AGENTS.md:1, 0d69238fea1c)
  • Introduced scope: The verified base-to-head change contains two test files, with 10 insertions and 5 deletions; production code, dependencies, and workflows are unchanged. (0d69238fea1c)
  • Readiness ordering: The child sends ready after synchronous metadata writing completes. The parent installs its bounded IPC listener immediately after spawn, before yielding, and retains the existing migration and retirement assertions. Previously, file existence alone allowed the JSON read to race the child write. (tests/singleton-migration.test.ts:31, 0d69238fea1c)
  • Existing platform budget contract: The shared helper multiplies hang-detection budgets by three on Windows. Applying it to the relay file changes its test timeout from 10 to 30 seconds on Windows while leaving other platforms and behavioral assertions unchanged. (tests/helpers/timing.ts:11, 0d69238fea1c)
  • Main and release necessity: Inspected both files on pinned main; they retain the unscaled relay timeout and metadata-existence polling. The v0.13.9 tree has the same pre-patch blobs, so that release does not contain these fixes. (64d613c1e96f)
  • Area history and routing: Main-branch history associates Peter Steinberger with the singleton fixtures and daemon implementation at 95edea1, and the shared timing helper at b1640df. An older follow-history traversal failed because a historical object was unavailable and the remote hostname could not resolve; available current-source and commit inspection remained sufficient for this review. (tests/singleton-migration.test.ts, 95edea12d715)

Likely related people:

  • 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.

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer validation on 0d69238fea1c97423ba7aa6e928e4ef6c9e989a3: pnpm check and the full pnpm test passed (217 files, 1,861 tests; 26 skipped). Focused real authenticated Chrome-relay fixture runs passed both conflict orders (4.32 s and 3.19 s on macOS), including one retained MCP child and execution of a generated CLI. The built CLI also passed list and call against a synthetic loopback HTTP MCP server. Independent local and committed-branch autoreview through P2 are clean.

The local suite reproduced a migration-fixture empty JSON read before this repair; readiness now comes from IPC sent after the metadata write, rather than file existence. The relay test uses the existing Windows timeout scale without changing production limits.

CI: https://github.com/openclaw/mcporter/actions/runs/33988089802. The first attempt passed the repaired fixtures but hit an unrelated Windows process-ownership observation failure in process-retirement.integration.test.ts; the failed job was rerun once. The rerun completed successfully: all Linux, macOS, and Windows jobs are green on this exact head.

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed CodeQL alerts 22 and 23 on the edited fixture line. They flag the existing JSON.stringify(metadata) and JSON.stringify(socket) expressions, which serialize synthetic filesystem paths as JavaScript string literals in a Node-only test script. Node 24 accepts the resulting JSON literals, including escaped quotes, backslashes, and Unicode separators; this is not HTML/script-tag construction. The paths are generated by the fixture, and this PR only adds the post-write IPC readiness signal. I found no actionable injection path and made no change to production security checks or alert-dismissal state.

@steipete
steipete merged commit 57dff27 into main Sep 5, 2026
10 of 11 checks passed
@steipete
steipete deleted the triage/20260905-relay-fixture-budget branch September 5, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants