@optitransfer/proofline 0.0.0-stage → 0.2.0-next.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.
@@ -0,0 +1,50 @@
1
+ # 11 — Development and release pipeline
2
+
3
+ ## Development loop
4
+
5
+ ```mermaid
6
+ flowchart TD
7
+ I[Issue / requirement] --> C[Contract and acceptance criteria]
8
+ C --> D[Design / ADR if needed]
9
+ D --> IMP[Small implementation slice]
10
+ IMP --> U[Unit + schema tests]
11
+ U --> INT[Integration + adapter contract tests]
12
+ INT --> ADV[Adversarial conformance fixtures]
13
+ ADV --> REV[Independent diff / requirement review]
14
+ REV --> REC[Reconcile claims, changes, evidence]
15
+ REC -->|gap| IMP
16
+ REC -->|clean| CI[CI release gates]
17
+ CI --> REL[Versioned release + report]
18
+ ```
19
+
20
+ ## Branch and review policy
21
+
22
+ - `main` should represent a coherent, CI-checked baseline.
23
+ - Use short-lived feature branches and pull requests.
24
+ - Each PR names requirement IDs and updates tests/docs/changelog as appropriate.
25
+ - Do not merge a change that weakens a mandatory gate without an ADR and explicit rationale.
26
+ - Require at least one review for changes to command execution, evidence integrity, gate logic, permissions, or schema migrations.
27
+ - Protect `main` with required CI and review rules once repository settings are available.
28
+
29
+ ## CI stages
30
+
31
+ 1. Checkout with minimal permissions.
32
+ 2. Static formatting and lint.
33
+ 3. Type/schema checks.
34
+ 4. Unit tests.
35
+ 5. Integration tests using synthetic/local fixtures.
36
+ 6. Adapter contract tests.
37
+ 7. Adversarial conformance suite.
38
+ 8. Security and dependency checks.
39
+ 9. Build/package.
40
+ 10. Generate provenance/checksum and release report.
41
+
42
+ The workflow in `.github/workflows/proofline.yml` runs the self-gate (`node bin/proofline.mjs gate --ci`) on every push to `main` and on pull requests, with the branch tip before the push as the base, and uploads the evidence report. Documentation CI must not be misrepresented as software verification.
43
+
44
+ ## Release discipline
45
+
46
+ - Version schemas independently or document compatibility in the package versioning policy.
47
+ - Record commit, build inputs, test results, and artifact digests.
48
+ - Publish release notes with added behaviour, limitations, migration notes, and known issues.
49
+ - Never publish a release based only on the agent's assertion that it is ready.
50
+ - Keep a release checklist and a rollback/recovery plan.
@@ -0,0 +1,104 @@
1
+ # 12 — Roadmap
2
+
3
+ This is a dependency-ordered roadmap, not a promise of calendar dates. A phase is complete only when its exit criteria are evidenced.
4
+
5
+ ## Phase 0 — Contract and feasibility spike
6
+
7
+ **Goal:** remove ambiguity before building a broad framework.
8
+
9
+ Deliverables:
10
+ - Agree initial adapter choice based on a small integration spike.
11
+ - Define task-contract, event, evidence, finding, and report schemas.
12
+ - Select implementation language/runtime based on the adapter and existing project conventions.
13
+ - Validate that required lifecycle events and revision identity can be captured.
14
+ - Write 5–10 adversarial scenarios.
15
+
16
+ Exit criteria:
17
+ - A real agent session can be correlated with a workspace revision.
18
+ - The team can state which lifecycle facts are available and which are not.
19
+ - The MVP scope and first adapter are recorded in an ADR.
20
+
21
+ ## Phase 1 — Local contract and evidence core
22
+
23
+ **Goal:** establish the trustworthy core without agent integration complexity.
24
+
25
+ Deliverables:
26
+ - Contract validation and versioning.
27
+ - Local run state machine.
28
+ - Evidence schema and append-oriented local ledger.
29
+ - Deterministic gate engine.
30
+ - JSON/Markdown report.
31
+ - Synthetic fixtures and negative tests.
32
+
33
+ Exit criteria:
34
+ - Missing, stale, skipped, and failed mandatory evidence cannot produce `verified`.
35
+ - A report is reproducible from the same contract, policy, and evidence set.
36
+
37
+ ## Phase 2 — First real adapter
38
+
39
+ **Goal:** observe one supported agent end-to-end.
40
+
41
+ Deliverables:
42
+ - Adapter event normalization.
43
+ - Workspace/diff observation.
44
+ - Start, observe, verify, report workflow.
45
+ - Safe failure and adapter diagnostics.
46
+
47
+ Exit criteria:
48
+ - Real task can be observed in `observe` mode without breaking the agent workflow.
49
+ - Event gaps and adapter limitations are documented.
50
+
51
+ ## Phase 3 — Verification and corrective guidance
52
+
53
+ **Goal:** catch useful omissions without creating noisy loops.
54
+
55
+ Deliverables:
56
+ - Requirement traceability.
57
+ - Independent configured checks.
58
+ - Scope drift detection.
59
+ - Unsupported completion-claim detection.
60
+ - Bounded corrective feedback and loop detection.
61
+
62
+ Exit criteria:
63
+ - Mandatory adversarial fixtures pass.
64
+ - Pilot measures both true catches and false blocks.
65
+
66
+ ## Phase 4 — Enforce mode and hardening
67
+
68
+ **Goal:** allow policy-based delivery gates.
69
+
70
+ Deliverables:
71
+ - Enforce-mode gate integration.
72
+ - Human approval/exception records.
73
+ - Command policy and security hardening.
74
+ - CI/release report integration.
75
+
76
+ Exit criteria:
77
+ - Security review and failure-mode tests pass.
78
+ - Enforcement does not silently fail open when required signals are missing.
79
+
80
+ ## Phase 5 — Optional ecosystem integrations
81
+
82
+ **Goal:** add value without compromising standalone operation.
83
+
84
+ Candidates:
85
+ - HiveVault connector for prior decisions and accepted exceptions.
86
+ - Additional agent adapters.
87
+ - CI provider integrations.
88
+ - Export/import and evidence replay tooling.
89
+
90
+ Exit criteria:
91
+ - Core remains standalone; integrations are optional and cannot bypass evidence gates.
92
+
93
+ ## Deferred until justified
94
+
95
+ - Dashboard.
96
+ - Hosted control plane.
97
+ - Multi-agent orchestration.
98
+ - Broad domain packs outside software engineering.
99
+ - CRDT-backed replicated evidence store.
100
+ - Commercial/team policy management.
101
+
102
+ ## Go/no-go criteria
103
+
104
+ Continue beyond the pilot only if measured omission detection and false-completion prevention justify added latency and review overhead. The key metric is useful, verified catches per interruption—not the number of events collected.
@@ -0,0 +1,53 @@
1
+ # 13 — Interdependencies
2
+
3
+ ## Dependency map
4
+
5
+ ```mermaid
6
+ flowchart TD
7
+ CONTRACT[Contract schema] --> STATE[Run state machine]
8
+ EVENTS[Normalized event schema] --> ADAPTER[First agent adapter]
9
+ ADAPTER --> EVENTS
10
+ STATE --> LEDGER[Evidence ledger]
11
+ EVENTS --> LEDGER
12
+ GIT[Workspace / revision inspector] --> LEDGER
13
+ RUNNER[Command policy + check runner] --> LEDGER
14
+ CONTRACT --> TRACE[Requirement traceability]
15
+ LEDGER --> TRACE
16
+ TRACE --> VERIFY[Verifier]
17
+ VERIFY --> RECON[Reconciliation]
18
+ CONTRACT --> RECON
19
+ RECON --> GATE[Gate decision]
20
+ POLICY[Approval / exception policy] --> GATE
21
+ GATE --> REPORT[Portable reports]
22
+ REPORT --> PILOT[Pilot metrics]
23
+ HV[Optional context connector] -. non-authoritative context .-> CONTRACT
24
+ ```
25
+
26
+ ## Dependency register
27
+
28
+ | ID | Dependency | Needed by | Risk if delayed | Mitigation |
29
+ |---|---|---|---|---|
30
+ | DEP-01 | Contract schema and stable requirement IDs | State machine, traceability, reports | Requirements become untestable prose | Define schema and examples first |
31
+ | DEP-02 | Adapter lifecycle capability | Observer, end-to-end workflow | Cannot reliably correlate task to events | Spike adapter early; document unsupported signals |
32
+ | DEP-03 | Workspace/revision identity | Evidence freshness, diff review | Stale evidence may appear current | Make revision identity mandatory where available |
33
+ | DEP-04 | Safe command runner | Independent checks | Arbitrary execution risk | Allowlist, structured argv, timeouts, isolated environment |
34
+ | DEP-05 | Evidence record model | All verification and reporting | Lost provenance and non-reproducible decisions | Version schema before multiple consumers |
35
+ | DEP-06 | Deterministic gate rules | Enforce mode | False pass or inconsistent status | Implement and test gate logic before hooks can block |
36
+ | DEP-07 | Conformance fixtures | Verifier confidence | Regressions in safety semantics | Build adversarial fixtures alongside core |
37
+ | DEP-08 | Pilot instrumentation | Product go/no-go | No evidence product helps users | Capture catches, false blocks, latency, interruptions |
38
+ | DEP-09 | An optional context connector, for example a project-memory store such as HiveVault | Cross-run context only | Integration may couple core to memory | Keep adapter boundary optional and read-only initially |
39
+
40
+ ## Critical path
41
+
42
+ `contract schema -> evidence schema -> deterministic gate engine -> synthetic conformance suite -> first adapter -> pilot -> enforce mode`
43
+
44
+ The first adapter spike can run in parallel with schema work, but it must not force vendor-specific concepts into the core model.
45
+
46
+ ## Integration rule for context connectors
47
+
48
+ A context connector may store or retrieve prior decisions, project constraints, known failure patterns, and accepted exceptions. Proofline must:
49
+ - mark imported context as historical context;
50
+ - show source and timestamp;
51
+ - ask for confirmation when a historical decision conflicts with the current contract;
52
+ - never treat a memory entry as current-run test evidence;
53
+ - work with the connector absent.
@@ -0,0 +1,40 @@
1
+ # 14 — Metrics and evaluation
2
+
3
+ ## Primary product question
4
+
5
+ Does Proofline catch meaningful omissions and unsupported completion claims at an acceptable cost in latency, false blocks, and user attention?
6
+
7
+ ## Metrics
8
+
9
+ | Metric | Definition | Why it matters |
10
+ |---|---|---|
11
+ | Verified omission catches | Confirmed missing requirements caught before delivery | Core value |
12
+ | False completion claims blocked | Delivery claims contradicted by evidence | Trust value |
13
+ | False-positive blocks | Blocks later judged unnecessary or incorrect | Adoption risk |
14
+ | Missed defects/omissions | Known pilot issues not detected | Reliability risk |
15
+ | Mandatory evidence coverage | Mandatory criteria with fresh, sufficient evidence / all mandatory criteria | Traceability |
16
+ | Stale-evidence rejection rate | Stale evidence correctly prevented from satisfying gates | Evidence freshness |
17
+ | Mean verification latency | Time added by verification, split by deterministic and model-assisted steps | Workflow cost |
18
+ | Interruptions per task | Agent/user interruptions introduced by the tool | Usability |
19
+ | Corrective cycles | Number of guidance/retry cycles per run | Loop/noise risk |
20
+ | Human review burden | Minutes spent reviewing findings and reports | Adoption |
21
+ | Reproducible decision rate | Decisions replayed from captured contract/policy/evidence with same result | Auditability |
22
+
23
+ ## Pilot design
24
+
25
+ - Select a representative set of real tasks, including known failure examples.
26
+ - Establish expected acceptance criteria before running the agent.
27
+ - Compare normal agent workflow with observe mode first.
28
+ - Label each finding as true positive, false positive, duplicate, or inconclusive.
29
+ - Measure total added time and user intervention.
30
+ - Include cases where the agent succeeds cleanly; do not evaluate only failures.
31
+ - Do not claim statistical generality from a small pilot.
32
+
33
+ ## Initial go/no-go
34
+
35
+ No numerical threshold is asserted before baseline data exists. The pilot should agree thresholds in advance for:
36
+ - minimum confirmed useful catches;
37
+ - maximum false-positive block rate;
38
+ - maximum added latency;
39
+ - maximum user review burden;
40
+ - no tolerance for a false `verified` status in the mandatory negative fixtures.
@@ -0,0 +1,28 @@
1
+ # ADR-0001: Product boundary and independence
2
+
3
+ - Status: Accepted
4
+ - Date: 2026-10-14
5
+
6
+ ## Context
7
+
8
+ Agent frameworks already expose hooks and lifecycle events. A thin hook wrapper would be easy to copy and would not solve the central problem: whether the requested work was actually completed and independently verified.
9
+
10
+ ## Decision
11
+
12
+ Build the product around an accepted task contract, evidence ledger, independent verification, reconciliation, and delivery decision. Hooks/adapters are replaceable integration layers. HiveVault is optional.
13
+
14
+ ## Consequences
15
+
16
+ Positive:
17
+ - Core value is not tied to a single agent.
18
+ - Evidence can be exported and audited independently.
19
+ - Standalone use is possible.
20
+
21
+ Trade-offs:
22
+ - More upfront design and conformance work than a prompt-only tool.
23
+ - Verification quality is limited by the quality of the contract and available oracles.
24
+ - The first adapter must be selected carefully to avoid premature generalization.
25
+
26
+ ## Revisit when
27
+
28
+ Pilot evidence shows that the core abstraction is too heavy, or a specific host imposes lifecycle constraints that materially change the architecture.
@@ -0,0 +1,22 @@
1
+ # ADR-0002: Evidence-based delivery states
2
+
3
+ - Status: Accepted
4
+ - Date: 2026-10-14
5
+
6
+ ## Context
7
+
8
+ Agent completion messages and process exit codes are insufficient to establish that all requirements were met. Skipped checks and stale evidence must not be confused with passing checks.
9
+
10
+ ## Decision
11
+
12
+ Use explicit check states (`passed`, `failed`, `skipped`, `not_run`, `inconclusive`, `stale`, `waived`) and terminal delivery states (`verified`, `partial`, `blocked`, `unverified`). Every gate decision is derived from the contract, policy, evidence freshness, and unresolved findings.
13
+
14
+ ## Consequences
15
+
16
+ - Reports are more nuanced than a single green/red result.
17
+ - The gate engine and state machine require thorough negative tests.
18
+ - Human-approved exceptions remain visible and do not rewrite the evidence history.
19
+
20
+ ## Revisit when
21
+
22
+ Pilot workflows demonstrate a required terminal state not covered by the model.
@@ -0,0 +1,18 @@
1
+ # ADR-0003: Standalone-first, context connectors optional
2
+
3
+ - Status: Accepted
4
+ - Date: 2026-10-14
5
+
6
+ ## Context
7
+
8
+ HiveVault can provide persistent project context, but coupling Proofline to it would limit adoption and blur the difference between remembered claims and current evidence.
9
+
10
+ ## Decision
11
+
12
+ The MVP works locally without HiveVault. Any connector is optional and initially supplies clearly labelled historical context only.
13
+
14
+ ## Consequences
15
+
16
+ - Standalone use remains possible.
17
+ - Cross-run knowledge can be added later without making the core dependent on it.
18
+ - Imported context must never satisfy current-run verification gates by itself.
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@optitransfer/proofline",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0-next.0",
4
+ "description": "Independent V&V for coding agents. The agent says done; Proofline re-runs every check against a contract, rejects claims the evidence does not support, and gates the push.",
5
+ "keywords": [
6
+ "ai-agents",
7
+ "llm",
8
+ "mcp",
9
+ "mcp-server",
10
+ "agentic-ai",
11
+ "claude-code",
12
+ "verification",
13
+ "validation",
14
+ "testing",
15
+ "test-automation",
16
+ "quality-gate",
17
+ "ci-cd",
18
+ "devops",
19
+ "code-review",
20
+ "git-hooks",
21
+ "audit",
22
+ "attestation",
23
+ "developer-tools",
24
+ "nodejs",
25
+ "cli"
26
+ ],
27
+ "homepage": "https://github.com/mgillr/proofline",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/mgillr/proofline.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/mgillr/proofline/issues"
34
+ },
35
+ "author": "mgillr",
36
+ "license": "Apache-2.0",
37
+ "private": false,
38
+ "type": "module",
39
+ "bin": { "proofline": "bin/proofline.mjs" },
40
+ "engines": { "node": ">=22" },
41
+ "files": [
42
+ "bin",
43
+ "src",
44
+ "docs",
45
+ "AGENTS.md",
46
+ "README.md",
47
+ "LICENSE",
48
+ "NOTICE",
49
+ "CHANGELOG.md",
50
+ "CONTRIBUTING.md",
51
+ "PATENTS-NONASSERT.md"
52
+ ],
53
+ "scripts": {
54
+ "test": "node --test test/*.test.mjs",
55
+ "demo": "node examples/demo/demo.mjs",
56
+ "self-gate": "node bin/proofline.mjs gate PL-SELF --skip-pushed",
57
+ "mcp": "node bin/proofline.mjs mcp"
58
+ }
59
+ }
package/src/cache.mjs ADDED
@@ -0,0 +1,81 @@
1
+ // Result cache: a PASS of an expensive check (command, metric) on a clean tree runs once per HEAD and is reused.
2
+ // Opt-in per contract (defaults.reuse_results). The PASS is recorded in the evidence log; the cache file points at
3
+ // that entry, and a result is reused only from an entry that is still in an intact chain with the same hash.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { git, sha256, canon, readJson } from './util.mjs';
7
+ import { record, readLog, verifyChain } from './evidence.mjs';
8
+
9
+ /** The only verifiers whose PASS is reused. The others are cheap, or depend on the base. */
10
+ export const REUSABLE = ['command', 'metric'];
11
+ export const DEFAULT_MAX_AGE_H = 24;
12
+ export const cacheDir = (root) => path.join(root, '.proofline', 'cache');
13
+ const cacheFile = (root, key) => path.join(cacheDir(root), `${key}.json`);
14
+
15
+ /** A contract's reuse settings: on only when defaults.reuse_results is true. */
16
+ export function settings(c) {
17
+ const d = c.defaults || {};
18
+ const age = d.reuse_max_age_h;
19
+ return { on: d.reuse_results === true, maxAgeH: typeof age === 'number' && age > 0 ? age : DEFAULT_MAX_AGE_H, maxLoad: typeof d.max_load_per_cpu === 'number' ? d.max_load_per_cpu : undefined };
20
+ }
21
+
22
+ /** The env vars a check names: `$VAR` and `${VAR}` in its command, `{VAR}` in a metric's output_file. */
23
+ export function namedEnv(v) {
24
+ const names = new Set();
25
+ for (const m of String(v.cmd ?? '').matchAll(/\$\{?([A-Za-z_]\w*)/g)) names.add(m[1]);
26
+ for (const m of String(v.output_file ?? '').matchAll(/\{(\w+)\}/g)) names.add(m[1]);
27
+ return [...names].sort();
28
+ }
29
+
30
+ /**
31
+ * The cache key of a criterion's verifier, or null when its result is neither reused nor stored: not a reusable
32
+ * verifier, no HEAD, or a tree that differs from HEAD outside .proofline/ (an uncommitted edit never reuses a result).
33
+ * The key holds the verifier (canonical JSON), HEAD, process.version and the values of the env vars the check names;
34
+ * for a metric also its baseline and the regression tolerance, which decide its verdict.
35
+ */
36
+ export function keyFor(root, v, { baseline, tolerancePct } = {}) {
37
+ if (!REUSABLE.includes(v.type)) return null;
38
+ const head = git(['rev-parse', '--verify', '--quiet', 'HEAD'], root);
39
+ if (!head.ok || !head.out) return null;
40
+ // --untracked-files=normal: an untracked file counts even where status.showUntrackedFiles=no hides it.
41
+ const st = git(['status', '--porcelain', '--untracked-files=normal'], root);
42
+ if (!st.ok || st.out.split('\n').some((l) => l && !l.includes('.proofline/'))) return null;
43
+ const env = Object.fromEntries(namedEnv(v).map((n) => [n, v.env?.[n] ?? process.env[n] ?? null]));
44
+ const k = { verifier: v, head: head.out, node: process.version, env };
45
+ if (v.type === 'metric') Object.assign(k, { baseline: baseline?.[v.name || v.key] ?? null, tolerance_pct: tolerancePct ?? 20 });
46
+ return { key: sha256(canon(k)), head: head.out };
47
+ }
48
+
49
+ /**
50
+ * The evidence entry of a PASS that may be reused for `key`, or null (then the check runs). The cache file must name
51
+ * an entry that is in an intact chain with the hash it stored, records a PASS for this key, is no older than
52
+ * maxAgeH hours, and, for a metric, ran at a load per CPU within maxLoad when that is set.
53
+ */
54
+ export function lookup(root, key, { maxAgeH = DEFAULT_MAX_AGE_H, maxLoad, now = Date.now() } = {}) {
55
+ const c = readJson(cacheFile(root, key));
56
+ if (!c || c.key !== key || c.status !== 'pass' || !Number.isInteger(c.entry)) return null;
57
+ let e;
58
+ try { if (!verifyChain(root).ok) return null; e = readLog(root)[c.entry]; } catch { return null; }
59
+ if (!e || e.hash !== c.entry_hash || e.type !== 'result' || e.data?.key !== key || e.data.status !== 'pass') return null;
60
+ const age = now - Date.parse(e.ts);
61
+ if (!(age >= 0 && age <= maxAgeH * 3600e3)) return null;
62
+ if (e.data.type === 'metric' && typeof maxLoad === 'number' && !(e.data.evidence?.machine?.load_per_cpu <= maxLoad)) return null;
63
+ return e;
64
+ }
65
+
66
+ /** Record a fresh PASS in the evidence log and point the cache file for its key at that entry. Returns the entry. */
67
+ export function store(root, { key, head }, task, a, r) {
68
+ const data = { task, criterion: a.id, type: a.verifier.type, key, head, status: r.status, detail: r.detail, evidence: r.evidence };
69
+ const e = record(root, 'result', data);
70
+ const f = cacheFile(root, key), tmp = `${f}.${process.pid}.tmp`;
71
+ fs.mkdirSync(path.dirname(f), { recursive: true });
72
+ fs.writeFileSync(tmp, JSON.stringify({ ...data, ts: e.ts, entry: e.seq, entry_hash: e.hash }, null, 2) + '\n');
73
+ fs.renameSync(tmp, f);
74
+ return e;
75
+ }
76
+
77
+ /** A criterion's result taken from the evidence entry that recorded its PASS. */
78
+ export function reusedResult(e) {
79
+ const from = `reused from ${e.ts} (evidence entry ${e.seq})`;
80
+ return { status: 'pass', detail: `${from}: ${e.data.detail}`, evidence: { ...e.data.evidence, reused_from: { ts: e.ts, entry: e.seq, hash: e.hash, head: e.data.head } }, reused: { ts: e.ts, entry: e.seq } };
81
+ }