Skip to content

fix(lifecycle): preserve ownership, cancellation, and cleanup outcomes - #4238

Merged
morluto merged 12 commits into
mainfrom
fix/provider-lifecycle-outcomes
Oct 15, 2026
Merged

morluto merged 12 commits into
mainfrom
fix/provider-lifecycle-outcomes

Conversation

@morluto

@morluto morluto commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Preserve lifecycle facts from provider startup through cancellation and cleanup. A late handshake, cancelled finalization, failed launch, or partially successful close now retains the observations and ownership needed to explain the outcome and recover.

Fixes #4232, #4233, #4005, #4009, #3935, #4240. Related audit: #4227.

Problem and expected behavior

Trigger Previous behavior Result after repair
Hopper authenticates only during cleanup, or its first listener is abandoned Missing application identity, misleading idle/closed status, or a pinned native Python thread Shared handshake identity capture, visible startup/retained cleanup, bounded unauthenticated listener lifetime
SIGINT/abort arrives after workload exit while finalization is pending Successful complete Evidence despite cancellation Typed cancellation with collected observations retained and cleanup reported separately
LLDB denies launch but returns a valid, already-exited process Unknown retained target ownership and cleanup_incomplete Historical creation/PID and positive exit proof remain distinct; capability denial survives confirmed cleanup
Composite children have mixed health/close outcomes Known failure disappears; retry closes an already released child Observed non-idle health survives missing peer coverage; only unresolved cleanup is retried
One-shot provider cleanup fails Completed Evidence or primary diagnostics are replaced by the close failure Canonical cleanup error retains observations, primary diagnostics, resources and owner recovery instructions

Change and scope

The initial eight semantic commits repair the producing boundaries and their consumers. Four review follow-ups keep client, route and run ID together through retirement, failed startup and restoration; preserve original cleanup-resource diagnostics alongside the later close assessment; reuse the canonical native result projection to retain completed facts on finalization failure; and emit typed Flutter/web cleanup errors at their resource owners, preserving paths, causes and recovery actions through service composition. Thirteen CLI command families reuse the existing finishAnalysisCommand; shared error composition preserves cleanup recovery actions. Design/testing docs define the lifecycle invariants, synchronized failure scenarios and atomic-publication exception, with an AGENTS.md pointer.

The initial eight-commit series was replayed on main e2db76801; git range-diff confirms patch equivalence to the audited series. Static checks and focused regressions are revalidated on that base below.

Ordinary fixes within existing provider authorities. A new-provider/protection-recovery scope decision is not applicable. The cross-provider audit remains open for unavailable platforms and engines.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Hopper handshake/listener and cleanup; LLDB bridge/tracer launch and finalization; process-capture finalization; composite ownership; one-shot CLI close/error composition.
  • Contribution scope: existing lifecycle/diagnostic repairs; no new tool, provider, target selection or execution authority.
  • CLI/MCP contract: additive binary_session.cleanup_pending; retained client health/activity/lineage remains visible under its original analysis_run.run_id after target retirement. Confirmed cleanup clears that run; replacements receive a fresh ID. Cancelled finalization returns typed failure; cleanup failure preserves partial observations. Existing named tools and inputs remain unchanged.
  • Compatibility: the LLDB bridge's added exit-proof field is optional at the TypeScript parser; provider-specific readiness/ownership facts remain distinct. Positive owned exit proof resolves target lifetime; other resources still require cleanup and missing proof remains unresolved.
  • Evidence: primary diagnostics, collected observations and cleanup actions survive composition. Existing session-ledger clearing and atomic publication receipts remain unchanged.
  • Authority/cleanup: exact authenticated application identity or owned debugger handle establishes cleanup authority. Attached/unrelated targets are preserved; authenticated idle/native work does not inherit the unauthenticated listener grace period.
  • Generated/package impact: canonical status schema updated and SDK-converted schemas validated. Ignored generated catalogs/build outputs are excluded; no install, release or global server replacement.

Effects below describe the existing workflows touched, not expanded authority.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

Executed reproductions at bde139c5d:

  • Public process CLI delivered SIGINT during real temporary-root removal: exit status 130 still carried successful Evidence. Repaired output is cancelled, with observed target exit 0 retained as partial data and root removal confirmed. Non-aborted control succeeds.
  • Controlled WABT executables plus a real filesystem denial made the public CLI return generic UNKNOWN, losing its completed result. The repaired fault/control regression retains valid completed observations or combined primary/cleanup diagnostics. This is not real WABT verification.
  • Real hardened-runtime LLDB launch returned an error with a valid, nonzero-PID, eStateExited process. The native-call verifier failed before repair and passes afterward.
  • Production composite/session regressions failed on missing-peer health and repeated successful child close. Controls cover mixed-mode retries, idle/unknown coverage and recovery actions.
  • Hopper producer regression failed on an abandoned first listener. Controlled late-handshake/foreign-identity cases and real native fixture cancellation/reopen checks passed after repair.

Detailed executed audit evidence and limits: audit record.

  • 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

Host: macOS 26.3 arm64, Node 24.18.0; matching local toolchain used throughout.

  • npm run test:focused with 25 exact lifecycle/schema/CLI/acceptance paths: 169 passed, one existing skip on the PR branch. Includes whole-catalog SDK-converted schema validation, process CLI/MCP cancellation, Hopper recovery, composite ownership, LLDB failures, SQLite parity and controlled public CLI cleanup denial.
  • Review follow-ups at 3bd6c99ce: 89 focused tests passed across seven files, including public MCP close/retry/status, failed startup/restoration ownership, direct cleanup-diagnostic controls, public CLI cleanup denial and schema validation. npm run check, npm run docs:check (five README tests) and npm run check:fast passed. The new assertions first failed on the old implementation. Provider outcomes are controlled seams; no additional real-engine run is claimed.
  • Additional review follow-ups at b3f328f9d: 158 focused tests passed across 15 files, covering native finalization, Flutter/web retained cleanup and final CLI projection, mixed-owner resources/recovery actions, CLI/MCP workflows and the whole-catalog schema gate. Full static checks, docs checks (five README tests) and final pre-push checks passed. Native finalization uses the completed result schema's optional facts; journal-only failures continue to omit unreported facts.
  • Real native verifier rerun during these review fixes: node scripts/verify-native-calls.mjs passed on Apple LLDB 2100.0.17.108 through CLI and stdio MCP (six events; exited/event-limit/duration-elapsed; hardened-runtime denial and get-task-allow success). Late-cancellation and cleanup fault timing remain controlled regressions, distinct from this real-engine control lane.
  • python3 -m unittest discover -s bridge/native -p test_rea_lldb_tracer.py: 13 passed, including failed termination without inferred exit.
  • npm run check: passed; npm run check:fast: passed again before each push.
  • npm run docs:check: passed, including five README tests; npm run docs:build: passed after the documentation update; git diff --check: passed.

Real-provider results below were executed during the audit of the patch-equivalent series; they were not rerun after replay onto main:

  • npm run verify:native-calls: passed, Apple LLDB 2100.0.17.108, real CLI/stdio MCP, exit/event/duration limits and hardened-runtime denial/get-task-allow controls.
  • Real scoped audit lanes: verify:ghidra passed on Ghidra 12.1.4/JDK21 (373 successful, 52 rejected calls); verify:browser passed on Chrome 155/Playwright 1.58.2; verify:inspector passed on disposable Node targets. verify:native-ui initially had a window-geometry mismatch, then passed on rerun.
  • Real owned Hopper fixture startup/close, MCP cancellation/reopen and abandoned-listener cleanup passed; this lane was exercised with native Hopper 6.6.0-demo.

Compatibility, safety, and release

Author readiness

Human owner: @morluto (PR author; declarations left for human completion).

  • 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

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • 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.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Keep cleanup remediation through combined errors and direct or managed one-shot analysis while retaining primary diagnostics.

Refs: #4227
Authenticate initial and cleanup handshakes through the same identity owner. Expose startup and cleanup activity, retain health after target retirement, and expire abandoned unauthenticated listeners without timing out authenticated work.

Refs: #4227
Preserve observed child health with incomplete peer coverage, retry only unresolved clients, and retain all child cleanup recovery actions.

Refs: #4233
Check the request signal after cleanup and before final publication, retaining completed observations under typed cancellation.

Refs: #4005
Publish failed-launch process identity and observed exit separately from object validity. Retire only the exact owned process and retain uncertainty when exit cannot be established.

Refs: #4232
Check cancellation after runtime-root cleanup and retain collected trace observations as partial cancellation evidence.

Refs: #4009
Reuse the existing one-shot finalizer across thirteen command families to retain completed Evidence and primary diagnostics on close failure. Cover success, denied cleanup, and combined primary/cleanup failure through the public CLI.

Refs: #3935
Document distinct ownership/readiness/exit facts, late cancellation and atomic publication boundaries, partial child cleanup, and diagnostic retention. Link representative regressions and route contributor guidance through AGENTS.md.

Refs: #4227
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner Author

Follow-up probing of this PR head confirmed separate remaining cases: Android late-cancellation classification (#3927), firmware late-cancellation classification (#3923), concurrent Ghidra startup cancellation ownership (#3983), and loss of original cleanup-resource diagnostics in direct CLI error composition (new #4240).

The fresh results and controls are recorded in the lifecycle audit #4227. These probes used compiled production services/clients with controlled provider boundaries; they do not establish real-engine frequency. No source changes were added to this PR during the follow-up pass, and these cases are not claimed fixed here.

@morluto
morluto marked this pull request as ready for review October 15, 2026 20:44
@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-15T21:08:04.358305Z b3f328f 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: 6e64a09a3f

ℹ️ 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/binary/BinarySession.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[High impact] The PR appears safe to merge; both previous findings are addressed and no new blocking issue was found.

Summary

The PR preserves ownership and collected facts across startup, cancellation and cleanup.

  • Hopper keeps its identity when its first handshake comes late.
  • LLDB keeps process and trace facts through launch failures and cleanup.
  • Process capture reports cancellation that arrives during final cleanup.
  • Binary sessions keep the same provider run visible until cleanup succeeds.
  • One-shot commands keep their result when closing resources fails.
  • Lifecycle guidance spells out ownership and finalization checks.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Run["Provider run"] --> Retire["Retire target"]
  Retire --> Close{"Cleanup succeeds?"}
  Close -->|No| Retain["Keep client, route and run ID"]
  Retain --> Close
  Close -->|Yes| Clear["Clear retained run"]
Loading

Reviews (3) · Last reviewed commit: "fix(providers): report retained cleanup ..." · Reviewed by Greptile

Comment thread src/native/LldbCallTracer.ts Resolved
Comment thread src/cli/flutterCommands.ts Resolved
@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

Labels

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

Projects

None yet

1 participant