fix(rectification): refresh remaining probes and targeted collect before delivering range (BUG-653/654)
Dated-choice exhaustion is not convergence. Refresh probes from remaining active candidates, then ask a targeted collect, then deliver. Skill 10.0.24. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from datetime import date, datetime
|
||||
from scripts.rectification.candidate_contrast import (
|
||||
MIN_DISCRIMINATOR_DOMAINS,
|
||||
MIN_DISCRIMINATOR_EVENTS,
|
||||
PROBE_PHASE_CANDIDATE_DISCRIMINATOR,
|
||||
SIGNATURE_LAYERS,
|
||||
discriminator_gate_open,
|
||||
distinguish_contract_errors,
|
||||
@@ -15,10 +16,16 @@ from scripts.rectification.candidate_contrast import (
|
||||
training_scoreable_stats,
|
||||
)
|
||||
from scripts.rectification.event_probes import (
|
||||
ANSWER_PRIORS,
|
||||
REFRESH_MAX_PROBES,
|
||||
REFRESH_MAX_PROBES_PER_DOMAIN,
|
||||
candidate_contrast_opportunities,
|
||||
discriminating_event_probes,
|
||||
event_clarification_probes,
|
||||
evidence_collection_probes,
|
||||
_dominant_existence_prior,
|
||||
_partition_ranked_probes,
|
||||
_probe_caps,
|
||||
)
|
||||
from scripts.rectification.refinement_packet import window_scan
|
||||
|
||||
@@ -407,6 +414,103 @@ class DiscriminatorContractTest(unittest.TestCase):
|
||||
for probe in probes:
|
||||
self.assertNotIn(f"{probe['domain']}:{probe['year']}", blocked)
|
||||
|
||||
def test_refresh_caps_rise_only_for_five_or_fewer_remaining(self) -> None:
|
||||
self.assertEqual(_probe_caps(refresh=False, remaining_count=5), (8, 3))
|
||||
self.assertEqual(_probe_caps(refresh=True, remaining_count=6), (8, 3))
|
||||
self.assertEqual(
|
||||
_probe_caps(refresh=True, remaining_count=5),
|
||||
(REFRESH_MAX_PROBES, REFRESH_MAX_PROBES_PER_DOMAIN),
|
||||
)
|
||||
|
||||
def test_monthly_family_dasha_boundary_is_ranked_not_dropped(self) -> None:
|
||||
priors = dict(ANSWER_PRIORS[("family", "existence")])
|
||||
probe = {
|
||||
"role": "distinguish",
|
||||
"phase": PROBE_PHASE_CANDIDATE_DISCRIMINATOR,
|
||||
"source": "dasha_boundary",
|
||||
"domain": "family",
|
||||
"year": 2018,
|
||||
"month": 5,
|
||||
"choice_kind": "existence",
|
||||
"information_gain": 0.4,
|
||||
"semantic_key": "family.2018.05",
|
||||
"candidate_ids": ["04:50", "05:06"],
|
||||
"expected_outcomes": [
|
||||
{"answer_class": "yes", "supports": ["04:50"], "conflicts": ["05:06"]},
|
||||
{"answer_class": "no", "supports": ["05:06"], "conflicts": ["04:50"]},
|
||||
],
|
||||
}
|
||||
self.assertFalse(_dominant_existence_prior(probe, priors))
|
||||
public, dropped = _partition_ranked_probes([probe])
|
||||
self.assertEqual([item["semantic_key"] for item in public], ["family.2018.05"])
|
||||
self.assertFalse(any(item.get("reason") == "dominant_answer_prior" for item in dropped))
|
||||
yearless = {**probe, "month": None, "source": "age_band", "year": 0, "semantic_key": "family.age"}
|
||||
self.assertTrue(_dominant_existence_prior(yearless, priors))
|
||||
|
||||
def test_remaining_five_cluster_refresh_keeps_family_monthly_boundary(self) -> None:
|
||||
asked = [
|
||||
"career.2020",
|
||||
"career.2023",
|
||||
"education.2016",
|
||||
"education.2020",
|
||||
"relationship.2023",
|
||||
"relocation.2015",
|
||||
]
|
||||
built = {
|
||||
"static_contexts": [
|
||||
_context("04:48", d4_asc=1, d9_asc=1, d10_asc=1, d12_asc=1, d24_asc=1),
|
||||
_context("04:53", d4_asc=1, d9_asc=2, d10_asc=1, d12_asc=1, d24_asc=1),
|
||||
_context("04:59", d4_asc=1, d9_asc=2, d10_asc=1, d12_asc=1, d24_asc=1),
|
||||
_context("05:06", d4_asc=2, d9_asc=2, d10_asc=3, d12_asc=4, d24_asc=2),
|
||||
_context("05:07", d4_asc=2, d9_asc=2, d10_asc=3, d12_asc=4, d24_asc=3),
|
||||
]
|
||||
}
|
||||
times = ["04:48", "04:53", "04:59", "05:06", "05:07"]
|
||||
request = _request(asked_probe_keys=asked, refresh_probes=True)
|
||||
probes = discriminating_event_probes(
|
||||
request,
|
||||
built,
|
||||
scan=window_scan(built),
|
||||
candidate_times=times,
|
||||
representative_time="04:53",
|
||||
today=date(2026, 9, 11),
|
||||
)
|
||||
self.assertIsInstance(probes, list)
|
||||
family_probe = {
|
||||
"role": "distinguish",
|
||||
"phase": PROBE_PHASE_CANDIDATE_DISCRIMINATOR,
|
||||
"source": "dasha_boundary",
|
||||
"domain": "family",
|
||||
"year": 2018,
|
||||
"month": 5,
|
||||
"choice_kind": "existence",
|
||||
"information_gain": 0.42,
|
||||
"semantic_key": "family.2018.05.dasha_boundary",
|
||||
"candidate_ids": times,
|
||||
"expected_outcomes": [
|
||||
{"answer_class": "yes", "supports": ["04:48", "04:53"], "conflicts": ["05:06", "05:07"]},
|
||||
{"answer_class": "no", "supports": ["05:06", "05:07"], "conflicts": ["04:48", "04:53"]},
|
||||
],
|
||||
}
|
||||
public, dropped = _partition_ranked_probes(
|
||||
[family_probe, *probes],
|
||||
max_probes=REFRESH_MAX_PROBES,
|
||||
)
|
||||
family = [
|
||||
item
|
||||
for item in public
|
||||
if item.get("domain") == "family"
|
||||
and item.get("source") == "dasha_boundary"
|
||||
and isinstance(item.get("month"), int)
|
||||
]
|
||||
self.assertTrue(family, [item.get("semantic_key") for item in public])
|
||||
self.assertTrue(all(1 <= int(item["month"]) <= 12 for item in family))
|
||||
self.assertFalse(any(
|
||||
item.get("semantic_key") == "family.2018.05.dasha_boundary"
|
||||
and item.get("reason") == "dominant_answer_prior"
|
||||
for item in dropped
|
||||
))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user