RunLedger can post a risk receipt for the AI coding agent sessions behind a pull request. The receipt is one sticky comment that is updated on every push: a header with the highest risk (🟢 Low, 🟡 Medium, 🔴 High, with the score), a table with one row per session (title, agent and model, steps, estimated cost, risk), and a collapsible section per session with the Guard decisions, the test verdict, the risk reasons and the files changed. The comment states that it was built in safe mode, with paths shortened and e-mail addresses masked.
The comment is only ever updated in place when it is RunLedger's own comment, or a bot's. A comment someone else wrote that happens to contain the marker is left alone, and a new comment is created instead.
RunLedger reads the session files of every agent it supports: Claude Code .jsonl
transcripts under ~/.claude/projects/<project-folder>/ (on Windows:
%USERPROFILE%\.claude\projects\, or under $CLAUDE_CONFIG_DIR if you set it), Codex
rollout .jsonl files, Factory Droid .jsonl transcripts, and .runledger.json files
written by any agent in the RunLedger format. To find the sessions for a project:
cd path/to/project
runledger list # recent sessions for this folder, with their idsCopy the session files you want reviewed into .runledger/sessions/ in the repository.
The action scores every .jsonl and .runledger.json file in that folder, so copy only
the sessions for the work in the pull request. A Droid session needs its sibling
<session-id>.settings.json next to it: that file carries the token usage and cost.
Aider's .aider.chat.history.md is not scored directly: the action reads session files, not the
markdown history. To get an Aider run into the comment, write it in the RunLedger format
(format.md) into the folder, or run runledger receipt --agent aider locally and
share that receipt.
Privacy. A session transcript is a record of everything the agent saw: your prompts, file contents it read or wrote, command output, and anything pasted into the chat. It can contain secrets, such as API keys or the contents of
.envfiles. Review a session file before you commit it, and remove the lines you do not want to share. Anyone who can read the repository can read the committed file. The PR comment itself shows each session's first request, the file paths and the risk reasons, with known secret formats masked, and it is visible to everyone who can see the pull request. The masking in the PR comment does not sanitize the committed session file. For a public repository, do not commit a raw transcript unless you are comfortable publishing the whole file; runrunledger receiptlocally instead, or use this action with session files only in a private repository.
Copy examples/workflows/runledger.yml to
.github/workflows/runledger.yml. The job needs pull-requests: write to post the
comment, and contents: read to check the repository out:
name: RunLedger receipt
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
receipt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: kodji7202-code/runledger@v1.0.1
with:
sessions-dir: .runledger/sessions # default
fail-on: "60" # default; "" never fails the job| Input | Default | Meaning |
|---|---|---|
sessions-dir |
.runledger/sessions |
Folder of session files (.jsonl, .runledger.json) to score |
fail-on |
60 |
Fail the job if the highest score is at or above this (0-100); empty = never fail |
allow-empty |
false |
Accept a folder with no session files: notice, nothing posted, exit 0 |
python-version |
3.11 |
Python version the action installs |
github-token |
${{ github.token }} |
Token that posts the comment |
Outputs: risk_score (0-100) and risk_level (Low, Medium or High).
Exit codes of the command the action runs: 0 ok, 1 highest score at or above
--fail-on (and the comment was posted), 2 bad arguments, 3 runtime error (no
session files, no pull request, no token, GitHub API error). A comment that could not be
posted is always 3, even when the risk score is above the threshold; both messages are
printed. An empty session folder is a 3 too, unless --allow-empty is passed. The
action fails on any non-zero code.
Nothing is posted with --dry-run, and no network is used:
python -m runledger.github comment --session tests/fixtures/sample_session.jsonl --dry-run
python -m runledger.github comment --sessions-dir .runledger/sessions --dry-run > comment.mdTo post from your own machine, set GITHUB_TOKEN to a token with pull request write
access and pass the pull request explicitly:
python -m runledger.github comment --sessions-dir .runledger/sessions \
--repo owner/name --pr 42 --fail-on 60- Forks. Pull requests from forks get a read-only token, so GitHub refuses the
comment. RunLedger detects that (
Resource not accessible by integration, or apull_requestevent whose head repository is a fork), writes the full receipt to the job summary instead, prints a notice and exits0(thefail-onthreshold still applies). The receipt is then on the workflow run page rather than on the pull request. Any other refusal (401, or a 403 with a different message) stays an error with exit3. - One bad session. A session file that cannot be read is skipped with a
::warning file=…::annotation and named in the comment ("N session(s) could not be read"). The other sessions are still scored and posted. If no file can be read at all, nothing is posted and the exit code is3. - GitHub Enterprise Server. GitHub sets
GITHUB_API_URLin Actions automatically. Outside Actions, set it to the API base, for examplehttps://ghe.example.com/api/v3. - Token safety. The token is read from an environment variable (
--token-env, defaultGITHUB_TOKEN) and never printed. Do not pass tokens on the command line. - Safe mode. The comment is always built in safe mode: paths are shown relative to the
repository (or with
~for the home folder) and e-mail addresses are masked. See safe mode. - Session text cannot link anywhere. The titles, risk reasons and model names taken from a
session are escaped for Markdown, and a bare URL in them (
https://…,http://…,www.…) is shown with an invisible separator inside the scheme, because GitHub links such a URL on its own. An@is split with the same separator only where GitHub would read a mention (at the start of the text or after a character that is not a letter, digit or underscore), so@someonein a session's text is not a mention while a remote such asgit@github.com:org/repo.gitis shown exactly as it was written. The footer's link tohttps://runledger.siteis the only live link in the comment. - Test verdict. The
Tests:line describes the session's final test command: the number of test commands, that run's summary and the verdict (last run 3 passed, 0 failed · verdict: passed). When the final command's output has no readable summary, the line sayslast run unreadable (…) · verdict: unknownand names any readable earlier run as earlier, so a final unverified run is never reported as a pass. A session with no test command saysno tests run. - Size. The comment is kept under 60,000 characters. Long reports are shortened with a notice at the end.