Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ All notable project changes are recorded here. Dates use ISO 8601 (`YYYY-MM-DD`)
### Added

- `proofline contract decompose <scope.json> [--out <proposal.json>] [--against a.json,b.json] [--check] [--lint-warn]` turns a scope file (`proofline-scope/1`: an id prefix, tasks with title, acceptance checks, requirement ids, dependencies and an owner placeholder, plus shared defaults and criteria put before or after each task's own) into an unsigned proposal that `contract merge` accepts. The output is byte-stable: fixed key order, criterion ids `<task>-AC01...`, two-space JSON and a final newline, and the command prints its sha256. A duplicate id (in the scope or in an `--against` contract), an unknown dependency, a cycle and a task `contract validate` would refuse are refused and nothing is written. It never writes `proofline.json` or a `.sig`. `--check` exits 1 when the `--out` file differs from what the scope gives. `docs/DECOMPOSITION.md` describes the process from scope file to proposal PR, fold with `merge`, `sign` and `verify-sig`, with a CI job. The toy fixture is `fixtures/decompose/`.
- Contract-mode `proofline receipt <TASK>` reruns a task's checks, records revision-bound evidence in a v1 in-toto predicate, signs the envelope with the configured agentkey role, and writes it under `.proofline/receipts/`. Without a usable role key it emits an unsigned L0 receipt, explains the reason on stderr, and preserves the verifier exit code.
- The receipt schema describes contract evidence, subject binding, public/private repository naming, and the distinction between L0 unsigned and L1 agent-signed receipts. The no-task zero-config receipt path remains available.

### Fixed
- Isolation no longer claims success when the container runtime or pinned image cannot run its Node version probe; unavailable runtimes block the check instead of recording `node=unknown` as isolated.
- Zero-config suite inference tests a toolchain by running its version command, not by checking whether a path exists. Broken launchers, such as a pytest script whose interpreter is missing, are treated as unavailable.

## 0.2.0-next.2 (2026-10-21)

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ proofline next -> TASK-1: Saves return a durable receipt on the default path
Caught five, passed one.
```

## A receipt for a contract task

After a task's checks run, create a signed, revision-bound receipt:

```bash
proofline receipt TASK-1 --role claude-code
```

The envelope records the base and head, red-on-base and green-on-head attempts, suite and metric results, scope, forbidden findings, and claim reconciliation. It is signed when the selected agentkey role is available. Without that key, Proofline writes an unsigned L0 receipt, reports why on stderr, and preserves the verifier's exit code. The receipt records which checks ran; it does not prove the acceptance criteria were sufficient or that arbitrary software is correct. See [the receipt format and verification guide](docs/receipt.md).

## Sixty seconds

In the repository the agent works on:
Expand Down
12 changes: 8 additions & 4 deletions bin/proofline.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const HELP = `proofline: independent V&V and delivery controller
evidence record <type> --data '{..}' | evidence verify | evidence log
verify-receipt <envelope> [--keys <dir>] [--sigstore] [--recompute --base <sha>]
exit 0 verified, 1 failed or differs, 2 unknown key, 3 usage
receipt [--role <name>] [--base <rev>] [--vault]
one receipt for the revision; --vault writes the note when a daemon answers
receipt <TASK> [--role <name>] [--base <rev>] [--out <path>] [--vault]
contract receipt for a task; without <TASK>, infer a zero-config receipt
hook pre-commit|pre-push (used by git hooks)
hook stop read a Stop hook payload on stdin; one receipt for new commits, or silence
connect claude-code merge a Stop hook into ~/.claude/settings.json, after any hook already there
Expand Down Expand Up @@ -112,7 +112,7 @@ const ACCEPTED_FLAGS = {
'evidence verify': [],
'evidence log': [],
'verify-receipt': ['keys', 'sigstore', 'recompute', 'base'],
receipt: ['base', 'role', 'task', 'vault'],
receipt: ['base', 'role', 'task', 'out', 'vault'],
hook: [],
watch: [],
connect: [],
Expand Down Expand Up @@ -271,13 +271,17 @@ try {
break;
}
case 'receipt': {
if (flags.task === true || flags.role === true || flags.out === true || flags.base === true) throw new Error('receipt flags need values');
const task = typeof flags.task === 'string' ? flags.task : sub;
const r = await buildReceipt(root, {
base: flags.base === true ? undefined : flags.base,
role: flags.role === true ? undefined : flags.role,
task: flags.task === true ? undefined : flags.task,
task,
out: flags.out === true ? undefined : flags.out,
vault: flags.vault === true,
});
print(r);
if (typeof task === 'string' && Number.isInteger(r.exitCode)) process.exitCode = r.exitCode;
break;
}
case 'hook': {
Expand Down
59 changes: 49 additions & 10 deletions docs/receipt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
# Receipt

Without a contract, `receipt` infers the suite from the manifest at the base revision. A change to that command is reported and is not what runs.
Proofline has two receipt paths. `proofline receipt <TASK>` runs the task's contract checks and writes a signed, contract-bound DSSE envelope. Calling `proofline receipt` without a task keeps the earlier zero-config inference path used by the Claude Code Stop hook.

## Contract receipt

```sh
proofline receipt TASK-1 [--base <sha>] [--role claude-code] [--out receipt.json]
```

The command reruns the task through Proofline's verifier with fresh results. `--base` is optional when `proofline next` pinned the task's base; in a fresh clone, pass the original base explicitly. A receipt is bound to the current committed `HEAD` and its Git tree. Contract-mode receipts require a clean worktree so the subject names the exact revision that was checked.

The output file defaults to `.proofline/receipts/<head-sha7>.json`. `.proofline/` is ignored by default. Use `--out` to choose a different destination.

### Trust levels

- **L0 — unsigned:** no role was configured, the role key could not be loaded, the base is unavailable, or the worktree is dirty. The envelope is not authenticated. The reason is written to stderr, and the command preserves the verifier's exit code.
- **L1 — agent-signed:** the task evidence is in a DSSE envelope signed by the configured `agentkey` role. Set `--role <role>` or `PROOFLINE_AGENT_ROLE`; keep the private key in the agentkey home, never in the repository or receipt.
- **L2 — CI-verified:** reserved for a future CI attestation flow. Contract-mode receipts from this command do not claim L2.

The statement predicate type is `https://proofline.dev/receipt/v1` and is validated against `schema/receipt-v1.json`. It includes the producer and task contract hash; base and head commit/tree identifiers; changed tests and red-on-base/green-on-head attempts; suite and metric results; scope and forbidden-check results; claim reconciliation; agent role and key id; repository visibility; timestamps; heuristic limitations; and optional memory evidence.

The in-toto subject digest binds `gitCommit` and `gitTree` to `predicate.head`. Public repository subjects include the sanitized remote URL and commit. Private repository subjects use the commit reference alone; the repository URL is kept in the predicate. Repository visibility defaults to private. Set `PROOFLINE_REPOSITORY_VISIBILITY=public` only for a repository that is public.

### What a receipt does not claim

A valid signature proves that the named role signed the recorded bytes. It does not prove the role's key was uncompromised, that acceptance criteria were complete, that a test was sufficient, or that arbitrary software is correct or safe. A receipt records what Proofline ran, the revision and base it used, and the results it observed. `grep`, `wiring`, and the forbidden-pattern scan remain heuristics; they are one layer, not a boundary.

## Offline verification

`verify-receipt` checks the DSSE signature offline against PEM files in `--keys` or `$AGENTKEY_HOME/keys`, named `<keyid>.pem`.

```sh
proofline verify-receipt .proofline/receipts/<head-sha7>.json --keys trusted-keys
proofline verify-receipt receipt.json --keys trusted-keys --recompute --base <base-sha>
```

Exit 0 means the envelope verifies; exit 1 means the signature/schema/subject differs; exit 2 means the key is unknown or the receipt is unsigned/unverifiable; exit 3 means usage or a missing required argument. `--sigstore` is the only path that loads the optional Sigstore verifier.

If the current commit differs but its tree matches the receipt subject, base-relative fields such as red-on-base and scope are reported unverified unless `--recompute` reruns them against the receipt's exact base. A different subject tree does not verify as the same receipt.

The MCP tools `receipt` and `verify_receipt` return the same JSON as the CLI. Without a `task` argument, the MCP receipt tool uses the zero-config path.

## Zero-config receipt

Without `<TASK>`, `receipt` infers suites from the manifest at the base revision. A changed suite command is reported, and the base command is what runs.

| Manifest | Command |
| --- | --- |
Expand All @@ -10,16 +53,12 @@ Without a contract, `receipt` infers the suite from the manifest at the base rev
| go.mod | `go test ./...` |
| build.gradle, `*.sln` | no default command, status blocked |

Changed tests are paths under `test/` or `tests/`, or names matching `*_test.*`, `*.test.*`, `*.spec.*` or `test_*.py`. Nothing inferable yields an L0 receipt and exit 2. A missing toolchain is blocked, not a pass.

`verify-receipt` checks the DSSE envelope offline against PEM files in `--keys` (or `$AGENTKEY_HOME/keys`), named `<keyid>.pem`. Exit 0 is verified, 1 is a bad signature, a schema problem or a `--recompute` difference, 2 is an unknown key, and 3 is usage. `--sigstore` is the only path that loads that verifier.

The MCP tools `receipt` and `verify_receipt` return that same JSON. `tools/list` shows nine tools.
Changed tests are paths under `test/` or `tests/`, or names matching `*_test.*`, `*.test.*`, `*.spec.*` or `test_*.py`. Nothing inferable yields an L0 receipt and exit 2. A missing or unusable toolchain is blocked, not passed.

`proofline hook stop` reads a Claude Code Stop payload and writes one receipt for the commits that session made. A second run on the same range writes none. `proofline connect claude-code` adds that hook after any Stop hook already in `~/.claude/settings.json`.
## Optional HiveVault note

When `GET /v1/state/digest` answers within 2 seconds, an L1 receipt gains `memory.vault_digest` and `memory.frontier`. An L2 receipt in ci mode gains only `memory_commitment`, the sha256 of the vault id, the digest and the frontier JSON, so a replica id is not in the receipt. No answer leaves the receipt unchanged. `--vault` writes `work/receipts/<date>-<role>-<sha7>.md` with origin `proofline`.
When the local daemon answers `GET /v1/state/digest` within 2 seconds, `--vault` attaches a digest and writes a receipt note. No answer leaves the receipt unchanged. `HIVEVAULT_TOKEN` is used only for the request and is never placed in the receipt.

The weakening check is a warning beside the owner signature. It names a loosened threshold, a removed criterion, or a changed command. Once `guard/owner.pub` is pinned, a missing, altered or wrongly-signed contract is refused with `contract not owner-signed`.
For an L1 receipt the note carries `memory.vault_digest` and `memory.frontier`. A CI/L2 receipt carries only `memory_commitment`, a sha256 commitment over the vault id, digest, and frontier. The Stop hook writes one zero-config receipt for a session that created commits and stays quiet when the same range was already receipted. `proofline connect claude-code` adds the Stop hook after existing hooks in the Claude Code settings file.

grep, wiring and the forbidden scan are marked `heuristic` in the receipt. They are one layer, not a boundary. An isolated run records `isolated` and `env_digest`. A local run records `isolated` false.
The contract weakening check remains alongside the owner signature. Once `guard/owner.pub` is pinned, a missing, altered, or wrongly signed contract is refused. Heuristic checks are labeled and never substitute for a domain-specific acceptance oracle.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"files": [
"bin",
"src",
"schema",
"docs",
"AGENTS.md",
"README.md",
Expand All @@ -56,6 +57,9 @@
"self-gate": "node bin/proofline.mjs gate PL-SELF --skip-pushed",
"mcp": "node bin/proofline.mjs mcp"
},
"dependencies": {
"@optitransfer/agentkey": "0.1.1"
},
"devDependencies": {
"@optitransfer/agentkey": "0.1.1",
"hivevault": "0.3.3"
Expand Down
Loading
Loading