Skip to content
pi-c Artifact [3c0336a297]
Login

Artifact [3c0336a297]

Artifact 3c0336a29721c98a5c41e13e35c2343101d6e9920c723b11cfd6eb01222b55ce:


pic implementation plan

Replaces the earlier 11-stage plan (preserved in history at check-in 11f47eadde20), which assumed an embedded context core and front-loaded qualification work. Decisions in force:

Stages

  1. Durable loop: done. Merged at f4faaeff6422. Journal, idempotent admission, replay-safe vs replay-unsafe effects, supervised exec, single-writer fencing, 26-case crash suite (make test-pic).
  2. Real provider: next, detailed below.
  3. Usable tool set and context assembly. read/edit/grep/ls, output limits, cancellation, system prompt and project instructions. Exit: you complete a real task in it.
  4. Sessions. Resume, fork, compaction; the ctx outbox plus ctx ingest upstream (file the ctx issue with real sample records from stage 3 sessions).
  5. Clients and release. print/JSON mode, then TUI; release qualification with PGO, Fil-C, and MC/DC on the journal and parsers only.

Stage 2: real provider

Goal: pic run --provider anthropic completes a small task against the live API with the existing write/exec tools, and survives a crash at any point, including mid-stream.

Protocol: Anthropic Messages, streaming SSE, anthropic-version: 2026-10-21. Default model claude-opus-5-5, overridable with --model. That model always thinks: omit thinking; set output_config.effort. max_tokens 64000. Tools are sent with eager_input_streaming: true, so pic validates every tool input itself before running it. Server-side fallbacks are on by default (anthropic-beta: server-side-fallback-2026-07-01, "fallbacks": "default"). stop_reason refusal ends the turn with an error answer, never a tool run. max_tokens ends it as an incomplete answer.

Modules:

Journal changes:

Mid-stream crash semantics: a provider request is a billed, replay-unsafe effect, but it has no outside-world side effect, so re-requesting is safe; it only costs money. Decision: the partial stream is never journaled. On recovery, a started generation is marked failed (interrupted) and the turn is re-requested, up to 3 attempts per turn, after which the submission stops with an error. Attempts and any usage seen are recorded, so the cost of a crash is visible. Incremental persistence of partial output is deferred to stage 5, where clients need it.

Credentials: the API key comes from ANTHROPIC_API_KEY only (ant profiles later). It lives in memory for one request, is never journaled, logged, or put in error text, and request headers are never stored. A test runs with a sentinel key and fails if the bytes appear anywhere in the database, WAL, or output.

Tests (exit criteria):

Out of scope: OpenAI-family decoders (a second decoder later on the same framer), prompt caching tuning, message threads, compaction, token counting.