Story Crater Bot
|
b18932b10c
|
feat: M3.8.1 phase 1 — content router + log compressor
ContentRouter uses Google Magika ML for content detection (<1ms) with regex
fallback. Detects JSON, code, logs, diffs, config, text.
LogCompressor reuses M3.7.7 patterns (markers, cascade, strip_ansi) to
shrink build logs by keeping errors/stacks and dropping noise.
17 unit tests passing:
- router: json, code, diff, log, text detection
- log: error lines, stack traces, ansi stripping, compression
- optimizer: token estimation, passthrough mode
Magika + ort ONNX runtime added to Cargo.toml.
|
2026-08-28 09:29:56 -07:00 |
|
Story Crater Bot
|
d632f10795
|
feat: Implement M2.5 & M2.6 — Obsidian vault projector + rebuild orchestrator
M2.5 ✅ Complete: Deterministic vault generation from event log
Implementation (crates/mem-store/src/obsidian.rs):
- ObsidianProjector::project() reads log → writes vault
- Vault structure:
- vault/<project>/index.md — L2 synthesis, links all L1
- vault/<project>/<query-id>.md — L1 per standing query
- vault/<project>/evidence/<source>-<t>.md — L0 (optional)
- Frontmatter rendering with stable key order (BTreeMap)
- `updated` from log (not now()) — deterministic rebuilds
- Sorted provenance section (by source, then t)
- Empty memory still writes with "_No evidence found_" note
- Bidirectional links: L1↔L2 via [[query-id]] and [[index]]
- Write with \n line endings, no trailing whitespace, exactly 1 final newline
Types:
- MemoryRecord: {level, project, query_id, text, updated, run_id, t, source, parents}
- MemoryParent: {source, t, description}
- ProjectorOpts: {emit_evidence_notes}
- ProjectorStats: {files_written}
Tests (10 integration tests in tests/it_projector.rs):
1. a1_byte_identical_twice — multiple renders are byte-equal
2. a2_no_generation_timestamp — no now() leakage
3. a3_frontmatter_key_order — stable alphabetical order
4. a4_golden_structure — complete section presence
5. a5_empty_memory_still_writes — explicit fallback text
6. a6_links_bidirectional — L1↔L2 linkage
7. a7_evidence_notes_rendering — L0 note format
8. a8_line_endings_and_newline — \n only, 1 trailing
9. a9_provenance_sorted — source then t order
10. a10_no_trailing_whitespace — deterministic formatting
M2.6 ✅ Complete: Rebuild orchestration from event log
Implementation (crates/mem-store/src/rebuild.rs):
- RebuildEngine::new(db_url) with Postgres pool
- RebuildEngine::rebuild(opts) — full orchestration
- Four-step process:
1. Clear project (nodes cascade → edges)
2. Read log memories → convert to MemoryNodes
3. Upsert all nodes (ON CONFLICT DO NOTHING)
4. Insert all edges (two-pass: nodes then edges)
5. Project vault (M2.5)
- Three rebuild modes:
- Default: both database + vault
- --vault-only: skip database operations
- --db-only: skip vault projection
- Incomplete log detection (no run_end) — error by default
- --allow-partial flag to proceed anyway
- Embedding cache by content sha256
- Keyed on memory text hash (not node id)
- Survives runs, reduces recomputation
- Statistics reporting: nodes by level, edges, embeddings cached/computed
Types:
- RebuildOpts: {project, vault_only, db_only, allow_partial, cache_dir, vault_dir, log_dir}
- RebuildStats: {nodes_l0, nodes_l1, nodes_l2, edges, embeddings_computed, embeddings_cached}
- Content identity via sha256(memory.text)
Tests (6 integration tests in tests/it_rebuild.rs):
1. a1_from_empty — rebuild creates expected node counts
2. a2_idempotent_db — rebuild twice = same row counts
3. a3_idempotent_vault — rebuild twice = byte-identical files
4. a5_embedding_cache_reduces_computation — cache lookup works
5. a6_incomplete_log_refused — no run_end → error unless --allow-partial
6. a7_memory_sha_content_identity — same text = same hash
7. a8_rebuild_opts_modes — mode flags work correctly
Dependency:
- crates/mem-store/Cargo.toml: added sha2 (workspace)
Updated INDEX.md:
- M2.x: 6/8 done (M2.7, M2.8 remain)
- Total: 48✅ + 2🟡 + 23⬜ (was 45✅)
- 26 new tests (M2.5: 10, M2.6: 6) + 10 utility unit tests
Architecture notes:
- M2.5 schema validates via M2.3 tables
- M2.6 uses M2.4 PgRepo for all DB operations
- Rebuild chain: clear → nodes → edges → vault (order required)
- FK constraints enforce two-pass for edges
- Deterministic output enables M2.8 gate (byte-identical verification)
|
2026-08-27 20:54:43 -07:00 |
|