fix(learn): withhold label-tracking signals from the v1 classifier; leak audit

Maintainer decision "Neutralise both for v1".

1. Phantom candidates. A pair side's candidates are now only the functions that
   side declares (plane/harvest.py `declares`, the excerpt builder's
   function_bounds); a labelled function absent from a side is listed under
   `absent_on_side` and never asked, and a side declaring none of its verify
   family's functions is no verify unit. The recorded harvest units held 58
   phantom verify candidates (53 fixed, 5 vulnerable sides). build_features.py
   skips label rows whose side does not declare the function and drops their
   earlier rows (MemoryStore.drop_rows); rebuilt the pair records from the
   recorded signals, no model call: 126 label rows absent_on_side (117 fixed,
   9 vulnerable) -- access_control 13, config_secrets 4, deserialization 20,
   injection 28, memory 4, output_encoding 16, path 15, untrusted_destination
   26 -- so 252 feature rows dropped (1712 -> 1460); no other row changed.

2. Engine withheld. Input profiles in learn/schema.py (`v1` withholds the
   engine instrument, `full` withholds nothing); ProgramSpec.inputs defaults to
   v1 and compile.toml records it. Neither the engine's state nor its values
   reach the candidate, examples, demonstrations or the instruction proposer's
   error summary, and the Gower retrieval distance leaves the engine block out.
   Stored records are unchanged. design.md Risks records the decision and that
   the engine returns only through a pre-registered A/B on assumed-benign and
   benign-control negatives.

3. `ousast learn audit-leaks` (learn/leaks.py): per feature and per instrument
   state, separation = (pairs the signal alone puts on the right side - on the
   wrong side) / pairs, over all pairs and per family; flagged at >= 0.20 over
   >= 10 pairs. Counts under
   benchmarks/measurements/2026-10-01-decision-engine-leak-audit/ (before and
   after the rebuild). After: facts.function_lines (0.80 untrusted_destination,
   0.75 config_secrets, 0.26 injection; higher on fixed), verify.turns_mean
   0.67 config_secrets, eng.* 0.35-0.40 output_encoding, verify.flag_a/votes/
   site_offset and agree.final 0.20-0.30 on 10-12 pair families. Before the
   rebuild the phantom fixed sides drove state.source/state.roles/ms.flagged
   to 1.0 and state.engine to 0.95 on deserialization.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
Marius Ciepluch
2026-10-01 19:40:58 +02:00
co-authored by Claude Opus 5.5
parent 4c96a59f8f
commit 9e3c83cfdc
20 changed files with 12062 additions and 35 deletions
+32 -1
View File
@@ -75,11 +75,42 @@ def test_prompts_hold_no_excluded_field_and_no_candidate_label() -> None:
def test_missing_instruments_are_said_in_words() -> None:
prompt, _ = program().prepare(candidate(engine="none"), FOLD)
prompt, _ = program(inputs="full").prepare(candidate(engine="none"), FOLD)
tail = str(prompt.messages[-1]["content"]).rsplit("Candidate:\n", 1)[1]
assert "engine: no coverage" in tail and "delta: not applicable" in tail and "eng.findings" not in tail
ENGINE_FIELD = re.compile(r"^(engine:|eng\.)", re.MULTILINE)
@pytest.mark.parametrize("engine", ["ran", "failed", "none"])
def test_v1_prompts_contain_no_engine_field(engine: str) -> None:
"""v1 (the default input profile) withholds the engine -- state and values -- from every rendered message: the
candidate, the retrieved examples and the demonstrations, as the scripted client receives them."""
assert ProgramSpec().inputs == "v1"
demo_example = EXAMPLES[0]
demo = Demo(demo_example.id, demo_example.excerpt_sha, 0, "injection", "not_vulnerable", 0.8, "Line 11 escapes q.", (11,))
chat = ScriptedChat()
caller = Caller(MeteredClient(chat, prices=PRICES), "deepseek-flash", PRICES)
program(demos=(demo,), k=2).decide(candidate(engine=engine, findings=2 if engine == "ran" else 0), FOLD, caller)
assert len(chat.calls) == 2
for call in chat.calls:
text = "\n".join(str(m["content"]) for m in call["messages"])
assert "Demonstration 1:" in text and text.count("(label: ") == 6 and "Candidate:" in text
assert not ENGINE_FIELD.search(text), ENGINE_FIELD.search(text)
assert "qr.enabled_hits:" in text and "delta: not applicable" in text # the other instruments still show
full, _ = program(demos=(demo,), inputs="full").prepare(candidate(engine=engine), FOLD)
assert ENGINE_FIELD.search("\n".join(str(m["content"]) for m in full.messages))
def test_v1_proposer_summary_contains_no_engine_field() -> None:
from openultrasast.learn.compile import _signal_summary
leaky = replace(EXAMPLES[0], **{k: v for k, v in x_record(hits=2, findings=3).items() if k in ("x", "instruments")})
assert not any(k.startswith("eng.") for k in _signal_summary(leaky))
assert any(k.startswith("eng.") for k in _signal_summary(leaky, "full"))
def test_the_prefix_is_byte_identical_across_candidates() -> None:
demo_example = EXAMPLES[0]
demo = Demo(demo_example.id, demo_example.excerpt_sha, 0, "injection", "not_vulnerable", 0.8, "Line 11 escapes q.", (11,))