Skip to content

feat(service)!: Require the token for every run - #70

Merged
dcramer merged 3 commits into
mainfrom
feat/require-token-for-runs
Nov 14, 2026
Merged

dcramer merged 3 commits into
mainfrom
feat/require-token-for-runs

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Every run now needs the service token, in every mode. Before, anyone could start a replay run, so CI of forks could replay without a secret. That made each recording readable by anyone who knew the tenant name.

This uses one token for reads and writes: the existing ROACH_TOKEN / writeTokenHash. There is no separate read token.

What changes

  • POST /__roach/runs checks the token first and returns 401 without it, or with a wrong one, before it reads the body. This applies in every mode.
  • The locked-down path for runs without a token is gone, because no such runs exist now:
    • the key worker (key-worker.ts)
    • the shared body budget (503/408)
    • the per-client and global run caps (429), and client-address grouping
    • the idle and 2-hour timeouts (the 6-hour limit stays)
    • the replayOnly refusal
    • the smaller learn, value, and work limits, and the plumbing that passed them around (WorkLimit, LearnLimit, the maxValues count in extractValues, the time-limit argument of keyRequest)
  • Every run gets change on its misses in stats and reports. That was only for runs with the token before.
  • Clients without the token turn Roach off, they don't fail. The vitest global setup and the action run the tests or the command with no proxy, so requests go direct, and print a note (the action also writes it to the job summary). So running tests or evals locally or in a fork just works. Only an explicit ROACH_MODE other than off (for example replay) fails without the token, so a job that must not go live can't silently go live.
  • startRemoteRun now requires token. RefusalReason loses replayOnly. The roach.write span attribute and the busy / timeout results are gone.
  • README, TELEMETRY, action.yml, and the deploy/gcp comments are updated. Terraform needs no change, because the config keeps writeTokenHash.

Breaking

The consumer repos already have ROACH_TOKEN in CI, so their jobs behave the same. Jobs without the token, such as CI of forks, now send requests direct (or fail, if they set a ROACH_MODE other than off) instead of replaying.

Follow-up (not in this PR)

The PROXY-header handling (proxyProtocol, clients.ts) now only strips the header, since nothing uses the client address. Removing it means changing proxy_header on the load balancer at the same time as a service deploy, so it is left for a separate change. Renaming writeTokenHash has the same deploy-ordering problem, so it keeps its name.

via @dcramer.

--

View Session [Sentry]

Each run now needs the token, in every mode. Before, anyone could start
a replay run, so CI of forks could replay without a secret. That made
every recording readable by anyone who could guess a tenant name.

With no runs from untrusted clients, the locked-down path for them goes
away: the key worker, the shared body budget, the per-client and global
run caps, the idle and short run timeouts, the replay-only refusal, and
the smaller learn and value limits. All runs now explain their misses.

The clients default to auto mode and fail early without ROACH_TOKEN or
the action token input, unless ROACH_MODE is off. Jobs that must not
record set ROACH_MODE=replay. The service config keeps writeTokenHash,
so the deploy needs no change.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@sentry-junior
sentry-junior Bot force-pushed the feat/require-token-for-runs branch from da68b2d to dd335d2 Compare November 14, 2026 18:04
@sentry-junior sentry-junior Bot changed the title feat(service)!: Require a token for every run feat(service)!: Require the token for every run Nov 14, 2026
sentry-junior Bot and others added 2 commits November 14, 2026 18:09
A client without the token no longer fails. The vitest global setup and
the action run the tests or the command without Roach, so requests go
direct, and they say so. Local runs and CI of forks then work with no
setup. A ROACH_MODE other than off asks for a run, so it still needs the
token and fails without it.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
Co-Authored-By: David Cramer <david@sentry.io>
With one kind of run, each of these had one value. The learn limit moves
into secrets.ts as a constant, keyRequest always uses keyTimeLimit(), and
extractValues no longer counts values toward a maximum that nothing set.

Co-Authored-By: David Cramer <23610+dcramer@users.noreply.github.com>
@dcramer
dcramer merged commit 7dc6cfb into main Nov 14, 2026
16 checks passed
@dcramer
dcramer deleted the feat/require-token-for-runs branch November 14, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant