fix(kvb-org-organize): move the council root out of /tmp with a lossless migration
councilroot.py resolves one durable council root for every script and migrates the old /tmp root under the held locks: a preflight conflict moves nothing, each legacy file is renamed to a staging name before it is copied so a late writer is merged by the catch-up, id-less journals merge by line multiset, a differing whole file is kept beside its namesake, and a crash marker makes install copy the skills and report. One settings-file list, managed drop-ins included, serves councilroot.py and queue.py. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14). 🎯 Fix: 88 % 💥 Break: 7 % 💸 Tokens: 100 % ⏱️ Velocity: 100 % 🛡️ Security: 100 % 🏆 Score: 82 🚦 Gate: ⛔ fix 88 % < 90, break 7 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
699f3227c9
commit
8726ed37a7
47 files changed
+2199
-191
No files matched your search
@@ -7,7 +7,8 @@ description: >
|
||||
|
||||
`${CLAUDE_SKILL_DIR}/scripts/radio.py` is the channel every skill uses to
|
||||
reach other agents, on every runtime. Both channels share one store,
|
||||
`news.jsonl` in the council directory (`/tmp/agents-council`).
|
||||
`news.jsonl` in the council directory, which
|
||||
`${CLAUDE_SKILL_DIR}/../kvb-org-organize/scripts/councilroot.py root` prints.
|
||||
|
||||
```bash
|
||||
radio.py post "<text>" [--to <name> ...] [--session <id>]
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
"""Reach other agents: the radio is immediate, the post waits until a turn ends; one shared store.
|
||||
|
||||
Environment:
|
||||
AGENTS_COUNCIL_ROOT: council directory shared by every agent on the host;
|
||||
/tmp/agents-council unless set. Rows live in <root>/news.jsonl under
|
||||
AGENTS_COUNCIL_ROOT, XDG_STATE_HOME, HOME: the council directory the
|
||||
kvb-org-organize councilroot.py resolves, shared by every agent on the
|
||||
host. Rows live in <root>/news.jsonl under
|
||||
<root>/news.lock, the store the old news.py reads and writes too.
|
||||
AGENTS_COUNCIL_CONFIG: config file; its "notify" argv tells the operator
|
||||
of a mayday, its "never_block" and "mayday_allow" regexes name the
|
||||
@@ -89,18 +90,9 @@ from pathlib import Path
|
||||
from types import ModuleType
|
||||
|
||||
# Every agent on the host must agree on one council directory and one config without being told.
|
||||
ROOT = Path(os.environ.get("AGENTS_COUNCIL_ROOT", "/tmp/agents-council"))
|
||||
CONFIG = Path(
|
||||
os.environ.get("AGENTS_COUNCIL_CONFIG", str(Path.home() / ".claude" / "agents-council" / "config.json"))
|
||||
)
|
||||
NEWS = ROOT / "news.jsonl"
|
||||
LOCK = ROOT / "news.lock"
|
||||
SEEN = ROOT / "news-seen"
|
||||
STATE = ROOT / "radio-seen"
|
||||
LISTEN = ROOT / "radio-listen"
|
||||
SILENCE = ROOT / "radio-silence.json"
|
||||
NOTIFIED = ROOT / "radio-notified"
|
||||
FEEDBACK = ROOT / "feedback.json"
|
||||
ORGANIZE = Path(__file__).resolve().parents[2] / "kvb-org-organize" / "scripts"
|
||||
SELF = Path(__file__).resolve()
|
||||
RADIO = ("mayday", "pan-pan", "security", "call", "broadcast")
|
||||
@@ -140,6 +132,17 @@ def organize(name: str) -> ModuleType:
|
||||
return module
|
||||
|
||||
|
||||
ROOT = organize("councilroot").root()
|
||||
NEWS = ROOT / "news.jsonl"
|
||||
LOCK = ROOT / "news.lock"
|
||||
SEEN = ROOT / "news-seen"
|
||||
STATE = ROOT / "radio-seen"
|
||||
LISTEN = ROOT / "radio-listen"
|
||||
SILENCE = ROOT / "radio-silence.json"
|
||||
NOTIFIED = ROOT / "radio-notified"
|
||||
FEEDBACK = ROOT / "feedback.json"
|
||||
|
||||
|
||||
def council() -> ModuleType:
|
||||
return organize("council")
|
||||
|
||||
@@ -149,8 +152,9 @@ def name_of(sid: str) -> str:
|
||||
|
||||
|
||||
def items() -> list[dict]:
|
||||
nofollow = organize("nofollow")
|
||||
try:
|
||||
lines = organize("nofollow").read_text(ROOT, NEWS).splitlines()
|
||||
lines = nofollow.read_tail(ROOT, NEWS, nofollow.READ_LIMIT).splitlines()
|
||||
except OSError:
|
||||
return []
|
||||
rows = []
|
||||
@@ -361,7 +365,11 @@ def store(entries: list[dict]) -> float:
|
||||
for entry in entries:
|
||||
entry["ts"] = ts
|
||||
ts = math.nextafter(ts, math.inf)
|
||||
write_atomic(NEWS, "".join(json.dumps(row) + "\n" for row in [*rows[-(KEPT - len(entries)):], *entries]))
|
||||
cut = max(0, len(rows) - max(0, KEPT - len(entries)))
|
||||
if cut:
|
||||
archive = ROOT / "archive" / f"news-{time.strftime('%Y-%m-%d')}.jsonl"
|
||||
organize("nofollow").append(ROOT, archive, "".join(json.dumps(row) + "\n" for row in rows[:cut]), 0o600)
|
||||
write_atomic(NEWS, "".join(json.dumps(row) + "\n" for row in [*rows[cut:], *entries]))
|
||||
return entries[-1]["ts"]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user