buildproof 3.8.1 → 3.11.0

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/README.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # BuildProof v3 - proof gate for AI-written code
2
2
 
3
+ **Quick start (30 seconds):**
4
+
5
+ ```
6
+ npx buildproof try # see it first, on a throw-away sample: a skipped test is caught, the real fix is proven
7
+ npx buildproof init # then on your project: hooks for Claude Code / Cursor / git, 14-day free trial (add --ci for the GitHub PR check)
8
+ ```
9
+
10
+ After `init`, keep working as usual. When your AI tool finishes, BuildProof re-runs your real checks; if a test was skipped, deleted or weakened, or "all tests pass" is not true, it answers NOT PROVEN and sends the reason back to the AI.
11
+
3
12
  Works two ways, same guarantees:
4
13
 
5
14
  **A. BuildProof fixes it** - task from phone / tablet / PC -> diagnose (baseline build/test) -> scope proposal (tests locked) -> your approval -> fix library or local AI (Ollama) under supervision -> proof -> signed certificate.
@@ -18,7 +27,11 @@ One-tap hooks (Projects -> AI tools, or `buildproof connect git,claude,cursor`):
18
27
  Projects: Node / Web (npm scripts typecheck, lint, build, test) and Python (syntax check of every file without writing .pyc, ruff and mypy when configured, pytest or unittest).
19
28
  Also (3.7.1): Go (go build, go vet, go test), Rust (cargo build, cargo test - also tests inside the source file), Java with Maven or Gradle (JUnit results), .NET (dotnet build, dotnet test), Ruby (syntax check, RSpec or Minitest), PHP (syntax check, PHPUnit). Each uses its own toolchain on your computer; a missing toolchain or unreadable test results is reported, never counted as proven.
20
29
 
21
- Pull request checks (3.8.0; free trial, then Team and Enterprise): `buildproof ci --init` adds a GitHub workflow; every pull request is compared with its base branch - test-integrity rules on the changed files, build/test on both sides, fail-closed verdict in the job summary. Spec check (free trial, then Pro and up; `buildproof spec` locally or inside `buildproof ci`): `.buildproof/spec.md`, one requirement per line with the test that proves it (`- Free shipping from $50 => test: free shipping from 50`); a requirement without a passing test is never accepted. Live demo: https://buildproof.mgrprosnetwork.com/demo
30
+ Pull request checks (3.8.0; free trial, then Team and Enterprise): `buildproof ci --init` adds a GitHub workflow; every pull request is compared with its base branch - test-integrity rules on the changed files, build/test on both sides, fail-closed verdict in the job summary. A check that fails is run once more: if it then passes it is reported as FLAKY (not blamed on the pull request); `--no-retry` keeps it strict (3.11). Spec check (free trial, then Pro and up; `buildproof spec` locally or inside `buildproof ci`): `.buildproof/spec.md`, one requirement per line with the test that proves it (`- Free shipping from $50 => test: free shipping from 50`); a requirement without a passing test is never accepted. Live demo: https://buildproof.mgrprosnetwork.com/demo
31
+
32
+ Audit report (3.9.0; free trial, then Enterprise): `buildproof audit --since 2026-01-01` writes a signed HTML + JSON report of every accepted and rejected change; `buildproof audit --verify report.json` shows any later edit. Team dashboard (Team and Enterprise): `buildproof team` opens it; your licence key unlocks your own team's certificates.
33
+
34
+ AI bug hunt (3.10.0; Pro and up, and the trial): `buildproof hunt --base main` uploads the change to the BuildProof server, where the hunter runs your code and the AI-written tests in a locked-down container (no network) and reports only bugs it PROVED (a test that fails on the new code and passes on the old). By default your own local model (Ollama) answers the AI's questions - free; `--cloud` uses the server's AI (one cloud check; 5 in the trial; `buildproof credits --buy 20`). Your code is deleted from the server when the check ends.
22
35
 
23
36
  CLI: `buildproof start | check [--claim "..."] | accept [--force] | rollback | connect | verify <cert.html> | status | ci [--base origin/main] [--spec spec.md]`. `buildproof check` exits 0 only when proven.
24
37
 
package/bin/buildproof.js CHANGED
@@ -11,11 +11,14 @@
11
11
  * buildproof status service and AI status
12
12
  * buildproof verify <certificate.html|.json> [--rerun folder] verify a certificate (and re-run its checks)
13
13
  * buildproof repro <evidence.json> [folder] replay one hidden-bug finding (isolated copy)
14
- * buildproof init [folder] one-time setup: background service, project, AI tool hooks
14
+ * buildproof init [folder] [--ci] one-time setup: background service, project, AI tool hooks (--ci also adds the GitHub PR check)
15
+ * buildproof try 30-second demo on a throw-away sample project: a skipped test is caught, the real fix is proven
15
16
  * buildproof activate <key> activate a license key buildproof license show the plan
16
17
  * buildproof open open BuildProof in the browser
17
18
  * buildproof ci [folder] [--base origin/main] [--spec spec.md] pull request check for CI (--init writes the GitHub workflow)
18
19
  * buildproof spec [folder] [--base main] check the change against .buildproof/spec.md (every requirement needs a passing test)
20
+ * buildproof audit [--since 2026-01-01] [--out report.html] signed audit report of every checked change buildproof team team dashboard
21
+ * buildproof hunt [folder] [--base main] [--cloud] AI bug hunt on the server (your own model by default) buildproof credits [--buy 20]
19
22
  *
20
23
  * Hook mode (installed by "connect"): --hook=claude | --hook=cursor | --hook=git
21
24
  */
@@ -90,7 +93,53 @@ async function activeGuard(projectId) {
90
93
  return (r.tasks || []).find((t) => t.kind === 'guard' && t.projectId === projectId && ['baselining', 'watching', 'checking'].includes(t.state));
91
94
  }
92
95
 
96
+ /** Plain-language result of `buildproof init`: what is protected now, what is missing, what to do next. */
97
+ function initSummary({ project, connected, lic, ciNote, git }) {
98
+ const L = [''];
99
+ const ok = (t) => L.push(' [ok] ' + t), warn = (t) => L.push(' [!] ' + t);
100
+ ok(`project ${project.name} (${project.type})`);
101
+ if ((project.verify || []).length) ok(`proof steps: ${project.verify.join(', ')} - these run before and after every AI change`);
102
+ else warn('no build/test scripts found - BuildProof can only prove what your checks cover. Add a "test" script, then run init again.');
103
+ if (connected.includes('claude')) ok('Claude Code: checked automatically every time Claude finishes');
104
+ if (connected.includes('cursor')) ok('Cursor: checked automatically every time the agent finishes');
105
+ if (connected.includes('git')) ok('git: checked before every commit');
106
+ if (!connected.length) warn('no AI tool found here - open this folder in Claude Code or Cursor, then run: buildproof connect');
107
+ if (ciNote) ok(ciNote); else if (git) L.push(' [+] pull requests too: buildproof init --ci');
108
+ L.push(` licence: ${lic.label || 'unknown'}${lic.status && String(lic.status).toLowerCase() !== String(lic.label || '').toLowerCase() ? ' (' + lic.status + ')' : ''}${lic.daysLeft != null ? ' - ' + lic.daysLeft + ' days left' : ''}`);
109
+ L.push('');
110
+ L.push(' Next: ask your AI tool for a change as usual. If it skips, deletes or weakens a test, or says "all tests pass" when they do not,');
111
+ L.push(' BuildProof says NOT PROVEN and sends the reason back to the AI. See it on a sample first: buildproof try');
112
+ return L.join('\n');
113
+ }
114
+
93
115
  async function main() {
116
+ if (cmd === 'hunt' || cmd === 'credits') { // AI bug hunt on the BuildProof server (Pro and up, and the trial)
117
+ const hc = require('../core/hunt-client');
118
+ const server = (process.env.BUILDPROOF_SERVER || config.load().licenseServer || 'https://buildproof.mgrprosnetwork.com').replace(/\/$/, '');
119
+ const license = require('../core/license');
120
+ if (cmd === 'credits') { const r = await hc.credits({ license, server, buy: typeof flag('buy') === 'string' ? flag('buy') : null, open: openUrl }); out(r.text, r.code); }
121
+ const root = path.resolve(positional[0] || process.cwd());
122
+ const base = typeof flag('base') === 'string' ? flag('base') : (require('../core/ci').findBase(root, null) || 'HEAD~1');
123
+ const r = await hc.run({ root, base, cloud: !!flag('cloud'), intent: typeof flag('intent') === 'string' ? flag('intent') : '', cfg: config.load(), license, server, log: (l) => console.log(l) });
124
+ out(r.text, r.code);
125
+ }
126
+ if (cmd === 'audit') { // Enterprise audit report: signed HTML + JSON of every checked change in a period
127
+ const audit = require('../core/audit');
128
+ if (typeof flag('verify') === 'string') {
129
+ let signed; try { signed = JSON.parse(fs.readFileSync(flag('verify'), 'utf8')); } catch { out('AUDIT_VERIFY_FAIL cannot read the file', 1); }
130
+ const ok = audit.verifySigned(signed, require('../core/certs'));
131
+ out(ok ? `AUDIT_VALID signed by ${signed.fingerprint}` : 'AUDIT_INVALID the report was changed after it was signed', ok ? 0 : 1);
132
+ }
133
+ const lic = require('../core/license');
134
+ if (!lic.has(lic.F.audit)) out('NOT_IN_PLAN audit reports are in the Enterprise plan (and the free trial)', 2);
135
+ const day = (v) => (typeof v === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(v) ? v : null);
136
+ const r = audit.write({ out: typeof flag('out') === 'string' ? flag('out') : null, since: day(flag('since')), until: day(flag('until')) });
137
+ out(`AUDIT ${r.htmlFile} accepted=${r.summary.accepted} rejected=${r.summary.rejected} invalid_signatures=${r.summary.badSignatures}`, 0);
138
+ }
139
+ if (cmd === 'team') { // Team dashboard on the BuildProof server (your licence key unlocks it there)
140
+ const u = (config.load().licenseServer || 'https://buildproof.mgrprosnetwork.com').replace(/\/$/, '') + '/team';
141
+ openUrl(u); out('TEAM_DASHBOARD ' + u, 0);
142
+ }
94
143
  if (cmd === 'ci' || cmd === 'spec') { // pull request check (Team+) / spec check (Pro+): no background service needed
95
144
  const ci = require('../core/ci');
96
145
  const folder = positional[0] || process.cwd();
@@ -98,7 +147,7 @@ async function main() {
98
147
  const lic = ci.licensed(require('../core/license'), cmd);
99
148
  if (!lic.ok) out(`CANNOT_CHECK ${lic.why}`, 2);
100
149
  const base = typeof flag('base') === 'string' ? flag('base') : null;
101
- const r = await ci.check(folder, { base, spec: typeof flag('spec') === 'string' ? flag('spec') : null, requireSpec: cmd === 'spec', noBaseline: !!flag('no-baseline') });
150
+ const r = await ci.check(folder, { base, spec: typeof flag('spec') === 'string' ? flag('spec') : null, requireSpec: cmd === 'spec', noBaseline: !!flag('no-baseline'), noRetry: !!flag('no-retry') });
102
151
  const sum = typeof flag('summary') === 'string' ? flag('summary') : process.env.GITHUB_STEP_SUMMARY;
103
152
  if (sum) { try { fs.appendFileSync(sum, r.md + '\n'); } catch { /* summary is optional */ } }
104
153
  out(r.text, r.code);
@@ -187,16 +236,30 @@ async function main() {
187
236
  const lic = await api('GET', '/api/license');
188
237
  const connected = Object.entries(hk.hooks || {}).filter(([, v]) => v.connected).map(([k]) => k);
189
238
  console.log(`INIT project=${pr.project.name} type=${pr.project.type} proof=${pr.project.verify.join(',') || 'none'} tools=${connected.join(',') || 'none'} service=${sv.how}${sv.autostart ? '/' + sv.autostart : ''} license=${lic.label}:${lic.status}${lic.daysLeft != null ? '(' + lic.daysLeft + 'd)' : ''}`);
239
+ let ciNote = '';
240
+ if (flag('ci')) { const w = require('../core/ci').init(dir); ciNote = w.ok ? `pull request check added: ${path.relative(dir, w.file)} - add your licence key as the BUILDPROOF_LICENSE secret in GitHub` : `pull request check already there: ${path.relative(dir, w.file)}`; }
241
+ console.log(initSummary({ project: pr.project, connected, lic, ciNote, git: tools.includes('git') }));
190
242
  if (!process.env.MGR_NO_AUTOSTART && !process.env.MGR_NO_OPEN) openUrl(`http://127.0.0.1:${sv.port}/connect`);
191
243
  out(`OPEN http://127.0.0.1:${sv.port}/connect (BuildProof on this computer + add your phone)`, 0);
192
244
  }
245
+ if (cmd === 'try') { // 30-second demo on a throw-away sample project, never on your code
246
+ const service = require('../core/service');
247
+ const sv = await service.ensure({ autostart: !process.env.MGR_NO_AUTOSTART });
248
+ if (!sv.ok) out(`TRY_FAIL BuildProof could not start on port ${sv.port}`, 1);
249
+ const r = await require('../core/try-demo').run({ api, sleep, say: (t) => console.log(t) });
250
+ if (!r.ok) out(`TRY_FAIL ${r.error}${r.error === 'license_required' ? ' (start the free trial: buildproof init)' : ''}${r.limit ? ' (limit ' + r.limit + ' projects in this plan)' : ''}`, 1);
251
+ const good = !r.round1.proven && r.round2.proven;
252
+ console.log('');
253
+ console.log(good ? 'That is BuildProof: the shortcut was caught and undone, the real fix was proven. Set it up on your project: npx buildproof init' : 'The demo did not end as expected - please tell us: https://buildproof.mgrprosnetwork.com');
254
+ out(`TRY ${good ? 'OK' : 'UNEXPECTED'} shortcut=${r.round1.proven ? 'PROVEN' : 'NOT_PROVEN'} real_fix=${r.round2.proven ? 'PROVEN' : 'NOT_PROVEN'}`, good ? 0 : 1);
255
+ }
193
256
  if (cmd === 'open') { const u = `http://127.0.0.1:${config.load().port || 38700}/connect`; openUrl(u); out('OPEN ' + u, 0); }
194
257
  if (cmd === 'status') {
195
258
  const r = await api('GET', '/api/status');
196
259
  out(r.ok ? `BUILDPROOF v${r.version} AI=${r.ai.ok ? 'OK' : 'DOWN'} fixes=${r.fixes} key=${r.fingerprint}` : `DOWN ${r.error}`, r.ok ? 0 : 1);
197
260
  }
198
- if (!['start', 'check', 'accept', 'rollback', 'connect'].includes(cmd)) {
199
- out(fs.readFileSync(__filename, 'utf8').split('\n').slice(3, 19).map((l) => l.replace(/^ \* ?/, '')).join('\n'), cmd === 'help' ? 0 : 1);
261
+ if (!['start', 'check', 'accept', 'rollback', 'connect', 'try'].includes(cmd)) {
262
+ out(fs.readFileSync(__filename, 'utf8').split('\n').slice(3, 22).map((l) => l.replace(/^ \* ?/, '')).join('\n'), cmd === 'help' ? 0 : 1);
200
263
  }
201
264
 
202
265
  const input = await readStdin();
package/core/audit.js ADDED
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+ /**
3
+ * Audit report (Enterprise): every change BuildProof checked on this computer in a period, one self-contained file.
4
+ * accepted changes = signed certificates (each signature re-verified while building the report)
5
+ * rejected changes = guard checks that ended NOT PROVEN / rejected / rolled back
6
+ * The report itself is signed with this computer's BuildProof key, so a later edit of the file shows.
7
+ *
8
+ * buildproof audit [--since 2026-01-01] [--until 2026-12-31] [--out report.html] (also writes report.json)
9
+ */
10
+ const fs = require('fs');
11
+ const path = require('path');
12
+ const crypto = require('crypto');
13
+
14
+ const REJECTED = new Set(['unproven', 'rejected', 'rolled_back', 'failed']);
15
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
16
+ const inRange = (t, since, until) => !!t && (!since || t >= since) && (!until || t <= until + 'T23:59:59.999Z');
17
+
18
+ function build({ certs = [], tasks = [], since = null, until = null, verify = () => false, machine = '' }) {
19
+ const accepted = certs.filter((c) => inRange(c.issuedAt, since, until)).map((c) => {
20
+ const p = c.payload || {};
21
+ const checks = (p.checks || []).map((k) => `${k.step}:${k.after}`).join(' ');
22
+ return {
23
+ id: c.id, date: c.issuedAt, project: c.project, task: (p.task && p.task.text) || '', result: c.result,
24
+ signatureValid: !!verify(c), countersigned: !!(c.countersign && c.countersign.entry), files: (p.changes || []).length,
25
+ checks, integrityClean: !!(p.integrity && p.integrity.clean), revert: (p.revertCheck && p.revertCheck.verdict) || null,
26
+ falseClaims: (p.claims || []).filter((x) => x.true === false).length, aiModel: (p.ai && p.ai.model) || null,
27
+ };
28
+ });
29
+ const rejected = tasks.filter((t) => REJECTED.has(t.state) && inRange(t.finishedAt || t.createdAt, since, until)).map((t) => ({
30
+ id: t.id, date: t.finishedAt || t.createdAt, project: t.projectName || t.projectId || '', kind: t.kind || '', state: t.state,
31
+ why: String(t.resultText || '').slice(0, 300), integrityFindings: (t.integrity && t.integrity.findings ? t.integrity.findings.map((f) => f.rule) : []),
32
+ }));
33
+ const ruleCount = {};
34
+ for (const r of rejected) for (const rule of r.integrityFindings) ruleCount[rule] = (ruleCount[rule] || 0) + 1;
35
+ const summary = {
36
+ accepted: accepted.length, acceptedWithWarnings: accepted.filter((a) => a.result === 'ACCEPTED_WITH_WARNINGS').length,
37
+ rejected: rejected.length, badSignatures: accepted.filter((a) => !a.signatureValid).length,
38
+ countersigned: accepted.filter((a) => a.countersigned).length, weakenedChecksCaught: ruleCount,
39
+ };
40
+ return { format: 'buildproof-audit/1', generatedAt: new Date().toISOString(), machine, period: { since, until }, summary, accepted, rejected };
41
+ }
42
+
43
+ /** Sign the report body (canonical JSON) with this computer's key; anyone can check it with the public key inside. */
44
+ function sign(report, certs) {
45
+ const k = certs.keys();
46
+ const body = certs.canonical(report);
47
+ return { report, signature: crypto.sign(null, Buffer.from(body, 'utf8'), k.privateKey).toString('base64'), publicKey: k.spkiB64, fingerprint: k.fingerprint, sha256: crypto.createHash('sha256').update(body).digest('hex') };
48
+ }
49
+
50
+ function verifySigned(signed, certs) {
51
+ try {
52
+ const pub = crypto.createPublicKey({ key: Buffer.from(signed.publicKey, 'base64'), format: 'der', type: 'spki' });
53
+ return crypto.verify(null, Buffer.from(certs.canonical(signed.report), 'utf8'), pub, Buffer.from(signed.signature, 'base64'));
54
+ } catch { return false; }
55
+ }
56
+
57
+ function html(signed) {
58
+ const r = signed.report, s = r.summary;
59
+ const rules = Object.entries(s.weakenedChecksCaught).map(([k, v]) => `${esc(k)}: ${v}`).join(', ') || 'none';
60
+ const row = (cells) => '<tr>' + cells.map((c) => `<td>${c}</td>`).join('') + '</tr>';
61
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>BuildProof audit report</title>
62
+ <style>:root{color-scheme:dark}body{margin:0;background:#08111f;color:#edf3ff;font:15px/1.5 Arial,sans-serif}main{max-width:1100px;margin:auto;padding:24px 14px}h1{margin:0 0 4px}small{color:#a8bfd7}
63
+ .k{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:10px;margin:16px 0}.k div{border:1px solid #3b5575;border-radius:12px;background:#14243a;padding:12px}.k b{display:block;font-size:26px}
64
+ table{width:100%;border-collapse:collapse;margin:8px 0 22px;font-size:13px}th,td{border-bottom:1px solid #2c4461;padding:6px;text-align:left;vertical-align:top}th{color:#f5d8a2}.bad{color:#ffb3bf}.ok{color:#9ff0bf}code{word-break:break-all;color:#a8bfd7}</style></head><body><main>
65
+ <h1>BuildProof audit report</h1><small>Period: ${esc(r.period.since || 'start')} to ${esc(r.period.until || 'today')} · machine ${esc(r.machine)} · generated ${esc(r.generatedAt)}</small>
66
+ <div class="k"><div>Accepted changes<b>${s.accepted}</b></div><div>Rejected changes<b>${s.rejected}</b></div><div>Accepted with warnings<b>${s.acceptedWithWarnings}</b></div><div>Countersigned (public log)<b>${s.countersigned}</b></div><div>Certificate signatures invalid<b class="${s.badSignatures ? 'bad' : 'ok'}">${s.badSignatures}</b></div></div>
67
+ <p>Weakened checks caught: ${rules}</p>
68
+ <h2>Accepted changes (signed certificates)</h2><table><tr><th>Date</th><th>Project</th><th>Task</th><th>Result</th><th>Checks</th><th>Files</th><th>Signature</th><th>Certificate</th></tr>
69
+ ${r.accepted.map((a) => row([esc(a.date.slice(0, 16).replace('T', ' ')), esc(a.project), esc(a.task.slice(0, 120)), esc(a.result), esc(a.checks), a.files, a.signatureValid ? '<span class="ok">valid</span>' : '<span class="bad">INVALID</span>', `<code>${esc(a.id)}</code>`])).join('\n') || row(['-', '', 'none in this period', '', '', '', '', ''])}</table>
70
+ <h2>Rejected changes</h2><table><tr><th>Date</th><th>Project</th><th>State</th><th>Why</th><th>Weakened checks</th></tr>
71
+ ${r.rejected.map((x) => row([esc(String(x.date).slice(0, 16).replace('T', ' ')), esc(x.project), esc(x.state), esc(x.why), esc(x.integrityFindings.join(', '))])).join('\n') || row(['-', '', 'none in this period', '', ''])}</table>
72
+ <h2>Report signature</h2><p>SHA-256 of the report body: <code>${esc(signed.sha256)}</code><br>Signed by BuildProof key <code>${esc(signed.fingerprint)}</code>. The signed data is the report.json file next to this one: <code>buildproof audit --verify report.json</code></p>
73
+ </main></body></html>`;
74
+ }
75
+
76
+ /** Collect, sign and write report.html + report.json. */
77
+ function write({ out, since, until }) {
78
+ const certs = require('./certs');
79
+ const store = require('./store');
80
+ const projects = Object.fromEntries(store.list('projects').map((p) => [p.id, p.name]));
81
+ const tasks = store.list('tasks').map((t) => ({ ...t, projectName: projects[t.projectId] }));
82
+ const report = build({ certs: store.list('certs'), tasks, since, until, verify: certs.verify, machine: require('os').hostname() });
83
+ const signed = sign(report, certs);
84
+ const htmlFile = path.resolve(out || `buildproof-audit-${new Date().toISOString().slice(0, 10)}.html`);
85
+ const jsonFile = htmlFile.replace(/\.html?$/i, '') + '.json';
86
+ fs.writeFileSync(htmlFile, html(signed));
87
+ fs.writeFileSync(jsonFile, JSON.stringify(signed, null, 2));
88
+ return { htmlFile, jsonFile, summary: report.summary };
89
+ }
90
+
91
+ module.exports = { build, sign, verifySigned, html, write };
package/core/ci.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * CI / pull request check: compare the pull request (HEAD) with its base branch, without the background service.
4
4
  *
5
- * buildproof ci [folder] [--base origin/main] [--spec spec.md] [--no-baseline] [--summary file.md]
5
+ * buildproof ci [folder] [--base origin/main] [--spec spec.md] [--no-baseline] [--no-retry] [--summary file.md]
6
6
  *
7
7
  * 1. test-integrity rules on every changed file (deleted / skipped / weakened tests, silenced checkers...)
8
8
  * 2. the project's build / test scripts on the base and on the pull request
@@ -54,14 +54,27 @@ async function installDeps(dir, info, timeoutMs) {
54
54
  return run(pm, args, { cwd: dir, timeoutMs });
55
55
  }
56
56
 
57
- async function verifyDir(dir, info, commandFor, timeoutMs) {
57
+ /**
58
+ * Run every check step. A step that really ran and FAILED is run once more (retries=1 by default):
59
+ * if it passes the second time it is reported as FLAKY - in the summary, in the text line and in the verdict -
60
+ * instead of blaming the pull request for a test that fails at random. A step that did not really run
61
+ * (timeout, no tests found) is never retried, and a test that fails every time still fails.
62
+ */
63
+ async function verifyDir(dir, info, commandFor, timeoutMs, retries = 1) {
58
64
  const results = {};
59
65
  for (const step of info.verify) {
60
66
  const { cmd, args } = commandFor(info, step);
61
- // NODE_TEST_CONTEXT would make a nested `node --test` report to its parent instead of failing here
62
- const r = await run(cmd, args, { cwd: dir, timeoutMs, env: { PYTHONDONTWRITEBYTECODE: '1', NODE_TEST_CONTEXT: undefined } });
63
- const g = gate.evaluate(step, r, { strictCounts: STRICT_TYPES.has(info.type) });
64
- results[step] = { ...g, tail: String(r.output || '').slice(-1500) };
67
+ const once = async () => {
68
+ // NODE_TEST_CONTEXT would make a nested `node --test` report to its parent instead of failing here
69
+ const r = await run(cmd, args, { cwd: dir, timeoutMs, env: { PYTHONDONTWRITEBYTECODE: '1', NODE_TEST_CONTEXT: undefined } });
70
+ return { ...gate.evaluate(step, r, { strictCounts: STRICT_TYPES.has(info.type) }), tail: String(r.output || '').slice(-1500) };
71
+ };
72
+ let g = await once();
73
+ for (let i = 0; i < retries && !g.pass && g.ran; i++) {
74
+ const again = await once();
75
+ if (again.pass) { g = { ...again, flaky: true, firstFailure: g.tail }; break; }
76
+ }
77
+ results[step] = g;
65
78
  }
66
79
  return results;
67
80
  }
@@ -130,11 +143,13 @@ function checkSpec(items, { root, baseDir, testFiles, after, baseline }) {
130
143
  function stepLine(s, r) {
131
144
  if (!r) return `- ${s}: did not run`;
132
145
  const t = r.tests ? ` (${r.tests.passed}/${r.tests.total} tests)` : '';
133
- return `- ${s}: ${r.pass ? 'pass' : r.ran ? 'FAIL' : 'did not really run (' + r.reason + ')'}${t}`;
146
+ return `- ${s}: ${r.pass ? (r.flaky ? '**FLAKY** - failed, then passed when run again' : 'pass') : r.ran ? 'FAIL' : 'did not really run (' + r.reason + ')'}${t}`;
134
147
  }
135
148
 
136
149
  function markdown(res) {
137
150
  const L = [`## BuildProof: ${res.proven ? 'PROVEN' : 'NOT PROVEN'}`, '', res.why, ''];
151
+ const flaky = (res.steps || []).filter((st) => res.after && res.after[st] && res.after[st].flaky);
152
+ if (flaky.length) L.push(`> **Flaky:** ${flaky.join(', ')} failed once and passed when run again. Not blamed on this pull request - but fix or quarantine the flaky test (\`--no-retry\` turns the re-run off).`, '');
138
153
  L.push(`Compared with \`${res.base}\`: ${res.changes.length} changed file(s).`, '');
139
154
  if (res.integrity.findings.length) {
140
155
  L.push('### Checks weakened in this change');
@@ -186,12 +201,12 @@ async function check(root, opts = {}) {
186
201
  const steps = info.verify || [];
187
202
  let after = null, baseline = null, verdict = null;
188
203
  if (steps.length) {
189
- after = await verifyDir(root, info, projects.commandFor, timeoutMs);
204
+ after = await verifyDir(root, info, projects.commandFor, timeoutMs, opts.noRetry ? 0 : 1);
190
205
  if (!opts.noBaseline) {
191
206
  const binfo = projects.detect(baseDir);
192
207
  binfo.verify = steps.filter((s) => (binfo.verify || []).includes(s));
193
208
  await installDeps(baseDir, binfo, timeoutMs);
194
- baseline = await verifyDir(baseDir, binfo, projects.commandFor, timeoutMs);
209
+ baseline = await verifyDir(baseDir, binfo, projects.commandFor, timeoutMs, opts.noRetry ? 0 : 1);
195
210
  }
196
211
  // no baseline: every step must pass on its own (stricter)
197
212
  verdict = gate.judge(baseline || after, after, steps, true); // a pull request must leave every check passing
@@ -211,7 +226,8 @@ async function check(root, opts = {}) {
211
226
  : (integ.clean && verdict && verdict.ok ? `Spec not met: ${specBad.slice(0, 3).map((x) => `${x.req} (${x.why})`).join('; ')}` : gate.whyNot(verdict, integ));
212
227
  const res = { proven, why, base, changes, integrity: integ, steps, after, baseline, spec };
213
228
  const md = markdown(res);
214
- const text = `${proven ? 'PROVEN' : 'NOT_PROVEN'} files=${changes.length} base=${base} | ${why}`;
229
+ const flaky = steps.filter((st) => after && after[st] && after[st].flaky);
230
+ const text = `${proven ? 'PROVEN' : 'NOT_PROVEN'} files=${changes.length} base=${base}${flaky.length ? ' flaky=' + flaky.join(',') : ''} | ${why}${flaky.length ? ` Flaky: ${flaky.join(', ')} failed once and passed when run again - fix or quarantine it.` : ''}`;
215
231
  return { code: proven ? 0 : 1, proven, why, text, md };
216
232
  } finally {
217
233
  try { git(['worktree', 'remove', '--force', baseDir], root); } catch { /* ignore */ }
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+ /**
3
+ * buildproof hunt: send the change to the BuildProof hunter server and get back PROVEN bugs.
4
+ * --cloud the server's AI does the thinking (uses one cloud check; the trial includes 5)
5
+ * default YOUR local model answers (Ollama on this computer): free, and the hunter code stays on the server
6
+ * Your code is uploaded to the BuildProof server, runs there in a locked-down container (no network) and is deleted
7
+ * when the check ends. The result is signed by the server.
8
+ */
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const http = require('http');
12
+ const https = require('https');
13
+ const cp = require('child_process');
14
+
15
+ const git = (args, cwd) => cp.execFileSync('git', args, { cwd, encoding: 'buffer', maxBuffer: 80 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
16
+ const gitText = (args, cwd) => git(args, cwd).toString('utf8').trim();
17
+
18
+ function request(method, urlStr, headers, body, timeoutMs = 60000) {
19
+ return new Promise((resolve) => {
20
+ let u; try { u = new URL(urlStr); } catch { resolve({ code: 0, j: null }); return; }
21
+ const data = body ? JSON.stringify(body) : null;
22
+ const req = (u.protocol === 'https:' ? https : http).request(u, { method, timeout: timeoutMs, headers: { ...headers, ...(data ? { 'content-type': 'application/json', 'content-length': Buffer.byteLength(data) } : {}) } }, (res) => {
23
+ let b = ''; res.on('data', (d) => { b += d; }); res.on('end', () => { let j = null; try { j = JSON.parse(b); } catch { /* not json */ } resolve({ code: res.statusCode, j }); });
24
+ });
25
+ req.on('timeout', () => req.destroy(new Error('timeout')));
26
+ req.on('error', () => resolve({ code: 0, j: null }));
27
+ req.end(data);
28
+ });
29
+ }
30
+
31
+ /** licence key (Pro and up) or the trial device */
32
+ function authHeaders(license) {
33
+ const key = license.currentKey();
34
+ if (key) return { authorization: 'Bearer ' + key };
35
+ return { 'x-bp-device': license.deviceId() };
36
+ }
37
+
38
+ /** base and changed code as .tar.gz (tracked files; uncommitted edits included) */
39
+ function archives(root, baseRef) {
40
+ const mergeBase = gitText(['merge-base', baseRef, 'HEAD'], root);
41
+ const work = gitText(['stash', 'create'], root) || 'HEAD'; // a commit of the working tree, nothing is changed
42
+ return { before: git(['archive', '--format=tar.gz', mergeBase], root).toString('base64'), after: git(['archive', '--format=tar.gz', work], root).toString('base64'), mergeBase };
43
+ }
44
+
45
+ /** the customer's own model (Ollama by default) */
46
+ function localLlm(cfg, env = process.env) {
47
+ const endpoint = env.BUILDPROOF_AI_URL || (cfg.ollama && cfg.ollama.endpoint) || 'http://127.0.0.1:11434';
48
+ const model = env.BUILDPROOF_AI_MODEL || (cfg.ollama && cfg.ollama.model) || 'qwen3-coder:30b';
49
+ return async (prompt) => {
50
+ const r = await request('POST', endpoint.replace(/\/$/, '') + '/api/generate', {}, { model, prompt, stream: false, options: { temperature: 0.7, num_ctx: 16384 } }, 300000);
51
+ return r.j ? r.j.response || '' : '';
52
+ };
53
+ }
54
+
55
+ async function run({ root, base, cloud, intent, cfg, license, server, llm, log = () => {}, pollMs = 2000, maxMs = 40 * 60000 }) {
56
+ const headers = authHeaders(license);
57
+ let a; try { a = archives(root, base); } catch (e) { return { code: 2, text: 'CANNOT_HUNT git: ' + String(e.message).split('\n')[0] }; }
58
+ const start = await request('POST', server + '/api/hunt', headers, { before: a.before, after: a.after, mode: cloud ? 'cloud' : 'local', intent }, 300000);
59
+ if (start.code !== 200 || !start.j || !start.j.ok) {
60
+ const e = (start.j && start.j.error) || 'server_unavailable';
61
+ const hint = { no_cloud_checks: 'no cloud checks left: buildproof credits --buy 20, or run without --cloud (your own model, free)', hunter_not_in_plan: 'the hunter is in Pro and up', trial_ended: 'the trial has ended', cloud_ai_not_configured: 'cloud AI is not available yet, run without --cloud' }[e];
62
+ return { code: 2, text: `CANNOT_HUNT ${e}${hint ? ' - ' + hint : ''}` };
63
+ }
64
+ const id = start.j.id;
65
+ const ask = llm || localLlm(cfg || {});
66
+ log(`HUNT_STARTED ${id} mode=${start.j.mode}`);
67
+ const t0 = Date.now();
68
+ for (;;) {
69
+ if (Date.now() - t0 > maxMs) return { code: 2, text: 'CANNOT_HUNT timeout' };
70
+ const st = await request('GET', `${server}/api/hunt/${id}`, headers);
71
+ if (st.code !== 200 || !st.j) { await sleep(pollMs); continue; }
72
+ for (const p of st.j.prompts || []) { // the server's AI questions, answered by the local model
73
+ const text = await ask(p.prompt);
74
+ await request('POST', `${server}/api/hunt/${id}/answer`, headers, { id: p.id, text }, 60000);
75
+ }
76
+ if (st.j.status === 'done' || st.j.status === 'error') {
77
+ const dir = path.join(root, '.buildproof'); fs.mkdirSync(dir, { recursive: true });
78
+ const file = path.join(dir, `hunt-${id}.json`);
79
+ fs.writeFileSync(file, JSON.stringify({ report: st.j.report, certificate: st.j.certificate, signature: st.j.signature, algo: st.j.algo }, null, 2));
80
+ if (st.j.status === 'error') return { code: 2, text: `CANNOT_HUNT ${(st.j.report && st.j.report.error) || 'hunter error'}`, file };
81
+ const proven = (st.j.report.findings || []).filter((f) => f.proven);
82
+ const lines = proven.map((f) => ` - ${f.oracle} ${f.file}${f.line ? ':' + f.line : ''} ${f.why || ''}`);
83
+ return { code: proven.length ? 1 : 0, text: `${proven.length ? 'BUGS_PROVEN ' + proven.length : 'NO_PROVEN_BUGS'} files=${(st.j.report.files || []).length} report=${file}${lines.length ? '\n' + lines.join('\n') : ''}`, file, report: st.j.report };
84
+ }
85
+ await sleep(pollMs);
86
+ }
87
+ }
88
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
89
+
90
+ async function credits({ license, server, buy, open }) {
91
+ const headers = authHeaders(license);
92
+ if (buy) {
93
+ const r = await request('POST', server + '/api/credits/order', headers, { pack: String(buy) });
94
+ if (r.code !== 200 || !r.j || !r.j.ok) return { code: 2, text: 'CANNOT_BUY ' + ((r.j && r.j.error) || 'server_unavailable') };
95
+ open(r.j.approve);
96
+ return { code: 0, text: `PAY ${r.j.checks} cloud checks for $${r.j.usd} in the PayPal page that opened: ${r.j.approve}` };
97
+ }
98
+ const r = await request('GET', server + '/api/credits', headers);
99
+ if (r.code !== 200 || !r.j) return { code: 2, text: 'CANNOT_READ ' + ((r.j && r.j.error) || 'server_unavailable') };
100
+ return { code: 0, text: `CLOUD_CHECKS ${r.j.cloudChecks} (buy more: buildproof credits --buy 20)` };
101
+ }
102
+
103
+ module.exports = { run, credits, archives, authHeaders, localLlm };
package/core/license.js CHANGED
@@ -17,11 +17,11 @@ const GRACE_DAYS = 3;
17
17
  const DAY = 864e5;
18
18
 
19
19
  const F = { guard: 'guard', hooks: 'hooks', certificates: 'certificates', remote: 'remote', revertCheck: 'revertCheck', claims: 'claims', aiFix: 'aiFix', ci: 'ci', spec: 'spec', verifyPage: 'verifyPage', dashboard: 'dashboard', sso: 'sso', audit: 'audit' };
20
- const BASIC = [F.guard, F.hooks];
20
+ const BASIC = [F.guard, F.hooks, F.certificates]; // signed certificates are what sets BuildProof apart: in every paid plan
21
21
  const PRO = [...BASIC, F.certificates, F.remote, F.revertCheck, F.claims, F.aiFix, F.spec];
22
22
  const TEAM = [...PRO, F.ci, F.verifyPage, F.dashboard];
23
23
  const PLANS = {
24
- trial: { label: 'Trial', price: 'free for 14 days', projects: 2, features: [...PRO, F.ci] }, // the trial opens everything up to Team checks
24
+ trial: { label: 'Trial', price: 'free for 14 days', projects: 2, features: [...PRO, F.ci, F.verifyPage, F.dashboard, F.audit] }, // the trial opens everything (SSO is set up on request)
25
25
  basic: { label: 'Basic', price: '$15 / month', projects: 3, features: BASIC },
26
26
  pro: { label: 'Pro', price: '$25 / month', projects: Infinity, features: PRO },
27
27
  team: { label: 'Team', price: '$50 / user / month', projects: Infinity, features: TEAM },
@@ -79,19 +79,23 @@ function trialStart() {
79
79
  try{fs.writeFileSync(marker,iso)}catch{}
80
80
  return prev;
81
81
  }
82
- function onlineTrial(){
83
- if(global.__bpTrialCache && Date.now()-global.__bpTrialCacheAt<30000)return global.__bpTrialCache;
82
+ function deviceId(){
84
83
  const cp=require('child_process');
85
- const cfg=require('./config').load();
86
- const base=process.env.MGR_TRIAL_SERVER||cfg.licenseServer;
87
- if(!base)return null; // developer test installations without a configured server
88
84
  const os=require('os');
89
85
  let identity='';
90
86
  if(process.platform==='win32'){
91
87
  try{identity=cp.execFileSync('reg',['query','HKLM\\SOFTWARE\\Microsoft\\Cryptography','/v','MachineGuid'],{encoding:'utf8',timeout:1500}).match(/MachineGuid\s+REG_SZ\s+(\S+)/i)?.[1]||''}catch{}
92
88
  }else {try{identity=fs.readFileSync('/etc/machine-id','utf8').trim()}catch{}}
93
89
  if(!identity)identity=os.hostname()+'|'+Object.values(os.networkInterfaces()).flat().filter(x=>x&&!x.internal&&x.mac&&x.mac!=='00:00:00:00:00:00').map(x=>x.mac).sort().join('|');
94
- const device=crypto.createHash('sha256').update('BuildProof-trial-v4:'+identity).digest('hex');
90
+ return crypto.createHash('sha256').update('BuildProof-trial-v4:'+identity).digest('hex');
91
+ }
92
+ function onlineTrial(){
93
+ if(global.__bpTrialCache && Date.now()-global.__bpTrialCacheAt<30000)return global.__bpTrialCache;
94
+ const cp=require('child_process');
95
+ const cfg=require('./config').load();
96
+ const base=process.env.MGR_TRIAL_SERVER||cfg.licenseServer;
97
+ if(!base)return null; // developer test installations without a configured server
98
+ const device=deviceId();
95
99
  const url=new URL('/api/trial/start',base).href;
96
100
  const childCode="const u=process.argv[1],d=process.argv[2],m=u.startsWith('https:')?require('https'):require('http');const r=m.request(u,{method:'POST',headers:{'content-type':'application/json'},timeout:3000},s=>{let b='';s.on('data',x=>b+=x);s.on('end',()=>{if(s.statusCode!==200)process.exit(4);try{const v=JSON.parse(b);if(!v.ok||!['trial','expired'].includes(v.status)||!Number.isInteger(v.daysLeft))process.exit(5);process.stdout.write(JSON.stringify(v))}catch{process.exit(6)}})});r.on('timeout',()=>r.destroy());r.on('error',()=>process.exit(7));r.end(JSON.stringify({device:d}))";
97
101
  const r=cp.spawnSync(process.execPath,['-e',childCode,url,device],{encoding:'utf8',timeout:4500,windowsHide:true});
@@ -162,4 +166,4 @@ function publicInfo() {
162
166
  return { ...status(), plans: Object.fromEntries(Object.entries(PLANS).map(([k, v]) => [k, { label: v.label, price: v.price, projects: v.projects === Infinity ? null : v.projects, features: v.features }])), featureText: FEATURE_TEXT };
163
167
  }
164
168
 
165
- module.exports = { status, has, currentKey, activate, renew, parseKey, signKey, publicInfo, PLANS, F, TRIAL_DAYS };
169
+ module.exports = { deviceId, status, has, currentKey, activate, renew, parseKey, signKey, publicInfo, PLANS, F, TRIAL_DAYS };
package/core/server.js CHANGED
@@ -266,7 +266,9 @@ ${links.map((l, i) => `<div class="q"><div id="q${i}"></div><p>${l.replace(/toke
266
266
  if (need('guard', 'license_required')) return;
267
267
  const all = store.list('projects');
268
268
  const known = all.some((x) => path.resolve(x.root).toLowerCase() === path.resolve(String(b.root || '')).toLowerCase());
269
- if (!known && lic.projects != null && all.length >= lic.projects) return send(res, 402, { ok: false, error: 'plan_limit_projects', limit: lic.projects, license: lic });
269
+ // `buildproof try` sample: a throw-away folder in the temp dir, removed right after - never counts against the plan
270
+ const tryDemo = b.demo === true && /^buildproof-try-/.test(path.basename(String(b.root || ''))) && path.resolve(String(b.root || '')).toLowerCase().startsWith(path.resolve(require('os').tmpdir()).toLowerCase() + path.sep);
271
+ if (!known && !tryDemo && lic.projects != null && all.length >= lic.projects) return send(res, 402, { ok: false, error: 'plan_limit_projects', limit: lic.projects, license: lic });
270
272
  const r = projects.add({ name: b.name, root: b.root });
271
273
  return send(res, r.ok ? 200 : 400, r);
272
274
  }
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+ /**
3
+ * `buildproof try` - a 30-second, safe demo on a throw-away sample project (never on your code).
4
+ * 1. An "AI" says "Fixed, all tests pass" after skipping the failing test -> BuildProof: NOT PROVEN, rolled back.
5
+ * 2. The real fix of the bug -> BuildProof: PROVEN.
6
+ * The sample project is created in the temp folder and removed at the end, together with its project entry,
7
+ * so it does not use a project slot of your plan.
8
+ */
9
+ const fs = require('fs');
10
+ const os = require('os');
11
+ const path = require('path');
12
+
13
+ const PKG = { name: 'buildproof-try', version: '1.0.0', private: true, scripts: { test: 'node --test' } };
14
+ const BUGGY = `'use strict';
15
+ /** Order total with shipping: shipping is free from $50. */
16
+ function total(items) {
17
+ const sum = items.reduce((s, i) => s + i.price * i.qty, 0);
18
+ const shipping = sum > 50 ? 0 : 7;
19
+ return sum + shipping;
20
+ }
21
+ module.exports = { total };
22
+ `;
23
+ const FIXED = BUGGY.replace('sum > 50', 'sum >= 50');
24
+ const TEST = `'use strict';
25
+ const test = require('node:test');
26
+ const assert = require('node:assert');
27
+ const { total } = require('./price');
28
+
29
+ test('small order pays shipping', () => { assert.strictEqual(total([{ price: 10, qty: 1 }]), 17); });
30
+ test('large order ships free', () => { assert.strictEqual(total([{ price: 30, qty: 3 }]), 90); });
31
+ test('free shipping from 50', () => { assert.strictEqual(total([{ price: 25, qty: 2 }]), 50); });
32
+ `;
33
+ const CHEAT = TEST.replace("test('free shipping from 50'", "test.skip('free shipping from 50'");
34
+
35
+ function makeSample() {
36
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'buildproof-try-'));
37
+ fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(PKG, null, 2) + '\n');
38
+ fs.writeFileSync(path.join(dir, 'price.js'), BUGGY);
39
+ fs.writeFileSync(path.join(dir, 'price.test.js'), TEST);
40
+ return dir;
41
+ }
42
+
43
+ /** api(method, path, body) talks to the local BuildProof service; say(text) prints one line. */
44
+ async function run({ api, say, sleep, keepFolder = false }) {
45
+ const dir = makeSample();
46
+ let projectId = null;
47
+ const waitGuard = async (g) => {
48
+ for (let i = 0; g && ['baselining', 'checking'].includes(g.state) && i < 600; i++) { await sleep(500); g = (await api('GET', `/api/tasks/${g.id}`)).task; }
49
+ return g;
50
+ };
51
+ const startGuard = async () => {
52
+ const r = await api('POST', '/api/guards', { projectId, source: 'try' });
53
+ if (!r.ok) throw new Error(r.error || 'guard_not_started');
54
+ const g = await waitGuard(r.task);
55
+ if (!g || g.state !== 'watching') throw new Error(g ? g.resultText || g.state : 'guard_not_started');
56
+ return g;
57
+ };
58
+ try {
59
+ const pr = await api('POST', '/api/projects', { root: dir, name: 'buildproof-try', demo: true });
60
+ if (!pr.ok) return { ok: false, error: pr.error === 'license_required' ? 'license_required' : pr.error || 'project_not_added', limit: pr.limit };
61
+ projectId = pr.project.id;
62
+ say('Sample shop project (not your code): price.js has a bug - an order of exactly $50 pays shipping, but it should be free.');
63
+ say('Its test "free shipping from 50" fails, as it should.');
64
+ say('');
65
+
66
+ // round 1: the shortcut many AI agents take
67
+ let g = await startGuard();
68
+ fs.writeFileSync(path.join(dir, 'price.test.js'), CHEAT);
69
+ say('Round 1 - the AI skips the failing test and says: "Fixed, all tests pass."');
70
+ let c = await api('POST', `/api/guards/${g.id}/check`, { claim: 'Fixed the shipping bug, all tests pass.' });
71
+ let full = (await api('GET', `/api/tasks/${g.id}`)).task || {};
72
+ const why = [
73
+ ...((full.integrity && full.integrity.findings) || []).map((f) => f.text),
74
+ ...((full.claims || []).filter((x) => x.truth === false).map((x) => `claim "${x.text}" is not true`)),
75
+ ];
76
+ const round1 = { proven: !!c.proven, why };
77
+ say(` BuildProof: ${c.proven ? 'PROVEN (unexpected)' : 'NOT PROVEN'}${why.length ? ' - ' + why.slice(0, 3).join('; ') : ''}`);
78
+ const rb = await api('POST', `/api/guards/${g.id}/rollback`, {});
79
+ say(` Rolled back: ${rb.ok ? 'the project is exactly as before' : 'rollback failed: ' + rb.error}`);
80
+ say('');
81
+
82
+ // round 2: the real fix
83
+ g = await startGuard();
84
+ fs.writeFileSync(path.join(dir, 'price.js'), FIXED);
85
+ say('Round 2 - the AI fixes the real cause in price.js (sum >= 50) and leaves the tests alone.');
86
+ c = await api('POST', `/api/guards/${g.id}/check`, { claim: 'Fixed the shipping bug, all tests pass.' });
87
+ full = (await api('GET', `/api/tasks/${g.id}`)).task || {};
88
+ const round2 = { proven: !!c.proven, revert: full.revertCheck ? full.revertCheck.verdict : null };
89
+ say(` BuildProof: ${c.proven ? 'PROVEN' : 'NOT PROVEN - ' + (full.resultText || '')}${round2.revert ? ' (revert check: ' + round2.revert + ')' : ''}`);
90
+ await api('POST', `/api/guards/${g.id}/rollback`, {}); // end the demo guard; this is a throw-away folder
91
+ return { ok: true, round1, round2, dir };
92
+ } catch (e) {
93
+ return { ok: false, error: String(e.message || e) };
94
+ } finally {
95
+ if (projectId) await api('DELETE', `/api/projects/${projectId}`);
96
+ if (!keepFolder) { try { fs.rmSync(dir, { recursive: true, force: true }); } catch { /* temp folder */ } }
97
+ }
98
+ }
99
+
100
+ module.exports = { run, makeSample, BUGGY, FIXED, TEST, CHEAT };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "buildproof",
3
- "version": "3.8.1",
3
+ "version": "3.11.0",
4
4
  "description": "BuildProof - proof gate for AI-written code: test-integrity guard, fail-closed checks, scope lock, full rollback, signed certificates, local AI under supervision.",
5
5
  "main": "core/server.js",
6
6
  "scripts": {
7
7
  "start": "node core/server.js",
8
8
  "guard": "node scripts/guard.js",
9
9
  "test": "node test/run-all.js && npm run test:unit",
10
- "test:unit": "node --test test/ci.test.js test/update-check.test.js test/modules.test.js test/guard-process.test.js test/av-scan.test.js test/license-net.test.js test/guard-force.test.js test/guard-security.test.js tools/mutation-runner/acceptance.test.js",
10
+ "test:unit": "node --test test/ci.test.js test/try-demo.test.js test/update-check.test.js test/audit.test.js test/modules.test.js test/guard-process.test.js test/av-scan.test.js test/license-net.test.js test/guard-force.test.js test/guard-security.test.js tools/mutation-runner/acceptance.test.js",
11
11
  "bench": "node tools/benchmark/run.js",
12
12
  "test:hard": "node test/hardening.js"
13
13
  },