Files
portal/docs/observer
Дмитрий f7f37fb4e4 docs(brain): observer factor-analysis extension — normative sync
ADR-011 amended: +Decision §5 (observer v2 four-layer), §3 4→5
controllers (+C5), Enforcement +routing-gate + C5 bullets, related
+factor-analysis spec/plan.

Pravila v1.31→v1.32: §16.2 +абзац «Схема эпизода v2», §16.3 4→5
контролёров (+C5 row), +§16.7 routing-тег-дисциплина (mechanical
Stop-hook decision:block, stop_hook_active loop guard), +§16.8
самодисциплина наблюдателя (observer_error marker, parse_gap event,
C5 lefthook warn-only), §16.6 +cross-refs на factor-analysis spec/plan.

PSR_v1 v3.16→v3.17: R16.1 +предложение про schema v2 поля и
расширенные события; R16.4 +cross-refs.

Tooling Прил. Н v2.17: §0 cross-ref strings 1.31/3.16 → 1.32/3.17
(no header version bump).

brain-governance spec: related +factor-analysis spec.
observer-factor-analysis-design.md: status draft→accepted.

CLAUDE.md v2.19: §0 Pravila/PSR_v1 cross-refs bumped to v1.32/v3.17
with v2 summary prepended (legacy preserved as «v1.31 наследие» /
«v3.16 наследие»); §3.6 appended observer schema v2 + routing-gate +
C5 + brain-retro analyzer paragraph; §9 +v2.19 entry.

cross-ref-checker: 0 drift in 4 files.

Plan: docs/superpowers/plans/2026-05-19-observer-factor-analysis.md
Spec: docs/superpowers/specs/2026-05-19-observer-factor-analysis-design.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 11:08:55 +03:00
..

Observer infrastructure

Passive evidence-loop for the Лидерра «brain» per ADR-011.

Files

  • episodes-YYYY-MM.jsonl — append-only JSONL, one line per Stop-event. Schema v2 (schema_version: 2): the 5 mandatory fields + decision_provenance (who chose the node), environment (economy_level / model / post_compaction / session_turn / parallel_session), task_size, task_ref, prompt_signal, and an outcome that is unknown at write time (refined by /brain-retro). On an internal hook failure a minimal observer_error marker line is written instead of a silent skip. Written by tools/observer-stop-hook.mjs via tools/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 by tools/status-md-generator.mjs.
  • .read-counter.json — C3 observer-of-observer counter. Updated on Read of observer files.

Lifecycle

  1. Write: every Stop-event appends one JSONL line, parsed from the session transcript (Stop-hook).
  2. Aggregate: /brain-retro skill reads JSONL each sprint, proposes regulatory candidates.
  3. Surface: STATUS.md shows controllers + monthly stats.
  4. Self-prune: C3 warns if 54 weeks pass without any read of observer files.

Routing-tag discipline

When the user dictates a specific method/node (e.g. «запусти discovery-interview»), Claude must emit one line in its response:

<!-- routing: provenance=user_directed_method node=<chosen> counterfactual=<node Claude would have chosen autonomously> -->

The Stop-hook routing-gate (tools/observer-routing-detector.mjs + routingGateDecision) detects a dictated method; if the tag is missing it returns decision: block, so the turn cannot end without the tag. The gate fires at most once per turn (stop_hook_active guard). This makes decision_provenance reliable — factor analysis can separate a router error from a user-dictated one.

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-*.jsonl manually — it's append-only.
  • Don't write outside docs/observer/notes/ for hand-curated notes.
  • Don't change .read-counter.json manually — 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.json already 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.