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

Access 5: a visitor with no account is someone the forge knows, and what they made comes with them when they sign up #18069

opened this in answer to

Parked 2h 27m ago

A visitor with no account now has a signed id, a role in the CAN table, and a way to bring what they made into an account. Three things the issue lists are not done: the same-origin tab forge's and the Apple app's POST /visitor/work calls, the existing anonymous spawn, and the "same may() table".

Notes

opened this

A visitor with no account now has a signed id, a role in the CAN table, and a way to bring what they made into an account. Three things the issue lists are not done: the same-origin tab forge's and the Apple app's POST /visitor/work calls, the existing anonymous spawn, and the "same may() table". I ran bun x tsc --noEmit, bun scripts/design-lint.ts, bun test test/mcp-size.test.ts and about 400 related tests, all green. I did not run the whole suite; the forge's check does that.

Threat note. The risk is account takeover and privacy: someone planting their things into a victim's account, or lifting a victim's device list.

  • The id is signed under its own label (visitor-principal), not the analytics one. Cookie forge_vp, shape v…; forge_visitor and c… ids are never accepted as one, and the two are never joined.
  • The id is minted only at POST /visitor/work, never on a read. Do-Not-Track and Global Privacy Control mean no id is given.
  • Bringing needs a signed-in person, a same-origin form, the signed id, and a confirm bound to account, session, device and chosen rows. The confirm comes from the page that account was shown. A forged, borrowed or missing one moves nothing, with or without a passkey on the account.
  • A bringing is one transaction with a receipt. It can be undone for a day, then it is theirs.
  • Visitor events are not added to the reader-visible event list.

What changed

  • src/auth/visitor_principal.ts: mints and verifies the signed id and builds its cookie and confirmation token. It reuses cookieValue and the refusesTracking check.
  • src/core/visitor_work.ts: keeps what a visitor made (apps from the tab forge, notes, game players) and does the bringing and the undo. The visitor_principal, visitor_item and visitor_carry tables are in migration 20261204052000-visitor-principal.
  • src/core/roles.ts: a visitor role with read and keep_work. docs/ROLES.md is regenerated.
  • Limits: three visitor.* rows in settings/limits.ts: things per visitor (20), things per forge per day (1000), new ids per day (2000). Past one, the door answers 429.
  • Web: /visitor/bring (list, bring, undo) and POST /visitor/work, in src/web/pages/visitor_bring.ts. After sign-in the front page says once that something waits.
  • Move-in: /forges/move-in brings the visitor's tab_app items into the account that moves in.
  • Terminal: the palette entry "Brought in from a device" shows what was brought and the receipts. u undoes the newest bringing still inside its day.
  • Docs: docs/features/visitor-carry.md, and two threat bullets in docs/threats/automated-attacker.md.
  • Cookie roster: test/cookie-flags.test.ts gained entries for the new cookie.
  • Tests: test/visitor-carry.test.ts, 14 tests. They cover make as a visitor, bring, find it owned by the account, and a second visitor presenting the first's id without its signature being refused. They also cover forged, borrowed and missing confirms into a passkey account, a cross-site post, undo, limits, GPC/DNT, and the move-in hook.

What I chose not to do

  • Existing anonymous spawn: its own claim link (src/spawn/claim.ts) is untouched; moving it onto this model is a separate slice.
  • Callers of the door: the tab forge's and the Apple app's calls to POST /visitor/work (#18043, forge-apple #52) are theirs to add. There is no API route or MCP tool, so mcp-size is unaffected.
  • "Same may() table": contract/can.ts's may() is the evaluator for apps' contracts. The forge's own table is CAN, so the visitor role went there.
  • Account page: the account page and terminal can screen list every ability, so a member now also sees "Keep what you make before you have an account: no".
  • Per-client mint limit: there is no per-address limit on minting, since that would store an address-derived value. Minting is capped per forge per day, and each visitor is capped per kept item.

Try it. On the preview, curl -i -d 'kind=tab_app&ref=notes&label=Notes' -H 'origin: <preview url>' <preview>/visitor/work returns a forge_vp cookie. Open /visitor/bring signed out, then signed in, to choose and bring the item, then undo it. On the terminal, open the palette entry "Brought in from a device".

[
  {"go": "/visitor/bring", "look": "signed out, in a browser holding forge_vp with a kept item", "expect": "the item is listed with Sign in and Sign up buttons"},
  {"go": "/visitor/bring", "look": "signed in, same browser", "expect": "checkboxes and one button to bring the chosen things; after pressing it a receipt with Undo"},
  {"go": "/", "look": "signed in with an unbrought item on the device", "expect": "one notice pointing at /visitor/bring"}
]

🤖 Generated with Claude Code

Closes #18051

21 earlier comments · 1 event
commented

A visitor with no account now has a signed id, a role in the CAN table, and a way to bring what they made into an account. Three things the issue lists are not done: the same-origin tab forge's and the Apple app's POST /visitor/work calls, the existing anonymous spawn, and the "same may() table". I ran bun x tsc --noEmit, bun scripts/design-lint.ts, bun test test/mcp-size.test.ts and about 400 related tests, all green. I did not run the whole suite; the forge's check does that.

Threat note. The risk is account takeover and privacy: someone planting their things into a victim's account, or lifting a victim's device list.

  • The id is signed under its own label (visitor-principal), not the analytics one. Cookie forge_vp, shape v…; forge_visitor and c… ids are never accepted as one, and the two are never joined.
  • The id is minted only at POST /visitor/work, never on a read. Do-Not-Track and Global Privacy Control mean no id is given.
  • Bringing needs a signed-in person, a same-origin form, the signed id, and a confirm bound to account, session, device and chosen rows. The confirm comes from the page that account was shown. A forged, borrowed or missing one moves nothing, with or without a passkey on the account.
  • A bringing is one transaction with a receipt. It can be undone for a day, then it is theirs.
  • Visitor events are not added to the reader-visible event list.

What changed

  • src/auth/visitor_principal.ts: mints and verifies the signed id and builds its cookie and confirmation token. It reuses cookieValue and the refusesTracking check.
  • src/core/visitor_work.ts: keeps what a visitor made (apps from the tab forge, notes, game players) and does the bringing and the undo. The visitor_principal, visitor_item and visitor_carry tables are in migration 20261204052000-visitor-principal.
  • src/core/roles.ts: a visitor role with read and keep_work. docs/ROLES.md is regenerated.
  • Limits: three visitor.* rows in settings/limits.ts: things per visitor (20), things per forge per day (1000), new ids per day (2000). Past one, the door answers 429.
  • Web: /visitor/bring (list, bring, undo) and POST /visitor/work, in src/web/pages/visitor_bring.ts. After sign-in the front page says once that something waits.
  • Move-in: /forges/move-in brings the visitor's tab_app items into the account that moves in.
  • Terminal: the palette entry "Brought in from a device" shows what was brought and the receipts. u undoes the newest bringing still inside its day.
  • Docs: docs/features/visitor-carry.md, and two threat bullets in docs/threats/automated-attacker.md.
  • Cookie roster: test/cookie-flags.test.ts gained entries for the new cookie.
  • Tests: test/visitor-carry.test.ts, 14 tests. They cover make as a visitor, bring, find it owned by the account, and a second visitor presenting the first's id without its signature being refused. They also cover forged, borrowed and missing confirms into a passkey account, a cross-site post, undo, limits, GPC/DNT, and the move-in hook.

What I chose not to do

  • Existing anonymous spawn: its own claim link (src/spawn/claim.ts) is untouched; moving it onto this model is a separate slice.
  • Callers of the door: the tab forge's and the Apple app's calls to POST /visitor/work (#18043, forge-apple #52) are theirs to add. There is no API route or MCP tool, so mcp-size is unaffected.
  • "Same may() table": contract/can.ts's may() is the evaluator for apps' contracts. The forge's own table is CAN, so the visitor role went there.
  • Account page: the account page and terminal can screen list every ability, so a member now also sees "Keep what you make before you have an account: no".
  • Per-client mint limit: there is no per-address limit on minting, since that would store an address-derived value. Minting is capped per forge per day, and each visitor is capped per kept item.

Try it. On the preview, curl -i -d 'kind=tab_app&ref=notes&label=Notes' -H 'origin: <preview url>' <preview>/visitor/work returns a forge_vp cookie. Open /visitor/bring signed out, then signed in, to choose and bring the item, then undo it. On the terminal, open the palette entry "Brought in from a device".

[
  {"go": "/visitor/bring", "look": "signed out, in a browser holding forge_vp with a kept item", "expect": "the item is listed with Sign in and Sign up buttons"},
  {"go": "/visitor/bring", "look": "signed in, same browser", "expect": "checkboxes and one button to bring the chosen things; after pressing it a receipt with Undo"},
  {"go": "/", "look": "signed in with an unbrought item on the device", "expect": "one notice pointing at /visitor/bring"}
]

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it (46c10cf33). Only src/generated/screens.ts conflicted. It's generated, so I took main's version and regenerated it with bun scripts/own-source.ts.

After the merge, bun x tsc --noEmit was clean and test/own-source.test.ts passed (3 tests). I did not run the wider test set. scripts/fast.ts found 4144 files affected, about 5 hours of tests, so I stopped it. The forge's check will run the full suite on this push.

No new behaviour, no new dependencies, and no page changes.

commented

This push fixes the one failing check from #18069: the event-audience coverage test, which flagged visitor.brought and visitor.undone. Those two events are emitted when someone brings a device's work into their account or undoes it (src/web/pages/visitor_bring.ts). Nobody had classified them, so they would have defaulted to admin-only.

I classified both as the actor's own receipts in src/core/event_audience.ts. Only the person who brought or undid the items sees them in their feed. The commit carries No door: an event audience entry, not a page, action or route, because no page, action or API route changed.

I ran these before pushing:

  • Event audience coverage test: passes (5/5).
  • The other three checks the crew keeps failing: the dead-code, module-state and during job-timing tests pass (test/unused-exports.test.ts, test/module-state.test.ts, test/job-slices.test.ts).
  • bun x tsc --noEmit: clean.
  • bun scripts/gate.ts --fix: it rewrapped nothing. It did print two "one implementation?" notes, on receiptsOf and on visitorRoutes. They aren't errors, and I left them alone because merging them would change code beyond this fix.

I did not run the full suite. The forge runs it on this push.

I chose not to touch anything else in the pull. To try it, sign in on a device that has anonymous work, open /visitor/bring, bring something in, and undo it. The receipt shows in your own activity and in nobody else's.

commented

I merged main into this branch and pushed it. src/generated/marks.ts was the only conflict, and I regenerated it with bun scripts/own-source.ts instead of merging it by hand.

bun x tsc --noEmit is clean. test/own-source.test.ts and the visitors tests pass (17 tests). I did not run the full suite; the forge runs the whole check on the push.

bun scripts/gate.ts --fix ran and left nothing to commit. It still prints two "one implementation?" similarity notes, on receiptsOf and on visitorRoutes, which I left alone.

commented

I merged main into the branch and pushed. The only conflict was docs/ROLES.md.

Both sides had rewritten the opening of that file, so I kept both. From main I kept the new "The words" table and the paragraph on principalOf. I merged my visitor-carry sentence (#18051) into that paragraph. Its old line said nothing is stored for a visitor, which contradicted what this branch does. It now reads "no account row exists for one, though they may keep what they make to bring it into an account when they sign up", and points to docs/features/visitor-carry.md.

bun x tsc --noEmit is clean, and the roles, own-source and visitors tests pass (29 tests). I did not run the full suite; the forge runs the whole check on the push. bun scripts/gate.ts --fix left nothing to commit. It still prints the "one implementation?" similarity note on visitorRoutes, which I left alone.

commented

I merged main into the branch again and pushed. The only conflict was src/generated/marks.ts, same as the first time. I took main's copy and regenerated it with bun scripts/own-source.ts, so it reflects both sides.

bun x tsc --noEmit is clean. The own-source, visitors and roles tests pass (29 tests). I did not run the full suite; the forge runs the whole check on the push. bun scripts/gate.ts --fix left nothing to commit. It still prints the "one implementation?" similarity note on visitorRoutes, which I left alone.

commented

Still red on current main: every top-level page has an entry in the audit. Fix it and push.

commented

This push fixes the failing check. docs/design/audit.md had no entry for /visitor/bring, the page this pull added, so the audit had 141 entries against 142 pages. I added the entry after /bring. test/design-audit.test.ts now passes (4 of 4), and I ran only that file, not the full suite or tsc.

I made no other changes. Every other change in the pull is as it was before this push, and no code changed here.

Review

[{"go":"/visitor/bring","look":"the page lists what this device made before an account","expect":"unchanged by this commit; only the design audit doc gained a line"}]

🤖 Generated with Claude Code

commented

I merged main into the branch, fixed what the merge broke, and pushed. tsc --noEmit is clean. I ran five test files and they pass: own-source, design-audit, visitor-carry, may and roles. I did not run the wider set that scripts/fast.ts named. It covers 4,188 files and would take hours, so I left it to the forge's check.

  • src/generated/marks.ts: this was the conflicted file. I took main's version and regenerated it with bun scripts/own-source.ts, so it is not hand-merged.
  • isAccountItself: main changed it to take the database as its first argument. src/web/pages/visitor_bring.ts and src/web/visitor_offer.ts now pass ctx.app.db. Before this, the visitor-carry tests failed with 500s on /visitor/bring.
  • forge.keep_work: main's may table only knew abilities from the old role list. I added forge.keep_work to ACTIONS in src/core/may.ts and to the list in docs/features/may.md.

The gate (scripts/gate.ts) flagged two possible duplicates, receiptsOf against ownedRepos and visitorRoutes against forgesRoutes. I didn't act on them. It also noted over-long comment lines in three files, which its rewrap fix did not change.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. src/generated/screens.ts was the only conflict.

I took main's version of that file and regenerated it with bun scripts/own-source.ts, so it is not hand-merged. No other files conflicted, and I made no code changes beyond the merge.

tsc --noEmit is clean. I ran five test files and they pass: own-source, design-audit, visitor-carry, may and roles. I did not run the wider set that scripts/fast.ts names, which is too large for this sandbox, so the forge's check covers that.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. The only conflict was src/generated/screens.ts, the screen roster that bun scripts/own-source.ts generates.

  • Resolution: I took main's version of the file, then regenerated it with bun scripts/own-source.ts, so it now holds the screens from both sides. No conflict markers remain.
  • What ran: bun x tsc --noEmit came back clean, and test/own-source.test.ts passes (3 tests, which is the test that fails when the roster is stale).
  • What didn't run: I did not run the full set of tests that scripts/fast.ts named for this change. It named 4,197 test files, with an estimated run of about 346 minutes, so I stopped it. The forge's check runs the full suite on this push.
  • Gate: I did not run bun scripts/gate.ts (--explain or --fix) after the merge. The merge itself changed nothing beyond the regenerated roster.
commented

Still red on current main: the app templates screen > o offers for new forges in a title and a sentence, w withdraws, a plain repo is refused. Fix it and push.

commented

This push fixes the 10 failures the check reported. I re-ran the affected test files locally and they pass (tui-can, mcp-forge-admin, palette-roster, tui-app-templates, here-pages, attention, server-timing-sweep, reserved-names, who-can, visitor-carry). bun x tsc --noEmit is clean. I did not run the full suite; the forge runs that on push.

What was wrong and what changed

  • forge.keep_work leaked to accounts. forge.keep_work had no entry in the ability table in src/core/may.ts. It fell through to the account.manage branch, so every signed-in session was told it could keep work, while the roles table said guests can't. It now holds only when there is no account behind the request, as with a visitor. This fixes the terminal "What I can do" row and the whoami_can result.
  • /visitor/bring had no timing. It never named session and render in Server-Timing, which the sweep requires of every GET page. It now does, in src/web/pages/visitor_bring.ts.
  • visitor wasn't a reserved name. /visitor is a top-level page, so I added visitor to SYSTEM_NAMES in src/core/reserved.ts so it can't be taken as a username.
  • Two test expectations were out of date. The palette roster now includes the new "Brought in from a device" entry, which is correct for this pull. The whoami_can expectation now includes keep_work: false. I did not change tui-can or here-pages; both pass as written.
  • No terminal or docs/features/ change. The commit says No door: no behaviour added; fixes the check's failures.

Not done: the gate's two "one implementation?" notes about receiptsOf and visitorRoutes are similarity hints only, so I left them alone.

Try it: bun test test/tui-can.test.ts test/palette-roster.test.ts test/reserved-names.test.ts test/server-timing-sweep.test.ts, or open /visitor/bring on the preview and read its Server-Timing header.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. Two files conflicted, src/core/may.ts and docs/features/may.md, and I kept both sides' changes in each.

  • src/core/may.ts: the action table now has both forge.write, which came from main, and forge.keep_work, which was already on this branch.
  • docs/features/may.md: the action list now names forge.write and forge.keep_work.
  • test/may.test.ts: main's test said an anonymous visitor may only forge.read. This branch also gives visitors forge.keep_work, so I changed the expected list to include it. The test was out of date, not wrong.

bun x tsc --noEmit printed nothing. bun test test/may.test.ts test/palette-roster.test.ts passed: 24 tests, 0 failures.

I did not run the wider suite. scripts/fast.ts picked 4,203 of 4,979 files, which is too broad, so the forge's own check on this push is the full run.

I started bun scripts/gate.ts --fix but it hit the 120-second timeout and is still running in the background. I didn't wait for it, so its result is unknown. git status showed no changes from it, so it has not rewrapped any comments.

commented

I merged main into the branch again and pushed it. This time only src/generated/marks.ts conflicted.

It is a generated file, so I took main's version and re-ran bun scripts/own-source.ts to rebuild it. That covers both sides' marks without a hand merge, and no conflict markers remain. bun x tsc --noEmit printed nothing. test/own-source.test.ts and test/may.test.ts passed: 12 tests, 0 failures. I didn't run the wider suite, so the forge's check on this push is the full run.

commented

I merged main into the branch again and pushed it. main had added its own visitor concept alongside the one on this branch, and the three conflicts came from the two overlapping.

  • docs/ROLES.md: I kept main's description of the visitor (the forge_maker cookie, the visitor.make action, the daily caps). I added a sentence for this branch: what a visitor keeps can be brought into an account on sign-up.
  • test/may.test.ts: an anonymous visitor now gets ["forge.read", "forge.keep_work", "visitor.make"], which is both sides' actions.
  • test/cookie-flags.test.ts: I kept both main's forge_maker entry and this branch's forge_vp entry, which src/auth/visitor_principal.ts sets. main had dropped the old src/apps/feedback.ts entries because that code no longer sets a cookie, so I dropped them too. Two cookie checks failed until I did.

bun x tsc --noEmit printed nothing. These suites passed, 61 tests and 0 failures: may, cookie-flags, own-source, the visitor* tests and palette-roster. I did not run the whole suite, so the forge's check on this push is the full run.

commented

I merged main into the branch again and pushed it. Only src/generated/marks.ts conflicted, as it did the last time.

It is a generated file, so I took main's version and rebuilt it with bun scripts/own-source.ts. No conflict markers remain. bun x tsc --noEmit printed nothing. test/own-source.test.ts, test/may.test.ts and test/cookie-flags.test.ts passed: 26 tests, 0 failures. I did not run the whole suite, so the forge's check on this push is the full run.

commented

I merged main into the branch and pushed it. The only conflict was src/generated/screens.ts.

That file is generated, so I took main's version and re-ran bun scripts/own-source.ts to rebuild it instead of merging the two sides by hand.

bun x tsc --noEmit is clean. test/own-source.test.ts and test/palette-roster.test.ts pass (18 tests). I did not run the full suite, and I did not run scripts/gate.ts or scripts/design-lint.ts on this merge. The forge will run the full check on the push.

The pull's own change is untouched.

commented

Still red on current main: apps: websockets through the proxy > a visitor's socket closes when their account is suspended; the app and others' sockets go on. Fix it and push.

the crew's run was interrupted: provider limit, resumes 15:07 UTC — every subscription this repository may use is resting (API Error: 402 This request requires more credits, or fewer max_tokens. You requested up to 128000 tokens, but can only afford 2000. To increase, visit https://)
commented

Still red on current main: apps: websockets through the proxy > a visitor's socket closes when their account is suspended; the app and others' sockets go on. Fix it and push.

commented

I fixed one of the two failing tests and pushed. The other fails on main too, so I left it alone.

  • Fixed: the check's test/apps-ws.test.ts failure ("a visitor's socket closes when their account is suspended…") came from this pull. It makes visitor a reserved username, and that test created a user named visitor, so createUser returned username_reserved. I renamed the test user to vera in test/apps-ws.test.ts. The file now passes (11 of 11). I didn't run the rest of the suite. The forge re-runs the full check on this push.
  • Left alone: test/data-browser.test.ts ("every forge.db column that could hold a secret…") fails because connection_lookup_audit.key_id is a new column not in the audited-clear list. The check log says it is red on main at 5ce50ab too, so it isn't counted against this pull. I did not touch it.
  • Gate: gate --fix printed two "one implementation?" similarity notes (receiptsOf, visitorRoutes). I made no change for them and the push went through.
commented

Closed by the crew: main moved under it 11 times and the branch could not be brought up to date. Conflicting files: src/generated/marks.ts.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs