Skip to content

Per-leaf run cost report from pi session streams (E6/E1) - #139

Merged
pdettori merged 1 commit into
rossoctl:mainfrom
pdettori:feat/run-cost-report
Jul 17, 2026
Merged

pdettori merged 1 commit into
rossoctl:mainfrom
pdettori:feat/run-cost-report

Conversation

@pdettori

Copy link
Copy Markdown
Member

Summary

Adds authoritative per-leaf token/cost capture for the SWE-bench sharing run, so E6/E1 report run cost automatically.

The in-harness usage field is unreliable on the pinned pi build (both getSessionStats and the getBranch fallback throw), but the pi session stream in Redis (session:<sessionId>) carries per-assistant-turn usage plus pi's own model-accurate cost.total. Every leaf the drivers dispatch uses a sessionId ending in the driver pid (-$$), so a session:*-<pid> scan captures exactly one run's leaves — curve, sweep, and benefit arms alike — with no hot-loop sid threading.

Changes

  • deploy/knative/session-usage.py — brace-matches and sums one leaf's usage stream → {sid,turns,input,output,cacheRead,cacheWrite,total,costUsd}.
  • lib.sh — LIB_DIR (locate co-located scripts) + run_cost_report <pid> <outfile>: scan session:*-<pid>, sum each leaf, write per-leaf JSONL, echo a COST_REPORT leaves=… totalTokens=… costUsd=… avgUsdPerLeaf=… summary.
  • e6-saturation.sh / e1-benefit.sh — emit COST_REPORT on the E6_RESULT/E1B_RESULT lines and into EXPERIMENTS.md. Gated to WORKLOAD=swebench in E6 so the synthetic path output is byte-identical.

Validation

Live on OCP 4.20 against the costed-pilot leaves (haiku): 6 leaves, $0.555/leaf avg; per-leaf costs match pi's cost.total exactly, and the sweep leaves are now captured alongside the curve leaves. shellcheck + bash -n clean; session-usage.py py_compile clean. No image rebuild — driver-side + a host-run script reading Redis.

Assisted-By: Claude Code

Adds authoritative per-leaf token/cost capture for the SWE-bench sharing run. The
in-harness usage field is unreliable on the pinned pi build (getSessionStats and
the getBranch fallback both throw), but the pi session stream in Redis
(session:<sessionId>) carries per-assistant-turn usage + pi's own model-accurate
cost.total. Every leaf the drivers dispatch uses a sessionId ending in the driver
pid (-$$), so a session:*-<pid> scan captures exactly one run's leaves — curve,
sweep, and benefit arms alike — with no hot-loop sid threading.

- deploy/knative/session-usage.py: brace-matches and sums a leaf's usage stream
  (input/output/cacheRead/cacheWrite + costUsd from cost.total).
- lib.sh: LIB_DIR (locate co-located scripts) + run_cost_report <pid> <outfile>
  (scan session:*-<pid>, sum each, echo a COST_REPORT summary line).
- e6-saturation.sh / e1-benefit.sh: emit COST_REPORT + per-leaf usage on the
  E6_RESULT/E1B_RESULT lines and into EXPERIMENTS.md. Gated to WORKLOAD=swebench
  in e6 so the synthetic path output is unchanged.

Live-validated on OCP 4.20 against the costed-pilot leaves (haiku): 6 leaves,
$0.555/leaf avg, per-leaf costs match pi cost.total exactly. shellcheck + bash -n
clean; session-usage.py py_compile clean.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori merged commit 2cd17b8 into rossoctl:main Jul 17, 2026
10 checks passed
@pdettori
pdettori deleted the feat/run-cost-report branch July 17, 2026 02:38
webchang added a commit to webchang/moca that referenced this pull request Nov 23, 2026
…octl#338)

CodeQL on PR C (rossoctl#137 js/polynomial-redos, rossoctl#138 and rossoctl#139
js/file-access-to-http, relay-release.ts:62/65/67):

- The listener's base URL loses its trailing slashes in a loop
  (releaseUrl), not with /\/+$/, which backtracks on many slashes.
- The release URL and bearer now travel as the control plane's other
  secrets do: configFromEnv reads them into the config
  (CpConfig.relayRelease, every profile, with the same boot checks), and
  the request that needs them builds the releaser from deps.config
  (releaserOf), as the operator inference token reaches its upstream.
  Before, depsFromEnv built a releaser that closed over values read from
  withCredentials' merged env, whose dynamic property writes of file data
  CodeQL counts as tainting every value read from it, the URL included.
  deps.relayRelease stays as the test seam.

A local CodeQL 2.27.5 run (security-extended, as CI) over the control
plane reports the three alerts at the previous head and none here.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
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.

1 participant