Skip to content

Official Codebase of 3DCodeVerse

Python

cleanup: A3 — Delete five dead cost helpers

gaoypeng4f30f4f04483
diff --git a/harness/codeverse/cost/__init__.py b/harness/codeverse/cost/__init__.py
index a6ef3d72..54c2b749 100644
--- a/harness/codeverse/cost/__init__.py
+++ b/harness/codeverse/cost/__init__.py
@@ -17,7 +17,7 @@ Nothing here imports tracks/ or orchestrator/, so any layer may use it.
from __future__ import annotations
-from codeverse.cost.audit import Audit, WasteItem, audit_dir, audit_runs
+from codeverse.cost.audit import Audit, WasteItem, audit_runs
from codeverse.cost.caching import (
Block,
PrefixReport,
@@ -86,7 +86,6 @@ __all__ = [
"Stage",
"Summary",
"WasteItem",
- "audit_dir",
"audit_runs",
"bind_run",
"cache_efficiency",
diff --git a/harness/codeverse/cost/audit.py b/harness/codeverse/cost/audit.py
index 972dd5dc..441bae4c 100644
--- a/harness/codeverse/cost/audit.py
+++ b/harness/codeverse/cost/audit.py
@@ -220,10 +220,6 @@ def audit_runs(paths: Iterable[str | Path], *, recheck: bool = False) -> Audit:
return audit
-def audit_dir(root: str | Path, *, recheck: bool = False) -> Audit:
- return audit_runs([root], recheck=recheck)
-
-
# --------------------------------------------------------------------------- derived views
def cached_input_share(audit: Audit) -> tuple[int, int, float]:
"""``(cached, total input, $ paid for cache reads)`` — how much of every prompt
diff --git a/harness/codeverse/cost/ledger.py b/harness/codeverse/cost/ledger.py
index a683302b..64b8febe 100644
--- a/harness/codeverse/cost/ledger.py
+++ b/harness/codeverse/cost/ledger.py
@@ -382,7 +382,3 @@ def summarise(rows: Iterable[CallCost], *, dimensions: Sequence[str] = DIMENSION
bucket = out.by.setdefault(dim, {}).setdefault(_key(row, dim), CostBucket(key=_key(row, dim)))
bucket.add(row)
return out
-
-
-def totals_by(rows: Iterable[CallCost], dim: str) -> dict[str, CostBucket]:
- return summarise(rows, dimensions=(dim,)).dimension(dim)
diff --git a/harness/codeverse/cost/types.py b/harness/codeverse/cost/types.py
index bb4dd2fc..3835b14a 100644
--- a/harness/codeverse/cost/types.py
+++ b/harness/codeverse/cost/types.py
@@ -14,14 +14,15 @@ from enum import StrEnum
from pydantic import BaseModel, ConfigDict, Field
-from codeverse.contracts.common import Usage
-
class Stage(StrEnum):
"""Where in a run the money was spent. Mirrors the stage/round vocabulary
of ``events.jsonl`` (``stage.start``/``generate.done`` labels)."""
PLAN = "plan"
+ #: SKELETON / ASSEMBLE / GATES / RENDER are *deterministic harness work* (no
+ #: model call at all); kept in the enum so latency can be attributed to them
+ #: from events (``report.STAGE_ORDER``, ``audit.stage_latency``).
SKELETON = "skeleton"
ASSETS = "assets"
ENV = "env"
@@ -51,10 +52,6 @@ class Role(StrEnum):
OTHER = "other"
-#: stages whose spend is *deterministic harness work* (no model call at all).
-#: Kept in the enum so latency can be attributed to them from events.
-FREE_STAGES: frozenset[Stage] = frozenset({Stage.SKELETON, Stage.ASSEMBLE, Stage.GATES, Stage.RENDER})
-
#: label prefix → stage, longest prefix wins (``asset_stone_lantern`` → assets)
_LABEL_STAGES: tuple[tuple[str, Stage], ...] = (
("asset_", Stage.ASSETS),
@@ -263,17 +260,3 @@ class Summary(BaseModel):
def ranked(self, name: str, *, limit: int | None = None) -> list[CostBucket]:
rows = sorted(self.dimension(name).values(), key=lambda b: -b.cost_usd)
return rows[:limit] if limit else rows
-
- def share(self, name: str, key: str) -> float:
- b = self.dimension(name).get(key)
- return (b.cost_usd / self.total.cost_usd) if b and self.total.cost_usd else 0.0
-
-
-def usage_to_tokens(usage: Usage) -> dict[str, int]:
- return {
- "input_tokens": int(usage.input_tokens),
- "cached_tokens": int(usage.cached_tokens),
- "output_tokens": int(usage.output_tokens),
- "thoughts_tokens": int(usage.thoughts_tokens),
- "tool_calls": int(usage.tool_calls),
- }