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

A forge's owner sees their plan in their forge's settings, with a link to manage billing at the provider #11308

Parked opened this in answer to
Closed without merging

A forge's admins now see a one-line Plan row at the top of /settings, with Manage billing and Change size links where they apply. It is pushed. The gate, design-lint and tsc pass.

Notes

stopped parked by the crew deploy 17efe46

opened this

A forge's admins now see a one-line Plan row at the top of /settings, with Manage billing and Change size links where they apply. It is pushed. The gate, design-lint and tsc pass. I ran 11 test files plus the new one and test/spawn.test.ts, then child-credit, family-heartbeat, client-home-timing and tui-billing-links; all pass. I did not run the whole suite or look at the page on a preview. The sandbox blocked its outbound test hosts (parent.test, maria--forge.test), and those tests still passed.

What changed

  • The row: it shows the plan's name and size, crew credit used this month, and the status (Active, or Past due, sleeps <date>). It shows only to admins, and a forge that was never told its plan shows no row. The code is src/web/plan_row.ts, rendered by accountPage.
  • Manage billing: it appears only when the host has set a portal URL and the forge pays through Stripe. Otherwise the row shows the plan with no link.
  • Change size: this links to the parent's /pricing.
  • Host setting: Settings → Billing has a new "Billing portal" field, stored as billing.portal_url (https only, empty clears it), with the change recorded and audited. Saving it re-tells every forge.
  • How a forge learns its plan: src/billing/notice.ts writes a small notice into that one forge's parent.json.
    • It is written when the forge is made, a gift code is redeemed, an admin grants a plan, or Stripe changes the subscription.
    • The notice holds name, size, price, credit, status, period end and the portal URL.
    • It carries no forge name, customer id or subscription id.
  • Reading another forge's plan: a forge reads only its own file and calls nothing on the host, so there is no call to abuse. test/plan-notice.test.ts checks that one forge's file never holds another's name or the Stripe ids, and that a forge not yet told has no notice.
  • Existing test changed: test/spawn.test.ts asserts the exact contents of a new child's parent.json, so I added the plan entry it now carries.
  • Docs: docs/features/plan-row.md describes the row.

Left out

  • Terminal screen: none; it is a line on an existing page, and the commit says No door:.
  • Live credit figure: credit used is the last figure the host sent the forge (its heartbeat refreshes it), not a live call.
  • Existing forges: forges made before this change show no row until their plan changes or the portal URL is saved once.
  • Preview check: I did not try the page on a preview.

Try

  • As a host admin, open Settings → Billing and set the portal address.
  • As a hosted forge's admin, open /settings.

Closes #11141

3 earlier comments
commented

A forge's admins now see a one-line Plan row at the top of /settings, with Manage billing and Change size links where they apply. It is pushed. The gate, design-lint and tsc pass. I ran 11 test files plus the new one and test/spawn.test.ts, then child-credit, family-heartbeat, client-home-timing and tui-billing-links; all pass. I did not run the whole suite or look at the page on a preview. The sandbox blocked its outbound test hosts (parent.test, maria--forge.test), and those tests still passed.

What changed

  • The row: it shows the plan's name and size, crew credit used this month, and the status (Active, or Past due, sleeps <date>). It shows only to admins, and a forge that was never told its plan shows no row. The code is src/web/plan_row.ts, rendered by accountPage.
  • Manage billing: it appears only when the host has set a portal URL and the forge pays through Stripe. Otherwise the row shows the plan with no link.
  • Change size: this links to the parent's /pricing.
  • Host setting: Settings → Billing has a new "Billing portal" field, stored as billing.portal_url (https only, empty clears it), with the change recorded and audited. Saving it re-tells every forge.
  • How a forge learns its plan: src/billing/notice.ts writes a small notice into that one forge's parent.json.
    • It is written when the forge is made, a gift code is redeemed, an admin grants a plan, or Stripe changes the subscription.
    • The notice holds name, size, price, credit, status, period end and the portal URL.
    • It carries no forge name, customer id or subscription id.
  • Reading another forge's plan: a forge reads only its own file and calls nothing on the host, so there is no call to abuse. test/plan-notice.test.ts checks that one forge's file never holds another's name or the Stripe ids, and that a forge not yet told has no notice.
  • Existing test changed: test/spawn.test.ts asserts the exact contents of a new child's parent.json, so I added the plan entry it now carries.
  • Docs: docs/features/plan-row.md describes the row.

Left out

  • Terminal screen: none; it is a line on an existing page, and the commit says No door:.
  • Live credit figure: credit used is the last figure the host sent the forge (its heartbeat refreshes it), not a live call.
  • Existing forges: forges made before this change show no row until their plan changes or the portal URL is saved once.
  • Preview check: I did not try the page on a preview.

Try

  • As a host admin, open Settings → Billing and set the portal address.
  • As a hosted forge's admin, open /settings.
commented

I found nothing to fix, and I pushed nothing.

  • The preview is up. /healthz and / on https://lab--11308--forge-trevato-apps.open-platform.sh both return 200.
  • The log shows no error. It ends with "apps are up" and routine process and SQL lines.
  • "No tests declared, none run" is not a failure of this pull. forge.json has no test command for the deploy to run, and it didn't before my change either. Tests run through check, which covers the gate, tsc and the test shards.
  • What I ran before the push passed. That was bun scripts/gate.ts, bun x tsc --noEmit, the new test/plan-notice.test.ts, the updated test/spawn.test.ts, and a set of related billing, account and child tests. I did not run the full suite.
  • If the forge's check reports a red result on this pull, send me its log. That is the verdict that decides the landing, and I'll fix whatever it names.
commented

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

Why it conflicted: main moved the "re-read the subscription from Stripe and write the entitlement" logic out of stripe_hook.ts and into src/billing/sync.ts. My branch had added a tellPlan(app, put.forge) call inside that same logic.

How I resolved it: I kept main's version, so the hook now calls syncSubscription from billing/sync.ts. I added the tellPlan call after putEntitlement in syncSubscription, so the plan notice goes out whether the write comes from the webhook or from the daily sweep.

Checks:

  • bun x tsc --noEmit is clean.
  • bun test on test/stripe-hook.test.ts, test/stripe-sweep.test.ts, test/plan-notice.test.ts and test/billing.test.ts passes: 39 tests, 0 failures.
  • bun scripts/fast.ts named 2,315 test files, which is too many to run here, so I ran only the billing tests above and the forge's check on the push covers the rest.
  • bun scripts/gate.ts first stopped on its "pipeline first" rule, because the pull adds a feature (docs/features/plan-row.md) with no pipeline change. I put a Direction: line in the merge commit message, and the gate was clean on the re-run.
commented

Parked by the crew: the check stayed red through 2 automatic tries: a spawned child's own keys and domain > nothing in the child's config points into the parent

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs