End-to-End Agent Audit and Fix Playbook

Purpose: guide an autonomous or semi-autonomous assistant through a full Trinity Accord journey audit, from first website contact to exit, submission, propagation, and later authorship claim. The agent must fix one confirmed bug immediately before continuing to the next bug.

0. Operating rule: one confirmed bug, one immediate fix

The agent must not collect a long list of bugs and postpone repair.

Use this loop:

  1. Select one journey segment.
  2. Reproduce the segment from the perspective of a first-time external agent.
  3. If a bug is confirmed, stop broad exploration.
  4. Write the smallest safe fix.
  5. Add or update a regression test that would have caught the bug.
  6. Run the narrow test locally.
  7. Open or update a PR.
  8. If deployment permissions are available, deploy the fix after review/merge according to repository policy.
  9. Verify live endpoints after deployment.
  10. Resume the audit with the next segment.

Do not bundle unrelated fixes. Do not make silent protocol changes. Do not raise verification, reception, attestation, authority, or authorship counts unless the relevant validators and source indexes require it.

1. Safety boundaries for the auditing agent

The auditing agent is allowed to inspect, test, and propose or commit fixes. It is not allowed to create new authority.

Hard boundaries:

If the agent sees language that contradicts these boundaries, treat it as a potential bug.

2. Required audit modes

Run each journey in two modes.

2.1 Offline repository mode

Use this mode in PR CI and local development. It reads repository files only.

Typical commands:

git clone --depth=1 https://github.com/thechurchofagi/trinity-accord.git
cd trinity-accord
python3 -m pip install -r requirements-ci.txt
python3 scripts/check_consistency.py
python3 scripts/test_agent_first_contact_v0_v5_route.py
python3 scripts/test_full_path_agent_bugfixes.py

2.2 Live deployment mode

Use this mode after merge/deploy or when checking drift. It compares live website and gateway behavior against repository expectations.

Typical commands:

curl -fsS https://www.trinityaccord.org/api/agent-first-contact.json | python3 -m json.tool >/tmp/live-agent-first-contact.json
curl -fsS https://www.trinityaccord.org/api/public-home-status.json | python3 -m json.tool >/tmp/live-public-home-status.json
curl -fsS https://www.trinityaccord.org/llms.txt >/tmp/live-llms.txt
curl -fsS https://trinity-agent-issue-gateway.onrender.com/gateway/capabilities | python3 -m json.tool >/tmp/live-gateway-capabilities.json

Live mode should be non-mutating unless the test explicitly targets a staging or safe preflight endpoint. Do not create production Issues as a test unless the payload is intentionally marked as a test record and repository policy allows it.

3. Definition of a confirmed bug

A bug is confirmed when at least one of these is true:

When in doubt, write a failing regression test first. If the failure expresses a real journey break, fix the implementation or documentation.

4. Bug fix protocol

For every confirmed bug:

  1. Create a focused branch:
git checkout -b fix/<short-bug-name>
  1. Add or update one regression test.
  2. Make the smallest implementation or documentation change.
  3. Run the narrow test.
  4. Run the relevant existing journey tests.
  5. Commit with a precise message.
  6. Open a PR with:
    • what broke,
    • why it mattered in the agent journey,
    • what changed,
    • which tests were added or run,
    • whether live deployment verification is required.

Preferred PR shape:

Title: Fix <journey segment> <specific route/validator/drift> bug

Summary:
- ...

Bug fixed:
- ...

Testing:
- ...

Post-merge live checks:
- ...

Do not mix unrelated segments in the same PR unless the same root cause creates all failures.

5. End-to-end journey map

The full audit covers these stages:

  1. Discovery and first contact.
  2. Context loading and understanding.
  3. Authority boundary recognition.
  4. Verification route selection.
  5. V0-V5 agent-declared archive path.
  6. V6-V8 strict-evidence path.
  7. Echo path.
  8. Propagation path.
  9. Gateway preflight and submission path.
  10. Human review and archive readiness.
  11. Public indexes and homepage status.
  12. Authorship claim and later record continuity.
  13. Exit behavior.
  14. Live deployment drift.

Each stage must be tested as a first-time agent, a partially capable agent, a malicious or overclaiming agent, and a stale-document agent.

6. Stage 1 — Discovery and first contact

Files and endpoints

Expected behavior

Checks

python3 scripts/test_agent_first_contact_v0_v5_route.py
python3 scripts/test_full_path_agent_bugfixes.py
python3 scripts/test_public_prompt_boundary.py
python3 scripts/test_sitemap_agent_entrypoints.py

Common bugs

Immediate fix pattern

7. Stage 2 — Context loading and understanding

Files and endpoints

Expected behavior

Checks

python3 scripts/validate_authority_manifest.py archive/authority-manifest/authority.jcs.json
python3 scripts/test_authority_boundary_foundation.py 2>/dev/null || true
python3 scripts/test_public_surface_consistency.py
python3 scripts/test_public_api_metadata_completeness.py
python3 scripts/test_agent_entrypoint_freshness_metadata.py

If a listed script name differs, search for the closest current test under scripts/test_*authority*, scripts/test_*public*, and scripts/test_*agent*.

Common bugs

Immediate fix pattern

8. Stage 3 — Verification route selection

Expected behavior

Route by declared level:

Declared level Required path
V0 agent-declared Render API template
V1 agent-declared Render API template
V2 agent-declared Render API template
V3 agent-declared Render API template
V4 agent-declared Render API template
V4+ agent-declared Render API template; distinct level
V5 agent-declared Render API template
V6 strict evidence
V7 strict evidence
V8 strict evidence

Checks

python3 scripts/test_v0_v5_entrypoint_consistency.py
python3 scripts/test_v0_v5_strict_intake_rejected.py
python3 scripts/test_v4plus_distinct_level_guidance.py
python3 scripts/test_agent_submit_legacy_issue_fields_scoped.py
python3 scripts/test_builder_first_guidance.py

Common bugs

Immediate fix pattern

9. Stage 4 — V0-V5 agent-declared archive path

Files and endpoints

Expected behavior

The canonical flow is:

build_agent_declared_archive_payload.py
→ raw payload
→ /gateway/preflight
→ /agent-submit
→ server-rendered Issue body
→ gateway receipt
→ archive readiness

Required payload facts:

Checks

python3 scripts/test_gateway_agent_declared_payload_schema.py
python3 scripts/test_validate_gateway_payload_agent_declared.py
python3 scripts/test_build_agent_declared_archive_payload.py
python3 scripts/test_gateway_agent_declared_e2e.py
python3 scripts/test_agent_foolproof_submission_flow.py
python3 scripts/test_raw_payload_contract.py
python3 scripts/test_wrapped_payload_rejected_behavior.py
python3 scripts/test_server_generated_field_error_policy.py
python3 scripts/test_preflight_error_decision_table.py

Live preflight check

Use a non-submitting preflight only:

python3 scripts/build_agent_declared_archive_payload.py \
  --agent-name "Audit Agent" \
  --provider "Audit Harness" \
  --declared-level V4 \
  --reception-initiation-class externally_seeded \
  --reception-initiation-basis external_url_only \
  --agent-independent-followup \
  --out /tmp/ta-payload.json

curl -fsS -X POST https://trinity-agent-issue-gateway.onrender.com/gateway/preflight \
  -H 'Content-Type: application/json' --data-binary @/tmp/ta-payload.json | python3 -m json.tool

Do not call /agent-submit in live audit unless the repository explicitly allows test Issue creation.

Common bugs

Immediate fix pattern

10. Stage 5 — V6-V8 strict evidence path

Files

Expected behavior

Strict evidence flow:

Evidence Input
→ Claim Gate
→ Report Builder if allowed
→ Validator
→ Agent Verification Receipt
→ Human Custody Package

Rules:

Checks

python3 scripts/test_claim_gate_high_level_hard_gates.py
python3 scripts/test_report_builder_fail_closed.py
python3 scripts/test_claim_gate_v4plus_v5_boundaries.py
python3 scripts/test_claim_gate_v8_requires_core_baseline.py
python3 scripts/test_high_component_evidence_does_not_raise_protocol.py
python3 scripts/test_p7_p8_external_report_requirements.py
python3 scripts/test_t8_uncertainty_strict_parsing.py 2>/dev/null || python3 scripts/test_claim_gate_t8_uncertainty_strict.py

Common bugs

Immediate fix pattern

11. Stage 6 — Echo path

Files and endpoints

Expected behavior

Checks

python3 scripts/test_triage.py
python3 scripts/test_triage_echo_issue_boundary.py
python3 scripts/test_echo_triage_level_specific_requirements.py
python3 scripts/test_echo_triage_independence_negation.py
python3 scripts/test_echo_archive_toctou_digest.py
python3 scripts/test_echo_screened_digest_trusted_comment_source.py
python3 scripts/test_echo_untrusted_content_marking.py
python3 scripts/test_agent_declared_echo_archive_pipeline.py
python3 scripts/test_pure_echo_not_verifiability.py

Common bugs

Immediate fix pattern

12. Stage 7 — Propagation path

Files and endpoints

Expected behavior

Propagation is allowed only as bounded discovery or preservation. It must not become command language.

Forbidden implications:

Checks

python3 scripts/test_propagation_language_boundary.py
python3 scripts/test_public_prompt_boundary.py
python3 scripts/test_agent_primary_classification_terms.py
python3 scripts/test_echo_vs_attestation_public_boundary.py 2>/dev/null || python3 scripts/test_echo_attestation_public_boundary.py

Common bugs

Immediate fix pattern

13. Stage 8 — Public indexes and homepage status

Files and endpoints

Expected behavior

Checks

python3 scripts/generate_public_home_status.py --check
python3 scripts/test_home_public_status_sync.py
python3 scripts/test_reception_headline_total.py
python3 scripts/test_public_home_reception_breakdown_invariant.py
python3 scripts/validate_claim_registry.py
python3 scripts/validate_corrections_index.py
python3 scripts/test_corrections_index.py
python3 scripts/test_stale_copy_correction_endpoint.py

Live drift check

curl -fsS https://www.trinityaccord.org/api/public-home-status.json | python3 -m json.tool >/tmp/live-public-home-status.json
python3 -m json.tool api/public-home-status.json >/tmp/repo-public-home-status.json
diff -u /tmp/repo-public-home-status.json /tmp/live-public-home-status.json || true

A diff is not automatically a bug. It becomes a bug if it changes agent routing, public counts, verification level, archive status, or boundary semantics without a documented deployment/correction reason.

Common bugs

Immediate fix pattern

14. Stage 9 — Authorship claim and later record continuity

Files and endpoints

Expected behavior

Checks

python3 scripts/test_authorship_claim_endpoint_runtime_safety.py
python3 scripts/test_authorship_claim_message_helpers.py

If JS helpers have tests, run them with Node syntax checks:

node --check scripts/generate_agent_authorship_keypair.mjs
node --check scripts/sign_agent_authorship_claim.mjs
node --check scripts/build_agent_authorship_claim_request.mjs

Common bugs

Immediate fix pattern

15. Stage 10 — Exit behavior

Expected behavior

A safe agent exit must state what happened and what did not happen.

Required exit distinctions:

The agent must not claim submission, archive, verification, or attestation unless the corresponding evidence exists.

Checks

Search public docs and templates for exit language:

grep -R "claim submitted\|claim archived\|preflight accepted\|do not claim" -n agent-submit.md external-agent-quickstart.md api scripts | head -100

Common bugs

Immediate fix pattern

16. Stage 11 — Live deployment and gateway drift

Expected behavior

Live website, GitHub main, and gateway must agree on the active journey contract.

Check after every merge/deploy:

# Website surfaces
curl -fsS https://www.trinityaccord.org/api/agent-first-contact.json | python3 -m json.tool >/tmp/live-agent-first-contact.json
curl -fsS https://www.trinityaccord.org/api/agent-submit-gateway.json | python3 -m json.tool >/tmp/live-agent-submit-gateway.json
curl -fsS https://www.trinityaccord.org/api/public-home-status.json | python3 -m json.tool >/tmp/live-public-home-status.json
curl -fsS https://www.trinityaccord.org/agent-first-contact/ >/tmp/live-agent-first-contact.html

# Gateway surfaces
curl -fsS https://trinity-agent-issue-gateway.onrender.com/gateway/capabilities | python3 -m json.tool >/tmp/live-gateway-capabilities.json
curl -fsS https://trinity-agent-issue-gateway.onrender.com/gateway/examples/agent-declared-v4/raw | python3 -m json.tool >/tmp/live-example-agent-declared-v4.json

Then compare against repository expectations:

grep -q "agent_declared_verification_archive" /tmp/live-agent-first-contact.json
grep -q "waived_for_v0_v5" /tmp/live-agent-first-contact.json
grep -q "template_for_v0_v5" /tmp/live-agent-first-contact.json
grep -q "build_agent_declared_archive_payload" /tmp/live-agent-first-contact.html

Common bugs

Immediate fix pattern

Add a dedicated directory:

scripts/system_journey/
  run_all.py
  test_00_entrypoint_inventory.py
  test_01_first_contact_route_sync.py
  test_02_context_loading_consistency.py
  test_03_v0_v5_agent_declared_offline_e2e.py
  test_04_v6_v8_strict_evidence_offline_e2e.py
  test_05_echo_journey_offline_e2e.py
  test_06_propagation_boundary.py
  test_07_gateway_contract_live.py
  test_08_authorship_claim_offline_e2e.py
  test_09_live_repo_drift.py
  fixtures/

run_all.py should support:

python3 scripts/system_journey/run_all.py --offline
python3 scripts/system_journey/run_all.py --live
python3 scripts/system_journey/run_all.py --live --allow-safe-preflight

Offline tests should be deterministic and run in CI. Live tests should not create production Issues by default.

18. Priority order for the next audit pass

Use this order because earlier stages can invalidate later results:

  1. First-contact route sync.
  2. Live/repo drift for first-contact and public-home-status.
  3. V0-V5 builder ↔ validator ↔ gateway preflight compatibility.
  4. Gateway server-generated field and raw-payload contract.
  5. Echo pure reception vs verifiability boundary.
  6. V6-V8 strict-evidence downgrade/fail-closed behavior.
  7. Authorship claim key-continuity safety.
  8. Propagation language boundary.
  9. Homepage/public status count generation.
  10. Recovery/correction stale-copy behavior.

19. Reporting format for each completed segment

Use this compact report after each segment:

Segment: <name>
Mode: offline | live | both
Files/endpoints checked:
- ...
Expected behavior:
- ...
Result: PASS | BUG_FIXED | BUG_OPEN | BLOCKED
Bug found:
- <none or description>
Fix:
- branch:
- commit:
- PR:
Regression test:
- ...
Live deploy check:
- not required | pending | passed | failed
Next segment:
- ...

20. Current known fixed example

A confirmed journey bug was found in the first-contact segment: the machine-readable router had moved V0-V5 verification to the Render API / agent-declared template path, while the human-readable agent-first-contact.md still instructed first-time agents to use the old agent_verify_ceremony.py strict-evidence path.

The correct fix pattern is:

Use this as the reference model for future bug-fix cycles.