Skip to content

feat(exec): keep durable session processes across Gateway restarts - #188465

Merged
steipete merged 4 commits into
mainfrom
codex/durable-session-processes
Oct 30, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/durable-session-processes

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Long-running session commands end when the Gateway restarts, so durable work currently needs an external launcher and loses the session's process controls and completion wake.

User Impact

exec can opt into durable: true with background: true or yieldMs on Gateway-host Linux with a reachable systemd user manager, version 250 or newer. The session retains list/poll/log/kill controls after a Gateway restart. Durable work does not block cooperative suspension or safe restart. Unsupported hosts refuse instead of falling back.

Durable processes have no interactive input. Raw append-only logs consume disk until process retention removes them; operators must provision disk space. Direct managed GitHub credentials are captured at launch and are not refreshed, so long jobs can outlive their tokens. Secret-egress proxy grants are refused because their lifetime belongs to the Gateway.

Why This Change Was Made

The existing background-process registry remains the owner. It launches an opaque transient user unit outside the Gateway cgroup, using ExitType=cgroup, RemainAfterExit=yes, KillMode=control-group, RuntimeMaxSec, and the ordinary exec memory bound as MemoryMax. Command policy, approval, cwd, environment preparation, and final launch authority stay on the ordinary exec path. Infrastructure executables resolve from Gateway PATH; credential values are passed through the prepared environment rather than command arguments.

The shared-state worker creates one optional durable_background_processes table on first write (id, record_json); Kysely and existing schema admission own it. No schema-version bump is needed. Reads do not create storage. The record contains registry/restart facts, a generic command summary, and final status; it contains no environment values, output, or requester continuation. PostgreSQL-generated schema artifacts and the update contract are updated too.

Startup restores registry entries, then the existing observation cadence reconciles units. Real terminal status is persisted before unit cleanup, and final output is drained after checking exit. Post-restart completion is fresh session input under the session principal's current authority, with notification and session eligibility rechecked. Live requester completion behavior stays unchanged.

The simplification consolidated persistence into one module and removed the global pending/finalizer maps, duplicate settlement paths, and separate runtime notification flags. Production is +1,014/-60 lines (net +954); tests are +841/-55 (net +786). This is about 25% smaller than the previous +1,277 production delta, but does not meet the requested well-under-half target. Generated schema churn is separate (+375/-281).

Evidence

  • Base public-launch regression: node scripts/run-vitest.mjs src/agents/bash-process-durable-base-launch.test.ts --maxWorkers=1 in an isolated base checkout with a temporary native fixture. It reached the real exec entry point and failed because a running handle was returned without creating the external unit. Supervisor cleanup completed; this was not a setup failure.

  • Green: node scripts/run-vitest.mjs src/agents/bash-process-durable.test.ts src/agents/bash-durable-process-store.test.ts --maxWorkers=1 passed after the final fixes. The wider run passed 237 tests across 16 scoped files, covering exec policy/approvals, registry/observation, requester notifications, prefix stability, schemas, and migration contracts. The launch/adoption and persistence proofs run through native main-thread host-broker fixtures; only the external manager is synthetic. The final focused rerun also covers output written during the terminal status check and startup without synchronous unit queries.

  • Published upgrade: installed [email protected], created its real schema-20 database, ran candidate doctor --non-interactive --fix in isolated state with external service-repair policy, and verified schema 36 plus both Doctor backups with quick_check. The same native store fixture passed over a verified copy of that upgraded database, including first-use table creation, preserved metadata, worker-only SQL, and close/reopen.

  • pnpm tsgo; scoped lint and format; baseline, database-worker/dialect, assertion, line-cap, test-line, timeout, and mock-export ratchets; generated Kysely/PostgreSQL verification; git diff --check passed. Codex autoreview finished scoped-clean through P2 after fixing final-output ordering and startup reconciliation latency.

  • Unused-file inventory: production scan passed with zero entries. The full-tree scan reports five unchanged performance scripts; none of this PR's files appear.

  • Local real-systemd proof (partial, source 291b281081e0): OrbStack Docker with cgroup v2, privileged container built from node:24-bookworm-slim (Debian 12), systemd 252.39 as PID 1, unprivileged UID 1001 with lingering and a reachable real user manager. Copied source, container-local pnpm install --frozen-lockfile (pnpm 12.15.0, Node 24.22.2), and the repository qaRuntime build passed. A real isolated Gateway plus a scripted loopback Responses provider launched exec with background:true,durable:true; the command and child ran in a transient user-unit cgroup outside the Gateway cgroup, and sessions.processes.list found the running handle.

  • Stopped proof requirement: the owning sessions.list row had no background-process count (status: done, hasActiveRun: false while the unit was running), confirming the separate session-count integration gap already noted below. The harness stopped at that failed requirement; SIGTERM/SIGKILL restart-and-adoption, process-tool tree kill, downtime-exit/completion deduplication, and both refusal scenarios were not executed. No runtime code was changed. Descendant timeout and memory-limit live proof also remain unexecuted.

  • Environment exposure PASS: a unique synthetic value injected through secrets store set ... --kind env was absent from durable_background_processes.record_json (false) and Gateway/process logs, including the persisted Gateway log (false), and present in systemctl --user show <unit> -p Environment (true) and the transient unit file under $XDG_RUNTIME_DIR/systemd/transient/ (true, tmpfs). Unit-property exposure is readable by the same Unix user and is now stated in docs/tools/exec.md. The non-persistence statement is scoped to durable bookkeeping: the shared secret store intentionally stores env entries in SQLite, and commands may explicitly print or persist them.

  • Docs follow-up: docs(exec): state durable unit environment exposure (34c9db137824). Targeted formatter and MDX validation, git diff --check, and Codex autoreview through P2 passed. No CI reruns or merge requested. Gateway and synthetic unit/container cleanup completed; manual systemctl cleanup is not process-tool kill proof.

  • Landing CI repair (073bb5c44821): Linux startup added an earlier lifetime sidecar, exposing positional cleanup-handle assumptions and an unisolated durable persistence import in the worker-free fixture. The existing update-check ownership case reproduced red locally with Linux selected. Select handles by identity/name, isolate the durable worker owner, await actual readiness, and exercise the Linux branch on every host. Extract the unchanged trace recorder into a sibling helper to satisfy the line-cap ratchet. All 77 startup tests pass (12.31s wall); targeted gateway test types, scoped lint/format, whitespace checks, commit hooks, and independent Codex autoreview through P2 pass. This fixture repair adds 12 net test lines, covered by its allocation.

  • Baseline CI failure on final head (e484c8e36a7e): run 41090351803 attempt 1, job 124183102346, src/gateway/tool-resolution.test.ts > Gateway-built tool final effects > fences workspace-restricted persistent Gateway delegation: tool-cancelled expects a retained cancelled snapshot but receives undefined at tool-resolution.effects.test-support.ts:253. It reproduces identically on the PR and isolated main 6a550b0a7ce01364035fbea8a60c0c7bc4d2a7d6 (same assertion/stack). The baseline command was node scripts/run-vitest.mjs src/gateway/tool-resolution.test.ts --maxWorkers=1 -t 'fences workspace-restricted persistent Gateway delegation' (109.14s wall; one failed, three passed). No CI reruns were requested; this failure remains recorded, not relabeled green. The final attempt completed with 99 terminal jobs; all three PostgreSQL shards and security-fast passed. The aggregate classifier reports unknown because scheduled main has no matching job. Independent reproduction on main and seven identical relevant test/owner Git objects across that main, CI baseline, and tested PR merge establish the unrelated-failure attribution. Native auto-merge was armed and then retired through the supported recovery owner before selecting the documented pre-existing-failure route.

  • PostgreSQL CI repair (e484c8e36a7e): prior-head run 41086438511, job 124170316671, exposed the complete-inventory expectation of 135 tables after this PR adds the 136th table. The same test failed locally against isolated PostgreSQL 17 with 135 versus 136 before the fix. Updated only that fixed count; both state-port.postgres.test.ts tests then passed through the real PostgreSQL conformance entrypoint (66.07s wall), retaining complete round-trip, exact/sanitized backup, optional-fragment, and schema-drift coverage. Scoped lint/format, commit hooks, and independent P2 autoreview passed. The other two PostgreSQL CI shards passed. The synthetic local container was removed. No CI reruns requested.

No sidebar UI changes or deployment are included. The parallel session-count projection has not landed on the checked main revision. Rollback to a binary without this feature requires inspecting/stopping retained user units through systemd; existing database-version rollback rules still apply.

@clawsweeper

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-10-30T16:07:38.279216Z 073bb5c New commits
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: e484c8e36a7e5178c84930893915365d75468319
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/bash-tools.exec-approval-binding.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/exec-tool-target-pinning.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR adds opt-in Linux systemd execution that retains background-process handles, output, and completion handling across Gateway restarts.

Example: A session launches npm run build with background:true,durable:true on Linux with systemd 252.

  • Before: Restarting the Gateway stops ordinary supervised work and loses its process handle.
  • After: The intended behavior keeps the build running and restores its original process handle after restart.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful maintainer-directed capability with partial real-systemd evidence, but concrete authority and restart integration defects prevent a pass.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Long-running commands lose their supervised process controls when the Gateway restarts.
Reason: The maintainer-authored direction adds a distinct capability while retaining the existing process owner and documenting its host, credential, and retention tradeoffs.

Merge readiness

⛔ Blocked before merge - 9 items remain

Keep open: this maintainer-directed feature has clear value, but restart bookkeeping, launch and stop authority, and a diff-caused startup-test failure need correction.

Priority: P2
Reviewed head: 34c9db137824240359a9836b5497eb6675c73987

Before merge

  • Add real behavior proof - Authority-chain proof required: demonstrate approved launch and authorized stop, then deny a changed approved script and a revoked session caller before systemd I/O; also demonstrate that reset, archived, or revoked sessions cannot receive privileged adopted completion effects. The supplied real Gateway/systemd 252 run proves launch, external cgroup placement, listing, and environment exposure at runtime-identical source 291b281, but explicitly stopped before restart adoption, process-tool kill, downtime completion, refusals, and descendant limits. Provide redacted terminal output or logs covering those paths, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve the final mutable-file preflight for durable launches (P1) - For an approved command such as sh /workspace/job.sh, the asynchronous approval binding check runs before startDurableExecProcess. The new path then awaits manager discovery, filesystem work, persistence, and show-environment before launching systemd-run. The supplied beforeSpawn callback only checks current policy; it does not rerun the script-byte or cwd binding. Replacing job.sh during those waits therefore executes different bytes under the earlier approval. Carry the existing asynchronous binding revalidation to the final systemd launch boundary after preparation.
  • Carry RPC stop authorization into queued systemd cancellation (P1) - A browser sessions.processes.stop request validates its session-mutation authority in session-processes.ts, but stopBackgroundProcess forwards no assertion. This new branch captures an agent-tool guard, which does not contain that RPC's authorization, then queues a worker write and systemctl stop. If session access or requester authority is revoked while that work waits, the systemctl effect still proceeds using only the durable store's lifetime check. Pass the RPC's live authorization through the process-control owner and recheck it immediately before the stop effect.
  • Exclude surviving durable work from the stopped-process marker (P1) - Start a durable background command and gracefully restart the Gateway. listRunningSessions still includes that command, so this unchanged consumer sets hadBackgroundExec:true. Startup consequently tells the resumed agent that its background processes were stopped and should be rerun, even though this PR keeps the unit alive and restores its handle. Distinguish durable processes when creating the marker, preserving the stopped warning for ordinary processes and correct behavior for mixed sessions.
  • Update startup fixtures for the durable lifetime sidecar (P2) - On Linux this inserts durable-processes before the existing lifetime sidecars. The unchanged startup tests select the first published sidecar as update-check cleanup and expect the previous sidecar count, so exact-head CI fails at server-startup-post-attach.test.ts:775 and :976. Update those consumers to select cleanup ownership by name and account for the new durable owner while preserving their lifecycle assertions.
  • Resolve security concern: Approved script identity can drift before durable launch - The durable adapter introduces awaited preparation after the last byte-binding check; synchronous policy checks do not establish that the executable or script still matches the approved content.
  • Resolve security concern: Queued browser stop loses its request-specific authority - The final systemctl invocation receives store liveness and an agent-tool guard rather than the browser RPC's current session-mutation authorization.
  • Explain or restore the original intent of Graceful restart background-process warning - 9344233: The restart redesign deliberately stops background processes and tells resumed sessions to inspect and replace them.
  • Explain or restore the original intent of Mutable script and cwd approval binding - ab5611f: Approval authorizes reviewed script bytes and canonical paths, with revalidation at the final owned launch boundary.

Findings

  • [P1] Preserve the final mutable-file preflight for durable launches — src/agents/bash-tools.exec-runtime.ts:580-583
  • [P1] Carry RPC stop authorization into queued systemd cancellation — src/agents/bash-process-control.ts:69-70
  • [P1] Exclude surviving durable work from the stopped-process marker — src/gateway/session-restart-resume.ts:171-175
  • [high] Approved script identity can drift before durable launch — src/agents/bash-tools.exec-runtime.ts:582
  • [high] Queued browser stop loses its request-specific authority — src/agents/bash-process-control.ts:70

Provenance

  • Graceful restart background-process warning changes intended behavior without addressing why it exists (9344233: The restart redesign deliberately stops background processes and tells resumed sessions to inspect and replace them.)
  • Mutable script and cwd approval binding changes intended behavior without addressing why it exists (ab5611f: Approval authorizes reviewed script bytes and canonical paths, with revalidation at the final owned launch boundary.)

Tests

  • Missing end-to-end proof: Complete the real-systemd restart/adoption, process-tool tree-stop, downtime-completion, refusal and descendant-limit scenarios, including final-effect denial after approval drift or authorization revocation.
Agent review details

How this fits together

The exec pipeline prepares and authorizes commands, the process registry owns their lifecycle, systemd hosts durable process trees, and shared-state workers persist restart facts for later observation and session completion.

flowchart TD
  A[Session exec request] --> B[Exec policy and approval]
  B --> C[Process registry]
  C --> D[Systemd user unit]
  C --> E[Shared state worker]
  E --> F[Restart adoption]
  F --> C
  D --> G[Output and terminal status]
  G --> C
  C --> H[Process controls and session completion]
Loading

Technical review

Best possible solution:

Keep the existing registry and shared-state owners, preserve final launch and stop authorization, and distinguish surviving durable work in restart snapshots.

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

Source establishes the ordinary restart limitation and the introduced integration failures; exact-head CI independently confirms the startup-fixture mismatch, but this review ran no target code.

Is this the best way to solve the issue?

Using systemd behind the existing registry is coherent, but the cutover must include restart snapshots and preserve authorization through the new asynchronous launch and stop paths.

Full review comments:

  • [P1] Preserve the final mutable-file preflight for durable launches — src/agents/bash-tools.exec-runtime.ts:580-583
    For an approved command such as sh /workspace/job.sh, the asynchronous approval binding check runs before startDurableExecProcess. The new path then awaits manager discovery, filesystem work, persistence, and show-environment before launching systemd-run. The supplied beforeSpawn callback only checks current policy; it does not rerun the script-byte or cwd binding. Replacing job.sh during those waits therefore executes different bytes under the earlier approval. Carry the existing asynchronous binding revalidation to the final systemd launch boundary after preparation.
    Confidence: 0.94
    Late finding: first raised on code an earlier review cycle already covered.
  • [P1] Carry RPC stop authorization into queued systemd cancellation — src/agents/bash-process-control.ts:69-70
    A browser sessions.processes.stop request validates its session-mutation authority in session-processes.ts, but stopBackgroundProcess forwards no assertion. This new branch captures an agent-tool guard, which does not contain that RPC's authorization, then queues a worker write and systemctl stop. If session access or requester authority is revoked while that work waits, the systemctl effect still proceeds using only the durable store's lifetime check. Pass the RPC's live authorization through the process-control owner and recheck it immediately before the stop effect.
    Confidence: 0.96
    Late finding: first raised on code an earlier review cycle already covered.
  • [P1] Exclude surviving durable work from the stopped-process marker — src/gateway/session-restart-resume.ts:171-175
    Start a durable background command and gracefully restart the Gateway. listRunningSessions still includes that command, so this unchanged consumer sets hadBackgroundExec:true. Startup consequently tells the resumed agent that its background processes were stopped and should be rerun, even though this PR keeps the unit alive and restores its handle. Distinguish durable processes when creating the marker, preserving the stopped warning for ordinary processes and correct behavior for mixed sessions.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Update startup fixtures for the durable lifetime sidecar — src/gateway/server-startup-post-attach.ts:133-135
    On Linux this inserts durable-processes before the existing lifetime sidecars. The unchanged startup tests select the first published sidecar as update-check cleanup and expect the previous sidecar count, so exact-head CI fails at server-startup-post-attach.test.ts:775 and :976. Update those consumers to select cleanup ownership by name and account for the new durable owner while preserving their lifecycle assertions.
    Confidence: 1
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Restart and suspension treatment of background processes changes intended behavior with a stated reason (02cd9bf: Ordinary live background processes block suspension and safe restart until their owner confirms exit.)
  • Live requester completion authority keeps the original intent (aa8b35b: Live completions retain only the originating requester's current authority; restart recovery does not restore that capability.)
  • Secret-egress grant lifetime keeps the original intent (3a036bd: Each supervised command owns a proxy grant that ends on cancellation, exit, or Gateway shutdown.)

Testing

Proof path: shipped entry point.

Security

Needs attention: The new asynchronous execution paths leave gaps in final script-binding checks and RPC stop authorization.

Evidence

Security concerns:

  • [high] Approved script identity can drift before durable launch — src/agents/bash-tools.exec-runtime.ts:582
    The durable adapter introduces awaited preparation after the last byte-binding check; synchronous policy checks do not establish that the executable or script still matches the approved content.
    Confidence: 0.94
  • [high] Queued browser stop loses its request-specific authority — src/agents/bash-process-control.ts:70
    The final systemctl invocation receives store liveness and an agent-tool guard rather than the browser RPC's current session-mutation authorization.
    Confidence: 0.96

What I checked:

  • Reviewed revision and clean checkout: Reviewed the introduced merge-base-to-head changes at 34c9db1; the final working-tree status was clean, and no target code or tests were executed. (34c9db137824)
  • Maintainer direction and recorded tradeoffs: The full PR body and comments establish maintainer direction and explicitly accept opt-in Linux support, noninteractive execution, unbounded raw log growth until retention, launch-time credentials, refusal of proxy grants, and same-user visibility of unit environment properties. (34c9db137824)
  • Current main still lacks durable process ownership: Current main retains the in-memory process registry and counts all promoted background processes; it has no durable systemd launch or adoption path. (src/agents/bash-process-registry.ts:573, 54def34074cc)
  • Graceful restart still classifies surviving processes as stopped: The restart snapshot sets hadBackgroundExec for every running process, and resume appends a stopped-process instruction. The earlier redesign explicitly assumed background processes would not survive replacement: refactor: resume running sessions after graceful restarts #185730. (src/gateway/session-restart-resume.ts:175, 34c9db137824)
  • Existing approval-binding invariant: The existing security repair requires canonical script bytes and cwd to be revalidated at the last owned launch boundary; durable launch introduces manager queries and persistence after that asynchronous preflight. Original rationale: fix(security): prevent approved scripts from changing before execution #124858. (src/agents/bash-tools.exec-runtime.ts:582, 34c9db137824)
  • Queued stop authority: The local process-stop RPC holds request and session-mutation assertions, but stopBackgroundProcess does not pass them into cancellation; the new durable branch queues persistence and systemctl execution using a tool-context guard instead. (src/agents/bash-process-control.ts:70, 34c9db137824)

Likely related people:

  • Joseph Turian: Raw commit bd31f8c adds src/agents/bash-tools.process.ts:536 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bd31f8c581e7; files: src/agents/bash-tools.process.ts)

PR surface

Source +1037, Tests +774, Docs +133, Other +13. Total +1957 across 48 files. Added test files: 6.

View PR surface stats
Area Files Added Removed Net
Source 29 1375 338 +1037
Tests 11 795 21 +774
Docs 6 151 18 +133
Config 0 0 0 0
Generated 0 0 0 0
Other 2 13 0 +13
Total 48 2334 377 +1957

Review metrics

Metric Value Why it matters
Production versus test growth Production +1,014/-60; tests and support +795/-21 Excluding generated schema artifacts, growth provides the systemd adapter, persistence, adoption, and distinct lifecycle contracts; no unnecessary parallel process owner was identified.
New execution parameter 1 optional boolean: durable The new model-facing parameter defaults to ordinary execution and requires explicit background or yield behavior.
Persistent storage addition 1 first-use table; no schema-version bump durable_background_processes stores registry restart facts through existing schema admission and worker operations.

Labels

Label changes:

  • add P2: This is an opt-in execution improvement limited to supported Linux Gateways, with concrete integration defects to repair.
  • add merge-risk: 🚨 session-state: Graceful restart currently describes surviving durable processes as stopped, potentially prompting duplicate work.
  • add merge-risk: 🚨 security-boundary: Durable launch delays mutable-file preflight, and queued RPC cancellation does not carry its session-mutation authorization to systemctl.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is an opt-in execution improvement limited to supported Linux Gateways, with concrete integration defects to repair.
  • merge-risk: 🚨 security-boundary: Durable launch delays mutable-file preflight, and queued RPC cancellation does not carry its session-mutation authorization to systemctl.
  • merge-risk: 🚨 session-state: Graceful restart currently describes surviving durable processes as stopped, potentially prompting duplicate work.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed October 30, 2026, 12:02 PM ET / 16:02 UTC.

Select sidecar cleanup owners without depending on Linux publication order, keep durable persistence outside the worker-free startup fixture, and wait for the readiness owner. Exercise the Linux branch on every host. All 77 startup tests pass after reproducing the ownership failure, targeted checks pass, and final P2 autoreview is scoped-clean. The separate tool-cancelled delegation assertion fails identically on main at 6a550b0.

@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: 073bb5c448

ℹ️ 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 on lines +307 to +310
finalize: () =>
enqueue(async () => {
record.notificationSettled = true;
await persistence.upsert(record);

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 Retire durable state after removing a running process

When process remove targets a running durable process, the process tool sets backgrounded = false and removes its visible registry entry. On exit, moveToFinished consequently skips finished-session retention, but this finalizer still persists the durable record. Since durable.remove() is only called when a finished registry entry is deleted, the SQLite row and log never expire during the current Gateway lifetime, and the removed process reappears if the Gateway restarts before its retention deadline. Retire the durable record and log after a hidden process finishes settling instead of relying exclusively on finished-session eviction.

Useful? React with 👍 / 👎.

The optional durable process table raises the complete state-port inventory from 135 to 136 tables. Preserve the existing round-trip, exact and sanitized backup, optional-fragment, and schema-drift coverage. Reproduced the count failure against isolated PostgreSQL 17, then passed both state-port tests in 66.07 seconds. Scoped lint/format and independent P2 autoreview pass.
@steipete
steipete enabled auto-merge (squash) October 30, 2026 16:40
@steipete
steipete disabled auto-merge October 30, 2026 16:43
@steipete
steipete merged commit 20c1a15 into main Oct 30, 2026
164 of 167 checks passed
@steipete
steipete deleted the codex/durable-session-processes branch October 30, 2026 17:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…penclaw#188465)

* feat(exec): add durable session background processes

* docs(exec): state durable unit environment exposure

* test(gateway): isolate durable startup lifecycle fixtures

Select sidecar cleanup owners without depending on Linux publication order, keep durable persistence outside the worker-free startup fixture, and wait for the readiness owner. Exercise the Linux branch on every host. All 77 startup tests pass after reproducing the ownership failure, targeted checks pass, and final P2 autoreview is scoped-clean. The separate tool-cancelled delegation assertion fails identically on main at f5d6eb2.

* test(state): include durable processes in PostgreSQL inventory

The optional durable process table raises the complete state-port inventory from 135 to 136 tables. Preserve the existing round-trip, exact and sanitized backup, optional-fragment, and schema-drift coverage. Reproduced the count failure against isolated PostgreSQL 17, then passed both state-port tests in 66.07 seconds. Scoped lint/format and independent P2 autoreview pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts security-sensitive-changed size: XL 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.

1 participant