From ed5774d7b4daef4f333ad70ff45866e9460e3330 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 15:44:21 +0100 Subject: [PATCH] Seed Python daemon shard logs --- packages/cultcache-py/PARITY.md | 3 ++- packages/cultcache-py/README.md | 5 +++-- packages/cultcache-py/src/cultmesh_py/daemon.py | 7 ++++++- packages/cultcache-py/tests/test_cultcache.py | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/cultcache-py/PARITY.md b/packages/cultcache-py/PARITY.md index f4875233..c8c4514c 100644 --- a/packages/cultcache-py/PARITY.md +++ b/packages/cultcache-py/PARITY.md @@ -102,7 +102,8 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti. body and emits a bounded readiness document for process supervisors while the 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. + real payload schema and serve both a real snapshot and a real shard-log entry + 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 diff --git a/packages/cultcache-py/README.md b/packages/cultcache-py/README.md index 893194e7..8100df00 100644 --- a/packages/cultcache-py/README.md +++ b/packages/cultcache-py/README.md @@ -315,14 +315,15 @@ 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 --seed-interop-note --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 --seed-shard-id interop --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. 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. +record for wire probes. Seeded records are committed through the raw mutation +path, so peers can read them through both snapshot and shard-log catch-up. ```python diff --git a/packages/cultcache-py/src/cultmesh_py/daemon.py b/packages/cultcache-py/src/cultmesh_py/daemon.py index 52bceb74..e0f7271c 100644 --- a/packages/cultcache-py/src/cultmesh_py/daemon.py +++ b/packages/cultcache-py/src/cultmesh_py/daemon.py @@ -30,6 +30,8 @@ def main(argv: list[str] | None = None) -> int: parser.add_argument("--ready-file") parser.add_argument("--register-interop-note", action="store_true") parser.add_argument("--seed-interop-note", action="store_true") + parser.add_argument("--seed-shard-id", default="interop") + parser.add_argument("--seed-shard-epoch", type=int, default=1) args = parser.parse_args(argv) stop = threading.Event() @@ -57,7 +59,7 @@ def start_server(args: argparse.Namespace) -> CultMeshLocalServer: if args.cache_file: node.database.pull() if args.seed_interop_note: - node.database.put( + node.database.put_raw_message( interop_note_document, f"note:{args.runtime_id}", { @@ -68,6 +70,9 @@ def start_server(args: argparse.Namespace) -> CultMeshLocalServer: "body": "The Python CultMesh daemon is serving typed state over CultNet.", "tags": [args.runtime_id, "python", "cultmesh", "daemon"], }, + message_id=f"daemon-seed:{args.runtime_id}", + shard_id=args.seed_shard_id, + shard_epoch=args.seed_shard_epoch, ) return CultMesh.serve_node( node, diff --git a/packages/cultcache-py/tests/test_cultcache.py b/packages/cultcache-py/tests/test_cultcache.py index b468f5aa..c595180c 100644 --- a/packages/cultcache-py/tests/test_cultcache.py +++ b/packages/cultcache-py/tests/test_cultcache.py @@ -3044,6 +3044,8 @@ class CultCacheTests(unittest.TestCase): "--ready-file", str(ready_path), "--seed-interop-note", + "--seed-shard-id", + "daemon-interop", ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -3086,6 +3088,18 @@ class CultCacheTests(unittest.TestCase): note = interop_note_document.decode_payload(snapshot_response.documents[0].payload) self.assertEqual(note["authorRuntimeId"], "daemon-test-peer") self.assertIn("daemon", note["tags"]) + + shard_catalog = client.fetch_shard_catalog(schema_ids=["cultcache.interop-note"]) + self.assertEqual(shard_catalog["shards"][0]["shardId"], "daemon-interop") + self.assertEqual(shard_catalog["shards"][0]["schemaIds"], ["cultcache.interop-note"]) + + shard_log = client.fetch_shard_log_response(shard_id="daemon-interop", shard_epoch=1) + self.assertFalse(shard_log.resync_required) + self.assertEqual(shard_log.entries[0].sequence, 1) + self.assertEqual(shard_log.entries[0].change_kind, "added") + self.assertIsNotNone(shard_log.entries[0].raw_document) + assert shard_log.entries[0].raw_document is not None + self.assertEqual(shard_log.entries[0].raw_document.record_key, "note:daemon-test-peer") finally: process.terminate() try: