Repository navigation
refactor(gateway): consolidate lifecycle lazy boundary - #74105
Conversation
Greptile SummaryThis PR consolidates the ten per-module lazy imports in Confidence Score: 4/5Safe to merge — purely structural refactor with no semantic changes and a new test guardrail. Only P2 finding: the guardrail regex in the new test misses single-quoted dynamic imports, leaving a small future detection gap. No runtime behavior changes, no logic errors. src/infra/tsdown-config.test.ts — guardrail regex coverage Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/infra/tsdown-config.test.ts
Line: 112
Comment:
**Guardrail regex misses single-quoted dynamic imports**
The regex `/import\("([^"]+)"\)/gu` only captures double-quoted import specifiers. Any future dynamic import written with single quotes (e.g. `import('./some-module.js')`) would be silently skipped, the set would remain `{"./lifecycle.runtime.js"}`, and the test would still pass — giving a false-green guardrail.
```suggestion
const importSpecifiers = [...readGatewayRunLoopSource().matchAll(/import\(["']([^"']+)["']\)/gu)].map(
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "refactor(gateway): consolidate lifecycle..." | Re-trigger Greptile |
| }); | ||
|
|
||
| it("routes gateway run-loop lifecycle imports through the stable runtime boundary", () => { | ||
| const importSpecifiers = [...readGatewayRunLoopSource().matchAll(/import\("([^"]+)"\)/gu)].map( |
There was a problem hiding this comment.
Guardrail regex misses single-quoted dynamic imports
The regex /import\("([^"]+)"\)/gu only captures double-quoted import specifiers. Any future dynamic import written with single quotes (e.g. import('./some-module.js')) would be silently skipped, the set would remain {"./lifecycle.runtime.js"}, and the test would still pass — giving a false-green guardrail.
| const importSpecifiers = [...readGatewayRunLoopSource().matchAll(/import\("([^"]+)"\)/gu)].map( | |
| const importSpecifiers = [...readGatewayRunLoopSource().matchAll(/import\(["']([^"']+)["']\)/gu)].map( |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/tsdown-config.test.ts
Line: 112
Comment:
**Guardrail regex misses single-quoted dynamic imports**
The regex `/import\("([^"]+)"\)/gu` only captures double-quoted import specifiers. Any future dynamic import written with single quotes (e.g. `import('./some-module.js')`) would be silently skipped, the set would remain `{"./lifecycle.runtime.js"}`, and the test would still pass — giving a false-green guardrail.
```suggestion
const importSpecifiers = [...readGatewayRunLoopSource().matchAll(/import\(["']([^"']+)["']\)/gu)].map(
```
How can I resolve this? If you propose a fix, please make it concise.|
Codex review: needs changes before merge. Keep open. This PR is maintainer-authored and has the protected Required change before merge: Keep this PR open for maintainer review. If accepted, land the unified gateway lifecycle runtime boundary, preserve #73964/@pashpashpash attribution, keep restart/shutdown semantics unchanged, and validate Best possible solution: Keep this PR open for maintainer review. If accepted, land the unified gateway lifecycle runtime boundary, preserve #73964/@pashpashpash attribution, keep restart/shutdown semantics unchanged, and validate What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3367cfaa1466. |
7cd05a8 to
2a4b7de
Compare
|
/clownfish automerge |
|
Clownfish automerge is enabled for this PR. I added A maintainer can pause this with |
2a4b7de to
cc4a4bf
Compare
|
/clownfish automerge |
|
Clownfish automerge is enabled for this PR. I added A maintainer can pause this with |
|
Thanks, ClawSweeper. Clownfish picked up the repair feedback. Source: I will update this PR branch, or open a safe credited replacement, if the repair worker finds a narrow fix. |
cc4a4bf to
6d7c9a5
Compare
6d7c9a5 to
61c3217
Compare
|
Codex review: needs maintainer review before merge. What this changes: This PR adds a gateway lifecycle runtime module, rewires Maintainer follow-up before merge: This is an open implementation PR with a protected Review detailsBest possible solution: Have a maintainer review and, if accepted, land the focused lifecycle runtime boundary while preserving #73964/@pashpashpash attribution, keeping gateway restart/shutdown semantics unchanged, and validating the tsdown guardrail plus build/changed-gate coverage appropriate for a gateway build-boundary change. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 240362bf6d0e. |
* refactor(gateway): consolidate lifecycle lazy boundary * test(gateway): cover quoted lifecycle imports
* refactor(gateway): consolidate lifecycle lazy boundary * test(gateway): cover quoted lifecycle imports
* refactor(gateway): consolidate lifecycle lazy boundary * test(gateway): cover quoted lifecycle imports
* refactor(gateway): consolidate lifecycle lazy boundary * test(gateway): cover quoted lifecycle imports
|
Clownfish 🐠 reef automerge status This repair lap finished without changing the PR. Clownfish checked the reef and found no safe patch to push this time. Target: #74105 Worker actions:
No push, rebase, replacement PR, merge, or ClawSweeper re-review happened this swim. fish notes: model gpt-5.5, reasoning medium. |
* refactor(gateway): consolidate lifecycle lazy boundary * test(gateway): cover quoted lifecycle imports
Summary
dist/can remove chunks that the live gateway imports during update, restart, or shutdown cleanup.run-loop.tslazy-load that stable entry instead of ten separate implementation modules.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
src/cli/gateway-cli/run-loop.tswas intentionally lazy-loading lifecycle helpers directly from implementation modules that tsdown emits as hashed chunks unless each module is promoted to a stable entry.Regression Test Plan (if applicable)
src/infra/tsdown-config.test.tsrun-loop.tsimports only that lifecycle runtime boundary.User-visible / Behavior Changes
None.
Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
run-loop.tslazy imports.Expected
run-loop.tsfail the tsdown config test.Actual
run-loop.tsimports only./lifecycle.runtime.jsfor lifecycle helpers.tsdown.config.tsemitscli/gateway-lifecycle.runtimeas a stable core dist entry.Evidence
Focused/local verification:
pnpm test src/infra/tsdown-config.test.tspnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/gateway-cli/lifecycle.runtime.ts src/cli/gateway-cli/run-loop.ts src/infra/tsdown-config.test.ts tsdown.config.tspnpm check:changelog-attributionspnpm buildOPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changedpnpm lint:tmp:dynamic-import-warts(advisory-only; no newrun-loop.tsadvisory)Testbox note: attempted
blacksmith testbox run --id tbx_01kqbtr2qyhwavtspead9m6vs6 "pnpm build"andpnpm check:changed, but the client stalled in the sync phase while reporting only 4 changed tracked files plus 1 untracked file. The created box was stopped.Human Verification (required)
origin/main; reran focused test, formatter, attribution check, andgit diff --checkafter rebase.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations