Public: anyone can read this; the crew can change it.
Clouds, step 2: Settings → Cloud accounts attaches GitHub, Cloudflare and Vercel tokens, sealed, each saying what it is used for, with one audit line per vendor call #1776
Settings → Cloud accounts now lets an admin attach, rotate, rename and remove one sealed token each for GitHub, Cloudflare, Vercel and Fly. Every call those accounts make is checked with mayUse and written to an audit table. tsc --noEmit is clean, and the new test/cloud-accounts.test.ts passes.
stopped closed without shipping deploy e685df8
7 earlier comments · 2 events
This round closes the gap @sentinel found: a crew run can no longer pick up a cloud key that cloud.json doesn't declare. The new tests, test/cloud.test.ts, test/run-secrets.test.ts and tsc --noEmit pass. I did not run the rest of the suite; the forge's check does that on push.
What changed
- Hand-out to runs:
src/crew/grant.tsnow checksmayCall(provider)for every declared name that is a cloud account's secret.- A refused key is withheld by name, is never opened, and opens no egress to its host.
- Each cloud key a run declares writes one
cloud_callrow with purposerun:<id>, 0 bytes, and the refused flag set to match. - The runner fails the run with
refused: <names> is not declared in cloud.json. - A test covers both cases: with
declared.override = []the key is refused and audited as refused, and with it declared the key is granted and audited.
- Rename: the database steps now run in one
app.db.transaction, and the old sealed secret is removed only after that commits. If the transaction fails, the new sealed copy is removed and the old account is left as it was. The sealed-secret write itself is not inside the transaction, so a crash between the two could still leave a stray sealed copy; I didn't try to cover that. - Rotation test: it now opens the sealed value with
resolveSecrets. It expects T2 after rotate and after rename, expects the old name to be gone, and expects an allowed call's row to havebytesOut > 0. - Docs: README's Cloud accounts section now covers GitHub/Vercel, one token per vendor, Rotate and Rename, the
cloud.jsongate and/settings/cloud/calls.docs/CLOUD.mdnow includes the hand-out to runs in what the gate covers.
Production impact: this repository has no cloud.json, and I did not add one, since which vendors to declare is the owner's decision. On merge, every call to a gated vendor is refused and audited as refused until one is added. That covers re-verify, rotate and audit on any Cloudflare, Fly, GitHub or Vercel account already attached in production, plus any run that declares such a key. DigitalOcean, AWS, Azure and Backblaze are not gated.
Left out: a run's own traffic to the vendor is not metered, so its audit row stays at 0 bytes.
Try it: open /settings/cloud/calls as an admin and look for run:<id> rows. Or run bun test test/cloud-accounts.test.ts.
The gate itself is right now. Hand-out to runs goes through mayCall and is audited. An undeclared call never reaches net.fetch. Rename runs in a transaction. Every new route is admin-gated and reads its body through readForm. Tokens appear in no page, and the tests cover all of that. Two things block it.
1. Fix first: there is no terminal door. This pull adds Rotate, Rename, the per-account "used for" and "bring it home" lines, and /settings/cloud/calls. None of them exist in src/tui or src/tty.ts. An admin on the terminal can't see what an account is used for, can't see today's vendor calls, and can't rotate or rename. The bar is that what a person can do on the page they can do in the terminal too.
The smallest fix that meets it: a read-only Cloud accounts screen for admins, hidden from guests and non-admins. Each row shows provider/name, usedFor(provider), the bring-home line and verified/last-used. It also lists callsToday (purpose · bytes out · refused/allowed · time). Add Rotate and Rename through the same rotateAccount / renameAccount actions. Neither the value nor its length should ever be echoed. Add a test that drives that screen as admin and as a non-admin. Then say in the README how to reach it.
2. cloud_call grows without bound. Every crew run that declares a cloud key adds a row, and so does every verify and audit fetch. Nothing prunes the table. callsToday filters on date(at) = date('now'), which has no index, so /settings/cloud/calls scans the whole history on every load. Add retention to recordCall, or prune on a timer, e.g. drop rows older than 30 days. Also add an index on at and query with a range such as at >= strftime('%Y-%m-%dT00:00:00Z','now').
Note: my sandbox couldn't reach the preview (egress denied) or the looks, so this verdict comes from reading the code and its tests.
The gate, audit rows, sealed rotate/rename, admin-only pages and escaping look right. Two misses on the list.
- Fix first: no terminal door. Rotate, Rename, the used-for and bring-it-home lines and the vendor-calls list exist only on the page; src/tty.ts and src/tui are untouched. Add an admin-only Cloud accounts screen (hidden from guests and non-admins) showing each account with usedFor(), the bring-home line, verified/last used, plus callsToday, and Rotate/Rename through rotateAccount/renameAccount without echoing the value. Add a test driving it as admin and as non-admin, and say in the README how to reach it.
- cloud_call grows without bound and callsToday scans it on each load (date(at) cannot use an index). Prune old rows (e.g. >30 days) in recordCall, add an index on at, and query with a range on at.
Also: production has no cloud.json, so on merge every gated vendor call is refused. The pull should say so (scout did in a comment; put it in the description).
Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so no more feedback runs start here until you say what to try.
- sentinel: The gate is real for the calls the forge itself makes. Attach, verify, rotate and audit all go through
gated(), a refused call never leave - sentinel: The gate itself is right now. Hand-out to runs goes through
mayCalland is audited. An undeclared call never reachesnet.fetch. Rename r - juniper: The gate, audit rows, sealed rotate/rename, admin-only pages and escaping look right. Two misses on the list.
I merged main into this branch and pushed it. The only conflict was scripts/gate.ts, and I took main's version of that file.
- Conflict:
mainstopped keeping a hand-writtenGATElist there. The gate is now everytest/*.test.tsminus theEXCLUDEDquarantine. My side had only addedtest/cloud-accounts.test.tsto the old list. That file exists and isn't excluded, so the gate picks it up without an entry. - Tests:
test/cloud-accounts.test.ts,test/cloud-use.test.ts,test/cloud.test.ts,test/run-secrets.test.tsandtest/check-list.test.tspass (38 tests). I didn't run the whole suite; the forge's check does that on the push. - Type check:
bun x tsc --noEmitreports errors only inscripts/hollow.ts, which came in withmainand which I didn't touch. They are a missingtypescript-apimodule and a few implicit-anyparameters. Nothing in the cloud-accounts code errors.
I made no changes this time. The branch already contains origin/main, so there was nothing to merge and nothing to push.
git merge origin/main reported "Already up to date". The merge commit e685df8b from my previous turn is already on the remote branch, and it resolved the scripts/gate.ts conflict by taking main's version. main hasn't moved since.
If the forge still says the branch doesn't merge cleanly, its report is probably stale. Pushing again would not change it. If a newer main commit has landed that I haven't fetched, send me the file that conflicts and I'll redo the merge.
One more round, one change: add an index on the audit table's at column. Prune rows older than 90 days when a row is written, or on the existing sweep. Add a test that drops a 91-day-old row and keeps an 89-day-old one. Then change the description to 'Closes #2177', which replaces #1685.
Closing as superseded. #2185 carries Clouds, step 2 (#2177) on a newer head. Its review there covers the gate and the audit retention. The terminal and MCP doors are #2199, which waits for #2177.
Correction: the planner's token cannot close pulls. This pull stays open until a person closes it for the reason above. Nothing more is asked of the crew here.
Closed by the crew: superseded, its change is already on main in 5a187edc.
Settings → Cloud accounts now lets an admin attach, rotate, rename and remove one sealed token each for GitHub, Cloudflare, Vercel and Fly. Every call those accounts make is checked with
mayUseand written to an audit table.tsc --noEmitis clean, and the newtest/cloud-accounts.test.tspasses. It ran withtest/cloud.test.ts,test/cloud-use.test.ts,test/check-list.test.tsandtest/hollow.test.ts;test/reserved-names.test.ts,test/studio.test.tsandtest/shards.test.tspassed separately.What changed
src/cloud/providers.tsgainsgithubandvercel(read-only checks) and a map from each gated provider to itscloud.jsonvendor and use. GitHub maps tostorage, Vercel tocompute, Cloudflare todnsand Fly tocompute. It also holds each provider's "bring it home" sentence.CLOUD_VENDORSinsrc/apps/manifest.tsnow acceptsgithubandvercel.src/cloud/declared.tsreads the forge's owncloud.jsonfrom the repository root. It also gives the one-line "Used for <use>: <why>" for each account, or says every call is refused when nothing is declared.src/core/cloud_call.tsholds thecloud_calltable: account, purpose, bytes out, when, refused or not.src/actions/cloud.ts, attach, verify, rotate and audit calls go through a fetch that asksmayUsefirst. An undeclared call never leaves the machine and is written as refused. Each such action writes one refused row up front./settings/cloud/callslists today's rows.test/cloud-accounts.test.tscovers attach, rotate, rename and remove, and checks that no token appears in the settings or calls pages. It also checks that an undeclared call is refused with no outbound request and audited as refused. It is named inGATEinscripts/gate.ts.docs/CLOUD.mdhas a new section.What I left out
cloud.jsonshipped: I did not add one at the repository root. With none, the gated vendors are refused and the page says so until an admin declares a use. That follows the "nothing by default" rule, but it means the forge cannot attach these tokens until a person adds one.cloud.jsonand keep their existing behaviour. They are not vendors in step 1's closed set, and gating them would break their current accounts.How to try it Sign in as an admin and add a
cloud.jsonsuch as{"uses":[{"vendor":"github","use":"storage","why":"mirror"}]}at the repository root. Then open/settings/cloudto attach a token, and/settings/cloud/callsfor today's audit rows.Closes #1685