Skip to content

refactor(providers): consolidate stream and catalog owners - #173563

Merged
steipete merged 4 commits into
mainfrom
deslop/z11-3-provider-stream-owners-20261015
Oct 16, 2026
Merged

steipete merged 4 commits into
mainfrom
deslop/z11-3-provider-stream-owners-20261015

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Provider implementations still have parallel stream settlement/framing paths,
catalog borrower protocols, and a private OpenCode Go watchdog competing with
the runner's existing liveness owner. Codex also materializes schema references
and defaults that the schema dependency and actual consumers already own.

User Impact

Internal cleanup with existing provider features, cancellation, FIFO, security,
resource bounds and shutdown settlement retained. Ollama now reports a progress
callback failure instead of swallowing it as malformed JSON. Radius accepts
standard mixed SSE line endings. No configuration or migration is required.

Why This Change Was Made

Use one owner for payload-hook settlement, sync/promise stream mapping, raw SSE
framing and bounded Ollama NDJSON. Keep vendor payload rules, EOF behavior,
reader lifetimes and transport validation local. Vertex uses existing Anthropic
thinking/output-budget policy, including authoritative listed capability overrides.

Read-only catalog loads become bounded, auth-keyed shared promises rather than
consumer-counted controllers and removable waiters. Native TypeBox reference
resolution replaces Codex's recursive schema closure/default injection; consumed
modality defaults live at the model owner. Owned finalization projections no
longer need recursive freezing; source/model/auth detachment stays.

The OpenCode Go provider uses the existing runner watchdog instead of a second
queue, pump, timer and terminal-event synthesizer. The registered-provider
integration test retains human-reported issue #93610's missing-EOF protection.
Actual cloud/cron/explicit bounds, transport first-SSE timeout and failover remain.

Net production: 609 lines removed, excluding tests, support, fixtures,
generated files, declarations and documentation. No dependency, persisted schema,
protocol, permission or public SDK contract change. Phase E is untouched.

Best-effort tradeoffs accepted

Evidence

Targeted production and changed extension-test types passed. Runtime and Madge
cycles are both zero. SDK exports/surface checks, syntax lint, changed line caps,
formatting and diff checks passed. Fresh complete independent review found no
actionable P0–P2 findings. The moved assertion retains its explanatory invariant.

The first two focused provider/owner shards passed174 tests across15 files; the remaining
selection was stopped before repair edits. The pre-push lint-suppression
suite passed3/3. Full build remains pending; public SDK API comparison is running
against frozen refs. The isolated root-script test type graph reports an unchanged Vitest
performance-plugin type mismatch; the one changed inventory row only removes a
deleted test filename. Exact-head hosted CI is the broad proof, not a claim that
unfinished local preparation passed. The existing environment-count mismatch
(452 versus 453) was reproduced on the untouched base previously.

The assertion ratchet identified five stale allowances after the implementation
removed their casts; those exact rows are shrunk, never expanded. The broad
changed-check invocation was stopped after its unrelated SQLite ratchet made no
progress for over thirty minutes; scoped provider gates and hosted CI own the
remaining proof. No database code is changed.

Release-note context: provider-internal consolidation and visible Ollama progress
failure reporting; no live-provider, billing or general performance result claimed.

Owned CI repairs

The first exact-head run exposed four owned jobs, not inherited failures:
checks-node-compact-small-1-2 caught two newly eager imports outside the protected
tooling extraction; check-test-types caught a reader import lost by the clean
main merge; extension bundles3/5 caught that import and four stale private-freeze
assertions. The repair routes thinking through the existing Anthropic facet and
SSE framing through the existing shared transport owner. The protected wrapper,
inventory and allowances remain unchanged. Main's later retirement of the private
reader is adopted: both negative assertions use the existing prepared-notification
owner, retaining malformed-item and nonterminal rejection. Only obsolete Object.isFrozen assertions are removed,
leaving content, detachment, persistence and authority checks intact. These are
source/test repairs, not CI reruns or timeout/retry changes.

Fresh repair review is scoped-clean through P2; targeted production types, syntax
lint, 67-file line-cap check, runtime cycles0 and suppression3/3 pass. A direct run
of the unchanged closure owner reports missing[]/stale[]. Its Vitest invocation
timed out at the unchanged120s bound on the loaded host without an assertion
verdict. Earlier separate Codex replays were stopped during prolonged preparation,
not claimed passing. Expanded repair-test types pass. The full Madge recheck was
stopped before integration; API rendering remains pending. The previous cut's Madge0 proof is reused:
the only added import is a direct shortcut over the existing
internal/anthropic→providers/anthropic→anthropic-transport-options path; the SSE
move adds no import, and all other repair edges are removed. No new component is
possible from that shortcut.

A real one-file import conflict and the named type gate required a conflict-only
rebase onto main. Main's prepared-notification owner and private-reader retirement
are preserved. Fresh test-only review is clean through P2; conflicted-graph types,
runtime cycles0, SDK exports/surface, syntax lint, line caps and suppression3/3 pass.
All18 protocol-validator assertions passed (the wrapper was stopped during its
generation-cleanup phase, so no aggregate exit-zero claim). A separate direct
production-owner probe also accepts the valid terminal fixture and rejects both
malformed nested text and nonterminal status. Exact repaired-head CI supplies broad proof.

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T01:00:22.783607Z fde1c46 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9f6337ffb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Object.freeze(selection);
Object.freeze(this);
}
) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the remaining frozen-context assertions

When the Codex settled-finalization suites run, this empty constructor leaves both the context and its data array mutable, but run-attempt.settled-finalization.test-support.ts (lines 208 and 290), settled-turn-finalizer.native.test.ts (line 803), and session-history.test.ts (line 213) still assert that these values are frozen. Those assertions now deterministically fail, so remove or revise all of them as part of this behavior change.

AGENTS.md reference: AGENTS.md:L85-L86

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Oct 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR consolidates provider stream composition, framing, catalog caching, and Codex validation around shared owners.

Example: While downloading gemma4:e2b from Ollama, the progress callback throws "progress display failed".

  • Before: The exception is swallowed as malformed JSON, allowing a later success record to report a successful download.
  • After: The pull reports "Failed to download gemma4:e2b: progress display failed" and returns false.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful, approved consolidation with scoped harness coverage, but confirmed test and wrapper-cutover failures prevent merge.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; inspected evidence consists of source, focused-test claims, and hosted CI rather than live provider output.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Duplicated provider lifecycle and framing implementations can drift; Ollama also hides progress callback failures.
Reason: The maintainer-authored PR explicitly approves the consolidation and its tradeoffs, and source inspection supports the shared-owner placement.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep this PR open: the maintainer-approved consolidation is worthwhile, but three concrete cutover defects need repair before merge.

Priority: P2
Reviewed head: f9f6337ffb9a752cff2ac5e1e42c1191904efe6c

Before merge

  • Update every remaining frozen-context assertion (P2) - The constructor now leaves both the context and its data mutable, but run-attempt.settled-finalization.test-support.ts:208 and :290, settled-turn-finalizer.native.test.ts:803, and session-history.test.ts:213 still require Object.isFrozen(...) to be true. Hosted CI reports these exact failures. Revise the obsolete freeze assertions while retaining their history, selection, and detachment checks; the accepted removal of freezing does not require restoring it.
  • Include the newly reachable modules in the PR wrapper inventory (P2) - These exports add runtime dependencies on anthropic-transport-options.ts and sse-frames.ts, but scripts/pr-lib/wrapper-components.txt includes neither. The trusted wrapper's extracted tree therefore cannot resolve its runtime imports; both inventory and extracted-context tests fail with these paths. Add the two modules to the maintained inventory.
  • Exercise new notification cases through the current public owner (P2) - Main commit 05ade66 deliberately made readCodexTurnCompletedNotification private and migrated existing tests to prepareCodexServerNotification. These added direct calls merge alongside that migration without an import; the inspected CI merge reports ReferenceError at the first call. Adapt both new cases to prepareCodexServerNotification and assert completedTurn is undefined, preserving main's encapsulation rather than restoring the retired export.

Findings

  • [P2] Update every remaining frozen-context assertion — extensions/codex/src/app-server/settled-turn-context.ts:22-25
  • [P2] Include the newly reachable modules in the PR wrapper inventory — packages/ai/src/internal/shared.ts:3-4
  • [P2] Exercise new notification cases through the current public owner — extensions/codex/src/app-server/protocol-validators.test.ts:218-223

Tests

  • Low-value test src/llm/providers/stream-wrappers/stream-payload-utils.test.ts: Remove the added helper-only phase/Promise-shape matrix and cover any missing replacement-ordering contract through an actual provider's outgoing request boundary.
  • Missing end-to-end proof: The supplied validation exercises tests and in-process owners rather than a shipped provider request, and no before/after run demonstrates the new Ollama callback-failure case.
Agent review details

How this fits together

Provider plugins translate model requests into transport calls; shared stream helpers process hooks and response frames, catalog helpers cache model metadata, and the runner owns inference liveness.

flowchart TD
  A[Agent runner] --> B[Provider adapters]
  B --> C[Shared payload and stream helpers]
  C --> D[Provider transports]
  D --> E[Provider services]
  B --> F[Shared catalog cache]
  F --> E
Loading

Technical review

Best possible solution:

Complete the test and packaging cutover while retaining the approved shared-owner design and accepted tradeoffs.

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

Source inspection establishes the remaining freeze assertions and missing wrapper inventory entries, and hosted CI corroborates both; the notification-test failure is additionally verified in CI's synthetic merge with the overlapping main change.

Is this the best way to solve the issue?

The shared-owner approach fits the repository's design guidance, and the recorded maintainer tradeoffs resolve its intentional behavior changes; the remaining repairs should complete that cutover rather than restore the removed machinery.

Full review comments:

  • [P2] Update every remaining frozen-context assertion — extensions/codex/src/app-server/settled-turn-context.ts:22-25
    The constructor now leaves both the context and its data mutable, but run-attempt.settled-finalization.test-support.ts:208 and :290, settled-turn-finalizer.native.test.ts:803, and session-history.test.ts:213 still require Object.isFrozen(...) to be true. Hosted CI reports these exact failures. Revise the obsolete freeze assertions while retaining their history, selection, and detachment checks; the accepted removal of freezing does not require restoring it.
    Confidence: 1
  • [P2] Include the newly reachable modules in the PR wrapper inventory — packages/ai/src/internal/shared.ts:3-4
    These exports add runtime dependencies on anthropic-transport-options.ts and sse-frames.ts, but scripts/pr-lib/wrapper-components.txt includes neither. The trusted wrapper's extracted tree therefore cannot resolve its runtime imports; both inventory and extracted-context tests fail with these paths. Add the two modules to the maintained inventory.
    Confidence: 1
  • [P2] Exercise new notification cases through the current public owner — extensions/codex/src/app-server/protocol-validators.test.ts:218-223
    Main commit 05ade66 deliberately made readCodexTurnCompletedNotification private and migrated existing tests to prepareCodexServerNotification. These added direct calls merge alongside that migration without an import; the inspected CI merge reports ReferenceError at the first call. Adapt both new cases to prepareCodexServerNotification and assert completedTurn is undefined, preserving main's encapsulation rather than restoring the retired export.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 012bb1ccaf0b.

Provenance checked

  • Catalog cancellation and observer retention changes intended behavior with a stated reason (b9f0c3e: Independent callers needed separate cancellation while preserving shared acquisition; e7ca781 subsequently released cancelled joiners before load settlement.)
  • OpenCode Go stalled-stream watchdog changes intended behavior with a stated reason (769579b: Provider streams could leave cron runs waiting for stuck-session recovery; the PR explicitly transfers liveness to the now-capable runner and retains registered-provider missing-EOF coverage.)
  • Codex schema materialization and default injection changes intended behavior with a stated reason (8738fe1: Compacted generated schemas required reference closure reconstruction while the earlier TypeBox migration preserved defaults; the PR replaces reconstruction with native resource resolution and preserves consumed modality defaults at model admission.)
  • Codex settled-turn freezing changes intended behavior with a stated reason (4431033: Bounded detached history supported eligible settled-turn fallback without excessive copies; the PR explicitly retains detachment and captured selection while dropping recursive freezing.)
  • Payload hook replacement handling keeps the original intent (073d43c: Provider transforms must apply to synchronous and asynchronous replacement bodies, while in-place caller overrides retain precedence; the shared hook composition preserves that ordering.)
  • Anthropic Vertex thinking and output budgets keeps the original intent (d795000: Vertex-specific SDK ownership moved into its plugin without changing routing or request shaping; this PR keeps client and provider defaults local while reusing shared thinking and budget policy.)
  • Ollama framing and pull completion keeps the original intent (865a728: Pulls require an actual success record and bounded stream handling; consolidation preserves those contracts and narrows malformed-JSON handling so callback failures remain visible.)
  • OAuth and realtime cancellation changes intended behavior with a stated reason (5e0a75f: Realtime startup needed lifecycle settlement and cancellation cleanup; the PR explicitly adopts existing shared race precedence while retaining startup errors, timer cleanup, and the final OAuth credential-return abort check.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/codex/src/app-server/protocol-validators.test.ts --maxWorkers=1
  • pnpm test extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/settled-turn-finalizer.native.test.ts extensions/codex/src/app-server/session-history.test.ts --maxWorkers=1
  • pnpm test test/scripts/eager-import-closure.test.ts --maxWorkers=1
  • git diff --check
  • Verify the repaired head's check-test-types and affected extension/tooling CI checks.

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 283d5e6 adds extensions/codex/src/app-server/settled-turn-context.ts:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 283d5e6fe371; files: extensions/codex/src/app-server/settled-turn-context.ts)
  • Vincent Koc: Raw commit e7ca781 adds src/plugin-sdk/provider-catalog-shared.ts:68 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e7ca781b5478; files: src/plugin-sdk/provider-catalog-shared.ts)
  • YangManBOBO: Raw commit 073d43c adds src/llm/providers/stream-wrappers/stream-payload-utils.test.ts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 073d43cfec64; files: src/llm/providers/stream-wrappers/stream-payload-utils.test.ts)

PR surface

Source -610, Tests -28, Docs +12, Other -3. Total -629 across 68 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 49 482 1092 -610
Tests 17 599 627 -28
Docs 1 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 5 -3
Total 68 1095 1724 -629

Labels

Label changes:

  • add P2: This is useful internal consolidation with focused test and packaging defects, without an established urgent runtime incident introduced by the patch.
  • add merge-risk: 🚨 automation: The new internal exports leave the trusted PR wrapper extraction missing runtime dependencies, breaking its import closure.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is useful internal consolidation with focused test and packaging defects, without an established urgent runtime incident introduced by the patch.
  • merge-risk: 🚨 automation: The new internal exports leave the trusted PR wrapper extraction missing runtime dependencies, breaking its import closure.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed October 15, 2026, 8:09 PM ET / October 16, 2026, 00:09 UTC.

@steipete
steipete force-pushed the deslop/z11-3-provider-stream-owners-20261015 branch from f9f6337 to fde1c46 Compare October 16, 2026 00:54
@steipete
steipete merged commit cc83172 into main Oct 16, 2026
144 of 145 checks passed
@steipete
steipete deleted the deslop/z11-3-provider-stream-owners-20261015 branch October 16, 2026 01:08
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…173563)

* refactor(providers): consolidate stream and catalog owners

* chore(providers): shrink removed assertion allowances

* fix(providers): preserve tooling imports and retained fixture contracts

* test(codex): validate prepared terminal notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant