|
| 1 | +# Archetype Transcode Crate Scaffold — v1 |
| 2 | + |
| 3 | +> **Status:** In progress (2026-04-24) |
| 4 | +> **Owner:** @archetype-specialist, @truth-architect |
| 5 | +> **Scope:** NEW crate `crates/lance-graph-archetype/`; deps only on `lance-graph-contract`, `arrow`, `lance` (peer-dep, optional). |
| 6 | +> **Depends on:** ADR-0001 Decision 1 (transcode-not-bridge). No runtime dependency on upstream Python. |
| 7 | +
|
| 8 | +## Goal |
| 9 | + |
| 10 | +Flip `lance-graph-archetype` from "does-not-exist" to "scaffolded-and-locked." Ship the 6 foundational trait/struct files per ADR-0001 Decision 1. No runtime behaviour yet — this is the LOCKED-MAPPING-INCOMPLETE → LOCKED-AND-SCAFFOLDED pivot. |
| 11 | + |
| 12 | +## Deliverables |
| 13 | + |
| 14 | +- **DU-2.1** — `crates/lance-graph-archetype/Cargo.toml` + `src/lib.rs` + workspace `members` entry in root `Cargo.toml`. |
| 15 | +- **DU-2.2** — `src/component.rs: pub trait Component { fn arrow_field() -> arrow::datatypes::Field; fn type_id() -> &'static str; }` plus a test-only `MockComponent` impl asserting trait-object construction. |
| 16 | +- **DU-2.3** — `src/processor.rs: pub trait Processor { fn matches(schema: &arrow::datatypes::Schema) -> bool; fn process(batch: arrow::record_batch::RecordBatch) -> Result<arrow::record_batch::RecordBatch, ArchetypeError>; }`. |
| 17 | +- **DU-2.4** — `src/world.rs: pub struct World { tick: u64, dataset_uri: String }` with `new() / tick() / current_tick() / fork(&self, branch: &str) / at_tick(&self, tick: u64)` methods. `fork()` and `at_tick()` return `Err(ArchetypeError::Unimplemented { method: "..." })` stubs — docstrings tie to ADR-0001:61-72 / 95. |
| 18 | +- **DU-2.5** — `src/command_broker.rs: pub struct CommandBroker { queue: Vec<Command>, ... }` + `pub enum Command { Spawn, Despawn, Update }` — channel-based drain interface with `submit() / drain()` method stubs. |
| 19 | +- **DU-2.6** — `src/error.rs: pub enum ArchetypeError { Unimplemented { method: &'static str }, SchemaMismatch { ... }, LanceIo(...) }` with `thiserror::Error` impl. |
| 20 | + |
| 21 | +## Non-goals (explicit) |
| 22 | + |
| 23 | +- Runtime World tick behaviour — stubs only. |
| 24 | +- `AsyncProcessor` (Python async equivalent) — future follow-up. |
| 25 | +- Entity=`PersonaCard` wiring — DU-2.7, later PR. |
| 26 | +- Lance dataset integration beyond the `dataset_uri: String` placeholder — the `fork()` → `lance::checkout(branch)` wiring is DU-2.8. |
| 27 | + |
| 28 | +## Acceptance criteria |
| 29 | + |
| 30 | +- `cargo check -p lance-graph-archetype` compiles cleanly. |
| 31 | +- `cargo test -p lance-graph-archetype` — minimum 4 tests pass (one per core trait + one per stub-returns-Unimplemented). |
| 32 | +- `cargo test --workspace` — no regressions in other crates. |
| 33 | +- Root `Cargo.toml` workspace.members updated. |
| 34 | +- `STATUS_BOARD.md` DU-2 row status: Queued → In progress. |
| 35 | +- Verdict flip in `.claude/plans/unified-integration-v1.md §6`: Archetype row `LOCKED-MAPPING-INCOMPLETE` → `LOCKED-AND-SCAFFOLDED`. |
| 36 | +- `.claude/board/INTEGRATION_PLANS.md` — prepend entry pointing to this plan file. |
| 37 | +- `.claude/board/LATEST_STATE.md § Contract Inventory` — add a new block for `lance-graph-archetype` naming the shipped types. |
| 38 | +- `.claude/board/EPIPHANIES.md` — prepend short FINDING entry noting scaffold landed. |
| 39 | + |
| 40 | +## Architecture notes |
| 41 | + |
| 42 | +Per ADR-0001 Decision 1 (`.claude/adr/0001-archetype-transcode-stack.md:14-102`): this crate defines its OWN Rust interface. It does NOT mirror the Python `VangelisTech/archetype` API. The Python repo is a DESIGN SPEC, not a runtime dependency. "Upstream Python API unstable" is NOT a blocker. |
| 43 | + |
| 44 | +Per ADR-0001 Decision 3 (`adr/0001-archetype-transcode-stack.md:320-334`): BBB invariant bans `Vsa16kF32` / `RoleKey` / `NarsTruth` / `BlackboardEntry` from crossing the membrane. Archetype types defined in this crate are INSIDE-BBB; they do NOT appear on `CognitiveEventRow`. The scalar projection for "archetype tick happened" is already covered by `CognitiveEventRow.cycle_fp_hi/lo` + `MetaWord`. |
| 45 | + |
| 46 | +Mapping (locked, do not re-litigate): |
| 47 | + |
| 48 | +| ECS concept | lance-graph-contract type | This crate | |
| 49 | +|---|---|---| |
| 50 | +| Entity | `contract::persona::PersonaCard` | imported, not redefined | |
| 51 | +| World | `contract::a2a_blackboard::Blackboard` (runtime) + `World { dataset_uri, tick }` (archetype meta) | the latter is new here | |
| 52 | +| Tick | `contract::collapse_gate::GateDecision` fire | imported, not redefined | |
| 53 | +| Component | trait in this crate | **DU-2.2** | |
| 54 | +| Processor | trait in this crate | **DU-2.3** | |
| 55 | +| CommandBroker | struct in this crate | **DU-2.5** | |
| 56 | + |
| 57 | +## File layout |
| 58 | + |
| 59 | +``` |
| 60 | +crates/lance-graph-archetype/ |
| 61 | + Cargo.toml |
| 62 | + src/ |
| 63 | + lib.rs # pub use component::*; etc. |
| 64 | + component.rs # trait Component |
| 65 | + processor.rs # trait Processor |
| 66 | + world.rs # struct World |
| 67 | + command_broker.rs # struct CommandBroker, enum Command |
| 68 | + error.rs # enum ArchetypeError (thiserror) |
| 69 | +``` |
| 70 | + |
| 71 | +## Test layout |
| 72 | + |
| 73 | +Each module gets a `#[cfg(test)] mod tests` with at minimum one test. Minimum 4 tests total: |
| 74 | + |
| 75 | +1. `component::tests::mock_component_has_arrow_field` |
| 76 | +2. `processor::tests::trait_object_is_constructable` |
| 77 | +3. `world::tests::fork_returns_unimplemented` |
| 78 | +4. `world::tests::tick_increments` |
| 79 | + |
| 80 | +## Dependencies |
| 81 | + |
| 82 | +```toml |
| 83 | +[dependencies] |
| 84 | +lance-graph-contract = { path = "../lance-graph-contract" } |
| 85 | +arrow = { workspace = true } |
| 86 | +thiserror = { workspace = true } |
| 87 | + |
| 88 | +[dev-dependencies] |
| 89 | +# nothing initially |
| 90 | +``` |
0 commit comments