@behavproof/cli 0.0.0-stage → 0.1.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 +14 -2
- package/dist/api.d.ts +6 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +5 -0
- package/dist/api.js.map +1 -0
- package/dist/check.d.ts +272 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +220 -0
- package/dist/check.js.map +1 -0
- package/dist/formal-evaluation.d.ts +108 -0
- package/dist/formal-evaluation.d.ts.map +1 -0
- package/dist/formal-evaluation.js +78 -0
- package/dist/formal-evaluation.js.map +1 -0
- package/dist/formal-worker.d.ts +2 -0
- package/dist/formal-worker.d.ts.map +1 -0
- package/dist/formal-worker.js +32 -0
- package/dist/formal-worker.js.map +1 -0
- package/dist/formal.d.ts +148 -0
- package/dist/formal.d.ts.map +1 -0
- package/dist/formal.js +99 -0
- package/dist/formal.js.map +1 -0
- package/dist/impact.d.ts +20 -0
- package/dist/impact.d.ts.map +1 -0
- package/dist/impact.js +23 -0
- package/dist/impact.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +38 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +46 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/project.d.ts +97 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +101 -0
- package/dist/project.js.map +1 -0
- package/dist/registration.d.ts +595 -0
- package/dist/registration.d.ts.map +1 -0
- package/dist/registration.js +112 -0
- package/dist/registration.js.map +1 -0
- package/dist/report.d.ts +23 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +34 -0
- package/dist/report.js.map +1 -0
- package/dist/scopes.d.ts +48 -0
- package/dist/scopes.d.ts.map +1 -0
- package/dist/scopes.js +60 -0
- package/dist/scopes.js.map +1 -0
- package/dist/trust.d.ts +533 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +130 -0
- package/dist/trust.js.map +1 -0
- package/package.json +51 -4
- package/presets/basic-v1.json +21 -0
- package/presets/critical-v1.json +39 -0
- package/presets/standard-v1.json +21 -0
- package/schemas/config.schema.json +492 -0
- package/schemas/evidence.schema.json +3612 -0
- package/schemas/manifest.schema.json +225 -0
- package/schemas/policy.schema.json +21 -0
- package/schemas/registration.schema.json +1065 -0
- package/schemas/registry.schema.json +307 -0
- package/schemas/trust-root.schema.json +1445 -0
- package/templates/audit.yml +28 -0
- package/templates/protected-github-producer.yml +58 -0
- package/templates/protected-github-publisher.yml +111 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { resolve, extname } from 'node:path';
|
|
4
|
+
import { canonicalJson, hash, safeRead, safeReadJson } from '@behavproof/core';
|
|
5
|
+
import { detectProject, gitDiff } from '@behavproof/adapter-reports';
|
|
6
|
+
import { renderDocuments, analyzeImpact, reconcile } from '@behavproof/contract-registry';
|
|
7
|
+
import { check } from './check.js';
|
|
8
|
+
import { formatReport } from './report.js';
|
|
9
|
+
import { executeFormal } from './formal.js';
|
|
10
|
+
import { config, exists, fileList, registry, git, writeScoped, select, ref } from './project.js';
|
|
11
|
+
const help = `BehavProof 0.1.0\nCommands: init, doctor, check, explain <rule>, baseline create, contracts discover|list|validate, intent diff, impact, docs generate|check, formal discover|check|replay\ncheck reads artifacts; it never runs tests. Gate requires --trust-root outside project.\nOptions: --config --base --head --profile --mode audit|gate --format console|json|markdown --output --trust-root --dry-run --check --help --version\n`;
|
|
12
|
+
async function main() {
|
|
13
|
+
const { values, positionals } = parseArgs({ allowPositionals: true, strict: true, options: { config: { type: 'string' }, base: { type: 'string' }, head: { type: 'string' }, profile: { type: 'string' }, mode: { type: 'string' }, format: { type: 'string' }, output: { type: 'string' }, 'trust-root': { type: 'string' }, 'dry-run': { type: 'boolean' }, check: { type: 'boolean' }, help: { type: 'boolean' }, version: { type: 'boolean' }, root: { type: 'string' }, model: { type: 'string' } } });
|
|
14
|
+
const root = resolve(values.root ?? process.cwd()), [command, sub, ...rest] = positionals;
|
|
15
|
+
if (values.version) {
|
|
16
|
+
process.stdout.write('0.1.0\n');
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
if (values.help || !command) {
|
|
20
|
+
process.stdout.write(help);
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
if (rest.length)
|
|
24
|
+
throw Error('Unexpected command arguments');
|
|
25
|
+
const emit = async (text) => { if (values.output)
|
|
26
|
+
await writeScoped(root, values.output, text);
|
|
27
|
+
else
|
|
28
|
+
process.stdout.write(text); };
|
|
29
|
+
if (command === 'init') {
|
|
30
|
+
if (sub)
|
|
31
|
+
throw Error('Unexpected init argument');
|
|
32
|
+
const path = values.config ?? 'behavproof.config.json', found = await exists(root, path), detection = await detectProject(root);
|
|
33
|
+
const proposal = { schemaVersion: 1, mode: 'audit', profile: 'standard', git: { base: 'origin/main' }, reports: { vitest: '.behavproof/input/vitest.json', coverage: 'coverage/lcov.info', mutation: 'reports/mutation/mutation.json' }, executionManifests: [], contracts: { enabled: false, sources: [] } };
|
|
34
|
+
if (!values['dry-run'] && !found)
|
|
35
|
+
await writeScoped(root, path, JSON.stringify(proposal, null, 2) + '\n', true);
|
|
36
|
+
process.stdout.write(JSON.stringify({ path, action: found ? 'preserve' : values['dry-run'] ? 'would-create' : 'created', detection, notice: 'No package installation, workflow edits or separate specification documents are required.' }, null, 2) + '\n');
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
if (command === 'doctor') {
|
|
40
|
+
if (sub)
|
|
41
|
+
throw Error('Unexpected doctor argument');
|
|
42
|
+
const detection = await detectProject(root);
|
|
43
|
+
await config(root, values.config, values.profile);
|
|
44
|
+
await emit(JSON.stringify({ node: process.version, ...detection, trust: 'External producer and protection authority must be configured separately.' }, null, 2) + '\n');
|
|
45
|
+
return detection.support === 'single-package' ? 0 : 1;
|
|
46
|
+
}
|
|
47
|
+
if (command === 'explain') {
|
|
48
|
+
const explanations = { testResult: 'Vitest assertions must complete; skipped/zero tests or unverified producers remain unknown.', changedLineCoverage: 'Changed-line coverage requires current authenticated LCOV, complete executable-line scope and source mapping. Missing data is unknown; collect coverage in the verified execution.', mutationScore: 'Score = (Killed + Timeout) / (Killed + Timeout + Survived + NoCoverage). Missing mapping or insufficient comparable mutants is unknown.', pipelineIntegrity: 'A final always() gate checks all upstream results and artifacts. External issuer-bound branch protection requires independent verification; unavailable authority is unknown.', contractExecution: 'Declared contracts require verified runtime binding and all required cases. A fake callback can pass comparisons; production reach and sensitivity remain separate unknown claims.', intentApproval: 'Intent and contract transitions require current content-bound human approval from a protected authority.', policyProtection: 'Protected policy is supplied through a trusted external host and cannot be weakened by project configuration.' };
|
|
49
|
+
Object.assign(explanations, { productionTargetObserved: 'Require case-scoped authenticated calls to the registered real production target; comparisons alone cannot prove reach.', mutationSensitivityObserved: 'Require an actual failed comparison after the registered case-specific fault; retain it separately from ordinary test evidence.', negativeCases: 'Require the registered negative cases to execute and compare their retained expectations.', changeImpact: 'Analyze Git changes and the static dependency graph; unresolved critical impact blocks, standard warns. This does not prove behavioral equivalence.' });
|
|
50
|
+
const key = (sub ?? '').replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
51
|
+
if (!explanations[key])
|
|
52
|
+
throw Error('Unknown rule');
|
|
53
|
+
await emit(explanations[key] + '\n');
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
if (command === 'formal') {
|
|
57
|
+
const result = await executeFormal(root, sub ?? '', values);
|
|
58
|
+
await emit(canonicalJson(result.report) + '\n');
|
|
59
|
+
return result.exitCode;
|
|
60
|
+
}
|
|
61
|
+
if (command === 'check') {
|
|
62
|
+
if (sub)
|
|
63
|
+
throw Error('Unexpected check argument');
|
|
64
|
+
const options = Object.fromEntries(Object.entries(values).filter(([key, value]) => typeof value === 'string' && ['config', 'profile', 'mode', 'base', 'head', 'trust-root'].includes(key)));
|
|
65
|
+
const report = await check(root, options);
|
|
66
|
+
await emit(formatReport(report, values.format ?? 'console'));
|
|
67
|
+
return report.exitCode;
|
|
68
|
+
}
|
|
69
|
+
const cfg = await config(root, values.config, values.profile), files = await fileList(root), sha = (await git(root, ['rev-parse', '--verify', 'HEAD^{commit}'])).trim(), current = await registry(root, cfg, files, sha);
|
|
70
|
+
if (command === 'contracts') {
|
|
71
|
+
if (!['discover', 'list', 'validate'].includes(sub ?? ''))
|
|
72
|
+
throw Error('Expected contracts discover|list|validate');
|
|
73
|
+
await emit(canonicalJson(current) + '\n');
|
|
74
|
+
return sub === 'validate' && current.discoveryDiagnostics?.length ? 1 : 0;
|
|
75
|
+
}
|
|
76
|
+
if (command === 'baseline' && sub === 'create') {
|
|
77
|
+
await writeScoped(root, values.output ?? '.behavproof/baseline.json', canonicalJson(current) + '\n', true);
|
|
78
|
+
if (!values.output)
|
|
79
|
+
process.stdout.write('Created .behavproof/baseline.json; this is proposed data until registered by a trusted host.\n');
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
if (command === 'docs') {
|
|
83
|
+
const action = values.check ? 'check' : sub ?? 'generate';
|
|
84
|
+
if (!['generate', 'check'].includes(action))
|
|
85
|
+
throw Error('Expected docs generate|check');
|
|
86
|
+
let generated;
|
|
87
|
+
if (values['trust-root']) {
|
|
88
|
+
const report = await check(root, { ...(values.config ? { config: values.config } : {}), ...(values.profile ? { profile: values.profile } : {}), ...(values.head ? { head: values.head } : {}), base: values.base ?? 'HEAD', mode: 'audit', 'trust-root': values['trust-root'] });
|
|
89
|
+
const evidence = report.documentEvidence;
|
|
90
|
+
generated = renderDocuments(evidence.registry, evidence.rows, { approvals: report.approvals, expectedBindings: evidence.bindings, verifyEvidence: row => evidence.authenticatedRows.includes(hash(row)), verifyApproval: approval => evidence.authenticatedApprovals.includes(hash(approval)) });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const rows = [];
|
|
94
|
+
for (const manifestRef of select(files, cfg.executionManifests)) {
|
|
95
|
+
const { ExecutionManifestSchema } = await import('@behavproof/core');
|
|
96
|
+
const manifest = ExecutionManifestSchema.parse(await safeReadJson(root, manifestRef));
|
|
97
|
+
for (const artifact of manifest.artifacts)
|
|
98
|
+
if (artifact.kind === 'contract_report' && await exists(root, artifact.ref)) {
|
|
99
|
+
const data = await safeReadJson(root, artifact.ref);
|
|
100
|
+
if (!Array.isArray(data?.contracts))
|
|
101
|
+
throw Error('Malformed contract report');
|
|
102
|
+
rows.push(...data.contracts);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
generated = renderDocuments(current, rows);
|
|
106
|
+
}
|
|
107
|
+
const extension = values.output ? extname(values.output) : '', single = extension ? extension === '.md' ? 'markdown' : extension === '.html' ? 'html' : extension === '.json' ? 'json' : undefined : undefined;
|
|
108
|
+
if (extension && !single)
|
|
109
|
+
throw Error('Unsupported document extension');
|
|
110
|
+
const directory = values.output && !extension ? values.output : cfg.contracts.documents.output;
|
|
111
|
+
const paths = single ? { [single]: values.output } : { markdown: `${directory}/behavior.md`, html: `${directory}/behavior.html`, json: `${directory}/behavior.json` };
|
|
112
|
+
let outdated = false;
|
|
113
|
+
for (const [format, path] of Object.entries(paths)) {
|
|
114
|
+
const content = generated[format];
|
|
115
|
+
if (action === 'generate')
|
|
116
|
+
await writeScoped(root, path, content);
|
|
117
|
+
else if (!await exists(root, path) || (await safeRead(root, path)).toString('utf8') !== content)
|
|
118
|
+
outdated = true;
|
|
119
|
+
}
|
|
120
|
+
process.stdout.write(outdated ? 'DOCUMENT_OUTDATED: regenerate documents\n' : `Documents ${action === 'generate' ? 'generated' : 'current'}; declarations alone do not prove execution.\n`);
|
|
121
|
+
return outdated ? 1 : 0;
|
|
122
|
+
}
|
|
123
|
+
if (command === 'impact' || command === 'intent' && sub === 'diff') {
|
|
124
|
+
const diff = await gitDiff(root, ref(values.base ?? cfg.git.base), ref(values.head ?? 'HEAD'));
|
|
125
|
+
if (diff.headSha !== sha)
|
|
126
|
+
throw Error('The selected --head must be checked out for static analysis');
|
|
127
|
+
if (command === 'impact') {
|
|
128
|
+
const sources = {};
|
|
129
|
+
for (const p of files.filter(p => /\.[cm]?[jt]sx?$/.test(p)))
|
|
130
|
+
sources[p] = (await safeRead(root, p)).toString('utf8');
|
|
131
|
+
const mappings = {};
|
|
132
|
+
for (const c of current.contracts) {
|
|
133
|
+
const path = c.sourceRef.replace(/:\d+(?::\d+)?$/, '');
|
|
134
|
+
(mappings[path] ??= []).push(c.id);
|
|
135
|
+
}
|
|
136
|
+
await emit(canonicalJson({ ...analyzeImpact(sources, diff.files.map(f => f.path), mappings), diff }) + '\n');
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
const baseFiles = (await git(root, ['ls-tree', '-r', '--name-only', '-z', diff.diffBaseSha ?? diff.baseSha])).split('\0').filter(Boolean), sourceRows = [];
|
|
140
|
+
for (const s of cfg.contracts.sources)
|
|
141
|
+
for (const p of select(baseFiles, s.include))
|
|
142
|
+
sourceRows.push({ kind: s.type, ref: p, content: await git(root, ['show', `${diff.diffBaseSha ?? diff.baseSha}:./${p}`]) });
|
|
143
|
+
const { discoverSources, snapshot } = await import('@behavproof/contract-registry');
|
|
144
|
+
const base = snapshot(discoverSources(sourceRows), diff.diffBaseSha ?? diff.baseSha, cfg.contracts.sources.flatMap(s => s.include));
|
|
145
|
+
await emit(canonicalJson({ ...reconcile(base, current), notice: 'Git-derived baseline is comparison data, not independent approval authority.' }) + '\n');
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
throw Error('Unknown command');
|
|
149
|
+
}
|
|
150
|
+
main().then(code => { process.exitCode = code; }).catch(error => { process.stderr.write(`BehavProof error: ${error instanceof Error ? error.message : 'Unknown error'}\n`); process.exitCode = 2; });
|
|
151
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|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,KAAK,CAAC,OAAO,CAAA,CAAC,CAAA,eAAe,IAAI,CAAC,CAAC,CAAA,OAAO,CAAC,QAAQ,GAAC,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type EvidenceStatus } from '@behavproof/core';
|
|
2
|
+
import { GitHubAuthority, type Observation } from '@behavproof/adapter-github';
|
|
3
|
+
import type { TrustRoot } from './trust.js';
|
|
4
|
+
type Auth = {
|
|
5
|
+
trustedCi: boolean;
|
|
6
|
+
verified: ReadonlySet<string>;
|
|
7
|
+
artifactBytes: ReadonlyMap<string, Uint8Array>;
|
|
8
|
+
};
|
|
9
|
+
/** Artifacts come from authenticate's retained snapshots, never candidate rereads. */
|
|
10
|
+
export declare function pipelineEvaluation(root: string, trust: TrustRoot, auth: Auth, provider?: GitHubAuthority): Promise<{
|
|
11
|
+
status: EvidenceStatus;
|
|
12
|
+
jobs: {};
|
|
13
|
+
artifacts: string[];
|
|
14
|
+
observations: {
|
|
15
|
+
upstream?: Observation;
|
|
16
|
+
protection?: Observation;
|
|
17
|
+
};
|
|
18
|
+
workflow?: never;
|
|
19
|
+
} | {
|
|
20
|
+
status: "unknown" | "pass" | "fail" | "not_applicable";
|
|
21
|
+
jobs: Record<string, string>;
|
|
22
|
+
artifacts: string[];
|
|
23
|
+
observations: {
|
|
24
|
+
upstream?: Observation;
|
|
25
|
+
protection?: Observation;
|
|
26
|
+
};
|
|
27
|
+
workflow: {
|
|
28
|
+
ref: string;
|
|
29
|
+
sha256: string;
|
|
30
|
+
sourceStatus: string;
|
|
31
|
+
diagnosis: {
|
|
32
|
+
internal: Observation<unknown>;
|
|
33
|
+
protection: Observation<unknown>;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,cAAc,EAAC,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAC,eAAe,EAAmC,KAAK,WAAW,EAAC,MAAM,4BAA4B,CAAC;AAC9G,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAC1C,KAAK,IAAI,GAAC;IAAC,SAAS,EAAC,OAAO,CAAC;IAAA,QAAQ,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAAA,aAAa,EAAC,WAAW,CAAC,MAAM,EAAC,UAAU,CAAC,CAAA;CAAC,CAAC;AAExG,sFAAsF;AACtF,wBAAsB,kBAAkB,CAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,CAAC,EAAC,eAAe;YAGpE,cAAc;;eAAyB,MAAM,EAAE;;mBADnD,WAAW;qBAAa,WAAW;;;;;;;;mBAAnC,WAAW;qBAAa,WAAW;;;;;;;;;;;GA2BlE"}
|
package/dist/pipeline.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { safeRead, hashBytes } from '@behavproof/core';
|
|
2
|
+
import { GitHubAuthority, diagnoseWorkflow, evaluateUpstream } from '@behavproof/adapter-github';
|
|
3
|
+
const worst = (states) => states.includes('fail') ? 'fail' : states.length > 0 && states.every(status => status === 'pass') ? 'pass' : 'unknown';
|
|
4
|
+
/** Artifacts come from authenticate's retained snapshots, never candidate rereads. */
|
|
5
|
+
export async function pipelineEvaluation(root, trust, auth, provider) {
|
|
6
|
+
const p = trust.pipeline;
|
|
7
|
+
const observations = {};
|
|
8
|
+
if (!p)
|
|
9
|
+
return { status: 'unknown', jobs: {}, artifacts: [], observations };
|
|
10
|
+
const bytes = await safeRead(root, p.workflow), source = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
11
|
+
const sourceStatus = !p.currentRun || hashBytes(bytes) === p.currentRun.workflowHash ? 'pass' : 'unknown';
|
|
12
|
+
const diagnosis = diagnoseWorkflow(source, p);
|
|
13
|
+
const available = [...auth.verified].sort();
|
|
14
|
+
let jobs = {}, upstreamStatus = 'unknown', protectionStatus = 'unknown';
|
|
15
|
+
const github = trust.github;
|
|
16
|
+
const authority = provider ?? (github ? new GitHubAuthority({ repository: github.repository, ...(process.env.GITHUB_TOKEN ? { token: process.env.GITHUB_TOKEN } : {}) }) : undefined);
|
|
17
|
+
if (p.currentRun) {
|
|
18
|
+
if (auth.trustedCi && authority && sourceStatus === 'pass') {
|
|
19
|
+
const r = p.currentRun, result = await authority.upstream(r.ci, { ci: r.ci, workflowPath: r.workflowPath, workflowSha: r.workflowSha, gateJob: p.gateJob, requiredJobs: p.requiredJobs });
|
|
20
|
+
observations.upstream = result;
|
|
21
|
+
if (result.status === 'pass' && result.value) {
|
|
22
|
+
jobs = result.value.jobs;
|
|
23
|
+
upstreamStatus = evaluateUpstream(jobs, available, p).status;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const reports = trust.manifests.flatMap(spec => spec.expected.artifacts).filter(artifact => artifact.kind === 'pipeline' && auth.verified.has(artifact.ref));
|
|
29
|
+
if (reports.length === 1) {
|
|
30
|
+
const captured = auth.artifactBytes.get(reports[0].ref);
|
|
31
|
+
if (!captured)
|
|
32
|
+
throw Error('Authenticated pipeline snapshot unavailable');
|
|
33
|
+
const raw = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(captured));
|
|
34
|
+
if (!raw || !raw.jobs || !Array.isArray(raw.artifacts))
|
|
35
|
+
throw Error('Invalid pipeline report');
|
|
36
|
+
jobs = raw.jobs;
|
|
37
|
+
upstreamStatus = evaluateUpstream(jobs, raw.artifacts, p).status;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (auth.trustedCi && github && authority) {
|
|
41
|
+
observations.protection = await authority.protection(p.protectedBranch, github.requiredChecks);
|
|
42
|
+
protectionStatus = observations.protection.status;
|
|
43
|
+
}
|
|
44
|
+
return { status: worst([sourceStatus, diagnosis.internal.status, upstreamStatus, protectionStatus]), jobs, artifacts: available, observations, workflow: { ref: p.workflow, sha256: hashBytes(bytes), sourceStatus, diagnosis } };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,SAAS,EAAqB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAC,eAAe,EAAC,gBAAgB,EAAC,gBAAgB,EAAkB,MAAM,4BAA4B,CAAC;AAG9G,MAAM,KAAK,GAAC,CAAC,MAAwB,EAAgB,EAAE,CAAA,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA,CAAC,CAAA,MAAM,CAAA,CAAC,CAAA,MAAM,CAAC,MAAM,GAAC,CAAC,IAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAA,EAAE,CAAA,MAAM,KAAG,MAAM,CAAC,CAAA,CAAC,CAAA,MAAM,CAAA,CAAC,CAAA,SAAS,CAAC;AAC9J,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAW,EAAC,KAAe,EAAC,IAAS,EAAC,QAAyB;IACtG,MAAM,CAAC,GAAC,KAAK,CAAC,QAAQ,CAAC;IACvB,MAAM,YAAY,GAAiD,EAAE,CAAC;IACtE,IAAG,CAAC,CAAC;QAAC,OAAO,EAAC,MAAM,EAAC,SAA2B,EAAC,IAAI,EAAC,EAAE,EAAC,SAAS,EAAC,EAAc,EAAC,YAAY,EAAC,CAAC;IAChG,MAAM,KAAK,GAAC,MAAM,QAAQ,CAAC,IAAI,EAAC,CAAC,CAAC,QAAQ,CAAC,EAAC,MAAM,GAAC,IAAI,WAAW,CAAC,OAAO,EAAC,EAAC,KAAK,EAAC,IAAI,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GAAC,gBAAgB,CAAC,IAAI,EAAC,GAAG,CAAC,SAAS,EAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC7E,CAAC;IACH,CAAC;IACD,IAAG,IAAI,CAAC,SAAS,IAAE,MAAM,IAAE,SAAS,EAAC,CAAC;QAAA,YAAY,CAAC,UAAU,GAAC,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,EAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAAA,gBAAgB,GAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC;IAAA,CAAC;IACnL,OAAO,EAAC,MAAM,EAAC,KAAK,CAAC,CAAC,YAAY,EAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAC,cAAc,EAAC,gBAAgB,CAAC,CAAC,EAAC,IAAI,EAAC,SAAS,EAAC,SAAS,EAAC,YAAY,EAAC,QAAQ,EAAC,EAAC,GAAG,EAAC,CAAC,CAAC,QAAQ,EAAC,MAAM,EAAC,SAAS,CAAC,KAAK,CAAC,EAAC,YAAY,EAAC,SAAS,EAAC,EAAC,CAAC;AACjN,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type Config } from '@behavproof/core';
|
|
2
|
+
export declare function git(root: string, args: string[]): Promise<string>;
|
|
3
|
+
export declare function exists(root: string, path: string): Promise<boolean>;
|
|
4
|
+
export declare function config(root: string, path?: string, profile?: string): Promise<Config>;
|
|
5
|
+
export declare function fileList(root: string): Promise<string[]>;
|
|
6
|
+
export declare function select(files: readonly string[], patterns: readonly string[]): string[];
|
|
7
|
+
export declare function registry(root: string, cfg: Config, files: readonly string[], commitSha: string, extraSources?: Config['contracts']['sources'], readSource?: (path: string) => Promise<string>): Promise<{
|
|
8
|
+
schemaVersion: 1;
|
|
9
|
+
commitSha: string;
|
|
10
|
+
contracts: {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: "external" | "examples" | "invariant" | "state_machine" | "api_contract";
|
|
13
|
+
intentIds: string[];
|
|
14
|
+
revisionHash: string;
|
|
15
|
+
sourceRef: string;
|
|
16
|
+
formal?: {
|
|
17
|
+
modelId: string;
|
|
18
|
+
modelHash: string;
|
|
19
|
+
propertyIds: string[];
|
|
20
|
+
driverHash?: string | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
caseIds?: string[] | undefined;
|
|
23
|
+
risk?: "basic" | "standard" | "critical" | undefined;
|
|
24
|
+
cases?: {
|
|
25
|
+
id: string;
|
|
26
|
+
input: import("zod").JSONType;
|
|
27
|
+
expected: import("zod").JSONType;
|
|
28
|
+
negative?: boolean | undefined;
|
|
29
|
+
}[] | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
intents: {
|
|
32
|
+
id: string;
|
|
33
|
+
statement: string;
|
|
34
|
+
risk: "basic" | "standard" | "critical";
|
|
35
|
+
contentHash: string;
|
|
36
|
+
origin: {
|
|
37
|
+
kind: "external" | "manifest" | "inline";
|
|
38
|
+
ref: string;
|
|
39
|
+
};
|
|
40
|
+
}[];
|
|
41
|
+
repositoryId?: string | undefined;
|
|
42
|
+
policyHash?: string | undefined;
|
|
43
|
+
extractorVersion?: string | undefined;
|
|
44
|
+
scope?: string[] | undefined;
|
|
45
|
+
discoveryDiagnostics?: {
|
|
46
|
+
code: string;
|
|
47
|
+
sourceRef: string;
|
|
48
|
+
message: string;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function writeScoped(root: string, path: string, content: string, exclusive?: boolean): Promise<void>;
|
|
52
|
+
export declare function ref(value: string): string;
|
|
53
|
+
export declare function registryAtGit(root: string, cfg: Config, sha: string, extraSources?: Config['contracts']['sources']): Promise<{
|
|
54
|
+
schemaVersion: 1;
|
|
55
|
+
commitSha: string;
|
|
56
|
+
contracts: {
|
|
57
|
+
id: string;
|
|
58
|
+
kind: "external" | "examples" | "invariant" | "state_machine" | "api_contract";
|
|
59
|
+
intentIds: string[];
|
|
60
|
+
revisionHash: string;
|
|
61
|
+
sourceRef: string;
|
|
62
|
+
formal?: {
|
|
63
|
+
modelId: string;
|
|
64
|
+
modelHash: string;
|
|
65
|
+
propertyIds: string[];
|
|
66
|
+
driverHash?: string | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
caseIds?: string[] | undefined;
|
|
69
|
+
risk?: "basic" | "standard" | "critical" | undefined;
|
|
70
|
+
cases?: {
|
|
71
|
+
id: string;
|
|
72
|
+
input: import("zod").JSONType;
|
|
73
|
+
expected: import("zod").JSONType;
|
|
74
|
+
negative?: boolean | undefined;
|
|
75
|
+
}[] | undefined;
|
|
76
|
+
}[];
|
|
77
|
+
intents: {
|
|
78
|
+
id: string;
|
|
79
|
+
statement: string;
|
|
80
|
+
risk: "basic" | "standard" | "critical";
|
|
81
|
+
contentHash: string;
|
|
82
|
+
origin: {
|
|
83
|
+
kind: "external" | "manifest" | "inline";
|
|
84
|
+
ref: string;
|
|
85
|
+
};
|
|
86
|
+
}[];
|
|
87
|
+
repositoryId?: string | undefined;
|
|
88
|
+
policyHash?: string | undefined;
|
|
89
|
+
extractorVersion?: string | undefined;
|
|
90
|
+
scope?: string[] | undefined;
|
|
91
|
+
discoveryDiagnostics?: {
|
|
92
|
+
code: string;
|
|
93
|
+
sourceRef: string;
|
|
94
|
+
message: string;
|
|
95
|
+
}[] | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2D,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGxG,wBAAsB,GAAG,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,EAAE,mBAAuL;AAC1O,wBAAsB,MAAM,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,oBAA0J;AAC9M,wBAAsB,MAAM,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,SAAyB,EAAC,OAAO,CAAC,EAAC,MAAM,GAAE,OAAO,CAAC,MAAM,CAAC,CAAqJ;AAC5P,wBAAsB,QAAQ,CAAC,IAAI,EAAC,MAAM,qBAGzC;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAC,SAAS,MAAM,EAAE,EAAC,QAAQ,EAAC,SAAS,MAAM,EAAE,YAAuJ;AAChO,wBAAsB,QAAQ,CAAC,IAAI,EAAC,MAAM,EAAC,GAAG,EAAC,MAAM,EAAC,KAAK,EAAC,SAAS,MAAM,EAAE,EAAC,SAAS,EAAC,MAAM,EAAC,YAAY,GAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAI,EAAC,UAAU,CAAC,EAAC,CAAC,IAAI,EAAC,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMvL;AACD,wBAAsB,WAAW,CAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,EAAC,OAAO,EAAC,MAAM,EAAC,SAAS,UAAM,iBAMvF;AACD,wBAAgB,GAAG,CAAC,KAAK,EAAC,MAAM,UAAsG;AAEtI,wBAAsB,aAAa,CAAC,IAAI,EAAC,MAAM,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,MAAM,EAAC,YAAY,GAAC,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKnH"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { readdir, lstat, mkdir, open, realpath } from 'node:fs/promises';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { join, dirname, relative, sep, matchesGlob } from 'node:path';
|
|
4
|
+
import { execFile } from 'node:child_process';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { parseConfig, RelativePathSchema, safeRead, safeReadJson } from '@behavproof/core';
|
|
7
|
+
import { discoverSources, snapshot } from '@behavproof/contract-registry';
|
|
8
|
+
const exec = promisify(execFile);
|
|
9
|
+
export async function git(root, args) { return (await exec('git', ['-c', 'core.fsmonitor=false', ...args], { cwd: root, timeout: 30000, maxBuffer: 10 * 1024 * 1024, encoding: 'utf8', env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' } })).stdout; }
|
|
10
|
+
export async function exists(root, path) { try {
|
|
11
|
+
await lstat(join(root, RelativePathSchema.parse(path)));
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
if (e.code === 'ENOENT')
|
|
16
|
+
return false;
|
|
17
|
+
throw e;
|
|
18
|
+
} }
|
|
19
|
+
export async function config(root, path = 'behavproof.config.json', profile) { const raw = await exists(root, path) ? await safeReadJson(root, path) : { schemaVersion: 1 }; return parseConfig({ ...raw, ...(profile ? { profile } : {}) }); }
|
|
20
|
+
export async function fileList(root) {
|
|
21
|
+
const files = [];
|
|
22
|
+
let count = 0;
|
|
23
|
+
const walk = async (dir, depth) => { if (depth > 64)
|
|
24
|
+
throw Error('Directory depth limit exceeded'); for (const ent of await readdir(join(root, dir), { withFileTypes: true })) {
|
|
25
|
+
if (++count > 50000)
|
|
26
|
+
throw Error('Project file inventory exceeds limit');
|
|
27
|
+
const path = dir ? `${dir}/${ent.name}` : ent.name;
|
|
28
|
+
if (['.git', 'node_modules', '.npm-cache', '.superpowers'].includes(ent.name) || path === '.behavproof/generated')
|
|
29
|
+
continue;
|
|
30
|
+
if (ent.isDirectory())
|
|
31
|
+
await walk(path, depth + 1);
|
|
32
|
+
else
|
|
33
|
+
files.push(path);
|
|
34
|
+
} };
|
|
35
|
+
await walk('', 0);
|
|
36
|
+
return files.sort();
|
|
37
|
+
}
|
|
38
|
+
export function select(files, patterns) { for (const pattern of patterns)
|
|
39
|
+
RelativePathSchema.parse(pattern); return files.filter(file => patterns.some(pattern => matchesGlob(file, pattern))).sort(); }
|
|
40
|
+
export async function registry(root, cfg, files, commitSha, extraSources = [], readSource) {
|
|
41
|
+
const sources = [...cfg.contracts.sources, ...extraSources], seen = new Set(), rows = [];
|
|
42
|
+
for (const source of sources)
|
|
43
|
+
for (const ref of select(files, source.include)) {
|
|
44
|
+
const key = `${source.type}:${ref}`;
|
|
45
|
+
if (seen.has(key))
|
|
46
|
+
continue;
|
|
47
|
+
seen.add(key);
|
|
48
|
+
rows.push({ kind: source.type, ref, content: readSource ? await readSource(ref) : (await safeRead(root, ref)).toString('utf8') });
|
|
49
|
+
}
|
|
50
|
+
const result = discoverSources(rows);
|
|
51
|
+
for (const source of sources)
|
|
52
|
+
for (const pattern of source.include)
|
|
53
|
+
if (!select(files, [pattern]).length)
|
|
54
|
+
result.diagnostics.push({ code: 'SOURCE_MISSING', sourceRef: pattern, message: 'Configured discovery source is absent' });
|
|
55
|
+
return snapshot(result, commitSha, [...new Set(sources.flatMap(s => s.include))].sort());
|
|
56
|
+
}
|
|
57
|
+
export async function writeScoped(root, path, content, exclusive = false) {
|
|
58
|
+
RelativePathSchema.parse(path);
|
|
59
|
+
const base = await realpath(root);
|
|
60
|
+
let current = base;
|
|
61
|
+
const parts = path.split('/');
|
|
62
|
+
for (const part of parts.slice(0, -1)) {
|
|
63
|
+
current = join(current, part);
|
|
64
|
+
try {
|
|
65
|
+
await mkdir(current);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
if (e.code !== 'EEXIST')
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
71
|
+
const stat = await lstat(current);
|
|
72
|
+
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
73
|
+
throw Error('Unsafe output directory');
|
|
74
|
+
}
|
|
75
|
+
const parent = await realpath(dirname(join(base, path))), rel = relative(base, parent);
|
|
76
|
+
if (rel === '..' || rel.startsWith(`..${sep}`))
|
|
77
|
+
throw Error('Output escapes project');
|
|
78
|
+
const handle = await open(join(base, path), constants.O_WRONLY | constants.O_CREAT | constants.O_NOFOLLOW | constants.O_NONBLOCK | (exclusive ? constants.O_EXCL : 0), 0o600);
|
|
79
|
+
try {
|
|
80
|
+
const stat = await handle.stat();
|
|
81
|
+
if (!stat.isFile() || stat.nlink > 1)
|
|
82
|
+
throw Error('Output is not a single regular file');
|
|
83
|
+
if (!exclusive)
|
|
84
|
+
await handle.truncate(0);
|
|
85
|
+
await handle.writeFile(content, 'utf8');
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
await handle.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function ref(value) { if (!value || value.startsWith('-') || value.includes('\0'))
|
|
92
|
+
throw Error('Invalid Git ref'); return value; }
|
|
93
|
+
export async function registryAtGit(root, cfg, sha, extraSources = []) {
|
|
94
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(sha))
|
|
95
|
+
throw Error('Expected immutable Git object');
|
|
96
|
+
const files = (await git(root, ['ls-tree', '-r', '--name-only', '-z', sha])).split('\0').filter(Boolean);
|
|
97
|
+
if (files.length > 50000)
|
|
98
|
+
throw Error('Git source inventory exceeds limit');
|
|
99
|
+
return registry(root, cfg, files, sha, extraSources, path => git(root, ['show', `${sha}:./${RelativePathSchema.parse(path)}`]));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CA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