Ambitwin · source-available, not open source · © 2026 Nicolò Ghignatti
| Word | Meaning | Example |
|---|---|---|
| Organization | A customer that signed up. registry keeps its record | northfield, tier pooled |
| Domain | The space in tenancy that holds an organization’s members and buildings | domain northfield |
| Reconcile | Compare “what should exist” with “what exists”, then fix the difference | Pending northfield, no domain yet: create it, mark ready |
| Tick | One run of the reconcile loop | One every 15 seconds |
| Pending | An organization that signed up but is not built yet | registry status provisioning |
| Tier | How an organization is hosted | pooled, dedicated, on-prem |
| Identity mode | Who checks the passwords of the organization’s people | platform (Ambitwin does), byo-idp (the organization’s own provider does) |
| Join policy | Who may join a domain without being invited | invite-only, open-via-idp |
| HMAC signature | A short code made from a shared secret and the request body. Only a holder of the secret can make a matching one | X-Signature: 52a0b3… |
| Port | A Go interface the core logic talks to, so tests can swap the real thing for a fake | RegistryClient, TenancyClient |
| Context | A Go value that carries a deadline. When it runs out, every call using it stops | context.WithTimeout(ctx, 15s) |
provisioner is a small Go service in backend/provisioner. It has one job: when a new organization signs up, build the domain it needs in tenancy.
It does that by looking at a list every 15 seconds. This page walks through the whole service, file by file, with the real code.
registry, the domain lives in tenancy. provisioner only moves facts from one to the other.GET /health on port 3000, so the orchestrator can tell it is alive.pooled tier. Any other tier is marked failed.For the business side of “what is an organization and a domain”, read Identity & Tenancy first.
Picture a clerk at a desk with a tray marked “new customers”.
tenancy) and asks: “please open a space for this customer”.ready and puts it back.failed, with a note saying why.That is the whole service. registry is the tray, tenancy is the other desk, provisioner is the clerk.
flowchart LR
U["new customer<br/>signs up"] --> R[("registry<br/>the tray")]
P["provisioner<br/>the clerk"] -- "1. what is pending?" --> R
P -- "2. open a domain" --> T["tenancy<br/>the other desk"]
P -- "3. mark ready / failed" --> RThree calls per organization, always in this order: list, create, mark.
The signup request in registry could build the domain itself. It does not, on purpose.
tenancy. If tenancy is slow or down, signup would be slow or down too.tenancy only delays the build. The customer is already signed up.Example. tenancy takes 3 seconds to answer instead of 50 milliseconds. Signup in registry is as fast as ever: it never waits for tenancy. The clerk is the one that waits.
| Path | What it does |
|---|---|
cmd/provisioner/main.go | Starts everything: reads config, builds the two clients, serves /health, runs the timer |
internal/config/config.go | Reads three environment variables |
internal/reconciler/reconciler.go | The actual logic, plus the two ports it talks through |
internal/registryclient/client.go | Signed HTTP calls to registry: Pending, MarkReady, MarkFailed |
internal/tenancyclient/client.go | Signed HTTP call to tenancy: CreateDomain |
*_test.go | Tests for the reconciler and for both clients |
The rule of the house: the reconciler knows only the two ports (RegistryClient, TenancyClient). It never imports an HTTP package. In production main.go hands it the real HTTP clients. In tests, a fake that just records calls takes their place.
flowchart TD
M["main.go"] --> C["config.go"]
M --> RC["registryclient"]
M --> TC["tenancyclient"]
M --> RE["reconciler"]
RC -. "implements RegistryClient" .-> RE
TC -. "implements TenancyClient" .-> REThe dotted lines point at the ports. The clients import the reconciler (for its Organization type), never the other way round.
config.go: three variables, no defaultsThe smallest file, so it goes first. It decides how the service is told where registry and tenancy are.
type Config struct {
RegistryURL string
TenancyURL string
InternalSecret []byte
ReconcileInterval time.Duration
}Four values the rest of the service needs. The secret is []byte because the signing function wants bytes, not text.
func Load() (Config, error) {
registryURL := os.Getenv("REGISTRY_URL")
if registryURL == "" {
return Config{}, fmt.Errorf("REGISTRY_URL is required")
}
tenancyURL := os.Getenv("TENANCY_URL")
if tenancyURL == "" {
return Config{}, fmt.Errorf("TENANCY_URL is required")
}
secret := os.Getenv("INTERNAL_SIGNING_SECRET")
if secret == "" {
return Config{}, fmt.Errorf("INTERNAL_SIGNING_SECRET is required")
}Read each variable. If one is empty, stop at once with an error that names it. There is no default on purpose: a default URL or a default secret would let the service start and then fail in a confusing way later.
return Config{
RegistryURL: registryURL, TenancyURL: tenancyURL, InternalSecret: []byte(secret),
ReconcileInterval: 15 * time.Second,
}, nil
}Everything is fine, so build the result. The 15 seconds is fixed in code, not read from the environment.
Example. Start the service with REGISTRY_URL=http://registry:3000 and TENANCY_URL=http://tenancy:3000 but forget the secret. The process prints config: INTERNAL_SIGNING_SECRET is required and exits. Better to crash at start than to sign every call with an empty key.
reconciler.go: the clerk’s brainThis is the file that matters. Everything else is plumbing around it.
type Organization struct {
ID string
Name string
DisplayName string
Tier string
IdentityMode string // "platform" | "byo-idp"
}What the clerk needs to know about one pending customer. Five fields, all plain text.
ID: the key registry uses. Needed to mark the organization at the end.Name: the short, URL-friendly name (northfield). It becomes the domain name.DisplayName: the human name (Northfield Library).Tier: decides whether this service can build it at all.IdentityMode: decides the join policy.type RegistryClient interface {
Pending(ctx context.Context) ([]Organization, error)
MarkReady(ctx context.Context, id string) error
MarkFailed(ctx context.Context, id, detail string) error
}
type TenancyClient interface {
CreateDomain(ctx context.Context, name, displayName, joinPolicy string) error
}These are the ports. Each is a list of “things the reconciler is allowed to ask for”. It says nothing about HTTP. A test can write a ten-line fake that fits these shapes.
Notice CreateDomain returns only an error. The reconciler does not care about the domain that comes back, only whether it worked.
type Reconciler struct {
registry RegistryClient
tenancy TenancyClient
}
func New(registry RegistryClient, tenancy TenancyClient) *Reconciler {
return &Reconciler{registry: registry, tenancy: tenancy}
}The reconciler holds one of each port and nothing else. No state between ticks. That is why a restart loses nothing.
func (r *Reconciler) ReconcileOnce(ctx context.Context) error {
orgs, err := r.registry.Pending(ctx)
if err != nil {
return fmt.Errorf("listing pending organizations: %w", err)
}
for _, org := range orgs {
r.reconcileOne(ctx, org)
}
return nil
}Step by step:
registry for the pending list.%w wraps the original error, so the log shows the full chain.reconcileOne returns nothing. A problem with one organization never stops the others, and never fails the tick.Example. registry returns three pending organizations: northfield, unibo, acme. The loop handles them one after another. If unibo fails, acme is still tried.
func (r *Reconciler) reconcileOne(ctx context.Context, org Organization) {
if org.Tier != "pooled" {
_ = r.registry.MarkFailed(ctx, org.ID,
fmt.Sprintf("provisioner does not yet support tier %q (only pooled)", org.Tier))
return
}Guard first. Only pooled is built. Any other tier is marked failed with a readable reason, and the function stops. %q puts quotes around the tier so the message reads … tier "dedicated" (only pooled).
The _ = throws away the result of MarkFailed. See What can go wrong for what that means.
// Only an org whose identity is federated to its own IdP (BYO-IdP) gets a
// self-service-join domain.
joinPolicy := "invite-only"
if org.IdentityMode == "byo-idp" {
joinPolicy = "open-via-idp"
}Pick who may join the new domain on their own.
invite-only: someone must send an invite.byo-idp), that provider already vouches for its people. So anyone it vouches for may join: open-via-idp. if err := r.tenancy.CreateDomain(ctx, org.Name, org.DisplayName, joinPolicy); err != nil {
_ = r.registry.MarkFailed(ctx, org.ID, "tenancy provisioning failed: "+err.Error())
return
}
_ = r.registry.MarkReady(ctx, org.ID)
}The real work, in two steps:
tenancy for the domain. On any error, mark the organization failed with the error text attached, and stop.ready.The flow for one organization, as a picture:
flowchart TD
A["organization from Pending"] --> T{"tier is pooled?"}
T -- no --> F1["MarkFailed:<br/>does not yet support tier"]
T -- yes --> P{"identityMode is byo-idp?"}
P -- yes --> J1["joinPolicy = open-via-idp"]
P -- no --> J2["joinPolicy = invite-only"]
J1 --> C["CreateDomain"]
J2 --> C
C -- error --> F2["MarkFailed:<br/>tenancy provisioning failed"]
C -- ok --> R["MarkReady"]Worked example, three organizations in one tick:
| Organization | Tier | Identity mode | What happens |
|---|---|---|---|
northfield | pooled | platform | Domain created with invite-only. Marked ready |
unibo | pooled | byo-idp | Domain created with open-via-idp. Marked ready |
bigcorp | dedicated | platform | No call to tenancy. Marked failed: provisioner does not yet support tier "dedicated" (only pooled) |
registryclient/client.go: talking to registryThis client turns the three port methods into signed HTTP calls.
type Client struct {
baseURL string
secret []byte
http *http.Client
}
func New(baseURL string, secret []byte) *Client {
return &Client{baseURL: baseURL, secret: secret, http: &http.Client{Timeout: 5 * time.Second}}
}baseURL: where registry lives, like http://registry:3000.secret: the shared key used to sign every call.http: a Go HTTP client with a 5 second timeout. Go’s default client has no timeout, so a hung registry would hang the service silently, with no error and no fallback. Five seconds turns a hang into an error the loop can log.Pending: read the trayfunc (c *Client) Pending(ctx context.Context) ([]reconciler.Organization, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+"/internal/organizations/pending", nil)
if err != nil {
return nil, err
}
req.Header.Set(authcontracts.SignatureHeader, authcontracts.Sign(c.secret, nil))Build a GET request. NewRequestWithContext ties it to the tick’s deadline, so if the tick runs out of time, this call stops too. Then sign it. A GET has no body, so Sign runs over empty bytes. The result goes in the X-Signature header.
resp, err := c.http.Do(req)
if err != nil {
return nil, fmt.Errorf("registry unreachable: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("registry returned %d", resp.StatusCode)
}Send it. Network trouble becomes registry unreachable: …. Any status other than 200 becomes registry returned 403 (or whatever came back). defer resp.Body.Close() frees the connection when the function ends.
var raw []map[string]string
if err := json.NewDecoder(resp.Body).Decode(&raw); err != nil {
return nil, fmt.Errorf("decoding pending organizations: %w", err)
}
out := make([]reconciler.Organization, len(raw))
for i, r := range raw {
out[i] = reconciler.Organization{
ID: r["id"], Name: r["name"], DisplayName: r["displayName"],
Tier: r["tier"], IdentityMode: r["identityMode"],
}
}
return out, nil
}Read the JSON as a list of plain maps, then copy the five fields it cares about into Organization values. Extra fields are ignored. A missing field becomes an empty string.
Worked example. registry answers 200 with:
[
{
"id": "6f1c0a52-9b1e-4a77-8d10-3c0f2a9e7b44",
"name": "northfield",
"displayName": "Northfield Library",
"tier": "pooled",
"identityMode": "platform",
"issuer": ""
}
]The client returns one value:
Organization{
ID: "6f1c0a52-9b1e-4a77-8d10-3c0f2a9e7b44", Name: "northfield",
DisplayName: "Northfield Library", Tier: "pooled", IdentityMode: "platform",
}issuer is in the JSON but nobody here reads it. (The id above is made up for the example.)
MarkReady and MarkFailed: stamp the formfunc (c *Client) setStatus(ctx context.Context, id string, body map[string]string) error {
raw, err := json.Marshal(body)
if err != nil {
return err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost,
c.baseURL+"/internal/organizations/"+id+"/status", bytes.NewReader(raw))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set(authcontracts.SignatureHeader, authcontracts.Sign(c.secret, raw))Both stamps share this one helper. It turns the map into JSON bytes (raw), builds a POST to /internal/organizations/{id}/status, and signs those exact bytes. This detail matters: registry checks the signature against the bytes it receives. Sign one string and send another, even with the same meaning, and the check fails.
resp, err := c.http.Do(req)
if err != nil {
return fmt.Errorf("registry unreachable: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("registry returned %d", resp.StatusCode)
}
return nil
}Send it. Only 204 No Content counts as success. Anything else is an error.
func (c *Client) MarkReady(ctx context.Context, id string) error {
return c.setStatus(ctx, id, map[string]string{"status": "ready"})
}
func (c *Client) MarkFailed(ctx context.Context, id, detail string) error {
return c.setStatus(ctx, id, map[string]string{"status": "failed", "detail": detail})
}The two public methods only differ by the body they pass.
var _ reconciler.RegistryClient = (*Client)(nil)A compile-time check. If Client ever stops matching the port, the build fails here, not at runtime.
tenancyclient/client.go: talking to tenancySame setup as the registry client (base URL, secret, 5 second timeout). One method.
func (c *Client) CreateDomain(ctx context.Context, name, displayName, joinPolicy string) error {
body, err := json.Marshal(map[string]string{
"name": name, "displayName": displayName, "joinPolicy": joinPolicy,
})
if err != nil {
return err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/internal/domains", bytes.NewReader(body))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set(authcontracts.SignatureHeader, authcontracts.Sign(c.secret, body))Make the JSON body, build a POST to /internal/domains, sign the exact body bytes.
resp, err := c.http.Do(req)
if err != nil {
return fmt.Errorf("tenancy unreachable: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusConflict {
return nil
}
return fmt.Errorf("tenancy returned %d", resp.StatusCode)
}Send it and look at the answer:
201 Created: the domain was made, or it already existed. Success.409 Conflict: two creators raced on the same name. Also success. The goal was “this domain exists”, and it does.Worked example. For northfield with invite-only, the request is:
POST http://tenancy:3000/internal/domains
Content-Type: application/json
X-Signature: <64 hex characters>
{"displayName":"Northfield Library","joinPolicy":"invite-only","name":"northfield"}The keys come out in alphabetical order because Go writes map keys sorted. That does not matter to tenancy, but it does mean the signed bytes are exactly these.
tenancy does with itWorth knowing, because it explains why running a tick twice is safe. In tenancy’s service code (backend/tenancy/internal/service/tenancy.go):
func (s *Service) CreateDomain(ctx context.Context, in CreateDomainInput) (store.Domain, error) {
if existing, err := s.store.DomainByName(ctx, in.Name); err == nil {
return existing, nil
} else if !errors.Is(err, store.ErrNotFound) {
return store.Domain{}, err
}
// … otherwise insert; a unique-name clash from a race becomes ErrDomainNameTaken (409)201 for it. Nothing new is made.tenancy answers 409. This is the only case that gives 409, and the client treats it as success too.registry and tenancy know the caller is provisionerNeither of these routes has a user. There is no login. Instead, the caller proves it knows a shared secret.
The code lives in backend/libs/auth-contracts/internalsig.go:
func Sign(secret, body []byte) string {
mac := hmac.New(sha256.New, secret)
mac.Write(body)
return hex.EncodeToString(mac.Sum(nil))
}The receiving side is a middleware, RequireSignature:
signature := r.Header.Get(SignatureHeader)
if signature == "" {
http.Error(w, "missing signature", http.StatusForbidden)
return
}
body, err := io.ReadAll(r.Body)
// …
r.Body = io.NopCloser(bytes.NewReader(body))
if !Verify(secret, body, signature) {
http.Error(w, "invalid signature", http.StatusForbidden)
return
}
next.ServeHTTP(w, r)403 missing signature.403 invalid signature.Verify uses hmac.Equal, which takes the same time whatever the input. A normal == would stop at the first wrong character, and the answer time would leak how much of a guess was right.
Worked example with real numbers. The test secret in schemas/fixtures/internal-signature.json gives:
| Body | Signature |
|---|---|
empty (like the Pending call) | 52a0b3efd233aae8d54e811f3e10623f119e3978fd9411c10174b8e5307607b7 |
Change one letter of a body and its signature changes completely. That is why both sides must use the very same bytes.
One secret serves every hop: INTERNAL_SIGNING_SECRET must be identical in provisioner, registry, tenancy and claims-gateway. A mismatch shows up as 403 invalid signature in the receiver’s answer.
main.go: start, wait, repeatNow the part that wires everything together and runs the timer.
func main() {
cfg, err := config.Load()
if err != nil {
log.Fatalf("config: %v", err)
}Read config. On failure, print config: … and exit.
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()Make a context that ends when the process gets Ctrl+C (os.Interrupt) or SIGTERM (what Docker and Kubernetes send on shutdown). Everything else hangs off this context, so one signal stops the whole service.
registry := registryclient.New(cfg.RegistryURL, cfg.InternalSecret)
tenancy := tenancyclient.New(cfg.TenancyURL, cfg.InternalSecret)
rec := reconciler.New(registry, tenancy)Build the two real clients and hand them to the reconciler. This is the only place where the real HTTP clients meet the logic.
go func() {
mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) })
_ = http.ListenAndServe(":3000", mux)
}()Start a tiny web server in the background (go func()), with one route: /health answers 200 and nothing else. Docker Compose and Kubernetes poll it to see that the process is up. If the server fails to start, the error is dropped (_ =); the loop keeps running.
log.Printf("provisioner reconciling every %s", cfg.ReconcileInterval)
ticker := time.NewTicker(cfg.ReconcileInterval)
defer ticker.Stop()Log one startup line (provisioner reconciling every 15s) and start a ticker that fires every 15 seconds.
runOnce := func() {
reconcileCtx, cancel := context.WithTimeout(ctx, cfg.ReconcileInterval)
defer cancel()
if err := rec.ReconcileOnce(reconcileCtx); err != nil {
log.Printf("reconcile: %v", err)
}
}One tick, wrapped in a function. Each tick gets its own deadline of 15 seconds. If a tick hangs, it is cut off before the next one is due, so two ticks never overlap. An error from the tick is logged and nothing more. The next tick is the retry.
runOnce()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
runOnce()
}
}
}Run one tick right away, so a fresh start does not wait 15 seconds. Then loop forever: either the stop signal arrives (ctx.Done()) and the function returns, or the ticker fires and another tick runs.
The timeline:
sequenceDiagram
autonumber
participant S as Docker / k8s
participant M as main.go
participant R as reconciler
S->>M: start
M->>R: tick (at once)
loop every 15 s
M->>R: tick
R-->>M: nil, or error (logged)
end
S->>M: SIGTERM
M-->>S: loop ends, process exitsExample. registry is down at 10:00:00. The tick logs reconcile: listing pending organizations: registry unreachable: … after at most 5 seconds (the client timeout). At 10:00:15 the next tick tries again, with no help from anyone.
A note on time. The tick has 15 seconds and each HTTP call can take up to 5. An organization costs two or three calls. A tick with a big backlog and a slow tenancy can run out of time midway. The calls still in flight stop with context deadline exceeded, and what is left is picked up by the next tick. Nothing is lost, only delayed.
Everything above, put together. Example: northfield signed up as tier pooled, identity mode platform.
sequenceDiagram
autonumber
participant M as main.go<br/>runOnce
participant Rc as reconciler<br/>ReconcileOnce
participant RC as registryclient
participant Rg as registry
participant TC as tenancyclient
participant Tn as tenancy
M->>Rc: ReconcileOnce(ctx with 15 s deadline)
Rc->>RC: Pending(ctx)
RC->>RC: Sign(secret, empty body)
RC->>Rg: GET /internal/organizations/pending<br/>X-Signature
Rg-->>RC: 200 [{id, name, displayName, tier, identityMode, issuer}]
RC-->>Rc: []Organization
loop each organization
Rc->>Rc: reconcileOne(org)
Rc->>TC: CreateDomain(name, displayName, joinPolicy)
TC->>TC: json body, Sign(secret, body)
TC->>Tn: POST /internal/domains<br/>X-Signature
Tn-->>TC: 201, or 409 when the name is taken
TC-->>Rc: nil
Rc->>RC: MarkReady(id)
RC->>Rg: POST /internal/organizations/{id}/status<br/>{"status":"ready"}
Rg-->>RC: 204
endWhat the data looks like at each step:
| Step | Data |
|---|---|
| 3 | Sign over an empty body. With the test secret it gives 52a0b3efd233aae8d54e811f3e10623f119e3978fd9411c10174b8e5307607b7 |
| 5 | [{"id":"6f1c…","name":"northfield","displayName":"Northfield Library","tier":"pooled","identityMode":"platform","issuer":""}] |
| 6 | Organization{ID:"6f1c…", Name:"northfield", DisplayName:"Northfield Library", Tier:"pooled", IdentityMode:"platform"} |
| 8 | CreateDomain("northfield", "Northfield Library", "invite-only") |
| 9 | Body {"displayName":"Northfield Library","joinPolicy":"invite-only","name":"northfield"}, signed over these exact bytes |
| 11 | 201 with the domain |
| 14 | Body {"status":"ready"}, signed |
| 15 | 204. northfield leaves the pending list |
| Method and path | Body | Success is | Counted as success |
|---|---|---|---|
GET registry/internal/organizations/pending | none | 200 with a list | 200 only |
POST registry/internal/organizations/{id}/status | {"status":"ready"} or {"status":"failed","detail":"…"} | 204 | 204 only |
POST tenancy/internal/domains | {"name","displayName","joinPolicy"} | 201 | 201 or 409 |
The loop is built so that doing the same thing twice is harmless. Here is each failure, and what the next tick does about it.
| What fails | What happens now | On the next tick |
|---|---|---|
The Pending call | The tick ends and logs the error | Tries again |
CreateDomain fails (any reason) | That organization is marked failed. The others carry on | failed is not pending, so it is not tried again |
MarkReady, after the domain was made | Error dropped. Organization stays provisioning | Listed again. tenancy finds the domain and answers success. MarkReady runs again |
MarkFailed | Error dropped. Organization stays provisioning | Tried again from the first step |
Tier is not pooled | Marked failed | Not tried again |
Example of the safe case. Tick 1 creates domain northfield, then registry times out on MarkReady. Tick 2, 15 seconds later, lists northfield again. tenancy sees the domain already exists and answers success. MarkReady works this time. One domain, organization ready.
Example of the sharp edge. Tick 1 lists northfield. tenancy is mid-restart, so CreateDomain fails with tenancy unreachable. The reconciler marks northfield as failed with the note tenancy provisioning failed: tenancy unreachable: …. The next tick does not retry it: failed is a final state. A two-second blip in tenancy costs the customer their account, until someone fixes it by hand.
| Variable | Default | What it is |
|---|---|---|
REGISTRY_URL | required | Base URL of registry, like http://registry:3000 |
TENANCY_URL | required | Base URL of tenancy |
INTERNAL_SIGNING_SECRET | required | HMAC secret used by both clients |
Fixed in code: tick every 15 seconds, HTTP timeout 5 seconds per call, health port :3000.
just test provisioner| File | What it checks |
|---|---|
reconciler_test.go | A pooled organization is built and marked ready. byo-idp gets open-via-idp, platform gets invite-only. A tenancy error marks failed. Other tiers are marked failed. One failure does not stop the rest. An empty list does nothing. A registry error is returned |
registryclient/client_test.go | Requests are signed. The list is parsed. The ready and failed bodies are right. A non-200/204, an unreachable server, bad JSON and a bad URL are all errors |
tenancyclient/client_test.go | The body is signed. 201 and 409 succeed. 500 and an unreachable server fail. A bad URL fails before any call |
Here is the style of the reconciler tests. The fake registry just remembers what it was told:
func (f *fakeRegistry) MarkReady(_ context.Context, id string) error {
if f.markReadyErr != nil {
return f.markReadyErr
}
f.ready = append(f.ready, id)
return nil
}And a test reads like the story it checks:
registry := &fakeRegistry{pending: []org{{ID: "org-1", Name: "unibo", DisplayName: "UniBO", Tier: "pooled"}}}
tenancy := &fakeTenancy{}
rec := reconciler.New(registry, tenancy)
rec.ReconcileOnce(context.Background())
// tenancy.created == ["unibo"], registry.ready == ["org-1"]One pending organization goes in. One domain is asked for, one ready stamp comes out. No network, no database, runs in microseconds.
failed. Any CreateDomain error, even “tenancy was restarting”, marks the organization failed. Nothing moves it back to provisioning. Only a manual database change does.pooled. registry accepts dedicated and on-prem, and this service fails them at once.registry’s POST /organizations has no route at the edge and no caller in the repo. Organizations reach this loop only through a direct call inside the network.