Share failed table lookups and recover redundant tool discriminators
This commit is contained in:
1 parent
8f833761b1
commit
7cef55d21e
14 files changed
+1747
-5
No files matched your search
@@ -0,0 +1,52 @@
|
||||
# BUG-000023: Gemeinsame Tabellenhinweise und redundantes Aktionsfeld
|
||||
|
||||
Generation 183 wurde in H1, Iteration 7 nach drei unterschiedlichen Ablehnungen
|
||||
blockiert: inkonsistent maskiertes JSON, fehlendes next.kind und anschließend
|
||||
PROJECT_DATABASE_TABLE_UNKNOWN für database.schema / item_template. Der letzte
|
||||
Fehler wurde korrekt als ungültiger Rechercheauftrag behandelt, nicht als Ausfall
|
||||
der Datenbank. Seine präzise Rückmeldung war gespeichert, aber die gemeinsame
|
||||
Grenze für ungültige Antworten war bereits ausgeschöpft.
|
||||
|
||||
Neue Untersuchungskontexte und Korrekturkontexte erhalten nun einen gemeinsamen
|
||||
Bestand früherer fehlgeschlagener Tabellenzugriffe aus den Notizen aller
|
||||
Hypothesen derselben Untersuchungsrevision. Höchstens 32 ausgewählte Call-Records
|
||||
werden gelesen, höchstens acht deduplizierte Datenbank-/Tabellenpaare angezeigt.
|
||||
Die Reihenfolge stammt aus der archivierten Ablagefolge. Es werden nur sichere
|
||||
Bezeichner übernommen, keine Filterwerte, SQL-Fehlertexte oder Zugangsdaten.
|
||||
Tabellennamen werden anhand der gebundenen Standarddatenbank beziehungsweise
|
||||
ihrer expliziten Qualifizierung eingeordnet. Kompakte, schlanke und begrenzte
|
||||
Promptansichten erhalten die Hinweise. Bereits gespeicherte Kontexte und Requests
|
||||
bleiben unverändert.
|
||||
|
||||
Die Hinweise sind keine fachlichen Belege und kein Beweis physischer
|
||||
Nichtexistenz. Sie fordern die KI auf, solche Tabellen erst nach neuer
|
||||
Katalog-/Schemabestätigung erneut zu verwenden und ansonsten verfügbare Tabellen
|
||||
oder Source-/Paketdaten zu untersuchen. Es erfolgt keine automatische Auswahl
|
||||
einer anderen Datenbank oder Tabelle und keine Erweiterung von Zugriffsrechten.
|
||||
Die Anweisung verbessert die Kontextkontinuität, garantiert aber nicht das
|
||||
künftige Verhalten der LLM.
|
||||
|
||||
Die opt-in Antwortnormalisierung für Window-v2-Untersuchungen kann jetzt ein
|
||||
fehlendes next.kind=tool ergänzen, wenn next ausschließlich die bereits explizite
|
||||
Operation project.query und vollständige Argumente enthält. Die Argumente müssen
|
||||
den kanonischen Projektquery-Vertrag erfüllen, die ergänzte Gesamtantwort das
|
||||
Ausgabeschema. Es werden keine expliziten Aktionswerte überschrieben, unbekannte
|
||||
Operationen ergänzt oder fehlende Abfrageparameter erfunden. Weitere Controller-
|
||||
und Belegprüfungen bleiben erforderlich. Originalantwort und Normalisierungsregel
|
||||
werden protokolliert; ein Format-Hinweis wird im regulären Folgekontext mitgegeben.
|
||||
|
||||
Die aufgezeichnete zweite Antwort von Generation 183 besteht diese Reparatur.
|
||||
Die erste Antwort mit inkonsistenter Maskierung bleibt abgelehnt. Die Reparatur
|
||||
eines Darstellungsfeldes legitimiert keine Abfrage einer nicht vorhandenen Tabelle.
|
||||
|
||||
84 lokale Tests zu Antwortreparatur, Tool-Guidance, Window-v2-Verträgen und
|
||||
Promptfenstern bestanden. Enthalten sind der reale kuratierte Ablehnungsfall,
|
||||
unbekannte Operationen, zusätzliche Absichtsfelder, unvollständige oder unzulässige
|
||||
Argumente, einmalige Toolausführung mit Audit sowie der tatsächliche Scheduler-
|
||||
Wechsel von H1 zu H2 mit erhaltenem Tabellenhinweis. Keine kostenpflichtigen
|
||||
LLM-Aufrufe. Die bestehenden Wiederholungsgrenzen werden nicht erhöht und eine
|
||||
bereits bestehende Sperre wird nicht automatisch aufgehoben.
|
||||
|
||||
Die neue Verbrauchsbilanz steht in token-usage/bug23-blocked-g00000183-20261120.json.
|
||||
Die älteren Snapshots bleiben erhalten. Die drei ausgewählten Antworten und der
|
||||
zugehörige Ausgabe-Vertrag sind im kuratierten Fehlerkorpus 20261120 gesichert.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -225,7 +225,7 @@ def model_view(context):
|
||||
'confidence':h['confidence'],'disposition':h['disposition']}
|
||||
if brief is None:
|
||||
view['hypotheses'][selected]['legacy_notes']=copy.deepcopy(hypotheses[selected].get('notes',[]))
|
||||
for field in ('previous_rejection','previous_rejection_details'):
|
||||
for field in ('previous_rejection','previous_rejection_details','database_query_failures'):
|
||||
if field in context:view[field]=copy.deepcopy(context[field])
|
||||
return consolidate_origins(view) if context.get('prompt_version') in {'investigation_project_v16','investigation_project_v17','investigation_project_v18'} else view
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ def build(context):
|
||||
'known_schemas':schemas,
|
||||
'evidence_catalog':view['evidence_catalog'],'archive_ids':view['archive_ids'],
|
||||
'budget':view['budget'],
|
||||
**{k:view[k] for k in ('shared_metadata','previous_rejection','previous_rejection_details') if k in view}},
|
||||
**{k:view[k] for k in ('shared_metadata','previous_rejection','previous_rejection_details','database_query_failures') if k in view}},
|
||||
'output_schema':contract}
|
||||
# Keep actual argument contracts in the stable prefix, not inferred from
|
||||
# prose. No arbitrary SQL or shell is added by the lean protocol.
|
||||
|
||||
@@ -202,7 +202,7 @@ def project(request, context):
|
||||
# Keep the separately validated output schema; describe the strict shape once.
|
||||
view = {k: copy.deepcopy(inp[k]) for k in (
|
||||
'hypothesis', 'alternatives', 'previous_result', 'checkpoint_intent',
|
||||
'early_review', 'previous_rejection', 'previous_rejection_details') if k in inp}
|
||||
'early_review', 'previous_rejection', 'previous_rejection_details','database_query_failures') if k in inp}
|
||||
view['case'] = inp.get('case', {})
|
||||
if 'hypothesis' not in view:
|
||||
hid = context['selected_hypothesis']
|
||||
|
||||
@@ -322,6 +322,11 @@ class Investigator:
|
||||
if raw_size > 4000 or len(json_bytes(session.get('turns', []))) > 2000:
|
||||
session['checkpoint'] = True
|
||||
session['intent'] = 'review'
|
||||
with PackageReader(self._latest(state['case_id'],state['package_id']),self.store.limits) as reader:
|
||||
from .tool_guidance import database_failure_history
|
||||
failures = database_failure_history(reader,state,context,self._read)
|
||||
if failures:
|
||||
context['database_query_failures'] = failures
|
||||
if len(json_bytes(context))>self.limits.max_context_bytes:raise InvestigationError("INVESTIGATION_CONTEXT_LIMIT")
|
||||
validate(context,"investigation-context")
|
||||
return context
|
||||
@@ -805,6 +810,11 @@ class Investigator:
|
||||
detail = database_rejection_feedback(code, outcome.get('document', outcome.get('rejected_document')), context)
|
||||
if detail:
|
||||
context['previous_rejection_details'] = detail
|
||||
with PackageReader(self._latest(state['case_id'],state['package_id']),self.store.limits) as reader:
|
||||
from .tool_guidance import database_failure_history
|
||||
failures = database_failure_history(reader,state,context,self._read)
|
||||
if failures:
|
||||
context['database_query_failures'] = failures
|
||||
active["context_ref"]=f"analysis/investigation/{state['analysis_revision']:04d}/contexts/{active['hypothesis_id']}-{active['iteration']:04d}-attempt-{active['attempt']:04d}.json"
|
||||
state,result=self._save(state,context=context)
|
||||
self.runner.logger.error("Investigation response rejected case_id=%s code=%s",state["case_id"],code)
|
||||
|
||||
@@ -3,6 +3,28 @@ import copy
|
||||
import re
|
||||
|
||||
|
||||
def database_failure_history(reader, state, context, read_call):
|
||||
"""Bounded operational hints across hypotheses, never causal evidence."""
|
||||
refs = {n['llm_ref'] for h in state['hypotheses'].values() for n in h.get('notes', [])
|
||||
if n.get('kind') == 'invalid_response' and n.get('code') == 'PROJECT_DATABASE_TABLE_UNKNOWN'
|
||||
and isinstance(n.get('llm_ref'), str)}
|
||||
ordered = [n for n in reader._archive.namelist() if n in refs][-32:]
|
||||
entries = {}
|
||||
for ref in ordered:
|
||||
call = read_call(reader, ref, 'llm-call')
|
||||
outcome = call.get('outcome', {})
|
||||
detail = database_rejection_feedback('PROJECT_DATABASE_TABLE_UNKNOWN',
|
||||
outcome.get('document', outcome.get('rejected_document')), context)
|
||||
if not detail:
|
||||
continue
|
||||
table = detail['rejected_table'].split('.')[-1]
|
||||
database = detail.get('selected_database')
|
||||
identity = (database, table)
|
||||
entries.pop(identity, None)
|
||||
entries[identity] = {'table': table, 'database': database}
|
||||
return list(entries.values())[-8:]
|
||||
|
||||
|
||||
def database_rejection_feedback(code, document, context):
|
||||
"""Safe identifiers only; never copy SQL errors, credentials or filter values."""
|
||||
if code not in {'PROJECT_DATABASE_TABLE_UNKNOWN', 'PROJECT_DATABASE_COLUMN_UNKNOWN'}:
|
||||
@@ -94,4 +116,9 @@ def instructions(context):
|
||||
'Replace the illustrative column/value with schema-verified, case-grounded inputs. '
|
||||
'Never emit [] or flatten an object into ["column",...,"operator",...,"value",...]. '
|
||||
'Input compression encodings do not apply to output: return ordinary JSON objects.\n')
|
||||
if context.get('database_query_failures'):
|
||||
text += ('database_query_failures lists earlier failed metadata lookups across hypotheses, not causal evidence. '
|
||||
'Do not reuse those database/table pairs without new catalog/schema evidence that they are available. '
|
||||
'Use database.tables to discover permitted alternatives, then inspect their actual schema, or use source/package data. '
|
||||
'A failed lookup is not proof that the underlying bug has a missing implementation.\n')
|
||||
return text
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Bounded, opt-in format recovery. Never infer evidence, actions or missing values."""
|
||||
"""Bounded, opt-in format recovery. Never invent evidence, tool intent or data."""
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
@@ -73,8 +73,27 @@ def normalize(document, *, request=None):
|
||||
return value
|
||||
result=visit(result)
|
||||
action=result.get('next',{});args=action.get('arguments',{}) if isinstance(action,dict) else {}
|
||||
# project.query explicitly states the tool intent. Restore only its
|
||||
# redundant missing discriminator when the contract admits exactly one
|
||||
# complete response. Never replace an explicit (even invalid) kind.
|
||||
if (request and enabled(request) and request.get('output_schema',{}).get('x-viano-investigation-window') == 2
|
||||
and isinstance(action,dict) and set(action) == {'operation','arguments'}
|
||||
and action['operation'] == 'project.query' and isinstance(args,dict)):
|
||||
from jsonschema import Draft202012Validator
|
||||
from importlib.resources import files
|
||||
query_contract = json.loads(files('viano_bug_analysis.schemas').joinpath('project-query-v1.schema.json').read_text())
|
||||
candidate = copy.deepcopy(result)
|
||||
candidate['next']['kind'] = 'tool'
|
||||
# The provider may use a relaxed schema. Validate the query against
|
||||
# the canonical primitive contract too; unknown operations/fields and
|
||||
# incomplete arguments must not become executable through this repair.
|
||||
if (Draft202012Validator(query_contract).is_valid(args)
|
||||
and Draft202012Validator(request['output_schema']).is_valid(candidate)):
|
||||
result = candidate
|
||||
action = result['next'];args = action['arguments']
|
||||
rules.append('restore_redundant_tool_kind:/next/kind')
|
||||
# Versioned, narrow container recovery. Never choose among queries, add a
|
||||
# discriminator, infer an ID, flatten unknown fields or change action intent.
|
||||
# new action intent, infer an ID, flatten unknown fields or change data.
|
||||
# The controller must still validate the entire normalized answer before any
|
||||
# budget or research side effect. Original text/document remain in the audit.
|
||||
if (request and enabled(request) and request.get('output_schema',{}).get('x-viano-investigation-window') == 2
|
||||
|
||||
@@ -917,6 +917,34 @@
|
||||
},
|
||||
"research_guidance_version": {
|
||||
"const": 1
|
||||
},
|
||||
"database_query_failures": {
|
||||
"type": "array",
|
||||
"maxItems": 8,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"table",
|
||||
"database"
|
||||
],
|
||||
"properties": {
|
||||
"table": {
|
||||
"type": "string",
|
||||
"maxLength": 64,
|
||||
"pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
|
||||
},
|
||||
"database": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"maxLength": 64,
|
||||
"pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# BUG-000023: mixed rejection limit
|
||||
|
||||
Generation 183, revision 1, H1 iteration 7. The first response has inconsistent escaping inside next and fails JSON parsing. The second omits next.kind while specifying project.query and arguments; a deterministic discriminator repair may be possible but has not been proven safe for all variants. The third is structurally valid but requests database.schema for item_template in the default cata_world database, which has no visible table metadata. All three count toward the same configured invalid-response limit of 3. Detailed table feedback is saved for the next attempt but the controller blocks before it can be used. Earlier schema-execution recovery worked and the investigation progressed. This is not a connection outage. Unknown-table knowledge from earlier iterations/hypotheses was not sufficient to prevent this repeat. Do not change stored answers or infer alternate tables automatically. No full prompts or secrets are included.
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"assessment": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"reason": {
|
||||
"type": "string"
|
||||
},
|
||||
"semantic_score": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"semantic_score",
|
||||
"reason"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"next": {
|
||||
"properties": {
|
||||
"kind": {
|
||||
"enum": [
|
||||
"tool",
|
||||
"recall",
|
||||
"checkpoint"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"observation": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"assessment",
|
||||
"observation",
|
||||
"next"
|
||||
],
|
||||
"type": "object",
|
||||
"x-viano-investigation-window": 2,
|
||||
"x-viano-response-recovery": 1
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
[
|
||||
{
|
||||
"call_ref": "llm/operations/9d94a56f71b21f01a9b59e1f935e199a9e59dd72e2ab77b517fb5e2b1bdd864e/round-0001.json",
|
||||
"provider_code": "LLM_RESPONSE",
|
||||
"controller_code": "LLM_RESPONSE",
|
||||
"document": null,
|
||||
"response_text": "{\"assessment\":{\"reason\":\"Source search for 60678 returned only incidental coordinate and broadcast text matches, indicating item 60678 is likely stored in the database item tables rather than code files.\",\"semantic_score\":25},\"next\":{\"kind\\\":\\\"tool\\\",\\\"operation\\\":\\\"project.query\\\",\\\"arguments\\\":{\\\"filters\\\":[{\\\"column\\\":\\\"entry\\\",\\\"operator\\\":\\\"eq\\\",\\\"value\\\":60678}],\\\"kind\\\":\\\"database.rows\\\",\\\"limit\\\":1,\\\"offset\\\":0,\\\"table\\\":\\\"item_template\\\"}},\"observation\":\"Repository search for 60678 yielded no direct item/spell definitions in source code or updates; checking item_template table for item 60678 spell parameters.\"}",
|
||||
"diagnostics": {
|
||||
"json_error_kind": "missing_delimiter",
|
||||
"parse_column": 455,
|
||||
"parse_line": 1,
|
||||
"response_error": "invalid_json",
|
||||
"response_stage": "output_json"
|
||||
}
|
||||
},
|
||||
{
|
||||
"call_ref": "llm/operations/f312162a57b4add0d8cceb9efc246aa7d4bcad5e2a69117c22937d8293e9704e/round-0001.json",
|
||||
"provider_code": "LLM_OUTPUT_SCHEMA",
|
||||
"controller_code": "LLM_OUTPUT_SCHEMA",
|
||||
"document": {
|
||||
"assessment": {
|
||||
"reason": "Lexical search for 60678 matched mostly unrelated floats and broadcast text IDs in older SQL updates.",
|
||||
"semantic_score": 25
|
||||
},
|
||||
"next": {
|
||||
"arguments": {
|
||||
"kind": "database.schema",
|
||||
"table": "item_template"
|
||||
},
|
||||
"operation": "project.query"
|
||||
},
|
||||
"observation": "Checking schema for item_template to see available columns for item 60678 spell properties."
|
||||
},
|
||||
"response_text": "{\"assessment\":{\"reason\":\"Lexical search for 60678 matched mostly unrelated floats and broadcast text IDs in older SQL updates.\",\"semantic_score\":25},\"next\":{\"arguments\":{\"kind\":\"database.schema\",\"table\":\"item_template\"},\"operation\":\"project.query\"},\"observation\":\"Checking schema for item_template to see available columns for item 60678 spell properties.\"}",
|
||||
"diagnostics": {
|
||||
"response_stage": "candidate",
|
||||
"validation_fields": [
|
||||
"kind"
|
||||
],
|
||||
"validation_keyword": "required",
|
||||
"validation_path": "/next"
|
||||
}
|
||||
},
|
||||
{
|
||||
"call_ref": "llm/operations/67408eb8469db583d37c1341e26f0531b8f260ef2c14ddc73fb16b5598c2b2ff/round-0001.json",
|
||||
"provider_code": null,
|
||||
"controller_code": "PROJECT_DATABASE_TABLE_UNKNOWN",
|
||||
"document": {
|
||||
"assessment": {
|
||||
"reason": "Text search for 60678 in source returns miscellaneous SQL updates and coordinates, but does not directly reveal item template fields or spell associations.",
|
||||
"semantic_score": 30
|
||||
},
|
||||
"next": {
|
||||
"arguments": {
|
||||
"kind": "database.schema",
|
||||
"table": "item_template"
|
||||
},
|
||||
"kind": "tool",
|
||||
"operation": "project.query"
|
||||
},
|
||||
"observation": "Querying the schema of item_template to see available columns for spell ID and interaction definitions."
|
||||
},
|
||||
"response_text": "{\"assessment\":{\"reason\":\"Text search for 60678 in source returns miscellaneous SQL updates and coordinates, but does not directly reveal item template fields or spell associations.\",\"semantic_score\":30},\"next\":{\"kind\":\"tool\",\"operation\":\"project.query\",\"arguments\":{\"kind\":\"database.schema\",\"table\":\"item_template\"}},\"observation\":\"Querying the schema of item_template to see available columns for spell ID and interaction definitions.\"}",
|
||||
"diagnostics": {}
|
||||
}
|
||||
]
|
||||
@@ -227,3 +227,55 @@ def test_nonexistent_or_semantically_incomplete_repair_path_is_not_used():
|
||||
def test_oversized_document_is_not_duplicated_for_normalization():
|
||||
raw={'text':'x'*65536,'next':{'kind':'tool','operation':'project.query','arguments':rows(filters=['id','eq',1])}}
|
||||
assert normalize(raw)==(raw,None)
|
||||
|
||||
|
||||
|
||||
def test_recorded_bug23_missing_tool_kind_is_recovered_without_changing_content():
|
||||
from pathlib import Path
|
||||
root=Path(__file__).parent/'fixtures/llm_rejections/20261120/bug23-mixed-rejections'
|
||||
replies=json.loads((root/'rejected-answers.json').read_text(encoding='utf-8'))
|
||||
contract=json.loads((root/'output-schema.json').read_text(encoding='utf-8'))
|
||||
request={'prompt_version':'investigation_project_v20','output_schema':contract}
|
||||
raw=replies[1]['document'];before=copy.deepcopy(raw)
|
||||
fixed,audit=normalize(raw,request=request)
|
||||
assert fixed == dict(raw,next=dict(raw['next'],kind='tool'))
|
||||
assert raw == before and audit['original_document'] == before
|
||||
assert audit['rules'] == ['restore_redundant_tool_kind:/next/kind']
|
||||
assert normalize(fixed,request=request) == (fixed,None)
|
||||
# Inconsistent escaping is not an unambiguous missing discriminator.
|
||||
with pytest.raises(LLMError):parse_text(replies[0]['response_text'],request)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('change',[
|
||||
lambda a:a.update(kind='unknown'),
|
||||
lambda a:a.update(operation='invented.operation'),
|
||||
lambda a:a.update(reason='ambiguous extra intent'),
|
||||
lambda a:a['arguments'].pop('table'),
|
||||
lambda a:a['arguments'].update(sql='SELECT secrets'),
|
||||
])
|
||||
def test_missing_kind_repair_does_not_guess_intent_or_complete_invalid_queries(change):
|
||||
from pathlib import Path
|
||||
root=Path(__file__).parent/'fixtures/llm_rejections/20261120/bug23-mixed-rejections'
|
||||
raw=json.loads((root/'rejected-answers.json').read_text(encoding='utf-8'))[1]['document']
|
||||
contract=json.loads((root/'output-schema.json').read_text(encoding='utf-8'))
|
||||
change(raw['next']);before=copy.deepcopy(raw)
|
||||
assert normalize(raw,request={'prompt_version':'investigation_project_v20','output_schema':contract}) == (before,None)
|
||||
assert raw == before
|
||||
|
||||
|
||||
def test_missing_kind_query_executes_once_with_audited_normalization(tool_case):
|
||||
from test_bounded_contract_v2 import loop_for
|
||||
class MissingKind:
|
||||
async def generate(self, config, request, **kwargs):
|
||||
return ProviderResponse({'assessment':None,'observation':'Read scoped records.',
|
||||
'next':{'operation':'project.query','arguments':rows()}},'fixture',100,50)
|
||||
worker=loop_for(tool_case,MissingKind())
|
||||
result=asyncio.run(worker.step(*CASE))
|
||||
assert result.status == 'PROGRESSED'
|
||||
with PackageReader(result.package) as reader:
|
||||
refs=[n for n in reader.files if n.startswith('llm/operations/') and n.endswith('/round-0001.json')]
|
||||
calls=[json.loads(reader.read_bytes(n)) for n in refs]
|
||||
call=next(c for c in calls if c['phase']=='INVESTIGATING_HYPOTHESES')
|
||||
assert 'kind' not in call['outcome']['normalization']['original_document']['next']
|
||||
assert call['outcome']['document']['next']['kind'] == 'tool'
|
||||
assert len(BudgetManager(tool_case[0]).snapshot(*CASE).state['accounts']['H1']['actions']) == 1
|
||||
@@ -235,3 +235,56 @@ def test_execution_metadata_failure_returns_to_model_without_fabricating_evidenc
|
||||
assert 'INV-1-H1-1-recovery-1' in account['actions']
|
||||
assert account['actions']['INV-1-H1-1']['failed']
|
||||
assert PackageValidator().validate(result.package).valid
|
||||
|
||||
|
||||
@pytest.mark.parametrize('lean',[False,True])
|
||||
def test_shared_database_failure_hints_survive_bounded_prompt_views(lean):
|
||||
c=context(lean);c['tool_guidance_version']=1
|
||||
c['database_query_failures']=[{'table':'missing_items','database':'cata_world'}]
|
||||
request=build_prompt(c)
|
||||
assert 'missing_items' in request['messages'][1]['content']
|
||||
assert 'database_query_failures' in request['messages'][1]['content']
|
||||
assert 'not causal evidence' in request['messages'][0]['content']
|
||||
|
||||
|
||||
def test_failed_tables_are_shared_across_hypotheses_and_bounded():
|
||||
from viano_bug_analysis.analysis.tool_guidance import database_failure_history
|
||||
class Archive:
|
||||
def namelist(self):return [f'call{i}' for i in range(20)]
|
||||
class Reader:
|
||||
_archive=Archive()
|
||||
state={'hypotheses':{'H1':{'notes':[{'kind':'invalid_response','code':'PROJECT_DATABASE_TABLE_UNKNOWN','llm_ref':f'call{i}'} for i in range(10)]},
|
||||
'H2':{'notes':[{'kind':'invalid_response','code':'PROJECT_DATABASE_TABLE_UNKNOWN','llm_ref':f'call{i}'} for i in range(10,20)]}}}
|
||||
def read(reader,ref,contract):
|
||||
return {'outcome':{'document':{'next':{'operation':'project.query','arguments':{'table':'db.items'+ref[4:]}}}}}
|
||||
entries=database_failure_history(Reader(),state,{},read)
|
||||
assert len(entries)==8 and entries[0]=={'database':'db','table':'items12'}
|
||||
assert entries[-1]=={'database':'db','table':'items19'}
|
||||
|
||||
|
||||
|
||||
def test_failed_table_is_visible_when_scheduler_moves_to_another_hypothesis(tool_case):
|
||||
from test_investigator import LoopAdapter,run
|
||||
from test_case_interpreter import gateway
|
||||
from test_project_research import FakeDB,rows
|
||||
from viano_bug_analysis.analysis import Investigator
|
||||
from viano_bug_analysis.tools import InvestigationToolRouter,ToolError
|
||||
from viano_bug_analysis.tools.project_query import ProjectResearch
|
||||
from viano_bug_analysis.package import PackageReader
|
||||
class Missing(FakeDB):
|
||||
def validate(self,args):
|
||||
if args.get('table')=='missing_items':raise ToolError('PROJECT_DATABASE_TABLE_UNKNOWN')
|
||||
with PackageReader(tool_case[1]) as reader:
|
||||
service=ProjectResearch(reader.manifest['project'],database=Missing())
|
||||
selected=[]
|
||||
def change(reply,c):
|
||||
selected.append(c['selected_hypothesis'])
|
||||
if len(selected)==1:
|
||||
query=rows(table='missing_items')
|
||||
else:
|
||||
assert c['database_query_failures']==[{'table':'missing_items','database':None}]
|
||||
query={'kind':'database.tables','text':'item','offset':0,'limit':10}
|
||||
reply['next']={'kind':'tool','operation':'project.query','arguments':query}
|
||||
loop=Investigator(tool_case[0],gateway(LoopAdapter(change)),router=InvestigationToolRouter(project_research=service))
|
||||
run(loop,steps=3)
|
||||
assert selected==['H1','H1','H2']
|
||||
Reference in new issue
Block a user