model-usage bed: prove the usage store end to end (ADR 0054)

A VM bed: a postgres provider and the model-usage consumer on one node, the
substrate on the other. A usage event injected into the mesh is upserted into
model-usage's provisioned store, asserted at both grains, latest-per-key, and
in the clear.

Also, in build-module-runtime.sh, add migrate/index.ts and pg.d.ts to the
compiled entrypoint set so a module may carry a run-once entry and an ambient
type declaration (model-usage uses the latter for the pg driver).

The bed surfaced and drove several fixes elsewhere: a short module slug for the
S3-key identity bound (ADR 0049), host-network containers getting the mesh's
names (mesh-control), and injecting the event from a publisher rather than the
pure-consumer store (its account has no publish right by design).

Claude-Session: https://claude.ai/code/session_01LrgweAeERJYBg88c5cKDzF
This commit is contained in:
2026-09-07 04:07:41 +02:00
parent 8313e78325
commit 9cc3c1ac2a
3 changed files with 461 additions and 3 deletions
+6 -3
View File
@@ -23,11 +23,14 @@ BASE="${RUNTIME_BASE:-node:22-bookworm-slim}"
# Compile whichever of the module's entrypoints exist. Besides the serve-time entrypoints (tools,
# events, provisioner) and the run-once bootstrap, a module may carry scheduled/one-shot entrypoints
# it names in a `schedule`/`run-once` container's args (novox/hq ADR 0052/0053) — refresh/apply/usage
# for the anthropic model-access modules. tsc pulls in their imports, so leaf files they use are
# compiled with them.
# for the anthropic model-access modules, migrate for model-usage's run-once schema step. tsc pulls
# in their imports, so leaf files they use are compiled with them. A module may also carry an ambient
# `.d.ts` typing a third-party dep it default-imports (model-usage's pg.d.ts) — listed here so the
# ambient declaration is in the program even though the dep is only installed into the image below.
SRCS=(); for f in \
client.ts index.ts tools/index.ts provisioner/index.ts bootstrap/index.ts \
adopt/index.ts refresh/index.ts apply/index.ts usage/index.ts; do
adopt/index.ts refresh/index.ts apply/index.ts usage/index.ts migrate/index.ts \
pg.d.ts; do
[ -f "$MOD/$f" ] && SRCS+=("$f")
done
TSC="$MESH_SDK/node_modules/.bin/tsc"; ( cd "$MOD" && "$TSC" "${SRCS[@]}" --module NodeNext --moduleResolution NodeNext --target ES2022 --outDir dist >/dev/null )