ghostauthor 1.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ghostauthor-1.6.1/LICENSE +21 -0
- ghostauthor-1.6.1/PKG-INFO +506 -0
- ghostauthor-1.6.1/README.md +478 -0
- ghostauthor-1.6.1/ghostauthor/__init__.py +7 -0
- ghostauthor-1.6.1/ghostauthor/__main__.py +14 -0
- ghostauthor-1.6.1/ghostauthor/cli.py +764 -0
- ghostauthor-1.6.1/ghostauthor/coverage.py +537 -0
- ghostauthor-1.6.1/ghostauthor/engine.py +228 -0
- ghostauthor-1.6.1/ghostauthor/evidence.py +191 -0
- ghostauthor-1.6.1/ghostauthor/gitparse.py +284 -0
- ghostauthor-1.6.1/ghostauthor/lint.py +84 -0
- ghostauthor-1.6.1/ghostauthor/mcp_server.py +481 -0
- ghostauthor-1.6.1/ghostauthor/models.py +203 -0
- ghostauthor-1.6.1/ghostauthor/options.py +288 -0
- ghostauthor-1.6.1/ghostauthor/portfolio.py +476 -0
- ghostauthor-1.6.1/ghostauthor/report.py +574 -0
- ghostauthor-1.6.1/ghostauthor/roster/agents.json +60 -0
- ghostauthor-1.6.1/ghostauthor/roster.py +213 -0
- ghostauthor-1.6.1/ghostauthor/signer.py +363 -0
- ghostauthor-1.6.1/ghostauthor/web/app.html +850 -0
- ghostauthor-1.6.1/ghostauthor/web.py +418 -0
- ghostauthor-1.6.1/ghostauthor.egg-info/PKG-INFO +506 -0
- ghostauthor-1.6.1/ghostauthor.egg-info/SOURCES.txt +43 -0
- ghostauthor-1.6.1/ghostauthor.egg-info/dependency_links.txt +1 -0
- ghostauthor-1.6.1/ghostauthor.egg-info/entry_points.txt +3 -0
- ghostauthor-1.6.1/ghostauthor.egg-info/requires.txt +2 -0
- ghostauthor-1.6.1/ghostauthor.egg-info/top_level.txt +2 -0
- ghostauthor-1.6.1/pyproject.toml +45 -0
- ghostauthor-1.6.1/setup.cfg +4 -0
- ghostauthor-1.6.1/tests/test_cli.py +68 -0
- ghostauthor-1.6.1/tests/test_coverage.py +181 -0
- ghostauthor-1.6.1/tests/test_engine.py +203 -0
- ghostauthor-1.6.1/tests/test_evidence.py +186 -0
- ghostauthor-1.6.1/tests/test_gitparse.py +309 -0
- ghostauthor-1.6.1/tests/test_hardening.py +344 -0
- ghostauthor-1.6.1/tests/test_hook.py +289 -0
- ghostauthor-1.6.1/tests/test_lint.py +168 -0
- ghostauthor-1.6.1/tests/test_mcp.py +336 -0
- ghostauthor-1.6.1/tests/test_options.py +390 -0
- ghostauthor-1.6.1/tests/test_portfolio.py +211 -0
- ghostauthor-1.6.1/tests/test_report.py +161 -0
- ghostauthor-1.6.1/tests/test_roster.py +211 -0
- ghostauthor-1.6.1/tests/test_schema.py +108 -0
- ghostauthor-1.6.1/tests/test_sign.py +249 -0
- ghostauthor-1.6.1/tests/test_web.py +265 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xiangsir
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ghostauthor
|
|
3
|
+
Version: 1.6.1
|
|
4
|
+
Summary: Deterministic AI code provenance ledger: who signed the commits in your repo — auditable, reproducible, no LLM. Stdlib only.
|
|
5
|
+
Author: xiangsir
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/xiangsir4088/ghostauthor
|
|
8
|
+
Project-URL: Repository, https://github.com/xiangsir4088/ghostauthor
|
|
9
|
+
Project-URL: Releases, https://github.com/xiangsir4088/ghostauthor/releases
|
|
10
|
+
Project-URL: Mirror (AtomGit), https://atomgit.com/xiangsir/ghostauthor
|
|
11
|
+
Keywords: ai,provenance,git,audit,mcp,ci,attribution
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Environment :: Console
|
|
21
|
+
Classifier: Environment :: Web Environment
|
|
22
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# ghostauthor
|
|
30
|
+
|
|
31
|
+
> **Don't let "looks AI-written" pass as an audit conclusion — the signature is the auditable evidence.**
|
|
32
|
+
> 别让「看着像 AI 写的」当成审计结论——署名才是可审计的证据。
|
|
33
|
+
|
|
34
|
+
`ghostauthor` is a deterministic ledger of AI code provenance. It reads what
|
|
35
|
+
agents already sign — the `Co-Authored-By:` git trailers — and answers, for
|
|
36
|
+
any repository: **which agent signed which commits, how many lines, in what
|
|
37
|
+
sessions.** No LLM, no style detection, no network. Python, stdlib only.
|
|
38
|
+
|
|
39
|
+
## What problem does this solve
|
|
40
|
+
|
|
41
|
+
"AI code ratio" is already a number everyone quotes and nobody can defend.
|
|
42
|
+
Today it comes from one of three places:
|
|
43
|
+
|
|
44
|
+
1. **Usage trackers** count tokens spent in a session. That measures
|
|
45
|
+
*activity*, not *output* — a long session can merge zero code.
|
|
46
|
+
2. **Style classifiers** guess "this looks like AI". Probabilistic — and it
|
|
47
|
+
cannot answer the question an auditor actually asks: *which commit, which
|
|
48
|
+
agent, when*?
|
|
49
|
+
3. **Host-bound dashboards** (e.g. GitLab's `refs/notes/ai`) work great —
|
|
50
|
+
if your whole org lives on that host and that mechanism.
|
|
51
|
+
|
|
52
|
+
The real problem is not "can we measure AI output?". The real problem is that
|
|
53
|
+
**"AI wrote it" is currently an unverifiable claim in commit history.** The
|
|
54
|
+
agents already sign their work in a standard place — git trailers. Nobody
|
|
55
|
+
reads those signatures the way `git log` reads everything else: with rigor.
|
|
56
|
+
|
|
57
|
+
`ghostauthor` does exactly that one thing, and treats the answer like an
|
|
58
|
+
audit artifact: reproducible, traceable, appealable.
|
|
59
|
+
|
|
60
|
+
## Start here if the ledger is empty
|
|
61
|
+
|
|
62
|
+
A provenance ledger has a cold-start problem: if the agents in your repository
|
|
63
|
+
never wrote a trailer, the audit is *correct* and *useless*. Every commit is
|
|
64
|
+
`unsigned`, the ratio is `0.0%`, and it looks like the tool is broken. It is
|
|
65
|
+
not — the signatures are missing, and there are exactly two reasons:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
ghostauthor coverage /path/to/your/repo
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`coverage` separates them, because they have different fixes:
|
|
72
|
+
|
|
73
|
+
| What it finds | What it means | Fix |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| A trailer no roster rule claims | The signature exists (`Co-Authored-By: Cursor <…>`), the roster just does not know that name | **Data**: add a roster rule (`--roster`) |
|
|
76
|
+
| Unsigned commits carrying a literal tool marker (`Generated with [Claude Code]`) | The agent never emitted a trailer | **Write path**: `install-hook`, or turn the trailer on in the agent |
|
|
77
|
+
| Unsigned commits with no marker | Unknown. It may be a human, or an agent that leaves no trace | **Nothing is claimed.** The ledger records signatures; it does not guess |
|
|
78
|
+
|
|
79
|
+
It also reports coverage by author and by ISO week, so "when did adoption
|
|
80
|
+
start, and who is still outside it" is a measurement rather than a guess.
|
|
81
|
+
`coverage` never changes an attribution — markers are hints, and they are
|
|
82
|
+
labelled as hints.
|
|
83
|
+
|
|
84
|
+
## 60-second start
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install ghostauthor
|
|
88
|
+
# (PyPI, v1.3+; always-latest alternative:
|
|
89
|
+
# pip install git+https://atomgit.com/xiangsir/ghostauthor.git)
|
|
90
|
+
ghostauthor /path/to/your/repo
|
|
91
|
+
ghostauthor /path/to/your/repo --format json --max-ai-ratio 0.5
|
|
92
|
+
ghostauthor /path/to/your/repo --since 2026-07-01 --until 2026-10-01
|
|
93
|
+
# audit a quarter, not a history (epoch, YYYY-MM-DD or ISO 8601; since is
|
|
94
|
+
# inclusive, until is exclusive)
|
|
95
|
+
ghostauthor /path/to/your/repo --ref feature-x
|
|
96
|
+
# audit one branch/tag/commit instead of HEAD
|
|
97
|
+
ghostauthor /path/to/your/repo --base main --ref feature-x
|
|
98
|
+
# two-branch diff: only what feature-x adds over main (git range main..feature-x)
|
|
99
|
+
ghostauthor /path/to/your/repo --format sarif
|
|
100
|
+
# SARIF 2.1.0 for compliance pipelines
|
|
101
|
+
ghostauthor /path/to/your/repo --format html --out audit.html
|
|
102
|
+
# a self-contained brief for readers who will not run the CLI: no script,
|
|
103
|
+
# no remote asset, no timestamp — the same state regenerates the same bytes
|
|
104
|
+
ghostauthor portfolio ~/code --format html --out portfolio.html
|
|
105
|
+
# the same ledger across every repository under a directory (aggregate is
|
|
106
|
+
# weighted by commit, never a mean of ratios); a broken repo is recorded
|
|
107
|
+
# in the output instead of aborting the scan
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Signing (opt-in, v1.0) — the only write path, off by default:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
ghostauthor sign /path/to/repo --agent claude
|
|
114
|
+
# dry-run by default: shows the amended message, writes nothing
|
|
115
|
+
ghostauthor sign /path/to/repo --agent claude --commit
|
|
116
|
+
# actually amends HEAD with the agent's Co-Authored-By trailer (roster `signing` identity)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Signing at commit time (opt-in, v1.1) — a repo-level `commit-msg` hook,
|
|
120
|
+
installed only when you ask for it:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
ghostauthor install-hook /path/to/repo --agent claude
|
|
124
|
+
# every commit now carries the trailer at commit time — before the commit
|
|
125
|
+
# exists, so no amend and no sha rewrite. Replaces its own hook
|
|
126
|
+
# idempotently; never touches a foreign one.
|
|
127
|
+
ghostauthor uninstall-hook /path/to/repo
|
|
128
|
+
# back to unsigned; a one-off bypass is `git commit --no-verify` (the
|
|
129
|
+
# audit shows the bypass as an unsigned commit — nothing is hidden)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
And a lint that warns — without rejecting — when a legal roster is fragile:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
ghostauthor lint-roster --roster my-team.json
|
|
136
|
+
# [warn] lint-catch-all / lint-overlap; exit 0 either way. Validation still
|
|
137
|
+
# rejects malformed rosters (exit 2); lint only surfaces fragility
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Drilling into a verdict (v1.2) — per-commit evidence and a reproducible
|
|
141
|
+
bundle:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
ghostauthor evidence /path/to/repo <sha>
|
|
145
|
+
# which roster rule matched each trailer and why the audit attributed the
|
|
146
|
+
# commit the way it did — the same attribution code as the audit, so the
|
|
147
|
+
# two can never disagree
|
|
148
|
+
ghostauthor evidence /path/to/repo <sha> --format json
|
|
149
|
+
# machine-readable; the JSON contract is frozen (schema_version 1,
|
|
150
|
+
# schema/evidence.schema.json — the same additive/bump policy as the report)
|
|
151
|
+
ghostauthor evidence /path/to/repo --bundle out/bundle
|
|
152
|
+
# a reproducible evidence package: report.json (frozen schema) +
|
|
153
|
+
# evidence.json + the exact roster used + manifest.txt with sha256s — no
|
|
154
|
+
# timestamps, so re-running on the same state is byte-identical
|
|
155
|
+
# (canonical UTF-8/LF)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The JSON contract it reads and writes under is frozen: `schema_version` in
|
|
159
|
+
the output, `schema/report.schema.json` as the machine-checkable form,
|
|
160
|
+
`docs/schema.md` as the single source of truth (compatibility policy
|
|
161
|
+
included). What signing means — and what it deliberately is **not** — is
|
|
162
|
+
documented in [docs/attestation.md](docs/attestation.md): the read side
|
|
163
|
+
reports, the write side makes a claim, and the tool makes claims easy and
|
|
164
|
+
auditable, not true.
|
|
165
|
+
|
|
166
|
+
No repository handy? Clone this one and build the bundled demo fixtures
|
|
167
|
+
(deterministic: fixed dates, identities, contents — the SHAs are stable):
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://atomgit.com/xiangsir/ghostauthor.git
|
|
171
|
+
cd ghostauthor
|
|
172
|
+
python -m examples.make_fixtures out/fixtures
|
|
173
|
+
python -m ghostauthor.cli out/fixtures/mixed
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Output, verbatim from a real run on the `mixed` fixture:
|
|
177
|
+
|
|
178
|
+
```text
|
|
179
|
+
ghostauthor — deterministic AI code provenance ledger
|
|
180
|
+
repo: D:\Projects\atomcode\ghostauthor\out\fixtures\mixed ref: HEAD
|
|
181
|
+
|
|
182
|
+
commits: 12 total
|
|
183
|
+
agent-signed 6 (50.0%)
|
|
184
|
+
cosigned-unknown 1 (8.3%)
|
|
185
|
+
unsigned 5 (41.7%)
|
|
186
|
+
|
|
187
|
+
lines touched: 18 total
|
|
188
|
+
agent 9 cosigned 2 unsigned 7
|
|
189
|
+
|
|
190
|
+
agents:
|
|
191
|
+
ID NAME COMMITS +ADDED -REMOVED SESSIONS LONGEST
|
|
192
|
+
claude Claude (Anthropic) 4 4 2 1 4
|
|
193
|
+
codex Codex (OpenAI) 3 3 2 1 3
|
|
194
|
+
|
|
195
|
+
authors x agents:
|
|
196
|
+
AUTHOR claude codex cosigned unsigned TOTAL
|
|
197
|
+
Sam Human <sam@example.com> 4 3 1 5 12
|
|
198
|
+
|
|
199
|
+
findings (3):
|
|
200
|
+
[warn] cosigned-unknown 9f4f9cc34f31: Co-Authored-By: VibeBot <vibe@example.com>
|
|
201
|
+
Co-Authored-By present but no roster rule matched
|
|
202
|
+
[info] multi-agent-commit 99186ce21e94
|
|
203
|
+
commit carries signatures of several agents: claude, codex
|
|
204
|
+
[warn] trailer-in-body bf73ac1eecac: Co-Authored-By: Claude <noreply@anthropic.com>
|
|
205
|
+
Co-Authored-By line outside the trailer block is prose, not metadata — ignored by design
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
As a CI gate, the exit code is the contract — also a real run, on the
|
|
209
|
+
`agent-heavy` fixture (11 of 12 commits agent-signed):
|
|
210
|
+
|
|
211
|
+
```text
|
|
212
|
+
$ python -m ghostauthor.cli out/fixtures/agent-heavy --max-ai-ratio 0.5
|
|
213
|
+
...
|
|
214
|
+
gate: ai ratio 91.7% vs limit 50.0% — BREACHED
|
|
215
|
+
$ echo $?
|
|
216
|
+
4
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
| Exit code | Meaning |
|
|
220
|
+
|---|---|
|
|
221
|
+
| `0` | report produced; gate (if any) not breached |
|
|
222
|
+
| `2` | environment/usage error: not a repo, no commits, bad roster, bad args |
|
|
223
|
+
| `4` | gate breached: agent-signed ratio above `--max-ai-ratio` |
|
|
224
|
+
|
|
225
|
+
It also ships a **read-only MCP server** (three tools — `repo_authorship_report`,
|
|
226
|
+
`commit_evidence` and `adoption_diagnosis` — stdio, zero dependencies) — see
|
|
227
|
+
`ghostauthor/mcp_server.py`. Each exposes its CLI command's option surface
|
|
228
|
+
(scope, window, roster, gate) and returns bytes that are **identical to the
|
|
229
|
+
CLI's** for the same request. It reports; it never executes. That is an invariant, not a
|
|
230
|
+
promise.
|
|
231
|
+
|
|
232
|
+
## Web UI
|
|
233
|
+
|
|
234
|
+
The same ledger with a local dashboard: one self-contained HTML page served
|
|
235
|
+
by a stdlib-only `http.server`. No framework, no build step, no CDN — the
|
|
236
|
+
"runs on the machine it audits" invariant holds for the web version too, and
|
|
237
|
+
the page only ever triggers the read-only `git log` in the repository you
|
|
238
|
+
point it at. The JSON it shows and lets you download is **byte-identical to
|
|
239
|
+
the CLI's** `--format json` for the same repo state: one source of truth,
|
|
240
|
+
two skins.
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
ghostauthor-web # → http://127.0.0.1:8321
|
|
244
|
+
ghostauthor-web --port 9000 # different port
|
|
245
|
+
ghostauthor-web --host 0.0.0.0 # only if you really mean it
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
It binds `127.0.0.1` by default. Enter one or two repository paths — each
|
|
249
|
+
optionally scoped to a ref (`main` vs a feature branch) — plus the same
|
|
250
|
+
options the CLI has: time window, session gap, `--max-ai-ratio` gate, roster
|
|
251
|
+
file or dir. Add a second entry to compare two codebases, or one codebase at
|
|
252
|
+
two refs, side by side. Every count expands to its commit list, and every
|
|
253
|
+
commit row drills into its **evidence** — which roster rule matched each
|
|
254
|
+
trailer and why the audit attributed the commit that way; a standalone query
|
|
255
|
+
box covers shas outside the current audit scope. The raw byte-stable JSON is
|
|
256
|
+
one click away. Under the hood the dashboard is two JSON endpoints —
|
|
257
|
+
`/api/audit` and `/api/evidence` — each serving bytes identical to the CLI for
|
|
258
|
+
the same request, so the page and the terminal can never disagree. Like the
|
|
259
|
+
CLI and the MCP server, the web transport is **read-only**: it reports, it
|
|
260
|
+
never executes.
|
|
261
|
+
|
|
262
|
+
## Design trade-offs
|
|
263
|
+
|
|
264
|
+
| Decision | Why |
|
|
265
|
+
|---|---|
|
|
266
|
+
| No LLM anywhere in the verdict path | A reviewer that can be steered by wording will eventually be steered by wording. Verdicts must be re-runnable, auditable, and appealable. |
|
|
267
|
+
| Trailers only — no style detection | Provenance, not guessing. "Unsigned" is a category, not an accusation: unsigned ≠ human. |
|
|
268
|
+
| Stdlib only, zero dependencies | An audit tool must run on the machine it audits. No venv ritual, no supply chain of its own. |
|
|
269
|
+
| Read-only MCP server, two read-only tools | The read side reports; it never executes. That is an invariant, not a promise. |
|
|
270
|
+
| One write path, opt-in, supervised (v1.0) | The moment a tool can *act*, the risk model changes from "advice" to "supervised decision". So the write path crosses that line **on purpose and visibly**: `ghostauthor sign` is an explicit subcommand (no hook, no default), dry-run by default, idempotent, refuses conflicts, and signs only with identities the roster itself validates. The boundary is written down in [docs/attestation.md](docs/attestation.md). |
|
|
271
|
+
| Exit codes `0/2/4` as a CI contract | A tool nobody can wire into a pipeline is a toy. |
|
|
272
|
+
| Missing ≡ empty, never an exception | Incomplete data is the norm. A tool that crashes on a malformed trailer demands "fill it in completely first" — nobody does that under pressure. |
|
|
273
|
+
|
|
274
|
+
## Invariants — what keeps this honest for years
|
|
275
|
+
|
|
276
|
+
These are not features. They are the things that would quietly rot the tool:
|
|
277
|
+
|
|
278
|
+
1. **Provenance, not style.** Only the git trailer block is read — git's
|
|
279
|
+
semantics, not our invention. A `Co-Authored-By:` line in the *body* of a
|
|
280
|
+
message is prose: ignored as data, surfaced as a `trailer-in-body`
|
|
281
|
+
finding. Without this boundary, the tool becomes a guesser wearing a
|
|
282
|
+
ledger's skin.
|
|
283
|
+
2. **Every number is traceable.** Every bucket, agent and session count
|
|
284
|
+
carries its commit list in the JSON report. A verdict you cannot expand
|
|
285
|
+
into evidence is a verdict you cannot defend in a review.
|
|
286
|
+
3. **The cap.** One commit can carry several agent signatures. Per-agent
|
|
287
|
+
attribution may overlap — but the deduplicated totals never do. The
|
|
288
|
+
report shows both numbers, so "per-agent sums exceed the total" is a
|
|
289
|
+
documented fact, not a contradiction.
|
|
290
|
+
4. **Same repo state ⇒ same report.** Commits are ordered by
|
|
291
|
+
`(authored_at, sha)` read from the commits — never the wall clock, never
|
|
292
|
+
hash-iteration luck. JSON output is byte-stable (`sort_keys`): diffable,
|
|
293
|
+
CI-friendly, archive-able.
|
|
294
|
+
5. **Boundary semantics are pinned by tests.** A ratio *exactly at*
|
|
295
|
+
`--max-ai-ratio` is a PASS (`>`, not `>=`); a window *includes* its
|
|
296
|
+
`--since` bound and *excludes* its `--until` bound. Changing any of
|
|
297
|
+
these semantics requires changing the test on purpose.
|
|
298
|
+
|
|
299
|
+
The write path (v1.0) adds five more — see
|
|
300
|
+
[docs/attestation.md](docs/attestation.md) for the full boundary:
|
|
301
|
+
|
|
302
|
+
6. **Round-trip (load-bearing).** Sign a commit with a roster agent and
|
|
303
|
+
the audit must attribute it to that agent — never `cosigned`, never
|
|
304
|
+
`unsigned`. A signature that could not be read back is refused at
|
|
305
|
+
roster validation (`roster-signing-roundtrip`) and again at sign time
|
|
306
|
+
(`sign-ambiguous`), not written.
|
|
307
|
+
7. **Idempotency.** Signing an already-signed commit is a no-op; the
|
|
308
|
+
second run's diff is empty.
|
|
309
|
+
8. **Opt-in & consent.** The command exists only when explicitly invoked
|
|
310
|
+
(no default flow); dry-run is the default and `--commit` is the
|
|
311
|
+
explicit consent. The v1.1 commit-msg hook extends the same line: it
|
|
312
|
+
exists only after an explicit `install-hook`, is repo-level,
|
|
313
|
+
marker-protected (a foreign `commit-msg` is never overwritten or
|
|
314
|
+
removed), and removable at any time — no repository is ever signed
|
|
315
|
+
by default.
|
|
316
|
+
9. **No-merge on conflict.** A commit already signed by *another* roster
|
|
317
|
+
agent is refused (`sign-conflict`) — conflicts are for humans, never
|
|
318
|
+
for the tool to resolve.
|
|
319
|
+
10. **Single source of truth.** Matching (read) and signing (write) share
|
|
320
|
+
one roster; the signing identity is part of that agent's roster
|
|
321
|
+
record, not env or free text.
|
|
322
|
+
|
|
323
|
+
## A traceable sample (real run, JSON fragment)
|
|
324
|
+
|
|
325
|
+
From the same `mixed` fixture — every count below expands to the commit
|
|
326
|
+
lists under `bucket_commit_shas`:
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"agents": [
|
|
331
|
+
{
|
|
332
|
+
"commits": 4,
|
|
333
|
+
"display_name": "Claude (Anthropic)",
|
|
334
|
+
"first_ts": 1767229200,
|
|
335
|
+
"id": "claude",
|
|
336
|
+
"last_ts": 1767261600,
|
|
337
|
+
"lines_added": 4,
|
|
338
|
+
"lines_removed": 2,
|
|
339
|
+
"longest_session_commits": 4,
|
|
340
|
+
"sessions": 1
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"commits": 3,
|
|
344
|
+
"display_name": "Codex (OpenAI)",
|
|
345
|
+
"first_ts": 1767240000,
|
|
346
|
+
"id": "codex",
|
|
347
|
+
"last_ts": 1767261600,
|
|
348
|
+
"lines_added": 3,
|
|
349
|
+
"lines_removed": 2,
|
|
350
|
+
"longest_session_commits": 3,
|
|
351
|
+
"sessions": 1
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
"ai_ratio": 0.5,
|
|
355
|
+
"bucket_commit_shas": {
|
|
356
|
+
"agent": [
|
|
357
|
+
"deb8b1e68469d720a92ba6b1ab7efedc0dbb07b2",
|
|
358
|
+
"5dc8f5c47ad6ecda46bc52b1f2ca38f05f70c904",
|
|
359
|
+
"d9bdca2577cb2a312e8397dbef7e94cffe01d298",
|
|
360
|
+
"06ba554e15d5ec38c87d17134470b357deb137e5",
|
|
361
|
+
"b7439afbe93d8edd462b4abe2473a1b3d8a10855",
|
|
362
|
+
"99186ce21e94660c0466914561ccd0e7e0943c09"
|
|
363
|
+
],
|
|
364
|
+
...
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## How to contribute
|
|
368
|
+
|
|
369
|
+
The most valuable contribution to this project is **not code — it is the
|
|
370
|
+
roster**. The builtin roster ships 8 agents — 7 of them with a canonical
|
|
371
|
+
`signing` identity, so `ghostauthor sign --agent claude` works out of the
|
|
372
|
+
box; yours is probably not on it:
|
|
373
|
+
|
|
374
|
+
- `ghostauthor/roster/agents.json` is declarative: `id`, `display_name`,
|
|
375
|
+
`name_patterns` (regexes matched against the trailer name) and
|
|
376
|
+
`email_domains` (matched against the trailer's email domain). The first
|
|
377
|
+
match in file order wins — precedence is data, not magic.
|
|
378
|
+
- An optional `signing` section (`{"name": ..., "email": ...}`) opts the
|
|
379
|
+
agent into the write path: `ghostauthor sign --agent <id>` will then
|
|
380
|
+
sign with exactly that identity — and the validator rejects any
|
|
381
|
+
identity that would not read back to its own agent
|
|
382
|
+
(`roster-signing-roundtrip`).
|
|
383
|
+
- Rosters are **validated, not trusted**: duplicate ids, broken regexes,
|
|
384
|
+
empty selectors are rejected with a rule id — never silently repaired. A
|
|
385
|
+
silently "fixed" roster would make the verdict unauditable.
|
|
386
|
+
- Teams can keep several roster files in one directory (`--roster-dir`):
|
|
387
|
+
files merge in sorted filename order, and a duplicate id *across* files
|
|
388
|
+
is rejected (`roster-dir-dup`) — conflicts are for humans to resolve,
|
|
389
|
+
never for merge order to hide.
|
|
390
|
+
- Bring a test: `tests/test_roster.py` is the validator's own spec.
|
|
391
|
+
|
|
392
|
+
The full writing guide — matching semantics (first-match-wins, prefix
|
|
393
|
+
matches, explicit anchors), every validation rule id, lint rules and
|
|
394
|
+
best practice — is [docs/roster.md](docs/roster.md).
|
|
395
|
+
|
|
396
|
+
For code contributions, read `docs/architecture.md` first — each module has
|
|
397
|
+
things it is forbidden to do (the engine does no rendering, the report does
|
|
398
|
+
no recomputation, the MCP server does no execution). Keep it that way.
|
|
399
|
+
|
|
400
|
+
## Roadmap
|
|
401
|
+
|
|
402
|
+
- [x] v0.2 — `--since/--until` time windows (audit a quarter, not a history)
|
|
403
|
+
- [x] v0.2 — SARIF 2.1.0 output for compliance pipelines
|
|
404
|
+
- [x] v0.2 — multiple roster files / `--roster-dir`
|
|
405
|
+
- [x] v0.3 — `--ref`: audit one branch/tag/commit instead of HEAD
|
|
406
|
+
- [x] v0.3 — web UI: local read-only dashboard, stdlib only, byte-stable JSON, side-by-side comparison
|
|
407
|
+
- [x] v0.3.1 — `--base`: CLI two-branch diff (git range `base..target`; the web UI compares two refs side by side)
|
|
408
|
+
- [x] v0.3.1 — per-author × per-agent cross-tabulation (every cell traceable to a commit list)
|
|
409
|
+
- [x] v0.3.2 — encoding hardening: UTF-8 stdout/stderr and git subprocess (`i18n.logOutputEncoding`, `core.quotepath=false`) so Chinese Windows (GBK locale) never mangles reports; web UI light theme
|
|
410
|
+
- [x] v0.4.0 — CI integration: composite GitHub Action, self-audit workflow, PR comment template
|
|
411
|
+
- [x] v0.5.0 — read-side contract frozen: `schema_version` in the JSON, `schema/report.schema.json`, golden snapshot, verify enforces the freeze (a mutation goes red)
|
|
412
|
+
- [x] v1.0.0 — write path: opt-in `ghostauthor sign` (dry-run default, `--commit` to apply, idempotent, conflict refused) with the detection/attestation boundary documented in `docs/attestation.md`
|
|
413
|
+
- [x] v1.1.0 — commit-time signing: repo-level `commit-msg` hook via `install-hook` / `uninstall-hook` (signed at commit time — no amend, no sha rewrite; marker-protected against foreign hooks; `--no-verify` is the documented escape hatch) + `lint-roster` (catch-all / cross-agent-overlap warnings, exit 0) + canonical `signing` identities for the builtin roster
|
|
414
|
+
- [x] v1.2.0 — per-commit `evidence` (which roster rule matched each trailer and why — the same attribution code as the audit, so the two can never disagree) + `--bundle` reproducible evidence package (report + evidence + roster snapshot + sha256 manifest, no timestamps) + `roster.match_detail` (reason-carrying match)
|
|
415
|
+
- [x] v1.3.0 — installable from PyPI (`pip install ghostauthor`; OIDC trusted publishing, no token in the repo) + the evidence JSON contract frozen (`schema/evidence.schema.json`, enforced by verify — a mutation goes red) + `docs/roster.md` (writing guide) + `README.zh.md`
|
|
416
|
+
- [x] v1.4.0 — read-side surface parity: the MCP `repo_authorship_report` gains the full option surface (scope, window, roster, gate) and a second read-only tool `commit_evidence`; the web gains `/api/evidence` + an in-dashboard evidence drill-down. Every surface now serves the **same bytes** as the CLI for the same request — parity by construction, not by test, because report/evidence selection is one shared function
|
|
417
|
+
- [x] v1.5.0 — **product surface**: `coverage` (adoption diagnosis — separates an unrecognized signature from a missing one, and never guesses), `--format html` (a self-contained, timestamp-free brief that can be mailed or archived), `portfolio` (multi-repository aggregate, weighted by commit, partial failures recorded). Read-side additions only — no schema bump
|
|
418
|
+
- [x] v1.6.0 — **one definition of a boundary**: scope / window / roster / session gap / gate move into `ghostauthor/options.py`, called by the CLI, the MCP server and the web transport. Fixes the drift the copies had accumulated — `/api/audit` silently ignored `base`, lost the CLI's error codes, and spelled the scope flag differently from its own siblings. Read-side only — no schema bump
|
|
419
|
+
|
|
420
|
+
## Free and commercial
|
|
421
|
+
|
|
422
|
+
The CLI is MIT and always will be. It is also the whole product for one
|
|
423
|
+
repository: audit, evidence, signing, the MCP server, the local dashboard.
|
|
424
|
+
|
|
425
|
+
Everything a **team or an auditor** needs on top of that is a separate,
|
|
426
|
+
paid surface — and the boundary is deliberately drawn at the point where
|
|
427
|
+
work stops being a command and becomes a deliverable:
|
|
428
|
+
|
|
429
|
+
| Free (MIT, this repository) | Commercial |
|
|
430
|
+
|---|---|
|
|
431
|
+
| CLI audit, JSON / text / markdown / SARIF | Branded HTML briefs for a board or a client |
|
|
432
|
+
| Per-commit evidence, evidence bundles | Multi-repository portfolio reports with history |
|
|
433
|
+
| Local web dashboard | Hosted scans, scheduled snapshots, trend lines |
|
|
434
|
+
| `coverage` diagnosis | Policy-as-code: per-path / per-team rules |
|
|
435
|
+
| `portfolio` over local checkouts | Organisation roll-up with SSO and retention |
|
|
436
|
+
| Single-repository CI gate | Audit liaison: methodology pack, reviewer Q&A |
|
|
437
|
+
|
|
438
|
+
Nothing in the free tier is crippled after the fact, and the JSON contract is
|
|
439
|
+
frozen either way: a report you generate today validates against the same
|
|
440
|
+
schema next year. If you need the commercial surface, open an issue with
|
|
441
|
+
`commercial` in the title.
|
|
442
|
+
|
|
443
|
+
## Tests
|
|
444
|
+
|
|
445
|
+
312 tests pin **properties**, not coverage:
|
|
446
|
+
|
|
447
|
+
- **Reproducibility** — same repo state ⇒ identical report, regardless of input order
|
|
448
|
+
- **Trailer-block semantics** — negative cases: signature in the body, signature followed by prose, CRLF messages, missing email, lowercase keys, continuation lines
|
|
449
|
+
- **The validator, validated** — malformed rosters that must be rejected, each checked against its rule id
|
|
450
|
+
- **The cap** — a multi-agent commit is counted once in totals; per-agent overlap is documented, not hidden
|
|
451
|
+
- **Gate boundary** — exactly at the limit is a pass; a breach exits 4
|
|
452
|
+
- **Window boundary** — `--since` inclusive, `--until` exclusive; an empty or inverted window is a contract error, not a silently empty report
|
|
453
|
+
- **Window-bound parsing** — epoch / date / ISO 8601 resolve to the same instants; naive values are UTC; garbage is rejected
|
|
454
|
+
- **Roster-dir merge** — sorted filename order, cross-file duplicate ids rejected by rule id
|
|
455
|
+
- **Signing identity** — the roster `signing` section is optional; a signing identity that would not read back to its own agent is rejected (`roster-signing-roundtrip`), never repaired
|
|
456
|
+
- **Write path** — dry-run is the default (nothing lands without `--commit`); sign → audit round-trips to the same agent; a second sign is a no-op; another roster agent's signature is refused (`sign-conflict`); an identity that roster precedence would misattribute is refused (`sign-ambiguous`); every error path exits 2 and changes nothing
|
|
457
|
+
- **Commit-msg hook** — a real `git commit` fires the installed hook and the trailer round-trips to the audit; a presigned message keeps exactly one trailer (idempotent); a conflicting commit is **blocked** (non-zero commit-msg exit aborts the commit, nothing lands); `--no-verify` bypasses and the audit shows the unsigned commit; `install-hook` refuses a foreign `commit-msg` (`hook-exists`) and `uninstall-hook` refuses one it did not install (`hook-not-ours`); the generated script pins its own interpreter, PYTHONPATH and roster
|
|
458
|
+
- **Roster lint** — a catch-all `name_patterns` entry is warned (`lint-catch-all`), a signing identity that roster precedence would attribute to another agent is warned (`lint-overlap`); warnings are advisory (exit 0, deterministic, byte-stable JSON), a malformed roster is still a hard error (exit 2); the builtin roster lints clean
|
|
459
|
+
- **Evidence** — for every commit, the evidence's attribution equals the audit's bucket (they are the same code); a matched trailer names the exact roster selector (`match_detail` agrees with `match`); the JSON is byte-stable; an unknown SHA exits 2 (`sha-unknown`); a `--bundle` is reproducible (same state + path ⇒ same bytes), its `report.json` equals the audit's report, its manifest sha256s match the files on disk, and writing into an existing directory is refused (`bundle-exists`)
|
|
460
|
+
- **Evidence freeze** — the real `evidence --format json` output validates against `schema/evidence.schema.json`; the bundle's `evidence.json` is the same bytes; a removed key, an added key and a bogus attribution are each rejected by name
|
|
461
|
+
- **Schema freeze** — the real `render_json` output validates against `schema/report.schema.json`; the golden snapshot is byte-stable; removed/added keys are rejected by name
|
|
462
|
+
- **SARIF mapping** — byte-stable; findings → results with rule descriptors; a breached gate is an `error`-level result
|
|
463
|
+
- **Framing contract** — the git-output parser is pinned against crafted streams, including rejection of unframed output
|
|
464
|
+
- **Ref scoping** — a ref limits the scan to that branch/tag/commit; combining it with `--all` is rejected (`ref-conflict`); a missing path is `not-a-repo`, never a server failure
|
|
465
|
+
- **Two-branch diff** — `--base` scans git's `base..target` range; an empty range is `no-commits` (never a silent report); `--base` + `--all` is `ref-conflict`; a `-`-leading base is `ref-invalid`
|
|
466
|
+
- **Cross-tab** — per-author rows, per-agent columns: multi-agent commits land in every matched column (the cap invariant), row totals are deduplicated, every cell expands to a commit list
|
|
467
|
+
- **Web parity** — the web transport serves byte-identical JSON to the CLI; request-level errors (bad window/gate/roster) are 400, per-entry errors (not-a-repo 404, no-commits 422) carry their documented codes
|
|
468
|
+
- **MCP parity** — all three MCP tools return the CLI's exact bytes for the same request: `repo_authorship_report` mirrors the full option surface, `commit_evidence` mirrors `evidence --format json` (multi-sha input order preserved, no bundle — the server never writes files), `adoption_diagnosis` mirrors `coverage --format json` (so an agent that sees 0% can ask *why* without shelling out); request errors carry the CLI's codes, repo errors (`sha-unknown`, `not-a-repo`) are pinned
|
|
469
|
+
- **Web evidence** — `/api/evidence` serves the CLI's `evidence` bytes for scope / multi-sha / window requests; `sha-unknown` is 422, `not-a-repo` is 404, request errors are 400; the dashboard carries the evidence UI (query box + per-sha inline drill-down)
|
|
470
|
+
- **Adoption diagnosis** — `coverage` bands are inclusive at the lower bound (0.2 / 0.8) and zero is its own band (`none`, never `minimal`); an unrecognized trailer is reported as a signature with its fix, a known tool marker is a hint on an unsigned commit and never changes a bucket, and a commit with no marker produces no claim at all; author rows reconcile with the bucket totals; the JSON is byte-stable and validates against `schema/coverage.schema.json`
|
|
471
|
+
- **Portfolio weighting** — the aggregate is `sum(signed)/sum(commits)`, never a mean of per-repository ratios (pinned with 1 commit at 100% vs 99 at 0%); a failed repository is counted, named and excluded from the totals instead of aborting the run; all repositories failing is `portfolio-empty` (exit 2); per-repository agent detail expands the rollup; `--max-ai-ratio` applies the report's boundary to the aggregate (`ratio > limit` breaches, equality passes) and exits 4 after producing the report
|
|
472
|
+
- **HTML brief** — byte-stable (no generation timestamp), self-contained (no `<script>`, no remote URL), every interpolated value escaped, and the method statement travels with the document — the properties that let it sit next to the JSON as evidence rather than as a screenshot
|
|
473
|
+
- **Web coverage** — `/api/coverage` serves the CLI's `coverage` bytes for the same request; the dashboard shows an inline diagnosis prompt only below 20% coverage (a healthy ledger is never nagged), and its error mapping matches the exit codes
|
|
474
|
+
- **A wrong type is a request error, never a guess** — `"all": "false"` is rejected (`scope-invalid`) instead of being coerced, because Python's `bool("false")` is `True` and the old behaviour silently scanned every ref; `ref: 123` is a 400, not a 500; `roster_dir: []` no longer falls back to the builtin roster; a boolean is not a minute count or a gate limit
|
|
475
|
+
- **Option parity** — one definition of scope / window / roster / session gap / gate (`ghostauthor/options.py`), called by all three surfaces: the same bad request yields the **same error code** on the CLI, the MCP server and the web transport, and the web serves the CLI's exact bytes for the same scope — including a two-branch diff, which `/api/audit` used to silently ignore; `all` and `all_refs` are synonyms everywhere; a malformed entry is a `400`, never an unhandled exception
|
|
476
|
+
- **Byte identity is compared as bytes** — the web serves the report as the CLI's exact byte string, and the assertions compare **raw strings**, not parsed dicts: a re-serialization (different key order, different indentation) parses to the same thing and would pass a dict comparison while making the claim false
|
|
477
|
+
- **The write path sees every signature** — the conflict guard scans the whole message, not just git's trailer block: a commit already signed by another agent is refused even when prose follows the trailer (and signing is still idempotent when *our* signature is the one followed by prose)
|
|
478
|
+
- **Nothing hides** — an unmatched co-author is surfaced on *every* commit, not only on the ones whose whole bucket is `cosigned`; the `trailer-in-body` finding quotes the offending prose line, not the legitimate trailer that follows it
|
|
479
|
+
- **A malformed request never kills a server** — one bad JSON-RPC line is answered with a JSON-RPC error and the MCP server keeps serving; a stalled request body is answered and the connection closed instead of parking a worker thread
|
|
480
|
+
- **The same bound means the same thing everywhere** — the accepted ISO 8601 subset is pinned by an explicit parser, not by the interpreter's `fromisoformat`, so a bound behaves identically on every supported Python
|
|
481
|
+
|
|
482
|
+
One click runs the whole matrix (roster → unit suite → 3 deterministic
|
|
483
|
+
fixture repos → CLI exit codes → real MCP `initialize`/`tools/list`/
|
|
484
|
+
`tools/call` → rendering → time window → roster-dir merge → SARIF → live
|
|
485
|
+
web server, byte-stable vs the CLI → two-branch diff + cross-tab → CI
|
|
486
|
+
assets → schema freeze, enforced → write path: round-trip / idempotency /
|
|
487
|
+
conflict / default-off → hook: install / sign-at-commit / idempotent /
|
|
488
|
+
conflict / uninstall + roster lint → evidence: audit agreement / byte
|
|
489
|
+
stability / reproducible bundle → evidence freeze, enforced → MCP surface
|
|
490
|
+
parity: 3 tools, each byte-identical to the CLI, every error code → web
|
|
491
|
+
evidence: `/api/evidence` byte-identical, 400/404/422, UI markers), and
|
|
492
|
+
prints anything it skips and why:
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
python verify.py
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## Changelog
|
|
499
|
+
|
|
500
|
+
See [CHANGELOG.md](CHANGELOG.md) for the full release history (v0.1.0 →
|
|
501
|
+
present), including the read-side contract-freeze policy and the additive-only
|
|
502
|
+
write path.
|
|
503
|
+
|
|
504
|
+
## License
|
|
505
|
+
|
|
506
|
+
MIT — see [LICENSE](LICENSE).
|