stemedb/ai-lookup/services/lifecycle.md
jordan 3cfaa1e1d3 feat: Complete Phase 1 (The Spine) - storage foundation
Phase 1 delivers the complete durability and storage layer:

- WAL with crash recovery: Append-only journal with BLAKE3 checksums,
  fsync guarantees, and proper seek-to-EOF on reopen
- Storage engine: sled-backed KVStore with scan_prefix for range queries
- Content-addressed storage: H:{hash}, V:{hash}, E:{hash} key patterns
- Ingestor: Background worker tailing WAL, writing to KV with 8-byte
  aligned record headers for rkyv zero-copy deserialization
- Comprehensive tests: 31 tests covering crash recovery, round-trips,
  and multi-cycle durability

New crates: stemedb-wal, stemedb-storage, stemedb-ingest

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 14:15:34 -07:00

1.9 KiB

Lifecycle Stages

Quick Ref: Assertions have lifecycle state: Proposed → UnderReview → Approved | Deprecated | Rejected

The Problem

AI agents can't distinguish proposals from decisions. An RFC saying "we should use ES256" looks the same as an approved policy saying "use ES256." Agents query, get proposals, treat them as truth.

The Solution

enum LifecycleStage {
    Proposed,      // Idea, RFC, suggestion
    UnderReview,   // Being evaluated
    Approved,      // Accepted as current truth
    Deprecated,    // Was true, now superseded
    Rejected,      // Considered and declined
}

struct Assertion {
    // ... existing fields
    pub lifecycle: LifecycleStage,
}

Query Integration

# Only approved patterns (safe for implementation)
GET /query?subject=auth/jwt&predicate=algo&lifecycle=approved

# All stages (for research/context)
GET /query?subject=auth/jwt&predicate=algo&lifecycle=any

# Show proposals needing review
GET /query?predicate=*&lifecycle=under_review

State Transitions

Proposed → UnderReview → Approved → Deprecated
                      ↘ Rejected

Transitions are new assertions, not mutations:

POST /assert
{
  "subject": "auth/jwt",
  "predicate": "signing_algorithm",
  "object": { "Text": "ES256" },
  "lifecycle": "Approved",
  "parent_hash": "proposal_hash...",  # Links to original proposal
  "signatures": [{ "agent_id": "security_lead", ... }]
}

Lens Interaction

Lens Lifecycle Behavior
Recency Returns most recent matching lifecycle filter
Consensus Counts votes within lifecycle stage
Authority Weights by signer reputation, respects lifecycle
EpochAware Filters by epoch AND lifecycle

Origin

This feature emerged from user research (see .claude/agents/perspective-*.md). The Implementation Agent's core need: "If proposed and approved look the same, I can't use this."