docs: close readiness gaps with prototype-validated contracts (§5, §6.1, §6.5, §6.7, §6.9) (#3)
26d6f6ae86cc569aeed22ec189402e91e335badc
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
- Parent 1: 10c3b95879a7
* docs: close §5 readiness gaps — role model, thinking round-trip, error taxonomy
First readiness-gap pass (user decisions applied):
- §5.1 Role slimmed to System|User|Assistant|Tool. ContentBlock is the
authoritative content representation: tool results are Tool-role
messages carrying ToolResult blocks; the ToolResult/Custom/
BashExecution roles are gone. Roles say who speaks; SessionEntry
kinds say what happened — bash executions become a §6.5 entry kind.
- §5.1 Thinking gains opaque provider_metadata (preserved, never
consumed) so signed thinking round-trips across turns (§7.2
adapters attach and replay it).
- §5.2 ProviderEvent payload shapes pinned; ToolCall events are
assembled-complete at the provider boundary. ProviderError kinds
(RateLimit, AuthFailed, Network, ServerError, InvalidRequest,
ModelNotFound, Timeout) declared — §7.5's failover matrix was
spec'd against undeclared types; now keyed to §5.2.
- §5.8 rewritten as the error umbrella: names the wrapped domain
errors at their subsystems and defines the recoverable-vs-fatal
rule (recoverable surfaces as content and the loop continues;
fatal restores the terminal and exits nonzero).
- §6.5 notes new entry kinds are forward-compatible via §6.6
unknown-variant preservation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* docs: define session tree operations (SPEC §6.5)
Second readiness-gap pass (user decisions applied). §6.5 had the data
structure (parent pointers, current leaf) and evidence of operations
(session_before_fork event, fork tests) but never defined them:
- branches are emergent (root->leaf paths), never stored or named;
append-only immutability stated precisely,
- operations: append (implicit fork points at non-leaf appends),
switch leaf, read path, fork (clone-to-new-session, distinct from
in-tree branching),
- LLM context = current path only; sibling branches invisible,
- leaf persistence: leaf switches append a metadata entry (new §6.5
entry kind) — effective leaf on load = last switch or last append;
rides §6.6 append-only recovery, leaf history replayable,
- leaf switches never touch the working tree: filesystem time travel
is time-travel-plugin policy via smith.vcs.op_restore + stored
VcsOpId; conversation navigation alone is never destructive,
- no branch deletion in v1; single writer per session.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* docs: define compaction contract (SPEC §6.9)
Third readiness-gap pass (user decisions applied). Compaction falls out
of the §6.5 immutability decisions: it cannot rewrite history, so it is
a context-assembly-time mask, not a storage mutation.
- storage never shrinks; a pass appends a summary entry recording the
covered span + summary + token estimates,
- context assembly folds the path: covered spans collapse into their
summary, trimmed content into stubs; the file is untouched,
- branching needs no special case: pre-compaction leaf switches see
full history (eligible to re-compact); post-compaction branches
inherit the mask,
- trigger: estimated folded-path tokens exceed a named config threshold
(fraction of context window minus output reserve; reloadable),
- trim ladder: old tool-result bodies -> old thinking blocks -> LLM
summarization of the oldest span,
- summarization model: active model unless compaction_model config key
overrides (resolved via §5.7); usage tracked as normal cost,
- survives verbatim: secret registrations, system prompt snapshot,
prior summaries, and a token-budget recency window (fraction of the
context window, adapting to model size),
- session_before_compact may veto/adjust span/replace prompt.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* docs: define secret proxy contract (SPEC §6.7)
Fourth readiness-gap pass (user decisions applied): registry-only
detection, masked display, detection mechanisms are plugin territory.
- core owns masking mechanics only; detection mechanisms (pattern-based
or otherwise) are plugins using smith.secret.register through the
§9.8 input/tool_result hooks,
- ordering mechanic that enables detection plugins: the ingestion scan
runs after plugin hooks, so values registered while inspecting
content are masked in that same content,
- registration paths: auto (auth resolver credentials; manifest
declared-secrets read via SDK), explicit (/secret built-in), plugins
(smith.secret.* — list() returns labels/ids, never plaintext),
- plaintext lives in exactly one entry kind (secret registration);
all other content stores smith:sec:N placeholders from ingestion,
- rehydration at exactly one layer: immediately before tool execution;
provider requests/traces/events stay masked; replay-compare
rehydrates from registration entries; unknown ids pass through,
- TUI renders placeholders masked with label,
- limits stated: unregistered secrets are unprotected by design (§11).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* docs: define steering/follow-up semantics and input queue UX (SPEC §6.1, §8.11)
Fifth readiness-gap pass (user's UX design applied). Core semantics
(§6.1):
- follow-up: FIFO, consulted instead of agent_end — dequeues as a
fresh user message and starts a new turn cycle,
- steering: delivers at the next safe boundary (stream end or current
tool completion); pending tool calls resolve as synthetic
error-flagged "skipped: user steered" results so every wire call has
a result; queued steers drain FIFO before the next provider call,
- input during a run steers by default, modifier submits follow-up;
plugins override via the input hook / smith.send_message,
- queues are ephemeral: entries recorded on delivery only; compaction
neither consumes nor drops queues; after an abort the remainder
stays queued for the user to send, edit, or discard.
Input queue UX (new §8.11; deferred scope bumped to §8.12):
- one visually combined queue, follow-ups above steers (steers nearest
the input — they deliver soonest), oldest-to-newest per kind,
visually distinct kinds,
- promote/demote toggles a message between steer and follow-up,
- Up-arrow cycles the queue; editing temporarily removes the message,
re-send returns it to its previous position (best effort), re-send
empty deletes it,
- cancel keys pop queued messages newest-to-oldest instead of their
default action while the queue is non-empty; abort only on empty
queue.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* docs: add prototype plan for campaign 2 (p12-p14)
The readiness passes added contracts (§5, §6.1, §6.5, §6.7, §6.9)
without prototype evidence. New targets validate their risky cores:
- p12 session-tree-fold: emergent branches, leaf-switch persistence
under §6.6 recovery, assembly-time compaction folding, and the
branch-past-compaction property; hunts fold edge cases (spans
crossing fork points, nested summaries),
- p13 secret-proxy-mechanics: ingestion masking, hook-then-scan
ordering with a real Lua detector plugin, tool-boundary rehydration,
resume rebuild; hunts overlapping-secret edge cases,
- p14 steering-queue: boundary delivery, synthetic skipped results,
FIFO drain, follow-up-instead-of-agent_end, abort-keeps-queue;
reports the parallel-tool boundary ambiguity.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* feat(prototypes): p13 secret proxy mechanics — PASS with findings
Proves SPEC §6.7: ingestion masking (plaintext bytes exist exactly once
in the file — in the registration entry, byte-scan verified), hook-then-
scan ordering with a real Lua detector plugin (value registered during
a tool_result hook is masked in the content that surfaced it),
rehydration as a view at the tool-execution boundary only (Rust and Lua
alike), unknown-id passthrough, resume rebuild with original ids.
Findings for §6.7 (1×P1, 3×P2):
- masking order MUST be longest-match-first, single left-to-right pass
never rescanning emitted placeholders — naive order provably leaks a
'-123' residue of the longer secret (P1),
- placeholder-grammar registered values alias legit placeholders;
single-pass rehydration is load-bearing (a second pass exposes an
unrelated secret's plaintext),
- scan is post-transform only: a hook that re-encodes a secret launders
it past exact matching — deliberate limit, must be stated,
- resume must restore the id allocator past max-seen (reuse would
alias), duplicate registration is idempotent, placeholder ids parse
as maximal digit runs (smith:sec:12 != id 1 + '2').
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* feat(prototypes): p14 steering queue — PASS with findings
Proves SPEC §6.1: boundary delivery (stream end / current tool
completion, never interrupting), synthetic skipped results for every
unexecuted call, FIFO steer drain before the next provider call,
follow-up-instead-of-agent_end, delivery-time-only entry recording,
abort-keeps-queue with intact snapshots.
Findings for §6.1 (2×P1, 2×P2, 1×P3):
- parallel boundary must be WAIT-FOR-ALL-IN-FLIGHT: once a steer is
queued no new call starts, started calls run to completion,
never-started calls skip — "currently executing tool" is ill-defined
with N in flight (P1),
- transcript rule: synthetics sort AFTER all real results (which may be
in completion order), synthetics themselves in original call order,
steer messages follow (P1),
- mid-stream steer: ALL calls of that assistant message skip, none
executes — the coherent reading, but must be stated,
- skipped calls emit §6.4-style Start/End(is_error) events,
- abort leaves a dangling tool-call tail in the session; resume must
tolerate or repair it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* feat(prototypes): p12 session tree fold — PASS with disproof
Proves SPEC §6.5/§6.9 composite: tree ops (implicit fork points),
append-only leaf-switch persistence under §6.6 recovery, assembly-time
folding (span collapse, trim stubs, byte-identical storage), and
branch-past-compaction (pre-compaction switch sees full history and
re-compacts as a SIBLING summary; post-compaction branches inherit the
mask).
DISPROOF (P1): §6.5's literal leaf-load rule ("last leaf-switch target,
else last append") yields a stale leaf whenever appends follow the last
switch. Correct rule: replay entries in file order — append moves the
leaf to itself, switch to its target; last surviving entry decides;
dangling switch targets ignored.
Findings:
- §6.9×§6.7 contradiction (P1): registrations hold plaintext, so
"survives verbatim" must mean structural survival (hoisted from
collapsed spans) with masked/excluded provider rendering,
- span well-formedness: contiguous ancestor segment; violations are
file damage — ignore summary, show raw, diagnose,
- nested summaries are inevitable (re-compaction covers the prior
summary); outermost-wins; "survives verbatim" scopes to the trim
ladder only,
- §6.6 corrupt-skip can orphan children / dangle switches: detach-and-
report orphans, ignore dangling switches on replay,
- metadata entries inside covered spans fold away safely (leaf replay
reads raw storage, never the fold).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
* docs: fold campaign-2 prototype evidence into SPEC
All three campaign-2 prototypes complete (result blocks in PLAN.md).
Evidence-driven fixes:
§6.5 (p12): leaf-load rule CORRECTED — the shipped rule was disproven
(stale leaf when appends follow a switch); now replay-in-file-order,
last surviving entry decides, dangling switch targets ignored. Orphan/
dangling recovery rules added (detach-and-report, never silently graft).
§6.9 (p12): fold rules pinned — span well-formedness (contiguous
ancestor segment; violations ignored with diagnostic, never partial
collapse), nested summaries outermost-wins (nesting is inevitable via
re-compaction), metadata entries fold away safely, sibling summaries on
re-compacted branches. "Survives verbatim" rescoped to the trim ladder;
secret registrations survive STRUCTURALLY but are masked in provider
rendering — fixes the §6.9x§6.7 plaintext-to-LLM contradiction (P1).
§6.7 (p13): longest-match-first single-pass masking (any other order
leaks overlap residue — P1), single-pass rehydration, placeholder-
grammar registrations rejected, idempotent re-registration, maximal-
digit-run parsing, allocator resume past max id, post-transform-only
scan limit stated.
§6.1 (p14): parallel steering boundary pinned to wait-for-all-in-flight
(P1), transcript ordering reals-then-synthetics-then-steers (P1),
mid-stream steer skips all calls, skipped calls emit §6.4-style events,
dangling tool-call tail after abort repaired at next request assembly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB
---------
Co-authored-by: Claude <noreply@anthropic.com>