Skip to main content

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 read catalogue/paths.json from disk.
  • go:embed cannot reference files above the package directory, so the file cannot be embedded from cmd/.

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​

  1. The deployment runs the seed. A new binary, cmd/pathmgmt-seed (named like pathmgmt, pathmgmt-projector, pathmgmt-reports), embeds the declared catalogue at build time through a tiny root package catalogue/ (//go:embed paths.json; the Dockerfile's build stage has COPY . ., so the file is present) and replicates seed_catalogue.py's converge semantics exactly: the same decision table, the same comparisons (a Go duration compared by value so a stored 2h0m0s equals a declared 2h; the intake compared as a set; an absent eligibility equal to {}), the same PUT body (only the revisable keys the entry declares — an intake: [] is sent as [], never dropped), and a POST under a deterministic Idempotency-Key derived from the declaration. SEED_BASE_URL is mandatory (no localhost default: the error names the variable); the binary waits for GET /readyz for 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.
  2. 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 with command: ["/app/pathmgmt-seed"] and SEED_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_URL following fullnameOverride/service.port) and disabled (nothing renders).
  3. It ships dark. catalogueSeed.enabled defaults to false. The binary only exists in images built after this change; a Job that runs a binary its image lacks fails, and a failed post-install/post-upgrade hook fails the release. Enablement is therefore sequenced: first roll an image that contains cmd/pathmgmt-seed (this change merged, released and deployed with the flag still off), then a warehouse-infra values PR sets catalogueSeed.enabled: true. The flag is not flipped in this repository.
  4. The operator script is kept unchanged. scripts/seed_catalogue.py remains the manual path (a port-forward and a --dry-run preview 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/upgrade that 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 DEACTIVATED id 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 new pathId), and scripts/seed_catalogue.py --dry-run still 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 catalogue package 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 activeDeadlineSeconds beyond 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 /readyz fails 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 small resources block, and no ConfigMap: it reads only SEED_BASE_URL and LOG_LEVEL, which the template renders explicitly.