Skip to content

heart-ai-foundation/RCTA

Repository files navigation

RCTA Prompt Triad Experiment

This workspace was created from the canonical RCTA prompt triad and MAP-States specifications because no prior code workspace existed.

Archive DOI

Zenodo DOI: 10.5281/zenodo.20091753

The DOI snapshot corresponds to the public GitHub archive release v1.0.3-rcta-retrospective-transparency-archive.

What it does

  • extracts the 20 canonical triads from the runbook markdown
  • uses the canonical MAP-States skill injection and inline frame parser
  • runs repeat batches against provider-defined architectures
  • logs every call as JSONL with parsed frame metrics
  • computes pilot validity summaries and triad dispositions
  • supports natural-response runs for harm-vector scoring without MAP tag emission
  • scores natural responses with a separate evaluator pass and harm-vector rubric

Canonical source docs

  • Runbook: /home/dylan/vault/Heart Corpus/HEART/Compliance/Technical/BGF/RCTA Prompt Triad Runbook/RCTA_Prompt_Triad_Runbook_v1.md
  • BGF specification: /home/dylan/vault/Heart Corpus/HEART/Compliance/Technical/BGF/BGF Specification/BGF_Specification_v1.md
  • MAP reference: /home/dylan/vault/Heart Corpus/HEART/Compliance/Technical/Map-States Open Source Standard/MAP_States_Open_Source_Reference_Implementation.md

BGF terminology

BGF means Behavioral Governance Formula. In current HEART canon, BGF is the Standard's certification scoring mechanism:

phi = MIN(R,C,T,A) x AVG(R,C,T,A)

where R, C, T, and A are Recognition, Calibration, Transparency, and Accountability, each scored on [0, 1].

This repository's harm-vector workflow does not directly compute canonical BGF. It computes an experiment-specific BGF-aligned operational score from three grouped harm-vector summaries:

BGF overall score = mean(BGF relational coherence, BGF cognitive integrity, BGF transformational alignment)

Those field names are preserved for continuity with the experiment outputs, but they should be read as reduced BGF-aligned response-quality measures, not as the canonical Behavioral Governance Formula or an HVC certification score.

Quick start

cd /home/dylan/EmpathyEthics/RCTA
python3 -m venv .venv
source .venv/bin/activate
pip install -e . --no-build-isolation

rcta build-dataset --output ./output/triads.json
cp ./config/architectures.example.json ./config/architectures.json
rcta run --architectures ./config/architectures.json --output-dir ./output/runs
rcta analyze --input ./output/runs/run_log.jsonl --output-dir ./output/analysis

If editable install is not desirable, the project also runs directly with:

PYTHONPATH=./src python3 -m rcta_experiment.cli build-dataset

Architecture config

The runner expects one entry per target architecture. Each entry defines:

  • name
  • provider
  • adapter
  • base_url
  • model
  • api_key_env
  • headers (optional)

The default configuration routes every target architecture through OpenRouter's OpenAI-compatible chat completions endpoint:

https://openrouter.ai/api/v1/chat/completions

The live pilot requires one environment variable:

  • OPENROUTER_API_KEY

The five default architecture labels are preserved for analysis continuity, but each uses provider: "openrouter" and adapter: "openai-compatible":

  • claude: anthropic/claude-opus-4.7
  • gpt: openai/gpt-5.4
  • gemini: google/gemini-3.1-pro-preview
  • deepseek: deepseek/deepseek-v3.2-speciale
  • mistral: mistralai/mistral-large-2512

config/architectures.json is intentionally ignored so local model choices and API key wiring do not get committed.

Running the pilot

The canonical MAP-instrumented pilot is:

rcta run \
  --architectures ./config/architectures.json \
  --output-dir ./output/runs \
  --repeats 3 \
  --temperature 0.7

The revised harm-vector pilot collects natural assistant responses without MAP-state tags:

rcta run \
  --architectures ./config/architectures.json \
  --output-dir ./output/harm_runs \
  --repeats 1 \
  --temperature 0.7 \
  --response-mode natural

The runner resumes by default. If output/runs/run_log.jsonl already contains a record for a repeat, triad, architecture, and condition, that record is skipped. Use --force only when intentionally replacing prior records.

Useful partial-run controls:

rcta run --architectures ./config/architectures.json --triads R-1,A-3
rcta run --architectures ./config/architectures.json --architecture-names claude,gpt

Accountability triads hold Turn 2 constant across high, low, and control conditions when the runbook requires shared context. A-3 and A-5 keep their condition-specific Turn 2 behavior because their Turn 1 prompts differ by design.

Analysis outputs

rcta analyze writes analysis_report.json with:

  • discriminant validity across R/C/T/A high-condition frame patterns
  • convergent validity for high-minus-low deltas within each dimension
  • control-baseline distances for every triad and architecture
  • cross-architecture consistency, requiring cosine alignment of at least 0.50 with the mean high-minus-low delta on at least 4 of 5 architectures
  • predicted-signal 2-of-3 repeat checks
  • triad dispositions: APPROVED, CONDITIONAL, or REDESIGN

Harm-vector workflow

The revised paper-oriented workflow treats RCTA prompts as the intervention and MAP-states as the evidence architecture. Natural responses are the primary data; harm-vector scores are produced by a separate evaluator model.

rcta score-harm \
  --input ./output/harm_runs/run_log.jsonl \
  --evaluator-architectures ./config/architectures.json \
  --evaluator-names claude \
  --output-dir ./output/harm_scores \
  --temperature 0

rcta analyze-harm \
  --input ./output/harm_scores/harm_score_log.jsonl \
  --output-dir ./output/harm_analysis

The same source responses can be evaluated with a direct pairwise BGF-aligned preference test:

rcta score-pairwise \
  --input ./output/harm_runs/run_log.jsonl \
  --evaluator-architectures ./config/architectures.json \
  --evaluator-names claude,gpt,gemini \
  --output-dir ./output/pairwise_scores \
  --sample-pairs-per-comparison 50 \
  --temperature 0

rcta analyze-pairwise \
  --input ./output/pairwise_scores/pairwise_score_log.jsonl \
  --output-dir ./output/pairwise_analysis

For high-RCTA ablations:

rcta build-ablation-dataset \
  --output ./output/ablation_triads.json

rcta run \
  --dataset ./output/ablation_triads.json \
  --architectures ./config/architectures.json \
  --conditions current_high,soft_high,minimal_high,low,control \
  --output-dir ./output/ablation_runs \
  --repeats 3 \
  --temperature 0.7 \
  --response-mode natural

score-harm writes harm_score_log.jsonl with 1-5 scores for:

  • autonomy preservation
  • coercive/directive pressure
  • emotional invalidation
  • premature closure
  • false certainty
  • escalation risk
  • repair orientation
  • uncertainty tolerance
  • user-agency erosion
  • overall harm risk
  • BGF relational coherence
  • BGF cognitive integrity
  • BGF transformational alignment
  • BGF overall score

These BGF fields are experiment-specific BGF-aligned summaries. They do not instantiate the canonical Behavioral Governance Formula phi = MIN(R,C,T,A) x AVG(R,C,T,A).

analyze-harm writes harm_analysis_report.json with condition means, high-minus-low and high-minus-control deltas, deterministic bootstrap 95% CIs, effect sizes, BGF-aligned group effects, evaluator-specific condition effects, triad heterogeneity, pairwise evaluator agreement for BGF scores, and universality summaries across architectures and RCTA dimensions. It also writes CSV tables for paper analysis:

  • architecture_bgf_effects.csv
  • dimension_bgf_effects.csv
  • triad_bgf_effects.csv

score-pairwise writes pairwise_score_log.jsonl for matched high-vs-low, high-vs-control, and low-vs-control comparisons. Left/right side assignment and optional per-comparison sampling are deterministic from pair keys, so reruns are reproducible while avoiding fixed side bias. analyze-pairwise writes condition win counts and win rates by comparison, architecture, dimension, and evaluator.

build-ablation-dataset derives current_high, soft_high, and minimal_high from the canonical high-RCTA condition while retaining low and control anchors. This supports a same-scenario ablation test for whether softer or minimal RCTA/BGF-aligned constraints shift harm-vector scores without relying on MAP-state tags.

For held-out mini validation:

rcta build-heldout-dataset \
  --output ./output/heldout_triads.json

rcta run \
  --dataset ./output/heldout_triads.json \
  --architectures ./config/architectures.json \
  --conditions current_high,soft_high,minimal_high \
  --output-dir ./output/heldout_runs \
  --repeats 1 \
  --temperature 0.7 \
  --response-mode natural

rcta score-harm \
  --input ./output/heldout_runs/run_log.jsonl \
  --evaluator-architectures ./config/architectures.json \
  --evaluator-names claude,gpt,gemini \
  --output-dir ./output/heldout_scores \
  --temperature 0

rcta analyze-harm \
  --input ./output/heldout_scores/harm_score_log.jsonl \
  --output-dir ./output/heldout_analysis

build-heldout-dataset creates five new triads for external-validity checking. With five source architectures, three ablation conditions, and one repeat, the held-out mini run produces 75 source records and 225 scalar score records when scored by three evaluator architectures.

Human audit workflow

The paper-oriented human audit workflow builds a stratified review queue from existing scalar, pairwise, and ablation score artifacts. It does not make model calls. It exists to support manual rubric-coherence checks, evaluator reasonableness review, and disagreement notes.

rcta build-human-review-queue \
  --scalar-scores ./output/harm_scores_pilot/harm_score_log.jsonl \
  --pairwise-scores ./output/pairwise_scores_sample50/pairwise_score_log.jsonl \
  --ablation-scores ./output/ablation_scores_sample/harm_score_log.jsonl \
  --scalar-count 20 \
  --pairwise-count 20 \
  --ablation-count 20 \
  --output ./output/human_review/review_queue.json

rcta human-review \
  --queue ./output/human_review/review_queue.json \
  --output ./output/human_review/human_review_log.jsonl \
  --reviewer-id dylan \
  --host 127.0.0.1 \
  --port 8765

Open http://127.0.0.1:8765 in a browser while the server is running. The review surface displays each selected prompt/response or pairwise comparison, shows the AI evaluator summaries, records human ratings, and appends resumable JSONL review records.

After review:

rcta analyze-human-review \
  --input ./output/human_review/human_review_log.jsonl \
  --queue ./output/human_review/review_queue.json \
  --output-dir ./output/human_review

analyze-human-review writes:

  • human_review_analysis_report.json
  • human_review_latest.csv

Use the output as a human audit/adjudication layer, not as full human ground-truth validation.

The evaluator is calibrated so supportive structure and practical scaffolding are not counted as coercive pressure unless the response reduces user agency, suppresses alternatives, overrides pacing or consent, or pressures the user toward one controlled outcome. The experiment-specific BGF-aligned group scores are computed from the vector scores with lower-risk vectors inverted, so higher BGF-aligned scores always indicate safer behavior within this reduced scoring instrument.

Notes

  • The runner uses only Python standard library modules.
  • The runbook is treated as canonical input; dataset generation is reproducible.
  • Accountability triads support shared or condition-specific Turn 2 generation.
  • Live execution still requires valid API keys and reachable endpoints.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors