Skip to content

refactor(backend): import defining owners and extract ACP startup - #39417

Merged
nwparker merged 3 commits into
mainfrom
module-layout-v2/backend-direct-owners-main822
Nov 7, 2026
Merged

nwparker merged 3 commits into
mainfrom
module-layout-v2/backend-direct-owners-main822

Conversation

@nwparker

@nwparker nwparker commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Import orchestration and session types/functions from the files that define them, and give ACP startup and messaging validation real implementation owners.

Files Added Deleted Net
Test 721 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6396 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7588 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1192
Prod 971 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5421 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4369 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1052

What Changed

  • Remove 50 redundant forwarding exports and identity aliases across the backend owners; update consumers directly.
  • Replace the generic orchestration schemas module with four substantive messaging owners. Colocate the federation input type with its defining shared schema and retire its empty forwarding shell.
  • Extract the ACP session-start implementation, preserving acquisition, abort, refusal, cleanup and exit classification. Preserve main's newer session-specific option lookup.
  • Remove redundant schema/mock/work-count test cases and assertions. Retain the persisted cold-delivery witness and actual refusal, retry, disposal, asynchronous setup and replay safety cases.

Why

Forwarding shells obscure the actual dependencies. These changes make ownership explicit without adding barrels, wrappers or compatibility shims.

Linked Issue

Continuation of the module-layout cleanup tracker.

Visual Proof

N/A: backend ownership and test maintenance; no UI change.

Testing

  • Current head 8e4df96ff639 is rebased onto the actual merged host commit 23808bb73f04 and targets main. Current node typecheck and changed-code quality across 74 source files pass; normal push passed.
  • The actual-parent whole-entry proof preserves 85 authored and 183 incoming paths with zero contacts, including all 29 upstream deletions. All 1,103 incoming requests and five bindings into authored owners resolve. This is root evidence; the new independent SOURCE/BOUNDARY reviews remain gates.
  • Original independent implementation/test-policy audits and sealed root replays remain scoped to their exact pins and initialization qualifications. Historical focused coverage includes 40 tests across six refinement files, 11 tests across three ACP files and 122 tests across 13 original files; overlapping counts are not summed as current coverage.
  • Fresh exact-head full PR CI, independent actual-parent reviews, latest-main composition and authenticated actual squash parent/tree remain required before merge. No previous-head CI is transferred.

Risk

Medium: direct imports can change isolated initialization timing, and startup extraction must retain cleanup/error precedence. Audits preserve the actual bodies, schema input/output types, 197 explicit bare admissions, singleton owners and production composition. Narrower standalone graphs and test initialization changes are explicitly qualified. There is no persisted-data migration or intended wire behavior change.

Review

The real cold-history helper was not dead: its first-completed-frame delivery witness remains in the existing command test. Genuine relational identity, active/disposed callback delivery, foreign-target refusal and external replay side-effect guards remain. Tests do not gain new production exports or test hooks.

Detailed tracker, reports and reproducible evidence remain local and ignored.

Agent skill upstream boundary

  • This change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

@nwparker
nwparker force-pushed the module-layout-v2/host-terminal-owners-97f2de9 branch from c47cd78 to b1a4974 Compare November 7, 2026 08:55
@nwparker
nwparker force-pushed the module-layout-v2/backend-direct-owners-main822 branch from b1670f7 to 13905ad Compare November 7, 2026 08:59
@nwparker
nwparker marked this pull request as ready for review November 7, 2026 09:00
@nwparker
nwparker force-pushed the module-layout-v2/host-terminal-owners-97f2de9 branch from b1a4974 to d7cad1e Compare November 7, 2026 09:34
@nwparker
nwparker force-pushed the module-layout-v2/backend-direct-owners-main822 branch from 2d0f69d to d0fb811 Compare November 7, 2026 09:36
@nwparker
nwparker force-pushed the module-layout-v2/host-terminal-owners-97f2de9 branch from d7cad1e to 39d6c42 Compare November 7, 2026 09:50
@nwparker
nwparker force-pushed the module-layout-v2/backend-direct-owners-main822 branch from d0fb811 to 68f593e Compare November 7, 2026 09:53
@nwparker
nwparker force-pushed the module-layout-v2/host-terminal-owners-97f2de9 branch from 39d6c42 to ec3804f Compare November 7, 2026 10:46
@nwparker
nwparker force-pushed the module-layout-v2/backend-direct-owners-main822 branch from 68f593e to c9c9703 Compare November 7, 2026 10:51
@nwparker
nwparker force-pushed the module-layout-v2/backend-direct-owners-main822 branch from c9c9703 to 8e4df96 Compare November 7, 2026 11:43
@nwparker
nwparker changed the base branch from module-layout-v2/host-terminal-owners-97f2de9 to main November 7, 2026 11:47
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The pull request extracts ACP structured-session startup into a dedicated helper. It moves orchestration constants, RPC parameter types, and message-processing helpers to shared or dedicated modules. It updates imports and removes selected re-exports. Crew and orchestration tests are revised, and a restored-session Crew stream test replaces cold-load cost-profile coverage.

Merge Risk: Minimal · up to 8e4df

This refactor reorganizes imports and extracts session startup without an intended behavior change. Only minor test-quality points remain, so merge-readiness risk is minimal.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title describes the direct imports and ACP startup extraction.
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.
Description check Passed The description covers the main changes, rationale, testing, and risks. It should add reviewer test steps, tested platforms, and rollback guidance. If the author is an outside contributor, it must als…
Full details: Description check

Explanation

The description covers the main changes, rationale, testing, and risks. It should add reviewer test steps, tested platforms, and rollback guidance. If the author is an outside contributor, it must also link an issue.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 50 files. (24 skipped: 24 over the file limit.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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: 2

tests/e2e/crew-recipient-real-command.unit.test.ts: 1

572-572: Trivial · Maintainability & Code Quality · Quick win

Replace randomUUID() with fixed constants in the new test.

The test builds session IDs (Line 572) and operationId (Line 596) from randomUUID(). Non-deterministic inputs make failures hard to reproduce. The PR also states that restored sessions are seeded with one fixed operation clock. Use hardcoded UUIDs. The operationId can then be ${fixtureNow}-<fixed hex> or derived from the index.

Proposed fix

-  const ids = Array.from({ length: 3 }, () => randomUUID())
+  const ids = [
+    'aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa',
+    'bbbbbbbb-2222-4222-8222-bbbbbbbbbbbb',
+    'cccccccc-3333-4333-8333-cccccccccccc'
+  ]
-          operationId: `${fixtureNow}-${randomUUID().replaceAll('-', '')}`,
+          operationId: `${fixtureNow}-${sessionId.replaceAll('-', '')}`,

Based on learnings: "In test code, avoid using current system time (e.g., now()) or randomly generated IDs/UUIDs as inputs. Use fixed, hardcoded constants instead."

Also applies to: 596-596

Source: Learnings

src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts: 1

571-571: Trivial · Functional Correctness · Quick win

Restore the nextCommands assertion for the outcome-unknown case.

The test now checks only failedStage. The removed check covered the recovery commands that operators use to recover from an unknown outcome. A regression in nextCommands no longer fails this test. Keep a minimal assertion that nextCommands is non-empty.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ebfcf6ff-1cdb-4b6f-a9bb-d79def6e0a3e
Commits

Reviewing files that changed from the base of the PR and between b0dd73e and 8e4df96.

Files selected for processing: 85

  • src/main/acp/acp-private-temp.ts
  • src/main/acp/acp-structured-session-adapter.ts
  • src/main/acp/acp-structured-start.ts
  • src/main/native-chat/agent-session-journal/projection/journal-dispatch-doubt-reasons.ts
  • src/main/native-chat/agent-session-journal/queued-messages/queued-edit-host.test-fixture.ts
  • src/main/native-chat/agent-session-wire/host/testing/structured-agent-session-rest-test-rig.ts
  • src/main/native-chat/agent-session-wire/operations/structured-agent-session-host-mutations.ts
  • src/main/native-chat/agent-session-wire/operations/structured-agent-session-mutation-plans.ts
  • src/main/native-chat/agent-session-wire/providers/structured-agent-session-adapter.ts
  • src/main/native-chat/agent-session-wire/termination/structured-agent-session-dead-generation-settlement.ts
  • src/main/runtime/orchestration/crew/crew-follow-up-authority-inputs.test.ts
  • src/main/runtime/orchestration/crew/crew-host-derivation.ts
  • src/main/runtime/orchestration/crew/crew-identity-inputs.ts
  • src/main/runtime/orchestration/crew/crew-parent-persistence.test.ts
  • src/main/runtime/orchestration/crew/crew-parent-relations.test.ts
  • src/main/runtime/orchestration/crew/crew-parent-relations.ts
  • src/main/runtime/orchestration/crew/crew-parties.ts
  • src/main/runtime/orchestration/crew/crew-party-snapshot.ts
  • src/main/runtime/orchestration/crew/crew-pending-questions.test.ts
  • src/main/runtime/orchestration/crew/crew-read-model.test-fixture.ts
  • src/main/runtime/orchestration/crew/crew-read-model.test.ts
  • src/main/runtime/orchestration/crew/crew-read-model.ts
  • src/main/runtime/orchestration/crew/crew-recipient-authority.test.ts
  • src/main/runtime/orchestration/crew/crew-recipient-availability.ts
  • src/main/runtime/orchestration/crew/crew-recipient-delta-cost.test-fixture.ts
  • src/main/runtime/orchestration/crew/crew-recipient-delta-cost.test.ts
  • src/main/runtime/orchestration/crew/crew-recipient-demand.test.ts
  • src/main/runtime/orchestration/crew/crew-recipient-inputs.ts
  • src/main/runtime/orchestration/crew/crew-recipient-mailbox-selection.ts
  • src/main/runtime/orchestration/crew/crew-runtime-watch.ts
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-context-store.ts
  • src/main/runtime/orchestration/db/dispatch-context/worker-follow-up-lineage.ts
  • src/main/runtime/orchestration/db/dispatch-depth.test.ts
  • src/main/runtime/orchestration/db/dispatch-depth.ts
  • src/main/runtime/orchestration/db/legacy/legacy-compatibility-principals.ts
  • src/main/runtime/orchestration/db/messages/message-insert.ts
  • src/main/runtime/orchestration/db/reset/orchestration-reset.ts
  • src/main/runtime/orchestration/db/runs/worker-run-binding.ts
  • src/main/runtime/orchestration/db/schema/adopt-legacy-run.ts
  • src/main/runtime/orchestration/db/schema/backfill-legacy-question-threads.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/migrate-legacy-contract-storage.ts
  • src/main/runtime/orchestration/db/schema/migrate-v2-v12.ts
  • src/main/runtime/orchestration/db/worker-dispatch/worker-dispatch-start.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/db/writer-run-required.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federated-worker-agent-launch.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-start-schema.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-start-schema.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/ask-methods.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/ask-remote.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-direct.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-methods.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-run-pending-mail.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-run.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-worker.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/finished-worker-mail.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/mailbox-page-routing.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/message-methods.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/message-payload.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/recipient-routing.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/reply-method.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/send-control-mail.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/send-group.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/send-methods.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/send-params.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/send-point-to-point.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/send-remote.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/settled-worker-follow-through.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/task-update-params.ts
  • src/main/runtime/rpc/methods/orchestration/routing.ts
  • src/main/runtime/rpc/methods/orchestration/runs/dispatch-methods.ts
  • src/main/runtime/rpc/methods/orchestration/runs/reset-methods.ts
  • src/main/runtime/rpc/methods/orchestration/schemas.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts
  • src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts
  • src/shared/queued-edit-host.test-fixture.ts
  • src/shared/rpc-contract/orchestration-federation-start-params.ts
  • tests/e2e/crew-cli-addresses.unit.test.ts
  • tests/e2e/crew-parent-rpc.unit.test.ts
  • tests/e2e/crew-recipient-real-command.unit.test.ts
Files with no reviewable changes: 11

  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/native-chat/agent-session-journal/queued-messages/queued-edit-host.test-fixture.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-start-schema.ts
  • src/main/runtime/orchestration/crew/crew-party-snapshot.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-start-schema.test.ts
  • src/main/runtime/orchestration/db/worker-terminal/worker-terminal-listing.ts
  • src/main/runtime/orchestration/crew/crew-recipient-delta-cost.test.ts
  • src/main/native-chat/agent-session-wire/providers/structured-agent-session-adapter.ts
  • src/shared/queued-edit-host.test-fixture.ts
  • src/main/runtime/rpc/methods/orchestration/schemas.ts
  • src/main/native-chat/agent-session-journal/projection/journal-dispatch-doubt-reasons.ts

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

@nwparker
nwparker merged commit 27a724e into main Nov 7, 2026
84 checks passed
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.

1 participant