@@ -166,10 +166,13 @@ Accepted V48 architecture law (decided 2026-06-25):
166166 Pipeline+Phase+Agent+Step+Generation and runs on the formal primitives, not
167167 hand-rolled inference: ` PipelineExecution ` -> phase -> ` factoryAgent ` /
168168 ` factoryAgentWithPTRR ` -> step -> Failsafe(prepare|chunk|stitch) of
169- Thricified(reason|judge|structured_output). The pipeline is N agents
169+ ** Thinkings** (reason|judge|structured_output) — renamed from "Thricified"
170+ (2026-07-02): the reason and judge[ -reasoning] generations are the thinking
171+ generations of that sequence. The pipeline is N agents
170172 (mostly PTRR, some Simple — both are base ` Agent ` implementations) across the
171- 5 phases; each PTRR agent renders 4 steps x 3 failsafe x 3 thricified = 36
172- formal LLM calls. Every call renders in the rich SDIVF telemetry with correct
173+ 5 phases; each PTRR agent renders 4 steps x 3 failsafe x 3 thinkings = 36
174+ formal LLM calls (the Failsafes-sequence clarification below revises the
175+ per-step shape to selection → task(×chunks) → repair-only). Every call renders in the rich SDIVF telemetry with correct
173176 phase/agent/step/failsafe/generation labels, because the formal executors
174177 populate the execution state (the lightweight path's ` undefined ` labels were
175178 a symptom of bypassing them).
@@ -431,6 +434,74 @@ Garrett, 2026-06-27):
431434 (` agent-measure-asset-packs-absolutes-for-depositor ` ,
432435 ` agent-measure-asset-packs-needinesses-for-reader ` , etc.).
433436
437+ ### The Failsafes sequence — formal clarification + the PrepareConciseContext contract (Garrett, 2026-07-02)
438+
439+ A Step's generation is the Failsafes sequence: THREE failsafes in fixed order, each
440+ with a DISTINCT trigger and a DISTINCT job. "Thricified" is RENAMED ** Thinkings** —
441+ the atomic typed generation-sequence Reason → Judge → StructuredOutput, named for the
442+ thinking generations (reason and judge[ -reasoning] ) that precede the typed output.
443+
444+ 1 . ** PrepareConciseContext (PCC — the context failsafe; ALWAYS runs; selection-only).**
445+ The pipeline's full execution context accumulates without bound (every phase,
446+ agent, step, and generation stores state below the root), so inference quality
447+ demands state-cleaning: PCC is the FILTER that reduces noisy context to exactly
448+ what the task at hand needs. Its contract:
449+ - INPUT: ` { preparation, system, pipeline_execution_keys } ` where
450+ ` preparation ` = the composed task prompt(s) it is preparing for (pipeline system
451+ prompt + agent system prompt + step prompt — e.g.
452+ ` Implement-WriteAssetPacksDiffs-Refine ` ), ` system ` = PCC's own instructions
453+ (what is PCC requesting to be inferred?), and ` pipeline_execution_keys ` = the
454+ FULL root execution state tree rendered as ** keys only**
455+ (` { phase1: { agent1: { step1: ... } ... } ... } ` ) — never the values.
456+ - OUTPUT: the selected KEYS. PCC's inference is a Thinkings generation against the
457+ key-selection schema — NOT the step's output schema (PCC never attempts the task).
458+ - READ-IN: the harness then reads the VALUES of exactly the selected keys from the
459+ execution state and provides them as the task context to the subsequent
460+ generations (CS, SC).
461+ 2 . ** ChunkThenSum (CS — the input failsafe; trigger = the composed request exceeds the
462+ request/context limit).** Non-triggering (the composed prompt — hierarchical system
463+ prompt + task input including the PCC-selected values — fits the request limit):
464+ exactly ONE Thinkings task generation, no chunking. Triggering: split the selected
465+ context values into chunks that each fit, run the task generation per chunk, then
466+ ONE summing generation over the chunk results.
467+ 3 . ** StitchComplete (SC, ` factoryStitchUntilComplete ` — the output failsafe; trigger =
468+ the response is schema-INCOMPLETE, i.e. missing expected keys of the output schema,
469+ or truncated).** Non-triggering (the response parses complete against the expected
470+ schema): zero additional generations — the CS result passes through. Triggering:
471+ stitch-repair generations, each carrying the EXACT validation failure (the schema
472+ error names the missing/invalid fields — a repair prompted only with "continue"
473+ cannot fix a schema gap), bounded, with the final attempt validated rather than
474+ discarded.
475+
476+ Testing law: CS and SC are each tested on BOTH paths — triggering (input exceeds the
477+ request limit; response missing expected schema keys) and non-triggering (input fits;
478+ response schema-complete) — with deterministic boundary LLM mocks.
479+
480+ AUDIT (2026-07-02, of the shipped implementation vs this contract): SC conforms after
481+ the stitch corrections (schema-incomplete trigger, error-carrying repairs, bounded with
482+ final-attempt validation). PCC and CS do NOT yet conform: PCC snapshots a FIXED set of
483+ root namespaces (repository/source/read/config/attachments/instructions/
484+ evidence_documents/pipeline.input) with full VALUES — no keys-only tree, no selection
485+ inference (its generation runs the step's output schema, producing a discarded full
486+ task attempt), and the deterministic size-based ` prepareConciseContext ` chunker stands
487+ in for selection; CS triggers on that snapshot's serialized size (against the model's
488+ max-OUTPUT tokens, not the request limit) instead of measuring the composed request,
489+ and its chunked path threads the full accumulated input into every chunk call. The
490+ Gate-3 correction aligns the implementation to this contract: PCC becomes the keys-only
491+ selection inference + value read-in; CS measures the actual composed request and chunks
492+ only the selected values; the three failsafes stop wrapping three identical task
493+ generations (the current 3×3 shape) and become selection → task(×chunks) → repair-only.
494+
495+ ** Cross-phase store-visibility law (same decision).** SDIVF phases execute on isolated
496+ sibling child nodes (` seq-N ` ), and ` findUp ` walks ANCESTORS only — so any artifact one
497+ phase produces for another (or for the dispatching route) MUST be stored on the SHARED
498+ outer pipeline execution (the F20 mode-propagation precedent), never on the producer's
499+ own sibling subtree. The 2026-07-02 sweep found the deposit flow violating this
500+ end-to-end (implementation options, discovery comprehensions, preprocess
501+ inventory/exclusions, setup obfuscation guidance — all invisible to their consumers and
502+ to the route's completion read); the Gate-3 correction re-homes cross-phase artifacts
503+ onto the shared execution and pins the producer/consumer store contract with tests.
504+
434505### Failsafe chunk/stitch precision — recursive, size-variable N (later V48 gate roadmap; Garrett, 2026-06-27)
435506
436507The Failsafe substeps ` chunk ` (` factoryChunkThenSum ` ) and ` stitch `
0 commit comments