Repository navigation
feat(cost): share each attempt's spend across its statements, with coverage (#1330) - #1338
Merged
Merged
Conversation
…verage (#1330) The roll-up billed DAG pod attempts (run_costs), but statement executions were recorded only on the composed run_all path, never by a pod, so the attempts it priced had no statements to share across. A lake-writing pod task now records its executions under its task id (er_cli::with_recorded_executions around run_pod_task). A read-only task records nothing, because the drain is a lake write. cost_roll then shares each (run, stage)'s spend across its statements by statement time over attempt wall time. What the statements don't cover stays unattributed and shows as coverage below 1. Every roll-up reports each dataset's spend, attributed spend, coverage, its top ten statements by cost, and the rest. Nothing under a cent is priced alone; those statements are only counted. Read through statement_execution/read/durations_for_runs from each dataset's lake. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alyser requires (#1330) Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
temporarily deployed
to
marketing-preview
November 28, 2026 04:44 — with
GitHub Actions
Inactive
This branch was previously deployed
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 #1330
What
exec_taskwraps a lake-writing pod task iner_cli::with_recorded_executions(session, run_id, task_id, …), the same recorderrun_alluses. A read-only task (materialize_previews, export, extract, train, write_back_scan) records nothing, because the drain is a lake write.statement_execution/read/durations_for_runs: per(run, stage, statement), the total ms and the execution count.cost_rollgains aStatementSource(each dataset's own lake, in production) andstatement_costs:(run, stage)'s spend is shared across its statements by statement time over attempt wall time, so uncovered time stays unattributed instead of inflating the statements;statements: per dataset,spend_usd,attributed_usd,coverage(statement time / wall time), thetop10 statements by cost (each ≥ $0.01),rest, andbelow_one_cent, which is counted but never priced alone;Why
#1330 assumed statement attribution was already persisted. It was, but only on the composed
run_allpath (ExecutionScopeinrun_all_ensemble_observed). A DAG pod runs astage_*function directly and recorded nothing, so the runner attempts the roll-up prices (run_costs) had no statements to share across.Proof
pg_run_all_pipeline(eight realexec-taskpods) now assertsstatement_executionsrows foringest,standardize,matchandreconcileunder the job's run id. With recording disabled inexec_task, it fails withthe ingest pod recorded no statements: {}.pg_cost_rollwith a fakeStatementSource: every dataset is reported, coverage is within (0, 1], attributed ≤ spend, the top statement is named, and a sub-cent statement is counted, not priced.a_stages_spend_is_shared_by_statement_time_and_coverage_is_honest(exact $6.00 / $2.00 / $0.40, coverage 0.6) andnothing_under_a_cent_is_priced_alone_and_skew_never_overbills.make check: exit 0 (entity analyser, skills drift, er-span's statement bound at 360).Risk & rollback
A lake-writing pod now appends one batch of
statement_executionsper task. It's best-effort: a failure is logged and the task still succeeds, as on the composed path. Rollback isgit revert <merge-sha>.Post-merge ledger
Closed by: agent · session
Claude Code:871c2645-29b1-4996-bd69-8809abfc82feonbrians-MacBook-Pro· 2026-11-28T05:01:52Zmainis green with this change on it — the merge SHA, and the runthat proves it. A later head SHA with this commit as an ancestor counts;
a cancelled run with zero jobs does not: c668141: rust 46108951351, frontend 46108951349, images 46108951381, infra 46108951350, devcontainer 46108951366, all success.
imagesbuilt, or correctly never ran because nothing that goes intoan image changed: built, run 46108951381 success.
deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: converged: deploy 46109293404 at c668141, dev and prod legs success; runner pods launched from this image record their statements from now on.
deploy,drift,kind's nightly leg) is green, or knowingly red for a reason that is notthis change: deploy green. drift is red on The er-alerts SNS email subscription has never been confirmed — 19 armed alarms reach nobody #1107's unconfirmed SNS subscriber, not this change.
Donethrough the automation rather than byhand, and the issue closed: Cost: per-statement share of attempt spend, with coverage #1330 closed by the merge.
(a skill, a reference, memory) — or nothing new was learned: recorded in the PR: statement executions were recorded only on the composed run_all path, never by a DAG pod. with_recorded_executions now covers lake-writing pod tasks.
Specific to this change
er-cost-rollJob's report after runs that executed with this change. blocked: needs runs executed with this image and then the next scheduled er-cost-roll (07:17 UTC daily). The pg_cost_roll test proves the report's shape and the pipeline e2e proves the recording.🤖 Generated with Claude Code