perf(skills): cut the tokens and start-up time every agent pays
Requirement 071, from the skeptic audit picks. Output: radio.py show groups older rows per peer and class into one line each (7 days 143,520 -> 3,229 bytes); rasci.py show is narrower (7,081 -> 2,915 bytes) and archives tasks ended over 7 days ago into rasci-archive.json, still listed by get, --all, artifacts and tools and revived by any command that names them; make test runs quiet. Hooks: hooks register as python3 -I -S (site import skipped), the hook paths of watch, queue, radio, graph and log skip argparse, and traceback, tempfile, configparser, tomllib, statistics and urllib load lazily; councilroot.guard() serves watch and radio; the dream reminder exits before Python when no row can be on. pre-bash 68 ms, post-bash 50 ms. Hub: names.json keeps only the entries every lookup needs (11.6 MB -> 11 KB, lookups identical) and phrasing is cached; a state build takes 55 instead of 104 ms. Context: the commit-chain skills shrink from 3,330 to 1,192 words with their names kept, details moved to chain.md and reference.md files read on demand; descriptions capped at 25 words; .ignore and .rgignore keep state and worktrees out of searches. overhead.py of kvb-check-efficiency measures hook and script cost per call. 🎯 Fix: 93 % 💥 Break: 5 % 💸 Tokens: 107 % ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 83 🚦 Gate: ⚠️ tokens 107 % > 100 (on-demand reference files; resident text and daily cost fall): operator approved the commit Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c969be21c
commit
9403e17e97
53 files changed
+1219
-522
No files matched your search
@@ -1,11 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import random
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import hub_support # noqa: F401
|
||||
from kvb_orchestrator import names
|
||||
from kvb_orchestrator.matching import born_of
|
||||
|
||||
|
||||
class TestRenameOnce(unittest.TestCase):
|
||||
@@ -59,5 +62,37 @@ class TestDirectoryLookups(unittest.TestCase):
|
||||
self.assertEqual(book.directory().now("s1"), "B")
|
||||
|
||||
|
||||
def lookups(entries: list[dict]) -> dict:
|
||||
directory = names.Directory(entries)
|
||||
known = sorted(directory.by_name)
|
||||
return {
|
||||
"renames": [(row["id"], row["title"]) for row in directory.renames(-1.0, 1e9)],
|
||||
"born": [born_of(name, entries, []) for name in known],
|
||||
"aliases": [sorted(directory.aliases(name)) for name in known],
|
||||
"holders": [directory.by_name[name] for name in known],
|
||||
"now": {session: directory.now(session) for session in directory.by_session},
|
||||
"names": {session: directory.names(session) for session in directory.by_session},
|
||||
"find": [directory.find(name, 1e9) for name in known],
|
||||
}
|
||||
|
||||
|
||||
class TestCompaction(unittest.TestCase):
|
||||
def test_thirty_thousand_flip_flops_shrink_and_every_lookup_stays(self):
|
||||
pick = random.Random(7)
|
||||
cycle = [{"session": "s1", "name": pick.choice(("Stage", "i18n 2.0", "Stage:x")), "first_seen": float(index), "source": "claim"} for index in range(30000)]
|
||||
entries = [{"session": "s0", "name": "Main", "first_seen": 0.0, "source": "claim"}, *cycle,
|
||||
{"session": "s1", "name": "Skills", "first_seen": 30000.0, "source": "title"},
|
||||
{"session": "s2", "name": "Stage", "first_seen": 30001.0, "source": "claim"}]
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
store = Path(folder) / "names.json"
|
||||
store.write_text(json.dumps({"entries": entries, "observed": {}}), encoding="utf-8")
|
||||
before = store.stat().st_size
|
||||
kept = names.Names(store).listed()
|
||||
self.assertLess(len(kept), 60)
|
||||
self.assertLess(store.stat().st_size * 100, before)
|
||||
self.assertEqual(lookups(kept), lookups(entries))
|
||||
self.assertEqual(names.Names(store).listed(), kept)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user