Skip to content

fix(process): forward-port startup cleanup and shared lineage fixes - #192386

Merged
RomneyDa merged 5 commits into
mainfrom
fix/forward-port-1010-process
Nov 5, 2026
Merged

RomneyDa merged 5 commits into
mainfrom
fix/forward-port-1010-process

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Problem

Process startup failures discovered during the 2026.10.10 stable release cycle could be hidden by cleanup errors, or cleanup could be declared uncertain before a loaded native process tree had time to settle. A source-host/dist-plugin combination could also load separate inherited-lineage bindings.

This is the process-only split of #191830. It targets main directly and does not depend on the other split PRs.

Solution

  • Preserve the bounded five-second startup cleanup window, keeping the original startup failure when cleanup succeeds.
  • Keep the startup failure first when cleanup also fails, retaining cleanup uncertainty and its restart guidance as secondary evidence. The refused-launch hard-deadline test now expects an AggregateError; the cleanup fence is unchanged.
  • Share inherited process lineage through the existing global-singleton owner across module copies.

The original commit attribution and release references are preserved: ba42adbc70, e51fa6420f, and 7dc3350cb9 from release/2026.10.10.

Scope and regression budget

The simplify pass retains the existing process/relay owners and distinct tests for delayed cleanup, startup-vs-cleanup error precedence, and duplicate-module lineage. There is no new manager or alternate cleanup path. Product delta is +62/-24 lines; net test growth is 92 lines. A dedicated 92-line test allocation covers exactly this split's net regression growth; the original aggregate allocation is not copied.

Evidence

  • Focused process suites: 42/42 tests passed across three files (147.51s wall including a 115s cold worker compilation).
  • After the review-driven fake-clock correction, owned-stdio.test.ts: 4/4 passed in 2.45s wall (5ms tests).
  • Scoped oxfmt check and git diff --check: passed.
  • Core typecheck attempted; fails in untouched src/agents/agent-bundle-mcp-materialize.ts and mcp-metadata.ts (missing exported McpCatalogTool and optional UI metadata versus required Pick). Scoped lint is blocked by the same declaration-emitter prerequisite. These files are unchanged from the pinned main base.
  • Local ClawSweeper reviewed base 34007820fa2c through c838f5525d7f: no production or security defects; its exact test-budget allocation and deterministic-clock findings are addressed. The later changes only add the scoped allocation and replace real waits with fake-clock advancement.
  • CI duration: pending.

Original #191830 recorded failing-without-fix regression evidence for these process changes. This split preserves the production hunks unchanged; the mocked timing regression now advances a fake clock rather than waiting in real time. Native Linux/Windows live-process lanes have not been rerun locally; broad/platform coverage remains PR CI work.

Split CI status

  • Observed CI failure is inherited from main 34007820fa2c: missing McpCatalogTool export in mcp-metadata.ts and consequent optional UI metadata errors. That file and agent-bundle-mcp-materialize.ts / agent-bundle-mcp-types.ts are byte-identical to the base; SDK declaration preparation propagates the same error into build/boundary/lint lanes.
  • Test-line ratchet retains the pre-split 47-line deficit: baseline total 6,444,916 versus ceiling 6,444,869. This split’s dedicated allocation covers its exact positive test-line delta; inflating it would violate the allocation checker.
  • Ready for review does not mean green CI or ready to merge. Remaining broad checks are still running; no merge requested.

Exact-head CI attribution audit

Audited 2026-11-04 at 82fcb528584d78b1d31687fc6f6153a0db0a5a2e. Failed job logs were inspected individually, not inferred from their names.

The MCP failures are inherited from base 34007820fa2c: src/agents/mcp-metadata.ts, agent-bundle-mcp-materialize.ts, and agent-bundle-mcp-types.ts have identical Git blob IDs at base and PR head. The missing McpCatalogTool export and consequent optional-property errors propagate through SDK declarations into boundary/build/lint/type lanes.

The test-line ratchet is also inherited: this PR offsets its exact positive test-line delta, and its job still exceeds the adjusted ceiling by the same 47 lines already present at base (6,444,916 vs 6,444,869). No baseline increase or unrelated repair is included.

Failed check Attribution
checks-fast-baseline-ratchets Inherited 47-line test-budget deficit
check-additional-extension-package-boundary Inherited MCP declaration/type failure
check-prod-types Inherited MCP declaration/type failure
check-test-types Inherited MCP declaration/type failure
check-test-types-core-1 Inherited MCP declaration/type failure
check-test-types-core-2 Inherited MCP declaration/type failure
check-test-types-core-3 Inherited MCP declaration/type failure
check-test-types-core-4 Inherited MCP declaration/type failure
check-test-types-core-5 Inherited MCP declaration/type failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure
openclaw/ci-gate Aggregate of failed or downstream-skipped prerequisite jobs above; not an independent runtime failure

Cancelled dispatch jobs are orchestration cancellations, not passing tests or additional source defects. CI remains red; this section explains the failures rather than claiming green.

Rebase onto current main

Rebased onto a1f99240c8367a0e012b401bed71831a3cc65026, including merged Goal-test correction #192387. New candidate: 2e37fc63ad8e028ebafeb8dd467366430aada830. This PR still targets main independently.

Verified the complete rebased tree equals the previous PR patch integrated with that main snapshot. No new behavior was added during rebase. Prior test and CI attribution sections remain evidence for their named old revisions; fresh CI on this head is pending, not claimed green.

@clawsweeper

clawsweeper Bot commented Nov 3, 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.

@RomneyDa
RomneyDa marked this pull request as ready for review November 3, 2026 23:36
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR extends startup cleanup waiting, preserves the original startup error alongside cleanup failures, and shares inherited lineage across module copies.

Example: A stdio server fails to start and its admitted process cleanup completes after 750 ms.

  • Before: The 500 ms wait reports cleanup uncertainty despite subsequent successful cleanup.
  • After: The five-second bounded wait observes successful cleanup and reports the original startup failure.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with distinct regression coverage and no identified correctness defect; behavioral validation is harness-based and CI attribution remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied focused tests exercise cleanup ordering and duplicate-module state, while the body expressly leaves native live-process qualification unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Startup failures can lose their useful diagnosis, valid delayed cleanup can be reported uncertain, and duplicate module graphs can miss the inherited native process owner.
Reason: The maintainer-authored direction restores release-tested behavior while preserving cleanup fencing and existing caller contracts.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs cleanup and lineage behavior still present on main; no actionable introduced defect was found, but required CI remains red.

Priority: P2
Reviewed head: 82fcb528584d78b1d31687fc6f6153a0db0a5a2e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate delayed native startup cleanup and shared source/dist lineage through a shipped entry point on this head.
Agent review details

How this fits together

MCP, LSP, and command execution use the shared process adapters, which accept launch parameters and return readiness, output, exit results, and independently confirmed cleanup.

flowchart TD
  A[MCP LSP and command callers] --> B[Owned stdio and child adapter]
  B --> C[Service child relay host]
  D[Shared inherited lineage] --> C
  C --> E[Native process owner]
  E --> F[Command and descendants]
  E --> G[Startup and cleanup results]
  G --> B
Loading

Technical review

Best possible solution:

Land this focused forward-port through the existing process owners once the required CI failures are resolved or independently attributed.

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

Main's 500 ms wait demonstrably misclassifies a cleanup promise settling after 750 ms; source also shows startup errors being displaced by cleanup rejection and lineage bindings isolated per module instance.

Is this the best way to solve the issue?

The patch is a small, coherent repair: it adjusts the existing bounded wait, retains both failures, and replaces module-local lineage state with the existing singleton mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 57c207777674.

Provenance checked

  • Owned stdio startup cleanup changes intended behavior with a stated reason (bcef3b3: Require confirmed resource cleanup before releasing owned work; later cleanup work preserved the separate startup guard.)
  • Relay startup error ordering keeps the original intent (69ff526: Use rejection status rather than undefined sentinels while retaining acknowledgment and cleanup waits.)
  • Inherited lineage state changes intended behavior with a stated reason (8277325: Carry process lineage into descendant launches; native owner selection was subsequently added by 2aed866.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8277325 adds src/process/supervisor/inherited-process-lineage.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8277325ccf1b; files: src/process/supervisor/inherited-process-lineage.ts)
  • Vincent Koc: Raw commit faad1d4 adds src/process/owned-stdio.ts:79 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: faad1d457de8; files: src/process/owned-stdio.ts)
  • Jason (Json): Raw commit b4b499a adds src/process/supervisor/service-child-relay-host.test.ts:178 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: b4b499acc6a3; files: src/process/supervisor/service-child-relay-host.test.ts)

PR surface

Source +38, Tests +92, Other +2. Total +132 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 62 24 +38
Tests 3 100 8 +92
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 8 164 32 +132

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs bounded process-startup diagnostics and lineage sharing without evidence of a widespread current outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-04T00:00:47.717Z sha 82fcb52 :: needs maintainer review before merge. :: none

Reviewed November 4, 2026, 5:11 PM ET / 22:11 UTC (Revision 2).

@RomneyDa

RomneyDa commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
roboclaw-bot and others added 5 commits November 4, 2026 17:48
Co-authored-by: RomneyDa <[email protected]>

Forward-port of ba42adb from release/2026.10.10.
When an owned stdio process failed to start and its cleanup also failed,
the relay host rethrew the cleanup rejection instead of the anchor's
startup error, and owned stdio replaced the message again with "stdio
startup cleanup did not confirm closure". The Docker CLI backend lane
only showed the identity-loss cleanup error, never why startup failed.

Throw the startup failure first with the cleanup failure as a secondary
AggregateError member, and lead the owned stdio message with the startup
failure plus the next step (restart the Gateway before retrying).

On main this also changes the refused-launch hard-deadline case from
#187137: the refusal now leads and the hard-deadline cleanup failure
follows as the secondary member; the cleanup fence itself is unchanged.

Forward-port of e51fa64 from release/2026.10.10.
The CLI backend live lane runs its Gateway from source under vitest while
bundled plugins load from dist. The anthropic plugin's openclaw/plugin-sdk
import is natively aliased to the source SDK, so src/process/supervisor
loads a second time outside vitest's graph. That copy never saw the test's
bindInheritedNativeProcessOwner(dist anchor) and fell back to the source
anchor.

Inherited lineage fds and the native process owner are process state, so
keep them in one global singleton slot that every module copy shares.

Forward-port of 7dc3350 from release/2026.10.10.
@RomneyDa
RomneyDa force-pushed the fix/forward-port-1010-process branch from 82fcb52 to 2e37fc6 Compare November 5, 2026 01:50
@RomneyDa

RomneyDa commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Stronger local real-process proof (2026-11-04)

Tested PR head 2e37fc63ad8e028ebafeb8dd467366430aada830 on macOS arm64. Launcher: Node v26.12.1; the repository wrapper selected its pinned OpenClaw Bun/Vitest runtime for the process shard. These are real OS child processes, sockets, IPC, process groups, and production relay/anchor code—not mocked adapters or fake clocks.

PR-specific before/after proof

The pre-fix control used the same head checkout and identical harness, replacing only the four changed production files with their versions from base a1f99240c8367a0e012b401bed71831a3cc65026. This is a controlled removal of this PR's production fixes, not a claim that the entire base checkout was tested. All four files were then restored byte-for-byte and the head replayed.

Real-process scenario Pre-fix control PR head
Native owner + live socket FD bound through an independently transpiled second module copy, then consumed by the production launch path FAIL: no bytes received on the inherited socket PASS: actual native owner launched; inherited socket delivered actual-inherited-socket; command output drained and owner process group gone
Actual missing executable (ENOENT) + deliberately withheld native-anchor closing receipt FAIL: cleanup error replaces the expected primary error chain PASS: OS ENOENT remains first, cleanup failure remains separate, and the user-facing error still reports unconfirmed cleanup / restart required
Admission revoked after the real native child reports ready; its genuine closing frame is delayed 900 ms FAIL: returns generic cleanup uncertainty at 501 ms PASS: waits beyond the former 500 ms budget, returns the same original admission Error, and verifies the owner process group is gone
Ordinary real ENOENT, followed by another owned child launch and confirmed shutdown PASS PASS

Pre-fix result: 3 failed / 1 passed, all failures at the expected behavioral assertions—not setup failures. Initial candidate run: 4/4 passed (delayed cleanup: 909 ms). Final restored-head combined replay: 12 passed, 2 Windows-only skipped, across six test files.

The missing-receipt case intentionally remains a cleanup failure: eventual OS process-group disappearance is observed separately for fixture retirement; it is not substituted for the missing protocol certificate. The longer startup wait does not turn unconfirmed cleanup into success.

Existing native integration coverage replayed

  • Real stdin EOF shutdown drains both protocol stdout and 8,192 UTF-8 diagnostic lines before completion.
  • Real private-input backpressure: 512 KiB on each output stream while 1 MiB private input is pending, including consume and cancel cases.
  • Native-owner selection, output/closing receipts, lineage EOF, and process-group extinction.
  • Refusal before launch leaves a later shutdown usable; refusal after the launch frame retains the shutdown fence.
  • Root exit with a background child holding stdio, with both service-relay modes.

Reproduction

Save the disposable harness below as src/process/supervisor/pr192386-local-proof.real.test.ts in a checkout at the tested head, then run:

node scripts/run-vitest.mjs \
  src/process/supervisor/pr192386-local-proof.real.test.ts \
  src/process/owned-stdio.real.test.ts \
  src/process/supervisor/supervisor.prelaunch-initiation.real.test.ts \
  src/process/supervisor/service-child-relay-host.readiness.real.test.ts \
  src/process/supervisor/service-child-relay.native-owner.test.ts \
  src/process/supervisor/supervisor.root-exit.real.test.ts \
  --maxWorkers=1

For the pre-fix control in a disposable checkout, replace these files from the stated base, run only the new harness, then restore the head versions:

  • src/process/owned-stdio.ts
  • src/process/supervisor/inherited-process-lineage.ts
  • src/process/supervisor/service-child-relay-host.ts
  • src/process/supervisor/service-child-relay-retirement.ts

Limits: this is local process-component integration proof, not a full interactive Gateway/provider session, packaged plugin release test, or native Linux/Windows qualification. The duplicate-module test independently transpiles the real module into a second ESM graph; it does not install a shipped plugin. The missing/delayed closing frames are explicit fault injection in a temporary wrapper around the real anchor. No mocked completion receipts or fake timers are used. Two Windows-specific tests were skipped; no Linux/Windows result is claimed. PR source/head is unchanged; the disposable harness is included here for review/reproduction rather than added to permanent test allocation.

Disposable live-proof harness (complete)
import { once } from "node:events";
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { stripTypeScriptTypes } from "node:module";
import net from "node:net";
import os from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { expect, it } from "vitest";
import { resolveRuntimeProcessEntrypointUrl } from "../../infra/runtime-process-url.js";
import { closeOwnedStdioProcess, createOwnedStdioProcess } from "../owned-stdio.js";
import { bindInheritedNativeProcessOwner } from "./inherited-process-lineage.js";
import { isOwnedProcessGroupGone } from "./service-child-group-ownership.js";

async function fixture() {
  const root = await mkdtemp(path.join(os.tmpdir(), "pr192386-live-"));
  const receipt = path.join(root, "receipt.json");
  const owner = path.join(root, "owner.mjs");
  const anchor = resolveRuntimeProcessEntrypointUrl("serviceChildGroupAnchor").href;
  return { root, receipt, owner, anchor, dispose: async () => {
    const record = await readFile(receipt,"utf8").then(JSON.parse, error => { if(error.code!=="ENOENT") throw error; });
    if(record) {
      const deadline=Date.now()+6000;
      while(!isOwnedProcessGroupGone(record.pid) && Date.now()<deadline) await new Promise(resolve=>setTimeout(resolve,20));
      expect(isOwnedProcessGroupGone(record.pid)).toBe(true);
    }
    await rm(root, { recursive: true, force: true });
  } };
}

it("real launch consumes native owner and live socket FD bound by a separately transpiled module", async () => {
  const f = await fixture();
  const server = net.createServer();
  server.listen(path.join(f.root, "lineage.sock"));
  await once(server, "listening");
  const connected = once(server, "connection");
  const client = net.connect(path.join(f.root, "lineage.sock"));
  await once(client, "connect");
  const [peer] = await connected as [net.Socket];
  let received = "";
  peer.on("data", data => { received += data.toString(); });
  const fd = (client as unknown as { _handle: { fd: number } })._handle.fd;
  const source = await readFile(path.join(process.cwd(), "src/process/supervisor/inherited-process-lineage.ts"), "utf8");
  const singleton = await readFile(path.join(process.cwd(), "src/shared/global-singleton.ts"), "utf8");
  await writeFile(path.join(f.root, "singleton.mjs"), stripTypeScriptTypes(singleton));
  await writeFile(path.join(f.root, "lineage.mjs"), stripTypeScriptTypes(source).replace("../../shared/global-singleton.js", "./singleton.mjs"));
  const duplicate = await import(/* @vite-ignore */ pathToFileURL(path.join(f.root, "lineage.mjs")).href);
  await writeFile(f.owner, `import { writeFileSync, writeSync } from "node:fs";
await import(${JSON.stringify(f.anchor)});
process.prependListener("message", start => {
 if (start.type !== "start") return;
 const fds = start.parentLineageFds ?? [];
 writeFileSync(${JSON.stringify(f.receipt)}, JSON.stringify({pid:process.pid,fds}));
 for (const fd of fds) writeSync(fd, "actual-inherited-socket\\n");
});`);
  const releaseOwner = duplicate.bindInheritedNativeProcessOwner(pathToFileURL(f.owner).href);
  const releaseFds = duplicate.bindInheritedProcessLineageFds([fd]);
  let child;
  try {
    child = await createOwnedStdioProcess({ argv: [process.execPath, "-e", "process.stdin.resume();process.stdin.on('end',()=>process.stdout.write('real-child-done'))"] });
    let output = "";
    child.onStdout(chunk => { output += chunk; });
    await closeOwnedStdioProcess(child);
    expect(output).toBe("real-child-done");
    expect(received).toBe("actual-inherited-socket\n");
    const record = JSON.parse(await readFile(f.receipt, "utf8"));
    expect(record.fds).toHaveLength(1);
    expect(isOwnedProcessGroupGone(record.pid)).toBe(true);
    console.log("LIVE duplicate-module: inherited socket bytes received; native owner group extinct", record);
  } finally {
    releaseOwner(); releaseFds();
    if (child) await closeOwnedStdioProcess(child, {force:true}).catch(() => {});
    client.destroy(); peer.destroy(); await new Promise<void>(resolve => server.close(() => resolve()));
    await f.dispose();
  }
}, 20_000);

it("real missing executable retains ENOENT and allows a subsequent owned launch", async () => {
  const f = await fixture();
  try {
    await expect(createOwnedStdioProcess({argv:[path.join(f.root, "does-not-exist")]})).rejects.toMatchObject({code:"ENOENT"});
    const child = await createOwnedStdioProcess({argv:[process.execPath, "-e", "process.stdin.resume()"]});
    await closeOwnedStdioProcess(child);
    await expect(child.waitForExtinction!()).resolves.toBeUndefined();
    console.log("LIVE ENOENT: original OS error retained; subsequent real launch and extinction succeeded");
  } finally { await f.dispose(); }
}, 20_000);

it("real ENOENT remains primary when the native anchor closing receipt is fault-injected away", async () => {
  const f = await fixture();
  await writeFile(f.owner, `import { writeFileSync } from "node:fs";
import { Socket } from "node:net";
writeFileSync(${JSON.stringify(f.receipt)}, JSON.stringify({pid:process.pid}));
const originalWrite = Socket.prototype.write;
Socket.prototype.write = function(chunk, ...args) {
 let message; try { message=JSON.parse(String(chunk)); } catch {}
 if (message?.type === "closing") {
   const callback=args.find(arg=>typeof arg==="function");
   if(callback) queueMicrotask(()=>callback());
   return true;
 }
 return originalWrite.call(this,chunk,...args);
};
await import(${JSON.stringify(f.anchor)});`);
  const release = bindInheritedNativeProcessOwner(pathToFileURL(f.owner).href);
  try {
    const error = await createOwnedStdioProcess({argv:[path.join(f.root, "does-not-exist")]}).then(() => { throw new Error("unexpected launch"); }, error => error);
    const primary = error.cause instanceof AggregateError ? error.cause.errors[0] : error;
    expect(primary).toBeInstanceOf(AggregateError);
    expect(primary.errors[0]).toMatchObject({code:"ENOENT"});
    expect(String(primary.errors[1])).toMatch(/cleanup|closing|identity|receipt/i);
    const record = JSON.parse(await readFile(f.receipt, "utf8"));
    const deadline=Date.now()+6000;
    while(!isOwnedProcessGroupGone(record.pid) && Date.now()<deadline) await new Promise(resolve=>setTimeout(resolve,20));
    expect(isOwnedProcessGroupGone(record.pid)).toBe(true);
    console.log("LIVE missing receipt: OS ENOENT is first cause; cleanup remains a separate failure; native group extinct", {message:error.message, primary:primary.errors.map((e:Error)=>e.message), pid:record.pid});
  } finally { release(); await f.dispose(); }
}, 20_000);

it("real admitted child cleanup delayed 900ms retains the original admission error", async () => {
  const f = await fixture();
  await writeFile(f.owner, `import { writeFileSync } from "node:fs";
import { Socket } from "node:net";
writeFileSync(${JSON.stringify(f.receipt)}, JSON.stringify({pid:process.pid}));
const originalWrite = Socket.prototype.write;
Socket.prototype.write = function(chunk, ...args) {
 let message; try { message=JSON.parse(String(chunk)); } catch {}
 if (message?.type === "closing") {
   setTimeout(()=>originalWrite.call(this,chunk,...args),900);
   return true;
 }
 return originalWrite.call(this,chunk,...args);
};
await import(${JSON.stringify(f.anchor)});`);
  const release = bindInheritedNativeProcessOwner(pathToFileURL(f.owner).href);
  const admissionError = new Error("proof: admission revoked after real native ready");
  let calls = 0;
  let failedAt = 0;
  try {
    const error = await createOwnedStdioProcess({
      argv:[process.execPath,"-e","process.stdin.resume()"],
      assertCurrent:()=>{ if(++calls===4) { failedAt=performance.now(); throw admissionError; } }
    }).then(child => closeOwnedStdioProcess(child).then(()=>new Error("unexpected launch")), error => error);
    const elapsed = performance.now()-failedAt;
    console.log("LIVE delayed cleanup", {calls,elapsed,error:error.message});
    expect(calls).toBe(4);
    expect(error).toBe(admissionError);
    expect(elapsed).toBeGreaterThanOrEqual(800);
    const record=JSON.parse(await readFile(f.receipt,"utf8"));
    expect(isOwnedProcessGroupGone(record.pid)).toBe(true);
  } finally {
    release();
    // The 500ms baseline fails before the real delayed receipt arrives. Join fixture retirement.
    const record=JSON.parse(await readFile(f.receipt,"utf8"));
    const deadline=Date.now()+6000;
    while(!isOwnedProcessGroupGone(record.pid) && Date.now()<deadline) await new Promise(resolve=>setTimeout(resolve,20));
    expect(isOwnedProcessGroupGone(record.pid)).toBe(true);
    await f.dispose();
  }
},20_000);

@RomneyDa
RomneyDa merged commit 6d08b6c into main Nov 5, 2026
128 checks passed
@RomneyDa
RomneyDa deleted the fix/forward-port-1010-process branch November 5, 2026 03:11
RomneyDa added a commit that referenced this pull request Nov 5, 2026
Carry the final reviewed changes from #191830, #192378, #192379,
#192380, #192383, #192385, and #192386. Preserve #191838's existing
file-transfer import fix. Adapt Gateway readiness to the release owner
and include the narrow SQLite cold-admission prerequisite from #192586.

Do not carry #192387: its Goal expectation depends on main-only
Stop-to-paused behavior absent from this release.

Retain regression allocations without changing the shared baseline.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…penclaw#192386)

* fix(process): preserve loaded startup cleanup

Co-authored-by: RomneyDa <[email protected]>

Forward-port of ba42adb from release/2026.10.10.

* fix(process): keep stdio startup failures ahead of cleanup errors

When an owned stdio process failed to start and its cleanup also failed,
the relay host rethrew the cleanup rejection instead of the anchor's
startup error, and owned stdio replaced the message again with "stdio
startup cleanup did not confirm closure". The Docker CLI backend lane
only showed the identity-loss cleanup error, never why startup failed.

Throw the startup failure first with the cleanup failure as a secondary
AggregateError member, and lead the owned stdio message with the startup
failure plus the next step (restart the Gateway before retrying).

On main this also changes the refused-launch hard-deadline case from
openclaw#187137: the refusal now leads and the hard-deadline cleanup failure
follows as the secondary member; the cleanup fence itself is unchanged.

Forward-port of e51fa64 from release/2026.10.10.

* fix(process): share inherited process lineage across module copies

The CLI backend live lane runs its Gateway from source under vitest while
bundled plugins load from dist. The anthropic plugin's openclaw/plugin-sdk
import is natively aliased to the source SDK, so src/process/supervisor
loads a second time outside vitest's graph. That copy never saw the test's
bindInheritedNativeProcessOwner(dist anchor) and fell back to the source
anchor.

Inherited lineage fds and the native process owner are process state, so
keep them in one global singleton slot that every module copy shares.

Forward-port of 7dc3350 from release/2026.10.10.

* test(ci): scope process forward-port regression allocation

* test(process): use deterministic startup cleanup clocks

---------

Co-authored-by: roboclaw-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

2 participants