Select phase-specific working context and retain auditable source evidence

This commit is contained in:
Nico committed 2026-10-16 01:25:19 +02:00
1 parent 3ea7cd5000
commit d6749001bb
36 files changed
+599 -60

No files matched your search

@@ -159,10 +159,10 @@ def feedback(reader, phase, failure):
if len(available) <= 32:
issue["allowed_source_ids"] = available
issues.append(issue)
if error.get('prompt_version') in {'case_interpretation_resolved_v2','case_interpretation_resolved_v3','case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7'}:
if error.get('prompt_version') in {'case_interpretation_resolved_v2','case_interpretation_resolved_v3','case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7','case_interpretation_resolved_v8'}:
from .contracts import entity_citation_issues
issues.extend(entity_citation_issues(payload,context))
if error.get('prompt_version') in {'case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7'}:
if error.get('prompt_version') in {'case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7','case_interpretation_resolved_v8'}:
for index,entity in enumerate(payload.get('relevant_entities',[])):
source = context['sources'].get(entity.get('entity_id'),{})
bindings = source.get('data',{}).get('name_bindings',[])
@@ -170,7 +170,7 @@ def feedback(reader, phase, failure):
if allowed and not set(entity.get('source_ids',[])) & set(allowed):
issues.append({'field':f'relevant_entities/{index}/source_ids',
'constraint':'cite_typed_name_binding','allowed_source_ids':allowed})
if error.get('prompt_version') in {'case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7'}:
if error.get('prompt_version') in {'case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7','case_interpretation_resolved_v8'}:
from .quality import unnamed_entity_reasons
reasons = unnamed_entity_reasons(context)
for index, entity in enumerate(payload.get('relevant_entities',[])):
@@ -182,7 +182,7 @@ def feedback(reader, phase, failure):
if (source['kind']=='data_quality' and source['case_pointer'].startswith('/entity_resolution/')
and not any(sid in s.get('source_ids',[]) for s in payload.get('unknowns',[]) if isinstance(s,dict))):
issues.append({'field':'unknowns','source_id':sid,'constraint':'retain_scoped_lookup_uncertainty'})
if error.get('prompt_version') in {'case_interpretation_resolved_v3','case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7'}:
if error.get('prompt_version') in {'case_interpretation_resolved_v3','case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7','case_interpretation_resolved_v8'}:
from .quality import description_sources
allowed = description_sources(context)
for index, statement in enumerate(payload.get('described_behavior',[])):
@@ -229,7 +229,7 @@ def feedback(reader, phase, failure):
if not set(proposal.get("interpretation_ids", [])) & focus:
issues.append({"field": "hypotheses/0/interpretation_ids", "constraint": "primary_focus", "allowed_source_ids": sorted(focus)[:32]})
instruction = "Return a complete replacement JSON object conforming to the supplied schema and source rules. Do not invent facts or sources. Use empty arrays/null for unsupported claims. Distinct hypotheses must retain valid grounding and count constraints."
if phase == 'interpretation' and error.get('prompt_version') in {'case_interpretation_resolved_v2','case_interpretation_resolved_v3','case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7'}:
if phase == 'interpretation' and error.get('prompt_version') in {'case_interpretation_resolved_v2','case_interpretation_resolved_v3','case_interpretation_resolved_v4','case_interpretation_resolved_v5','case_interpretation_resolved_v6','case_interpretation_resolved_v7','case_interpretation_resolved_v8'}:
instruction += " Keep tester observations in observed_behavior with observation sources; move technical assertions to confirmed_technical_facts with fact sources. Retain selected entity_id values and cite their original mentions plus entity or matching capture evidence. Keep lookup uncertainties scoped to their queries."
return {"code":error["code"],"issues":issues[:32],"instruction":instruction}