e0a25ff629
Design for making the brain governance observer rich enough for real factor analysis. Surfaced during a discussion with the owner: the observer is "paper-complete" but episodes lack the data factor analysis needs — the outcome is a hardcoded "success", there is no decision provenance (who chose the node — Claude autonomously, or the owner forcing a method), no environment factors, no task grouping. 4-layer architecture: - Layer 1 — episode schema v2: decision_provenance (+ counterfactual), environment block, task_size, real outcome enum, task_ref. - Layer 2 — capture: deterministic transcript parsing for all factors + a one-line routing tag (owner-forced-method only). - Layer 3 — two-sided enforcement: 3a routing-gate (Stop-hook blocks the turn until the tag is present — unbypassable by Claude); 3b observer self-discipline (silent failures become recorded observer_error markers; coverage + registration verified by a controller). - Layer 4 — analysis: /brain-retro infers real outcome from the next episode's opening prompt, groups episodes into tasks, correlates causal chains, builds the factor matrix. Scope: everything except an independent agent-judge — that, plus confusion_marker as a real judgment and real-time friction flags, is phase 2 (separate spec). Brainstormed via superpowers:brainstorming. Next: writing-plans. Refs: ADR-011, spec 2026-05-19-brain-governance-design.md, Pravila §16. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Observer infrastructure
Passive evidence-loop for the Лидерра «brain» per ADR-011.
Files
episodes-YYYY-MM.jsonl— append-only JSONL, one line per Stop-event (one prompt→response turn). Written bytools/observer-stop-hook.mjs, which parses the session transcript (transcript_path) viatools/observer-transcript-parser.mjs.notes/YYYY-MM-DD-<slug>.md— optional MD notes for sessions with qualitative history.STATUS.md— auto-generated dashboard. Regenerated per-commit bytools/status-md-generator.mjs..read-counter.json— C3 observer-of-observer counter. Updated on Read of observer files.
Lifecycle
- Write: every Stop-event appends one JSONL line, parsed from the session transcript (Stop-hook).
- Aggregate:
/brain-retroskill reads JSONL each sprint, proposes regulatory candidates. - Surface:
STATUS.mdshows controllers + monthly stats. - Self-prune: C3 warns if 54 weeks pass without any read of observer files.
Privacy
PII filter (phone numbers, emails, tokens) is applied before every write — see tools/observer-pii-filter.mjs. gitleaks pre-push also scans observer files as part of full-history sweep.
Don't
- Don't edit
episodes-*.jsonlmanually — it's append-only. - Don't write outside
docs/observer/notes/for hand-curated notes. - Don't change
.read-counter.jsonmanually — it's maintained by hooks.
HK1 pre-check (Pravila ADR-010) — verified 2026-05-19
Before registering tools/observer-stop-hook.mjs on Stop event (Task B5), verified collision against 6-component economy/skill-discipline architecture:
- User-level
~/.claude/settings.jsonalready has Stop hook: agent-type Sonnet-4.6 economy compliance verifier (analyzes transcript for claim-without-evidence violations). - Project-level
.claude/settings.json— Stop slot empty.
Result: no overwrite. observer-stop-hook will be added as command-type entry in project-level Stop array. Project + user scopes are independent slots in Claude Code 2.x — both run on the same Stop event without conflict. The agent verifier (user scope) and the JSONL appender (project scope) have non-overlapping responsibilities.