feat: close pre-zai local blockers

This commit is contained in:
OpenCode
2026-09-21 16:46:59 -03:00
parent 84b08c2150
commit b10131953c
13 changed files with 2775 additions and 0 deletions
@@ -0,0 +1,13 @@
def test_company_session_is_company_first_review_only_and_has_ipi_impact(tmp_path):
from scripts.run_company_decision_session import build_session
session = build_session(tmp_path, "docs/LOCAL_FISCAL_CONTEXT_QUESTIONS_V2.json") if (tmp_path / "docs/LOCAL_FISCAL_CONTEXT_QUESTIONS_V2.json").exists() else None
# Use a small local fixture because the production artifact is intentionally large.
if session is None:
(tmp_path / "docs/runs/multi_db").mkdir(parents=True)
(tmp_path / "docs").mkdir(exist_ok=True)
(tmp_path / "docs/LOCAL_FISCAL_CONTEXT_QUESTIONS_V2.json").write_text('{"questions":[{"QUESTION_ID":"Q1","DATABASE":"A","SCOPE":"COMPANY","KEY":"entry_scope","VALID_OPTIONS":["INTRA","INTER","MIXED_OR_DYNAMIC"],"QUESTION":"Escopo?"}]}', encoding="utf-8")
(tmp_path / "docs/FISCAL_COVERAGE_FULL_V3.json").write_text('{"total_products":1,"ipi":{"numeric":1,"non_numeric":0,"ambiguous":0}}', encoding="utf-8")
session = build_session(tmp_path)
assert all(question["scope"] == "COMPANY" for question in session["questions"])
assert session["persisted"] is False and session["firebird_writes"] == 0
@@ -0,0 +1,9 @@
def test_missing_historical_identity_is_preserved_not_guessed():
from central.app.ai.historical_conflicts import INSUFFICIENT_EVIDENCE, reconstruct_historical_conflicts
report = reconstruct_historical_conflicts({"products": [{"gtin": "x", "fingerprint": "f"}]}, historical_count=73)
assert report["historical_conflicts_before"] == 73
assert report["historical_conflicts_resolved"] == 0
assert report["historical_conflicts_remaining"] == 73
assert report["classification_counts"] == {INSUFFICIENT_EVIDENCE: 73}
assert all(row["resolution"] == "PRESERVE_CONFLICT" for row in report["conflicts"])
+9
View File
@@ -0,0 +1,9 @@
def test_pre_zai_state_is_explicit_about_human_and_external_blockers(tmp_path):
from scripts.generate_pre_zai_state import build_state
state = build_state(tmp_path)
assert state["DETERMINISTIC_COMPLETE"] is True
assert state["COMPANY_CONTEXT_COMPLETE"] is False
assert state["FIREBIRD_AI_WRITES"] == 0
assert state["READY_FOR_ZAI_GOLD_EVAL"] is True
assert state["REMAINING_EXTERNAL_BLOCKERS"] == ["EXTERNAL_AI_CREDENTIAL_OR_BALANCE"]