harness-everything 0.50.0 → 0.52.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 (97) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +23 -0
  4. package/CHANGELOG.md +174 -115
  5. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-a-evid-001.md +123 -0
  6. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-b-route-001.md +130 -0
  7. package/ci/mechanism-2am-observations-session-import.test.js +4 -1
  8. package/ci/mechanism-34-observations.test.js +127 -23
  9. package/ci/mechanism-349-ci-change-scope.test.js +260 -0
  10. package/ci/mechanism-handoff-file.test.js +121 -0
  11. package/ci/mechanism-prb-outline-review.test.js +783 -107
  12. package/ci/mechanism-system-one-contract.test.js +9 -2
  13. package/ci/mechanism-system-one-curves.test.js +206 -0
  14. package/ci/mechanism-system-one-cycle.test.js +585 -0
  15. package/ci/mechanism-system-one-evaluation.test.js +32 -5
  16. package/ci/mechanism-system-one-handoff-input.test.js +208 -0
  17. package/ci/mechanism-system-one-install.test.js +202 -77
  18. package/ci/mechanism-system-one-live.test.js +361 -0
  19. package/ci/mechanism-system-one-relevance.test.js +11 -1
  20. package/ci/mechanism-system-one-train.test.js +136 -53
  21. package/ci/release-unreleased-heading.test.js +24 -0
  22. package/ci/system-one-adapter-test.py +331 -0
  23. package/ci/system-one-train-test.py +116 -24
  24. package/docs/adr/EVID-001.md +123 -0
  25. package/docs/adr/ROUTE-001-error-lesson-delivery.md +305 -0
  26. package/docs/doc-workflow-reconciliation.md +29 -16
  27. package/docs/governed-index.md +2 -0
  28. package/docs/platform-capabilities.md +2 -0
  29. package/docs/routing.md +2 -2
  30. package/docs/system-one-cycle.md +68 -0
  31. package/docs/system-one-observations.md +9 -8
  32. package/docs/system-one-routing.md +163 -115
  33. package/docs/system-one-suggestion-gates.md +6 -8
  34. package/docs/system-one-training.md +44 -7
  35. package/docs/workflow-runtime.md +19 -0
  36. package/harness-everything/SKILL.md +1 -1
  37. package/harness-everything/scripts/kernel-router.js +2 -1
  38. package/harness-everything/scripts/system-one/contract.js +19 -15
  39. package/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  40. package/harness-everything/scripts/system-one/evaluate.js +4 -9
  41. package/harness-everything/scripts/system-one/handoff-input.js +76 -0
  42. package/harness-everything/scripts/system-one/install.js +281 -113
  43. package/harness-everything/scripts/system-one/manifest.js +58 -0
  44. package/harness-everything/scripts/system-one/provider.js +96 -2
  45. package/harness-everything/scripts/system-one/resident.js +47 -1
  46. package/harness-everything/scripts/system-one/router.js +80 -1
  47. package/harness-everything/scripts/tier-router.js +21 -6
  48. package/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
  49. package/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
  50. package/hooks/scripts/lib/observations.js +43 -4
  51. package/hooks/scripts/lib/workflow-obligations.js +8 -4
  52. package/hooks/scripts/state-persist.js +26 -7
  53. package/hooks/scripts/w6-state-operations.js +239 -0
  54. package/opencode-plugin/plugin.json +1 -1
  55. package/package.json +2 -2
  56. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  57. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +12 -0
  58. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +575 -12
  59. package/plugins/harness-everything/hooks/scripts/lib/observations.js +43 -4
  60. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +8 -4
  61. package/plugins/harness-everything/hooks/scripts/state-persist.js +26 -7
  62. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +239 -0
  63. package/plugins/harness-everything/plugin.json +1 -1
  64. package/plugins/harness-everything/scripts/handoff-file.js +223 -0
  65. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  66. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +2 -1
  67. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/contract.js +19 -15
  68. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  69. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/evaluate.js +4 -9
  70. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/handoff-input.js +76 -0
  71. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +281 -113
  72. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +58 -0
  73. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +96 -2
  74. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/resident.js +47 -1
  75. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +80 -1
  76. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +21 -6
  77. package/sbom.cdx.json +7 -7
  78. package/scripts/ci-change-scope.js +59 -0
  79. package/scripts/handoff-file.js +223 -0
  80. package/scripts/sync-openai-plugin.js +4 -0
  81. package/scripts/system-one-calibrate.js +108 -41
  82. package/scripts/system-one-curves.js +332 -0
  83. package/scripts/system-one-cycle/adjudication-input.js +65 -0
  84. package/scripts/system-one-cycle/build.js +165 -0
  85. package/scripts/system-one-cycle/collect.js +50 -0
  86. package/scripts/system-one-cycle/common.js +137 -0
  87. package/scripts/system-one-cycle/engines.js +62 -0
  88. package/scripts/system-one-cycle/evaluate.js +70 -0
  89. package/scripts/system-one-cycle/judge.js +106 -0
  90. package/scripts/system-one-cycle/label.js +59 -0
  91. package/scripts/system-one-cycle/package.js +173 -0
  92. package/scripts/system-one-cycle/score.py +111 -0
  93. package/scripts/system-one-cycle/train.js +136 -0
  94. package/scripts/system-one-cycle.js +131 -0
  95. package/scripts/system-one-observations-export.js +29 -6
  96. package/scripts/system-one-observations-review.js +4 -5
  97. package/scripts/system-one-train.py +117 -61
@@ -123,6 +123,51 @@ function start(manifest, files, deps) {
123
123
  }
124
124
  return unavailable('provider-starting');
125
125
  }
126
+ function activeStateFiles(active) {
127
+ const base = path.join(path.dirname(active.pointerPath), `system-one-active-resident-${active.fingerprint.slice(0, 16)}`);
128
+ return { state: `${base}.json`, lock: `${base}.starting` };
129
+ }
130
+ function defaultActiveCommand(active) {
131
+ return [active.python, [adapterPath({}), '--serve-active']];
132
+ }
133
+ function startActive(active, files, deps) {
134
+ const lock = lockInfo(files.lock);
135
+ if (lock && lock.ageMs < LOCK_TTL_MS) return unavailable(lock.failed ? 'provider-unavailable' : 'provider-starting');
136
+ if (lock) { try { fs.unlinkSync(files.lock); } catch (_) { /* another caller replaced it */ } }
137
+ try { fs.writeFileSync(files.lock, JSON.stringify({ createdAt: Date.now() }), { flag: 'wx', mode: 0o600 }); }
138
+ catch (_) { return unavailable('provider-starting'); }
139
+ let child = null;
140
+ try {
141
+ const [exe, prefix] = (deps.command || defaultActiveCommand)(active);
142
+ child = spawn(exe, [...prefix, active.pointerPath, files.state, files.lock, active.fingerprint],
143
+ { detached: true, stdio: 'ignore', windowsHide: true, shell: false,
144
+ env: { ...process.env, HARNESS_SYSTEM_ONE_NODE: process.execPath } });
145
+ child.on('error', () => { /* recorded synchronously below: a failed spawn has no pid */ });
146
+ child.unref();
147
+ } catch (_) { child = null; }
148
+ if (!child || !child.pid) {
149
+ try { fs.writeFileSync(files.lock, JSON.stringify({ createdAt: Date.now(), failed: 'spawn-failed' })); } catch (_) { /* best effort */ }
150
+ return unavailable('provider-unavailable');
151
+ }
152
+ return unavailable('provider-starting');
153
+ }
154
+ function activeOutcome(result, files, state, active, deps) {
155
+ if (result.reply) {
156
+ if (result.reply.ok === true && Object.hasOwn(result.reply, 'response')) return { status: 'scored', response: result.reply.response };
157
+ if (result.reply.reason === 'artifact-changed') removeIfSame(files.state, state);
158
+ return unavailable(result.reply.ok === false ? 'provider-unavailable' : 'provider-json');
159
+ }
160
+ if (result.error === 'refused') { removeIfSame(files.state, state); return startActive(active, files, deps); }
161
+ return unavailable({ timeout: 'provider-timeout', limit: 'provider-output-limit', json: 'provider-json' }[result.error] || 'provider-unavailable');
162
+ }
163
+ async function scoreActiveStage(active, stage, request, deps = {}) {
164
+ validateRequest(request);
165
+ if (!['validity', 'intent', 'tier'].includes(stage)) return unavailable('provider-config');
166
+ const files = activeStateFiles(active);
167
+ const state = liveState(files);
168
+ if (!state) return startActive(active, files, deps);
169
+ return activeOutcome(await callAsync(state.port, { token: state.token, op: 'score', stage, request }), files, state, active, deps);
170
+ }
126
171
  // Returns a live server state, or null after removing state that provably belongs to a dead server.
127
172
  function liveState(files) {
128
173
  const state = readState(files.state);
@@ -202,4 +247,5 @@ if (require.main === module) {
202
247
  if (op === 'stop') stop(manifest, manifestPath);
203
248
  process.stdout.write(`${JSON.stringify(status(manifest, manifestPath))}\n`);
204
249
  }
205
- module.exports = { stateFiles, readState, callSync, callAsync, score, scoreAsync, ensureReady, status, stop, defaultCommand, LOCK_TTL_MS, CALL_TIMEOUT_MS };
250
+ module.exports = { stateFiles, readState, callSync, callAsync, score, scoreAsync, scoreActiveStage,
251
+ activeStateFiles, defaultActiveCommand, ensureReady, status, stop, defaultCommand, LOCK_TTL_MS, CALL_TIMEOUT_MS };
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
  const { createRequest, decide } = require('./contract');
3
3
  const provider = require('./provider');
4
+ const { prepareHandoffInput } = require('./handoff-input');
4
5
  const TIER_OPTIONS = Object.freeze([
5
6
  { id: 'tier1', text: 'A small bounded edit or operation with clear scope.' },
6
7
  { id: 'tier2', text: 'Implementation or bug fix needing iterative testing.' },
@@ -9,6 +10,84 @@ const TIER_OPTIONS = Object.freeze([
9
10
  ].map(Object.freeze));
10
11
  const LABELS = { tier1: 'Tier 1 (Trivial)', tier2: 'Tier 2 (Standard Task)', tier3: 'Tier 3 (Macro Task)' };
11
12
  const RANK = { tier1: 1, tier2: 2, tier3: 3 };
13
+ const VALIDITY_OPTIONS = Object.freeze([
14
+ { id: 'actionable', text: 'The current prompt contains an actionable request.' },
15
+ { id: 'invalid', text: 'The request needs conversation context to understand.' },
16
+ ].map(Object.freeze));
17
+ const isProbability = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1;
18
+ function liveOptions() {
19
+ const { INTENT_OPTIONS } = require('./catalogs');
20
+ return { validity: VALIDITY_OPTIONS, intent: INTENT_OPTIONS, tier: TIER_OPTIONS };
21
+ }
22
+ function exactScores(value, ids) {
23
+ return value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === ids.length
24
+ && ids.every(id => Object.hasOwn(value, id) && isProbability(value[id]));
25
+ }
26
+ function routeLive(input, result) {
27
+ if (!result || typeof result.version !== 'string' || !result.version
28
+ || typeof result.sha256 !== 'string' || !/^[a-f0-9]{16}$/.test(result.sha256)) {
29
+ return { tier: input.tier, reference: { available: false } };
30
+ }
31
+ const options = liveOptions();
32
+ const stages = result.stageScores || {};
33
+ const thresholds = result.thresholds || {};
34
+ const referenceOnly = Object.fromEntries(['validity', 'intent', 'tier'].map(stage => [stage,
35
+ Array.isArray(result.referenceOnly?.[stage]) ? result.referenceOnly[stage].filter(id => typeof id === 'string') : []]));
36
+ const validityScores = exactScores(stages.validity, ['invalid'])
37
+ && isProbability(thresholds.validity?.invalid) ? { invalid: stages.validity.invalid } : null;
38
+ const validity = validityScores === null || referenceOnly.validity.includes('invalid') ? 'abstain'
39
+ : validityScores.invalid >= thresholds.validity.invalid ? 'invalid' : 'actionable';
40
+ const intentCatalogIds = options.intent.map(option => option.id).filter(id => id !== 'unclassified');
41
+ // A packaged checkpoint may omit the non-selectable unclassified option from its intent scores.
42
+ const intentScores = stages.intent && typeof stages.intent === 'object' && !Array.isArray(stages.intent)
43
+ ? Object.fromEntries(Object.entries(stages.intent).filter(([id]) => id !== 'unclassified')) : null;
44
+ const intents = validity === 'actionable' && exactScores(intentScores, intentCatalogIds)
45
+ && intentCatalogIds.every(id => isProbability(thresholds.intent?.[id])) ? intentScores : null;
46
+ const tierIds = ['tier1', 'tier2', 'tier3'];
47
+ const tierScores = validity === 'actionable' && exactScores(stages.tier, tierIds)
48
+ && tierIds.every(id => isProbability(thresholds.tier?.[id])) ? stages.tier : null;
49
+ const selectedIntents = intents ? intentCatalogIds.filter(id => !referenceOnly.intent.includes(id) && intents[id] >= thresholds.intent[id])
50
+ .sort((a, b) => (intents[b] - intents[a]) || (intentCatalogIds.indexOf(a) - intentCatalogIds.indexOf(b))).slice(0, 3) : [];
51
+ const rankedTiers = tierScores ? tierIds.filter(id => !referenceOnly.tier.includes(id)).sort((a, b) => (tierScores[b] - tierScores[a])
52
+ || (tierIds.indexOf(a) - tierIds.indexOf(b))) : [];
53
+ const bestTier = rankedTiers[0];
54
+ const selectedTier = bestTier && tierScores[bestTier] >= thresholds.tier[bestTier]
55
+ && (rankedTiers.length === 1 || tierScores[bestTier] !== tierScores[rankedTiers[1]]) ? bestTier : null;
56
+ const systemOne = {
57
+ version: result.version,
58
+ sha256: result.sha256,
59
+ mode: 'live',
60
+ inputEnrichment: { handoffFiles: Number.isSafeInteger(result.inputEnrichment?.handoffFiles)
61
+ ? result.inputEnrichment.handoffFiles : 0 },
62
+ referenceOnly,
63
+ validity: validityScores,
64
+ intents,
65
+ tier: tierScores,
66
+ decision: { validity, intents: selectedIntents, tier: selectedTier },
67
+ };
68
+ const top = (stage, scores) => scores ? Object.entries(scores).sort((a, b) => b[1] - a[1]
69
+ || Object.keys(scores).indexOf(a[0]) - Object.keys(scores).indexOf(b[0])).slice(0, 3)
70
+ .map(([id, probability]) => ({ stage, id, probability })) : [];
71
+ const referenceOnlyOptions = Object.entries(referenceOnly).flatMap(([stage, ids]) => ids
72
+ .filter(id => isProbability(stages[stage]?.[id]))
73
+ .map(id => ({ stage, id, probability: stages[stage][id] })));
74
+ const reference = { version: result.version, sha256: result.sha256,
75
+ topOptions: [...top('validity', validityScores), ...top('intent', intents), ...top('tier', tierScores)],
76
+ referenceOnlyOptions };
77
+ const floorValid = input.floor == null || Object.hasOwn(RANK, input.floor);
78
+ const belowFloor = selectedTier && input.floor != null && RANK[selectedTier] < RANK[input.floor];
79
+ const applied = floorValid && validity === 'actionable' && selectedTier !== null && !input.explicit && !belowFloor;
80
+ return { tier: applied ? LABELS[selectedTier] : input.tier, systemOne, reference, applied };
81
+ }
82
+ async function prescoreLive(prompt, env = process.env, score = provider.scoreLive, cwd = process.cwd()) {
83
+ if (env.HARNESS_SYSTEM_ONE_MODE !== 'live') return null;
84
+ try {
85
+ const prepared = prepareHandoffInput(prompt, cwd);
86
+ const result = await score(prepared.input, env, liveOptions());
87
+ return result ? { ...result, inputEnrichment: { handoffFiles: prepared.handoffFiles } } : result;
88
+ }
89
+ catch (_) { return null; }
90
+ }
12
91
  // input.floor is the deterministic structural minimum; a scorer may raise the tier, never lower it below the floor.
13
92
  function selectTier(input, env = process.env, scorer = provider.score) {
14
93
  const mode = env.HARNESS_SYSTEM_ONE_MODE || 'off';
@@ -50,4 +129,4 @@ async function prescoreTier(prompt, env = process.env, scoreAsync = provider.sco
50
129
  return result;
51
130
  };
52
131
  }
53
- module.exports = { selectTier, prescoreTier, TIER_OPTIONS };
132
+ module.exports = { selectTier, prescoreTier, prescoreLive, routeLive, TIER_OPTIONS, VALIDITY_OPTIONS };
@@ -344,15 +344,24 @@ function run(userPrompt, context, options = {}) {
344
344
  }
345
345
  }
346
346
 
347
- const { selectTier } = require('./system-one/router');
347
+ const { selectTier, routeLive } = require('./system-one/router');
348
348
  const structuralFloor = hasMacroSignal ? 'tier3'
349
349
  : !isTrivialDocsEdit && hasMultipleTasks && hasMultipleSentences ? 'tier2' : null;
350
- const semantic = selectTier({ prompt: userPrompt, tier: recommendedTier, floor: structuralFloor,
351
- explicit: profileLookup || Boolean(detectExplicitStrategy(userPrompt, detectFableModel(userPrompt))) }, process.env, options.systemOneScorer || undefined);
350
+ const routeInput = { prompt: userPrompt, tier: recommendedTier, floor: structuralFloor,
351
+ explicit: profileLookup || Boolean(detectExplicitStrategy(userPrompt, detectFableModel(userPrompt))) };
352
+ const liveMode = process.env.HARNESS_SYSTEM_ONE_MODE === 'live';
353
+ const semantic = liveMode ? routeLive(routeInput, options.systemOneResult)
354
+ : selectTier(routeInput, process.env, options.systemOneScorer || undefined);
352
355
  if (semantic.diagnostic) console.log(`\n=> SYSTEM ONE: ${JSON.stringify(semantic.diagnostic)}`);
353
- if (semantic.diagnostic?.applied) {
356
+ if (liveMode && semantic.reference?.available === false) {
357
+ console.log('\n=> SYSTEM ONE REFERENCE CONFIDENCE unavailable; lexical routing retained.');
358
+ } else if (liveMode && semantic.reference) {
359
+ console.log(`\n=> SYSTEM ONE REFERENCE CONFIDENCE (not a verdict): ${JSON.stringify(semantic.reference)}`);
360
+ }
361
+ const systemOneApplied = liveMode ? semantic.applied : semantic.diagnostic?.applied;
362
+ if (systemOneApplied) {
354
363
  recommendedTier = semantic.tier;
355
- rationale = 'System One selected a tier from the fixed catalog; deterministic policy remains authoritative.';
364
+ rationale = 'System One reference confidence informed the default tier; deterministic routing constraints remain authoritative.';
356
365
  reasonCodes.splice(loadedConfig.reasonCodes.length);
357
366
  addReason(reasonCodes, 'system-one-tier');
358
367
  }
@@ -466,6 +475,8 @@ function run(userPrompt, context, options = {}) {
466
475
  },
467
476
  });
468
477
 
478
+ if (semantic.systemOne) contract.workflowPlan.systemOne = semantic.systemOne;
479
+
469
480
  if (knowledgeSignals.length > 0) {
470
481
  console.log(`\n=> KNOWLEDGE SIGNALS (STEP INPUT ONLY): ${knowledgeSignals.join(', ')}`);
471
482
  console.log(' These normalized prompt signals help compose requirement steps; they do not select or load documents.');
@@ -508,7 +519,11 @@ async function main(prompt, context) {
508
519
  if (['shadow', 'prefer'].includes(process.env.HARNESS_SYSTEM_ONE_MODE)) {
509
520
  try { systemOneScorer = await require('./system-one/router').prescoreTier(prompt); } catch (_) { /* the sync path still scores */ }
510
521
  }
511
- run(prompt, context, { systemOneScorer });
522
+ let systemOneResult = null;
523
+ if (process.env.HARNESS_SYSTEM_ONE_MODE === 'live') {
524
+ try { systemOneResult = await require('./system-one/router').prescoreLive(prompt); } catch (_) { /* lexical route remains available */ }
525
+ }
526
+ run(prompt, context, { systemOneScorer, systemOneResult });
512
527
  }
513
528
 
514
529
  if (require.main === module) {
@@ -197,6 +197,7 @@ function creditChain(context, set, dependencies = {}) {
197
197
  principals,
198
198
  baseline,
199
199
  captures,
200
+ allowInFlightW6ToolUseId: dependencies.allowInFlightW6ToolUseId || null,
200
201
  };
201
202
  const originProvider = dependencies.originProvider || createOriginProvider(providerInput);
202
203
  const produced = produceDocSnapshot({
@@ -457,6 +458,17 @@ function assess(context, set, dependencies = {}) {
457
458
  report.unsatisfied.push({ obligationId: 'doc-change:scope', state: 'unavailable', reasonCode: reason });
458
459
  }
459
460
  }
461
+ if (!withhold && dependencies.allowInFlightW6ToolUseId) {
462
+ report.pilotCredit = false;
463
+ report.pilotStatus = 'pending';
464
+ report.creditedCapabilities = [];
465
+ report.acceptedRefs = [];
466
+ report.outlineEvidence = { status: 'pending', outcome: 'none', observation: 'pending',
467
+ acceptedRefs: [], recordRefs: [], diagnostics: [{ code: 'state-operation-in-flight',
468
+ message: 'the verification state operation has not completed its host result', obligationId: null }] };
469
+ report.diagnostics.push({ code: 'state-operation-in-flight',
470
+ message: 'the verification state operation has not completed its host result', obligationId: null });
471
+ }
460
472
  report.diagnostics = report.diagnostics.map(diagnosticOf);
461
473
  try { atomicWriteJson(path.join(context.sessionDir, 'doc-reconciliation-pilot.json'), report); }
462
474
  catch {