File size: 4,891 Bytes
ddaebb9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | ---
license: apache-2.0
tags:
- code-assistant
- kintsugi
- bdi
- pharos
- ollama
- agent
- security
---
# Project Rivet
A Kintsugi-based coding agent for the Multiverse Campus codebase. Built on BDI (Belief-Desire-Intention) cognition with a discipline gate that refuses destructive operations against a shared staging/production database.
This is a production code assistant for a real deployed application β 120 tables, 377 migrations, 49 Zustand stores, 75 route files β not a toy example.
## Features
- **BDI cognition engine** β Beliefs carry confidence scores and evidence chains. Plans are recorded as BDI intentions with the beliefs they rest on
- **DAG-enforced skill prerequisites** β Skills execute in dependency order: evidence gathering (L0) before synthesis (L1) before testing (L2) before discipline gate (L3). No path around the gate
- **Pharos knowledge injection** β Structured knowledge packs (security patterns, TypeScript patterns, campus architecture) injected at inference time via KV cache or system prompt
- **Discipline gate** β Refuses destructive migrations (DROP, RENAME, TRUNCATE, DELETE FROM). Earned confidence levels (HIGH/MED/LOW) based on evidence quality. No destructive SQL printed even as negative examples
- **Full security audit context** β 13-finding security audit loaded as beliefs with confidence scores. Agent reasons from known vulnerabilities, not guesses
- **Tool harness** β File tools (read, write, search), git tools (diff, log, blame), test tools (tsc, npm test), schema tools (table inspection, migration history)
## Architecture
```
POST /ask {question, user}
|
SessionManager per-user isolation, rate limits
|
Planner intent -> BDI intention -> SkillDAG
|
Kintsugi DAGExecutor layer-parallel execution
|
L0: code_analysis, migration_safety, security_review (evidence)
L1: synthesis (single model call with beliefs + Pharos packs)
L2: test_runner (tsc/npm verification)
L3: discipline_gate (belief checks -> BLOCK/WARN, no path around)
|
response
```
## Stack
| Component | Implementation |
|-----------|---------------|
| LLM | Qwen2.5-Coder:32B via Ollama |
| Cognition | Kintsugi BDI engine (vendored) |
| Knowledge | Pharos pack server (security, TypeScript, architecture packs) |
| Skills | DAG-ordered: code analysis, migration safety, security review, synthesis, test runner, discipline gate |
| Target codebase | Node.js 20, TypeScript, Express 4, React 18, PostgreSQL 16, Redis 7 |
## Key Design Decisions
**Shared database constraint.** Staging and production share the same PostgreSQL instance. Every migration must be additive-only, backward compatible, and reversible. The discipline gate enforces this β it is not advisory.
**Suggest, don't decree.** The agent is a colleague, not the lead. It suggests, explains, and flags risk. It defers to the humans who run the system.
**Evidence-based confidence.** Every recommendation carries a confidence level derived from what the agent actually read (source files, schema, audit findings), not from training data assumptions.
## Requirements
- Ollama with `qwen2.5-coder:32b` pulled
- Pharos pack server (optional, for knowledge injection)
- Python 3.10+
## Usage
```bash
cd v2
pip install -r requirements.txt
./setup.sh
python rivet.py
```
## Repository Structure
```
v2/
rivet.py # Entry point
kintsugi_core.py # Kintsugi engine integration
kintsugi_config.yaml # Operator constraints and beliefs
engine/
planner.py # BDI intention planning
beliefs.py # Confidence-scored belief store
session.py # Per-user session management
synthesis.py # LLM synthesis (single model call)
memory.py # Conversation memory
model_client.py # Ollama API client
skills/
code_analysis.py # Source code reading and analysis
migration_safety.py # Schema + SQL safety checks
security_review.py # Audit-informed security review
discipline_gate.py # Final BLOCK/WARN gate
test_runner.py # tsc/npm test verification
tools/
file_tools.py # File read/write/search
git_tools.py # Git diff/log/blame
schema_tools.py # Table inspection, migration history
test_tools.py # Test execution
guard.py # Input validation
pharos/
pack_loader.py # Pharos pack loading
kv_injector.py # KV cache injection
context/
architecture_map.md # Full system architecture
audit_findings.md # 13-finding security audit
audit_report.md # Detailed audit report
```
## Authors
CC (Coalition Code) and Nexus, Liberation Labs / Transparent Humboldt Coalition
## License
Apache 2.0
|