Let controller resolve unavailable hypothesis switch recommendations
This commit is contained in:
1 parent
930cab243d
commit
85670cc9fd
8 files changed
+5048
-7
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -117,11 +117,8 @@ def wire(context,reply):
|
||||
raise InvestigationError('INVESTIGATION_MEMORY_LIMIT',feedback={'requirement':'consolidate_redundant_findings_with_explicit_retirements_preserve_counterevidence'})
|
||||
nxt=copy.deepcopy(reply['next'])
|
||||
if nxt['kind']=='switch':
|
||||
target=nxt['hypothesis_id'];h=context['hypotheses'].get(target)
|
||||
from viano_bug_analysis.budget.engine import TERMINAL
|
||||
if (target==context['selected_hypothesis'] or h is None or h['disposition']!='active'
|
||||
or context['budget']['accounts'][target]['status'] in TERMINAL):
|
||||
raise InvestigationError('INVESTIGATION_SWITCH_TARGET',feedback={'requirement':'choose_another_active_hypothesis_with_available_budget'})
|
||||
# Switching is a scheduling recommendation, not a semantic finding.
|
||||
# The controller resolves unavailable targets after accepting the review.
|
||||
nxt={'kind':'defer','reason':nxt['reason']}
|
||||
return {'assessment':copy.deepcopy(reply['assessment']),'next':nxt,
|
||||
'update':{'confidence':reply['confidence'],'add_questions':[],'resolve_questions':[],
|
||||
|
||||
@@ -204,6 +204,14 @@ def project(request, context):
|
||||
'hypothesis', 'alternatives', 'previous_result', 'checkpoint_intent',
|
||||
'early_review', 'previous_rejection', 'previous_rejection_details','database_query_failures','database_access') if k in inp}
|
||||
view['case'] = inp.get('case', {})
|
||||
if context.get('switch_routing_version') == 1:
|
||||
from viano_bug_analysis.budget.engine import TERMINAL
|
||||
view['hypothesis_overview'] = [
|
||||
{'id': other, 'title': h['proposal']['title'][:120],
|
||||
'confidence': h['confidence'], 'status': context['budget']['accounts'][other]['status'],
|
||||
'eligible': h['disposition']=='active' and context['budget']['accounts'][other]['status'] not in TERMINAL
|
||||
and h['iterations']<context['policy']['max_iterations_per_hypothesis']}
|
||||
for other,h in context['hypotheses'].items() if other!=context['selected_hypothesis']]
|
||||
if 'hypothesis' not in view:
|
||||
hid = context['selected_hypothesis']
|
||||
view['hypothesis'] = {'id': hid, 'proposal': {k: context['hypotheses'][hid]['proposal'][k]
|
||||
|
||||
@@ -330,6 +330,7 @@ class Investigator:
|
||||
if failures:
|
||||
context['database_query_failures'] = failures
|
||||
if len(json_bytes(context))>self.limits.max_context_bytes:raise InvestigationError("INVESTIGATION_CONTEXT_LIMIT")
|
||||
context['switch_routing_version'] = 1
|
||||
validate(context,"investigation-context")
|
||||
return context
|
||||
|
||||
@@ -975,13 +976,24 @@ class Investigator:
|
||||
if kind != 'recall' and context['policy'].get('prompt_window_version') in {1,2}:
|
||||
state.get('recalled_evidence', {}).pop(hid, None)
|
||||
state.get('recalled_pages', {}).pop(hid, None)
|
||||
switch_note=None
|
||||
if 'lean_session' in context:
|
||||
from .investigation_lean import checkpoint
|
||||
if checkpoint(context):
|
||||
if kind != 'recall' or context['policy'].get('prompt_window_version') == 2:
|
||||
h['lean_session']={'turns':[],'checkpoint':False}
|
||||
if call['outcome']['document']['next']['kind']=='switch':
|
||||
state['lean_preferred_hypothesis']=call['outcome']['document']['next']['hypothesis_id']
|
||||
from .investigation_scheduler import priority_order
|
||||
accounts=budget.snapshot(case_id,package_id).state['accounts']
|
||||
eligible=[other for _,other in priority_order(state['hypotheses'])
|
||||
if other!=hid and state['hypotheses'][other]['disposition']=='active'
|
||||
and accounts[other]['status'] not in TERMINAL
|
||||
and state['hypotheses'][other]['iterations']<state['policy']['max_iterations_per_hypothesis']]
|
||||
requested=call['outcome']['document']['next']['hypothesis_id']
|
||||
chosen=requested if requested in eligible else next(iter(eligible),None)
|
||||
state.pop('lean_preferred_hypothesis',None)
|
||||
if chosen:state['lean_preferred_hypothesis']=chosen
|
||||
switch_note=f" [Controller: switch requested {requested}; scheduled {chosen or 'no eligible sibling'}.]"
|
||||
else:
|
||||
raw=call['outcome']['document']
|
||||
session=h.setdefault('lean_session',{'turns':[],'checkpoint':False})
|
||||
@@ -999,6 +1011,7 @@ class Investigator:
|
||||
if q["id"] in update["resolve_questions"]:q["resolved"]=True
|
||||
for text in update["add_questions"]:h["questions"].append({"id":f"Q{len(h['questions'])+1:04d}","text":text,"resolved":False})
|
||||
note={"kind":"assessment","text":update["note"],"llm_ref":active["llm_ref"]}
|
||||
if switch_note:note['text'] += switch_note
|
||||
if skipped_action:
|
||||
note['text'] += f" [Controller: proposed research not executed; {terminal_status}.]"
|
||||
if 'causal_review' in update:
|
||||
|
||||
@@ -948,6 +948,9 @@
|
||||
},
|
||||
"database_access_version": {
|
||||
"const": 1
|
||||
},
|
||||
"switch_routing_version": {
|
||||
"const": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# BUG-23 terminal consolidation requests unavailable switch
|
||||
|
||||
Generation 539. H1 correctly exhausted at 4 units after the previous controller fix. H2 and H3 terminated for low information gain (remaining 27 and 34). During H2 final lean consolidation, three structurally valid replies requested switching to exhausted H1 and were rejected with INVESTIGATION_SWITCH_TARGET. The bounded user input contains only the selected hypothesis, without a catalog of eligible switch targets. Correction feedback requires another active hypothesis despite none being available. The final consolidation findings remain uncommitted. This is a lifecycle/prompt contract mismatch; it does not justify reopening or increasing hypothesis budgets.
|
||||
|
||||
Proposed correction: expose a compact controller-owned list of eligible switch targets and finalization-only state; give actionable feedback when no target exists. Preserve a fully validated final consolidation when the only impossible intent is switching to a known terminal sibling, handing scheduling back to the controller with an audit record. Invalid evidence and unknown action kinds must still fail validation; target identity is only a scheduling recommendation. Do not interpret budget exhaustion as causal rejection. Cover all-terminal consolidation, one eligible sibling, unknown/self targets, resume and no budget reset.
|
||||
|
||||
Implemented: structurally valid switch recommendations normalize to defer regardless of target availability. After full semantic validation and consolidation, the controller honors an eligible target or chooses a sibling using scheduler priority. With no eligible sibling, the existing terminal scheduler concludes after flushing dirty sessions. No budget is reset and no corrective model call is needed for scheduling alone. Invalid evidence and unknown action kinds remain validation errors. A versioned compact overview exposes sibling title, confidence, account status and eligibility in new bounded prompts; frozen old requests remain unchanged. Tests cover self/unavailable and unknown recommendations, fallback to H2, all-terminal completion, and crash/resume after settlement.
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
{
|
||||
"selected_hypothesis": "H2",
|
||||
"hypotheses": {
|
||||
"H1": {
|
||||
"disposition": "budget_exhausted",
|
||||
"iterations": 22,
|
||||
"confidence": "plausible"
|
||||
},
|
||||
"H2": {
|
||||
"disposition": "abandoned_low_information_gain",
|
||||
"iterations": 35,
|
||||
"confidence": "weakened"
|
||||
},
|
||||
"H3": {
|
||||
"disposition": "abandoned_low_information_gain",
|
||||
"iterations": 17,
|
||||
"confidence": "plausible"
|
||||
}
|
||||
},
|
||||
"accounts": {
|
||||
"H1": {
|
||||
"status": "budget_exhausted",
|
||||
"remaining": 4,
|
||||
"low_information_steps": 0
|
||||
},
|
||||
"H2": {
|
||||
"status": "abandoned_low_information_gain",
|
||||
"remaining": 27,
|
||||
"low_information_steps": 3
|
||||
},
|
||||
"H3": {
|
||||
"status": "abandoned_low_information_gain",
|
||||
"remaining": 34,
|
||||
"low_information_steps": 3
|
||||
}
|
||||
},
|
||||
"rejected": [
|
||||
{
|
||||
"ref": "llm/operations/646b80a1399471dd87e7a92a232513eb99408a1304b4af6c6b0aea45748bbc2b/round-0001.json",
|
||||
"response": {
|
||||
"assessment": null,
|
||||
"confidence": "weakened",
|
||||
"findings": [
|
||||
{
|
||||
"direction": "against",
|
||||
"evidence_refs": [
|
||||
"E000006"
|
||||
],
|
||||
"text": "Hypothesis H2 solely addresses creature 44329 spawn/summon logic, but quest 26922 requires both slaying Scourge Bone Animus Bunny (44360) and Stickbone Berserkers (44329), and tester reproduction confirmed throwing the grenade at the animus produces no effect."
|
||||
},
|
||||
{
|
||||
"direction": "support",
|
||||
"evidence_refs": [
|
||||
"E000002"
|
||||
],
|
||||
"text": "Creature 44329 (Stickbone Berserker) exists in creature_template but has 0 records in the creature table, confirming no static spawns exist in the world."
|
||||
},
|
||||
{
|
||||
"direction": "support",
|
||||
"evidence_refs": [
|
||||
"E000006"
|
||||
],
|
||||
"text": "Quest 26922 explicitly requires slaying 1 Scourge Bone Animus Bunny (44360) and 5 Stickbone Berserkers (44329), but neither has smart_scripts entries and Stickbone Berserker has no static spawns."
|
||||
},
|
||||
{
|
||||
"direction": "support",
|
||||
"evidence_refs": [
|
||||
"E000020"
|
||||
],
|
||||
"text": "Source search for 44329 shows creature template updates in historical SQL updates, but no static spawns or summoning script implementations."
|
||||
},
|
||||
{
|
||||
"direction": "support",
|
||||
"evidence_refs": [
|
||||
"E000022"
|
||||
],
|
||||
"text": "In sql/old/4.3.4/TDB00_to_TDB01_updates/world/114_western_plaguelands.sql, creature 44360 (Scourge Bone Animus Bunny) only receives an addon entry with aura 82880, confirming no script or summon handling is configured there."
|
||||
}
|
||||
],
|
||||
"next": {
|
||||
"hypothesis_id": "H1",
|
||||
"kind": "switch",
|
||||
"reason": "H2 fails to account for the primary defect where throwing Jearl's Hand Grenade (item 60678) at Scourge Bone Animus Bunny (44360) produces no effect. Switching to H1 to investigate the grenade spell script."
|
||||
},
|
||||
"next_question": "What spell is cast by item 60678 and how is its spell script implemented to handle animus destruction and berserker summoning?",
|
||||
"retire": [],
|
||||
"uncertainties": [
|
||||
"The spell ID cast by item 60678 (Jearl's Hand Grenade) and whether its spell script is missing or fails to interact with creature 44360 and summon creature 44329."
|
||||
]
|
||||
},
|
||||
"feedback": {
|
||||
"previous_rejection": null,
|
||||
"previous_rejection_details": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"ref": "llm/operations/170998a0ef06e87edc1e25b8b7ff4748a1b49b6172a82a721d46811f5f45941d/round-0001.json",
|
||||
"response": {
|
||||
"assessment": null,
|
||||
"confidence": "weakened",
|
||||
"findings": [
|
||||
{
|
||||
"direction": "against",
|
||||
"evidence_refs": [
|
||||
"E000006"
|
||||
],
|
||||
"text": "Quest 26922 requires both destroying Scourge Bone Animus Bunny (44360) and slaying Stickbone Berserkers (44329). Tester reproduction established that throwing the grenade produces no effect on the animus, which is not accounted for by creature 44329 spawn/summon logic alone."
|
||||
},
|
||||
{
|
||||
"direction": "support",
|
||||
"evidence_refs": [
|
||||
"E000002"
|
||||
],
|
||||
"text": "Creature 44329 (Stickbone Berserker) exists in creature_template but has 0 records in the creature table, confirming no static spawns exist in the world."
|
||||
}
|
||||
],
|
||||
"next": {
|
||||
"hypothesis_id": "H1",
|
||||
"kind": "switch",
|
||||
"reason": "Switching to H1 to investigate the missing grenade spell script for item 60678, which is required to destroy the animus and handle quest progression."
|
||||
},
|
||||
"next_question": "Does the grenade spell script for item 60678 handle destroying creature 44360 and summoning creature 44329?",
|
||||
"retire": [],
|
||||
"uncertainties": [
|
||||
"The spell ID associated with item 60678 and how the grenade spell interacts with creature 44360 or summons creature 44329."
|
||||
]
|
||||
},
|
||||
"feedback": {
|
||||
"previous_rejection": "INVESTIGATION_SWITCH_TARGET",
|
||||
"previous_rejection_details": {
|
||||
"requirement": "choose_another_active_hypothesis_with_available_budget"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ref": "llm/operations/c17739a9564f5467a9babf63a6119168ac6c155c334f7c9a46c35419891e75da/round-0001.json",
|
||||
"response": {
|
||||
"assessment": null,
|
||||
"confidence": "weakened",
|
||||
"findings": [
|
||||
{
|
||||
"direction": "against",
|
||||
"evidence_refs": [
|
||||
"E000006"
|
||||
],
|
||||
"text": "Hypothesis H2 focuses solely on creature 44329 spawn/summon logic, failing to explain why throwing Jearl's Hand Grenades has no effect on Scourge Bone Animus Bunny (creature 44360), which is quest objective 1."
|
||||
}
|
||||
],
|
||||
"next": {
|
||||
"hypothesis_id": "H1",
|
||||
"kind": "switch",
|
||||
"reason": "Switching to active hypothesis H1 to investigate the grenade spell script for item 60678 and quest 26922, addressing both the animus interaction and Stickbone Berserker spawning."
|
||||
},
|
||||
"next_question": "How is the grenade spell configured and scripted for quest 26922?",
|
||||
"retire": [],
|
||||
"uncertainties": [
|
||||
"Whether the grenade spell script (hypothesis H1) handles both destroying creature 44360 and summoning creature 44329."
|
||||
]
|
||||
},
|
||||
"feedback": {
|
||||
"previous_rejection": "INVESTIGATION_SWITCH_TARGET",
|
||||
"previous_rejection_details": {
|
||||
"requirement": "choose_another_active_hypothesis_with_available_budget"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -248,7 +248,9 @@ def test_terminal_settlement_preserves_observation_and_skips_followup(tool_case,
|
||||
else:
|
||||
out={'assessment':assessment,'confidence':'plausible','findings':[],
|
||||
'uncertainties':['Cause remains unconfirmed.'],'next_question':None,
|
||||
'retire':[],'next':{'kind':'finish','reason':'No further funded research.'}}
|
||||
'retire':[],'next':{'kind':'switch',
|
||||
'hypothesis_id':'H9999' if body['input']['hypothesis']['id']=='H3' else 'H1',
|
||||
'reason':'Investigate another hypothesis.'}}
|
||||
return ProviderResponse(out,'fixture',100,50)
|
||||
adapter=Continue()
|
||||
config=BudgetConfig(default_action_cost=40)
|
||||
@@ -281,6 +283,9 @@ def test_terminal_settlement_preserves_observation_and_skips_followup(tool_case,
|
||||
checkpoints=[b for b in adapter.calls if b['task']=='consolidate_investigation_session']
|
||||
assert len(checkpoints)==3
|
||||
assert all('Preserve this last observation.' in json.dumps(b) for b in checkpoints)
|
||||
assert all('hypothesis_overview' in b['input'] for b in checkpoints)
|
||||
assert any('no eligible sibling' in n['text'] for h in state(result)['hypotheses'].values() for n in h['notes'])
|
||||
assert any('switch requested H1; scheduled H2' in n['text'] for n in state(result)['hypotheses']['H1']['notes'])
|
||||
count=len(adapter.calls)
|
||||
assert run(loop).package==result.package and len(adapter.calls)==count
|
||||
assert PackageValidator().validate(result.package).valid
|
||||
|
||||
Reference in new issue
Block a user