Skip to content

feat(dump): JSON dump of all taskguard knows about a job - #29

Merged
SpoBo merged 1 commit into
masterfrom
vincent/explain-json
Oct 16, 2026
Merged

SpoBo merged 1 commit into
masterfrom
vincent/explain-json

Conversation

@SpoBo

@SpoBo SpoBo commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Why

Roderik reported jobs that kept reserving a one-time 17 GB peak. To find the cause we had to read the SQLite history by hand. This adds one command that prints everything taskguard knows about a job, so the next case (and tuning the rules) takes one paste.

What

taskguard dump PATTERN | --cmd "COMMAND" | --run ID [--runs N] prints JSON. For each job it shows:

  • match: pool, label, minimums, and which rule set what.
  • config: settings files, which file changed which setting, and the learn rules (keep, boost_runs, outlier_*, new_job_mem, caps).
  • learned: what the history says, with outliers and ignored failed runs.
  • next_need: what the next run reserves. Each step has a reason (history, boost, first_guess, cpu_cap, min_cpu, min_mem, mem_cap).
  • runs: each stored run (every column), its wait_spans and adjustments, and a role: whether it is in the window, an outlier, failed and ignored, or a boost trigger.
  • pruned and live (the queue entry with its blocker).

How

  • The need math moved from runner.rs into src/need.rs (need::derive). The runner and dump now call the same code, so the dump cannot drift from what really runs. Behaviour is unchanged.
  • Each run stores its need steps in a new nullable column runs.need_why (JSON). The column is also added to pruned_runs and RUN_COLUMNS. It is added in Db::open like nested_jobs, so mixed versions keep working. Older versions leave it empty, and an older version's prune drops it. It is debug data only.

Verified

  • cargo fmt --check, cargo clippy --all-targets -D warnings, and cargo test (173 unit + 29 CLI) pass.
  • New tests: need::tests (each step and its reason, caps, minimums, first guess, ignored failed runs) and dump_shows_what_a_job_reserves_and_why (CLI: by key, --run, --cmd, and stored need_why).
  • Ran on a copy of a real history: taskguard dump 'root:tsc_-p_tsconfig.json' shows the 14.5 GB failed run as "failed, and its peak is ignored", with a next need of 193 MB.

No release: this goes in the next version.

🤖 Generated with Claude Code

`taskguard dump PATTERN | --cmd "COMMAND" | --run ID` prints one JSON
document per job: how it matches, the rules in force and who set them, what
the next run reserves and why (step by step), each recent run with its wait
spans, adjustments and role in the need, pruned runs, and live queue entries.

The need math moves from runner.rs into need.rs, so the runner and dump use
the same code. Each run now stores its need steps in a new nullable column,
runs.need_why (also in pruned_runs and RUN_COLUMNS), so old runs can be
explained after the fact.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SpoBo
SpoBo merged commit 34e3292 into master Oct 16, 2026
2 checks passed
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