Skip to content

perf(ci): reuse compiled session workers and native byte comparisons - #134192

Closed
steipete wants to merge 13 commits into
codex/ci-windows-runtime-20260831from
codex/ci-compiled-session-workers-20260831
Closed

steipete wants to merge 13 commits into
codex/ci-windows-runtime-20260831from
codex/ci-compiled-session-workers-20260831

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #134038

What Problem This Solves

Windows CI repeatedly starts TypeScript loaders while testing transcript archive and reconciliation workers, even when the invocation already owns a compiled runtime generation. Large SQLite snapshot assertions also spend seconds expanding unchanged Buffer bytes into JavaScript entries.

Why This Change Was Made

The two existing workers now use the canonical runtime entry declaration and URL resolver. This removes their duplicate source/package resolvers and package-entry declarations, while retaining stable published worker paths, standalone source execution, original source preload arguments, messages and cleanup ordering. The existing real-worker fixture now verifies that archive execution uses its invocation-owned generation.

Five existing snapshot assertions use Node strict equality over the same complete Buffers and metadata. Native comparison preserves byte-for-byte protection without Vitest’s per-byte traversal. No SQLite schema, stored data, queue, worker count, concurrency, timeout, dependency or configuration changes.

User Impact

Faster developer validation with the same production worker behavior and exact snapshot checks. This PR is stacked on #134038 so its CI includes the already-reviewed startup and routing repairs; it will target main after that prerequisite lands.

Evidence

The existing borrower fixture fails before the runtime repair because the actual Worker URL still ends in source .ts. Integrated validation passes the two actual compiled-borrower/standalone-source cases, 18 archive cases, four reconciliation lifecycle cases, 23 state-ownership cases and 23 package-entry guards. These retain archive byte fidelity, publication ordering, stale-state rejection, failure preservation and database-lease release before terminal messages.

A controlled local replay preserves all 25 archive and two reconciliation Workers: archive test-body time falls from 17.01 to 4.95 seconds, with median archive-worker lifetime falling from 580.2 to 109.9 milliseconds. The existing ownership case falls from 1.727 seconds to 164 milliseconds; an eight-scenario parity probe rejects the same byte, length, metadata and file-set changes. These are local macOS measurements, not native Windows after timings. The Windows long-path test retains its platform guard and still requires native CI.

A full canonical package build passes in 3m30.9s and creates both previously absent stable worker outputs; both emitted files pass Node syntax checking. Parent integration passes all 70 focused cases. The complete changed-file gate passes, including all selected type programs and full lint. Scoped Codex review reports no actionable finding at the configured blocking threshold. Exact-head CI is required before landing. Whole CI below five minutes remains an open goal.

The previous CI failed an unrelated report-fixture cleanup race: a child could exit between a liveness probe and a raw SIGKILL, causing ESRCH in finally. The three affected cleanup sites now use the existing killPidIfAlive owner, which accepts only that already-gone result and still throws other errors. A deterministic real-process interleaving reproduces the old race; all 43 report/helper cases pass after repair with the same assertions, signal sequence and deadlines. Both original commits remain byte-identical after restacking onto the parent's Gateway validation fixes. Full changed-file gates and fresh Codex review pass.

Runtime/build code is net -23 lines, tests/support net +10 after the cleanup simplification, and documentation net +1. No retry, timeout increase or process-lifecycle assertion was added or weakened.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:20 PM ET / 16:20 UTC.

ClawSweeper review

What this changes

The PR registers two session transcript workers in the shared compiled-runtime entry set, streamlines SQLite byte assertions, and makes test cleanup tolerate an already-exited child process.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No introduced correctness or security defect was found. This maintainer-authored, still-useful refactor should remain open for exact-head CI and maintainer acceptance.

Priority: P3
Reviewed head: 9e29e3957d9b2f86ccba229369f766c4d18a819f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with direct source/package coverage and no concrete review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored internal CI/runtime refactor is exempt from the external-contributor proof gate; the focused worker and package evidence is supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored internal CI/runtime refactor is exempt from the external-contributor proof gate; the focused worker and package evidence is supplemental.
Evidence reviewed 5 items Shared resolution and packaged output: The introduced registry entries use the two stable package paths, and the shared build-entry map derives their source files from that registry; this replaces duplicated caller-local resolution without changing loader arguments.
Resolver and package checks: The resolver selects a relative source worker outside dist and the declared package path inside dist. The archive fixture observes the real Worker URL in both modes, and release checks require both package worker files.
Snapshot and cleanup semantics: The assertions retain complete Buffer and file-family comparisons. The reused cleanup helper suppresses only ESRCH after the liveness probe and rethrows other kill failures; its focused tests cover both outcomes.
Findings None None.
Security None None.

How this fits together

Session archive and reconciliation run in Node worker threads from source checkouts and packaged builds. The shared runtime-entry registry selects the matching worker URL so CI fixtures can reuse compiled outputs while production retains stable packaged paths.

flowchart LR
  A[Session archive or reconciliation] --> B[Worker launcher]
  B --> C[Shared runtime entry registry]
  C --> D[Worker URL resolver]
  D --> E[Source or compiled worker]
  E --> F[SQLite transcript result]
Loading

Decision needed

Question Recommendation
After exact-head CI completes, should this maintainer-authored CI performance refactor be accepted on its stated source and package-worker coverage? Accept after green CI: Merge once the exact head’s required checks are green and the stack’s target is resolved.

Why: The PR is associated with a repository member and carries the maintainer label, so automated cleanup must leave final acceptance to a maintainer.

Before merge

  • Complete next step (P2) - No mechanical repair is indicated; final acceptance awaits normal exact-head CI and maintainer review for this member-authored branch.
Agent review details

Security

None.

PR surface

Source -19, Tests +10, Docs +1, Other -4. Total -12 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 3 16 35 -19
Tests 4 24 14 +10
Docs 1 6 5 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 4 -4
Total 9 46 58 -12

Review metrics

Metric Value Why it matters
Production versus test delta production −23, tests/support +10, docs +1 The refactor removes duplicated production resolver and build-entry declarations while adding focused observation coverage.

Technical review

Best possible solution:

Land the single shared worker-entry declaration after the exact PR head receives normal green CI, retaining the existing source and packaged resolution contract.

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

Not applicable: the PR optimizes CI and test execution rather than reporting an end-user defect; the changed source/package resolution paths are directly traceable.

Is this the best way to solve the issue?

Yes: consolidating the duplicate resolvers into the existing shared runtime-entry registry keeps build and launch paths aligned without a parallel mechanism.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded developer-validation performance and cleanup change with no reported user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored internal CI/runtime refactor is exempt from the external-contributor proof gate; the focused worker and package evidence is supplemental.

Evidence

What I checked:

  • Shared resolution and packaged output: The introduced registry entries use the two stable package paths, and the shared build-entry map derives their source files from that registry; this replaces duplicated caller-local resolution without changing loader arguments. (src/infra/runtime-process-entrypoints.ts:15, d17b12f3ace2)
  • Resolver and package checks: The resolver selects a relative source worker outside dist and the declared package path inside dist. The archive fixture observes the real Worker URL in both modes, and release checks require both package worker files. (src/infra/runtime-worker-url.ts:11, 9e29e3957d9b)
  • Snapshot and cleanup semantics: The assertions retain complete Buffer and file-family comparisons. The reused cleanup helper suppresses only ESRCH after the liveness probe and rethrows other kill failures; its focused tests cover both outcomes. (src/test-utils/process-tree.ts:63, 9e29e3957d9b)
  • Current-main necessity: The fetched main revision still has the local worker resolvers and lacks these registry entries, so the central performance change is not already implemented or superseded. (src/config/sessions/session-accessor.sqlite-archive.ts:286, 9e29e3957d9b)
  • Recent area history: Recent history associates Peter Steinberger with the shared worker and session paths. The partial checkout could not provide raw-parent verification for older history, so this is routing evidence rather than an introduction claim. (src/infra/runtime-worker-url.ts:11, d17b12f3ace2)

Likely related people:

  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-08-31T14:42:24.390Z sha d94db62 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/ci-windows-runtime-20260831 branch from 8cc1e0f to d088cbd Compare August 31, 2026 15:08
@steipete
steipete force-pushed the codex/ci-compiled-session-workers-20260831 branch from d94db62 to 9e29e39 Compare August 31, 2026 16:12
@steipete
steipete force-pushed the codex/ci-windows-runtime-20260831 branch 2 times, most recently from 767c47e to acbf9f0 Compare August 31, 2026 17:36
@steipete
steipete deleted the branch codex/ci-windows-runtime-20260831 August 31, 2026 20:32
@steipete steipete closed this Aug 31, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Implemented through #134038, merged as 4ee565c6d2a, including compiled session-worker reuse and native byte comparison. The integration preserves the connected main changes and removes the superseded duplicate paths.

Exact-head CI33434384581 completed successfully with all applicable Testboxes green. Both Windows jobs, all 16 UI jobs and the macOS Node job passed. The integration PR records the focused source-owner and regression proof, including the Windows readiness repair and trusted-wrapper merge checks. This source PR is superseded by that verified landing.

@RomneyDa
RomneyDa deleted the codex/ci-compiled-session-workers-20260831 branch October 22, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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