From b114b292216b8b3faa9fab73e39cb6e08516e846 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 23 Nov 2026 13:02:33 -0700 Subject: [PATCH] Route prints notes for passed-over workers only under --explain; plain output at most 6 lines. done / next: fix 3 (unused code) --- sisi/workers.py | 9 +++++++-- tests/test_worker_routes.py | 22 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/sisi/workers.py b/sisi/workers.py index bdd34d3..0876867 100644 --- a/sisi/workers.py +++ b/sisi/workers.py @@ -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: diff --git a/tests/test_worker_routes.py b/tests/test_worker_routes.py index a9bb704..d001404 100644 --- a/tests/test_worker_routes.py +++ b/tests/test_worker_routes.py @@ -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)