Repository navigation
refactor: delete dead infra and config exports - #106019
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc007f45d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, | ||
| "packages/memory-host-sdk": { | ||
| entry: [ | ||
| "src/runtime.ts!", |
There was a problem hiding this comment.
Drop nonexistent memory SDK entry
When running pnpm deadcode:knip or pnpm deadcode:report, this new workspace entry points Knip at packages/memory-host-sdk/src/runtime.ts, but that file does not exist and the package export map only has runtime-core, runtime-cli, and runtime-files. Knip's configuration docs classify unmatched entry patterns as configuration hints, and this script does not pass --no-config-hints, so the dead-code scan becomes noisy/failing for a typo rather than checking the actual memory SDK entries.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 7:19 AM ET / 11:19 UTC. Summary Reproducibility: yes. at source level: start two Gateways sharing one state directory but using different config paths, then repeat with the second process requesting a different free port. The current lock derivation and liveness probe show how both cases bypass the existing owner. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Restore one ownership lock per canonical state directory, evaluate an existing owner using its recorded port, rebase to a clean merge result, and run exact-head gateway-lock plus broad lifecycle validation before owner approval. Do we have a high-confidence way to reproduce the issue? Yes at source level: start two Gateways sharing one state directory but using different config paths, then repeat with the second process requesting a different free port. The current lock derivation and liveness probe show how both cases bypass the existing owner. Is this the best way to solve the issue? No. Removing dead exports is reasonable, but changing Gateway lock identity and liveness while doing so is not the narrowest safe solution; those ownership semantics must remain intact or be handled in a separately reviewed change. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4b6575636fd4. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (3 earlier review cycles)
|
64f730a to
54a6ecd
Compare
54a6ecd to
50cc111
Compare
cc4aa00 to
3205d6b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3205d6b152
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const hash = sha256HexPrefix(configPath, 8); | ||
| const lockPath = path.join(lockDir, `gateway.${hash}.lock`); |
There was a problem hiding this comment.
Keep the gateway lock keyed by state directory
This now derives the only lock file from configPath, so two Gateway processes that use different OPENCLAW_CONFIG_PATH values but the same OPENCLAW_STATE_DIR no longer contend on the documented state ownership lock (docs/gateway/gateway-lock.md:19-20, docs/cli/doctor.md:206-210). That lets a live Gateway race another Gateway or destructive SQLite maintenance over state/openclaw.sqlite; the previous gateway.state.<hash>.lock keyed by the canonical state directory prevented exactly this shared-state collision.
Useful? React with 👍 / 👎.
| const ownerStatus = ownerPid | ||
| ? await resolveGatewayOwnerStatus( | ||
| ownerPid, | ||
| lastPayload, | ||
| platform, | ||
| port, | ||
| opts.readProcessCmdline, | ||
| ) |
There was a problem hiding this comment.
Probe the owning lock port, not the requested one
When a second Gateway starts with the same config lock but a different requested lockPort, this passes the new requested port into resolveGatewayOwnerStatus; that helper calls checkPortFree(port) before checking the lock owner's PID/cmdline, so a free new port makes the live owner look dead, removes its lock, and allows a second Gateway to acquire it. This should use the port recorded in lastPayload (or avoid port probing for owner liveness) rather than the candidate startup port.
Useful? React with 👍 / 👎.
3205d6b to
3e8b638
Compare
* refactor: delete dead infra and config exports * refactor: preserve live infra and config contracts * refactor(config): remove obsolete file-store lifecycle APIs * refactor(infra): finish current-main dead export cleanup
Block: heartbeat wake test-reset residue and the moved lifecycle suite. - resetHeartbeatWakeStateForTests / resetSessionEventWakeStateForTests were deleted upstream in d1684f4 (openclaw#106019); 2273ef6/5a6971fc3a revived them. Removed both production exports; no continuation test needs them (the existing afterEach drain with a disabled handler empties the queue). - heartbeat-wake.test.ts restored to upstream b51feb9 bytes. This brings back the six lifecycle tests verbatim, including the createDeferred owner from a67f462 (openclaw#146809), and drops the lifecycle-file copy of "executes distinct targeted wakes ...", deleted upstream in 2bdf870 (openclaw#158725), plus its four byte-duplicate tests. - heartbeat-wake.lifecycle.test.ts deleted. The six continuation routing tests (trusted/untrusted slot separation, parentRunId forwarding) moved unchanged into heartbeat-wake.continuation-routing.test.ts so the upstream file stays within its line cap. Home: restored to upstream (drift residue). Stayed: continuation routing tests in their own sibling file. Refs #1418 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #105595
AI-assisted: implemented and reviewed with Codex.
What Problem This Solves
The enforced production-mode Knip ratchet still carried 593 dead-export entries under
src/config(214) andsrc/infra(379). Those exports unnecessarily enlarged internal module surfaces and kept tests coupled to code that production never imports.Why This Change Was Made
This removes export modifiers where implementations remain useful internally, deletes code and tests that existed only for dead exports, and keeps production/config contracts that are consumed by runtime callers, schema generation, or documented surfaces. Tests retained for meaningful behavior now exercise production APIs instead of re-exported test helpers. The dead-export baseline was regenerated from current
mainimmediately before the final push.User Impact
No intended runtime or config behavior change. The internal TypeScript surface is smaller, dead test-only code is gone, and the enforced baseline drops every
src/configandsrc/infraentry so future regressions are blocked by CI.Evidence
cc4aa00cb34c30b0f25c23198228f0d61351f238; merge base:5cd1d13493757ff294cda9fc64c991e3b02fc0f7.5f2c54dfa965dba18a8d9064317e7242cea9306490d6ff269e6820b39369631e; zero entries begin withsrc/config/orsrc/infra/.tbx_01kxd6g4s4rjtpgmhgkdqbj3qnpassedpnpm deadcode:exports:update,pnpm deadcode:exports,pnpm tsgo:prod,pnpm tsgo:scripts,pnpm tsgo:test,pnpm check:architecture,pnpm build, the session-accessor boundary guard, and 465 focused tests across infra, gateway run-loop, ACP command dispatch, and auto-reply before the final clean rebase.main,node scripts/check-deadcode-exports.mjs --updateandnode scripts/check-deadcode-exports.mjspassed on the final head. Testbox refresh was unavailable because Blacksmith workflow fetches returned HTTP 429 and the fallback coordinators were at shared owner capacity (11/10).node scripts/run-vitest.mjs src/infra/clawhub.test.ts src/security/windows-acl.test.tspassed 71/71 tests.main's workshop import formatting; the dead-export verifier passed again on the pushed head.git diff --check: clean.