DocsTruehands Audit
Policies and gates
A policy decides what each finding does to a clip and its pay, and which quality gates a run must pass. It is a small YAML file you keep in your repository, review in pull requests and simulate on past runs before a person activates it.
Without a policy, a program uses the Truehands default (version 0), which decides exactly as the engine does.
The file#
A policy is YAML (or JSON) with four optional keys:
| Key | What it holds |
|---|---|
program | The program's slug. When present, it must match the program the policy is checked for. |
reasons | code: consequence for the findings you want to change: reject, review, partial or ignore, within what each code allows. |
thresholds | key: value for the thresholds you want to change, within the engine's limits. |
gates | A list of run-level checks. |
Anything left out keeps the default. The CLI looks for .truehands/policy.yml unless you name another file. This example tightens two thresholds and adds three gates:
# .truehands/policy.yml: what each finding does to a clip and its pay, and the quality gates a run must pass.
#
# truehands policy lint # file:line:col code message; exit 1 on errors
# truehands policy diff # STRICTER / LOOSER against the active policy
# truehands policy simulate --last 10 # what would have changed on recent runs
# truehands policy push # a draft; a person activates it in the console
#
# Anything left out keeps the Truehands default, which decides exactly as the engine does. Comments, key order and
# quoting never change the policy's sha256. YAML anchors, aliases and tags are refused.
program: home-tasks
# reject | review | partial | ignore, within what each finding allows. Reject and review pay nothing; partial
# pays the clip's length minus its idle time. Intake failures (unreadable, wrong codec, over limits, bad manifest
# rows) and exact copies of a video stream are always rejected and are not listed here.
reasons:
self_duplicate: reject # reject | review
cross_contributor_duplicate: reject # reject | review
public_dataset_match: reject # reject | review
sensor_mismatch: reject # reject | review | ignore; only for clips sent with an IMU log
task_mismatch: review # zero-shot and weak on fine hand work: rejecting on it rejects honest clips
not_from_capture_app: review
reused_capture_timestamp: review
timing_mismatch: review
idle_time: partial # partial | review | reject | ignore
cross_run_duplicate: reject # reject | review; never stricter than the cross-run matcher's own verdict
# Thresholds stay within what the engine reports: values below a floor are refused (below_engine_floor).
thresholds:
duplicate_reject_coverage: 0.5 # 0.3 to 1, lower is stricter
duplicate_reject_distinct: 0.4 # 0.3 to 1
duplicate_review_coverage: 0.3 # 0.3 to 1, at most the reject value; partial overlap goes to review
duplicate_review_distinct: 0.3
public_match_coverage: 0.5 # 0.5 to 1
public_match_distinct: 0.4 # 0.4 to 1
idle_min_run_seconds: 4 # 4 to 60 s; shorter pauses are normal
idle_review_share: 0.5 # send a clip to review when half of it is idle (null: off)
task_max_rank: 5 # flag when the claimed task ranks below this...
task_min_frame_share: 0.1 # ...and leads fewer than this share of frames
imu_min_corr: 0.3 # flag when gyro and picture motion correlate below this
# Quality gates, checked on every finished run. A failed gate fails the run in CI (`truehands run --wait` and
# `truehands gates` exit 1); a gate with hold_payout stops the run's payout until an owner or admin releases it.
# Metrics: reject_share, review_share, flagged_time_share, reason_count, reason_share (both need codes),
# intake_failure_share, pay_blocked_usd. Exactly one of max or min. Runs with fewer than min_clips are skipped.
gates:
- id: reject-share
metric: reject_share
max: 0.15 # fail when more than 15% of clips are rejected
action: fail
min_clips: 20 # small test batches skip this gate
- id: no-public-footage
metric: reason_count
codes: [public_dataset_match]
max: 0 # a single clip of public dataset footage fails the run...
action: fail
hold_payout: true # ...and holds its payout until a person has looked
- id: pipeline-health
metric: intake_failure_share
max: 0.05 # more than 5% unreadable or wrong-codec files: something upstream broke
action: warnIdentity. The server turns a policy into a canonical form (every key filled in, keys sorted, gates ordered by id, numbers rounded to four places) and identifies it by that form's SHA-256. Comments, key order and quoting never change the hash, so truehands policy status can tell whether the file in your repository is the policy in force.
reasons#
Each reason code allows some consequences and not others; the reason codes page lists them all. The rules that cannot be changed:
- Intake failures (
unreadable_file,ambiguous_streams,codec_not_allowed,over_limits,invalid_manifest) and exact copies of a video stream are always rejected and never paid. engine_erroranddecode_timeoutalways hold the clip for review.- A partial overlap with an earlier clip (above the review thresholds, below the reject thresholds) always goes to review, whatever
self_duplicateorcross_contributor_duplicateis set to. cross_run_duplicatetakes the less severe of the policy's consequence and the cross-run matcher's own verdict.- A finding whose code the catalog does not know keeps its producer's severity.
partial pays the clip's length minus the seconds the finding measured: idle runs for idle_time, replayed seconds for internal_repeat, repeated frames for slowed_playback.
thresholds#
| Engine floor | For thresholds marked yes, the engine reports nothing below the minimum, so a lower value could never apply. The linter refuses it as below_engine_floor. |
| Direction | Whether a lower or a higher value flags more. diff uses it to label each change STRICTER or LOOSER. |
| Review band | duplicate_review_coverage, duplicate_review_distinct and duplicate_review_distinct_self must sit at or below their reject counterparts. |
| Threshold | Default | Range | Direction | Engine floor | What it does |
|---|---|---|---|---|---|
duplicate_reject_coverage | 0.5 | 0.3 to 1 | lower is stricter | yes | Share of the clip that lines up, in order, with an earlier clip: at or above it (with distinct), a copy. |
duplicate_reject_distinct | 0.45 | 0.3 to 1 | lower is stricter | yes | How far that alignment beats every other time offset, as a share of the clip. |
duplicate_review_coverage | 0.3 | 0.3 to 1 | lower is stricter | yes | Partial overlap that sends a clip to review. At most the reject value. |
duplicate_review_distinct | 0.3 | 0.3 to 1 | lower is stricter | yes | Partial overlap that sends a clip to review. At most the reject value. |
duplicate_review_distinct_self | 0.4 | 0.3 to 1 | lower is stricter | yes | The same, for a match with the contributor's own earlier clip: their new footage of the same workstation and task looks like their old footage by nature. At most the reject value. |
public_match_coverage | 0.5 | 0.5 to 1 | lower is stricter | yes | Share of the clip that matches public dataset footage. |
public_match_distinct | 0.4 | 0.4 to 1 | lower is stricter | yes | How far that match beats every other time offset. |
idle_min_run_seconds | 4 | 4 to 60 | lower is stricter | yes | Seconds without meaningful motion before a pause counts as idle. Shorter pauses are normal. |
idle_review_share | null (off) | 0.05 to 1 or null | lower is stricter | no | Send a clip to review instead of partial pay when at least this share of it is idle. null: off. |
task_max_rank | 5 | 1 to 200 | lower is stricter | no | Flag when the claimed task ranks below this for the whole clip... |
task_min_frame_share | 0.1 | 0 to 1 | higher is stricter | no | ...and is in the top 3 for fewer than this share of frames. |
imu_min_corr | 0.3 | -1 to 1 | higher is stricter | no | Flag when gyro and image motion correlate below this while the picture moves, or the phone is still. |
How the server re-decides a clip under a policy: it keeps the numbers the engine measured (coverage, distinct, idle runs, task rank, sensor correlation) and applies your thresholds to them, without decoding the video again. At the default task and sensor thresholds it takes the engine's own answer; when you change them, the program-footage veto of the task check still applies, and the sensor check's review band stays at 0.5.
gates#
A gate checks one number of a finished run against a limit. Keys: id, metric, codes, max, min, action, min_clips, hold_payout.
| Key | Meaning |
|---|---|
id | 1-40 lowercase letters, digits or hyphens, unique in the policy. |
metric | One of the metrics below. |
codes | For reason_count and reason_share only: the reason codes to count. |
max or min | Exactly one. Shares are 0 to 1; reason_count is a whole number; pay_blocked_usd is dollars. |
action | fail (default): the run's gate fails. warn: it is reported and does not fail. |
min_clips | Runs with fewer clips skip the gate. Default 0. |
hold_payout | true: when the gate fails or warns, the run's payout is held until an owner or admin releases it in the console. |
| Metric | Unit | Needs codes | What it measures |
|---|---|---|---|
reject_share | share | no | Share of clips rejected |
review_share | share | no | Share of clips held for review |
flagged_time_share | share | no | Share of submitted time rejected, held or cut as idle |
reason_count | clips | yes | Clips with any of these findings |
reason_share | share | yes | Share of clips with any of these findings |
intake_failure_share | share | no | Share of clips refused at intake (unreadable, wrong codec, over limits) |
pay_blocked_usd | usd | no | Pay blocked by rejects and idle cuts, USD |
Each gate ends passed, failed, warned or skipped; the run's overall result is the worst of them (failed before warned before passed), or skipped when the policy has no gates. Gates are evaluated after the policy has decided every clip, on the decided verdicts.
In CI, a failed gate makes truehands run --wait and truehands watch exit 1, whatever --fail-on says, and truehands gates RUN prints each gate's observed value against its threshold:
Quality gate FAILED run run_9b1f04c2e7aa policy v3 6fba70d3fd96
GATE METRIC OBSERVED THRESHOLD RESULT ACTION
no-public-footage reason_count 2 max 0 failed fail holds payout
pipeline-health intake_failure_share 0.0 max 0.05 passed warn
reject-share reject_share 0.0808 max 0.15 passed fail
payout held: gate:no-public-footage
https://app.truehands.io/runs/run_9b1f04c2e7aa#gatestruehands gates RUN --expect-policy .truehands/policy.yml also exits 2 unless the run was decided with exactly that file, which catches a job that ran before the policy was activated.
Lint, diff, simulate, push#
The CLI has no YAML parser: it sends the file to the server, which parses it with a hardened loader and answers with line and column numbers. Nothing here activates a policy.
truehands policy init # write the active (or default) policy to .truehands/policy.yml
truehands policy lint # file:line:col code message; exit 1 on errors
truehands policy diff # STRICTER / LOOSER changes against the active policy, then a unified diff
truehands policy simulate --last 10 # re-decide the last 10 finished runs with the file
truehands policy push # store the file as a draft (idempotent) and print where to activate it
truehands policy status --check # exit 1 when the file and the active policy differ$ truehands policy lint examples/policy/policy.yml
examples/policy/policy.yml: ok · sha256 6fba70d3fd96 · tighten against active v0 (5 stricter, 0 looser)
$ truehands policy diff --no-color examples/policy/policy.yml
examples/policy/policy.yml against active v0 of home-tasks: tighten (5 stricter, 0 looser)
STRICTER thresholds.duplicate_reject_distinct: 0.45 -> 0.4
STRICTER thresholds.idle_review_share: null -> 0.5
STRICTER gates.no-public-footage: null -> {metric: reason_count, max: 0, action: fail, codes: [public_dataset_match], min_clips: 0, hold_payout: true}
STRICTER gates.pipeline-health: null -> {metric: intake_failure_share, max: 0.05, action: warn, codes: [], min_clips: 0, hold_payout: false}
STRICTER gates.reject-share: null -> {metric: reject_share, max: 0.15, action: fail, codes: [], min_clips: 20, hold_payout: false}Simulation re-decides up to the last 20 finished runs of the program (at most 50,000 clips) from their stored findings, synchronously, and reports what would change against the active policy: clips whose verdict changes and how (for example accept → review), payable time and payout, clips held for review, runs failing a gate before and after, and contributors affected. --format markdown writes a table for a pull request or $GITHUB_STEP_SUMMARY.
What the linter refuses#
The policy file is untrusted input. The loader refuses, with a line and column:
- files over 64 KiB (
too_large), more than one YAML document (multiple_documents), nesting deeper than 4 levels (too_deep); - YAML anchors, aliases, tags and directives (
yaml_feature_not_allowed), duplicate keys (duplicate_key), keys that are not text (invalid_key); - unknown keys, codes, thresholds and metrics (
unknown_key,invalid_gate), with a "did you mean" suggestion; - values of the wrong type or outside their range (
invalid_type,invalid_value,invalid_range,below_engine_floor), consequences a code does not allow (not_allowed), a policy for another program (program_mismatch), a gate id used twice (duplicate_gate_id), more than 20 gates (too_many_gates).
It warns, without failing, when a rule can have no effect (no_effect) and when task_mismatch is set to reject (weak_check).
Activation#
Policies are versioned per program: draft, then active, then retired, plus pending for a loosening change that has one of its two approvals. truehands policy push stores a draft and prints the console link; truehands policy activate only prints where to go, and exits 2.
- Only a person activates: an owner or admin signed in to the console with a password, typing the program slug to confirm. Scripts, CI and service accounts can lint, simulate and push drafts, never activate.
- Tightening takes effect at once.
- Loosening (or a mixed change) needs a simulation against the active version from the last 7 days, and 2 different people. The first approval leaves the version pending.
- When it applies: to runs whose verdicts are stored after activation. When a run's verdicts are stored, the active policy is applied in one transaction: findings are kept, every clip is re-decided, the summary is recomputed and the gates are evaluated. If anything goes wrong the run fails closed, with the gate in error and the payout held, rather than publishing the engine's defaults silently. Billing is never rewritten by a policy.
- Going back: version 0 is the Truehands default. Push a policy equal to it to return.
In a pull request#
integrations/github/truehands-policy.yml lints, diffs and simulates .truehands/policy.yml on every pull request that changes it, writes the diff and simulation into the job summary, and pushes a draft when the change lands on main:
# Truehands policy as code for GitHub Actions. Copy this file to .github/workflows/truehands-policy.yml.
#
# Pull requests that touch .truehands/policy.yml are linted, diffed against the active policy (STRICTER / LOOSER) and
# simulated on the program's last 10 runs; the diff and simulation land in the job summary. A push to main stores
# the file as a draft. Nothing here activates a policy: a person does that in the Truehands console, and a change
# that loosens the policy needs a simulation and two approvers.
#
# Settings: secrets TRUEHANDS_KEY and TRUEHANDS_SECRET_KEY (the key pair of a CI service account: it can lint,
# simulate and push drafts, never activate) and the variable TRUEHANDS_API_URL. Secrets are not given to pull requests
# from forks.
name: Truehands policy
on:
pull_request:
paths: [".truehands/policy.yml"]
push:
branches: [main]
paths: [".truehands/policy.yml"]
permissions:
contents: read
concurrency:
group: truehands-policy-${{ github.ref }}
cancel-in-progress: true
env:
TRUEHANDS_API_URL: ${{ vars.TRUEHANDS_API_URL }}
TRUEHANDS_KEY: ${{ secrets.TRUEHANDS_KEY }}
TRUEHANDS_SECRET_KEY: ${{ secrets.TRUEHANDS_SECRET_KEY }}
TRUEHANDS_CLI: truehands-cli==0.4.0 # 0.4.0 and later read TRUEHANDS_KEY and TRUEHANDS_SECRET_KEY
defaults:
run:
shell: bash # bash -eo pipefail: a failing truehands command fails the step even inside a pipe
jobs:
check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install the Truehands CLI (standard library only)
run: pipx install "$TRUEHANDS_CLI"
- name: Lint .truehands/policy.yml
run: truehands policy lint
- name: Diff against the active policy
run: |
{
echo "### Policy changes"
echo
echo '```diff'
truehands policy diff --no-color
echo '```'
} | tee -a "$GITHUB_STEP_SUMMARY"
- name: Simulate on the last 10 runs
run: truehands policy simulate --last 10 --format markdown | tee -a "$GITHUB_STEP_SUMMARY"
push-draft:
if: github.event_name == 'push'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install the Truehands CLI (standard library only)
run: pipx install "$TRUEHANDS_CLI"
- name: Store the policy as a draft (idempotent; prints the console link to activate it)
run: truehands policy push | tee -a "$GITHUB_STEP_SUMMARY"
- name: Show whether the active policy matches main
run: truehands policy statusThe default policy#
What truehands policy init writes for a program that has never had a policy, generated from the catalog:
# Truehands policy for program home-tasks.
# Check it with `truehands policy lint`; a person activates it in the console.
# Loosening changes need a simulation and two approvers.
program: home-tasks
# What each finding does to a clip and its pay: reject | review | partial | ignore.
# Intake failures (unreadable_file, ambiguous_streams, codec_not_allowed, over_limits, invalid_manifest)
# and exact copies of a video stream are always rejected and never paid.
reasons:
self_duplicate: reject # reject | review
cross_contributor_duplicate: reject # reject | review
public_dataset_match: reject # reject | review
sensor_mismatch: reject # reject | review | ignore
task_mismatch: review # reject | review | ignore
not_from_capture_app: review # reject | review | ignore
reused_capture_timestamp: review # reject | review | ignore
timing_mismatch: review # reject | review | ignore
idle_time: partial # partial | review | reject | ignore
internal_repeat: partial # partial | review | reject | ignore
slowed_playback: partial # partial | review | reject | ignore
decode_errors: review # reject | review | ignore
sensor_log_invalid: review # reject | review | ignore
attestation_invalid: reject # reject | review
attestation_missing: review # review | reject | ignore
cross_run_duplicate: reject # reject | review
# Within engine limits. 'lower' or 'higher' says which direction is stricter.
thresholds:
duplicate_reject_coverage: 0.5 # 0.3 to 1.0, lower is stricter
duplicate_reject_distinct: 0.45 # 0.3 to 1.0, lower is stricter
duplicate_review_coverage: 0.3 # 0.3 to 1.0, lower is stricter
duplicate_review_distinct: 0.3 # 0.3 to 1.0, lower is stricter
duplicate_review_distinct_self: 0.4 # 0.3 to 1.0, lower is stricter
public_match_coverage: 0.5 # 0.5 to 1.0, lower is stricter
public_match_distinct: 0.4 # 0.4 to 1.0, lower is stricter
idle_min_run_seconds: 4 # 4 to 60, lower is stricter
idle_review_share: null # 0.05 to 1.0 or null, lower is stricter
task_max_rank: 5 # 1 to 200, lower is stricter
task_min_frame_share: 0.1 # 0.0 to 1.0, higher is stricter
imu_min_corr: 0.3 # -1.0 to 1.0, higher is stricter
# Run-level quality gates. Metrics: reject_share, review_share, flagged_time_share, reason_count, reason_share, intake_failure_share, pay_blocked_usd.
gates: []Its canonical SHA-256 is 09a42af93bc6fd777d1259b5d7a2d8f361bb6a8a39ca99cd32bd85b2f8cccfea.
Limits#
| Limit | Value |
|---|---|
| Policy file size | 64 KiB |
| Nesting depth | 4 |
| Gates per policy | 20 |
| Runs per simulation | 1-20 |
| Clips per simulation | 50,000 |
| Changed clips listed in a simulation | 200 |
| Approvals to activate a loosening change | 2 |
| Age of the simulation a loosening change needs | 7 days or less |