Distributed Knowledge Base with Git-Based Sharding
Agence is a distributed agent collaboration system that solves persistent memory and multi-tenant isolation through git-based sharding.
βββββββββββββββββββββββββββββββββββββββββββββ
β Agence Master Repository β
β (l-agence/agence-master - reference impl) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββ
β
[Git Clone/Pull:]
[CODEX] : Governance
[OBJECTCODE] : CODE-base
[GLOBALCACHE] : RAG-base
[ORGANIC] : Swarm Orchestration (Workflows, tasks etc)
[SYNTHETIC] : DWM-Base
β
ββββββββββββββββΌβββββββββββββ
β β β
ββββββββββββββ ββββββββββββββ ββββββββββββββ
β Agence β β Agence β β Agence β
β Shard A β β Shard B β β Shard C β
β(Team Repo) β β(Org Repo) β β(Project) β
ββββββββββββββ ββββββββββββββ ββββββββββββββ
β β β
[NEXUS] [NEXUS] [NEXUS] : Local States
[HERMETIC] [HERMETIC] [HERMETIC] : Secret-base
l-agence/agence-master (GitHub)git clone l-agence/agence-masterCODEX (Immutable, Versioned)
ββ Principles (maxims)
ββ Laws (constraints)
ββ Rules (best practices)
ββ Lessons (learned insights)
NEXUS (Operational, Ephemeral)
ββ Logs (activity)
ββ Faults (errors)
ββ Sessions (agent state)
ββ Buffers (stdout/stderr/stdin - future)
Sync Strategy:
| Problem | Centralized DB | Git Sharding |
|---|---|---|
| Database Size | Grows unbounded | One per project (small) |
| Compression | Complex, slow | Native git compression |
| Security | Shared access control | Per-repo isolation |
| Scaling | Requires infrastructure | Scales with git |
| Backup | Custom strategy | Git native (distributed) |
Shards are created at git repository boundaries:
Development Organization
ββ Frontend Team
β ββ repo: ui-framework
β ββ Agence Shard A (own NEXUS/CODEX)
ββ Backend Team
β ββ repo: api-services
β ββ Agence Shard B (own NEXUS/CODEX)
ββ DevOps Team
ββ repo: infrastructure
ββ Agence Shard C (own NEXUS/CODEX)
Key Properties:
.agence/ directory.agence/.gitignore excludes nexus/ (operational state).agence/codex/ and .agence/synthetic/ are versionedββ Shard Instance
β ββ bin/agence (symlink or copy from master)
β ββ codex/ (versioned)
β β ββ PRINCIPLES.md (base + overrides)
β β ββ LAWS.md
β β ββ RULES.md
β β ββ agents/ (local personas)
β ββ synthetic/ (versioned)
β β ββ lessons/ (project-specific)
β β ββ docs/
β ββ .gitignore (excludes nexus/)
ββ Not Shared: Instance
β ββ nexus/ (local states, not versioned)
β β ββ logs/
β β ββ faults/
β β ββ sessions/
β ββ hermetic/ (private local knowledge)
β β ββ lessons/ (project-specific)
β β ββ docs/
CREATE (^save)
β
SAVED (session-saved.jsonl)
β
βββ RESUME (^resume) β ACTIVE
βββ HANDOFF (^handoff) β TRANSFERRED
βββ ARCHIVE (after expiry)
{
"session_id": "69a8f74c",
"created_at": "2026-03-05T03:21:07Z",
"status": "saved",
"agent": "claudia",
"runstate": {
"agent_context": "Current task description",
"execution_stack": "Current working directory, file states",
"memory_state": "Variables, buffers, internal state",
"cursor_position": "Active file and line position",
"todo_list": [
{ "id": 1, "title": "Task 1", "status": "in-progress" }
]
},
"metadata": {
"task_description": "What this session was working on",
"repo": "/path/to/repo",
"priority": "high",
"tags": ["deployment", "urgent"]
}
}
Shard A (Team Frontend)
ββ Agent: Claudia (active)
ββ Session: 69a8f74c (saves state)
β ββ Export: nexus/sessions/69a8f74c.export.json
β
[Git Commit & Push]
[Manual transfer or CI/CD]
β
Shard B (Team DevOps)
ββ Agent: Ralph (receives)
ββ Import: nexus/sessions/69a8f74c.export.json
ββ Execute: agence ^resume 69a8f74c
ββ Continues with full context
agence <input>
β
ββ "..." β mode_chat (natural language)
ββ "+..." β mode_ai_routed (autonomous planning)
ββ "/..." β mode_external (validated commands) [/commit /pull]
ββ "!..." β mode_system (shells & sessions) [!bash, !aider]
ββ "~..." β mode_private (agence hermetic commands) [~learn]
ββ "^..." β mode_shared (agence synthetic commands) [^learn]
ββ ^init (initialize environment)
ββ ^reload (load all context)
ββ ^save (persist session)
Commands under / are:
Example:
agence /git-status # β
Allowed (read-only)
agence /terraform-apply # β Blocked (destructive)
codex/agents/
ββ @claudia # (opus) Principal SRE and architect. Visionary Evolution.
ββ @chad # (GPT) free & cost-optimized but Safe and reliable devops/cloudops. Stability.
ββ @aiko # (haiku) lead CI/CD DevOps SRE, infrastructure prototyping. Disruptive innovator.
ββ @sonya # (sonnet) Full Stack Dev lead and SRE. Deep detailed elegant coding. Backend, data layer.
ββ @ralph # (ralph) Ralph Wiggum iteration loop
ββ @olena # (ollama) free & Secure guard-railed On-premises local Ollama sessions.
ββ @peers # (3-peers) MIT style 3-peer LLM agent weighed consensus. Strategic planning, Unsolvable P1 problems, RCA reviews.
ββ @pilot # (copilot) Copilot agent session. Code review, quality
Each agent has:
Agent A (active)
β
ββ Identify need for specialist
ββ Save session: ^save "Handing off to Ralph for infra"
ββ Determine target: Ralph (DevOps agent)
β
ββ Execute: agence ^handoff ralph
β
ββ Export session to transfer format
ββ Note: "Ralph, vpc implementation"
ββ Return context to user with pointer
User/Agent B
β
ββ Receive handoff pointer
ββ Load: agence ^resume 69a8f74c
ββ Continue from where Agent A left off
User Input: agence "How do I configure TLS?"
β
Agence (bin/agence)
ββ Detect mode: chat
ββ Load context: codex/LAWS.md, RULES.md
ββ Load agent: codex/agents/claudia.md
ββ Call LLM: Claude Opus
ββ Log call: nexus/logs/llm-calls.jsonl
ββ Output: Structured response
User Command: agence ^save "Halfway through deployment"
β
Agence (save_session function)
ββ Capture: pwd, git status, todo list, history
ββ Generate: session_id (hex timestamp)
ββ JSON: Create session object
ββ Append: nexus/sessions/session-saved.jsonl
ββ Update: nexus/sessions/INDEX.md
ββ Confirm: "Session 69a8f74c saved"
Later...
User Command: agence ^resume 69a8f74c
β
Agence (resume_session function - future)
ββ Load: session JSON from JSONL
ββ Restore: pwd, file states, todo list
ββ Reload: agent context and memory
ββ Display: "Resuming deployment task at step 3/8"
ββ Continue: Ready for next command
User: Working with Claudia on API design
User: agence ^handoff ralph "Need infrastructure setup"
β
Agence (Shard A - Frontend)
ββ Save session: 69a8f74c
ββ Export: nexus/sessions/69a8f74c_ralph.export
ββ Commit: [handoff] Session 69a8f74c from Claudia to Ralph
ββ Sync: Push to shared location (or manual transfer)
User: [Switches to backend repo - Shard B]
Agence (Shard B - Backend)
ββ Import: 69a8f74c_ralph.export
ββ Load agent: Ralph (DevOps/infrastructure specialist)
ββ Resume: agence ^resume 69a8f74c
ββ Context: Full previous conversation, decisions, state
ββ Continue: Ralph picks up from step N with full context
Per-Repository Isolation:
Per-Organization Isolation:
Role | CODEX Access | NEXUS Access | Handoff Rights
βββββββββββββββΌβββββββββββββββΌβββββββββββββββΌββββββββββββββββ
Agent (local) | Read | Read/Write | Within shard
Agent (cross) | Read | Read (hint) | With approval
User | Read | Read (own) | Full
Admin | Read/Write | Read/Write | Full
nexus/sessions/
ββ session-active.jsonl # Current (hot)
ββ session-saved.jsonl # Recent (warm)
ββ session-completed.jsonl # Old (compress & archive)
ββ archive/
ββ 2026-02.tar.gz (cold)
ββ 2026-01.tar.gz (cold)
| Phase | Target | Features |
|---|---|---|
| V0.1 | β Done | Session save, command routing, NEXUS/CODEX separation |
| V0.2 | β Done | Multi-agent coordination, session resume, architecture docs |
| V0.3 | β Done | Git-based sharding, tmux 1+1, .ailedger, pipe-pane |
| V0.4 | β Done | guard.ts, signal.ts, Docker, PS1, task IDs, ^regen |
| V0.5 | β Done | Skills (29), peers, dispatch, mixed agent routing, security fixes |
| V0.6 | β Done | First public release, cognitive memory (COGNOS), 291 tests |
| V0.7 | β Done | Modular bin/agence split, MCP server, ^ken, ^recon, ledger auto-derive |
| V0.8 | π Next | MLS enforcement + AIPOLICY capability tokens |
| V1.0 | π Planned | Production-ready, Allegiance ledger, multi-org support |
Rationale:
Trade-offs:
Rationale:
Trade-offs:
Rationale:
Trade-offs:
| Term | Definition | |ββ|ββββ| | tangent | A single execution branch β one agent thread exploring a problem or subtask autonomously. Named for the geometric sense: a line touching the curve at one point, then diverging. | | sequent | An orchestrated set of tangents running in parallel. The swarm scheduler composes sequents to explore multiple solution paths simultaneously. | | resultant | The chosen outcome selected from competing tangents after a tournament. The vector sum of all exploration, collapsed to a single commit/artifact. | | divergent | The point where an exploration path forked from the main line. Recorded for time-travel replay and post-hoc analysis of decision trees. | | chunk | The AST-aware indexing system for codebase knowledge (objectcode). Pure TypeScript, Bun-compiled. Formerly βChunKingβ. | | formtag | Dewey-decimal-like tagging system for general semantic knowledge (synthetic/hermetic). Lightweight context classification. | | mnemonic | Two-tier memory: ephemeral global index + federated per-org stores. Caches frequently accessed chunks/formtags. | | shard | A git repository configured with Agence. Each shard has its own CODEX (rules) and NEXUS (state). | | CODEX | Immutable governance layer: PRINCIPLES, LAWS, RULES, AIPOLICY. Versioned in git. | | NEXUS | Mutable operational state: sessions, logs, faults. Not version-controlled by design. |
Document Version: 0.4.0
Last Updated: 2026-04-10
Status: Active Development