feat(core): node veth idempotency, multi-node cdp ports, brain last ids persistence, and pulse interval variable
This commit is contained in:
+19
-3
@@ -574,9 +574,10 @@ def read_brain_messages(agent, sidechat_name, since_ts):
|
||||
|
||||
Resolves sidechat_name -> UUID via dm (never hardcoded; UUIDs rotate),
|
||||
reads via the same muse_hybrid primitive the loop uses, returns
|
||||
[{"sender", "text", "ts"}]. Tracks last message_id per (agent, name);
|
||||
first run anchors at newest with no backfill (same policy as
|
||||
new_messages for main chat).
|
||||
[{"sender", "text", "ts"}]. Tracks last message_id per (agent, name)
|
||||
in the module cache, which do_check() persists to the watermark JSON
|
||||
(brain.brain_last_ids) across ticks. First run anchors at newest with
|
||||
no backfill (same policy as new_messages for main chat).
|
||||
"""
|
||||
try:
|
||||
import dm
|
||||
@@ -635,6 +636,14 @@ def do_check(only_agent=None):
|
||||
try:
|
||||
from brain import BrainWorkspace
|
||||
brain = BrainWorkspace(STATE_FILE, read_fn=read_brain_messages)
|
||||
# Restore persisted brain message IDs so !loop commands posted
|
||||
# between ticks are not missed (module cache is per-process).
|
||||
for k, v in (brain.state.get("brain_last_ids") or {}).items():
|
||||
try:
|
||||
ag, nm = k.split("|", 1)
|
||||
_BRAIN_LAST_IDS[(ag, nm)] = v
|
||||
except ValueError:
|
||||
pass
|
||||
intake = brain.intake()
|
||||
if intake.get("commands"):
|
||||
log("brain: %d commands, %d acks, %d ignored-senders" % (
|
||||
@@ -787,6 +796,13 @@ def do_check(only_agent=None):
|
||||
watermarks=wm_epochs,
|
||||
health=health,
|
||||
)
|
||||
# Persist brain message IDs for the next tick.
|
||||
try:
|
||||
brain.state["brain_last_ids"] = {
|
||||
"%s|%s" % k: v for k, v in _BRAIN_LAST_IDS.items()
|
||||
if v is not None}
|
||||
except Exception:
|
||||
pass
|
||||
brain.save()
|
||||
except Exception as e:
|
||||
log("brain post_thinking failed (non-fatal): %r" % e)
|
||||
|
||||
Reference in New Issue
Block a user