harness-everything 0.55.2 → 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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +1 -1
- package/BENCHMARK_SOP.md +2 -2
- package/CHANGELOG.md +22 -0
- package/README.md +15 -16
- package/SECURITY.md +1 -1
- package/VERIFICATION.md +4 -8
- package/behavioral-evals/PAIRED-BENCHMARK.md +12 -27
- package/behavioral-evals/README.md +21 -65
- package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +26 -33
- package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +15 -17
- package/behavioral-evals/paired-benchmark.js +3 -40
- package/behavioral-evals/run.js +2 -3
- package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
- package/ci/invariant-routing.test.js +32 -6
- package/ci/lib/opencode-verification-loader.js +3 -5
- package/ci/mechanism-2a-rule-of-3.test.js +111 -97
- package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
- package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
- package/ci/mechanism-32-paired-benchmark.test.js +1 -2
- package/ci/mechanism-33-issues-205-207.test.js +1 -1
- package/ci/mechanism-338-opencode-async.test.js +18 -49
- package/ci/mechanism-36-verify-timeout.test.js +3 -189
- package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
- package/ci/mechanism-397-opencode-observations.test.js +64 -9
- package/ci/mechanism-check-packet-write-set.test.js +163 -8
- package/ci/mechanism-codex-hook-results.test.js +9 -5
- package/ci/mechanism-prb-outline-review.test.js +1 -13
- package/ci/mechanism-system-one-router.test.js +1 -1
- package/ci/openai-plugin-package.test.js +30 -7
- package/ci/openai-plugin-runtime.test.js +64 -32
- package/ci/prompt-contract-regressions.test.js +1 -5
- package/ci/router-workflow-plan.test.js +8 -8
- package/ci/self-evolve-loop.test.js +51 -51
- package/ci/workflow-execution-contract.test.js +3 -6
- package/code-review/SKILL.md +1 -1
- package/code-review/templates/finding.template.md +17 -1
- package/docker-verify.sh +1 -117
- package/docs/architecture.md +9 -7
- package/docs/document-lifecycle.md +1 -1
- package/docs/enforcement-locks.md +12 -10
- package/docs/mechanism-first-skill-mesh.md +2 -2
- package/docs/openai-plugin.md +3 -3
- package/docs/philosophy.md +1 -1
- package/docs/platform-capabilities.md +4 -3
- package/docs/platform-compatibility.json +2 -2
- package/docs/reflection.md +1 -1
- package/docs/routing.md +2 -2
- package/docs/system-one-suggestion-gates.md +4 -4
- package/docs/troubleshooting.md +9 -35
- package/docs/workflow-runtime.md +19 -18
- package/docs/workflows/environment-detection.md +11 -9
- package/docs/workflows/fable-discipline.md +6 -5
- package/docs/workflows/fable-mode.md +6 -5
- package/docs/workflows/harness-everything.md +5 -5
- package/docs/workflows/improve-codebase-architecture.md +10 -8
- package/docs/workflows/install-cognitive-os.md +5 -5
- package/docs/workflows/tdd.md +9 -9
- package/docs/workflows/zoom-out.md +20 -30
- package/environment-detection/SKILL.md +2 -2
- package/environment-detection/references/shell-syntax-rules.md +1 -1
- package/eval-harness/SKILL.md +1 -1
- package/eval-harness/references/scoring-rubric.md +3 -3
- package/evals/zoom-out/eval.yaml +2 -2
- package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
- package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
- package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
- package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
- package/fable-discipline/SKILL.md +3 -3
- package/fable-discipline/references/discipline-rules.md +1 -1
- package/fable-mode/SKILL.md +1 -1
- package/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/fable-mode/fable-haiku/SKILL.md +1 -1
- package/fable-mode/fable-opus/SKILL.md +2 -2
- package/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/fable-mode/references/execution-phases.md +2 -2
- package/harness-everything/SKILL.md +3 -3
- package/harness-everything/references/router-workflow-plan.md +2 -2
- package/harness-everything/references/skill-registry.md +2 -2
- package/harness-everything/references/triage-and-tiers.md +5 -5
- package/harness-everything/scripts/bootstrap.js +1 -26
- package/harness-everything/scripts/kernel-router-core.js +2 -3
- package/harness-everything/scripts/kernel-router.js +1 -1
- package/harness-everything/scripts/router-contract-core.js +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/hooks/hooks.json +0 -33
- package/hooks/scripts/lib/harness-state.js +5 -6
- package/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/hooks/scripts/openai-session-start.js +2 -4
- package/improve-codebase-architecture/SKILL.md +3 -3
- package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/install-cognitive-os/SKILL.md +3 -3
- package/opencode-plugin/README.md +18 -43
- package/opencode-plugin/index.mjs +52 -380
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -4
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/hooks.json +0 -14
- package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
- package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
- package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
- package/plugins/harness-everything/hooks/session-start.js +2 -4
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
- package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
- package/plugins/harness-everything/skills/code-review/SKILL.md +1 -1
- package/plugins/harness-everything/skills/code-review/templates/finding.template.md +17 -1
- package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
- package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
- package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
- package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
- package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
- package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
- package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
- package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
- package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
- package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
- package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
- package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
- package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
- package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
- package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
- package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
- package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
- package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
- package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
- package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
- package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
- package/references/platform-advisory-template.md +3 -9
- package/sbom.cdx.json +7 -7
- package/scripts/check-packet-write-set.js +76 -1
- package/scripts/lib/advisory-text.js +2 -2
- package/scripts/lib/workspace.js +2 -2
- package/self-evolve/SKILL.md +1 -1
- package/self-evolve/references/memory-resolution.md +3 -3
- package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
- package/self-evolve/scripts/lesson-candidate.js +1 -0
- package/skill-creator/SKILL.md +1 -1
- package/skill-creator/references/quality-checklist.md +1 -1
- package/skill-creator/references/quality-principles.md +4 -4
- package/submission/openai/test-cases.json +5 -5
- package/tdd/SKILL.md +2 -2
- package/tdd/references/core-discipline.md +3 -5
- package/todo-driven-workflow/SKILL.md +2 -2
- package/zoom-out/SKILL.md +14 -26
- package/zoom-out/references/circuit-breaker.md +18 -62
- package/behavioral-evals/opencode-hardlock-live.js +0 -17
- package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
- package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
- package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
- package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
- package/hooks/scripts/reset-circuit-breaker.js +0 -30
- package/hooks/scripts/rule-of-3-tracker.js +0 -165
- package/hooks/scripts/rule-of-3.js +0 -171
- package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
- package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
- 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
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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"
|
|
@@ -89,11 +78,15 @@ function harnessRuntime() {
|
|
|
89
78
|
return process.versions.bun ? "node" : process.execPath
|
|
90
79
|
}
|
|
91
80
|
|
|
92
|
-
function runKernelRouter(payload, signal) {
|
|
93
|
-
if (
|
|
81
|
+
function runKernelRouter(payload, signal, unavailable) {
|
|
82
|
+
if (signal?.aborted) return Promise.resolve(null)
|
|
83
|
+
if (!ROUTER_FILE) {
|
|
84
|
+
unavailable("runtime-missing")
|
|
85
|
+
return Promise.resolve(null)
|
|
86
|
+
}
|
|
94
87
|
return new Promise(resolveOutput => {
|
|
95
88
|
let stdout = ""
|
|
96
|
-
let child, timeout, termination,
|
|
89
|
+
let child, timeout, termination, failureReason, timedOut = false, settled = false
|
|
97
90
|
const terminate = () => {
|
|
98
91
|
if (!termination && child) termination = terminateVerificationChild(child)
|
|
99
92
|
}
|
|
@@ -101,11 +94,19 @@ function runKernelRouter(payload, signal) {
|
|
|
101
94
|
if (settled) return
|
|
102
95
|
settled = true
|
|
103
96
|
clearTimeout(timeout)
|
|
104
|
-
signal?.removeEventListener("abort",
|
|
97
|
+
signal?.removeEventListener("abort", terminate)
|
|
105
98
|
if (termination) await termination
|
|
106
|
-
|
|
99
|
+
if (signal?.aborted || timedOut) {
|
|
100
|
+
resolveOutput(null)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
if (failureReason || code !== 0) {
|
|
104
|
+
unavailable(failureReason || "runtime-failed")
|
|
105
|
+
resolveOutput(null)
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
resolveOutput(stdout.trim())
|
|
107
109
|
}
|
|
108
|
-
const abort = () => { cancelled = true; terminate() }
|
|
109
110
|
try {
|
|
110
111
|
child = spawn(harnessRuntime(), [ROUTER_FILE], {
|
|
111
112
|
cwd: payload.cwd || HARNESS_ROOT,
|
|
@@ -115,21 +116,22 @@ function runKernelRouter(payload, signal) {
|
|
|
115
116
|
windowsHide: true,
|
|
116
117
|
})
|
|
117
118
|
} catch {
|
|
119
|
+
unavailable("spawn-failed")
|
|
118
120
|
resolveOutput(null)
|
|
119
121
|
return
|
|
120
122
|
}
|
|
121
123
|
child.stdout.on("data", chunk => { stdout += chunk })
|
|
122
|
-
child.stdin.on("error", () => {
|
|
124
|
+
child.stdin.on("error", () => { failureReason ||= "runtime-failed"; terminate() })
|
|
123
125
|
child.once("error", () => {
|
|
124
|
-
|
|
126
|
+
failureReason = child.pid ? "runtime-failed" : "spawn-failed"
|
|
125
127
|
if (!child.pid) void finish(null)
|
|
126
128
|
else terminate()
|
|
127
129
|
})
|
|
128
130
|
child.once("close", code => { void finish(code) })
|
|
129
|
-
signal?.addEventListener("abort",
|
|
130
|
-
if (signal?.aborted)
|
|
131
|
+
signal?.addEventListener("abort", terminate, { once: true })
|
|
132
|
+
if (signal?.aborted) terminate()
|
|
131
133
|
timeout = setTimeout(() => { timedOut = true; terminate() }, 5000)
|
|
132
|
-
try { child.stdin.end(JSON.stringify(payload)) } catch {
|
|
134
|
+
try { child.stdin.end(JSON.stringify(payload)) } catch { failureReason ||= "runtime-failed"; terminate() }
|
|
133
135
|
})
|
|
134
136
|
}
|
|
135
137
|
|
|
@@ -261,9 +263,8 @@ function getStateHome() {
|
|
|
261
263
|
|
|
262
264
|
// Keys state per real workspace (`directory`, which opencode itself resolves
|
|
263
265
|
// - never a cwd walk) instead of one flat dir shared by every project on the
|
|
264
|
-
// machine. The pre-fix `~/.harness-state` had no such key at all
|
|
265
|
-
//
|
|
266
|
-
// (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).
|
|
267
268
|
function getWorkspaceKey(directory) {
|
|
268
269
|
let real = resolve(directory)
|
|
269
270
|
try { real = realpathSync(real) } catch { /* directory may not exist yet */ }
|
|
@@ -328,12 +329,6 @@ function isWithin(parent, candidate) {
|
|
|
328
329
|
)
|
|
329
330
|
}
|
|
330
331
|
|
|
331
|
-
function samePath(left, right) {
|
|
332
|
-
const a = resolve(left)
|
|
333
|
-
const b = resolve(right)
|
|
334
|
-
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b
|
|
335
|
-
}
|
|
336
|
-
|
|
337
332
|
function getSessionDir(directory, sessionID) {
|
|
338
333
|
const sessionsRoot = resolve(join(getStateRoot(directory), "sessions"))
|
|
339
334
|
const candidate = resolve(sessionsRoot, getSessionKey(sessionID))
|
|
@@ -372,194 +367,20 @@ function defaultEditState() {
|
|
|
372
367
|
}
|
|
373
368
|
}
|
|
374
369
|
|
|
375
|
-
function defaultBreakerState() {
|
|
376
|
-
return {
|
|
377
|
-
failures: {},
|
|
378
|
-
lastReflection: null,
|
|
379
|
-
lastReflectionSignature: null,
|
|
380
|
-
reflectionPending: false,
|
|
381
|
-
reflectionRequestedAt: null,
|
|
382
|
-
reflectionToken: null,
|
|
383
|
-
reflectionSignature: null,
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
370
|
function normalizeEditState(state) {
|
|
388
371
|
return { ...defaultEditState(), ...(state || {}) }
|
|
389
372
|
}
|
|
390
373
|
|
|
391
|
-
function normalizeBreakerState(state) {
|
|
392
|
-
const { hardLock: _retiredHardLock, ...rest } = state || {}
|
|
393
|
-
return { ...defaultBreakerState(), ...rest, failures: (state && state.failures) || {} }
|
|
394
|
-
}
|
|
395
|
-
|
|
396
374
|
function isRecord(value) {
|
|
397
375
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
398
376
|
}
|
|
399
377
|
|
|
400
|
-
function loadBreakerState(file) {
|
|
401
|
-
if (!existsSync(file)) return defaultBreakerState()
|
|
402
|
-
try {
|
|
403
|
-
const state = JSON.parse(readFileSync(file, "utf8"))
|
|
404
|
-
const finiteOrNull = (value) => value === undefined || value === null || Number.isFinite(value)
|
|
405
|
-
const stringOrNull = (value) => value === undefined || value === null || typeof value === "string"
|
|
406
|
-
if (
|
|
407
|
-
!isRecord(state) ||
|
|
408
|
-
(state.failures !== undefined && !isRecord(state.failures)) ||
|
|
409
|
-
(state.reflectionPending !== undefined && typeof state.reflectionPending !== "boolean") ||
|
|
410
|
-
!finiteOrNull(state.lastReflection) ||
|
|
411
|
-
!finiteOrNull(state.reflectionRequestedAt) ||
|
|
412
|
-
!stringOrNull(state.lastReflectionSignature) ||
|
|
413
|
-
!stringOrNull(state.reflectionToken) ||
|
|
414
|
-
!stringOrNull(state.reflectionSignature) ||
|
|
415
|
-
Object.values(state.failures || {}).some((entry) =>
|
|
416
|
-
!isRecord(entry) ||
|
|
417
|
-
(entry.count !== undefined && (!Number.isInteger(entry.count) || entry.count < 0)) ||
|
|
418
|
-
!finiteOrNull(entry.firstSeen) ||
|
|
419
|
-
!finiteOrNull(entry.lastSeen)
|
|
420
|
-
)
|
|
421
|
-
) throw new Error("invalid breaker state shape")
|
|
422
|
-
return normalizeBreakerState(state)
|
|
423
|
-
} catch {
|
|
424
|
-
console.warn(`Harness: ignoring corrupt circuit-breaker state at "${file}" and starting fresh.`)
|
|
425
|
-
return defaultBreakerState()
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const REFLECTION_FILE = "zoom-out-report.md"
|
|
430
|
-
const REFLECTION_SECTIONS = ["## Goal", "## Failed Attempts", "## Verified Facts", "## Diagnosis", "## Decision"]
|
|
431
|
-
|
|
432
|
-
function reflectionReportPath(stateDir) {
|
|
433
|
-
return join(stateDir, REFLECTION_FILE)
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
function isValidReflection(reportFile, breaker) {
|
|
437
|
-
if (!breaker.reflectionPending || !breaker.reflectionToken || !existsSync(reportFile)) return false
|
|
438
|
-
try {
|
|
439
|
-
const report = readFileSync(reportFile, "utf8")
|
|
440
|
-
const lines = report.split(/\r?\n/)
|
|
441
|
-
const sectionIndexes = new Map(
|
|
442
|
-
lines.map((line, index) => [line.trim(), index]).filter(([line]) => REFLECTION_SECTIONS.includes(line)),
|
|
443
|
-
)
|
|
444
|
-
if (!REFLECTION_SECTIONS.every((section) => sectionIndexes.has(section))) return false
|
|
445
|
-
const decisionStart = sectionIndexes.get("## Decision") + 1
|
|
446
|
-
const nextHeading = lines.findIndex((line, index) => index >= decisionStart && /^##\s+/.test(line.trim()))
|
|
447
|
-
const decisionLines = lines.slice(decisionStart, nextHeading === -1 ? lines.length : nextHeading)
|
|
448
|
-
const firstDecisionLine = decisionLines.find((line) => line.trim().length > 0)
|
|
449
|
-
return !!firstDecisionLine && /^(?:RESUME|ESCALATE)\s*:/i.test(firstDecisionLine.trim()) &&
|
|
450
|
-
report.includes(`Reflection token: ${breaker.reflectionToken}`)
|
|
451
|
-
} catch {
|
|
452
|
-
return false
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function completeReflection(breakerFile, reportFile) {
|
|
457
|
-
const breaker = loadBreakerState(breakerFile)
|
|
458
|
-
if (!isValidReflection(reportFile, breaker)) return false
|
|
459
|
-
const completedAt = Math.max(Date.now(), (breaker.reflectionRequestedAt || 0) + 1)
|
|
460
|
-
breaker.lastReflection = completedAt
|
|
461
|
-
breaker.lastReflectionSignature = breaker.reflectionSignature
|
|
462
|
-
if (breaker.reflectionSignature && breaker.failures[breaker.reflectionSignature]) {
|
|
463
|
-
breaker.failures[breaker.reflectionSignature].count = 0
|
|
464
|
-
breaker.failures[breaker.reflectionSignature].firstSeen = completedAt
|
|
465
|
-
breaker.failures[breaker.reflectionSignature].lastSeen = completedAt
|
|
466
|
-
}
|
|
467
|
-
breaker.reflectionPending = false
|
|
468
|
-
breaker.reflectionRequestedAt = null
|
|
469
|
-
breaker.reflectionToken = null
|
|
470
|
-
breaker.reflectionSignature = null
|
|
471
|
-
saveJSON(breakerFile, breaker)
|
|
472
|
-
return true
|
|
473
|
-
}
|
|
474
|
-
|
|
475
378
|
function defaultCompliance() {
|
|
476
379
|
return {
|
|
477
380
|
sessionStart: Date.now(),
|
|
478
381
|
totalEdits: 0,
|
|
479
382
|
verifiedEdits: 0,
|
|
480
|
-
circuitBreakerTrips: 0,
|
|
481
|
-
reflectionsForced: 0,
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// Test-level evidence of an actual failing check, in line order: TAP, Node
|
|
486
|
-
// test-runner symbols, Jest test blocks, indented Mocha numbering, and
|
|
487
|
-
// assertion/error lines (which may also be indented). `✖ failing tests:`
|
|
488
|
-
// (the node:test summary header) is skipped in favor of the specific test
|
|
489
|
-
// line that follows it, and Jest's `● Console` section is not failure
|
|
490
|
-
// evidence: neither the heading nor its indented payload (logged output,
|
|
491
|
-
// including deeper-indented lines beginning with "●") becomes a marker.
|
|
492
|
-
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];
|
|
493
|
-
|
|
494
|
-
// Suite/file-level context, never an identity on its own: Jest prints
|
|
495
|
-
// `FAIL <file>` (or `● Test suite failed to run`) above the failing test
|
|
496
|
-
// blocks, so different tests in one file would otherwise share a signature.
|
|
497
|
-
// A context line is carried into the signature only when a test-level marker
|
|
498
|
-
// follows it; without one, the full-evidence digest decides.
|
|
499
|
-
const CONTEXT_MARKER_PATTERNS = [/^FAIL\b.*$/m, /^\s*●\s+(?:Test suite failed to run|Validation Error)\b.*$/m];
|
|
500
|
-
|
|
501
|
-
function normalizeFailureLine(line) {
|
|
502
|
-
let text = String(line || "").replace(/\s+/g, " ").trim();
|
|
503
|
-
text = text.replace(/\s*\(\d+(?:\.\d+)?\s*m?s\)\s*$/, ""); // runner timing suffixes
|
|
504
|
-
text = text.replace(/^not ok \d+\b/, "not ok"); // TAP plan numbering
|
|
505
|
-
return text.slice(0, 160);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function firstFailureMarker(text) {
|
|
509
|
-
const lines = String(text || "").replace(/\u001b\[[0-9;]*m/g, "").split(/\r?\n/);
|
|
510
|
-
let context = null;
|
|
511
|
-
let consoleIndent = null;
|
|
512
|
-
for (const line of lines) {
|
|
513
|
-
const bullet = /^([ \t]*)●[ \t]+/.exec(line);
|
|
514
|
-
if (consoleIndent !== null) {
|
|
515
|
-
// Jest's Console block contains indented log payloads, which may
|
|
516
|
-
// themselves begin with "●". Only a peer/parent section bullet or a
|
|
517
|
-
// non-indented line may end the block; deeper bullets remain data.
|
|
518
|
-
if (bullet) {
|
|
519
|
-
if (bullet[1].length > consoleIndent) continue;
|
|
520
|
-
consoleIndent = null;
|
|
521
|
-
} else if (line.trim() === "" || /^[ \t]/.test(line)) {
|
|
522
|
-
continue;
|
|
523
|
-
} else {
|
|
524
|
-
consoleIndent = null;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (bullet && /^Console\b/.test(line.slice(bullet[0].length))) {
|
|
528
|
-
consoleIndent = bullet[1].length;
|
|
529
|
-
continue;
|
|
530
|
-
}
|
|
531
|
-
if (FAILURE_MARKER_PATTERNS.some((pattern) => pattern.test(line))) {
|
|
532
|
-
const normalized = normalizeFailureLine(line);
|
|
533
|
-
if (normalized) return context ? `${context}: ${normalized}` : normalized;
|
|
534
|
-
}
|
|
535
|
-
if (CONTEXT_MARKER_PATTERNS.some((pattern) => pattern.test(line))) {
|
|
536
|
-
const normalized = normalizeFailureLine(line);
|
|
537
|
-
if (normalized) context = normalized;
|
|
538
|
-
}
|
|
539
383
|
}
|
|
540
|
-
return null;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
// A stable, normalized signature: command + outcome + exit condition + the
|
|
544
|
-
// first test-level failing marker (with a suite/file context line when the
|
|
545
|
-
// runner printed one). Without a test-level marker the signature falls back
|
|
546
|
-
// to a digest of the complete streams (stdout and stderr both), so
|
|
547
|
-
// suite-header-only or banner-only prefixes from *different* failures can
|
|
548
|
-
// never collide (identical byte-for-byte evidence still matches, which is
|
|
549
|
-
// the honest reading: the same observation repeated). The user-visible
|
|
550
|
-
// `error` is a bounded diagnostic and is only the legacy fallback when no incremental
|
|
551
|
-
// identity was supplied.
|
|
552
|
-
function buildFailureSignature(result) {
|
|
553
|
-
const evidence = String((result && (result.evidence || result.error)) || "");
|
|
554
|
-
const marker = result && Object.hasOwn(result, "failureMarker") ? result.failureMarker : firstFailureMarker(evidence);
|
|
555
|
-
const exit =
|
|
556
|
-
result && Number.isInteger(result.exitCode) ? `exit=${result.exitCode}`
|
|
557
|
-
: result && result.signal ? `signal=${result.signal}`
|
|
558
|
-
: "exit=unknown";
|
|
559
|
-
const base = `${(result && result.command) || "verification"} [${(result && result.outcome) || "unknown"}] ${exit}`;
|
|
560
|
-
if (marker) return `${base}: ${marker}`;
|
|
561
|
-
const digest = result && result.evidenceDigest || createHash("sha256").update(evidence.replace(/\s+/g, " ").trim()).digest("hex").slice(0, 16);
|
|
562
|
-
return `${base}: unrecognized-output ${digest}`;
|
|
563
384
|
}
|
|
564
385
|
|
|
565
386
|
function getAvailableScripts(cwd) {
|
|
@@ -574,15 +395,12 @@ function getAvailableScripts(cwd) {
|
|
|
574
395
|
|
|
575
396
|
// Verification budget for the npm scripts run on session.idle. The Harness
|
|
576
397
|
// self-regression suite needs ~2 minutes on a laptop, so the original 60s cap
|
|
577
|
-
// killed healthy runs and reported them as failures
|
|
578
|
-
// the
|
|
579
|
-
//
|
|
580
|
-
// only bounded excerpts/line prefixes remain in memory, while all bytes feed
|
|
581
|
-
// 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.
|
|
582
401
|
const VERIFY_TIMEOUT_ENV = "HARNESS_VERIFY_TIMEOUT_MS"
|
|
583
402
|
const DEFAULT_VERIFY_TIMEOUT_MS = 600000
|
|
584
403
|
const VERIFY_OUTPUT_LIMIT = 2000
|
|
585
|
-
const VERIFY_LINE_LIMIT = 4096
|
|
586
404
|
const VERIFY_KILL_GRACE_MS = 150
|
|
587
405
|
|
|
588
406
|
function verifyTimeoutMs() {
|
|
@@ -590,74 +408,23 @@ function verifyTimeoutMs() {
|
|
|
590
408
|
return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_VERIFY_TIMEOUT_MS
|
|
591
409
|
}
|
|
592
410
|
|
|
593
|
-
//
|
|
594
|
-
// state is per stream, so asynchronous stdout/stderr interleaving does not
|
|
595
|
-
// change identity. An overlong line keeps its prefix for marker recognition;
|
|
596
|
-
// its complete contents still contribute to the digest.
|
|
411
|
+
// Keep bounded diagnostic excerpts while consuming the complete streams.
|
|
597
412
|
function createVerificationCapture() {
|
|
598
|
-
|
|
599
|
-
let head = "", tail = "", length = 0, bytes = 0, line = "", context = null, consoleIndent = null
|
|
600
|
-
let marker = null, markerContext = null, pendingSpace = false, hashedText = false, lineTruncated = false, unsafeIdentity = false
|
|
601
|
-
function consumeLine(value, truncated) {
|
|
602
|
-
if (marker) return
|
|
603
|
-
const clean = value.replace(/\u001b\[[0-9;]*m/g, "")
|
|
604
|
-
const bullet = /^([ \t]*)●[ \t]+/.exec(clean)
|
|
605
|
-
if (consoleIndent !== null) {
|
|
606
|
-
if (bullet) {
|
|
607
|
-
if (bullet[1].length > consoleIndent) return
|
|
608
|
-
consoleIndent = null
|
|
609
|
-
} else if (clean.trim() === "" || /^[ \t]/.test(clean)) return
|
|
610
|
-
else consoleIndent = null
|
|
611
|
-
}
|
|
612
|
-
if (bullet && /^Console\b/.test(clean.slice(bullet[0].length))) {
|
|
613
|
-
consoleIndent = bullet[1].length
|
|
614
|
-
return
|
|
615
|
-
}
|
|
616
|
-
// A clipped marker or suite name cannot identify a check safely. A long
|
|
617
|
-
// ordinary progress/banner line need not discard a later complete marker.
|
|
618
|
-
if (truncated && (clean.trim() === "" || /^\u001b\[[0-9;]*$/.test(clean)
|
|
619
|
-
|| [...FAILURE_MARKER_PATTERNS, ...CONTEXT_MARKER_PATTERNS].some(pattern => pattern.test(clean)))) {
|
|
620
|
-
unsafeIdentity = true
|
|
621
|
-
return
|
|
622
|
-
}
|
|
623
|
-
if (FAILURE_MARKER_PATTERNS.some(pattern => pattern.test(clean))) {
|
|
624
|
-
marker = normalizeFailureLine(clean)
|
|
625
|
-
markerContext = context
|
|
626
|
-
} else if (CONTEXT_MARKER_PATTERNS.some(pattern => pattern.test(clean))) context = normalizeFailureLine(clean)
|
|
627
|
-
}
|
|
413
|
+
let head = "", tail = "", length = 0, bytes = 0
|
|
628
414
|
return {
|
|
629
415
|
write(chunk) {
|
|
630
416
|
const text = String(chunk)
|
|
631
417
|
bytes += Buffer.byteLength(text)
|
|
632
418
|
length += text.length
|
|
633
|
-
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)
|
|
634
420
|
tail = (tail + text).slice(-VERIFY_OUTPUT_LIMIT)
|
|
635
|
-
for (const part of text.split(/(\s+)/)) {
|
|
636
|
-
if (!part) continue
|
|
637
|
-
if (/^\s+$/.test(part)) pendingSpace = hashedText
|
|
638
|
-
else {
|
|
639
|
-
if (pendingSpace) hash.update(" ")
|
|
640
|
-
hash.update(part)
|
|
641
|
-
pendingSpace = false
|
|
642
|
-
hashedText = true
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
for (const [index, part] of text.split("\n").entries()) {
|
|
646
|
-
if (index > 0) { consumeLine(line, lineTruncated); line = ""; lineTruncated = false }
|
|
647
|
-
if (line.length + part.length > VERIFY_LINE_LIMIT) lineTruncated = true
|
|
648
|
-
if (line.length < VERIFY_LINE_LIMIT) line += part.slice(0, VERIFY_LINE_LIMIT-line.length)
|
|
649
|
-
}
|
|
650
421
|
},
|
|
651
422
|
excerpt(limit) {
|
|
652
423
|
if (length <= limit) return head.slice(0, length)
|
|
653
|
-
const half = Math.floor(limit/2)
|
|
654
|
-
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)}`
|
|
655
426
|
},
|
|
656
427
|
get bytes() { return bytes },
|
|
657
|
-
finish() {
|
|
658
|
-
consumeLine(line, lineTruncated)
|
|
659
|
-
return { digest: hash.digest("hex"), marker, markerContext, context, unsafeIdentity }
|
|
660
|
-
},
|
|
661
428
|
}
|
|
662
429
|
}
|
|
663
430
|
|
|
@@ -698,7 +465,6 @@ function runVerificationCommand(cwd, command, remainingMs, signal, onProgress) {
|
|
|
698
465
|
clearInterval(progressTimer)
|
|
699
466
|
signal?.removeEventListener("abort", abort)
|
|
700
467
|
if (termination) await termination
|
|
701
|
-
const out = stdout.finish(), err = stderr.finish()
|
|
702
468
|
const both = stdout.bytes > 0 && stderr.bytes > 0
|
|
703
469
|
const errorOutput = both
|
|
704
470
|
? `stdout:\n${stdout.excerpt(VERIFY_OUTPUT_LIMIT/2)}\nstderr:\n${stderr.excerpt(VERIFY_OUTPUT_LIMIT/2)}`
|
|
@@ -712,12 +478,6 @@ function runVerificationCommand(cwd, command, remainingMs, signal, onProgress) {
|
|
|
712
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)"}`
|
|
713
479
|
else result.error = errorOutput || `command exited ${exitCode}`
|
|
714
480
|
}
|
|
715
|
-
if (outcome === "test_failure") {
|
|
716
|
-
result.failureMarker = out.unsafeIdentity || err.unsafeIdentity ? null : out.marker
|
|
717
|
-
? (out.markerContext ? `${out.markerContext}: ${out.marker}` : out.marker)
|
|
718
|
-
: err.marker ? `${err.markerContext || out.context ? `${err.markerContext || out.context}: ` : ""}${err.marker}` : null
|
|
719
|
-
result.evidenceDigest = createHash("sha256").update(`stdout:${out.digest}\nstderr:${err.digest}`).digest("hex").slice(0, 16)
|
|
720
|
-
}
|
|
721
481
|
resolveCommand(result)
|
|
722
482
|
}
|
|
723
483
|
if (signal?.aborted) {
|
|
@@ -775,36 +535,6 @@ async function runVerification(cwd, { signal, onProgress } = {}) {
|
|
|
775
535
|
return { allPassed: !signal?.aborted && results.every(result => result.success), skipped: false, results }
|
|
776
536
|
}
|
|
777
537
|
|
|
778
|
-
/**
|
|
779
|
-
* Records a verification failure against the circuit breaker and returns the
|
|
780
|
-
* action to take: allow (with retries remaining) or force_reflection on the
|
|
781
|
-
* third matching failure. Completing reflection resets that signature's count.
|
|
782
|
-
*/
|
|
783
|
-
function tripBreaker(breakerFile, signature) {
|
|
784
|
-
const breaker = loadBreakerState(breakerFile)
|
|
785
|
-
|
|
786
|
-
if (!breaker.failures[signature]) {
|
|
787
|
-
breaker.failures[signature] = { count: 0, firstSeen: Date.now() }
|
|
788
|
-
}
|
|
789
|
-
const entry = breaker.failures[signature]
|
|
790
|
-
entry.count++
|
|
791
|
-
entry.lastSeen = Date.now()
|
|
792
|
-
|
|
793
|
-
if (entry.count >= 3) {
|
|
794
|
-
if (!breaker.reflectionPending) {
|
|
795
|
-
breaker.reflectionPending = true
|
|
796
|
-
breaker.reflectionRequestedAt = Date.now()
|
|
797
|
-
breaker.reflectionToken = randomUUID().replace(/-/g, "")
|
|
798
|
-
breaker.reflectionSignature = signature
|
|
799
|
-
}
|
|
800
|
-
saveJSON(breakerFile, breaker)
|
|
801
|
-
return { action: "force_reflection", count: entry.count, reflectionToken: breaker.reflectionToken }
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
saveJSON(breakerFile, breaker)
|
|
805
|
-
return { action: "allow", count: entry.count, remaining: 3 - entry.count }
|
|
806
|
-
}
|
|
807
|
-
|
|
808
538
|
function recordCompliance(complianceFile, mutate) {
|
|
809
539
|
const compliance = loadJSON(complianceFile, defaultCompliance())
|
|
810
540
|
mutate(compliance)
|
|
@@ -1035,9 +765,7 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
|
|
|
1035
765
|
return {
|
|
1036
766
|
stateDir,
|
|
1037
767
|
editStateFile: join(stateDir, "edit-state.json"),
|
|
1038
|
-
breakerFile: join(stateDir, "circuit-breaker.json"),
|
|
1039
768
|
complianceFile: join(stateDir, "compliance.json"),
|
|
1040
|
-
reflectionFile: reflectionReportPath(stateDir),
|
|
1041
769
|
}
|
|
1042
770
|
}
|
|
1043
771
|
|
|
@@ -1099,55 +827,16 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
|
|
|
1099
827
|
try { rmSync(stateDir, { recursive: true, force: true }) } catch { /* fail open */ }
|
|
1100
828
|
}
|
|
1101
829
|
|
|
1102
|
-
function toolTarget(input, output) {
|
|
1103
|
-
const args = { ...((output && output.args) || {}), ...((input && input.args) || {}) }
|
|
1104
|
-
return args.filePath || args.file_path || args.path || args.filename || args.file || null
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
function patchTargets(input, output) {
|
|
1108
|
-
const args = { ...((output && output.args) || {}), ...((input && input.args) || {}) }
|
|
1109
|
-
if (typeof args.patchText !== "string") return []
|
|
1110
|
-
return [...args.patchText.matchAll(/^\*\*\*\s+(?:(?:Add|Update|Delete) File|Move to):[ \t]*([^\r\n]+)$/gm)]
|
|
1111
|
-
.map((match) => match[1].trim())
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
function isReflectionWrite(input, output, reportFile) {
|
|
1115
|
-
if (!EDIT_TOOLS.has(input.tool)) return false
|
|
1116
|
-
if (input.tool === "apply_patch") {
|
|
1117
|
-
const targets = patchTargets(input, output)
|
|
1118
|
-
return targets.length > 0 && targets.every((patchTarget) => samePath(resolve(workspace, patchTarget), reportFile))
|
|
1119
|
-
}
|
|
1120
|
-
const target = toolTarget(input, output)
|
|
1121
|
-
return Boolean(target && samePath(resolve(workspace, target), reportFile))
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
830
|
return {
|
|
1125
|
-
"tool.execute.before": async
|
|
831
|
+
"tool.execute.before": async input => {
|
|
1126
832
|
telemetryBefore(input)
|
|
1127
|
-
if (!EDIT_TOOLS.has(input.tool)) return
|
|
1128
|
-
const { breakerFile, reflectionFile } = pathsFor(input.sessionID)
|
|
1129
|
-
const breaker = loadBreakerState(breakerFile)
|
|
1130
|
-
if (breaker.reflectionPending && !isReflectionWrite(input, output, reflectionFile)) {
|
|
1131
|
-
throw new Error(
|
|
1132
|
-
`Harness reflection is required before another code edit. ` +
|
|
1133
|
-
`Write a valid reflection report to "${reflectionFile}" first.`,
|
|
1134
|
-
)
|
|
1135
|
-
}
|
|
1136
833
|
},
|
|
1137
834
|
|
|
1138
835
|
"tool.execute.after": async (input, output) => {
|
|
1139
836
|
telemetryAfter(input)
|
|
1140
837
|
recordHostCapture(input, output)
|
|
1141
838
|
if (!EDIT_TOOLS.has(input.tool)) return
|
|
1142
|
-
const { editStateFile,
|
|
1143
|
-
|
|
1144
|
-
// The reflection artifact is a protocol write, not a code edit. It is
|
|
1145
|
-
// accepted only when it contains the current token and all required
|
|
1146
|
-
// sections; this is the only path that records lastReflection.
|
|
1147
|
-
if (isReflectionWrite(input, output, reflectionFile)) {
|
|
1148
|
-
completeReflection(breakerFile, reflectionFile)
|
|
1149
|
-
return
|
|
1150
|
-
}
|
|
839
|
+
const { editStateFile, complianceFile } = pathsFor(input.sessionID)
|
|
1151
840
|
|
|
1152
841
|
const state = normalizeEditState(loadJSON(editStateFile, defaultEditState()))
|
|
1153
842
|
activeVerifications.get(input.sessionID || "default")?.abort()
|
|
@@ -1193,10 +882,7 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
|
|
|
1193
882
|
controller.finished = new Promise(resolveFinished => { finishVerification = resolveFinished })
|
|
1194
883
|
activeVerifications.set(activeSession, controller)
|
|
1195
884
|
try {
|
|
1196
|
-
const { editStateFile,
|
|
1197
|
-
// This fallback makes the lifecycle complete even if the host omits
|
|
1198
|
-
// tool input args on the artifact's after hook.
|
|
1199
|
-
completeReflection(breakerFile, reflectionFile)
|
|
885
|
+
const { editStateFile, complianceFile } = pathsFor(activeSession)
|
|
1200
886
|
|
|
1201
887
|
const state = normalizeEditState(loadJSON(editStateFile, defaultEditState()))
|
|
1202
888
|
if (state.followUpPending) return
|
|
@@ -1251,38 +937,19 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
|
|
|
1251
937
|
|
|
1252
938
|
let text
|
|
1253
939
|
if (!confirmed) {
|
|
1254
|
-
// Timeout or execution error: no check produced a verdict
|
|
1255
|
-
// must not advance the same-check Rule-of-3 counter. Report it as an
|
|
1256
|
-
// uncompleted verification and stay honest about what is unknown.
|
|
940
|
+
// Timeout or execution error: no check produced a verdict.
|
|
1257
941
|
const detail =
|
|
1258
942
|
primary.outcome === "timeout"
|
|
1259
943
|
? `timed out (budget ${Math.round(verifyTimeoutMs() / 1000)}s; set ${VERIFY_TIMEOUT_ENV} to raise it)`
|
|
1260
944
|
: "could not run to completion (execution error, not a confirmed test failure)"
|
|
1261
945
|
text =
|
|
1262
946
|
`Harness: verification did not complete - "${primary.command}" ${detail}. ` +
|
|
1263
|
-
`No failing check was confirmed, so this does NOT count toward the repeated-failure reflection. ` +
|
|
1264
947
|
`Diagnostics: ${primary.error || "(no output captured)"}. ` +
|
|
1265
948
|
`Fix the cause (or raise the budget) and verify again; a new edit re-runs verification.`
|
|
1266
949
|
} else {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
const { stateDir } = pathsFor(activeSession)
|
|
1271
|
-
text =
|
|
1272
|
-
`Harness: "${confirmed.command}" has now failed 3 times with the same error. Stop and reflect ` +
|
|
1273
|
-
`before retrying. Write a report to "${reflectionReportPath(stateDir)}" with sections ` +
|
|
1274
|
-
`## Goal, ## Failed Attempts, ## Verified Facts, ## Diagnosis, and ## Decision. ` +
|
|
1275
|
-
`The Decision must begin with RESUME: or ESCALATE:. Include reflection token: ${trip.reflectionToken}. ` +
|
|
1276
|
-
`After the report is recorded, resume with a different approach. Failure: ${confirmed.error || "(no output captured)"}`
|
|
1277
|
-
recordCompliance(complianceFile, (c) => {
|
|
1278
|
-
c.circuitBreakerTrips++
|
|
1279
|
-
c.reflectionsForced++
|
|
1280
|
-
})
|
|
1281
|
-
} else {
|
|
1282
|
-
text =
|
|
1283
|
-
`Harness: verification failed (${trip.remaining} retries before a forced reflection). ` +
|
|
1284
|
-
`"${confirmed.command}" - ${confirmed.error || "(no output captured)"}. Fix it and this will re-run automatically.`
|
|
1285
|
-
}
|
|
950
|
+
text =
|
|
951
|
+
`Harness: verification failed - "${confirmed.command}" - ${confirmed.error || "(no output captured)"}. ` +
|
|
952
|
+
`Review the result, address the cause, and verify again.`
|
|
1286
953
|
}
|
|
1287
954
|
|
|
1288
955
|
try {
|
|
@@ -1290,8 +957,7 @@ export const HarnessEnforcement = async ({ client, directory, signal }) => {
|
|
|
1290
957
|
} catch (error) {
|
|
1291
958
|
if (controller.signal.aborted) return
|
|
1292
959
|
// A failed delivery is retryable on the next idle event, but the
|
|
1293
|
-
// saved message means retrying does not run verification again
|
|
1294
|
-
// increment the circuit-breaker count.
|
|
960
|
+
// saved message means retrying does not run verification again.
|
|
1295
961
|
const failedState = normalizeEditState(loadJSON(editStateFile, defaultEditState()))
|
|
1296
962
|
failedState.followUpPending = false
|
|
1297
963
|
failedState.followUpDeliveryPending = true
|
|
@@ -1344,7 +1010,13 @@ export default {
|
|
|
1344
1010
|
return pending
|
|
1345
1011
|
}
|
|
1346
1012
|
let unresolvedIdentityCount = 0
|
|
1013
|
+
const routerUnavailableCounts = new Map()
|
|
1347
1014
|
|
|
1015
|
+
const routerUnavailable = reason => {
|
|
1016
|
+
const count = (routerUnavailableCounts.get(reason) || 0) + 1
|
|
1017
|
+
routerUnavailableCounts.set(reason, count)
|
|
1018
|
+
try { console.warn(`[Harness] OpenCode router-unavailable (${reason}; count=${count})`) } catch {}
|
|
1019
|
+
}
|
|
1348
1020
|
const unresolvedIdentity = reason => {
|
|
1349
1021
|
unresolvedIdentityCount++
|
|
1350
1022
|
try { console.warn(`[Harness] OpenCode session workspace unresolved (${reason}; count=${unresolvedIdentityCount}); workspace-dependent handling skipped.`) } catch {}
|
|
@@ -1483,7 +1155,7 @@ export default {
|
|
|
1483
1155
|
if (events.signal.aborted) return
|
|
1484
1156
|
const routerPayload = { host: "opencode", session_id: event.sessionID,
|
|
1485
1157
|
...(prompt.messageID ? { turn_id: prompt.messageID } : {}), cwd: prompt.workspace, prompt: event.prompt.text }
|
|
1486
|
-
const routerOutput = await runKernelRouter(routerPayload, events.signal)
|
|
1158
|
+
const routerOutput = await runKernelRouter(routerPayload, events.signal, routerUnavailable)
|
|
1487
1159
|
if (!events.signal.aborted && promptRoutes.get(event.sessionID) === prompt) prompt.routerOutput = routerOutput
|
|
1488
1160
|
})
|
|
1489
1161
|
await prompt.routerPromise
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-everything",
|
|
3
|
-
"version": "0.55.
|
|
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",
|