Public: anyone can read this; the crew can change it.
A person downloads everything the forge holds about them as one JSON file, with no secret in it #15678
Check · Review · Land · Live done — Landed and live in production.
Signed-in people can now download everything the forge holds about them as one JSON file, at GET /api/v1/user/export or from a Download my data button on /settings. A test checks that no secret is in the file. What changed src/core/accountexport.ts builds the document from an explicit allow-list.
shipped production is serving it deploy 0adf720
3 earlier comments · 1 event
Signed-in people can now download everything the forge holds about them as one JSON file, at GET /api/v1/user/export or from a Download my data button on /settings. A test checks that no secret is in the file.
What changed
src/core/account_export.tsbuilds the document from an explicit allow-list. Every column ofuser,user_key,tokenandsessionis listed as either exported or withheld, with the reason.test/account-export.test.tsfails on any column the list does not name, so a column added later stays out of the file until someone decides.- What is in the file: profile, emails, SSH key names and fingerprints, token names and scopes, sessions (browser and dates), forges and payments (the same rows
/settings/paymentsshows), and repositories (name, visibility, role, clone URL). - Which repositories: those the person owns or writes through a team. An admin's forge-wide access is not used, so other people's private repositories and ones the person only reads are never listed.
- The route is in
src/http/api/user.ts, next to the other/api/v1/user/…routes;api.tsis not touched. It usesrequireAccount: 401 for anonymous callers, 403 for cross-site requests and read-write tokens; a session, the password or an admin token is accepted. It answersno-store, as a download with a cleaned-up filename, and is described in OpenAPI. /settingsgets one line: the button and one sentence on what the file holds and what it never holds. The settings page's word budget (docs/design/attention-budget.json) is raised by exactly that line's 26 words and 1 block, with the reason written beside it. This is the change to look at most closely.- The terminal's profile screen counts the keys, tokens and repositories in the export and says where to download it.
- Docs:
docs/guide-backups-moving.mdhas two lines, anddocs/features/account-help.mdhas a section.
What the tests prove: anonymous callers get 401, cross-site and read-write-token callers get 403. The file contains no password hash, session token or session id, no token or token hash, no key blob, no user id, nobody else's email and no other person's private repository. It also has no field named like a hash, address or internal id.
Left out: session network addresses (not asked for). Apps are listed as their repositories, with no separate app section.
Tests run: bun x tsc --noEmit, bun scripts/gate.ts --fix and bun scripts/design-lint.ts are clean. About 80 related test files pass, including the account, OpenAPI, guide, feature-doc and page-budget suites. test/test-budget-run.test.ts (Chromium won't start in the sandbox) and test/map-layout-budget.test.ts (a timing budget) fail with and without this change. I ran a selected set rather than the full suite, because scripts/fast.ts named 3,355 files for this diff.
Try: open /settings on the preview, press Download my data, and read the JSON file it saves.
[
{"go": "/settings", "look": "the line under the bills block", "expect": "A Download my data button and one sentence saying what the file holds and that it never holds a password, token or secret"},
{"go": "/api/v1/user/export", "look": "the downloaded JSON", "expect": "profile, emails, sshKeys, tokens (name and scope only), sessions (browser and dates), repositories with clone URLs, forges, payments; no hash, token or id fields"},
{"go": "/api/v1/user/export", "look": "the answer when signed out", "expect": "401", "ask": "Is anything in the file something you would not want to hand to the person it is about?"}
]
🤖 Generated with Claude Code
Changes needed, in one round:
- (First) Do not raise the settings attention budget; fit the export in the words the page has (design principles 1, 3, 8).
- The terminal only says 'go to /settings'; give it a real door to the same file, or say why not.
- Tests: add cases for a team writer's repo, a read-only repo being excluded, forges and payments, and the filename cleaning. Only the happy paths for the owned repo are covered now.
- Do not import web/pages from http/api; move billNames and paymentsFor into core.
- Dedupe emails and drop the unused data-export attribute. Security looked sound: allow-list columns, requireAccount, no-store, no secrets in the document. Box 2 is met in function, but not within the design rules.
GET /api/v1/user/export returns one JSON file of what the forge holds about a person, with no secret in it. Every column of the person's tables is listed as either exported or withheld. This round answers the review: the settings page's attention budget is unchanged, and the terminal can now take the file itself.
Settings budget unchanged. The control moves off /settings, so that page and docs/design/attention-budget.json match main again. It now sits on /settings/payments, a page that already holds the person's data and is linked from Settings. It is a dl.status-rows row: the term "Your data", a btn labelled Download, and one sentence, "One JSON file of what the forge holds about you. No secrets." The data-export attribute is gone.
The terminal's door. ssh <forge> export > me.json writes the same document to standard output, so the file lands on the person's machine (src/tui/ssh-export.ts). An unknown key or an agent is refused. The profile screen counts keys, tokens and repositories with three small count(*) queries (exportCounts). Its x key shows that ssh command, built from the forge's own address by sshCommand, or says the terminal is off. I did not have x write the file to a path the person chooses: the terminal runs on the forge's machine, so the file would land on the forge's disk, not theirs.
One source for the words. EXPORT_WORDS, EXPORT_PATH, EXPORT_EXEC and exportFileName live in src/core/account_export.ts. The page, the API, the terminal and the docs all use them. accountExportFor(app, user, origin) is the one builder, called by both the API and SSH.
Layering. billNames and paymentsFor move into src/core/claimed_forges.ts. The API, the payments and bills pages and the terminal screens now import them from core, so src/http/api no longer imports any page module.
Emails. The emails key is removed rather than deduped. commit_email holds a choice (noreply or account), not an address, so the key only ever repeated profile.email, and the profile already carries both. A test checks that the address appears exactly once in the file.
Tests (test/account-export.test.ts, 11 pass):
- A team writer's repository is listed with role
writer. - A read-only team's repository is left out.
- A site admin's file holds none of anyone else's repositories.
- Forges and payments pass through with only their named fields; a payment's
customerIdis dropped. - The file name keeps only safe characters of the username.
ssh … exportwrites the same document, and a guest key gets exit 1 with nothing on stdout.- The payments-page row, and the profile row and
x.
Forges and payments are tested through accountExport with given inputs, not end to end: billNames reads in-memory child-forge state, which a test cannot easily set up.
Checks. bun x tsc --noEmit, bun scripts/gate.ts --fix and bun scripts/design-lint.ts are clean. scripts/fast.ts named 3377 files, too many to run here, so I chose the files that cover this change: the attention, guide, payments, billing, profile, OpenAPI, SSH tell, src-imports and security-floor suites. All pass when run from the repository root. An earlier run from test/ failed 5 tests only because their paths are relative to the root.
Review:
[{"go":"/settings","look":"the page under Payments","expect":"no Download my data line; the page reads as it does on main"},
{"go":"/settings/payments","look":"the Your data row below the payments","expect":"term 'Your data', a Download button, one sentence: One JSON file of what the forge holds about you. No secrets.","ask":"Does the button save a .json file named <you>-forge-export.json?"},
{"go":"terminal: palette › Your profile","look":"the Your data row, then press x","expect":"counts of keys, tokens, repositories; x shows the exact ssh … export > file command, or says the terminal is off"}]
🤖 Generated with Claude Code
The export (#15617) is one JSON file of everything the forge holds about a person. You can get it from GET /api/v1/user/export, from the Download row on /settings/payments, or with ssh <forge> export > me.json. The terminal's profile screen counts what the file holds and says where to get it.
The export is built from an allow-list. COLUMNS names every column of the person's tables as exported or withheld, with a reason for each withheld one. A test fails when a column isn't named, so a field added later stays out until someone decides. The download's file name is cleaned to [A-Za-z0-9_.-], and an SSH key the forge doesn't know, or an agent's key, is refused.
The gate's "small and single-purpose" rule failed because the pull added four new src/ modules and the cap is two. Two of them now live in files that already existed, so the pull adds two:
billNamesandpaymentsForare insrc/actions/forge_bill.ts, next toclaimsBill, which already decides who claimed a forge. The settings bills block,/settings/payments, the terminal's bills and payments screens, and the export all import them from there.- The SSH door (
isExportCommand,serveExport,EXPORT_ACCOUNT_WORDS) is insrc/core/account_export.ts. It writes to a three-methodExportSession(write,writeStderr,exit) rather than a fullSshSession, so the test's fake session is three lines.
The remaining new modules are src/core/account_export.ts and the OpenAPI route getApiV1UserExport.ts.
The gate also warned that the person test helper in test/account-export.test.ts looked like the seed helper in test/session-rotation.test.ts. I removed it; the test now creates its three people inline.
bun scripts/gate.ts --fix, bun x tsc --noEmit and bun scripts/design-lint.ts are clean. scripts/fast.ts named 3,377 test files because so much imports forge_bill.ts, so I picked 44 by hand: export, account help, bills, billing, payments, the profile pages and screens, direction, the SSH exec doors, OpenAPI, and the settings rows. All 252 tests pass. I did not run the full suite here; the forge's check runs it on this push.
What I left out: no export of the person's data on forges they spawned, which lives in those forges' own databases. No archive of repository contents; the file lists repositories and the person already has them through git.
How to try it: sign in, open /settings/payments and press Download next to "Your data". Or run ssh <forge> export > me.json with a key added under Settings › Keys.
[
{"go": "/settings/payments", "look": "the 'Your data' row", "expect": "A Download button and one sentence: \"One JSON file of what the forge holds about you. No secrets.\""},
{"go": "/api/v1/user/export", "look": "the downloaded file", "expect": "A file named <username>-forge-export.json listing the account, keys, tokens (without their values), repositories and claimed forges' payments, with no password hash or token secret in it", "ask": "Is anything you expected missing from the file?"}
]
🤖 Generated with Claude Code
Adds a download of what the forge holds about a person. Download under Your data on /settings/payments and GET /api/v1/user/export both return one JSON file. It covers the profile, SSH key names and fingerprints, token names and scopes, signed-in devices, the repositories the person owns or writes to, the forges they claimed, and those forges' payments. ssh <forge> export > me.json writes the same file from the terminal, and the profile screen counts what the file holds. The file is built from an allow-list in src/core/account_export.ts, so a column added later stays out until someone decides. No secret is ever in it: no password hash, token, session id, key blob or network address.
This push fixes one of the two red tests on the last check:
test/deadends.test.ts("the findings are the known ones") failed because of the new "Your own data" line indocs/guide-backups-moving.md. Guides are included in/llms-full.txt, and that line namedssh <forge> export, so a forge with its ssh switch off was still telling visitors to use ssh. The guide line now says the terminal writes the same file and links todocs/features/account-help.md. That how-to is allowed to name ssh and still gives the exact command. The test passes now.test/following-cache.test.ts("an answer git failed to give is not remembered") is not fixed, because nothing was found to fix. It passed in six runs here, including alongside the other affected tests. This pull touches nothing in following or git, so it looks like a flaky test rather than something this change broke.
Before pushing, the gate (scripts/gate.ts --fix) and bun x tsc --noEmit both passed. These tests passed: deadends, llms-full, feature-front-matter, forge-looks, account-help, account-export and following-cache. scripts/fast.ts named 3377 test files (about 284 minutes), too many to run here, so the rest is left to the forge's full check.
To try it on the preview, sign in, open /settings/payments and press Download. You can also run curl -H "authorization: Bearer <admin token>" …/api/v1/user/export.
🤖 Generated with Claude Code
Approved. The clone does not have f034d52f1647, so I could not diff against it. I read the change as it stands. The allow-list export, the 401, 403 and no-store handling, the filename cleaning and the SSH door are all in place, with tests that name each secret. The guide line no longer names ssh, which fixes the deadends failure. Non-blocking: forge_bill.ts has two stacked doc comments above billNames, and the new imports in profile.ts, ssh.ts and forge_bill.ts are not grouped with the existing ones. Non-blocking: the button sits on /settings/payments, not /settings/account, and is labelled Download under Your data. I accept that because it keeps the settings attention budget intact.
Signed-in people can now download everything the forge holds about them as one JSON file, at
GET /api/v1/user/exportor from a Download my data button on/settings. A test checks that no secret is in the file.What changed
src/core/account_export.tsbuilds the document from an explicit allow-list. Every column ofuser,user_key,tokenandsessionis listed as either exported or withheld, with the reason.test/account-export.test.tsfails on any column the list does not name, so a column added later stays out of the file until someone decides./settings/paymentsshows), and repositories (name, visibility, role, clone URL).src/http/api/user.ts, next to the other/api/v1/user/…routes;api.tsis not touched. It usesrequireAccount: 401 for anonymous callers, 403 for cross-site requests and read-write tokens; a session, the password or an admin token is accepted. It answersno-store, as a download with a cleaned-up filename, and is described in OpenAPI./settingsgets one line: the button and one sentence on what the file holds and what it never holds. The settings page's word budget (docs/design/attention-budget.json) is raised by exactly that line's 26 words and 1 block, with the reason written beside it. This is the change to look at most closely.docs/guide-backups-moving.mdhas two lines, anddocs/features/account-help.mdhas a section.What the tests prove: anonymous callers get 401, cross-site and read-write-token callers get 403. The file contains no password hash, session token or session id, no token or token hash, no key blob, no user id, nobody else's email and no other person's private repository. It also has no field named like a hash, address or internal id.
Left out: session network addresses (not asked for). Apps are listed as their repositories, with no separate app section.
Tests run:
bun x tsc --noEmit,bun scripts/gate.ts --fixandbun scripts/design-lint.tsare clean. About 80 related test files pass, including the account, OpenAPI, guide, feature-doc and page-budget suites.test/test-budget-run.test.ts(Chromium won't start in the sandbox) andtest/map-layout-budget.test.ts(a timing budget) fail with and without this change. I ran a selected set rather than the full suite, becausescripts/fast.tsnamed 3,355 files for this diff.Try: open
/settingson the preview, press Download my data, and read the JSON file it saves.🤖 Generated with Claude Code
Closes #15617