Repository navigation
refactor: consolidate provider and plugin processing - #167750
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: needs maintainer review before merge. What this changesConsolidates repeated model-provider processing, Policy checks and repairs, and Workboard task projections without intended user-visible changes. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep open: this owner-directed cleanup remains distinct from current main, and source review found no concrete introduced defect. Hosted check failures remain unattributed because their detailed logs were unavailable. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherModel providers convert agent messages and tool definitions into requests and streamed replies. The Policy plugin evaluates operator rules and prepares repairs, while Workboard stores and displays tasks. flowchart TD
A[Agent messages and tool definitions] --> B[Shared provider processing]
B --> C[Provider requests and streamed replies]
D[Operator configuration and rules] --> E[Policy checks and repairs]
F[Stored task records] --> G[Workboard task projections]
Technical reviewBest possible solution: Keep consolidation within the existing owners, retaining explicit provider profiles and existing configuration, storage and authority contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates internal processing rather than repairing a reported user-visible defect. Is this the best way to solve the issue? Yes: the patch removes replaced processing paths and uses explicit profiles to preserve meaningful provider differences, without expanding public configuration or SDK contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cff1f4fcb901. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -637, Other -1. Total -638 across 54 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
Reviewed October 9, 2026, 5:42 AM ET / 09:42 UTC (Revision 2). |
22dc0b2 to
d5c1a6e
Compare
Refresh the immutable JS and CSS generation pointers after the Workboard browser input changes in #167750. Generated with pnpm plugins:assets:build on Linux using the frozen dependency lockfile.
* refactor: share provider schema and stream processing * refactor: share Policy resolution and repair mechanics * refactor: share OpenAI catalog and request normalization * refactor: share Workboard projections and dependency links * chore: prune provider assertion allowances * chore: prune stale session assertion allowance
Refresh the immutable JS and CSS generation pointers after the Workboard browser input changes in openclaw#167750. Generated with pnpm plugins:assets:build on Linux using the frozen dependency lockfile.
What Problem This Solves
Provider processing, Policy diagnostics and Workboard projections repeated the same internal work across closely related variants.
User Impact
No user-visible change relative to current main. Provider request/response shapes, model IDs, config keys, CLI flags, protocol and persisted data shapes, and user-visible text remain unchanged. No migration or operator action is required.
Why This Change Was Made
Shared schema traversal and normalization now take explicit profiles for real provider differences. The same approach consolidates stream handling, ordered catalog metadata, Policy scope/evidence resolution and repair construction, and Workboard projections. Validation order, fallback precedence, sparse arrays, identity reuse, authority checks and transaction boundaries remain with their existing owners.
This second deep pass removes 637 net production lines across 53 files: AI 330, OpenAI 91, Policy 173 and Workboard 43 (1,177 additions; 1,814 deletions). Tests, fixtures, generated files and declarations are excluded. No tests, fixtures or declarations were changed by this PR; the generated assertion baseline only shrinks by twelve allowances across nine entries.
This uses the campaign's 500–999-line exception with a coverage log after more than two hours of implementation. Prior rejected/partial candidates were revisited first, followed by uncovered and adjacent owners. Implemented experiments that increased size or cost were discarded. Together with #167227, this would remove 1,845 lines (2.08% of the measured 88,655-line starting baseline), leaving 815 lines to reach the original 3% target.
Evidence
Candidate head:
d5c1a6e9edd6ba528af90ac25cf2cf7c1518272a; base:c0a28dde4602681fa17b5f273be7702d39505fdf; tree:e0a6fe2846a520f6f9334fde4a95d1261363cec6.The latest rebase was required by a hosted baseline finding. It completed without conflicts: all five previous commits are patch-identical by range-diff, and dependency manifests/lockfile are unchanged. The only additional commit decreases one stale session-reader assertion allowance from 3 to 2. Native generation also proposed an unrelated upstream allowance; only its generated decreases to existing entries were retained. No allowance or source assertion was added. The unchanged full native ratchet passes. The protected session implementation is untouched.
The earlier conflict resolution preserved main's missing-usage fallback and bounded warning in the shared Completions append. Buffered deltas are detached before replay. Main independently removed three overlapping lines during that rebase, leaving the final 637-line production reduction.
22dc0b2655fea76474b40be9b1d5a04cbd693310: full AI 139 files / 2,521 tests; Policy 16 / 428; Workboard 53 / 646 across backend/root and browser runs. Focused Completions passed 59 cases; Google passed 65. Native changed-file core lint passed all 28 existing changed AI files. The first 20 native changed-check stages and all nine post-extension guards passed, including formatting, ratchets, Doctor contracts, plugin boundaries, script lint, legacy stores, sidecar loaders, cycles, webhook and pairing rules.d2475357ab82931d7421f235febe5dc9fd06728cto22dc0b2655fea76474b40be9b1d5a04cbd693310passed with no API changes. This is retained prior-head proof for the unchanged provider patches; it is not a claim that the comparison was rerun after the latest rebase.Hosted attempt 1, run 37911107458, had two root failures:
checks-fast-baseline-ratchets: stale session-reader assertion allowance, 3 recorded versus 2 actual. Since this PR edits the generated baseline, treated as ours and fixed by the shrink-only maintenance above.check-test-types-core-1: TS2554 in untouchedsrc/cli/update-cli.windows-lifecycle.test.ts, calling aSIGINTlistener without its required argument. Reproduced on clean current basec0a28dde4602681fa17b5f273be7702d39505fdfusingnode scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.cli-update.json; exit 2 at line 545 (line 508 in the earlier tested merge). Candidate and clean-base file blobs match. This unrelated updater test is unchanged by the PR. Main fixed it in3223e13a514c6134e10ee7f585627434d245fd20by passing"SIGINT"; the latest hosted merge includes that fix.The failed CI gate aggregates those root failures. No test/check job in the ready CI run was cancelled. Five earlier metadata cancellations have successful same-head replacements; the original cancelled runs are not passing proof. Fresh hosted run 37913257396 passed on exact head
d5c1a6e9edd6ba528af90ac25cf2cf7c1518272a, including the CI gate. Its preflight captured this head merged with3223e13a514c6134e10ee7f585627434d245fd20, so both earlier failures are resolved in the tested merge.Local limitations remain explicit. On the preceding patch-identical provider source, OpenAI passed two database transport files / 18 tests and 86 provider files / 1,219 tests, with six timing failures in two files. Two oversized streaming error-response cases returned AbortError, and four ordinary/telephony speech watchdog cases reached their two-second deadlines. All six reproduced on clean
d2475357ab82931d7421f235febe5dc9fd06728cwith the same Node 26.5 and dependencies (35 passed / 6 failed). The tests and wire implementation are unchanged, butspeech-provider.tsis touched, so this does not automatically qualify an overlapping hosted failure for admin merge.An initial Workboard directory run hit the unchanged 120-second no-output watchdog after 27 sessions-board cases. Subsequent complete coverage passed in separate sessions-board, remaining backend/root, and browser runs; the interrupted attempt is retained and is not claimed repaired by replay. The old lint-suppression run had a stale Cron allowlist failure reproduced on its clean base; main fixed it in
2997d800d7d, and the latest run passes all three cases.Earlier global core lint reached its unchanged 900-second limit; focused core lint passed. Extension lint could not start because required SDK declaration preparation reached its unchanged 300-second limit. Knip production and full-tree scans reached unchanged 600-second limits, including a bounded serialized attempt; the script scan passed with zero entries. A broad wrapper attempt hit three 120-second deadlines; only the first was separately reproduced on the earlier clean main. Dedicated source-closure (three tests) and shadow guards (20 tests) passed. Older proof also includes all 27 core-test type shards and extension test types under the earlier base. These limits and historical results are not relabeled current-head success. No assertions, timeouts, retries, skips, ignores or budgets were weakened.
Remote preparation was cancelled before the twenty-minute allocation limit and before any lease or remote command started; native cleanup was verified. The exact-head hosted run passed; no admin exception is needed.
File-by-file coverage and retained differences
The generated
config/assertion-safety-baseline.txtwas pruned by its native checker: 2,884 to 2,883 recorded files and 6,885 to 6,873 allowances, with no increase or new path. This maintenance file is excluded from production LOC.Implementation ran from 00:05 UTC through after 02:13 UTC on 2026-10-09. The records below describe reviewed owners; final totals above supersede intermediate measurements. A shared Anthropic header assembler added one line, contract-preserving function-tool shaping added five, and a browser optional-field projector added seven: all were rejected. Generated browser event-label keys lost exhaustive typing and were restored. A broader automation normalization rewrite passed output comparisons but increased per-record cost; manual automation parsing is retained and only diagnostic normalization is shared.
ai
openai-completions.test.ts,openai-completions.legacy-function-call.test.ts, managed completions params/stream/integration, structured-content parity and DSML tests; preserve stream event sequence, buffering and thinking/refusal/text phases.ai-anthropic
packages/ai/src/providers/anthropic.test.tspackages/ai/src/providers/anthropic-tool-projection.test.tspackages/ai/src/transports/anthropic-transport-stream.test.tspackages/ai/src/transports/anthropic-payload-policy.test.tspackages/ai/src/anthropic-cache-transport-parity.test.tspackages/ai/src/anthropic-cache-carrier-parity.test.tspackages/ai/src/anthropic-client-identity-parity.test.tspackages/ai/src/anthropic-binding-transport-parity.test.tspackages/ai/src/anthropic-sonnet-55-transport-parity.test.tspackages/ai/src/transports/anthropic-stream-fairness.test.tsai-google
ai-chatgpt
transports/openai-responses-stream-internal.tstransports/openai-responses-replay-internal.tstransports/openai-responses-websocket-recovery.tstransports/openai-responses-stream-slots-internal.tsvalues()explicitly preserves indexed-first ordering and deduplication, independent of admission order.providers/openai-chatgpt-responses-events.tsproviders/openai-chatgpt-responses-websocket-authority.tsopenai-chatgpt-responses.ts: d28p1 completion/processing consolidation retained. Current mid-stream connection expiry reclassification remains untouched. SSE/WS retry boundaries, caller versus request signals, acceptance timing and cached raw wire equality are real differences.openai-chatgpt-responses-protocol.ts: current byte scanner handles bounded retained frames, mixed/chunk-split CR/LF, EOF dispatch, consumer errors, and nonsettling cancellation. Replacing it with SDK SSE decoding would change DONE handling, errors and cancellation; retained.openai-chatgpt-responses-websocket-state.ts: cached-entry compare-and-set protects concurrent replacement; weak references allow global cleanup without retaining runtime hosts. One-session versus all-session fallback-clear/close ordering retained.openai-responses-websocket.ts: SDK iterator listeners are installed eagerly and retained across steering handoff. Cached/transient leases, automatic versus required-input steering, post-dispatch error classification, and cooldown ownership remain distinct. Existing loop and cleanup shapes retained.openai-responses-stream-terminal-internal.ts: d28p1 terminal appendText/tool ID cleanup is already present. Streamed item-done versus terminal snapshot completion has different null-content semantics, saved collapse candidates, delta emission, and tracker/event ordering; no safe whole-handler replacement.openai
openai-provider.ts(1,007): read end to end, read all 1,917 lines of provider tests plus dynamic model, Codex discovery and API-key catalog suites. One ordered metadata table now supplies the five shared forward-compat template selections and synthetic-catalog augmentation models. Dynamic patches still consume only id/templateIds; augmentation still consumes id/contextWindow/contextTokens. Order, exact model IDs, template search precedence, context values and object key presence are unchanged. -41 LOC before formatting.speech-provider.ts(277): read complete source and all 652 lines of boundary tests, plus tts/audio-transcription owners. Unified raw/resolved config normalization with explicit source mode. Raw input still unwraps provider records, resolves secret input and strips URL trailing slashes; resolved input still reads direct values and preserves its endpoint string. Defaults, extra_body fallback, speed policy, format validation, directive and Talk routes unchanged. -12 LOC before formatting.image-generation-provider.ts(902): complete current read. Prior merged edit already unifies generation/edit request options and errors. Subscription transport has deliberate sequential response-model retries, per-image count requests and a differently scoped timeout/auth owner; REST generation/edit has multipart versus JSON body. No further shared core justified yet.realtime-quicksilver-bridge.ts(714): complete read. Direct public transcript drain spans cancelled generation; GA/legacy tool continuations depend on owner callbacks and terminal readiness ordering.realtime-quicksilver-gateway-bridge.ts(671): complete read. WebRTC versus direct sockets share sideband connect/adoption already; peer late completion, pending raw/decoded audio, resource limits and server finalization have distinct owners from direct bridge.realtime-quicksilver-wire.ts(602): complete read. Route-specific call ID validation, allocation before SDP parsing, multipart/JSON payload and precise auth/error redaction rules remain distinct.realtime-voice-session-policy.ts(552): complete read. Platform/OAuth capability, presence and resolution differ; browser/GA format/default differences are preserved. No flattening of these contracts.realtime-quicksilver-protocol.ts(216): complete read. Public session.closed acknowledgement and legacy synchronous closure intentionally have different completion/error precedence; retained.realtime-live-api.ts(101): complete read. Public Live allocation must precede SDP schema check; GA header allocation differs. Hangup resembles GA but attribution default-header authority differs; do not silently unify.realtime-quicksilver-events.ts(204): complete read. Transcript mapping has small duplicate transforms; reviewing common parser with explicit per-protocol shape next.realtime-quicksilver-peer.runtime.ts(271): complete read. Credited worker messages share a pattern with socket adapter but request completion versus EventEmitter closure, transferable audio and deadline handling are deliberately different.realtime-quicksilver-socket.ts(318): complete read. Same assessment; preserving FIFO-close semantics and ack order.openai-chatgpt-provider.ts(578): complete read. Native context patching, offline fallback, browser/device-code UI and identity projection remain distinct; smaller image-capability normalization candidate under review.usage.ts(260): complete read. Request fetch pagination already shared; costs permit empty records while completion records reject them. No profitable common accumulator beyond existing SDK owners.tts.ts(196): complete read. Existing host optional capture contract and SSRF deadline are retained.audio-transcription.ts(126): complete read. Subscription fallback occurs exclusively before upload and explicit config owns billing. Preserve auth/protocol shapes.openai-chatgpt-provider.ts: folded the sole image-capability helper and its sole predicate directly into the existing normalizeResolvedModel owner. Kept the transport-normalized name/id checks, unchanged-object identity, and input-array replacement behavior. Read complete 359-line hook tests; existing provider and dynamic-model boundary tests already read. -17 LOC.realtime-voice-events.ts: one call-scoped rejection closure owns itemId/callId and observer/result emission for the four argument-validation failures. Removed the private argument-bag method; exact reason codes, message strings, checks, and observer order retained. Read complete bridge-tools and terminal-outcomes tests plus protocol parent. -20 LOC.speech-provider.ts: self-review caught the edge where an environment base URL consisting only of slashes normalizes to empty; eliminated accidental double normalization so both raw/resolved paths preserve that prior result. No tests weakened or altered. Formatted delta now -13 LOC.realtime-voice-protocol.ts(478): complete read. Continuation IDs, response preparation/in-flight/manual IDs and output generation protect separate reentrant boundaries; removing retained state cannot be justified by linear-only reasoning.provider-policy-api.ts(678): complete current read. Considered normalizing authored facts once, but preserving route/error precedence requires the same decisions plus an additional intermediate shape. Prior p1 reduction already removes the useful route duplication.openai-chatgpt-oauth-flow.runtime.ts(245): complete read. Manual callback/prompt completion priority and cancellation behavior intentionally differ, with missing code requiring a final prompt; retained.token-sharing-oauth.runtime.ts(444): complete read. Authority checks remain on both sides of awaits and signature/registration verification is a distinct owner from browser Codex flow; shared callback core already in SDK.openai-chatgpt-device-code.ts(446): complete read. Poll success, retryable HTTP status, network and operation timeout each have different pacing/error semantics. Shared HTTP lease owner already used; no generalized policy bag.realtime-quicksilver-session.ts(705): complete read. Prior p1 common call allocation remains the worthwhile overlap. GA bridge and native controller paths have different construction, authority, cleanup and response-delivery lifetimes.realtime-session-retirement.ts(172): complete read. Existing common lease owns retirement/disposal/retry ordering and retains original retirement promise for reentrant cancellation. Private type explicitly projects ReadonlyMap; removing it would widen ownership surface.realtime-quicksilver-sideband.ts(249): complete read. Opening listeners transfer terminal observation; discarded sockets retain error swallowing. Existing wait helper already owns late/aborted promises.realtime-quicksilver-audio.worker.ts(170): complete read. Message credits for audio, RTP and media errors differ in retained payload and coalescing. A generic queue would add policy and leave almost all transport logic.realtime-quicksilver-socket.runtime.ts(325): complete read. Audio drops oldest while control overflows terminally; one FIFO ordering and credited event owner already shared. Cannot flatten separate counters without recomputing payload sizes on hot paths.realtime-quicksilver-media.runtime.ts(528): complete read. Considered deriving codec-free flags by clearing owner slots, but each slot would need an alias to preserve clear-before-free/reentry semantics; no simplification after measurement by construction. RTP sequence/reorder/PLC distinctions retained.codex-client-version.runtime.ts(116): new since first pass, read complete. Already one request/cache/pending owner; success/failure TTLs and stale last-good retention are distinct.embedding-batch.ts(252): complete current read. Group retries, provider deadline and live diagnostic contracts already parameterize SDK owners. No worthwhile adjacent owner duplication.realtime-provider-shared.ts(118),model-service-tiers.ts(57): complete read. Existing transport/normalization/projectors retained; profile trimming differs from direct fallback outcomes and cannot be silently reused there.policy
security/autoAllowSkillsevidence resolution. Security preserves malformed exact configured values and wildcard-source fallback; autoAllowSkills falls to defaults when neither supplies a boolean. Synthetic fallback now private. Allowlist parser/identity unchanged.workboard
workboard-browser