Repository navigation
refactor(core): share repeated lifecycle and plugin paths - #167646
Conversation
Consolidate capability projections, rollback steps, inference checks, provider and transport handlers, and file-transfer parsing. Preserve messages, ordering, authority checks, and persisted contracts. Remove 513 net production lines with unchanged tests.
Remove the intermediate mapped array while retaining style field order and indentation coalescing. Resolve the no-map-spread finding without a lint suppression.
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR consolidates repeated request preparation, result projection, validation, and cleanup within existing core and plugin owners. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored refactor remains a distinct, useful contribution. The inspected introduced hunks preserve existing contracts, and no concrete regression was identified. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCore coordinates agent execution and managed agent packages, while plugins handle provider and channel operations. These paths receive requests and runtime events and produce results, messages, saved artifacts, and cleanup outcomes. flowchart TD
A[User and agent requests] --> B[Core lifecycle owners]
A --> C[Provider and channel plugins]
B --> D[Shared preparation and validation]
C --> D
D --> E[Existing operation and transport owners]
E --> F[Results and messages]
E --> G[Ordered cleanup and rollback]
Technical reviewBest possible solution: Keep consolidation within the existing owners while preserving exact outputs, live checks, rollback ordering, and stored formats. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving consolidation rather than a reported user-facing defect. Is this the best way to solve the issue? Yes: the inspected changes reuse existing owners and remove parallel implementations without adding configuration, SDK surface, or a competing lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d1ebf36cd054. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -512, Other 0. Total -512 across 54 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 9, 2026, 2:23 AM ET / 06:23 UTC. |
…67646) Share capability projections, rollback and inference handling, provider and channel operations, file-transfer parsing, and cleanup within existing owners. Preserve outputs, ordering, authority checks, configuration, and persisted contracts. Remove 512 net production lines with unchanged tests.
What Problem This Solves
Core and small plugins repeat request preparation, result projection, and cleanup logic across closely related operations.
User Impact
No user-visible change. Features, messages, configuration, CLI options, wire formats, and persisted data remain identical. No migration is required.
Why This Change Was Made
Share the repeated work while keeping meaningful differences explicit: Markdown source context, provider stream state, request variants, resource rollback order, inference authority checks, and worker cleanup. The old parallel implementations are removed.
The implemented deep pass removes 512 net production lines, counting new helpers and excluding tests and baselines. This uses the campaign's 500–999 exception; the normal 1,000-line and 3% targets were not reached. The coverage log includes retained paths and candidates discarded after implementation and measurement.
Evidence
The final source is reviewed and the focused syntax check confirms the corrected eight-file lint batch is clean. Full type-aware lint and final Linux Zalouser proof remain hosted-CI gates: local SDK preparation hit its unchanged budget, and the final Testbox reservation did not allocate within the 20-minute window and was stopped. No additional lease was allocated after that cutoff.
The complete directory run passed 646 files / 7,871 tests across 15 shards on
blacksmith-testbox(621.06s; 2 files / 52 existing tests skipped). It covered all four core directories, all 19 touched plugin packages, lint-suppression tests, and landing-wrapper/eager-import closure tests. The isolated failing-case selection passed 34 tests (22.05s), and all four real Claws lifecycle CLI cases passed (287.16s including build preparation).The final loop correction passed all 205 rendering tests locally and 3,176 complete renderer output comparisons against the original base. Redaction separately matched native patterns in 31,125 comparisons across 6,225 inputs. Tests, assertions, deadlines, retries, and skip conditions are unchanged. Independent review of the full candidate and the subsequent one-file correction is scoped-clean through P2. Final runtime-value cycles and Madge cycles are both zero; clean-base Madge is also zero. Fresh lint-suppression tests passed all three cases.
Core production and all 27 core test graphs passed. Extension production and extension test typechecks also passed again after the final loop correction. Core and scripts lint passed. The remaining static checks passed except one own
no-map-spreadfinding, corrected by projecting each style inside the existing merge loop without an intermediate array or suppression. The Plugin SDK API comparison from121417e32b0fec872d73a785865a47f1e25d797ctod45efeb68bb82abe62637b5e0d453a89c8eb47dbreports no changes. The later delta affects only the private Zalouser renderer loop, outside the unchanged SDK rendering inputs.The full changed-file gate failed on four untouched unused exports. A fresh pinned-main checkout at
48e0271f6040cca380256d69d1d97e5f1636b770reproduced all four. Completed main CI job 113659329749, at15305ccd53dedd1663a89f92a402480d7b71bbf8, independently reports the exact same findings. All four file blobs match between that main run, pinned main, and this candidate; none is in this PR's changed paths:src/agents/cli-runner/tool-authority.ts:bindCliQuestionAnswerAuthoritysrc/auto-reply/reply/session-event-handoff.ts:prepareSessionEventTargetForHostsrc/config/sessions/session-accessor.sqlite-entry-cache-publication.ts:readSessionEntryCreationTransitionsrc/infra/heartbeat-events-filter.ts:RESTART_CONTINUATION_CONTEXT_PREFIXLocal failures remain recorded; a passing isolated run does not establish a fix for them:
src/system-agent/probes.test.tsingress.test-support.ts, with six late-handled rejections from the same promises. Cases: durable append before dispatch; completed-duplicate rejection; independent-conversation dispatch; auth dead-lettering; DM pairing account scope; missing-mention diagnostics; explicit-mention routing. Their mocked sending/ingress paths do not reach the corrected renderer loop. The earlier isolated full run passed them; local contention was observed, but its precise causal contribution remains unproven.One early invocation ran zero tests because this lane pruned its assertion baseline during build preparation; inputs were then frozen. Duplicate local builds/checks were deliberately interrupted with exit 130 after isolated proof became available. Their task-owned stale artifact locks were recovered only after verifying process cleanup. Later local Knip and SDK-declaration preparation exceeded their existing 600-second and 300-second budgets; these were tooling proof gaps, not passing checks. No timeout was raised. The final local changed-file attempt again passed its preceding guards and extension typechecks, then its Knip scan reached the unchanged 600-second deadline. Isolated proof supplies the completed checks described above; exact-head hosted CI must cover the remaining full-lint/Linux gap.
File-by-file deep-pass coverage
d29 P2 coverage
Each row records inspected source or an implemented candidate. Partial reads and candidates discarded after implementation and measurement are explicit. Checkpoint observations are historical; final PR evidence owns validation results.
lead
src/logging/redact.tssrc/logging/diagnostic-stability.tssrc/logging/diagnostic-support-export.tssrc/logging/diagnostic-cpu-profile.tssrc/logging/diagnostic-heap-profile.tssrc/logging/diagnostic-profile.tssrc/logging/diagnostic-memory-bundle.tsextensions/google-meet/src/cli-space-commands.tsextensions/google-meet/src/meet-api.tsextensions/visitor-access/src/visitors.tsextensions/device-pair/index.tsextensions/google-meet/src/cli-export.tsextensions/facetime/src/runtime-call-control.tsextensions/facetime/src/runtime-call-events.tsextensions/facetime/src/runtime.tsextensions/facetime/src/runtime-state.tsextensions/facetime/src/call-lifecycle.tsextensions/facetime/src/runtime-helper-results.tsextensions/visitor-access/src/cloudflare.tsextensions/diagnostics-prometheus/src/service.tsextensions/diagnostics-prometheus/src/prometheus-metric-store.tsextensions/diagnostics-prometheus/src/service-memory.tsextensions/diagnostics-prometheus/src/service-sessions.tsextensions/teams-meetings/index.tsextensions/slack-huddles/index.tsextensions/session-share/src/session-catalog.tsextensions/admin-http-rpc/src/handler.tsextensions/facetime/src/runtime-call-control.tsextensions/llm-task/src/llm-task-tool.tscore
logging
redact-linear-matchers.tsredact-pattern-runtime.tsredact-pem.tsredact-json-tokens.tsredact-edit-composition.tsdiagnostic-liveness.tsdiagnostic-session-attention.tsdiagnostic-owned-activity.tsdiagnostic-session-recovery-coordinator.tsdiagnostic-runtime.tsdiagnostic-session-recovery.tsdiagnostic-argument-churn-activity.tsdiagnostic-repeated-request-activity.tsdiagnostic-run-activity-state.tsdiagnostic-run-activity-snapshot.tsdiagnostic-tool-loop.tsdiagnostic-model-stream-progress.tsdiagnostic-gc.tsdiagnostic-heap-snapshot.tsdiagnostic-phase.tscode-mode-diagnostic.tsdiagnostic-payload.tsdiagnostic-stability-readers.tsdiagnostic-stability-query.tsdiagnostic-session-context.tsdiagnostic.tslogger.tssubsystem.tsconsole.tsconfig.tslog-file-path.tslog-file-shared.tssecret-redaction-registry.tsdiagnostic-stability-bundle.tsthrow/use-zero). Read path keeps missing-file outcome; pruning retains best-effort stat fallback and published-file protection. Serialized bundle and public exports untouched. Delta pending formatter.diagnostic-memory-bundle.tsredact-bounded.tsredact-source.tsredact-prefilter.tsredact-internal.tsredact-internal-state.tsredact-mask.tsredact-performance.tsstructured-authorization-code.tsparse-log-line.tsjson-console-line.tslogger-file-message.tstimestamps.tslogger-settings-internal.tsredact-patterns.tsdiagnostic-run-activity-recovery.tsdiagnostic-run-activity.tstrue; DiagnosticEmbeddedRunOwner. Retained exact authority semantics.logger-file-transport.tslog-tail.tsredacting-stream.tsmessage-lifecycle.tsdiagnostic-session-state.tsdiagnostic-embedded-run-index.tslevels.tsenv-log-level.tsstate.tstypes.tsproviders
channels
misc
interactiveScriptalready shares request/result/cancellation lifecycle; VNC service handover and node launch have different credential/session custody. Retain all native scripts.markPhase; canonical CAS retry and generation mutation helpers own repeated work. Projection shapes kept exact. Retain.hasNameretains canonical path selection and exact message spacing. Policy/real-dir tests read in full.; -9