terraphim / terraphim/terraphim-ai
Constitutional guardrails (CONSTITUTION.md) for agent supervisor
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 62
- Forks
- 5
- Avg merge
- 2h 27m
- Merged PRs (30d)
- 1
Description
Summary
Create an immutable set of architectural principles (CONSTITUTION.md) that terraphim agents cannot violate, even when given explicit instructions to do so. Enforced by terraphim_agent_supervisor as a pre-execution validation step.
Motivation
Inspired by Ouroboros BIBLE.md pattern. The agent system crates are incomplete partly because there is no specification of what agents MUST NOT do. A constitution constrains the design space, making it easier to complete the agent layer because boundaries are clear.
Proposed Principles
- Privacy-first: No data leaves the device unless explicitly configured by the user
- Deterministic-first: Prefer Aho-Corasick automata over LLM when deterministic matching suffices
- Type-safe: No
unwrap()in library crates; all errors propagated viaResult - Compile-time checked: Prefer compile-time guarantees over runtime reflection
- Local-first: Offline operation is the default; network is optional
- Auditable: Every agent decision must be traceable to an input and a rule
- Reversible: Agent actions should be reversible where possible; destructive actions require confirmation
Implementation Plan
- Create
CONSTITUTION.mdat repo root with the principles above (editable by maintainers, versioned in git) - Embed as a compile-time resource via
rust-embed(already used interraphim_agentanddesktop) - Add
ConstitutionValidatortoterraphim_agent_supervisor:- Pre-execution hook: check proposed agent action against constitution rules
- Rules encoded as structured checks (not LLM interpretation)
- Violation = action rejected with reason, logged as event
- Cryptographically sign the constitution using existing
zipsigninfrastructure fromterraphim_update - Add integration tests: attempt constitutional violations, verify rejection
Affected Crates
terraphim_agent_supervisor(primary -- add validation)terraphim_types(addConstitutionRuletype)terraphim_agent(embed constitution resource)
Estimated Effort
~2 hours
Part of
Epic #595
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the affected crates listed in the issue: terraphim_agent_supervisor, terraphim_types, and terraphim_agent, then inspect the existing rust-embed and zipsign usage. Define the constitution resource, structured validation and signing boundaries, and integration tests for rejected violations. Done means the documented rules are embedded, validated before execution, logged on rejection, and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- ai, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100