Metadata-Version: 2.4
Name: bylines
Version: 0.3.0
Summary: Verify that an AI agent's submitted work was really written in its session: replay transcripts, classify every line by first appearance, and check authorship, time-window and revision rules.
Author: kaamura
License: MIT
Project-URL: Homepage, https://github.com/kaamura-ai/bylines
Project-URL: Repository, https://github.com/kaamura-ai/bylines
Keywords: ai-agent,attestation,provenance,transcript,verification
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# bylines

[![CI](https://github.com/kaamura-ai/bylines/actions/workflows/ci.yml/badge.svg)](https://github.com/kaamura-ai/bylines/actions)

**Every line has an author. Prove which ones were the agent's.**

`bylines` verifies that work attributed to an AI agent was really produced
inside the agent's own session. Give it a repository and the session
transcripts (Muse, Claude Code, Codex, or a redacted bylines bundle) and it will:

1. **Replay** every `write`/`edit` tool call in timestamp order, reconstructing
   each file exactly as the session built it.
2. **Classify every line by first appearance.** A line counts as
   *agent-authored* only if its first appearance in the transcript is inside a
   `write`/`edit` payload. Lines that first surfaced in a tool result, a file
   read, a shell output, or a pasted blob stay *external* forever — later edits
   cannot launder them into authored lines.
3. **Check the rules** a reviewer actually cares about:
   - `reproduces` — enough of the final code was agent-authored, little enough
     came from nowhere;
   - `in_window` — the work happened inside the allowed time window;
   - `revised` — files reached their final content through real iteration, not
     a single paste;
   - `coverage` — every file in the repo is accounted for: authored, declared
     (vendored / binary / generated, with hashes), or flagged unexplained.
4. **Emit a deterministic report** (`report.json` + a human-readable summary)
   that anyone can re-run and re-check. Same inputs, same verdict.

## Why

Maintainers and platforms are flooded with agent-produced pull requests,
contest entries and bounty submissions. A one-prompt paste and a carefully
steered, multi-hour session look identical from the outside. `bylines` makes
honest agent work legible — and raises the cost of faking it from zero to
substantial.

## What it does not prove

`bylines` proves *internal consistency*: these transcripts reproduce this
artifact under these rules. It does not prove the transcripts are authentic, a
human was present, or the timestamps are true. Forgery is possible; it is just
no longer free. See `DESIGN.md` for the full threat model.

## Install

```
pip install git+https://github.com/kaamura-ai/bylines
```

(A PyPI release is in preparation; once it lands, `pipx install bylines`
will work too.)

Python 3.11+, standard library only. No network, no API keys, fully offline.

## Quickstart

```
bylines verify \
  --repo ./my-entry \
  --sessions ./bundle/sessions \
  --harness claude-code \
  --policy policy.toml \
  --out report.json --md report.md
```

`--harness` selects the transcript format: `muse` (Muse session JSONL,
the default), `claude-code` (`~/.claude/projects/**/*.jsonl`, subagent
transcripts included), `codex` (`~/.codex/sessions/**/rollout-*.jsonl`,
including `apply_patch` writes), or `events` (redacted bylines bundles,
below).

Exit code: `0` pass, `1` fail, `2` input error.

## Redacted bundles

Raw transcripts contain your prompts and everything your tools printed —
not something you publish. `bylines redact` converts them into a shareable
bylines event file:

```
bylines redact --sessions ~/.claude/projects/-home-dev-myrepo \
  --harness claude-code --anchor myrepo --out ./attestation
bylines verify --repo ./myrepo --sessions ./attestation --harness events
```

Redaction keeps timestamps, tool-call structure and the `write`/`edit`
payloads (those lines are the artifact itself — the repo already publishes
them), and removes all conversation text and tool outputs. Outputs survive
only as per-line SHA-256 hashes, which is exactly what verification needs:
a line first sighted in an output is still classified *external*, so a
pasted file still fails — the verdict on a redacted bundle is the verdict
on the raw transcript.

## GitHub Action

Commit a redacted bundle with your repo and verify it in CI:

```yaml
- uses: actions/checkout@v4
- uses: kaamura-ai/bylines@v0.2.0
  with:
    sessions: ./attestation
    harness: events
    policy: ./policy.toml
```

The action fails the job on a `fail` verdict and uploads `report.json` /
`report.md` as artifacts.

## Policy (TOML)

```toml
[window]
opens  = "2026-12-01T00:00:00Z"
closes = "2026-12-07T00:00:00Z"

[counted]
include = ["**/*.py", "**/*.md"]
exclude = ["vendor/**", "*.min.js"]

[reproduces]
authored_min   = 0.30
unwritten_max  = 0.40

[revised]
min_files = 1
min_ops   = 2

[coverage]
unexplained = "fail"   # or "warn"
```

## Status

v0.3 — Muse, Claude Code and Codex transcript adapters, replay engine,
the four checks above, JSON/Markdown reports, redacted bundles
(`bylines redact`), and a GitHub Action. Transcript hash-chain anchoring
is on the roadmap (see `DESIGN.md`).

Validated against a production corpus: a real contest submission verified
by a platform's own (closed) checker reproduces the same verdict under
bylines, from both the raw and the redacted transcript.

See `examples/self-verification/` for bylines verifying its own
development session — bundle, policy and report included, warts and all.

## License

MIT
