Repository navigation
refactor(gateway): deslop gateway - #164603
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. Reviewed October 3, 2026, 11:18 PM ET / October 4, 2026, 03:18 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR removes unused Gateway forwarding helpers and options, consolidates repeated projections and cleanup logic, and strengthens HTTP authorization and test-fixture lifetime coverage. Merge readiness⛔ Blocked before merge - 1 item remains This remains useful maintainer-owned cleanup. The prior embeddings admission defect and merge-conflict concern are resolved; no new actionable defect was found in the introduced patch. Exact-head CI still has failures whose causes are not established by this review. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway accepts HTTP and WebSocket requests, applies authentication and session policy, and dispatches work to agents, providers, channels, and workers. This refactor simplifies those internal paths while preserving their response and lifecycle contracts. flowchart TD
A[HTTP and WebSocket clients] --> B[Gateway authentication]
B --> C[Request and session policy]
C --> D[Agent and provider dispatch]
C --> E[Session and worker owners]
D --> F[Responses and events]
E --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource -565, Tests +38. Total -527 across 49 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep the consolidation within the existing Gateway owners, preserving authorization, synchronous session presentation, and cleanup settlement contracts. Do we have a high-confidence way to reproduce the issue? Not applicable to the cleanup request. The prior embeddings defect has a focused HTTP regression and reported negative control; this read-only review did not execute it. Is this the best way to solve the issue? Yes. Removing single-use forwarding and reusing existing owners is a maintainable approach, and the reviewed hunks preserve the relevant admission and lifecycle checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 35f60579010c. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Remove single-use adapters and unused internal options, reuse canonical projections and types, and consolidate duplicate state and event assembly. Preserve configuration, wire shapes, storage contracts, and lifecycle authority. Keep the upstream retirement of full-array CLI history merging.
1b29b25 to
4062cde
Compare
|
The P1 embeddings admission finding is fixed in The identical isolated The conflict-only rebase retains current main’s complete archive and session-resolution paths. Its exact head passed 306 tests across 13 files, production and Gateway-root/server types, strict touched-file lint, and both cycle checks. The earlier conflicted head never received a CI run. Hosted CI and security review must validate this exact head before landing; no security or authority exception is requested. |
Evidence for the inherited-failure exceptionReviewed/tested PR head:
Baseline focused command: The exact candidate passed 306 focused tests, production and Gateway test typechecks, strict lint, both zero-cycle gates, and independent P0/P1 review. Its Under the explicit coordinator order, these inherited non-security failures are reported for the main CI owner rather than repaired in this lane. The squash submission is pinned to the live API head SHA above. The review bot’s data-model prompt is a path-classification false positive: |
* refactor(gateway): deslop gateway Remove single-use adapters and unused internal options, reuse canonical projections and types, and consolidate duplicate state and event assembly. Preserve configuration, wire shapes, storage contracts, and lifecycle authority. Keep the upstream retirement of full-array CLI history merging. * refactor(gateway): retain concurrently maintained helpers * refactor(gateway): retain security scanner admission contracts * refactor(gateway): preserve captured row type boundary * refactor(gateway): retain original session creation forwarding * fix(gateway): restore embeddings admission and fixture ownership * test(gateway): assert embedding wire options directly * refactor(gateway): retain cleanup and error contracts
What Problem This Solves
The Gateway root retained single-use forwarding layers, unused internal options, and repeated projection/cleanup logic after the first cleanup pass. This batch keeps behavior with its existing owners and removes 565 net production lines across 46 files. Tests/support add 38 lines across 3 files. Configuration, stored data, wire responses, CLI output, and public SDK contracts are unchanged; no migration or operator action is required.
The simplifications inline the one-call request executor; remove unused HTTP message-channel options; remove the approval-audience source-provider abstraction; consolidate pairing and iOS approval projections; reuse existing session/store/type owners; and simplify worker evidence, channel suppression, credential planning, diagnostics, and bounded media filenames. Cleanup transactions retain their exact-record and live-authority checks. Creation forwarding, archive reading, session resolution, and cleanup/error paths with ambiguous contracts were withdrawn rather than changed during landing.
Fixes found along the way
Restored the embeddings endpoint’s explicit
chat.sendadmission and scope resolver after review caught an incomplete restoration. The existing trusted-proxy test now proves reader denial before provider work, writer success, and admin-only model override. Its negative control failed for the intended HTTP 200/effect mismatch; the corrected 43-test suite passed (55.97 s wall, no extra Gateway boot).Registered the shared OpenAI-compatible Gateway fixture with the existing lifetime owner, preventing reset hooks from deleting its active database. Existing startup/close behavior and cleanup assertions remain; there are no new sleeps, retries, relaxed timeouts, or weakened assertions.
Validation and scope
Conflict-only rebase onto
cc740dfaf528fa92d36af5eba2e97c15708c3c4fretained main’s archive and session-resolution implementations. Exact rebased head4062cde6201020b26dbce49376cca3682d2e0cb2passed 306 tests across 13 files (134.76 s), production and Gateway-root/server test types, strict lint (48 files, 0 warnings/errors, 18.41 s), and both zero-cycle checks. Earlier full static validation passed all 27 dependent type graphs, guards, and three dead-export scans. Independent P0/P1 reviews are clean; current ClawSweeper review reports no actionable patch or security finding.The isolated
sessions.createcommand passed on clean main and unchanged prior candidate on the same lease. The earlier timeout’s cause remains unproven; creation-forwarding changes were withdrawn and the full worktree-creation suite passes. Earlier Mac startup and history timing failures are not claimed as fixed. No full-tree green CI claim is made below.The batch is BELOW-1000 after exhausting sound opportunities and preserving concurrent changes. The complete largest-first 314-file coverage log follows the evidence.
Evidence
Reviewed/tested PR head:
4062cde6201020b26dbce49376cca3682d2e0cb2. Exact-head CI: 37173313459. Five root failures remain; the aggregate gate reflects them. No failed check is being called green.checks-fast-baseline-ratchets:check-test-mock-exports.mtsexits withspawnSync git ENOBUFS301a040200d10e65813c434a57364c5eb79e7b97: job 111351985083. This PR does not change the ratchet or its Git/source-loading helpers.checks-node-changed-compact-large-14-2: aggregate global preview lackslastMessagePreviewchecks-node-compact-small-3: type-suppression inventory has 18 entries rather than 16src/plugin-sdk/plugin-config-runtime.test.tsnegative type assertions on main job 111351986757, also reproduced locally on clean main. This PR does not alter these assertions or inventory tooling.checks-node-changed-compact-small-4-1: presence expects[email protected]first but receives[email protected]301a040…reproduced the identical email-order mismatch on repetition 3 of 20; the other 19 repetitions passed. Unchanged producers timestamp each connection and sort descending by timestamp; the unchanged assertion incorrectly pairs that result with insertion order. Both identities are present. No stability fix is claimed.checks-node-changed-compact-small-5-2: catalog refresh observes onereadAcpSessionMetaForEntriescall rather than zero301a040…reproduced the same one-call assertion. The baseline lease reached its hard TTL during later shard cases; the matching failure was captured, but a completed full-shard result is not claimed. The test, row-fact/ACP producer, and catalog invalidation source are unchanged by this PR; the reviewed inlining adds no read or await.Baseline focused command:
node scripts/run-vitest.mjs src/gateway/server-request-context.presence.test.ts src/gateway/server-methods/sessions-list-config.test.ts(20 separate diagnostic executions, no changed tests or retry behavior). The recorded-shard comparison usednode --import tsx scripts/ci-run-node-test-shard.mtswith the original job's decoded test-group configuration.The exact candidate passed 306 focused tests, production and Gateway test typechecks, strict lint, both zero-cycle gates, and independent P0/P1 review. Its
security-fast, OpenGrep, all Security High checks, and security-sensitive review passed. The earlier embeddings authority bug is fixed and has a failing-before/passing-after regression; no security, authority, or permission failure is admitted by this exception.Under the explicit coordinator order, these inherited non-security failures are reported for the main CI owner rather than repaired in this lane. Merged as
917be1c590630ec4def5a9e7d547da15bb8d2c6fby squash pinned to the API head above; ancestry verified on fresh main. Final measured production reduction: 565 lines.The review bot’s data-model prompt is a path-classification false positive:
embeddings-http.tsonly inlines provider-option construction and removes internal aliases;embeddings-provider-lifetime.tsinlines retention in the same in-memory retirement map. Neither changes stored vector metadata, schemas, formats, or migrations. The managed-image refactor retains the same SQL transitions, exact-record checks, transaction owner, and cleanup ordering. No data migration is introduced or required.Gateway-root coverage: 314 production files over 200 lines
src/gateway/server-channels.tssrc/gateway/server-chat.tssrc/gateway/managed-image-attachments.tssrc/gateway/session-reset-service.tssrc/gateway/node-registry.tssrc/gateway/config-reload.tssrc/gateway/session-create-service.tssrc/gateway/server-cron.tssrc/gateway/watch-node-http.tssrc/gateway/call.tssrc/gateway/control-ui.tssrc/gateway/server-node-events.tssrc/gateway/server-startup-post-attach.tssrc/gateway/openai-http.tssrc/gateway/openresponses-http.tssrc/gateway/exec-approval-lifecycle.tssrc/gateway/server-http.tssrc/gateway/server-reload-hot.tssrc/gateway/tool-resolution.tssrc/gateway/exec-approval-manager.tssrc/gateway/control-ui-session-pr-subscriptions.tssrc/gateway/session-row-projection-record.tssrc/gateway/server-broadcast.tssrc/gateway/github-publication-executor.tssrc/gateway/server-plugin-reload.tssrc/gateway/server-restart-sentinel.tssrc/gateway/session-row-projection.tssrc/gateway/mention-inbox.tssrc/gateway/server-startup-finish.tssrc/gateway/sessions-patch.tssrc/gateway/node-registry-private.tssrc/gateway/server-session-events.tssrc/gateway/cron-stream-job-owner.tssrc/gateway/session-sharing.tssrc/gateway/session-utils-row.tssrc/gateway/github-personal-oauth.tssrc/gateway/session-companion-ask.tssrc/gateway/server-restart-sentinel-agent-delivery.tssrc/gateway/cli-session-history-index.worker.tssrc/gateway/server-lifecycle.tssrc/gateway/session-observer.tssrc/gateway/server-worker-environment-startup.tssrc/gateway/server-chat-state.tssrc/gateway/chat-abort.tssrc/gateway/hooks.tssrc/gateway/server-close.tssrc/gateway/session-activity-summaries.tssrc/gateway/session-sharing-preparation.tssrc/gateway/hooks-mapping.tssrc/gateway/question-session-access.tssrc/gateway/cron-stream-output.tssrc/gateway/server-runtime-subscriptions.tssrc/gateway/chat-display-projection.sanitize.tssrc/gateway/mcp-app-operations.tssrc/gateway/github-repository-publication.tssrc/gateway/http-auth-utils.tssrc/gateway/session-utils-list.tssrc/gateway/operator-approval-store.receipts.tssrc/gateway/server-startup-config.tssrc/gateway/session-worktree-preparation.tssrc/gateway/session-row-projection-materialize.tssrc/gateway/question-manager.tssrc/gateway/agent-runtime-identity-token.tssrc/gateway/chat-display-projection.history.tssrc/gateway/github-oauth-lifecycle.tssrc/gateway/session-utils-model.tssrc/gateway/config-reload-plan.tssrc/gateway/github-publication.tssrc/gateway/probe.tssrc/gateway/node-invoke-plugin-policy.tssrc/gateway/server-maintenance.tssrc/gateway/mcp-http.tssrc/gateway/server-runtime-state-prepare.tssrc/gateway/control-ui-session-prs.tssrc/gateway/server-worker-placement-startup.tssrc/gateway/server-runtime-state.tssrc/gateway/server-startup-bootstrap.tssrc/gateway/github-publication-store.tssrc/gateway/github-publication-git-transport.tssrc/gateway/server-request-context.tssrc/gateway/sessions-history-http.tssrc/gateway/cli-session-history.claude.tssrc/gateway/mcp-grant-store.tssrc/gateway/session-recovery-service.tssrc/gateway/github-repository-publication-executor.tssrc/gateway/session-artifact-read.tssrc/gateway/github-personal-publication.tssrc/gateway/github-publication-coordinator-methods.tssrc/gateway/auth.tssrc/gateway/operator-run-authority.tssrc/gateway/session-lifecycle-state.tssrc/gateway/server-cron-notifications.tssrc/gateway/server-reload-restart.tssrc/gateway/chat-display-projection.core.tssrc/gateway/session-utils-store-lookup.tssrc/gateway/server-core-runtime.tssrc/gateway/server-restart-sentinel-notice.tssrc/gateway/mcp-http.runtime.tssrc/gateway/mcp-app-form-resources.tssrc/gateway/github-repository-publication-store.tssrc/gateway/session-transcript-read-kernel.tssrc/gateway/chat-attachments.tssrc/gateway/node-command-policy.tssrc/gateway/server-methods.tssrc/gateway/server-reload-managed-secrets.tssrc/gateway/server-plugin-in-process-authority.tssrc/gateway/server-aux-handlers.tssrc/gateway/server-runtime-services.tssrc/gateway/server-plugin-subagent-runtime.tssrc/gateway/server-reload-managed.tssrc/gateway/control-ui-asset-retention.tssrc/gateway/operator-approval-store.rows.tssrc/gateway/session-observer-model.tssrc/gateway/server-plugin-reload-cleanup.tssrc/gateway/net.tssrc/gateway/node-invoke-system-run-approval.tssrc/gateway/operator-approval-standing-grants.tssrc/gateway/tools-invoke-shared.tssrc/gateway/server-worker-placement-session-target.tssrc/gateway/sessions-resolve.tssrc/gateway/session-row-placement-projection.tssrc/gateway/session-sharing-policy.tssrc/gateway/operator-approval-store.transitions.tssrc/gateway/cron-exit-watchers.tssrc/gateway/session-history-tail.tssrc/gateway/plugin-icon-http.tssrc/gateway/session-list-filters.tssrc/gateway/model-account-connect.tssrc/gateway/cron-creator-authority-grant.tssrc/gateway/session-utils-store.tssrc/gateway/client.tssrc/gateway/mcp-app-standalone-host.tssrc/gateway/plugin-node-capability.tssrc/gateway/server-plugins.tssrc/gateway/mcp-app-extension-runtime.tssrc/gateway/session-access-authority.tssrc/gateway/dashboard-session-title.tssrc/gateway/session-row-projection-refresh.tssrc/gateway/mcp-app-host-files.tssrc/gateway/server-http-upgrades.tssrc/gateway/approval-web-push.tssrc/gateway/mcp-app-standalone.tssrc/gateway/session-transcript-files.fs.tssrc/gateway/human-mention-policy.tssrc/gateway/auth-rate-limit.tssrc/gateway/operator-model-presentation.tssrc/gateway/conversation-turn.tssrc/gateway/user-profiles-http.tssrc/gateway/session-row-scope.tssrc/gateway/server-run-shutdown.tssrc/gateway/control-ui-plugin-assets.tssrc/gateway/server-secrets-reload.tssrc/gateway/node-registry.invoke-stream.tssrc/gateway/server-startup-plugins.tssrc/gateway/session-transcript-archive-reader.tssrc/gateway/server-plugin-in-process-dispatch.tssrc/gateway/session-membership-projection.tssrc/gateway/exec-approval-ios-push.tssrc/gateway/github-user-identity.tssrc/gateway/operator-approval-store.kernel.tssrc/gateway/server-control-ui-root.tssrc/gateway/server-node-subscriptions.tssrc/gateway/cron-stream-watchers.tssrc/gateway/mcp-http.loopback-runtime.tssrc/gateway/server-instance-runtime.tssrc/gateway/server-chat-progress-snapshot.tssrc/gateway/github-publication-git-index.tssrc/gateway/github-repository-publication-recovery.tssrc/gateway/control-ui-session-prs-checks.tssrc/gateway/session-identity-projection.tssrc/gateway/message-action-turn-capability.tssrc/gateway/github-publication-availability.tssrc/gateway/session-utils-store-sources.tssrc/gateway/session-row-membership-read.tssrc/gateway/control-ui-session-pr-read.tssrc/gateway/server-worker-placement-reclaim.tssrc/gateway/board-host-tools.tssrc/gateway/control-ui-public-session.tssrc/gateway/session-lifecycle-preparation.tssrc/gateway/ws-log.tssrc/gateway/node-catalog.tssrc/gateway/http-utils.tssrc/gateway/session-transcript-catalog.tssrc/gateway/embeddings-http.tssrc/gateway/github-publication-requester.tssrc/gateway/server-cron-lazy.tssrc/gateway/session-transcript-index.fs.tssrc/gateway/server-startup-config-helpers.tssrc/gateway/conversation-route-ownership.tssrc/gateway/mcp-http.request.tssrc/gateway/operator-access-policy.tssrc/gateway/github-personal-publication-store.tssrc/gateway/session-history-snapshot.tssrc/gateway/node-runner-inventory-runtime.tssrc/gateway/client-bootstrap.tssrc/gateway/control-ui-plugin-tabs.tssrc/gateway/node-claude-skill-runtime.tssrc/gateway/session-row-projection-ancestors.tssrc/gateway/operator-role-policy.tssrc/gateway/server-kernel.tssrc/gateway/session-row-presentation.tssrc/gateway/restart-trace.tssrc/gateway/managed-image-record-store.kernel.tssrc/gateway/operator-approval-placement-grants.tssrc/gateway/control-ui-session-prs-git.runtime.tssrc/gateway/method-scopes.tssrc/gateway/session-transcript-title-reader.tssrc/gateway/server-shared-auth-generation.tssrc/gateway/server-broadcast-narration.tssrc/gateway/credentials.tssrc/gateway/http-common.tssrc/gateway/event-web-push.tssrc/gateway/session-store-key.tssrc/gateway/web-push-authority.tssrc/gateway/control-ui-plugin-auth-cookie.tssrc/gateway/session-history-state.tssrc/gateway/session-repository-materialization.tssrc/gateway/channel-health-monitor.tssrc/gateway/operator-approval-session-events.tssrc/gateway/server-in-process-dispatch.tssrc/gateway/chat-display-projection.canvas.tssrc/gateway/server-discovery-runtime.tssrc/gateway/mention-inbox-projection.tssrc/gateway/presence-summary.tssrc/gateway/github-publication-pull-requests.tssrc/gateway/session-reset-acp.tssrc/gateway/device-revocation.tssrc/gateway/session-transcript-readers.tssrc/gateway/conversation-list.tssrc/gateway/chat-queued-turns.tssrc/gateway/ingress-attribution.tssrc/gateway/operator-approval-store.tssrc/gateway/control-ui-session-prs-landing.tssrc/gateway/node-pending-work.tssrc/gateway/session-create-model-selection.tssrc/gateway/server-startup-trace.tssrc/gateway/channel-operator-authority.tssrc/gateway/chat-display-projection.helpers.tssrc/gateway/server-model-catalog.tssrc/gateway/session-transcript-record-parser.tssrc/gateway/github-public-api.tssrc/gateway/server-startup-log.tssrc/gateway/session-group-catalog.tssrc/gateway/open-responses.schema.tssrc/gateway/board-view-ticket.tssrc/gateway/chat-abort-lifecycle-internal.tssrc/gateway/http-auth-user-profile.tssrc/gateway/control-ui-link-preview.tssrc/gateway/control-ui-session-pr-check-details.tssrc/gateway/project-github-search.tssrc/gateway/session-groups.tssrc/gateway/session-row-projection-generation.tssrc/gateway/local-request-context.tssrc/gateway/session-utils-core.tssrc/gateway/server-reload-contracts.tssrc/gateway/mcp-http.handlers.tssrc/gateway/auth-surface-resolution.tssrc/gateway/node-pairing-ssh-verify.tssrc/gateway/control-ui-static.tssrc/gateway/session-sharing-read.tssrc/gateway/update-run-watcher.tssrc/gateway/server-connection-state.tssrc/gateway/session-utils-projection.tssrc/gateway/control-ui-public-session-token.tssrc/gateway/live-chat-projector.tssrc/gateway/github-publication-shared-read.kernel.tssrc/gateway/session-event-payload.tssrc/gateway/session-sharing-target-input.tssrc/gateway/http-byte-range.tssrc/gateway/session-row-prepared-read.tssrc/gateway/server-broadcast-live-text.tssrc/gateway/provider-browser-auth.tssrc/gateway/device-scope-upgrade.tssrc/gateway/workspace-icon-http.tssrc/gateway/cli-session-history.claude-snapshot.tssrc/gateway/server-chat-metadata-lifecycle.tssrc/gateway/session-history-worker-reader.tssrc/gateway/credentials-secret-inputs.tssrc/gateway/server-startup-session-migration.tssrc/gateway/session-row-projection-read.tssrc/gateway/stale-install.tssrc/gateway/tool-resolution-completion.tssrc/gateway/github-repository-publication-snapshot.tssrc/gateway/internal-source-reply-persistence.tssrc/gateway/startup-auth.tssrc/gateway/connection-details.tssrc/gateway/local-http-probe.tssrc/gateway/session-group-catalog.kernel.tssrc/gateway/session-transcript-derived-readers.tssrc/gateway/session-companion-rpc.tssrc/gateway/server-plugin-runtime-client.tssrc/gateway/node-invoke-plugin-approval.tssrc/gateway/session-incognito-lifetime.tssrc/gateway/mcp-http.schema.tssrc/gateway/session-create-service.types.tssrc/gateway/approval-session-audience.tssrc/gateway/probe-auth.tssrc/gateway/server-runtime-config.tssrc/gateway/session-utils-display.tssrc/gateway/server-plugin-reload-channels.tssrc/gateway/node-connection-notifications.tssrc/gateway/node-plugin-tool-snapshot.tssrc/gateway/session-event-prepared-row.tssrc/gateway/session-companion-context.tssrc/gateway/call-device-auth.tssrc/gateway/server-plugins-node-runtime.tssrc/gateway/session-row-projection-archive.tssrc/gateway/session-catalog-identity.tssrc/gateway/skill-library-authoring.tssrc/gateway/session-row-projection-context.tssrc/gateway/update-run-notice-target.tssrc/gateway/github-actions-read.tssrc/gateway/node-reapproval-coordinator.tssrc/gateway/mcp-app-transcript.ts