Skip to content

Add automated PR review workflow - #34

Merged
gnanam1990 merged 2 commits into
mainfrom
codex/pr-auto-review
Jun 3, 2026
Merged

Add automated PR review workflow#34
gnanam1990 merged 2 commits into
mainfrom
codex/pr-auto-review

Conversation

@Vasanthdev2004

Copy link
Copy Markdown
Collaborator

Summary

  • Add a PR Auto Review workflow that runs diff hygiene, typecheck, tests, build, and smoke build on PR updates.
  • Add a Bun review script that posts or updates one stable automated review comment with blockers and validation status.
  • Add focused tests for outcome normalization and review markdown formatting.

Validation

  • bun run typecheck
  • bun test ./tests/pr-review.test.ts --timeout 15000
  • bun test ./tests --timeout 15000
  • bun run build
  • bun run smoke:build
  • dry-run bun run review:pr

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Typecheck: bun run typecheck
  • [pass] Tests: bun run test
  • [pass] Build: bun run build
  • [pass] Smoke build: bun run smoke:build

Scope

Head: 53e2894c35de
Changed files (4): .github/workflows/pr-auto-review.yml, package.json, scripts/pr-review.ts, tests/pr-review.test.ts

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@anandh8x anandh8x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: Automated PR review workflow

No blockers. Clean CI-integrated auto-review with deterministic validation checks.

What's good

  • Always posts — All check steps use continue-on-error: true, so the review comment is posted even when checks fail. Then the final step fails the workflow. Best of both worlds.
  • Marker-upsertZERO_AUTO_REVIEW_MARKER pattern lets the script find-and-replace its own comment on re-runs (synchronize events). No duplicate comments.
  • Outcome normalizationnormalizeOutcome handles GitHub's varied outcome strings (timed-outtimed_out, case insensitivity, undefinedunknown). Defensive.
  • buildReviewMarkdown — Clear verdict line, blockers section (only failures), validation table, scope with SHA + file list, and a human-reviewer caveat.
  • formatChangedFiles — Caps at 12 files with "and N more" suffix. No unbounded comment bodies.
  • resolvePullRequestContext — Reads GITHUB_EVENT_PATH JSON directly; validated error messages for missing event path or repository.
  • collectChangedFiles — Graceful fallback: returns [] on fetch or diff failure instead of crashing.
  • Dry-run supportZERO_PR_REVIEW_DRY_RUN=1 prints the body to stdout without posting. Useful for local testing.
  • Posting failure is non-fatal — The try/catch logs the error and falls back to printing the body. A network failure doesn't mask check results.
  • Diff hygiene checkgit diff --check detects trailing whitespace, space-before-tab, etc. as a dedicated step.
  • GITHUB_TOKEN scoped correctlycontents: read, issues: write, pull-requests: write. Appropriate least-privilege.
  • Skips draft PRsif: !github.event.pull_request.draft. No noise on WIP branches.
  • Test coveragenormalizeOutcome, buildChecksFromEnv, hasBlockingChecks, buildReviewMarkdown, formatOutcome all tested. (The network/git-dependent functions are understandably not tested.)

Observations (non-blocking)

  • collectChangedFiles double-fetches — The checkout step already has fetch-depth: 0 (all history). The script then does another git fetch --depth=1 origin {baseRef}. The fetch is a no-op for already-present refs, but adds latency. Could skip fetch and diff against origin/{baseRef} directly.
  • upsertReviewComment limits to 100 comments — If a PR accumulates 100+ issue comments, the marker search would miss later pages. Academic at this scale.
  • Issue comment vs review API — Uses issue comments (PATCHable) rather than the reviews API (append-only). The marker-upsert pattern works well for issue comments and is simpler than deleting/re-creating reviews. Intentional choice.
  • No diff-size/complexity analysis — Currently checks only whitespace hygiene. Could add file-count, diff-stat, or large-file warnings in the future.

@gnanam1990
gnanam1990 requested a review from anandh8x June 3, 2026 10:36

@gnanam1990 gnanam1990 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review update

Verdict: Changes requested

Reviewed PR #34 at head a6112fe88eaf. I also considered the existing github-actions[bot] summary comment, which reports that the workflow's validation commands passed.

Validation I ran locally:

  • bun install --frozen-lockfile passed
  • git diff --check origin/main...HEAD passed
  • bun test passed: 224 tests, 0 failures
  • bun run typecheck passed
  • bun run build passed
  • bun run smoke:build passed

GitHub checks are also passing, including Smoke on Ubuntu/macOS/Windows, Performance Smoke, and Zero Review.

Blocking concern:

  • The workflow posts the PR review summary by running bun run review:pr from the PR checkout while passing a write-scoped GITHUB_TOKEN into that step. After this lands, a future PR can modify package.json's review:pr script or scripts/pr-review.ts, and the workflow would execute that PR-controlled code with issues: write / pull-requests: write. That lets the PR author spoof or alter review comments/reviews using the workflow token.

Please keep the token-consuming posting logic out of PR-controlled code. For example, post with an inline workflow step / actions/github-script, or run a trusted copy of the posting script from the base branch before exposing GITHUB_TOKEN. The validation steps can still run against the PR code, but the step that receives write credentials should not execute files or package scripts from the PR branch.

@gnanam1990

Copy link
Copy Markdown
Collaborator

@Vasanthdev2004 @anandh8x please review this PR.

@Vasanthdev2004

Copy link
Copy Markdown
Collaborator Author

Blockers

None found.

Non-Blocking

  • The stable issue-comment upsert only scans the first 100 PR comments, so very noisy PRs could miss the marker and create a duplicate automated comment later.
  • collectChangedFiles refetches the base ref even though checkout already uses full history; harmless, but a little extra latency.

Looks Good

  • The workflow runs diff hygiene, typecheck, tests, build, and smoke build with continue-on-error, then posts a deterministic summary before failing on any blocking outcome.
  • The review script keeps one stable marker comment, normalizes GitHub step outcomes defensively, supports dry-run/local output, and avoids crashing the workflow if comment posting fails.
  • Validation passed: focused PR review tests 4/4, full suite 224/224, typecheck, build, smoke:build, dry-run failure-summary probe, and whitespace checks.
  • 411 additions, 0 deletions — focused CI/review automation with targeted helper coverage.

Verdict: Approve — Clean automated PR review workflow foundation.

@gnanam1990 gnanam1990 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rereview update

Verdict: Approve

I rereviewed the new commit 53e2894c35de after the requested security change.

The previous blocker is resolved: the workflow no longer passes the write-scoped GITHUB_TOKEN to PR-controlled bun run review:pr code. The token-consuming comment upsert now runs in an inline actions/github-script step, while PR code is limited to validation/build/test steps and changed-file collection.

Validation observed:

  • GitHub checks all pass: Smoke on Ubuntu/macOS/Windows, Performance Smoke, and Zero Review.
  • gh pr diff shows the posting logic moved into trusted workflow YAML instead of executing the PR branch script with write credentials.

No new blockers found.

@Vasanthdev2004

Copy link
Copy Markdown
Collaborator Author

Blockers

None found.

Non-Blocking

  • None.

Looks Good

  • The requested token-safety blocker is resolved at head 53e2894: the write-scoped GITHUB_TOKEN is now consumed only by an inline actions/github-script step, while scripts/pr-review.ts is local formatting output only and no longer performs authenticated API calls.
  • The automated comment still upserts by marker, paginates PR comments, falls back to the step summary if posting fails, and preserves deterministic blocker/validation/scope output.
  • Validation passed: focused PR review tests 5/5, full suite 225/225, typecheck, build, smoke:build, dry-run failure-summary probe, and whitespace checks.
  • 419 additions, 0 deletions — focused CI/review automation with the requested credential boundary fixed.

Verdict: Approve — Clean automated PR review workflow with trusted token-handling separated from PR-controlled scripts.

@gnanam1990
gnanam1990 merged commit 4c21a61 into main Jun 3, 2026
5 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the codex/pr-auto-review branch June 28, 2026 08:27
anandh8x added a commit that referenced this pull request Jul 4, 2026
…rrors

#19: bump maxStreamReconnects 2->4 and add up-to-50% jitter on the
exponential backoff (capped at 8s), so a multi-second network blip is
ridden out instead of killing the run on a 2s hiccup, and concurrent runs
(swarms, cron fleets) don't reconnect in lockstep.

#34: drop the '502'/'503' substring matches from shouldReconnect. 503
already exhausted providerio.SendWithRetry (retrying here is a redundant
double-retry) and 502 is non-idempotent by providerio's rule (the POST
may have been processed). Only genuine transport failures — where no
response was received — reconnect now.
anandh8x added a commit that referenced this pull request Jul 5, 2026
* feat(tui): actionable hints on provider/model errors

Classify a failed turn's provider error into auth / rate-limit /
connectivity / model-not-found / context-overflow and render a one-line
next step below the red error row, instead of dumping an identical raw
blob for every failure mode.

The classifier lives in a new internal/errhint package so both the TUI
error row and the CLI exec path can share it (TUIHint references slash
commands, CLIHint references zero subcommands). Classification is a
conservative string heuristic keyed off providerio.ClassifiedError's
prefixes plus lower-level DNS/TLS/timeout/context-length signatures,
since the numeric HTTP status is gone by the time the error reaches a UI
surface.

* feat(tools): budget bash output with head+tail truncation

bash was the one tool that returned command output with no byte cap —
'cat large.log' or a verbose test run could dump megabytes into context
and force compaction, while every other read/search tool already applies
a budget.

Cap stdout and stderr at 96KB each, keeping the head and tail of an
oversized stream (build/test failures usually land at the tail) and
dropping the middle behind a marker that points at redirect-to-file +
read_file. Record raw_bytes/emitted_bytes/estimated_tokens/truncated in
Meta like the other tools. Sandbox-denial and shell-issue detection still
run on the full raw output before budgeting.

* fix(gemini): retry 401 with refreshed OAuth token

The Gemini provider used providerio.SendWithRetry (429/503/529 only),
so an expired OAuth token surfaced as a terminal 'API key not valid'
auth error while OpenAI and Anthropic silently recovered via
SendWithAuthRetry's force-refresh-and-replay on 401.

Plumb OAuthResolver through gemini.Options/Provider and the factory
(exactly as the other two providers already do) and switch the stream
send to SendWithAuthRetry. With a nil resolver (API-key users) behavior
is unchanged.

* fix(errhint): gate classification on provider-origin marker

Address CodeRabbit review on #1: agentResponseMsg.err can also carry
local failures (a tool's 'permission denied', a 'file does not exist',
a config error), and broad substrings would have attached a bogus
/provider or /model hint to those.

Classify now returns Unknown unless the message carries a provider marker
the provider layer always attaches (auth error: / rate limit error: /
provider error: / provider request error: / provider stream error:).
Local errors never draw a provider hint; provider errors sub-classify as
before. Added local-failure test cases proving they stay Unknown.

* feat(cli): actionable hint on text-mode exec provider errors

zero exec printed provider failures as a bare '[zero] <raw error>' with
no next step. Append a one-line hint (reusing the shared errhint
classifier) for recognized provider failures — 'run `zero auth`',
'run `zero doctor`', etc. The provider-origin gate means non-provider
codes (sandbox_error, mcp_error) and JSON/stream-json output are
untouched.

* fix(tools): set Result.Truncated for budgeted bash output

Address CodeRabbit review on #3: budgetBashOutput recorded truncation in
meta["truncated"] but never set the Result.Truncated struct field, so
consumers reading the struct (like glob/web_fetch/read_minified do) would
miss truncated bash results. Return the bool from budgetBashOutput and
set Result.Truncated on every return path.

* perf(tui): reuse one LSP manager across prompts

runAgentWithOptions built a fresh lsp.NewManager per run and shut it down
when the run returned, so gopls (and every other language server)
cold-started on the first edit of every turn — 200ms-2s of latency the
manager's own design (long-lived, reused servers) exists to avoid.

Build one manager per session in newModel (cheap: servers start lazily on
first Check) and reuse it across runs; the SelfCorrector still gets a
fresh checker wrapping the shared manager each run. Torn down with a
short deadline in quit(). Runs fall back to a per-run manager when the
session manager is absent (cwd unknown, or a directly-built test model).

* perf(tui): accumulate streamingText as []byte (O(1) append)

m.streamingText += msg.delta was O(len) per delta -> O(n²) across a long
generation (a 10k-token code gen allocates hundreds of MB of intermediate
strings and the UI gets progressively laggier). Accumulate into a []byte
with append (O(1) amortized) and read via streamingTextString().

A []byte rather than strings.Builder because the TUI model is copied by
value on every Update, which would trip strings.Builder's copy check;
[]byte is nil-safe and copies cleanly like the other slice fields.

* perf(tui): coalesce streamed text deltas to one frame

Every OnText delta was its own tea.Msg, so a fast provider (100+ tok/s)
drove 100+ full Update->View cycles per second, each re-parsing the
growing markdown — visible stutter over SSH and wasted CPU.

Batch agentTextMsg deltas at the runtime sink over a ~16ms frame and
forward them as a single message, decoupling render rate from token rate.
Any non-text message flushes pending text first so ordering with
tool-call / reasoning / row messages is preserved; the final
agentResponseMsg (a tea.Cmd return, not a sink message) is safe because
the model already drops deltas for an inactive runID.

* fix(agent): raise tool-failure stop threshold 4->6

guardrails.go halted a run after 4 consecutive same-error tool failures.
A corrective hint fires at 2, and a model iterating on a genuinely tricky
edit can legitimately fail a couple more times after the hint while
converging — stopping at 4 cut those runs short. Raise to 6; the streak
still resets the instant the tool succeeds or hits a different error, so
only true same-error loops are affected.

* fix(agent): more reconnect retries with jitter; narrow to transport errors

#19: bump maxStreamReconnects 2->4 and add up-to-50% jitter on the
exponential backoff (capped at 8s), so a multi-second network blip is
ridden out instead of killing the run on a 2s hiccup, and concurrent runs
(swarms, cron fleets) don't reconnect in lockstep.

#34: drop the '502'/'503' substring matches from shouldReconnect. 503
already exhausted providerio.SendWithRetry (retrying here is a redundant
double-retry) and 502 is non-idempotent by providerio's rule (the POST
may have been processed). Only genuine transport failures — where no
response was received — reconnect now.

* fix(agent): reduce stall retries 2->1 to bound stuck-session time

A no-output stream stall is detected only after the full stream idle
timeout (~5min) elapses, and each retry can idle again — so 2 retries
left an interactive session frozen for ~15min. Drop to 1 retry: keeps the
common single-hiccup recovery while bounding the worst case to ~2x the
idle timeout.

* fix(tui): serialize coalescer forwarding to preserve message order

Address CodeRabbit review on #7: flush() and the run-switch path drained
the text buffer under c.mu but called forward() after releasing it, so a
timer-fired text flush could race a concurrent non-text send() and land
after the tool-call/reasoning message it should precede.

Hold c.mu across drain AND forward (drainAndForwardLocked), so whoever
holds the lock delivers atomically and the other caller blocks until it
is done — text can never overtake a following non-text message. Added a
concurrency stress test (timer racing an inline send) that passes under
-race.

* feat(tui): accept /compact now

Bare /compact already triggers compaction, but /compact now — what users
reach for when the context gauge climbs — hit the usage-error branch.
Accept the 'now' keyword and advertise it in the command usage.

* feat(tui): add /retry, /edit, /copy, /export commands

/retry resends the last prompt; /edit recalls it into the composer to
tweak and resend — both read a new lastPrompt field captured verbatim
(pre-expansion) in launchPrompt. /copy puts the last answer on the
clipboard via the existing copy machinery; /export writes a plain
role-prefixed transcript to a file (timestamped default, or a given
path). Real gaps for SSH users with no mouse select.

* feat(tools): separator-insensitive tool_search matching

tool_search ranked deferred tools by exact substring, so a model that
typed 'webfetch' (dropping the underscore) matched nothing and looped.
Add a separator-squashing fallback ('web_fetch' -> 'webfetch') scored
below an exact substring match, so precise queries still rank first.

* feat(tools): signal ask_user dismissal distinctly from a blank field

Empty answers all rendered as '(no answer provided)', so the model
couldn't tell a wholesale dismissal (user closed the prompt without
answering anything) from one field left blank amid real answers — and
might invent a default. FormatAskUserAnswers now flags a full dismissal
up front as a skip and marks individual empties '(left blank)' vs
'(skipped)'.

* feat(tui): fuzzy ranking in model/session pickers

The pickers filtered by flat strings.Contains with no ranking, so
finding 'sonnet 4.5' among 50+ models meant an exact prefix or scrolling.
Rank matches (exact < prefix < contains < subsequence, reusing
fuzzySubsequenceGap) so the closest match lands on top, and 'snt45' now
matches 'Sonnet 4.5'. Groups stay contiguous — ordered by their best
match, never split — so the grouped model picker still renders one header
per provider. Covers both /model and /resume (shared commandPicker).

* perf(agent): cache per-tool schema render across turns

partitionTools re-ran the recursive schema->map conversion
(schemaToRuntimeMap) for every tool on every turn — redundant, since a
tool's advertised name/description/schema is stable for the run. Add a
per-run definition cache keyed by tool name (nil-safe; the plain
partitionTools entrypoint and tests pass nil for fresh renders).

The partitioning itself (visibility, deferral, ordering) still recomputes
every turn — it must, because a tool's deferred state can flip mid-run
(swarm tools un-defer once a swarm is active). Only the expensive schema
render is memoized. tool_search is excluded by its callers (dynamic
description) so it never poisons the cache.

* perf(agent): calibrate compaction estimate against real prompt tokens

The byte/4 heuristic (ApproxTextTokens) over-counts code-heavy content
~15-20%, so with triggerRatio=0.7 compaction fired at ~60% of true
capacity — premature summarizer calls that degrade quality. Each turn now
folds (rawEstimate, provider InputTokens) into an EMA calibration ratio,
clamped per-sample to a sane band; maybeCompact and the reactive path
scale their estimates by it. Turn 1 uses the raw estimate (no data yet);
later turns compact near real capacity.

* style: gofmt the new agent test files

The CI gofmt check flagged the #22/#25 test files (struct-field and
switch alignment). No behavior change.

* feat(agent): turn-based plan staleness reminder

The stale-plan nudge only fired after 10 tool calls since the last
update_plan, so a plan that drifts stale across many low-tool-call turns
(one call per turn) took many turns to catch — the 'plan set turn 1 stays
pending forever' case. Add a turn-count complement: after
stalePlanTurnThreshold (8) turns without an update AND with items still
pending, fire the same one-shot reminder. Gated on pending items so a
fully-completed plan is never nagged; the existing tool-call trigger is
unchanged. (The roadmap's fuzzy 'tool calls unrelated to plan items'
relevance match is deliberately omitted — too false-positive-prone.)

* feat(agent): preserve recent-edits summary across compaction

Compaction preserved the plan, loaded skills, tool schemas, and project
instructions, but not file edits — so after the editing turns were elided
the model knew it had changed a file only vaguely, and would re-read to
rediscover its own footprint. Extract write_file/edit_file targets from
the elided middle with a one-line note from each tool result, merge them
across repeated compactions (newer note per path wins), and carry them in
the preserved-state JSON (capped at 20 paths / 160 bytes per note).

* feat(tui): workspace-scoped /resume + fewer event reads

/resume listed sessions from every project globally, and read the full
event file for each of them to test for resumable content. Filter the
picker (and /resume latest) by the current workspace Cwd, checked BEFORE
the per-session read so a large global history no longer pays N full file
reads to build one workspace's list; also skip zero-event sessions via
metadata without any read. Sessions with no recorded Cwd (older runs) and
an unknown current workspace stay visible so nothing is hidden that can't
be confidently placed. Explicit /resume <id> still resolves any session.

* feat(tui): warn on model switch that drops staged images

Staged images were silently dropped at submit when the active model had
no vision support — the user only learned after sending. Chips already
render above the composer (renderAttachmentChips); add an immediate amber
warning line to the /model switch status (both same-provider and
cross-provider paths) when images are staged and the newly selected model
can't accept them, so the drop is surfaced at switch time.

* feat(tui): inline recovery affordance on setup errors

A first-run setup error rendered as a bare red 'error: <text>' with no
pointer to the fix. Append a faint, stage-tailored recovery line (edit
the endpoint/name/key above then Enter, or pick another model) that names
only keys the stage's footer confirms, so the guidance is always accurate.
Empty for stages whose footer already makes recovery obvious.

* fix: address CodeRabbit review (5 findings)

- loop.go: recompute the compaction calibration estimate at calibration
  time, not request-build time, so a reactive-compaction reissue that
  shrinks the request feeds the EMA the sample that actually completed.
- errhint: match bare HTTP status codes (401/403/429/529) only at digit
  boundaries, so an incidental number ('4290ms', 'id 14015') isn't
  mis-bucketed as auth/rate-limit.
- bash: drop the stray unmatched ']' in the output-truncation marker.
- tui /retry: apply the same exiting/compactInFlight guards commandPrompt
  has, so a retry can't race compactResultMsg's rewrite of session state.
- tui /export: write the transcript 0o600 (it may contain echoed
  secrets), not world/group-readable 0o644.

* test(tui): skip export file-mode assertion on Windows

os.WriteFile ignores Unix permission bits on Windows and Stat reports
0666, so the 0o600 assertion failed there. The production 0o600 is
honored on Linux/macOS (where it matters); guard the check with
runtime.GOOS so Windows smoke passes.

* fix(tui): align /resume latest filters + case-insensitive workspace match on Windows

Address CodeRabbit review on #21:
- latestResumableInWorkspace now applies the SAME filters as the picker
  (skip zero-event metadata and empty/failed runs), so /resume latest
  can't land on a session the picker intentionally hides.
- sessionMatchesWorkspace compares paths case-insensitively on Windows
  (its filesystem is), so the same workspace spelled with different casing
  no longer hides resumable sessions; other platforms stay case-sensitive.

* fix(tui): /retry resends the last prompt's image/PDF attachments

/retry relaunched only lastPrompt's text, but launchPrompt clears the
pending image/document queues once a turn is sent. A vision- or PDF-backed
prompt that failed would silently retry as text-only and answer a different
task. Snapshot the consumed attachments at launch and re-stage them on
/retry so launchPrompt rebuilds an identical request (document preamble,
images, and the submit-time vision re-check). startNewSession drops the
snapshot so a post-/new /retry cannot leak the previous session's
attachments. Also correct the OAuthResolver factory comment, which omitted
the Gemini provider it is now passed to.

* fix: address jatmn review (reconnect 5xx, /edit attachments, edit-cap, coalescer test)

- reconnect: exclude HTTP 5xx (500/502/503/504) before the transport
  substring match so "504 Gateway Timeout" no longer slips through on the
  generic "timeout" needle. A gateway timeout is non-idempotent — the
  completion POST may already have reached the model — so replaying the
  connect risked duplicate billable work. Reuses a digit-boundary status
  matcher exported from errhint (HasStatusCode). Test asserts 504/500 stay
  non-reconnectable.

- tui /edit: re-stage the remembered image/PDF snapshot alongside the
  recalled prompt text, mirroring the /retry fix — editing a vision- or
  document-backed prompt no longer silently resends a text-only version.

- compaction recent-edits: order edits by LAST edit, not first, and move a
  re-touched path to the newest position on merge, so the maxRecentEdits
  tail cap keeps the file the model most recently edited instead of dropping
  it. Adds mergeRecentEdits (edit-specific) and a capped-list regression.

- coalescer test: inject the frame timer via afterFunc so
  TestCoalescerBatchesDeltas proves buffering deterministically instead of
  racing the real 16ms wall-clock timer.

* fix(tools): bound bash output capture in memory, not just model-visible text

Previously stdout/stderr streamed into unbounded bytes.Buffers and were only
truncated to the 96 KiB budget AFTER the command finished, so a runaway command
(cat huge.log, yes) could grow Zero's memory until it stalled or OOMed before
budgetBashOutput ever ran. Replace the capture with boundedBuffer, an io.Writer
that keeps only the head+tail each stream will surface and discards the middle as
it arrives, while counting the true total for the truncation marker. Memory is now
bounded to ~head+2×tail per stream regardless of output size.

truncateHeadTail is refactored onto a total-aware core so the string path (and its
tests) are unchanged, and budgetBashCapture reports the true raw_bytes even though
only a bounded slice was held. Adds boundedBuffer/capture unit tests and an
end-to-end test that streams ~5× the budget and asserts bounded emission with an
accurate raw_bytes.
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.

3 participants