Change grading

From woditschka/agentic-coding-reference · View interactive version

Change grading is an AI agent skill from the GitHub repository woditschka/agentic-coding-reference. Grade a passing change for how much human attention it deserves before merge. Load when running the change-grader after the reviewer roster approves. Holds the full grading protocol: the five facets, worst-facet aggregation, the facets-rationale-verdict order, persistence, and scope/non-goals.

How to use this skill

Skill file

What this grades, and what it does not

The reviewer roster answers is this change correct. This grader answers the different question the gate does not: how much human attention this passing change deserves before it merges. The verdict names that reading depth: skim or scrutinize. It concentrates scarce review on the changes where judgment pays off and lets the obvious-safe ones move fast.

Two boundaries are load-bearing and must never erode:

The grader is a terminal, advisory node. Nothing routes on its verdict; the router does not consume it. The routing table dispatches it as the terminal hop and the human acts on it.

Because nothing routes on it, the automatic dispatch is optional: layout.toml [harness] auto_grade = false tells route to reach feature-complete on roster approval without dispatching the grader. That gates only the pipeline hop — this skill stays runnable by hand at any time. A hand-run grader-verdict routes like an automatic one: to feature-complete, or to next-slice when the entry plans a later slice. Default is true; a project opts out when the per-change grade is not worth its cost.

The protocol, and the skill drives it

You are dispatched once. Inside that one dispatch you run the whole protocol. The deterministic script produces the structural row; you read the diff and decide.

  1. Extract. Run the deterministic extractor:

```

python3 scripts/grading.py extract --feature <REQ-ID>

```

You run before the human commits, so by default the extractor snapshots the live working tree — staged, unstaged, and untracked changes — and diffs it against HEAD. That uncommitted delta is the change under review; no commit exists yet, and the slice never commits mid-flight (only /ship does, terminally), so HEAD is the right base. It is the same change set a reviewer reads through python3 scripts/changeset.py, so your row and their view agree. It appends one grader-features record to .scratch/handoff.jsonl (the structural row, carrying head_kind: "worktree"). Pass --base <ref>/--head <ref> only to grade an already-committed range after the fact. Add --churn when commit/author history is wanted and the clone is complete. The script holds no verdict logic — it extracts facts and persists one record; you decide.

  1. Grade by reading the diff. Read the grader-features record and the raw diff at the coordinates it flags, through python3 scripts/changeset.py, the change set the reviewers read. Form the five facet notes, the rationale, and the verdict — in that order (§ Output).
  1. Record the verdict. Append one grader-verdict record via python3 scripts/handoff.py append grader-verdict (heredoc form per the handoff-append skill; summary, facets, rationale, verdict, responding_to the grader-features line), then return the change-grade report (§ Surface the verdict to the session) as your final message.

Both records are ephemeral per-feature working state. There is no calibration log in this version (§ Scope and non-goals).

Features are a map, not the answer

The extractor's row — per-file added/deleted/kind, modules touched (scatter), test/prod line ratio, hunk count, churn, sensitive paths, build/review status, retries, consultations, design revisions — tells you where to dive, never what to conclude.

A clean feature row is permission to read FAST. It is never permission to skip the read.

The anchoring risk is specific and it is the failure this whole grader exists to prevent: handed a clean-looking row, a model rubber-stamps skim without opening the diff — silently rebuilding the cheap scorer's blind spot while paying to not look. A one-line diff inverting balance >= amount to balance > amount is tiny, low-churn, clean on every structural axis, and catastrophic. The defense is structural: the verdict must come from reading the hunks at the flagged coordinates. Deriving it from the row alone is forbidden. You read the raw diff, not only the digested row, so a bug in extraction (shallow clone, wrong base) cannot blind both layers at once.

Recompute, don't trust. The row is evidence to direct your reading, not a conclusion to ratify. Where the row and the diff disagree, the diff wins and the disagreement is itself a signal worth noting in the rationale.

The five facets

Each facet is one real failure mode, judged on its own. A facet's value is skim, scrutinize, or unknown — never numeric. No 1–10, no scores. Judges cluster mid-scale and a 73-vs-82 distinction is noise; a hard gate wants a categorical call. unknown means genuinely insufficient information to judge, and it counts as scrutinize, never a coerced pass. Write a one-line plain-prose note for each facet — the reason for its verdict — and persist it beside the verdict.

Aggregation: worst facet, never average

This is the one place generic LLM-judge guidance does not transfer, because the costs are asymmetric: a needless scrutinize wastes minutes, a wrong skim ships an incident. Averaging buries the single dangerous facet under benign ones — the inverted-operator change scores skim four times and scrutinize once, and a mean says skim.

Any facet scrutinize or unknown → scrutinize. All five skim → skim. Do not average. Do not let four skims outvote one scrutinize.

unknown and missing data fail toward scrutinize. Absence of a risk signal is never evidence of safety.

Output: facet notes, then rationale, then verdict — in that order

Reasoning before the verdict improves judgment, so the per-facet notes and the rationale are the reasoning that produces the verdict, written before it — not a justification written after. Append one grader-verdict record via python3 scripts/handoff.py append grader-verdict (schema: schemas/scratch/grader-verdict.schema.json):

{
  "type": "grader-verdict",
  "req_id": "<REQ-ID>",
  "author": "change-grader",
  "responding_to": [<grader-features line>],
  "summary": "<short imperative name of the change, e.g. tighten retry-counter reset>",
  "facets": {
    "blast_radius":      { "verdict": "skim",   "note": "<one plain-prose explanation>" },
    "semantic_surprise": { "verdict": "scrutinize", "note": "<one plain-prose explanation>" },
    "test_adequacy":     { "verdict": "skim",   "note": "<one plain-prose explanation>" },
    "reviewer_hedging":  { "verdict": "skim",   "note": "<one plain-prose explanation>" },
    "scope_deviation":   { "verdict": "skim",   "note": "<one plain-prose explanation>" }
  },
  "rationale": "<20-60 words: the decisive point and what the human should do>",
  "verdict": "scrutinize"
}

Each facet carries a verdict (skim/scrutinize/unknown) and a one-line note. The verdict must equal the worst-facet aggregation — any facet scrutinize or unknown → scrutinize; all five skim → skim. A verdict that contradicts its own facets or rationale (a skim whose prose lists worries) is a visible reliability flag and is wrong by construction.

Surface the verdict to the session

A subagent's final message is returned to the caller, not shown to the user. So your returned summary is the change-grade report the human reads at the decision point. Render it as Markdown from the record you persisted — root relays it as the closing line of the loop:

# Change Grade — <REQ-ID>: <summary>

## Verdict — Skim
<rationale prose>
_Advisory only; nothing auto-merges._

Extracted: <facts line from the grader-features row>

## Blast Radius — Skim
<blast_radius note>

## Semantic Surprise — Skim
<semantic_surprise note>

## Test Adequacy — Skim
<test_adequacy note>

## Reviewer Hedging — Skim
<reviewer_hedging note>

## Scope Deviation — Skim
<scope_deviation note>

Rendering rules:

This report is display-only. It must never feed routing or gate logic: the verdict is what the human reads at the decision point; nothing acts on it.

Persistence

Both records live in the append-only .scratch/handoff.jsonl — the single source the rest of the harness already uses, no separate files:

| Record | Written by | Contents |

|---|---|---|

| grader-features | grading.py extract | the deterministic structural row; null for any missing input |

| grader-verdict | you (the grader) | the change summary, the five facet verdicts and notes, the rationale, and the verdict |

Schemas: schemas/scratch/grader-features.schema.json, schemas/scratch/grader-verdict.schema.json. Both records are ephemeral per-feature working state, cleared with .scratch/ between features. Nothing persists across features in this version (§ Scope and non-goals).

Determinism and the `unknown` contract

The feature row is a pure function of pinned inputs: the resolved base ref, the head (a --head commit, or the content-addressed tree of the working-tree snapshot — identical worktree content hashes to the identical tree, so two runs over an unchanged tree agree), the append-only .scratch/handoff.jsonl records, and scripts/layout.toml. The script reads git under a canonical environment and sorts every list. Missing data emits null, never a false zero: unresolved base or a failed snapshot → diff facets unknown; absent/unreadable handoff log → build/review/retry facts null → the dependent facets unknown → scrutinize.

Classification is scripts/layout.toml — per-project globs for test/prod/sensitive and module-derivation rules. A changed file matching no test/prod rule is kind unknown: recorded, never coerced to prod. Fix misclassification in the shared layout/engine so the fix helps every project.

The engine's module strategies are pinned on synthetic layouts by scripts/tests/grading/test_features_layout.py (stdlib unittest, run from the scripts dir with python3 -m unittest tests.grading.test_features_layout); the stack-agnostic engine pins live in scripts/tests/grading/test_features.py. No installed suite asserts this project's own scripts/layout.toml beyond loading it, so a project that reshapes its layout keeps a green install. The doctor validates the layout's shape; the classification the layout produces is read from the grader's records. The suite is not wired into the project build: the vendored runtime changes only at install time, and the install (materialize, or the marketplace setup) verifies every suite it copies. Run it manually when investigating a classification.

Scope and non-goals

This version is advisory-only. The grader emits a per-change recommendation (skim = a glance confirms it, scrutinize = read the flagged hunks closely) for the human at the decision point. Nothing auto-approves, nothing routes on the verdict, and no record persists across features.

Deliberately out of scope (future work, not built):

Reliability note

A single-model-family harness cannot use the textbook cross-family defense against self-enhancement bias (the implementer is also opus). Two things bound that here: the verdict is advisory-only — nothing auto-approves — and the lever if reliability ever needs hardening is double-grading (grade twice, route any disagreement to scrutinize), not a weaker judge. Capability is kept because the semantic read is the pipeline's sharpest-reasoning task.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.