buildproof 3.8.1 → 3.10.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
@@ -20,6 +20,10 @@ Also (3.7.1): Go (go build, go vet, go test), Rust (cargo build, cargo test - al
20
20
 
21
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
22
22
 
23
+ 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.
24
+
25
+ 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.
26
+
23
27
  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
28
 
25
29
  Run: `node scripts/guard.js` (keeps core/server.js alive on port 38700). Test: `node test/run-all.js`.
package/bin/buildproof.js CHANGED
@@ -16,6 +16,8 @@
16
16
  * buildproof open open BuildProof in the browser
17
17
  * buildproof ci [folder] [--base origin/main] [--spec spec.md] pull request check for CI (--init writes the GitHub workflow)
18
18
  * buildproof spec [folder] [--base main] check the change against .buildproof/spec.md (every requirement needs a passing test)
19
+ * buildproof audit [--since 2026-01-01] [--out report.html] signed audit report of every checked change buildproof team team dashboard
20
+ * buildproof hunt [folder] [--base main] [--cloud] AI bug hunt on the server (your own model by default) buildproof credits [--buy 20]
19
21
  *
20
22
  * Hook mode (installed by "connect"): --hook=claude | --hook=cursor | --hook=git
21
23
  */
@@ -91,6 +93,33 @@ async function activeGuard(projectId) {
91
93
  }
92
94
 
93
95
  async function main() {
96
+ if (cmd === 'hunt' || cmd === 'credits') { // AI bug hunt on the BuildProof server (Pro and up, and the trial)
97
+ const hc = require('../core/hunt-client');
98
+ const server = (process.env.BUILDPROOF_SERVER || config.load().licenseServer || 'https://buildproof.mgrprosnetwork.com').replace(/\/$/, '');
99
+ const license = require('../core/license');
100
+ 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); }
101
+ const root = path.resolve(positional[0] || process.cwd());
102
+ const base = typeof flag('base') === 'string' ? flag('base') : (require('../core/ci').findBase(root, null) || 'HEAD~1');
103
+ 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) });
104
+ out(r.text, r.code);
105
+ }
106
+ if (cmd === 'audit') { // Enterprise audit report: signed HTML + JSON of every checked change in a period
107
+ const audit = require('../core/audit');
108
+ if (typeof flag('verify') === 'string') {
109
+ let signed; try { signed = JSON.parse(fs.readFileSync(flag('verify'), 'utf8')); } catch { out('AUDIT_VERIFY_FAIL cannot read the file', 1); }
110
+ const ok = audit.verifySigned(signed, require('../core/certs'));
111
+ out(ok ? `AUDIT_VALID signed by ${signed.fingerprint}` : 'AUDIT_INVALID the report was changed after it was signed', ok ? 0 : 1);
112
+ }
113
+ const lic = require('../core/license');
114
+ if (!lic.has(lic.F.audit)) out('NOT_IN_PLAN audit reports are in the Enterprise plan (and the free trial)', 2);
115
+ const day = (v) => (typeof v === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(v) ? v : null);
116
+ const r = audit.write({ out: typeof flag('out') === 'string' ? flag('out') : null, since: day(flag('since')), until: day(flag('until')) });
117
+ out(`AUDIT ${r.htmlFile} accepted=${r.summary.accepted} rejected=${r.summary.rejected} invalid_signatures=${r.summary.badSignatures}`, 0);
118
+ }
119
+ if (cmd === 'team') { // Team dashboard on the BuildProof server (your licence key unlocks it there)
120
+ const u = (config.load().licenseServer || 'https://buildproof.mgrprosnetwork.com').replace(/\/$/, '') + '/team';
121
+ openUrl(u); out('TEAM_DASHBOARD ' + u, 0);
122
+ }
94
123
  if (cmd === 'ci' || cmd === 'spec') { // pull request check (Team+) / spec check (Pro+): no background service needed
95
124
  const ci = require('../core/ci');
96
125
  const folder = positional[0] || process.cwd();
@@ -196,7 +225,7 @@ async function main() {
196
225
  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
226
  }
198
227
  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);
228
+ out(fs.readFileSync(__filename, 'utf8').split('\n').slice(3, 21).map((l) => l.replace(/^ \* ?/, '')).join('\n'), cmd === 'help' ? 0 : 1);
200
229
  }
201
230
 
202
231
  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 };
@@ -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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "buildproof",
3
- "version": "3.8.1",
3
+ "version": "3.10.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/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
  },