Skip to content

fix(cli): exit after hooks inspection output#76922

Merged
steipete merged 1 commit into
openclaw:mainfrom
dorukardahan:codex/hooks-cli-exit-refresh
Jul 6, 2026
Merged

fix(cli): exit after hooks inspection output#76922
steipete merged 1 commit into
openclaw:mainfrom
dorukardahan:codex/hooks-cli-exit-refresh

Conversation

@dorukardahan

@dorukardahan dorukardahan commented May 3, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw hooks inspection and mutation commands can finish writing their output but keep the process alive indefinitely when plugin registration leaves a referenced timer, socket, or other handle behind.

On current main, a temporary plugin whose register() method starts a referenced interval produced complete hooks list --json output, then timed out after five seconds instead of exiting.

Why This Change Was Made

The bounded hooks commands now reuse the CLI's existing deferred one-shot exit lifecycle. Their actions request exit only after command work and output complete; runCli remains responsible for proxy, harness, memory, stdin, and output-stream teardown before the process exits.

The long-running hooks relay command and delegated compatibility install/update commands retain their existing lifecycle. A process-level regression test launches the real source CLI, loads a temporary plugin, leaves a referenced interval open, and verifies valid JSON plus exit code 0.

User Impact

Scripts and terminals running bare hooks, hooks list, hooks info, hooks check, hooks enable, or hooks disable now return promptly after completing. Command syntax and output are unchanged.

Evidence

  • Before fix: current main emitted 128 bytes of valid JSON, registered the test plugin, then timed out after 5,021 ms (exit 124).
  • After fix: the real temporary-plugin scenario emitted valid JSON, registered the plugin, and exited 0 despite its referenced interval.
  • Blacksmith Testbox tbx_01kwvy3gp0jsf8c8rgy1ep1bze (tidal-krill): 147 focused tests passed across the hooks CLI, deferred exit helper, and top-level cleanup ordering.
  • Same Testbox: path-scoped check:changed passed, including core and core-test tsgo, changed-file lint, import-cycle analysis, and policy guards.
  • Fresh autoreview: no accepted or actionable findings.

@dorukardahan

Copy link
Copy Markdown
Contributor Author

@codex review

@clawsweeper

clawsweeper Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 10:50 AM ET / 14:50 UTC.

Summary
The branch switches hooks list/info/check/enable/disable and bare hooks to request the shared one-shot CLI exit after the command action, with focused unit coverage.

PR surface: Source +15, Tests +40. Total +55 across 2 files.

Reproducibility: yes. source-level only: current main hooks commands build plugin diagnostics and do not request a one-shot exit, so plugin/register code that leaves handles open can keep the process alive. No fresh real terminal proof on the latest PR head was supplied.

Review metrics: 1 noteworthy metric.

  • Hook commands made one-shot: 6 switched. Hooks list/info/check/enable/disable and bare hooks now request a process exit, which is lifecycle-sensitive before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post redacted terminal output, live output, logs, or a short recording from a current-head run where a temporary plugin/register path leaves a handle open and a hooks command exits after output.
  • Update the PR body after adding proof so ClawSweeper re-reviews automatically; if it does not, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Only tests and local command lists are supplied; before merge, add redacted terminal output, logs, live output, or a recording showing the temporary lingering-handle hooks scenario exits after output, with private paths, tokens, phone numbers, IPs, and non-public endpoints redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] No current-head real behavior proof shows a hooks command with a temporary plugin/register path that leaves an open handle exiting after output; the supplied evidence is tests, CI, and local command lists.
  • [P1] The patch intentionally adds a hard process exit after several hooks commands, so merge confidence depends on proving that exit occurs only after top-level CLI cleanup and remains limited to the intended one-shot hooks paths.

Maintainer options:

  1. Require current-head terminal proof (recommended)
    Ask the contributor to post redacted terminal output, live output, or logs from a temporary plugin/register path that leaves a handle open and a hooks command exits after output.
  2. Accept unit-only proof
    A maintainer may intentionally merge based on the code and unit coverage, while owning the lack of real reproduction proof for this lifecycle path.

Next step before merge

  • [P1] Wait for contributor-provided real behavior proof or explicit maintainer proof override; there is no narrow ClawSweeper repair marker to open while the proof gate is missing.

Security
Cleared: The diff only changes CLI process-exit wiring and tests; it does not touch dependencies, workflows, secrets, package metadata, or artifact execution paths.

Review details

Best possible solution:

Land the narrow hooks one-shot exit change after redacted terminal or log proof shows the lingering-plugin-handle scenario exits after output while relay/install/update remain on the normal path.

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

Yes, source-level only: current main hooks commands build plugin diagnostics and do not request a one-shot exit, so plugin/register code that leaves handles open can keep the process alive. No fresh real terminal proof on the latest PR head was supplied.

Is this the best way to solve the issue?

Yes, this looks like the best narrow fix shape: reuse the shared one-shot helper after runCli cleanup instead of adding a hooks-local exit path, while leaving relay and deprecated install/update flows outside the one-shot wrapper.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5733fb0e193e.

Label changes

Label justifications:

  • P2: This is a focused hooks CLI availability bugfix with limited surface area and an active implementation path.
  • merge-risk: 🚨 availability: Changing hooks commands to force a post-output process exit can affect hangs or teardown behavior if the lifecycle boundary is wrong.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only tests and local command lists are supplied; before merge, add redacted terminal output, logs, live output, or a recording showing the temporary lingering-handle hooks scenario exits after output, with private paths, tokens, phone numbers, IPs, and non-public endpoints redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +15, Tests +40. Total +55 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 22 7 +15
Tests 1 42 2 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 64 9 +55

What I checked:

  • PR head hooks one-shot wiring: At the reviewed head, hooks list/info/check/enable/disable and bare hooks call runOneShotHooksCliAction, which requests the shared one-shot exit after the command action instead of exiting directly. (src/cli/hooks-cli.ts:176, 479d36fb0539)
  • Current main teardown order: Current runCli awaits proxy stop, agent harness disposal, memory manager close, and stdin pause before calling flushExitAfterOneShotOutput(), which is the ownership boundary this PR now uses. (src/cli/run-main.ts:1352, 5733fb0e193e)
  • Shared one-shot helper contract: The shared helper records an exit request only for the default runtime, then flushes stdout and stderr callbacks before scheduling the exit; tests cover deferral, custom runtimes, Vitest worker suppression, and stream callbacks. (src/cli/one-shot-exit.ts:34, 5733fb0e193e)
  • History provenance for shared helper: git blame ties the current shared one-shot helper and the runCli flush call to merged commit 9344bb8 from the model inspection exit fix, merged via fix(cli): exit after model inspection output #77904. (src/cli/one-shot-exit.ts:34, 9344bb8b48da)
  • Previous review finding addressed: Earlier review comments asked the contributor to delay forced hooks exits until CLI finalizers complete; the latest head replaces direct hooks exit scheduling with requestExitAfterOneShotOutput(). (src/cli/hooks-cli.ts:164, 479d36fb0539)
  • Proof remains test-only: The PR body and latest contributor comment list formatter/lint/test commands and describe behavior assertions, but they do not include redacted terminal output, logs, or live output from a temporary plugin/register path that leaves an open handle. (479d36fb0539)

Likely related people:

  • dorukardahan: Authored the merged shared one-shot exit helper in current main and authored this hooks-specific refresh that reuses it. (role: recent adjacent owner; confidence: high; commits: 9344bb8b48da, 479d36fb0539; files: src/cli/one-shot-exit.ts, src/cli/run-main.ts, src/cli/hooks-cli.ts)
  • vincentkoc: Merged the current shared one-shot helper PR and has recent history around plugin status/reporting surfaces that hooks diagnostics call into. (role: merger and adjacent plugin-status contributor; confidence: medium; commits: 9344bb8b48da, bb3f17fc0295, def5b954a869; files: src/cli/one-shot-exit.ts, src/cli/run-main.ts, src/plugins/status.ts)
  • steipete: Current live PR assignment is to steipete, and git history shows Peter Steinberger commits across hooks CLI, hook policy, and plugin diagnostics surfaces. (role: historical hooks and plugin diagnostics contributor; confidence: medium; commits: 5cb2f4558573, 42f23619e360, 58f4099a4fb0; files: src/cli/hooks-cli.ts, src/hooks/policy.ts, src/plugins/status.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.
Review history (3 earlier review cycles)
  • reviewed 2026-07-03T21:01:16.006Z sha 8f00a2f :: needs real behavior proof before merge. :: [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-06T08:16:11.337Z sha e7e9505 :: needs real behavior proof before merge. :: [P2] Delay forced hooks exits until CLI cleanup completes
  • reviewed 2026-07-06T09:19:33.469Z sha a8fa8c5 :: needs real behavior proof before merge. :: [P2] Delay forced exits until CLI cleanup completes

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

@dorukardahan

Copy link
Copy Markdown
Contributor Author

Synced this PR with latest main using a normal merge commit, no force push.

I kept the new upstream changelog entries and kept this PRs hooks CLI exit fix.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts
  • git diff --check

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Nice work!

ℹ️ 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".

@dorukardahan

Copy link
Copy Markdown
Contributor Author

Synced latest main again with a normal merge commit, no force push.

Only changelog moved. I kept the new upstream TUI fix note and kept this PRs hooks CLI exit note.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts

@codex review

@dorukardahan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

@dorukardahan

Copy link
Copy Markdown
Contributor Author

Synced latest main once more with a normal merge commit, no force push.

Only changelog moved again. I kept the new upstream Telegram/TUI notes and kept this PRs hooks CLI exit note.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2ff905c31

ℹ️ 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".

Comment thread src/cli/hooks-cli.ts Outdated
Comment on lines +157 to +159
function shouldForceExitAfterHooksInspection(env: NodeJS.ProcessEnv = process.env): boolean {
return !isVitestRuntimeEnv(env);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid suppressing one-shot exit on NODE_ENV=test

shouldForceExitAfterHooksInspection now delegates to isVitestRuntimeEnv, which treats any NODE_ENV="test" process as a test runtime. That means real CLI invocations run under NODE_ENV=test (common in CI wrappers/dev shells) will skip the new forced-exit path and can still hang when a hook/plugin leaves open handles, so the fix is silently disabled in a non-test environment.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

I changed the guard so NODE_ENV=test does not suppress the forced exit anymore. Only Vitest-specific env vars skip it now.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts
  • git diff --check

@codex review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label May 4, 2026
@dorukardahan

Copy link
Copy Markdown
Contributor Author

Synced latest main with a normal merge commit, no force push.

I kept the new upstream changelog notes and moved this PRs changelog line away from the constantly changing top of the fixes section. I also kept the NODE_ENV=test fix for the Codex P2 review.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts
  • git diff --check

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

@dorukardahan

Copy link
Copy Markdown
Contributor Author

Synced latest main with a normal merge commit, no force push.

I kept the new upstream Telegram changelog note and kept this PRs hooks CLI exit note. The code behavior is unchanged.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts
  • git diff --check

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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".

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 5, 2026
@dorukardahan

Copy link
Copy Markdown
Contributor Author

Synced latest main after the 2026.5.4 release using a normal merge commit, no force push.

I kept upstream changelog changes and re-added this PRs hooks CLI exit note. The code behavior is unchanged.

Local checks:

  • pnpm test src/cli/hooks-cli.test.ts
  • pnpm check:no-conflict-markers
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts
  • git diff --check

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Breezy!

ℹ️ 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".

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 5, 2026
@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label May 30, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label May 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 30, 2026
@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 31, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed agents Agent runtime and tooling triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7e9505251

ℹ️ 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".

Comment thread src/cli/hooks-cli.ts Outdated

async function runOneShotHooksCliAction(action: () => Promise<void> | void): Promise<void> {
await runHooksCliAction(action);
exitAfterHooksInspection();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Delay forced hooks exits until CLI cleanup finishes

When a hooks command loads plugin diagnostics, plugins can register async teardown work such as agent-harness dispose() hooks; runCli currently awaits disposeCliAgentHarnesses() and closeCliMemoryManagers() in its finally after parseAsync returns (src/cli/run-main.ts:1343-1348). Calling exitAfterHooksInspection() from inside the Commander action schedules process.exit(0) before those awaited finalizers are guaranteed to resolve, so a hooks command that loaded a plugin with an async dispose/subprocess cleanup can terminate mid-cleanup and leave plugin-owned resources behind. The hard exit should be owned after the top-level CLI cleanup has completed, while still forcing one-shot hook commands to exit afterward.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8fa8c5452

ℹ️ 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".

Comment thread src/cli/hooks-cli.ts Outdated

async function runOneShotHooksCliAction(action: () => Promise<void> | void): Promise<void> {
await runHooksCliAction(action);
exitAfterHooksInspection();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Delay forced exit until CLI finalizers complete

When these hooks commands load plugin diagnostics that register async teardown, this schedules runtime.exit(0) from inside the Commander action, before runCli reaches its finally cleanup that awaits disposeCliAgentHarnesses() and closeCliMemoryManagers(). In the case this change is meant to fix—plugin/register code leaving handles open—the new hard exit can run on the next stream-drain callback or setImmediate while those top-level finalizers are still pending, so plugin-owned subprocesses or memory managers can be terminated mid-cleanup rather than cleanly disposed.

Useful? React with 👍 / 👎.

@dorukardahan
dorukardahan force-pushed the codex/hooks-cli-exit-refresh branch from 4699212 to 479d36f Compare July 6, 2026 14:25
@dorukardahan

Copy link
Copy Markdown
Contributor Author

Addressed the Codex feedback at exact head 479d36fb05: hooks commands now only request the shared one-shot exit, and the actual stdout/stderr flush + process exit stays in the top-level runCli finalizer after harness/memory cleanup.

Local verification:

  • corepack pnpm exec oxfmt --check src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts
  • corepack pnpm exec oxlint src/cli/hooks-cli.ts src/cli/hooks-cli.test.ts src/cli/one-shot-exit.ts src/cli/run-main.ts src/cli/run-main.exit.test.ts
  • corepack pnpm test src/cli/hooks-cli.test.ts src/cli/one-shot-exit.test.ts src/cli/run-main.exit.test.ts — 153 tests passed
  • corepack pnpm test test/scripts/package-acceptance-workflow.test.ts — 42 tests passed
  • corepack pnpm check:no-conflict-markers
  • corepack pnpm check:madge-import-cycles — 0 cycles

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 479d36fb05

ℹ️ 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".

@steipete steipete self-assigned this Jul 6, 2026
Co-authored-by: dorukardahan <35905596+dorukardahan@users.noreply.github.com>
@steipete
steipete force-pushed the codex/hooks-cli-exit-refresh branch from 479d36f to 845bd07 Compare July 6, 2026 15:05
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready maintainer pass complete on 845bd07eab4.

What changed:

  • Reworked the contributor fix onto the shared deferred one-shot exit lifecycle.
  • Kept hooks relay and compatibility install/update flows outside forced exit.
  • Added a process-level regression that loads a real temporary plugin, leaves a referenced interval open, verifies JSON output, and requires exit code 0.

Proof:

  • Blacksmith Testbox tbx_01kwvy3gp0jsf8c8rgy1ep1bze (tidal-krill): corepack pnpm test src/cli/hooks-cli.process.test.ts src/cli/hooks-cli.test.ts src/cli/one-shot-exit.test.ts src/cli/run-main.exit.test.ts — 147 passed.
  • Same Testbox: corepack pnpm check:changed -- src/cli/hooks-cli.ts src/cli/hooks-cli.process.test.ts — passed, including core/core-test tsgo, lint, import cycles, and policy guards.
  • Before/after live proof: current main emitted complete JSON then timed out after 5,021 ms; this head emitted valid JSON, registered the plugin, and exited 0 despite the referenced timer.
  • Fresh autoreview: no accepted/actionable findings.
  • Exact-head hosted CI: https://github.com/openclaw/openclaw/actions/runs/28801519472 — green.

Known proof gaps: none for this bounded CLI lifecycle change.

@steipete
steipete merged commit 919811c into openclaw:main Jul 6, 2026
102 checks passed
@dorukardahan

dorukardahan commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @steipete, really appreciate the land-ready pass.

The process-level test with a real temp plugin and a referenced handle is exactly the kind of proof this needed. My unit/helper coverage was pointing in the right direction, but this is much closer to the real failure mode. i will use that pattern earlier for CLI lifecycle fixes next time.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
Co-authored-by: Peter Steinberger <steipete@gmail.com>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
Co-authored-by: Peter Steinberger <steipete@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants