From d26d1ad89be4fecfff357c54ceda6545d032f994 Mon Sep 17 00:00:00 2001 From: dp-web4 Date: Mon, 16 Nov 2026 22:13:42 -0800 Subject: [PATCH 1/3] toolset: lean keeps settle.id and settle.reopen (second lean-trial finding) Under brief, nomad-being passed reopen in 0 of 31 settles and id in 5. Under lean it passed both in 3 of 3, all refused: an invented id slug twice, and once a real id beside a question that belonged to another entry. Those two descriptions say id is an s-number for changing an existing entry and reopen=true removes it. Without them a small model fills every optional field, and a real id with a matching question would overwrite a conclusion it never meant to change. Lean is now 16,254 chars vs brief 22,236. Seat: nomad-claude Co-Authored-By: Claude Opus 5.5 --- sage/gateway/toolset.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sage/gateway/toolset.py b/sage/gateway/toolset.py index 15fa67c31..d4a2a3141 100644 --- a/sage/gateway/toolset.py +++ b/sage/gateway/toolset.py @@ -222,12 +222,19 @@ def here(cfg: Optional[dict], backend: Optional[str] = None) -> Dict[str, tuple] # an argument, not something to write into the file), memory_read.find (literal, not a regex; ignores the # line range), memory_edit.old (exact and unique), game.game (the valid ids are prose, not an enum). # Add a pair here when a lean being's per-verb failures show a dropped line was load-bearing. +# settle.id / settle.reopen: from the same trial (11-16..17). Under brief nomad-being passed reopen in 0 +# of 31 settles and id in 5; under lean it passed BOTH in 3 of 3, all refused: an invented id slug +# twice, and once a real id ('s22') beside a question that belonged to another entry. Those two lines +# say id is an s-number for changing an existing entry and reopen=true REMOVES it; without them a +# small model fills every optional field, and a real id with a matching question would overwrite +# a conclusion it never meant to change. # check.target: added from the first lean trial (nomad-being, 2026-11-16 01:01Z). Two beats into lean it # passed a file path as the target and the gate refused it; under brief it had used target 'tests' # correctly the day before. The values a target may take ('tests', a suite, suite::test) are prose here, # not an enum, so lean dropped them with the rest. LEAN_KEEP = frozenset({("run", "data"), ("request_run", "rerun"), ("memory_read", "find"), - ("memory_edit", "old"), ("game", "game"), ("check", "target")}) + ("memory_edit", "old"), ("game", "game"), ("check", "target"), + ("settle", "id"), ("settle", "reopen")}) def tool_descriptions_mode(cfg: Optional[dict]) -> str: From 713b099cabe9eddba007c2c989e57bc662cd4371 Mon Sep 17 00:00:00 2001 From: dp-web4 Date: Tue, 17 Nov 2026 01:17:18 -0800 Subject: [PATCH 2/3] toolset: lean keeps prose by rule, every optional parameter classified (#708) Both lean-trial regressions on Nomad (check.target, settle.id/reopen) came from one behaviour: without parameter prose, a small model fills every listed parameter. The rule from #708 (HUB on #753: apply it now) keeps the prose when misfilling would act on existing state, or when the valid values are a closed set written as prose. That adds memory_edit start_line/end_line, skill retire/distinct, retire_thread preview/confirmation, pr_amend body, tune value, pr_sync op and identity_edit field to LEAN_KEEP. Every other optional parameter is listed in LEAN_DROP_REVIEWED, and a test fails on any optional parameter in neither set. Lean is now 17,064 chars vs brief 22,243 (-23%); the size bound in the test goes from 0.75 to 0.80, with the reason. Built on #753. Seat: nomad-claude Co-Authored-By: Claude Opus 5.5 --- .../tests/test_lean_tool_descriptions.py | 16 +++++++++- sage/gateway/toolset.py | 29 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/sage/gateway/tests/test_lean_tool_descriptions.py b/sage/gateway/tests/test_lean_tool_descriptions.py index e417a272d..ded080029 100644 --- a/sage/gateway/tests/test_lean_tool_descriptions.py +++ b/sage/gateway/tests/test_lean_tool_descriptions.py @@ -47,10 +47,24 @@ def test_what_lean_leaves_out_is_one_describe_away(): def test_lean_is_materially_smaller_than_brief(): b = len(json.dumps(toolset.specs({}, {}, brief=True))) l = len(json.dumps(toolset.specs({}, {}, lean=True))) - assert l < 0.75 * b, f"lean {l} vs brief {b}" + # 0.80, not 0.75: the #708 rule keeps prose for parameters that act on existing state (about 800 + # chars). That trade is deliberate: lean is a saving, not a target, and safety lines outrank it. + assert l < 0.80 * b, f"lean {l} vs brief {b}" def test_every_load_bearing_pair_names_a_real_parameter(): """A typo in LEAN_KEEP would silently drop the line it meant to keep.""" for verb, param in toolset.LEAN_KEEP: assert verb in _TOOL_SCHEMAS and param in _TOOL_SCHEMAS[verb][1], (verb, param) + + +def test_every_optional_parameter_is_classified(): + """SAGE #708's rule: every optional parameter is either kept under lean (it acts on existing state, + or its valid values are prose) or reviewed as safe to drop. A new optional parameter in neither set + fails here, so it gets a decision instead of silently losing its prose.""" + optional = {(v, p) for v, (_d, props, req) in _TOOL_SCHEMAS.items() for p in props if p not in req} + unclassified = optional - toolset.LEAN_KEEP - toolset.LEAN_DROP_REVIEWED + assert not unclassified, f"classify these for lean (LEAN_KEEP or LEAN_DROP_REVIEWED): {sorted(unclassified)}" + assert not (toolset.LEAN_KEEP & toolset.LEAN_DROP_REVIEWED), "a parameter cannot be both kept and dropped" + for v, p in toolset.LEAN_DROP_REVIEWED: + assert v in _TOOL_SCHEMAS and p in _TOOL_SCHEMAS[v][1], ("stale LEAN_DROP_REVIEWED entry", v, p) diff --git a/sage/gateway/toolset.py b/sage/gateway/toolset.py index d4a2a3141..313285784 100644 --- a/sage/gateway/toolset.py +++ b/sage/gateway/toolset.py @@ -234,7 +234,34 @@ def here(cfg: Optional[dict], backend: Optional[str] = None) -> Dict[str, tuple] # not an enum, so lean dropped them with the rest. LEAN_KEEP = frozenset({("run", "data"), ("request_run", "rerun"), ("memory_read", "find"), ("memory_edit", "old"), ("game", "game"), ("check", "target"), - ("settle", "id"), ("settle", "reopen")}) + ("settle", "id"), ("settle", "reopen")}) | frozenset({ + # THE RULE, applied to every optional parameter (SAGE #708; HUB on #753: apply it now, not + # near-miss by near-miss). Both lean-trial regressions came from one behaviour: without the + # prose, a small model fills EVERY listed parameter. So the prose stays when misfilling would + # act on existing state, or when the valid values are a closed set written as prose: + ("memory_edit", "start_line"), ("memory_edit", "end_line"), # pick which lines get replaced + ("skill", "retire"), ("skill", "distinct"), # remove a skill / write beside one + ("retire_thread", "preview"), ("retire_thread", "confirmation"), # dry run vs. a real retire + ("pr_amend", "body"), # overwrites the PR body + ("tune", "value"), # 'default' resets the parameter + ("pr_sync", "op"), ("identity_edit", "field"), # closed sets written as prose +}) +# Every other optional parameter was REVIEWED and its prose may go: free text the being writes in +# its own words, or a read-only selector whose misfill costs a re-read, not a change. A parameter +# in neither set fails test_every_optional_parameter_is_classified, so a new one can't slip +# through lean unclassified. +LEAN_DROP_REVIEWED = frozenset({ + ("camera", "device"), ("camera", "out_path"), ("game", "expect"), ("gaze", "target"), + ("gaze", "words"), ("git_read", "n"), ("git_read", "path"), ("git_read", "rev"), + ("git_read", "rev2"), ("identity_edit", "text"), ("identity_edit", "why"), + ("memory_read", "end_line"), ("memory_read", "start_line"), ("pr_read", "repo"), + ("pr_read", "last"), ("pr_sync", "message"), ("recall", "query"), ("recall", "top_k"), + ("recall", "idx"), ("remember", "tags"), ("request_run", "why"), ("retire_thread", "reason"), + ("search", "path"), ("search", "n"), ("settle", "question"), ("settle", "answer"), + ("settle", "evidence"), ("settle", "why"), ("skill", "name"), ("skill", "query"), + ("skill", "description"), ("skill", "when"), ("skill", "body"), ("skill", "why"), + ("tune", "name"), ("tune", "why"), +}) def tool_descriptions_mode(cfg: Optional[dict]) -> str: From 576af29e05ff3021cba33755e364411e3614d591 Mon Sep 17 00:00:00 2001 From: dp-web4 Date: Tue, 17 Nov 2026 04:43:37 -0800 Subject: [PATCH 3/3] toolset: lean keeps camera.out_path, tune.name and skill.name (HUB on #759) Three anchors the first pass dropped, each the parameter that picks what a kept flag or write acts on: camera.out_path is a write destination (ffmpeg overwrites the path), tune.name picks what value sets or resets, and skill.name anchors both a rewrite and retire. A comment now says the classification test proves coverage, not correctness. Lean is 17,291 chars vs brief 22,243 (0.777). Seat: nomad-claude Co-Authored-By: Claude Opus 5.5 --- sage/gateway/toolset.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sage/gateway/toolset.py b/sage/gateway/toolset.py index 313285784..aeadcdd59 100644 --- a/sage/gateway/toolset.py +++ b/sage/gateway/toolset.py @@ -245,22 +245,27 @@ def here(cfg: Optional[dict], backend: Optional[str] = None) -> Dict[str, tuple] ("pr_amend", "body"), # overwrites the PR body ("tune", "value"), # 'default' resets the parameter ("pr_sync", "op"), ("identity_edit", "field"), # closed sets written as prose + # HUB on #759: three anchors the first pass dropped. Each picks WHAT a kept flag or write acts on. + ("camera", "out_path"), # a write destination: ffmpeg overwrites whatever path it names + ("tune", "name"), # picks which parameter `value` sets or resets + ("skill", "name"), # the anchor for a rewrite ("writing it again replaces it") and retire }) # Every other optional parameter was REVIEWED and its prose may go: free text the being writes in # its own words, or a read-only selector whose misfill costs a re-read, not a change. A parameter # in neither set fails test_every_optional_parameter_is_classified, so a new one can't slip -# through lean unclassified. +# through lean unclassified. The test proves every optional parameter is CLASSIFIED, not that each +# is classified CORRECTLY: that is a review question, and HUB's review of #759 moved three entries. LEAN_DROP_REVIEWED = frozenset({ - ("camera", "device"), ("camera", "out_path"), ("game", "expect"), ("gaze", "target"), + ("camera", "device"), ("game", "expect"), ("gaze", "target"), ("gaze", "words"), ("git_read", "n"), ("git_read", "path"), ("git_read", "rev"), ("git_read", "rev2"), ("identity_edit", "text"), ("identity_edit", "why"), ("memory_read", "end_line"), ("memory_read", "start_line"), ("pr_read", "repo"), ("pr_read", "last"), ("pr_sync", "message"), ("recall", "query"), ("recall", "top_k"), ("recall", "idx"), ("remember", "tags"), ("request_run", "why"), ("retire_thread", "reason"), ("search", "path"), ("search", "n"), ("settle", "question"), ("settle", "answer"), - ("settle", "evidence"), ("settle", "why"), ("skill", "name"), ("skill", "query"), + ("settle", "evidence"), ("settle", "why"), ("skill", "query"), ("skill", "description"), ("skill", "when"), ("skill", "body"), ("skill", "why"), - ("tune", "name"), ("tune", "why"), + ("tune", "why"), })