# Evidence-SSoT Phase 0 — Knowledge Propagation Infrastructure (2026-05-15)

# Evidence-SSoT Phase 0 — Knowledge Propagation Infrastructure (2026-05-15)

## Problem (CEO trigger 2026-05-15)

"Informacije iz John sesija se ne preklapaju, treba one place to go and find everything."

**Concrete symptom:** BookStack page 2932 (SnowIT migration evidence) created but not discoverable in next session. Knowledge created in one session context does not automatically surface in subsequent sessions.

## Root Cause (verifier-confirmed)

- `~/.claude/hooks/lightrag-auto-ingest.sh` wired in PostToolUse but writing to /dev/null effectively (no log file, async failures swallowed)
- 5 fragmented knowledge stores with no causal write-through
- `/tmp` ephemeral state lost on reboot
- Manual `MEMORY.md` edits as primary channel

## Phase 0 Architecture (lightweight, ~120 LOC total)

Phase 0 ships lightweight knowledge-propagation infrastructure before investing in full CQRS SQLite solution. Three components totaling ~120 LOC.

### Component 1: Visibility (#100792)

**File:** `~/.claude/hooks/lightrag-auto-ingest.sh`

**Adds:** 
- Structured logging to `~/.claude/hooks/lightrag-auto-ingest.log`
- Heartbeat file `~/system/state/lightrag-ingest-health.json`

**Effect:** Silent daemon failures now visible. Previously the hook ran but wrote nowhere, swallowing all async failures.

### Component 2: Append-only evidence ledger (#100793)

**File:** `~/system/tools/mc.js` (patched)

**Output:** `~/system/state/evidence-index.jsonl`

**Behavior:** On every `mc.js done/ready`, appends one JSON line with metadata:

```json
{
  "ts": "2026-05-15T15:45:23.123Z",
  "mc_id": 100788,
  "verb": "done",
  "status": "COMPLETE",
  "title": "Evidence-SSoT Phase 0 documentation",
  "priority": "H",
  "actor": "skillforge",
  "session_id": "abc123",
  "evidence_path": "/path/to/evidence.json",
  "bookstack_url": "https://docs.alai.no/books/..."
}
```

**Properties:**
- Idempotent (last-100-lines dedup window)
- Non-blocking on failure
- Append-only (no updates, immutable log)

### Component 3: SessionStart projection (#100794)

**File:** `~/system/tools/session-boot.js` + SessionStart hook in `~/.claude/settings.json`

**Output:** `~/system/state/session-boot-${PID}.json` per session

**Reads:**
- Last 50 entries from `evidence-index.jsonl`
- 20 pending events from `events.db`
- Open H-priority MCs from `mc.js`

**Per-PID file:** No clobber on concurrent sessions. Survives reboot (unlike `/tmp`).

## Schema: evidence-index.jsonl

| Field | Type | Description |
|-------|------|-------------|
| `ts` | ISO8601 string | When transition occurred |
| `mc_id` | int | Task ID |
| `verb` | enum: done\|ready\|close | State transition |
| `status` | string | Resulting status (COMPLETE, PARTIAL, BLOCKED, etc.) |
| `title` | string | Task title at time of transition |
| `priority` | enum: H\|M\|L | Task priority |
| `actor` | string | Who fired (john, edita, autowork, etc.) |
| `session_id` | string\|null | From CLAUDE_SESSION_ID env |
| `evidence_path` | string\|null | From --evidence-path CLI arg |
| `bookstack_url` | string\|null | From task field |

## Schema: session-boot-${PID}.json

**Keys:**
- `ts`: ISO8601 timestamp
- `pid`: Process ID
- `open_h_tasks[]`: Array of high-priority open tasks
- `recent_evidence[]`: Last 50 evidence-index entries
- `events_pending[]`: Pending events from events.db
- `schema_version`: Currently 1

## Operating Manual

### New sessions
SessionStart hook auto-fires; agent reads `~/system/state/session-boot-${PID}.json` as first context source before processing user input.

### Closing tasks
Just call `mc.js done/ready` normally; JSONL shim auto-captures metadata.

### Health check
```bash
cat ~/system/state/lightrag-ingest-health.json | jq .last_ts
```

### Recent evidence query
```bash
tail -20 ~/system/state/evidence-index.jsonl | jq -c .
```

## Phase 1 (deferred)

Full SQLite CQRS using existing `events.db` schema + MC #99910 CAS lease pattern.

**Trigger condition:** Phase 0 baseline eval shows hit_rate gain <30pp from current state.

**ETA:** Only if needed. Phase 0 establishes baseline; Phase 1 ships only if lightweight approach proves insufficient.

## ZAKON Candidates (NOT YET PROMULGATED)

Pending Phase 0 baseline evaluation:

- **EV-1:** `mc.js` closure for H/M auto-injects evidence-index.jsonl entry (already enforced in code)
- **EV-2:** BookStack page creation includes `mc_id` in URL or metadata for discoverability
- **EV-3:** Session boot consumes `/system/state/session-boot-${PID}.json` (enforced via SessionStart hook firing automatically)

## Key Decisions (Panel consensus)

1. **NOT new evidence.db** — Reuse existing `~/system/databases/events.db` (14.6MB, events/subscriptions/dead_letter tables already present + idempotency_key + status FSM)
2. **JSONL shim ships first** — (OpenAI-chief dissent: lightweight-first approach)
3. **SessionStart hook used** — (NOT PreToolUse per anthropic-chief — wrong event)
4. **Per-PID files in ~/system/state/** — (NOT /tmp — macOS purges on reboot)
5. **Auto-MC from reaper deferred** — (ZAKON #28 violation — flag-only for now)
6. **MC #99910 CAS lease pattern reserved for Phase 1** — (if Phase 0 baseline insufficient)

## References

- **Parent MC:** [#100788](https://docs.alai.no/books/infrastructure/page/mc-100788)
- **Child MCs:** [#100792](https://docs.alai.no/books/infrastructure/page/mc-100792), [#100793](https://docs.alai.no/books/infrastructure/page/mc-100793), [#100794](https://docs.alai.no/books/infrastructure/page/mc-100794)
- **Panel agentIds:**
  - a168d606fba37d0b4 (petter-graff)
  - a6f1160df9d829340 (kleppmann)
  - a368fa682b8686792 (huyen)
  - a69659af21909bf1b (hightower)
  - af8aef35661db36e3 (gerganov)
- **Verifier:** a2c7b716943a1e5a0
- **ADR pattern reuse:** `~/system/specs/pi-orch-collision-claim.md` (CAS lease for Phase 1)
- **CEO directives:** feedback_no_micro_decisions, feedback_pursue_goal_no_permission, feedback_no_architecture_fork_menu

## Timeline

- **2026-05-15 15:30:** CEO trigger ("one place to go and find everything")
- **2026-05-15 15:45:** Panel convened (5 specialists + verifier)
- **2026-05-15 16:00:** Phase 0 lightweight approach consensus
- **2026-05-15 16:30:** All 3 child MCs (#100792, #100793, #100794) delivered
- **2026-05-15 17:00:** Documentation (this page) published

---

## Related Documentation

**Reality Anchor Doctrine v1** — Deterministic probe primacy, Writer ≠ Witness, content-addressed audit. Panel-approved 2026-05-15.  
→ [Reality Anchor Doctrine v1](https://docs.alai.no/books/system-architecture/page/reality-anchor-doctrine-v1-final)