From 6fde91fe0a2e9f312b7471d8963cad7421059359 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 10 Oct 2026 05:47:00 +0200 Subject: [PATCH] Persona: compile fixes and the regenerated wire schemas The jsonschema error kind lives in jsonschema::error; the eureka-state tool closures own their input; huginn.mind_request/response.v1 carry the persona operations (derived by the existing published_wire_schemas test). Co-Authored-By: Claude Opus 5.5 --- crates/eureka-state/src/main.rs | 6 +- crates/huginn-mind/src/persona.rs | 3 +- .../huginn.mind_request.v1.schema.json | 54 ++++++ .../huginn.mind_response.v1.schema.json | 165 ++++++++++++++++++ 4 files changed, 224 insertions(+), 4 deletions(-) diff --git a/crates/eureka-state/src/main.rs b/crates/eureka-state/src/main.rs index 2138fa5..dcf65c6 100644 --- a/crates/eureka-state/src/main.rs +++ b/crates/eureka-state/src/main.rs @@ -260,7 +260,7 @@ impl EurekaState { description = "Admit one batch of pipeline documents into the mind, whole or not at all. Returns the outcome: committed with a receipt, already admitted, conflict, or a typed refusal. The instance is this server's configuration; do not pass one." )] async fn admit(&self, Parameters(input): Parameters) -> CallToolResult { - self.answer(|instance| { + self.answer(move |instance| { HuginnMindRequest::Admit(PipelineAdmissionBatch { instance, provenance: PipelineProvenance { @@ -277,14 +277,14 @@ impl EurekaState { #[tool(description = "Read one document by id, with its admission facts and status. null when the mind has no such document.")] async fn view(&self, Parameters(input): Parameters) -> CallToolResult { - self.answer(|instance| HuginnMindRequest::View { instance, id: input.id }).await + self.answer(move |instance| HuginnMindRequest::View { instance, id: input.id }).await } #[tool( description = "Query the mind with a CultNet typed selection, optionally ranked by semantic nearness. Returns one page; pass its cursor back in the selection for the next." )] async fn query(&self, Parameters(input): Parameters) -> CallToolResult { - self.answer(|instance| HuginnMindRequest::Query { + self.answer(move |instance| HuginnMindRequest::Query { instance, selection: input.selection, semantic: input.semantic, diff --git a/crates/huginn-mind/src/persona.rs b/crates/huginn-mind/src/persona.rs index 37639aa..f77a4a0 100644 --- a/crates/huginn-mind/src/persona.rs +++ b/crates/huginn-mind/src/persona.rs @@ -13,7 +13,8 @@ use std::sync::OnceLock; use cultcache_rs::{CultCacheEnvelope, DatabaseEntry}; use jsonschema::paths::LocationSegment; -use jsonschema::{ValidationErrorKind, Validator}; +use jsonschema::error::ValidationErrorKind; +use jsonschema::Validator; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/schemas/cultnet/huginn.mind_request.v1.schema.json b/schemas/cultnet/huginn.mind_request.v1.schema.json index 909a8a8..c075586 100644 --- a/schemas/cultnet/huginn.mind_request.v1.schema.json +++ b/schemas/cultnet/huginn.mind_request.v1.schema.json @@ -78,6 +78,60 @@ "required": [ "Query" ] + }, + { + "description": "The mind's persona document, if one is stored.", + "type": "object", + "properties": { + "PersonaGet": { + "type": "object", + "properties": { + "instance": { + "$ref": "#/$defs/Slug" + } + }, + "required": [ + "instance" + ] + } + }, + "additionalProperties": false, + "required": [ + "PersonaGet" + ] + }, + { + "description": "Replaces the mind's persona document whole. `expected_updated_at` is\nthe stored document's `updatedAt`, none for the first put. The\nprovenance is the asker's, as for `Admit`.", + "type": "object", + "properties": { + "PersonaPut": { + "type": "object", + "properties": { + "expected_updated_at": { + "type": [ + "string", + "null" + ] + }, + "instance": { + "$ref": "#/$defs/Slug" + }, + "provenance": { + "$ref": "#/$defs/PipelineProvenance" + }, + "state": true + }, + "required": [ + "instance", + "provenance", + "state" + ] + } + }, + "additionalProperties": false, + "required": [ + "PersonaPut" + ] } ], "$defs": { diff --git a/schemas/cultnet/huginn.mind_response.v1.schema.json b/schemas/cultnet/huginn.mind_response.v1.schema.json index 426cf7a..7e1eeda 100644 --- a/schemas/cultnet/huginn.mind_response.v1.schema.json +++ b/schemas/cultnet/huginn.mind_response.v1.schema.json @@ -70,6 +70,37 @@ "Refused" ] }, + { + "type": "object", + "properties": { + "Persona": { + "anyOf": [ + { + "$ref": "#/$defs/PersonaStateView" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "required": [ + "Persona" + ] + }, + { + "type": "object", + "properties": { + "PersonaPut": { + "$ref": "#/$defs/PersonaPutOutcome" + } + }, + "additionalProperties": false, + "required": [ + "PersonaPut" + ] + }, { "description": "The answer did not fit one send and is being held for the client to\nfetch. Nothing in a mind produces this: the daemon's serve module does,\nin place of an answer, and the answer it stands for is the named\nMessagePack of the `HuginnMindResponse` the mind gave.", "type": "object", @@ -1360,6 +1391,78 @@ "NotStewarded" ] }, + { + "description": "The persona document fails the published schema: `path` is the\ndocument location (a key the schema does not declare is `*`) and\n`message` the schema keyword that failed. Never the offending value.", + "type": "object", + "properties": { + "PersonaInvalid": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "path": { + "type": "string" + } + }, + "required": [ + "path", + "message" + ] + } + }, + "additionalProperties": false, + "required": [ + "PersonaInvalid" + ] + }, + { + "description": "The document's `personaId` is not this mind's instance, which is\n`instance`.", + "type": "object", + "properties": { + "PersonaForeign": { + "type": "object", + "properties": { + "instance": { + "type": "string" + } + }, + "required": [ + "instance" + ] + } + }, + "additionalProperties": false, + "required": [ + "PersonaForeign" + ] + }, + { + "description": "The put's `expected_updated_at` is not the stored document's\n`updatedAt`, which is `stored` (none when no persona is stored).", + "type": "object", + "properties": { + "PersonaStale": { + "type": "object", + "properties": { + "stored": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false, + "required": [ + "PersonaStale" + ] + }, + { + "description": "The document's `provenance.authority` is not `canonical`: a projection\nor an import is not the mind's persona.", + "type": "string", + "const": "PersonaNotCanonical" + }, { "description": "A run claims work another run in force already holds: `item` is the\nclaimed document's id and `run` the id of the run that holds it.", "type": "object", @@ -1504,6 +1607,13 @@ "instance": { "$ref": "#/$defs/Slug" }, + "persona": { + "description": "The stored persona document's `updatedAt`; none until the first put.", + "type": [ + "string", + "null" + ] + }, "receipts": { "type": "integer", "format": "uint32", @@ -1582,6 +1692,61 @@ "type": "string", "maxLength": 4000 }, + "PersonaPutOutcome": { + "description": "How a put ended. A refusal is an answer, as for `admit`.", + "oneOf": [ + { + "type": "object", + "properties": { + "Committed": { + "type": "object", + "properties": { + "receipt_id": { + "type": "string" + } + }, + "required": [ + "receipt_id" + ] + } + }, + "additionalProperties": false, + "required": [ + "Committed" + ] + }, + { + "type": "object", + "properties": { + "Refused": { + "$ref": "#/$defs/MindRefusal" + } + }, + "additionalProperties": false, + "required": [ + "Refused" + ] + } + ] + }, + "PersonaStateView": { + "description": "What `PersonaGet` answers: the stored document, its `updatedAt`, and the\nreceipt of the put that wrote it.", + "type": "object", + "properties": { + "receipt_id": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "value": true + }, + "required": [ + "value", + "updated_at", + "receipt_id" + ] + }, "PipelineAdmissionOutcome": { "description": "How admission ended. `Committed.writes` names every document the batch\nlanded, derived writes included; Cut 11 indexes from it after `admit`\nreturns, and never inside it.", "oneOf": [