navigation: never bypass the leaf intent guard

The leaf softmax offers only existing skills (create_skill is deliberately
not an option), so a confident winner is "the closest existing skill", never
a statement that it matches. Skipping the intent guard on a confident leaf
softmax winner therefore made codegen unreachable for an unmatched request:
with Winnow as the engine, "send a message to pepper on SimpleX" picked
connect_link (0.86) / next_message (0.995), bypassed the guard, and ran a
read skill instead of authoring simplex.send_message.

Always run confirm_skill_fit at the leaf — it is the sole leaf-level create
door. The category scope bypass stays (create_category is one of its
options, so a confident category winner is meaningful). Drop the now-unused
leaf_softmax_prob meta plumbing; update the docs and the regression test.

Also fix a deployment-hostname leak ("guppy") in winnow.py's docstring that
tripped test_no_env_leaks.
This commit is contained in:
gabby committed 2026-10-07 09:08:13 +00:00
1 parent ee7700275c
commit f1e0de33ca
6 files changed
+56 -52

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
"creation_approval": false, "creation_approval": false,
"timezone": "", "timezone": "",
"navigation": { "navigation": {
"_comment": "Navigation is two-stage at BOTH levels and the guards are the create doors (no threshold gate). Category: the softmax offers each existing category WITH its description (bare names carried no signal) plus create_category; confirm_category_fit then confirms the winner's scope (phase navigate:category_scope, P(covers) >= category_tau) and a rejected winner authors a new category. The `response` catchall and create_category share a boundary arbitrated by the actionability guard confirm_non_action (phase navigate:actionability, P(non_action) >= action_tau): the closed response tree is reached ONLY when the input is not a request, so a request no skill covers (e.g. \"what is 255 * 12?\") authors instead of getting a canned reply. Leaf: the softmax offers only existing skills; confirm_skill_fit then compares the winner's action to the request (phase navigate:intent, P(same) >= intent_tau) and a mismatch authors a new leaf. All three taus are separate from the top-level tau so tuning reuse-vs-create or actionability does not move run assessment/fidelity. The category check is deliberately permissive: with real descriptions in-scope requests score 0.9-1.0, so a borderline over-cover routes into a plausible category and the leaf guard catches it. A softmax winner at or above `softmax_bypass_tau` (default 0.5) skips its confirm guard — the winner is already decisive and each skipped guard is one fewer SemIf call on the hot path (traced `category_scope_bypassed` / `intent_bypass`); below it the two-stage confirm runs unchanged.", "_comment": "Navigation is two-stage at BOTH levels and the guards are the create doors (no threshold gate). Category: the softmax offers each existing category WITH its description (bare names carried no signal) plus create_category; confirm_category_fit then confirms the winner's scope (phase navigate:category_scope, P(covers) >= category_tau) and a rejected winner authors a new category. The `response` catchall and create_category share a boundary arbitrated by the actionability guard confirm_non_action (phase navigate:actionability, P(non_action) >= action_tau): the closed response tree is reached ONLY when the input is not a request, so a request no skill covers (e.g. \"what is 255 * 12?\") authors instead of getting a canned reply. Leaf: the softmax offers only existing skills; confirm_skill_fit then compares the winner's action to the request (phase navigate:intent, P(same) >= intent_tau) and a mismatch authors a new leaf. All three taus are separate from the top-level tau so tuning reuse-vs-create or actionability does not move run assessment/fidelity. The category check is deliberately permissive: with real descriptions in-scope requests score 0.9-1.0, so a borderline over-cover routes into a plausible category and the leaf guard catches it. A **category** softmax winner at or above `softmax_bypass_tau` (default 0.5) skips the scope confirm (traced `category_scope_bypassed`) — `create_category` is one of its options, so a confident winner really did beat authoring a category. The **leaf** intent guard is never bypassed: the leaf softmax offers only existing skills, so a confident winner is \"best of the wrong lot\", not a match, and the guard is the only leaf-level create door.",
"intent_tau": 0.6, "intent_tau": 0.6,
"category_tau": 0.75, "category_tau": 0.75,
"action_tau": 0.5, "action_tau": 0.5,
+8 -8
View File
@@ -58,15 +58,13 @@ flowchart TD
HASSKILLS -- "none" --> CREATESKILL["CreateSkill"] HASSKILLS -- "none" --> CREATESKILL["CreateSkill"]
HASSKILLS -- "one" --> SOLE["sole skill<br/>softmax skipped"] HASSKILLS -- "one" --> SOLE["sole skill<br/>softmax skipped"]
HASSKILLS -- "many" --> LEAF["SemIf choice<br/>phase 'navigate:leaf'<br/>options = existing skills only"] HASSKILLS -- "many" --> LEAF["SemIf choice<br/>phase 'navigate:leaf'<br/>options = existing skills only"]
LEAF --> PICK["picked skill<br/>+ leaf_softmax_prob"] LEAF --> PICK["picked skill"]
SOLE --> PICK SOLE --> PICK
%% ---------- reuse vs create ---------- %% ---------- reuse vs create ----------
PICK --> HARD{"hard-locked category?<br/>(housekeeping)"} PICK --> HARD{"hard-locked category?<br/>(housekeeping)"}
HARD -- "yes" --> RUN HARD -- "yes" --> RUN
HARD -- "no" --> INTENTBYP{"winner prob >=<br/>softmax_bypass_tau?"} HARD -- "no" --> INTENT["SemIf choice<br/>phase 'navigate:intent'<br/>P same >= intent_tau?"]
INTENTBYP -- "yes (decisive)" --> RUN
INTENTBYP -- "no (unsure)" --> INTENT["SemIf choice<br/>phase 'navigate:intent'<br/>P same >= intent_tau?"]
INTENT -- "same" --> RUN INTENT -- "same" --> RUN
INTENT -- "different" --> CREATESKILL INTENT -- "different" --> CREATESKILL
@@ -196,7 +194,7 @@ flowchart TD
| Category scope | does it cover? | `navigate:category_scope` | descend / create (skipped when decisive) | | Category scope | does it cover? | `navigate:category_scope` | descend / create (skipped when decisive) |
| Canned | which reply | `navigate:response` | canned line | | Canned | which reply | `navigate:response` | canned line |
| Leaf | which skill | `navigate:leaf` | skill | | Leaf | which skill | `navigate:leaf` | skill |
| Intent guard | same action? | `navigate:intent` | run / create (skipped when decisive) | | Intent guard | same action? | `navigate:intent` | run / create (never bypassed) |
| Config record | record or ask? | `config:record` | persisted / per-fire | | Config record | record or ask? | `config:record` | persisted / per-fire |
| Outcome | did it succeed? | `assess:outcome` | ok / failed | | Outcome | did it succeed? | `assess:outcome` | ok / failed |
| Requeue | complete or retry? | `assess:requeue` | done / requeue | | Requeue | complete or retry? | `assess:requeue` | done / requeue |
@@ -214,9 +212,11 @@ first and decides whether the input is an actionable request at all; only
non-action input reaches the closed `response` tree, so a request is never non-action input reaches the closed `response` tree, so a request is never
canned. The category softmax then offers the real categories (never `response`) canned. The category softmax then offers the real categories (never `response`)
plus `create_category`, and the leaf softmax offers only the existing skills — plus `create_category`, and the leaf softmax offers only the existing skills —
the reuse-vs-create decision is the intent guard. A softmax winner at or above the reuse-vs-create decision is the intent guard. A **category** softmax winner
`softmax_bypass_tau` (default 0.5) is already decisive, so its confirm guard at or above `softmax_bypass_tau` (default 0.5) is already decisive, so its scope
(scope/intent) is skipped; below it the guard runs and can reject into create. confirm is skipped; the **leaf** intent guard is never bypassed (the leaf softmax
has no create option, so a confident winner is only the closest existing skill,
never a match) — it always runs and can reject into create.
New-skill creation is also gated deterministically by the per-category New-skill creation is also gated deterministically by the per-category
`locks.new_skill` (the `housekeeping` and `response` categories are hard-locked `locks.new_skill` (the `housekeeping` and `response` categories are hard-locked
in code). in code).
+10 -18
View File
@@ -248,9 +248,10 @@ class Scheduler:
self.intent_tau = float(nav_cfg.get("intent_tau", 0.6)) self.intent_tau = float(nav_cfg.get("intent_tau", 0.6))
self.category_tau = float(nav_cfg.get("category_tau", 0.75)) self.category_tau = float(nav_cfg.get("category_tau", 0.75))
self.action_tau = float(nav_cfg.get("action_tau", 0.5)) self.action_tau = float(nav_cfg.get("action_tau", 0.5))
#: A softmax winner at or above this probability skips its confirm guard #: A **category** softmax winner at or above this probability skips the
#: (scope/intent) — the winner is already decisive. Below it the guard #: category scope confirm — the winner is already decisive. The leaf
#: runs and can reject into create. #: intent guard is never bypassed (the leaf softmax has no create
#: option, so its confidence carries no match signal).
self.bypass_tau = float(nav_cfg.get("softmax_bypass_tau", 0.5)) self.bypass_tau = float(nav_cfg.get("softmax_bypass_tau", 0.5))
self.max_reentries = max_reentries self.max_reentries = max_reentries
self.codegen = codegen self.codegen = codegen
@@ -456,10 +457,6 @@ class Scheduler:
# ---- dispatch ---- # ---- dispatch ----
def _dispatch(self, request: Request) -> DispatchResult: def _dispatch(self, request: Request) -> DispatchResult:
# Clear any confidence a prior dispatch left on the request (meta is
# copied across a requeue); navigation sets it fresh when a leaf softmax
# runs.
request.meta.pop("leaf_softmax_prob", None)
# Explicit housekeeping commands are deterministic: they route straight # Explicit housekeeping commands are deterministic: they route straight
# to the meta skill, bypassing the generic guards (which misread a # to the meta skill, bypassing the generic guards (which misread a
# task-like skill name as the task). Natural-language phrasings still go # task-like skill name as the task). Natural-language phrasings still go
@@ -501,17 +498,12 @@ class Scheduler:
# navigation's pick directly (the meta skill asks for any missing # navigation's pick directly (the meta skill asks for any missing
# target as an input variable). # target as an input variable).
return self._run_skill(navigation, request) return self._run_skill(navigation, request)
leaf_prob = request.meta.pop("leaf_softmax_prob", None) # The leaf softmax offers only existing skills (create_skill is
if leaf_prob is not None and leaf_prob >= self.bypass_tau: # deliberately not an option), so its winner is "the closest existing
# A decisive leaf softmax winner skips the intent confirm. # skill", never a statement that the skill matches. The intent guard is
self.trace.append( # therefore the sole leaf-level create door and is never bypassed: a
"intent_bypass", # confident softmax winner among only-wrong options must still be
request.id, # checked, or codegen can never be reached for an unmatched request.
category=navigation.category,
skill=navigation.name,
prob=leaf_prob,
)
return self._run_skill(navigation, request)
if not confirm_skill_fit( if not confirm_skill_fit(
self.engine, self.log, self.trace, request, navigation, self.intent_tau self.engine, self.log, self.trace, request, navigation, self.intent_tau
): ):
+16 -14
View File
@@ -1171,17 +1171,22 @@ def navigate(
) -> Skill | CreateCategory | CreateSkill: ) -> Skill | CreateCategory | CreateSkill:
"""Descend the tree one SemIf choice per level. Every choice is logged. """Descend the tree one SemIf choice per level. Every choice is logged.
**Confident softmax winners skip their confirm guard.** When the category **A confident category winner skips the scope confirm; the leaf intent
softmax winner's probability is >= `bypass_tau` (default 0.5) the scope guard always runs.** When the category softmax winner's probability is >=
confirm (`confirm_category_fit`) is skipped — the winner is taken as-is `bypass_tau` (default 0.5) the scope confirm (`confirm_category_fit`) is
(traced `category_scope_bypassed`); below it the guard runs and can reject skipped — the winner is taken as-is (traced `category_scope_bypassed`). That
the winner into create. The leaf softmax winner's probability is handed to is sound because `create_category` is one of the category softmax options, so
dispatch (`request.meta["leaf_softmax_prob"]`) so `confirm_skill_fit` is a confident winner genuinely beat "author a new category"; below the threshold
likewise skipped above the threshold (traced `intent_bypass`). The guards the guard runs and can reject the winner into create. The leaf softmax has
exist to catch an unsure softmax; a winner at 0.5+ is already decisive, and **no** create option (`create_skill` is deliberately absent), so its
each skipped guard is one fewer SemIf call on the hot path. Below the probabilities are renormalized over only the existing skills and a confident
threshold the two-stage behavior is unchanged. The recorded data agrees: winner means "best of the wrong lot", not a match. The leaf intent guard
every logged winner >= 0.5 also passed its guard. (`confirm_skill_fit`) is therefore **never** bypassed: it is the sole
leaf-level create door, and skipping it would make codegen unreachable for an
unmatched request. (Regression: with Winnow as the engine, "send a message to
pepper on SimpleX" picked `connect_link` at 0.86 / `next_message` at 0.995,
skipped the guard, and ran a read skill instead of authoring
`simplex.send_message`.)
The **actionability guard** (`confirm_non_action`, phase The **actionability guard** (`confirm_non_action`, phase
`navigate:actionability`, keyed by `navigation.action_tau`) runs at the **top** `navigate:actionability`, keyed by `navigation.action_tau`) runs at the **top**
@@ -1333,9 +1338,6 @@ def navigate(
leaf_result = engine.call(leaf) leaf_result = engine.call(leaf)
log.append(leaf, leaf_result, extra={"phase": "navigate:leaf", "run_id": request.id}) log.append(leaf, leaf_result, extra={"phase": "navigate:leaf", "run_id": request.id})
pick = leaf_result.selected pick = leaf_result.selected
# Hand the winner's confidence to dispatch so it can skip the intent guard
# when the softmax is already decisive (see `navigate` docstring).
request.meta["leaf_softmax_prob"] = float(leaf_result.probs.get(pick, 0.0))
return next((s for s in skills if s.name == pick), skills[0]) return next((s for s in skills if s.name == pick), skills[0])
+1 -1
View File
@@ -9,7 +9,7 @@ and the question becomes its ``instructions``; the server returns a probability
over exactly those keys. over exactly those keys.
Winnow runs as its own process (``winnow-server``); see ``local/ENVIRONMENT.md`` Winnow runs as its own process (``winnow-server``); see ``local/ENVIRONMENT.md``
for the guppy deployment. The engine is real: any network, HTTP, or distribution for this deployment. The engine is real: any network, HTTP, or distribution
failure raises `EngineUnavailable`, which the scheduler treats as fatal — there failure raises `EngineUnavailable`, which the scheduler treats as fatal — there
is no fallback model and no fabricated reply. is no fallback model and no fabricated reply.
""" """
+20 -10
View File
@@ -1015,7 +1015,8 @@ def test_dispatch_intent_tau_controls_reuse_vs_create(tmp_path):
{ {
"top-level category": {"simplex": 1.0}, "top-level category": {"simplex": 1.0},
"Does the scope": {"covers": 1.0}, "Does the scope": {"covers": 1.0},
# Below softmax_bypass_tau (0.5), so the intent guard runs. # The leaf softmax offers only existing skills, so the intent
# guard always runs (it is the create door).
"skill performs": {"next_message": 0.45, "connect_link": 0.3}, "skill performs": {"next_message": 0.45, "connect_link": 0.3},
"same action": {"same": 0.8, "different": 0.2}, "same action": {"same": 0.8, "different": 0.2},
} }
@@ -1127,10 +1128,15 @@ def test_dispatch_intent_match_runs_skill(tmp_path):
assert result.skill == "next_message" assert result.skill == "next_message"
def test_dispatch_confident_leaf_winner_skips_intent_guard(tmp_path): def test_dispatch_confident_leaf_winner_still_runs_intent_guard(tmp_path):
"""A leaf softmax winner at/above `softmax_bypass_tau` skips the intent """A leaf softmax winner at/above `softmax_bypass_tau` does NOT skip the
confirm: the guard would reject here (same action = different), but a intent confirm: the leaf softmax offers only existing skills (no create
decisive softmax runs the skill instead.""" option), so a confident winner is "best of the wrong lot", never a match.
The guard runs and, here, rejects the winner into create_skill.
Regression: with Winnow as the engine a send request picked `connect_link`
at 0.86 / `next_message` at 0.995, the old `intent_bypass` ran a read skill,
and codegen was never reached."""
engine = _ProbEngine( engine = _ProbEngine(
{ {
"top-level category": {"simplex": 1.0}, "top-level category": {"simplex": 1.0},
@@ -1165,12 +1171,16 @@ def test_dispatch_confident_leaf_winner_skips_intent_guard(tmp_path):
Skill(name="connect_link", category="simplex", description="Show the contact link."), Skill(name="connect_link", category="simplex", description="Show the contact link."),
] ]
} }
result = scheduler._dispatch(Request("read the next simplex message")) queued: list = []
assert result.kind == "ran" scheduler._queue_draft = lambda request, category, kind: queued.append(
assert result.skill == "next_message" (category, kind)
assert any(e["kind"] == "intent_bypass" for e in scheduler.trace.read()) )
result = scheduler._dispatch(Request("send a simplex message to pepper"))
assert result.kind == "create_skill"
assert queued == [("simplex", "skill")]
assert not any(e["kind"] == "intent_bypass" for e in scheduler.trace.read())
phases = [r["extra"].get("phase") for r in scheduler.log.read()] phases = [r["extra"].get("phase") for r in scheduler.log.read()]
assert "navigate:intent" not in phases assert "navigate:intent" in phases