Route prints notes for passed-over workers only under --explain; plain output at most 6 lines. done / next: fix 3 (unused code)

This commit is contained in:
swaits committed 2026-11-23 13:02:33 -07:00
1 parent 05ac5342d0
commit b114b29221
2 files changed
+27 -4

No files matched your search

+7 -2
View File
@@ -1447,9 +1447,14 @@ def cmd_route(args=()):
print("mechanism: %s" % mechanism_for(result["choice"]))
for line in _down_lines(down):
print(line)
for line in notes_for(by_worker, result["choice"], result["passed_over"]):
head = 2 + len(_down_lines(down))
explain = "--explain" in args
# Notes for the chosen worker always print; notes for workers passed over only with --explain.
# Plain output stays within 6 lines: the worker, the mechanism, what is down, then the notes.
for line in notes_for(by_worker, result["choice"], result["passed_over"] if explain else [],
limit=5 if explain else max(1, 5 - head)):
print(line)
if "--explain" in args:
if explain:
for line in routing.explain_choice(result, kind, difficulty):
print(line)
if excluded:
+20 -2
View File
@@ -123,14 +123,32 @@ class NotesAndLimitsTests(RouteCase):
text = "\n".join(notes)
self.assertIn("set it lower", text)
self.assertIn("information, not an instruction", text)
self.assertIn("passed over", text)
self.assertIn("approvals", text)
self.assertNotIn("approvals", text) # a passed-over worker's note waits for --explain
ex = self.sisi("route", "--kind", "impl", "--difficulty", "2", "--explain", env=self.env())
self.assertIn("passed over", ex.stdout)
self.assertIn("approvals", ex.stdout)
listing = self.sisi("workers", env=self.env())
self.assertIn("set it lower", listing.stdout)
self.sisi("workers", "note", "wk-fast", "--remove", env=self.env())
after = self.sisi("route", "--kind", "impl", "--difficulty", "2", env=self.env())
self.assertNotIn("set it lower", after.stdout)
def test_plain_route_is_short_and_quiet_about_workers_it_did_not_choose(self):
"""Plain `sisi route` is at most 6 lines; notes on passed-over workers (down or not) appear only with --explain."""
self.seed_real_shape()
self.down("muse/beta-1")
for pat in ("beta", "alpha", "muse", "codex", "wk-mid"):
self.sisi("workers", "note", pat, "standing fact about %s" % pat, "--why", "owner", env=self.env())
self.sisi("workers", "note", "wk-fast", "chosen worker fact", "--why", "owner", env=self.env())
r = self.sisi("route", "--kind", "impl", "--difficulty", "2", env=self.env())
self.assertEqual(r.returncode, 0, r.stdout)
lines = r.stdout.splitlines()
self.assertLessEqual(len(lines), 6, r.stdout)
self.assertIn("chosen worker fact", r.stdout)
self.assertNotIn("passed over", r.stdout)
ex = self.sisi("route", "--kind", "impl", "--difficulty", "2", "--explain", env=self.env())
self.assertIn("passed over", ex.stdout)
def test_only_limits_a_provider_to_named_models(self):
"""R-7.2-1, R-7.3-3: a newly discovered, cheap model on a limited provider is not routed."""
self.seed([("muse/beta-1", 9, 9)], difficulty=1)