Skip to content

fix(process): retain owned command cleanup diagnostics - #1907

Merged
N0zoM1z0 merged 1 commit into
mainfrom
fix/1856-owned-command-cleanup-ledger
Oct 11, 2026
Merged

N0zoM1z0 merged 1 commit into
mainfrom
fix/1856-owned-command-cleanup-ledger

Conversation

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Summary

An interrupted owned command can retain cleanup ownership while losing the diagnostics explaining which member could not be verified. Preserve that verification ledger through the supervisor and command failure, and identify the observed token mismatch in its summary. Fixes #1856.

Problem and expected behavior

A source-owned parent starts a child with a different ownership token in the same process group. On cancellation or timeout, cleanup correctly refuses to signal the mixed-ownership group. Its lower result identifies the child's PID and run-token-mismatch, but the supervisor previously discarded those fields and the command returned only process tree contains an unowned or PID-reused process.

Callers should receive the actual verification failures and retained owner, without treating an ordinary token mismatch as proof of PID reuse or acquiring additional authority.

Change and scope

  • Name the existing failed-cleanup representation and preserve it as optional cleanupResult on incomplete supervisor results and owned-command failures, including cleanup revalidation after launcher grace. Member failures, diagnostic reasons and sweep uncertainty remain intact.
  • Describe token mismatches with deterministic, deduplicated PID coordinates. Existing callers retaining the summary receive useful coordinates too.
  • Keep the existing fail-closed signal decisions, command failure reason/output, resource identities and retryable retained supervisor. Once the fixture cooperatively exits, a subsequent verified stop settles normally.

Contract and boundary impact

  • Semantic owner and earliest changed stage: process ownership verification produces the summary; the supervisor retains its complete failure result rather than reducing it to text.
  • CLI and MCP/tool-catalog contract: no advertised schema or operation changes. Failed-cleanup summaries become more specific; the shared process helper gains additive diagnostic fields.
  • Provider, bridge, target-format, or platform compatibility: no protocol or target-format change. Cleanup records retain their existing semantics.
  • Evidence, artifact, provenance, or reconstruction contract: no Evidence format change; captured command output and original interruption reason are preserved.
  • Process execution, authorization, cleanup, or containment impact: no new signaling authority. Unverified members remain unsignaled and ownership remains retained until a verified stop succeeds.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: actual parent/child cancellation and timeout cases; a controlled adapter case for a failed cleanup recheck retaining both member failures and sweep uncertainty. Existing ownership assertions now expect the factual token-mismatch summary.

  • Base reproduction: both new real process cases fail on the base because OwnedCommandFailure.cleanupResult is absent, while the lower cleanup result contains the exact child failure. Their cooperative cleanup still completes, so the tests leave no fixture processes behind.

  • User-visible output: the summary identifies the failed PID coordinates; process callers can inspect cleanupResult.failures for run-token-mismatch, environment-unreadable or process-identity-unavailable, and cleanupResult.unverified for sweep uncertainty.

  • Remaining proof gaps: no provider-specific leak, PID reuse or successful full client-family cleanup is inferred from this fixture. The recheck's unavailable-identity observation is deliberately injected; the parent/child token mismatch is observed through the real operating-system boundary.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- tests/boundary/process/ownedCommand.test.ts tests/boundary/process/providerProcess.test.ts src/process/ProcessOwnership.test.ts src/process/ProcessOwnership.part2.test.ts src/process/ProcessOwnership.part3.test.ts src/process/ProcessOwnership.validation.test.ts src/process/ProcessOwnership.identity.test.ts src/process/ProcessOwnership.observation.test.ts — 107 tests passed, one platform-conditional test skipped, eight files passed.
  • Final affected boundary reruns — passed after test-only type narrowing and ready-fixture PID validation.
  • Actual built-runtime helper on a source-owned nested-token process fixture — retained per-member diagnostics, unsignaled unresolved group and later verified settlement passed.
  • npm run check — passed.
  • npm run verify:test-discovery and git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; cleanupResult is additive and absent when no structured failure was produced. Consumers should use typed verification reasons instead of parsing historical summary text.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux process ownership and supervision exercised. Other operating systems and real analysis engines were not locally exercised for this change.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: preserve the existing token/identity checks, authority refusal and retained ownership. No ambient environment or token values are persisted. Verification ran serially under one CPU and 3 GiB; no binaries or generated outputs are committed.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed (none changed).
  • User-visible CLI/MCP changes include representative output (shared failure summary described above).
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Preserve per-member verification failures and sweep uncertainty across
supervisor stop and owned-command failures. Report the observed token
mismatch with its PID coordinates instead of implying PID reuse.

Keep unresolved ownership unsignaled and retain the supervisor for a later
verified stop. Exercise cancellation, timeout and cleanup revalidation with
source-owned process fixtures and cooperative settlement.

Closes #1856

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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-11T16:53:29.816567Z 33cf4c3 PR opened
ℹ️ 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.

@N0zoM1z0
N0zoM1z0 merged commit 38539a2 into main Oct 11, 2026
31 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/1856-owned-command-cleanup-ledger branch October 11, 2026 17:00
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Diagnose and settle retained owned-command cleanup after timeout

2 participants