Serve interop notes from Python daemon

This commit is contained in:
Meta Vens 2026-06-14 15:36:12 +01:00
commit 12efb01d1e
4 changed files with 43 additions and 4 deletions

View file

@ -100,7 +100,9 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti.
store beside the cache file by default. The `cultmesh-py-daemon` /
`python -m cultmesh_py.daemon` entrypoint launches that same local TCP server
body and emits a bounded readiness document for process supervisors while the
served CultNet endpoint remains the capability owner.
served CultNet endpoint remains the capability owner. The daemon can register
and seed the package interop-note document so launched processes advertise a
real payload schema and serve a real snapshot over the same CultNet lane.
- Python CultMesh authority leases:
Lease objects own validity and peer/role/shard coverage checks; the catalog
owns sorted listing, lookup, upsert, signature verification policy, and

View file

@ -315,11 +315,14 @@ The same local server can be launched as a package daemon when another runtime
or operator process needs a CultNet endpoint without embedding Python glue:
```powershell
python -m cultmesh_py.daemon --runtime-id python-runtime --display-name "Python Runtime" --host 127.0.0.1 --port 3075 --cache-file mesh.cc --enable-durable-shard-logs --ready-file mesh.ready.json
python -m cultmesh_py.daemon --runtime-id python-runtime --display-name "Python Runtime" --host 127.0.0.1 --port 3075 --cache-file mesh.cc --enable-durable-shard-logs --seed-interop-note --ready-file mesh.ready.json
```
The ready file and stdout line are process readiness hints. The served state and
capability truth still live on the framed CultNet/CultMesh endpoint.
capability truth still live on the framed CultNet/CultMesh endpoint. Use
`--register-interop-note` to expose the package interop-note schema without
seeding a note, or `--seed-interop-note` to register it and publish one local
record for wire probes.
```python

View file

@ -8,6 +8,8 @@ import threading
from pathlib import Path
from typing import Any
from cultcache_py.interop import INTEROP_SCHEMA_VERSION, interop_note_document
from .facade import CultMesh
from .server import CultMeshLocalServer
@ -26,6 +28,8 @@ def main(argv: list[str] | None = None) -> int:
parser.add_argument("--max-snapshot-documents", type=int)
parser.add_argument("--max-snapshot-bytes", type=int)
parser.add_argument("--ready-file")
parser.add_argument("--register-interop-note", action="store_true")
parser.add_argument("--seed-interop-note", action="store_true")
args = parser.parse_args(argv)
stop = threading.Event()
@ -48,6 +52,23 @@ def start_server(args: argparse.Namespace) -> CultMeshLocalServer:
enable_durable_shard_logs=args.enable_durable_shard_logs,
shard_log_path=args.shard_log_file,
)
if args.register_interop_note or args.seed_interop_note:
node.database.register_document(interop_note_document)
if args.cache_file:
node.database.pull()
if args.seed_interop_note:
node.database.put(
interop_note_document,
f"note:{args.runtime_id}",
{
"schemaVersion": INTEROP_SCHEMA_VERSION,
"documentId": f"note:{args.runtime_id}",
"authorRuntimeId": args.runtime_id,
"title": f"{args.runtime_id} wrote a CultMesh daemon note",
"body": "The Python CultMesh daemon is serving typed state over CultNet.",
"tags": [args.runtime_id, "python", "cultmesh", "daemon"],
},
)
return CultMesh.serve_node(
node,
host=args.host,

View file

@ -30,7 +30,7 @@ from cultcache_py.compare_csharp import (
_median_result,
_parity_status,
)
from cultcache_py.interop import read_note, write_note
from cultcache_py.interop import INTEROP_SCHEMA_VERSION, interop_note_document, read_note, write_note
from cultcache_py.verify import verify
from cultnet_py.interop_peer import append_shard_log_put, build_state, raw_snapshot_response
from cultnet_py import (
@ -3043,6 +3043,7 @@ class CultCacheTests(unittest.TestCase):
"0",
"--ready-file",
str(ready_path),
"--seed-interop-note",
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@ -3062,6 +3063,7 @@ class CultCacheTests(unittest.TestCase):
self.assertEqual(ready["schemaVersion"], READY_SCHEMA_VERSION)
self.assertEqual(ready["runtimeId"], "daemon-test-peer")
self.assertEqual(ready["endpoint"], f"cultnet://127.0.0.1:{ready['port']}")
self.assertEqual(ready["supportedDocumentTypes"], ["cultcache.interop-note"])
client = CultMesh.create_client("127.0.0.1", int(ready["port"]), timeout_seconds=2.0)
hello_response = client.request(
@ -3073,6 +3075,17 @@ class CultCacheTests(unittest.TestCase):
self.assertEqual(hello_response["displayName"], "Daemon Test Peer")
self.assertIn("cultnet.hello.v0", hello_response["supportedMessageVersions"])
self.assertIn("cultnet.schema_catalog_request.v0", hello_response["supportedMessageVersions"])
self.assertEqual(hello_response["supportedDocumentTypes"], ["cultcache.interop-note"])
schema_response = client.fetch_schema_catalog(schema_ids=["cultcache.interop-note"], include_schema_json=True)
self.assertEqual(schema_response["schemas"][0]["schemaVersion"], INTEROP_SCHEMA_VERSION)
self.assertEqual(schema_response["schemas"][0]["documentType"], "cultcache.interop-note")
snapshot_response = client.fetch_snapshot_response(schema_ids=["cultcache.interop-note"])
self.assertEqual(snapshot_response.documents[0].record_key, "note:daemon-test-peer")
note = interop_note_document.decode_payload(snapshot_response.documents[0].payload)
self.assertEqual(note["authorRuntimeId"], "daemon-test-peer")
self.assertIn("daemon", note["tags"])
finally:
process.terminate()
try: