## What & why S-18c, the **final** slice of the S-18 (#19) split (after S-18a #142, S-18b #143). Defines the **RegisterRecord** objecttype — the schema S-19 (#20) will write canonical register records against on approval — and registers it in the Objecttypen API at startup. Closes #141 ### What - **Schema** (`infra/objecttypen-registerrecord/registerrecord.schema.json`): public-safe by construction — `id`, `status` (enum `INGEDIEND`/`INGESCHREVEN`), `reference` only, `additionalProperties: false`, `dataClassification: open`. Mirrors the BFF's `OpenbaarEntry` — **no `bsn`/`naam`** (ADR-0027). - **Registration**: a `registerrecord-init` compose one-shot (stdlib Python on the stack network) POSTs the objecttype + a **published** version over the API once Objecttypen is healthy. The Objecttypen `setup_configuration` (3.4.2) only provisions tokens — no declarative objecttype step — so this follows the ADR-0020 self-seed pattern. **Idempotent**: if a `RegisterRecord` with a version already exists it is a no-op. - **Wiring**: schema + `register.py` streamed into the external `rr-registerrecord-config` volume by `seed-config.sh registerrecord` (main) / bind-mounted (local); added to `SEED`, `CFG_VOLS`, and the CI log-dump. `registerrecord-init` is a one-shot (not in `WAIT_SVCS`). - **Smoke**: `verify-registerrecord` (`run-registerrecord-check.sh` + `registerrecord-check.py`) asserts the objecttype exists, has a **published** version, and that version's schema carries `id`/`status`/`reference`; added as a verify-stack step + a row in the #136 summary. - **ADR-0027**: records the public-safe schema decision (mirror the BFF public view, not the internal projection; API-seeded one-shot). The slice issue #141 flagged the schema as ADR-worthy, so no separate adr-proposal issue was opened. ## Verified locally (end to end, real compose) Seeded `rr-registerrecord-config`, brought Objecttypen up, ran `registerrecord-init` → `registered RegisterRecord <uuid> v1 (published)`. `make verify-registerrecord` → **OK — RegisterRecord v1 published, fields=['id', 'reference', 'status']**. Re-running the one-shot → **no-op** (idempotent). `docker compose config` clean on both files; schema + script + ci.yaml validated. ## Definition of Done - [x] Failing smoke committed first (`test(infra): …`, "no objecttype named RegisterRecord"); implementation makes it pass. - [x] Conventional Commits referencing #141. - [x] CI green (verify-stack registerrecord step — validated locally; runner already unstarved by #145). - [x] `docker compose up` reaches health (one-shot registers after Objecttypen healthy). - [x] Docs: ADR-0027 + demo note. - [x] Closed by the merging PR (`closes #141`). This closes out the S-18 (#19) split — Objecttypen (S-18a) + Objecten (S-18b) + RegisterRecord (S-18c) are all up. Next: **S-19 (#20)** — ACL writes the register record to Objecten on approval, against this schema. 🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: #146
This commit was merged in pull request #146.
This commit is contained in:
@@ -631,6 +631,21 @@ services:
|
||||
condition: service_completed_successfully
|
||||
networks: [cg]
|
||||
|
||||
# ── RegisterRecord objecttype (S-18c) — API-seeded one-shot (local variant) ─
|
||||
registerrecord-init:
|
||||
image: docker.io/library/python:3-slim
|
||||
environment:
|
||||
OBJECTTYPEN: http://objecttypen:8000
|
||||
OBJECTTYPEN_TOKEN: ${OBJECTTYPEN_TOKEN:-0123456789abcdef0123456789abcdef01234567}
|
||||
SCHEMA: /config/registerrecord.schema.json
|
||||
command: python /config/register.py
|
||||
volumes:
|
||||
- ./objecttypen-registerrecord:/config:ro,z
|
||||
depends_on:
|
||||
objecttypen:
|
||||
condition: service_healthy
|
||||
networks: [cg]
|
||||
|
||||
# ── Objecten API (S-18b) — bind-mounted config (local variant) ─────────────
|
||||
objecten-db:
|
||||
image: docker.io/postgis/postgis:17-3.5
|
||||
|
||||
@@ -649,6 +649,25 @@ services:
|
||||
condition: service_completed_successfully
|
||||
networks: [cg]
|
||||
|
||||
# ── RegisterRecord objecttype (S-18c) — API-seeded one-shot ────────────────
|
||||
# The Objecttypen setup_configuration (3.4.2) can only provision tokens — no declarative objecttype
|
||||
# step — so this one-shot creates the RegisterRecord objecttype + a published version over the API
|
||||
# once Objecttypen is healthy (idempotent; ADR-0020 self-seed, ADR-0027 schema). The schema + script
|
||||
# are streamed into the external config volume by infra/seed-config.sh, like the *-init volumes.
|
||||
registerrecord-init:
|
||||
image: docker.io/library/python:3-slim
|
||||
environment:
|
||||
OBJECTTYPEN: http://objecttypen:8000
|
||||
OBJECTTYPEN_TOKEN: ${OBJECTTYPEN_TOKEN:-0123456789abcdef0123456789abcdef01234567}
|
||||
SCHEMA: /config/registerrecord.schema.json
|
||||
command: python /config/register.py
|
||||
volumes:
|
||||
- registerrecord-config:/config:ro
|
||||
depends_on:
|
||||
objecttypen:
|
||||
condition: service_healthy
|
||||
networks: [cg]
|
||||
|
||||
# ── Objecten API (S-18b) — upstream Maykin image, verbatim ─────────────────
|
||||
# The authoritative object store. Same shape as Objecttypen (own DB + redis, an `-init` that runs
|
||||
# setup_configuration from the external config volume, a health-checked web). Two differences: the
|
||||
@@ -791,6 +810,9 @@ volumes:
|
||||
objecttypen-config:
|
||||
external: true
|
||||
name: rr-objecttypen-config
|
||||
registerrecord-config:
|
||||
external: true
|
||||
name: rr-registerrecord-config
|
||||
objecten-config:
|
||||
external: true
|
||||
name: rr-objecten-config
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""S-18c (#141): register the RegisterRecord objecttype + a published version in the Objecttypen API.
|
||||
|
||||
Run by the `registerrecord-init` compose one-shot once Objecttypen is healthy. The Objecttypen API's
|
||||
setup_configuration (3.4.2) can only provision tokens — it has no declarative objecttype step — so
|
||||
the objecttype is created over the API here (the ADR-0020 self-seed pattern), idempotently: if a
|
||||
"RegisterRecord" objecttype with a published version already exists, it's a no-op. Stdlib only.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
BASE = os.environ.get("OBJECTTYPEN", "http://objecttypen:8000").rstrip("/")
|
||||
TOKEN = os.environ["OBJECTTYPEN_TOKEN"]
|
||||
SCHEMA_PATH = os.environ.get("SCHEMA", "/config/registerrecord.schema.json")
|
||||
NAME = "RegisterRecord"
|
||||
|
||||
|
||||
def api(method, path, body=None):
|
||||
data = json.dumps(body).encode() if body is not None else None
|
||||
req = urllib.request.Request(
|
||||
f"{BASE}{path}", data=data, method=method,
|
||||
headers={"Authorization": f"Token {TOKEN}", "Content-Type": "application/json"},
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=15) as r:
|
||||
return json.load(r) if r.length != 0 else {}
|
||||
|
||||
|
||||
def wait_ready():
|
||||
"""Objecttypen depends_on health already, but tolerate a slow first request."""
|
||||
for _ in range(20):
|
||||
try:
|
||||
api("GET", "/api/v2/objecttypes")
|
||||
return
|
||||
except (urllib.error.URLError, ConnectionError, TimeoutError):
|
||||
time.sleep(3)
|
||||
api("GET", "/api/v2/objecttypes") # last try, let it raise
|
||||
|
||||
|
||||
def main():
|
||||
schema = json.load(open(SCHEMA_PATH))
|
||||
wait_ready()
|
||||
|
||||
existing = next(
|
||||
(o for o in api("GET", "/api/v2/objecttypes").get("results", []) if o.get("name") == NAME),
|
||||
None,
|
||||
)
|
||||
if existing and existing.get("versions"):
|
||||
print(f"RegisterRecord already registered ({len(existing['versions'])} version(s)) — no-op")
|
||||
return 0
|
||||
|
||||
ot = existing or api("POST", "/api/v2/objecttypes", {
|
||||
"name": NAME,
|
||||
"namePlural": "RegisterRecords",
|
||||
"description": schema.get("description", ""),
|
||||
"dataClassification": "open", # public-safe: the openbaar register may show it
|
||||
})
|
||||
uuid = ot["uuid"]
|
||||
ver = api("POST", f"/api/v2/objecttypes/{uuid}/versions", {
|
||||
"status": "published",
|
||||
"jsonSchema": schema,
|
||||
})
|
||||
print(f"registered RegisterRecord {uuid} v{ver.get('version')} ({ver.get('status')})")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "RegisterRecord",
|
||||
"description": "Public-safe register entry shown in the openbaar (public) register. Mirrors the BFF's OpenbaarEntry (services/bff/Bff.Api/DownstreamClients.cs) — deliberately NO bsn or naam. S-19 (#20) writes records against this schema in the Objecten API on approval. See ADR-0027.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["id", "status"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "Zaak id — the register entry's stable primary key (the projection key)."
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["INGEDIEND", "INGESCHREVEN"],
|
||||
"description": "Registration lifecycle status (RegistrationStatus)."
|
||||
},
|
||||
"reference": {
|
||||
"type": ["string", "null"],
|
||||
"description": "Citizen-facing zaak identificatie shown publicly (ADR-0012)."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""S-18c (#141): prove the RegisterRecord objecttype is registered + published in the Objecttypen API.
|
||||
|
||||
Assert the objecttype named "RegisterRecord" exists, has a **published** version, and that version's
|
||||
jsonSchema carries the public-safe fields (id, status, reference) — i.e. registerrecord-init ran and
|
||||
seeded the schema S-19 will write records against. Stdlib only so it runs in a bare python:3-slim
|
||||
container on the compose network.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
BASE = os.environ["OBJECTTYPEN"] # http://<ip>:8000
|
||||
TOKEN = os.environ["OBJECTTYPEN_TOKEN"]
|
||||
TIMEOUT = int(os.environ.get("REGISTERRECORD_TIMEOUT", "60"))
|
||||
NAME = "RegisterRecord"
|
||||
EXPECTED_FIELDS = {"id", "status", "reference"}
|
||||
|
||||
|
||||
def get(path):
|
||||
req = urllib.request.Request(f"{BASE}{path}", headers={"Authorization": f"Token {TOKEN}"})
|
||||
with urllib.request.urlopen(req, timeout=10) as r:
|
||||
return json.load(r)
|
||||
|
||||
|
||||
def check():
|
||||
"""Return (ok, detail). Raises on transport errors so the caller can retry."""
|
||||
ots = get("/api/v2/objecttypes").get("results", [])
|
||||
match = next((o for o in ots if o.get("name") == NAME), None)
|
||||
if not match:
|
||||
return False, f"no objecttype named {NAME!r} (have: {[o.get('name') for o in ots]})"
|
||||
if not match.get("versions"):
|
||||
return False, f"{NAME} exists but has no versions"
|
||||
# The versions list holds URLs; fetch each to find a published one.
|
||||
for ver_url in match["versions"]:
|
||||
ver = get(ver_url[len(BASE):] if ver_url.startswith(BASE) else ver_url)
|
||||
if ver.get("status") != "published":
|
||||
continue
|
||||
props = set((ver.get("jsonSchema") or {}).get("properties", {}))
|
||||
if not EXPECTED_FIELDS <= props:
|
||||
return False, f"published version missing fields: {EXPECTED_FIELDS - props}"
|
||||
return True, f"{NAME} v{ver.get('version')} published, fields={sorted(props)}"
|
||||
return False, f"{NAME} has versions but none are published"
|
||||
|
||||
|
||||
def main():
|
||||
deadline = time.time() + TIMEOUT
|
||||
detail = "no attempt"
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
ok, detail = check()
|
||||
if ok:
|
||||
print(f"OK — {detail}")
|
||||
return 0
|
||||
except (urllib.error.URLError, ConnectionError, TimeoutError) as e:
|
||||
detail = f"transport: {e}"
|
||||
time.sleep(3)
|
||||
print(f"FAIL — {detail}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# S-18c (#141): assert the RegisterRecord objecttype is registered + published in the Objecttypen
|
||||
# API, against an ALREADY-RUNNING stack. Runs the check in a python:3-slim container on the stack
|
||||
# network (the service is reached by container IP; the runner can't reach published ports —
|
||||
# gitea-actions-gotchas.md §5/§6). Does NOT manage the stack lifecycle.
|
||||
set -euo pipefail
|
||||
|
||||
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# The dev token provisioned by infra/objecttypen/setup_configuration/data.yaml.
|
||||
TOKEN="${OBJECTTYPEN_TOKEN:-0123456789abcdef0123456789abcdef01234567}"
|
||||
|
||||
ot="$(docker ps -q --filter 'name=objecttypen' --filter 'health=healthy' | head -1)"
|
||||
[ -n "$ot" ] || ot="$(docker ps -q --filter 'name=[-_]objecttypen[-_]' | head -1)"
|
||||
[ -n "$ot" ] || { echo "ERROR: no running objecttypen container — bring the stack up first" >&2; exit 1; }
|
||||
net="$(docker inspect -f '{{range $k,$_ := .NetworkSettings.Networks}}{{$k}}{{"\n"}}{{end}}' "$ot" | head -1)"
|
||||
ip="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$ot")"
|
||||
echo ">> network=$net objecttypen=$ip"
|
||||
|
||||
cid="$(docker create --network "$net" \
|
||||
-e "OBJECTTYPEN=http://$ip:8000" -e "OBJECTTYPEN_TOKEN=$TOKEN" \
|
||||
-e "REGISTERRECORD_TIMEOUT=${REGISTERRECORD_TIMEOUT:-60}" \
|
||||
python:3-slim python /registerrecord-check.py)"
|
||||
docker cp "$here/registerrecord-check.py" "$cid:/registerrecord-check.py" >/dev/null
|
||||
rc=0; docker start -a "$cid" || rc=$?
|
||||
docker rm -f "$cid" >/dev/null
|
||||
exit $rc
|
||||
@@ -13,7 +13,7 @@
|
||||
# subcommand. Fixed-name `external` volumes keep the names deterministic across
|
||||
# both runtimes. See docs/runbooks/gitea-actions-gotchas.md.
|
||||
#
|
||||
# Usage: seed-config.sh <key> [<key> ...] where key ∈ { oz, nrc, kc, fl, objecttypen, objecten }
|
||||
# Usage: seed-config.sh <key> [<key> ...] where key ∈ { oz, nrc, kc, fl, objecttypen, objecten, registerrecord }
|
||||
set -euo pipefail
|
||||
|
||||
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -33,7 +33,7 @@ populate() { # volume source(file or dir/.)
|
||||
echo " seeded $vol"
|
||||
}
|
||||
|
||||
[ "$#" -gt 0 ] || { echo "usage: seed-config.sh <oz|nrc|kc|fl|objecttypen|objecten> ..." >&2; exit 2; }
|
||||
[ "$#" -gt 0 ] || { echo "usage: seed-config.sh <oz|nrc|kc|fl|objecttypen|objecten|registerrecord> ..." >&2; exit 2; }
|
||||
|
||||
# The registratie process (BPMN) and its diploma-eligibility DMN are deployed as SEPARATE Flowable
|
||||
# deployments — the process engine and the DMN engine each own theirs (S-13, ADR-0016). flowable-rest
|
||||
@@ -51,6 +51,7 @@ for key in "$@"; do
|
||||
kc) populate rr-kc-realms "$here/keycloak/realms/." ;;
|
||||
objecttypen) populate rr-objecttypen-config "$here/objecttypen/setup_configuration/." ;;
|
||||
objecten) populate rr-objecten-config "$here/objecten/setup_configuration/." ;;
|
||||
registerrecord) populate rr-registerrecord-config "$here/objecttypen-registerrecord/." ;;
|
||||
fl) d="$(mktemp -d)"; stage_flowable_workflows "$d"; populate rr-fl-bpmn "$d/." ;;
|
||||
*) echo "unknown seed key: $key" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user