Skip to content

release v0.0.205: resilient context management and launch kit - #239

Draft
justrach wants to merge 3 commits into
mainfrom
release/v0.0.205
Draft

release v0.0.205: resilient context management and launch kit#239
justrach wants to merge 3 commits into
mainfrom
release/v0.0.205

Conversation

@justrach

Copy link
Copy Markdown
Owner

Summary

  • make context accounting and compaction resilient across Codex WebSocket/SSE turns, retries, provider changes, session restore, and partial responses
  • make compaction transactional, with focused regression coverage for incomplete summaries, server meters, and transport recovery
  • split the six oversized Zig modules into focused source and test modules, with every repository Zig source now below 700 lines
  • add a CI-enforced 699-line source ceiling
  • add the Graff continual-learning launch thread, LinkedIn copy, nine social cards, and the AOS/DGM architecture notes

Why

The mid-turn compaction gate could rely on the local estimate while the server-reported context meter had already crossed the threshold. Chained Responses usage could also diverge from the full retained request, and a failed compaction summary needed stronger transactional isolation so partial mutations never escaped into session history.

Those paths had accumulated inside several 750 to 1,400-line modules, making transport, accounting, and recovery behavior harder to reason about. This release pairs server and local context measurements explicitly, isolates compaction mutations, adds end-to-end regression coverage, and separates the large modules by responsibility.

Impact

  • more reliable automatic compaction and recovery during long Codex sessions
  • accurate context reporting after model/provider changes, resume, and streamed partial turns
  • preserved full-input re-anchoring across WebSocket and SSE fallback
  • smaller Zig modules with stable public APIs and an automated size guard
  • publication-ready release copy and image cards for the continual-learning launch
  • local .codex configuration is now ignored so machine credentials cannot be committed accidentally

Validation

  • Debug: 227/227 Zig tests passed
  • ReleaseFast: 227/227 Zig tests passed
  • ReleaseFast executable build passed
  • JSON live-control protocol: 19/19 passed
  • PTY spinner, REPL, Markdown, model preference, stall/drop, and session persistence suites passed
  • all five Codex WebSocket/SSE transport and compaction scenarios passed
  • fleet score/submit end-to-end test passed
  • all 82 repository Zig sources pass the 699-line guard; largest is 675 lines
  • Zig formatting, Ruff, Python byte-compilation, and git diff checks passed
  • staged Gitleaks scan found no secrets

Relationship to existing work

This branch includes the server-meter fix currently proposed in #236. That PR remains open and overlaps this release PR until it is manually superseded.

justrach and others added 3 commits July 16, 2026 21:42
… the local estimate

The #193 pre-send gate (inputOverCompactThreshold) trusted only the local
byte/4 estimate (fullInputEstimateTokens). On codex/.responses that estimate
structurally under-counts retained encrypted-reasoning items — they're billed
large server-side but are compact base64 handles locally — so on a long single
turn the local estimate stayed under the threshold while the server had already
reported ~511k via last_context_tokens (refreshed mid-turn by
recordUsageResponses). The next resend was then rejected for "input exceeds the
context window" before any compaction ran — the gate had the right answer in
hand and ignored it.

The mid-turn gate now also trips on last_context_tokens — the same accurate
server meter the between-turns gates (mainloop.zig:683/734) already trust:

    if (self.last_context_tokens >= threshold) return true;

Supporting changes:
- The #193 test builds Agent = undefined, so the new last_context_tokens read
  was uninitialized-memory UB; explicitly zero it and add a meter-only case that
  trips the gate with an empty local history.
- fullInputEstimateTokens now falls back to the bytes counted so far on a
  serialize failure (catch return d.fullCount()/4) instead of a spurious 0, so a
  failed serialize can't blind the pre-send gate and the #202 meter floor at once.

zig build clean; 195/195 unit + 19/19 REPL tests green.

Co-authored-by: Codegraff <blackfloofie@codegraff.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