Skip to content

fix(lifecycle): preserve observations and cleanup ownership - #4274

Merged
N0zoM1z0 merged 71 commits into
mainfrom
fix/codebase-lifecycle-audit
Oct 16, 2026
Merged

N0zoM1z0 merged 71 commits into
mainfrom
fix/codebase-lifecycle-audit

Conversation

@morluto

@morluto morluto commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Preserve completed observations, primary failures, and cleanup ownership when cancellation or a failed close races finalization. Fixes #3923, #3927, #3983, #4255, #4256, #4257, #4258, #4260, #4261, #4264, #4266, #4277, and #4289. Related audit: #4227. Raw-partial recovery design follow-up: #4276.

Changes

  • Shared CLI/MCP completion preserves Evidence, typed partial outcomes, original failures, abort reasons, and cleanup ownership through cancellation and finalization. Browser scenario cancellation retains the exact abort reason and validated partial capture after both interrupted actions and final cleanup.
  • Descriptor reads and immutable snapshots retain exact cleanup capabilities. Cleanup leases resolve originating errors after confirmed release, including release before binding. ADB drains children before roots, retains acquisition/publication receipts, and preserves recovered snapshot failure history.
  • Kuna command/export outcomes carry descriptor cleanup explicitly. Cache lookup retries retained owners before reading, blocks unresolved admission, and keeps bounded retry causes. Profile and session inspection share an owner adapter; the file-close port accepts the close capability it actually needs.
  • Artifact analysis errors bind to their retained roots and descriptor scope. TShark/sigrok recovery updates the original returned error, preserves primary causes and partial observations, and skips confirmed process cleanup while retrying snapshots. JADX retirement resolves its reported errors after full release.
  • Main's shared startup owner serves Ghidra/Hopper. Peer cancellation, last-waiter cleanup, owner closure, retry cancellation, queued deadlines, and final-lineage cleanup retain their distinct semantics.
  • Linux publisher helpers borrow operation child scopes and preserve cleanup_failed through admission and launcher status. Windows runners keep native Job Object ownership and command locks through failed tree cleanup; POSIX-only fault controls are platform-scoped.
  • Lifecycle guidance covers explicit cleanup capabilities, blocked admission, late binding, mixed outcomes, and recovery. Website containment and repeated shutdown-event recovery remain included.

Validation

Local toolchain: Node 24.18.0 on macOS arm64. Native CI is identified below.

  • Static checks, cached runtime build, and generated documentation checks passed. The latest publisher/runner selection passed 17 tests with 7 Windows-only skips; publisher cleanup recovery uses the exact retained descriptor and the public Result contract.
  • JADX/Kuna/ADB cleanup retry controls passed 134 tests with 26 platform skips. Separate controls passed 28 Kuna cache tests, 6 uninstall cleanup tests, and 17 shared-transport/build-fixture tests. These selections overlap.
  • Before-fix controls reproduced the retained PCAP errors, second JADX retry error, Kuna mixed-owner and late-binding errors, ADB admission wrapper, Windows executable resolution, and uninstall primary-cause failures.
  • Focused native Windows verification passed 13 tests with 4 POSIX-only skips. This exercised real Job Object retention after leader exit, message/disconnect cancellation, protocol-stdin closure, bare executable resolution, and command shims. Supervisor tests join process exit, pipe closure, and IPC disconnection separately because parent-initiated IPC disconnect can omit Node's aggregate child close event.
  • Browser cancellation controls passed 28 tests across the provider, actual CLI signal subprocesses, MCP, and SDK probe lifecycle. The active-cancellation assertion failed against the prior merge result, which reported success. Freshly compiled artifacts were used for the CLI tests; schema validation and cleanup-failure precedence remain before cancellation classification.
  • Shared application cancellation controls passed 33 tests, including exact Error/object abort-reason identity at completion/admission, retained Evidence, and invalid-output precedence. Both new reason assertions failed against the prior helper. Publisher recovery assertions now check ownership phases rather than fixed retry counts and verify the exact SHA-256 digest; all 7 file-ownership tests passed.
  • Fresh stdio MCP exercise against the current build validated 207 unique tools and 414 schemas. Typed-error recovery, SQLite/blob values, retained Evidence, archive/plist routing, close, and shutdown passed. Runtime identity reports a null commit, so this verifies checkout content rather than hash attestation.
  • JADX cancellation controls passed 38 tests; two failed before the cause fix. Strengthened controls confirm both exact abort/close causes and actual descriptor release. ADB cancellation/publication controls passed 101 tests; four before-fix controls failed. Its shared finalization now constructs cancellation Evidence once and composes it with retained cleanup failures.
  • The macOS session MCP file passed all 9 tests locally. Its multi-roundtrip workflow took about 2 seconds alone but hit a bespoke 10-second CI cap during concurrent native suites; it now inherits the existing 30-second suite budget with all lifecycle assertions retained. The final Apple CI lane passed.
  • Linux PCAP controls passed 47 tests with one Windows-only skip. The real capture lane selects the provider regressions as well as snapshot/descriptor controls.

Historical real Ghidra 12.1.4/JDK21 verification at ea790d43b passed 373 CLI/MCP calls and 52 expected refusals; it was not rerun at the final revision.

Fault-injection regressions use controlled processes and filesystem faults. Native Kuna/JADX and physical ADB were not exercised locally. No complete token/CPU/process-family-memory benchmark was performed. Final-head CI for 9b58709f8 passed all 36 jobs, including all five boundary shards, source/static/docs checks, real browser/Apple workflows, and Windows/macOS/Linux package lanes. The separate real packet-capture, signal-recording, and Go-metadata workflows also passed.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Human readiness and required CI/platform checks completed.
  • Final diff and validation limitations reviewed by the human owner.

Validate completed provider reports before classifying cancellation and preserve Evidence and captured diagnostics. Share MCP recording and delivery across custom observation handlers. Add source-owned completion and public SDK recording controls. Refs #3923, #3927, #4261.
Keep completed Evidence after finalization and through CLI/MCP delivery. Preserve output and cleanup failure precedence. Refs #4254.
Classify final CDP detach and completed scenario cleanup at the provider boundary. Translate completed partials into canonical Evidence for MCP recording, and forward CLI cancellation to passive Electron tools. Refs #4255, #4256, #4257.
Keep startup group-owned while each caller has an independent abortable wait. Await final-owner cleanup and preserve cleanup facts before retrying. Reuse the shared abortable promise helper. Refs #3983.
Retain repeated event requests while unresolved owners need cleanup, and unregister only after success. Verify coalescing and failed-owner retry. Refs #4253.
Bind transfer digests to the exact private input bytes and preserve caller APK names. Retain failed descriptors and private-root owners with typed cleanup evidence; publish captures exclusively after the cancellation cutoff. Refs #4251, #4252.
Always close after attempted verification and keep unexpected primary failures and cleanup details visible. Exercise the production script with controlled imports, including null and undefined throws. Refs #4260.
Use the retained ChildProcess handle for IPC cancellation and parent disconnection. Keep the SQLite lock until observed child close, and include native Windows regressions in the curated CI lane. Native Windows results remain pending. Refs #4258.
Compare resolved targets with resolved repository and site roots. Accept directory aliases while preserving escape checks and keep fixtures within their temporary owner. Refs #4264.
Clarify validation-before-cancellation, independent startup waiter controls, producer and adapter coverage, and repeated shutdown events.
Fixes #4277. Include both snapshot and profile file-resource scopes in the owning status fact, preserving publication receipts and cleanup retry.
Document the observed SDK cancellation boundary and the open design decision in #4276 without promoting raw errors to Evidence.
@morluto
morluto marked this pull request as ready for review October 15, 2026 23:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-16T03:34:28.591990Z 9b58709 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90846dc7da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/run-exclusive-command.mjs Resolved
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The latest changes appear safe to merge; no new blocking issue was found.

Summary

This PR preserves completed observations, original failures, and resource ownership when cancellation races cleanup.

  • Completed Evidence stays attached when cancellation arrives during finalization.
  • Browser cancellations keep completed steps and the exact abort reason.
  • File cleanup retries keep the exact owner and the failure tied to it.
  • Kuna retries retained file owners before admitting more project work.
  • Provider and process cleanup keeps original outcomes while owners are released.
  • Provider startup and shutdown keep cleanup owners with the session that uses them.
  • Lifecycle guidance and verification tools describe the updated cleanup rules.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Provider work finishes] --> B[Close owned child resources]
  B --> C[Close containing workspace]
  C --> D{Caller cancelled?}
  D -->|Yes| E[Keep abort reason and completed Evidence]
  D -->|No| F[Keep original result]
  E --> G{Cleanup failed?}
  F --> G
  G -->|Yes| H[Return error bound to retained owner]
  H --> I[Retry exact owner]
  I --> J[Confirmed release clears pending cleanup]
  G -->|No| K[Return completed outcome]
Loading

Reviews (10) · Last reviewed commit: "test(mcp): use the shared budget for ses..." · Reviewed by Greptile

Comment thread src/kuna/KunaInstallation.ts Resolved
Comment thread src/ghidra/GhidraClient.ts Resolved
Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/adb/AdbProvider.ts Resolved
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

Merged current main (93c620c3e) into the PR branch in 4bc581082; pushed without rewriting existing commits. GitHub now reports MERGEABLE.

Resolved overlapping completion/delivery and file-resource ownership implementations, retained upstream CDP/runner/publisher/JADX cleanup improvements, and removed a duplicate scenario cancellation check introduced by the automatic merge. Reconciled typed Electron partial expectations and retry/concurrency fixture assumptions.

Final Node 24.18.0 checks passed: static checks, build, docs; 8,477 source tests; 803 MCP tests; 351 ownership/provider/verifier tests; 595 browser/scenario/CLI tests; fresh stdio exercise with 207 tools and 414 valid schemas; and real Chrome 155 CLI/MCP verification with owned cleanup complete. Groups overlap and counts are not additive. Native platform skips remain documented in the PR.

CI for the pushed revision is queued. New automated review threads on the prior revision remain open; they are separate from this conflict resolution.

morluto added a commit that referenced this pull request Oct 15, 2026
Report cleanup from the owning snapshot and provider-candidate resource scopes without retrying or starting work. Keep status accurate before a client exists and through cleanup retry.

Refs #4277, #4274

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4bc5810825

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/application/LinuxHopperPublisher.ts Resolved
Comment thread src/adb/AdbProvider.ts Resolved
Comment thread src/application/binary/BinarySession.ts Resolved
Comment thread src/application/LinuxHopper.ts Resolved
@N0zoM1z0
N0zoM1z0 merged commit 1b97b0f into main Oct 16, 2026
44 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/codebase-lifecycle-audit branch October 16, 2026 03:49
kaoru0822-kitauji added a commit that referenced this pull request Oct 16, 2026
Main (#4274) moved KunaTargetCommands#run behind command admission and
cleanup leases. Keep main's structure and pass the configured deadline
in place of reportedTimeoutMs; give main's new hash-owner tests typed
deadlines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kaoru0822-kitauji added a commit to pollychen-lab/rea that referenced this pull request Oct 16, 2026
Main (morluto#4274) rewrote the active-action cancellation test for its new
cancellation semantics (partial observation on AnalysisCancelledError).
This branch had only adjusted that test around main's earlier red run,
so take main's version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cold-atom added a commit to cold-atom/rea that referenced this pull request Oct 16, 2026
Integrate upstream PR morluto#4274, retaining its resource-owner implementations and our distinct process-ownership regressions. Bind the deadline-test fallback to the running phase and preserve validated host cleanup uncertainty alongside filesystem and clock observations.
N0zoM1z0 added a commit that referenced this pull request Oct 16, 2026
Expose exact-path, selected-property, paged reads of retained JavaScript application facts through the shared CLI/MCP analysis view. Preserve original identities, complete row Evidence and partial coverage; retain reproducible real-Joplin and actual-agent measurements, including negative cost results.

Fixes #4190. Part of #4027. Code mode remains deferred by #4091.

Integrate main after #4274. Validation: 114 distinct focused cases across documented invocations, 106 Python cases, full static/docs checks and 18 version-labelled real-application workflows with 9 complete CLI/MCP view parity controls. Preserve two local fixture deadline failures and the unchanged test passing on an available single CPU. Final-head CI passed all 36 jobs after one Windows timeout retry without source changes; both exact-head automated reviews are clear and all review threads resolved. Downloadable apps and raw large Evidence/transcripts are excluded.

Co-authored-by: Kaoru0822 <[email protected]>
Iyanuoluwa007 pushed a commit to Iyanuoluwa007/rea that referenced this pull request Oct 21, 2026
Main (morluto#4274) moved KunaTargetCommands#run behind command admission and
cleanup leases. Keep main's structure and pass the configured deadline
in place of reportedTimeoutMs; give main's new hash-owner tests typed
deadlines.
@morluto morluto added area: runtime Process capture and runtime observation bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment