Skip to content

refactor(gateway): consolidate request and lifecycle handling - #167159

Merged
steipete merged 5 commits into
mainfrom
deslop/d01-gateway-server-methods-p2-20261007
Oct 8, 2026
Merged

steipete merged 5 commits into
mainfrom
deslop/d01-gateway-server-methods-p2-20261007

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Related: #166621

What Problem This Solves

Gateway handlers repeat preparation, response projection, and lifecycle bookkeeping across variants, increasing the code that must stay consistent.

User Impact

No user-visible change. Features, authority checks, recovery and replay, configuration, protocol and persisted shapes, and user-facing text remain unchanged. No migration or operator action is required.

Why This Change Was Made

Share common work while keeping variant-specific decisions explicit: channel start/stop outcomes, device rotation/revocation cleanup, Web Push guards, Talk errors, and agent admission. Derive cancellation, channel recovery, and relay closure facts from their owning state. Preserve lazy-loading, synchronous authorization boundaries, and main's Workshop and uncertain-steering fixes.

856 net production lines removed across 111 files: 1,641 added and 2,497 deleted, excluding tests, fixtures, support code, generated files, and declarations. No tests or assertions changed. The only other change removes one obsolete assertion-baseline allowance. This uses the campaign's authorized 500–999-line exception after more than two hours of implementation and a 551-module coverage pass.

Per-file coverage log: 1/6, 2/6, 3/6, 4/6, 5/6, 6/6. It records implemented reductions and measured rejected alternatives, and distinguishes historical measurements from the final diff.

Evidence

  • Independent review of the complete rebased candidate found no actionable P0–P2 findings.
  • The complete changed-file gate passed: production types, all 27 test-type shards, all three Knip scans with zero findings, formatting, lint, ratchets, storage/schema guards, cycles, and authorization guards.
  • Broad proof before conflict-only integration: server-methods directory, 539 files / 7,289 tests passed (29m 49s); adjacent Gateway directories, 85 files / 1,275 tests passed (4m 5s). Existing skips are unchanged. A subsequent caller/lifecycle batch passed 85 files / 936 tests, including its build (11m 16s).
  • Final integration selection exercised 42 files: 609 tests passed and two Activity recap tests failed. The seven files deferred by the first failing shard were subsequently run and all 170 tests passed. Details below preserve the unresolved attribution.
  • Runtime and madge cycle counts are both zero. Strict PR-wrapper inventory and eager-source-closure tests passed. Tooling-consumed exports retain their signatures and behavior; no inventory update was needed.
  • SDK API comparison against the integrated base passed: no entrypoints or direct exports changed. Reachable declaration differences are only a private NodeRegistry helper and removal of an unused internal type re-export.

Local failures under investigation

The suppression test fails on the candidate and clean main de2b8ae04af1623cbb5b72e84bb80976008b784f with the same extra entry: src/config/sessions/session-transcript-lock-settlement.ts|typescript/prefer-promise-reject-errors|2. Both that excluded source file and the suppression test are unchanged here. No suppressions or allowlist entries were added.

Two candidate recap tests expected two admitted operations but observed one: queues a full Activity page and reports admission limits until a slot settles and does not let timeout release a preparation slot or dispatch a late model request. The latter also timed out during cleanup. Their production owners and tests are byte-identical to main. A reduced clean-main replay passed those cases but failed the separate overloaded-model queue test. That is not an exact reproduction of the candidate failures. The full-workload comparison has not executed: Testbox admission failed and the fallback was refused by fleet capacity. Assertions, timeouts, retries, and skips remain unchanged.

Search-handler deferral and CI

The coordinator-approved six-line search error-handler consolidation is deferred. sessions-read.ts is byte-identical to the base and is absent from the PR diff. No src/config/sessions file is changed.

The deferral passed independent review, core typechecking, lint, and runtime/madge cycle checks (both zero). Focused search tests passed 22 cases and reproduced only the pre-existing indexing: true failure. The suppression test repeated the storage-file mismatch described above; neither suppression source is changed by this PR.

The earlier head's sole substantive hosted failure was checks-node-changed-compact-large-4-1, with an aggregate openclaw/ci-gate failure. The same first-case sessions-search-scope.test.ts assertion failed independently on scheduled main job 113247823034, head 0043bb028914e6f92632623a99b482a8cd93b3b5: expected no indexing property, received true. This was an executed test failure, not cancellation. Main has since received owner fix 888bd0d488aa8fd4453a98b3bcdbc692f262c125 (#167174); this evidence does not claim repaired current main remains red.

Hosted CI run 37771088557 completed successfully on exact head 3fa749dfb9ba45ebf64552d168d25580551981c8. The complete check-run census has no failures or cancellations; aggregate CI, dependency review, and security-sensitive commit statuses are all successful. The cancelled context check was rerun successfully. No admin exception is needed.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL labels Oct 8, 2026
@steipete

steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

d01 PR 2 coverage, part 1 of 6

Gateway server-methods lane d01, PR 2 coverage

Original coverage baseline: c768d4e2fae02c21a18c2934ca794dbb4a7eefdd. Original pass: 424 production files, including 19 reserved exclusions. Adjacent pass: 126 production files.

Initial measured implementation: 865 net lines, 1676 added and 2541 deleted across 114 files. The table retains that frozen original-base measurement. Tests, fixtures, generated files and declarations are excluded.

Current candidate after the coordinator-approved search-handler deferral: 856 net production lines, 1,641 added and 2,497 deleted across 111 files, measured against 54bd6ecee1897f51b2963b6ea4c165a356e2d805. No test, fixture, support, generated, declaration, or protected storage file changes are counted. The assertion baseline shrinks by one line outside these totals.

Validation retained the enum validator's original typed bridge (+9 lines relative to the initial implementation), used the restriction owner's accepted entry type, and removed the unused worktree callback parameter. Final lint corrections retain explicit key/agentId response fields (+1 line), rename shadowing locals, and use Object.assign({}, format) for the existing shallow audio-format clone. session-activity-summary.ts is now byte-identical to main and receives no current credit.

The second rebase resolved two conflicts by preserving main's behavior. skills-workspace-handler.ts retains main's Workshop owner cutover and proposal/curator retirement; the lane keeps only the shared invalid-session response construction (52 → 46 lines against the current base). chat-send-message-injection.ts keeps main's uncertain-steering indeterminate outcome and preserves the running tool, without restoring the removed abort-on-unconfirmed-transcript path. That file is byte-identical to main and receives no lane credit; its initial net reduction was also zero. chat-send-background.ts remains byte-identical to main after main independently removed title admission, so its historical four-line reduction is likewise excluded.

The committed cancellation cleanup derives the qualified-session agent at its single use and removes nullable checks already ruled out by immutable captured bindings in holdPendingInputWithdrawal. It removes nine lines from the rebased committed handler (720 → 711); the complete handler delta against current main is 736 → 711 (-25). Main's descendant-owner extraction is retained and is not counted as lane work.

Implementation session started 2026-10-07T22:35:49.016704+00:00; source freeze was after 00:40 UTC on 2026-10-08, exceeding two hours of real implementation and review. No tests or test assertions changed. The per-file test column names existing test targets, not passing results; validation evidence is recorded separately and remains tied to the source revision actually tested.

Audit: missing original rows 0; duplicate rows 0; changed production paths without rows 0.

File Before Initial after Initial net removed Decision and rationale Existing test targets
src/gateway/server-methods/config.ts 1115 1115 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/agents.ts 1103 1103 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/send.ts 926 926 0 rejected: Formatted shared catch classifier 926→927 (+1). Callback and typed parameter overhead exceeds the three small catches; preserve partial-delivery-first checks and distinct action-vs-direct authority predicates. src/gateway/server-methods/send.test.ts src/gateway/server-methods/send.scheduled-reads.integration.test.ts src/gateway/server-methods/send.discord-request-authority.integration.test.ts
src/gateway/server-methods/cron.ts 835 835 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/chat-send-admission.ts 729 729 0 REVIEWED_UNCHANGED: PR1 already replaced reconstructed admission-context arguments with prepareChatSendAdmissionContext(params). This shared parameter path is present in the frozen PR2 base; no PR2 edit or LOC reduction is claimed. Full server-methods directory; results recorded separately
src/gateway/server-methods/update.ts 726 726 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: updateHandlers[update.run] already shares refusedUpdate, acknowledgeUpdate, refuseUnauthorizedChatUpdate and sentinelMeta. Host-owned refusal, package-root refusal, foreground handoff and campaign adoption each have different version reads, notifier timing and durable outcome ownership; no second updater implementation was found. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-metadata-runtime.ts 721 721 0 reviewed-no-change: Re-evaluated common agent/startup preparation and generation retirement. Agent projection and readCurrent already share the asynchronous core; startup ready-only reads must not begin work. Combining pending retirement adds an extra helper for five shared statements with different error/publication handling; leave lifecycle ownership explicit. src/gateway/server-methods/chat-metadata-runtime.test.ts src/gateway/server-methods/chat-metadata-runtime.refresh.test.ts src/gateway/server-methods/chat-metadata-runtime.cache.test.ts
src/gateway/server-methods/chat-send-handler.ts 712 710 2 APPLIED: One synchronous cancellation/routing settlement closure at the three preparation boundaries; checks retain original order and each existing await remains in its caller. Existing focused/full test targets: chat.directive-tags.test.ts chat-send-admission-authority.test.ts
src/gateway/server-methods/chat-send-agent-dispatch.ts 711 708 3 implemented: Share the immutable reply-finalization arguments between dispatched/source branches; preserve all branch conditions, dynamic runtime outcome options, and exact awaited calls. chat.directive-tags.test.ts;chat-send-session-binding.test.ts;chat-send-commentary-media.test.ts (results recorded separately)
src/gateway/server-methods/approval-shared.ts 709 701 8 applied: Shared live custody acquisition between initial lookup and commit-time revalidation, and forwarded existing recipient context. Exclusive follow-up ownership handed to admin for approval method factories; all original exports retained. src/gateway/server-methods/approval-shared.storage-failure.test.ts;src/gateway/server-methods/approval-shared.test.ts
src/gateway/server-methods/sessions-abort.ts 704 699 5 APPLIED: One result projection for exact embedded, queued collector, ordinary and absent abort results; response call arity, warning omission, and event timing unchanged. Existing focused/full test targets: sessions-abort.test.ts chat.abort-errors.test.ts
src/gateway/server-methods/projects.ts 701 686 15 APPLIED: Use existing validated-handler owner and one clone-failure projection for credential-unavailable and ProjectCloneError; cause, retryability, and exact messages preserved. Existing focused/full test targets: projects.test.ts projects-incognito.test.ts projects-observed.test.ts
src/gateway/server-methods/sessions-patch-engine.ts 697 697 0 reviewed-no-change: Re-evaluated all per-target rejection and preparation paths. Preflight writes indexed outcomes; queued projection writes ordered group outcomes and can defer catalogs without committing. Shared error mappers, targetAccessError, group writer and patchEffects already own their repeated work. A rejection helper would replace existing one-line pushes while preserving every continue, with no reduction. src/gateway/server-methods/sessions-mutations.catalog-queue.test.ts src/gateway/server-methods/sessions-mutations.owner.test.ts src/gateway/server-methods/sessions-mutations.archive-attribution.test.ts
src/gateway/server-methods/sessions-suggestions.ts 695 695 0 reviewed-no-change: Re-read add/list/resolve/typing. Add and resolve retain different worker claim/finalization custody. List captures exact row generations across I/O; typing aggregates connections and checks live viewers synchronously. Repeated comparison blocks carry different selected/target null handling; no duplicate effect owner. src/gateway/server-methods/sessions-suggestions.custody.test.ts;src/gateway/server-methods/sessions-suggestions.test.ts;src/gateway/server-methods/sessions-suggestions.visibility.test.ts
src/gateway/server-methods/chat-abort-runtime.ts 685 674 11 implemented: Aggregate active and pending selection facts through runPlans, retaining queued-first mutation order, protected-owner distinctions and worker cancellation. src/gateway/server.chat-abort-settlement.test.ts src/gateway/server.sessions.abort-authorization.test.ts src/gateway/session-utils.queued-collector-narrow-abort.test.ts
src/gateway/server-methods/chat-abort-handler.ts 683 667 16 APPLIED: Share exact map-entry/session/agent identity captures across active and queued cancellation; keep controller/abortability/withdrawal checks at the distinct callers with no added awaits. Existing focused/full test targets: chat.abort-authorization.test.ts chat.abort-incarnation.test.ts chat.abort-persistence.test.ts chat.abort-errors.test.ts chat.abort-cascade.test.ts chat.abort-save-warning.test.ts
src/gateway/server-methods/chat-send-session.ts 681 671 10 implemented: One synchronous restrictionFor core takes config, projected entry, model and persisted entry explicitly. Initial send check, commit-edge validation and committed-row response retain their original inputs and authority timing. src/gateway/server-methods/chat.native-runtime-consent.test.ts
src/gateway/server-methods/question.ts 681 680 1 implemented: Narrow selected-question preparation to original options responder; all three callers passed that same responder. Keep get preparation outside its error catch, as before. src/gateway/server-methods/question.test.ts src/gateway/server-methods/question.own-run.test.ts src/gateway/server-methods/question.session-access.test.ts src/gateway/server-methods/question.hosted-caller.test.ts src/gateway/server-methods/question.recovery.test.ts
src/gateway/server-methods/sessions-create.ts 677 677 0 retained: Creation holds one createGatewaySession call with prepared root/worktree strategies. Catalog/raw/project forks differ only in parameter expressions already on shared path; omitted versus explicit undefined payload keys preserved. sessions-create.child-custody.test.ts;sessions-create-dock.test.ts (results recorded separately)
src/gateway/server-methods/sessions-dispatch.ts 677 677 0 reviewed-no-change: Re-read newer worker-grant owner. Dispatch retries capture attempt receipts; move retains failure publication; reclaim observes committed generation changes. withWorkerPlacementAuthorization already shares grant preparation/release. The dispatch eligibility calls deliberately use current config and optional node access versus captured config and required node access. src/gateway/server-methods/sessions.dispatch.test.ts;src/gateway/server-methods/sessions.dispatch.device.test.ts;src/gateway/server-methods/sessions.dispatch.demand.test.ts
src/gateway/server-methods/sessions-files.ts 665 665 0 reviewed-no-change: Re-read all file routes and their repository adapter. list/get/assets already share read/host authority and publication. Their repository operation/result shapes differ. Raw patch loops preserve adds-before-moves ordering; combining regexes would change touched-file ordering. No changed store or host-read policy. src/gateway/server-methods/sessions-files.host-read.test.ts;src/gateway/server-methods/sessions-files.repository.test.ts;src/gateway/server-methods/sessions-files.test.ts
src/gateway/server-methods/chat-history-handler.ts 664 664 0 reviewed-no-change: Re-evaluated page/delta response core. Both already share selection, startup, current sharing, thinking and error projection. Page carries byte-framed response fields/defaults while delta rereads sharing after worker restoration and must publish only then. A common payload builder would require page-specific callbacks or an extra publication await; retain the direct projections. src/gateway/server-methods/chat-history-handler.availability.test.ts src/gateway/server-methods/chat-history-delta.test.ts
src/gateway/server-methods/sessions-mutations.ts 663 663 0 retained: Patch/patchMany already share executeSessionPatchMutations with explicit target/guard rules. Involvement and assignment differ in client identity, missing-session errors and live owner checks; no second full mutation owner exists. Reset already shares post-response publication. src/gateway/server-methods/sessions-mutations.owner.test.ts src/gateway/server-methods/sessions-mutations.catalog-queue.test.ts
src/gateway/server-methods/chat-send-pre-admission.ts 660 654 6 APPLIED: One durable-claim request assembler accepts the current entry and warning strategy; Goal replay and recovered retry retain their different warning strings and sequencing. Existing focused/full test targets: chat.directive-tags.test.ts chat-send-admission.reads.test.ts
src/gateway/server-methods/sessions-rewind.ts 650 650 0 retained: One mutateSessionAtMessage already parameterizes fork/rewind/switch. Repository fork and upstream fork need different rollback owners; common commit/await spine would require strategy hooks at each custody boundary. sessions-rewind.test.ts;sessions-rewind.storage.test.ts (results recorded separately)
src/gateway/server-methods/models-list-result.ts 649 648 1 applied: Moved repeated decisionModels result projection into the existing shared readOutcomeProjection; provider-config and configured reads retain identical key order and optional-field conditions. src/gateway/server-methods/models-list-result.arcee.test.ts;src/gateway/server-methods/models-list-result.cli-runtime-availability.test.ts;src/gateway/server-methods/models-list-result.configured-static.test.ts;src/gateway/server-methods/models-list-result.openai-routes.test.ts;src/gateway/server-methods/models-list-result.plugin-runtime.test.ts;src/gateway/server-methods/models-list-result.provider-outcomes.test.ts;src/gateway/server-methods/models-list-result.runtime-choices.test.ts;src/gateway/server-methods/models-list-result.service-tiers.test.ts
src/gateway/server-methods/chat-send-reply-dispatch.ts 645 643 2 APPLIED: Derive captured transcript lifecycle revision from the already retained rewrite state; delete the redundant independently assigned scalar. Existing focused/full test targets: chat-send-reply-dispatch.test.ts chat.directive-tags.test.ts
src/gateway/server-methods/terminal.ts 645 631 14 reviewed-no-change: Re-evaluated shared-core extraction: Shared connection/disable checks for input resize close; close remains exempt from enablement src/gateway/server-methods/terminal.test.ts src/gateway/server-methods/terminal.dispatch-authority.test.ts
src/gateway/server-methods/board.ts 644 644 0 rejected: Implemented synchronous typed five-method session preparation prototype 644→651 (+7). Validator binding and precise handler types cost more than the repeated preparation; discarded prototype, preserving existing per-method authority capture. src/gateway/server-methods/board.test.ts src/gateway/server-methods/board.runtime-boundaries.test.ts src/gateway/server-methods/board.mcp-admission.test.ts src/gateway/server-methods/board.approval.test.ts src/gateway/server-methods/board.github-actions.test.ts src/gateway/server-methods/board.plugin-capabilities.test.ts
src/gateway/server-methods/system-agent.ts 641 641 0 retained: Welcome variants already converge on one persisted session; new-agent rejoin preserves pending wizard and approval checks. Moving shared welcome response past lastUsedAt would change timestamp. Startup variants differ by owner binding and authority capture before await. system-agent.test.ts;system-agent-greeting-welcome.test.ts (results recorded separately)
src/gateway/server-methods/nodes.invoke.ts 640 640 0 REVIEWED_UNCHANGED: PR1 already introduced withinInvokeDeadline and respondWithInvocationResult, preserving explicit original-versus-decoded payload behavior. Both shared cores are present in the frozen PR2 base; this row describes retained PR1 work, not an unimplemented PR2 proposal. Full server-methods directory; results recorded separately
src/gateway/server-methods/channels.ts 631 608 23 implemented: Shared start/stop account resolution, current runtime snapshot and response identity; explicit action preserves the start-only capability check, outcome requirement and deferred reload projection. No new await. src/gateway/server-methods/channels.start.test.ts src/gateway/server-methods/channels.status.test.ts
src/gateway/server-methods/sessions-sharing.ts 617 613 4 implemented: Derive changed-event agentId from its owning sharing event instead of carrying duplicate top-level parameters. Membership, timestamps, actor capture, queue boundaries and all event payloads unchanged. src/gateway/server-methods/sessions-sharing.test.ts src/gateway/server-methods/sessions-sharing.authority.test.ts src/gateway/server-methods/sessions-sharing.identities.test.ts
src/gateway/server-methods/devices.ts 597 577 20 implemented: One parameterized rotate/revoke handler owns validation, authority, mutation and refusal; post-commit token delivery and teardown remain explicit branches with unchanged awaits. devices.test.ts;devices.lifecycle.test.ts (results recorded separately)
src/gateway/server-methods/exec-approval.ts 587 587 0 rejected: Cross-owner exec/plugin shared review prototypes measured by admin: full factory combined890→906 (+16), observation-only890→892 (+2). Retained distinct review handlers and existing shared lifecycle owner.
src/gateway/server-methods/control-ui.ts 585 585 0 retained: createGitHubReadHandler already parameterizes both GitHub routes. Session preview, PR checks and subscriptions retain distinct read owner lifetimes; subscription responds at admission while preview must consume and respond synchronously in the authorized frame. src/gateway/server-methods/control-ui.test.ts src/gateway/server-methods/control-ui.session-preview.test.ts
src/gateway/server-methods/tools-effective.ts 584 577 7 applied: Forwarded the internal trusted context into both runtime-model acquisitions, retaining explicit agentDir/workspace overrides. Inspected acquisition/static-reader implementation: neither spreads unknown fields to downstream tools. Kept explicit inventory projection because extra toolOverrides/spawnedBy there WOULD change semantics. src/gateway/server-methods/tools-effective.cache.test.ts;src/gateway/server-methods/tools-effective.global-agent.integration.test.ts;src/gateway/server-methods/tools-effective.test.ts
src/gateway/server-methods/chat-transcript-persistence.ts 581 579 2 implemented: One media-reference Set normalizer serves expected and actual transcript media; rejected-count and generation checks remain at original points. chat-transcript-persistence.mirrors.test.ts;chat-transcript-persistence.generated-media.test.ts (results recorded separately)
src/gateway/server-methods/doctor.ts 580 580 0 REVIEWED_UNCHANGED: PR1 already consolidated dreaming counters into totals and applied shared cron status across the three phase projections. These reductions are present in the frozen PR2 base; no PR2 edit or additional LOC credit applies. Full server-methods directory; results recorded separately
src/gateway/server-methods/system-changes.ts 577 577 0 reviewed-no-change: Re-evaluated the two journal scans and cursor advancement. scanCandidates already parameterizes projection and reader; merged cursors advance consumed raw rows independently. Collapsing them into a heterogeneous collection adds casts or adapters while obscuring independent exhaustion and pending-collapse ownership. src/gateway/server-methods/system-changes.test.ts
src/gateway/server-methods/chat-abort-authorization.ts 569 569 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: createChatAbortRunSelection already owns deduplication and protected/unauthorized tallies for active and preregistered scans. readPreRegisteredAgentDedupePayloadForSession tolerates legacy missing keys for exact-run requests; readPreRegisteredRun requires a session key for broad scans. Agent abort updates all owned agent dedupe keys; chat abort retires its pending attempt and publishes a marker, so their writes retain separate owners. Full server-methods directory; results recorded separately
src/gateway/server-methods/shared-types.ts 565 565 0 retained: Leaf type contract has no duplicated runtime work. Retain SystemAgent engine structural mirror to avoid documented agents/config type cycle; self-indexing model catalog params previously measured 6→3 declaration-only but worsens signature locality. full subsystem typecheck (results recorded separately)
src/gateway/server-methods/workspace-files.ts 559 553 6 implemented: Direct touched-file and host-boundary previews now share one read/response; candidate resolution order and all awaits remain unchanged. sessions-files.test.ts;sessions-files.host-read.test.ts;sessions-files.repository.test.ts (results recorded separately)
src/gateway/server-methods/session-catalog.ts 549 526 23 implemented: Re-evaluated rejected authorization wrapper: narrow the existing authorization helper to explicit access/provider plus validated request options. Four callers retain original await, catch and import reauthorization boundaries; no new wrapper or Promise. src/gateway/server-methods/session-catalog.test.ts src/gateway/server-methods/session-catalog-adoption.test.ts src/gateway/server-methods/session-catalog-import.test.ts src/gateway/server-methods/session-catalog-terminal-start.test.ts
src/gateway/server-methods/push.ts 540 528 12 implemented: Share deferred subscription mutation target, guard construction, binding-change rejection and response continuation through deferMutation. Preserve native/worker guard family and unsubscribe-only UNAVAILABLE mapping. src/gateway/server-methods/push.test.ts src/gateway/server-methods/push-authority.test.ts src/gateway/server-methods/push-authority-in-process.test.ts src/gateway/server-methods/push-authority-router.test.ts src/gateway/server-methods/push-preferences.worker.test.ts
src/gateway/server-methods/chat-send-work-admission.ts 535 535 0 retained: Reference owner combines admission cleanup with settlement custody. Active settlement flag cannot derive from references: one settlement can release while other retainers remain. Refcount arithmetic rewrite would hide zero/retained transitions. chat-send-work-admission.test.ts;chat-send-admission-authority.test.ts (results recorded separately)
src/gateway/server-methods/task-suggestions.ts 532 521 11 applied: Shared acceptance outcome response for pending and already-active calls; constructed common source task context once for session/new-session branches. Claim reservation, owner resolution, catch abandonment, and finally deletion ordering retained. src/gateway/server-methods/task-suggestions-session-start.test.ts;src/gateway/server-methods/task-suggestions.owner-recovery.test.ts;src/gateway/server-methods/task-suggestions.test.ts
src/gateway/server-methods/environments.ts 522 522 0 rejected-prototype: REJECTED measured defineDesktopObserve factory: 522 to 526 (+4), misc-prototypes/environments.ts. Factory only wraps already-shared respondDesktopObserve and adds a request adapter. Applied the sound shared worker service/error core in environments.desktop.ts instead. src/gateway/server-methods/environments.desktop.test.ts;src/gateway/server-methods/environments.node-command-authority.test.ts;src/gateway/server-methods/environments.pairing-snapshot.test.ts;src/gateway/server-methods/environments.pool.test.ts;src/gateway/server-methods/environments.session-exec-approval.test.ts;src/gateway/server-methods/environments.session-exec.test.ts;src/gateway/server-methods/environments.session.test.ts;src/gateway/server-methods/environments.test.ts
src/gateway/server-methods/artifacts.ts 519 519 0 rejected: Built one-await queued/fresh download scan prototype519→519 (0). It replaces the short queued return with a mutable promise and nests the fresh scan; original explicit queued ownership is clearer at equal size. src/gateway/server-methods/artifacts.test.ts
src/gateway/server-methods/skills.ts 518 514 4 implemented: Empty/nonempty security verdict inventories share one result projection; empty inventories still skip network fetch and any await. skills.clawhub.test.ts (results recorded separately)
src/gateway/server-methods/usage.ts 517 517 0 REVIEWED_UNCHANGED: PR1 already passes the resolved session-source bundle into the timeseries and logs readers, retaining their distinct options and responses. This is retained PR1 work, not an omitted PR2 implementation. Full server-methods directory; results recorded separately
src/gateway/server-methods/agents-files.ts 515 494 21 implemented: One response projection for missing/local/remote document results; local fs-safe and remote bridge reads, decoder differences, write bounds and CAS remain unchanged. agents-files.test.ts (results recorded separately)
src/gateway/server-methods/models-auth-status.ts 514 513 1 implemented: Inline the one-use abort adapter at provider-wide logout. Preserve its exact six capabilities; do not pass the full context, whose optional getRuntimeConfig would change abort routing. src/gateway/server-methods/models-auth-status.test.ts src/gateway/server-methods/models-auth-status-rollup.test.ts
src/gateway/server-methods/session-change-event.ts 512 512 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: ownerFor/registerPendingLifetime and startPendingSessionChange/finishPendingSessionChange already centralize debounce lifetime. emitSessionsChanged retains an oldest deletion object and mutates the newest matching object; captureFailed and captured must both be explicitly cleared when absent. Replacing that mutation with a generic object copy would retain stale optional fields or break shared tombstone identity. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-mutation-guards.ts 504 492 12 implemented: One synchronous withCommitGuards continuation retains expected-profile then commit guard order for worker preparation, invocation and target checks. Source assertion metadata and admitted-input authorities remain separate. src/gateway/session-sharing-committed-read.test.ts src/gateway/session-lifecycle-source-authority.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.mutation-authority.test.ts src/gateway/server-methods.session-narrow-mutations.test.ts
src/gateway/server-methods/session-create-project.ts 503 503 0 retained: Re-evaluated common project/materialize/refresh options; source identity checks and refresh retry straddle distinct awaits. Object assign/delete sites retain no-pending versus committed ownership boundaries. session-create-preparation.test.ts;sessions-create-worktree-base.test.ts (results recorded separately)
src/gateway/server-methods/sessions-read.ts 499 493 6 COORDINATOR-APPROVED DEFERRAL: The six-line projected/unprojected error helper was implemented and reviewed, then removed from this PR. This file is byte-identical to the base and receives zero final credit; historical columns record the original implementation. src/gateway/server-methods/sessions-read-active.test.ts;src/gateway/server-methods/sessions-read-async.test.ts;src/gateway/server-methods/sessions-read-cache.test.ts;src/gateway/server-methods/sessions-read-catalog-scope.test.ts;src/gateway/server-methods/sessions-read-diagnostics.test.ts;src/gateway/server-methods/sessions-read-fixture-lifetime.test.ts;src/gateway/server-methods/sessions-read-metadata.test.ts;src/gateway/server-methods/sessions-read-owner-counts.test.ts;src/gateway/server-methods/sessions-read-visibility.test.ts;src/gateway/server-methods/sessions-read.test.ts
src/gateway/server-methods/approval.ts 490 487 3 implemented: Inline a single-use resolution argument bundle into its sole decision call; manager choice, force-deny fallback, guard and grant expiry evaluation remain in their original order. src/gateway/server-methods/approval.test.ts src/gateway/server-methods/approval.settlement.test.ts src/gateway/server-methods/approval.channel-custody.test.ts src/gateway/server-methods/approval.legacy-authority.test.ts src/gateway/server-methods/approval.request-authority.test.ts
src/gateway/server-methods/usage-session-selection.ts 482 469 13 APPLIED: Move private family mapper inside its sole selection owner, eliminating repeated grouping/map parameters at both callers; instance/family precedence and visibility checks unchanged. Existing focused/full test targets: usage.sessions-usage.test.ts usage.sessions-usage-owner-attribution.integration.test.ts
src/gateway/server-methods/chat-restart-recovery.ts 481 481 0 reviewed-no-change: Re-read durable claim adoption and terminalization. Existing isAdoptedRestartRecoveryClaim and lifecycle snapshot owners already share behavior. pending/rejected/accepted transitions encode restart receipt ownership; terminalized records committed callback state that cannot derive from returned persistence alone. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/sessions-delete.ts 476 476 0 retained: Re-evaluated common current-reader/retirement strategy; outer release covers pre-mutation failure and finalize owns settled mutation drain, so neither is redundant. Actor and persisted readers carry distinct prepared authority. server.sessions.delete-lifecycle.test.ts;server.incognito-lifetime.test.ts (results recorded separately)
src/gateway/server-methods/workspace-fs.ts 455 453 2 implemented: One workspaceRelativePath projection serves local reads, remote reads, bounded prefixes, edits and session browser metadata; existing fs-safe exports and all I/O/guard order unchanged. workspace-fs.test.ts;agents-workspace.test.ts;sessions-files.test.ts (results recorded separately)
src/gateway/server-methods/chat-send-dispatch-errors.ts 451 451 0 reviewed-no-change: Re-evaluated setup/dispatch terminalization and lifecycle publication. Setup releases request admission before responding; dispatch retires abortability before persistence and defers cached terminal until lifecycle settlement. Common terminalization helper would introduce a new await before cleanup. Existing error classification and formatting are shared. src/gateway/server-methods/chat-send-dispatch-errors.test.ts
src/gateway/server-methods/sessions-compact.ts 450 450 0 reviewed-no-change: Re-evaluated trim/semantic compaction shared core. Existing lifecycle admission, source fence, operations and response owner are shared. Remaining preflight reads deliberately precede and follow admission; introducing an async read helper would add a yield between authority checking and branch consumption. Semantic compaction alone owns terminal accounting and model execution. src/gateway/server-methods/../server.sessions.compaction.test.ts src/gateway/server-methods/../server.sessions.compaction-read-errors.test.ts
src/gateway/server-methods/message-operation-route.ts 449 441 8 implemented: One context-owned route state contains bindings and queue, eliminating duplicate WeakMap allocation/access owners. Binding expiry still runs only through binding reads, not queue acquisition; lock/replay sequencing unchanged. src/gateway/server-methods/send.test.ts src/gateway/server-methods/send.scheduled-reads.integration.test.ts src/gateway/server-methods/send.discord-request-authority.integration.test.ts
src/gateway/server-methods/cron-caller-scope.ts 446 446 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/chat-send-message-injection.ts 443 443 0 historical net-zero change, superseded by main; zero current PR credit: The initial accepted-steer outcome projection was dropped during the second conflict rebase. Current source is byte-identical to main, retaining indeterminate uncertain-steering receipts and preserving the running tool. src/gateway/server-methods/chat-send-message-injection.test.ts;src/gateway/server-methods/chat-send-reply-dispatch.test.ts;src/auto-reply/reply/reply-run-registry.visibility.test.ts
src/gateway/server-methods/system-agent-approval.ts 437 437 0 retained: Proposal cleanup already serves entry, registration, and apply failures. Remaining local session checks protect separately awaited proposal, record, task and transcript boundaries; short helper prior 437→438 still grows. system-agent-approval.test.ts (results recorded separately)
src/gateway/server-methods/chat-history-page-kernel.ts 432 426 6 applied: Shared canvas augmentation plus reply attachment decoration for anchored pages and incremental tails. Cost-group traversal and anchor-boundary traversal retain distinct cost callback contracts and custom sequence readers. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/plugins.ts 428 424 4 APPLIED: One catalog failure mapper with explicit subject phrases for discovery/categories/details; preserve singular/plural text exactly and retain each handler own fallback. Existing focused/full test targets: plugins.test.ts
src/gateway/server-methods/session-catalog-list.ts 426 426 0 rejected: Built shared coalesced/fresh delivery tail426→423 (-3). It requires nesting153 lines inside a start closure and conditional ownership checks in catch/finally, less clear than independent coalesced early return. Original projection loops retain no new Promise yields. src/gateway/server-methods/session-catalog.test.ts
src/gateway/server-methods/users.ts 420 414 6 applied: Moved merge/display-name schema and error boilerplate into existing defineValidatedGatewayHandler with profileError; original options identity retained. REJECTED full preference get/set factory prototype: current 414 to 416 (+2), misc-prototypes/users-preferences.ts; differing error rethrow stays explicit. src/gateway/server-methods/users-auth-connect.control-plane.test.ts;src/gateway/server-methods/users-auth-connect.test.ts;src/gateway/server-methods/users-enumeration.worker.test.ts;src/gateway/server-methods/users-github.test.ts;src/gateway/server-methods/users-list.test.ts;src/gateway/server-methods/users-personal-file.test.ts;src/gateway/server-methods/users-preferences.test.ts;src/gateway/server-methods/users-role.worker.test.ts;src/gateway/server-methods/users.test.ts
src/gateway/server-methods/chat-send-source-finalization.ts 412 412 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: shared authority; retain current predicate and dropped result Full server-methods directory; results recorded separately
src/gateway/server-methods/system.ts 411 411 0 prototype-rejected: Formatted presence-field strategy table: 411 -> 411 (0). Nine-line table replaces nine-line direct app/mode/reason handling but adds positional boolean/label/value/fallback tuples and eagerly captures fields. Direct conditional projections are clearer; .local/d01-p2/sessions-prototypes/system.ts. src/gateway/server-methods/system-info.test.ts src/gateway/server-methods/system-event-routing.test.ts
src/gateway/server-methods/channel-pairing.ts 410 406 4 implemented: Reuse publicAccount projection for request rows; raw code remains omitted and sender/metadata/expiry fields retain their original owners. src/gateway/server-methods/channel-pairing.test.ts
src/gateway/server-methods/sessions-patch-model-selection.ts 406 406 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: share prepared and ordinary selection policy arguments Full server-methods directory; results recorded separately
src/gateway/server-methods/mcp-app.ts 402 398 4 implemented: Existing requested-view resolver now accepts prepared config/requester facts for operationHandler. Original config reads, requester capture, restore:false and post-await authority checks stay at their existing boundaries. src/gateway/server-methods/mcp-app.test.ts
src/gateway/server-methods/nodes.pairing.ts 401 401 0 reviewed-no-change: Re-evaluated approval/rejection/removal common handling. Pending ownership is already shared; approval additionally rotates pairing generation and updates only the retained connection while removal invalidates before replying and disconnects in finally. Shared event construction alone would need a separate return/broadcast adapter and does not replace those distinct owners. src/gateway/server-methods/nodes.test.ts
src/gateway/server-methods/sessions-reactions.ts 401 401 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: reactionScope and withSessionReactionAccess already share target selection. resolveMirrorTransport makes a synchronous first/last-reactor decision; mirrorReaction preserves FIFO order per transport slot and rechecks the persisted conversation at delivery. reactions.list only reads; reactions.set commits once, emits events only for a changed row, then mirrors. No duplicated reaction writer or queue owner remains. Full server-methods directory; results recorded separately
src/gateway/server-methods/migrations.ts 399 394 5 implemented: Pass the complete existing provider-plan parameter record directly to its owner; removes single-use four-field repack without changing plan input keys or call order. migrations.test.ts;migrations.resources.test.ts (results recorded separately)
src/gateway/server-methods/chat-send-reply-finalization.ts 398 398 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: shared finalizer authority/base contract plus retainCommittedChatReplyMedia callback used by reply dispatch; alternative placement in authority module was prototyped at net -2 LOC and rejected for mixing persistence side effects with authority; finalization-owner placement measured net -4 LOC and implemented Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-reply-media.ts 397 397 0 retained: Re-read the one shared normalizer and grouped reply builder. The preserved-audio/mixed-media branches already share createReplyMediaPathNormalizer; mixed payloads uniquely accumulate text, attachment positions and only newly observed failure receipts. A per-entry-only rewrite would replace whole-payload normalization and its metadata semantics, not eliminate a duplicate core. chat-reply-media.test.ts;chat-reply-media.workspace.test.ts;chat-reply-media.authority.test.ts; results recorded separately
src/gateway/server-methods/session-catalog-list-lifetime.ts 396 396 0 reviewed-no-change: Re-read synchronous/prepared subscriber drains and provider work. Native pending work outlives delivery abort and cannot derive from subscriber pending. Synchronous drain retains its captured current subscriber across prepare; async drain revalidates after every await. Existing callback holder explicitly releases request captures. src/gateway/server-methods/session-catalog-list-lifetime.test.ts
src/gateway/server-methods/chat-send-attachments.ts 395 395 0 reviewed-no-change: Re-read staging and media custody. Managed-PDF fallback, remote workspace bypass, sandbox size rejection, cancellation and post-ACK media custody are distinct exits around one staging call. Each authority check follows its owning awaited preparation; no second staging implementation. src/gateway/server-methods/chat-send-attachments.cancel.test.ts;src/gateway/server-methods/chat-send-attachments.owner.test.ts;src/gateway/server-methods/chat-send-attachments.private-skills.test.ts
src/gateway/server-methods/secrets.ts 388 388 0 retained: mutateStore already parameterizes set/delete owner and retains synchronous guard capture plus awaited attempt settlement. reload,resolve,list error messages are distinct and contain only 2/2/6 lines; typed shared failure helper plus calls would merely reshuffle them. secrets.test.ts;secrets.lifecycle.test.ts (results recorded separately)
src/gateway/server-methods/mcp-app-extensions.ts 387 387 0 prototype-rejected: Formatted launchOrCall prototype: 387 -> 392 (+5). It adds a fourth async dispatch layer only to choose existing call/launch owners, while launch retains view-lease transfer and call retains form authority. Reject longer indirection; .local/d01-p2/sessions-prototypes/mcp-app-extensions.ts. src/gateway/server-methods/mcp-app-extensions.test.ts
src/gateway/server-methods/nodes.read.ts 386 386 0 MEASURED_REJECTION: Implemented shared connected-node surface updater with explicit tools/skills callbacks: formatted 386 -> 388 (+2). Reverted own prototype; the strategy callback/result projection costs more than the two remaining concrete handlers. Previous factory was 386 -> 383 but required generic four-argument strategy and weakened readability; this simpler second implementation also failed the size bar. NOT RUN; unchanged production
src/gateway/server-methods/themes.ts 383 383 0 retained: readThemes/writeThemes own shared profile/catalog/storage logic. Extracting post-save read/response into async write owner would move publication/read scheduling; selection-field helper previously measured4→9 grows5. themes.test.ts (results recorded separately)
src/gateway/server-methods/sessions-lifecycle-drain.ts 377 371 6 applied: Applied owning SessionLifecycleParams directly to hasGatewaySessionAbortOwner; callee reads exactly context/sessionKeys/sessionId/agentId/defaultAgentId, never enumerates or retains the container. Same short-circuit position and all settlement, cancellation, reclaim and authority checks remain. ../server.sessions.archive-lifecycle.test.ts;../server.sessions.archive-worktree-lifecycle.test.ts; results recorded separately

Final committed candidate: 3fa749dfb9ba45ebf64552d168d25580551981c8. The search-handler deferral is reviewed and committed; focused types, lint, and both cycle checks passed. Hosted CI is bound to this new head. The PR body owns current test and CI dispositions.

@steipete

steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

d01 PR 2 coverage, part 2 of 6

Continuation of the historical per-file coverage. Current working candidate: 862 net production lines across 112 files against 54bd6ecee1897f51b2963b6ea4c165a356e2d805, including the pending nine-line cancellation cleanup. Test targets below are not proof claims.

File Before Initial after Initial net removed Decision and rationale Existing test targets
src/gateway/server-methods/chat-assistant-content.ts 373 361 12 applied: Shared managed outgoing block classification for presence and stripping, with explicit includeAttachmentBlockUrls parameter retaining their distinct attachment URL semantics. Display/persisted media and text assembly ordering unchanged. src/gateway/server-methods/chat-assistant-content.media-authority.test.ts
src/gateway/server-methods/sessions-patch-archive.ts 369 369 0 reviewed-no-change: Re-evaluated shared-core extraction: prepareSessionPatchArchive.resolveCurrent already shares initial and commit-edge source/ownership checks. Its pre-projection placement check deliberately sets validateModelRuntime=false; preview rechecks projected entry with true. validateSessionPatchArchiveProjection fences writer snapshots; prepareSessionPatchArchiveTransition delegates restore and returns its commit guard. No equivalent variants remain to collapse. src/gateway/server-methods/sessions-mutations.archive-attribution.test.ts src/gateway/server-methods/sessions-mutations.catalog-queue.test.ts
src/gateway/server-methods/request-authorization.ts 367 361 6 APPLIED: One synchronous method/startup/profile/scope reauthorization core; explicit assertion callback distinguishes invocation from preparation and release callback preserves final-access cleanup. Existing focused/full test targets: ../server-methods.dispatch-authorization.test.ts ../server-methods.canonical-validation.test.ts ../session-row-prepared-read.test.ts
src/gateway/server-methods/chat-send-commentary-media.ts 361 361 0 reviewed-no-change: Re-evaluated shared-core extraction: observeChatSendCommentaryMedia serializes committed commentary rewrites, captures writer authority, and distinguishes not-committed cleanup from uncertain worker outcomes. Its first projection wait repairs a missing anchor; the later wait precedes the rewrite after media preparation. createAssistantCommentaryMediaCustody owns the outer attempt observer lifetime. Removing either wait or merging cleanup paths changes custody. src/gateway/server-methods/chat-send-commentary-media.test.ts
src/gateway/server-methods/session-active-runs.ts 360 360 0 reviewed-no-change: Re-read key/id owner matching and indexed projection. Canonical/requested keys already share ordered matching. Session-id fallback intentionally omits key-derived owner resolution. Independent tracked, embedded, projected and subagent registries cannot derive liveness from one another. src/gateway/server-methods/session-active-runs.test.ts
src/gateway/server-methods/update-admission.ts 356 356 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: admitGatewayUpdateRequest rejects host/immutable ownership before OCM/native routing. resolveGatewayUpdateAdmission owns installation inspection once. recordHandoffFailure records a requested step with null exit code, whereas createUnexpectedUpdateFailureResult uses the active ledger step, exit code 1, elapsed duration and rollback facts. Their common ledger API is already the shared owner; their failure records represent different outcomes. Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-github.ts 355 355 0 retained: Options/status share defineSessionGitHubMethod and publicationStateUnavailableError already. Options additionally owns deadline revocation, shared identity preparation and personal/shared reconciliation; status performs prepared personal lookup before shared lookup. No repeated preparation segment can be moved across those awaits without changing the captured authority timeline. sessions-github.test.ts;sessions-github-read.test.ts;sessions-github-read.guest.test.ts; results recorded separately
src/gateway/server-methods/chat-send-user-turn.ts 346 346 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: prepareChatSendUserTurn uses one persistedMediaForTranscriptPromise for transcript facts, plugin-bound media and abandoned-media cleanup. buildTextContext serves original and approved text; applyChatSendManagedMedia already parameterizes replace-empty versus append-missing. Prompt image order, transcript image layout and requester-profile binding are distinct projections of that shared input, not independent persistence paths. Full server-methods directory; results recorded separately
src/gateway/server-methods/worktrees.ts 344 327 17 applied: Shared custom schema validation across all eight methods without copying original options. Shared STATE_OWNER_CHANGED error projection with exec approvals via local-state-owner; expected repo identity, optional/required owner guards, lossless removal and snapshot receipts remain explicit. src/gateway/server-methods/worktrees.authorization.test.ts;src/gateway/server-methods/worktrees.remove-restore-trim.test.ts;src/gateway/server-methods/worktrees.test.ts
src/gateway/server-methods/chat-history-session-read.ts 343 343 0 retained: Selected, excluded, and retained-history reads share source/visibility helpers but consume different exact row/transcript identities. Factory around those branches would require authority and error strategies without eliminating owning reads. chat-history-ownership.test.ts;chat-read-scope.rpc.test.ts (results recorded separately)
src/gateway/server-methods/chat-send-request.ts 341 341 0 retained: ordinaryChat already combines annotation/work-context admissibility. Provider-review, goal, and command paths preserve different normalization and error precedence; common field arrays would hide defined-versus-truthy distinctions and miss protocol text. chat-send-request.test.ts (results recorded separately)
src/gateway/server-methods/skills-library.ts 333 329 4 applied: Applied one local resolveTarget closure for initial activation selection and post-await identity checks. It rereads runtime config and current sessionKey at both original sites; conflict checks, planned selection admission and commit assertions unchanged. skills-library.test.ts;../skill-library-authoring.test.ts; results recorded separately
src/gateway/server-methods/chat-send-command-replies.ts 327 327 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: selectChatSendFinalReplyInputs centralizes block/final folding. mergeDefinedReplySemantics delegates media-only properties to mergeMediaReplySemantics; the former also merges reply targets, status/error and presentation fields. Prepared inputs must retain plan ownership, while raw inputs may fold matching media/text; fieldwise true-OR and defined-value precedence cannot be replaced by one object spread. Full server-methods directory; results recorded separately
src/gateway/server-methods/usage-date-range.ts 320 320 0 implemented: Share UTC midnight calculation for UTC and fixed-offset modes; retain offset adjustment as the explicit variant. Zero-line reduction; civil-zone and skipped-date handling untouched. src/gateway/server-methods/usage.test.ts
src/gateway/server-methods/claws-monitors.ts 315 315 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: inspectMonitors corroborates scheduler rows; claws.monitors quiesce/drain validates the deletion journal, waits for cron receipts and calls prepareAgentDeleteDatabases. This is deletion/config-retirement and scheduler custody in the reserved repair scope; no edit or prototype attempted. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-catalog-provider-access.ts 314 314 0 reviewed-no-change: Re-evaluated shared-core extraction: runSessionCatalogListSteps retains plugin consumer through next/close and completion callbacks; listSessionCatalogProvider legacy list path has no step iterator. createCatalogListCompletionOwner already centralizes deferred release. catalogRegistrationSnapshot rejects colliding share routes; resolveProviderCreateTarget caches only successful resolver execution. These caches and lifetimes have different invalidation keys, with no repeated equivalent body. src/gateway/server-methods/session-catalog-provider-access.test.ts src/gateway/server-methods/session-catalog-owner-steps.test.ts
src/gateway/server-methods/agent-session-patch.ts 313 312 1 applied: Removed redundant inheritedGroup=undefined from the catch: the only assignment is the final expression in its try, so every throwing path leaves the fresh variable undefined. Canonical-key migration errors still rethrow. agent-session-patch.test.ts;../agent-turn/agent-session-reuse.test.ts; results recorded separately
src/gateway/server-methods/sessions-suggestions-access.ts 311 301 10 applied: Reused already-destructured client/cfg/sharing in shared role and draft authorization calls, deleting repeated parameter projection. Both authorization invocations and all guard order remain unchanged. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/chat-send-turn-adoption.ts 303 303 0 retained: Terminal receipt core already parameterizes completion kind. enqueued/steered/terminalKnown are not derivable from map membership because settlement removes both terminal and steered entries. Shared release helper would replace4 lines with5. chat-send-queued-identity.test.ts;progress-card-refresh.queued.test.ts (results recorded separately)
src/gateway/server-methods/plugin-approval.ts 303 303 0 rejected prototype: Full list/wait/resolve shared factory with exec-approval measured combined 890→906 (+16); observation-only 890→892 (+2). Generic callback and authority ownership types exceed removed adapter bodies. Both formatted prototypes retained in admin-prototypes. plugin-approval.test.ts;plugin-approval.agent-runtime.test.ts (results recorded separately)
src/gateway/server-methods/tts.ts 303 303 0 reviewed-no-change: Re-read convert/speak/settings. Convert returns local paths and explicit override errors; speak performs max-byte/secret admission and returns inline bytes. They use different canonical synthesis APIs. Status/provider lists already share prepared provider facts; enable/disable share one parameterized handler. src/gateway/server-methods/tts.test.ts
src/gateway/server-methods/config-write-flow.ts 294 294 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/web-search-status.ts 291 291 0 reviewed-no-change: Re-evaluated shared-core extraction: credentialSource orders configured value, environment, configured fallback, then auth profile; the two value checks straddle the environment priority. prepareWebSearchStatus resolves one model and selects disabled/native/external/not-ready/managed routes with different testability and exact guidance. No parallel provider request loop or repeated acquisition owner is present. src/gateway/server-methods/web-search.test.ts
src/gateway/server-methods/chat-user-turn-recorder.ts 290 290 0 reviewed-no-change: Re-evaluated shared-core extraction: createGatewayChatUserTurnController constructs one recorder, one evolving input promise, and one mention commit. beforeMessageWrite fences fresh original input only; onOriginalInputCommitted filters retained mention spans against committed bytes; persist awaits transcript then mention custody. These callbacks act at different commit phases, so they cannot share an interchangeable write path. src/gateway/server-methods/chat.inject.parentid.test.ts
src/gateway/server-methods/agent-session-prepare.ts 289 286 3 applied: Derived visibleRequest from the existing isSystemGatewayRun fact instead of repeating cron/heartbeat exclusion. Computation moves across no await or mutation; initial and admitted session reads and all retry errors unchanged. ../agent-turn/agent-session-reuse.test.ts;artifacts.images.test.ts; results recorded separately
src/gateway/server-methods/github-personal-authorization.ts 288 288 0 retained: Shared currentGitHubClient is the actual scope core. Read allows absent human profile and snapshots archive state; action requires personal owner and rejects archived rows. Another common target reader would add options for errors, profile requirements, archive and sharing policy. github-personal-authorization.test.ts (results recorded separately)
src/gateway/server-methods/chat-metadata-session-projection.ts 285 271 14 applied: Inlined private single-use projectChatSessionMetadata into readPreparedChatMetadata, removing parameter threading while preserving account read, model overlay, sessionless early return, and runtime-lock projection order. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/nodes.wake.ts 282 282 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: maybeWakeNodeWithApns and maybeSendNodeWakeNudge share clearStaleApnsRegistrationIfNeeded and the runNodeWakeAttempt/runNodeWakeNudgeAttempt state owners. Wake duration starts inside the admitted attempt and catches registration-load failures; nudge duration starts before lifecycle capture and loads registration outside its send catch. Nudge additionally rechecks after stale-registration clearing and preserves a sent fact on invalidation. Those differences prevent treating their callbacks as interchangeable. Full server-methods directory; results recorded separately
src/gateway/server-methods/users-personal-file.ts 282 282 0 reviewed-no-change: Re-evaluated shared-core extraction: Share stable result identity across present missing and saved payloads src/gateway/server-methods/users-personal-file.test.ts
src/gateway/server-methods/models-auth-status-usage-cache.ts 280 280 0 reviewed-no-change: Re-read cache identity, SWR and timeout retention. cacheGeneration fences clear-and-replace; refresh object identity independently fences newer in-flight work. Identity fields are intentionally copied without retaining authStore/provider arrays in cached results. Scalar model-status and usage-status cold-read contracts differ. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/session-catalog-list-operations.ts 275 275 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: getSessionCatalogListOperations retains a config generation and per-client operations under one retirement controller. Caller close releases provider entries and clears pages; generation retirement aborts every caller then clears its own maps. startProviderOperation owns provider retention/deadlines; listSessionCatalogWithinBudget joins that operation and projects cached or pending hosts. Cached page identity and active operation lifetime are different state, not duplicate stores. Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-patch-expectations.ts 274 274 0 retained: Expected fields use strict/nullable/deep-equality comparisons with distinct failure precedence. Re-evaluated target identity projection: previous typed construct-and-delete prototype274→286 adds12; no shared generic serializer has same undefined omission shape. server.sessions.patch-expected-identity.test.ts (results recorded separately)
src/gateway/server-methods/sessions-subscriptions.ts 274 261 13 applied: Applied shared provisional subscription and rollback scaffold with explicit includeApprovals branch. Approval replay preparation/retry checks retain order and original catch scope; plain subscription commit remains inside its rollback catch while approval commit remains outside. Removed two aliases of validated params. sessions.messages-subscribe-approvals.test.ts;sessions.messages-subscribe-wait.test.ts;sessions.messages-subscribe-metadata.test.ts; results recorded separately
src/gateway/server-methods/update-status.ts 271 271 0 retained: Sentinel/checkout/reconciliation/identity recovery already shares warn(stage,error), but its different fallback values and conditional manager execution belong at original awaits. Result validation labels are distinct; merging the two response checks requires passing validators, labels and response closures, exceeding their current direct blocks. update-status.test.ts;update-status-schedule.test.ts;update-status-sentinel.test.ts; results recorded separately
src/gateway/server-methods/session-catalog-entry-snapshot.ts 268 268 0 reviewed-no-change: Re-evaluated shared-core extraction: createSessionCatalogRequestEntrySnapshot caches planning entries by projection revision/config/agent, freezes before provider I/O, and separately projects current adoption identity in projectHostSessions. entriesForAgent/entryIndexForAgent share row selection without repeated SQLite reads. Actor cache is request-scoped, whereas planning cache is revision-scoped; merging them would retain stale identity or rebuild indexes per lookup. src/gateway/server-methods/session-catalog-entry-snapshot.test.ts
src/gateway/server-methods/exec-approvals.ts 266 262 4 applied: Shared exact STATE_OWNER_CHANGED error projection with worktrees via local-state-owner. Local get/set keep distinct missing-state/hash behavior and node handler remains one policy/invoke owner. src/gateway/server-methods/exec-approvals.test.ts
src/gateway/server-methods/update-report.ts 263 263 0 reviewed-no-change: Re-read ledger/sentinel selection, consent digest, public projection and publication authority. Preview and submit already share preparation; repeated authority checks remain around provider publication. Different created/fallback result optionality is protocol-visible and retained. src/gateway/server-methods/update-report-run.test.ts;src/gateway/server-methods/update-report.test.ts
src/gateway/server-methods/sessions-messaging.ts 262 262 0 retained: Re-evaluated the admission paths: send and steer already share handleSessionSend. ACK facts intentionally capture cached/runId/interruptedActiveRun before respond may mutate payload; deriving them afterward changes behavior. Reactivation and ordinary publication have different error cleanup and cannot replace receipt capture. ../server.chat.gateway-server-chat.test.ts;../server.sessions.store-rpc.test.ts;../server-methods.session-narrow-mutations.test.ts; results recorded separately
src/gateway/server-methods/chat-broadcast.ts 261 261 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: pass existing node-delivery parameters to shared session-key resolver Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-goal.ts 261 261 0 retained: Update/clear/resume already share mutation owner and source authority. Resume dispatch and direct mutation must retain different receipt/write owners; source failure releases both acquired authorities in reverse lifecycle order. sessions-goal.test.ts;sessions-goal.event-custody.test.ts (results recorded separately)
src/gateway/server-methods/agents-workspace.ts 260 245 15 implemented: Text/image variants share content selection, unsupported refusal, and final file projection; only image paths await MIME detection, and each retains the same size/decoder gate. agents-workspace.test.ts (results recorded separately)
src/gateway/server-methods/web-search.ts 259 257 2 applied: Applied shared successful search envelope for results and answer; explicit variant content projections retain unwrap order, own undefined citations and cached flag. Error results retain selected rather than executed provider and identical authority/credential checks. web-search.test.ts;web-search.authority.test.ts; results recorded separately
src/gateway/server-methods/approval-record-lookup.ts 255 241 14 implemented: Inline single-use lookup refusal mapper at narrowed none/ambiguous branch; simplify final visibility truth table while retaining all authority and storage checks. approval-shared.test.ts;approval.legacy-authority.test.ts;plugin-approval.test.ts (results recorded separately)
src/gateway/server-methods/chat-history-delta.ts 251 251 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: one exact limits builder for incognito/local/worker reads; no changed maxBytes or maxEvents Full server-methods directory; results recorded separately
src/gateway/server-methods/environments.session.ts 250 250 0 reviewed-no-change: Re-read attached environment create/status/destroy. Shared caller owner handles synthetic/operator policy and live session identity. Create additionally owns presentation permission and UI handoff; destroy binds canonical session attachment; status projects null separately. No duplicate attached service owner. src/gateway/server-methods/environments.session-exec-approval.test.ts;src/gateway/server-methods/environments.session-exec.test.ts;src/gateway/server-methods/environments.session.test.ts
src/gateway/server-methods/chat-history-budget.ts 248 248 0 reviewed-no-change: Re-evaluated shared-core extraction: createChatHistoryByteCounter accounts for message plus optional activity framing; createChatHistoryDeltaByteCounter accounts for a snapshot-overlaid envelope. boundInFlightRunSnapshotForChatHistory retains startedAt, event suffix, plan, then text in that priority. The counters have different framing contracts; replacement placeholders and unavailable sentinel handle different size outcomes. src/gateway/server-methods/chat-history-budget.test.ts
src/gateway/server-methods/approval-visible-record.ts 247 247 0 reviewed-no-change: Re-evaluated shared-core extraction: Shared session/reviewer visibility with lazy source/reviewer suppliers: config read precedes source fields; session authorization precedes reviewer binding read; preserves synchronous reentrancy order src/gateway/server-methods/approval.test.ts src/gateway/server-methods/approval.request-authority.test.ts src/gateway/server-methods/approval.legacy-authority.test.ts
src/gateway/server-methods/artifacts-session-resolution.ts 245 245 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: createArtifactSessionAccess is the shared HTTP/RPC release owner. prepareArtifactSessionResolution captures the query, resolves run versus explicit-session addressing and exposes one readCurrent fence used before delivery. artifactResponseIsCurrent only translates its typed error to RespondFn; it does not repeat authorization or facts acquisition. Full server-methods directory; results recorded separately
src/gateway/server-methods/models-auth-status-facts.ts 242 239 3 APPLIED: Share configured provider tracking after the existing per-source eligibility/normalization checks; same API-key exclusion and OAuth expectation sets. Existing focused/full test targets: models-auth-status.test.ts models-auth-status-rollup.test.ts
src/gateway/server-methods/session-catalog-visibility.ts 242 242 0 retained: Provider enumeration awaits must be followed by synchronous current policy/read selection. Previously prepared-visibility async helper242→241 adds a yield at that boundary; rechecked explicit strategy cannot share that awaited core safely. session-catalog-visibility.test.ts;session-catalog-privacy.test.ts (results recorded separately)
src/gateway/server-methods/chat-origin-routing.ts 240 236 4 applied: Inlined private one-call ACP segment predicate into binding result. Same optional chaining, split/includes and Boolean coercion; binding lookup/account gate unchanged. chat-webchat-acp-binding.test.ts;../managed-image-attachments.test.ts; results recorded separately
src/gateway/server-methods/plugin-host-hooks.ts 239 239 0 retained: Session action validator already shares refusal projection. UI descriptors and action results use distinct schemas/error codes and dynamic scope checks; returning wireResult directly would leak extra plugin fields that current projections omit. plugin-host-hooks.registry.test.ts (results recorded separately)
src/gateway/server-methods/approval-request-authority.ts 238 238 0 reviewed-no-change: Re-read broad then source-narrowed policy capture. Worker grant and native authority intentionally select different guard families, then share assertPolicyCurrent. configRevoked records intermediate revoke/restore transitions and cannot derive from latest config alone. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/memory-search.ts 234 234 0 reviewed-no-change: Re-evaluated shared-core extraction: memory.search v1 uses a transient legacy MemorySearchManager, floors/clamps maxResults, exposes searchMode/staleness, and closes the manager in finally; version 2 delegates to memory-provider. memory.get/status are intentional lazy imports. Versioned parameter validation and wire results differ, so merging parsers or provider ownership would change the shipped contract. src/gateway/server-methods/memory-search.test.ts
src/gateway/server-methods/agent-reset-phase.ts 233 233 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: runAgentResetPhase records reset completion at the reset commit and again after the returned reset identity is known. Post-reset text continues admission; a bare reset instead delivers an acknowledgement, caches its result and records reply failure without replaying reset. The shared performGatewaySessionReset owner already owns the reset itself; the two completion observations protect different failure windows. Full server-methods directory; results recorded separately
src/gateway/server-methods/conversations.ts 233 233 0 retained: send/turn already share handleConversationWrite and explicit method variant. Durable input errors and operation conflicts need different dedupe lifetime; deriving releaseRequestIdentity from outcome loses conflict category. conversations.test.ts (results recorded separately)
src/gateway/server-methods/audit.ts 232 232 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/wizard.ts 232 232 0 rejected-prototype: Rejected measured nextWizardResult shared completion prototype: 232->238 formatted lines (+6). Typed context/session/id helper and calls exceed two direct terminal drains; helper also hides their response boundary. Original sanitization and wizardSessionHandler remain shared. wizard.test.ts;../gateway-wizard.e2e.test.ts;../gateway-wizard-cancel.e2e.test.ts; results recorded separately
src/gateway/server-methods/cron-runs.ts 231 231 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/chat-metadata-handler.ts 227 227 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveChatMetadataReadParams shares assertRequestCurrent, then saved sessions retain prepareChatMetadataSessionRead and visibility fences while drafts retain requester/account selection only. handleChatMetadataRequest uses createPreparedReadHandler for one lifecycle. Saved-session release/withCurrent and draft personal-selection validation are not interchangeable flows; no duplicate preparation owner was found. src/gateway/server-methods/chat-metadata-handler.test.ts
src/gateway/server-methods/cron-history.ts 227 227 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/device-scope-upgrade.ts 227 227 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: readUpgradeOwner and respondDeviceRequired already serve requestUpgrade and waitUpgrade. RequestUpgrade verifies the paired public key, proposed scopes and current-scope inclusion before creating pairing; waitUpgrade releases an approved token only under the current role ceiling. Request creation and identity-bound waiting are separate coordinator operations, with different public refusal text. Full server-methods directory; results recorded separately
src/gateway/server-methods/tools-catalog.ts 224 224 0 reviewed-no-change: Re-read static/plugin groups. PR1 appendTool already shares group/seen/default metadata; declared tool fallback and materialized tool metadata preserve distinct summary and parameter semantics. No additional competing group builder. src/gateway/server-methods/tools-catalog.test.ts
src/gateway/server-methods/session-catalog-gateway-copy.ts 223 223 0 retained: Copy shares createGatewaySession/import owner; explicit untrusted copy warning, model availability decision and abortable catalog waiting distinguish import. Common outer creation wrapper would relocate commit authority and add a promise boundary. session-catalog-gateway-copy.test.ts (results recorded separately)
src/gateway/server-methods/system-agent-setup-wizard.ts 223 223 0 excluded: EXCLUDED: activation delegates to system-agent-execution/config-retirement owner. Read only; no edits. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/core-handlers.ts 222 222 0 retained: Re-evaluated largest static loader table. Each entry binds a distinct literal import/export; lazy ownership and eager-closure discovery require those explicit edges. Existing createLazyCoreHandlers/createLazyPromise already own common loading/rejection policy. Prior generic export selector prototype was 222->262 (+40); no additional executable per-family core remains. lazy-core-handlers.test.ts;../server-methods-list.test.ts; results recorded separately
src/gateway/server-methods/chat-webchat-media.ts 221 221 0 retained: The local path resolver, trusted audio reader and image validator implement different security contracts; final builder already joins their results. Per-payload audio/image flags reflect newly added deduplicated blocks, whereas global sets own cross-payload dedupe and final fallback text. Neither can derive the other without extra scanning. chat-webchat-media.test.ts;chat-reply-media.authority.test.ts; results recorded separately
src/gateway/server-methods/memory-provider.ts 221 221 0 reviewed-no-change: Re-evaluated shared-core extraction: handleMemoryProviderRequest already owns search/get/health admission, provider acquisition, response, close, and authority release. parseOperation preserves operation-specific error order; captureMemoryReadAuthority distinguishes admitted synthetic runs from live operator sockets. No second provider-execution pipeline remains. src/gateway/server-methods/memory-provider.test.ts
src/gateway/server-methods/sessions-groups.ts 221 221 0 MEASURED_REJECTION: Implemented shared mutation error responder: 221 -> 223 (+2); revised shared error-shape mapper: 221 -> 228 (+7). Reverted own prototypes. Put publishes only success/catalog changes while rename/delete publish in finally; existing shared validated handlers already own validation and a larger mutation strategy would obscure those boundaries. NOT RUN; unchanged production
src/gateway/server-methods/message-action-context.ts 219 219 0 reviewed-no-change: Re-read capability redemption and action guards. Fenced reads, scheduled writes, and delivery attempts intentionally carry separate owner assertions composed by createAgentRuntimeAuthorityGuard. Empty/non-empty context projections differ in authenticated requester selection and signed identity validation. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/chat-transcript-inject.ts 215 207 8 implemented: One transcript scope serves settled-abort and ordinary append variants. Their independent append owners, identity checks, expected revisions, predicates and result projections remain intact. src/gateway/server-methods/chat.inject.parentid.test.ts src/gateway/server-methods/chat-history-delta.test.ts src/gateway/server-methods/chat.abort-cascade.test.ts
src/gateway/server-methods/cron-creator-authority-admission.ts 214 214 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/cron-input-validation.ts 213 213 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/session-processes.ts 213 213 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: observeProcesses already parameterizes list/stop and shares select, queries and assertCurrent. Remote work requires an active worker-turn placement and asynchronous publication revalidation; local work consumes readBackgroundProcesses/stopBackgroundProcess. The list-only canStop projection checks mutation scope after reading; it cannot be shared with the stop result shape. Full server-methods directory; results recorded separately
src/gateway/server-methods/models.ts 208 205 3 applied: Applied one error response after ordered typed error classification. Unknown provider, sharing authorization, superseded publication retry and account authority retain original instanceof precedence and shapes; unrecognized errors still rethrow. models.prepared.test.ts;models-list.membership.integration.test.ts;models-list.freshness.integration.test.ts; results recorded separately
src/gateway/server-methods/chat-metadata-session-read.ts 207 207 0 retained: Incognito and durable read owners both expose current callbacks but only durable paths own refreshable predicates and registered resource settlement. Common return helper would need six callback parameters and duplicate selected read types. chat-metadata-handler.test.ts;chat-metadata-invalidation.test.ts (results recorded separately)
src/gateway/server-methods/web.ts 205 203 2 applied: Applied generic QR-login entry owner combining parameter validation, provider resolution, bound method selection and catch. Start/wait callbacks explicitly retain distinct stop/restart behavior and emit success themselves, so no new awaited boundary precedes their response. Formatted 205->203. web.start.test.ts;web.gateway.test.ts; results recorded separately
src/gateway/server-methods/agent-session-reset.ts 199 199 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveBareSessionResetResult skips delivery when unrequested, prepares the session delivery plan once, rechecks authority after each await, and gives main/global resets their existing best-effort default. buildBareSessionResetResult/Response are separate payload and RPC-envelope builders. No duplicate send execution exists inside the file. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/session-catalog-import.ts 199 199 0 retained: Imported transcript uses exact source sharing generation plus created-session publication; gateway copy uses model policy and continuation history. Shared payload identity fields small and creation authority differs. session-catalog-import.integration.test.ts (results recorded separately)
src/gateway/server-methods/nodes.pending-work.ts 198 177 21 applied: Validation restored the original typed bridge (+9 lines): runtime enum validation retains static string types. Retained consolidation reused nodes.shared pairing error response with explicit pending-work wording. Wake/reconnect, generation rechecks and invalidated queued-item deletion order retained. src/gateway/server-methods/nodes.pending-work.test.ts
src/gateway/server-methods/tools-github.ts 198 198 0 reviewed-no-change: Re-read configure and OAuth operations. Status/source config, configure install+retire, start preflight, poll generic failure, and cancel unavailable response have distinct error scopes. The repeated agent resolution is outside configure/start catches and must not become a shared catch scope. src/gateway/server-methods/tools-github.test.ts
src/gateway/server-methods/agents-config-mutations.ts 197 197 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/models-probe.ts 196 196 0 reviewed-no-change: Re-evaluated shared-core extraction: mapProbeResult already shares status/error projection for all probe targets. FAILURE_PRIORITY and PROBE_REASON_MESSAGES are existing tables; safeProbeTargetLabel preserves profile/config/environment labels. models.probe performs one runAuthProbes call with fixed token/concurrency bounds. No repeated provider-specific execution path was found. src/gateway/server-methods/models-probe.test.ts
src/gateway/server-methods/device-pair-setup.ts 195 195 0 retained: Setup code and status share unavailable wrapper but own separate writes versus receipt-only projection. Status confirmed/uncertain payload construction is already shared; setup bootstrap profile variants already use explicit expressions. More strategy plumbing would hide the join-only captured admission and QR fallback boundary. device-pair-setup.test.ts;../device-pair-setup-completion.test.ts; results recorded separately
src/gateway/server-methods/sessions-shared.ts 195 195 0 rejected-prototype: Rejected measured shared protected-session message prototype 195->197 (+2): adds an intermediate discriminator and final projection instead of two direct constant error branches. Unknown-before-main ordering and lazy main-session lookup are retained. ../server.sessions.archive-lifecycle.test.ts;../server.sessions.patch-expected-identity.test.ts;../server.sessions.store-rpc.test.ts; results recorded separately
src/gateway/server-methods/session-typing-state.ts 192 192 0 retained: Throttle and active-viewer maps have different pending timers/expiry semantics. LRU helper must explicitly retain empty-key difference (!oldestKey versus undefined), so callback/configuration overhead exceeds two short eviction blocks. sessions-typing.test.ts (results recorded separately)
src/gateway/server-methods/sessions-search-projected.ts 192 192 0 reviewed-no-change: Re-read selection, search and archived preparation. select/sameSelection/matchingHits already share the repeated core. Current owner and config checks after each await are authority revalidation, not redundant state. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/cron-list.ts 189 189 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/session-create-idempotency.ts 189 189 0 reviewed-no-change: Re-evaluated shared-core extraction: idempotentSessionCreate owns one per-context/per-principal cache. Completed entries expire, inflight entries cannot be evicted, retries require unchanged request identity and retained scopes, and unsuccessful work releases its reservation. The inflight/completed union carries either pending work or a terminal result; replacing it with one general cache would lose distinct TTL/custody semantics. src/gateway/server-methods/session-create-idempotency.test.ts
src/gateway/server-methods/models-auth-login.ts 188 188 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: models.authLogin shares resolveChoice and assertCurrent across start and use. Wizard browser authorization adds browser lifetime to assertFlowCurrent; post-login model-access selection intentionally uses signal plus operator authority after browser.close. Credential save, config-application failure and auth-refresh failure retain distinct saved-state messages; there is no alternate login flow in this module. Full server-methods directory; results recorded separately
src/gateway/server-methods/commands-list-result.ts 186 186 0 retained: Common final array carries native/plugin entries, but native alias and argument projection differs. A shared wire entry helper would duplicate per-variant input remapping and include optional fields currently omitted. commands.test.ts (results recorded separately)
src/gateway/server-methods/plugins-mutations.ts 186 186 0 reviewed-no-change: Re-read shared lifecycleHandler and each mutation callback. One owner already captures publication receipts, persistent authority, lease, runtime warnings and errors. entered distinguishes lease refusal from accepted mutation and cannot derive from application presence. src/gateway/server-methods/plugins-mutations.test.ts
src/gateway/server-methods/chat-message-get-handler.ts 184 178 6 applied: Applied one respondMessage core for pending and transcript messages: identical invisible and transport-budget refusals; explicit applyModelPolicy is true only for transcript projection. Both calls remain inside existing withCurrentSession closure and all awaits remain in place. chat-message-get-handler.test.ts;chat-history-handler.cli-import.test.ts; results recorded separately
src/gateway/server-methods/health.ts 184 184 0 retained: Cached response requires live delivery/context/event-loop enrichment and stale-field removal before background scheduling; refreshed response obtains those through the health owner. Both project startup/child facts at their original response sites; generic wrapper would need cache metadata and refresh scheduling parameters without removing those distinct operations. health.owner-routing.test.ts;../server.health.test.ts;../server.health.lifecycle.test.ts; results recorded separately
src/gateway/server-methods/sessions-sharing-authority.ts 182 182 0 reviewed-no-change: Re-evaluated shared-core extraction: Share synchronous current-policy target and membership reader; retain each acquisition await and disposal owner src/gateway/server-methods/sessions-sharing.authority.test.ts src/gateway/server-methods/session-discovery.authority.test.ts src/gateway/server-methods/sessions-reactions.authority.test.ts src/gateway/server-methods/sessions-reactions.test.ts
src/gateway/server-methods/chat-send-setup.ts 180 180 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: one preparation parameter bundle across existing phase order Full server-methods directory; results recorded separately
src/gateway/server-methods/progress-card.ts 180 180 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveProgressCardSession and projectProgressCard already share target and wire identity. progressCard.get retains a scoped read through I/O; refresh passes a guarded reread to refresh dispatch; put owns revision CAS, signal/commit checks, and conditional broadcast. A common read/write callback would need separate authority and publication policies for each operation. src/gateway/server-methods/progress-card.test.ts

Final committed candidate: 3fa749dfb9ba45ebf64552d168d25580551981c8. The search-handler deferral is reviewed and committed; focused types, lint, and both cycle checks passed. Hosted CI is bound to this new head. The PR body owns current test and CI dispositions.

@steipete

steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

d01 PR 2 coverage, part 3 of 6

Continuation of the historical per-file coverage. Current working candidate: 862 net production lines across 112 files against 54bd6ecee1897f51b2963b6ea4c165a356e2d805, including the pending nine-line cancellation cleanup. Test targets below are not proof claims.

File Before Initial after Initial net removed Decision and rationale Existing test targets
src/gateway/server-methods/agent-cron-continuation.ts 179 179 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: createCronContinuationController.release is the sole claim mutation path; releaseWithRecovery calls it again under an independent retained lifecycle. release distinguishes committed generated work, base-session supersession and rollback to initialEntry. Removing recoveryScheduled or the exact captured claim comparison would allow duplicate recovery owners, so they are not derivable solely from claim presence. Full server-methods directory; results recorded separately
src/gateway/server-methods/nodes.event.ts 178 174 4 implemented: Share synchronous pairing-generation connection lookup; event and APNs paths keep independent captured generations and original awaited liveness checks. Fresh client connection reads remain after registry lookup. src/gateway/server-methods/nodes.event.test.ts src/gateway/server-methods/nodes.apns-registration.test.ts
src/gateway/server-methods/session-repository-workspace-access.ts 178 178 0 reviewed-no-change: Re-read stored/active access and set/read inspection. One run helper owns tunnel, command and result validation. Workspace set adds exclusive lifecycle hold and worker mutation grant; read uses captured repository revision. No duplicate transport core. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/users-model-account-access.ts 178 178 0 retained: Connection capture is shared owner; profile references versus email alias preparation require distinct awaited selection and revalidation. Personal/default selection changes required scope, already represented explicitly. users-model-accounts.test.ts (results recorded separately)
src/gateway/server-methods/sessions-read-by-key.ts 176 176 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: sessions.describe presents a prepared row through prepareProjectedSessionPresentation, including description authorization and null-session response. sessions.get has permissive legacy key/limit input, reads bounded transcript content and revalidates the same physical session before a messages response. Both already use withReadySessionRows, but their validation, visibility and missing-result contracts differ. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-aborted-partial.ts 174 174 0 retained: Producer handoff and fallback persistence are separate ownership outcomes. Error construction preserves SessionMutationAuthorizationChangedError class and original cause; warning delivery remains isolated after producer settlement. chat-abort.test.ts;chat-abort.queued.test.ts (results recorded separately)
src/gateway/server-methods/chat-history-pages.ts 173 173 0 rejected prototype: Formatted shared local-history projection prototype173→173 saves zero and nests backend selection; restored simpler sequential CLI/kernel branches. Archive/native identity and exact await sites remain unchanged. chat-history-handler.cli-import.test.ts;chat-history-delta.test.ts (results recorded separately)
src/gateway/server-methods/cron-job-access.ts 173 173 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/chat-metadata-model-list.ts 171 171 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: createChatMetadataModelList.prepare is the single projection cache owner. read excludes personal/session-private selections from shared caching, uses request-local linked-account authority when no session is pinned, and otherwise reuses prepare. requested retains reusable request descriptions across generations; projections retains only current promises, so those maps serve different invalidation lifetimes. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-catalog-list-admission.ts 171 171 0 retained: Single runSteps owner already parameterizes immediate versus continued providers. continued cannot derive from completion pending because failed step also settles; queue timing and abort removal remain independent. session-catalog-list-admission.test.ts (results recorded separately)
src/gateway/server-methods/sessions-suggestions-dispatch.ts 171 171 0 retained: Already has one shared authorization/dispatch route parameterized by send versus queue; attributedSuggestionClient adds the sole author snapshot. Entry source read and post-await current read are separate authority checks. No duplicated dispatch owner remains. sessions-suggestions.test.ts;sessions-suggestions.store-binding.test.ts;sessions-suggestions.custody.test.ts; results recorded separately
src/gateway/server-methods/chat-send-reservation.ts 169 169 0 reviewed-no-change: Re-read reservation, dedupe visibility and goal retry. Pending reservation access owns read/clear; response-less retained identities intentionally do not replay ACKs. Newly published receipt detection requires comparing prepared dedupe with current receipt. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/usage-result-cache.ts 169 169 0 reviewed-no-change: Re-read aggregate/session cache keys and per-agent totals. Shared loadUsageResultCached owns concurrency/completeness. All-agent fold retains max timestamps/days and combines daily totals; private aggregate reader already accepts original params from PR1. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/usage-session-loading.ts 168 168 0 reviewed-no-change: Re-evaluated shared-core extraction: runUsageAgentTasks already centralizes bounded all-or-nothing concurrency. loadUsageSessionSummaries batches every instance by agent, then folds contiguous family instances into the original entry index with one accumulator. discoverAllSessionsForUsage is a separate discovery query, not a second summary-fold implementation. No equivalent variants require another grouping adapter. src/gateway/server-methods/usage.sessions-usage.test.ts
src/gateway/server-methods/suspend.ts 167 167 0 reviewed-no-change: Re-evaluated shared-core extraction: Share prepare/status conflict recovery and draining response core with explicit conflict text src/gateway/server-methods/suspend.test.ts
src/gateway/server-methods/chat-server-timing.ts 166 166 0 retained: First-assistant emission derives from owning ChatRunTiming with local fallback already. ACK timing projection and live phase event have different clocks/field names; shared numeric rounding is factored. Reconnect copy intentionally occurs only after the operator flag is accepted. ../server-chat.agent-events.test.ts;../server.chat.gateway-server-chat-b.test.ts; results recorded separately
src/gateway/server-methods/sessions-fork-runtime-guard.ts 165 165 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveUpstreamForkHarness already selects V2 before legacy per registration. createUpstreamForkCurrentGuard shares readCurrent between source incarnation checks and host-only execution policy. Its inSourceTransaction borrow intentionally substitutes the captured link only while the upstream link owner holds its transaction; rollback uses the child initializer authority instead of reviving forward authority. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-metadata-facts.ts 164 164 0 reviewed-no-change: Re-evaluated shared-core extraction: captureGenerationFacts batches roster/catalog reads and pairs full catalog with its own auth generation. authStoresCurrent checks revisions; generationFactsMatch compares captured ordered agents with metadata/catalog/auth scope differences. Capture, live revision validation, and snapshot equivalence answer different questions; removing any comparison changes cache invalidation. src/gateway/server-methods/chat-metadata-runtime.test.ts
src/gateway/server-methods/session-catalog-list-diagnostics.ts 163 163 0 retained: Shared start phase already selects CPU measurement explicitly; optional timing fields intentionally remain absent if stages never admitted. Replacing projections with map would need heterogeneous timing formulas and type casts. session-catalog-phase-diagnostics.test.ts;session-catalog-provider-diagnostics.test.ts (results recorded separately)
src/gateway/server-methods/transcripts.ts 163 163 0 reviewed-no-change: Re-read all five transcript methods. transcriptMethod already owns schema, archive authority, store and error projection. Summarize adds three authority checks around summary and subsequent read; list/get provider label cache is already shared. src/gateway/server-methods/transcripts.test.ts
src/gateway/server-methods/claws-packages.ts 161 161 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: claws.packages.remove binds journal operation, install digest and package plan before applyClawPackageRemovals under withPluginLifecycleLease. captureGatewayPluginRuntimeApplications supplies the one runtime application owner; runtimeFailure projection records a committed application separately from removal warnings. This is one planned removal flow, with no second package lifecycle implementation. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-discussion.ts 161 161 0 retained: info/open already share sessionDiscussionHandler; explicit operation selects both validators and provider method. Open alone awaits bounded title generation; completion remains with title owner. Further helper only replaces the three existing paired validator choices with a longer typed table. session-discussion.test.ts; results recorded separately
src/gateway/server-methods/session-placement-read-projection.ts 161 161 0 reviewed-no-change: Re-evaluated shared-core extraction: readSessionRowFacts captures prepared placement facts and recomputes them only when getProjectionFacts returns a new source. present refreshes live permission status and uses placement readers without reacquiring database facts. readSessionRowHasBoard permits only the incognito read path. Combining acquisition with presentation would change warm-row I/O and invalidation behavior. src/gateway/server-methods/session-row-facts.test.ts
src/gateway/server-methods/session-repository-artifacts.ts 160 160 0 retained: Rechecked map-entry shared projection: per-variant basename/prefix/name/directory setup needs three mutable fields versus direct branch outputs. Prior actual four-argument helper 160→162 (+2); no further shared work beyond existing readArtifacts/fileEntry. sessions-files.repository.test.ts (results recorded separately)
src/gateway/server-methods/environments.desktop.ts 159 149 10 applied: Shared worker service availability, dispatch, success and error projection for observe/launch; explicit operation retains launch-only typed codes and exact fallback text. Host/node observer credentials path remains separate. src/gateway/server-methods/environments.desktop.test.ts
src/gateway/server-methods/mcp-auth-login.ts 159 159 0 retained: MCP uses startWizardLogin and browser.authorizePrepared common owners. Inner finally is deliberately inside outer catch so browser.close/cancel errors produce saved-aware diagnostic; attemptState is exact OAuth cancellation identity and saved is token-commit evidence, neither derivable from wizard status. ../server.mcp-auth-login.test.ts; results recorded separately
src/gateway/server-methods/models-list-result.owner.ts 157 157 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: infer internal owner result type from sole producer Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-file-assets.ts 156 156 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: getSessionWorkspaceAssets owns sequential byte-budget consumption and shared MIME validation. readAsset has a repository preview branch capped by WORKSPACE_PREVIEW_MAX_BYTES and a host branch using resolveSessionFileReadTarget/statWorkspacePath/readWorkspaceFile. Missing, outside-boundary, too-large and unsupported outcomes arise at different host/provider boundaries; the common asset encoding is already outside both branches. Full server-methods directory; results recorded separately
src/gateway/server-methods/message-operation-result.ts 153 153 0 reviewed-no-change: Re-read delivery error and mirror queue. Shared createGatewayInflightResult owns dedupe publication; partial delivery and queued custody produce distinct retry/error fields. Mirror queue owns ordered per-session writes and records two genuinely different non-success outcomes. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/users-profile-access.ts 153 153 0 reviewed-no-change: Re-read profile capture and administration. assertConnection preserves original identity and scopes through alias acquisition; assertCurrent adds profile revision. Administration uses independent role policy checks; no duplicate authority owner. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/provider-usage-runtime.ts 151 151 0 reviewed-no-change: Re-evaluated shared-core extraction: getProviderUsageRuntimeSnapshot reuses config/store/agent/plugin/auth generations; fingerprintProviderUsageCredentials separately records credentials, direct keys, auth order, lastGood, and selected profile order. resolveDirectApiKeys applies configured-before-env precedence. No duplicated snapshot builder exists; dropping a fingerprint component would reuse usage after account-selection changes. src/gateway/server-methods/usage.status-cache.test.ts
src/gateway/server-methods/chat-send-background.ts 150 146 4 superseded by main; zero final PR credit: Derive private admission choice from supplied turn custody. All session callers supply turn and creation callers omit it, so redundant admissionScope parameter and arguments are deleted. chat.directive-tags.test.ts (results recorded separately)
src/gateway/server-methods/nodes.pending.ts 150 150 0 reviewed-no-change: Re-read pending actions. Preserved explicit isNodeCommandAllowed result variable required by hosted security rule. withPendingNodeActions already shares generation/connection checks while its deferred result callback preserves post-await publication. src/gateway/server-methods/nodes.pending-work.test.ts
src/gateway/server-methods/restart.ts 150 150 0 prototype-rejected: Formatted synchronous matchesActiveLock prototype: 150 -> 152 (+2). Typed helper and two calls exceed the repeated four-field fence; stop keeps authority around awaited lock read, restart keeps its distinct catch behavior. Reject longer helper; .local/d01-p2/sessions-prototypes/restart.ts. src/gateway/server-methods/restart.test.ts
src/gateway/server-methods/skills-install.ts 149 149 0 retained: One handler intentionally routes source-specific install owners. ClawHub dedupe identity, upload retained authority/rollback, and local install results have different contracts; result projection only overlaps ok/error primitives. skills.clawhub.test.ts;skills.install-upload-policy.test.ts (results recorded separately)
src/gateway/server-methods/approval-request-delivery.ts 148 148 0 retained: Delivery variants already use startDelivery(run,errorLabel); first-success settlement counter tracks unresolved callbacks independently of completed truthy results. Replacing it with Promise.any requires converting false results to failures and handling empty input, adding rejected promises and more code. approval-request-delivery.test.ts; results recorded separately
src/gateway/server-methods/chat-history-response-page.ts 148 140 8 APPLIED: One common page-cap parameter record for anchor and tail; anchor selection stays explicit and budgets/cursors are unchanged. Existing focused/full test targets: chat-history-pages.test.ts chat-history-page-cursor.test.ts chat-history-worker.test.ts ../session-history-worker.integration.test.ts
src/gateway/server-methods/sessions-patch-replacement.ts 148 148 0 retained: Admitted and detached writes share same store options but differ in snapshot revalidation and write reacquisition. Sharing project callback would add .then to detached path and extra await before commit. sessions-patch-model-selection.test.ts (results recorded separately)
src/gateway/server-methods/gateway-client-identity.ts 146 146 0 retained: Profile/synthetic/fallback sender paths differ in durable identity publication; existing withCommandSenderAuthority owns live scope. Initial profile-pending state and post-sync absence cannot share a single read because sync can replace the profile. No extra mutable state or duplicate authorizer found. gateway-client-identity.test.ts; results recorded separately
src/gateway/server-methods/sessions-list-diagnostics.ts 146 146 0 reviewed-no-change: Re-evaluated shared-core extraction: startSessionListDiagnostics already owns response timing, stage aggregation, and thread CPU metrics. startSyncCpu may disable CPU collection independently; finishSyncCpu accumulates only successful probes; finish publishes/logs best effort without replacing a response. These are measurement start/stop/publication stages, not interchangeable repeated handlers. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/sessions-reactions-access.ts 145 145 0 reviewed-no-change: Re-evaluated shared-core extraction: Share synchronous current-policy target and membership reader; retain each acquisition await and disposal owner src/gateway/server-methods/sessions-sharing.authority.test.ts src/gateway/server-methods/session-discovery.authority.test.ts src/gateway/server-methods/sessions-reactions.authority.test.ts src/gateway/server-methods/sessions-reactions.test.ts
src/gateway/server-methods/portals.session.ts 144 144 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: sessionPortalOwner centralizes all session portal operations and captures access plus placement identity. prepareTarget retains session resource authority for bearer connections and releases it after connection.close; list/open/close all consume this owner. General portalOperations lacks that retained session bearer lifetime, so using it here would erase the resource boundary. Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-compaction-runner.ts 144 144 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: preflightGatewaySessionCompaction reads the active transcript tree only for legacy OpenClaw compaction and suppresses lookup failures so the runner owns errors. runGatewaySessionCompaction resolves the runtime target and current delivery/model policy before compactEmbeddedAgentSession. sessionStoreKey selects physical transcript reads while sessionKey is retained for runtime delivery; those target objects are intentionally not identical. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-create-root.ts 143 137 6 applied: Shared prepareRoot closure for inherited cwd and root, passing the differing path explicitly and reusing cwd when identical. Filesystem calls, sandbox policy and failure order retained. src/gateway/server-methods/session-create-root.test.ts
src/gateway/server-methods/sessions-title.ts 143 143 0 retained: Title request copies params before personal-selection preparation; shared assertCallerCurrent and assertCurrent already layer creation, selection and captured-run authority. Reusing live params would lose request snapshot behavior; merging null-result branches across preparation would alter admission ordering. sessions-title.test.ts; results recorded separately
src/gateway/server-methods/chat-send-reply-context.ts 142 142 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveChatSendReplyContext reads one quoted message, applies chat display projection, scrubs assistant-only scaffolding, truncates body, and preserves ReplyToId on every miss/failure. extractReplyTargetText has ordered text/string-content/block-content fallbacks; applyChatSendReplyContextFields copies only present keys. Merging extraction and hydration would discard missing-reference behavior or source precedence. src/gateway/server-methods/chat-send-reply-context.test.ts
src/gateway/server-methods/portals.ts 142 142 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: portalOperations owns optional environment binding and prepareTarget; mutatePortal already combines open/close error mapping and change broadcasting. portal.list is synchronous, applies read-scope redaction and maps selection errors to INVALID_REQUEST/String(error), while mutations map to UNAVAILABLE/error.message. No duplicate mutation controller remains. Full server-methods directory; results recorded separately
src/gateway/server-methods/presence.ts 142 142 0 retained: Presence summary variants already share summarize(query,locations); location batching adds network include only to the preparatory query, then rereads live requester/observations after await. Lookup authority guard uses current owner per call. No duplicate summary core remains. presence.test.ts; results recorded separately
src/gateway/server-methods/session-create-spawn.ts 142 142 0 retained: Permission inheritance crosses agent boundaries while model inheritance/fork do not; common requester construction already serves all. Final activeParentFork conditional-spread adds a nested object decision without eliminating any parameter projection. sessions-create.child-custody.test.ts (results recorded separately)
src/gateway/server-methods/sessions-provider-review.ts 142 142 0 reviewed-no-change: Re-read acknowledgement issuance and continuation handoff. handedOff records custody transfer before awaiting the downstream handler; deriving it from resolution would incorrectly retire accepted work on unknown outcome. Existing single path retained. src/gateway/server-methods/sessions-provider-review.test.ts
src/gateway/server-methods/open-path.ts 141 137 4 implemented: Inline single-use PowerShell quote escaping at the string-literal construction. Apostrophe doubling and platform lifetimes are unchanged. src/gateway/server-methods/open-path.test.ts
src/gateway/server-methods/system-agent-chat-turn.ts 139 139 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: runSystemAgentChatInput already dispatches answerWizard/cancelWizard/handle. getSystemAgentChatInputError preserves ordered conflicts for answer and cancel. buildSystemAgentRejoinResult must revive live wizard controls and optional welcome; buildSystemAgentChatResult maps action/handoff and fallback reply text. Rejoin and new-turn results are different protocol events, not parallel implementations. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat.ts 138 138 0 retained: Inject owns one admission/persistence/project/broadcast flow and uses transcript owner. Disabled toolTitles must retain shipped RPC text. The injected node event and connection broadcast have distinct transport audiences and already share chatPayload. ../server.chat.gateway-server-chat-b.test.ts; results recorded separately
src/gateway/server-methods/task-suggestion-acceptance.ts 138 138 0 reviewed-no-change: Re-read rollback/finalize/restore. Rollback combines deletion receipt with physical entry absence. fail and finish already reuse broadcast/claim owners; distinct source-session failure must never delete original session. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/chat-send-diagnostics.ts 136 136 0 retained: Active Set already owns phase liveness from PR1. Top-level finished remains needed because empty active set also describes unstarted scopes; acknowledged stage holds distinct elapsed origin. chat-send-diagnostics.test.ts (results recorded separately)
src/gateway/server-methods/models-list-runtime-choices.ts 136 136 0 retained: Alternative runtimes share one filter/map and one live-read closure. Unavailable entries deliberately omit capabilities after stripping identity fields; available entries preserve them. Explicit policy branches already converge on agentRuntime construction and native evaluation. models-list-result.runtime-choices.test.ts;models-list-result.cli-runtime-availability.test.ts; results recorded separately
src/gateway/server-methods/agent-subagent-registration.ts 135 135 0 reviewed-no-change: Re-evaluated shared-core extraction: registerPluginSubagentRunFromGateway tries adoptPausedSubagentRunForFollowUp before registration only without an explicit requester, then checks adoptPausedSubagentRunIntoSuccessor after registration to catch a concurrently published pause. resolveTrustedGroupMetadata follows stored, inherited, current-key, parent-key precedence. Removing either adoption point changes audience or race handling. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/environments.session-exec.ts 135 125 10 APPLIED: Shared approval predicate consumes freshly resolved policy; retain both policy reads, short-circuit behavior after approval, and separate exec/process admission. Existing focused/full test targets: environments.session-exec.test.ts environments.session-exec-approval.test.ts
src/gateway/server-methods/session-discovery-access.ts 135 135 0 reviewed-no-change: Re-evaluated shared-core extraction: withSessionDiscoveryAccess already delegates capture/current sharing facts to createSessionSharingFacts. Its remaining work is discovery-specific: exact physical source/lifecycle check, structuredClone before discovery, and skillLibrarySelections comparison before synchronous response. Those guards cannot move into the generic sharing reader because sharing mutations do not bind skill selections. src/gateway/server-methods/session-discovery.authority.test.ts
src/gateway/server-methods/sessions-diff.ts 134 134 0 retained: One loadSessionDiff owner dispatches stored/remote/local strategies; common local call parameterized already. Commit-scope missing commit must throw before invoking owner; remote root stripping remains remote-only. sessions-diff.test.ts (results recorded separately)
src/gateway/server-methods/chat-send-late-followup.ts 133 133 0 rejected-prototype: REJECTED measured common delivery projector: 133 to 139 (+6), misc-prototypes/chat-send-late-followup.ts. Explicit payload/state parameters add ceremony without unifying the progress versus terminal custody transition. src/gateway/server-methods/chat-send-late-followup.test.ts
src/gateway/server-methods/diagnostics.ts 133 117 16 applied: Applied profileHandler generic core for all three profile RPCs: undefined-to-empty parameter defaulting, unchanged validator/message strategy, lifetime union, authority recheck and common outcome response. Lazy capture imports remain explicit and unchanged; 133->117. diagnostics.test.ts;diagnostics.cpu-profile.test.ts;diagnostics.heap-profile.test.ts;diagnostics.heap-snapshot.test.ts; results recorded separately
src/gateway/server-methods/chat-history-reply-messages.ts 131 131 0 reviewed-no-change: Re-evaluated shared-core extraction: projectChatHistoryWithReplies batches quoted originals with page messages without recursively following replies. attachChatHistoryReplyMessages performs page-local deduplicated lookups, rejects pending-input IDs, removes model identity from quote previews, and enforces 8 KiB. These are display-batch projection and I/O attachment phases; one cannot replace the other. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/approval-publication.ts 127 127 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: publishAppliedApprovalResolution already funnels awaited best-effort callbacks through runSideEffect. Internal approvalEvents publication remains synchronous; web push selects expired versus resolved; exec/plugin forwarders and iOS handlers have different typed payloads; system-agent forwards only expired/cancelled outcomes because its decision owner publishes decisions. One generic event cast would weaken those kind-specific contracts. Full server-methods directory; results recorded separately
src/gateway/server-methods/channels-account.ts 127 127 0 retained: Channel account selector already shares explicit/reload/default precedence. Logout rechecks current runtime before credential mutation and only caller authority afterward because logout may publish config; these cannot merge. channels.status.test.ts;channels.start.test.ts (results recorded separately)
src/gateway/server-methods/models-auth-order.ts 127 127 0 reviewed-no-change: Re-read profile-order validation and saved-write publication. rejectInvalidOrder already shares response construction; post-write publication catch must preserve committed success. No duplicate profile order writer. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/restart-request.ts 126 112 14 implemented: Reuse existing canonical asSafeIntegerInRange plus trimmed string owner for target pid/port validation; same positive safe pid and1..65535 integer port domain, unchanged output keys. restart.test.ts;update.test.ts (results recorded separately)
src/gateway/server-methods/users-auth-connect.ts 126 126 0 reviewed-no-change: Re-evaluated shared-core extraction: connectHandler already centralizes validation, prepareUserModelAccountAction, service availability, current authority, and error mapping for ten methods. Each table entry is only the service method/argument projection plus explicit read/write/admin scope. Further merging would replace typed service calls with dynamic invocation rather than remove a duplicate body. src/gateway/server-methods/users-auth-connect.test.ts
src/gateway/server-methods/setup-admission.ts 125 125 0 retained: Setup lease and wizard admission use different lifetimes already composed through one create callback. wizardSessionInProgress spans asynchronous lock acquisition before a session exists; WeakMap settlement cannot derive that state. Release callback owns root work plus abort listener and is shared by completion/failure. setup-admission.test.ts;wizard.test.ts; results recorded separately
src/gateway/server-methods/plugins-control-ui.ts 122 122 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: captureCatalogAuthority is shared by list and reload. listControlUiPluginCatalog reads current assets; reloadControlUiPluginCatalog mutates one plugin and broadcasts a revision before response. report verifies a connected Control UI and active revision; status projects a bounded sorted client inventory. These operations share registry lifetime but have separate result/error and mutation contracts. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-recovery-continuation.ts 122 122 0 retained: Authorization, absent prepared grant, absent runId, and absent callback outcome are distinct error codes/messages. One dispatch already consumes all guarded session fields; shared error helper would obscure these boundary outcomes. session-recovery-continuation.test.ts (results recorded separately)
src/gateway/server-methods/canvas.ts 121 121 0 reviewed-no-change: Re-read stored view and caller preview. respondWithCanvasHtml already owns concurrent HTML/listener acquisition and live host revalidation. Stored CSP/size admission and preview UTF-8 admission retain their differing error contracts. src/gateway/server-methods/canvas.test.ts
src/gateway/server-methods/chat-pending-inputs.ts 119 119 0 retained: Pending page has one projector and one budget owner. queuedCount includes live turns outside the displayed page; visible items use original acceptedAt and stripped correlation metadata. Combining its two passes would lose the page-size budget computed before per-item projection. chat-pending-inputs.test.ts; results recorded separately
src/gateway/server-methods/cron-visibility.ts 119 119 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/ui-command.ts 119 119 0 reviewed-no-change: Re-evaluated shared-core extraction: dispatchUiCommandToRequester resolves navigation session identity separately from the captured requester UI target, filters current Control UI connections and capabilities, then rechecks participant authority before broadcasting. ui.command only adds runtime authority and error mapping. No second recipient-selection path exists in this module. src/gateway/server-methods/ui-command.test.ts
src/gateway/server-methods/projects-recents.ts 118 118 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: indexPathProjects owns workspace/path precedence; listProjectRecents owns sorted session selection, deduplication and the eight-item limit. Repository-workspace recents require awaited durable ownership checks and dedupe by URL; project/folder recents use configured path identity and node-qualified folder keys. They converge on one result list after their different identity checks. Full server-methods directory; results recorded separately
src/gateway/server-methods/fs.ts 117 117 0 retained: Node bridge, admin-local and confined workspace variants already share local listing owner; remote declared-command/allowlist/result checks stay separate. Only confined workspace-root result strips parent path. fs.test.ts (results recorded separately)
src/gateway/server-methods/plugins-lifecycle-error.ts 116 116 0 reviewed-no-change: Re-read lease refusal, abort unwrap, persisted error, consent/trust details and runtime receipts. projectPluginRuntimeFailure remains canonical; conditional fields follow distinct accepted-write/failure meanings. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/skills-workspace-handler.ts 115 110 5 historical initial reduction; current retained reduction is 6 lines (52 to 46): Reused invalidSessionRequest for agent-selection refusals. The second rebase preserves main's Workshop owner cutover and retirement of proposal/curator APIs; the obsolete generic proposal handler and unused imports are not restored. src/gateway/server-methods/skills-workspace-handler.test.ts;src/gateway/server-methods/skills-workshop.test.ts
src/gateway/server-methods/cron-list-diagnostics.ts 113 113 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/method-authorization.ts 113 113 0 reviewed-no-change: Re-evaluated shared-core extraction: authorizeGatewayMethod is one ordered dispatcher: role validity, node exemption, invalidation, current operator policy, device scope recovery, admin, registered scope, own-session fallback, and exact cron grant. Each early return is a distinct authorization contract; a table would need the same ordered predicates and state-dependent inputs. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/doctor-memory-target.ts 112 112 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveDoctorMemoryAgent validates raw agentId type before any storage-capable resolution, normalizes it and retains requestedAgentId for scope behavior. resolveDoctorMemoryTarget adds only workspace selection; memoryActionHandler already shares target validation for every diary mutation. General agent-id-shared uses different compatibility fallback, normalization and error strings, so it is not an equivalent target owner. Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-patch-effects.ts 112 112 0 retained: Hook/model/publication/activity events share per-target loop; batch archive cron cleanup is distinct aggregate effect. No change to cron-owned import/call. sessions-patch-effects.test.ts (results recorded separately)
src/gateway/server-methods/computer.ts 110 110 0 reviewed-no-change: Re-read caller owner and status/invoke/close. resolveComputerCaller already shares current authority; close selects a cleanup-only purpose before invoking the service. Status fallback is read-only and cannot share invocation unavailable behavior. src/gateway/server-methods/computer.test.ts
src/gateway/server-methods/system-agent-execution.ts 109 109 0 reviewed-no-change: Re-evaluated shared-core extraction: runSystemAgentGatewayTask combines active-work accounting with an execution lock; verifyGatewaySetupInference fences the applied config hash before/after the probe; activateGatewaySetupInference retains completion through finally outside the task lock. These are scheduling, verification, and activation responsibilities, with no duplicate setup execution loop. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/agent-expected-session.ts 107 107 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveExpectedExistingSessionConstraint validates backend-only input and constructs the constraint. validateExpectedExistingSessionTarget checks explicit request identity, assertExpectedExistingSession checks the live row, and consumeExpectedSessionWorkAdmission consumes an existing handoff lease. These are parse, compare and ownership-transfer stages; no repeated lease or validator implementation exists. Full server-methods directory; results recorded separately
src/gateway/server-methods/environments.session-exec-approval.ts 107 107 0 retained: Single registered approval and consumeAllowOnce path already shares manager owner. Runtime identity creation, registration, delivery, and one-shot decision are different awaited authority checkpoints. environments.session-exec-approval.test.ts (results recorded separately)
src/gateway/server-methods/approval-run-cancellation.ts 106 102 4 applied: Forwarded each caller-owned private cancellation context into cancelMatchingApprovals while keeping explicit match predicate differences. Exact worker/run identity checks and publication order retained. src/gateway/server-methods/approval-run-cancellation.test.ts
src/gateway/server-methods/artifacts-content.ts 105 105 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveBlockDownload has a single source-precedence pipeline: detected data URL, direct base64, safe remote URL, then unsupported. It preserves declared size separately from measured inline payload size. mediaUrlValue and resolveMessageRunId normalize separate field shapes. No parallel media-kind decoder exists to consolidate. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/progress-card-refresh.ts 105 105 0 retained: Already shares terminal fallback error projection. Original card revision, dedupe revision and newly read current card are different facts across completion race; accepted receipt is published only after authority checks. No redundant revision state. progress-card-refresh.test.ts;progress-card-refresh.integration.test.ts;progress-card-refresh.queued.test.ts; results recorded separately
src/gateway/server-methods/sessions-maintenance.ts 105 105 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: createSessionStorageHandler already combines status/run, including post-read caller authority; only run requests maintenance. sessions.cleanup delegates mutation to runSessionsCleanup and serialization to serializeSessionCleanupResult, then emits changes for committed summaries and lifecycle failures. Cleanup cannot share status/run result/error publication because partial cleanup is an accepted durable outcome. Full server-methods directory; results recorded separately
src/gateway/server-methods/users-github.ts 104 104 0 retained: runPersonalGitHub already owns five variant actions and error projection. Sync operations must respond synchronously and asynchronous results reassert owner authority; unconditional await would alter this distinction. users-github.test.ts (results recorded separately)
src/gateway/server-methods/doctor-memory-files.ts 103 103 0 reviewed-no-change: Re-read remote/local listing and diary fallback. stat ENOENT advances filename while read failure returns the selected filename as missing. Combining catches would need phase state; remote maintenance remains the sole adapter. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/usage-cache.ts 102 101 1 applied: Removed current cache-entry alias after identity comparison; settlement writes the exact owning entry under unchanged map identity and inFlight checks. TTL, replacement, stale reads and async-work custody unchanged. usage-cache.test.ts;usage.sessions-usage-cache.test.ts; results recorded separately
src/gateway/server-methods/chat-abort-queued-collector-publication.ts 100 100 0 reviewed-no-change: Re-evaluated shared-core extraction: createQueuedCollectorPublication captures the original incarnation and stores prepared rows only for the synchronous publishResult callback. publishSnapshot differentiates initial Stop from settled last-run publication; prepare clears temporary rows in finally. These are the same publication owner at different phases, already sharing the emitter. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/models-auth-status-api-keys.ts 99 99 0 retained: One provider loop implements config/reference/environment precedence. Marker suppression and explicit nonenv references are different classifications; common source projection would require optional envVar semantics unchanged. models-auth-status.test.ts (results recorded separately)
src/gateway/server-methods/cron-scratch.ts 96 96 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/validation.ts 94 94 0 reviewed-no-change: Re-evaluated shared-core extraction: defineValidatedGatewayHandler is the common runtime owner; hasValidMethodParams narrows the original options object so opaque authority is not lost through cloning. defineValidatedGatewayMethod additionally binds a core method to GatewayCoreRequestParams. Removing that typed boundary would require a cast or reconstructed options; no duplicate validator execution remains. src/gateway/server-methods/validation.test.ts

Final committed candidate: 3fa749dfb9ba45ebf64552d168d25580551981c8. The search-handler deferral is reviewed and committed; focused types, lint, and both cycle checks passed. Hosted CI is bound to this new head. The PR body owns current test and CI dispositions.

@steipete

steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

d01 PR 2 coverage, part 4 of 6

Continuation of the historical per-file coverage. Current working candidate: 862 net production lines across 112 files against 54bd6ecee1897f51b2963b6ea4c165a356e2d805, including the pending nine-line cancellation cleanup. Test targets below are not proof claims.

File Before Initial after Initial net removed Decision and rationale Existing test targets
src/gateway/server-methods/artifacts-image-page.ts 93 93 0 retained: Invalid cursor construction is already shared. Connection-bound cursor map captures beforeSeq/imageOffset/readWindow/expiry as continuation facts; deriving them from latest page would violate replay window. Cleanup and 128-entry cap retain different bounds. artifacts.images.test.ts; results recorded separately
src/gateway/server-methods/client-types.ts 93 93 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: GatewayClient projects selected GatewayWsClient fields and adds trusted in-process capabilities. TrustedAgentToolCaller and GatewayNodeInvokeStream describe separate closure-bound authority surfaces. Removing these distinctions or replacing the explicit Pick with the full WebSocket client would widen the handler contract rather than delete a duplicate implementation. Full server-methods directory; results recorded separately
src/gateway/server-methods/mcp-app-onboarding.ts 93 93 0 retained: One plugin lookup/read/dispatch flow. Generic errorShapeFromError prototype93→91 changes diagnostics and database/incognito error mapping, so retained exact Error.message-or-String contract. mcp-app-onboarding.test.ts (results recorded separately)
src/gateway/server-methods/send-channel-resolution.ts 93 93 0 reviewed-no-change: Re-read channel normalization and outbound target resolution. Explicit/internal-only channel policies differ but already share normalized input. Runtime config selection uses its canonical owner and preserves missing-snapshot fallback. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/sessions-recover.ts 93 93 0 reviewed-no-change: Re-read recovery and continuation. One recoverGatewaySession call owns the mutation; source archive event and successor event carry different keys/reasons. Exact guard composition and response authority retained. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/inflight.ts 90 90 0 implemented: Remove the redundant metadata-presence branch: object spread accepts undefined and the cached marker remains the last writer. Zero-line reduction; no replay timing changes. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/session-file-read-authority.ts 90 89 1 APPLIED: Inline the single-use authorizeHostRead alias in the returned API; keep one memoized admission Promise and all live authority checks. Existing focused/full test targets: sessions-files.host-read.test.ts sessions-files.test.ts
src/gateway/server-methods/agent-run-model-selection.ts 89 89 0 retained: One selection callback updates runtime identity then optional exact cron continuation. Set/delete execution-provider branches cannot merge with spread without retaining retired property; cron path unchanged. sessions-patch-model-selection.test.ts;chat.directive-tags.test.ts (results recorded separately)
src/gateway/server-methods/sessions-patch-permissions.runtime.ts 89 89 0 reviewed-no-change: Re-read active permission grant and settlement. publish is already shared; failure stop is intentionally best-effort after accepted mode persistence. Cancellation promises are retained and joined before reporting. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/doctor-memory-provider-status.ts 88 88 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: share success/failure health projection before resource close Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-account-selection.ts 87 87 0 reviewed-no-change: Re-evaluated shared-core extraction: prepareChatAccountSelection retains requester links authority across a private account read, then returns a synchronous currentness-checked presenter. resolveChatAccountSelection distinguishes automatic, shared credential, owned personal, and another owner display-only account. Sharing a private lookup with display fallback would expose an account the viewer cannot inspect. src/gateway/server-methods/chat-account-selection.test.ts
src/gateway/server-methods/cron-list-projection.ts 87 87 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/sessions-patch-diagnostics.ts 87 87 0 retained: Already derives per-scope liveness from Set membership. Top-level finished remains necessary after all scopes close to forbid subsequent scopes. Fixed PHASES owns deterministic output order independently of Map insertion/parallel phase completion. sessions-patch-diagnostics.test.ts; results recorded separately
src/gateway/server-methods/agent-run-handler.ts 86 86 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: agentRunHandler is already an adapter over createAgentTurnIo, prepareAgentRequestPreflight and createAgentTurnService. Upload admission precedes validation by contract, then runtime authority gates startTurn. Its catch maps SessionMutationAuthorizationChangedError directly and delegates closed-runtime handling; there is no local second turn pipeline to remove. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-send-reply-delivery.ts 86 86 0 retained: Single anchor classifier evaluates missing input, reply bounds, later user, watermark drift, delivery in required precedence. Watermark fallback retains released SDK omission contract. chat.directive-tags.test.ts (results recorded separately)
src/gateway/server-methods/models-auth-status.types.ts 86 86 0 reviewed-no-change: Re-read exported types. Profile health and usage fields already derive with Pick; the remaining fields are distinct public result decorations, with no executable duplication. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/plugins.credentials.ts 86 86 0 retained: Authorization/base-hash/declaration refusals already share denied(message). Outer catch intentionally uses a separate UNAVAILABLE bounded error because authored credential data cannot cross that boundary. Two authority calls bracket config I/O and cannot collapse. plugins.credentials.test.ts; results recorded separately
src/gateway/server-methods/skills-status.ts 86 86 0 retained: Workspace resolution and session-discovery access are canonical owners. Remote eligibility and node eligibility are prepared once then combined in one status call; watcher startup remains inside access scope. No duplicated branch. skills.remote.test.ts; results recorded separately
src/gateway/server-methods/attach.ts 85 85 0 reviewed-no-change: Re-evaluated shared-core extraction: attach.grant resolves canonical ownership, rejects protected harness entries, ensures loopback runtime, then mints one bounded grant; attach.revoke validates only its token and removes the grant. There is no common acquisition/revocation core, and the harness guard must precede server startup. src/gateway/server-methods/attach.test.ts
src/gateway/server-methods/nodes.wake-reconnect.ts 84 84 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: wakeNodeForReconnect already parameterizes force and invoke/pending source. It retains one absolute push deadline, bounds reconnect polling to remaining budget and preserves source-specific log text/duration. The overload keeps the no-deadline caller result free of the deadline sentinel; removing it would widen callers without deleting behavior. Full server-methods directory; results recorded separately
src/gateway/server-methods/workspace-path-containment.ts 84 84 0 reviewed-no-change: Re-read canonical path ancestor walk and synchronous effect-time revalidation. Async admission and current config realpath checks differ in timing/contract; one shared path-inside owner already supplies both. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/users-channel-identities.ts 83 83 0 retained: Link/unlink already parameterize identityMutationHandler; listing shares administration preparation and identityError but requires its own post-read authority recheck. Mutation union-kind assertion protects action mismatch; not redundant state. ../server-methods.channel-identities.test.ts; results recorded separately
src/gateway/server-methods/chat-send-retry-comparison.ts 81 81 0 reviewed-no-change: Re-evaluated shared-core extraction: readChatSendRetryComparison captures source/session/lifecycle identity with submitted input. compareChatSendSubmittedInput first rejects mismatched capture, then compares mention/context-bearing bytes while legacy unannotated input bypasses comparison. The two functions separate asynchronous acquisition from synchronous admission; merging adds an await at the guard. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/sessions-search-scope.ts 81 81 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveSessionSearchScope handles configured ACP store owners and unconfigured retained store owners before the generic requested-agent resolver. It canonicalizes every requested key and rejects multi-agent batches before ambient fallback. The two owner exemptions use different roster/persisted-owner predicates; normalization and agent cardinality already converge afterward. Full server-methods directory; results recorded separately
src/gateway/server-methods/agents-list.ts 79 79 0 retained: Rechecked optional-model-catalog helper retains serial scalar fallback, whereas this handler runs all scalar reads concurrently. Prior79→67 helper reuse would change await/concurrency order. agents-list.test.ts;optional-model-catalog.test.ts (results recorded separately)
src/gateway/server-methods/artifacts-base64.ts 79 79 0 reviewed-no-change: Re-read validation, size counting and optional data normalization. Byte buffer avoids large per-character allocations; replacing it with chained regex replacements would trade memory for line count. Encoded length is required without materializing decoded bytes. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/skills-upload.ts 79 79 0 retained: Begin/chunk/commit already use makeUploadHandler with validator/action strategies. Disabled feature precedence intentionally precedes validation. Private mapUploadError preserves authorization errors apart from request/unavailable failures. skills-upload.test.ts;skills-upload.policy.test.ts; results recorded separately
src/gateway/server-methods/catalog.ts 78 78 0 retained: Browse and keyword search already share defineCatalogHandler including workspace selection, owner call and error response. Browse-only invalidRequest runs outside catch; replacing it with a general strategy table would merely relocate existing parameters. catalog.test.ts; results recorded separately
src/gateway/server-methods/chat-send-retry.ts 78 78 0 reviewed-no-change: Re-evaluated shared-core extraction: classifyAcceptedChatSendFailure maps pre/post-ack and execution side effects to client-retry/reconcile/retry/terminal. runAcceptedChatSendDispatch already shares the bounded three-attempt loop, and waitForAcceptedChatSendRetry waits only for the typed failed projection. No duplicated retry loop remains. src/gateway/server-methods/chat-send-retry.test.ts
src/gateway/server-methods/models-list-public-projection.ts 78 78 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: buildPublicModelProjection explicitly allowlists public model fields and conditionally omits details. projectModelServiceTiers intersects a harness response with already-authorized tiers; projectProviderCatalogOutcomes strips provider-private metadata. These project different inputs to different public contracts; spreading source records would leak route/auth fields. Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-patch-sandbox.runtime.ts 78 78 0 retained: One permission validator checks admin/sandbox/consent and independent session/embedded/run/worker owners. No duplicate state or duplicated authority operation. sessions-patch-native-recovery.test.ts (results recorded separately)
src/gateway/server-methods/terminal-upload.ts 78 76 2 implemented: Capture current responder in private invalid-response closure, deleting repeated parameter threading and type-only import; same branch errors and catch mapping. terminal.test.ts;terminal-upload.policy.test.ts (results recorded separately)
src/gateway/server-methods/tools-invoke.ts 77 77 0 reviewed-no-change: Re-read canonical invocation and response mapping. Success/error payloads share tool identity but have distinct discriminants and required nested error fields. Existing error map is already table-driven; no duplicate invocation. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/session-activity-summary.ts 76 75 1 historical one-line reduction withdrawn during lint validation; zero current PR credit: Preserve explicit key and agentId response fields. Current source is byte-identical to the second-rebase base; batch authorization and enqueue order remain unchanged. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/agent-identity.ts 74 74 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: agentIdentityGetHandler has one requested-agent resolution path and one awaited avatar projection. It distinguishes malformed session keys from agent-selection errors and asserts mutation authority after avatar preparation. The output is a public avatar projection; there is no alternate identity writer or cache here. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-history-page-cursor.ts 73 73 0 retained: Single cursor schema and encoder already serve both directions. Older/newer anchors and truncation comparisons are distinct and optional keys remain absent. chat-history-page-cursor.test.ts (results recorded separately)
src/gateway/server-methods/models-list-capabilities.ts 72 72 0 reviewed-no-change: Re-evaluated shared-core extraction: listDecisionModels deduplicates model IDs in plugin order while retaining plugin attribution; createModelsListProviderFilter builds known provider IDs from manifest contracts/config/catalog using one prepared normalizer. Model enumeration and provider-name admissibility have different inputs and one implementation each. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/session-scoped-read.ts 72 72 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: retainSessionScopedRead initially exempts broad callers with no visibility filter, then captures a row only for scoped reads. Its assertCurrent rechecks actor identity, scope, row lifetime and visibility on every use; initial policy and current policy are intentionally sampled at different points. release is already centralized on both failed capture and returned lifecycle. Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-patch-catalog-preparation.ts 72 72 0 retained: Map is sole shared pending preparation owner; prepare/load/available differ in error exposure. Ordered project awaits full owner while prepare returns continuation requirements; combining them would obscure when catalog failure becomes required. sessions-patch-model-selection.test.ts;../sessions-patch-catalog-queue.e2e.test.ts; results recorded separately
src/gateway/server-methods/device-management-authz.ts 70 70 0 retained: Role checks already share requestsNonOperatorDeviceRole. Device token role loop reads only token.role; passing complete token through request-role parser would additionally interpret hypothetical roles fields and add array allocation. Existing callbacks each contain just normalize and compare. device-management-authz.test.ts;devices.test.ts;../server.node-pairing-authz.test.ts; results recorded separately
src/gateway/server-methods/chat-send-delivery-authority.ts 69 69 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: shared finalizer authority and lazy media scope Full server-methods directory; results recorded separately
src/gateway/server-methods/model-auth-agent-scope.ts 69 65 4 implemented: Default and explicit agent selection now converge on one successful directory/result projection; preserve distinct invalid input messages and default-selection error mapping. models-auth-status.test.ts (results recorded separately)
src/gateway/server-methods/nodes.handlers.invoke-result.ts 69 69 0 reviewed-no-change: Re-read null/nonstring payload normalization, node identity and late result receipt. Normalization owns legacy wire inputs; shared final success response was already consolidated in PR1. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/agent-runtime-authority.ts 67 67 0 reviewed-no-change: Re-read has/assert/guard adapters. Canonical hasActive predicate serves boolean, throwing, response and commit adapters used independently by callers. Removing an adapter would only duplicate its required boundary conversion. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/sessions-patch-errors.ts 67 67 0 reviewed-no-change: Re-evaluated shared-core extraction: unexpectedPatchError owns typed catalog/account/authorization/worktree error precedence. createCommitGuard converts thrown authority failures; assertSessionPatchCommitAllowed runs personal selection, commit guards, then archive transition guards in order. Error projection and synchronous commit validation are different phases, already centralized. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/agent.ts 66 66 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: agent.wait uses one authorizeWait closure before prepared.wait and again on the returned observation, preserving run generation and session visibility. agent dispatch is imported as agentRunHandler rather than reimplemented. The two authorization calls bracket an await and cannot be replaced by a saved pre-wait decision. Full server-methods directory; results recorded separately
src/gateway/server-methods/prepared-read.ts 66 66 0 retained: withPreparedGatewayRead owns release outcome; createPreparedReadHandler adapts successful response interception without affecting error replies. Merging would duplicate direct/prepared dispatcher logic. session-row-projection.prepared-read.test.ts;session-row-prepared-read.test.ts (results recorded separately)
src/gateway/server-methods/model-provider-capabilities.ts 65 65 0 reviewed-no-change: Re-read manifest choices and provider aggregation. One Map owns OR accumulation and one resolveProvider normalizes both choices and login options. Models versus non-text setup surfaces remain intentionally filtered. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/config-submission-validation.ts 64 64 0 rejected-prototype: Rejected measured ordered validator-loop prototype 64->63 (-1): one mutable config result plus validator array obscures raw-before-effective validation for a single line. Existing respondInvalid already shares the only duplicated response core. config.shared-auth.test.ts; results recorded separately
src/gateway/server-methods/session-unread-ack.ts 64 64 0 retained: Allowed-key Set is canonical key policy; two consumers share isSessionUnreadAckOnlyPatch. Apply/missing/stale are distinct CAS outcomes and stale retains authoritative entry. No repeated state transition. ../server.sessions.patch-expected-identity.test.ts;../sessions-patch.test.ts; results recorded separately
src/gateway/server-methods/terminal-open-plan.ts 63 63 0 reviewed-no-change: Re-evaluated shared-core extraction: authorizeTerminalNodeCommand verifies connected node, declared command, then current allowlist. resolveTerminalOpenSpawnPlan chooses default shell, local catalog command behind policy-selected login shell, or remote relay metadata. Node authorization and process spawn translation are separate responsibilities; local and remote plans intentionally have different shell/cwd semantics. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/agent-id-shared.ts 62 62 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveConfiguredAgentIdOrRespondError performs strict ID normalization and roster membership with the agent-not-found message. resolveAgentIdOrRespondError accepts unknown input, preserves requested spelling, tries legacy compatibility/ambient selection and reports unknown-agent or selection-required messages. Callers rely on these different input and error contracts. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-metadata-contract.ts 60 60 0 retained: Type-only contracts derive fields from canonical session/protocol owners; chatMetadataSessionFields is one field list consumed by read snapshots. There is no executable duplicated model selection to extract. chat-metadata-handler.test.ts;chat-metadata-runtime.test.ts; results recorded separately
src/gateway/server-methods/chat-tts-markers.ts 60 60 0 reviewed-no-change: Re-read text projection and supplement markers. Media-only marker delegates to canonical text/hash builder; stripVisibleText uses plugin-owned metadata. No duplicate hash or transcript selection. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/environments.session-tool-policy.ts 60 60 0 retained: Captured run and inherited policy are admitted caps; current conversation capability is separate live policy. assertAllowed composes both at use-time; collapsing captured/current inputs would grant authority after changes. environments.session-exec.test.ts; results recorded separately
src/gateway/server-methods/session-catalog-read.ts 60 60 0 reviewed-no-change: Re-evaluated shared-core extraction: readAuthorizedSessionCatalog calls provider.read once, rechecks session-viewers audience after I/O, then maps profile senders through a request-local display cache. Registration/source visibility occurs in its caller; moving it here would duplicate those checks or change the post-I/O authorization point. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/attachment-normalize.ts 59 59 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: normalizeAttachmentContent handles string, ArrayBuffer view with offset/length, and whole ArrayBuffer through one normalizer. normalizeRpcAttachmentsToChatAttachments combines top-level fields with Anthropic source data and filters only absent content. Optional numeric fields are omitted when invalid while string fields remain present as undefined; generic record copying would change that shape. Full server-methods directory; results recorded separately
src/gateway/server-methods/models-list-result.default-models.ts 59 59 0 retained: Preview computes once and reports executable utility route only for exact sole-agent setting; explicit/auto/disabled variants already select same lazy runtime owner. models-list-result.configured-static.test.ts;model-discovery-policy.test.ts (results recorded separately)
src/gateway/server-methods/artifacts-session-read.ts 58 58 0 reviewed-no-change: Re-read selected source and lifecycle guard. One assertCurrent binds physical store/session/lifecycle for both scoped and empty reads. Conditional scope omission is public type shape; current direct early return remains clearer. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/channels-status-issues.ts 58 58 0 retained: Per-plugin try/catch isolates diagnostics errors while deferred reload issue is independently appended. Shared collectChannelStatusIssues already owns plugin issue projection; flattening global collection would let one failure suppress later plugins. channels.status.test.ts; results recorded separately
src/gateway/server-methods/lazy-core-handlers.ts 58 58 0 reviewed-no-change: Re-evaluated shared-core extraction: prepareGatewayRequestHandler resolves nested forwarding wrappers and refreshes dispatch authority; createLazyCoreHandlers retains request-entry lifetime through module loading, releases it before invoking the real handler, and releases again in finally. The forwarding wrapper is the lazy entry boundary, not redundant exported behavior. src/gateway/server-methods/lazy-core-handlers.test.ts
src/gateway/server-methods/nodes.invoke-talk-events.ts 58 58 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: TALK_PTT_EVENT_TYPES already parameterizes four Talk commands. emitTalkPttNodeEvent is the single capture-id, bounded sequence-map and canonical talk.event projection. Remaining fields encode the wire event, including final=false only for start; no duplicate command handler remains. Full server-methods directory; results recorded separately
src/gateway/server-methods/skills-curator.ts 58 58 0 retained: Retired pin/unpin/restore already share factory. Current status versus legacy inventory removal/timestamp filtering protects client-capability contract. skills-curator.test.ts (results recorded separately)
src/gateway/server-methods/chat-human-mentions.ts 57 57 0 reviewed-no-change: Re-read ordered NFC span normalization. previousEnd guards original spans while normalized offsets measure sanitized output; neither derives from the other. splitsSurrogate already shares boundary logic. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/sessions-patch-types.ts 56 56 0 reviewed-no-change: Re-evaluated shared-core extraction: MutationTarget, PreparedPatchTarget, MutationOutcome, GroupMutationOperation/Result/AdmissionResult, and MutationCoreResult are the shared engine/writer boundary. Discriminants distinguish catalog deferral, detached snapshots, and completed outcomes. This file has no executable variant body to simplify; widening unions would weaken caller narrowing. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/commands.ts 55 55 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: commands.list delegates selected-agent validation to resolveAgentIdOrRespondError, session visibility to withSessionDiscoveryAccess and command projection to buildCommandsListResult. This file contributes only the method-specific changed-session error and provider/scope options; it contains no independent command discovery implementation. Full server-methods directory; results recorded separately
src/gateway/server-methods/device-management-security.ts 55 55 0 retained: One trusted event projection hashes actor/target identifiers and records reason in both policy/event intentionally. Device token/pairing callers already parameterize outcome/policy/control. devices.test.ts;devices.lifecycle.test.ts (results recorded separately)
src/gateway/server-methods/nodes.shared.ts 55 58 -3 applied: Extended pairing error owner with optional operation wording; existing invocation text/default behavior unchanged, pending-work caller supplies its exact prior phrase. Lifecycle-before/after-generation checks remain intact. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/chat-send-reply-session.ts 54 54 0 retained: Prepared session binding owns historical initialization; readCurrentSession owns fresh store read with routing fence. captureTranscriptStart combines prepared identity and lifecycle revision. They cannot derive each other after initialization or reset. chat-send-reply-context.test.ts;chat-send-reply-dispatch.test.ts; results recorded separately
src/gateway/server-methods/session-model-catalog-wait.ts 54 54 0 reviewed-no-change: Re-evaluated shared-core extraction: createSessionModelCatalogWait owns one deadline and one unavailable Error instance. run combines abort sources and enforces remaining time; settle translates only that exact sentinel into a typed result and rethrows unrelated errors. The two operations are execution bounding and result translation, not parallel wait implementations. src/gateway/server-methods/session-model-catalog-wait.test.ts
src/gateway/server-methods/sessions-sharing-identities.ts 54 54 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: knownSessionIdentities uses one remember function for actor, creators and profiles, with profile entries last. It preserves only the prior nonempty label while replacing type/avatar/identity from the latest source. A generic merge would incorrectly retain stale avatar or identity; the current map is the sole dedupe owner. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-send-external-entry.ts 53 53 0 retained: Resolve and dashboard read use similar parameter adaptation but one captures cron capability and other checks caller policy before adaptation. A shared6-line adaptation helper plus calls grows by1. chat-send-admission-authority.test.ts;chat-send-session-binding.test.ts (results recorded separately)
src/gateway/server-methods/session-file-read.ts 53 53 0 retained: Single path resolver selects local workspace or authorized host target; no duplicate body. Host errors deliberately collapse to undefined, boundary refusal remains distinct sentinel. sessions-files.host-read.test.ts (results recorded separately)
src/gateway/server-methods/wizard-login.ts 53 53 0 reviewed-no-change: Re-read login admission and owner cleanup. One cancellation callback and one shared settlement callback cover successful/failed settlement; rejected admission closes before responding. No duplicate session owner. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/chat-send-admission-context.ts 52 52 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: prepareChatSendAdmissionContext creates trace attributes and calls resolveChatSendOriginatingRoute once. assertChatSendSessionTargetOrRespond sequences session authority, cleanup and error response. The repeated caller argument reconstruction was removed in chat-send-admission.ts; these two remaining functions perform projection and guard/error handling rather than the same task. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-send-agent-dispatch.types.ts 52 52 0 retained: Single shared dispatch parameter contract derives owners types; no runtime declarations. Collapsing this module into caller moves the same LOC without removing a seam. chat-send-reply-dispatch.test.ts; results recorded separately
src/gateway/server-methods/chat-history-recovery.ts 51 51 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveEmbeddedAgentRunRecoverySnapshot resolves explicit/canonical/requested session precedence and presents an embedded owner; respondChatHistoryUnavailable owns retry metadata for history methods. Run recovery and protocol error response do not share a data or control-flow core. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/chat-send-admission-cleanup.ts 49 49 0 reviewed-no-change: Re-read retained-work/media cleanup and abort receipt. Optional media callback can be assigned after admission and is cleared only after cleanup; it cannot derive from the retained-work release. One abort receipt publication remains. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/session-catalog-result.ts 49 49 0 retained: One public capability projection and one error normalizer; duplicative startTerminal flag belongs to both root capabilities and createSession nested contract. session-catalog.test.ts (results recorded separately)
src/gateway/server-methods/agent-timestamp.ts 47 47 0 retained: buildTimestampPrefix already shares timestamp formatting for historic boundary stamps and CLI injection. Wrapper additionally excludes existing envelope/cron clocks and returns original on invalid zone; direct callers require distinct contracts. server-methods.test.ts; results recorded separately
src/gateway/server-methods/nodes.helpers.ts 46 46 0 reviewed-no-change: Re-evaluated shared-core extraction: respondUnavailableOnNodeInvokeError is exported by src/plugin-sdk/gateway-runtime.ts as the two-argument SDK surface; respondUnavailableOnNodeInvokeErrorWithProvenance adds internal dispatch evidence for nodes.invoke/exec-approvals. Removing the wrapper requires changing the public SDK contract/callers outside assignment; error formatting itself already has one implementation. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/nodes.invoke-authority.ts 46 46 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: isForwardedNodeInvokeApprovalAuthorityActive checks the live approval decision. resolveNodeInvokeRuntimeAuthorityError first validates the current agent runtime capability and only then the approval capability, preserving two distinct error messages. A valid stored decision cannot substitute for live run authority, so both checks remain. Full server-methods directory; results recorded separately
src/gateway/server-methods/mentions.ts 44 44 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: one validated list/dismiss inbox flow preserving callback publication Full server-methods directory; results recorded separately
src/gateway/server-methods/sessions-patch-discovery.ts 44 44 0 retained: Two passes intentionally finish all target discoveries before duplicate-target refusal; merging loop would change later discovery errors and side effects. sessions-patch-model-selection.test.ts (results recorded separately)
src/gateway/server-methods/optional-model-catalog.ts 43 43 0 rejected-prototype: REJECTED measured single batch-result Map projector: 43 to 44 (+1), misc-prototypes/optional-model-catalog.ts. Requires typed intermediate results plus tuple allocation; original scalar/batch/catch accumulator stays clearer. src/gateway/server-methods/optional-model-catalog.test.ts
src/gateway/server-methods/projects-list-diagnostics.ts 43 43 0 retained: One stage tracker feeds both diagnostics channel and slow warning; phase records current span to finish. Unlike update.status it starts when either channel subscribers or process flag exist; a shared timing wrapper needs distinct admission and publication policies. projects.test.ts; results recorded separately
src/gateway/server-methods/cron-error-classification.ts 42 42 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/chat-send-active-leaf.ts 41 41 0 reviewed-no-change: Re-evaluated shared-core extraction: assertExpectedLeafActive is a single synchronous fence combining transcript ancestry with requestedSessionId. allowEmptyAncestor is used only by admission; Stop/recovery require the captured empty view. Removing that option or collapsing exact/ancestor conditions changes accepted replay semantics. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/chat-startup-requester.ts 41 41 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: prepareChatStartupRequester captures either an attached profile or a legacy email origin, then returns a reader that resolves profile merges under current admission. Attached-profile and email-origin invalidation conditions intentionally differ. The async email ensure and synchronous resident lookup belong to creation and publication respectively. Full server-methods directory; results recorded separately
src/gateway/server-methods/cron-run-log-filters.ts 41 41 0 excluded: Reserved original campaign exclusion; no edits. Config-retirement, global chat identity or cron owner retained.
src/gateway/server-methods/send-account-route.ts 40 40 0 retained: Validates every explicit account before conflict rejection; effective default is for idempotency only and cannot replace absent caller-selected account. send.test.ts (results recorded separately)
src/gateway/server-methods/chat-send-session-binding.ts 39 39 0 reviewed-no-change: Re-read deferred native session binding. One returned callback fences registration, generation, admission and projection state before writing SID. Independent guards protect different owners; no unused binding option. src/gateway/server-methods/chat-send-session-binding.test.ts
src/gateway/server-methods/local-state-owner.ts 38 46 -8 reviewed-no-change: Re-evaluated shared-core extraction: captureLocalStateMutationGuard captures the physical Gateway state owner and config, rechecks signal/request authority and owner at use time, and optionally checks a source inode. Target inode identity is a separate filesystem boundary, not duplicate state-owner validation. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/nodes.handlers.invoke-progress.ts 38 38 0 retained: Single validated RPC checks caller identity and byte bound then delegates node-registry owner; no second invoke-progress path or local progress state. nodes.validation.test.ts; results recorded separately
src/gateway/server-methods/storage.ts 38 38 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: storage.locations.list delegates to listStorageLocations with an optional loaded registry. storage.locations.probe delegates to probeStorageLocation with an explicit empty storageProviders map when unavailable. One is a synchronous catalog read and the other an asynchronous probe with a different registry fallback; each is already a single owner call. Full server-methods directory; results recorded separately
src/gateway/server-methods/hooks-status.ts 37 37 0 retained: One report combines registry hook facts and directory loading. These are distinct plugin/workspace ownership inputs, no repeated discovery. hooks-status.test.ts (results recorded separately)
src/gateway/server-methods/chat-send-goal-retry.ts 36 36 0 retained: Single goal read captures dedupe before await. Known SessionGoalOperationError is intentionally receipt data; unknown failures propagate. A common response wrapper would still need this distinction and earlier snapshot. chat-send-request.test.ts;../server.chat-goal.test.ts;../server-chat.goal-lifecycle.test.ts; results recorded separately
src/gateway/server-methods/node-command-rejection-hint.ts 36 36 0 reviewed-no-change: Re-evaluated shared-core extraction: buildNodeCommandRejectionHint maps policy reasons in order: undeclared command, Talk trust, explicit deny, dangerous allow opt-in, generic allowlist, and pending declared-surface approval. Each return has distinct exact user remediation; no repeated action body accompanies the text branches. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/session-create-initial-turn.ts 36 36 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveSessionCreateInitialTurn shares attachment normalization with chat ingress and distinguishes invalid attachment-only input from no initial turn. isFreshChatSendStarted interprets an acknowledgement only when it is not cached. Input construction and result classification do not overlap. Full server-methods directory; results recorded separately
src/gateway/server-methods/chat-send-session-settings.ts 35 35 0 retained: Expectations are always checked before optional snapshot capture; folding into commit branch would omit noncommitting checks. chat.directive-tags.test.ts (results recorded separately)
src/gateway/server-methods/speech-mime.ts 35 35 0 rejected-prototype: REJECTED measured ordered lazy-predicate MIME strategy table: 35 to 39 (+4), misc-prototypes/speech-mime.ts. Four short branches preserve varying prefix/suffix support and extension precedence with fewer closures and no rule allocations. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/native-hook-relay.ts 34 34 0 reviewed-no-change: Re-read relay bridge. One call carries explicit generation requirement and requester signal, then maps its only result/error. Existing direct response has no duplicated native owner. src/gateway/server-methods/native-hook-relay.test.ts
src/gateway/server-methods/users-mentionable.ts 33 33 0 retained: Single validated method delegates to mentionInbox callback. Success/error projection is one canonical result union; adding a generic responder for this one call would grow LOC. ../mention-directory.test.ts;../mention-inbox.test.ts; results recorded separately
src/gateway/server-methods/backup.ts 32 32 0 reviewed-no-change: Re-evaluated shared-core extraction: backup.status parallel-reads backup runs and cron jobs, then projects targets/schedules/storage locations. summarizeBackupSchedules and summarizeBackupTargets are already owned elsewhere, and cron/state changes are excluded. The handler has one read composition and no duplicate branch. src/gateway/server-methods/backup.test.ts
src/gateway/server-methods/models-auth-refresh.ts 32 32 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: models.authRefresh validates once, resolves explicit or ambient auth owner through resolveModelAuthAgentScope and invokes refreshModelAuthStateAfterMutation under respondUnavailableOnThrow. This is already a single shared refresh call; changing the empty-string agent fallback would change accepted request behavior. Full server-methods directory; results recorded separately
src/gateway/server-methods/system-agent-session-owner.ts 32 32 0 reviewed-no-change: Re-read owner precedence. Delegation precedes durable profile, pending-profile fence, email, device and connection. A precomputed list would evaluate later identities before the pending-profile fence; direct short-circuit owner selection retained. src/gateway/server-methods/system-agent-session-ownership.test.ts
src/gateway/server-methods/voicewake.ts 32 32 0 retained: Read and write share respondUnavailableOnThrow; set must normalize, persist and broadcast committed triggers in that order. A shared handler factory adds strategy type/callback plumbing to two already short adapters. ../server.models-voicewake-misc.test.ts; results recorded separately

Final committed candidate: 3fa749dfb9ba45ebf64552d168d25580551981c8. The search-handler deferral is reviewed and committed; focused types, lint, and both cycle checks passed. Hosted CI is bound to this new head. The PR body owns current test and CI dispositions.

@steipete

steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

d01 PR 2 coverage, part 5 of 6

Continuation of the historical per-file coverage. Current working candidate: 862 net production lines across 112 files against 54bd6ecee1897f51b2963b6ea4c165a356e2d805, including the pending nine-line cancellation cleanup. Test targets below are not proof claims.

File Before Initial after Initial net removed Decision and rationale Existing test targets
src/gateway/server-methods/artifacts-transcript-images.ts 31 31 0 reviewed-no-change: Re-evaluated shared-core extraction: findTranscriptImageArtifact prepares the exact session read, queries one image artifact, rechecks authority, and returns the same assertion with the artifact. Missing scope is an early empty lookup; combining it with the successful response would skip or misplace the post-I/O check. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/models-list-context.ts 31 31 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: ModelsListCatalogSource discriminates Gateway catalog loading from a published owner with auth materializations; PreparedModelsListRequest carries request-specific metadata authority. GatewayModelCatalogContext is a narrow Pick used by both. These are capability boundaries, not a manually mirrored function result; the redundant result mirror was removed from models-list-result.owner.ts instead. Full server-methods directory; results recorded separately
src/gateway/server-methods/session-create-category.ts 31 31 0 retained: One post-commit registration with source checks and forced catalog invalidation on ambiguous write failure; catch has deliberate commit-before-error handling. sessions-create-category.test.ts (results recorded separately)
src/gateway/server-methods/update-outcome-observation.ts 31 31 0 retained: Single classification and actor format; public failure code projection deliberately sanitizes fields independently and reads last failing step only on failures. No duplicate outcome owner. update.test.ts; results recorded separately
src/gateway/server-methods/user-preference-events.ts 31 31 0 reviewed-no-change: Re-evaluated shared-core extraction: publishUserPreferencesChanged resolves the canonical profile once, selects exact or alias-matching connected profiles, and publishes only to that set. Exact-ID short-circuit avoids unnecessary alias reads. There is one identity filter and one event construction. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/nodes-policy.ts 30 30 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: nodeInvokePolicy owns wake/pending constants, pending-pairing read scope and the one private Claude-run rejection. canReadPendingNodePairing shares the admin/pairing rule with node reads; rejectClaudeAgentRun delegates the supported continuation path in its existing error. No second scope or command policy is implemented here. Full server-methods directory; results recorded separately
src/gateway/server-methods/nodes.invoke-foreground.ts 30 30 0 retained: Platform and command gates precede shared structured error marker extraction. No duplicate handler body beyond three explicit camera/screen/talk prefixes. nodes.invoke-wake.test.ts (results recorded separately)
src/gateway/server-methods/projects-session-store.ts 30 30 0 retained: New30-line adapter explicitly selects canonical combined loader versus already-provided incognito stores; mergeCombinedSessionStore remains the sole projection core. Removing adapter would duplicate this branching in project callers. src/gateway/server-methods/projects.test.ts
src/gateway/server-methods/session-goal-change.ts 29 29 0 retained: One event write plus synchronous projection fence; finally awaits writer even when publication throws and diagnostic catch preserves committed outcome. sessions-goal.event-custody.test.ts (results recorded separately)
src/gateway/server-methods/sessions-collaboration-diagnostics.ts 28 28 0 reviewed-no-change: Re-read timing owner. Single queued emitter and nested best-effort catch keep diagnostics from replacing operation failure; no duplicate measurement lifecycle. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/system-agent-chat-params.ts 28 28 0 reviewed-no-change: Re-read sanitized context. Context omission and invalid/delegated context already share one destructuring exit; page validation and plugin projection each execute once. src/gateway/server-methods/system-agent.test.ts
src/gateway/server-methods/skills-proposal-history.ts 27 27 0 retained: Two retained RPC names already share respondRetiredHistory and constant message; each keeps its own schema validation. Removing aliases is forbidden feature change. skills.proposals.test.ts; results recorded separately
src/gateway/server-methods/node-push-transport.ts 26 26 0 reviewed-no-change: Re-evaluated shared-core extraction: resolveNodePushTransport returns relay configuration synchronously within its async function without loading signing material; direct registration awaits APNS auth resolution. Both already return the same ok/error union, but acquiring the two transports through one eager path would read disallowed credentials for relays. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/chat-send-external-authority-contract.ts 24 24 0 retained: Type-only narrow capability operations share their request record; resolve/classify/run have distinct contracts and no implementation duplication. chat-send-admission-authority.test.ts (results recorded separately)
src/gateway/server-methods/models-auth-status-config.ts 24 24 0 reviewed-no-change: Re-read provider config auth references. One Set deduplicates canonical and incompatible-profile references; provider iteration cannot be replaced by direct profile iteration because config owns membership. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/response.ts 24 24 0 retained: respondUnavailable is canonical error projection; respondUnavailableOnThrow adds catch with required authority-error rethrow. Both are broadly called and represent separate operations. ../server.models-voicewake-misc.test.ts; results recorded separately
src/gateway/server-methods/gateway-personal-caller.ts 21 21 0 reviewed-no-change: Re-evaluated shared-core extraction: isSyntheticGatewayCaller recognizes synthetic clients, delegated tools, runtime identities, and ambient tool callers. isIneligiblePersonalGatewayCaller adds the distinct rule that real shared-secret sockets may carry a system actor plus owner profile. The latter reuses the former instead of duplicating its conditions. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/session-model-selection-policy.ts 21 21 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: resolveGatewayModelSelectionPolicy composes admin scope with config writability and delegates target selection to resolveStickyModelSelectionPolicy. It deliberately omits an absent scope. There is one policy invocation and no duplicated selection state to derive. Full server-methods directory; results recorded separately
src/gateway/server-methods/nodes.ts 20 20 0 retained: Method-family composition and existing wake exports only; deleting facade would require unrelated import cutover and add equivalent registry imports elsewhere. nodes.invoke-wake.test.ts (results recorded separately)
src/gateway/server-methods/session-goal-request.ts 20 20 0 reviewed-no-change: Re-read canonical fingerprinting. JSON replacer sorts object keys while retaining array order; process identity HMAC is already the only digest path. src/gateway/server-methods/session-goal-request.test.ts
src/gateway/server-methods/logs.ts 19 19 0 retained: One validated handler delegates readConfiguredLogTail; no local file loop/cache. Error prefix is retained transport contract. ../server.logs-tail.test.ts; results recorded separately
src/gateway/server-methods/system-agent-approvals.ts 19 19 0 reviewed-no-change: Re-evaluated shared-core extraction: openclaw.approval.list delegates all visibility to listVisiblePendingApprovalRequests, supplies live config only for authenticated profiles, and returns an empty list without a manager. There is no local approval filter or second list implementation to remove. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/chat-startup-projection-contract.ts 18 18 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: ChatStartupProjectionReadParams distinguishes optional current versus ready metadata reads and includes a late requester-profile reader; ChatStartupProjectionResult carries session and default catalogs separately. Both are small input/output contracts used across metadata and history, not redundant producer result mirrors. Full server-methods directory; results recorded separately
src/gateway/server-methods/question.errors.ts 17 17 0 retained: One sentinel error class and precise manager-error response mapper. Cannot merge with generic errors without consuming unrelated failures. question.test.ts (results recorded separately)
src/gateway/server-methods/agent-request-types.ts 15 15 0 reviewed-no-change: Re-read schema-derived request type. Three internal fields override protocol types and workspaceDir adds internal context; no runtime or duplicate schema body. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/chat-send-pre-admission.types.ts 14 14 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: ChatSendPreAdmissionParams is the shared request/session/client and current-authority contract consumed by retry, Stop and admission phases. LoadedChatSendSession is deliberately weaker than the qualified session required by admitChatSend. Replacing it with the later prepared contract would eliminate the qualification boundary rather than duplicate code. Full server-methods directory; results recorded separately
src/gateway/server-methods/connect.ts 12 12 0 retained: One shipped post-handshake refusal with exact text; no branch/state or duplicate owner. server-methods.test.ts; results recorded separately
src/gateway/server-methods/sessions.runtime.ts 11 11 0 reviewed-no-change: Re-evaluated shared-core extraction: This barrel is the lazy loadSessionsRuntimeModule boundary for cleanupSessionBeforeMutation, lifecycle hooks, and performGatewaySessionReset in session-reset-service. It contains exports only; removing it would migrate lazy imports/callers rather than simplify an in-feature implementation. src/gateway/server-methods/ (full suite)
src/gateway/server-methods/response-types.ts 9 9 0 REVIEWED_UNCHANGED: PR2 full-file shared-core re-evaluation: RespondFn is the sole four-argument protocol-response callback type: success, payload, structured error and internal meta. There is no implementation or parallel declaration within this file to consolidate. Full server-methods directory; results recorded separately
src/gateway/server-methods/voicewake-routing.ts 8 8 0 retained: Eight-line single load response adapter, no extra state or duplicate behavior. server.models-voicewake-misc.test.ts (results recorded separately)
src/gateway/server-methods/base-hash.ts 6 6 0 reviewed-no-change: Re-read six-line multi-caller adapter. Canonical nullable-string normalization owns coercion; removing the adapter would duplicate protocol field extraction across callers. full subsystem and direct caller tests; lead owns frozen proof
src/gateway/server-methods/types.ts 4 4 0 retained: Four-line public type barrel; moving exports does not remove types and churns callers. No runtime duplication. typecheck (parent gate); results recorded separately
src/gateway/server-methods/chat-transcript-persistence.runtime.ts 2 2 0 reviewed-no-change: Re-evaluated shared-core extraction: Two exports form the lazy abort persistence boundary: captureAbortedPartial and persistAbortedPartials. They are owned by separate modules and loaded together by abort callers; there is no forwarding function or executable duplicate in this file. src/gateway/server-methods/ (full suite)
src/gateway/server-channels.ts 1696 1670 26 APPLIED: Read complete manager, lifetime/startup/stop owners, thaw caller and all direct tests. Flatten timeout-recovery state from recoveryStopTimedOut/recoveryStartRequested; one retry response path replaces a cleared boolean. Shared skipped-account publisher takes explicit disabled/unconfigured/unlinked patch; cancellation predicate reused at the same boundaries; channel runtime scoped to its single assignment. Snapshot/lifetime/stop ownership and await order preserved. No new exports/imports/lazy boundaries. NOT RUN; lead coordinated proof: src/gateway/server-channels.test.ts src/gateway/server-channels.account-lifetime.test.ts src/gateway/server-channels.ownership.test.ts src/gateway/server-channels.trust-refusal.test.ts src/gateway/server-channels.work-scope.test.ts src/gateway/server-channels.scheduler-context.test.ts
src/gateway/managed-image-attachments.ts 1617 1592 25 applied: Shared cleanup outcome counting, exact/fallback session lookup input, abandoned block cleanup callback, and HTTP not-found response. Preserved every authority check/await and original file-retention decisions. No changes to MIME/byte/dimension budgets, staging/transcoding, tickets, transcript membership or response text. src/gateway/managed-image-attachments.test.ts;src/gateway/managed-image-attachments.authority.test.ts;src/gateway/managed-image-attachments.sqlite-visibility.test.ts;src/gateway/managed-image-attachments.branch-retention.test.ts
src/gateway/node-registry.ts 1393 1359 34 implemented: One connectivity failure serializer preserves distinct errors and settlement; three singleton pairing reads consume the existing synchronous pairing projection owner; disconnect and revocation use one pending invoke/event cleanup. Private projection type narrowed to actual pairing-bound sessions; all public signatures unchanged. src/gateway/node-registry.test.ts src/gateway/node-registry-pairing.test.ts src/gateway/node-registry-policy.test.ts src/gateway/node-registry.worker-launch.test.ts
src/gateway/talk/handlers/index.ts 933 927 6 applied: Applied shared ordered loop for input/output audio-format shallow clones, retaining both empty-array inclusion and insertion order. Empty provider/audio result refusals now share error construction via explicit invalidAudio discriminator, preserving provider-before-audio precedence and text. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/handlers/provider-discovery.test.ts; results recorded separately
src/gateway/terminal/session-manager.ts 794 790 4 implemented: Shared best-effort backend kill across cancelled spawn; lost eviction slot; finalization. Ownership deletion still follows kill; pending aborted spawn still retains onExit tracking. Rejected formatted agent-action guard/result helper790->791 (+1); rejected formatted list projection helper790->791 (+1). src/gateway/terminal/session-manager.test.ts;src/gateway/terminal/session-manager.open-cancellation.test.ts;src/gateway/terminal/session-manager.eviction.test.ts;src/gateway/terminal/session-manager.agent-lifecycle.test.ts;src/gateway/terminal/session-manager.detach.test.ts
src/gateway/agent-turn/agent-job.ts 753 753 0 rejected-prototype: REJECTED measured shared terminal metadata projector: 753 to 754 (+1), misc-prototypes/agent-job.ts. Snapshot merge already shares sticky outcome and session provenance; source-specific replay barriers and pending retry deadlines remain distinct. Two phase maps retain different failure grace contracts. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/managed-linux.ts 722 718 4 implemented: One startup-generation assertion serves readiness timeout, native spawn, pair readiness and startup; each check remains synchronous at its original call site. managed-linux.test.ts;managed-linux-audio.test.ts;computer-authority.runtime.test.ts (results recorded separately)
src/gateway/agent-turn/agent-run-execution-phase.ts 720 720 0 reviewed-no-change: Read complete execution and cleanup. dispatchAdmittedAgentRun already centralizes runtime generation/user-input scope. Settlement authority intentionally survives cancellation while dispatch authority rejects it. Cleanup, deferred recovery and terminal publication are ordered by nested finally boundaries; no duplicate effect owner. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/relay/operations.ts 720 718 2 applied: Applied local current-relay assertion callback to two identical pre-steering guard sites. The post-control check remains separately scoped because it intentionally checks relay identity without repeating caller authorization. Required cancellation epochs, pending/final result ownership and provider acceptance barriers remain unchanged. src/gateway/talk/relay/index.test.ts;src/gateway/talk/relay/barge-in.regression.test.ts;src/gateway/talk/relay/cancellation-recovery.test.ts; results recorded separately
src/gateway/methods/core-descriptors.ts 714 714 0 rejected-prototype: Rejected measured adminWrite constructor prototype across 40 rows: 714->710 (-4). Three generic literal-preservation parameters and an indirect scope/write-policy owner hide the already concise canonical tuple fields; the table already is the explicit strategy data. Kept stable append-only method ordering, names, scopes, release trains and policy objects. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/agent-turn/agent-run-admission-phase.ts 702 681 21 applied: Forwarded the existing PrepareAgentRunDispatchParams user-turn contract into prepareAgentRunUserTurn, retaining explicit generated assertions, controller signal, completion observer, admitted SID and thread overrides. Callee reads named fields only and does not forward unknown inputs; original authority closure already retains this admission frame. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/client-agent-consult.ts 688 688 0 retained: Read entire admission/claim/steering owner. runArgs already owns all execution; owned versus reusable adapters differ in completion claims, requester-final registration, dynamic confirmation context and detached run custody. PromptOwner.isCurrent captures live registration identity, while lifecycleGeneration/requestSignal guard earlier admission; neither duplicates current Map membership. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/talk/relay/session-create.ts 688 688 0 retained: Single harness owns both public relay events and internal Talk events. Output item, playback turn, response owner and continuity-reset facts represent different timelines. Shared emit/error/current-relay helpers already exist. Tool-consult aliases and forced/native decisions converge through provider-results owners; further extraction would pass most closure state unchanged. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/agent-turn/agent-turn-service.ts 670 628 42 applied: Carried preflight/routing records through dedupe, routing and content preparation; captured the common run parameter bundle once for admission/execution. Kept mutable session ID, accepted provenance, current assertions and phase callbacks explicit. Removed now-unused routing destructuring. No I/O or authority boundary moved. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/client-gateway-control.ts 646 646 0 retained: Control versus consult paths already share bounded queues/readiness/active-owner helpers. Pending and active owners must coexist during replacements and provider draining; consult controllers intentionally outlive transport cancellation. The two readiness methods differ in transcript flush versus spoken-confirmation readiness and retain distinct entry invariants. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/desktop/session-registry.ts 605 605 0 retained: released flag fences reentrant close callbacks before bulk observer removal; stopped flag fences ticket cancellation before abort; neither derives safely from owning containers. Shared startup/stop cores already serve acquisition and activation. full desktop directory; focused list pending (lead proof)
src/gateway/talk/handlers/session.ts 604 567 37 applied: Applied shared Talk request error owner with explicit session and legacy-relay projections; acknowledgeMark retains all-errors-unavailable behavior while ordinary sessions classify authorization/agent-selection errors. Shared successful appendAudio response remains synchronous for transcription and after the original await for realtime. Original transport/brain validation and session registration order unchanged. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/handlers/target.test.ts;src/gateway/talk/handlers/native-consult-target.test.ts; results recorded separately
src/gateway/agent-turn/agent-session-persist.ts 567 563 4 applied: Derived send-policy denial from the retained deniedSessionEntry instead of a parallel boolean. Shared exact refusal response for early and final policy checks. Persisted/fresh entry state, recovery transitions, hook ordering and admission rechecks unchanged. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/host-source.ts 521 521 0 retained: Managed/attached source acquisition already converges through registry. Shared unavailable-envelope candidate needs detail,reason,security typed adapter while retaining conditional security omission; no repeated I/O or state to remove. host-source.test.ts;host-observe.integration.test.ts (results recorded separately)
src/gateway/talk/handlers/client-create.ts 520 502 18 applied: Applied shared request-error projection with client steering/session adapters, preserving client error shape without Talk issue details. Reused local captured target assertion at identical authorization/replacement guard points; commit guard and provider-open assertions retain their original positions. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/handlers/client.test.ts;src/gateway/talk/handlers/client-native-actions.test.ts;src/gateway/talk/handlers/client-native-control.test.ts;src/gateway/talk/handlers/target.test.ts; results recorded separately
src/gateway/agent-turn/agent-run-dispatch.ts 517 515 2 applied: Returned the final cleanup-owned completion promise directly instead of storing a single-use runCompletion variable. Replay publication remains behind cleanupRunOwner, and every nested finally/settlement await is unchanged. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/server-aux-handlers.ts 508 498 10 implemented: Bind each of five existing lazy loaders once via a local curried createLazyHandler adapter; retain 24 explicit ordered method keys and their exact inferred required-key API. Original createLazyHandler, lazy promises, creation timing, error text, invocation object, and lifecycle/disposal unchanged. Rejected formatted table prototype 508->497 (-11): one extra line saved requires a new mapped-key construction assertion; assertion-free factory 508->498 (-10) preserves API without a baseline increase. Rejected createLazyCoreHandlers substitution: changes request-entry custody semantics. src/gateway/server-aux-methods.test.ts;src/gateway/server-aux-handlers.test.ts;src/gateway/server-aux-handlers.authority.test.ts;src/gateway/server-import-boundary.test.ts;src/gateway/operator-approval-mcp-grants.test.ts;src/gateway/server-methods/mcp-app.view-grant.test.ts
src/gateway/agent-turn/agent-run-user-turn.ts 488 484 4 applied: Shared claimFollowup core for canonical and raw-session alias handoff claims; session key is the only explicit parameter. Both admission guards and fallback invocation order remain unchanged; transcript/media custody and finalization untouched. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/computer-service.ts 437 437 0 retained: prepare and assertRuntime share predicate terms but inspect provider at different short-circuit points. Current/closed/closing retain admission versus cleanup distinctions; request and settled sets preserve idempotency replay window. full desktop directory; focused list pending (lead proof)
src/gateway/agent-turn/internal-facade.ts 429 429 0 rejected-prototype: REJECTED measured acceptance/final response projector: 429 to 431 (+2), misc-prototypes/internal-facade.ts. Entry lifetime/trackExecution scopes differ because dispatch authorizes before startup while wait authorizes inside observation scope; original options identity and disposal remain explicit. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/relay/state.ts 424 418 6 applied: Removed redundant phase!=cancelling term already implied by phase==unowned in output claim. Formatting then collapses the pure conjunction (424->418). State counters and cancelledTerminal remain distinct generation/twin-terminal facts. Measured capacity extraction across this file/transcription/lifecycle: current 919->936 (+17), rejected because explicit independent limits and error labels add more parameter plumbing than the two small checks. src/gateway/talk/relay/index.test.ts;src/gateway/talk/relay/barge-in.regression.test.ts;src/gateway/talk/relay/cancellation-recovery.test.ts; results recorded separately
src/gateway/talk/transcription-relay.ts 420 417 3 applied: Derived closed state from exact owning transcriptionSessions Map membership, removing private boolean/type/initialization. All close callers select registered sessions; deletion still fences reentry before provider close and terminal event. Draining/receivedAudio remain independent facts for bounded final transcripts. Shared capacity prototype was +17 aggregate LOC and rejected. src/gateway/talk/transcription-relay.test.ts; results recorded separately
src/gateway/desktop/rfb-preauth.ts 414 412 2 implemented: Legacy32-bit selection and modern8-bit count share zero/refusal handling; explicit legacy branch still validates selected type and modern branch still reads offered types and replies. No await or wire-byte changes. rfb-preauth.test.ts;host-observe.integration.test.ts;node-observe.integration.test.ts;audio-observe.integration.test.ts (results recorded separately)
src/gateway/talk/relay/forced-consults.ts 410 410 0 retained: Forced terminal drain already shares submitPending/currentness/completion owners. Snapshot cancellation uses bounded allSettled retry, whereas dynamic native ids use Promise.all recursion until all current ids accept. Those are explicit recovery differences; merging would add policy parameters while retaining both loop bodies. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/talk/voice-selection.ts 403 403 0 retained: Voice change has shared cancellation/currentness/target/finish owners. claimed is admission consumption, clientReady/providerReady are independent two-sided handshake facts, and original session retirement is separately required. Existing session map cannot derive these booleans without dropping the replacement protocol. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/desktop/observe-bridge.ts 371 371 0 retained: shared closeBoth owns every source; preauthentication and transparent splice already converge without granting audio early. Moving browser detach into finally would change stream installation order. full desktop directory; focused list pending (lead proof)
src/gateway/desktop/node-stream-broker.ts 351 350 1 implemented: One exact-connection predicate is consumed before and after awaited pairing-state lookup; false initial or awaited result short-circuits exactly as before. node-stream-broker.test.ts;node-observe.integration.test.ts (results recorded separately)
src/gateway/talk/handlers/client.ts 332 318 14 applied: Applied shared request-error owner only to client.steer, whose complete mapping duplicates client creation. Tool admission/transcript/close keep their INVALID_REQUEST-only error boundaries. Legacy binding reads before and after awaits stay separate to capture concurrent replacement. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/handlers/client.test.ts;src/gateway/talk/client-authority.test.ts; results recorded separately
src/gateway/desktop/managed-linux-audio.ts 328 328 0 retained: daemon and capture process owners have distinct readiness, failure, cleanup and stream semantics. Existing stop/capture owner functions own all retry and terminal paths. full desktop directory; focused list pending (lead proof)
src/gateway/agent-turn/agent-dedupe-lifecycle.ts 321 321 0 reviewed-no-change: Read reserve/bind/clear/reset/restart paths. recordCommittedReset already shares response and replay publication with differing follow-up messages. reserved and accepted distinguish reservation ownership from durable acceptance; neither can derive from current cache after another writer replaces it. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/session-config.ts 321 321 0 retained: Runtime and transcription config already share resolveConfiguredVoiceModelDefaultRef, getVoiceProviderConfig and configuredOrFalse. Their model override precedence and configured-provider fallbacks differ explicitly. Launch option sanitizer already table-drives string and finite-number families; no schema/config changes attempted. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/desktop/rfb-probe.ts 296 296 0 retained: probe reader keeps bytes in native readable-mode buffer for exact connected handoff; preauth reader accumulates flowing WebSocket/Duplex input. A generic reader strategy would need distinct buffering, EOF, abort and detach adapters. full desktop directory; focused list pending (lead proof)
src/gateway/agent-turn/agent-request-preflight.ts 289 289 0 reviewed-no-change: Read all collector/recovery/identity checks. rejectInvalidRequest already shares response; authoritative collector registration and session provenance determine private-field admission. Different guard texts and order protect distinct boundaries, with no parallel state writer. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-admission-controller.ts 275 265 10 applied: Shared release/accept/cache-metadata response for pre-admission abort, timeout and superseded outcomes, with explicit payload variants and original precedence. Lifecycle rotation remains its separate no-response cleanup branch. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/terminal/launch.ts 275 262 13 retained-reviewed: Inherited untested worker change retained after full source/test/caller read: one priority restriction selection; one commit cleanup; one spawn projection with explicit Windows/POSIX branch. No config fields or policy timing changed. src/gateway/terminal/launch.test.ts
src/gateway/agent-turn/agent-content-phase.ts 273 273 0 reviewed-no-change: Read attachment/model/voice-wake paths. Image capability discovery precedes voice routing; deferred attachment parse follows it. Agent-target and session-target voice routes preserve different validation/log text. They already join one returned content bundle. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/computer-process.ts 268 268 0 retained: transport fail and close share cleanup but report different original errors and gate physical cleanup separately from provider finalization. active flag fences failures before close publication. full desktop directory; focused list pending (lead proof)
src/gateway/agent-turn/agent-request-routing.ts 258 256 2 applied: Forwarded the locally constructed explicitRecipient object to canonical recipient resolution instead of copying its identical agent/channel/to fields. Reservation and awaited provider-route error cleanup stay in the same positions. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/audio-bridge.ts 255 249 6 implemented: One idempotent capture settlement function removes listeners before explicit resolve/reject continuations; same end/close/error/abort callbacks and backpressure behavior. audio-bridge.test.ts;audio-observe.integration.test.ts (results recorded separately)
src/gateway/agent-turn/agent-delivery-phase.ts 247 247 0 reviewed-no-change: Read complete delivery resolution. Canonical planner owns routing, while default-channel and missing-target recovery have separate failure policies. Incognito error wrapper centralizes redaction; best-effort fallback never redirects the bound target on failure. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/node-source.ts 241 241 0 rejected prototype: Formatted shared credentials descriptor/validation/redaction241→245 (+4); postbranch shared redaction241→241 saves zero. Original explicit VNC versus ARD blocks retained. node-source.test.ts;node-observe.integration.test.ts (results recorded separately)
src/gateway/agent-turn/agent-run-subagent.ts 235 235 0 reviewed-no-change: Read successor, parent-resume, requester completion and plugin registration paths. These already share final native admission predicates but transfer distinct completion owners. settleUnstartedGatewayFollowup owns the single exact physical-registration settlement core. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-dedupe.ts 232 224 8 applied: Forwarded original dedupe publication context into the canonical single-entry writer and aborted-result batch writer; only key and generated entry are explicit overrides. Writer source inspection confirms extra private fields never enter replay payloads or persisted state. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/handlers/voice.ts 216 209 7 applied: Applied local authorizeSession(agentId,sessionKey) core for managed and browser targets, with each original target identity and assertion order. Voice-change variants now share one awaited success response while retaining managed changeVoice and browser requestTalkVoiceChange strategies. src/gateway/talk/handlers/voice.test.ts;src/gateway/talk/handlers/voice-channel.test.ts; results recorded separately
src/gateway/talk/session-registry.ts 212 212 0 retained: Shared cleanup runner retains original failure owner and nextRun independently. pending closes reentrant shutdown before callback returns; failed keeps retry custody even without a promise. Removing either field would allow owner replacement after failed or pending teardown. Session records and connection cleanup maps own different lifetimes. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/terminal/output-flow-control.ts 197 190 7 retained-reviewed: Inherited untested worker change retained: one hysteresis core with explicit periodic reassert flag. Normal undefined-pressure probes still no-op; periodic probes resume and reassert even unchanged state. Watermarks/frame/coalesce bytes and timers unchanged. src/gateway/terminal/session-manager.test.ts;src/gateway/terminal/session-manager.detach.test.ts
src/gateway/desktop/computer.worker.ts 192 190 2 implemented: Derive stopped state from owning stopping promise: set before any synchronous reentry, never cleared, and already authoritative for stop idempotence. computer-process.runtime.test.ts;computer-process.test.ts;computer-authority.runtime.test.ts (results recorded separately)
src/gateway/talk/relay/provider-results.ts 183 183 0 retained: Final provider results already share submission/completion tracker. Provider/agent tombstones and pending working/final maps represent distinct acceptance barriers and cancellation epochs. A single pending map cannot preserve final-before-working prohibition or late cancellation retries. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/talk/agent-consult.ts 181 181 0 retained: Single chat-send adapter preserves terminal ACK classification, pre-ACK and post-ACK failure behavior, and exact relay registration cleanup. runId may be an explicitly returned empty string, so the missing-active-run branch remains reachable and must preserve its error. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/agent-turn/agent-handler-helpers.ts 173 173 0 reviewed-no-change: Read lifecycle rejection, CLI continuation, prompt suppression and ACK/recovery delay helpers. Existing resolveSessionWorkStartError owns policy; specialized adapters have multiple callers. Cron delay/compatibility behavior left unchanged. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/handoff.ts 158 158 0 rejected-prototype: Rejected measured shared closeHandoff(id,record,reason) prototype 158->158 (0). A third helper needs the original map key independently of externally readable record.id and only replaces two straightforward event/delete pairs; no reduction or clarity gain. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/desktop/rfb-view-only-filter.ts 143 135 8 implemented: Handshake and permitted message phases share forwarding tail. Unsupported-security error returns fail(error), which discards the entire local forwarded array and latches failure; no partial bytes escape, as caller and existing19/30 tests confirm. rfb-view-only-filter.test.ts;observe-bridge.test.ts;host-observe.integration.test.ts;node-observe.integration.test.ts (results recorded separately)
src/gateway/transcript-image-artifacts.ts 143 143 0 rejected-prototype: REJECTED measured canonical safe-integer helper prototype: 143 to 145 (+2), misc-prototypes/transcript-image-artifacts.ts. Shared numeric owner requires three retained values and expanded import; original strict canonical encoding and source/content position checks remain shorter. src/gateway/artifact-downloads.test.ts;src/gateway/artifact-download-projection.test.ts;src/gateway/server-methods/artifacts.test.ts
src/gateway/talk/relay/tool-call-ledger.ts 142 142 0 retained: mark(callIds,mutate) already shares admission and updates for completion/cancellation variants. retainedBytes and overflowReported cannot derive cheaply from active metadata because identities remain permanently admitted through terminal fact clearing. Clear methods target different fields and are each three-line loops. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/terminal/node-relay.ts 140 140 0 implemented: Use existing asOptionalRecord owner after JSON.parse; same object/non-array guard removes two assertions. Net zero production LOC. Input splitting, exact connection authority, early-exit buffering unchanged. src/gateway/terminal/node-relay.test.ts
src/gateway/talk/relay/voice.ts 135 135 0 retained: Transcript queue owns retry, overflow and persisted confirmation; create and close share ensureRelayVoiceSession/logging. voiceSessionCreated remains durable record existence, not transport registration, and voiceSessionClose captures asynchronous close completion. No redundant authority state. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/methods/registry.ts 133 133 0 retained: Post-spread startup/lifetime/controlPlaneWrite/advertise projections are required, not redundant: registry.test explicitly exercises inherited and non-enumerable metadata. Normalization is already one core for all descriptor owners; duplicate-name fail-closed registration remains canonical. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/agent-turn/agent-run-admission-revalidation.ts 129 129 0 reviewed-no-change: Read dual synchronous/async revalidation. Success returns literal true synchronously to preserve acceptance atomicity. Rejection and abort settle different pending-input outcomes before response; shared resolveAgentRunAdmissionError already preserves typed authority failures. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/artifact-download-grants.ts 129 129 0 reviewed-no-change: removeDownload already owns deletion/release for expiration, per-connection bound and abort. Grant object identity, caller lifetime, live authority and TTL fence independent invalidation sources; none is derivable from another. No byte retention added. src/gateway/artifact-downloads.test.ts;src/gateway/artifact-download-projection.test.ts;src/gateway/server-methods/artifacts.test.ts
src/gateway/artifact-downloads.ts 129 128 1 applied: Shared the final unavailable response for missing projection and thrown read/authority/thumbnail preparation; clear prepared bytes before the shared exit. Original range, MIME, security headers and exact Not Found response remain unchanged. src/gateway/artifact-downloads.test.ts;src/gateway/artifact-download-projection.test.ts;src/gateway/server-methods/artifacts.test.ts
src/gateway/methods/core-method-policy.ts 123 123 0 retained: One canonical spec list/map owns method classification and descriptor projection. Getter functions expose distinct filtered metadata contracts; handler fallback loop intentionally detects unknown handlers after known-row projection. No parallel authorization implementation remains. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/talk/realtime-run-control.ts 115 115 0 retained: Delegation/transcript control already share handleInput/enqueue with readiness/result/error strategies. prepare runs before FIFO admission deliberately, and reply failures remain outside execution catch. Queue seal/flush owns shutdown; no duplicate controller. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately

Final committed candidate: 3fa749dfb9ba45ebf64552d168d25580551981c8. The search-handler deferral is reviewed and committed; focused types, lint, and both cycle checks passed. Hosted CI is bound to this new head. The PR body owns current test and CI dispositions.

@steipete

steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

d01 PR 2 coverage, part 6 of 6

Continuation of the historical per-file coverage. Current working candidate: 862 net production lines across 112 files against 54bd6ecee1897f51b2963b6ea4c165a356e2d805, including the pending nine-line cancellation cleanup. Test targets below are not proof claims.

File Before Initial after Initial net removed Decision and rationale Existing test targets
src/gateway/methods/descriptor.ts 112 112 0 retained: Plugin descriptor creation shares namespace normalization with registry but retains caller name and default admin semantics before later normalized indexing. Public owner/scope/sessionAccess/read-sharing types are canonical contracts, not removable mirrors. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/managed-image-attachments.custody.ts 111 111 0 reviewed-no-change: One record/file custody owner handles insert settlement and durable cleanup claim. Accepted transfer, rejected transfer, unknown SQLite outcome and physical file absence are distinct recovery facts; shared settleFile preserves bytes until the exact claim proves discard. src/gateway/managed-image-attachments.test.ts;src/gateway/managed-image-attachments.authority.test.ts;src/gateway/managed-image-attachments.sqlite-visibility.test.ts;src/gateway/managed-image-attachments.branch-retention.test.ts
src/gateway/agent-turn/agent-run-admission-types.ts 105 105 0 reviewed-no-change: Read schema-derived admission types. Prepared model ownership is a mutually exclusive union; user-turn fields derive through Omit. No executable duplication or unused mode removed. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-restart-recovery-context.ts 103 103 0 reviewed-no-change: Read source-channel and execution-identity reconstruction. Recovery tuple match and source authority precede display context; control-ui and channel variants preserve explicit contracts. Audit/token semantics are outside this refactor and untouched. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/run-ownership.ts 99 99 0 retained: One currentness closure composes voice binding, chat registration, backend attempt, reply pending owner, signal and lifecycle generation. Captured absence must survive waits; replacing snapshots with live lookup changes control target. Session-wide versus voice-call scope is already explicit. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/terminal/session-manager.types.ts 99 99 0 reviewed-no-change: 99 lines of backend/request/owner/session contracts consumed by manager and public callers. No mirrored implementation owner; deleting or widening fields would change supported calls. src/gateway/terminal/session-manager.test.ts;src/gateway/terminal/session-manager.agent-lifecycle.test.ts
src/gateway/talk/relay-session-lifecycle.ts 84 84 0 retained: Existing expiry/close/lookup generic owners are shared by both relays. Measured capacity helper with explicit independent limits/labels grows current three-file surface 919->936 (+17); retained simple bounded checks at owners. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/agent-turn/types.ts 82 82 0 reviewed-no-change: Read frame/IO/principal/context/observation types. Terminal outcome derives from canonical owner and other types represent independent transport/authority roles. No runtime duplication. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/artifact-download-projection.ts 82 82 0 reviewed-no-change: One content digest shared by capability preparation and read validation. Full response decodes directly into owned allocation; range response decodes complete base64 quanta before slicing. Unifying with eager full decode would violate range memory behavior. src/gateway/artifact-downloads.test.ts;src/gateway/artifact-download-projection.test.ts;src/gateway/server-methods/artifacts.test.ts
src/gateway/terminal/agent-session-drain.ts 74 74 0 reviewed-no-change: 74-line exact-incarnation tracker owns overlapping drain receipts and exiting backends. Active/drained/exiting maps represent distinct lifecycle states; collapsing would permit premature release or archive. src/gateway/terminal/session-manager.agent-lifecycle.test.ts
src/gateway/agent-turn/agent-run-dispatch-outcome.ts 73 73 0 reviewed-no-change: Read abort/timeout classification. Canonical signal reason helper serves both rejection and resolved timeout paths; response status map is already table-driven. Raw AbortError rejection intentionally differs from owner-recorded cancellation. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/relay/issues.ts 71 71 0 retained: Single public error projector groups failover categories and hides opaque routes. resolveTalkRealtimeRelayPresentation separately prepares public selection and private launch facts; their model distinction is required and no duplicate projection exists. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/agent-turn/agent-run-execution-lineage.ts 70 70 0 reviewed-no-change: Read authenticated lineage consumption. One admission serializer owns token construction after one-use lineage consumption; collection/provenance contract is audit-adjacent and unchanged. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-wait.ts 70 70 0 reviewed-no-change: Read queued-before/during/after observations. queuedResult already shares projection and pending waits capture original session identity. Terminal replay wait must retain source-specific barrier; queued observations can finish a wait without ending execution. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/session-history.ts 67 67 0 retained: Single bounded transcript reader and quoted-history builder serve browser/relay callers. Byte budgets apply to distinct raw items and quoted serialized prompt forms, so combining loops loses prompt-byte accounting. Both currentness assertions bracket asynchronous transcript work. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/methods/core-profile-access.ts 66 66 0 retained: One predicate combines canonical session-method policy plus explicit exact/prefix exceptions. Prefixes cannot replace listed exact methods without widening profile requirements to unlisted method names; no duplicated runtime state. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/talk/session-target.ts 64 64 0 retained: prepare/assert share one storage target resolver; prepared identity retains original key and canonical storage key separately. Object.freeze keeps captured target immutable. Live assertion revalidates physical store without consulting ambient Talk defaults. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/agent-turn/internal-facade.types.ts 63 63 0 reviewed-no-change: Read internal API types and callers. Numeric dispatch timeout overload and wait callbacks are existing internal seams; no unused variant proved across callers, and no protocol shape changed. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/terminal/open-deadline.ts 62 60 2 implemented: Reuse assertCurrent for initial absolute-deadline fence; closure setup is synchronous and no new awaits. Same deadline reason and error normalization; caller still closes late success. src/gateway/server-methods/terminal.test.ts
src/gateway/agent-turn/agent-run-commentary-media.ts 61 61 0 reviewed-no-change: Read media binding and delegated dispatch. loadCommentaryMedia preserves original dispatch object identity for execution provenance; it lazily imports custody owner and validates exact abort registration. No duplicate media owner. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-run-execution-types.ts 60 60 0 reviewed-no-change: Read execution parameter contract. It deliberately differs from admission input in resolved session, accepted provenance, media and recovery ownership. Shared runtime parameter bundle removes caller repetition without widening this exported type. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-run-admission-model.ts 58 58 0 reviewed-no-change: Read model override/runtime selection and lifecycle store locator. One canonical override resolver and runtime selector own policy; path read retains list-only projection and keyless admission fallback. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/agent-turn/agent-run-recovery-admission.ts 57 57 0 reviewed-no-change: Read admitted recovery and interruption callback. restored records a successful durable transition and cannot derive from invocation count; original exact admitted attempt is retained across retry and returned target projection. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/managed-image-attachments.media-kind.ts 56 56 0 reviewed-no-change: One media-kind/limit owner already serves ingestion and HTTP. Explicit document allowlist, SVG exclusion, local audio/video maximum and independent image limits remain canonical; no parallel MIME policy found. src/gateway/managed-image-attachments.test.ts;src/gateway/managed-image-attachments.authority.test.ts;src/gateway/managed-image-attachments.sqlite-visibility.test.ts;src/gateway/managed-image-attachments.branch-retention.test.ts
src/gateway/talk/relay/agent-consult.ts 53 50 3 applied: Applied one claimForCurrentOwner keyed core for successful/failure completion claims. It samples currentness first but always invokes the underlying claim, even when retired; preserves cleanup consumption before returning conjunction. src/gateway/talk/relay/index.test.ts;src/gateway/talk/relay/confirmation.test.ts; results recorded separately
src/gateway/talk/handlers/client-legacy-voice-bindings.ts 52 52 0 retained: Read and write already share TTL pruning and key formation. Forget intentionally does not prune unrelated entries and deletes only matching voice identity. Retained shipped clients require implicit binding compatibility. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/terminal/session-connection-index.ts 51 51 0 reviewed-no-change: 51-line reverse index already shares add/remove cores; snapshots must stay copied because manager mutates during disconnect. Two 3-line snapshot methods generalized through a 4-line helper plus two calls yields no reduction. src/gateway/terminal/session-manager.test.ts;src/gateway/terminal/session-manager.detach.test.ts;src/gateway/terminal/session-manager.open-cancellation.test.ts
src/gateway/agent-turn/principal.ts 41 41 0 reviewed-no-change: Read principal capture and observer callback. Selected transport fields deliberately exclude request lifetime; two opaque owner transfers preserve separate ingress/operator identities. TOOL_EVENTS capability check is shared by every caller. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/computer-protocol.ts 41 41 0 retained: schema definitions and output parser wrappers are protocol owners; no semantic schema changes authorized. full desktop directory; focused list pending (lead proof)
src/gateway/methods/read-share-keys.ts 41 41 0 retained: Single deterministic operatorReadShareKey core handles ownership exclusions and sorted object/scopes/caps. Cron and models wrappers encode different shareability vetoes; merging them would require the same two policy callbacks and no LOC reduction. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/talk/relay/cancellation-deadline.ts 41 41 0 retained: Two timers own different deadlines: bounded cancellation resumes input while retaining discard fence; stale-generation timeout closes only that fence. Both validate exact session identity; one cannot replace the other without authorizing stale output. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/methods/core-descriptor-types.ts 40 40 0 retained: Compact canonical descriptor policy tuple types derive shared fields from descriptor contracts. Moving these declarations creates no production LOC reduction and widens imports in the static table. src/gateway/methods/registry.test.ts;src/gateway/methods/core-descriptors.since.test.ts; results recorded separately
src/gateway/terminal/session-projection.ts 40 40 0 reviewed-no-change: 40-line canonical summary and recipient projection already reused by attach/list. Summary fields; order; optional title; attach high-water offset are wire behavior. src/gateway/terminal/session-manager.detach.test.ts;src/gateway/terminal/session-manager.test.ts
src/gateway/talk/handlers/mode.ts 39 39 0 retained: One lightweight handler deliberately checks connected Talk node before parameter validation, then commits/broadcasts synchronously. It remains independent of provider runtime loading. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/talk/client-agent-consult.types.ts 36 36 0 retained: Canonical lifecycle/reusable callback contracts derive native request parameters. Owned callbacks intentionally add readiness/requester-final controls; folding signatures widens APIs and requires adapters at callers. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/talk/client-gateway-control.types.ts 34 34 0 retained: Gateway owner types derive native control and consult contracts. bindControl is required on the returned owner despite optional provider contract; the intersection protects caller authority. No duplicate runtime code. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/desktop/observe-requester.ts 32 32 0 retained: single authenticated display/connection authority projection, no duplicated implementation. full desktop directory; focused list pending (lead proof)
src/gateway/terminal/intro-banner.ts 32 32 0 reviewed-no-change: 32-line exact user-visible colored CRLF banner; art bytes and palette explicitly asserted. No sound structural reduction without golfing byte data. src/gateway/terminal/intro-banner.test.ts;src/gateway/terminal/session-manager.intro-banner.test.ts
src/gateway/agent-turn/agent-run-diagnostics.ts 30 30 0 reviewed-no-change: Read privacy capture and diagnostic adapters. One incognito classification drives runtime logging, warning text and replay metadata with distinct field omission contracts; no second privacy owner. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/terminal/output-ring.ts 25 25 0 reviewed-no-change: 25-line specialized BoundedBuffer reuses owning buffer and fits safe UTF-16 tail; snapshot joins retained values. No duplicate state or alternate owner. src/gateway/terminal/session-manager.output-ring.test.ts
src/gateway/terminal/buffer-text.ts 23 23 0 reviewed-no-change: 23-line ANSI/control and CR overwrite normalization; byte classes and overwrite order all behavioral, no duplicate paths. src/gateway/terminal/buffer-text.test.ts
src/gateway/talk/nodes.ts 22 19 3 applied: Inlined single-call node capability predicate into the registry some traversal; same awaited node list, normalization and talk-capability-before-command short circuit. Removed private helper/type dependency. src/gateway/talk/nodes.test.ts; results recorded separately
src/gateway/terminal/gateway-transport.ts 22 22 0 reviewed-no-change: 22-line targeted-broadcast adapter preserves data-only dropIfSlow and caller pressure owner; backend/process do not own WS options. src/gateway/terminal/session-manager.test.ts;src/gateway/server-methods/terminal.test.ts
src/gateway/agent-turn/agent-run-dispatch-execution-identity.ts 21 21 0 reviewed-no-change: Read private WeakMap binding. Copying on bind preserves caller object while giving the dispatch a unique provenance key. Same object must survive commentary setup; public token fields are intentionally absent. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/desktop/host-source-errors.ts 20 20 0 retained: concrete credentials error subclass preserves name, detailCode and narrowed auth contract. full desktop directory; focused list pending (lead proof)
src/gateway/desktop/attachment.ts 16 16 0 retained: one explicit unix/TCP adapter and attachment contract, no repeated logic. full desktop directory; focused list pending (lead proof)
src/gateway/desktop/host-guidance.ts 16 16 0 retained: data table owns required platform messages; fallback remains Linux guidance. full desktop directory; focused list pending (lead proof)
src/gateway/agent-turn/io.ts 15 15 0 reviewed-no-change: Read synchronous frame adapter. emitAcceptance and emitFinal already share emit; three versus four response arguments is intentionally preserved for undefined metadata. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/terminal/backend.ts 15 15 0 reviewed-no-change: 15-line local/node backend contract has all methods used by manager/output and both backend producers. Removing methods breaks real callers. src/gateway/terminal/node-relay.test.ts;src/gateway/terminal/session-manager.test.ts
src/gateway/talk/agent-consult-transcript.ts 14 14 0 retained: One direct delegation to canonical display projector, with exact stopped-final/no-tool-call predicate. Spoken transcript and lossless history ownership cannot be collapsed. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/terminal/session-limits.ts 14 14 0 reviewed-no-change: 14-line authoritative limits retain every public default and comments defining UTF-16/deadline units. No competing owner. src/gateway/terminal/session-manager.eviction.test.ts;src/gateway/terminal/session-manager.detach.test.ts;src/gateway/terminal/session-manager.output-ring.test.ts
src/gateway/desktop/computer-owner.ts 12 12 0 retained: exact authority tuple serialization is security identity contract, no duplicate body. full desktop directory; focused list pending (lead proof)
src/gateway/desktop/node-source-context.ts 11 11 0 retained: narrow symbol-keyed context accessor; removing would move same cast and key ownership to callers. full desktop directory; focused list pending (lead proof)
src/gateway/terminal/session-types.ts 10 10 0 reviewed-no-change: 10-line narrowed protocol projection types used by manager/projection and agents. Exact owner encoding and attach field omissions are public behavior. src/gateway/terminal/session-manager.test.ts;src/gateway/terminal/session-manager.detach.test.ts
src/gateway/talk/relay-audio-base64.ts 9 9 0 retained: Nine-line canonical decoder delegates normalization and preserves label-specific errors. No hand-rolled duplicate base64 validator. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/talk/session-target.types.ts 8 8 0 retained: Eight-line identity contract intentionally avoids importing storage runtime into shared Talk consumers; relocation would preserve LOC and widen runtime-adjacent imports. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/relay/index.test.ts; results recorded separately
src/gateway/terminal/enabled.ts 6 6 0 reviewed-no-change: 6-line lazy import boundary used by HTTP/CSP without launch policy. Inlining would repeat policy or pull heavyweight launch imports into startup. src/gateway/terminal/launch.test.ts
src/gateway/agent-turn/internal-facade.runtime.ts 1 1 0 reviewed-no-change: Read one-line runtime barrel and consumers. This is the maintained lazy runtime entrypoint, not an unused forwarding layer; retained unchanged. src/gateway/agent-turn full directory; gateway agent RPC tests
src/gateway/talk/request-error.ts 0 24 -24 applied: New shared error projection owner. client/session classify authorization and agent-selection errors identically; session adds existing talkIssue only for unavailable outcomes. legacy-relay explicitly suppresses classification for acknowledgeMark compatibility. Error text and optional details shape preserved. src/gateway/talk/handlers/index.test.ts;src/gateway/talk/handlers/client.test.ts;src/gateway/talk/handlers/target.test.ts; results recorded separately

Validation follow-up

The final Knip scan found one internal type re-export orphaned by the approval lookup simplification. This adds one adjacent module to the coverage log: 551 modules total. The row below uses the second-rebase base 54bd6ecee1897f51b2963b6ea4c165a356e2d805; the earlier tables retain their original-base measurements.

File Before After Net removed Decision and rationale Existing test targets
src/gateway/exec-approval-manager.ts 741 740 1 Removed only the unused ExecApprovalIdLookupResult re-export. The lifecycle owner imports the canonical type directly; both lookup method signatures remain unchanged. Whole-repo reference and SDK/tooling export audits found no consumer of the removed alias. exec-approval-manager.test.ts; exec-approval-manager.lifetime.test.ts; exec-approval-manager.expiry.test.ts

Final committed candidate: 3fa749dfb9ba45ebf64552d168d25580551981c8. The search-handler deferral is reviewed and committed; focused types, lint, and both cycle checks passed. Hosted CI is bound to this new head. The PR body owns current test and CI dispositions.

@steipete
steipete marked this pull request as ready for review October 8, 2026 10:34
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 3fa749dfb9ba45ebf64552d168d25580551981c8
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/desktop/rfb-preauth.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/exec-approval-manager.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/gateway/server-methods/channel-pairing.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/devices.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/exec-approvals.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/gateway/server-methods/model-auth-agent-scope.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/models-auth-status-facts.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/models-auth-status.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/request-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/session-file-read-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 8, 2026, 7:27 AM ET / 11:27 UTC (Revision 2).

ClawSweeper review

What this changes

The branch consolidates repeated Gateway request preparation, response projection, and lifecycle bookkeeping while preserving existing contracts.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful consolidation with no concrete patch finding, supported by broad harness coverage but limited runtime proof and unresolved search-failure attribution.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This verified maintainer refactor is outside the external-contributor proof gate. Supplied candidate evidence is existing Gateway harness coverage; historical predecessor media does not prove this head. Inspection establishes no stored-format or migration change and no material transfer or widening of authority.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: This continues an established owner-directed cleanup that reduces repeated preparation and lifecycle code. The maintenance benefit is supported by removing duplication while retaining existing contracts.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this is useful, distinct consolidation work with no verified introduced defect. The hosted session-search failure remains unattributed, and the PR explicitly awaits its resolution before landing.

Priority: P3
Reviewed head: 888a1cb1c4a7b3b6a4abd7f10e1de2b847740453

Before merge

  • Complete next step (P2) - Establish the hosted session-search failure’s cause and record a verified owner repair or supported inherited-failure disposition before landing.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.

Findings

None.

Tests

  • Missing end-to-end proof: Existing harness coverage is the strongest supplied candidate evidence; no run through the shipped Gateway entry point is claimed.
Agent review details

How this fits together

The Gateway receives requests from OpenClaw clients and coordinates agent turns, sessions, connected devices, channels, and voice calls. These handlers validate requests, consume current authority, invoke existing owners, and return responses.

flowchart TD
  A[OpenClaw clients] --> B[Gateway request validation]
  B --> C[Current caller and session authority]
  C --> D[Shared request preparation]
  D --> E[Agent and lifecycle owners]
  E --> F[Response projection]
  F --> A
Loading

Technical review

Best possible solution:

Retain the shared Gateway owners and settle search readiness through its canonical transcript-search owner without weakening assertions or current-authority checks.

Do we have a high-confidence way to reproduce the issue?

Not applicable to the behavior-preserving refactor. GitHub confirms a search assertion failure, but no high-confidence current-main reproduction or causal attribution to this patch is established.

Is this the best way to solve the issue?

Yes: consolidation stays within existing owners and keeps variant-specific outcomes explicit; no competing capability or public API was introduced.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 888bd0d488aa.

Provenance checked

Testing

Proof path: in-process harness. Added test files: 0.

Security

None.

Evidence

What I checked:

  • Pinned introduced changes inspected: Read the complete locally available introduced diff, extending the truncated host file inventory. Changes are Gateway production refactors and one shrink-only assertion allowance; no tests, dependencies, workflows, or protocol schemas change. (888a1cb1c4a7)
  • Hosted failure independently confirmed: GitHub's failed-check annotation reports that completed scope search unexpectedly returned indexing: true. The failed Node shard and aggregate gate are not attributed as inherited in the current PR body. (src/gateway/server-methods/sessions-search-scope.test.ts:163, 888a1cb1c4a7)
  • Search change does not establish failure causation: The introduced search hunks extract identical catch handling. The scoped search invocation, successful response, indexing calculation, and failing test are unchanged; the inspected transcript-search owner separately determines snapshot currentness and indexing. (src/gateway/server-methods/sessions-read.ts:73, 888a1cb1c4a7)
  • Latest validation disposition: The complete current body records broad passing coverage, the independently reproduced suppression failure, unresolved Activity recap observations, and a clean-main search replay that does not reproduce the hosted workload. It explicitly reserves landing until a verified search-owner repair or scope disposition; https://github.com/openclaw/openclaw/actions/runs/37764421613/job/113269362987 is the failed shard. (888a1cb1c4a7)
  • Authorization boundaries retained: The shared authorization closure preserves method/startup checks, profile binding, caller-specific synchronous assertions, scope equality, and release behavior. Device rotation/revocation retains scope caps, final-response custody, invalidation, and distinct teardown ordering. (src/gateway/server-methods/request-authorization.ts:191, 888a1cb1c4a7)
  • No stored-format migration: The persistence changes share rejection and transcript-scope construction and remove a redundant denial flag. Persisted fields, writer calls, commit guards, and serialization contracts remain unchanged; the migrations handler only forwards its existing parameter bundle. (src/gateway/agent-turn/agent-session-persist.ts:154, 888a1cb1c4a7)

Likely related people:

  • Peter Steinberger: Raw commit 0b1fc0e adds src/gateway/agent-turn/agent-turn-service.ts:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0b1fc0e27990; files: src/gateway/agent-turn/agent-turn-service.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/gateway/agent-turn/agent-session-persist.ts, unknown-truncated-pull-files. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal structural cleanup with no intended user-visible change; failed validation alone does not raise product urgency.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T10:43:00.177Z sha 888a1cb :: blocked before merge. :: none

@steipete
steipete merged commit de4ba75 into main Oct 8, 2026
186 of 187 checks passed
@steipete
steipete deleted the deslop/d01-gateway-server-methods-p2-20261007 branch October 8, 2026 11:51
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…aw#167159)

Consolidate shared Gateway request preparation, response projection, and lifecycle bookkeeping while retaining explicit variant-specific authority, recovery, and error behavior.

Remove 856 net production lines across 111 files without changing tests, configuration, protocol or persisted shapes, or user-visible text. Defer the six-line session-search handler consolidation so the storage-owner path remains unchanged.

Validation includes independent review, the complete changed-file gate, focused and broad Gateway tests, zero runtime/madge cycles, strict PR-wrapper checks, SDK API comparison, and hosted CI on the final head. The PR body and linked coverage log retain the detailed proof and unrelated local-test findings.
steipete added a commit that referenced this pull request Oct 15, 2026
Remove a test-only config cache-reset wrapper, duplicate internal selection
and channel-support checks, an unused session-file metadata fallback, and
duplicate usage target shapes. Carry transcript delivery facts from their
first parsing pass. Keep all network validation, effect authority, transcript
durability, current update policy and standalone session memory machinery.

Best-effort tradeoffs accepted:
- Internal agent updates trust the selection-shape check at their sole
  production caller, agents.update. The duplicate originated in the Models
  agent-selection feature #150224; the same boundary check still rejects
  invalid user input. Live runtime choice validation stays at the effect.
- Channel start support is checked once at the synchronous request boundary.
  The inner check from #67815 / #167159 cannot observe a different plugin
  without unsupported synchronous mutation; the boundary guard remains.
- Workspace-root readers require caller-prepared metadata: both production
  consumers already provide it. The unused fallback from #161747 is deleted,
  not the Phase E backend or any factory. A future invalid internal caller
  gets a clear error instead of starting another metadata read.
- Update handlers trust the required getRuntimeConfig contract instead of
  falling back to a global schedule for an invalid context. Keep #158301's
  real scheduler-policy incident fix and its post-await current-config read.
- Usage summaries trust the canonical required target identity from #169660;
  the first-instance fallback served no production caller. The integration
  fixture now supplies that identity with all original assertions retained.

No public schema/config/SDK/protocol or persisted shape changes. The config
tests call the same canonical invalidators directly; no coverage is removed.

Follow-up removes 54 net production lines; branch total removes 154. Targeted
types (including MCP consumers), retained-file type-aware lint, formatting,
zero runtime import cycles, suppression audit and independent P2 review pass.
Gateway behavioral suites remain incomplete after a loaded-host startup run
was stopped at about ten minutes (exit 143). The prior full static-graph gap
remains pending for the coordinator bundle; no new production edge is added.
steipete added a commit that referenced this pull request Oct 15, 2026
…-5 bundle A) (#172989)

* refactor(ui): remove unused page plumbing and duplicate presentation work

Fold sole-caller Config and Cron adapters into their existing owners, reuse
canonical controller types, and remove unused request arguments and login
selection options. Adopt the complete background mutation receipt instead of
rereading the write; keep authoritative preflight and live ownership checks.

Best-effort tradeoffs accepted: a later background edit in another browser is
reflected by normal preference events or refresh, not an unconditional read of
our own successful write. The introducing feature PR #168301 does not identify
a human incident requiring that reread. Settled rendering and public contracts
are unchanged; both shipping renderer paths remain intact.

* refactor(ui): consolidate presentation helpers and cached preview inputs

Share point-menu trigger attributes and deletion-first LCS traversal. Remove
an obsolete empty-badge predicate, a one-caller loading facade, and redundant
whole-map translation fallback. Preserve both active Lit and Solid paths,
positioning formulas, diff work budgets, visible text, and rendering.

Best-effort tradeoffs accepted:
- Trust successful synchronous Web Storage writes instead of reading them back.
  Introducing PR #162428 supplied synthetic storage failures, not a human
  incident where successful setItem silently failed. Nonconforming Storage
  replacements may miss a cache publication until the next refresh.
- Trust immutable message/tool-card identities for cached source previews.
  PR #148431's in-place mutation assertions were synthetic; production owners
  publish replacement snapshots. Unsupported in-place mutation may leave a
  decoration stale until replacement. Run/frame/origin and external source
  validation remain unchanged.

Net production reduction: 76 lines; tests: 20 lines removed, only synthetic
same-object mutation assertions. Kept config coercion tied to human Safari
report #13348, along with security, durability, ordinary navigation ownership,
and all active migration paths.

Focused proof: 73 boot/cache/diff tests, 82 menu tests, 46 badge/assistant tests,
20 i18n tests, 8 browser details tests, 3 lint-suppression tests; UI typecheck,
formatting, stylesheet lint and CSS declaration parity passed.

Known inherited local check failure: environment-variable count is 455 against
budget 454, independently reproduced against clean HEAD/index. Its counted
source roots exclude UI. No budget or unrelated source changes made.

* refactor(ui): remove obsolete presentation compatibility and styling

Use the native Popover capability required by the Control UI bootstrap
instead of retaining old-engine in-flow fallbacks. Keep native overlay
occlusion and all real connection/navigation ownership.

Remove retired sidebar style hooks and share identical question-panel
declarations. Supported browsers render identically; no user-visible
copy, feature, renderer selection, config, protocol, or storage change.

Best-effort tradeoffs accepted

- Old engines without Popover support, or invalid direct popover mounts,
  no longer receive an in-flow menu fallback. The fallback came from
  #105598 as generic compatibility, not a human incident; #168595 made
  native Popover support a required bootstrap capability. Invalid direct
  mounts now fail clearly rather than silently changing layering.

Deeper coverage and retained candidates are recorded in the requested
task-local y03 ledger for coordinator bundling.

Branch total: 123 net production LOC removed (+114/-237), excluding tests,
fixtures, generated files and declarations. Below the 500-line campaign
floor after the deeper components/app/lib/styles and lead-owned owner pass;
push branch-only for bundling.

* refactor(gateway): reuse server method owners

Consolidate duplicate catalog response handling,
optional catalog reads, pairing resolution, requester assertions and system
agent transcript persistence. Carry prepared pairing and actor facts instead
of probing or re-reading them. Remove redundant cache-generation and internal
receipt checks; retain security, durability, pagination and resource bounds.

Best-effort tradeoffs accepted:
- Pairing captures its selected adapter once. Repeated internal checks added
  by #112401 guarded hypothetical in-place plugin mutation, not a reported
  incident. Such a mutation now leaves this request on its selected adapter;
  later requests discover the current registration.
- Channel identity RPCs trust the canonical mutation result instead of
  repeating the action/kind assertion introduced in #161284. No human incident
  justified the redundant adapter assertion; live mutation authority remains
  with the state owner.

No user-facing feature, protocol/config/persistence shape, schema, dependency,
test coverage or standalone session memory backend changes.

Net production reduction: 100 lines (179 added / 279 deleted).
Type-aware lint, targeted production types, formatting, runtime cycles (zero),
SDK surface, suppression audit and independent P2 review pass. Gateway focused
suites and the full static import graph remain incomplete on the loaded host;
retain these proof gaps for the coordinator bundle rather than claiming green.

* refactor(gateway): trust prepared server method inputs

Remove a test-only config cache-reset wrapper, duplicate internal selection
and channel-support checks, an unused session-file metadata fallback, and
duplicate usage target shapes. Carry transcript delivery facts from their
first parsing pass. Keep all network validation, effect authority, transcript
durability, current update policy and standalone session memory machinery.

Best-effort tradeoffs accepted:
- Internal agent updates trust the selection-shape check at their sole
  production caller, agents.update. The duplicate originated in the Models
  agent-selection feature #150224; the same boundary check still rejects
  invalid user input. Live runtime choice validation stays at the effect.
- Channel start support is checked once at the synchronous request boundary.
  The inner check from #67815 / #167159 cannot observe a different plugin
  without unsupported synchronous mutation; the boundary guard remains.
- Workspace-root readers require caller-prepared metadata: both production
  consumers already provide it. The unused fallback from #161747 is deleted,
  not the Phase E backend or any factory. A future invalid internal caller
  gets a clear error instead of starting another metadata read.
- Update handlers trust the required getRuntimeConfig contract instead of
  falling back to a global schedule for an invalid context. Keep #158301's
  real scheduler-policy incident fix and its post-await current-config read.
- Usage summaries trust the canonical required target identity from #169660;
  the first-instance fallback served no production caller. The integration
  fixture now supplies that identity with all original assertions retained.

No public schema/config/SDK/protocol or persisted shape changes. The config
tests call the same canonical invalidators directly; no coverage is removed.

Follow-up removes 54 net production lines; branch total removes 154. Targeted
types (including MCP consumers), retained-file type-aware lint, formatting,
zero runtime import cycles, suppression audit and independent P2 review pass.
Gateway behavioral suites remain incomplete after a loaded-host startup run
was stopped at about ten minutes (exit 143). The prior full static-graph gap
remains pending for the coordinator bundle; no new production edge is added.

* refactor(ui): consolidate page lifecycle and config plumbing

Reuse the existing controller host, subscription and plugin-icon owners;
share cloud-worker config edit wiring and Usage query comparisons. Remove
the unused Usage detail predicate and duplicate model loading flag.

Retire the Web Awesome-era picker hiding fence now that native Popover
owns generation-bound close completion. Keep both rendering paths,
draft recovery, user-intent checks and dispatch-time write authority.
Settled rendering is unchanged. Net production reduction: 210 lines.

Best-effort tradeoffs accepted:
- Failed channel artwork retries on the next channel refresh rather than
  a queued trailing ensure. #131511 was a synthetic ordering regression;
  the human-reported owning-plugin bug #144152 remains covered.
- Picker triggers may reopen during closing. #126032's fence came from
  CI/synthetic overlap, not a human incident; #171441 transferred lifecycle
  ownership to native Popover, which ignores superseded completions.

Focused proof: 281 tests passed, including Chromium/WebKit overlay lifecycle
and responsive placement controls. Independent P0-P2 review: scoped-clean.
Final UI production and UI-pages test typechecks passed; suppression tests 3/3.
Scoped lint passed after a mechanical no-lonely-if fix.
Runtime and static import cycles: zero. No visual or locale changes.
The global environment-name budget is inherited at 455/454 on both the
untouched base and origin/main; none of its counted source roots changed.

* refactor(ui): remove unused new-session hiding selector

* refactor(gateway): retain legacy catalog and update handler contracts

Withdraw two wave-5 cleanups after focused CI failures and bounded isolated replay. Preserve the existing scalar-read concurrency and update-status handler contract. Tighten task-suggestions assertion allowance to match the cleaned source.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…-5 bundle A) (openclaw#172989)

* refactor(ui): remove unused page plumbing and duplicate presentation work

Fold sole-caller Config and Cron adapters into their existing owners, reuse
canonical controller types, and remove unused request arguments and login
selection options. Adopt the complete background mutation receipt instead of
rereading the write; keep authoritative preflight and live ownership checks.

Best-effort tradeoffs accepted: a later background edit in another browser is
reflected by normal preference events or refresh, not an unconditional read of
our own successful write. The introducing feature PR openclaw#168301 does not identify
a human incident requiring that reread. Settled rendering and public contracts
are unchanged; both shipping renderer paths remain intact.

* refactor(ui): consolidate presentation helpers and cached preview inputs

Share point-menu trigger attributes and deletion-first LCS traversal. Remove
an obsolete empty-badge predicate, a one-caller loading facade, and redundant
whole-map translation fallback. Preserve both active Lit and Solid paths,
positioning formulas, diff work budgets, visible text, and rendering.

Best-effort tradeoffs accepted:
- Trust successful synchronous Web Storage writes instead of reading them back.
  Introducing PR openclaw#162428 supplied synthetic storage failures, not a human
  incident where successful setItem silently failed. Nonconforming Storage
  replacements may miss a cache publication until the next refresh.
- Trust immutable message/tool-card identities for cached source previews.
  PR openclaw#148431's in-place mutation assertions were synthetic; production owners
  publish replacement snapshots. Unsupported in-place mutation may leave a
  decoration stale until replacement. Run/frame/origin and external source
  validation remain unchanged.

Net production reduction: 76 lines; tests: 20 lines removed, only synthetic
same-object mutation assertions. Kept config coercion tied to human Safari
report openclaw#13348, along with security, durability, ordinary navigation ownership,
and all active migration paths.

Focused proof: 73 boot/cache/diff tests, 82 menu tests, 46 badge/assistant tests,
20 i18n tests, 8 browser details tests, 3 lint-suppression tests; UI typecheck,
formatting, stylesheet lint and CSS declaration parity passed.

Known inherited local check failure: environment-variable count is 455 against
budget 454, independently reproduced against clean HEAD/index. Its counted
source roots exclude UI. No budget or unrelated source changes made.

* refactor(ui): remove obsolete presentation compatibility and styling

Use the native Popover capability required by the Control UI bootstrap
instead of retaining old-engine in-flow fallbacks. Keep native overlay
occlusion and all real connection/navigation ownership.

Remove retired sidebar style hooks and share identical question-panel
declarations. Supported browsers render identically; no user-visible
copy, feature, renderer selection, config, protocol, or storage change.

Best-effort tradeoffs accepted

- Old engines without Popover support, or invalid direct popover mounts,
  no longer receive an in-flow menu fallback. The fallback came from
  openclaw#105598 as generic compatibility, not a human incident; openclaw#168595 made
  native Popover support a required bootstrap capability. Invalid direct
  mounts now fail clearly rather than silently changing layering.

Deeper coverage and retained candidates are recorded in the requested
task-local y03 ledger for coordinator bundling.

Branch total: 123 net production LOC removed (+114/-237), excluding tests,
fixtures, generated files and declarations. Below the 500-line campaign
floor after the deeper components/app/lib/styles and lead-owned owner pass;
push branch-only for bundling.

* refactor(gateway): reuse server method owners

Consolidate duplicate catalog response handling,
optional catalog reads, pairing resolution, requester assertions and system
agent transcript persistence. Carry prepared pairing and actor facts instead
of probing or re-reading them. Remove redundant cache-generation and internal
receipt checks; retain security, durability, pagination and resource bounds.

Best-effort tradeoffs accepted:
- Pairing captures its selected adapter once. Repeated internal checks added
  by openclaw#112401 guarded hypothetical in-place plugin mutation, not a reported
  incident. Such a mutation now leaves this request on its selected adapter;
  later requests discover the current registration.
- Channel identity RPCs trust the canonical mutation result instead of
  repeating the action/kind assertion introduced in openclaw#161284. No human incident
  justified the redundant adapter assertion; live mutation authority remains
  with the state owner.

No user-facing feature, protocol/config/persistence shape, schema, dependency,
test coverage or standalone session memory backend changes.

Net production reduction: 100 lines (179 added / 279 deleted).
Type-aware lint, targeted production types, formatting, runtime cycles (zero),
SDK surface, suppression audit and independent P2 review pass. Gateway focused
suites and the full static import graph remain incomplete on the loaded host;
retain these proof gaps for the coordinator bundle rather than claiming green.

* refactor(gateway): trust prepared server method inputs

Remove a test-only config cache-reset wrapper, duplicate internal selection
and channel-support checks, an unused session-file metadata fallback, and
duplicate usage target shapes. Carry transcript delivery facts from their
first parsing pass. Keep all network validation, effect authority, transcript
durability, current update policy and standalone session memory machinery.

Best-effort tradeoffs accepted:
- Internal agent updates trust the selection-shape check at their sole
  production caller, agents.update. The duplicate originated in the Models
  agent-selection feature openclaw#150224; the same boundary check still rejects
  invalid user input. Live runtime choice validation stays at the effect.
- Channel start support is checked once at the synchronous request boundary.
  The inner check from openclaw#67815 / openclaw#167159 cannot observe a different plugin
  without unsupported synchronous mutation; the boundary guard remains.
- Workspace-root readers require caller-prepared metadata: both production
  consumers already provide it. The unused fallback from openclaw#161747 is deleted,
  not the Phase E backend or any factory. A future invalid internal caller
  gets a clear error instead of starting another metadata read.
- Update handlers trust the required getRuntimeConfig contract instead of
  falling back to a global schedule for an invalid context. Keep openclaw#158301's
  real scheduler-policy incident fix and its post-await current-config read.
- Usage summaries trust the canonical required target identity from openclaw#169660;
  the first-instance fallback served no production caller. The integration
  fixture now supplies that identity with all original assertions retained.

No public schema/config/SDK/protocol or persisted shape changes. The config
tests call the same canonical invalidators directly; no coverage is removed.

Follow-up removes 54 net production lines; branch total removes 154. Targeted
types (including MCP consumers), retained-file type-aware lint, formatting,
zero runtime import cycles, suppression audit and independent P2 review pass.
Gateway behavioral suites remain incomplete after a loaded-host startup run
was stopped at about ten minutes (exit 143). The prior full static-graph gap
remains pending for the coordinator bundle; no new production edge is added.

* refactor(ui): consolidate page lifecycle and config plumbing

Reuse the existing controller host, subscription and plugin-icon owners;
share cloud-worker config edit wiring and Usage query comparisons. Remove
the unused Usage detail predicate and duplicate model loading flag.

Retire the Web Awesome-era picker hiding fence now that native Popover
owns generation-bound close completion. Keep both rendering paths,
draft recovery, user-intent checks and dispatch-time write authority.
Settled rendering is unchanged. Net production reduction: 210 lines.

Best-effort tradeoffs accepted:
- Failed channel artwork retries on the next channel refresh rather than
  a queued trailing ensure. openclaw#131511 was a synthetic ordering regression;
  the human-reported owning-plugin bug openclaw#144152 remains covered.
- Picker triggers may reopen during closing. openclaw#126032's fence came from
  CI/synthetic overlap, not a human incident; openclaw#171441 transferred lifecycle
  ownership to native Popover, which ignores superseded completions.

Focused proof: 281 tests passed, including Chromium/WebKit overlay lifecycle
and responsive placement controls. Independent P0-P2 review: scoped-clean.
Final UI production and UI-pages test typechecks passed; suppression tests 3/3.
Scoped lint passed after a mechanical no-lonely-if fix.
Runtime and static import cycles: zero. No visual or locale changes.
The global environment-name budget is inherited at 455/454 on both the
untouched base and origin/main; none of its counted source roots changed.

* refactor(ui): remove unused new-session hiding selector

* refactor(gateway): retain legacy catalog and update handler contracts

Withdraw two wave-5 cleanups after focused CI failures and bounded isolated replay. Preserve the existing scalar-read concurrency and update-status handler contract. Tighten task-suggestions assertion allowance to match the cleaned source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant