Cognitive debt review coverage¶
agent-strace cognitive-debt reports how much observed agent-written code has review evidence. It is a workflow and repository metric. It does not measure code quality, claim that agent use caused an outcome, or rank individuals.
Local generation¶
Generate both the versioned report and a Shields-compatible static badge:
mkdir -p artifacts
agent-strace cognitive-debt \
--since 30d \
--by repository \
--format json \
--output artifacts/cognitive-debt.json \
--badge-output artifacts/cognitive-debt-badge.json
One run writes both, so they describe the same report. Both files are complete static JSON. CI can upload them without an agent-trace service.
Status and coverage¶
The report keeps reviewed, unreviewed, and unknown lines separate. Unknown authorship or review state never becomes zero debt.
| Status | Meaning |
|---|---|
clean |
All observed agent-written lines have review evidence |
partial |
Review is known and some lines lack review evidence, within the configured threshold |
above_threshold |
Review is known and the unreviewed ratio is above --threshold |
unknown |
No agent-written lines were observed, or authorship or review state is incomplete |
The JSON report has schema_version: 1. Its root coverage object includes:
agent_written_linesreviewed_linesandreviewed_percentunreviewed_linesandunreviewed_percentunknown_review_linesandunknown_review_percentunknown_authorship_linesauthorship_stateandreview_stateunreviewed_ratio, which isnullwhen review state is unknown
workflows contains per-session detail. groups contains repository or branch aggregates. Neither contains author rankings. The interpretation object records that this is review coverage, not code quality or causal evidence.
File paths¶
Each entry in workflows[].files and the legacy sessions[].files has two path fields:
| Field | Value |
|---|---|
path |
The path as the trace recorded it, often an absolute path on the recording machine |
relative_path |
path relative to the session's recorded working_dir, with / separators, or null when the session recorded no absolute working_dir or the file is not below it |
relative_path is computed from the recorded text alone. Symlinks and the current directory are not resolved, so a path written through a symlinked name of the working directory is not below it. A relative path is read as relative to working_dir. A local file:// URI is decoded first.
The text report prints relative_path when it is set and path otherwise, so a report pasted into a pull request names src/app.py instead of the recording machine's directory layout.
Agent-written lines lists the write tools and argument shapes counted for each agent. Review evidence lists every review signal and its weight. Commits, merged pull requests, co-author trailers and words in commit messages are not review evidence.
--commits RANGE and --agent-trace-records FILE also count agent lines from git-ai notes and Agent Trace records. The JSON report then has a top-level external_attribution list, and each workflow and session has a source.
Malformed trace data, malformed write-tool arguments, malformed local review records, and malformed GitHub review responses fail closed. The command writes no report or badge when input validation fails.
Shields badge¶
The badge output follows the Shields endpoint schema:
{
"schemaVersion": 1,
"label": "cognitive debt",
"message": "60% reviewed, 40% unreviewed",
"color": "yellow"
}
Commit or publish cognitive-debt-badge.json, then point Shields at its raw URL:
Use the versioned report for automation. Use the badge only for presentation.
PR check¶
The GitHub Action can add the cognitive debt result for the linked review
session to the reviewability check. Set the
cognitive-debt input to auto (the default), false, report, or check.
auto is false on pull_request, pull_request_target and merge_group
events and report otherwise: cognitive debt reads GitHub reviews of merged pull requests
only, so before merge it cannot see the review. Run it on the default branch
after merge, or use the team view on a schedule. The check
reads schema_version and status. unknown is unavailable and never a pass.
Team view in CI¶
The PR check grades one session before merge, when its review cannot be seen
yet. The team view is the report after merge: how much agent-written code
reached a branch without review over a window, grouped by repository. Set the
Action's cognitive-debt-team input to true in a workflow that runs on
schedule or workflow_dispatch:
permissions:
contents: read
pull-requests: read
on:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
jobs:
cognitive-debt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Siddhant-K-code/agent-trace@v0.132.0
with:
cognitive-debt-team: "true"
cognitive-debt-window: "30d"
examples/ci/cognitive-debt-weekly.yml is the full workflow. Team mode runs instead of the eval, the review and the PR comment.
What it reads in CI¶
A runner has none of the sessions recorded on developer machines. Team mode reads what the repository carries for the commits on the checked-out branch in the window:
| Source | How it is read |
|---|---|
| Entire checkpoints | The checkpoints that Entire-Checkpoint trailers in those commits name are fetched from origin (their refs/entire/checkpoints/ refs, or the entire/checkpoints/v1 branch) and imported into trace-dir with agent-strace import --entire --commits RANGE. Each becomes a session, with its branch, so the reviews of its merged pull request are read. A checkpoint that cannot be read or imported is skipped, the log names it, and the rest are still counted. |
| git-ai notes | refs/notes/ai is fetched from origin and read with --commits RANGE. See git-ai notes. |
| Agent Trace records | The review-agent-trace-records file, when set, read with --agent-trace-records. |
Sessions in trace-dir |
Any sessions already there, for example restored from an artifact. |
Review notes (refs/notes/agent-strace) hold review findings, not file writes,
so they are not a source. review-fetch-agent-refs: "false" skips both fetches;
the step then reads only what the checkout already has.
Window, range and permissions¶
cognitive-debt-window (default 30d) is passed as --since: a duration
such as 30d or 12h, or an ISO date before now. Any other value fails the
step before anything is fetched. The range is BASE..HEAD, where BASE is the
newest first-parent commit made before the window starts, so commits merged in
the window count. The range needs the full history: a shallow clone fails the
step and asks for fetch-depth: 0.
The job needs contents: read and pull-requests: read. github-token, the
workflow token by default, reads the reviews of merged pull requests. The
step passes it to cognitive-debt in AGENT_STRACE_GITHUB_TOKEN, not on the
command line. Without a token those reviews are not read, and only local
review evidence counts. One cognitive-debt run writes the text, JSON and
badge reports, and asks GitHub for each pull request once. When a GitHub
request fails, for example on a rate limit, the files that needed it count no
GitHub review and the log has one warning with the number of failed requests.
Results¶
| Result | Contents |
|---|---|
| Job summary | The text report under "Cognitive debt: team view", with the window and the number of commits |
cognitive-debt-json-path |
cognitive-debt-team.json, the schema v1 report grouped by repository |
cognitive-debt-badge-path |
cognitive-debt-team-badge.json, the Shields endpoint JSON |
cognitive-debt-status |
The report's status |
agent-trace-cognitive-debt-team artifact |
Both JSON files |
Team mode reports. Debt never fails the job; a bad input, a shallow clone, or
a report that was not written does. On pull_request, pull_request_target
and merge_group it warns that it cannot see the open pull request's review,
and still runs.
Limits¶
- Work never pushed as an Entire checkpoint, a git-ai note, or an Agent Trace record is not counted. Sessions that stay on developer machines are invisible to CI.
- A session counts when it started in the window, so a session that started before the window is left out even when its commit is in the window.
- git-ai note and Agent Trace record lines are matched to merged pull requests
by the checked-out branch, not the branch that wrote them, so on the default
branch their GitHub reviews are not found.
Reviewed-by:trailers still count. - A window with more than 500 commits on the branch adds a notice: Entire checkpoints are not imported, and git-ai notes are read from 500 commits only. Shorten the window.
CI and release assets¶
A release job can generate immutable evidence and upload both files:
mkdir -p artifacts
agent-strace cognitive-debt \
--since 30d \
--by repository \
--format json \
--output artifacts/cognitive-debt.json \
--badge-output artifacts/cognitive-debt-badge.json
gh release upload "$GITHUB_REF_NAME" \
artifacts/cognitive-debt.json \
artifacts/cognitive-debt-badge.json \
--clobber
For an always-current badge, publish the badge JSON to a stable branch path. For release evidence, keep both JSON files as release assets. A later PR Evidence Check can read artifacts/cognitive-debt.json, require schema_version == 1, and treat status == "unknown" as unavailable evidence rather than a passing result.
A CI job runs in a different directory from the one the session recorded. The command then reads the current checkout's git history when its remote names the session's repository and the session started at the repository root; see Reading a trace from another checkout. Check out with fetch-depth: 0 so the branch history is available.