Personas

Persona lifecycle for consensus-tools — packs, deterministic reputation updates, and respawn with learning.

Overview

@consensus-tools/personas provides the persona lifecycle for consensus-tools: built-in persona packs, a deterministic reputation update engine, and persona respawn when a reviewer's accuracy degrades.

Installation

pnpm add @consensus-tools/personas

Quick start

import { getPersonasByPack, getEvalPersonas, PERSONA_PACKS } from "@consensus-tools/personas";

// Get governance personas (PersonaConfig[])
const voters = getPersonasByPack("governance");

// Get evaluation personas with systemPrompt + evaluationFocus (EvalPersonaConfig[])
const evalPersonas = getEvalPersonas("default", 3);

// List available pack names
console.log(PERSONA_PACKS); // ["default", "skill-review", "governance"]

Persona packs

Three built-in packs of personas ready to use:

PackCountFocus
default3Security analyst, compliance officer, operations engineer
skill-review5Specialists for SKILL.md evaluation (doc-architect, api-accuracy, agent-usability, completeness-auditor, style-guardian)
governance5Lifecycle personas for consensus voting (with reputation)

API reference

Reputation updates

Deterministic reputation engine. Aligned voters gain reputation, misaligned voters lose it, with a confidence penalty boost for high-confidence wrong votes.

import { updateReputation, DEFAULT_RULESET } from "@consensus-tools/personas";

const votes = [
  { persona_id: "security-analyst", vote: "NO", confidence: 0.9 },
  { persona_id: "compliance-officer", vote: "YES", confidence: 0.7 },
];

const result = updateReputation(votes, "BLOCK", voters, DEFAULT_RULESET);
// result.changes: ReputationChange[] — per-persona delta and new reputation

Default ruleset:

ParameterValueEffect
rewardAligned+0.02Aligned with final decision
penalizeMisaligned-0.03Disagreed with final decision
highConfidencePenaltyBoost-0.02Extra penalty for confident wrong votes
minRep0.05Floor — personas are never fully silenced
maxRep0.95Ceiling

Persona respawn

When a persona's reputation drops too low, analyze its mistakes and create a successor:

import { buildLearningSummary, mutatePersona } from "@consensus-tools/personas";

// Analyze past decisions to find mistake patterns
const learning = buildLearningSummary("security-analyst", decisionHistory);
// learning: { source_decisions: number, mistake_patterns: string[] }

// Create a successor persona informed by learning
const successor = mutatePersona(originalPersona, learning);
// successor: PersonaConfig with updated bias/non_negotiables

Automatic respawn in universal

@consensus-tools/universal calls these functions automatically when a persona's reputation drops below respawnThreshold (default 0.15). You only need this package directly if you're managing the persona lifecycle yourself.

Exports reference

ExportKindDescription
getPersonasByPack(pack)FunctionGet lifecycle personas by pack name
getEvalPersonas(pack, count?)FunctionGet evaluation personas with prompt fields
PERSONA_PACKSConstList of available pack names
updateReputation(votes, truth, voters, ruleset)FunctionDeterministic reputation update engine
DEFAULT_RULESETConstDefault reputation update rules
buildLearningSummary(id, history)FunctionAnalyze past decisions for mistake patterns
mutatePersona(persona, learning)FunctionCreate successor persona from learning
PersonaConfigTypeBase persona (id, name, role, reputation?, bias?)
EvalPersonaConfigTypeEvaluation persona (extends PersonaConfig with systemPrompt, evaluationFocus)
PersonaSetTypeSet of personas with metadata and lineage
ReputationRulesetTypeConfigurable reputation update rules
ReputationChangeTypeOne persona's reputation delta
ReputationDeltaResultTypeFull reputation update result
LearningSummaryTypeLearning analysis from decision history
RespawnResultTypeResult of a persona respawn operation
  • universal -- uses personas for LLM mode deliberation and automatic respawn
  • evals -- ReputationTracker wraps this engine for A/B eval workflows