DocsOperate
Deployment and data handling
Truehands runs in one of two places. Both run the same engine, built from the same lockfile.
| Truehands Cloud | In your AWS account (Mode A) | |
|---|---|---|
| Where footage goes | Uploaded to Truehands over HTTPS | Stays in your S3 bucket; nothing leaves the account |
| What runs | The API, the run queue, the web console, the review desk, cross-run memory, policies, webhooks, exports | The engine, as Fargate tasks in a VPC with no internet path |
| Results | In the console and the API | audit.json, report.html, usage.json and provenance.json in your output bucket |
| Who operates it | Truehands | You, with a Terraform module |
| Billing | Billable hours measured per run | You send usage.json; its audit_sha256 ties the bill to an audit you keep |
Truehands Cloud#
The hosted service is the server in truehands/server/: a FastAPI application with a run queue and the console, which you can also run on one machine (see the quickstart).
- Isolation per run. Each run executes the engine in its own child process, so a crash, a memory spike or a cancel ends that run only. Cross-run matching runs in a separate child process too; the API process never loads the video models.
- Isolation per organisation. Every query is scoped to the caller's organisation, and feature caches are kept per organisation, so one customer cannot learn from timing that another already audited a video.
- Uploads are checked on arrival with the engine's strict reader and stored by content hash.
- Media (videos, evidence frames, reports) is served only through links signed with the server's secret that expire after 1 hour.
- Credentials. Key pair secrets, session tokens and SCIM tokens are random and stored only as hashes; passwords are hashed with scrypt. Failed sign-ins are rate-limited per username and per address. Every sensitive action is written to the organisation's audit log, with secret-looking values redacted.
- Single sign-on. An organisation can sign in with its identity provider over OpenID Connect, with PKCE, a state bound to the browser and strict ID token checks; requests to the provider go through the same address guard as webhooks. See Single sign-on and SCIM.
- The console runs under a Content-Security-Policy that allows only its own scripts.
Running the server yourself#
uv sync --locked --extra server
uv run python -m truehands.server create-user --data var --org "Example Lab" --username owner
uv run python -m truehands.server serve --data var --reference data/raw/buildai --public-url https://app.truehands.iopython -m truehands.server serve
run the API, the run queue and the console
| Flag | Default | Description |
|---|---|---|
--data | required | folder for the database, uploads and runs |
--reference | folder of public-dataset videos every run is matched against | |
--host | 127.0.0.1 | |
--port | 8080 | |
--public-url | address people open in the browser (default http://HOST:PORT) | |
--workers | 1 | runs processed at the same time |
--max-upload-mb | 2048 | |
--media-retention-days | delete footage this many days after it was last used (1-365; default 30, or TRUEHANDS_MEDIA_RETENTION_DAYS); organisation owners may shorten it | |
--min-free-gb | refuse uploads (507) when the data volume has less free space than this or 5% of it, whichever is larger (default 10, or TRUEHANDS_MIN_FREE_GB; 0 turns it off) |
python -m truehands.server purge-media
delete footage now (default: everything past retention); prints what it would delete or deleted. Runs, verdicts and reasons are kept
| Flag | Default | Description |
|---|---|---|
--data | required | |
--org | only this organisation (its id, or a member's username) | |
--older-than-days | delete footage last used more than this many days ago, whatever the retention setting (0: all of it now, for the end of a pilot) | |
--media-retention-days | the server's retention value, as given to serve (default 30, or TRUEHANDS_MEDIA_RETENTION_DAYS) | |
--dry-run | only print what would be deleted |
python -m truehands.server purge-org
delete an organisation and every trace of it from this server: its rows (one transaction), files, blobs no other organisation has, copy-detection memory; prints a deletion certificate. Asks for the organisation's name
| Flag | Default | Description |
|---|---|---|
--data | required | |
--org | required | the organisation: its id (org_...) or a member's username; the id again finishes an interrupted purge |
--dry-run | only print the rows per table and the files and bytes that would go | |
--cancel-runs | cancel its queued and running runs first (without it, the command refuses while there are any) | |
--wait | 60 | seconds to wait for cancelled runs to stop (default 60) |
--confirm | the organisation's name, for scripts; without it the command asks | |
--certificate | also write the certificate to this path (JSON for a .json path, otherwise text) | |
--by | who runs it, for the operator record (default: SUDO_USER or USER) |
python -m truehands.server erase-contributor
erase one contributor's data for a data-subject request: footage, frames and copy-detection memory deleted, ids replaced by a random token, notes removed; prints a receipt. Asks for the id again
| Flag | Default | Description |
|---|---|---|
--data | required | |
--org | required | the organisation: its id (org_...) or a member's username |
--contributor | required | the contributor id, as in the manifests; - to type it, which keeps it out of sudo's log and the shell history |
--dry-run | only print the receipt of what would change | |
--confirm | the contributor id again, for scripts; without it the command asks | |
--receipt | also write the receipt to this path (JSON for a .json path, otherwise text) | |
--by | who runs it, for the audit log (default: SUDO_USER or USER) |
python -m truehands.server cancel-run
cancel a queued or running run, as POST /v1/runs/{id}/cancel does; a running one stops when the server's queue sees the request
| Flag | Default | Description |
|---|---|---|
--data | required | |
--run | required | the run id (run_...) |
--wait | 30 | seconds to wait for a running run to stop (default 30) |
--by | who runs it, for the run log and the audit log (default: SUDO_USER or USER) | |
--public-url | http://127.0.0.1:8080 | console address for the run.cancelled event's link (default http://127.0.0.1:8080) |
python -m truehands.server create-user
create an organisation and its owner; prints a key pair (TH-Key and TH-Secret-Key) and a 72-hour link to set a password
| Flag | Default | Description |
|---|---|---|
--data | required | |
--org | required | |
--username | required | |
--name | ||
--public-url | http://127.0.0.1:8080 | console address the link points at (default http://127.0.0.1:8080) |
python -m truehands.server add-user
add a user to the organisation of an existing user; prints a key pair and, for people, a 72-hour password link
| Flag | Default | Description |
|---|---|---|
--data | required | |
--to | required | username of someone already in the organisation |
--username | required | |
--name | ||
--role | admin | One of owner, admin, reviewer, viewer, operator, ci. |
--public-url | http://127.0.0.1:8080 | console address the link points at (default http://127.0.0.1:8080) |
python -m truehands.server password-link
break-glass: a 24-hour link for a person to set a new password
| Flag | Default | Description |
|---|---|---|
--data | required | |
--username | required | |
--public-url | http://127.0.0.1:8080 | console address the link points at (default http://127.0.0.1:8080) |
python -m truehands.server sso-domain
mark an organisation's single sign-on email domain verified, for a server that cannot query DNS (check who owns it first), or take that away
| Flag | Default | Description |
|---|---|---|
action | One of verify, unverify. | |
--data | required | |
--org | required | the organisation: its id (org_...), its sign-in name, or a member's username |
--domain | required | one of the organisation's allowed email domains |
Flags read from truehands/server/__main__.py.
--public-url matters behind a proxy: links in run pages, CI templates and webhook payloads use it, and the CLI refuses to send keys to a plain http:// address that is not local. The single sign-on redirect URI (<public url>/v1/sso/callback) and the SCIM base URL (<public url>/scim/v2) are built from it too, so it must be the https address people use: with a plain http:// address, the browser cookie that binds a sign-in is not marked Secure. Verifying an organisation's email domain looks up a DNS TXT record from the server; a server that cannot query DNS uses sso-domain verify instead (verify your email domains).
Mode A: the engine in your AWS account#
The engine ships as a container image, and deploy/terraform/mode-a-aws/ runs it as Fargate tasks inside your own AWS account, on footage that stays in your own S3 bucket. Truehands gets no role, no key and no network path into the account. The engine's network has no internet gateway and no NAT, resolves only the AWS service names it needs, and can reach only your input prefix, your output bucket, ECR and CloudWatch Logs.
What the module creates#
| Resource | Purpose |
|---|---|
| VPC with two private subnets | No internet gateway, no NAT, no default route. The default security group is locked. |
| S3 gateway endpoint | Its policy allows reads under input_prefix and writes to the output bucket, both only in this account (aws:ResourceAccount), plus reads from the bucket ECR serves image layers from. |
Interface endpoints for ecr.api, ecr.dkr and logs | Image pulls and logs without the internet, reachable on 443 from engine tasks only. |
| Route 53 Resolver DNS Firewall | Resolves the ECR, Logs and S3 names; every other name gets NXDOMAIN. Fail-closed, with mutation protection on the association. |
| KMS key | Encrypts results, logs and the image repository. Rotation on. |
| Output bucket | Versioned, Object Lock (governance mode, output_retention_days), SSE-KMS with the key above, public access blocked, TLS only; writes with any other encryption or key are refused. |
| ECR repository | Immutable tags, KMS-encrypted, scan on push. Tasks run the image by digest, never by tag. |
| ECS cluster and two task definitions | audit and egress-probe. Read-only root filesystem, user 10001, all Linux capabilities dropped. |
| Two IAM roles | Execution role: pull this one repository, write this one log group. Task role: list and read the input prefix, write new objects to the output bucket, use the key. The egress probe gets no task role at all. |
Deploy#
You need Terraform 1.6 or later, AWS CLI v2, cosign, crane and jq.
1. Verify the engine image. Each release is built by .github/workflows/release.yml on a version tag and signed by digest with Sigstore keyless signing, so the signature is tied to that workflow running on that tag. The release notes give the image digest and the exact identity to check.
VERSION=v0.3.0
IMAGE=ghcr.io/<owner>/truehands-engine@sha256:<digest from the release>
cosign verify "$IMAGE" \
--certificate-identity "https://github.com/<owner>/truehands/.github/workflows/release.yml@refs/tags/$VERSION" \
--certificate-oidc-issuer https://token.actions.githubusercontent.comStop if the check fails. The image also carries an SBOM and a build provenance attestation.
2. Apply the module. Pin source to a release commit, not a tag. deploy/terraform/mode-a-aws/examples/basic is a complete root module.
module "truehands" {
source = "github.com/<owner>/truehands//deploy/terraform/mode-a-aws?ref=<release commit SHA>"
input_bucket = "example-collect" # existing bucket with your programs
input_prefix = "programs/" # the engine can read nothing outside it
input_kms_key_arn = null # set if the input bucket uses SSE-KMS
output_bucket_name = "example-truehands-audits" # created by the module
engine_image_digest = "sha256:<digest from step 1>"
}
output "truehands" {
value = module.truehands
}terraform init && terraform apply3. Copy the verified image into your ECR, by digest. crane copy copies the manifest bytes as they are, so the digest does not change, and the task definitions name <repository>@<digest>: a task can only start the exact image you verified.
REPO=$(terraform output -json truehands | jq -r .ecr_repository_url)
aws ecr get-login-password | crane auth login "${REPO%%/*}" -u AWS --password-stdin
crane copy "$IMAGE" "$REPO:$VERSION"4. Check that the network is sealed.
scripts/verify_mode_a.sh <your terraform directory>From your machine, the script checks that the VPC has no internet gateway, no NAT gateway and no route except the local one and the S3 endpoint, and that DNS Firewall is associated and fail-closed. Then it starts one egress-probe task inside the VPC. The egress probe (python -m truehands.runner egress-probe) tries three ways out, a public DNS lookup, a raw TCP connection to a public address on port 443 and an HTTPS request to a public site, and exits 0 only if all three fail. The script prints sealed and exits 0 only if every check passes. The same probe runs, with --network none, before every release image is signed.
5. Check capacity before a large backfill. preflight compares the vCPUs a backfill needs with your account's Fargate On-Demand vCPU quota in the region. It calls the Service Quotas API, which the sealed VPC cannot reach, so run it from a checkout on your machine:
uv run python -m truehands.runner preflight --hours 10000 --deadline-hours 48It plans with 1.7 vCPU-hours per hour of footage, a conservative figure: the current engine measured 0.73 on the benchmark. It exits 0 when the quota is enough, 1 when it is not (with the vCPUs to request, or the hours the backfill would take at your quota), and 2 when no Fargate On-Demand vCPU quota is found.
Run an audit#
A program prefix holds program.json, manifest.csv and the files the manifest names, in the same layout as a local program folder (see Concepts).
D=$(terraform output -json truehands)
aws ecs run-task \
--cluster "$(jq -r .cluster_arn <<<"$D")" \
--task-definition "$(jq -r .audit_task_definition_arn <<<"$D")" \
--launch-type FARGATE \
--network-configuration "$(jq -r .network_configuration <<<"$D")" \
--overrides '{"containerOverrides":[{"name":"engine","command":["audit",
"--input","s3://example-collect/programs/home-tasks/",
"--output","s3://example-truehands-audits/runs/","--work","/work/run"]}]}'- Only what the manifest names is fetched, each object pinned to the S3 version id seen when it was listed, so the bytes audited are the bytes recorded in the provenance file. A file over the program's size limit is not downloaded; intake rejects it from its size.
- Results never overwrite each other. Every run writes to a new
runs/<run id>/prefix withIf-None-Match: *, and Object Lock keeps each object for the retention period. The override may name any input path, but the task role and the endpoint policy only allow reads underinput_prefixand writes to the output bucket. - Logs go to the
/<name>/enginelog group: a JSONrun_startedevent, one line per clip, and a JSONrun_finishedevent with the verdict counts and billable hours.
| File | Contents |
|---|---|
audit.json | Verdict, payable seconds, reasons and evidence for every clip; the program summary. |
report.html | One self-contained page with no network requests; faces blurred in evidence frames. |
usage.json | What the run bills: billable hours (total and by submission day), clip counts, the engine version and model hash, the input location and the SHA-256 of audit.json. No footage and no contributor ids. |
provenance.json | For every staged file: key, S3 version id, size and SHA-256. |
The runner's commands and flags:
python -m truehands.runner audit
audit a program folder or S3 prefix
| Flag | Default | Description |
|---|---|---|
--input | required | |
--output | required | |
--reference | folder or S3 prefix of public-dataset clips to match against | |
--work | scratch folder (default: a new temporary folder) | |
--kms-key | KMS key id for output objects (default: the bucket's default encryption) | |
--max-bytes | MAX_BYTES | |
--keep-work |
python -m truehands.runner egress-probe
exit 0 only if this task cannot reach the internet
| Flag | Default | Description |
|---|---|---|
--timeout | 4 |
python -m truehands.runner preflight
check the Fargate vCPU quota for a backfill
| Flag | Default | Description |
|---|---|---|
--hours | required | footage hours to audit |
--deadline-hours | 48 |
Flags read from truehands/runner.py.
Run the image anywhere#
The same image runs on any machine with Docker, sealed the same way:
docker build -t truehands-engine .
docker run --rm --network none --read-only --tmpfs /work:uid=10001,gid=10001 \
-v "$PWD/data/program:/in:ro" -v "$PWD/runs:/out" truehands-engine audit --input /in --output /outModule variables#
| Variable | Default | Description |
|---|---|---|
name | "truehands" | Prefix for every resource the module creates. |
input_bucket | required | Existing bucket that holds programs (program.json, manifest.csv and the clips it names). |
input_prefix | "" | Prefix under input_bucket the engine may read, for example "programs/". Empty means the whole bucket. |
input_kms_key_arn | null | KMS key that encrypts the input bucket, if it uses SSE-KMS. The task may only decrypt with it. |
output_bucket_name | required | Name of the bucket the module creates for audit results. Object Lock keeps every run immutable. |
output_retention_days | 365 | Object Lock retention (governance mode) for audit results. |
engine_image_digest | required | Digest of the verified Truehands engine image copied into this module's ECR repository, like "sha256:...". Tags are never used. |
vpc_cidr | "10.42.0.0/24" | CIDR for the isolated VPC. It has no internet gateway and no NAT. |
task_cpu | 4096 | Fargate vCPU units for an audit task (1024 = 1 vCPU). The engine needs about 1.7 vCPU-hours per hour of 960x540 video. |
task_memory | 16384 | Fargate memory (MiB) for an audit task. |
ephemeral_storage_gib | 100 | Scratch disk for staged clips and features, 21-200 GiB. |
log_retention_days | 90 | Retention for the engine's CloudWatch logs. |
tags | {} | Tags added to every resource. |
Outputs: vpc_id, cluster_arn, audit_task_definition_arn, egress_probe_task_definition_arn, subnet_ids, task_security_group_id, ecr_repository_url, output_bucket and network_configuration (ready for aws ecs run-task --network-configuration).
Signed images and pinned dependencies#
- FFmpeg is built from a release tarball checked against its SHA-256, with only the MOV demuxer, the H.264 and HEVC parsers and decoders, and the file and pipe protocols. The release job checks the built image lists exactly those.
- Python dependencies are installed from
uv.lock, every package pinned by hash; PyTorch's CPU wheels come only from PyTorch's own index, and no other package may come from it. - Model files are fetched at build time and refused unless their hashes match (see below).
- The image runs as an unprivileged user (10001) on a read-only root filesystem. Before signing, the release job runs it with no network and checks that the egress probe finds every way out closed and that both model files load.
- Signing is by digest, with the release workflow's GitHub identity (Sigstore keyless, so there is no signing key to leak). Verify before you copy the image into your registry.
Data handling#
Face blur#
First-person footage shows bystanders in mirrors, doorways and on screens. Before any evidence frame or thumbnail is written where a reviewer can see it, faces are detected with OpenCV's YuNet model at a low score threshold (0.5), tuned to over-blur rather than miss; each box is padded by 30% and heavily Gaussian-blurred. This applies to evidence frames, thumbnails and the report. The submitted footage itself is not modified. The same detector counts faces on a few sampled frames of each clip, at a stricter score (0.8): faces in audit.json, see what the engine extracts.
Pinned model weights#
The engine loads two model files, only from local disk, and only when their SHA-256 matches the value pinned in the code. It never downloads at run time (HF_HUB_OFFLINE=1), and it loads CLIP weights only as .safetensors: pickled checkpoints, which can run code, are refused.
| Model | Used for | Pinned SHA-256 |
|---|---|---|
OpenCLIP ViT-B/32, LAION-2B (laion2b_s34b_b79k), one upstream revision | Copy, public-dataset and task checks | ac4f8c4b88af6d963118cbf40ad93176d092abbedfcb752601ae1866352656e6 |
| YuNet face detector (2023mar) | Blurring faces in evidence, counting faces on sampled frames | 8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4 |
scripts/fetch_weights.sh downloads both into models/ and refuses either if its hash does not match. The CLIP hash is recorded in every audit.json (engine.model_sha256).
Retention#
- Mode A. Footage never leaves your input bucket. Results in the output bucket are kept under Object Lock for
output_retention_days(default 365, governance mode: an administrator withs3:BypassGovernanceRetentioncan still delete). Engine logs are kept forlog_retention_days(default 90). The task's scratch copy of a program is deleted when the run ends. - Truehands Cloud. Footage is deleted 30 days after it was last used: the clock of each uploaded video or sensor log starts at the later of its upload and the end of the latest run that used it. With it go the run's working copies, evidence frames (including frame pairs and cross-run frames that show it) and the HTML report, which embeds frames. Every verdict, reason, payable second, review decision, payout record,
audit.jsonand audit-log entry is kept, and so is the copy-detection memory (stream fingerprints and frame embeddings, no pixels), so a re-upload is still caught as a copy after its footage is gone; deleting an organisation or a contributor removes those too. An owner can shorten the period for the organisation (PUT /v1/org/retention, 1 day up to the server's value); it can never be made longer than the server allows. To keep a copy, back runs up to your own bucket (results always, evidence frames and footage if you choose) or download a run's archive: a backup still waiting or running keeps the footage it needs for at most 3 days past its date, and each run sends onerun.media_expiringevent 7 days before its footage goes. Exports expire after 30 days; signed media links after 1 hour; console sessions after 12 hours. - Running Truehands Cloud yourself.
serve --media-retention-days N(1-365, default 30) sets the period; a sweep runs every 10 minutes, writes oneretention.media_deletedentry per organisation to the audit log, and never touches footage a queued or running run needs.python -m truehands.server purge-media --data var --org ORG --older-than-days 0deletes an organisation's footage now (--dry-runshows what would go; with--older-than-daysit does not wait for pending backups);purge-orgdeletes the whole organisation at the end of an agreement (deleting data). Uploads are refused with507 insufficient_storagewhen the data volume has less free space than--min-free-gb(default 10 GB) or 5% of its size, whichever is larger, andGET /v1/readyzreportsdiskas failing below the same line. Backup destinations' secret access keys and single sign-on client secrets are sealed with AES-256-GCM underTRUEHANDS_SECRETS_KEY(base64 of 32 random bytes) or, without it,secrets.keyin the data folder, created with mode 0600; set the variable to keep the key off the data volume, and keep a copy of it: without the key, destinations need their keys entered again, and single sign-on stops until an owner or admin enters the client secret again (owners can still sign in with their password).
Deleting an organisation or a contributor#
Retention deletes footage; results, the copy-detection memory, accounts and the audit log stay for as long as the organisation uses Truehands Cloud. Two operator commands delete those too, one for the end of an agreement and one for a person's request, and a third stops a run without the console:
| Command | Deletes | Stays |
|---|---|---|
purge-media --org ORG --older-than-days 0 | The organisation's footage and the media made from it, as retention does | Every row, audit.json, the copy-detection memory |
purge-org --org ORG | Everything of the organisation: every row of every table that belongs to it, its members, key pairs, sessions, SSO and SCIM settings, runs, verdicts, reviews, pilots, exports, payouts, webhooks, backup settings and audit log; its run folders, evidence, reports, exports, feature cache, sketch shards and inbox spools; and every uploaded file no other organisation also uploaded | One operator record (operator_log): the organisation's id and name, when, by whom and the rows deleted per table. No personal data |
erase-contributor --org ORG --contributor ID, or POST /v1/contributors/{id}/erase for an owner | One contributor's data: their footage and everything made from it, including frames that show it in other clips' findings; their copy-detection memory; their profile, watchlist and holds; reviewers' notes about them; exports that list them. Their contributor, device and upload ids are replaced everywhere by a random token | Their verdicts, payable seconds, review decisions and payout lines, under the token, so totals still add up |
cancel-run --run RUN | Nothing: it cancels a queued run at once, and a running one as soon as the server's queue sees the request (within a second), as POST /v1/runs/{id}/cancel does |
purge-org:
--dry-runprints the rows it would delete per table, and the files and bytes. The real run asks you to type the organisation's name (--confirm NAMEin a script), and refuses while the organisation has a queued or running run unless you add--cancel-runs.- Which rows are the organisation's is decided by one map over every table: a table with an
org_idis owned; a table without one is reached through its parent (sessions through members, payout lines through batches, webhook attempts through deliveries); the few global tables say why they hold no organisation's data. A table the map does not cover stops the command before it deletes anything. - The rows go in one transaction, with SQLite's
secure_deleteon (the server keeps it on for every connection), so deleted rows are overwritten in the database file; the write-ahead log is checkpointed afterwards. Then the files go. If the command is interrupted after the transaction, run it again with the organisation's id: it finishes the files. - It prints a deletion certificate (
--certificate PATHalso writes it, as JSON for a.jsonpath): what was deleted (rows per table, files, bytes, uploaded files deleted and those kept because another organisation has the same bytes), when and by whom, and what remains.
erase-contributor takes --dry-run too, asks for the contributor id again (--confirm ID), and prints a receipt in the same shape; --contributor - asks for the id instead of taking it on the command line, which keeps it out of sudo's log and the shell history. What erasing means, and what is refused, is in the API reference.
What remains after either command, and for how long. Truehands Cloud's own backups are encrypted on the server before they leave it. The database backups are kept hourly for 48 hours, daily for 14 days and weekly for 8 weeks, so the deleted rows leave them within 56 days. The files backups are kept daily for 7 days, so deleted footage leaves them within 8 days; the operator can remove it the same day (thctl backup scrub-files). Copies that already left the server are out of reach: exports, payout files and run archives you downloaded, webhook deliveries already sent, and backups in your own bucket. The certificate and the receipt list them with their dates.
What the engine refuses to trust#
- Container metadata: paid seconds come from the video stream, never the container's duration.
- Format guessing: every read forces the MP4/MOV demuxer and local files only.
- The file hash: exact copies are matched on the video stream's packets, so a remuxed or retagged copy is still a copy.
- The manifest: ids must match
^[A-Za-z0-9_-]{1,64}$, and files must sit inside the program folder. - Downloads at run time: none; model files load only from disk and only with matching hashes.
- Its own report: every string is HTML-escaped, a Content-Security-Policy allows only the page's one script, fonts are embedded and faces are blurred.