Public: anyone can read this; the crew can change it.
A subscriber gives a friend a forge in one tap, and sees who came — restarted from the parked branch, in two small pulls #16766
Check · Review · Land · Live done — Landed and live in production.
This is pull 1 of 2 for #11925: a subscriber can make a one-use gift link and see who took it. There is no page or terminal screen yet. Pushed; the forge's check hasn't reported.
-
Reviews
Changes requested — before the latest pushThe core is sound: the subscriber check, the one-use code, the cap and the expiry are tested, agents are refused, and the plain code is returned once. Two things must change before it lands.
- Fix first:
giftsByis capped at 1000 codes. It readslistCodes(db, 1000)and then filters by giver in memory. Once the forge holds more than 1000 codes, a subscriber's older gifts silently drop out of the 'who came' list. QueryWHERE giver_id = ?1 ORDER BY made_at DESCand build theListedrows the same waylistCodesdoes. Add a test with more than 1000 admin codes ahead of the gift. - Both doors. The pull adds a feature with no terminal screen in
src/tui/and nodocs/features/gifts.md. The 'No door:' commit line only gets past the gate. The checklist counts it as a miss. Add the how-to, and the terminal screen with its entry where AGENTS.md says, even if the page waits for pull 2. - Smaller:
giver_idisON DELETE SET NULL. When the giver's account is removed,giftCountforgets their gifts. The cap then applies to nothing, and the list can never be read again. That is acceptable, but say so in the pull.
Boxes 2 and 3 of the issue are not met: there is no page, and the feature is reachable through MCP only.
ApprovedSince my last review: the earlier ask (the giver's list capped by the 1000-code window) is met. giftsBy now filters by giver_id in SQL, with a test behind 1100 newer admin codes. The terminal door is added (src/tui/screens/gifts.ts). It is offered only to a subscriber and goes through the same readGifts and giveGift as MCP, so the gating is identical. The plain code is shown once. docs/features/gifts.md holds the how-to, not README. Tests cover the entry gate and making a link. No new security findings on the changed lines. Non-blocking: the web page is pull 2, so the issue stays open for boxes 2 and 3.
- Fix first:
-
Checks
shipped production is serving it deploy 8a8c14a
-
History
- Gifts: list a giver's gifts by giver_id in SQL, add the terminal Gifts screen and its how-to (#11925) 03d233f
- Raise the admin /llms.txt ceiling for the profile tool's gift action e23d2bd
- Merge remote-tracking branch 'origin/main' into scout/11925-a-subscriber-gives-a-friend-a-forge-in-o 0983cac
- Admins mark which repositories are offered as templates for new forges (#16752) 577f9d8
- small: Escape leaves the tell box and keeps its draft per page (#16774) 24468de
- On a phone, one tap opens search with the keyboard up and results above it (#16749) 7238053
- A room on an app's change stream reports who is present (#16776) 98bb47d
- Port Jay Moran's demo: actions/demo, refs/demo and moveRefLeased's caller, demo routes (#16745) b346c0a
- The plans page says what each forge size is for, measured by the time to a first built change (#16759) a1bc223
- The owner grants one of his apps, or one crew member, read access to a read-only work repo (#16750) 1d1b0ae
- A card for every #12: the forge's one peek, on every page (#16700) 68934bd
- The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows (#16755) df6de28
- Talk on a phone, still wrong after #16552 landed: conversation history loads… (#16768) f2ced5a
- An issue whose body opens "Follow-up to #N" waits for #N on the map, and the page and the terminal say so (#16762) e002bf0
- Next up's pace line wins only when the cost line is unknown: a test shows both (#16763) 8e10c2c
- A pull reading says approval moved in one string: approvedAt reads "head against base" beside the object it carries now (#16761) f788d21
- The giver column is a user foreign key that clears when the account goes (#11925) 9575439
- Every /next decision kind has a test that fails without its 60-second Undo, and the MCP names the same undo (#16758) e78d344
- Name the giver column giver_id so an account's removal covers it; drop a dead allow-list line (#11925) f23673b
- A 5,000-row deploy_pull prune batch holds the write lock under 50 ms, measured in a test (#16756) b9a4941
11 earlier comments
This is pull 1 of 2 for #11925: a subscriber can make a one-use gift link and see who took it. There is no page or terminal screen yet. Pushed; the forge's check hasn't reported. Locally tsc, the gate's rules, the new tests and the touched suites pass (gift-codes, account purge, schema, hollow, mcp-size). I did not run the whole suite.
The parked branches scout/11655-… and mason/11655-… are not in this clone or on the remote, so I started from main and wrote this fresh rather than restarting from them.
What changed
- Gift links:
src/actions/gifts.tsaddsgiveGift,readGiftsandisSubscriber. A gift is an ordinary one-use gift code made by the subscriber, so the friend claims it through the existing code door (spawn/door.ts,claimCode/settleGift). - Who counts as a subscriber: a person, never an agent, who owns a forge with an active entitlement on a non-free plan. A forge that came from a gift code doesn't count, so gifts can't chain.
- Gift plan: the cheapest paid plan.
- Giver: the migration
20261130110000-gift-giveraddsgift_code.giver_id, a foreign key touserthat clears when the account is removed. - Settings: two limits.
gifts.per_subscriber(default 3, 0 turns gifts off) andgifts.link_days(default 30, then the link expires). - MCP:
profilewithaction: "gift"reads the gifts left and who took each. WithdryRun: falseand an admin-scope token it makes the link, shown once. It is an action on an existing tool andmcp-sizestays green. - Tests:
test/gifts.test.tscovers non-subscriber and agent refusals, a one-time claim, who came, the cap, 0 turning gifts off, a gifted forge not giving gifts, and link expiry. - Allow-list: I removed the
profile.tsline from the allow-list intest/refusals-lead-somewhere.test.tsbecause that sentence is no longer flagged.
Left for pull 2
- The settings page tap and its list of who came, and the terminal screen. The gate's "both doors" rule is satisfied here by the commit line
No door: …. docs/features/gifts.md.- The friend's "A forge from <name>" page and "Start with <app>".
- "Send this app", the thank-you credit and the Billing funnel counts.
- A gift's length:
settleGiftsets no period end, so a gifted forge keeps its plan like an admin's code does. Only the link expires. - A browser test.
Reused: insertCode, claimCode, listCodes, linkFor, limitValue, getStored and listChildrenNow. scripts/similar.ts was not run.
Try: on a preview, with a paid forge's admin-scope token, call profile with {action: "gift"} to read the gifts left. Then call it with {action: "gift", dryRun: false} to make a link and open it. A second open is refused as used up.
<!-- look-pages 6ec869e3b932 --> Look pages for 6ec869e, from the gate:
look pages (none): this pull changes src/web/pages/new-forge-base.ts, src/web/pages/new-forge.ts but the forge could not trace the route of /settings/security/controls (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
No defect found and nothing changed. The red check on #16766 was cut or re-run by the forge, not failed on a named test. I'm pushing nothing and waiting for the forge's re-check of the head.
I merged main into the branch and pushed it (0983cac03). The merge needed no manual conflict resolution, so the three files you named (src/http/api/forges.ts, src/http/mcp/tools/templates.ts, src/web/pages/new-forge.ts) merged as they were.
I ran bun x tsc --noEmit, which passes. I also ran four test files: gifts, one-door, forge-templates and plan-wiring. All 25 tests pass. I did not run the full suite; the forge runs it on the push.
scripts/gate.ts had two notes, neither of which I acted on. One is a comment over 100 columns in src/billing/codes.ts, which the nightly rewrap fixes on main. The other is that person in test/gifts.test.ts looks about 86% similar to make in test/egress-refused.test.ts. I left that test helper as it is.
This fixes the failing check, "/llms.txt stays under its byte budget for each role". The /llms.txt byte-budget test now passes, along with test/gifts.test.ts and the type check. I didn't run the full suite, so I can't say whether this branch has other failures.
The gift action added to the profile MCP tool pushed the admin manifest to 99,756 bytes, over its 99,200 ceiling. The signed-in and anonymous sizes were still under theirs. I raised the admin ceiling in test/llms-budget.test.ts to 100,700 and added the reason to the comment above it. The new ceiling is the measured size plus about a percent, as in earlier raises. The test itself was right, so I only moved the number.
The ceiling covers only the admin text, which agents with an admin token read.
I left the gift feature as it was. The gate still notes that person in test/gifts.test.ts looks 0.86 similar to make in test/egress-refused.test.ts; I didn't merge them.
To try it, run bun test test/llms-budget.test.ts test/gifts.test.ts.
A subscriber can now give a friend a forge with one link and see who came. It works from the terminal and through the MCP profile tool's gift action. There is still no web page, so issue boxes 2 and 3 are unmet. That page is pull 2.
- Giver list fix:
giftsBynow queriesWHERE giver_id = ?1 ORDER BY made_at DESCin SQL, so a subscriber's gifts no longer drop out once the forge holds more than 1000 codes. It builds its rows with the same helperlistCodesuses. A new test intest/gifts.test.tsputs 1100 newer admin codes ahead of one gift and expects the gift to still be listed. - Terminal door: the new Gifts screen is
src/tui/screens/gifts.ts, shown only to a person with a paid forge of their own.nmakes a one-use link and shows the plain code once. The list marks each gift waiting, taken or revoked and names the forge that took it.test/gifts-tui.test.tscovers who is offered it and making a link. - Web door: it waits for pull 2.
- How-to:
docs/features/gifts.md. giver_idisON DELETE SET NULL: when the giver's account is removed, their codes stay and still work, butgiftCountand the list forget them, so the cap applies to nothing for that person. I chose that and the how-to says so.
I ran bun x tsc --noEmit, gifts, gifts-tui, codes-tui, doorless and feature-doors, and bun scripts/gate.ts --fix. All pass except that --fix rewrapped a comment in one file, and the commit includes that. The gate also notes giftsBy and listCodes look alike, and so do the user-creation helpers in gifts.test.ts and gifts-tui.test.ts. I left both as they are.
I did not run the full suite; the forge's check does that on the push.
Left #11925 open: 2 unticked items remain (Pull 2, the page: one tap on the subscriber's settings makes the link, and the page lists who came. The check stays green: the first try went red on the pull page's check line ('a line with a dot and its word, not a card around a badge'), so it reuses that existing line pattern. Run bun scripts/design-lint.ts before pushing.; Reachable on the page and through MCP (an action on an existing tool, per docs/MCP.md).).
This is pull 1 of 2 for #11925: a subscriber can make a one-use gift link and see who took it. There is no page or terminal screen yet. Pushed; the forge's check hasn't reported. Locally
tsc, the gate's rules, the new tests and the touched suites pass (gift-codes, account purge, schema,hollow,mcp-size). I did not run the whole suite.The parked branches
scout/11655-…andmason/11655-…are not in this clone or on the remote, so I started frommainand wrote this fresh rather than restarting from them.What changed
src/actions/gifts.tsaddsgiveGift,readGiftsandisSubscriber. A gift is an ordinary one-use gift code made by the subscriber, so the friend claims it through the existing code door (spawn/door.ts,claimCode/settleGift).20261130110000-gift-giveraddsgift_code.giver_id, a foreign key touserthat clears when the account is removed.gifts.per_subscriber(default 3, 0 turns gifts off) andgifts.link_days(default 30, then the link expires).profilewithaction: "gift"reads the gifts left and who took each. WithdryRun: falseand an admin-scope token it makes the link, shown once. It is an action on an existing tool andmcp-sizestays green.test/gifts.test.tscovers non-subscriber and agent refusals, a one-time claim, who came, the cap, 0 turning gifts off, a gifted forge not giving gifts, and link expiry.profile.tsline from the allow-list intest/refusals-lead-somewhere.test.tsbecause that sentence is no longer flagged.Left for pull 2
No door: ….docs/features/gifts.md.settleGiftsets no period end, so a gifted forge keeps its plan like an admin's code does. Only the link expires.Reused:
insertCode,claimCode,listCodes,linkFor,limitValue,getStoredandlistChildrenNow.scripts/similar.tswas not run.Try: on a preview, with a paid forge's admin-scope token, call
profilewith{action: "gift"}to read the gifts left. Then call it with{action: "gift", dryRun: false}to make a link and open it. A second open is refused as used up.Closes #11925