diffpact 0.0.0-stage → 0.4.3
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.
- package/CHANGELOG.md +142 -0
- package/LICENSE +21 -0
- package/README.md +223 -2
- package/bin/diffpact.mjs +15 -0
- package/dist/adapters/claude-code.d.ts +21 -0
- package/dist/adapters/claude-code.js +191 -0
- package/dist/adapters/codex.d.ts +31 -0
- package/dist/adapters/codex.js +348 -0
- package/dist/adapters/gemini-agy.d.ts +26 -0
- package/dist/adapters/gemini-agy.js +429 -0
- package/dist/adapters/vercel-board.d.ts +30 -0
- package/dist/adapters/vercel-board.js +138 -0
- package/dist/amend.d.ts +46 -0
- package/dist/amend.js +476 -0
- package/dist/boundaries.d.ts +43 -0
- package/dist/boundaries.js +309 -0
- package/dist/canonical-json.d.ts +6 -0
- package/dist/canonical-json.js +63 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1704 -0
- package/dist/delegate.d.ts +22 -0
- package/dist/delegate.js +140 -0
- package/dist/doctor.d.ts +36 -0
- package/dist/doctor.js +293 -0
- package/dist/git.d.ts +27 -0
- package/dist/git.js +234 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/merge-verify.d.ts +31 -0
- package/dist/merge-verify.js +721 -0
- package/dist/report.d.ts +25 -0
- package/dist/report.js +220 -0
- package/dist/review.d.ts +46 -0
- package/dist/review.js +527 -0
- package/dist/runner.d.ts +45 -0
- package/dist/runner.js +213 -0
- package/dist/schema.d.ts +6 -0
- package/dist/schema.js +424 -0
- package/dist/types.d.ts +190 -0
- package/dist/types.js +220 -0
- package/dist/verify.d.ts +45 -0
- package/dist/verify.js +952 -0
- package/dist/worktree.d.ts +82 -0
- package/dist/worktree.js +717 -0
- package/examples/harnesses/README.md +63 -0
- package/examples/quickstart/README.md +17 -0
- package/examples/quickstart/run.mjs +247 -0
- package/package.json +62 -4
- package/schemas/contract.schema.json +148 -0
- package/schemas/receipt.schema.json +49 -0
- package/schemas/review.schema.json +48 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Cross-Harness Setup Examples
|
|
2
|
+
|
|
3
|
+
`diffpact` works alongside your existing coding agent CLIs without locking you into a single vendor.
|
|
4
|
+
|
|
5
|
+
## 1. Install Native Guard Hooks (Idempotent)
|
|
6
|
+
|
|
7
|
+
Run inside your repository (or linked worktree):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Claude Code (.claude/settings.local.json)
|
|
11
|
+
diffpact install-hooks --harness claude-code
|
|
12
|
+
|
|
13
|
+
# OpenAI Codex CLI (.codex/hooks.json)
|
|
14
|
+
diffpact install-hooks --harness codex
|
|
15
|
+
|
|
16
|
+
# Google Gemini CLI (.gemini/settings.json)
|
|
17
|
+
diffpact install-hooks --harness gemini
|
|
18
|
+
|
|
19
|
+
# Antigravity agy (.agents/hooks.json)
|
|
20
|
+
diffpact install-hooks --harness agy
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To preview any config without writing files:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
diffpact print-config --harness claude-code
|
|
27
|
+
diffpact print-config --harness codex
|
|
28
|
+
diffpact print-config --harness gemini
|
|
29
|
+
diffpact print-config --harness agy
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 2. Launch Workers Through `diffpact run`
|
|
33
|
+
|
|
34
|
+
`diffpact run` wraps pre-flight boundary checks, strips `DIFFPACT_REVIEWER_SECRET` from worker child environments, prints live progress heartbeats, and executes host-side `diffpact verify` after exit:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Claude Code (root-safe --permission-mode acceptEdits)
|
|
38
|
+
diffpact run --harness claude --prompt "Implement .diffpact/contract.json"
|
|
39
|
+
|
|
40
|
+
# OpenAI Codex CLI (auto-adds linked-worktree Git dirs for workspace-write commits)
|
|
41
|
+
diffpact run --harness codex --prompt "Implement .diffpact/contract.json"
|
|
42
|
+
|
|
43
|
+
# Crush (isolates .crush/ state outside the worktree via --data-dir)
|
|
44
|
+
diffpact run --harness crush --prompt "Implement .diffpact/contract.json"
|
|
45
|
+
|
|
46
|
+
# Gemini CLI / Antigravity agy
|
|
47
|
+
diffpact run --harness gemini --prompt "Implement .diffpact/contract.json"
|
|
48
|
+
diffpact run --harness agy --prompt "Implement .diffpact/contract.json"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 3. `@vercel/board` Integration
|
|
52
|
+
|
|
53
|
+
Pin contracts onto board tasks and fail closed on completion until verified and independently reviewed:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
diffpact board post-contract 42
|
|
57
|
+
# ...worker commits, verifies, and independent reviewer signs diffpact review...
|
|
58
|
+
diffpact board complete 42
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `exit 0` (`PASS`) → completes task on the board (reclaiming expired leases automatically).
|
|
62
|
+
- `exit 1` (`VIOLATION`) → fails task with structured violation summary.
|
|
63
|
+
- `exit 2` / `exit 3` (`INCOMPLETE` / `STALE`) → posts a `HOLD` note and keeps the task open without burning it.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# 30-Second Quickstart Demo
|
|
2
|
+
|
|
3
|
+
Run a completely self-contained, zero-dependency walkthrough of `diffpact` in a temporary Git repository:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm run quickstart
|
|
7
|
+
# or directly:
|
|
8
|
+
node examples/quickstart/run.mjs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What It Demonstrates Live
|
|
12
|
+
|
|
13
|
+
1. **`diffpact init`** — Pins `starting_sha`, allows only `src/pricing.mjs` and `test/pricing.test.mjs`, forbids `migrations/**` and `package.json`, and registers `node --test test/pricing.test.mjs`.
|
|
14
|
+
2. **Collateral Edit Attack (`EXIT 1 VIOLATION`)** — Simulates a coding agent modifying a forbidden SQL migration (`migrations/0001_billing.sql`) alongside its feature change. `diffpact verify` fails closed immediately.
|
|
15
|
+
3. **Silent Skipped Test (`EXIT 2 INCOMPLETE`)** — Simulates an agent marking an edge-case test with `test.skip(...)` so the test runner exits `0`. `diffpact verify` rejects the skipped suite (*No Silent Zero*).
|
|
16
|
+
4. **Clean Bounded Commit + Missing Review Notice** — Fixes the code and tests cleanly (`diffpact verify` exits `0`), while `diffpact status` explicitly shows `review: missing (0/1)`.
|
|
17
|
+
5. **Non-Self-Certified, Diff-SHA-Bound Review (`EXIT 1` → `EXIT 0`)** — Blocks the implementer from approving its own commit, then runs `diffpact diff` and records an independent cross-model approval bound to `raw_diff_sha256` + HMAC (`DIFFPACT_REVIEWER_SECRET`), unlocking `diffpact status --require-review`.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 30-second self-contained quickstart demonstrating diffpact end-to-end on a
|
|
4
|
+
* temporary local Git repository (zero network calls, zero external dependencies).
|
|
5
|
+
*
|
|
6
|
+
* Run: npm run quickstart (or: node examples/quickstart/run.mjs)
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const pkgRoot = path.resolve(__dirname, '../..');
|
|
16
|
+
const diffpactBin = path.join(pkgRoot, 'bin/diffpact.mjs');
|
|
17
|
+
const emitJson = process.argv.includes('--json');
|
|
18
|
+
|
|
19
|
+
const baseTmp = fs.existsSync('/var/tmp') ? '/var/tmp' : os.tmpdir();
|
|
20
|
+
const repoDir = fs.realpathSync(fs.mkdtempSync(path.join(baseTmp, 'diffpact-quickstart-')));
|
|
21
|
+
|
|
22
|
+
const transcript = [];
|
|
23
|
+
|
|
24
|
+
function git(args) {
|
|
25
|
+
return execFileSync('git', args, { cwd: repoDir, encoding: 'utf8' }).trim();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function runDiffpact(args, envExtra = {}) {
|
|
29
|
+
const env = { ...process.env, ...envExtra };
|
|
30
|
+
delete env.NODE_TEST_CONTEXT;
|
|
31
|
+
const res = spawnSync(process.execPath, [diffpactBin, ...args], {
|
|
32
|
+
cwd: repoDir,
|
|
33
|
+
env,
|
|
34
|
+
encoding: 'utf8'
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
exitCode: res.status ?? 1,
|
|
38
|
+
stdout: (res.stdout ?? '').trim(),
|
|
39
|
+
stderr: (res.stderr ?? '').trim()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function logStep(step, title, cmdDisplay, result) {
|
|
44
|
+
transcript.push({
|
|
45
|
+
step,
|
|
46
|
+
title,
|
|
47
|
+
command: cmdDisplay,
|
|
48
|
+
exitCode: result.exitCode,
|
|
49
|
+
stdout: result.stdout,
|
|
50
|
+
stderr: result.stderr
|
|
51
|
+
});
|
|
52
|
+
if (emitJson) return;
|
|
53
|
+
|
|
54
|
+
console.log(`\n━━━ Step ${step}: ${title} ━━━`);
|
|
55
|
+
console.log(`$ ${cmdDisplay}`);
|
|
56
|
+
if (result.stdout) console.log(result.stdout);
|
|
57
|
+
if (result.stderr) console.log(result.stderr);
|
|
58
|
+
console.log(`→ exit code: ${result.exitCode}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
// Seed a realistic, tiny billing repo
|
|
63
|
+
git(['init', '-b', 'main']);
|
|
64
|
+
git(['config', 'user.name', 'Demo Author']);
|
|
65
|
+
git(['config', 'user.email', 'demo@example.com']);
|
|
66
|
+
|
|
67
|
+
fs.mkdirSync(path.join(repoDir, 'src'), { recursive: true });
|
|
68
|
+
fs.mkdirSync(path.join(repoDir, 'test'), { recursive: true });
|
|
69
|
+
fs.mkdirSync(path.join(repoDir, 'migrations'), { recursive: true });
|
|
70
|
+
|
|
71
|
+
fs.writeFileSync(
|
|
72
|
+
path.join(repoDir, 'src/pricing.mjs'),
|
|
73
|
+
`export function applyDiscount(cents, percent) {\n return Math.round(cents * (1 - percent / 100));\n}\n`
|
|
74
|
+
);
|
|
75
|
+
fs.writeFileSync(
|
|
76
|
+
path.join(repoDir, 'test/pricing.test.mjs'),
|
|
77
|
+
`import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { applyDiscount } from '../src/pricing.mjs';\n\ntest('applies percentage discount', () => {\n assert.equal(applyDiscount(1000, 10), 900);\n});\n`
|
|
78
|
+
);
|
|
79
|
+
fs.writeFileSync(
|
|
80
|
+
path.join(repoDir, 'migrations/0001_billing.sql'),
|
|
81
|
+
`CREATE TABLE invoices (id TEXT PRIMARY KEY, total_cents INTEGER NOT NULL);\n`
|
|
82
|
+
);
|
|
83
|
+
fs.writeFileSync(
|
|
84
|
+
path.join(repoDir, 'package.json'),
|
|
85
|
+
JSON.stringify({ name: 'billing-demo', version: '1.0.0', type: 'module' }, null, 2) + '\n'
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
git(['add', '.']);
|
|
89
|
+
git(['commit', '-m', 'chore: initial billing repo']);
|
|
90
|
+
|
|
91
|
+
// Step 1: Pin the task contract
|
|
92
|
+
const initArgs = [
|
|
93
|
+
'init',
|
|
94
|
+
'--task-id',
|
|
95
|
+
'fix-discount-bounds',
|
|
96
|
+
'--mission',
|
|
97
|
+
'Clamp discount percentage to [0, 100] without touching migrations',
|
|
98
|
+
'--allow',
|
|
99
|
+
'src/pricing.mjs',
|
|
100
|
+
'--allow',
|
|
101
|
+
'test/pricing.test.mjs',
|
|
102
|
+
'--forbid',
|
|
103
|
+
'migrations/**',
|
|
104
|
+
'--forbid',
|
|
105
|
+
'package.json',
|
|
106
|
+
'--check',
|
|
107
|
+
'unit=node --test test/pricing.test.mjs',
|
|
108
|
+
'--implementer',
|
|
109
|
+
'codex-worker:sess-01:codex'
|
|
110
|
+
];
|
|
111
|
+
const s1 = runDiffpact(initArgs);
|
|
112
|
+
logStep(
|
|
113
|
+
1,
|
|
114
|
+
'Pin Task Contract (SHA-pinned allowlist + forbidden migrations)',
|
|
115
|
+
'diffpact init --task-id fix-discount-bounds --allow src/pricing.mjs --allow test/pricing.test.mjs --forbid "migrations/**" --check "unit=node --test test/pricing.test.mjs" --implementer "codex-worker:sess-01:codex"',
|
|
116
|
+
s1
|
|
117
|
+
);
|
|
118
|
+
if (s1.exitCode !== 0) throw new Error('Expected Step 1 init to pass');
|
|
119
|
+
|
|
120
|
+
// Step 2: Collateral edit attack on forbidden migration file -> EXIT 1
|
|
121
|
+
fs.writeFileSync(
|
|
122
|
+
path.join(repoDir, 'src/pricing.mjs'),
|
|
123
|
+
`export function applyDiscount(cents, percent) {\n const clamped = Math.min(100, Math.max(0, percent));\n return Math.round(cents * (1 - clamped / 100));\n}\n`
|
|
124
|
+
);
|
|
125
|
+
fs.appendFileSync(
|
|
126
|
+
path.join(repoDir, 'migrations/0001_billing.sql'),
|
|
127
|
+
`ALTER TABLE invoices ADD COLUMN discount_pct INTEGER DEFAULT 0;\n`
|
|
128
|
+
);
|
|
129
|
+
git(['add', '.']);
|
|
130
|
+
git(['commit', '-m', 'feat: clamp discount (and sneaky migration edit)']);
|
|
131
|
+
|
|
132
|
+
const s2 = runDiffpact(['verify']);
|
|
133
|
+
logStep(
|
|
134
|
+
2,
|
|
135
|
+
'Worker Edits Forbidden Migration File -> Blocked (EXIT 1 VIOLATION)',
|
|
136
|
+
'diffpact verify',
|
|
137
|
+
s2
|
|
138
|
+
);
|
|
139
|
+
if (s2.exitCode !== 1) throw new Error(`Expected Step 2 exit 1, got ${s2.exitCode}`);
|
|
140
|
+
|
|
141
|
+
// Step 3: Revert migration, but agent skips a test while exiting 0 -> EXIT 2
|
|
142
|
+
git(['reset', '--hard', 'HEAD~1']);
|
|
143
|
+
fs.writeFileSync(
|
|
144
|
+
path.join(repoDir, 'src/pricing.mjs'),
|
|
145
|
+
`export function applyDiscount(cents, percent) {\n const clamped = Math.min(100, Math.max(0, percent));\n return Math.round(cents * (1 - clamped / 100));\n}\n`
|
|
146
|
+
);
|
|
147
|
+
fs.writeFileSync(
|
|
148
|
+
path.join(repoDir, 'test/pricing.test.mjs'),
|
|
149
|
+
`import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { applyDiscount } from '../src/pricing.mjs';\n\ntest('applies percentage discount', () => {\n assert.equal(applyDiscount(1000, 10), 900);\n});\n\ntest.skip('clamps negative discounts to 0%', () => {\n assert.equal(applyDiscount(1000, -25), 1000);\n});\n`
|
|
150
|
+
);
|
|
151
|
+
git(['add', '.']);
|
|
152
|
+
git(['commit', '-m', 'feat: clamp discount (with skipped edge-case test)']);
|
|
153
|
+
|
|
154
|
+
const s3 = runDiffpact(['verify']);
|
|
155
|
+
logStep(
|
|
156
|
+
3,
|
|
157
|
+
'Skipped Test Exits 0, Caught as No Silent Zero (EXIT 2 INCOMPLETE)',
|
|
158
|
+
'diffpact verify',
|
|
159
|
+
s3
|
|
160
|
+
);
|
|
161
|
+
if (s3.exitCode !== 2) throw new Error(`Expected Step 3 exit 2, got ${s3.exitCode}`);
|
|
162
|
+
|
|
163
|
+
// Step 4: Clean bounded fix + full tests -> verify PASS, status warns review missing
|
|
164
|
+
fs.writeFileSync(
|
|
165
|
+
path.join(repoDir, 'test/pricing.test.mjs'),
|
|
166
|
+
`import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { applyDiscount } from '../src/pricing.mjs';\n\ntest('applies percentage discount', () => {\n assert.equal(applyDiscount(1000, 10), 900);\n});\n\ntest('clamps negative and >100% discounts', () => {\n assert.equal(applyDiscount(1000, -25), 1000);\n assert.equal(applyDiscount(1000, 150), 0);\n});\n`
|
|
167
|
+
);
|
|
168
|
+
git(['add', '.']);
|
|
169
|
+
git(['commit', '-m', 'test: enable discount clamping edge cases']);
|
|
170
|
+
|
|
171
|
+
const s4 = runDiffpact(['verify']);
|
|
172
|
+
logStep(4, 'Clean Bounded Commit Passes Verification (EXIT 0)', 'diffpact verify', s4);
|
|
173
|
+
if (s4.exitCode !== 0) throw new Error(`Expected Step 4 exit 0, got ${s4.exitCode}`);
|
|
174
|
+
|
|
175
|
+
const s5 = runDiffpact(['status']);
|
|
176
|
+
logStep(5, 'Status Explicitly Flags Missing Review Before Merge', 'diffpact status', s5);
|
|
177
|
+
|
|
178
|
+
// Step 6: Worker tries to self-certify its own commit -> Blocked (EXIT 1)
|
|
179
|
+
const diffMeta = runDiffpact(['--json', 'diff']);
|
|
180
|
+
const diffSha = JSON.parse(diffMeta.stdout).raw_diff_sha256;
|
|
181
|
+
const shortDiffSha = diffSha.slice(0, 16);
|
|
182
|
+
|
|
183
|
+
const s6 = runDiffpact([
|
|
184
|
+
'review',
|
|
185
|
+
'--reviewer',
|
|
186
|
+
'codex-worker:sess-01:codex',
|
|
187
|
+
'--verdict',
|
|
188
|
+
'approve',
|
|
189
|
+
'--diff-sha',
|
|
190
|
+
shortDiffSha,
|
|
191
|
+
'--summary',
|
|
192
|
+
'Looks good to me!'
|
|
193
|
+
]);
|
|
194
|
+
logStep(
|
|
195
|
+
6,
|
|
196
|
+
'Self-Certification Attempt Blocked (EXIT 1 VIOLATION)',
|
|
197
|
+
`diffpact review --reviewer "codex-worker:sess-01:codex" --verdict approve --diff-sha ${shortDiffSha} --summary "Looks good to me!"`,
|
|
198
|
+
s6
|
|
199
|
+
);
|
|
200
|
+
if (s6.exitCode !== 1) throw new Error(`Expected Step 6 exit 1, got ${s6.exitCode}`);
|
|
201
|
+
|
|
202
|
+
// Step 7: Independent reviewer inspects primary raw diff & signs HMAC diff-SHA review
|
|
203
|
+
const reviewSecret = 'demo-orchestrator-hmac-secret';
|
|
204
|
+
const s7Diff = runDiffpact(['diff']);
|
|
205
|
+
logStep(7, 'Independent Reviewer Inspects Primary Raw Git Diff', 'diffpact diff', s7Diff);
|
|
206
|
+
|
|
207
|
+
const s8 = runDiffpact(
|
|
208
|
+
[
|
|
209
|
+
'review',
|
|
210
|
+
'--reviewer',
|
|
211
|
+
'claude-reviewer:sess-99:claude-code',
|
|
212
|
+
'--verdict',
|
|
213
|
+
'approve',
|
|
214
|
+
'--diff-sha',
|
|
215
|
+
shortDiffSha,
|
|
216
|
+
'--summary',
|
|
217
|
+
'Inspected raw diff; clamping logic and bounds tests verified.'
|
|
218
|
+
],
|
|
219
|
+
{ DIFFPACT_REVIEWER_SECRET: reviewSecret }
|
|
220
|
+
);
|
|
221
|
+
logStep(
|
|
222
|
+
8,
|
|
223
|
+
'Independent Diff-SHA + HMAC Review Recorded (EXIT 0)',
|
|
224
|
+
`diffpact review --reviewer "claude-reviewer:sess-99:claude-code" --verdict approve --diff-sha ${shortDiffSha} --summary "Inspected raw diff; clamping logic and bounds tests verified."`,
|
|
225
|
+
s8
|
|
226
|
+
);
|
|
227
|
+
if (s8.exitCode !== 0) throw new Error(`Expected Step 8 exit 0, got ${s8.exitCode}`);
|
|
228
|
+
|
|
229
|
+
const s9 = runDiffpact(['status', '--require-review'], {
|
|
230
|
+
DIFFPACT_REVIEWER_SECRET: reviewSecret
|
|
231
|
+
});
|
|
232
|
+
logStep(
|
|
233
|
+
9,
|
|
234
|
+
'Final Merge Gate Passes (Verified + Independently Reviewed)',
|
|
235
|
+
'diffpact status --require-review',
|
|
236
|
+
s9
|
|
237
|
+
);
|
|
238
|
+
if (s9.exitCode !== 0) throw new Error(`Expected Step 9 exit 0, got ${s9.exitCode}`);
|
|
239
|
+
|
|
240
|
+
if (emitJson) {
|
|
241
|
+
console.log(JSON.stringify({ ok: true, shortDiffSha, steps: transcript }, null, 2));
|
|
242
|
+
} else {
|
|
243
|
+
console.log('\nQuickstart complete: all 9 contract, boundary, skip, and review gates verified.');
|
|
244
|
+
}
|
|
245
|
+
} finally {
|
|
246
|
+
fs.rmSync(repoDir, { recursive: true, force: true });
|
|
247
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diffpact",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.3",
|
|
4
|
+
"description": "Local, stateless Git task contracts, deterministic diff boundaries, and cross-harness review gates for multi-agent coding workflows.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "InterfaceDelta, Inc. (https://interfacedelta.com)",
|
|
7
|
+
"homepage": "https://interfacedelta.com",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/interface-delta/diffpact.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/interface-delta/diffpact/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ai-agents",
|
|
17
|
+
"coding-agents",
|
|
18
|
+
"multi-agent",
|
|
19
|
+
"claude-code",
|
|
20
|
+
"codex",
|
|
21
|
+
"gemini",
|
|
22
|
+
"git",
|
|
23
|
+
"code-review",
|
|
24
|
+
"verification",
|
|
25
|
+
"sarif"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.6.0"
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"bin": {
|
|
34
|
+
"diffpact": "bin/diffpact.mjs"
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./schemas/*": "./schemas/*"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"bin/",
|
|
45
|
+
"dist/",
|
|
46
|
+
"schemas/",
|
|
47
|
+
"examples/",
|
|
48
|
+
"CHANGELOG.md",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "node scripts/build.mjs",
|
|
54
|
+
"prepare": "node scripts/build.mjs",
|
|
55
|
+
"prepack": "node scripts/build.mjs",
|
|
56
|
+
"quickstart": "node examples/quickstart/run.mjs",
|
|
57
|
+
"test": "node --test test/*.test.ts",
|
|
58
|
+
"typecheck": "node scripts/typecheck.mjs"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/node": "^22.10.0",
|
|
62
|
+
"typescript": "^5.8.0"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://diffpact.dev/schemas/v0.1/contract.schema.json",
|
|
4
|
+
"title": "DiffpactTaskContractV01",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schema_version",
|
|
9
|
+
"task_id",
|
|
10
|
+
"task_type",
|
|
11
|
+
"mission",
|
|
12
|
+
"starting_sha",
|
|
13
|
+
"worktree",
|
|
14
|
+
"allowed_paths",
|
|
15
|
+
"forbidden_paths",
|
|
16
|
+
"required_checks",
|
|
17
|
+
"implementer_session"
|
|
18
|
+
],
|
|
19
|
+
"properties": {
|
|
20
|
+
"schema_version": { "const": "diffpact-contract-v0.1" },
|
|
21
|
+
"task_id": { "type": "string", "minLength": 1 },
|
|
22
|
+
"task_type": { "type": "string", "enum": ["coding", "research"] },
|
|
23
|
+
"mission": { "type": "string", "minLength": 1 },
|
|
24
|
+
"starting_sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
|
|
25
|
+
"candidate_sha": { "type": ["string", "null"], "pattern": "^[0-9a-f]{40}$" },
|
|
26
|
+
"worktree": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"branch": { "type": "string", "minLength": 1 },
|
|
31
|
+
"path": { "type": "string", "minLength": 1 },
|
|
32
|
+
"require_clean_start": { "type": "boolean" },
|
|
33
|
+
"require_clean_end": { "type": "boolean" }
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"allowed_paths": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
37
|
+
"read_only_paths": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
38
|
+
"forbidden_paths": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
39
|
+
"version_assertions": {
|
|
40
|
+
"type": "array",
|
|
41
|
+
"items": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"additionalProperties": false,
|
|
44
|
+
"required": ["path", "kind", "key", "expected"],
|
|
45
|
+
"properties": {
|
|
46
|
+
"path": { "type": "string" },
|
|
47
|
+
"kind": { "type": "string", "enum": ["sha256", "json_pointer", "regex_exact"] },
|
|
48
|
+
"key": { "type": "string" },
|
|
49
|
+
"expected": { "type": "string" }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"interfacedelta_lockfile": {
|
|
54
|
+
"type": ["object", "null"],
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"required": ["path", "sha256"],
|
|
57
|
+
"properties": {
|
|
58
|
+
"path": { "type": "string" },
|
|
59
|
+
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
60
|
+
"must_remain_unmodified": { "type": "boolean" }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"budget": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"additionalProperties": false,
|
|
66
|
+
"properties": {
|
|
67
|
+
"max_budget_usd": { "type": "number", "minimum": 0 },
|
|
68
|
+
"reserved_budget_usd": { "type": "number", "minimum": 0 },
|
|
69
|
+
"delegation_depth": { "type": "integer", "minimum": 0 },
|
|
70
|
+
"max_delegation_depth": { "type": "integer", "minimum": 0 },
|
|
71
|
+
"parent_contract_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"required_checks": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"items": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"required": ["id", "command"],
|
|
80
|
+
"properties": {
|
|
81
|
+
"id": { "type": "string" },
|
|
82
|
+
"command": { "type": "string" },
|
|
83
|
+
"cwd": { "type": "string" },
|
|
84
|
+
"timeout_sec": { "type": "integer", "minimum": 1 },
|
|
85
|
+
"forbid_skipped": { "type": "boolean" }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"advisory_checks": {
|
|
90
|
+
"type": "array",
|
|
91
|
+
"items": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"required": ["id", "command"],
|
|
95
|
+
"properties": {
|
|
96
|
+
"id": { "type": "string" },
|
|
97
|
+
"command": { "type": "string" },
|
|
98
|
+
"cwd": { "type": "string" },
|
|
99
|
+
"timeout_sec": { "type": "integer", "minimum": 1 },
|
|
100
|
+
"forbid_skipped": { "type": "boolean" }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"allow_no_checks": { "type": "boolean" },
|
|
105
|
+
"allow_no_commit": { "type": "boolean" },
|
|
106
|
+
"implementer_session": { "$ref": "#/$defs/sessionIdentity" },
|
|
107
|
+
"review_policy": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": false,
|
|
110
|
+
"properties": {
|
|
111
|
+
"required_reviews": { "type": "integer", "minimum": 1 },
|
|
112
|
+
"require_non_self_certified": { "type": "boolean" },
|
|
113
|
+
"require_distinct_harness": { "type": "boolean" },
|
|
114
|
+
"require_raw_diff_inspection": { "type": "boolean" },
|
|
115
|
+
"canonical_integrator_agent_id": { "type": "string" }
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"role_substitution": {
|
|
119
|
+
"type": ["object", "null"],
|
|
120
|
+
"additionalProperties": false,
|
|
121
|
+
"required": ["substitute_agent_id", "authorized_by", "task_id", "active", "spent"],
|
|
122
|
+
"properties": {
|
|
123
|
+
"substitute_agent_id": { "type": "string" },
|
|
124
|
+
"authorized_by": { "type": "string" },
|
|
125
|
+
"task_id": { "type": "string" },
|
|
126
|
+
"active": { "type": "boolean" },
|
|
127
|
+
"spent": { "type": "boolean" },
|
|
128
|
+
"reason": { "type": "string" }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"$defs": {
|
|
133
|
+
"sessionIdentity": {
|
|
134
|
+
"type": "object",
|
|
135
|
+
"additionalProperties": false,
|
|
136
|
+
"required": ["agent_id", "session_id", "harness"],
|
|
137
|
+
"properties": {
|
|
138
|
+
"agent_id": { "type": "string", "minLength": 1 },
|
|
139
|
+
"session_id": { "type": "string", "minLength": 1 },
|
|
140
|
+
"harness": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"enum": ["claude-code", "codex", "crush", "gemini-cli", "agy", "vercel-board", "manual", "other"]
|
|
143
|
+
},
|
|
144
|
+
"model": { "type": "string" }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://diffpact.dev/schemas/v0.1/receipt.schema.json",
|
|
4
|
+
"title": "DiffpactVerificationReceiptV01",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schema_version",
|
|
9
|
+
"receipt_sha256",
|
|
10
|
+
"contract_sha256",
|
|
11
|
+
"task_id",
|
|
12
|
+
"verified_at",
|
|
13
|
+
"starting_sha",
|
|
14
|
+
"candidate_sha",
|
|
15
|
+
"raw_diff_sha256",
|
|
16
|
+
"branch",
|
|
17
|
+
"worktree_path",
|
|
18
|
+
"working_tree_clean",
|
|
19
|
+
"status",
|
|
20
|
+
"exit_code",
|
|
21
|
+
"diff_summary",
|
|
22
|
+
"version_assertions_ok",
|
|
23
|
+
"interfacedelta_lockfile_ok",
|
|
24
|
+
"subcontracts_checked",
|
|
25
|
+
"checks",
|
|
26
|
+
"violations"
|
|
27
|
+
],
|
|
28
|
+
"properties": {
|
|
29
|
+
"schema_version": { "const": "diffpact-receipt-v0.1" },
|
|
30
|
+
"receipt_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
31
|
+
"contract_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
32
|
+
"task_id": { "type": "string" },
|
|
33
|
+
"verified_at": { "type": "string" },
|
|
34
|
+
"starting_sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
|
|
35
|
+
"candidate_sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
|
|
36
|
+
"raw_diff_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
37
|
+
"branch": { "type": "string" },
|
|
38
|
+
"worktree_path": { "type": "string" },
|
|
39
|
+
"working_tree_clean": { "type": "boolean" },
|
|
40
|
+
"status": { "type": "string", "enum": ["pass", "violation", "incomplete", "stale"] },
|
|
41
|
+
"exit_code": { "type": "integer", "enum": [0, 1, 2, 3] },
|
|
42
|
+
"diff_summary": { "type": "object" },
|
|
43
|
+
"version_assertions_ok": { "type": "boolean" },
|
|
44
|
+
"interfacedelta_lockfile_ok": { "type": ["boolean", "null"] },
|
|
45
|
+
"subcontracts_checked": { "type": "integer" },
|
|
46
|
+
"checks": { "type": "array" },
|
|
47
|
+
"violations": { "type": "array" }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://diffpact.dev/schemas/v0.1/review.schema.json",
|
|
4
|
+
"title": "DiffpactReviewAttestationV01",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"schema_version",
|
|
9
|
+
"review_sha256",
|
|
10
|
+
"contract_sha256",
|
|
11
|
+
"receipt_sha256",
|
|
12
|
+
"task_id",
|
|
13
|
+
"starting_sha",
|
|
14
|
+
"candidate_sha",
|
|
15
|
+
"raw_diff_sha256",
|
|
16
|
+
"evidence_lineage_id",
|
|
17
|
+
"inspected_raw_diff",
|
|
18
|
+
"implementer_session",
|
|
19
|
+
"reviewer_session",
|
|
20
|
+
"verdict",
|
|
21
|
+
"findings",
|
|
22
|
+
"summary",
|
|
23
|
+
"reviewed_at"
|
|
24
|
+
],
|
|
25
|
+
"properties": {
|
|
26
|
+
"schema_version": { "const": "diffpact-review-v0.1" },
|
|
27
|
+
"review_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
28
|
+
"contract_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
29
|
+
"receipt_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
30
|
+
"task_id": { "type": "string" },
|
|
31
|
+
"starting_sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
|
|
32
|
+
"candidate_sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
|
|
33
|
+
"raw_diff_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
34
|
+
"evidence_lineage_id": { "type": "string" },
|
|
35
|
+
"inspected_raw_diff": { "type": "boolean" },
|
|
36
|
+
"attestation_mode": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": ["wrapper-verified", "diff-sha-bound", "cli-explicit", "api"]
|
|
39
|
+
},
|
|
40
|
+
"attestation_hmac_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
41
|
+
"implementer_session": { "$ref": "contract.schema.json#/$defs/sessionIdentity" },
|
|
42
|
+
"reviewer_session": { "$ref": "contract.schema.json#/$defs/sessionIdentity" },
|
|
43
|
+
"verdict": { "type": "string", "enum": ["approve", "reject"] },
|
|
44
|
+
"findings": { "type": "array", "items": { "type": "string" } },
|
|
45
|
+
"summary": { "type": "string" },
|
|
46
|
+
"reviewed_at": { "type": "string" }
|
|
47
|
+
}
|
|
48
|
+
}
|