Skip to content

test(runner): resolve native fixture source dependencies - #170263

Merged
steipete merged 5 commits into
mainfrom
dbasync/redmain-native-runner-publication
Oct 12, 2026
Merged

steipete merged 5 commits into
mainfrom
dbasync/redmain-native-runner-publication

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two generated fixtures in test/non-isolated-runner.test.ts fail before completing their intended lifecycle proof. After #170162 (17c9b482ee5d), the native cron module gained runtime dependencies that Node could not resolve from TypeScript source. Fixing relative imports exposed a workspace alias, then a parameter property in the existing retry package that Node's strip-only mode cannot load. Separately, #169880 (04d4e9cd3fbf) removed the synchronous provenance initializer still called by both generated Gateway lifetime tests.

Why This Change Was Made

Prime the real cron module through the fixture's native CommonJS entry point with a temporary synchronous resolution hook for relative source imports and exact aliases from tsconfig.json. Always deregister the hook in finally, and enable Node's native TypeScript transformation only in this generated child project's execArgv. Vite still imports the same native generation. Migrate both Gateway fixtures to await the existing prepareClawInstallSchemaVersions(options) owner and publish its result. Carry the Gateway project's plugins into the child and give its newly asynchronous worker calls the same managed compiled-worker setup and joined disposal used by the cleanup child. Run this generated host fixture in a fork: shared-state admission requires a process main thread, as the existing live and agents-support test configurations already document. Keep the Gateway isolation and custom cleanup runner.

User Impact

The combined change touches three test files (+59/−17). It preserves native cache identity, reset behavior, partial-mock metadata, readiness and close notifications, afterAll ordering, awaited resource drains, retired-generation isolation, and every lifecycle assertion and aggregate count. The pool metadata assertion now expects forks. Readiness failures include the captured provenance error before the intentional close replaces that snapshot. Production code, timeouts, and test counts are unchanged.

Evidence

At final head b59341be18c2, CI run 38314652902 passes both tests in test/non-isolated-runner.test.ts: shared runner cleanup in 60.697 seconds and Gateway worker lifetimes in 38.036 seconds. Vitest duration is 100.66 seconds; the CI test step takes 104 seconds and its job takes 172 seconds including setup. This is exact-head runtime proof for the complete patch; the earlier failed runs below only establish the causes. The focused reproduction command is pnpm test test/non-isolated-runner.test.ts --maxWorkers=1; no separate local runtime run is claimed.

The two earlier resolver changes each passed targeted formatting/lint, diff checks, normal commit hooks, and an independent Codex P0–P2 review. The fixture follow-ups passed targeted lint, formatting, diff checks, and normal hooks; the transform/provenance follow-up also received a separate maintainer diff inspection. The two completed review rounds are retained without a third round.

CI run 38302535736 showed the original relative-import failure; 38306200884 reached the workspace-alias failure. At the prior PR head 2fe45983c46b, run 38310484484 passed the selected type, lint, baseline, source-contract, and architecture checks, but both parent tests failed: cleanup encountered the unsupported retry parameter property, and Gateway lifetime encountered the removed initializer. The cleanup report expected six failed modules/suite errors from intentional fixtures and observed ten/nine because of the unexpected import failures. Those intentional MCP, watcher, and cancellation failures are not product regressions.

At head 3703bbbc703d, run 38312339272 passed cleanup in 63.515 seconds, confirming the native import and transformation fixes. Gateway lifetime still failed with A:state-error and B:state-error. That log did not emit the underlying exception, and no retained fixture artifact was uploaded. The following patch restored omitted Gateway plugins and managed compiled-worker ownership and added error diagnostics.

At head aefd7bcd3712, run 38313572251 again passed cleanup and exposed the exact Gateway error: Shared-state admission requires the host broker. The native isMainThread guard in openSharedStateSqliteWorkerStore rejects the inherited thread pool before broker admission. The final fixture-only change selects forks and updates the pool metadata expectation; it does not mock or weaken that owner boundary.

All selected static leaf checks pass at the final head: changed-test, source-contract, boundary, lint, production-type, all five core test-type stripes, root test-type, and baseline-ratchet checks. The architecture job executes both cycle checks with zero cycles and passes Kysely guardrails.

The PR does not select Knip. Scoped Knip evidence comes from the actual V28 scan at 0c4b38b77adf: its only findings were three unrelated Team-scale fixture exports, fixed on main by 36e78f215f1f. Comparing the three fixture files and their configs shows no new static module edges, exports, dependencies, or test entry selection after that scan. The generated provenance import switches symbols within the same owner module; runtime changes are proven by this PR's passing tests. The only Knip-config difference is the unrelated PostgreSQL generator entry already landed as e2f58e771393. This qualifies the fixture scope; it does not claim that the full V28 Knip scan passed.

The diff is test-only: no SQL statements, requests, T1 calls, SDK APIs, schema, updater, or service lifecycle behavior changes are claimed. Build and published-driver jobs are skipped by PR selection. The final exact-head CI run is green, including openclaw/ci-gate: 28 jobs succeeded and 28 were skipped by selection.

Prime the real cron source with a temporary native resolution hook before the Vite external import. Preserve native cache identity, reset behavior, partial mock metadata, and all aggregate assertions after the cron module gained runtime dependencies. The hook applies only during synchronous fixture loading and always deregisters.

Focused formatting and lint plus independent Codex review pass. Runtime regression remains pending with the qualification owner.
@clawsweeper

clawsweeper Bot commented Oct 12, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR fixes native source resolution and asynchronous database preparation in generated test-runner fixtures.

Example: The generated Gateway producer fixture prepares Claw schema-version facts.

  • Before: It calls the removed initializeCachedClawInstallSchemaVersions function and fails before verifying readiness.
  • After: It awaits prepareClawInstallSchemaVersions, publishes the result, and retains the A:ready and subsequent cleanup assertions.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch preserves the existing contracts and has successful reviewed-head CI execution; inspected evidence remains limited to harness source and CI step metadata.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-only repair is outside the ordinary contributor proof gate; reviewed-head CI confirms successful shard execution, but its detailed logs were inaccessible from the review sandbox.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers cannot complete the runner lifecycle regressions because generated fixtures fail during loading or preparation.
Reason: Restoring existing behavioral coverage has clear value, and the maintainer-authored direction stays within test infrastructure.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs broken lifecycle fixtures while preserving their assertions, and the reviewed diff contains no actionable correctness or security finding.

Priority: P2
Reviewed head: b59341be18c25719cb361fde401de6997c65d560

Before merge

None.

Findings

None.

Agent review details

How this fits together

The runner regression suite generates child Vitest projects that load repository modules and report native module identity, cross-file cleanup, database closure, and listener retirement.

flowchart TD
  A[Runner regression suite] --> B[Generated child projects]
  B --> C[Native cron source loader]
  B --> D[Gateway lifecycle fixtures]
  C --> E[Native identity assertions]
  D --> F[Managed SQLite workers]
  F --> G[Readiness and cleanup assertions]
Loading

Technical review

Best possible solution:

Land the focused fixture repair through the existing CI and landing workflow while retaining every lifecycle assertion.

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

Source inspection confirms the obsolete initializer call and native dependency-resolution mismatch; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch adapts the fixtures to existing source-loading and worker owners, preserves native identity checks, and fixes the previously reported transformation and preparation defects without weakening production boundaries.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native test API fixture loading keeps the original intent (fbfc46e: Preserve native publishers while retiring freshly inlined test API publications after their complete lifecycle.)
  • Repeated partial-mock native import keeps the original intent (c29f34d: Exercise replacement of native fetch metadata by a manual-mock placeholder while retaining the independent native execution record.)
  • Gateway lifetime child keeps the original intent (540450d: Prove database closure and awaited resource drains precede the next isolated file without notifying retired provenance listeners.)
  • Synchronous provenance initialization keeps the original intent (04d4e9c: Move startup database work into existing worker-backed preparation and publish prepared facts before consumers proceed.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 540450d adds test/non-isolated-runner.gateway-lifecycle-fixtures.ts:30 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 540450d8fd1f; files: test/non-isolated-runner.gateway-lifecycle-fixtures.ts)

PR surface

Tests +42. Total +42 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 59 17 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 59 17 +42

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Broken runner fixtures impair developer validation without establishing a production outage or user-data impact.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 (3 earlier review cycles)
  • reviewed 2026-10-12T21:33:43.770Z sha 2fe4598 :: needs changes before merge. :: [P2] Handle non-erasable TypeScript during native fixture loading
  • reviewed 2026-10-12T21:50:50.767Z sha 3703bbb :: needs changes before merge. :: [P2] Make async preparation succeed in both Gateway lifetime fixtures
  • reviewed 2026-10-12T22:14:31.223Z sha b59341b :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 6:21 PM ET / 22:21 UTC (Revision 4).

Enable native TypeScript transformation only in the generated runner child so source aliases can load retry parameter properties without changing module identity. Migrate both generated Gateway lifetime probes to the existing async provenance preparation API after the synchronous initializer was removed.

Keep every test count, native identity, notification, afterAll, resource-drain, and retired-generation assertion. Formatting and targeted lint pass; runtime qualification remains with the red-main coordinator.
Carry the Gateway plugins and managed compiled-worker owner into the generated lifecycle child now that provenance preparation invokes a state worker. Reuse the cleanup fixture ownership pattern and join disposal after the child completes. Preserve every readiness, closure, ordering, and aggregate assertion, with the captured provenance error included in readiness diagnostics.

Source inspection identified the missing prerequisites after CI reported only A/B state-error snapshots. That run did not capture the underlying exception. Targeted lint, formatting, and diff checks pass; runtime confirmation remains pending with the red-main coordinator.
@clawsweeper clawsweeper Bot added 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 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. labels Oct 12, 2026
@steipete
steipete merged commit aeaae03 into main Oct 12, 2026
86 checks passed
@steipete
steipete deleted the dbasync/redmain-native-runner-publication branch October 12, 2026 22:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…0263)

## What Problem This Solves

Two generated fixtures in `test/non-isolated-runner.test.ts` fail before completing their intended lifecycle proof. After openclaw#170162 (`271e435a9bbe`), the native cron module gained runtime dependencies that Node could not resolve from TypeScript source. Fixing relative imports exposed a workspace alias, then a parameter property in the existing retry package that Node's strip-only mode cannot load. Separately, openclaw#169880 (`c8a40c7a9dab`) removed the synchronous provenance initializer still called by both generated Gateway lifetime tests.

## Why This Change Was Made

Prime the real cron module through the fixture's native CommonJS entry point with a temporary synchronous resolution hook for relative source imports and exact aliases from `tsconfig.json`. Always deregister the hook in `finally`, and enable Node's native TypeScript transformation only in this generated child project's `execArgv`. Vite still imports the same native generation. Migrate both Gateway fixtures to await the existing `prepareClawInstallSchemaVersions(options)` owner and publish its result. Carry the Gateway project's plugins into the child and give its newly asynchronous worker calls the same managed compiled-worker setup and joined disposal used by the cleanup child. Run this generated host fixture in a fork: shared-state admission requires a process main thread, as the existing live and agents-support test configurations already document. Keep the Gateway isolation and custom cleanup runner.

## User Impact

The combined change touches three test files (+59/−17). It preserves native cache identity, reset behavior, partial-mock metadata, readiness and close notifications, `afterAll` ordering, awaited resource drains, retired-generation isolation, and every lifecycle assertion and aggregate count. The pool metadata assertion now expects `forks`. Readiness failures include the captured provenance error before the intentional close replaces that snapshot. Production code, timeouts, and test counts are unchanged.

## Evidence

At final head `b59341be18c2`, [CI run 38314652902](https://github.com/openclaw/openclaw/actions/runs/38314652902) passes both tests in `test/non-isolated-runner.test.ts`: shared runner cleanup in 60.697 seconds and Gateway worker lifetimes in 38.036 seconds. Vitest duration is 100.66 seconds; the CI test step takes 104 seconds and its job takes 172 seconds including setup. This is exact-head runtime proof for the complete patch; the earlier failed runs below only establish the causes. The focused reproduction command is `pnpm test test/non-isolated-runner.test.ts --maxWorkers=1`; no separate local runtime run is claimed.

The two earlier resolver changes each passed targeted formatting/lint, diff checks, normal commit hooks, and an independent Codex P0–P2 review. The fixture follow-ups passed targeted lint, formatting, diff checks, and normal hooks; the transform/provenance follow-up also received a separate maintainer diff inspection. The two completed review rounds are retained without a third round.

CI run [38302535736](https://github.com/openclaw/openclaw/actions/runs/38302535736) showed the original relative-import failure; [38306200884](https://github.com/openclaw/openclaw/actions/runs/38306200884) reached the workspace-alias failure. At the prior PR head `2fe45983c46b`, run [38310484484](https://github.com/openclaw/openclaw/actions/runs/38310484484) passed the selected type, lint, baseline, source-contract, and architecture checks, but both parent tests failed: cleanup encountered the unsupported retry parameter property, and Gateway lifetime encountered the removed initializer. The cleanup report expected six failed modules/suite errors from intentional fixtures and observed ten/nine because of the unexpected import failures. Those intentional MCP, watcher, and cancellation failures are not product regressions.

At head `3703bbbc703d`, run [38312339272](https://github.com/openclaw/openclaw/actions/runs/38312339272) passed cleanup in 63.515 seconds, confirming the native import and transformation fixes. Gateway lifetime still failed with `A:state-error` and `B:state-error`. That log did not emit the underlying exception, and no retained fixture artifact was uploaded. The following patch restored omitted Gateway plugins and managed compiled-worker ownership and added error diagnostics.

At head `aefd7bcd3712`, run [38313572251](https://github.com/openclaw/openclaw/actions/runs/38313572251) again passed cleanup and exposed the exact Gateway error: `Shared-state admission requires the host broker`. The native `isMainThread` guard in `openSharedStateSqliteWorkerStore` rejects the inherited thread pool before broker admission. The final fixture-only change selects `forks` and updates the pool metadata expectation; it does not mock or weaken that owner boundary.

All selected static leaf checks pass at the final head: changed-test, source-contract, boundary, lint, production-type, all five core test-type stripes, root test-type, and baseline-ratchet checks. The architecture job executes both cycle checks with zero cycles and passes Kysely guardrails.

The PR does not select Knip. Scoped Knip evidence comes from the actual V28 scan at `0c4b38b77adf`: its only findings were three unrelated Team-scale fixture exports, fixed on main by `2531250f6525`. Comparing the three fixture files and their configs shows no new static module edges, exports, dependencies, or test entry selection after that scan. The generated provenance import switches symbols within the same owner module; runtime changes are proven by this PR's passing tests. The only Knip-config difference is the unrelated PostgreSQL generator entry already landed as `19581446c556`. This qualifies the fixture scope; it does not claim that the full V28 Knip scan passed.

The diff is test-only: no SQL statements, requests, T1 calls, SDK APIs, schema, updater, or service lifecycle behavior changes are claimed. Build and published-driver jobs are skipped by PR selection. The final exact-head CI run is green, including `openclaw/ci-gate`: 28 jobs succeeded and 28 were skipped by selection.
RomneyDa added a commit that referenced this pull request Oct 13, 2026
#170162 backport

The #170162 backport (cf6f760) added a runtime import of agents/run-termination.js to cron/service/active-run-cancellation.ts. The non-isolated runner fixture loads that source through native CommonJS require, which cannot resolve .js specifiers to TypeScript sources, so 09-d and 09-i failed with 'Cannot find module .../run-termination.js' (FRV run 38333371459, job 115088198455).

Port the cron fixture portion of main's companion fix #170263 (aeaae03): prime the native generation through a temporary synchronous resolve hook for relative .js and tsconfig alias imports, and enable --experimental-transform-types in the generated child project. The Gateway lifetime hunks of #170263 are not ported: they follow #169880, which is not on this branch, and that test passes here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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