harness-everything 0.13.0 → 0.15.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.
Files changed (25) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +33 -0
  4. package/ci/contract-integrity.test.js +155 -1
  5. package/ci/mechanism-2ak-contract-probe-adapter.test.js +207 -0
  6. package/ci/openai-plugin-package.test.js +10 -0
  7. package/contract-integrity/ADAPTERS.md +37 -0
  8. package/contract-integrity/fixtures/node-probe-project/package.json +8 -0
  9. package/contract-integrity/fixtures/node-probe-project/probe-plan.json +27 -0
  10. package/contract-integrity/fixtures/node-probe-project/src/limit.js +8 -0
  11. package/contract-integrity/fixtures/node-probe-project/test/contract.test.js +14 -0
  12. package/contract-integrity/scripts/audit.js +225 -2
  13. package/contract-integrity/scripts/node-probe-adapter.js +390 -0
  14. package/opencode-plugin/plugin.json +1 -1
  15. package/package.json +1 -1
  16. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  17. package/plugins/harness-everything/contract-integrity/ADAPTERS.md +37 -0
  18. package/plugins/harness-everything/contract-integrity/scripts/audit.js +225 -2
  19. package/plugins/harness-everything/contract-integrity/scripts/node-probe-adapter.js +390 -0
  20. package/plugins/harness-everything/plugin.json +1 -1
  21. package/plugins/harness-everything/skills/verification-loop/SKILL.md +2 -2
  22. package/plugins/harness-everything/skills/verification-loop/references/verification-phases.md +9 -1
  23. package/scripts/sync-openai-plugin.js +4 -1
  24. package/verification-loop/SKILL.md +2 -2
  25. package/verification-loop/references/verification-phases.md +9 -1
@@ -10,7 +10,7 @@
10
10
  "name": "harness-everything",
11
11
  "source": "./",
12
12
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
13
- "version": "0.13.0",
13
+ "version": "0.15.0",
14
14
  "author": {
15
15
  "name": "Miya Daniel"
16
16
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-everything",
3
3
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
4
- "version": "0.13.0",
4
+ "version": "0.15.0",
5
5
  "author": {
6
6
  "name": "Miya Daniel"
7
7
  },
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.15.0](https://github.com/dyphn1/Harness-everything/compare/v0.14.0...v0.15.0) (2026-09-20)
6
+
7
+ ### Features
8
+
9
+ * **contract:** add freshness provenance helpers ([865fc0b](https://github.com/dyphn1/Harness-everything/commit/865fc0bdb111feff865c3a85767fc587aecbd11a))
10
+ * **contract:** emit requirement-scoped repair guidance ([cbd33ce](https://github.com/dyphn1/Harness-everything/commit/cbd33ce18fb8575671056bd4b2701bd0138baa96))
11
+ * **contract:** reject stale completion reports ([79ea49e](https://github.com/dyphn1/Harness-everything/commit/79ea49e40f110fe062ac714519597e8a23a6ab5b))
12
+ * **contract:** sync freshness audit runtime ([c5d0381](https://github.com/dyphn1/Harness-everything/commit/c5d038163b7ff2dc14e11bd4733e140e85e39f55))
13
+
14
+ ### Bug Fixes
15
+
16
+ * **contract:** harden freshness evidence boundaries ([33ebbda](https://github.com/dyphn1/Harness-everything/commit/33ebbdafb2b63c4ece86ee81c14c4fcc6d33907f))
17
+ * **contract:** launch npm probes cross-platform ([9ca5315](https://github.com/dyphn1/Harness-everything/commit/9ca5315cb30e8f03b08fb1f8789a141ea1179af4))
18
+ * **contract:** launch npm probes cross-platform ([2cad76e](https://github.com/dyphn1/Harness-everything/commit/2cad76e217af136d934946f05c740d816e051acd))
19
+ * **contract:** require complete freshness provenance ([5b6d717](https://github.com/dyphn1/Harness-everything/commit/5b6d717487fce37dcd1d1e8cbe8b037597035103))
20
+ * **contract:** require complete freshness provenance ([d94e256](https://github.com/dyphn1/Harness-everything/commit/d94e2562c54d615d223a8572fd4d468e017a5807))
21
+
22
+ ## [0.14.0](https://github.com/dyphn1/Harness-everything/compare/v0.13.0...v0.14.0) (2026-09-20)
23
+
24
+ ### Features
25
+
26
+ * **contract:** add node npm probe adapter ([02f4044](https://github.com/dyphn1/Harness-everything/commit/02f4044c82a6cb082d4b8e4fe810071afe064c21))
27
+ * **contract:** add packaged node probe adapter ([de72904](https://github.com/dyphn1/Harness-everything/commit/de7290434346cdc358ea119845c72ddca3ea0090))
28
+ * **contract:** package node probe adapter runtime ([783dc8f](https://github.com/dyphn1/Harness-everything/commit/783dc8f891a3244461f3dfe154542bad15125f15))
29
+
30
+ ### Bug Fixes
31
+
32
+ * **contract:** close linked-workspace isolation gap ([574ea2f](https://github.com/dyphn1/Harness-everything/commit/574ea2f299ae02aa93785cca7aa5b4a829e9f961))
33
+ * **contract:** launch npm probes cross-platform ([b39b2c0](https://github.com/dyphn1/Harness-everything/commit/b39b2c09a223c64d3665d383852a6313fff888fc))
34
+ * **contract:** launch npm probes cross-platform ([723bae1](https://github.com/dyphn1/Harness-everything/commit/723bae19ac4a05bfefe44ad0d61bd5dfb8b0ba50))
35
+ * **contract:** reject symlink probe escapes ([bf577a5](https://github.com/dyphn1/Harness-everything/commit/bf577a5b58dec2a4779709402146073f0fd0ce29))
36
+ * **contract:** reject symlink probe escapes ([5e3c569](https://github.com/dyphn1/Harness-everything/commit/5e3c569b1b7b883490e40fd66a64385f2d24d717))
37
+
5
38
  ## [0.13.0](https://github.com/dyphn1/Harness-everything/compare/v0.12.3...v0.13.0) (2026-09-19)
6
39
 
7
40
  ### Features
@@ -265,5 +265,159 @@ for (const relative of [
265
265
  'Phase 2 OpenAI package mirror matches canonical: ' + relative);
266
266
  }
267
267
 
268
- console.log(`\n${failed === 0 ? 'PASS' : 'FAIL'}: #84 contract integrity phase 1-2 (${failed} failure${failed === 1 ? '' : 's'})`);
268
+ // Phase 4: reports carry actionable requirement-scoped repair guidance and
269
+ // content fingerprints so stale completion evidence cannot be reused.
270
+ check(driftReport.repairGuidance.some(item =>
271
+ item.requirementId === 'REQ-001' && item.code === 'update-living-spec' &&
272
+ item.sourceRef === 'docs/specs/api.md#REQ-001'),
273
+ 'stale-spec drift emits requirement-scoped living-spec repair guidance');
274
+ check(paddedReport.repairGuidance.some(item =>
275
+ item.requirementId === 'REQ-001' && item.code === 'strengthen-weak-oracle' && item.priority === 'BLOCKER'),
276
+ 'surviving required probe emits BLOCKER weak-oracle guidance');
277
+ check(/Repair Guidance/.test(markdown(driftReport)) && /REQ-001/.test(markdown(driftReport)),
278
+ 'Markdown keeps repair guidance concise and tied to requirement identity');
279
+
280
+ const freshRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-contract-freshness-'));
281
+ try {
282
+ const workspace = path.join(freshRoot, 'workspace');
283
+ fs.mkdirSync(workspace, { recursive: true });
284
+ for (const artifact of baseline.artifacts) {
285
+ const file = path.join(workspace, artifact.path);
286
+ fs.mkdirSync(path.dirname(file), { recursive: true });
287
+ fs.writeFileSync(file, artifact.id + ': fixture content\n', 'utf8');
288
+ }
289
+ const tracePath = path.join(freshRoot, 'trace.json');
290
+ const tddPath = path.join(freshRoot, 'tdd.json');
291
+ const reportPath = path.join(freshRoot, 'report.json');
292
+ fs.writeFileSync(tracePath, JSON.stringify(baseline), 'utf8');
293
+ fs.writeFileSync(tddPath, JSON.stringify(baselineTdd), 'utf8');
294
+
295
+ const unboundReportPath = path.join(freshRoot, 'report-unbound.json');
296
+ const unboundAudit = spawnSync(process.execPath, [
297
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
298
+ tracePath,
299
+ '--tdd-evidence', tddPath,
300
+ '--output', unboundReportPath,
301
+ ], { encoding: 'utf8' });
302
+ check(unboundAudit.status === 0, 'strict audit may emit a PASS report without workspace binding for immediate inspection');
303
+ const emptyWorkspace = path.join(freshRoot, 'empty-workspace');
304
+ fs.mkdirSync(emptyWorkspace, { recursive: true });
305
+ const unboundFreshness = spawnSync(process.execPath, [
306
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
307
+ tracePath,
308
+ '--tdd-evidence', tddPath,
309
+ '--workspace', emptyWorkspace,
310
+ '--verify-fresh', unboundReportPath,
311
+ ], { encoding: 'utf8' });
312
+ check(unboundFreshness.status === 1 &&
313
+ /report-workspace-unbound/.test(unboundFreshness.stderr) &&
314
+ /artifact-fingerprint-missing:/.test(unboundFreshness.stderr),
315
+ 'report created without workspace fingerprints cannot later authorize freshness against a supplied workspace');
316
+
317
+ const audit = spawnSync(process.execPath, [
318
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
319
+ tracePath,
320
+ '--tdd-evidence', tddPath,
321
+ '--workspace', workspace,
322
+ '--output', reportPath,
323
+ ], { encoding: 'utf8' });
324
+ check(audit.status === 0, 'strict audit with existing workspace artifacts produces fresh PASS report', audit.stderr);
325
+ const freshReport = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
326
+ check(freshReport.provenance?.inputs?.trace?.sha256 &&
327
+ freshReport.provenance?.inputs?.tddEvidence?.sha256 &&
328
+ freshReport.provenance?.artifacts?.length === baseline.artifacts.length &&
329
+ freshReport.provenance.artifacts.every(item => item.sha256 && item.missing === false),
330
+ 'report provenance records trace/TDD hashes plus current artifact hashes');
331
+
332
+ const verifyFresh = () => spawnSync(process.execPath, [
333
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
334
+ tracePath,
335
+ '--tdd-evidence', tddPath,
336
+ '--workspace', workspace,
337
+ '--verify-fresh', reportPath,
338
+ ], { encoding: 'utf8' });
339
+
340
+ const current = verifyFresh();
341
+ check(current.status === 0 && /Freshness: PASS/.test(current.stdout),
342
+ 'unchanged PASS report can authorize completion');
343
+
344
+ const failingTracePath = path.join(freshRoot, 'trace-failing.json');
345
+ const failingReportPath = path.join(freshRoot, 'report-failing.json');
346
+ const failingTrace = clone(baseline);
347
+ failingTrace.probes[0].status = 'SURVIVED';
348
+ failingTrace.probes[0].failureClass = 'none';
349
+ fs.writeFileSync(failingTracePath, JSON.stringify(failingTrace), 'utf8');
350
+ const failingAudit = spawnSync(process.execPath, [
351
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
352
+ failingTracePath,
353
+ '--tdd-evidence', tddPath,
354
+ '--workspace', workspace,
355
+ '--output', failingReportPath,
356
+ ], { encoding: 'utf8' });
357
+ check(failingAudit.status === 1, 'surviving required probe produces a reusable FAIL report fixture');
358
+ const forgedReport = JSON.parse(fs.readFileSync(failingReportPath, 'utf8'));
359
+ forgedReport.result = 'PASS';
360
+ forgedReport.completionGate = 'PASS';
361
+ fs.writeFileSync(failingReportPath, JSON.stringify(forgedReport), 'utf8');
362
+ const forgedFreshness = spawnSync(process.execPath, [
363
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
364
+ failingTracePath,
365
+ '--tdd-evidence', tddPath,
366
+ '--workspace', workspace,
367
+ '--verify-fresh', failingReportPath,
368
+ ], { encoding: 'utf8' });
369
+ check(forgedFreshness.status === 1 && /current-audit-not-pass/.test(forgedFreshness.stderr),
370
+ 'freshness verification re-derives the current gate instead of trusting forged PASS fields');
371
+
372
+ const linkedWorkspace = path.join(freshRoot, 'linked-workspace');
373
+ fs.mkdirSync(linkedWorkspace, { recursive: true });
374
+ for (const artifact of baseline.artifacts.filter(item => item.id !== 'IMPL-001')) {
375
+ const file = path.join(linkedWorkspace, artifact.path);
376
+ fs.mkdirSync(path.dirname(file), { recursive: true });
377
+ fs.writeFileSync(file, artifact.id + ': fixture content\n', 'utf8');
378
+ }
379
+ const outsideImpl = path.join(freshRoot, 'outside-implementation');
380
+ fs.mkdirSync(outsideImpl, { recursive: true });
381
+ fs.writeFileSync(path.join(outsideImpl, 'api.js'), 'IMPL-001: fixture content\n', 'utf8');
382
+ fs.symlinkSync(outsideImpl, path.join(linkedWorkspace, 'src'),
383
+ process.platform === 'win32' ? 'junction' : 'dir');
384
+ const linkedAudit = spawnSync(process.execPath, [
385
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
386
+ tracePath,
387
+ '--tdd-evidence', tddPath,
388
+ '--workspace', linkedWorkspace,
389
+ ], { encoding: 'utf8' });
390
+ check(linkedAudit.status === 2 && /linked-path: IMPL-001/.test(linkedAudit.stderr),
391
+ 'workspace-aware audit rejects artifact paths that resolve through a symlink or junction');
392
+
393
+ const testArtifact = path.join(workspace, 'tests/api.test.js');
394
+ fs.appendFileSync(testArtifact, 'changed after audit\n', 'utf8');
395
+ const staleTestReport = verifyFresh();
396
+ check(staleTestReport.status === 1 &&
397
+ /artifact-changed-since-audit:TEST-001/.test(staleTestReport.stderr),
398
+ 'test artifact change invalidates previously passing report');
399
+ fs.writeFileSync(testArtifact, 'TEST-001: fixture content\n', 'utf8');
400
+
401
+ fs.writeFileSync(tddPath, JSON.stringify({ ...baselineTdd, changedAfterAudit: true }), 'utf8');
402
+ const staleEvidence = verifyFresh();
403
+ check(staleEvidence.status === 1 &&
404
+ /tdd-evidence-changed-since-audit/.test(staleEvidence.stderr),
405
+ '#58 evidence change invalidates previously passing report');
406
+
407
+ fs.writeFileSync(tddPath, JSON.stringify(baselineTdd), 'utf8');
408
+ fs.rmSync(path.join(workspace, 'src/api.js'));
409
+ const missingArtifactAudit = spawnSync(process.execPath, [
410
+ path.join(ROOT, 'contract-integrity/scripts/audit.js'),
411
+ tracePath,
412
+ '--tdd-evidence', tddPath,
413
+ '--workspace', workspace,
414
+ ], { encoding: 'utf8' });
415
+ check(missingArtifactAudit.status === 2 &&
416
+ /provenance artifact missing from workspace: IMPL-001/.test(missingArtifactAudit.stderr),
417
+ 'strict workspace-aware audit fails closed when traced implementation evidence is missing');
418
+ } finally {
419
+ fs.rmSync(freshRoot, { recursive: true, force: true });
420
+ }
421
+
422
+ console.log(`\n${failed === 0 ? 'PASS' : 'FAIL'}: #84 contract integrity phase 1-4 mechanism (${failed} failure${failed === 1 ? '' : 's'})`);
269
423
  process.exit(failed === 0 ? 0 : 1);
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const assert = require('assert');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+ const { spawnSync } = require('child_process');
9
+
10
+ const ROOT = path.resolve(__dirname, '..');
11
+ const FIXTURE = path.join(ROOT, 'contract-integrity', 'fixtures', 'node-probe-project');
12
+ const ADAPTER = path.join(ROOT, 'contract-integrity', 'scripts', 'node-probe-adapter.js');
13
+ const { applyProbe, executePlan, validatePlan } = require(ADAPTER);
14
+ const { evaluateTrace } = require(path.join(ROOT, 'contract-integrity', 'scripts', 'audit.js'));
15
+
16
+ let failed = 0;
17
+ function check(condition, message, detail = '') {
18
+ if (condition) console.log(' PASS ' + message);
19
+ else {
20
+ console.error(' FAIL ' + message + (detail ? ' — ' + detail : ''));
21
+ failed++;
22
+ }
23
+ }
24
+ function clone(value) {
25
+ return JSON.parse(JSON.stringify(value));
26
+ }
27
+ function json(file) {
28
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
29
+ }
30
+ function digest(file) {
31
+ return require('crypto').createHash('sha256').update(fs.readFileSync(file)).digest('hex');
32
+ }
33
+
34
+ console.log('=== Contract Integrity Phase 3 Node Probe Adapter (#84) ===');
35
+
36
+ const plan = json(path.join(FIXTURE, 'probe-plan.json'));
37
+ check(validatePlan(plan).length === 0, 'declared node-npm-v1 probe plan validates');
38
+
39
+ const beforeSource = digest(path.join(FIXTURE, 'src', 'limit.js'));
40
+ const beforeTest = digest(path.join(FIXTURE, 'test', 'contract.test.js'));
41
+ const protectedReport = executePlan(FIXTURE, plan);
42
+ check(protectedReport.result === 'PROTECTED', 'green baseline plus both explicit probes produces PROTECTED evidence');
43
+ check(protectedReport.probes.length === 2 && protectedReport.probes.every(probe =>
44
+ probe.status === 'KILLED' && probe.failureClass === 'contract' && probe.workspaceIsolation === 'isolated'),
45
+ 'env and exact-replace probes are killed only by expected contract failures');
46
+ check(digest(path.join(FIXTURE, 'src', 'limit.js')) === beforeSource &&
47
+ digest(path.join(FIXTURE, 'test', 'contract.test.js')) === beforeTest,
48
+ 'adapter never mutates the source workspace');
49
+ check(!JSON.stringify(protectedReport).includes('out-of-range input must be rejected'),
50
+ 'probe report retains output hashes/evidence refs instead of project test output');
51
+
52
+ const trace = json(path.join(ROOT, 'contract-integrity', 'fixtures', 'consistent-trace.json'));
53
+ trace.probes = protectedReport.probes.filter(probe => probe.probeId === 'PROBE-001').map(probe => ({
54
+ probeId: probe.probeId,
55
+ requirementId: probe.requirementId,
56
+ status: probe.status,
57
+ sourceSection: probe.sourceSection,
58
+ evidenceRef: probe.evidenceRef,
59
+ workspaceIsolation: probe.workspaceIsolation,
60
+ failureClass: probe.failureClass,
61
+ }));
62
+ const tdd = json(path.join(ROOT, 'tdd', 'fixtures', 'pass-evidence.json'));
63
+ tdd.requirements[0].source.path = 'docs/specs/api.md';
64
+ tdd.requirements[0].source.section = 'REQ-001';
65
+ const integrated = evaluateTrace(trace, { tddEvidence: tdd });
66
+ check(integrated.result === 'PASS' && integrated.scores.protectionScore === 100,
67
+ 'derived adapter evidence feeds the existing #84/#58 strict integrity gate');
68
+
69
+ const survivingPlan = clone(plan);
70
+ survivingPlan.probes = [clone(plan.probes[0])];
71
+ survivingPlan.probes[0].env.HARNESS_CONTRACT_PROBE = 'noop';
72
+ const surviving = executePlan(FIXTURE, survivingPlan);
73
+ check(surviving.result === 'SURVIVED' && surviving.probes[0].status === 'SURVIVED',
74
+ 'green test run under a required probe is explicitly SURVIVED, never PASS');
75
+ const weakTrace = clone(trace);
76
+ weakTrace.probes[0] = {
77
+ probeId: surviving.probes[0].probeId,
78
+ requirementId: surviving.probes[0].requirementId,
79
+ status: surviving.probes[0].status,
80
+ sourceSection: surviving.probes[0].sourceSection,
81
+ evidenceRef: surviving.probes[0].evidenceRef,
82
+ workspaceIsolation: surviving.probes[0].workspaceIsolation,
83
+ failureClass: surviving.probes[0].failureClass,
84
+ };
85
+ const weakAudit = evaluateTrace(weakTrace, { tddEvidence: tdd });
86
+ check(weakAudit.result === 'FAIL' && weakAudit.scores.completenessScore === 100 &&
87
+ weakAudit.scores.protectionScore === 0,
88
+ 'green but weak suite cannot compensate 100 completeness with a surviving contract probe');
89
+
90
+ const unrelatedPlan = clone(plan);
91
+ unrelatedPlan.probes = [clone(plan.probes[0])];
92
+ unrelatedPlan.probes[0].expectedFailureContains = 'THIS-MARKER-DOES-NOT-EXIST';
93
+ const unrelated = executePlan(FIXTURE, unrelatedPlan);
94
+ check(unrelated.probes[0].status === 'INVALID' && unrelated.probes[0].failureClass === 'unknown',
95
+ 'unrelated failing test output is INVALID and cannot be credited as a kill');
96
+
97
+ const ambiguousReplace = clone(plan);
98
+ ambiguousReplace.probes = [clone(plan.probes[1])];
99
+ ambiguousReplace.probes[0].find = 'return';
100
+ const ambiguous = executePlan(FIXTURE, ambiguousReplace);
101
+ check(ambiguous.probes[0].status === 'NOT_EVALUATED' &&
102
+ /exactly once/.test(ambiguous.probes[0].adapterReason),
103
+ 'ambiguous exact-replace fallback fails closed without mutating source');
104
+
105
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-contract-adapter-test-'));
106
+ try {
107
+ const symlinkWorkspace = path.join(temp, 'symlink-workspace');
108
+ fs.mkdirSync(symlinkWorkspace, { recursive: true });
109
+ const outsideDir = path.join(temp, 'outside-dir');
110
+ fs.mkdirSync(outsideDir, { recursive: true });
111
+ const outsideTarget = path.join(outsideDir, 'outside.txt');
112
+ fs.writeFileSync(outsideTarget, 'SAFE', 'utf8');
113
+ fs.symlinkSync(outsideDir, path.join(symlinkWorkspace, 'linked-dir'),
114
+ process.platform === 'win32' ? 'junction' : 'dir');
115
+ let symlinkRejected = false;
116
+ try {
117
+ applyProbe(symlinkWorkspace, {
118
+ strategy: 'replace',
119
+ target: path.join('linked-dir', 'outside.txt'),
120
+ find: 'SAFE',
121
+ replace: 'MUTATED',
122
+ });
123
+ } catch (error) {
124
+ symlinkRejected = /symbolic link|reparse-point|outside isolated workspace/.test(String(error.message || error));
125
+ }
126
+ check(symlinkRejected && fs.readFileSync(outsideTarget, 'utf8') === 'SAFE',
127
+ 'replace probe rejects symlink/junction escape without mutating outside the isolated workspace');
128
+
129
+ const linkedProject = path.join(temp, 'linked-project');
130
+ fs.mkdirSync(linkedProject, { recursive: true });
131
+ fs.writeFileSync(path.join(linkedProject, 'package.json'), JSON.stringify({
132
+ name: 'linked-project',
133
+ scripts: { contract: 'node test.js' },
134
+ }), 'utf8');
135
+ fs.writeFileSync(path.join(linkedProject, 'test.js'), [
136
+ "const fs = require('fs');",
137
+ "const path = require('path');",
138
+ "fs.writeFileSync(path.join(__dirname, 'linked-dir', 'outside.txt'), 'MUTATED', 'utf8');",
139
+ ].join('\n'), 'utf8');
140
+ fs.symlinkSync(outsideDir, path.join(linkedProject, 'linked-dir'),
141
+ process.platform === 'win32' ? 'junction' : 'dir');
142
+ const linkedPlan = {
143
+ schemaVersion: '1.0.0',
144
+ adapter: 'node-npm-v1',
145
+ script: 'contract',
146
+ probes: [{
147
+ probeId: 'PROBE-LINK',
148
+ requirementId: 'REQ-LINK',
149
+ sourceSection: 'Linked workspace',
150
+ strategy: 'env',
151
+ expectedFailureContains: 'unused',
152
+ env: { HARNESS_CONTRACT_PROBE: 'link' },
153
+ }],
154
+ };
155
+ const linkedReport = executePlan(linkedProject, linkedPlan);
156
+ check(linkedReport.result === 'NOT_EVALUATED' &&
157
+ linkedReport.baseline.workspaceIsolation === 'not-isolated' &&
158
+ linkedReport.probes.every(probe => probe.workspaceIsolation === 'not-isolated') &&
159
+ fs.readFileSync(outsideTarget, 'utf8') === 'SAFE',
160
+ 'workspace copy rejects source symlinks/junctions before project code can mutate an outside target');
161
+
162
+ const dependent = path.join(temp, 'dependent');
163
+ fs.cpSync(FIXTURE, dependent, { recursive: true });
164
+ const pkg = json(path.join(dependent, 'package.json'));
165
+ pkg.dependencies = { leftpad: '1.0.0' };
166
+ fs.writeFileSync(path.join(dependent, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
167
+ const dependencyReport = executePlan(dependent, plan);
168
+ check(dependencyReport.result === 'NOT_EVALUATED' &&
169
+ dependencyReport.discovery.reason === 'external-dependencies-not-supported-v1',
170
+ 'v1 adapter refuses to infer/install external dependencies');
171
+
172
+ const broken = path.join(temp, 'broken');
173
+ fs.cpSync(FIXTURE, broken, { recursive: true });
174
+ fs.appendFileSync(path.join(broken, 'test', 'contract.test.js'), "\nthrow new Error('baseline fixture failure');\n", 'utf8');
175
+ const baselineFailure = executePlan(broken, plan);
176
+ check(baselineFailure.result === 'NOT_EVALUATED' &&
177
+ baselineFailure.baseline.status === 'FAIL' &&
178
+ baselineFailure.probes.every(probe => probe.status === 'NOT_EVALUATED'),
179
+ 'non-green baseline blocks all protection claims');
180
+ } finally {
181
+ fs.rmSync(temp, { recursive: true, force: true });
182
+ }
183
+
184
+ const invalidPlan = clone(plan);
185
+ invalidPlan.probes[0].target = '../escape.js';
186
+ invalidPlan.probes[0].strategy = 'replace';
187
+ invalidPlan.probes[0].find = 'x';
188
+ invalidPlan.probes[0].replace = 'y';
189
+ delete invalidPlan.probes[0].env;
190
+ check(validatePlan(invalidPlan).some(error => /repo-relative/.test(error)),
191
+ 'probe plan rejects replace targets that escape the isolated workspace');
192
+
193
+ const protectedCli = spawnSync(process.execPath, [
194
+ ADAPTER, '--workspace', FIXTURE, '--plan', path.join(FIXTURE, 'probe-plan.json'),
195
+ ], { encoding: 'utf8' });
196
+ check(protectedCli.status === 0 && /"result": "PROTECTED"/.test(protectedCli.stdout),
197
+ 'CLI returns exit 0 only for fully killed declared probes', protectedCli.stderr);
198
+
199
+ const docs = fs.readFileSync(path.join(ROOT, 'contract-integrity', 'ADAPTERS.md'), 'utf8');
200
+ check(/does \*\*not\*\* claim generic mutation-testing support/.test(docs) &&
201
+ /zero external npm dependencies/.test(docs) &&
202
+ /Not yet supported/.test(docs),
203
+ 'adapter documentation states exact supported scope and explicit non-support');
204
+
205
+ console.log('\n' + (failed === 0 ? 'PASS' : 'FAIL') +
206
+ ': #84 contract protection node adapter (' + failed + ' failure' + (failed === 1 ? '' : 's') + ')');
207
+ process.exit(failed === 0 ? 0 : 1);
@@ -120,6 +120,16 @@ assert.doesNotMatch(packagedAuditSource, /\.\.\/\.\.\/tdd\/scripts\/quality-gate
120
120
  const packagedAudit = require(packagedContractAudit);
121
121
  assert.strictEqual(typeof packagedAudit.runCli, 'function', 'packaged contract audit runtime must load and export runCli');
122
122
 
123
+ const packagedProbeAdapter = path.join(PLUGIN, 'contract-integrity', 'scripts', 'node-probe-adapter.js');
124
+ const packagedAdapterDocs = path.join(PLUGIN, 'contract-integrity', 'ADAPTERS.md');
125
+ assert.ok(fs.existsSync(packagedProbeAdapter) && fs.existsSync(packagedAdapterDocs),
126
+ 'OpenAI package must include shared contract-probe adapter runtime and support boundary docs');
127
+ const packagedAdapter = require(packagedProbeAdapter);
128
+ assert.strictEqual(packagedAdapter.ADAPTER, 'node-npm-v1',
129
+ 'packaged contract-probe adapter must load without becoming a routed skill');
130
+ assert.match(fs.readFileSync(packagedAdapterDocs, 'utf8'), /does \*\*not\*\* claim generic mutation-testing support/,
131
+ 'packaged adapter docs must preserve the narrow support boundary');
132
+
123
133
  const verificationContractWrapper = path.join(PLUGIN, 'skills', 'verification-loop', 'scripts', 'contract-integrity-audit.js');
124
134
  assert.ok(fs.existsSync(verificationContractWrapper), 'verification-loop must package its contract audit wrapper');
125
135
  const verificationWrapper = require(verificationContractWrapper);
@@ -0,0 +1,37 @@
1
+ # Contract Protection Adapters
2
+
3
+ This directory does **not** claim generic mutation-testing support.
4
+
5
+ ## Supported in Phase 3
6
+
7
+ ### `node-npm-v1`
8
+
9
+ Supported project shape:
10
+
11
+ - Node.js project with a `package.json`;
12
+ - one explicitly selected npm script used as the contract-test command;
13
+ - **zero external npm dependencies** for this first adapter revision;
14
+ - probes are predeclared in a local JSON plan and tied to stable `REQ-*` IDs and authoritative source sections;
15
+ - every baseline and probe run executes in a fresh temporary copy; the source workspace is never mutated.
16
+
17
+ Source workspaces containing symbolic-link or junction entries are rejected before project code runs. The v1 adapter does not claim isolation when a copied path could retain an external filesystem target.
18
+
19
+ Supported probe strategies:
20
+
21
+ 1. **`env`** — explicit project-owned fault injection via environment variables.
22
+ 2. **`replace`** — exact one-occurrence text replacement in the isolated copy only. This is the fallback when the project has no built-in fault-injection seam.
23
+
24
+ A probe is `KILLED` only when the selected npm script fails **and** its output contains the predeclared requirement-specific observable marker. A green run is `SURVIVED`. Timeout/spawn failures, baseline failures, unsafe/ambiguous replacement, missing dependencies, or unrelated failures are `NOT_EVALUATED` / `INVALID`; none of those earn protection credit.
25
+
26
+ The adapter does not install dependencies, access the network, infer mutation locations, rewrite source documents, or commit generated probes.
27
+
28
+ ## Not yet supported
29
+
30
+ - arbitrary Jest/Vitest/Mocha/Pytest/Go/Rust/.NET adapter discovery;
31
+ - projects that require dependency installation inside the isolated copy;
32
+ - automatic source-derived mutation synthesis;
33
+ - compiler-failure-as-kill;
34
+ - flaky-test attribution;
35
+ - dirty-worktree mutation or in-place production changes.
36
+
37
+ Those remain future adapters/slices. Phase 3 intentionally proves one narrow real runner plus an explicit isolated fault-injection fallback.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "contract-probe-fixture",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "test:contract": "node --test test/contract.test.js"
7
+ }
8
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "adapter": "node-npm-v1",
4
+ "script": "test:contract",
5
+ "probes": [
6
+ {
7
+ "probeId": "PROBE-001",
8
+ "requirementId": "REQ-001",
9
+ "sourceSection": "docs/specs/api.md#REQ-001",
10
+ "strategy": "env",
11
+ "env": {
12
+ "HARNESS_CONTRACT_PROBE": "accept-invalid"
13
+ },
14
+ "expectedFailureContains": "[REQ-001]"
15
+ },
16
+ {
17
+ "probeId": "PROBE-REPLACE",
18
+ "requirementId": "REQ-001",
19
+ "sourceSection": "docs/specs/api.md#REQ-001",
20
+ "strategy": "replace",
21
+ "target": "src/limit.js",
22
+ "find": "return Number.isInteger(value) && value >= 1 && value <= 10;",
23
+ "replace": "return true;",
24
+ "expectedFailureContains": "[REQ-001]"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ function acceptsLimit(value) {
4
+ if (process.env.HARNESS_CONTRACT_PROBE === 'accept-invalid') return true;
5
+ return Number.isInteger(value) && value >= 1 && value <= 10;
6
+ }
7
+
8
+ module.exports = { acceptsLimit };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const test = require('node:test');
4
+ const assert = require('node:assert/strict');
5
+ const { acceptsLimit } = require('../src/limit');
6
+
7
+ test('[REQ-001] accepts supported boundary', () => {
8
+ assert.equal(acceptsLimit(1), true);
9
+ assert.equal(acceptsLimit(10), true);
10
+ });
11
+
12
+ test('[REQ-001] rejects out-of-range input', () => {
13
+ assert.equal(acceptsLimit(0), false, '[REQ-001] out-of-range input must be rejected');
14
+ });