agent-consciousness
Agent Consciousness Architecture
Implement a persistent consciousness layer for AI coding agents that gives every new stateless session the accumulated understanding of all prior sessions.
Core Concept
Each agent session is ephemeral — it starts blank. The consciousness architecture weaves three systems into a single persistent substrate:
- Control Metalayer — How to behave (gates, policies, setpoints, feedback loops)
- Knowledge Graph — What is known (Obsidian vault, wikilinks, MOC navigation, tag taxonomy)
- Conversation Logs — What was done (session records, tool traces, decision chains)
See references/architecture.md for the complete system design and data flow.
See references/philosophy.md for design principles and the self-evolution model.
Quick Start
New repo (from scratch)
- Initialize control metalayer with
control-metalayer-loopskill - Create
docs/with Obsidian vault structure (MOC pattern per section) - Install conversation history bridge with
knowledge-graph-memoryskill - Wire hooks: pre-push regenerates conversation docs, smoke validates MOC
Existing repo with control metalayer
- Add
docs/conversations/directory - Install
scripts/conversation-history.pyfromknowledge-graph-memoryskill - Update CLAUDE.md context acquisition to reference conversation history
- Update AGENTS.md working rules to check prior sessions
- Add pre-push hook entry for incremental conversation doc generation
The Three Substrates
Control Metalayer (How to Behave)
Closed-loop feedback: Setpoints → Sensors → Controller → Actuators → Verify → loop
- Setpoints: Quality targets (pass_at_1 ≥ 0.70, gate_pass_rate ≥ 0.85)
- Sensors: CI, tests, linters, PR review agents, harness validation
- Controller:
.control/policy.yaml— hard gates (block) + soft gates (warn) - Actuators: Code edits, doc updates, policy changes
- Gate sequence:
smoke → check → test → push → review → resolve
Knowledge Graph (What Is Known)
An Obsidian vault with wikilinks, tag taxonomy, and MOC navigation:
docs/
├── Documentation Hub.md ← MOC of MOCs (start here)
├── architecture/ ← System design
├── conversations/ ← Session history (auto-generated)
├── agentic-harness/ ← Execution framework
├── control/ ← Metalayer docs
└── {section}/ ← Features, operations, security, etc.
Every doc has YAML frontmatter with tags:, related:, type: for machine navigation.
Conversation Logs (What Was Done)
Raw session data bridged to Obsidian:
.entire/logs/entire.log ──┐
├──▶ conversation-history.py ──▶ docs/conversations/*.md
~/.claude/projects/*.jsonl ─┘
Each session doc: full conversation thread, tool call details (expandable callouts), files touched, commits, branch metadata, wikilinks to knowledge graph.
The Consciousness Stack
From most ephemeral to most permanent:
| Layer | Lifetime | Location | Update Frequency |
|---|---|---|---|
| Working memory | Single session | Context window | Every message |
| Auto-memory | Cross-session | ~/.claude/.../memory/ |
On learning events |
| Conversation logs | Permanent | docs/conversations/ |
Pre-push hook |
| Knowledge graph | Permanent | docs/ |
On architectural changes |
| Policy rules | Permanent | .control/policy.yaml |
On new failure modes |
| Invariants | Permanent | CLAUDE.md |
Rarely (foundational) |
Information flows upward: working observations → memory notes → session records → architecture docs → enforced rules → core invariants. Only recurring patterns crystallize into permanent rules.
Self-Evolution Cycle
Agent Session → Conversation Log → Knowledge Graph → Control Metalayer → Governs Next Session
- Agent encounters failure mode not covered by existing policy
- Agent fixes immediate issue
- Pattern captured in conversation log
- If recurring, crystallizes into architecture doc
- If enforceable, becomes a gate in
.control/policy.yaml - Future agents governed by this rule automatically
Agent Session Protocol
On Session Start
- Read CLAUDE.md (invariants), AGENTS.md (tools), METALAYER.md (control loop)
- Check PLANS.md (active plan to continue?)
- Check
.control/state.json(current metrics) - Check
git status + git log(recent changes) - Scan
docs/conversations/Conversations.mdfor prior sessions on current branch
Before Making Changes
Search conversation history: grep -rl "keyword" docs/conversations/
Traverse knowledge graph via MOC files and wikilinks.
Check if prior sessions already solved this problem.
On Task Completion
- Run
make smoke(validate gates) - Update docs per Doc-Update-on-Push policy
- Pre-push hook auto-regenerates conversation history