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

Domain claims: proved names should lapse, so a re-registered domain can be reclaimed #14892

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A re-registered domain can now be claimed by its new owner without an admin, and a name whose holder's proof is still in DNS can't be taken. tsc is clean, and test/core-domains.test.ts plus app-domains and domain-dns pass (40 tests).

Notes

shipped production is serving it deploy 9504585

opened this

A re-registered domain can now be claimed by its new owner without an admin, and a name whose holder's proof is still in DNS can't be taken. tsc is clean, and test/core-domains.test.ts plus app-domains and domain-dns pass (40 tests). I didn't run the claim endpoint itself, and I did not run the full suite or bun scripts/fast.ts.

What changed. Takeover is decided by the proof, not the clock, which is your second option. A new endpoint, POST /api/v1/repos/:owner/:name/app/domains/:host/claim (admin scope), looks up _forge-verify.<host>.

  • Proof present. If the claimant's token is published and the holder's token is not, the row moves to the claimant, already verified. The old holder's row is deleted and an app.domain.claimed event is recorded.
  • Holder still live. If the holder's TXT record is still there, or the claimant's is missing, the endpoint answers 422 held with the TXT record to publish.
  • Unheld name. A name nobody holds is added as usual.
  • Resolver errors. A failed DNS lookup counts as "still held", so a flaky resolver can't hand a name over.
  • Claim token. It is derived from host and app (claimToken), so the claimant can read it before they own a row. Like every token here, it proves nothing until it is in the zone.

The decision logic is takeOverDomain in src/core/domains.ts. The DNS check is checkClaim in src/apps/domains.ts, the action is claimAppDomain in src/actions/domains.ts, and the route is in src/http/api/app.ts. The feature doc docs/features/app-own-domain.md gets a short section, and the activity feed has wording for the new event. The three new tests in test/core-domains.test.ts cover both cases from the issue and the claim token's shape.

What I left out.

  • #14821 is not in this tree. There is no UNVERIFIED_HOLD_MS or proofToken here. A name held by another app is simply taken, so the 24-hour hold the issue describes doesn't exist on this branch. Claim-by-proof works on unproved rows too, so it undercuts that hold once #14821 lands.
  • No scheduled re-check. Nothing drops a proved name back to unproved on a timer.
  • No claim button or command. The claim is reachable through the API only, not the settings page, the terminal screens or MCP.
  • No action-level test. claimAppDomain and the route aren't covered by a test, only the core logic.
  • Gate. The pre-push hook wanted a commit saying how to try the change, so I added an empty "Try:" commit.

To try it. Add a verified domain on app A. On app B, POST …/app/domains/<host>/claim with an admin token and read the publish record in the 422 answer. Publish that TXT, remove A's forge-verify TXT, and POST again. The answer is 201 and the name is now B's.

Closes #14888

2 earlier comments · 1 event
commented

A re-registered domain can now be claimed by its new owner without an admin, and a name whose holder's proof is still in DNS can't be taken. tsc is clean, and test/core-domains.test.ts plus app-domains and domain-dns pass (40 tests). I didn't run the claim endpoint itself, and I did not run the full suite or bun scripts/fast.ts.

What changed. Takeover is decided by the proof, not the clock, which is your second option. A new endpoint, POST /api/v1/repos/:owner/:name/app/domains/:host/claim (admin scope), looks up _forge-verify.<host>.

  • Proof present. If the claimant's token is published and the holder's token is not, the row moves to the claimant, already verified. The old holder's row is deleted and an app.domain.claimed event is recorded.
  • Holder still live. If the holder's TXT record is still there, or the claimant's is missing, the endpoint answers 422 held with the TXT record to publish.
  • Unheld name. A name nobody holds is added as usual.
  • Resolver errors. A failed DNS lookup counts as "still held", so a flaky resolver can't hand a name over.
  • Claim token. It is derived from host and app (claimToken), so the claimant can read it before they own a row. Like every token here, it proves nothing until it is in the zone.

The decision logic is takeOverDomain in src/core/domains.ts. The DNS check is checkClaim in src/apps/domains.ts, the action is claimAppDomain in src/actions/domains.ts, and the route is in src/http/api/app.ts. The feature doc docs/features/app-own-domain.md gets a short section, and the activity feed has wording for the new event. The three new tests in test/core-domains.test.ts cover both cases from the issue and the claim token's shape.

What I left out.

  • #14821 is not in this tree. There is no UNVERIFIED_HOLD_MS or proofToken here. A name held by another app is simply taken, so the 24-hour hold the issue describes doesn't exist on this branch. Claim-by-proof works on unproved rows too, so it undercuts that hold once #14821 lands.
  • No scheduled re-check. Nothing drops a proved name back to unproved on a timer.
  • No claim button or command. The claim is reachable through the API only, not the settings page, the terminal screens or MCP.
  • No action-level test. claimAppDomain and the route aren't covered by a test, only the core logic.
  • Gate. The pre-push hook wanted a commit saying how to try the change, so I added an empty "Try:" commit.

To try it. Add a verified domain on app A. On app B, POST …/app/domains/<host>/claim with an admin token and read the publish record in the 422 answer. Publish that TXT, remove A's forge-verify TXT, and POST again. The answer is 201 and the name is now B's.

commented

A name now moves to the app that proves it once the holder's own TXT record is gone, and the terminal can do this too. This push fixes the check failure, which was the "both doors" rule: the pull changed the API without touching src/tui/.

  • Terminal: the domains screen (n from deploys) has a new g key, "claim a name another app holds". It calls claimAppDomain, the same action as the API's POST …/domains/:host/claim. A claim that fails because the holder still stands is told with the TXT record to publish. Any other refusal uses the page's usual words.
  • Duplication: src/actions/domains.ts gains admittedServing and domainRules, so claimAppDomain shares the admin gate and name rules with the other domain actions instead of repeating them.
  • Checks: bun scripts/gate.ts exits 0 and tsc is clean. The 15 domain test files pass (114 tests). bun scripts/fast.ts named 2797 files for this diff, so I ran only the domain-related ones rather than the whole set; the forge runs the full check.
  • Left over: the gate still prints a similarity note between claimAppDomain and checkAppDomain, but it is advisory and does not fail. I left it, and I added no test for the terminal's g key.

To try it, open n from a deploys screen as the app's admin and press g. Enter a name another app holds and you get the TXT record to publish. Once the holder's record is gone, claim it again and the name moves to your app.

Changes requested — before the latest push

Changes needed, all in one round:

  1. FIRST: tests. checkClaim (src/apps/domains.ts), claimAppDomain, the POST .../app/domains/:host/claim route and the TUI g key have no test. The behaviours that matter are untested: a resolver failure returns holderPublished:true so the name stays held; a non-admin is refused; the 422 held body carries the publish record; the app.domain.claimed event is written; an unheld name falls through to add. Add action/API tests (fake resolver) and a TUI test for g, each failing without the change.
  2. Docs: docs/features/app-own-domain.md describes only the API. Add the terminal door (domains screen, g) there.
  3. Clean: src/actions/domains.ts has a stray blank line inside the ../core/domains.ts import list, and const runtime = { value: gate.value.runtime } is a shim repeated in four actions to keep old code unchanged. Destructure runtime directly. Import order in test/core-domains.test.ts and src/http/api/app.ts (core import placed between actions imports) should follow the file's pattern. The long one-line SQL/claimProofRecord lines should be wrapped as the repo's gate expects.
  4. Security hardening: takeOverDomain deletes and re-inserts the row with env hardcoded to 'production', dropping the holder's env/old_records binding silently. State that in the doc or carry it deliberately. Also claimProofRecord uses the raw host in the 422 body and TUI toast; the route should use the normalised host so the published name matches what is checked.
  5. Direction: the repo's direction is pipeline first (#6534, #6611, #5276, #3316 ...); this is a feature that none of the listed items asks for. Also scout notes #14821 (the unverified hold) is not in this tree, so this claim path undercuts it once it lands; confirm ordering with the owner or land after #14821.

I did not find an authorization bypass: the claim needs admin scope on the claimant app and the claimant's own TXT in DNS, and a lookup failure fails closed.

commented

Claiming a name by proof is now tested on every path the review named, and the review's clean-up and doc points are done. bun scripts/gate.ts, tsc, and four test files (tui-deploys, core-domains, app-domains, mcp-app-domains; 40 tests) pass here. I did not run the full suite; the forge runs that on push.

What changed

  • Behaviour: a name moves to the app whose own TXT record is published once the holder's record is gone. Otherwise the claim answers 422 with the record to publish. A resolver failure counts as "holder still there".
  • Terminal key is t, not g: g is the list's go-to-top, so the screen swallowed it before the claim saw it. The domains screen has t, "take a name another app holds", and the doc says so.
  • Error code: the 422 body's error is now name_held, because the API already gives held a pull-on-hold hint, which was misleading here. Every 422 body also carries an automatic hint.
  • Normalised host: the route and the proof record use the lowercased host, so the published name matches the one that is checked.
  • Tests:
    • checkClaim (including a resolver failure), claimAppDomain and the claim route are tested in test/app-domains.test.ts: a non-admin is refused, an unheld name falls through to add, and a name you already hold answers own_domain.
    • The app.domain.claimed event is checked there too.
    • The t key is tested in test/tui-deploys.test.ts.
  • Clean-up:
    • src/actions/domains.ts destructures runtime directly, and the stray import blank line is gone.
    • The import order matches the file's pattern, and the long SQL line is wrapped.
    • The shared gate helper makes listAppDomains use it too.
  • Doc: docs/features/app-own-domain.md now covers the terminal door.

Row after a claim: the claimed row is production's, with a fresh claim token and no old records. Those were the holder's and go with the holder's row. The doc states this.

Not done

  • Direction and #14821: these are not mine to settle. This is a feature outside the pipeline-first list, and it should land after #14821 (the unverified hold) or after the owner confirms the order. That needs a person.
  • Gate similarity note: it still prints a note that claimAppDomain resembles checkAppDomain. It is advisory and the gate exits 0.

Try it: with an admin token on the claimant app, POST /api/v1/repos/:owner/:name/app/domains/:host/claim on a held name answers 422 name_held with the TXT record to publish. Publish it, remove the holder's record, and the same call answers 201. In the terminal, n then t does the same.

Approved

Approved. I could not diff against 6a3f7fdadc51 (not in the clone), so I read the current change. Earlier asks look met: the terminal door (t, tested), the name_held code, the normalised host in the route and proof record, tests for checkClaim, the action, the route and the event, and the doc covering both doors. Security reads right: admin scope plus the action gate, a resolver failure counts as held, and the holder keeps the name while its record stands.

Non-blocking: (1) claimAppDomain awaits DNS and then takeOverDomain deletes whatever row is there; re-check that the holder is still the one you proved against. (2) The old holder gets no notice when the name moves. (3) There is no MCP tool for the claim. (4) This is outside the pipeline-first list; a person should confirm the order against #14821.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs