carlos / platform Public

domains: platform link fields in the account manifest

AccountManifest gains platform, platform_ref and platform_mint, all
omitempty, so an unlinked manifest marshals byte-identical to before.
MintLinkedAccount writes the link in the create-only mint and is
idempotent on the console's mint id: the scan that already reads every
manifest returns a live match instead of minting again (Astra r1-1).
NextAccountID and MintAccount now share scanManifests and mint.
RenameAccountManifest is a CAS rename that keeps every other field.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev fa833a50b8cefda16ed263956f0b6ee507eddc50 parent c459635
2 files changed, +397 −18
  • internal/domains/mint.go +148 −18
  • internal/domains/mint_test.go +249 −0

Intent

Human

<task-notification> <task-id>a9983c8fbb178ffbc</task-id> <tool-use-id>toolu_011qZJE9ask4NNxLewwHCoUz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9284fe97-c7c7-4e03-80f2-87c51eb0406d/tasks/a9983c8fbb178ffbc.output</output-file> <status>completed</status> <summary>Agent "Implement Task 1: CLI UX pass" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS. The concerns are about wording in other tasks' sections, which this task wasn't allowed to edit. **Commit:** `c4596352 plan: platform accounts slice 1, CLI UX pass`. It changes only `docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md`: Task 1's section and the copy table. **Tests:** none, since this task has no code. I checked widths by rendering the mocks at 80 columns. Before the pass, two lines wrapped: the mint line (82 columns) and an over-the-limit usage row with a grace date (87). Now the longest line in the mocks is 73 columns, and the worst case is 76. **Changes:** - `customers show` now opens with the state ("bakery (bdg) is near a limit"). - The `customers list` heading now gives over and near counts ("3 of 50 customer accounts, 1 over a limit, 1 near a limit"). - The mint expiry and the grant reason each have their own row now. - "owned" is now "claimed", the spec's word, which slice 2's claim links will also use. - "plans" is now "customer plans" and "new accounts start on" is now "default plan", to match `--default-plan`. - New mocks: - the turned-off grant and the revoke reply - `customers list` and `customers show` on a console with no plan catalog, alongside the create and grant outputs from C17 - Every copy-table id is kept. Seven rows are new: `LabelReason`, `ListOver`, `ListNear`, `ShowOK`, `ShowNear`, `ShowOver`, `LabelValidUntil`. Thirteen rows have new text. - I moved the planning notes out of the `CreatedNoPlan` and `audit.grant_no_plans` text so they can't be shipped as copy. **Concerns:** 1. A comment on Task 6's `TestAccountsPlatformShowWithoutPlans` still names the "new accounts start on" line. The test uses the copy constants, so only the comment is out of date. 2. Task 11's tests don't name the new behaviour: the list's over and near counts, how the `show` heading is chosen, the no-catalog list and show, and the `valid until` row. They are covered only through "Human output is the Task 1 mocks." 3. I left two things for the copy review, since they aren't in the mocks. `audit.revoke` prints "1 credentials" for one credential, the plural bug I fixed in `Revoked`. And a deploy-role mint doesn't say which app the credential is for. 4. The commit printed a `packed-refs.lock` error, but it landed: the branch points at `c4596352` and the tree is clean. Full report: `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-platform-accounts/.superpowers/sdd/2026-11-19-platform-accounts-1-platform-layer/task-1-report.md`</result> <usage><subagent_tokens>119384</subagent_tokens><tool_uses>31</tool_uses><duration_ms>443863</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>beuh36azf</task-id> <tool-use-id>toolu_01LBaPs5kQuixzfqbfpMhfHT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9284fe97-c7c7-4e03-80f2-87c51eb0406d/tasks/beuh36azf.output</output-file> <status>completed</status> <summary>Background command "Wait for Task 1 review and read it" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 11.6 g CO₂e (1,446,529 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-platform-accounts, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/domains/mint.go b/internal/domains/mint.go
index c478398ec..a913f7282 100644
--- a/internal/domains/mint.go
+++ b/internal/domains/mint.go
@@ -53,6 +53,17 @@ type AccountManifest struct {
// would materialize a membership the real session can never match.
Owner string `json:"owner,omitempty"`
+ // Platform is the sqid of the platform account that created this customer
+ // account; PlatformRef is the platform's own reference for the customer;
+ // PlatformMint is the console's pending-mint id (32 lowercase hex) the
+ // account was minted under, which is what makes MintLinkedAccount
+ // idempotent. All three are written once, in the create-only mint, and
+ // are ADDITIVE and omitempty: an unlinked manifest marshals byte for byte
+ // as it did before they existed, and an old body parses with no link.
+ Platform string `json:"platform,omitempty"`
+ PlatformRef string `json:"platform_ref,omitempty"`
+ PlatformMint string `json:"platform_mint,omitempty"`
+
// DeletedAt marks a retired account. The manifest is TOMBSTONED rather than
// removed, and the difference is the whole point: deleting the object would
// free the id for reuse (NextAccountID takes one past the highest id any
@@ -139,9 +150,32 @@ const mintAttempts = 5
// answer, a restart changes nothing, and once a later id is minted the
// skipped one sits below the highest claim, where nothing allocates.
func NextAccountID(ctx context.Context, s release.Store) (int64, error) {
+ manifests, err := scanManifests(ctx, s)
+ if err != nil {
+ return 0, err
+ }
+ return nextID(manifests), nil
+}
+
+// nextID is NextAccountID's answer over an already-scanned bucket.
+func nextID(manifests []AccountManifest) int64 {
+ max := int64(ReservedAccountID)
+ for _, m := range manifests {
+ if m.ID > max {
+ max = m.ID
+ }
+ }
+ return skipReservedIDs(max + 1)
+}
+
+// scanManifests reads every account manifest body in the bucket, tombstones
+// included. An unparseable body is left out (it claims no id we can honour);
+// an unreadable one fails the scan, because an id we cannot see is an id we
+// must not reuse.
+func scanManifests(ctx context.Context, s release.Store) ([]AccountManifest, error) {
keys, err := s.List(ctx, "accounts/")
if err != nil {
- return 0, fmt.Errorf("domains: list accounts: %w", err)
+ return nil, fmt.Errorf("domains: list accounts: %w", err)
}
var manifests []string
for _, key := range keys {
@@ -154,7 +188,7 @@ func NextAccountID(ctx context.Context, s release.Store) (int64, error) {
// another they took about 25 ms each, so a deployment with a hundred
// accounts made every new person's first sign-in wait nearly three
// seconds (2026-11-07).
- ids := make([]int64, len(manifests))
+ bodies := make([]*AccountManifest, len(manifests))
errs := make([]error, len(manifests))
sem := make(chan struct{}, nextIDReaders)
var wg sync.WaitGroup
@@ -176,23 +210,23 @@ func NextAccountID(ctx context.Context, s release.Store) (int64, error) {
if err := json.Unmarshal(body, &m); err != nil {
return // unparseable: claims no id we can honour
}
- ids[i] = m.ID
+ bodies[i] = &m
}()
}
wg.Wait()
- max := int64(ReservedAccountID)
+ out := make([]AccountManifest, 0, len(manifests))
for i := range manifests {
if errs[i] != nil {
- return 0, errs[i]
+ return nil, errs[i]
}
- if ids[i] > max {
- max = ids[i]
+ if bodies[i] != nil {
+ out = append(out, *bodies[i])
}
}
- return skipReservedIDs(max + 1), nil
+ return out, nil
}
-// nextIDReaders is how many account manifests NextAccountID reads at once.
+// nextIDReaders is how many account manifests scanManifests reads at once.
const nextIDReaders = 16
// MintAccount allocates the next free account id and publishes its manifest,
@@ -221,33 +255,129 @@ func MintAccount(ctx context.Context, s release.Store, name, owner string, creat
if owner != "" && !ValidAddress(owner) {
return 0, "", fmt.Errorf("domains: %q is not a keymail address — expected <user>@<host>, e.g. paul@keymail.dev", owner)
}
+ id, sqid, _, err := mint(ctx, s, AccountManifest{Name: name, Owner: owner}, created, nil)
+ return id, sqid, err
+}
+
+// ErrBadPlatformLink refuses a link MintLinkedAccount could never honour: a
+// platform that is not an account sqid, the ops account as a platform, or a
+// mint id that is not 32 lowercase hex.
+var ErrBadPlatformLink = errors.New("domains: bad platform link")
+
+// MintLinkedAccount mints a customer account linked to the platform account
+// platformSqid: MintAccount's create-only write, with no owner and the link
+// (Platform, PlatformRef, PlatformMint) in the same object, so the account
+// never exists without it.
+//
+// It is IDEMPOTENT on mintID. The scan that picks the next id already reads
+// every manifest body, and if a live one carries this platform and this mint
+// id it is returned with existing == true and nothing is written. A retry
+// after a failed or ambiguous Put, or after a failure further on in the
+// caller, therefore finds the account its first attempt made instead of
+// minting a second. A tombstoned manifest is not a match: that account is
+// gone, and the caller is asking for a live one.
+//
+// The link is checked before the first listing, so a refused mint writes
+// nothing. The ref is the console's to validate, not this function's.
+func MintLinkedAccount(ctx context.Context, s release.Store, name, platformSqid, ref, mintID string, created time.Time) (id int64, sqid string, existing bool, err error) {
+ if !ValidSqid(platformSqid) || platformSqid == Sqid(ReservedAccountID) || !validMintID(mintID) {
+ return 0, "", false, fmt.Errorf("%w: platform %q, mint id %q", ErrBadPlatformLink, platformSqid, mintID)
+ }
+ template := AccountManifest{Name: name, Platform: platformSqid, PlatformRef: ref, PlatformMint: mintID}
+ return mint(ctx, s, template, created, func(m AccountManifest) bool {
+ return !m.Deleted() && m.Platform == platformSqid && m.PlatformMint == mintID
+ })
+}
+
+// validMintID reports whether id is 32 lowercase hex digits, the shape the
+// console's pending-mint ids take (16 random bytes, hex encoded).
+func validMintID(id string) bool {
+ if len(id) != 32 {
+ return false
+ }
+ for i := 0; i < len(id); i++ {
+ c := id[i]
+ if (c < '0' || c > '9') && (c < 'a' || c > 'f') {
+ return false
+ }
+ }
+ return true
+}
+
+// mint is the create-only allocation loop MintAccount and MintLinkedAccount
+// share. Each attempt scans the bucket once; a manifest match accepts is
+// returned as it stands with existing == true, otherwise template is written
+// create-only at the next free id with its ID, Sqid and CreatedAt filled in.
+// A nil match never matches.
+func mint(ctx context.Context, s release.Store, template AccountManifest, created time.Time, match func(AccountManifest) bool) (int64, string, bool, error) {
for attempt := 0; attempt < mintAttempts; attempt++ {
- id, err := NextAccountID(ctx, s)
+ manifests, err := scanManifests(ctx, s)
if err != nil {
- return 0, "", err
+ return 0, "", false, err
}
+ if match != nil {
+ for _, m := range manifests {
+ if match(m) {
+ return m.ID, m.Sqid, true, nil
+ }
+ }
+ }
+ id := nextID(manifests)
sqid := Sqid(id)
- body, err := json.Marshal(AccountManifest{
- ID: id, Sqid: sqid, Name: name, CreatedAt: created.UTC(), Owner: owner,
- })
+ m := template
+ m.ID, m.Sqid, m.CreatedAt = id, sqid, created.UTC()
+ body, err := json.Marshal(m)
if err != nil {
- return 0, "", err
+ return 0, "", false, err
}
_, err = s.Put(ctx, AccountManifestKey(sqid), body, "")
if err == nil {
- return id, sqid, nil
+ return id, sqid, false, nil
}
if !errors.Is(err, release.ErrCASConflict) {
- return 0, "", fmt.Errorf("domains: write account manifest: %w", err)
+ return 0, "", false, fmt.Errorf("domains: write account manifest: %w", err)
}
// Somebody else took this id between our listing and our write. Re-list
// and try the next one.
}
- return 0, "", fmt.Errorf("domains: could not mint an account id in %d attempts — "+
+ return 0, "", false, fmt.Errorf("domains: could not mint an account id in %d attempts — "+
"another minter keeps taking the next free id, or the deployment bucket is rejecting "+
"create-only writes", mintAttempts)
}
+// RenameAccountManifest sets the name in an account's manifest and keeps
+// every other field. CAS overwrite with one retry, the same shape as
+// TombstoneAccount. A missing manifest is an error wrapping os.ErrNotExist.
+func RenameAccountManifest(ctx context.Context, s release.Store, sqid, name string) error {
+ key := AccountManifestKey(sqid)
+ rename := func() error {
+ body, etag, err := s.Get(ctx, key)
+ if err != nil {
+ return fmt.Errorf("domains: read %s: %w", key, err)
+ }
+ var m AccountManifest
+ if err := json.Unmarshal(body, &m); err != nil {
+ return fmt.Errorf("domains: parse %s: %w", key, err)
+ }
+ if m.Name == name {
+ return nil // nothing to change, so nothing to write
+ }
+ m.Name = name
+ out, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+ _, err = s.Put(ctx, key, out, etag)
+ return err
+ }
+ if err := rename(); errors.Is(err, release.ErrCASConflict) {
+ return rename() // one retry on a lost race; a second loss surfaces
+ } else if err != nil {
+ return err
+ }
+ return nil
+}
+
// TombstoneAccount retires an account in the bucket — the control plane, and
// therefore the only place a deletion is real.
//
diff --git a/internal/domains/mint_test.go b/internal/domains/mint_test.go
index ba9781089..44368c879 100644
--- a/internal/domains/mint_test.go
+++ b/internal/domains/mint_test.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
+ "os"
"strings"
"testing"
"time"
@@ -283,3 +284,251 @@ func TestNextAccountIDReadsEveryManifest(t *testing.T) {
t.Fatalf("NextAccountID with an unreadable manifest = %d, want an error", got)
}
}
+
+// The platform link tests below share a bucket shape: the ops account (id 1)
+// and a platform account "bcd" (id 49) already have manifests, so the next
+// mint is id 50.
+const (
+ mintA = "0123456789abcdef0123456789abcdef"
+ mintB = "fedcba9876543210fedcba9876543210"
+)
+
+func linkBucket(t *testing.T) *release.DirStore {
+ t.Helper()
+ if domains.Sqid(49) != "bcd" {
+ t.Fatalf("Sqid(49) = %q, the fixture expects bcd", domains.Sqid(49))
+ }
+ s := release.NewDirStore(t.TempDir())
+ writeManifest(t, s, domains.ReservedAccountID, domains.Sqid(domains.ReservedAccountID))
+ writeManifest(t, s, 49, "bcd")
+ return s
+}
+
+func readManifest(t *testing.T, s release.Store, sqid string) domains.AccountManifest {
+ t.Helper()
+ body, _, err := s.Get(context.Background(), domains.AccountManifestKey(sqid))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var m domains.AccountManifest
+ if err := json.Unmarshal(body, &m); err != nil {
+ t.Fatal(err)
+ }
+ return m
+}
+
+func listAccounts(t *testing.T, s release.Store) []string {
+ t.Helper()
+ keys, err := s.List(context.Background(), "accounts/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return keys
+}
+
+// The link lands in the same create-only write that allocates the id, so
+// there is never a moment when the customer account exists without it.
+func TestMintLinkedAccountWritesTheLinkInTheCreateOnlyWrite(t *testing.T) {
+ ctx := t.Context()
+ s := linkBucket(t)
+ now := time.Unix(1700000000, 0)
+ id, sqid, existing, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if existing {
+ t.Error("a first mint reported existing")
+ }
+ if id != 50 || sqid != domains.Sqid(50) {
+ t.Errorf("minted (%d, %q), want (50, %q)", id, sqid, domains.Sqid(50))
+ }
+ m := readManifest(t, s, sqid)
+ if m.Platform != "bcd" || m.PlatformRef != "4812" || m.PlatformMint != mintA ||
+ m.Owner != "" || m.ID != id || m.Sqid != sqid || m.Name != "shop" ||
+ !m.CreatedAt.Equal(now) {
+ t.Errorf("manifest = %+v", m)
+ }
+}
+
+// A retry with the same mint id finds the account the first attempt made
+// instead of minting a second one (Astra r1-1).
+func TestMintLinkedAccountIsIdempotentOnItsMintID(t *testing.T) {
+ ctx := t.Context()
+ s := linkBucket(t)
+ now := time.Unix(1700000000, 0)
+ id, sqid, _, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ before := listAccounts(t, s)
+
+ id2, sqid2, existing, err := domains.MintLinkedAccount(ctx, s, "other-name", "bcd", "4812", mintA, now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !existing || id2 != id || sqid2 != sqid {
+ t.Errorf("retry = (%d, %q, existing %v), want (%d, %q, true)", id2, sqid2, existing, id, sqid)
+ }
+ if after := listAccounts(t, s); strings.Join(after, ",") != strings.Join(before, ",") {
+ t.Errorf("retry wrote to the bucket: %v -> %v", before, after)
+ }
+ if m := readManifest(t, s, sqid); m.Name != "shop" {
+ t.Errorf("retry changed the name to %q", m.Name)
+ }
+
+ id3, _, existing, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4813", mintB, now)
+ if err != nil || existing || id3 != id+1 {
+ t.Errorf("different mint id = (%d, existing %v, %v), want (%d, false, nil)", id3, existing, err, id+1)
+ }
+
+ // A retired account is not the one a retry is looking for.
+ if err := domains.TombstoneAccount(ctx, s, sqid, now); err != nil {
+ t.Fatal(err)
+ }
+ id4, _, existing, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, now)
+ if err != nil || existing || id4 != id3+1 {
+ t.Errorf("after tombstone = (%d, existing %v, %v), want (%d, false, nil)", id4, existing, err, id3+1)
+ }
+}
+
+// ambiguousPutStore lands the first Put and then reports it failed: the
+// write a caller cannot tell from one that never happened.
+type ambiguousPutStore struct {
+ release.Store
+ failed bool
+}
+
+func (a *ambiguousPutStore) Put(ctx context.Context, key string, body []byte, ifMatch string) (string, error) {
+ etag, err := a.Store.Put(ctx, key, body, ifMatch)
+ if err == nil && !a.failed {
+ a.failed = true
+ return "", errors.New("synthetic: connection reset after the write")
+ }
+ return etag, err
+}
+
+func TestMintLinkedAccountRetryAfterAFailedPut(t *testing.T) {
+ ctx := t.Context()
+ inner := linkBucket(t)
+ s := &ambiguousPutStore{Store: inner}
+ now := time.Unix(1700000000, 0)
+ if _, _, _, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, now); err == nil {
+ t.Fatal("first mint succeeded through a failing Put")
+ }
+ id, sqid, existing, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !existing || id != 50 || sqid != domains.Sqid(50) {
+ t.Errorf("retry = (%d, %q, existing %v), want (50, %q, true)", id, sqid, existing, domains.Sqid(50))
+ }
+ carrying := 0
+ for _, key := range listAccounts(t, inner) {
+ sq, ok := domains.AccountManifestSqid(key)
+ if !ok {
+ continue
+ }
+ if readManifest(t, inner, sq).PlatformMint == mintA {
+ carrying++
+ }
+ }
+ if carrying != 1 {
+ t.Errorf("%d manifests carry the mint id, want exactly 1", carrying)
+ }
+}
+
+// A link the console could never honour is refused before anything is
+// listed or written: a refused mint burns no id.
+func TestMintLinkedAccountRefusesABadLink(t *testing.T) {
+ ctx := t.Context()
+ cases := []struct{ platform, mint string }{
+ {"", mintA},
+ {"not a sqid!", mintA},
+ {domains.Sqid(domains.ReservedAccountID), mintA},
+ {"bcd", ""},
+ {"bcd", "0123456789abcdef"},
+ {"bcd", mintA + "00"},
+ {"bcd", "0123456789ABCDEF0123456789ABCDEF"},
+ {"bcd", "0123456789abcdef0123456789abcdeg"},
+ }
+ for _, c := range cases {
+ s := linkBucket(t)
+ before := listAccounts(t, s)
+ _, _, _, err := domains.MintLinkedAccount(ctx, s, "shop", c.platform, "4812", c.mint, time.Now())
+ if !errors.Is(err, domains.ErrBadPlatformLink) {
+ t.Errorf("platform %q mint %q: err = %v, want ErrBadPlatformLink", c.platform, c.mint, err)
+ }
+ if after := listAccounts(t, s); strings.Join(after, ",") != strings.Join(before, ",") {
+ t.Errorf("platform %q mint %q wrote: %v -> %v", c.platform, c.mint, before, after)
+ }
+ }
+}
+
+// Wire shapes are additive: an unlinked manifest marshals exactly as it did
+// before the link existed, and an old body parses with an empty link.
+func TestUnlinkedManifestIsByteIdentical(t *testing.T) {
+ t0 := time.Date(2026, 8, 2, 9, 0, 0, 0, time.UTC)
+ body, err := json.Marshal(domains.AccountManifest{ID: 2, Sqid: "bab", Name: "a", CreatedAt: t0})
+ if err != nil {
+ t.Fatal(err)
+ }
+ const want = `{"id":2,"sqid":"bab","name":"a","created_at":"2026-08-02T09:00:00Z","deleted_at":"0001-01-01T00:00:00Z"}`
+ if string(body) != want {
+ t.Errorf("unlinked manifest = %s, want %s", body, want)
+ }
+ for _, key := range []string{`"platform"`, `"platform_ref"`, `"platform_mint"`} {
+ if strings.Contains(string(body), key) {
+ t.Errorf("unlinked manifest carries %s: %s", key, body)
+ }
+ }
+ var m domains.AccountManifest
+ if err := json.Unmarshal([]byte(`{"id":2,"sqid":"bab","name":"a","created_at":"2026-08-02T09:00:00Z"}`), &m); err != nil {
+ t.Fatal(err)
+ }
+ if m.Platform != "" || m.PlatformRef != "" || m.PlatformMint != "" {
+ t.Errorf("old body parsed with a link: %+v", m)
+ }
+}
+
+func TestRenameAccountManifestKeepsEveryField(t *testing.T) {
+ ctx := t.Context()
+ s := linkBucket(t)
+ _, sqid, _, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, time.Unix(1700000000, 0))
+ if err != nil {
+ t.Fatal(err)
+ }
+ before := readManifest(t, s, sqid)
+ if err := domains.RenameAccountManifest(ctx, s, sqid, "shop-2"); err != nil {
+ t.Fatal(err)
+ }
+ after := readManifest(t, s, sqid)
+ if after.Name != "shop-2" {
+ t.Errorf("name = %q, want shop-2", after.Name)
+ }
+ after.Name = before.Name
+ if after != before {
+ t.Errorf("rename changed more than the name:\n before %+v\n after %+v", before, after)
+ }
+
+ err = domains.RenameAccountManifest(ctx, s, domains.Sqid(4000), "x")
+ if !errors.Is(err, os.ErrNotExist) {
+ t.Errorf("renaming a missing manifest: err = %v, want one wrapping os.ErrNotExist", err)
+ }
+}
+
+// A retired customer account still says which platform made it.
+func TestTombstoneKeepsThePlatformLink(t *testing.T) {
+ ctx := t.Context()
+ s := linkBucket(t)
+ _, sqid, _, err := domains.MintLinkedAccount(ctx, s, "shop", "bcd", "4812", mintA, time.Unix(1700000000, 0))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := domains.TombstoneAccount(ctx, s, sqid, time.Unix(1700000100, 0)); err != nil {
+ t.Fatal(err)
+ }
+ m := readManifest(t, s, sqid)
+ if !m.Deleted() || m.Owner != "" || m.Platform != "bcd" || m.PlatformRef != "4812" || m.PlatformMint != mintA {
+ t.Errorf("tombstone = %+v", m)
+ }
+}