Initial commit: Conflict Checker
Cross-discipline design-contradiction checker for construction drawing sets. Standalone tool broken out from Iron_Bid; a pipeline stage may later fold back into Iron_Bid. Pipeline: PDF->images -> per-sheet assertion extraction -> deterministic clustering by location -> per-cluster reasoning -> report. Includes CLI (cli/run_check.py) and web UI (backend/main.py). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
jurisdiction.py - Stage 0: project intake and jurisdiction / code profile (LLM).
|
||||
|
||||
Turns whatever project metadata we have (intake form fields and/or values
|
||||
derived from the cover sheet) into a code profile that tells Stage 7 which
|
||||
review paths apply (IBC, ADA, TAS/TDLR, etc.). Returns {} on failure so the
|
||||
rest of the pipeline degrades gracefully.
|
||||
"""
|
||||
|
||||
import json
|
||||
from typing import Dict, Optional
|
||||
|
||||
from backend import config
|
||||
from backend.pipeline._stage import call_stage
|
||||
from backend.prompts import JURISDICTION_SYSTEM_PROMPT, JURISDICTION_USER_INSTRUCTION
|
||||
|
||||
|
||||
def run_jurisdiction(project_input: Optional[Dict]) -> Dict:
|
||||
"""Build the project code profile from available project metadata."""
|
||||
project_input = project_input or {}
|
||||
parsed = call_stage(
|
||||
JURISDICTION_SYSTEM_PROMPT,
|
||||
JURISDICTION_USER_INSTRUCTION,
|
||||
subs={"project_input": json.dumps(project_input, ensure_ascii=True)},
|
||||
max_tokens=config.JURISDICTION_MAX_TOKENS,
|
||||
)
|
||||
if not isinstance(parsed, dict):
|
||||
print("[Jurisdiction] no profile produced; code review will be limited")
|
||||
return {}
|
||||
# The prompt wraps the result in "project_code_profile"; unwrap when present.
|
||||
profile = parsed.get("project_code_profile")
|
||||
return profile if isinstance(profile, dict) else parsed
|
||||
|
||||
|
||||
def active_review_paths(profile: Dict) -> Dict:
|
||||
"""The review_paths sub-dict (which code checks are on), or {} if absent."""
|
||||
return (profile or {}).get("review_paths") or {}
|
||||
Reference in New Issue
Block a user