Repository navigation
Closed
Description
Problem
PR #504 implements Checkpoints with two design decisions that should be revisited:
- Transcript source: Currently extracts from Claude Code's
~/.claude/projects/JSONL files. This couples us to Claude Code's internal file format, which can change without notice and is not a stable API surface. - Checkpoint granularity: Currently captures one checkpoint per push. A push can contain multiple commits, so the checkpoint-to-commit linkage is imprecise — reasoning for individual commits is conflated.
Proposed Migration
Per-Commit Granularity
Switch from per-push to per-commit checkpoint creation:
- One checkpoint per commit — finest granularity, highest storage, most traceable
- Each commit SHA maps to exactly one checkpoint, making it possible to trace the reasoning behind any individual change
- The gateway push handler already receives the list of commits in a push; iterate over each and create a checkpoint per commit
- Storage cost increases linearly with commit count, but checkpoint data compresses well and the dedicated branch keeps main clean
Changes required:
gateway/checkpoint_handler.py: Iterate over commits in the push and create one checkpoint per commit instead of one per push- Checkpoint schema: Ensure
commit_shais a single value (not a list) — currently correct - CLI:
egg-checkpoint show <sha>already works per-commit;listshould show one entry per commit
Anthropic API Proxy Instrumentation
Replace Claude Code JSONL extraction with Anthropic API proxy instrumentation as the transcript source:
- Capture from API traffic — intercept request/response pairs at the proxy layer between the sandbox and the Anthropic API
- Format-independent: works regardless of which client (Claude Code, custom scripts, direct API calls) generates the traffic
- The proxy already exists in the architecture for network filtering; adding instrumentation captures transcripts at the source of truth
- Produces a clean, well-structured transcript since the API request/response format is stable and documented
Changes required:
- New proxy instrumentation layer to capture API request/response pairs (messages, tool use, token counts)
- Replace
shared/egg_contracts/transcript_extractor.py(currently parses Claude Code JSONL) with a new implementation that reads from proxy-captured data - Define a storage/buffering mechanism for captured API traffic (e.g., write to a local file per session, keyed by container ID)
- Gateway checkpoint handler reads from proxy-captured data instead of Claude Code project files
- Redactor (
shared/egg_contracts/redactor.py) still applies — input/output content needs the same secret scrubbing
What Stays the Same
- Checkpoint schema (
.egg/schemas/checkpoint.schema.json) — no structural changes needed - Storage on
egg/checkpoints/v1branch — same append-only model - Checkpoint loader and CLI — same interfaces
- Redactor — same redaction patterns, different input source
- Contract integration — same linkage model
Context
- Parent issue: Checkpoints: capture agent session context as versioned data in Git #500
- Current implementation: Add Checkpoints: capture agent session context in Git #504
- The key design questions from Checkpoints: capture agent session context as versioned data in Git #500 listed these as options; Add Checkpoints: capture agent session context in Git #504 chose Claude Code JSONL + per-push. This issue tracks migrating to the per-commit + API proxy instrumentation choices.
Acceptance Criteria
- Each commit produces exactly one checkpoint (per-commit granularity)
- Transcripts are captured from Anthropic API proxy traffic, not Claude Code project files
- Existing checkpoint schema validates without changes
- CLI commands work with per-commit checkpoints
- Redaction still applies to proxy-captured transcripts
- Graceful degradation: if proxy instrumentation fails, push still succeeds
— Authored by egg
Metadata
Metadata
Assignees
Labels
No labels
Activity
Initialize SDLC contract for issue #509
Initialize SDLC contract for issue #509
james-in-a-box commentedon Feb 11, 2026
Draft analysis for issue #509: checkpoint migration
Refine review: approved for issue #509
Agent-mode design review: approved (refine phase, issue #509)
james-in-a-box commentedon Feb 11, 2026
Analysis: Migrate checkpoints to per-commit granularity and API proxy transcript capture
Problem Statement
The current checkpoint implementation (PR #504) makes two design decisions that limit traceability and maintainability:
Per-push granularity: One checkpoint per push operation, even when a push contains multiple commits. This conflates the reasoning behind individual commits, making it impossible to trace exactly what led to a specific change.
Claude Code JSONL dependency: Transcripts are extracted from
~/.claude/projects/{project}/{session}.jsonlfiles, which are internal to Claude Code and can change without notice. This couples the system to an unstable API surface.The desired outcome is:
Current Behavior
Checkpoint Capture Flow (
gateway/gateway.py:683-708)After a successful git push, the gateway:
git rev-parse HEADto get the tip commit SHAcapture_and_store_checkpoint()with only that single SHAKey limitation: Multi-commit pushes only checkpoint HEAD. Commits
HEAD~1,HEAD~2, etc. are not checkpointed.Transcript Extraction (
shared/egg_contracts/transcript_extractor.py)The current extractor:
~/.claude/projects/for JSONL session filesKey limitations:
/→-)Existing Proxy Architecture (
gateway/gateway.py:2689-2840)The gateway already proxies all Anthropic API traffic:
http://egg-gateway:9848/v1/messages(HTTP, no credentials)https://api.anthropic.com/v1/messagesThis provides a single instrumentation point for all API traffic.
Constraints
Technical Constraints
commit_shaas single string) already supports per-commit granularity—no schema changes neededArchitectural Constraints
Dependencies
tests/gateway/test_anthropic_proxy.pyhas 700+ lines of coverageegg-checkpoint show <sha>already works per-commit; minimal CLI changes neededOptions Considered
Option A: Iterate Commits at Push Time + Session Transcript Reuse
Approach: When a push occurs, iterate over all commits being pushed (using
git rev-list) and create one checkpoint per commit. Reuse the same session transcript for all checkpoints.Implementation:
git rev-list {old-sha}..{new-sha}to get all pushed commitscommit_shabut shared transcript contentPros:
Cons:
Option B: API Proxy Instrumentation + Ring Buffer
Approach: Instrument the gateway's Anthropic proxy to capture request/response pairs into a session-scoped ring buffer. On push, create per-commit checkpoints using buffered API traffic.
Implementation:
proxy_anthropic_messages()to capture:/tmp/egg-transcripts/{container_id}.jsonl)Pros:
usagefield in response)Cons:
Option C: Hybrid - Proxy Instrumentation + Commit Markers
Approach: Combine API proxy instrumentation with commit-triggered markers to enable precise transcript segmentation.
Implementation:
git commit, gateway inserts a marker into the buffer with commit SHAgit push, extract transcript segments between markers for each commitPros:
Cons:
git commithandling in gateway (new hook point)Option D: API Proxy Instrumentation + Shared Transcript Reference
Approach: Capture full session transcript via API proxy, store once, and have per-commit checkpoints reference the shared transcript.
Implementation:
transcript_refpointing to session transcriptcommit_offsetfields to indicate rough position in transcriptPros:
Cons:
transcript_reffield)Recommended Approach
Option B: API Proxy Instrumentation + Ring Buffer is recommended, with elements from Option A for the commit iteration.
Rationale
Implementation Phases
Phase 1: Per-Commit Iteration (Low Risk)
gateway/checkpoint_handler.pyto iterate commits viagit rev-listPhase 2: API Proxy Instrumentation (Medium Risk)
proxy_anthropic_messages()ingateway/gateway.py/tmp/egg-transcripts/{container_id}.jsonl)Phase 3: Transcript Source Migration (Medium Risk)
transcript_extractor.pycontent with proxy buffer readercheckpoint_handler.pyto use new sourcePhase 4: Cleanup
Why Not Option C (Commit Markers)?
While Option C provides the most precise segmentation, it requires:
git commitat the gateway (currently only push is hooked)Most sessions have a small number of commits (1-3), and the full session transcript provides sufficient context even without perfect segmentation.
Why Not Option D (Shared Reference)?
While storage-efficient, it:
transcript_reffield)Open Questions
1. Buffer Location and Lifecycle
Where should the proxy transcript buffer be stored, and when should it be cleaned up?
Options:
/tmp/egg-transcripts/{container_id}.jsonl: Simple, auto-cleaned on reboot/var/lib/egg/transcripts/: Persistent, survives restartsRecommendation: Use
/tmp/with explicit cleanup on session end (container stop event).2. Buffer Size Limits
How large should the buffer be allowed to grow before rotation?
Long sessions can generate megabytes of API traffic. Options:
Recommendation: 10MB ring buffer with oldest entries dropped when full.
3. Fallback Behavior
If proxy instrumentation fails or buffer is empty, should we fall back to Claude Code JSONL?
Options:
Recommendation: Graceful fallback during migration period, with metrics to track fallback rate. Remove fallback after 30 days of production stability.
Authored-by: egg
Analysis Phase Complete
The analysis above has passed internal review and is ready for human approval.
View run logs
Ready for Review
Authored-by: egg
11 remaining items
Approve and advance to implement phase for issue #509
james-in-a-box commentedon Feb 11, 2026
Phase plan approved by @jwbron.
Advancing to implement phase.
--- Authored by egg
Populate contract tasks from plan for issue #509
Implement per-commit checkpoint granularity (Phase 1)
Implement API proxy transcript capture (Phase 2)
Migrate transcript source to API proxy buffer (Phase 3)
Update autofix attempts for issue #509
Migrate checkpoints to per-commit granularity with API proxy transcri…
james-in-a-box commentedon Feb 11, 2026
SDLC cleanup completed.
egg/issue-509--- Authored by egg