harness-everything 1.3.0 → 1.3.1

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 (125) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +6 -0
  4. package/ci/archive/325-prep/README.md +9 -2
  5. package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
  6. package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
  7. package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
  8. package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
  9. package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
  10. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  11. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
  12. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  13. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
  14. package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
  15. package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
  16. package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
  17. package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
  18. package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
  19. package/ci/fixtures/stop/fail-session-writes.js +109 -0
  20. package/ci/fixtures/workflow-contract/cases.json +3355 -0
  21. package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
  22. package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
  23. package/ci/mechanism-2an-workflow-replay.test.js +324 -0
  24. package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
  25. package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
  26. package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
  27. package/ci/mechanism-325-3b-preparation.test.js +208 -49
  28. package/ci/mechanism-325-3b-s1-review.test.js +20 -828
  29. package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
  30. package/ci/mechanism-325-f3-derived-views.test.js +140 -0
  31. package/ci/mechanism-341-opencode-lane.test.js +164 -284
  32. package/ci/mechanism-35-verification-contract.test.js +246 -0
  33. package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
  34. package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
  35. package/ci/mechanism-397-opencode-observations.test.js +151 -18
  36. package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
  37. package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
  38. package/ci/mechanism-553-p3-plan-start.test.js +212 -0
  39. package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
  40. package/ci/mechanism-553-stop.test.js +427 -0
  41. package/ci/mechanism-553-t2a-derive.test.js +110 -0
  42. package/ci/mechanism-553-t2c-derive.test.js +94 -0
  43. package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
  44. package/ci/mechanism-outline-sanitizer.test.js +0 -8
  45. package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
  46. package/ci/mechanism-prb-outline-review.test.js +101 -3283
  47. package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
  48. package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
  49. package/docs/doc-workflow-reconciliation.md +17 -2
  50. package/docs/document-lifecycle.md +6 -2
  51. package/docs/platform-capabilities.md +35 -5
  52. package/hooks/hooks.json +0 -46
  53. package/hooks/scripts/lib/workflow-obligations.js +0 -55
  54. package/hooks/scripts/state-persist.js +7 -95
  55. package/hooks/scripts/workflow-disposition.js +0 -2
  56. package/hooks/scripts/workflow-stop-gate.js +17 -30
  57. package/opencode-plugin/index.mjs +6 -70
  58. package/opencode-plugin/plugin.json +1 -1
  59. package/package.json +1 -1
  60. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  61. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  62. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
  63. package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
  64. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
  65. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
  66. package/plugins/harness-everything/plugin.json +1 -1
  67. package/sbom.cdx.json +7 -7
  68. package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
  69. package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
  70. package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
  71. package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
  72. package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
  73. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
  74. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
  75. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
  76. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
  77. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
  78. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
  79. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
  80. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
  81. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
  82. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
  83. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
  84. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
  85. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
  86. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
  87. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
  88. package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
  89. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
  90. package/ci/lib/doc-reconciliation-file-spy.js +0 -23
  91. package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
  92. package/ci/lib/doc-reconciliation-replay.js +0 -104
  93. package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
  94. package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
  95. package/ci/mechanism-325-3b-s1.test.js +0 -188
  96. package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
  97. package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
  98. package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
  99. package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
  100. package/ci/mechanism-325-f4-invariants.test.js +0 -606
  101. package/ci/mechanism-325-f4-projections.test.js +0 -392
  102. package/ci/mechanism-325-f4-qualification.test.js +0 -228
  103. package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
  104. package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
  105. package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  106. package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  107. package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  108. package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  109. package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  110. package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  111. package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  112. package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  113. package/hooks/scripts/w6-state-operations.js +0 -239
  114. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  115. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  116. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  117. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  118. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  119. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  120. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  121. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  122. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
  123. package/scripts/system-one-eval-laya.js +0 -112
  124. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
  125. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- // #325 F4-T2 test-only file-access spy. Loaded with `node --require` before the CI preloader. It appends each access to
4
- // the qualification export to the file named by F4_SPY_LOG, and it changes no result. Production never loads it, and
5
- // no environment or argv switch in the runtime reads it.
6
-
7
- const fs = require('fs');
8
-
9
- const EXPORT_PATH = /doc-reconciliation-qualification\.json$/;
10
- const logFile = process.env.F4_SPY_LOG;
11
- const appendLog = fs.appendFileSync;
12
-
13
- function note(operation, target) {
14
- if (logFile && EXPORT_PATH.test(String(target))) appendLog(logFile, `${operation} ${target}\n`);
15
- }
16
-
17
- for (const operation of ['readFileSync', 'openSync', 'existsSync', 'statSync', 'lstatSync']) {
18
- const real = fs[operation];
19
- fs[operation] = function spied(target, ...rest) {
20
- note(operation, target);
21
- return real.call(this, target, ...rest);
22
- };
23
- }
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- // #325 Phase 3b F4 CI-only qualification preloader (docs/doc-workflow-reconciliation.md, F4 "Test transport").
4
- //
5
- // Loaded only by the test driver: `node --require <this file> <real entry> ...`. It is not packaged, no
6
- // production code reads it, and no environment or argv switch enables it.
7
- //
8
- // Boundary: it supplies only the explicitly fake qualification object through the origin-provider factory,
9
- // and only when the caller omitted qualification. It never touches the snapshot, resolveEvent outcomes,
10
- // principals, capability, accepted records or core eligibility.
11
-
12
- const fs = require('fs');
13
- const path = require('path');
14
-
15
- const FAKE_QUALIFICATION = Object.freeze({
16
- source: 'fake-test-fixture',
17
- faked: true,
18
- ref: 'ci-qualification-preload',
19
- toolUseIdPopulated: true,
20
- agentIdPopulated: true,
21
- });
22
-
23
- // The entry decides which provider copy is patched, so the canonical and packaged legs are each covered.
24
- const entry = process.argv[1] ? path.resolve(process.argv[1]) : '';
25
- const providerFile = path.join(path.dirname(entry), 'lib', 'doc-reconciliation-provider.js');
26
-
27
- if (fs.existsSync(providerFile)) {
28
- const provider = require(providerFile);
29
- const factory = provider.createClaudeOriginProvider;
30
- provider.createClaudeOriginProvider = input => {
31
- const safe = input && typeof input === 'object' && !Array.isArray(input) ? input : {};
32
- return factory({
33
- ...safe,
34
- qualification: safe.qualification === undefined ? FAKE_QUALIFICATION : safe.qualification,
35
- });
36
- };
37
- }
@@ -1,104 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const os = require('os');
5
- const path = require('path');
6
- const { spawn, spawnSync } = require('child_process');
7
- const fx = require('./doc-reconciliation-prep-fixtures');
8
-
9
- const CORPUS = path.join(__dirname, '..', 'fixtures', 'doc-obligations', 'reconciliation-s2b', 'corpus');
10
- const CASES = path.join(__dirname, '..', 'fixtures', 'doc-obligations', 'reconciliation-s2b', 'f4', 'cases.json');
11
- const EVENT_HOOKS = new Set(['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'SubagentStart', 'SubagentStop']);
12
- const SITES = ['moduleLoads', 'stateFiles', 'captureRecords', 'pilotReport', 'workflowStep', 'workflowStop', 'genericStop'];
13
-
14
- function load(streamId) {
15
- const file = path.join(CORPUS, `${streamId}.json`);
16
- const stream = JSON.parse(fs.readFileSync(file, 'utf8'));
17
- if (!stream.id || !Array.isArray(stream.events) || !stream.expectations) throw new Error(`invalid stream ${file}`);
18
- for (const site of SITES) if (!stream.expectations[site]) throw new Error(`${stream.id} missing expectation site ${site}`);
19
- return stream;
20
- }
21
-
22
- function tracePreloader(file) {
23
- fs.writeFileSync(file, `const M=require('module'), fs=require('fs'); const old=M._load; M._load=function(id,p,m){const x=old.apply(this,arguments);if(typeof id==='string'&&/(doc-reconciliation|state-persist|workflow-disposition|stop-gate)/.test(id))fs.appendFileSync(process.env.F4_C1_TRACE,JSON.stringify({pid:process.pid,module:id,requester:m&&m.filename})+'\\n');return x};\n`);
24
- }
25
-
26
- function actionsFor(stream, template) {
27
- const actions = template.actions.filter(a => !['lint-run','post-lint','verify-pass','stop','stop-generic'].includes(a.id));
28
- stream.events.forEach((event, i) => {
29
- if (!EVENT_HOOKS.has(event.event)) throw new Error(`${stream.id}: unsupported event ${event.event}`);
30
- const id = `capture-${String(i + 1).padStart(2, '0')}`;
31
- if (event.runArgs) actions.push({ id: `${id}-run`, op: 'hostRun', payload: { command: 'doc-check', args: event.runArgs } });
32
- const payload = { event: event.event };
33
- if (event.toolName) payload.toolName = event.toolName;
34
- if (event.command !== undefined) payload.command = event.command;
35
- if (event.toolUseId) payload.toolUseId = event.toolUseId;
36
- if (event.runArgs && event.event === 'PostToolUse') payload.fromRun = `${id}-run`;
37
- if (event.event === 'PostToolUse') payload.response = { stdout: event.runArgs ? 'doc-check completed' : 'completed', stderr: '', interrupted: false };
38
- if (event.event === 'PostToolUseFailure') { payload.error = 'stable fixture failure'; payload.isInterrupt = false; }
39
- if (event.event === 'SubagentStart' || event.event === 'SubagentStop') {
40
- payload.agentId = `agent-${i + 1}`; payload.agentType = 'reviewer';
41
- if (event.event === 'SubagentStop') payload.lastAssistantMessage = 'APPROVE: reviewed the governed document.';
42
- }
43
- actions.push({ id, op: 'hookDeliver', payload });
44
- });
45
- actions.push({ id: 'verify-pass', op: 'step', payload: { stepId: 'req-verify', disposition: 'pass', evidence: 'recorded document verification' }, expectExit: { on: [0, 2] } });
46
- actions.push({ id: 'stop', op: 'stop' }, { id: 'stop-generic', op: 'stopGeneric' });
47
- return actions;
48
- }
49
-
50
- function concurrent(stream, leg, mode) {
51
- const dist = fx.DISTRIBUTIONS[leg];
52
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'f4c1-concurrent-'));
53
- const stateHome = path.join(root, 'state'); const workspace = path.join(root, 'workspace');
54
- fs.mkdirSync(workspace); fs.mkdirSync(stateHome);
55
- const barrier = path.join(root, 'barrier'); fs.mkdirSync(barrier);
56
- const worker = path.join(root, 'worker.js');
57
- fs.writeFileSync(worker, `const fs=require('fs'),cp=require('child_process'),path=require('path');const [hook,barrier,home,workspace,sid,index,pilot]=process.argv.slice(2);fs.writeFileSync(path.join(barrier,'ready-'+index),'ready');while(!fs.existsSync(path.join(barrier,'go')))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,20);const p={session_id:sid,cwd:workspace,hook_event_name:'PostToolUse',tool_name:'Bash',tool_input:{command:'npm test'},tool_use_id:'concurrent-'+index,tool_response:{stdout:'ok',stderr:'',interrupted:false}};const r=cp.spawnSync(process.execPath,[hook],{input:JSON.stringify(p),encoding:'utf8',env:{...process.env,HARNESS_STATE_HOME:home,HARNESS_WORKSPACE_ROOT:workspace,...(pilot==='on'?{HARNESS_DOC_RECONCILIATION_PILOT:'1'}:{})}});process.exit(r.status||0);`);
58
- const children = [1, 2].map(i => spawn(process.execPath, [worker, dist.stateHook, barrier, stateHome, workspace, 'concurrent-session', String(i), mode], { stdio: 'ignore' }));
59
- while (![1, 2].every(i => fs.existsSync(path.join(barrier, `ready-${i}`)))) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
60
- fs.writeFileSync(path.join(barrier, 'go'), 'release');
61
- const exits = children.map(child => new Promise(resolve => child.on('exit', (code, signal) => resolve({ code, signal }))));
62
- return Promise.all(exits).then(results => {
63
- const files=[]; const walk=d=>{for(const e of fs.readdirSync(d,{withFileTypes:true})){const f=path.join(d,e.name);if(e.isDirectory())walk(f);else files.push({path:path.relative(stateHome,f),json:f.endsWith('.json')?safeJson(f):undefined,provenance:'concurrent state-persist process'});}};walk(stateHome);
64
- fs.rmSync(root,{recursive:true,force:true}); return {results,files};
65
- });
66
- }
67
- function safeJson(file){try{return JSON.parse(fs.readFileSync(file,'utf8'));}catch(_){return null;}}
68
-
69
- async function replay(streamId, leg='source', mode='on') {
70
- if (!fx.DISTRIBUTIONS[leg]) throw new Error(`unknown distribution ${leg}`);
71
- if (!['on','off'].includes(mode)) throw new Error(`unknown mode ${mode}`);
72
- const stream=load(streamId); const cases=JSON.parse(fs.readFileSync(CASES,'utf8')).cases;
73
- const template=cases.find(item=>item.id==='F4-POS-body-edit');
74
- const definition={...template,id:stream.id,actions:actionsFor(stream,template)};
75
- const scratch=fs.mkdtempSync(path.join(os.tmpdir(),'f4c1-')); const spy=path.join(scratch,'trace.js'); const trace=path.join(scratch,'modules.jsonl'); tracePreloader(spy);
76
- const previous=process.env.F4_C1_TRACE; process.env.F4_C1_TRACE=trace;
77
- let root;
78
- try { root=fx.replayCase(definition,leg,{...(mode==='on'?{pilot:'1'}:{}),nodeArgs:['--require',spy]}); }
79
- finally { if(previous===undefined)delete process.env.F4_C1_TRACE;else process.env.F4_C1_TRACE=previous; }
80
- const modules=fs.existsSync(trace)?fs.readFileSync(trace,'utf8').trim().split('\n').filter(Boolean).map(JSON.parse):[];
81
- const stateFiles=[]; const provenance=[];
82
- for(const [actionId,action] of Object.entries(root.actions)) for(const key of ['workflow','obligations','handoff','capture']) if(action.state&&action.state[key]) {
83
- stateFiles.push({actionId,key,provenance:`snapshot after ${actionId}`,value:action.state[key]});
84
- if(key==='capture') for(const record of action.state.capture.records||[]) provenance.push({actionId,event:record.event,toolUseId:record.tool_use_id||record.toolUseId,provenance:'state-persist capture journal'});
85
- }
86
- const result={stream:stream.id,leg,mode,infrastructureErrors:fx.infrastructureFaults(definition,root,mode),moduleLoads:modules,stateFiles,captureRecords:provenance,pilotReport:root.pilot,pilotReportOrigin:root.pilotReportOrigin,workflowStep:Object.fromEntries(Object.entries(root.actions).filter(([id])=>id==='verify-pass').map(([id,a])=>[id,{exitCode:a.exitCode,stdout:a.stdout,stderr:a.stderr}])),workflowStop:root.actions.stop&&{exitCode:root.actions.stop.exitCode,stdout:root.actions.stop.stdout,stderr:root.actions.stop.stderr},genericStop:root.actions['stop-generic']&&{exitCode:root.actions['stop-generic'].exitCode,stdout:root.actions['stop-generic'].stdout,stderr:root.actions['stop-generic'].stderr},expectations:stream.expectations};
87
- if(stream.concurrency) result.concurrency=await concurrent(stream,leg,mode);
88
- fs.rmSync(scratch,{recursive:true,force:true});
89
- return result;
90
- }
91
-
92
- async function selfCheck(){
93
- const ids=fs.readdirSync(CORPUS).filter(f=>f.endsWith('.json')).map(f=>path.basename(f,'.json')).sort();
94
- let failed=false;
95
- for(const leg of ['source','packaged']) for(const id of ids){const stream=load(id);const result=await replay(id,leg,stream.mode);const journal=result.concurrency&&result.concurrency.files.find(file=>file.path.endsWith('doc-reconciliation-capture.json'));const concurrentBad=result.concurrency&&(result.concurrency.results.some(x=>x.code!==0)||!journal||journal.json.records.length!==2);const bad=result.infrastructureErrors.length||concurrentBad;console.log(`${bad?'INFRA':'OK'} ${leg}/${id}${bad?`: ${JSON.stringify(result.infrastructureErrors)} ${JSON.stringify(result.concurrency&&result.concurrency.results)} journalRecords=${journal&&journal.json.records.length}`:''}`);failed ||= Boolean(bad);}
96
- return failed?1:0;
97
- }
98
-
99
- if(require.main===module){
100
- if(process.argv[2]==='--worker')process.exit(0);
101
- if(process.argv[2]==='--self-check')selfCheck().then(code=>process.exit(code));
102
- else replay(process.argv[2],process.argv[3]||'source',process.argv[4]||'on').then(r=>console.log(JSON.stringify(r,null,2)));
103
- }
104
- module.exports={load,replay,selfCheck};
@@ -1,102 +0,0 @@
1
- 'use strict';
2
-
3
- // #325 F4-T2 test helper: stages a scratch copy of one leg's real entries (hooks, harness scripts and the retained
4
- // live-host capture), so a test chooses the qualification export itself. A staged tree never carries the repository's
5
- // export, and nothing here writes into the repository. The real entries run from the copy, with copied siblings, so
6
- // the provider walks up to the copied retained directory exactly as it would in the checkout.
7
-
8
- const fs = require('fs');
9
- const os = require('os');
10
- const path = require('path');
11
- const crypto = require('crypto');
12
-
13
- const ROOT = path.resolve(__dirname, '..', '..');
14
- const LIVE_REL = path.join('benchmarks', 'results', 'live-host', 'claude-325-3b-s2b');
15
- const EXPORT_FILE = 'doc-reconciliation-qualification.json';
16
- const CAPTURE_FILE = 'capture.sanitized.jsonl';
17
- // The export names its sanitized capture as a sibling in the same lib directory, so source and packaged copies resolve it
18
- // the same way (the provider reads it from there).
19
- const SIBLING_CAPTURE = 'doc-reconciliation-capture.sanitized.jsonl';
20
- // Facts observed in the retained Run 2b capture (see benchmarks/results/live-host/claude-325-3b-s2b/README.md). A valid
21
- // export states exactly these; the runtime checks them against the sibling file.
22
- const OBSERVED_PAYLOAD_KINDS = {
23
- PostToolUse: ['agent_id', 'interrupted', 'tool_use_id'],
24
- PreToolUse: ['agent_id', 'tool_use_id'],
25
- SubagentStart: ['agent_id'],
26
- SubagentStop: ['agent_id'],
27
- };
28
- const OBSERVED_CORRELATION = { preToPostByToolUseId: true, interruptedExplicit: true, subagentStartStopSameAgent: true, agentResultAliasCorrelated: true };
29
-
30
- // Top-level entries the source leg never reads: VCS and dependency trees, the worktrees, the test corpus, the evidence
31
- // directories and the packaging copies. The live-host capture is copied separately, below.
32
- const SOURCE_EXCLUDE = new Set(['.git', 'node_modules', '.worktrees', 'ci', 'benchmarks', 'behavioral-evals', 'evals', 'docs', 'plugins', 'submission', 'opencode-plugin']);
33
-
34
- function sha256File(file) {
35
- return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
36
- }
37
-
38
- // Stages one leg. Returns the replay distribution (explicit entry paths inside the copy) and the helpers a test needs.
39
- // The live-host directory is copied to the top of the tree, which is where the provider's upward walk finds it.
40
- function stage(leg) {
41
- if (leg !== 'source' && leg !== 'packaged') throw new Error(`unknown leg ${leg}`);
42
- const root = fs.mkdtempSync(path.join(os.tmpdir(), `f4-staged-${leg}-`));
43
- let base;
44
- if (leg === 'source') {
45
- // The source package: the root carries the hooks, the harness scripts, the shared libraries and the root skill
46
- // folders that bindings resolve. Only data that the entries never read is left out.
47
- for (const entry of fs.readdirSync(ROOT)) {
48
- if (SOURCE_EXCLUDE.has(entry)) continue;
49
- fs.cpSync(path.join(ROOT, entry), path.join(root, entry), { recursive: true });
50
- }
51
- base = root;
52
- } else {
53
- fs.cpSync(path.join(ROOT, 'plugins', 'harness-everything'), path.join(root, 'plugin'), { recursive: true });
54
- base = path.join(root, 'plugin');
55
- }
56
- fs.cpSync(path.join(ROOT, LIVE_REL), path.join(root, LIVE_REL), { recursive: true });
57
- const libDir = path.join(base, 'hooks', 'scripts', 'lib');
58
- // The copied tree may carry a checkout's own export: a staged tree starts without one.
59
- fs.rmSync(path.join(libDir, EXPORT_FILE), { force: true });
60
- fs.rmSync(path.join(libDir, SIBLING_CAPTURE), { force: true });
61
- fs.copyFileSync(path.join(root, LIVE_REL, CAPTURE_FILE), path.join(libDir, SIBLING_CAPTURE));
62
- const skillScripts = leg === 'source' ? path.join(base, 'harness-everything', 'scripts') : path.join(base, 'skills', 'harness-everything', 'scripts');
63
- const dist = {
64
- controller: path.join(base, 'hooks', 'scripts', 'workflow-disposition.js'),
65
- stopGate: path.join(base, 'hooks', 'scripts', 'workflow-stop-gate.js'),
66
- kernel: path.join(skillScripts, 'kernel-router.js'),
67
- genericStopGate: path.join(base, 'hooks', 'scripts', 'stop-gate.js'),
68
- stateHook: path.join(base, 'hooks', 'scripts', 'state-persist.js'),
69
- docCheck: path.join(skillScripts, 'doc-check.js'),
70
- };
71
- return {
72
- root,
73
- leg,
74
- dist,
75
- libDir,
76
- exportFile: path.join(libDir, EXPORT_FILE),
77
- captureFile: path.join(libDir, SIBLING_CAPTURE),
78
- retainedCaptureFile: path.join(root, LIVE_REL, CAPTURE_FILE),
79
- // The export that binds the staged capture bytes and records the two populated fields.
80
- // The valid export for this capture. `overrides` lets a test change one field, to show the runtime refuses it.
81
- validExport(overrides = {}) {
82
- return {
83
- schema: 'harness.doc-reconciliation.qualification.v1',
84
- host: 'claude-code',
85
- hostVersion: '2.1.308',
86
- captureRecordVersion: 'claude-capture-record/1',
87
- payloadKinds: OBSERVED_PAYLOAD_KINDS,
88
- correlation: OBSERVED_CORRELATION,
89
- sanitizedCapture: { file: SIBLING_CAPTURE, sha256: sha256File(path.join(libDir, SIBLING_CAPTURE)) },
90
- ...overrides,
91
- };
92
- },
93
- writeExport(content) {
94
- fs.writeFileSync(this.exportFile, typeof content === 'string' ? content : JSON.stringify(content, null, 2) + '\n', 'utf8');
95
- },
96
- cleanup() {
97
- fs.rmSync(root, { recursive: true, force: true });
98
- },
99
- };
100
- }
101
-
102
- module.exports = { stage, EXPORT_FILE, SIBLING_CAPTURE, LIVE_REL, CAPTURE_FILE };
@@ -1,206 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- // #325 H1 deterministic qualification: provider independence/preparation.
5
- // H1 only: advisory suggestions are never passed to the F4 consumer.
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- const fx = require(path.join(__dirname, 'lib', 'doc-reconciliation-prep-fixtures'));
11
- const { stage } = require(path.join(__dirname, 'lib', 'doc-reconciliation-staged-tree'));
12
- const F4_CASES = path.join(__dirname, 'fixtures', 'doc-obligations', 'reconciliation-s2b', 'f4', 'cases.json');
13
-
14
- const REPO_ROOT = path.resolve(__dirname, '..');
15
- const SOURCE_OBLIGATIONS = require(path.join(REPO_ROOT, 'harness-everything', 'scripts', 'doc-obligations.js'));
16
- const PACKAGED_OBLIGATIONS = require(path.join(REPO_ROOT, 'plugins', 'harness-everything', 'skills', 'harness-everything', 'scripts', 'doc-obligations.js'));
17
- const SOURCE_PROVIDER = require(path.join(REPO_ROOT, 'harness-everything', 'scripts', 'doc-providers.js'));
18
- const PACKAGED_PROVIDER = require(path.join(REPO_ROOT, 'plugins', 'harness-everything', 'skills', 'harness-everything', 'scripts', 'doc-providers.js'));
19
-
20
- const LEGS = ['source', 'packaged'];
21
- const CASE = id => fx.readCaseCorpus(F4_CASES).cases.find(item => item.id === id);
22
-
23
- const EXPECTED_MUSTS = [
24
- { id: 'doc-change:doc-lint', capability: 'doc-lint', strength: 'MUST', applicability: 'applicable', scope: { paths: ['docs/a.md'] }, acceptance: 'Run document lifecycle lint for every changed governed document.' },
25
- { id: 'doc-change:link-check', capability: 'link-check', strength: 'MUST', applicability: 'applicable', scope: { paths: ['docs/a.md'] }, acceptance: 'Check in-repository links for every changed governed document.' }
26
- ];
27
-
28
- const PROVIDER_A_INPUT = {
29
- activeStep: { id: 'verify-docs', stepType: 'verification' },
30
- neededCapabilities: ['doc-lint'],
31
- availableProviderMetadata: [
32
- { providerId: 'fixture-lint-a', capabilities: ['doc-lint'], stepTypes: ['verification'], requiresHostCapabilities: ['execution-events'], locator: { kind: 'tool', id: 'fixture-lint-a' } }
33
- ],
34
- hostCapabilities: ['execution-events']
35
- };
36
-
37
- const PROVIDER_B_INPUT = {
38
- activeStep: { id: 'verify-docs', stepType: 'verification' },
39
- neededCapabilities: ['doc-lint'],
40
- availableProviderMetadata: [
41
- { providerId: 'fixture-lint-b', capabilities: ['doc-lint'], stepTypes: ['verification'], requiresHostCapabilities: ['execution-events'], locator: { kind: 'tool', id: 'fixture-lint-b' } }
42
- ],
43
- hostCapabilities: ['execution-events']
44
- };
45
-
46
- const PROVIDER_OMITTED_INPUT = {
47
- activeStep: { id: 'verify-docs', stepType: 'verification' },
48
- neededCapabilities: ['doc-lint'],
49
- availableProviderMetadata: [],
50
- hostCapabilities: []
51
- };
52
-
53
- const PROVIDER_A_SUGGESTION = [{ capability: 'doc-lint', providerId: 'fixture-lint-a', availability: 'available', reason: 'active-step capability and host requirements match' }];
54
- const PROVIDER_B_SUGGESTION = [{ capability: 'doc-lint', providerId: 'fixture-lint-b', availability: 'available', reason: 'active-step capability and host requirements match' }];
55
- const PROVIDER_OMITTED_UNAVAILABLE = [{ capability: 'doc-lint', reason: 'no available provider metadata for the active-step capability' }];
56
-
57
- let passCount = 0;
58
- let failCount = 0;
59
- let infraCount = 0;
60
-
61
- function deepEqual(left, right) {
62
- return JSON.stringify(left) === JSON.stringify(right);
63
- }
64
-
65
- function record(status, id, detail) {
66
- const suffix = detail ? ` - ${detail}` : '';
67
- if (status === 'PASS') passCount += 1;
68
- else if (status === 'FAIL') failCount += 1;
69
- else infraCount += 1;
70
- console.log(` ${status.padEnd(5)} ${id}${suffix}`);
71
- }
72
-
73
- function cloneZero(caseDef) {
74
- return {
75
- ...caseDef,
76
- id: `${caseDef.id}-zero-evidence`,
77
- actions: caseDef.actions.filter(action => action.id !== 'lint-run' && action.id !== 'post-lint')
78
- };
79
- }
80
-
81
- function checkProvider(leg, providerCase) {
82
- const module = leg === 'source' ? SOURCE_PROVIDER : PACKAGED_PROVIDER;
83
- let input;
84
- let expectedSuggestions;
85
- let expectedUnavailable;
86
- if (providerCase === 'A') {
87
- input = PROVIDER_A_INPUT;
88
- expectedSuggestions = PROVIDER_A_SUGGESTION;
89
- expectedUnavailable = [];
90
- } else if (providerCase === 'B') {
91
- input = PROVIDER_B_INPUT;
92
- expectedSuggestions = PROVIDER_B_SUGGESTION;
93
- expectedUnavailable = [];
94
- } else {
95
- input = PROVIDER_OMITTED_INPUT;
96
- expectedSuggestions = [];
97
- expectedUnavailable = PROVIDER_OMITTED_UNAVAILABLE;
98
- }
99
- const result = module.suggestDocProviders(input);
100
- const ok = deepEqual(result.suggestions, expectedSuggestions) && deepEqual(result.unavailable, expectedUnavailable);
101
- record(ok ? 'PASS' : 'FAIL', `H1.${leg}.${providerCase}.provider-suggestion`, ok ? '' : `suggestions=${JSON.stringify(result.suggestions)}, unavailable=${JSON.stringify(result.unavailable)}`);
102
- return ok;
103
- }
104
-
105
- function checkDerivedMusts(leg, label) {
106
- const module = leg === 'source' ? SOURCE_OBLIGATIONS : PACKAGED_OBLIGATIONS;
107
- const caseDef = CASE('F4-POS-body-edit');
108
- const config = JSON.parse(caseDef.input.baseFiles['.agents/harness-everything/project-docs.json']);
109
- const base = { files: caseDef.input.baseFiles };
110
- const candidate = { files: { ...caseDef.input.baseFiles, ...caseDef.input.candidateFiles } };
111
- const { facts } = module.deriveDocFacts({ base, candidate, config, inventory: { complete: true } });
112
- const obligations = module.deriveDocObligations(facts);
113
- const fullMusts = obligations.filter(item => item.strength === 'MUST' && item.applicability === 'applicable');
114
-
115
- let ok = deepEqual(fullMusts, EXPECTED_MUSTS);
116
- for (const item of fullMusts) {
117
- if (!item.id || !item.capability || !item.strength || !item.applicability || !item.scope || !Array.isArray(item.scope.paths) || item.scope.paths.some(pathValue => !pathValue) || !item.acceptance) ok = false;
118
- }
119
- record(ok ? 'PASS' : 'FAIL', `${label}.derived-full-musts`, ok ? '' : JSON.stringify(fullMusts));
120
- return ok;
121
- }
122
-
123
- function runCell(leg, providerCase, evidenceMode) {
124
- const label = `H1.${leg}.${providerCase}.${evidenceMode}`;
125
- const staged = stage(leg);
126
- try {
127
- checkProvider(leg, providerCase);
128
- checkDerivedMusts(leg, label);
129
-
130
- staged.writeExport(staged.validExport());
131
-
132
- const baseCase = CASE('F4-POS-body-edit');
133
- const caseDef = evidenceMode === 'valid' ? baseCase : cloneZero(baseCase);
134
-
135
- const root = fx.replayCase(caseDef, staged.dist, { pilot: '1' });
136
- const faults = fx.infrastructureFaults(caseDef, root, 'on');
137
- if (faults.length) {
138
- record('INFRA', label, faults.map(fault => `${fault.actionId}: ${fault.message}`).join('; '));
139
- return;
140
- }
141
-
142
- const pilot = root.pilot || {};
143
- const checks = [];
144
-
145
- checks.push(deepEqual(root.pilotReportOrigin, 'runtime'));
146
- checks.push(deepEqual(pilot.reportOrigin, 'runtime'));
147
- checks.push(deepEqual(pilot.expectedMustIds, ['doc-change:doc-lint', 'doc-change:link-check']));
148
- const verifyAction = root.actions && root.actions['verify-pass'];
149
- const verifyRequirement = verifyAction?.state?.obligations?.requirements?.find(item => item.id === 'req-verify');
150
- checks.push(verifyRequirement?.requiredBindings?.some(binding => binding.id === 'verification-loop' && binding.status === 'loaded') === true);
151
-
152
- if (evidenceMode === 'valid') {
153
- checks.push(pilot.pilotCredit === true);
154
- checks.push(pilot.pilotStatus === 'credited');
155
- checks.push(deepEqual(pilot.unsatisfied, []));
156
- checks.push(deepEqual(pilot.creditedCapabilities, ['doc-lint', 'link-check']));
157
- checks.push(Array.isArray(pilot.acceptedRefs) && pilot.acceptedRefs.some(ref => ref.endsWith('#doc-lint')) && pilot.acceptedRefs.some(ref => ref.endsWith('#link-check')));
158
- checks.push(verifyAction && verifyAction.exitCode === 0);
159
- const stopAction = root.actions && root.actions.stop;
160
- checks.push(stopAction && stopAction.exitCode === 0);
161
- checks.push(stopAction && stopAction.state && stopAction.state.workflow && stopAction.state.workflow.state === 'satisfied');
162
- } else {
163
- checks.push(pilot.pilotCredit === false);
164
- checks.push(pilot.pilotStatus === 'unresolved');
165
- checks.push(Array.isArray(pilot.unsatisfied) && pilot.unsatisfied.length >= 2);
166
- checks.push(pilot.unsatisfied.some(item => item.obligationId === 'doc-change:doc-lint'));
167
- checks.push(pilot.unsatisfied.some(item => item.obligationId === 'doc-change:link-check'));
168
- checks.push(deepEqual(pilot.creditedCapabilities, []));
169
- checks.push(deepEqual(pilot.acceptedRefs, []));
170
- checks.push(verifyAction && verifyAction.exitCode === 2);
171
- const stopAction = root.actions && root.actions.stop;
172
- checks.push(stopAction && stopAction.exitCode === 0);
173
- checks.push(stopAction && stopAction.state && stopAction.state.workflow && stopAction.state.workflow.state === 'running');
174
- }
175
-
176
- record(checks.every(Boolean) ? 'PASS' : 'FAIL', label, checks.every(Boolean) ? '' : `checks=${JSON.stringify(checks)}, pilot=${JSON.stringify(pilot).slice(0, 500)}`);
177
- } catch (error) {
178
- record('FAIL', label, error.message);
179
- } finally {
180
- staged.cleanup();
181
- }
182
- }
183
-
184
- function main() {
185
- console.log('\n== H1 qualification: provider side input and F4 replay matrix ==');
186
- for (const leg of LEGS) {
187
- for (const providerCase of ['A', 'B', 'omitted']) {
188
- for (const evidenceMode of ['valid', 'zero']) {
189
- runCell(leg, providerCase, evidenceMode);
190
- }
191
- }
192
- }
193
-
194
- console.log('\n== H1 qualification evidence ==');
195
- console.log(`passing checks: ${passCount}`);
196
- console.log(`unexpected failures: ${failCount}`);
197
- console.log(`infrastructure faults: ${infraCount}`);
198
- if (failCount === 0 && infraCount === 0) {
199
- console.log('\nSTATUS: GREEN (all assertions passed)');
200
- return 0;
201
- }
202
- console.log('\nSTATUS: NOT-GREEN');
203
- return 1;
204
- }
205
-
206
- process.exitCode = main();