Skip to content

feat(run): record CPU and peak RSS; match scoring ids by text - #165

Merged
musingfox merged 2 commits into
mainfrom
muster/pr-run-recording
Nov 10, 2026
Merged

musingfox merged 2 commits into
mainfrom
muster/pr-run-recording

Conversation

@musingfox

Copy link
Copy Markdown
Owner

Summary

  • digest_runs.summary now records cpu_seconds and peak_rss_bytes for every run, on SQLite and D1 alike, through an optional Deps.process_usage (no schema change). ru_maxrss is normalized to bytes; a missing resource module (Windows) wires None and leaves the summary unchanged.
  • Scoring matches reply ids as stripped text, so an echoed "7" matches a stored 7; a whole-number float such as 7.0 still matches. The "Scored none of N" warning names the id types and the first ids sent and received, so a zero match that this fix does not explain names its own cause.

Tickets: run-resource-metrics, scoring-ids-match-none (vault pm/cyris/tasks).

Verification

  • scripts/check.sh passed outside the sandbox at both commits (fe68ffd: 5329 passed; the tip's tree equals the reviewed 1aab628c, which passed).
  • An independent review passed the contract.
  • Still open after merge: a cloud run's digest_runs row read back with both values, and a real run logging Scored N / N.

🤖 Generated with Claude Code

musingfox and others added 2 commits November 10, 2026 13:34
`digest_runs` held only `wall_seconds`, so the hosted-pool estimate that a
run mostly waits on the LLM was never measured. `run_digest` now calls an
optional `Deps.process_usage` as the run ends and merges `cpu_seconds`
(user + system) and `peak_rss_bytes` into the summary, which D1RunLog
already stores whole: no new table or column.

The read is `adapters/process_usage.py`, wired in `build_deps`. `ru_maxrss`
is bytes on macOS and KiB on Linux; it is normalized to bytes. None leaves
the summary unchanged, and a failing read is logged and never replaces the
run's result.

`resource` does not exist on Windows, and bootstrap imports the adapter,
so `import cyris.bootstrap` would have raised there. The adapter tolerates
its absence, and `build_deps` wires `process_usage=None` when `resource`
is unavailable, which leaves the run's summary unchanged.

The None case is tested to log no error: without the None guard in
run_digest the call raised, was caught, and logged an error while the
summary still lacked the keys, so a test asserting only the summary would
stay green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scoring prompt prints `original_id` bare, so an int and a string
look the same to the model, but the reply lookup was exact on type and
whitespace: an int 7 never matched an echoed "7", nor a string "7" an
echoed 7 or " 7 ". Ids now compare as stripped text, for the score and
for the fallback language. A whole-number float reply id such as 7.0
keys as its integer text, so it still matches a stored int 7 as it did
when ids compared with ==.

The "Scored none of N articles" warning now also names the type of the
ids sent, the first five sent and the first five received (ids only,
each clipped, never article text), so an occurrence the match fix does
not explain names its own cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

raise
finally:
summary["wall_seconds"] = round(time.monotonic() - started, 2)
if deps.process_usage is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RUSAGE_SELF is cumulative for the whole process, but wall_seconds next to it is per run. If run_digest can run more than once in one process (a long-lived container serving regenerate reruns or scheduled runs), cpu_seconds and peak_rss_bytes include earlier work. ru_maxrss also never goes down. Those rows would overstate what the run used, and nothing in the stored row says so. Either record a baseline at the start of run_digest and store the CPU delta, or document that the figures are process lifetime and only meaningful for one-shot cyris run. The wall_seconds comparison invites reading them as per-run.

@claude

claude Bot commented Nov 10, 2026

Copy link
Copy Markdown

Review of #165: I found one thing worth raising, posted inline. cpu_seconds and peak_rss_bytes come from RUSAGE_SELF, so they cover the whole process. If run_digest runs more than once in a long-lived process, they overstate what a single run used, unlike wall_seconds, which is per run. The _id_key normalization in scoring and the zero-match logging look correct and are well tested. The process_usage read is guarded so a failure can't replace the run's result. I didn't run the tests.

@musingfox

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T14:13:38.116511Z e14dd44 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: e14dd44e3e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@musingfox
musingfox merged commit a5a411f into main Nov 10, 2026
3 checks passed
@musingfox
musingfox deleted the muster/pr-run-recording branch November 10, 2026 17:05
musingfox added a commit that referenced this pull request Nov 10, 2026
#167 changed nothing in §1–§6, so it has no row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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