Public: anyone can read this; the crew can change it.

Universal runner: a Mac registers itself, ships TestFlight from main with the forge's secrets, and has one switch #18291

opened this in answer to

Merged 4h 20m ago, live in production

This pull is the first slice of #18257: environments and runner trust. It does not close the issue. A job on main can't use any of it yet, and no runner, page or terminal shows it.

Notes

opened this

This pull is the first slice of #18257: environments and runner trust. It does not close the issue. A job on main can't use any of it yet, and no runner, page or terminal shows it. I did not run the full suite. The gate passes; the tests I ran (placement, base gate, lent runners, settings runners, repo delete, schema migrations, openapi, the new test/environments.test.ts and a few rule tests) all pass.

What changed

  • Store and rule: a repository now has named environments of variables and secrets. src/checks/environment.ts holds the store and the one rule for what a job receives. Each entry is for any runner or trusted runners only.
    • Secrets are sealed with kernel/secret.ts, bound to repository, environment and name. They are write-only: nothing returns a value.
    • Variables default to any runner. A secret defaults to trusted, and for any runner it needs confirm set to its own name.
    • A secret goes to a job only when the job's lane is main, the runner is trusted, and the entry allows it. A pull's head and a fork's get none. A fork is another repository, so it holds its own entries and none of its parent's.
    • Variables, and the lane-gated secrets, are opened only in the claim reply. They are never stored on the job's spec.
  • Claim: src/checks/job_environment.ts builds the job's environment at claim. The run log gets one line naming what was received and what was withheld, with the reason, never a value. CI and FORGE_* can't be shadowed.
  • Logs: the runner's report route masks every secret value in log lines and in step errors and notes.
  • forge.json: check.environment names the environment, and a bad name is refused. RunnerJob gains environment and lane. A missing lane means a pull.
  • Trust: two new columns on check_runner record who set it and when. The forge's own local-N runners can't be marked.
  • Migration: 20261204140000-repo-environment.ts is additive and pinned. Deleting a repository deletes its entries.
  • API, in the openapi contract:
    • GET /api/v1/repos/{owner}/{name}/environments lists entries: variables with values, secrets by name.
    • PUT and DELETE on .../environments/{env}/{entry} set and remove one entry. All three are for the repository's administrator; anyone else gets 404.
    • POST /api/v1/admin/runners/{id}/trust marks a runner trusted or takes it back. It is admin only.
  • Reused: seal/open, the existing runner claim and report routes, canAdmin, and the repo-delete cleanup pattern.
  • Docs: docs/features/environments.md.

What I chose not to do

  • Jobs on main: none exist yet, so no job carries lane: "main" and a secret can't reach a runner yet. Only any-runner variables flow today, to checks that name an environment. Jobs on main come next, and the TestFlight job after that.
  • Doors: no web page, terminal screen or MCP tool for entries or trust yet. The first commit says No door: for this; the Runners page switch is the next slice. The existing /settings/runners page and pause/resume switch are untouched.
  • Fork variables: a fork does not inherit the parent's any-runner variables. It inherits nothing.
  • Not started: auto-register, offered Macs, the tab spike, the security review of the secrets slice, and removing scripts/testflight --watch.

Try it: with an admin token on the preview, run PUT /api/v1/repos/OWNER/NAME/environments/testflight/ASC_KEY with {"kind":"secret","value":"x"}. Then GET .../environments lists the name and no value. POST /api/v1/admin/runners/ID/trust with {"trusted":true} marks a runner.

🤖 Generated with Claude Code

Closes #18257

Show 2 earlier items

7 earlier comments
commented

I've pushed fixes for the four failing tests. Each of the four passes when run on its own here, and tsc is clean. I didn't run the full suite. I also didn't re-run the gate's rewrap pass after committing.

  • Route timing: /api/v1/repos/:owner/:name/environments is now in the UNTIMED allowlist in test/route-timing-coverage.test.ts. It is a single indexed read with no page to phase.
  • OpenAPI tags: the environment routes were generating an environments tag with no description. I added an alias in src/contract/tags.ts that files them under apps, where TAG_WORDS already mentions environments.
  • Account purge: repo_env.set_by and check_runner.trusted_by hold usernames, not user ids. They are now listed in COVERED in src/core/account_purge.ts, and purgeAccount rewrites them to "a former member" when an account is erased. Nothing tests that rewrite directly.
  • Data browser: repo_env.value is added to AUDITED_CLEAR in test/data-browser.test.ts. A variable is stored in the clear and a secret is sealed before it is stored.

The gate still prints a few "one implementation?" similarity notes. I left them alone.

🤖 Generated with Claude Code

commented

This push addresses all six points of the review, and I disagree on one part of point 1. The new tests, the touched suites and tsc pass locally. I did not run the full suite: scripts/fast.ts named 4,232 of 5,000 files, so I ran the suites that cover this change.

1. Mask bypass. maskFor now masks by every secret of the job's environment, whatever the runner's trust or the entry's scope (secretValues in src/checks/environment.ts). Revoking trust mid-job no longer unmasks the value, and a test claims, revokes, reports and expects ***. I did not keep values in memory for the claim's life. A module-level map is what the module-state test forbids, so a secret rotated or removed mid-job is still not masked. docs/features/environments.md says so.

2. Multi-line and short secrets.

  • Masking now covers the whole value and each line of it. Each form is also masked in base64 and URL-encoded form.
  • A secret under 4 characters is refused at set time, which replaces the old silent skip.
  • A secret split across two reported lines or batches is still not caught. The docs list this too.

3. Tests (test/environments-masks.test.ts):

  • The report route masks a line, a step's error and the note, and the stored result is checked.
  • The claim's log line says what was received and what was withheld.
  • A trusted-only variable is withheld from an untrusted runner.
  • A repository's entries go when the repository is deleted.
  • An erased account's name on repo_env.set_by and check_runner.trusted_by becomes the placeholder's.

4. Both doors.

  • A new terminal screen, the palette's "Environments", lists entries by name only. a sets one, with the secret's value asked in a hidden prompt, and x removes one.
  • The Runners page has Trust and Untrust buttons.
  • In the terminal's runners list, t toggles trust on the selected runner.

5. Reserved names. The match is now case-insensitive. It adds NODE_*, LD_*, DYLD_*, GIT_*, SSH_*, BASH_ENV, ENV, SHELL, IFS, PS4, TMPDIR and USER.

6. Main-lane producer. tryRunner now sets lane on every job. It is main only for the default branch's own check (laneOf), fork for an outside contributor's pull, and pull otherwise. A test covers all four cases.

The remaining issue boxes stay open, as you said. I did not pull in the unrelated "one implementation?" gate notes.

🤖 Generated with Claude Code

commented

<!-- look-pages f6a5f39be8a9 --> Look pages for f6a5f39, from the gate:

  • look pages (none): this pull changes src/web/pages/runners.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

The three failing checks should pass now, and I pushed the fix. I re-ran test/environments-masks.test.ts, test/no-secrets-tracked.test.ts, test/tree.test.ts and test/boot-lazy.test.ts locally and all 31 tests pass. I did not re-run bun x tsc --noEmit or the full suite. The forge's check runs on the push.

  • Stale route list: I regenerated src/http/lazy_lists.ts with bun scripts/lazy-lists.ts.
  • Key-shaped fixture: test/environments-masks.test.ts held a literal PEM private-key header in two places. The tree audit and the token scan both flagged them. I now build the dashes from a constant, the same way test/tree.test.ts does, so the test still checks the same strings.
  • Gate warning, left alone: scripts/gate.ts --fix reports that offer in test/environments-masks.test.ts and in test/environments.test.ts are 95% alike ("one implementation?"). That is a duplication note, not a failure. I did not fold the two together.

No page or UI behaviour changed.

commented

<!-- look-pages ca3b0ffc2d39 --> Look pages for ca3b0ff, from the gate:

  • look pages (none): this pull changes src/web/pages/runners.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

I addressed the feedback and pushed. The gate now reports no failures, only the two notes below. I did not re-run bun x tsc --noEmit or the full suite; the forge's check runs on the push.

  • Look pages: the last commit carries a No look: line. /settings/runners is not in app.looks, and the page change is two buttons behind an admin check.
  • Route marks: gate --explain showed a failing test, "every route is marked admin or open". POST /settings/runners/:id/trust and /untrust had no mark. I marked both admin in src/http/marks/settings.json, since the handler already refuses non-admins. The neighbouring runner routes are marked open. I left those as they were.
  • The four refusals you listed:
    • The tests for dead exports, duplicate imports and untimed jobs pass.
    • The gate's "name the issue" rule passed, and I added a Direction: line (#18257) anyway.
  • Gate notes, not failures: the duplicate-function notes are unchanged, including the offer helper in two test files. The comment-width note says the nightly rewrap handles it.
commented

This adds no new commit: the branch on the forge already had the fix for the failing route-marks test, so I dropped my duplicate. Nothing was pushed from this run.

The failing test, "every registered route is marked admin or open", was missing marks for POST /settings/runners/:id/trust and POST /settings/runners/:id/untrust. Commit a6b9467fd ("Mark the runner trust routes admin so every route chooses") adds both to src/http/marks/settings.json. I made the same fix myself as open, then found theirs when my push was rejected and reset to it.

Admin or open: their commit marks the two routes admin, while the other runner routes in that file are open. Both versions pass the route-marks test. The handler, runnerTrust, checks for admin itself either way, so I kept admin, which is the stricter choice for a route that decides whether a machine is sent secrets.

Checks run on that branch state:

  • test/route-marks.test.ts passes (20 tests).
  • Before the reset, the four tests the forge named as common failures also passed: dead-code exports, duplicate imports, the route-timing coverage and module-level state. I did not re-run them on a6b9467fd, which differs from my tree only in that settings file.
  • bun x tsc --noEmit was clean before the reset; I did not re-run it after.
  • bun scripts/gate.ts --fix changed no files. It printed similarity notes between a few environment functions and between the two offer test helpers. I left them, because merging them would be a refactor outside this fix.

The gate also noted that the pull touches src/web/pages/runners.ts and needs a "Looks:" or "No look:" line in a commit message. This run made no commit, so I added none. The forge will run the full check on the next push.

commented

Left #18257 open: 9 unticked items remain (Jobs on main, not only pull checks. forge.json declares a job that runs when main moves (on: main, labels macos), with ordered steps. For forge-apple: smoke, archive, export, upload. Its run shows on the repository like any run, with logs, and a red run opens or updates one issue.; Per-run secrets, so nobody who merges needs a token. The repository's owner stores the App Store Connect key and signing material once as sealed, write-only repository secrets. A job that names a secret receives it for that run only, only on main (never on a pull's head, never from a fork), only on a runner the owner marked trusted for secrets, and it is masked in logs. Anyone, person or agent, merges; the forge and the runner do the rest.; Auto-register. A Mac signs in to the forge once (device flow from the menu bar helper or scripts/runner); after that it registers itself, heartbeats when it is available (AC power, idle, cool) and reappears after a restart with no token pasted anywhere. Its runner token stays in the Keychain.; …).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs