From 56b94cd58ec8c997617ae068a31a945c09a890ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 8 Oct 2026 07:38:36 -0400 Subject: [PATCH] Delete the eight functions nobody called Measured, not guessed: every top-level def in every tracked .py file was counted against every other tracked file, including markdown, scripts, Go and TypeScript. Eight names had zero references anywhere: cartridges_holding_atom and clear_mounts (memory.py reads each cartridge's own sources.json, and set_mounts already clears by replacing the set), gradient_checkpointing_enabled, group_hits_by_source, ingested_paths, is_finite_number, parse_runtime_json (the runtime answers in prose now, and the JSON path was never wired back), write_sources_json. Typer commands and pytest cases were excluded from the count because a framework calls them by name. The same scan now returns zero. 263 tests pass; repo-wide mypy is still 24 errors in 6 files, unchanged. --- backend/src/ely_eye/cartridge_store.py | 14 -------------- backend/src/ely_eye/ingestion_repository.py | 5 ----- backend/src/ely_eye/proofs/report.py | 4 ---- backend/src/ely_eye/retrieval.py | 7 ------- backend/src/ely_eye/runtime.py | 15 --------------- backend/src/ely_eye/training.py | 9 --------- bench/ingest_baseline.py | 5 ----- 7 files changed, 59 deletions(-) diff --git a/backend/src/ely_eye/cartridge_store.py b/backend/src/ely_eye/cartridge_store.py index e4bb9b4..32c7cc6 100644 --- a/backend/src/ely_eye/cartridge_store.py +++ b/backend/src/ely_eye/cartridge_store.py @@ -44,15 +44,6 @@ def membership_count(database: Database, cartridge_id: str) -> int: return _count(connection, cartridge_id) -def cartridges_holding_atom(database: Database, atom_id: str) -> list[str]: - with database.connect() as connection: - rows = connection.execute( - "SELECT cartridge_id FROM cartridge_atoms WHERE atom_id = ? ORDER BY cartridge_id", - (atom_id,), - ).fetchall() - return [str(row["cartridge_id"]) for row in rows] - - def atoms_of_cartridge(database: Database, cartridge_id: str) -> list[str]: with database.connect() as connection: rows = connection.execute( @@ -94,11 +85,6 @@ def set_mounts(database: Database, cartridge_ids: list[str], mounted_at: datetim ) -def clear_mounts(database: Database) -> None: - with database.connect() as connection: - connection.execute("DELETE FROM mounts") - - def _count(connection: sqlite3.Connection, cartridge_id: str) -> int: row = connection.execute( "SELECT COUNT(*) AS n FROM cartridge_atoms WHERE cartridge_id = ?", (cartridge_id,) diff --git a/backend/src/ely_eye/ingestion_repository.py b/backend/src/ely_eye/ingestion_repository.py index 3caa534..b60fe5e 100644 --- a/backend/src/ely_eye/ingestion_repository.py +++ b/backend/src/ely_eye/ingestion_repository.py @@ -314,8 +314,3 @@ def extract_generic_calls(text: str) -> list[dict[str, str]]: return calls -def write_sources_json(path: Path, sources: list[SourceRecord]) -> None: - path.write_text( - json.dumps([source.model_dump(mode="json") for source in sources], ensure_ascii=False, indent=2), - encoding="utf-8", - ) diff --git a/backend/src/ely_eye/proofs/report.py b/backend/src/ely_eye/proofs/report.py index 35680ca..ebdb6db 100644 --- a/backend/src/ely_eye/proofs/report.py +++ b/backend/src/ely_eye/proofs/report.py @@ -80,10 +80,6 @@ def format_scores(scores: dict[str, Any]) -> str: return ", ".join(parts) or "none" -def is_finite_number(value: Any) -> bool: - return isinstance(value, (int, float)) and math.isfinite(float(value)) - - def compact_generation_context(context: Any, section_hint: str, max_chars: int = 2400) -> Any: text_hits = [hit for hit in context.hits if hit.atom.modality.value == "text"] hits = (text_hits or context.hits)[:1] diff --git a/backend/src/ely_eye/retrieval.py b/backend/src/ely_eye/retrieval.py index da5c100..2e57cc4 100644 --- a/backend/src/ely_eye/retrieval.py +++ b/backend/src/ely_eye/retrieval.py @@ -169,13 +169,6 @@ class RetrievalService: return [hit.atom for hit in self.search(query, top_k, filters=filters).hits] -def group_hits_by_source(hits: list[RetrievalHit]) -> dict[str, list[RetrievalHit]]: - grouped: dict[str, list[RetrievalHit]] = defaultdict(list) - for hit in hits: - grouped[hit.atom.source].append(hit) - return dict(grouped) - - def encode_cursor(offset: int) -> str: return base64.urlsafe_b64encode(str(offset).encode()).decode() diff --git a/backend/src/ely_eye/runtime.py b/backend/src/ely_eye/runtime.py index a7546ed..79ba3ce 100644 --- a/backend/src/ely_eye/runtime.py +++ b/backend/src/ely_eye/runtime.py @@ -1,7 +1,6 @@ from __future__ import annotations import base64 -import json import logging import subprocess from dataclasses import dataclass @@ -429,17 +428,3 @@ def gpu_status() -> dict[str, Any]: } -def parse_runtime_json(text: str) -> dict[str, Any]: - stripped = text.strip() - if stripped.startswith("```"): - stripped = stripped.strip("`") - if stripped.lower().startswith("json"): - stripped = stripped[4:].strip() - try: - return json.loads(stripped) - except json.JSONDecodeError: - start = stripped.find("{") - end = stripped.rfind("}") - if start >= 0 and end > start: - return json.loads(stripped[start : end + 1]) - raise diff --git a/backend/src/ely_eye/training.py b/backend/src/ely_eye/training.py index 14771da..e3dfb21 100644 --- a/backend/src/ely_eye/training.py +++ b/backend/src/ely_eye/training.py @@ -1313,15 +1313,6 @@ def model_type_for_proof(model: Any) -> str | None: return None -def gradient_checkpointing_enabled(model: Any) -> bool: - if bool(getattr(model, "is_gradient_checkpointing", False)): - return True - config = getattr(model, "config", None) - if bool(getattr(config, "gradient_checkpointing", False)): - return True - return bool(getattr(model, "_gradient_checkpointing_func", None)) - - def make_optimizer(model: Any, learning_rate: float) -> tuple[Any, str]: params = [param for param in model.parameters() if param.requires_grad] try: diff --git a/bench/ingest_baseline.py b/bench/ingest_baseline.py index 5f68793..1ee8125 100644 --- a/bench/ingest_baseline.py +++ b/bench/ingest_baseline.py @@ -236,11 +236,6 @@ def ledger_outcomes() -> tuple[set[str], set[str]]: return ingested, failed -def ingested_paths() -> set[str]: - """Every file a shard ledger recorded as ingested, excluding the files it recorded as failed.""" - return ledger_outcomes()[0] - - def retry_failed() -> int: """Drop failed ledger entries so those files are attempted again, archiving what was dropped.""" archive = RUNS / "failures.jsonl"