terraphim / terraphim/terraphim-ai

Constitutional guardrails (CONSTITUTION.md) for agent supervisor

Ouverte
#596 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

architecture enhancement multi-agent
Langage dominant
Rust
Étoiles
62
Forks
5
Merge moyen
2 h 27 min
PR mergées (30 j)
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

  1. Privacy-first: No data leaves the device unless explicitly configured by the user
  2. Deterministic-first: Prefer Aho-Corasick automata over LLM when deterministic matching suffices
  3. Type-safe: No unwrap() in library crates; all errors propagated via Result
  4. Compile-time checked: Prefer compile-time guarantees over runtime reflection
  5. Local-first: Offline operation is the default; network is optional
  6. Auditable: Every agent decision must be traceable to an input and a rule
  7. Reversible: Agent actions should be reversible where possible; destructive actions require confirmation

Implementation Plan

  1. Create CONSTITUTION.md at repo root with the principles above (editable by maintainers, versioned in git)
  2. Embed as a compile-time resource via rust-embed (already used in terraphim_agent and desktop)
  3. Add ConstitutionValidator to terraphim_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
  4. Cryptographically sign the constitution using existing zipsign infrastructure from terraphim_update
  5. Add integration tests: attempt constitutional violations, verify rejection

Affected Crates

  • terraphim_agent_supervisor (primary -- add validation)
  • terraphim_types (add ConstitutionRule type)
  • terraphim_agent (embed constitution resource)

Estimated Effort

~2 hours

Part of

Epic #595

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rust
Domaine
ai, backend
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.