harness-everything 0.55.3 → 0.55.4

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 (170) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +1 -1
  4. package/BENCHMARK_SOP.md +2 -2
  5. package/CHANGELOG.md +13 -0
  6. package/README.md +15 -16
  7. package/SECURITY.md +1 -1
  8. package/VERIFICATION.md +4 -8
  9. package/behavioral-evals/PAIRED-BENCHMARK.md +12 -27
  10. package/behavioral-evals/README.md +21 -65
  11. package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +26 -33
  12. package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +15 -17
  13. package/behavioral-evals/paired-benchmark.js +3 -40
  14. package/behavioral-evals/run.js +2 -3
  15. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
  16. package/ci/invariant-routing.test.js +26 -5
  17. package/ci/lib/opencode-verification-loader.js +3 -5
  18. package/ci/mechanism-2a-rule-of-3.test.js +111 -97
  19. package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
  20. package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
  21. package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
  22. package/ci/mechanism-32-paired-benchmark.test.js +1 -2
  23. package/ci/mechanism-33-issues-205-207.test.js +1 -1
  24. package/ci/mechanism-338-opencode-async.test.js +18 -49
  25. package/ci/mechanism-36-verify-timeout.test.js +3 -189
  26. package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
  27. package/ci/mechanism-397-opencode-observations.test.js +6 -7
  28. package/ci/mechanism-codex-hook-results.test.js +9 -5
  29. package/ci/mechanism-prb-outline-review.test.js +1 -13
  30. package/ci/mechanism-system-one-router.test.js +1 -1
  31. package/ci/openai-plugin-package.test.js +30 -7
  32. package/ci/openai-plugin-runtime.test.js +64 -32
  33. package/ci/prompt-contract-regressions.test.js +1 -5
  34. package/ci/self-evolve-loop.test.js +51 -51
  35. package/ci/workflow-execution-contract.test.js +3 -6
  36. package/docker-verify.sh +1 -117
  37. package/docs/architecture.md +9 -7
  38. package/docs/document-lifecycle.md +1 -1
  39. package/docs/enforcement-locks.md +12 -10
  40. package/docs/mechanism-first-skill-mesh.md +2 -2
  41. package/docs/openai-plugin.md +3 -3
  42. package/docs/philosophy.md +1 -1
  43. package/docs/platform-capabilities.md +2 -2
  44. package/docs/platform-compatibility.json +2 -2
  45. package/docs/reflection.md +1 -1
  46. package/docs/routing.md +2 -2
  47. package/docs/system-one-suggestion-gates.md +4 -4
  48. package/docs/troubleshooting.md +9 -35
  49. package/docs/workflow-runtime.md +19 -18
  50. package/docs/workflows/environment-detection.md +11 -9
  51. package/docs/workflows/fable-discipline.md +6 -5
  52. package/docs/workflows/fable-mode.md +6 -5
  53. package/docs/workflows/harness-everything.md +5 -5
  54. package/docs/workflows/improve-codebase-architecture.md +10 -8
  55. package/docs/workflows/install-cognitive-os.md +5 -5
  56. package/docs/workflows/tdd.md +9 -9
  57. package/docs/workflows/zoom-out.md +20 -30
  58. package/environment-detection/SKILL.md +2 -2
  59. package/environment-detection/references/shell-syntax-rules.md +1 -1
  60. package/eval-harness/SKILL.md +1 -1
  61. package/eval-harness/references/scoring-rubric.md +3 -3
  62. package/evals/zoom-out/eval.yaml +2 -2
  63. package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
  64. package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
  65. package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
  66. package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
  67. package/fable-discipline/SKILL.md +3 -3
  68. package/fable-discipline/references/discipline-rules.md +1 -1
  69. package/fable-mode/SKILL.md +1 -1
  70. package/fable-mode/execution-guardrails/SKILL.md +2 -4
  71. package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  72. package/fable-mode/fable-haiku/SKILL.md +1 -1
  73. package/fable-mode/fable-opus/SKILL.md +2 -2
  74. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  75. package/fable-mode/references/execution-phases.md +2 -2
  76. package/harness-everything/SKILL.md +3 -3
  77. package/harness-everything/references/router-workflow-plan.md +2 -2
  78. package/harness-everything/references/skill-registry.md +2 -2
  79. package/harness-everything/references/triage-and-tiers.md +5 -5
  80. package/harness-everything/scripts/bootstrap.js +1 -26
  81. package/harness-everything/scripts/kernel-router-core.js +2 -3
  82. package/harness-everything/scripts/kernel-router.js +1 -1
  83. package/harness-everything/scripts/router-contract-core.js +1 -1
  84. package/harness-everything/scripts/routing-keywords.json +0 -2
  85. package/hooks/hooks.json +0 -33
  86. package/hooks/scripts/lib/harness-state.js +5 -6
  87. package/hooks/scripts/lib/learning-opportunity.js +3 -13
  88. package/hooks/scripts/openai-session-start.js +2 -4
  89. package/improve-codebase-architecture/SKILL.md +3 -3
  90. package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  91. package/install-cognitive-os/SKILL.md +3 -3
  92. package/opencode-plugin/README.md +12 -43
  93. package/opencode-plugin/index.mjs +21 -368
  94. package/opencode-plugin/plugin.json +1 -1
  95. package/package.json +1 -4
  96. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  97. package/plugins/harness-everything/hooks/hooks.json +0 -14
  98. package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
  99. package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
  100. package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
  101. package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
  102. package/plugins/harness-everything/hooks/session-start.js +2 -4
  103. package/plugins/harness-everything/plugin.json +1 -1
  104. package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
  105. package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
  106. package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
  107. package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
  108. package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
  109. package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
  110. package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
  111. package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
  112. package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
  113. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
  114. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  115. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  116. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
  117. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  118. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
  119. package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
  120. package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
  121. package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
  122. package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
  123. package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
  124. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
  125. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
  126. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
  127. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
  128. package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
  129. package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  130. package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
  131. package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
  132. package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
  133. package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  134. package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
  135. package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
  136. package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
  137. package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
  138. package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
  139. package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
  140. package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
  141. package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
  142. package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
  143. package/references/platform-advisory-template.md +3 -9
  144. package/sbom.cdx.json +7 -7
  145. package/scripts/lib/advisory-text.js +2 -2
  146. package/scripts/lib/workspace.js +2 -2
  147. package/self-evolve/SKILL.md +1 -1
  148. package/self-evolve/references/memory-resolution.md +3 -3
  149. package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  150. package/self-evolve/scripts/lesson-candidate.js +1 -0
  151. package/skill-creator/SKILL.md +1 -1
  152. package/skill-creator/references/quality-checklist.md +1 -1
  153. package/skill-creator/references/quality-principles.md +4 -4
  154. package/submission/openai/test-cases.json +5 -5
  155. package/tdd/SKILL.md +2 -2
  156. package/tdd/references/core-discipline.md +3 -5
  157. package/todo-driven-workflow/SKILL.md +2 -2
  158. package/zoom-out/SKILL.md +14 -26
  159. package/zoom-out/references/circuit-breaker.md +18 -62
  160. package/behavioral-evals/opencode-hardlock-live.js +0 -17
  161. package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
  162. package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
  163. package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
  164. package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
  165. package/hooks/scripts/reset-circuit-breaker.js +0 -30
  166. package/hooks/scripts/rule-of-3-tracker.js +0 -165
  167. package/hooks/scripts/rule-of-3.js +0 -171
  168. package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
  169. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
  170. package/plugins/harness-everything/hooks/scripts/rule-of-3.js +0 -171
@@ -18,22 +18,11 @@
18
18
  * message via client.session.prompt() to force the agent
19
19
  * to keep going instead of truly stopping.)
20
20
  * verify.js -> inlined into the session.idle handler
21
- * circuit-breaker.js -> tool.execute.before (throws to pause edit tools for the zoom-out boundary
22
- * once locked) + failure tracking inside session.idle
23
21
  * compliance.js -> folded into the same state writes, no separate stage
24
22
  *
25
- * The circuit breaker trips on repeated *verification* failures of the same
26
- * underlying check (same command + normalized failure evidence: the first
27
- * test-level failing marker with its suite header as context, or a digest of
28
- * the complete streamed stdout+stderr when no test-level marker exists), not on
29
- * arbitrary tool failures: tool.execute.after
30
- * gives back `{title, output, metadata}` for every tool with no normalized
31
- * success/failure field, so there is no reliable cross-tool failure signal to
32
- * key a signature on. Verification failures are self-produced and already
33
- * normalized, so that is the honest signal to use. Uncompleted verifications
34
- * (timeout, execution error such as ENOBUFS/ENOENT) are reported as failures
35
- * but never counted toward the same-check threshold, because no failing check
36
- * was actually confirmed.
23
+ * The verification runner classifies test failures, timeouts, and execution
24
+ * errors so its follow-up can describe the actual outcome. It does not track
25
+ * failures across edits or gate later tools.
37
26
  */
38
27
 
39
28
  import { homedir } from "node:os"
@@ -274,9 +263,8 @@ function getStateHome() {
274
263
 
275
264
  // Keys state per real workspace (`directory`, which opencode itself resolves
276
265
  // - never a cwd walk) instead of one flat dir shared by every project on the
277
- // machine. The pre-fix `~/.harness-state` had no such key at all: a circuit
278
- // breaker trip in one opencode project affected every other one too
279
- // (issue #42 item #4).
266
+ // machine. The pre-fix `~/.harness-state` had no such key at all, so plugin
267
+ // state from one OpenCode project could affect another (issue #42 item #4).
280
268
  function getWorkspaceKey(directory) {
281
269
  let real = resolve(directory)
282
270
  try { real = realpathSync(real) } catch { /* directory may not exist yet */ }
@@ -341,12 +329,6 @@ function isWithin(parent, candidate) {
341
329
  )
342
330
  }
343
331
 
344
- function samePath(left, right) {
345
- const a = resolve(left)
346
- const b = resolve(right)
347
- return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b
348
- }
349
-
350
332
  function getSessionDir(directory, sessionID) {
351
333
  const sessionsRoot = resolve(join(getStateRoot(directory), "sessions"))
352
334
  const candidate = resolve(sessionsRoot, getSessionKey(sessionID))
@@ -385,194 +367,20 @@ function defaultEditState() {
385
367
  }
386
368
  }
387
369
 
388
- function defaultBreakerState() {
389
- return {
390
- failures: {},
391
- lastReflection: null,
392
- lastReflectionSignature: null,
393
- reflectionPending: false,
394
- reflectionRequestedAt: null,
395
- reflectionToken: null,
396
- reflectionSignature: null,
397
- }
398
- }
399
-
400
370
  function normalizeEditState(state) {
401
371
  return { ...defaultEditState(), ...(state || {}) }
402
372
  }
403
373
 
404
- function normalizeBreakerState(state) {
405
- const { hardLock: _retiredHardLock, ...rest } = state || {}
406
- return { ...defaultBreakerState(), ...rest, failures: (state && state.failures) || {} }
407
- }
408
-
409
374
  function isRecord(value) {
410
375
  return value !== null && typeof value === "object" && !Array.isArray(value)
411
376
  }
412
377
 
413
- function loadBreakerState(file) {
414
- if (!existsSync(file)) return defaultBreakerState()
415
- try {
416
- const state = JSON.parse(readFileSync(file, "utf8"))
417
- const finiteOrNull = (value) => value === undefined || value === null || Number.isFinite(value)
418
- const stringOrNull = (value) => value === undefined || value === null || typeof value === "string"
419
- if (
420
- !isRecord(state) ||
421
- (state.failures !== undefined && !isRecord(state.failures)) ||
422
- (state.reflectionPending !== undefined && typeof state.reflectionPending !== "boolean") ||
423
- !finiteOrNull(state.lastReflection) ||
424
- !finiteOrNull(state.reflectionRequestedAt) ||
425
- !stringOrNull(state.lastReflectionSignature) ||
426
- !stringOrNull(state.reflectionToken) ||
427
- !stringOrNull(state.reflectionSignature) ||
428
- Object.values(state.failures || {}).some((entry) =>
429
- !isRecord(entry) ||
430
- (entry.count !== undefined && (!Number.isInteger(entry.count) || entry.count < 0)) ||
431
- !finiteOrNull(entry.firstSeen) ||
432
- !finiteOrNull(entry.lastSeen)
433
- )
434
- ) throw new Error("invalid breaker state shape")
435
- return normalizeBreakerState(state)
436
- } catch {
437
- console.warn(`Harness: ignoring corrupt circuit-breaker state at "${file}" and starting fresh.`)
438
- return defaultBreakerState()
439
- }
440
- }
441
-
442
- const REFLECTION_FILE = "zoom-out-report.md"
443
- const REFLECTION_SECTIONS = ["## Goal", "## Failed Attempts", "## Verified Facts", "## Diagnosis", "## Decision"]
444
-
445
- function reflectionReportPath(stateDir) {
446
- return join(stateDir, REFLECTION_FILE)
447
- }
448
-
449
- function isValidReflection(reportFile, breaker) {
450
- if (!breaker.reflectionPending || !breaker.reflectionToken || !existsSync(reportFile)) return false
451
- try {
452
- const report = readFileSync(reportFile, "utf8")
453
- const lines = report.split(/\r?\n/)
454
- const sectionIndexes = new Map(
455
- lines.map((line, index) => [line.trim(), index]).filter(([line]) => REFLECTION_SECTIONS.includes(line)),
456
- )
457
- if (!REFLECTION_SECTIONS.every((section) => sectionIndexes.has(section))) return false
458
- const decisionStart = sectionIndexes.get("## Decision") + 1
459
- const nextHeading = lines.findIndex((line, index) => index >= decisionStart && /^##\s+/.test(line.trim()))
460
- const decisionLines = lines.slice(decisionStart, nextHeading === -1 ? lines.length : nextHeading)
461
- const firstDecisionLine = decisionLines.find((line) => line.trim().length > 0)
462
- return !!firstDecisionLine && /^(?:RESUME|ESCALATE)\s*:/i.test(firstDecisionLine.trim()) &&
463
- report.includes(`Reflection token: ${breaker.reflectionToken}`)
464
- } catch {
465
- return false
466
- }
467
- }
468
-
469
- function completeReflection(breakerFile, reportFile) {
470
- const breaker = loadBreakerState(breakerFile)
471
- if (!isValidReflection(reportFile, breaker)) return false
472
- const completedAt = Math.max(Date.now(), (breaker.reflectionRequestedAt || 0) + 1)
473
- breaker.lastReflection = completedAt
474
- breaker.lastReflectionSignature = breaker.reflectionSignature
475
- if (breaker.reflectionSignature && breaker.failures[breaker.reflectionSignature]) {
476
- breaker.failures[breaker.reflectionSignature].count = 0
477
- breaker.failures[breaker.reflectionSignature].firstSeen = completedAt
478
- breaker.failures[breaker.reflectionSignature].lastSeen = completedAt
479
- }
480
- breaker.reflectionPending = false
481
- breaker.reflectionRequestedAt = null
482
- breaker.reflectionToken = null
483
- breaker.reflectionSignature = null
484
- saveJSON(breakerFile, breaker)
485
- return true
486
- }
487
-
488
378
  function defaultCompliance() {
489
379
  return {
490
380
  sessionStart: Date.now(),
491
381
  totalEdits: 0,
492
382
  verifiedEdits: 0,
493
- circuitBreakerTrips: 0,
494
- reflectionsForced: 0,
495
- }
496
- }
497
-
498
- // Test-level evidence of an actual failing check, in line order: TAP, Node
499
- // test-runner symbols, Jest test blocks, indented Mocha numbering, and
500
- // assertion/error lines (which may also be indented). `✖ failing tests:`
501
- // (the node:test summary header) is skipped in favor of the specific test
502
- // line that follows it, and Jest's `● Console` section is not failure
503
- // evidence: neither the heading nor its indented payload (logged output,
504
- // including deeper-indented lines beginning with "●") becomes a marker.
505
- const FAILURE_MARKER_PATTERNS = [/^not ok\b.*$/m, /^\s*[✖✕]\s*(?!\s*failing\b).+$/m, /^\s*●\s+(?!Console\b|Test suite failed to run\b|Validation Error\b).+$/m, /^[ \t]*\d+\)[ \t]+.+$/m, /^[ \t]*[A-Za-z]*Error\b.*$/m];
506
-
507
- // Suite/file-level context, never an identity on its own: Jest prints
508
- // `FAIL <file>` (or `● Test suite failed to run`) above the failing test
509
- // blocks, so different tests in one file would otherwise share a signature.
510
- // A context line is carried into the signature only when a test-level marker
511
- // follows it; without one, the full-evidence digest decides.
512
- const CONTEXT_MARKER_PATTERNS = [/^FAIL\b.*$/m, /^\s*●\s+(?:Test suite failed to run|Validation Error)\b.*$/m];
513
-
514
- function normalizeFailureLine(line) {
515
- let text = String(line || "").replace(/\s+/g, " ").trim();
516
- text = text.replace(/\s*\(\d+(?:\.\d+)?\s*m?s\)\s*$/, ""); // runner timing suffixes
517
- text = text.replace(/^not ok \d+\b/, "not ok"); // TAP plan numbering
518
- return text.slice(0, 160);
519
- }
520
-
521
- function firstFailureMarker(text) {
522
- const lines = String(text || "").replace(/\u001b\[[0-9;]*m/g, "").split(/\r?\n/);
523
- let context = null;
524
- let consoleIndent = null;
525
- for (const line of lines) {
526
- const bullet = /^([ \t]*)●[ \t]+/.exec(line);
527
- if (consoleIndent !== null) {
528
- // Jest's Console block contains indented log payloads, which may
529
- // themselves begin with "●". Only a peer/parent section bullet or a
530
- // non-indented line may end the block; deeper bullets remain data.
531
- if (bullet) {
532
- if (bullet[1].length > consoleIndent) continue;
533
- consoleIndent = null;
534
- } else if (line.trim() === "" || /^[ \t]/.test(line)) {
535
- continue;
536
- } else {
537
- consoleIndent = null;
538
- }
539
- }
540
- if (bullet && /^Console\b/.test(line.slice(bullet[0].length))) {
541
- consoleIndent = bullet[1].length;
542
- continue;
543
- }
544
- if (FAILURE_MARKER_PATTERNS.some((pattern) => pattern.test(line))) {
545
- const normalized = normalizeFailureLine(line);
546
- if (normalized) return context ? `${context}: ${normalized}` : normalized;
547
- }
548
- if (CONTEXT_MARKER_PATTERNS.some((pattern) => pattern.test(line))) {
549
- const normalized = normalizeFailureLine(line);
550
- if (normalized) context = normalized;
551
- }
552
383
  }
553
- return null;
554
- }
555
-
556
- // A stable, normalized signature: command + outcome + exit condition + the
557
- // first test-level failing marker (with a suite/file context line when the
558
- // runner printed one). Without a test-level marker the signature falls back
559
- // to a digest of the complete streams (stdout and stderr both), so
560
- // suite-header-only or banner-only prefixes from *different* failures can
561
- // never collide (identical byte-for-byte evidence still matches, which is
562
- // the honest reading: the same observation repeated). The user-visible
563
- // `error` is a bounded diagnostic and is only the legacy fallback when no incremental
564
- // identity was supplied.
565
- function buildFailureSignature(result) {
566
- const evidence = String((result && (result.evidence || result.error)) || "");
567
- const marker = result && Object.hasOwn(result, "failureMarker") ? result.failureMarker : firstFailureMarker(evidence);
568
- const exit =
569
- result && Number.isInteger(result.exitCode) ? `exit=${result.exitCode}`
570
- : result && result.signal ? `signal=${result.signal}`
571
- : "exit=unknown";
572
- const base = `${(result && result.command) || "verification"} [${(result && result.outcome) || "unknown"}] ${exit}`;
573
- if (marker) return `${base}: ${marker}`;
574
- const digest = result && result.evidenceDigest || createHash("sha256").update(evidence.replace(/\s+/g, " ").trim()).digest("hex").slice(0, 16);
575
- return `${base}: unrecognized-output ${digest}`;
576
384
  }
577
385
 
578
386
  function getAvailableScripts(cwd) {
@@ -587,15 +395,12 @@ function getAvailableScripts(cwd) {
587
395
 
588
396
  // Verification budget for the npm scripts run on session.idle. The Harness
589
397
  // self-regression suite needs ~2 minutes on a laptop, so the original 60s cap
590
- // killed healthy runs and reported them as failures (same truncated stdout as
591
- // the failure signature, three times in a row -> forced reflection).
592
- // One wall-clock budget covers the sequence. Output is consumed as it arrives;
593
- // only bounded excerpts/line prefixes remain in memory, while all bytes feed
594
- // incremental failure evidence. The manual verification CLI remains separate.
398
+ // killed healthy runs and reported them as failures. One wall-clock budget
399
+ // covers the sequence. Output is consumed as it arrives and only bounded
400
+ // excerpts remain in memory. The manual verification CLI remains separate.
595
401
  const VERIFY_TIMEOUT_ENV = "HARNESS_VERIFY_TIMEOUT_MS"
596
402
  const DEFAULT_VERIFY_TIMEOUT_MS = 600000
597
403
  const VERIFY_OUTPUT_LIMIT = 2000
598
- const VERIFY_LINE_LIMIT = 4096
599
404
  const VERIFY_KILL_GRACE_MS = 150
600
405
 
601
406
  function verifyTimeoutMs() {
@@ -603,74 +408,23 @@ function verifyTimeoutMs() {
603
408
  return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_VERIFY_TIMEOUT_MS
604
409
  }
605
410
 
606
- // Consume every chunk without retaining an unbounded transcript. Marker
607
- // state is per stream, so asynchronous stdout/stderr interleaving does not
608
- // change identity. An overlong line keeps its prefix for marker recognition;
609
- // its complete contents still contribute to the digest.
411
+ // Keep bounded diagnostic excerpts while consuming the complete streams.
610
412
  function createVerificationCapture() {
611
- const hash = createHash("sha256")
612
- let head = "", tail = "", length = 0, bytes = 0, line = "", context = null, consoleIndent = null
613
- let marker = null, markerContext = null, pendingSpace = false, hashedText = false, lineTruncated = false, unsafeIdentity = false
614
- function consumeLine(value, truncated) {
615
- if (marker) return
616
- const clean = value.replace(/\u001b\[[0-9;]*m/g, "")
617
- const bullet = /^([ \t]*)●[ \t]+/.exec(clean)
618
- if (consoleIndent !== null) {
619
- if (bullet) {
620
- if (bullet[1].length > consoleIndent) return
621
- consoleIndent = null
622
- } else if (clean.trim() === "" || /^[ \t]/.test(clean)) return
623
- else consoleIndent = null
624
- }
625
- if (bullet && /^Console\b/.test(clean.slice(bullet[0].length))) {
626
- consoleIndent = bullet[1].length
627
- return
628
- }
629
- // A clipped marker or suite name cannot identify a check safely. A long
630
- // ordinary progress/banner line need not discard a later complete marker.
631
- if (truncated && (clean.trim() === "" || /^\u001b\[[0-9;]*$/.test(clean)
632
- || [...FAILURE_MARKER_PATTERNS, ...CONTEXT_MARKER_PATTERNS].some(pattern => pattern.test(clean)))) {
633
- unsafeIdentity = true
634
- return
635
- }
636
- if (FAILURE_MARKER_PATTERNS.some(pattern => pattern.test(clean))) {
637
- marker = normalizeFailureLine(clean)
638
- markerContext = context
639
- } else if (CONTEXT_MARKER_PATTERNS.some(pattern => pattern.test(clean))) context = normalizeFailureLine(clean)
640
- }
413
+ let head = "", tail = "", length = 0, bytes = 0
641
414
  return {
642
415
  write(chunk) {
643
416
  const text = String(chunk)
644
417
  bytes += Buffer.byteLength(text)
645
418
  length += text.length
646
- if (head.length < VERIFY_OUTPUT_LIMIT) head += text.slice(0, VERIFY_OUTPUT_LIMIT-head.length)
419
+ if (head.length < VERIFY_OUTPUT_LIMIT) head += text.slice(0, VERIFY_OUTPUT_LIMIT - head.length)
647
420
  tail = (tail + text).slice(-VERIFY_OUTPUT_LIMIT)
648
- for (const part of text.split(/(\s+)/)) {
649
- if (!part) continue
650
- if (/^\s+$/.test(part)) pendingSpace = hashedText
651
- else {
652
- if (pendingSpace) hash.update(" ")
653
- hash.update(part)
654
- pendingSpace = false
655
- hashedText = true
656
- }
657
- }
658
- for (const [index, part] of text.split("\n").entries()) {
659
- if (index > 0) { consumeLine(line, lineTruncated); line = ""; lineTruncated = false }
660
- if (line.length + part.length > VERIFY_LINE_LIMIT) lineTruncated = true
661
- if (line.length < VERIFY_LINE_LIMIT) line += part.slice(0, VERIFY_LINE_LIMIT-line.length)
662
- }
663
421
  },
664
422
  excerpt(limit) {
665
423
  if (length <= limit) return head.slice(0, length)
666
- const half = Math.floor(limit/2)
667
- return `${head.slice(0, half)}\n... [${length-half*2} chars omitted] ...\n${tail.slice(-half)}`
424
+ const half = Math.floor(limit / 2)
425
+ return `${head.slice(0, half)}\n... [${length - half * 2} chars omitted] ...\n${tail.slice(-half)}`
668
426
  },
669
427
  get bytes() { return bytes },
670
- finish() {
671
- consumeLine(line, lineTruncated)
672
- return { digest: hash.digest("hex"), marker, markerContext, context, unsafeIdentity }
673
- },
674
428
  }
675
429
  }
676
430
 
@@ -711,7 +465,6 @@ function runVerificationCommand(cwd, command, remainingMs, signal, onProgress) {
711
465
  clearInterval(progressTimer)
712
466
  signal?.removeEventListener("abort", abort)
713
467
  if (termination) await termination
714
- const out = stdout.finish(), err = stderr.finish()
715
468
  const both = stdout.bytes > 0 && stderr.bytes > 0
716
469
  const errorOutput = both
717
470
  ? `stdout:\n${stdout.excerpt(VERIFY_OUTPUT_LIMIT/2)}\nstderr:\n${stderr.excerpt(VERIFY_OUTPUT_LIMIT/2)}`
@@ -725,12 +478,6 @@ function runVerificationCommand(cwd, command, remainingMs, signal, onProgress) {
725
478
  else if (outcome === "execution_error") result.error = `could not run to completion (execution error: ${cancelled ? "cancelled" : spawnError?.code || (childSignal ? `signal ${childSignal}` : "no exit status")}); output: ${errorOutput || spawnError?.message || "(none)"}`
726
479
  else result.error = errorOutput || `command exited ${exitCode}`
727
480
  }
728
- if (outcome === "test_failure") {
729
- result.failureMarker = out.unsafeIdentity || err.unsafeIdentity ? null : out.marker
730
- ? (out.markerContext ? `${out.markerContext}: ${out.marker}` : out.marker)
731
- : err.marker ? `${err.markerContext || out.context ? `${err.markerContext || out.context}: ` : ""}${err.marker}` : null
732
- result.evidenceDigest = createHash("sha256").update(`stdout:${out.digest}\nstderr:${err.digest}`).digest("hex").slice(0, 16)
733
- }
734
481
  resolveCommand(result)
735
482
  }
736
483
  if (signal?.aborted) {
@@ -788,36 +535,6 @@ async function runVerification(cwd, { signal, onProgress } = {}) {
788
535
  return { allPassed: !signal?.aborted && results.every(result => result.success), skipped: false, results }
789
536
  }
790
537
 
791
- /**
792
- * Records a verification failure against the circuit breaker and returns the
793
- * action to take: allow (with retries remaining) or force_reflection on the
794
- * third matching failure. Completing reflection resets that signature's count.
795
- */
796
- function tripBreaker(breakerFile, signature) {
797
- const breaker = loadBreakerState(breakerFile)
798
-
799
- if (!breaker.failures[signature]) {
800
- breaker.failures[signature] = { count: 0, firstSeen: Date.now() }
801
- }
802
- const entry = breaker.failures[signature]
803
- entry.count++
804
- entry.lastSeen = Date.now()
805
-
806
- if (entry.count >= 3) {
807
- if (!breaker.reflectionPending) {
808
- breaker.reflectionPending = true
809
- breaker.reflectionRequestedAt = Date.now()
810
- breaker.reflectionToken = randomUUID().replace(/-/g, "")
811
- breaker.reflectionSignature = signature
812
- }
813
- saveJSON(breakerFile, breaker)
814
- return { action: "force_reflection", count: entry.count, reflectionToken: breaker.reflectionToken }
815
- }
816
-
817
- saveJSON(breakerFile, breaker)
818
- return { action: "allow", count: entry.count, remaining: 3 - entry.count }
819
- }
820
-
821
538
  function recordCompliance(complianceFile, mutate) {
822
539
  const compliance = loadJSON(complianceFile, defaultCompliance())
823
540
  mutate(compliance)
@@ -1048,9 +765,7 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
1048
765
  return {
1049
766
  stateDir,
1050
767
  editStateFile: join(stateDir, "edit-state.json"),
1051
- breakerFile: join(stateDir, "circuit-breaker.json"),
1052
768
  complianceFile: join(stateDir, "compliance.json"),
1053
- reflectionFile: reflectionReportPath(stateDir),
1054
769
  }
1055
770
  }
1056
771
 
@@ -1112,55 +827,16 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
1112
827
  try { rmSync(stateDir, { recursive: true, force: true }) } catch { /* fail open */ }
1113
828
  }
1114
829
 
1115
- function toolTarget(input, output) {
1116
- const args = { ...((output && output.args) || {}), ...((input && input.args) || {}) }
1117
- return args.filePath || args.file_path || args.path || args.filename || args.file || null
1118
- }
1119
-
1120
- function patchTargets(input, output) {
1121
- const args = { ...((output && output.args) || {}), ...((input && input.args) || {}) }
1122
- if (typeof args.patchText !== "string") return []
1123
- return [...args.patchText.matchAll(/^\*\*\*\s+(?:(?:Add|Update|Delete) File|Move to):[ \t]*([^\r\n]+)$/gm)]
1124
- .map((match) => match[1].trim())
1125
- }
1126
-
1127
- function isReflectionWrite(input, output, reportFile) {
1128
- if (!EDIT_TOOLS.has(input.tool)) return false
1129
- if (input.tool === "apply_patch") {
1130
- const targets = patchTargets(input, output)
1131
- return targets.length > 0 && targets.every((patchTarget) => samePath(resolve(workspace, patchTarget), reportFile))
1132
- }
1133
- const target = toolTarget(input, output)
1134
- return Boolean(target && samePath(resolve(workspace, target), reportFile))
1135
- }
1136
-
1137
830
  return {
1138
- "tool.execute.before": async (input, output) => {
831
+ "tool.execute.before": async input => {
1139
832
  telemetryBefore(input)
1140
- if (!EDIT_TOOLS.has(input.tool)) return
1141
- const { breakerFile, reflectionFile } = pathsFor(input.sessionID)
1142
- const breaker = loadBreakerState(breakerFile)
1143
- if (breaker.reflectionPending && !isReflectionWrite(input, output, reflectionFile)) {
1144
- throw new Error(
1145
- `Harness reflection is required before another code edit. ` +
1146
- `Write a valid reflection report to "${reflectionFile}" first.`,
1147
- )
1148
- }
1149
833
  },
1150
834
 
1151
835
  "tool.execute.after": async (input, output) => {
1152
836
  telemetryAfter(input)
1153
837
  recordHostCapture(input, output)
1154
838
  if (!EDIT_TOOLS.has(input.tool)) return
1155
- const { editStateFile, breakerFile, complianceFile, reflectionFile } = pathsFor(input.sessionID)
1156
-
1157
- // The reflection artifact is a protocol write, not a code edit. It is
1158
- // accepted only when it contains the current token and all required
1159
- // sections; this is the only path that records lastReflection.
1160
- if (isReflectionWrite(input, output, reflectionFile)) {
1161
- completeReflection(breakerFile, reflectionFile)
1162
- return
1163
- }
839
+ const { editStateFile, complianceFile } = pathsFor(input.sessionID)
1164
840
 
1165
841
  const state = normalizeEditState(loadJSON(editStateFile, defaultEditState()))
1166
842
  activeVerifications.get(input.sessionID || "default")?.abort()
@@ -1206,10 +882,7 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
1206
882
  controller.finished = new Promise(resolveFinished => { finishVerification = resolveFinished })
1207
883
  activeVerifications.set(activeSession, controller)
1208
884
  try {
1209
- const { editStateFile, breakerFile, complianceFile, reflectionFile } = pathsFor(activeSession)
1210
- // This fallback makes the lifecycle complete even if the host omits
1211
- // tool input args on the artifact's after hook.
1212
- completeReflection(breakerFile, reflectionFile)
885
+ const { editStateFile, complianceFile } = pathsFor(activeSession)
1213
886
 
1214
887
  const state = normalizeEditState(loadJSON(editStateFile, defaultEditState()))
1215
888
  if (state.followUpPending) return
@@ -1264,38 +937,19 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
1264
937
 
1265
938
  let text
1266
939
  if (!confirmed) {
1267
- // Timeout or execution error: no check produced a verdict, so this
1268
- // must not advance the same-check Rule-of-3 counter. Report it as an
1269
- // uncompleted verification and stay honest about what is unknown.
940
+ // Timeout or execution error: no check produced a verdict.
1270
941
  const detail =
1271
942
  primary.outcome === "timeout"
1272
943
  ? `timed out (budget ${Math.round(verifyTimeoutMs() / 1000)}s; set ${VERIFY_TIMEOUT_ENV} to raise it)`
1273
944
  : "could not run to completion (execution error, not a confirmed test failure)"
1274
945
  text =
1275
946
  `Harness: verification did not complete - "${primary.command}" ${detail}. ` +
1276
- `No failing check was confirmed, so this does NOT count toward the repeated-failure reflection. ` +
1277
947
  `Diagnostics: ${primary.error || "(no output captured)"}. ` +
1278
948
  `Fix the cause (or raise the budget) and verify again; a new edit re-runs verification.`
1279
949
  } else {
1280
- const signature = buildFailureSignature(confirmed)
1281
- const trip = tripBreaker(breakerFile, signature)
1282
- if (trip.action === "force_reflection") {
1283
- const { stateDir } = pathsFor(activeSession)
1284
- text =
1285
- `Harness: "${confirmed.command}" has now failed 3 times with the same error. Stop and reflect ` +
1286
- `before retrying. Write a report to "${reflectionReportPath(stateDir)}" with sections ` +
1287
- `## Goal, ## Failed Attempts, ## Verified Facts, ## Diagnosis, and ## Decision. ` +
1288
- `The Decision must begin with RESUME: or ESCALATE:. Include reflection token: ${trip.reflectionToken}. ` +
1289
- `After the report is recorded, resume with a different approach. Failure: ${confirmed.error || "(no output captured)"}`
1290
- recordCompliance(complianceFile, (c) => {
1291
- c.circuitBreakerTrips++
1292
- c.reflectionsForced++
1293
- })
1294
- } else {
1295
- text =
1296
- `Harness: verification failed (${trip.remaining} retries before a forced reflection). ` +
1297
- `"${confirmed.command}" - ${confirmed.error || "(no output captured)"}. Fix it and this will re-run automatically.`
1298
- }
950
+ text =
951
+ `Harness: verification failed - "${confirmed.command}" - ${confirmed.error || "(no output captured)"}. ` +
952
+ `Review the result, address the cause, and verify again.`
1299
953
  }
1300
954
 
1301
955
  try {
@@ -1303,8 +957,7 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
1303
957
  } catch (error) {
1304
958
  if (controller.signal.aborted) return
1305
959
  // A failed delivery is retryable on the next idle event, but the
1306
- // saved message means retrying does not run verification again or
1307
- // increment the circuit-breaker count.
960
+ // saved message means retrying does not run verification again.
1308
961
  const failedState = normalizeEditState(loadJSON(editStateFile, defaultEditState()))
1309
962
  failedState.followUpPending = false
1310
963
  failedState.followUpDeliveryPending = true
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-enforcement",
3
3
  "description": "Repository inventory for the opencode enforcement plugin and its standalone helper",
4
- "version": "0.55.3",
4
+ "version": "0.55.4",
5
5
  "runtime": "index.mjs",
6
6
  "hooks": {
7
7
  "verify": "hooks/verify.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "0.55.3",
3
+ "version": "0.55.4",
4
4
  "description": "Harness OS: An Orchestrated Agent Operating System for AI-driven Development",
5
5
  "main": "harness-everything/scripts/bootstrap.js",
6
6
  "bin": {
@@ -50,13 +50,10 @@
50
50
  "eval:behavioral": "node behavioral-evals/run.js run",
51
51
  "eval:behavioral:validate": "node behavioral-evals/run.js validate",
52
52
  "eval:behavioral:plugin": "node behavioral-evals/run-with-plugin.js run",
53
- "eval:opencode:reflection-gate-live": "node behavioral-evals/opencode-reflection-gate-live.js run",
54
- "eval:opencode:hardlock-live": "node behavioral-evals/opencode-reflection-gate-live.js run",
55
53
  "eval:paired": "node behavioral-evals/paired-benchmark.js run",
56
54
  "eval:paired:summarize": "node behavioral-evals/paired-benchmark.js summarize",
57
55
  "test:ab": "node ci/ab-test-harness.js validate",
58
56
  "test:ab:run": "node ci/ab-test-harness.js run",
59
- "harness:reset": "node hooks/scripts/reset-circuit-breaker.js",
60
57
  "prepare": "husky install",
61
58
  "commitlint": "commitlint --edit",
62
59
  "test:telemetry": "node ci/telemetry.test.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "0.55.3",
3
+ "version": "0.55.4",
4
4
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
5
5
  "author": {
6
6
  "name": "Miya Daniel",
@@ -64,13 +64,6 @@
64
64
  "timeout": 15,
65
65
  "statusMessage": "Checking Harness pre-action approval gate"
66
66
  },
67
- {
68
- "type": "command",
69
- "command": "node \"${PLUGIN_ROOT}/hooks/scripts/rule-of-3.js\"",
70
- "commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\rule-of-3.js\"",
71
- "timeout": 15,
72
- "statusMessage": "Checking Harness circuit breaker"
73
- },
74
67
  {
75
68
  "type": "command",
76
69
  "command": "node \"${PLUGIN_ROOT}/hooks/scripts/context-compact.js\"",
@@ -141,13 +134,6 @@
141
134
  "timeout": 15,
142
135
  "statusMessage": "Recording Harness action-gate execution outcome"
143
136
  },
144
- {
145
- "type": "command",
146
- "command": "node \"${PLUGIN_ROOT}/hooks/scripts/rule-of-3-tracker.js\" --codex",
147
- "commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\rule-of-3-tracker.js\" --codex",
148
- "timeout": 15,
149
- "statusMessage": "Recording Harness failure evidence"
150
- },
151
137
  {
152
138
  "type": "command",
153
139
  "command": "node \"${PLUGIN_ROOT}/hooks/scripts/state-persist.js\" --codex",
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- // Shared path resolution for Harness runtime state (hook JSON, circuit-breaker
3
- // counters, handoff/verification timestamps, etc).
2
+ // Shared path resolution for Harness runtime state (hook JSON,
3
+ // handoff/verification timestamps, etc).
4
4
  //
5
5
  // Lives under a single user-global root - `getWorkspaceStateDir()` from
6
6
  // scripts/lib/workspace.js, i.e. `~/.agents/harness-everything/workspaces/
@@ -17,8 +17,8 @@
17
17
  // workspace, once, the first time that workspace is seen again.
18
18
  //
19
19
  // Session state keys under `sessions/<id>/` so two sessions open on the same
20
- // workspace never share (and stomp) each other's edit/verify timestamps or
21
- // breaker counts. Invocations with no session_id (manual terminal runs,
20
+ // workspace never share (and stomp) each other's edit/verify timestamps.
21
+ // Invocations with no session_id (manual terminal runs,
22
22
  // VERIFICATION.md recipes) fall into a fixed `sessions/default/` bucket
23
23
  // rather than a random one, so manual testing stays predictable.
24
24
  const fs = require('fs');
@@ -229,8 +229,7 @@ function writeCurrentSession(root, sessionId) {
229
229
  fs.mkdirSync(stateRoot, { recursive: true });
230
230
  fs.writeFileSync(path.join(stateRoot, CURRENT_SESSION_FILE), sessionId, 'utf8');
231
231
  } catch (err) {
232
- // Best-effort - only the manual reset-circuit-breaker.js escape hatch
233
- // depends on this, and it fails open too.
232
+ // Session binding is best effort; state pointer failure must not break startup.
234
233
  }
235
234
  }
236
235