Skip to content

feat(effects): recorded-stream API S1 — adopt @arniwesth's prototype, shared core, fail-loud bounded drain (#546) - #577

Merged
sunholo-voight-kampff merged 9 commits into
devfrom
sprint/m-recorded-stream-api-s1
Aug 3, 2026
Merged

feat(effects): recorded-stream API S1 — adopt @arniwesth's prototype, shared core, fail-loud bounded drain (#546)#577
sunholo-voight-kampff merged 9 commits into
devfrom
sprint/m-recorded-stream-api-s1

Conversation

@sunholo-voight-kampff

Copy link
Copy Markdown
Collaborator

Sprint M-RECORDED-STREAM-API-S1 (mission iter-135)

Adopts the recorded-stream API prototype from @arniwesth (arniwesth#2) and productionizes it per the quorum-cleared design doc + Mark's option-(c) ruling.

Commits (one per milestone):

  • M2c1 fd838911f@arniwesth's patch applied verbatim (5 files, +452, sha256-verified), credited
  • M1 198506afa — split ai_step.go decode/encode helpers → ai_decode.go/ai_encode.go (reordered after the patch: the verbatim patch's context references the pre-split file; split content identical)
  • M2c2 0b34e5218 — ONE shared core (ai_stream_core.go) with policy {record, failLoud}; stepWithStream behavior unchanged incl. its shipped silent skip
  • M3 df0cbb841 — fail-loud unencodable-chunk latch (stable public prefix unencodable stream chunk) + bounded inert drain (256 chunks / 1 MiB) — no panic/recover/sentinel (planner ruling: unsound on js&&wasm)
  • M4 9e2af445b — 14-row TestAIStreamCoreMatrix; author's four tests untouched
  • M4h 1ed9e8b5d — controller mutation probe found the budget test self-referential (256→2 survived); budgets now pinned + under-budget control; mutation re-run caught
  • M5 b0ad7b842 — LongDesc contract text (all four points), Since: v0.32.0, CHANGELOG credit
  • fb357bfb2 — pipeline builtin-types golden: +1 signature, 336 unchanged

What this PR may NOT claim (per the sprint plan): ADR-009 is not thereby unblocked; nothing about the js && wasm build changes.

Gates (controller, outside the codex sandbox): full make test green except the pipeline golden (intentional new-builtin delta, regenerated); check-file-sizes green (ai_step.go 379, core 165); gofmt/go vet clean; zero panic(/recover( in new code.

Refs #546

🤖 Generated with Claude Code

sunholo-voight-kampff and others added 9 commits August 3, 2026 17:59
…1_M2 part 1)

Applied verbatim from arniwesth#2 (arni-546-dev.patch,
sha256 4605a631): _ai_call_stream_recorded_ builtin returning
{ chunks: [StreamChunk], outcome: Result[StepResult, AIError] },
chunks preserved on BOTH outcomes, plus the author's four tests.

Refs #546

Co-Authored-By: arniwesth <arniwesth@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ode.go + ai_encode.go (S1_M1)

Behaviour-free move — zero logic change. ai_step.go 778 -> 525 lines
(800-line CI gate headroom restored). NOTE: plan ordered the split
BEFORE the patch; reordered because the verbatim patch's context lines
reference the pre-split file — patch-first preserves verbatim
reviewability, split content is identical (reused from the executor's
first pass).

Refs #546

Co-Authored-By: codex gpt-5.6-sol <noreply@openai.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ruct (S1_M2 part 2)

One private core in ai_stream_core.go, policy {record bool; failLoud bool}.
aiStepWithStream = core + {false,false} (behavior unchanged, incl. the
shipped silent skip); aiStepWithStreamRecorded = core + {true,true}.
Full internal/effects suite green at this commit (SKIP_NET_TESTS=1).

Refs #546

Co-Authored-By: codex gpt-5.6-sol <noreply@openai.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n for recorded streams (S1_M3)

Active only under failLoud: first unencodable chunk latches non-retryable
Internal error (PUBLIC-CONTRACT prefix 'unencodable stream chunk' in a
named constant); latch never overwritten by a later terminal outcome;
drain records/encodes/delivers nothing, budgets recordedDrainMaxChunks=256
/ recordedDrainMaxBytes=1MiB; on exhaustion drain goes INERT (no panic,
no recover, no sentinel — planner ruling on js&&wasm goroutine soundness);
trace metadata: provider_chunks, delivered_chunks, drain_exhausted.

Refs #546

Co-Authored-By: codex gpt-5.6-sol <noreply@openai.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
TestAIStreamCoreMatrix rows 01-14 per the sprint plan: failure parity,
typed no-handler/no-FnCaller errors, fail-soft callback, all three chunk
variants + Usage fields, unencodable first/middle, both drain budgets
independently, latch not overwritten, empty streams, order/identity/no
duplicates, capability+budget parity, trace contract, registry+metadata,
nested RecordedStream VM shape, ADR-009 ordering gate. Author's four
tests untouched.

Refs #546

Co-Authored-By: codex gpt-5.6-sol <noreply@openai.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…g credit (S1_M5)

LongDesc now states all four contract points: linear unbounded retention;
log exact w.r.t. adapter-EMITTED chunks (tool-call input_json never
emitted by design); unencodable chunk -> typed Internal with stable
prefix 'unencodable stream chunk' + explicitly incomplete prefix, bounded
per-chunk work but the call returns only when the provider stream ends;
deliberate divergence from stepWithStream's silent skip. CHANGELOG credits
@arniwesth (#546, arniwesth#2).

Refs #546

Co-Authored-By: codex gpt-5.6-sol <noreply@openai.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l (S1_M4 hardening)

Controller mutation probe: recordedDrainMaxChunks 256->2 survived the
matrix — the budget test fed recordedDrainMaxChunks+10 chunks, verifying
exhaustion for WHATEVER the budget is (self-referential). Now the row
pins both contract constants and adds an under-budget control proving
the exhaustion assertion is informative. Mutation re-run: caught.

Refs #546

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eam_recorded (S1_M2 follow-up)

Only delta: the one new builtin signature; 336 signatures unchanged
(verified from the golden test's own diff before regenerating).

Refs #546

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ded (evaluator NB-2)

Refs #546

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@sunholo-voight-kampff
sunholo-voight-kampff merged commit ab209fc into dev Aug 3, 2026
20 checks passed
@sunholo-voight-kampff
sunholo-voight-kampff deleted the sprint/m-recorded-stream-api-s1 branch August 3, 2026 16:55
sunholo-voight-kampff added a commit that referenced this pull request Aug 4, 2026
Carries: recorded-stream API S1 (#546, adopted from @arniwesth's prototype,
PR #577) + serve-api embeddable contract #498 Lane B M1 (PR #585) + v0.32.0
benchmark curation cycle. Greenlit by Mark (attended, 2026-08-04).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant