Skip to content

Wire CostTracker into project runs; persist cost_log.json for all attempts#53

Open
nandanadileep wants to merge 1 commit into
calesthio:mainfrom
nandanadileep:fix/wire-cost-tracker-to-project-runs
Open

Wire CostTracker into project runs; persist cost_log.json for all attempts#53
nandanadileep wants to merge 1 commit into
calesthio:mainfrom
nandanadileep:fix/wire-cost-tracker-to-project-runs

Conversation

@nandanadileep
Copy link
Copy Markdown

Closes #20

Summary

  • Add get_project_cost_tracker(pipeline_dir, project_id, config=None) factory to lib/checkpoint.py
  • The factory creates a CostTracker bound to <pipeline_dir>/<project_id>/cost_log.json, loaded from project config
  • Existing entries are reloaded automatically across agent turns / pipeline stages
  • Failed paid attempts are tracked via reconcile(entry_id, actual_usd, success=False) — they land in cost_log.json with status: "failed" so spend is never undercounted
  • asset_manifest.json remains the asset inventory artifact; cost_log.json is the authoritative spend ledger

What changed

lib/checkpoint.py — added get_project_cost_tracker() factory (no changes to existing functions)

tests/contracts/test_phase0_contracts.py — added TestProjectCostTracker with 5 tests:

  • Correct cost_log_path set to project directory
  • Cost log file is created on first operation
  • Failed paid attempts are written with status: "failed" and counted in spent budget
  • Entries reload correctly across stages (cross-turn persistence)
  • Different projects have isolated cost logs

Test plan

  • python3 -m pytest tests/contracts/test_phase0_contracts.py -v — all new tests pass, no regressions
  • Pre-existing failures are all ModuleNotFoundError: No module named 'numpy' (unrelated to this change)

Add get_project_cost_tracker() to lib/checkpoint.py so production pipeline
runs always persist a project-local cost_log.json. The factory creates a
CostTracker bound to <pipeline_dir>/<project_id>/cost_log.json, loaded from
project config, and reloads existing entries across agent turns so cumulative
spend — including failed paid attempts — is never lost.

Add five contract tests covering: correct log path, persistence on first
operation, failed-attempt tracking, cross-stage reload, and project isolation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in cost estimates

1 participant