Skip to content

Week 4 extension: COW/radix cache plan (design only) - #258

Closed
skyzh wants to merge 9 commits into
mainfrom
agent/week4v3-cow-radix-plan
Closed

Week 4 extension: COW/radix cache plan (design only)#258
skyzh wants to merge 9 commits into
mainfrom
agent/week4v3-cow-radix-plan

Conversation

@skyzh

@skyzh skyzh commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Why

Final PR of the 11-PR restacked Week 4 stack: preserve the deferred COW/radix-cache plan as a design-only document, per Chi's instruction. Stacked on the equivalence harness (#257); base branch agent/week4v3-day7-harness @ 5ae28aa.

What changed

  • docs/week4-cow-radix-extension-plan.md (new, design only) — why COW is deferred (a scaling mechanism, not a correctness one), the capabilities it uniquely adds (concurrent divergence, cross-session prefix sharing), a proposed PrefixRegistry/ForkedPrefix API sketch, safety invariants, honest accounting rules, and an evaluation outline. No implementation.
  • docs/week4-day-split.md — the 11-PR feature stack shape with the 7-day teaching mapping (Day 4 = checkpoint + rewind; Day 6 = steering/status + reconcile).

Review note

  • 109/109 week-4 refsol tests pass (unchanged); no code touched in this PR.
  • This completes the eleven-PR stack: reset+starter, loop/tools, receipts, session tree, KV checkpoint, sequential rewind, compaction, steering/status, reconcile, harness, COW plan.

AI-Assisted: DeepSeek V4 Flash + Forge

skyzh added 9 commits August 11, 2026 04:33
PR 3 of the restructured Week 4 stack. Day 2 per docs/week4-day-split.md:
workspace authorization core + immutable effect receipts.

- refsol workspace.py (simplified): bounds, protected/secret path rejection,
  symlink rejection, inspection-before-overwrite with observed digests,
  atomic writes (temp + fsync + rename), default-deny approvals, exact
  command allowlist with timeout, execute dispatch + receipt recording.
  Deliberately no mutation journal / undo / session binding (Day 6's
  exactly-once reconcile replaces that machinery).
- refsol receipts.py: content-addressed EffectReceipt + durable ReceiptStore
  (by_tool_call index, verified expand, tamper fail-closed).
- tests day_3: 22 tests (list/read bounds, unsafe/symlink paths, write/edit
  inspection, approvals, command allowlist, receipts via execute).
  62/62 day-1..3 refsol tests pass; weeks 1-3 unchanged.
Session-tree feature PR (maps into Day 3). session.py only: append-only
SessionLog/SessionStore (fsync-backed, tamper fail-closed), parent_of/
active_path (deterministic root-to-leaf), active_path_events. Pi-inspired
id/parentId tree; event-level only. The loop records into any session-like
object (Day 1 contract); this PR provides the real implementation.
KV-checkpoint feature PR (maps into Day 4). checkpoint.py: CacheManifest
(model/tokenizer/layers/position/prefix/tool-catalog/workspace-fingerprint)
with content-address digest, tamper fail-closed from_dict, require_current;
export_cache_manifest/validate_resume gates. generation.py: GenerationSession
restored with model/tokenizer identity and layer_count (rewind_to arrives in
the sequential-rewind feature PR).
Sequential-rewind feature PR (maps into Day 4). branch.py: SequentialBranch
(checkpoint -> act -> rewind -> do_again) over one GenerationSession with
honest BranchStats. generation.py: rewind_to discards only the divergent
cache tail; the unchanged prefix stays cached and is reused. No COW/registry/
refcounts (deferred to the COW/radix extension).
Receipt-compaction feature PR (maps into Day 5). compaction.py:
compact_tool_results replaces oversized tool-result renderings with verified
receipt handles (canonical bytes stay in the receipt store; durable trace
never mutated); expand_receipt_range/reexpand_receipt_message verify and
re-expand bounded ranges, failing closed on digest/range/handle errors.
receipts.py: compact_rendering keeps the full receipt handle intact so
re-expansion can always verify the content address. The old summarizer-based
ContextManager is not part of the new course.
Steering/status feature PR (maps into Day 6). control.py: CancellationToken
(first-writer-wins cooperative stop) and SteeringHandle (durable queued
steering). status.py: AgentStateCard derived only from the durable event
trace (goal, current action, approval state, last evidence, next safe step,
phase); never hidden chain-of-thought. StatusQuery answers a tool-disabled
paraphrase via sequential snapshot + rewind, leaving the main run unchanged.
…overy

Exactly-once reconcile feature PR (maps into Day 6). reconcile.py:
reconcile_effect/reconcile_interrupted_effects close interrupted tool calls
exactly once from durable receipts keyed to the session tool_call id; orphans
are reported, never guessed or re-run. largest_safe_checkpoint returns the
highest-position manifest passing fail-closed model/tokenizer/geometry/
catalog/workspace checks, else a cold reason.
Equivalence-harness feature PR (maps into Day 7). harness.py: RunSnapshot
(final/reason/completed/tool actions/receipts/observations/approval+world
state/token accounting) and compare_runs with three planes: semantic (final
+ exact tool-action sequence), evidence (receipt IDs + observations), policy
(approval/world state). Token/page/latency gains are reported but never pass
a run whose behavior differs. The old static-held-out grader is not part of
the new course.
COW/radix plan PR (non-day extension). docs/week4-cow-radix-extension-plan.md:
design-only plan for the deferred copy-on-write / radix cache — why it is
deferred (scaling, not correctness), capabilities it uniquely adds
(concurrent divergence, cross-session prefix sharing), proposed API sketch,
safety invariants, honest accounting, evaluation. docs/week4-day-split.md:
11-PR feature stack shape with the 7-day teaching mapping.
@skyzh
skyzh force-pushed the agent/week4v3-cow-radix-plan branch from 563b114 to cc01e8c Compare August 11, 2026 11:33
Base automatically changed from agent/week4v3-day7-harness to main August 12, 2026 13:33
@skyzh

skyzh commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

Closed as superseded by the merged seven-day Week 4 course and the fresh Days 8–9 design. The branch and pull-request history are intentionally preserved. — Forge

@skyzh skyzh closed this Aug 12, 2026
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