@llm-dev-ops/agentics-cli 2.7.38 → 2.7.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/mcp/mcp-server.js +5 -1
  2. package/dist/mcp/mcp-server.js.map +1 -1
  3. package/dist/pipeline/auto-chain.d.ts.map +1 -1
  4. package/dist/pipeline/auto-chain.js +82 -6
  5. package/dist/pipeline/auto-chain.js.map +1 -1
  6. package/dist/pipeline/exemplars.d.ts +34 -0
  7. package/dist/pipeline/exemplars.d.ts.map +1 -0
  8. package/dist/pipeline/exemplars.js +101 -0
  9. package/dist/pipeline/exemplars.js.map +1 -0
  10. package/dist/pipeline/output-validator.d.ts +38 -0
  11. package/dist/pipeline/output-validator.d.ts.map +1 -0
  12. package/dist/pipeline/output-validator.js +152 -0
  13. package/dist/pipeline/output-validator.js.map +1 -0
  14. package/dist/pipeline/phase2/phases/adr-generator.d.ts.map +1 -1
  15. package/dist/pipeline/phase2/phases/adr-generator.js +21 -3
  16. package/dist/pipeline/phase2/phases/adr-generator.js.map +1 -1
  17. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.d.ts.map +1 -1
  18. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js +17 -5
  19. package/dist/pipeline/phase4-adrs/phase4-adrs-coordinator.js.map +1 -1
  20. package/dist/pipeline/ruflo-phase-executor.d.ts.map +1 -1
  21. package/dist/pipeline/ruflo-phase-executor.js +52 -60
  22. package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
  23. package/dist/synthesis/ask-artifact-writer.d.ts.map +1 -1
  24. package/dist/synthesis/ask-artifact-writer.js +9 -6
  25. package/dist/synthesis/ask-artifact-writer.js.map +1 -1
  26. package/dist/synthesis/simulation-artifact-generator.d.ts.map +1 -1
  27. package/dist/synthesis/simulation-artifact-generator.js +26 -6
  28. package/dist/synthesis/simulation-artifact-generator.js.map +1 -1
  29. package/docs/templates/ADR-Good-Example.md +787 -0
  30. package/docs/templates/Implementation-Prompts-Good-Example.md +1158 -0
  31. package/docs/templates/promotion-changelog.md +94 -0
  32. package/docs/templates/regression-changelog.md +86 -0
  33. package/docs/templates/sparc-specification-good-example.md +600 -0
  34. package/package.json +2 -1
@@ -0,0 +1,600 @@
1
+ # Protein-Engine SPARC Specification
2
+ ### London School TDD / Outside-In Development Plan
3
+ **Version 1.0**
4
+
5
+ ---
6
+
7
+ ## S — Specification
8
+
9
+ ### Problem Statement
10
+
11
+ Build an AI-native, quantum-aware, distributed protein engineering platform packaged as a single `.rvf` cognitive container. The platform must support cellular reprogramming factor design (Yamanaka factors: OCT4, SOX2, KLF4, cMYC), with evolutionary optimization, neural fitness scoring, quantum energy simulation, and cryptographic auditability — deployable identically across Docker, WASM browser, bare-metal, Raspberry Pi, and AI agent (MCP) targets.
12
+
13
+ ### Functional Requirements
14
+
15
+ | ID | Requirement | Acceptance Criteria |
16
+ |----|-------------|---------------------|
17
+ | FR-01 | **Protein variant modeling** — represent sequences, mutations, fitness scores, and lineage as domain types | `ProteinVariant`, `Mutation`, `FitnessScore`, `ExperimentResult` types compile under `no_std` + WASM |
18
+ | FR-02 | **Sequence embedding** — generate 320-dim ESM-2 embeddings per variant | Embedding output matches reference ESM-2 t6 8M within tolerance; stored in VEC_SEG |
19
+ | FR-03 | **Similarity search** — sub-ms HNSW nearest-neighbor lookup across variant embeddings | 99th-percentile latency < 1ms for 100K vectors; INDEX_SEG persists across restarts |
20
+ | FR-04 | **Neural fitness scoring** — predict reprogramming efficiency, expression dynamics, and experimental outcomes | Ensemble (Transformer + LSTM + N-BEATS) returns `FitnessScore` within 100ms on CPU |
21
+ | FR-05 | **Evolutionary optimization** — mutation, crossover, selection loops over variant populations | Population converges over generations; top candidates promoted to HOT_SEG |
22
+ | FR-06 | **Quantum energy simulation** — VQE molecular Hamiltonians, QAOA sequence QUBO | pe-quantum routes to Origin Quantum / IBM / local WASM simulator; VQE snapshots in SKETCH_SEG |
23
+ | FR-07 | **Cryptographic audit trail** — every design, result, and model state is immutable and signed | QuDAG WITNESS_SEG chain verifiable; ML-DSA signatures validate; append-only JOURNAL_SEG |
24
+ | FR-08 | **Multi-agent swarm orchestration** — ephemeral agents per task (sequence-explorer, fitness-scorer, structural-validator, toxicity-screener, experiment-designer, quantum-dispatcher) | Agents coordinate via Synaptic-Mesh; SAFLA closed loop completes design-synthesize-measure-learn-redesign cycle |
25
+ | FR-09 | **RVF packaging** — all segments assembled into a single `.rvf` file | `.rvf` file opens in all 7 deployment targets; MANIFEST_SEG declares capabilities; parent hash lineage intact |
26
+ | FR-10 | **Lab instrument integration** — Opentrons/Hamilton protocol generation and live data ingestion | pe-stream ingests flow cytometry data; instrument-bridge generates valid Opentrons protocols |
27
+ | FR-11 | **WASM browser runtime** — full offline operation from a single file in a browser tab | pe-wasm exposes `score_sequence`, `run_evolution_step`, `run_local_quantum_sim`, `commit_to_ledger` |
28
+ | FR-12 | **MCP agent interface** — Claude Code can operate the entire platform via MCP server | `@ruvector/rvf-mcp-server` exposes all RVF operations; Claude can invoke scoring, evolution, and queries |
29
+
30
+ ### Non-Functional Requirements
31
+
32
+ | ID | Requirement | Target |
33
+ |----|-------------|--------|
34
+ | NFR-01 | WASM bundle size | < 10 MB (microkernel < 6 KB) |
35
+ | NFR-02 | Neural inference latency | < 100ms CPU, no GPU required |
36
+ | NFR-03 | Similarity search latency | < 1ms p99 at 100K vectors |
37
+ | NFR-04 | Post-quantum crypto | ML-KEM + ML-DSA for all signing/encapsulation |
38
+ | NFR-05 | Cross-platform compilation | `no_std` core types; `native` and `wasm` feature flags |
39
+ | NFR-06 | Tamper-evidence | SHA3-hashed journal; ML-DSA signed witness chain |
40
+
41
+ ### Constraints
42
+
43
+ - Language: Rust (2021 edition)
44
+ - All core domain types must be `no_std` compatible
45
+ - Feature flags: `native` (server/Docker) vs `wasm` (browser/edge)
46
+ - External quantum chemistry via Python sidecar (pyChemiQ), not inline
47
+ - Single `.rvf` artifact is the sole deployment unit
48
+
49
+ ---
50
+
51
+ ## P — Pseudocode
52
+
53
+ ### London School TDD: Outside-In Layered Test Strategy
54
+
55
+ Development proceeds **outside-in**, starting from the outermost user-facing boundary (API/CLI/WASM) and driving inward to core domain logic. Each layer defines collaborators as **traits** (interfaces), and inner layers are **test doubles (mocks/stubs)** until implemented.
56
+
57
+ ### Layer 7 → Layer 1 Implementation Order
58
+
59
+ ```
60
+ Outside-In Flow:
61
+ [API/CLI/WASM boundary tests]
62
+ ↓ mock
63
+ [Swarm orchestration tests]
64
+ ↓ mock
65
+ [Neural inference tests]
66
+ ↓ mock
67
+ [Vector/Graph DB tests]
68
+ ↓ mock
69
+ [Quantum simulation tests]
70
+ ↓ mock
71
+ [Ledger/Crypto tests]
72
+ ↓ mock
73
+ [Core domain types — real implementations bottom out here]
74
+ ```
75
+
76
+ ### Phase 1: pe-core (Domain Types — The Innermost Real Layer)
77
+
78
+ ```
79
+ // No mocks needed — these are pure value types
80
+
81
+ struct ProteinVariant:
82
+ id: Uuid
83
+ name: String
84
+ sequence: AminoAcidSequence // validated, immutable
85
+ target_factor: YamanakaFactor // OCT4 | SOX2 | KLF4 | CMYC
86
+ mutations: Vec<Mutation>
87
+ generation: u32
88
+ parent_id: Option<Uuid>
89
+
90
+ struct Mutation:
91
+ position: usize
92
+ from_residue: AminoAcid
93
+ to_residue: AminoAcid
94
+
95
+ struct FitnessScore:
96
+ reprogramming_efficiency: f64 // 0.0..1.0
97
+ expression_stability: f64
98
+ structural_plausibility: f64
99
+ safety_score: f64 // oncogenic risk, lower = safer
100
+ composite: f64 // weighted aggregate
101
+
102
+ struct ExperimentResult:
103
+ variant_id: Uuid
104
+ assay_type: AssayType
105
+ measured_values: HashMap<String, f64>
106
+ timestamp: DateTime
107
+ instrument_id: String
108
+
109
+ // TESTS (unit, no mocks):
110
+ test "ProteinVariant validates amino acid sequences"
111
+ test "Mutation applies to sequence producing new variant"
112
+ test "FitnessScore composite is weighted average of components"
113
+ test "AminoAcidSequence rejects invalid residue codes"
114
+ test "ProteinVariant tracks lineage via parent_id chain"
115
+ ```
116
+
117
+ ### Phase 2: pe-vector (Vector DB — Mock the Embedding Source)
118
+
119
+ ```
120
+ // Trait defining what we need from an embedding model
121
+ trait EmbeddingModel:
122
+ fn embed(sequence: &AminoAcidSequence) -> Result<Embedding320>
123
+
124
+ // Trait defining the vector store
125
+ trait VectorStore:
126
+ fn insert(id: Uuid, embedding: Embedding320, meta: VariantMeta)
127
+ fn search_nearest(query: Embedding320, k: usize) -> Vec<(Uuid, f32)>
128
+ fn get_meta(id: Uuid) -> Option<VariantMeta>
129
+
130
+ // RuVectorStore implements VectorStore backed by RuVector
131
+ struct RuVectorStore:
132
+ inner: ruvector::Database
133
+
134
+ // TESTS (London School — mock EmbeddingModel):
135
+ test "insert variant embedding and retrieve by ID":
136
+ mock_embedder returns fixed 320-dim vector
137
+ store.insert(variant.id, mock_embedder.embed(seq), meta)
138
+ assert store.get_meta(variant.id) == meta
139
+
140
+ test "search_nearest returns k closest by cosine similarity":
141
+ insert 100 variants with known embeddings
142
+ results = store.search_nearest(query_embedding, 5)
143
+ assert results.len() == 5
144
+ assert results are sorted by descending similarity
145
+
146
+ test "HNSW index persists to INDEX_SEG and reloads":
147
+ store.insert(variants...)
148
+ bytes = store.serialize_to_index_seg()
149
+ store2 = RuVectorStore::from_index_seg(bytes)
150
+ assert store2.search_nearest(...) == store.search_nearest(...)
151
+ ```
152
+
153
+ ### Phase 3: pe-neural (Fitness Scoring — Mock Vector Store + Models)
154
+
155
+ ```
156
+ trait FitnessPredictor:
157
+ fn predict(variant: &ProteinVariant, embedding: &Embedding320) -> Result<FitnessScore>
158
+
159
+ struct EnsemblePredictor:
160
+ transformer: TransformerScorer // reprogramming efficiency
161
+ lstm: LstmScorer // expression dynamics
162
+ nbeats: NBeatsScorer // outcome forecasting
163
+
164
+ // TESTS (London School — mock individual scorers):
165
+ test "EnsemblePredictor aggregates three sub-model scores":
166
+ mock_transformer returns reprogramming = 0.8
167
+ mock_lstm returns stability = 0.7
168
+ mock_nbeats returns outcome = 0.9
169
+ score = ensemble.predict(variant, embedding)
170
+ assert score.composite == weighted_average(0.8, 0.7, 0.9)
171
+
172
+ test "predict returns error when any sub-model fails":
173
+ mock_transformer returns Err(ModelNotLoaded)
174
+ assert ensemble.predict(...).is_err()
175
+
176
+ test "model weights load from QUANT_SEG bytes":
177
+ bytes = read_fixture("quant_seg_sample.bin")
178
+ scorer = TransformerScorer::from_quant_seg(bytes)
179
+ assert scorer.predict(sample_variant).is_ok()
180
+ ```
181
+
182
+ ### Phase 4: pe-swarm (Agent Orchestration — Mock All Collaborators)
183
+
184
+ ```
185
+ trait EvolutionEngine:
186
+ fn mutate(variant: &ProteinVariant) -> ProteinVariant
187
+ fn crossover(a: &ProteinVariant, b: &ProteinVariant) -> ProteinVariant
188
+ fn select(population: &[ScoredVariant], top_k: usize) -> Vec<ScoredVariant>
189
+
190
+ trait SwarmCoordinator:
191
+ fn run_design_cycle(config: CycleConfig) -> Result<CycleResult>
192
+
193
+ // Agent roles (each a trait implementor):
194
+ struct SequenceExplorer // evolutionary mutation + crossover
195
+ struct FitnessScorerAgent // delegates to FitnessPredictor
196
+ struct StructuralValidator // ESMFold / HNSW plausibility check
197
+ struct ToxicityScreener // oncogenic risk classifier
198
+ struct ExperimentDesigner // Opentrons protocol generation
199
+ struct QuantumDispatcher // VQE / QAOA job routing
200
+
201
+ // TESTS (London School — mock all agent collaborators):
202
+ test "SAFLA closed loop: design → score → validate → screen → log":
203
+ mock_explorer returns 10 mutated variants
204
+ mock_scorer returns fitness scores for each
205
+ mock_validator returns structural_ok for 8/10
206
+ mock_screener returns safe for 7/8
207
+ result = coordinator.run_design_cycle(config)
208
+ assert result.promoted.len() == 7
209
+ verify mock_explorer.mutate called 10 times
210
+ verify mock_scorer.predict called 10 times
211
+
212
+ test "agent retirement: low-performing agents replaced":
213
+ mock governance returns retirement signal for slow_agent
214
+ coordinator.tick()
215
+ assert slow_agent is removed from active pool
216
+ ```
217
+
218
+ ### Phase 5: pe-quantum (Quantum Routing — Mock Backends)
219
+
220
+ ```
221
+ trait QuantumBackend:
222
+ fn submit_vqe(hamiltonian: MolecularHamiltonian) -> Result<VqeResult>
223
+ fn submit_qaoa(qubo: QuboInstance) -> Result<QaoaResult>
224
+ fn capabilities() -> BackendCapabilities
225
+
226
+ struct QuantumRouter:
227
+ backends: Vec<Box<dyn QuantumBackend>>
228
+
229
+ // TESTS (London School — mock quantum backends):
230
+ test "router selects best backend for VQE by qubit count":
231
+ mock_origin supports 72 qubits
232
+ mock_ibm supports 127 qubits
233
+ mock_local supports 20 qubits
234
+ job requires 50 qubits
235
+ router.submit_vqe(hamiltonian)
236
+ verify mock_origin.submit_vqe called (closest fit)
237
+
238
+ test "router falls back to local WASM simulator when offline":
239
+ mock_origin returns Err(Unreachable)
240
+ mock_ibm returns Err(Unreachable)
241
+ result = router.submit_vqe(small_hamiltonian)
242
+ verify mock_local.submit_vqe called
243
+ assert result.is_ok()
244
+
245
+ test "VQE snapshots serialized to SKETCH_SEG format":
246
+ result = VqeResult { energy: -1.234, params: [...] }
247
+ bytes = result.to_sketch_seg()
248
+ roundtrip = VqeResult::from_sketch_seg(bytes)
249
+ assert roundtrip == result
250
+ ```
251
+
252
+ ### Phase 6: pe-ledger (Cryptographic Audit — Mock Crypto Primitives)
253
+
254
+ ```
255
+ trait LedgerWriter:
256
+ fn append_entry(entry: JournalEntry) -> Result<EntryHash>
257
+ fn verify_chain() -> Result<bool>
258
+
259
+ trait CryptoSigner:
260
+ fn sign(data: &[u8]) -> Result<MlDsaSignature>
261
+ fn verify(data: &[u8], sig: &MlDsaSignature) -> Result<bool>
262
+
263
+ // TESTS (London School — mock signer for fast tests):
264
+ test "append_entry chains SHA3 hashes correctly":
265
+ mock_signer returns deterministic signature
266
+ hash1 = ledger.append_entry(entry1)
267
+ hash2 = ledger.append_entry(entry2)
268
+ assert entry2.prev_hash == hash1
269
+
270
+ test "verify_chain detects tampered entry":
271
+ ledger.append_entry(entry1)
272
+ ledger.append_entry(entry2)
273
+ tamper entry1 payload
274
+ assert ledger.verify_chain() == Err(TamperDetected)
275
+
276
+ test "WITNESS_SEG round-trips through QuDAG":
277
+ entry = JournalEntry::new(ScoringRun { ... })
278
+ ledger.append_entry(entry)
279
+ seg_bytes = ledger.to_witness_seg()
280
+ restored = Ledger::from_witness_seg(seg_bytes)
281
+ assert restored.verify_chain().is_ok()
282
+ ```
283
+
284
+ ### Phase 7: pe-rvf (RVF Assembly — Mock All Segment Producers)
285
+
286
+ ```
287
+ trait RvfBuilder:
288
+ fn set_manifest(manifest: Manifest)
289
+ fn add_segment(seg_type: SegmentType, data: Vec<u8>)
290
+ fn build() -> Result<RvfFile>
291
+
292
+ // TESTS (London School — mock segment producers):
293
+ test "build assembles all 14 segment types into valid .rvf":
294
+ mock producers return fixture bytes for each segment
295
+ builder.set_manifest(manifest)
296
+ builder.add_segment(VEC_SEG, mock_vec_bytes)
297
+ builder.add_segment(INDEX_SEG, mock_index_bytes)
298
+ // ... all segments
299
+ rvf = builder.build()
300
+ assert rvf.manifest().capabilities contains all expected
301
+ assert rvf.segment_count() == 14
302
+
303
+ test "parent_hash lineage links child .rvf to parent":
304
+ parent_rvf = build_parent()
305
+ child_manifest = Manifest { parent_hash: parent_rvf.hash(), ... }
306
+ child = builder.build_with_manifest(child_manifest)
307
+ assert child.manifest().parent_hash == parent_rvf.hash()
308
+ ```
309
+
310
+ ### Phase 8: pe-api / pe-wasm / pe-cli (Outer Boundary — Integration Tests)
311
+
312
+ ```
313
+ // pe-api (axum HTTP):
314
+ test "POST /variants/score returns FitnessScore JSON":
315
+ mock FitnessPredictor behind trait
316
+ response = client.post("/variants/score", variant_json)
317
+ assert response.status == 200
318
+ assert response.body parses as FitnessScore
319
+
320
+ // pe-wasm (browser entry):
321
+ test "score_sequence WASM export returns valid score":
322
+ wasm_module = load_pe_wasm()
323
+ result = wasm_module.score_sequence("MKWVTFISLLLLFSSAYS...")
324
+ assert result.composite >= 0.0 && result.composite <= 1.0
325
+
326
+ // pe-cli:
327
+ test "cli run-evolution outputs generation summary":
328
+ output = run_cli(["run-evolution", "--generations", "5"])
329
+ assert output contains "Generation 5"
330
+ assert output contains "top variant"
331
+ ```
332
+
333
+ ---
334
+
335
+ ## A — Architecture
336
+
337
+ ### Crate Dependency Graph (Outside-In)
338
+
339
+ ```
340
+ pe-cli ─────┐
341
+ pe-api ─────┤
342
+ pe-wasm ────┤
343
+
344
+ pe-swarm ──────► pe-neural ──────► pe-vector ──────► pe-core
345
+ │ │ │
346
+ ▼ ▼ ▼
347
+ pe-governance pe-solver ruvector (ext)
348
+
349
+
350
+ pe-quantum ────► pe-quantum-wasm
351
+
352
+
353
+ pe-chemistry (sidecar bridge)
354
+
355
+ pe-ledger ─────► qudag (ext)
356
+
357
+ pe-stream ─────► midstream (ext)
358
+
359
+ pe-rvf ────────► rvf / rvf-types / rvf-wire (ext)
360
+ ```
361
+
362
+ ### Trait Boundaries (London School Mock Points)
363
+
364
+ Each arrow in the dependency graph represents a **trait boundary**. The London School approach mandates that when testing a layer, all downstream dependencies are replaced with test doubles.
365
+
366
+ | Consuming Crate | Trait | Mock Used In Tests |
367
+ |-----------------|-------|--------------------|
368
+ | pe-vector | `EmbeddingModel` | `MockEmbedder` returns fixed 320-dim vectors |
369
+ | pe-neural | `FitnessPredictor` | `MockScorer` returns predetermined fitness scores |
370
+ | pe-swarm | `EvolutionEngine` | `MockEvolver` returns canned mutation/crossover results |
371
+ | pe-swarm | `SwarmCoordinator` agents | `MockAgent` for each role (explorer, scorer, validator...) |
372
+ | pe-quantum | `QuantumBackend` | `MockBackend` returns predetermined VQE/QAOA results |
373
+ | pe-ledger | `CryptoSigner` | `MockSigner` returns deterministic signatures |
374
+ | pe-rvf | segment producers | `MockSegmentProducer` returns fixture bytes |
375
+ | pe-api | all domain traits | Full mock stack for HTTP handler tests |
376
+ | pe-wasm | all domain traits | Stub implementations for WASM integration tests |
377
+
378
+ ### RVF Segment Map (Architectural Invariant)
379
+
380
+ ```
381
+ MANIFEST_SEG 0x00 ──► root metadata, capabilities, lineage hash
382
+ VEC_SEG 0x01 ──► 320-dim ESM-2 protein embeddings
383
+ INDEX_SEG 0x02 ──► HNSW nearest-neighbor index
384
+ OVERLAY_SEG 0x03 ──► LoRA adapter deltas
385
+ JOURNAL_SEG 0x04 ──► append-only experiment log
386
+ GRAPH_SEG 0x05 ──► GNN protein interaction network
387
+ QUANT_SEG 0x06 ──► INT8 quantized neural weights
388
+ META_SEG 0x07 ──► per-variant filterable metadata
389
+ HOT_SEG 0x08 ──► top-100 promoted candidates
390
+ SKETCH_SEG 0x09 ──► MinHash sketches + VQE snapshots
391
+ WASM_SEG 0x0A ──► 5.5KB WASM microkernel
392
+ WITNESS_SEG 0x0B ──► QuDAG cryptographic witness chain
393
+ CRYPTO_SEG 0x0C ──► TEE attestation (SGX/SEV-SNP)
394
+ META_IDX_SEG 0x0D ──► filterable metadata index
395
+ KERNEL_SEG 0x0E ──► optional unikernel (Firecracker)
396
+ ```
397
+
398
+ ### Feature Flag Architecture
399
+
400
+ ```
401
+ ┌── native ──┐
402
+ │ tokio │
403
+ │ axum │
404
+ │ libp2p │
405
+ │ ort │
406
+ │ faer │
407
+ │ polars │
408
+ │ rayon │
409
+ Cargo.toml ────────┤ │
410
+ │ │
411
+ └── wasm ────┐
412
+ │ wasm-bindgen │
413
+ │ js-sys │
414
+ │ web-sys │
415
+ │ gloo-net │
416
+ │ rvf-wasm │
417
+ └────────────────┘
418
+
419
+ pe-core: no_std, no feature flags (always compiles everywhere)
420
+ pe-quantum-wasm: pure Rust, no feature flags (always available)
421
+ pe-quantum: native only (hardware backend routing)
422
+ pe-api: native only (axum server)
423
+ pe-wasm: wasm only (browser entry)
424
+ pe-cli: native only (binary entry)
425
+ ```
426
+
427
+ ### Deployment Target Matrix
428
+
429
+ | Target | Entry Crate | Feature | RVF Segment Used |
430
+ |--------|-------------|---------|------------------|
431
+ | Docker server | pe-cli / pe-api | `native` | KERNEL_SEG boots |
432
+ | WASM browser | pe-wasm | `wasm` | WASM_SEG runs |
433
+ | Bare-metal lab | pe-cli | `native` | KERNEL_SEG boots |
434
+ | Raspberry Pi | pe-cli | `native` (aarch64) | rvf-wire reads |
435
+ | Claude Code / MCP | rvf-mcp-server | `native` | All segments exposed |
436
+ | P2P transfer | rvf-wire | `native` | Zero conversion |
437
+
438
+ ---
439
+
440
+ ## R — Refinement
441
+
442
+ ### London School TDD Workflow Per Crate
443
+
444
+ ```
445
+ For each crate, working outside-in:
446
+
447
+ 1. Write a failing acceptance test at the crate's public API boundary
448
+ 2. Identify collaborator traits the crate needs
449
+ 3. Create mock/stub implementations of those traits
450
+ 4. Write unit tests for the crate's logic using mocks
451
+ 5. Make tests pass with minimal implementation
452
+ 6. Move inward: implement the next downstream crate
453
+ 7. Replace mocks with real implementations one layer at a time
454
+ 8. Run acceptance test again — now exercises real stack
455
+ ```
456
+
457
+ ### Implementation Phases
458
+
459
+ **Phase 1: Foundation (pe-core)**
460
+ - Pure domain types, zero dependencies beyond `serde`, `uuid`, `chrono`
461
+ - `no_std` compatible from day one
462
+ - Unit tests only (no mocks needed — leaf node)
463
+ - Deliverable: `ProteinVariant`, `Mutation`, `FitnessScore`, `ExperimentResult`, `AminoAcidSequence`
464
+
465
+ **Phase 2: Storage Layer (pe-vector + pe-rvf)**
466
+ - pe-vector: `VectorStore` + `EmbeddingModel` traits; `RuVectorStore` impl
467
+ - pe-rvf: `RvfBuilder` + segment serialization
468
+ - Mock: `MockEmbedder` for pe-vector tests
469
+ - Mock: `MockSegmentProducer` for pe-rvf tests
470
+ - Integration test: insert embeddings → serialize to VEC_SEG → reload
471
+
472
+ **Phase 3: Intelligence Layer (pe-neural + pe-solver)**
473
+ - pe-neural: `FitnessPredictor` trait; `EnsemblePredictor` (Transformer + LSTM + N-BEATS)
474
+ - pe-solver: sublinear-time sparse energy minimization
475
+ - Mock: individual scorer sub-models for ensemble tests
476
+ - Integration test: load QUANT_SEG fixture → score a known sequence
477
+
478
+ **Phase 4: Quantum Layer (pe-quantum + pe-quantum-wasm + pe-chemistry)**
479
+ - pe-quantum-wasm: pure-Rust statevector simulator (always available)
480
+ - pe-quantum: `QuantumBackend` trait; `QuantumRouter` dispatches to backends
481
+ - pe-chemistry: HTTP bridge to pyChemiQ sidecar
482
+ - Mock: `MockBackend` for router logic tests
483
+ - Integration test: VQE on H2 molecule via local simulator
484
+
485
+ **Phase 5: Trust Layer (pe-ledger + pe-governance)**
486
+ - pe-ledger: `LedgerWriter` + `CryptoSigner` traits; QuDAG integration
487
+ - pe-governance: daa lifecycle management
488
+ - Mock: `MockSigner` for fast chain tests
489
+ - Integration test: append 100 entries → verify chain → serialize to WITNESS_SEG
490
+
491
+ **Phase 6: Orchestration Layer (pe-swarm + pe-stream)**
492
+ - pe-swarm: `SwarmCoordinator` + agent role traits; Synaptic-Mesh integration
493
+ - pe-stream: live instrument data ingestion via midstream
494
+ - Mock: all downstream agent collaborators
495
+ - Integration test: SAFLA loop with mock agents → verify cycle output
496
+
497
+ **Phase 7: Interface Layer (pe-api + pe-wasm + pe-cli)**
498
+ - pe-api: axum HTTP/WebSocket handlers
499
+ - pe-wasm: WASM entry point compiled by wasm-pack
500
+ - pe-cli: CLI binary
501
+ - Mock: full domain trait stack behind dependency injection
502
+ - Integration test: HTTP round-trip with mock backend
503
+ - E2E test: WASM module exports callable from JS
504
+
505
+ ### Risk Mitigations
506
+
507
+ | Risk | Mitigation |
508
+ |------|------------|
509
+ | RuVector/QuDAG API instability | Pin git revisions in Cargo.toml; trait boundaries insulate |
510
+ | WASM bundle size exceeds budget | `opt-level=z` + `lto=thin`; WASM_SEG measured in CI |
511
+ | Quantum backend unavailable | pe-quantum-wasm pure-Rust simulator always available offline |
512
+ | pyChemiQ sidecar latency | Async HTTP bridge with timeout; cache VQE results in SKETCH_SEG |
513
+ | Feature flag combinatorial explosion | CI matrix tests `native` and `wasm` profiles; `pe-core` has no flags |
514
+ | Cross-compilation failures (aarch64) | CI includes aarch64 cross-compile step; `no_std` core validated |
515
+
516
+ ### Mock Library Choice
517
+
518
+ Use **`mockall`** crate for London School mocks:
519
+ - Auto-generates mock structs from trait definitions
520
+ - Supports expectation setting (call count, argument matching)
521
+ - Supports return value sequences
522
+ - Works with async traits via `#[async_trait]`
523
+
524
+ ```toml
525
+ [workspace.dependencies]
526
+ mockall = { version = "0.12", optional = true }
527
+
528
+ # In each crate's Cargo.toml:
529
+ [dev-dependencies]
530
+ mockall = { workspace = true }
531
+ ```
532
+
533
+ ---
534
+
535
+ ## C — Completion
536
+
537
+ ### Definition of Done Per Crate
538
+
539
+ - [ ] All public types and traits documented with rustdoc
540
+ - [ ] London School unit tests pass with mocked collaborators
541
+ - [ ] Integration tests pass with real downstream crates
542
+ - [ ] `cargo clippy` clean (no warnings)
543
+ - [ ] `cargo fmt` applied
544
+ - [ ] Compiles for target profile (`native` or `wasm` or both)
545
+ - [ ] Feature flag gating verified (no native deps leak into wasm)
546
+
547
+ ### Definition of Done for the Platform
548
+
549
+ - [ ] `cargo build --release --features native` succeeds
550
+ - [ ] `wasm-pack build crates/pe-wasm` produces < 10 MB bundle
551
+ - [ ] `./build-rvf.sh` assembles valid `.rvf` with all 15 segments
552
+ - [ ] `.rvf` opens in Docker, WASM browser, and CLI modes
553
+ - [ ] MCP server exposes all RVF operations to Claude Code
554
+ - [ ] Full SAFLA cycle completes: design → score → validate → screen → log
555
+ - [ ] QuDAG witness chain verifiable with ML-DSA signatures
556
+ - [ ] CI pipeline runs full test matrix (native + wasm + aarch64 cross-compile)
557
+
558
+ ### Test Pyramid
559
+
560
+ ```
561
+ ╱╲
562
+ ╱ ╲ E2E Tests (3-5)
563
+ ╱ ╲ .rvf opens in Docker + WASM + CLI
564
+ ╱──────╲
565
+ ╱ ╲ Integration Tests (15-25)
566
+ ╱ ╲ Real crate-to-crate interactions
567
+ ╱────────────╲
568
+ ╱ ╲ London School Unit Tests (100+)
569
+ ╱ ╲ Mocked collaborators, fast, isolated
570
+ ╱──────────────────╲
571
+ ╱ ╲ Property / Fuzz Tests (10-15)
572
+ ╱ ╲ AminoAcidSequence, RVF parsing,
573
+ ╱________________________╲ cryptographic round-trips
574
+ ```
575
+
576
+ ### CI Pipeline Stages
577
+
578
+ ```
579
+ 1. cargo fmt --check
580
+ 2. cargo clippy --all-targets --all-features
581
+ 3. cargo test --features native (London School unit + integration)
582
+ 4. cargo test --target wasm32-unknown-unknown --features wasm (WASM unit)
583
+ 5. wasm-pack build crates/pe-wasm (bundle size check)
584
+ 6. cross build --target aarch64-unknown-linux-gnu --features native
585
+ 7. ./build-rvf.sh && validate-rvf protein-engine.rvf
586
+ 8. docker compose -f docker-compose.dev.yml up --build --abort-on-container-exit
587
+ ```
588
+
589
+ ### Milestone Schedule
590
+
591
+ | Milestone | Crates | Key Deliverable |
592
+ |-----------|--------|-----------------|
593
+ | M1 — Foundation | pe-core, pe-rvf | Domain types + RVF builder with segment serialization |
594
+ | M2 — Storage | pe-vector | Embedding insert/search + HNSW persistence |
595
+ | M3 — Intelligence | pe-neural, pe-solver | Ensemble fitness scoring < 100ms |
596
+ | M4 — Quantum | pe-quantum, pe-quantum-wasm, pe-chemistry | VQE on local simulator + Origin Quantum bridge |
597
+ | M5 — Trust | pe-ledger, pe-governance | Verified witness chain + DAA lifecycle |
598
+ | M6 — Orchestration | pe-swarm, pe-stream | SAFLA closed loop + instrument ingestion |
599
+ | M7 — Interfaces | pe-api, pe-wasm, pe-cli | All 7 deployment targets operational |
600
+ | M8 — Integration | all | Single `.rvf` artifact passes full E2E suite |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llm-dev-ops/agentics-cli",
3
- "version": "2.7.38",
3
+ "version": "2.7.40",
4
4
  "description": "Agentics CLI - Pure orchestration layer for agentics platform services",
5
5
  "type": "module",
6
6
  "main": "./dist/cli/index.js",
@@ -10,6 +10,7 @@
10
10
  "files": [
11
11
  "dist",
12
12
  "docs/ecosystem.graph.json",
13
+ "docs/templates",
13
14
  "scripts/postinstall.sh",
14
15
  "README.md"
15
16
  ],