Skip to content

Commit a99540e

Browse files
V48 (specification-implementation): FailsafeGeneration / ThinkingsGeneration hierarchy names
Retire legacy SubStep/Meta vocabulary for Generation-within-Step: - FailsafeMetaSubStep → FailsafeGeneration (enum + BC alias) - GenerationSubMetaSubStep → ThinkingsGeneration (enum + BC alias) - SubStepExecution → GenerationExecution; Failsafe/Thinkings execution subclasses - FailsafeGenerationPrompt / ThinkingsGenerationPrompt (prompt BC aliases) - PTRRStepGenerationArchitecture; docs (FAMILIARIZATION, TERMINOLOGY, NOTES) Hierarchy: Generation → FailsafeGeneration | ThinkingsGeneration → PTRRAgent steps.
1 parent 8daa62a commit a99540e

19 files changed

Lines changed: 429 additions & 378 deletions

File tree

BITCODE_SPEC_V48_NOTES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,21 @@ not provider packages.
16181618
HostKind `local` replaces `inline` (BITCODE_PIPELINE_HOST; `inline` accepted as alias).
16191619
Spec G3-4 tables updated to LocalHost / hostKind `local`.
16201620

1621+
## Generation vocabulary: FailsafeGeneration / ThinkingsGeneration (Garrett, 2026-07-13)
1622+
1623+
Legacy `FailsafeMetaSubStep` / `GenerationSubMetaSubStep` / `SubStep` naming retired
1624+
for active vocabulary. SubStep was the old term for Generation within a PTRR step;
1625+
Meta is not a term.
1626+
1627+
```
1628+
Generation (primitive)
1629+
→ FailsafeGeneration # PCC / ChunkThenSum / Stitch kinds
1630+
→ ThinkingsGeneration # Reason → Judge → StructuredOutput kinds
1631+
```
1632+
1633+
BC aliases remain on enums and execution classes. Prefer hierarchy names in new code.
1634+
Architecture interface: `PTRRStepGenerationArchitecture`.
1635+
16211636
## Host vocabulary: no "Harness" for Host (Garrett, 2026-07-13)
16221637

16231638
Product/runtime Host-domain identifiers no longer use the word **Harness**

FAMILIARIZATION.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,43 +139,53 @@ Package paths: `packages/measurement-generics/`, `packages/generic-measurements/
139139
Hierarchy names: `Measurement``AbsolutesMeasureAgent`
140140
`SynthesizeAssetPacksAbsolutesMeasureAgent`.
141141

142-
### 3.1.2 Generations (failsafes + thinkings)
142+
### 3.1.2 Generations (FailsafeGeneration + ThinkingsGeneration)
143143

144144
```
145-
@bitcode/generation-generics Generation type + failsafe/thinkings enums
145+
Generation # primitive (@bitcode/generation-generics)
146146
147-
@bitcode/generic-generations-failsafes failsafes/ — prepared-context types + base
148-
@bitcode/generic-generations-thinkings thinkings/ — ReasonJudge→StructuredOutput base
147+
FailsafeGeneration # base kinds: PCC / ChunkThenSum / Stitch
148+
ThinkingsGeneration # base kinds: ReasonJudge → StructuredOutput
149149
150-
@bitcode/agent-generics Agent primitive (factoryAgent, factoryQuickAgent, substeps)
150+
@bitcode/generic-generations-failsafes failsafes/ — prepared-context + Failsafe surface
151+
@bitcode/generic-generations-thinkings thinkings/ — Thinkings vocabulary surface
151152
152-
@bitcode/generic-agents-ptrr PTRRAgent base (Plan→Try→Refine→Retry)
153+
@bitcode/agent-generics Agent primitive; LLM-bound generation factories
153154
154-
@bitcode/generic-agent-* / product agents specialized prompts/tools (no PTRR reimplementation)
155+
@bitcode/generic-agents-ptrr PTRRAgent steps compose Failsafe + Thinkings
156+
157+
product agents specialized prompts/tools (no reimplementation)
155158
```
156159

157160
Package paths: `packages/generic-generations/{failsafes,thinkings}/`,
158161
`packages/generic-agents/PTRR/`.
159162

160163
**PTRR** (Plan / Try / Refine / Retry) is the base Agent step model
161-
(`@bitcode/generic-agents-ptrr`). Each step runs a **Failsafes** sequence:
164+
(`@bitcode/generic-agents-ptrr`). Each step runs **FailsafeGeneration** kinds:
162165

163166
1. **PrepareConciseContext** — select execution-state *keys* (not values)
164167
2. **ChunkThenSum** — task generation; chunk only if request too large
165168
3. **StitchUntilComplete** — repair schema-incomplete/truncated output
166169

167-
Each failsafe’s generation is **Thinkings**: Reason → Judge → StructuredOutput.
170+
Each FailsafeGeneration runs **ThinkingsGeneration**: Reason → Judge → StructuredOutput.
171+
Tools run after failsafes (postprocess).
172+
173+
**Legacy naming (BC only):** `FailsafeMetaSubStep`, `GenerationSubMetaSubStep`, `SubStep`
174+
SubStep was the old term for Generation within a Step; Meta is not a term. Prefer
175+
`FailsafeGeneration` / `ThinkingsGeneration`.
168176

169177
Prepared-context types (`PreparedContext`, `prepareConciseContext`, …) live with
170-
**failsafes** (`@bitcode/generic-generations-failsafes`), not a free-floating
171-
context domain. `@bitcode/context` retains only process-global `GlobalContext`
172-
(+ BC re-exports of failsafe prepared-context helpers).
178+
**failsafes** (`@bitcode/generic-generations-failsafes`). `@bitcode/context` retains
179+
only process-global `GlobalContext` (+ BC re-exports of failsafe helpers).
173180

174181
LLM-bound failsafe/thinkings **factories** still execute via `AgentExecution`
175182
inside `agent-generics` until inverted onto pure Execution + LLM registry.
176183

177-
| Layer | Type name | Factory |
184+
| Layer | Type name | Factory / kinds |
178185
| --- | --- | --- |
186+
| Primitive | `Generation` | typed Executor |
187+
| Base | `FailsafeGeneration` | PCC / ChunkThenSum / Stitch kinds |
188+
| Base | `ThinkingsGeneration` | Reason / Judge / StructuredOutput kinds |
179189
| Primitive | `Agent` | `factoryAgent`, `factoryQuickAgent` |
180190
| Base + primitive | `PTRRAgent` | `factoryPTRRAgent` (`factoryAgentWithPTRR` BC) |
181191
| Specific | product agents | specialized configs over `factoryPTRRAgent` |
@@ -736,8 +746,8 @@ Land the edit with the structural change (same commit or accompanying
736746
| Execution | Accumulating hierarchical state for a run |
737747
| PhaseDelegator | Pipeline phase that resolves/runs agents |
738748
| PTRR | Plan-Try-Refine-Retry agent steps |
739-
| Thinkings | Reason → Judge → StructuredOutput generations |
740-
| Failsafe | PCC / ChunkThenSum / Stitch context&size&schema guards |
749+
| ThinkingsGeneration | Reason → Judge → StructuredOutput (children of each FailsafeGeneration) |
750+
| FailsafeGeneration | PCC / ChunkThenSum / Stitch (parents within a PTRR step) |
741751
| Lens / mode | deposit vs read variance on shared SynthesizeAssetPacks |
742752
| Host | Decoupled pipeline host (inline or sandbox) |
743753
| Journal | BTD ledger rows / reconciliation |

internal-docs/TERMINOLOGY.md

Lines changed: 53 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -8,202 +8,89 @@ This guide provides the precise terminology used in the Bitcode codebase, verifi
88

99
### PTRR Pattern (Current Implementation)
1010

11-
**Source**: `/packages/agent-generics/src/types.ts`
11+
**Source**: `/packages/agent-generics/src/types.ts`, `/packages/generic-agents/PTRR`
1212

1313
The codebase uses `AgentVariationStep` enum:
1414
```typescript
1515
export enum AgentVariationStep {
16-
PLAN = 'plan', // Failsafe: understand and strategize
17-
TRY = 'try', // Generation: initial attempt
18-
REFINE = 'refine', // Generation: improve results
19-
RETRY = 'retry' // Failsafe: guaranteed completion
16+
PLAN = 'plan',
17+
TRY = 'try',
18+
REFINE = 'refine',
19+
RETRY = 'retry'
2020
}
2121
```
2222

23-
### Sub-Step Architecture
23+
Preferred factory: `factoryPTRRAgent` (`factoryAgentWithPTRR` is BC).
2424

25-
**CRITICAL**: There are **EXACTLY 7 substeps per step** according to `PTRRSubStepArchitecture` interface.
25+
### Generation hierarchy within a PTRR step
2626

27-
#### Failsafe Meta Sub-Steps (3)
28-
**Source**: `/packages/agent-generics/src/types.ts`
27+
**Source**: `/packages/generation-generics/src/types.ts`
28+
29+
```
30+
Generation (primitive)
31+
→ FailsafeGeneration (base kinds — parents)
32+
→ ThinkingsGeneration (base kinds — children of each failsafe)
33+
```
34+
35+
#### FailsafeGeneration kinds (3)
2936
```typescript
30-
export enum FailsafeMetaSubStep {
31-
PREPARE_CONCISE_CONTEXT = 'prepare_concise_context', // CONTEXT SIGNAL/NOISE handling
32-
CHUNK_THEN_SUM = 'chunk_then_sum', // BIG INPUT handling
33-
STITCH_UNTIL_COMPLETE = 'stitch_until_complete' // CONVERSATIONSUTPUT handling
37+
export enum FailsafeGeneration {
38+
PREPARE_CONCISE_CONTEXT = 'prepare_concise_context', // CONTEXT SIGNAL/NOISE
39+
CHUNK_THEN_SUM = 'chunk_then_sum', // BIG INPUT
40+
STITCH_UNTIL_COMPLETE = 'stitch_until_complete' // BIG OUTPUT repair
3441
}
3542
```
3643

37-
#### Generation Sub Meta Sub-Steps (3)
44+
#### ThinkingsGeneration kinds (3)
3845
```typescript
39-
export enum GenerationSubMetaSubStep {
40-
REASON = 'reason', // Apply reasoning and logic
41-
JUDGE = 'judge', // Judge quality of reasoning
42-
STRUCTURED_OUTPUT = 'structured_output' // Format into typed output
46+
export enum ThinkingsGeneration {
47+
REASON = 'reason',
48+
JUDGE = 'judge',
49+
STRUCTURED_OUTPUT = 'structured_output'
4350
}
4451
```
4552

46-
#### Tool Execution (1)
47-
- `tools_execution` - Direct tool invocation
53+
#### Tools (1)
54+
- `tools_execution` — after all failsafes
4855

49-
**Total**: 3 + 3 + 1 = 7 substeps per PTRR step
56+
**Total per PTRR step**: 3 FailsafeGenerations × Thinkings composition + tools postprocess.
57+
58+
Architecture interface: `PTRRStepGenerationArchitecture`.
59+
60+
### Legacy names (do not use in new code)
61+
62+
| Legacy | Prefer |
63+
| --- | --- |
64+
| `FailsafeMetaSubStep` | `FailsafeGeneration` |
65+
| `GenerationSubMetaSubStep` | `ThinkingsGeneration` |
66+
| `SubStep` / `SubStepExecution` | `Generation` / `GenerationExecution` |
67+
| `FailsafeExecution` | `FailsafeGenerationExecution` |
68+
| `PTRRSubStepArchitecture` | `PTRRStepGenerationArchitecture` |
69+
| `FailsafeMetaSubStepPrompt` | `FailsafeGenerationPrompt` |
70+
| `AgentGenerationSubStepPrompt` | `ThinkingsGenerationPrompt` |
71+
72+
"SubStep" was the old term for Generation within a Step. "Meta" is not a term.
5073

5174
## Prompt System
5275

5376
### PromptPart
5477
**Source**: `/packages/prompts/src/parts/PromptPart.ts`
5578
- Branded string type: `string & { readonly __brand: 'PromptPart' }`
5679
- Created via `createPromptPart(content: string): PromptPart`
57-
- Zero runtime overhead
5880

5981
### Prompt Class
6082
**Source**: `/packages/prompts/src/prompt.ts`
6183
- Registry-based formatting system
6284
- Hierarchical path organization
63-
- Validates required parts
64-
65-
### Naming Conventions
66-
67-
#### File Naming Pattern (DOCUMENTED but NOT ENFORCED)
68-
Documentation claims this pattern:
69-
```
70-
promptpart_[generic|specific]_[domain]_[PROMPTCLASSNAME]_[semanticcontext]_[POSITION].ts
71-
```
72-
73-
**REALITY**: Multiple patterns exist in `/packages/prompts/src/raw_promptparts_promptparts/`:
74-
- `prompt_generic_*.ts` (e.g., `prompt_generic_and.ts`)
75-
- `engi_system_prompt_*.ts` (e.g., `engi_system_prompt_core_identity.ts`)
76-
- Simple names (e.g., `assumption_validation.ts`)
77-
- `patch_*.ts` files (52+ patch files)
78-
79-
## Doc-Comment System
80-
81-
### Current Implementation Status
82-
83-
**✅ Implemented**:
84-
- Doc-comment parser exists (`/packages/doc-comment/`)
85-
- Plugin system with base classes
86-
- TypeScript transformer factory created
87-
- Individual plugins (doc-prompt, doc-promptpart, etc.)
88-
89-
**❌ NOT Implemented**:
90-
- Transformer not integrated in build process
91-
- Automatic prototype injection not active
92-
- Runtime access functions don't exist
93-
- Build-time processing is aspirational
94-
95-
### Available Annotations
96-
97-
#### @doc-promptpart
98-
Version tracking for PromptParts (plugin exists)
99-
100-
#### @doc-code-tool
101-
Used in MCP tools with `DocCodeToolPrompt` class pattern
102-
103-
#### @doc-prompt
104-
Core prompt intelligence (plugin exists)
105-
106-
## Tool Architecture
107-
108-
### Tool Class Pattern
109-
**Source**: `@bitcode/tools-generics`
110-
- Abstract base class with `.use = primitiveFunction` pattern
111-
- MCP tools have `DocCodeToolPrompt` class with @doc-code-tool
112-
- No more cast patterns from 'ai' package
113-
- ToolUse (plans) → UsedTool (results)
114-
115-
## Agent Architecture
116-
117-
### Agent Interface
118-
**Source**: `/packages/agent-generics/src/types.ts`
119-
```typescript
120-
export interface Agent<TInput = any, TOutput = any> extends Executor<TInput, TOutput>
121-
```
122-
123-
### Agent Prompts
124-
- **NO @doc-code-agent** - This annotation doesn't exist
125-
- Agents use `Prompt` class with PromptParts
126-
- All agents use `new Prompt()` pattern for PTRR steps
127-
128-
## Package Structure
129-
130-
### Execution Packages
131-
- `/packages/execution-generics/` - Base Execution and Executor types
132-
- `/packages/agent-generics/` - Agent implementation with PTRR
133-
- `/packages/tools-generics/` - Tool abstraction
134-
135-
### Prompt Packages
136-
- `/packages/prompts/` - PromptPart and Prompt implementations
137-
- `/packages/doc-comment/` - Doc-comment infrastructure (no implementations)
138-
- `/packages/doc-code/` - Runtime injection system
139-
140-
## Frontend and product surface terms (V48)
141-
142-
Layout contract: `internal-docs/BITCODE_SOURCE_LAYOUT.md`.
143-
144-
### Experiences (7)
145-
146-
Marketing, Packs, Reads, Deposits, Docs, Conversations, Auxillaries — each with
147-
matching component prefixes (`Marketing*`, `Packs*`, …) under
148-
`uapi/components/<experience>/`.
149-
150-
### Component layers
151-
152-
- `Shadcn*` — root primitives (`uapi/components/shadcn/`).
153-
- `Bitcode*` — shared base over Shadcn (`uapi/components/bitcode/`).
154-
- Experience prefixes — page-specific composition over Bitcode.
155-
156-
### Component unit
157-
158-
Non-trivial UI lives in `ComponentName/ComponentName.tsx` (not `index.tsx`) with
159-
optional co-located `hooks/`, `styles/`, `__tests__/`.
160-
161-
### Pipeline vs Execution vs Terminal
162-
163-
| Term | Meaning |
164-
| --- | --- |
165-
| **Pipeline** | Product run surface: synthesis/read runs, master-detail tables, stream/log, selection (`BitcodePipeline*`). |
166-
| **Execution** (agent packages) | Low-level PTRR/agent executor primitives in packages such as `execution-generics`. Not the product UI name. |
167-
| **Journal / transaction** | BTD ledger journal rows and reconciliation vocabulary (`JournalEntry`, journal transaction kinds). |
168-
| **Terminal** | **Deleted**. No `/terminal` route or `app/terminal` tree. Do not reintroduce. |
169-
170-
### ❌ NEVER Use These Terms:
171-
- "FAILSAFE GROUP" or "GENERATION GROUP" - Use the actual enum names
172-
- "PTRRStep" - It's `AgentVariationStep`
173-
- "FailsafeSubStep" - It's `FailsafeMetaSubStep`
174-
- "GenerationSubStep" - It's `GenerationSubMetaSubStep`
175-
- "@doc-code-agent" - This doesn't exist
176-
- "Former patterns" - Just document current state
177-
- New product UI named "Terminal" or product-facing "Executions page" for pipeline runs
178-
179-
### ✅ ALWAYS Use These Terms:
180-
- `AgentVariationStep` for PTRR steps
181-
- `FailsafeMetaSubStep` for failsafe operations
182-
- `GenerationSubMetaSubStep` for generation operations
183-
- Exact class/type/enum names from source
184-
- File paths when referencing code
185-
- **Pipeline** for product run surfaces; **journal** for BTD ledger rows
186-
187-
## Mathematical Foundation
188-
189-
The documentation describes this unification theorem, though it's more philosophical than implemented:
190-
191-
```
192-
THEOREM: Finite(Type) ∪ Infinite(Prompt) = Unified(Program)
193-
```
194-
195-
This represents the aspiration that TypeScript types can carry prompt intelligence through doc-comments, though the build-time transformation is not currently active.
196-
197-
## Key Takeaway
198-
199-
Always verify documentation against source code. The Bitcode codebase has evolved rapidly, and documentation often describes aspirational states rather than current implementation. When in doubt:
20085

201-
1. `grep` for the actual usage
202-
2. Check the exports in package index files
203-
3. Look at real implementations, not just interfaces
204-
4. Verify enum values match documentation claims
86+
### Generation prompt levels
87+
1. `AgentPrompt` — name + identity
88+
2. `AgentStepPrompt` — Plan/Try/Refine/Retry purpose
89+
3. `FailsafeGenerationPrompt` — failsafe handling instruction
90+
4. `ThinkingsGenerationPrompt` — Reason/Judge/Output instruction
91+
5. `ToolExecutionPrompt` — tool postprocess
20592

206-
---
93+
## Hosts
20794

208-
*Last Updated: 2026-07-11*
209-
*Version: Aligned to V48 frontend component + Terminal eradication workstream*
95+
Use **Host** for pipeline execution boxes (LocalHost, SandboxHost). Do not use
96+
"Harness" for Host.

packages/agent-generics/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
# Agent Generics
22

3-
Agent **primitives**: execution, registries, substeps, `factoryAgent` / `factoryQuickAgent`.
3+
Agent **primitives**: execution, registries, generation-layer factories,
4+
`factoryAgent` / `factoryQuickAgent`.
45

56
## Hierarchy
67

78
```
8-
@bitcode/agent-generics # this package (Agent primitive)
9+
Generation / FailsafeGeneration / ThinkingsGeneration # generation-generics
10+
11+
@bitcode/agent-generics # this package (Agent primitive + LLM-bound factories)
912
1013
@bitcode/generic-agents-ptrr # PTRRAgent base (Plan→Try→Refine→Retry)
1114
1215
product / generic-agent-* # specialized agents
1316
```
1417

18+
Within each PTRR step: **FailsafeGeneration** ×3 (each runs **ThinkingsGeneration**
19+
Reason→Judge→StructuredOutput) + tools postprocess.
20+
21+
Legacy `*MetaSubStep` / `SubStep` names are BC aliases only — prefer
22+
`FailsafeGeneration` / `ThinkingsGeneration` / `GenerationExecution`.
23+
1524
PTRR base factories (`factoryPTRRAgent` / BC `factoryAgentWithPTRR`) live in
1625
`@bitcode/generic-agents-ptrr` and are re-exported here for compatibility.
1726

1827
## Quick vs. PTRR Agents
1928

20-
- **PTRRAgent** (`@bitcode/generic-agents-ptrr`): sequences Plan → Try → Refine → Retry. Each generation uses the 3×3 failsafed generation pattern by default.
29+
- **PTRRAgent** (`@bitcode/generic-agents-ptrr`): sequences Plan → Try → Refine → Retry. Each step uses FailsafeGeneration × ThinkingsGeneration by default.
2130
- **QuickAgent** (this package): Minimal, single‑generation agent for setup/utility behaviors where PTRR is unnecessary.
2231

2332
Create a QuickAgent:

0 commit comments

Comments
 (0)