Skip to content

fix(runtime): attribute destructive close requests - #12238

Merged
OrcaWin merged 3 commits into
stablyai:mainfrom
bbingz:fix/runtime-close-attribution-residual
Aug 4, 2026
Merged

OrcaWin merged 3 commits into
stablyai:mainfrom
bbingz:fix/runtime-close-attribution-residual

Conversation

@bbingz

@bbingz bbingz commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Attribute daemon kill success and failure outcomes to the requesting control client, and emit session-killed only after kill completion.
  • Add runtime, paired-device, request, target, decision, and outcome identities to terminal and session-tab close spans without serializing the bearer clientId.
  • Add focused topology and daemon attribution regressions to the existing destructive-close reliability gate.
  • Preserve the close-policy and RPC-schema behavior already shipped on main.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Validation on exact head b9a5e813b:

  • mise exec [email protected] -- pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/daemon-server-kill-attribution.test.ts - 3/3 passed.
  • Mutation check: removing the kill await made the deferred ordering test fail as expected; disabling tolerated not-found reconciliation made its attribution test fail as expected. Production code was restored, and the final commit changes only the test file.
  • mise exec [email protected] -- pnpm typecheck - Node, CLI, and Web TypeScript passed.
  • mise exec [email protected] -- pnpm check:code-quality:changed - zero new native, type-aware, or React Doctor findings across the changed code.
  • Targeted oxfmt, max-lines ratchet, diff checks, and the commit hook passed.

Full pnpm lint, full repository pnpm test, and pnpm build were not run. No Docker command was run.

Hosted status for exact head b9a5e813b:

  • PR Checks run 30829700381 - action_required.
  • Computer-use e2e run 30829701308 - action_required.

The predecessor head 1c847773b completed 48 hosted checks (44 successful and 4 skipped), but those results are not being treated as exact-head CI for the test-only follow-up.

AI Review Report

The review compared the focused follow-up with current main, the closed #8888 branch, and the OrcaWin completion commit. It checked that the already-shipped close-policy and capability gates were not restored or changed, that existing RpcContext.pairedDeviceId was reused instead of adding a duplicate identity field, and that daemon-control identity remained distinct from paired-device credentials.

CodeRabbit's follow-up review identified two missing test contracts: completion ordering and the tolerated pending-spawn not-found outcome. Exact-head tests now hold the kill promise unresolved before asserting that no success event exists, and verify that a canceled pending spawn retains sessionId, immediate, and clientId attribution without being logged as a failure. Temporary mutations demonstrated that each test fails for its targeted regression.

Cross-platform compatibility was reviewed for macOS, Linux, and Windows. The follow-up is test-only and does not alter shortcuts, labels, paths, shell commands, process spawning, Electron platform branches, SSH behavior, or folder-workspace behavior.

Security Audit

The review covered authentication identity, trace serialization, IPC context propagation, secret exposure, input handling, command execution, paths, and dependencies. The bearer credential in RpcContext.clientId is never passed to the span helper; close spans use the existing non-sensitive pairedDeviceId, and regression tests scan serialized records to prove the bearer value is absent. The daemon clientId field is the local authenticated control-client identity, not the paired-device bearer credential.

The change introduces no dependency, command execution, path handling, user-derived input, permission change, or new IPC/schema field. The exact-head follow-up changes tests only. No follow-up security action is currently identified.

Notes

Focused follow-up to #8888 and the residual work identified in its maintainer closeout. The destructive-close incident itself is already fixed on main; this PR intentionally contains only attribution and forensics improvements.

The PR is currently non-draft and MERGEABLE at exact head b9a5e813b. Its new hosted workflows require maintainer approval before they can run, so UNSTABLE is not being treated as complete required-CI coverage. Build/package, Electron E2E, and real runtime smoke validation were not run locally.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4bf1066-f702-4a57-b042-4cf7be68d70a

📥 Commits

Reviewing files that changed from the base of the PR and between b9a5e81 and b6fe6d0.

📒 Files selected for processing (8)
  • config/reliability-gates.jsonc
  • src/main/daemon/daemon-server-kill-attribution.test.ts
  • src/main/daemon/daemon-server.ts
  • src/main/runtime/rpc/methods/session-tab-close-methods.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/runtime-close-attribution-topology.test.ts
  • src/main/runtime/rpc/runtime-close-attribution.test.ts
  • src/main/runtime/rpc/terminal-close-attribution.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/main/runtime/rpc/runtime-close-attribution.test.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/terminal-close-attribution.ts
  • config/reliability-gates.jsonc
  • src/main/daemon/daemon-server.ts
  • src/main/daemon/daemon-server-kill-attribution.test.ts
  • src/main/runtime/rpc/runtime-close-attribution-topology.test.ts

📝 Walkthrough

Walkthrough

The daemon kill handler records session ID, immediate-kill status, and authenticated client ID for successful, tolerated, and failed kills. Runtime close tracing covers terminal, terminal-tab, session-tab, and lifecycle-close operations. The changes add device, request, target, outcome, and terminal metadata while excluding bearer credentials. Tests cover close outcomes, concurrent identities, runtime calls, and session inventory behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding attribution to destructive runtime close requests.
Description check ✅ Passed The description includes all required sections, documents testing limits, and summarizes review, security, platform, and follow-up details.
Linked Issues check ✅ Passed The changes address linked issue #8888 attribution requirements, including daemon client attribution, bearer-token exclusion, and regression coverage.
Out of Scope Changes check ✅ Passed The code and tests remain within the stated attribution, observability, privacy, and reliability objectives.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin force-pushed the fix/runtime-close-attribution-residual branch from 18a3105 to 1c84777 Compare August 3, 2026 12:36

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/main/daemon/daemon-server-kill-attribution.test.ts (1)

34-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover kill completion ordering and the tolerated outcome.

The success mock resolves immediately. The test can pass if routeRequest starts host.kill() but emits session-killed before the kill completes. Use a deferred promise. Assert that session-killed is absent before resolving it. Then resolve it and assert the success log.

Add a test for the tolerated kill condition. Assert its event payload includes sessionId, immediate, and clientId.

Based on PR objectives: this PR requires attribution for successful, tolerated, and failed kill outcomes.

Also applies to: 51-79


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 67c58e81-3c63-43ee-979c-d8c186f5dcae

📥 Commits

Reviewing files that changed from the base of the PR and between 18a3105 and 1c84777.

📒 Files selected for processing (8)
  • config/reliability-gates.jsonc
  • src/main/daemon/daemon-server-kill-attribution.test.ts
  • src/main/daemon/daemon-server.ts
  • src/main/runtime/rpc/methods/session-tab-close-methods.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/runtime/rpc/runtime-close-attribution-topology.test.ts
  • src/main/runtime/rpc/runtime-close-attribution.test.ts
  • src/main/runtime/rpc/terminal-close-attribution.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/runtime/rpc/runtime-close-attribution.test.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/main/daemon/daemon-server.ts
  • src/main/runtime/rpc/terminal-close-attribution.ts
  • src/main/runtime/rpc/methods/session-tab-close-methods.ts

@OrcaWin
OrcaWin force-pushed the fix/runtime-close-attribution-residual branch from b9a5e81 to b6fe6d0 Compare August 4, 2026 03:29
@OrcaWin
OrcaWin merged commit 79d3c84 into stablyai:main Aug 4, 2026
48 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Attribute destructive runtime and daemon close diagnostics to the requesting client and exact target, record outcomes only after completion, and add reliability-gated attribution regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants