0044. The deployment converges the declared catalogue: a hook Job runs the seed, the operator script stays
Status
Accepted (2026-11-28). Operationalizes ADR 0033
(the declared catalogue catalogue/paths.json), ADR 0034
(the intake rule the seed also converges) and the REST surface of
ADR 0040. It changes no contract: the
paths, their fields, the events and the endpoints are exactly what they were. It
changes WHO applies the catalogue after a deploy.
Context
catalogue/paths.json is the reviewed record of the paths every environment
must define (ADR 0033). The migrations insert no rows, so a fresh database has
no paths at all, and a cluster rebuilt from scratch stays that way until
scripts/seed_catalogue.py is run by an operator against the running
service (warehouse-infra's README, "Post-deploy seeds", step 1). Until then,
replenishment requests are dead-lettered because no REPLENISH path exists
(ADR 0036), and every consumer of the published language sees an empty
catalogue. The step is documented, idempotent and easy to forget; a deployment
whose correctness depends on a human remembering a command is not a deployment.
The script converges the store to the declaration through the public REST API
(GET/POST/PUT /process-paths) with exact, deliberately conservative rules:
absent → POST; identical → nothing (no spurious ProcessPathUpdated);
a revisable field differs → PUT; direct/destinationLocationRole differ →
report and exit 1 (immutable: define a new pathId); DEACTIVATED → report
and exit 1 (a deactivated id is never resurrected). Going through the API is
the point, not an implementation detail: every change runs the same use case,
transactional outbox and topic an operator's call does (ADR 0003), so
wes-work-planning, fulfillment-execution, workforce-management and
order-management receive it as a CloudEvent on
warehouse.process-path-management.events, exactly as if a human had done it.
Two facts shaped the design:
- The final image contains only binaries (plus
migrations/): the Dockerfile's runtime stage copies/out/*and nothing else, so a Job running in that image cannot readcatalogue/paths.jsonfrom disk. go:embedcannot reference files above the package directory, so the file cannot be embedded fromcmd/.
This context bans calls to sibling bounded contexts (REST, MCP, gRPC, Kafka).
The seed calls this service's own REST API — the same process, use case,
outbox and topic the operator script drives — which is not a sibling edge; the
context map and TestNoSiblingContextOutboundCalls are untouched.
Decision
- The deployment runs the seed. A new binary,
cmd/pathmgmt-seed(named likepathmgmt,pathmgmt-projector,pathmgmt-reports), embeds the declared catalogue at build time through a tiny root packagecatalogue/(//go:embed paths.json; the Dockerfile's build stage hasCOPY . ., so the file is present) and replicatesseed_catalogue.py's converge semantics exactly: the same decision table, the same comparisons (a Go duration compared by value so a stored2h0m0sequals a declared2h; the intake compared as a set; an absent eligibility equal to{}), the same PUT body (only the revisable keys the entry declares — anintake: []is sent as[], never dropped), and a POST under a deterministicIdempotency-Keyderived from the declaration.SEED_BASE_URLis mandatory (no localhost default: the error names the variable); the binary waits forGET /readyzfor a bounded 120 s, converges every entry (reporting each one, never stopping at the first failure), and exits 0 only when all of them are converged. - The chart ships it as a Helm hook Job,
templates/catalogue-seed-job.yaml:helm.sh/hook: post-install,post-upgrade,hook-delete-policy: before-hook-creation,restartPolicy: Never,backoffLimit: 2, running the same image and tag as the api Deployment withcommand: ["/app/pathmgmt-seed"]andSEED_BASE_URL=http://<fullname>:<service.port>— the release's own Service, no gateway, no other context. The chart render test covers the Job both enabled (hook annotations, command, image parity,SEED_BASE_URLfollowingfullnameOverride/service.port) and disabled (nothing renders). - It ships dark.
catalogueSeed.enableddefaults tofalse. The binary only exists in images built after this change; a Job that runs a binary its image lacks fails, and a failedpost-install/post-upgradehook fails the release. Enablement is therefore sequenced: first roll an image that containscmd/pathmgmt-seed(this change merged, released and deployed with the flag still off), then a warehouse-infra values PR setscatalogueSeed.enabled: true. The flag is not flipped in this repository. - The operator script is kept unchanged.
scripts/seed_catalogue.pyremains the manual path (a port-forward and a--dry-runpreview remain the way to inspect drift by hand); the Job is the same converge logic made automatic, not a replacement of the tool.
Consequences
- A rebuilt cluster defines its catalogue with its own deployment: the
helm install/upgradethat creates the release also converges it, and the replenishment dead-letter window closes without a human in the loop. - Drift that the seed refuses becomes a failed release rather than a
line in an operator's terminal: an immutable change or a declared
DEACTIVATEDid exits 1, the hook Job fails, and Helm reports it. That is the intended visibility; the fix is the same as for the script (declare a newpathId), andscripts/seed_catalogue.py --dry-runstill explains which entry and why. - Until the image roll and the infra values PR land, nothing changes at runtime: the flag is off, the Job is not rendered, and operators keep running the script. Turning the flag on before the image exists would fail every install and upgrade of the release, which is why the sequencing is part of this decision.
- The declaration now has two readers of the same bytes — the Python script
from disk and the Go binary from the embed. The
cataloguepackage test asserts the embedded bytes equal the committed file, and both readers are exercised by their own tests against the same decision table, so the semantics cannot drift apart silently. - The hook Job has no
activeDeadlineSecondsbeyond Helm's own hook timeout; the binary bounds itself (120 s of readiness wait plus a 10 s timeout per request), which stays well inside it. A cluster whose api pod takes longer than 120 s to answer/readyzfails the seed and the release, which is a signal about that cluster, not about the seed. - The Job runs with the chart's
podSecurityContext/securityContext, its own smallresourcesblock, and no ConfigMap: it reads onlySEED_BASE_URLandLOG_LEVEL, which the template renders explicitly.