Skip to content

fix(sessions): preserve signal exit status in tail follow - #138581

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
MoerAI:fix/sessions-tail-signal-status
Sep 4, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
MoerAI:fix/sessions-tail-signal-status

Conversation

@MoerAI

@MoerAI MoerAI commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #127348

What Problem This Solves

openclaw sessions tail --follow handled SIGINT and SIGTERM by cleaning up its polling interval and returning normally. The real CLI therefore exited 0, so scripts and supervisors could not distinguish an operator interrupt or termination request from a successful completed tail.

Why This Change Was Made

The follow owner now returns the exact signal after removing both listeners and clearing the polling interval. The command boundary maps that closed outcome to the conventional CLI statuses: 130 for SIGINT and 143 for SIGTERM.

This keeps cleanup in the follow lifecycle while keeping process-exit policy at the command boundary.

User Impact

Operators, shells, and supervisors now receive a truthful nonzero status when a followed session tail is interrupted or terminated. Normal non-following tails and existing error exits are unchanged.

Evidence

Current-main reproduction at 47dff2de27113271f91782f23a5ae5841eecce1a:

{"requestedSignal":"SIGINT","sentAfterEvent":true,"exitCode":0,"exitSignal":null}
{"requestedSignal":"SIGTERM","sentAfterEvent":true,"exitCode":0,"exitSignal":null}

Exact-head proof at 16f6ad0c0f977626669ea22a27aca451a7ce8a92 used the built CLI from a frozen isolated install, a real SQLite session/trajectory store, and real process actions only after the CLI rendered session.started:

{"head":"16f6ad0c0f977626669ea22a27aca451a7ce8a92","case":"signal","requestedSignal":"SIGINT","sentAfterEvent":true,"exitCode":130,"exitSignal":null}
{"head":"16f6ad0c0f977626669ea22a27aca451a7ce8a92","case":"signal","requestedSignal":"SIGTERM","sentAfterEvent":true,"exitCode":143,"exitSignal":null}
{"head":"16f6ad0c0f977626669ea22a27aca451a7ce8a92","case":"read-error","corruptedAfterEvent":true,"errorObserved":true,"exitCode":1,"exitSignal":null}

Additional exact-head verification:

  • node scripts/run-vitest.mjs src/commands/sessions-tail.test.ts - 33 passed.
  • pnpm build - passed.
  • openclaw sessions tail --help - passed.
  • Formal P1 autoreview - clean, correctness 0.98.
  • Duplicate search by issue number and signal behavior - no open fixing PR found.

Risk

  • Scope is limited to the already-installed SIGINT and SIGTERM handlers in follow mode.
  • Both listeners and the polling interval are released before requesting process exit.
  • No config, schema, persistence format, default, environment variable, migration, or public API changed.
  • Compatibility acceptance: interrupted follow mode intentionally changes from exit 0 to conventional statuses 130/143; all non-following behavior and existing error status 1 remain unchanged.
  • Production delta: +8 net lines; test delta: +13 net lines. The growth gives the follow lifecycle one named closed outcome and one idempotent cleanup owner.

Changelog

n/a - repository policy derives release notes from the PR user-impact and evidence sections.

…27348)

Return the terminating signal from follow cleanup and map it to the conventional CLI exit code after listeners and polling are released.
@clawsweeper

clawsweeper Bot commented Sep 4, 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.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Sep 4, 2026
@MoerAI
MoerAI marked this pull request as ready for review September 4, 2026 20:17
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-04T20:22:19.535017Z 8c15823 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Returning the terminating signal from the follow lifecycle and translating it to CLI status at the command boundary is the right separation. Both listeners and the polling interval are removed before runtime.exit, so cleanup does not depend on process termination side effects. The paired SIGINT/SIGTERM regression pins the conventional 130/143 contract cleanly.

@MoerAI

MoerAI commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The prior exact-head review placeholder lease expired without publishing a durable verdict. Head 8c15823e4162d17ae7670f51bff6ba908c2267be is unchanged, GitHub CI is fully green, and the PR remains cleanly mergeable.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 6:16 PM ET / 22:16 UTC.

ClawSweeper review

What this changes

The PR makes sessions tail --follow return 130 for SIGINT and 143 for SIGTERM after cleanup, while preserving error exit 1 and adding regression coverage.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it fixes the linked current defect, and the exact-head terminal trace now satisfies the prior real-behavior-proof request. Current main and v2026.9.1 retain the cleanup-only signal path, so the work is not obsolete.

Priority: P2
Reviewed head: 16f6ad0c0f977626669ea22a27aca451a7ce8a92

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused lifecycle repair with exact-head real-process proof, targeted regression coverage, and explicit compatibility acceptance.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The exact-head PR-body terminal trace exercises the built CLI against a real SQLite trajectory store after an event is rendered, observing SIGINT 130, SIGTERM 143, and a read-error exit of 1.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The exact-head PR-body terminal trace exercises the built CLI against a real SQLite trajectory store after an event is rendered, observing SIGINT 130, SIGTERM 143, and a read-error exit of 1.
Evidence reviewed 7 items Introduced lifecycle repair: The PR resolves one closed follow outcome after clearing the polling interval and both listeners, then maps ERROR/SIGINT/SIGTERM at the command boundary to 1/130/143.
CLI entry point: The registered sessions tail action awaits sessionsTailCommand through the shared command runtime, so the command-level exit mapping reaches the real CLI path.
Regression coverage: The table-driven regression asserts both conventional signal statuses and listener cleanup; the unreadable-store case asserts exactly one error exit even after a later SIGTERM emission.
Findings None None.
Security None None.

How this fits together

The sessions-tail CLI reads trajectory events from the session store and polls for new events in follow mode. Signals or read failures end that polling lifecycle, then the command runtime reports an exit status to shells and supervisors.

flowchart LR
  A[SQLite trajectory store] --> B[Sessions tail command]
  B --> C[Follow polling lifecycle]
  D[Signal or read error] --> C
  C --> E[Cleanup and terminal outcome]
  E --> F[CLI exit status]
  F --> G[Shell or supervisor]
Loading

Before merge

  • Resolve merge risk (P1) - Compatibility: scripts that deliberately treated SIGINT or SIGTERM interruption as successful follow completion will instead receive 130 or 143; the member review comment explicitly accepts this conventional CLI behavior.
Agent review details

Security

None.

PR surface

Source +8, Tests +13. Total +21 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 12 +8
Tests 1 16 3 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 36 15 +21

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +8 net; tests +13 net The small production increase creates one typed terminal outcome and one cleanup owner, replacing an error path that could leave polling active under non-exiting runtimes.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #127348
Summary: This PR is the concrete candidate fix for the linked sessions-tail signal-status bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the conventional signal-status change (recommended)
    Land the explicitly accepted change so interrupted follow mode reports 130 or 143 instead of a successful exit.

Technical review

Best possible solution:

Land the single lifecycle outcome and command-boundary status mapping so cleanup remains exact-once and shells receive the terminating signal status.

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

Yes: the supplied pre-fix terminal trace shows exit 0 for both signals, and current main retains the same follow implementation; the exact-head trace shows the corrected statuses.

Is this the best way to solve the issue?

Yes: this is the best fix because the follow owner records and cleans up one terminal outcome while the command boundary owns CLI exit policy, matching sibling signal-handling patterns.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5772aa2c5ab9.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The exact-head PR-body terminal trace exercises the built CLI against a real SQLite trajectory store after an event is rendered, observing SIGINT 130, SIGTERM 143, and a read-error exit of 1.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head PR-body terminal trace exercises the built CLI against a real SQLite trajectory store after an event is rendered, observing SIGINT 130, SIGTERM 143, and a read-error exit of 1.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This corrects a bounded CLI exit-status bug that affects scripts and supervisors but does not make the core runtime unavailable.
  • merge-risk: 🚨 compatibility: An intentional exit-status change can alter existing supervisor or shell branching for interrupted follow commands.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head PR-body terminal trace exercises the built CLI against a real SQLite trajectory store after an event is rendered, observing SIGINT 130, SIGTERM 143, and a read-error exit of 1.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head PR-body terminal trace exercises the built CLI against a real SQLite trajectory store after an event is rendered, observing SIGINT 130, SIGTERM 143, and a read-error exit of 1.

Evidence

What I checked:

  • Introduced lifecycle repair: The PR resolves one closed follow outcome after clearing the polling interval and both listeners, then maps ERROR/SIGINT/SIGTERM at the command boundary to 1/130/143. (src/commands/sessions-tail.ts:221, 16f6ad0c0f97)
  • CLI entry point: The registered sessions tail action awaits sessionsTailCommand through the shared command runtime, so the command-level exit mapping reaches the real CLI path. (src/cli/program/register.status-health-sessions.ts:413, 16f6ad0c0f97)
  • Regression coverage: The table-driven regression asserts both conventional signal statuses and listener cleanup; the unreadable-store case asserts exactly one error exit even after a later SIGTERM emission. (src/commands/sessions-tail.test.ts:367, 16f6ad0c0f97)
  • Current-main behavior: Fetched current main still has the former shared signal handler that clears resources and resolves without carrying the signal outcome. (src/commands/sessions-tail.ts:220, 5772aa2c5ab9)
  • Shipped behavior: The latest stable release v2026.9.1 also retains the former signal-cleanup-only implementation; no release contains this PR head. (src/commands/sessions-tail.ts:220, ad6fe23aecb9)
  • Exact-head real behavior proof: The untruncated PR body includes an exact-head built-CLI trace using a real SQLite store: SIGINT exits 130, SIGTERM exits 143, and an injected read error exits 1. This addresses the previous review's exact-head proof request. (16f6ad0c0f97)

Likely related people:

  • vincentkoc: 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 (3 earlier review cycles)
  • reviewed 2026-09-04T21:17:15.923Z sha 8c15823 :: blocked before merge. :: none
  • reviewed 2026-09-04T21:47:52.077Z sha 8c15823 :: blocked before merge. :: none
  • reviewed 2026-09-04T22:03:15.483Z sha 16f6ad0 :: needs real behavior proof before merge. :: none

@vincentkoc vincentkoc self-assigned this Sep 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer repair is now on head 16f6ad0c0f977626669ea22a27aca451a7ce8a92 as a signed commit atop the contributor commit.

  • Root cause: follow read errors called runtime.exit(1) inside the polling callback, while the still-live signal path could later request 130/143 from the command boundary.
  • Owner fix: the follow lifecycle now resolves one closed ERROR | SIGINT | SIGTERM outcome through an idempotent cleanup function; sessionsTailCommand alone maps that outcome to 1/130/143.
  • Regression proof: src/commands/sessions-tail.test.ts passes 33/33, including an unreadable-store case that emits SIGTERM afterward, observes exactly one [1] exit, and verifies both signal listeners return to baseline. Scoped oxlint, format, diff checks, and P1 autoreview are clean.
  • Surface: production +20/-12 (net +8); tests +16/-3 (net +13) against the PR base.
  • Compatibility: accepted. Interrupted follow runs intentionally change from status 0 to conventional 130/143 so shells and supervisors receive the terminating signal outcome.
  • Docs/changelog: no change required; the CLI docs do not contract these exit codes, and changelogs are release-generated.
  • Local full typecheck was not usable because the canonical checkout install has @openclaw/fs-safe 0.7.1 while this tree requires 0.7.2; exact-head CI is the authoritative full gate.

@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Head 16f6ad0c0f977626669ea22a27aca451a7ce8a92 adds the reviewed unified error outcome and exact-once cleanup/exit regression. Maintainer compatibility acceptance is recorded above.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 4, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@vincentkoc
vincentkoc merged commit 22a54d0 into openclaw:main Sep 4, 2026
121 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…38581)

* fix(sessions): preserve signal exit status in tail follow (openclaw#127348)

Return the terminating signal from follow cleanup and map it to the conventional CLI exit code after listeners and polling are released.

* fix(sessions): unify tail follow outcomes

---------

Co-authored-by: Vincent Koc <[email protected]>
@MoerAI
MoerAI deleted the fix/sessions-tail-signal-status branch September 5, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

sessions tail --follow maps SIGINT and SIGTERM to a successful exit

3 participants