Write Vili service state to CultCache
This commit is contained in:
parent
50c424380c
commit
8627297a6e
5 changed files with 208 additions and 6 deletions
10
README.md
10
README.md
|
|
@ -47,6 +47,16 @@ Idunn endpoint: 10.77.0.2:17870
|
|||
lowerings. They do not own daemon truth once Idunn has a fresh
|
||||
`idunn.daemon_health` record from Vili's RUDP publisher.
|
||||
|
||||
Vili also writes daemon-owned service state to:
|
||||
|
||||
```text
|
||||
E:\Projects\Vili\.vili\vili.service.cc
|
||||
```
|
||||
|
||||
That CultCache store owns the provider advertisement, operator state, Eve
|
||||
surface, command boundary, and transport profile. The adjacent JSON files are
|
||||
compatibility exports for tools that have not learned the `.cc` store yet.
|
||||
|
||||
Important routes:
|
||||
|
||||
- `GET /health`
|
||||
|
|
|
|||
|
|
@ -18,17 +18,27 @@ is a resident worker container that owns model lifetime for generation requests.
|
|||
|
||||
## Witnesses
|
||||
|
||||
- `.vili/provider-advertisement.json`: compatibility provider advertisement.
|
||||
- `.vili/operator-state.json`: daemon health and backend readiness.
|
||||
- `.vili/eve-operator-surface.json`: current operator surface.
|
||||
- `.vili/vili.service.cc`: Vili-owned CultCache store for provider
|
||||
advertisement, operator state, Eve surface, command boundary, and transport
|
||||
profile records.
|
||||
- `.vili/provider-advertisement.json`: compatibility export derived from the
|
||||
provider advertisement record.
|
||||
- `.vili/operator-state.json`: compatibility export derived from daemon health
|
||||
and backend readiness.
|
||||
- `.vili/eve-operator-surface.json`: compatibility export of the current
|
||||
operator surface.
|
||||
- `.vili/command-boundary.json`: compatibility export of Vili command
|
||||
authority.
|
||||
- `.vili/transport-profile.json`: compatibility export of Vili transport
|
||||
state.
|
||||
- `.vili/jobs/{jobId}.json`: accepted animation job records.
|
||||
- `.vili/artifacts/{jobId}/`: generated motion outputs when generation succeeds.
|
||||
- `vili-kimodo-worker`: resident Docker container exposing the loaded Kimodo
|
||||
model to Vili inside Raven's `Ubuntu-24.04` WSL runtime.
|
||||
|
||||
JSON is currently a compatibility witness because Raven's first Vili body is a
|
||||
small Node daemon. Promotion to `.cc` CultCache witnesses should happen when the
|
||||
animation job schema stabilizes.
|
||||
JSON is a compatibility witness. Vili's service/operator/command/transport
|
||||
truth is the daemon-owned `.cc` store; animation job schemas may still be
|
||||
promoted from JSON once that request/receipt shape stabilizes.
|
||||
|
||||
## Command Boundary
|
||||
|
||||
|
|
|
|||
17
package-lock.json
generated
17
package-lock.json
generated
|
|
@ -9,10 +9,23 @@
|
|||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@msgpack/msgpack": "^3.1.3",
|
||||
"cultcache-ts": "file:../CultLib/packages/cultcache-ts",
|
||||
"cultnet-ts": "file:../CultLib/packages/cultnet-ts",
|
||||
"ws": "^8.18.0"
|
||||
}
|
||||
},
|
||||
"../CultLib/packages/cultcache-ts": {
|
||||
"version": "0.13.5",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@msgpack/msgpack": "^3.1.3",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.0.0",
|
||||
"typescript": "^5.9.0"
|
||||
}
|
||||
},
|
||||
"../CultLib/packages/cultnet-ts": {
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
|
|
@ -37,6 +50,10 @@
|
|||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/cultcache-ts": {
|
||||
"resolved": "../CultLib/packages/cultcache-ts",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/cultnet-ts": {
|
||||
"resolved": "../CultLib/packages/cultnet-ts",
|
||||
"link": true
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@msgpack/msgpack": "^3.1.3",
|
||||
"cultcache-ts": "file:../CultLib/packages/cultcache-ts",
|
||||
"cultnet-ts": "file:../CultLib/packages/cultnet-ts",
|
||||
"ws": "^8.18.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,18 @@ const {
|
|||
createIdunnRudpHealthPublisher,
|
||||
publishIdunnRudpHealth,
|
||||
} = require("./idunn-rudp.cjs");
|
||||
const {
|
||||
CultCache,
|
||||
SingleFileMessagePackBackingStore,
|
||||
defineDocumentRegistry,
|
||||
defineDocumentType,
|
||||
} = require("cultcache-ts");
|
||||
const projectRoot = path.resolve(__dirname, "..");
|
||||
const ravenBaseUrl = process.env.VILI_PUBLIC_BASE_URL || "http://10.77.0.4:8824";
|
||||
const ravenDeckUrl = process.env.VILI_PUBLIC_DECK_URL || "ws://10.77.0.4:8824/eve/deck";
|
||||
const providerId = "vili.animation";
|
||||
const idunnHealthContract = "vili.cultnet-rudp-animation-health";
|
||||
const viliStoreFileName = "vili.service.cc";
|
||||
const kimodoWorkerName = process.env.VILI_KIMODO_WORKER_NAME || "vili-kimodo-worker";
|
||||
const kimodoWorkerPort = Number(process.env.VILI_KIMODO_WORKER_PORT || 8825);
|
||||
const kimodoWorkerUrl = `http://127.0.0.1:${kimodoWorkerPort}`;
|
||||
|
|
@ -32,6 +39,87 @@ const dockerHuggingFaceArgs = [
|
|||
"-e HUGGING_FACE_HUB_TOKEN",
|
||||
"-v /root/.cache/huggingface:/root/.cache/huggingface",
|
||||
].join(" ");
|
||||
const objectSchema = { parse: (value) => value };
|
||||
const providerAdvertisementDefinition = defineDocumentType({
|
||||
type: "gamecult.eve.provider_advertisement",
|
||||
schemaName: "gamecult.eve.provider_advertisement",
|
||||
schemaId: "gamecult.eve.provider_advertisement.v1",
|
||||
schemaVersion: "gamecult.eve.provider_advertisement.v1",
|
||||
name: (value) => value?.providerId || "provider",
|
||||
schema: objectSchema,
|
||||
members: [
|
||||
{ slot: 0, memberName: "providerId", typeName: "string", isName: true },
|
||||
{ slot: 1, memberName: "title", typeName: "string" },
|
||||
{ slot: 2, memberName: "verseId", typeName: "string" },
|
||||
{ slot: 3, memberName: "updatedAt", typeName: "string" },
|
||||
],
|
||||
});
|
||||
const operatorStateDefinition = defineDocumentType({
|
||||
type: "gamecult.vili.operator_state",
|
||||
schemaName: "gamecult.vili.operator_state",
|
||||
schemaId: "gamecult.vili.operator_state.v1",
|
||||
schemaVersion: "gamecult.vili.operator_state.v1",
|
||||
name: (value) => value?.service || "vili",
|
||||
schema: objectSchema,
|
||||
members: [
|
||||
{ slot: 0, memberName: "service", typeName: "string", isName: true },
|
||||
{ slot: 1, memberName: "providerId", typeName: "string" },
|
||||
{ slot: 2, memberName: "updatedAt", typeName: "string" },
|
||||
{ slot: 3, memberName: "backend", typeName: "object" },
|
||||
{ slot: 4, memberName: "idunnRudpHealth", typeName: "object" },
|
||||
],
|
||||
});
|
||||
const eveSurfaceDefinition = defineDocumentType({
|
||||
type: "gamecult.eve.surface_state",
|
||||
schemaName: "gamecult.eve.surface_state",
|
||||
schemaId: "gamecult.eve.surface_state.v1",
|
||||
schemaVersion: "gamecult.eve.surface_state.v1",
|
||||
name: (value) => value?.providerId || "surface",
|
||||
schema: objectSchema,
|
||||
members: [
|
||||
{ slot: 0, memberName: "providerId", typeName: "string", isName: true },
|
||||
{ slot: 1, memberName: "title", typeName: "string" },
|
||||
{ slot: 2, memberName: "updatedAt", typeName: "string" },
|
||||
{ slot: 3, memberName: "surface", typeName: "object" },
|
||||
],
|
||||
});
|
||||
const commandBoundaryDefinition = defineDocumentType({
|
||||
type: "gamecult.vili.command_boundary",
|
||||
schemaName: "gamecult.vili.command_boundary",
|
||||
schemaId: "gamecult.vili.command_boundary.v1",
|
||||
schemaVersion: "gamecult.vili.command_boundary.v1",
|
||||
name: (value) => value?.boundaryId || "vili",
|
||||
schema: objectSchema,
|
||||
members: [
|
||||
{ slot: 0, memberName: "boundaryId", typeName: "string", isName: true },
|
||||
{ slot: 1, memberName: "owner", typeName: "string" },
|
||||
{ slot: 2, memberName: "commandAuthority", typeName: "object" },
|
||||
{ slot: 3, memberName: "forbiddenAuthority", typeName: "string" },
|
||||
{ slot: 4, memberName: "updatedAt", typeName: "string" },
|
||||
],
|
||||
});
|
||||
const transportProfileDefinition = defineDocumentType({
|
||||
type: "gamecult.vili.transport_profile",
|
||||
schemaName: "gamecult.vili.transport_profile",
|
||||
schemaId: "gamecult.vili.transport_profile.v1",
|
||||
schemaVersion: "gamecult.vili.transport_profile.v1",
|
||||
name: (value) => value?.profileId || "vili",
|
||||
schema: objectSchema,
|
||||
members: [
|
||||
{ slot: 0, memberName: "profileId", typeName: "string", isName: true },
|
||||
{ slot: 1, memberName: "daemonId", typeName: "string" },
|
||||
{ slot: 2, memberName: "targetTransport", typeName: "string" },
|
||||
{ slot: 3, memberName: "state", typeName: "string" },
|
||||
{ slot: 4, memberName: "updatedAt", typeName: "string" },
|
||||
],
|
||||
});
|
||||
const viliDocumentRegistry = defineDocumentRegistry(
|
||||
providerAdvertisementDefinition,
|
||||
operatorStateDefinition,
|
||||
eveSurfaceDefinition,
|
||||
commandBoundaryDefinition,
|
||||
transportProfileDefinition,
|
||||
);
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = {
|
||||
|
|
@ -225,6 +313,67 @@ function operatorState() {
|
|||
};
|
||||
}
|
||||
|
||||
function commandBoundary() {
|
||||
return {
|
||||
schema: "gamecult.vili.command_boundary.v1",
|
||||
boundaryId: "vili",
|
||||
daemonId: args.idunnDaemon,
|
||||
owner: "Vili animation runtime",
|
||||
updatedAt: new Date().toISOString(),
|
||||
commandAuthority: {
|
||||
intake: {
|
||||
method: "POST",
|
||||
path: "/motion/generate",
|
||||
owns: [
|
||||
"animation job identity",
|
||||
"request persistence",
|
||||
"Kimodo resident worker lifecycle",
|
||||
"timeout handling",
|
||||
"motion artifact references",
|
||||
],
|
||||
},
|
||||
smoke: {
|
||||
method: "GET",
|
||||
path: "/smoke",
|
||||
owns: ["backend readiness proof", "resident worker warmup"],
|
||||
},
|
||||
liveness: {
|
||||
method: "GET",
|
||||
path: "/health",
|
||||
owns: ["compatibility liveness witness"],
|
||||
doesNotOwn: ["daemon truth when fresh RUDP health exists"],
|
||||
},
|
||||
},
|
||||
forbiddenAuthority:
|
||||
"HTTP health, WebSocket decks, and JSON sidecars are compatibility/operator lowerings; they do not own daemon health or provider truth when CultCache/CultNet records exist.",
|
||||
};
|
||||
}
|
||||
|
||||
function transportProfile() {
|
||||
return {
|
||||
schema: "gamecult.vili.transport_profile.v1",
|
||||
profileId: "vili",
|
||||
daemonId: args.idunnDaemon,
|
||||
targetTransport: CULTNET_RUDP_PROTOCOL_ID,
|
||||
currentTransport: idunnRudpHealthPublisher
|
||||
? "daemon-published-rudp-health + CultCache local state + compatibility HTTP/WS lowerings"
|
||||
: "CultCache local state + compatibility HTTP/WS lowerings",
|
||||
state: idunnRudpHealthPublisher ? "rudp-health-enabled" : "local-cultcache-only",
|
||||
healthContract: args.idunnHealthContract,
|
||||
providerAdvertisementSchema: "gamecult.eve.provider_advertisement.v1",
|
||||
operatorStateSchema: "gamecult.vili.operator_state.v1",
|
||||
commandBoundarySchema: "gamecult.vili.command_boundary.v1",
|
||||
compatibilityMechanisms: [
|
||||
`${ravenBaseUrl}/health`,
|
||||
`${ravenBaseUrl}/provider-advertisement`,
|
||||
`${ravenDeckUrl}/${providerId}`,
|
||||
],
|
||||
cutLine:
|
||||
"Vili owns typed provider, operator, command, transport, and RUDP health state. HTTP/WS/JSON projections are lowerings until Odin consumes Vili provider records over CultNet/RUDP.",
|
||||
updatedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
function viliHealthDetail() {
|
||||
const worker = backendStatus.kimodoWorker || "unknown";
|
||||
return `Vili animation daemon active on Raven; Kimodo worker ${worker}; HTTP/WS are compatibility lowerings.`;
|
||||
|
|
@ -301,10 +450,25 @@ function eveSurface() {
|
|||
|
||||
async function persistSurfaces() {
|
||||
await mkdir(args.stateRoot, { recursive: true });
|
||||
await persistCultCacheSurfaces();
|
||||
await writeFile(path.join(args.stateRoot, "vili-daemon.pid"), `${process.pid}\n`);
|
||||
await writeFile(path.join(args.stateRoot, "provider-advertisement.json"), JSON.stringify(providerAdvertisement(), null, 2));
|
||||
await writeFile(path.join(args.stateRoot, "operator-state.json"), JSON.stringify(operatorState(), null, 2));
|
||||
await writeFile(path.join(args.stateRoot, "eve-operator-surface.json"), JSON.stringify(eveSurface(), null, 2));
|
||||
await writeFile(path.join(args.stateRoot, "command-boundary.json"), JSON.stringify(commandBoundary(), null, 2));
|
||||
await writeFile(path.join(args.stateRoot, "transport-profile.json"), JSON.stringify(transportProfile(), null, 2));
|
||||
}
|
||||
|
||||
async function persistCultCacheSurfaces() {
|
||||
const cache = CultCache.builder()
|
||||
.withRegistry(viliDocumentRegistry)
|
||||
.withGenericStore(new SingleFileMessagePackBackingStore(path.join(args.stateRoot, viliStoreFileName)))
|
||||
.build();
|
||||
await cache.put(providerAdvertisementDefinition, providerId, providerAdvertisement());
|
||||
await cache.put(operatorStateDefinition, "vili", operatorState());
|
||||
await cache.put(eveSurfaceDefinition, providerId, eveSurface());
|
||||
await cache.put(commandBoundaryDefinition, "vili", commandBoundary());
|
||||
await cache.put(transportProfileDefinition, "vili", transportProfile());
|
||||
}
|
||||
|
||||
async function refreshBackendStatus({ includeKimodoHelp = false } = {}) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue