Skip to content

Commit f2b1f3a

Browse files
author
faresrafat3
committed
fix: repair invalid syntax + undefined names (CI was unrunnable)
Fixes for code quality issues revealed by enabling ruff in CI: Syntax errors (prevented module from loading): - skill_library.py:79: bare 'except:' with no handler -> 'except Exception:' - arsenal_run.py:113: 'async for' had no indented body (missing 4 spaces) - pipeline/l2_conductor.py / l3_search.py / router.py: same async-for pattern Undefined names (NameErrors at import): - arsenal_run.py:31: route_project() called but never imported - arsenal_run.py:116: 'return result' for undefined name 'result' - arsenal_run.py:76: RouteDecision used in mock branch but not imported (it is imported now via the models import line) Dead code: - llm.py: lower, prompt: assigned but never read in _offline_fallback Style: - bare 'except:' -> 'except Exception:' in economy.py - super() modernization in economy.py - ruff autofix for unsorted imports, UP rules pyproject.toml: - added [tool.ruff] config to ignore stylistic rules that don't apply to alpha code (BLE001, EXE001, C408, RUF013, S110, ISC004) Net effect: 'ruff check .' now passes; the package can be parsed and imported (deps still needed for full import, but syntax is valid). PR #4 was supposed to fix some of this; this lands the same fixes without the SSE merge that was the actual blocker.
1 parent 16b2dc0 commit f2b1f3a

32 files changed

Lines changed: 198 additions & 164 deletions

epistemic_forge/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""Epistemic Forge — ARSENAL-powered research & writing kit."""
22

3-
from .pipeline.arsenal_run import ArsenalRun, run_pipeline
43
from .models import Claim, ForgeResult, ProjectSpec
4+
from .pipeline.arsenal_run import ArsenalRun, run_pipeline
55

66
__version__ = "0.1.0"
77
__all__ = [
88
"ArsenalRun",
9-
"run_pipeline",
109
"Claim",
1110
"ForgeResult",
1211
"ProjectSpec",
1312
"__version__",
13+
"run_pipeline",
1414
]

epistemic_forge/benchmark/baseline.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing import List
65

7-
8-
def baseline_answer(title: str, question: str, domain: str, keywords: List[str]) -> str:
6+
def baseline_answer(title: str, question: str, domain: str, keywords: list[str]) -> str:
97
"""Produce a short unstructured answer — typical one-shot Q&A quality."""
108
kw = ", ".join(keywords) if keywords else "the main themes"
119
# Deliberately thin: claim-ish sentence, weak support, no rebuttal structure

epistemic_forge/benchmark/llm_judge.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""LLM-as-a-Judge for Automated, Scientific Epistemic Evaluation (Toulmin Model)."""
2-
from typing import Dict, Any
3-
from epistemic_forge.models import JudgeEvaluation
4-
from epistemic_forge.llm import generate_structured
2+
from typing import Any
3+
54
from loguru import logger
65

7-
def evaluate_artifact_quality(question: str, artifact_text: str) -> Dict[str, Any]:
6+
from epistemic_forge.llm import generate_structured
7+
from epistemic_forge.models import JudgeEvaluation
8+
9+
10+
def evaluate_artifact_quality(question: str, artifact_text: str) -> dict[str, Any]:
811
"""Uses a stronger model to judge the output based strictly on Toulmin's Model of Argumentation."""
912
logger.info("⚖️ Initiating strict Toulmin-based evaluation of the final artifact...")
1013

epistemic_forge/benchmark/metrics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import re
1010
from dataclasses import asdict, dataclass
11-
from typing import Any, Dict, List, Optional
11+
from typing import Any
1212

1313

1414
@dataclass
@@ -44,26 +44,26 @@ def overall(self) -> float:
4444
total += getattr(self, k) * w
4545
return round(total, 4)
4646

47-
def to_dict(self) -> Dict[str, Any]:
47+
def to_dict(self) -> dict[str, Any]:
4848
d = asdict(self)
4949
d["overall"] = self.overall()
5050
return d
5151

5252

53-
def _hit(text: str, patterns: List[str]) -> float:
53+
def _hit(text: str, patterns: list[str]) -> float:
5454
t = text.lower()
5555
return 1.0 if any(p in t for p in patterns) else 0.0
5656

5757

58-
def _count_hits(text: str, patterns: List[str]) -> int:
58+
def _count_hits(text: str, patterns: list[str]) -> int:
5959
t = text.lower()
6060
return sum(1 for p in patterns if p in t)
6161

6262

6363
def score_document(
6464
text: str,
6565
domain: str = "hybrid",
66-
keywords: Optional[List[str]] = None,
66+
keywords: list[str] | None = None,
6767
) -> QualityScores:
6868
"""Score a free-text answer for Toulmin completeness + packaging quality."""
6969
keywords = keywords or []

epistemic_forge/benchmark/suite.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
from dataclasses import asdict, dataclass
77
from pathlib import Path
8-
from typing import Any, Dict, List, Optional
8+
from typing import Any
99

1010
from epistemic_forge.benchmark.baseline import baseline_answer
1111
from epistemic_forge.benchmark.metrics import score_document, toulmin_coverage
@@ -18,10 +18,10 @@ class BenchCase:
1818
title: str
1919
question: str
2020
domain: str
21-
keywords: List[str]
21+
keywords: list[str]
2222

2323

24-
BENCHMARK_CASES: List[BenchCase] = [
24+
BENCHMARK_CASES: list[BenchCase] = [
2525
BenchCase(
2626
"p1",
2727
"Predictive processing and blame",
@@ -106,8 +106,8 @@ class CaseResult:
106106
forge_toulmin: float
107107
lift_overall: float
108108
lift_toulmin: float
109-
baseline_scores: Dict[str, Any]
110-
forge_scores: Dict[str, Any]
109+
baseline_scores: dict[str, Any]
110+
forge_scores: dict[str, Any]
111111

112112

113113
def _forge_text(case: BenchCase) -> str:
@@ -125,9 +125,9 @@ def _forge_text(case: BenchCase) -> str:
125125
return "\n\n".join(a.content for a in result.artifacts)
126126

127127

128-
def run_benchmark(cases: Optional[List[BenchCase]] = None) -> Dict[str, Any]:
128+
def run_benchmark(cases: list[BenchCase] | None = None) -> dict[str, Any]:
129129
cases = cases or BENCHMARK_CASES
130-
rows: List[CaseResult] = []
130+
rows: list[CaseResult] = []
131131
for case in cases:
132132
base_txt = baseline_answer(
133133
case.title, case.question, case.domain, case.keywords
@@ -187,7 +187,7 @@ def run_benchmark(cases: Optional[List[BenchCase]] = None) -> Dict[str, Any]:
187187
}
188188

189189

190-
def write_benchmark_reports(out_dir: str | Path) -> Dict[str, Any]:
190+
def write_benchmark_reports(out_dir: str | Path) -> dict[str, Any]:
191191
out = Path(out_dir)
192192
out.mkdir(parents=True, exist_ok=True)
193193
report = run_benchmark()

epistemic_forge/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
import argparse
1010
import sys
11+
1112
from rich.console import Console
1213
from rich.panel import Panel
1314
from rich.progress import Progress, SpinnerColumn, TextColumn
1415
from rich.tree import Tree
1516

17+
from epistemic_forge.memory.economy import budget_manager
1618
from epistemic_forge.models import ProjectSpec
1719
from epistemic_forge.pipeline.arsenal_run import run_pipeline
18-
from epistemic_forge.memory.economy import budget_manager
1920

2021
console = Console()
2122

epistemic_forge/experts/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
"""
77

88
from abc import ABC, abstractmethod
9-
from typing import Any, Dict
9+
from typing import Any
10+
1011
from pydantic import BaseModel
12+
1113
from epistemic_forge.models import ProjectSpec
1214

1315

@@ -18,10 +20,9 @@ class EpistemicExpert(ABC):
1820
@abstractmethod
1921
def expert_name(self) -> str:
2022
"""The formal identifier of the expert (e.g., 'RigorSentinel')."""
21-
pass
2223

2324
@abstractmethod
24-
def analyze(self, spec: ProjectSpec, context: Dict[str, Any]) -> BaseModel:
25+
def analyze(self, spec: ProjectSpec, context: dict[str, Any]) -> BaseModel:
2526
"""
2627
Executes the expert's specific neuro-symbolic logic.
2728
@@ -32,4 +33,3 @@ def analyze(self, spec: ProjectSpec, context: Dict[str, Any]) -> BaseModel:
3233
Returns:
3334
A strictly typed Pydantic BaseModel representing the expert's conclusion.
3435
"""
35-
pass

epistemic_forge/experts/claim_expert.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""Claim Lattice Expert Implementation (Agentic RAG Grounded)."""
2-
from typing import Dict, Any
2+
from typing import Any
3+
4+
from loguru import logger
5+
36
from epistemic_forge.experts.base import EpistemicExpert
4-
from epistemic_forge.models import ProjectSpec, ClaimLatticeOutput
57
from epistemic_forge.llm import generate_structured
8+
from epistemic_forge.models import ClaimLatticeOutput, ProjectSpec
69
from epistemic_forge.tools.search import multi_hop_search
7-
from loguru import logger
10+
811

912
class ClaimLatticeExpert(EpistemicExpert):
1013
"""Deconstructs the question into a structured, epistemically grounded claim lattice."""
@@ -13,7 +16,7 @@ class ClaimLatticeExpert(EpistemicExpert):
1316
def expert_name(self) -> str:
1417
return "Grounded_Claim_Lattice_Generator"
1518

16-
def analyze(self, spec: ProjectSpec, context: Dict[str, Any]) -> ClaimLatticeOutput:
19+
def analyze(self, spec: ProjectSpec, context: dict[str, Any]) -> ClaimLatticeOutput:
1720
"""Uses Agentic Multi-Hop Web Search to ground the LLM's claims in reality."""
1821

1922
# 1. Fetch real-world context using Multi-Hop Agentic RAG

epistemic_forge/experts/dialectic_expert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Hegelian Synthesis Expert Implementation."""
22

3-
from typing import Dict, Any
3+
from typing import Any
44

55
from epistemic_forge.experts.base import EpistemicExpert
6-
from epistemic_forge.models import ProjectSpec, HegelianDialecticOutput
76
from epistemic_forge.llm import generate_structured
7+
from epistemic_forge.models import HegelianDialecticOutput, ProjectSpec
88

99

1010
class HegelianExpert(EpistemicExpert):
@@ -15,7 +15,7 @@ def expert_name(self) -> str:
1515
return "Hegelian_Dialectic_Engine"
1616

1717
def analyze(
18-
self, spec: ProjectSpec, context: Dict[str, Any]
18+
self, spec: ProjectSpec, context: dict[str, Any]
1919
) -> HegelianDialecticOutput:
2020
"""Synthesizes the core question by forcing a steelmanned antithesis."""
2121
messages = [

epistemic_forge/experts/freelance_expert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
from __future__ import annotations
44

5-
from typing import Any, Dict
5+
from typing import Any
66

77
from epistemic_forge.models import ProjectSpec
88

99

1010
def build_client_pack(
11-
spec: ProjectSpec, claims_bundle: Dict[str, Any]
12-
) -> Dict[str, Any]:
11+
spec: ProjectSpec, claims_bundle: dict[str, Any]
12+
) -> dict[str, Any]:
1313
return {
1414
"client_brief": {
1515
"goal": spec.question,

0 commit comments

Comments
 (0)