Skip to content

refactor(native-chat): move the provider-exit proof out of structured-agent-session-adapter.ts so main's lint passes - #24323

Merged
Jinwoo-H merged 1 commit into
mainfrom
brennanb2025/adapter-max-lines
Oct 1, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
brennanb2025/adapter-max-lines

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 0
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​70 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8

ELI5

Main's lint check fails because one file grew past the 300-line limit when two recent PRs both added to it. This moves three helper functions out of that file, unchanged, so main's lint passes again. Nothing about how Orca behaves changes.

What Changed

The problem. The static analysis check fails on main and on every PR based on it: src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts:453 File has too many lines (301), against a maximum of 300. #24235 and #23935 each added to this file and passed on their own; together they crossed the limit. Because the lint check fails, the verify check fails too, so any PR that touches this area is blocked.

User-facing change. None. This is a pure move.

Mechanism. structured-agent-session-adapter.ts is the adapter contract: its types, its interface, and its typed failure errors. The only logic in it was three functions that read what a cleanup or a stop proved about whether the provider's process has exited:

  • rethrowAfterAgentSessionAcquisitionCleanup;
  • its private helper provenExitAcquisitionFailure;
  • stopAgentSessionProviderRoot.

They move verbatim into a new structured-agent-session-provider-exit-proof.ts, and their 6 callers now import from it. The new module imports from the adapter, and the adapter doesn't import it back, so there's no import cycle.

Why

Splitting by responsibility keeps the contract file as just the contract. The alternatives were worse:

  • adding a lint disable, which this repo forbids for max-lines;
  • squeezing lines to fit under the limit;
  • moving the error classes, which would touch 32 importers and separate the errors from the contract they describe.

Linked Issue

None: this fixes main's own red static-analysis check.

Visual Proof

N/A: this is a code move with no behavior or UI change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

No new tests, because nothing behaves differently. Ran:

  • full-repo oxlint: clean, and the max-lines error is gone;
  • the max-lines ratchet script: OK;
  • the node typecheck: passes;
  • 17 related test files, 202/202, covering the adapter, acquisition, eviction, host teardown, the Claude and Codex session adapters, and Stop.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Platform-, SSH- and mobile-neutral: no runtime change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…-agent-session-adapter.ts so main's lint passes

structured-agent-session-adapter.ts reached 301 lines once two changes on
main met, one over the 300-line limit, so oxlint fails on main.

The file is the adapter contract: its types, its interface and the typed
failure verdicts. The only logic in it read what a cleanup or a stop proved
about the provider child's exit: rethrowing a failed acquisition with the
verdict its cleanup reached, and reading whether a stop left the provider
root gone. That logic moves unchanged to
structured-agent-session-provider-exit-proof.ts, which imports the verdicts
from the adapter; nothing imports back. Its six importers now import from
the new module. No behavior change.
@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5b308ad0-7544-405a-9350-48f9afbdb62f

📥 Commits

Reviewing files that changed from the base of the PR and between 6593d7d and 43f01f1.

📒 Files selected for processing (8)
  • src/main/claude/claude-structured-acquisition-launch.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-acquisition.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adapter.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-attach-failure.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-recovery.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-eviction.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-provider-exit-proof.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The pull request moves acquisition cleanup classification and provider-root stop handling from the adapter to the provider-exit-proof module. It updates call sites and test imports to use the new module. The adapter retains its types and acquisition error classes.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 43f01

The helper extraction preserves acquisition cleanup and provider-stop behavior. No actionable merge-blocking risk remains beyond normal checks.

Architecture Summary

Architecture risk: 🟡 Medium · up to 43f01

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 8 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/claude/claude-structured-acquisition-launch.ts: The stopAgentSessionProviderRoot import moved from structured-agent-session-adapter to structured-agent-session-provider-exit-proof; the adapter import retains the acquisition input type.
  • observed — Modified behavior in src/main/native-chat/agent-session-wire/structured-agent-session-acquisition.ts: The adapter import no longer includes rethrowAfterAgentSessionAcquisitionCleanup; that helper is imported from structured-agent-session-provider-exit-proof instead. The provider child phase type remains sourced from the adapter.
  • observed — Modified behavior in src/main/native-chat/agent-session-wire/structured-agent-session-adapter.test.ts: The test imports AgentSessionAcquisitionRootExitObservedError from the adapter and moves rethrowAfterAgentSessionAcquisitionCleanup to the provider-exit-proof module.
  • observed — Modified behavior in src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts: The value import of isAgentSessionWireRefusalCode is removed; AgentSessionRefusalReason remains a type-only import.

Reliability and maintainability

  • inferred — Risk-relevant change factors for src: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 8 files. 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 refactor and its purpose: moving provider-exit proof logic out of structured-agent-session-adapter.ts to restore lint compliance.
Description check ✅ Passed The description is complete and relevant. It explains the problem, user impact, implementation, rationale, testing, platform considerations, and checklist status. The Linked Issue section states that …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Moves provider-exit logic into a new module.

The PR appears safe to merge; no actionable issue was identified.

Summary

The PR moves the provider-exit proof helpers into a dedicated module and updates their callers. The functions are unchanged, and the review found no actionable regression.

Reviews (1) · Last reviewed commit: "refactor(native-chat): move the provider..."

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

✅ No new issues found.

Reviewed changes — a pure mechanical extraction that unblocks main's static analysis check.

  • Provider-exit proofs extracted — rethrowAfterAgentSessionAcquisitionCleanup, its private provenExitAcquisitionFailure, and stopAgentSessionProviderRoot move verbatim from structured-agent-session-adapter.ts into the new structured-agent-session-provider-exit-proof.ts.
  • Callers re-pointed — the six importers (claude-structured-acquisition-launch.ts, structured-agent-session-acquisition.ts, structured-agent-session-attach-failure.ts, structured-agent-session-event-recovery.ts, structured-agent-session-eviction.ts, and the adapter test) now import from the new module.
  • Adapter trimmed — the now-unused runtime import of isAgentSessionWireRefusalCode is dropped; AgentSessionRefusalReason stays type-only and is still referenced at structured-agent-session-adapter.ts:58,129.

I confirmed the moved bodies are byte-identical to the removed originals, the six callers are the complete set of importers, the dependency direction is one-way (provider-exit-proof → adapter) so no cycle is introduced, npx oxlint over all eight changed files reports zero findings, and tsc --noEmit -p config/tsconfig.node.json is clean. No behavioral surface to review.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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.

2 participants