@@ -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
1313The codebase uses ` AgentVariationStep ` enum:
1414``` typescript
1515export 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.
0 commit comments