# Pre-action Evidence Recorder

Use the pre-action recorder when an external agent is connected before an action and you need evidence that Do Not Act was consulted before the agent continued or stopped.

The recorder does not execute trades, custody funds, hold private keys, sign orders, submit orders, route orders, or provide trading advice. It records the agent's stated intent, calls Do Not Act, and writes a local evidence bundle.

## Command

```bash
export DONOTACT_API_KEY="..."
python scripts/donotact_pre_action_recorder.py \
  --execute \
  --agent-id "my-agent" \
  --run-id "run-001" \
  --venue polymarket \
  --market-id 580810 \
  --intent-type pre_trade_check \
  --intent-summary "agent is about to evaluate a market action" \
  --intent-json '{"side":"yes","size":"redacted"}' \
  --include-resolution-risk \
  --poll-alerts \
  --write-public-redacted
```

## Outputs

- Private bundle: `donotact_pre_action_evidence/YYYY-MM-DD/{event_id}.json`
- Public redacted bundle: `donotact_pre_action_evidence/YYYY-MM-DD/{event_id}.public.json`
- Index: `donotact_pre_action_evidence/events.jsonl`

The private bundle contains the provided intent payload, diagnostic responses, decision, receipt evidence when present, and a canonical SHA-256 hash. The public redacted bundle removes the raw intent payload and keeps the intent hash, verdict excerpt, receipt excerpt, and claim boundary.

## Credibility guardrails

1. Record before action. The agent must call this recorder before continuing its own workflow.
2. Preserve the Do Not Act receipt. If the API response includes a signed receipt with `issued_at`, keep it; that timestamp is the best proof that the verdict existed before a later dispute.
3. Record every invocation. The append-only `events.jsonl` index must include `READY`, `DO_NOT_ACT`, `INSUFFICIENT_EVIDENCE`, and fetch failures. Do not publish only the wins.
4. Match outcomes later. Live proof requires later matching this pre-action evidence against future UMA status changes, including false positives and false negatives.

## Passive live-before-dispute runner

Use the passive runner to start accumulating proof before future disputes happen. It discovers current Polymarket UMA markets whose lifecycle is active (`proposed` or `disputed`) through the public Gamma API and records every sampled target through the same pre-action recorder.

```bash
export DONOTACT_API_KEY="..."
python scripts/donotact_live_before_dispute_runner.py \
  --execute \
  --max-markets 50 \
  --min-repeat-hours 6 \
  --write-public-redacted
```

The runner is append-only and deliberately conservative:

- It records every sampled target, not just wins.
- It records `READY`, `DO_NOT_ACT`, `INSUFFICIENT_EVIDENCE`, and recorder failures.
- It skips only recent duplicate records unless `--force` is set.
- It does not claim prediction accuracy until the outcome matcher has paired records against later dispute outcomes.
- It does not claim money saved without separate external evidence of customer position, intended size, or action that would otherwise have happened.

## Claim boundary

Allowed claim:

> The agent recorded a pre-action intent and Do Not Act returned this diagnostic verdict before the workflow continued.

Not allowed unless separate customer evidence exists:

- money saved
- ROI
- avoided loss amount
- user position
- fill or counterfactual execution
- alpha or trading performance
