Hand-offs without GitHub: bot kit zip, bot zip import, local refresh

- python -m collection export-bot-kit: policy.json, solver.js, graph.js and a
  README with checksums, zipped for the bot
- the bot import takes a folder or a zip (files may sit under any top folder)
- python -m collection refresh: the daily workflow, run locally
- trajectories files are named by date and raw checksum, so two imports on
  one day never overwrite each other

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-10 01:50:12 +00:00
co-authored by Claude Opus 5.5
parent 19209a2ad6
commit 5c49591dae
7 changed files with 174 additions and 2 deletions
+26
View File
@@ -113,6 +113,32 @@ class Bot(unittest.TestCase):
self.assertEqual(codegen.graph_js(), (ROOT / codegen.GRAPH_JS).read_text(encoding="utf-8"))
class Handoff(unittest.TestCase):
def test_bot_zip_imports_like_the_folder(self):
import zipfile
spec = read_yaml("collection/pipeline.yaml")["sources"]["bot"]["extract"]
z = TMP / "ken.zip"
with zipfile.ZipFile(z, "w") as f: # files under a top folder, as a zipped repo would have them
for rel in spec["files"]:
f.write(FX / rel, f"DragonKind-main/{rel}")
self.assertEqual(extract.pack_local(spec, z), extract.pack_local(spec, FX))
empty = TMP / "empty.zip"
with zipfile.ZipFile(empty, "w") as f:
f.writestr("notes.txt", "hi")
with self.assertRaises(RuntimeError):
extract.pack_local(spec, empty)
def test_bot_kit(self):
import zipfile
from collection.etl import handoff
zpath = handoff.export_bot_kit(str(TMP / "exports"))
with zipfile.ZipFile(zpath) as z:
self.assertEqual(sorted(z.namelist()), ["README.txt", "graph.js", "policy.json", "solver.js"])
self.assertEqual(z.read("solver.js"), (ROOT / "core/solver.js").read_bytes())
self.assertEqual(json.loads(z.read("policy.json"))["id"],
json.loads((ROOT / "data/public/policy.json").read_text(encoding="utf-8"))["id"])
class Sheets(unittest.TestCase):
def test_privacy_rules(self):
p = TMP / "sheet.csv"