Wire CostTracker into project runs; persist cost_log.json for all attempts#53
Open
nandanadileep wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20
Summary
get_project_cost_tracker(pipeline_dir, project_id, config=None)factory tolib/checkpoint.pyCostTrackerbound to<pipeline_dir>/<project_id>/cost_log.json, loaded from project configreconcile(entry_id, actual_usd, success=False)— they land incost_log.jsonwithstatus: "failed"so spend is never undercountedasset_manifest.jsonremains the asset inventory artifact;cost_log.jsonis the authoritative spend ledgerWhat changed
lib/checkpoint.py— addedget_project_cost_tracker()factory (no changes to existing functions)tests/contracts/test_phase0_contracts.py— addedTestProjectCostTrackerwith 5 tests:cost_log_pathset to project directorystatus: "failed"and counted in spent budgetTest plan
python3 -m pytest tests/contracts/test_phase0_contracts.py -v— all new tests pass, no regressionsModuleNotFoundError: No module named 'numpy'(unrelated to this change)