Written so the module system has something that proves itself rather than a claim about what it supports, and guarded by a test in the catalogue's own suite so it cannot quietly stop exercising things. Nine of the host's eleven resource kinds, all three artifact kinds including the one that compiles, all three ways a module's code can run, and all four things that code can be: tools, an event consumer, a provisioner, and processes. Two absences that are findings rather than gaps. `action` is refused to modules outright — the link may not carry a command to run (ADR 0005), so a module that needs something done ships a program that reconciles, which is what a run-once process is. `service` puts an EXISTING unit into a state and installs none, which is right for software shipping its own; code the mesh built has no unit until the mesh writes one, and that is a process. And it no longer picks its own port. ADR 0038 says a module cannot know what else is on the machine it was assigned to, and names exactly the trap this fell into: the number written three times — listens, serves, a container's ports — agreeing only because one person wrote all three, with nothing checking. So it says what it needs and the mesh assigns the number. Claude-Session: https://claude.ai/code/session_01D6qtiYU3P9jk3pnAXyAFyx
21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
// showcase's provisioner — how a consumer is given an instance of what this module provides.
|
|
//
|
|
// **A provider ships the provisioner that creates instances of the resource it offers** (ADR
|
|
// 0040). The mesh asks; this adapts that request to whatever the software actually needs, and
|
|
// hands back what the consumer is given.
|
|
import { provisioner } from "@novox/mesh-sdk/provisioner";
|
|
|
|
await provisioner({
|
|
provision: "greeting",
|
|
async create({ consumer }: { consumer: string }) {
|
|
// A real provider would create something here — a database, a vhost, an account. This one has
|
|
// nothing to create, so it returns what a consumer is told, which is the half that matters:
|
|
// the mesh seals it and delivers it, and the consumer never sees this code.
|
|
return { serves: { greeting: `hello ${consumer}` } };
|
|
},
|
|
async remove() {
|
|
// Removal is not optional. A provider that cannot take an instance back leaves the mesh unable
|
|
// to unassign a consumer without leaking whatever it was given.
|
|
},
|
|
});
|