Skip to content
Edit this page

git-ai notes and Agent Trace records

agent-strace counts the lines an agent wrote from the write tool calls it recorded. Two other tools record line attribution of their own, and it can read both:

  • git-ai attaches an authorship log to each commit as a git note under refs/notes/ai (Git AI Standard v3.0.0).
  • Agent Trace is an open RFC (v0.1.0) from Cursor and Cognition for a JSON TraceRecord that lists files, conversations, line ranges and a contributor type for each range.

agent-strace is not the Agent Trace spec. This repository is named agent-trace and the command is agent-strace, but neither implements or publishes that spec: the command reads Agent Trace records and does not write them.

Both sources are self-reported by the tool that wrote the lines. review lists them as external evidence and never grades them. cognitive-debt counts their agent lines.

Read them

agent-strace review --commits origin/main..HEAD
agent-strace review --commits origin/main..HEAD --agent-trace-records agent-trace.jsonl
agent-strace cognitive-debt --commits origin/main..HEAD --agent-trace-records agent-trace.jsonl
Flag Reads Commands
--commits RANGE The git-ai note of each commit in the range, when the clone has refs/notes/ai. The same flag reads commit trailers. review, health, pr-comment --review, cognitive-debt
--agent-trace-records FILE One Agent Trace record, a JSON array of records, or JSON Lines with one record per line review, health, pr-comment --review, cognitive-debt

The MCP review tool takes commits and agent_trace_records.

git-ai notes

A note has an attestation section, a --- line, and JSON metadata. Each file path starts at column 0. Each entry under it is indented two spaces and maps a key to line ranges such as 1-6,9:

Key Contributor
s_<14 hex>, optionally ::t_<14 hex> ai: a session in metadata.sessions
h_<14 hex> human: a person in metadata.humans
16 or 7 hex characters ai: a prompt in metadata.prompts (logs before v3.0.0)

A note is read only when schema_version is authorship/3.x.y and prompts is an object. The agent's tool name, model and session ID come from the session or prompt record.

A clone without refs/notes/ai gives no git-ai signal in review, health and pr-comment, and neither does a range that cannot be read or has no commits: the commit trailer signals already report that. cognitive-debt says the ref is missing and prints the command to fetch it.

Agent Trace records

A record must have a version of 0.x or 1.x, an id, an RFC 3339 timestamp and a files list. Each file has a path and a conversations list. Each conversation has a contributor (type is ai, mixed, human or unknown, with an optional model_id) and ranges with start_line and end_line. A range with its own contributor overrides the conversation's; when it names another type, it does not keep the conversation's model. vcs.revision names the commit. A record without one is its own revision.

The spec does not say where records are stored. Pass the file your tool writes.

How lines are counted

Lines are counted per path at each commit (git-ai) or each revision (Agent Trace). At one revision, each line counts once, in this order:

  1. Already captured: the line belongs to a conversation that a linked or reported session recorded. Its session or conversation ID equals the git-ai session ID, or one segment of the Agent Trace conversation url. These lines are counted once, under that session.
  2. ai
  3. mixed: AI and human together
  4. human
  5. unknown

Agent lines are ai plus mixed. Every output shows mixed on its own line next to ai, because cognitive-debt check can fail a pull request and reviewers need to see how much of the count is mixed.

Line numbers are per commit or per record. A line that a later commit in the range rewrites counts again at that commit, so a long range can count more lines than the final diff holds.

Where they show up

review, health and pr-comment

Each source is one external signal. Its detail names the line counts, the commits or records read, and the agent tools:

External evidence (commits main..feature, Agent Trace records records.json):
  - git-ai notes main..feature: present (medium). Lines: 8 AI, 0 mixed, 2 human, 0 unknown. 1 file has agent lines; 1 of 2 commits has a note. Tools: claude, cursor. Self-reported by the tool that wrote them; line numbers are per commit or record.
  - Agent Trace records records.json: present (medium). Lines: 0 AI, 2 mixed, 0 human, 0 unknown. 1 file has agent lines; 1 record read. Tools: cursor. Self-reported by the tool that wrote them; line numbers are per commit or record.
  Reported, not graded: never changes a status or the exit code.
Signal Status Confidence
Agent lines found present medium
Notes or records read, no agent line missing high, or medium when some were malformed or the read was capped
No commit in the range has a note missing high, or medium when the read was capped
The records file holds no record missing high
The file or the notes could not be read, or every note or record was malformed inconclusive low, with facts.read_error

JSON facts holds commits_read and commits_with_notes (git-ai) or records_read (Agent Trace), then ai_lines, mixed_lines, human_lines, unknown_lines, files, tools, models, malformed and truncated. The source is git_ai_notes or agent_trace_records. A present signal counts as agent involvement.

In review, the scope finding also lists the paths that have agent lines from a conversation no linked session captured, and that no linked session wrote:

Scope            inconclusive  low
  No session is linked, so no file activity was found.
  Agent lines from external attribution, not written in a linked session (not graded): README, app.py

JSON has them under facts.external_attribution on the scope finding, with graded: false, per-source counts in sources, and the paths in not_captured. The scope status and confidence do not change.

cognitive-debt

Each source with agent lines becomes one workflow, git-ai notes or Agent Trace, next to the recorded sessions. Its files get the same review evidence rules as a session's, on the current branch, from one second before the noted commit or the record's timestamp. The reporting window (--since, --until) does not apply to them: the range and the file already choose the lines.

External attribution (self-reported by the tool that wrote the lines):
  git-ai notes (main..feature), 1 of 2 commits has a note:
    AI lines:                8  (counted as agent-written)
    Mixed lines:             0  (AI and human; counted as agent-written)
    Human lines:             2  (not counted)
    Unknown lines:           0  (not counted)
    Already captured:        0  (counted once, under the session that captured them)
    Malformed:               0  (notes or records skipped)

JSON adds a top-level external_attribution list with one entry per source: source, label, subject, the counts above, already_captured_lines, tools, models, malformed, truncated and workflow_id. A git-ai entry also has notes_ref, and fetch when the ref is missing. Each entry in workflows and sessions has a source: captured_session for a recorded session, git_ai_notes or agent_trace_records otherwise.

A records file that cannot be read, notes that cannot be read, or a source in which every note or record is malformed makes cognitive-debt exit 1 with Error: and the reason. A count it cannot trust is not reported as zero.

review --cognitive-debt FILE reads external_attribution from the report and adds, for example, Counts agent lines from git-ai notes: 8 AI and 0 mixed. to the cognitive debt line in text and markdown, so a check failure shows where its lines came from. Review JSON has the same counts under artifacts.cognitive_debt.external_attribution, with source, ai_lines and mixed_lines.

CI: fetch the notes

The agent-strace GitHub Action fetches refs/notes/ai for you when review-commits is set. It fetches from the pull request head repository: the fork for a pull request from a fork, else origin. It passes the range to the reviewability check and to cognitive debt, and review-agent-trace-records passes a records file to both:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- uses: Siddhant-K-code/agent-trace@v0.132.0
  with:
    review-commits: origin/${{ github.base_ref }}..HEAD
    review-agent-trace-records: agent-trace.jsonl

If the range or the records file cannot be read, the check reports it, and cognitive debt leaves out only the source it cannot read and names it in a notice. Set review-fetch-agent-refs: "false" to skip the fetch of refs/notes/ai and of Entire checkpoints; see evidence order. In team mode the Action fetches refs/notes/ai from origin and reads the notes on the commits in the window.

Without the Action, actions/checkout does not fetch git notes. Fetch refs/notes/ai after the checkout and before agent-strace runs:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- name: Fetch git-ai notes
  run: git fetch origin 'refs/notes/ai:refs/notes/ai' || true

|| true keeps the job going when the remote has no notes. Notes exist only where they were pushed: for a pull request from a fork, they are in the fork. On GitLab, the agent-review component fetches them for the merge request.

Untrusted input

In CI, notes and records can come from a fork. agent-strace reads them as untrusted:

  • Size caps: 1 MiB per note, 16 MiB of notes per run, 16 MiB per records file, and 500 commits per range. A note over its cap is skipped as malformed. A run over the total or the commit cap is marked truncated. A records file over its cap is not read.
  • A note or record is skipped whole, and counted as malformed, when it has a wrong field type, a non-finite number (NaN, Infinity, 1e999), nesting too deep to parse, an unknown key, or an unsupported version. No part of it is used.
  • Line numbers must be whole numbers from 1 to 10,000,000, with the start no later than the end.
  • A path must be relative and stay inside the repository: no leading /, no drive letter, no .. part after \ becomes /, and at most 4,096 characters.
  • Output holds counts, repository-relative paths and tool names. Paths are printed through the same escaping as other trace text, so control characters show as escapes. A tool name is shown only when it is letters, digits, _ and -. Models appear only in JSON. Prompts, URLs, author names and custom attributes are never shown.

Not supported yet

  • Writing Agent Trace records (export --format agent-trace). A recorded write holds the text an agent wrote, not the line numbers it landed on in the committed file, so a record would need a line mapping agent-strace does not have yet.