@skathio/somi 4.1.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +8 -3
- package/.claude-plugin/plugin.json +9 -10
- package/.copilot-extension/extension.json +32 -40
- package/.copilot-extension/marketplace.json +8 -3
- package/README.md +88 -227
- package/VERSION +1 -1
- package/agents/somi-reviewer.md +21 -40
- package/agents/somi-security-reviewer.md +16 -90
- package/agents/somi-worker-high.md +11 -0
- package/agents/somi-worker-low.md +11 -0
- package/agents/somi-worker-medium.md +11 -0
- package/agents/somi.md +8 -75
- package/commands/somi-config.md +5 -14
- package/commands/somi-deliver.md +11 -0
- package/commands/somi-quality.md +10 -0
- package/commands/somi-review.md +10 -0
- package/commands/somi-status.md +11 -0
- package/commands/somi.md +10 -0
- package/hooks/hooks.json +29 -23
- package/hooks/lib/common.mjs +45 -34
- package/hooks/pre-tool/apply-tier.mjs +31 -0
- package/hooks/pre-tool/block-dangerous-bash.mjs +15 -0
- package/hooks/pre-tool/gate-dep-install.mjs +2 -2
- package/hooks/pre-tool/guard-protected-paths.mjs +9 -16
- package/hooks/pre-tool/guard-tier-config.mjs +17 -0
- package/hooks/pre-tool/reviewers-read-only.mjs +11 -0
- package/hooks/session-start/inject-digest.mjs +51 -0
- package/hooks/stop/review-due.mjs +44 -0
- package/hooks/user-prompt/capture-prompt.mjs +17 -0
- package/library/lenses/architecture.md +1 -0
- package/library/lenses/test-strategy.md +1 -0
- package/library/roles/accessibility.md +1 -0
- package/library/roles/answer.md +1 -0
- package/library/roles/atlas.md +1 -0
- package/library/roles/build.md +1 -0
- package/library/roles/debug.md +6 -0
- package/library/roles/design.md +1 -0
- package/library/roles/discover.md +1 -0
- package/library/roles/incident.md +1 -0
- package/library/roles/migrate.md +1 -0
- package/library/roles/perf.md +1 -0
- package/library/roles/plan.md +1 -0
- package/library/roles/refactor.md +1 -0
- package/library/roles/review.md +1 -0
- package/library/roles/security-review.md +1 -0
- package/library/roles/upgrade.md +1 -0
- package/library/skills/accessibility.md +16 -0
- package/library/skills/ci-infra-gotchas.md +12 -0
- package/library/skills/perf-method.md +10 -0
- package/library/skills/secure-coding.md +18 -0
- package/library/skills/testing-checklist.md +16 -0
- package/library/skills/threat-modeling.md +10 -0
- package/package.json +12 -17
- package/profiles/claude.json +21 -0
- package/profiles/copilot.json +5 -0
- package/rules/digest.md +40 -0
- package/scripts/check-links.mjs +65 -76
- package/scripts/lib/advisor.mjs +207 -0
- package/scripts/lib/check.mjs +167 -0
- package/scripts/lib/copilot-workflow.mjs +41 -0
- package/scripts/lib/doctor.mjs +91 -0
- package/scripts/lib/gates.mjs +69 -0
- package/scripts/lib/git-tree.mjs +201 -0
- package/scripts/lib/init.mjs +23 -0
- package/scripts/lib/ledger.mjs +38 -0
- package/scripts/lib/mcp-project-root.mjs +63 -67
- package/scripts/lib/migrate.mjs +73 -0
- package/scripts/lib/path-facts.mjs +2 -2
- package/scripts/lib/path-safety.mjs +6 -134
- package/scripts/lib/plan.mjs +69 -0
- package/scripts/lib/policy.mjs +103 -0
- package/scripts/lib/pr.mjs +28 -0
- package/scripts/lib/prompt.mjs +72 -0
- package/scripts/lib/quality/clones.mjs +76 -0
- package/scripts/lib/quality/css.mjs +43 -0
- package/scripts/lib/quality/gate.mjs +230 -0
- package/scripts/lib/quality/limits.mjs +97 -0
- package/scripts/lib/quality/metrics.mjs +159 -0
- package/scripts/lib/quality/parse.mjs +73 -0
- package/scripts/lib/quality/repo.mjs +69 -0
- package/scripts/lib/quality/run.mjs +58 -0
- package/scripts/lib/reviews.mjs +132 -0
- package/scripts/lib/routes.mjs +108 -0
- package/scripts/lib/setup.mjs +34 -0
- package/scripts/lib/shards.mjs +166 -0
- package/scripts/lib/signals.mjs +110 -0
- package/scripts/lib/state.mjs +42 -0
- package/scripts/lib/tiers.mjs +42 -0
- package/scripts/lib/update-notice.mjs +48 -0
- package/scripts/lib/views.mjs +62 -0
- package/scripts/lib/workflows.mjs +56 -0
- package/scripts/somi-mcp.mjs +182 -323
- package/scripts/somi.mjs +208 -0
- package/scripts/vendor/tree-sitter/LICENSE.vscode-tree-sitter-wasm +21 -0
- package/scripts/vendor/tree-sitter/LICENSE.web-tree-sitter +21 -0
- package/scripts/vendor/tree-sitter/cgmanifest.vscode-tree-sitter-wasm.json +16 -0
- package/scripts/vendor/tree-sitter/manifest.json +59 -0
- package/scripts/vendor/tree-sitter/package.json +3 -0
- package/scripts/vendor/tree-sitter/tree-sitter-css.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.js +4081 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.wasm +0 -0
- package/skills/somi-expertise/SKILL.md +6 -0
- package/workflows/deliver-stages.js +81 -0
- package/.claude/settings.json +0 -131
- package/agents/somi-architecture-reviewer.md +0 -101
- package/agents/somi-atlas.md +0 -100
- package/agents/somi-coder.md +0 -60
- package/agents/somi-designer.md +0 -36
- package/agents/somi-discovery-analyst.md +0 -57
- package/agents/somi-flow.md +0 -47
- package/agents/somi-general.md +0 -36
- package/agents/somi-impact.md +0 -95
- package/agents/somi-incident.md +0 -94
- package/agents/somi-plan-reviewer.md +0 -68
- package/agents/somi-planner.md +0 -57
- package/agents/somi-pr.md +0 -99
- package/agents/somi-refactor-designer.md +0 -81
- package/agents/somi-refactorer.md +0 -99
- package/agents/somi-sdlc-reviewer.md +0 -67
- package/agents/somi-test-strategist.md +0 -87
- package/commands/adopt.md +0 -14
- package/commands/architecture-review.md +0 -19
- package/commands/atlas.md +0 -19
- package/commands/code-loop.md +0 -19
- package/commands/code-parallel.md +0 -19
- package/commands/code.md +0 -19
- package/commands/debug.md +0 -19
- package/commands/design.md +0 -19
- package/commands/discover.md +0 -19
- package/commands/impact.md +0 -19
- package/commands/incident.md +0 -19
- package/commands/plan-loop.md +0 -19
- package/commands/plan.md +0 -19
- package/commands/pr.md +0 -19
- package/commands/refactor-design.md +0 -19
- package/commands/refactor.md +0 -19
- package/commands/release-readiness.md +0 -19
- package/commands/review-panel.md +0 -19
- package/commands/review.md +0 -19
- package/commands/security-review.md +0 -19
- package/commands/ship-loop.md +0 -19
- package/commands/ship.md +0 -19
- package/commands/test-strategy.md +0 -19
- package/commands/upgrade.md +0 -19
- package/examples/README.md +0 -19
- package/examples/code-review-example.md +0 -88
- package/examples/discovery-example.md +0 -200
- package/examples/feature-plan-example.md +0 -377
- package/examples/full-pipeline-example.md +0 -188
- package/examples/sample-consumer/.claude/settings.json +0 -29
- package/examples/sample-consumer/CLAUDE.md +0 -78
- package/examples/sample-consumer/README.md +0 -102
- package/hooks/post-tool/lint-changed-files.mjs +0 -209
- package/hooks/pre-tool/guard-cost-lowering.mjs +0 -192
- package/hooks/session-start/detect-repo-instructions.mjs +0 -287
- package/hooks/session-start/ensure-default-config.mjs +0 -113
- package/hooks/user-prompt-submit/inject-workflow-context.mjs +0 -580
- package/rules/00-priorities.md +0 -48
- package/rules/10-solid.md +0 -87
- package/rules/20-clean-code.md +0 -62
- package/rules/30-security-owasp.md +0 -83
- package/rules/40-engineering-practices.md +0 -65
- package/rules/50-collaboration.md +0 -114
- package/rules/99-overrides.md +0 -52
- package/rules/CLAUDE.md +0 -200
- package/scripts/check-session-artefacts.mjs +0 -149
- package/scripts/check-size-budget.mjs +0 -137
- package/scripts/generate-digest.mjs +0 -176
- package/scripts/lib/agent-info.mjs +0 -85
- package/scripts/lib/agent-registry.mjs +0 -92
- package/scripts/lib/cost-ceiling.mjs +0 -328
- package/scripts/lib/cost-config-edit.mjs +0 -102
- package/scripts/lib/cost-config.mjs +0 -64
- package/scripts/lib/cost-defaults.mjs +0 -53
- package/scripts/lib/cost-lowering.mjs +0 -89
- package/scripts/lib/cost-model.mjs +0 -110
- package/scripts/lib/dispatch-resolver.mjs +0 -243
- package/scripts/lib/escalation-facts.mjs +0 -146
- package/scripts/lib/escalation.mjs +0 -129
- package/scripts/lib/findings-ledger.mjs +0 -241
- package/scripts/lib/install-text.mjs +0 -97
- package/scripts/lib/loop-caps.mjs +0 -140
- package/scripts/lib/loop-diff.mjs +0 -38
- package/scripts/lib/loop-dispatch.mjs +0 -19
- package/scripts/lib/loop-engine.mjs +0 -227
- package/scripts/lib/loop-escalate.mjs +0 -49
- package/scripts/lib/loop-exit.mjs +0 -47
- package/scripts/lib/loop-notes-compact.mjs +0 -72
- package/scripts/lib/loop-notes.mjs +0 -282
- package/scripts/lib/loop-review.mjs +0 -395
- package/scripts/lib/loop-state.mjs +0 -44
- package/scripts/lib/loop-step-close.mjs +0 -75
- package/scripts/lib/loop-step-kit.mjs +0 -179
- package/scripts/lib/loop-step-review.mjs +0 -140
- package/scripts/lib/loop-step-tool.mjs +0 -89
- package/scripts/lib/loop-step.mjs +0 -303
- package/scripts/lib/run-budget.mjs +0 -28
- package/scripts/lib/run-card.mjs +0 -73
- package/scripts/lib/size-tier.mjs +0 -184
- package/scripts/lib/tier-record.mjs +0 -82
- package/scripts/size-budget-overrides.json +0 -58
- package/scripts/somi-card.mjs +0 -39
- package/scripts/somi-check.mjs +0 -237
- package/scripts/somi-config.mjs +0 -421
- package/scripts/somi-dispatch.mjs +0 -141
- package/scripts/somi-findings.mjs +0 -100
- package/scripts/somi-loop.mjs +0 -139
- package/scripts/somi-tier.mjs +0 -393
- package/scripts/validate.sh +0 -653
- package/skills/api-design/SKILL.md +0 -147
- package/skills/clean-code/SKILL.md +0 -142
- package/skills/flow-adopt/SKILL.md +0 -92
- package/skills/flow-architecture-review/SKILL.md +0 -94
- package/skills/flow-atlas/SKILL.md +0 -34
- package/skills/flow-code/SKILL.md +0 -167
- package/skills/flow-code-loop/SKILL.md +0 -263
- package/skills/flow-code-parallel/SKILL.md +0 -160
- package/skills/flow-debug/SKILL.md +0 -141
- package/skills/flow-design/SKILL.md +0 -170
- package/skills/flow-discover/SKILL.md +0 -204
- package/skills/flow-impact/SKILL.md +0 -35
- package/skills/flow-incident/SKILL.md +0 -49
- package/skills/flow-plan/SKILL.md +0 -254
- package/skills/flow-plan-loop/SKILL.md +0 -254
- package/skills/flow-pr/SKILL.md +0 -34
- package/skills/flow-refactor/SKILL.md +0 -58
- package/skills/flow-refactor-design/SKILL.md +0 -97
- package/skills/flow-release-readiness/SKILL.md +0 -82
- package/skills/flow-review/SKILL.md +0 -193
- package/skills/flow-review-panel/SKILL.md +0 -154
- package/skills/flow-security-review/SKILL.md +0 -83
- package/skills/flow-ship/SKILL.md +0 -125
- package/skills/flow-ship-loop/SKILL.md +0 -274
- package/skills/flow-somi-config/SKILL.md +0 -142
- package/skills/flow-status/SKILL.md +0 -43
- package/skills/flow-test-strategy/SKILL.md +0 -83
- package/skills/flow-upgrade/SKILL.md +0 -82
- package/skills/market-research/SKILL.md +0 -125
- package/skills/observability/SKILL.md +0 -133
- package/skills/owasp-defense/SKILL.md +0 -141
- package/skills/plan-review/SKILL.md +0 -83
- package/skills/reasoning-craft/SKILL.md +0 -213
- package/skills/requirements-engineering/SKILL.md +0 -137
- package/skills/role-coder/SKILL.md +0 -247
- package/skills/role-designer/SKILL.md +0 -172
- package/skills/role-discovery-analyst/SKILL.md +0 -288
- package/skills/role-planner/SKILL.md +0 -353
- package/skills/role-reviewer/SKILL.md +0 -218
- package/skills/rules/SKILL.md +0 -47
- package/skills/sdlc-process/SKILL.md +0 -74
- package/skills/solid-principles/SKILL.md +0 -143
- package/skills/somi-checkpoint/SKILL.md +0 -95
- package/skills/somi-dispatch/SKILL.md +0 -259
- package/skills/somi-routing/SKILL.md +0 -158
- package/skills/testing-playbook/SKILL.md +0 -133
- package/skills/threat-modeling/SKILL.md +0 -117
- package/templates/ADR.md.tmpl +0 -73
- package/templates/ATLAS.md.tmpl +0 -75
- package/templates/BRD.md.tmpl +0 -68
- package/templates/BRIEF.md.tmpl +0 -119
- package/templates/CONTEXT.md.tmpl +0 -74
- package/templates/DECISIONS.md.tmpl +0 -105
- package/templates/DESIGN.md.tmpl +0 -83
- package/templates/DIARY.md.tmpl +0 -70
- package/templates/DOD.md.tmpl +0 -90
- package/templates/FRD.md.tmpl +0 -64
- package/templates/PHASE.md.tmpl +0 -80
- package/templates/PROGRESS.md.tmpl +0 -63
- package/templates/RCA.md.tmpl +0 -53
- package/templates/RD-README.md.tmpl +0 -70
- package/templates/RESEARCH.md.tmpl +0 -96
- package/templates/REVIEW.md.tmpl +0 -82
- package/templates/SDD.md.tmpl +0 -82
- package/templates/SOMI-README.md.tmpl +0 -83
- package/templates/SPEC.md.tmpl +0 -123
- package/templates/SRS.md.tmpl +0 -85
- package/templates/TDD.md.tmpl +0 -77
- package/tests/hooks/cases/audit-log.json +0 -21
- package/tests/hooks/cases/block-dangerous-bash.json +0 -166
- package/tests/hooks/cases/block-secret-writes.json +0 -140
- package/tests/hooks/cases/detect-repo-instructions.json +0 -105
- package/tests/hooks/cases/gate-dep-install.json +0 -42
- package/tests/hooks/cases/guard-protected-paths.json +0 -222
- package/tests/hooks/cases/inject-workflow-context.json +0 -239
- package/tests/hooks/cases/lint-changed-files.json +0 -120
- package/tests/hooks/run.sh +0 -392
- package/tests/scripts/agent-model-frontmatter.sh +0 -38
- package/tests/scripts/agent-names.sh +0 -77
- package/tests/scripts/check-frontmatter.sh +0 -37
- package/tests/scripts/check-links.sh +0 -105
- package/tests/scripts/check-session-artefacts.sh +0 -60
- package/tests/scripts/check-size-budget.sh +0 -71
- package/tests/scripts/checkpoint-gate.sh +0 -131
- package/tests/scripts/convergence-runner.sh +0 -1514
- package/tests/scripts/cost-ceiling.sh +0 -255
- package/tests/scripts/cost-defaults.sh +0 -130
- package/tests/scripts/cost-hardcap.sh +0 -338
- package/tests/scripts/cost-lowering.sh +0 -261
- package/tests/scripts/cost-model.sh +0 -196
- package/tests/scripts/dispatch-guard.sh +0 -108
- package/tests/scripts/dispatch-line-gate.sh +0 -61
- package/tests/scripts/dispatch-reference-gate.sh +0 -173
- package/tests/scripts/ensure-default-config.sh +0 -162
- package/tests/scripts/escalation.sh +0 -409
- package/tests/scripts/eval-runner.sh +0 -3692
- package/tests/scripts/evals-packaging.sh +0 -224
- package/tests/scripts/fact-sheet.sh +0 -296
- package/tests/scripts/fixtures/legacy-shard-no-schema.json +0 -50
- package/tests/scripts/fixtures/mock-stdin-read-throw.cjs +0 -18
- package/tests/scripts/fixtures/size-tier-cases.json +0 -87
- package/tests/scripts/generate-digest.sh +0 -180
- package/tests/scripts/global-config.sh +0 -167
- package/tests/scripts/goldens/loop-state-breach.json +0 -1
- package/tests/scripts/goldens/loop-state-done.json +0 -1
- package/tests/scripts/goldens/somi-findings.json +0 -336
- package/tests/scripts/goldens/somi-loop.json +0 -168
- package/tests/scripts/lib/adr-shape.mjs +0 -41
- package/tests/scripts/lib/agent-registry-tests.mjs +0 -95
- package/tests/scripts/lib/brief-only-guard.mjs +0 -27
- package/tests/scripts/lib/checkpoint-gate.mjs +0 -91
- package/tests/scripts/lib/digest-marker-coupling.mjs +0 -52
- package/tests/scripts/lib/dispatch-reference-gate.mjs +0 -121
- package/tests/scripts/lib/escalation-facts-tests.mjs +0 -140
- package/tests/scripts/lib/escalation-tests.mjs +0 -154
- package/tests/scripts/lib/findings-ledger-tests.mjs +0 -118
- package/tests/scripts/lib/loop-engine-tests.mjs +0 -287
- package/tests/scripts/lib/loop-escalate-tests.mjs +0 -356
- package/tests/scripts/lib/loop-flow-gate.mjs +0 -173
- package/tests/scripts/lib/loop-notes-tests.mjs +0 -384
- package/tests/scripts/lib/loop-step-cli-tests.mjs +0 -156
- package/tests/scripts/lib/loop-step-close-tests.mjs +0 -351
- package/tests/scripts/lib/loop-step-lenient-tests.mjs +0 -114
- package/tests/scripts/lib/loop-step-state-tests.mjs +0 -127
- package/tests/scripts/lib/loop-step-tests.mjs +0 -499
- package/tests/scripts/lib/loop-step-unwritten-tests.mjs +0 -55
- package/tests/scripts/lib/multipass-dependence.mjs +0 -192
- package/tests/scripts/lib/multipass-source-identity.mjs +0 -243
- package/tests/scripts/lib/path-facts-tests.mjs +0 -198
- package/tests/scripts/lib/path-safety-tests.mjs +0 -201
- package/tests/scripts/lib/reference-pair.mjs +0 -61
- package/tests/scripts/lib/retirement-gate.mjs +0 -172
- package/tests/scripts/lib/run-suites.mjs +0 -139
- package/tests/scripts/lib/shell-embedded-js.mjs +0 -47
- package/tests/scripts/lib/ship-loop-sizing-guard.mjs +0 -52
- package/tests/scripts/lib/site-roadmap-gate.mjs +0 -64
- package/tests/scripts/lib/size-tier-drift.mjs +0 -74
- package/tests/scripts/lib/sizing-score-tests.mjs +0 -210
- package/tests/scripts/lib/sizing-set-tests.mjs +0 -131
- package/tests/scripts/lib/somi-mcp-client.mjs +0 -102
- package/tests/scripts/lib/somi-mcp-config-tests.mjs +0 -92
- package/tests/scripts/lib/somi-mcp-loop-tests.mjs +0 -226
- package/tests/scripts/lib/somi-mcp-tests.mjs +0 -491
- package/tests/scripts/lib/somi-mcp-tier-tests.mjs +0 -64
- package/tests/scripts/lib/somi-mcp-tool-schema.mjs +0 -38
- package/tests/scripts/loop-engine.sh +0 -22
- package/tests/scripts/loop-flow-gate.sh +0 -11
- package/tests/scripts/retirement-gate.sh +0 -306
- package/tests/scripts/review-panel-seats.sh +0 -32
- package/tests/scripts/run-card.sh +0 -57
- package/tests/scripts/run-suites.sh +0 -74
- package/tests/scripts/run.sh +0 -689
- package/tests/scripts/site-roadmap-gate.sh +0 -76
- package/tests/scripts/size-tier.sh +0 -562
- package/tests/scripts/somi-agent-dispatch-contract.sh +0 -224
- package/tests/scripts/somi-config.sh +0 -286
- package/tests/scripts/somi-dispatch.sh +0 -465
- package/tests/scripts/somi-mcp.sh +0 -15
- package/tests/scripts/suite-plan.json +0 -20
|
@@ -1,1514 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Unit guard for tests/evals/convergence.mjs's CLI section: argument
|
|
3
|
-
# parsing, --dry-run's shape/zero-model-call contract, --merge/--certify's shard-fold report, and
|
|
4
|
-
# the sha boundary check.
|
|
5
|
-
#
|
|
6
|
-
# Hermetic by construction: every case here is --dry-run, --merge/--certify (read-only, no
|
|
7
|
-
# --source resolution, no credential), or a direct call into an exported CLI helper -- never a
|
|
8
|
-
# live /code-loop draw. eval-runner.sh already covers the non-CLI logic (the extractor, the
|
|
9
|
-
# rank test, classifyDraw/fillArm/compareArms/the shard/resume layer); this file is scoped to what
|
|
10
|
-
# the CLI alone adds, so the two stay disjoint rather than duplicating each other.
|
|
11
|
-
#
|
|
12
|
-
# Exception: terminalVerdict()/writeNextShard()'s new
|
|
13
|
-
# `verdict` param/makeShardWriter() are shard/resume-layer additions, eval-runner.sh's stated home
|
|
14
|
-
# -- pinned here instead because the scope here was exactly these three files, not
|
|
15
|
-
# eval-runner.sh. Still fully hermetic (synthetic loop-state objects and scratch shas only, per
|
|
16
|
-
# this pass's own instruction not to spend a live draw), so it belongs with everything else in
|
|
17
|
-
# this file that shares that property, disjointness convention notwithstanding.
|
|
18
|
-
set -uo pipefail
|
|
19
|
-
|
|
20
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
21
|
-
cd "$ROOT"
|
|
22
|
-
CVD=tests/evals/convergence.mjs
|
|
23
|
-
pass=0; fail=0
|
|
24
|
-
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
25
|
-
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
26
|
-
check(){ if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want '$3', got '$2')"; fi; }
|
|
27
|
-
|
|
28
|
-
# Run a snippet with convergence.mjs imported as `M` -- same idiom eval-runner.sh's own `cj()`
|
|
29
|
-
# uses for lib/convergence.mjs, kept as a function so no case can forget the import path.
|
|
30
|
-
cj() { node --input-type=module -e "const M = await import('$ROOT/$CVD'); $1" 2>&1; }
|
|
31
|
-
|
|
32
|
-
echo "== convergence gate CLI (3.4) =="
|
|
33
|
-
|
|
34
|
-
# --- sha is a documented CLI input surface now; validateSha() is the boundary check ------
|
|
35
|
-
# `sha` reaches join() inside loopShardPath()/loopShardDir() unvalidated -- these cases pin the
|
|
36
|
-
# boundary check itself, both directions (a gate's suite must not only catch the bad
|
|
37
|
-
# input, it must also let a genuinely conforming one through).
|
|
38
|
-
check "validateSha accepts a real (40-char) git sha" \
|
|
39
|
-
"$(cj "process.stdout.write(M.validateSha('7c0ac2615fe6a14e3135d645645c59f1e38bd3bf'))")" \
|
|
40
|
-
"7c0ac2615fe6a14e3135d645645c59f1e38bd3bf"
|
|
41
|
-
check "validateSha accepts a short (7-char) sha, git's own minimum" \
|
|
42
|
-
"$(cj "process.stdout.write(M.validateSha('7c0ac26'))")" "7c0ac26"
|
|
43
|
-
|
|
44
|
-
f251_rejects() {
|
|
45
|
-
local got
|
|
46
|
-
got=$(cj "try { M.validateSha($2); process.stdout.write('NO THROW'); } catch { process.stdout.write('threw'); }")
|
|
47
|
-
check "validateSha rejects $1" "$got" "threw"
|
|
48
|
-
}
|
|
49
|
-
f251_rejects "a path-traversal attempt" "'../../../etc/passwd'"
|
|
50
|
-
f251_rejects "an absolute path" "'/etc/passwd'"
|
|
51
|
-
f251_rejects "uppercase hex (git shas print lowercase)" "'ABCDEF1'"
|
|
52
|
-
f251_rejects "a sha shorter than 7 chars" "'abc12'"
|
|
53
|
-
LONG41=$(printf 'a%.0s' $(seq 1 41))
|
|
54
|
-
f251_rejects "a sha longer than 40 chars" "'$LONG41'"
|
|
55
|
-
f251_rejects "a non-string" "42"
|
|
56
|
-
f251_rejects "null" "null"
|
|
57
|
-
|
|
58
|
-
# The underlying primitive has no traversal protection of its own -- proving WHY the boundary
|
|
59
|
-
# check has to exist, not just that it does: loopShardPath()/loopShardDir() join() sha straight
|
|
60
|
-
# into a path with no sanitising. Demonstrated by resolving the path a traversal sha WOULD
|
|
61
|
-
# produce and confirming it lands outside results/ -- read-only (path.resolve, no file touched).
|
|
62
|
-
escape_check=$(cj "
|
|
63
|
-
const path = await import('node:path');
|
|
64
|
-
const p = path.resolve(M.loopShardPath('../../../tmp/f251-probe', M.TASK_ID, 0));
|
|
65
|
-
const resultsDir = path.resolve('$ROOT/tests/evals/results');
|
|
66
|
-
process.stdout.write(String(!p.startsWith(resultsDir + path.sep)));
|
|
67
|
-
")
|
|
68
|
-
check "loopShardPath() itself has no traversal guard -- a raw '../../../tmp/f251-probe' sha resolves OUTSIDE results/ (this is what validateSha() at the CLI boundary exists to prevent)" \
|
|
69
|
-
"$escape_check" "true"
|
|
70
|
-
|
|
71
|
-
# Staged against a SCRATCH COPY, never the tracked file: neuter validateSha()'s own
|
|
72
|
-
# regex test so it can never throw, then drive the REAL CLI entrypoint (`--merge`) against it with
|
|
73
|
-
# the same traversal string above. The mutant must reach loopShardPath() with the traversal intact
|
|
74
|
-
# -- caught by checking the mutant's own reportArm() computes a path outside results/, the exact
|
|
75
|
-
# consequence the boundary check exists to prevent. Reverting restores the guard; the pristine file is checked last so this
|
|
76
|
-
# suite ends by re-confirming the shipped behaviour, not the mutant's.
|
|
77
|
-
F251_SCRATCH_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
78
|
-
trap 'rm -rf "$F251_SCRATCH_DIR"' EXIT
|
|
79
|
-
F251_SCRATCH="$F251_SCRATCH_DIR/convergence.mjs"
|
|
80
|
-
cp "$ROOT/$CVD" "$F251_SCRATCH"
|
|
81
|
-
ln -s "$ROOT/tests/evals/lib" "$F251_SCRATCH_DIR/lib"
|
|
82
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F251_SCRATCH_DIR/run.mjs"
|
|
83
|
-
node -e "
|
|
84
|
-
const fs = require('fs'); const p = '$F251_SCRATCH'; const s = fs.readFileSync(p, 'utf8');
|
|
85
|
-
const FROM = \"if (typeof sha !== 'string' || !/^[0-9a-f]{7,40}\$/.test(sha)) {\";
|
|
86
|
-
const TO = 'if (false) { // MUTANT (F-251): the boundary check never fires';
|
|
87
|
-
if (!s.includes(FROM)) throw new Error('F-251 mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
88
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
89
|
-
"
|
|
90
|
-
mutant_escape=$(node --input-type=module -e "
|
|
91
|
-
const M = await import('$F251_SCRATCH');
|
|
92
|
-
const path = await import('node:path');
|
|
93
|
-
const p = path.resolve(M.loopShardPath(M.validateSha('../../../tmp/f251-probe'), M.TASK_ID, 0));
|
|
94
|
-
const resultsDir = path.resolve('$ROOT/tests/evals/results');
|
|
95
|
-
process.stdout.write(String(!p.startsWith(resultsDir + path.sep)));
|
|
96
|
-
" 2>&1)
|
|
97
|
-
check "mutant (F-251: validateSha() neutered) lets a traversal sha through to loopShardPath() unrejected, landing outside results/" \
|
|
98
|
-
"$mutant_escape" "true"
|
|
99
|
-
pristine_rejects=$(cj "try { M.validateSha('../../../tmp/f251-probe'); process.stdout.write('NO THROW'); } catch { process.stdout.write('threw'); }")
|
|
100
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still rejects the same traversal sha" \
|
|
101
|
-
"$pristine_rejects" "threw"
|
|
102
|
-
rm -rf "$F251_SCRATCH_DIR"
|
|
103
|
-
trap - EXIT
|
|
104
|
-
|
|
105
|
-
# --- --dry-run: well-formed shape, mirroring run.mjs --dry-run's own contract -------------------
|
|
106
|
-
dryrun_out=$(node "$CVD" --dry-run --source HEAD)
|
|
107
|
-
dryrun_check=$(printf '%s' "$dryrun_out" | node -e "
|
|
108
|
-
let s=''; process.stdin.on('data', d=>s+=d).on('end', () => {
|
|
109
|
-
const o = JSON.parse(s);
|
|
110
|
-
const ok = o.dryRun === true && o.taskId === 'loop-code-loop' && Array.isArray(o.arm) && o.arm.length === 0
|
|
111
|
-
&& o.breach === false && o.runsRequested === 15 && typeof o.source.sha === 'string' && o.source.sha.length === 40
|
|
112
|
-
&& o.maxWaitAttempts === 2;
|
|
113
|
-
process.stdout.write(String(ok));
|
|
114
|
-
});
|
|
115
|
-
")
|
|
116
|
-
check "--dry-run produces a well-formed shape (dryRun:true, empty arm, breach:false, a real resolved sha, maxWaitAttempts echoing DEFAULT_MAX_WAIT_ATTEMPTS)" "$dryrun_check" "true"
|
|
117
|
-
check "--dry-run --runs 5 threads the requested count through" \
|
|
118
|
-
"$(node "$CVD" --dry-run --source HEAD --runs 5 | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>process.stdout.write(String(JSON.parse(s).runsRequested)))")" \
|
|
119
|
-
"5"
|
|
120
|
-
|
|
121
|
-
# --- --dry-run echoes the wait budget a live draw would actually use -- previously silent
|
|
122
|
-
# on it, so nothing confirmed a --max-wait-attempts value (or the implied default above) was the
|
|
123
|
-
# one that would apply before spending quota on the real draw.
|
|
124
|
-
check "--dry-run --max-wait-attempts 6 echoes the SUPPLIED value, not the default" \
|
|
125
|
-
"$(node "$CVD" --dry-run --source HEAD --max-wait-attempts 6 | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>process.stdout.write(String(JSON.parse(s).maxWaitAttempts)))")" \
|
|
126
|
-
"6"
|
|
127
|
-
|
|
128
|
-
# Mutation: prove the dry-run echo can actually fail to reflect the real value. Staged on a scratch
|
|
129
|
-
# copy, never the tracked file. Unversioned source (--source ., sha null) so this stays hermetic
|
|
130
|
-
# and quick, the same choice the fixture-pin mutation test below makes for the same reason.
|
|
131
|
-
F300_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
132
|
-
trap 'rm -rf "$F300_MUT_DIR"' EXIT
|
|
133
|
-
F300_MUT="$F300_MUT_DIR/convergence.mjs"
|
|
134
|
-
cp "$ROOT/$CVD" "$F300_MUT"
|
|
135
|
-
ln -s "$ROOT/tests/evals/lib" "$F300_MUT_DIR/lib"
|
|
136
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F300_MUT_DIR/run.mjs"
|
|
137
|
-
node -e "
|
|
138
|
-
const fs = require('fs'); const p = '$F300_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
139
|
-
const FROM = 'maxWaitAttempts: args.maxWaitAttempts ?? DEFAULT_MAX_WAIT_ATTEMPTS,';
|
|
140
|
-
const TO = 'maxWaitAttempts: null, // MUTANT (F-300): dry-run no longer echoes the wait budget';
|
|
141
|
-
if (!s.includes(FROM)) throw new Error('F-300 mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
142
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
143
|
-
"
|
|
144
|
-
mutant_dryrun_wait=$(node "$F300_MUT" --dry-run --source . --max-wait-attempts 6 | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>process.stdout.write(String(JSON.parse(s).maxWaitAttempts)))")
|
|
145
|
-
check "mutant (F-300: dry-run maxWaitAttempts forced null) no longer echoes the supplied --max-wait-attempts 6, catching the regression the checks above exist for" \
|
|
146
|
-
"$mutant_dryrun_wait" "null"
|
|
147
|
-
pristine_dryrun_wait=$(node "$CVD" --dry-run --source . --max-wait-attempts 6 | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>process.stdout.write(String(JSON.parse(s).maxWaitAttempts)))")
|
|
148
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still echoes maxWaitAttempts:6" \
|
|
149
|
-
"$pristine_dryrun_wait" "6"
|
|
150
|
-
rm -rf "$F300_MUT_DIR"
|
|
151
|
-
trap - EXIT
|
|
152
|
-
|
|
153
|
-
# Leak checks diff the set of live somi-eval-src-* worktrees, not a repo-wide count, which flaked (#39).
|
|
154
|
-
eval_src_worktrees() { git worktree list --porcelain | sed -n 's/^worktree //p' | grep '/somi-eval-src-' | while IFS= read -r p; do [ -d "$p" ] && echo "$p"; done | sort; }
|
|
155
|
-
new_eval_src_worktrees() { comm -13 <(printf '%s\n' "$1") <(eval_src_worktrees) | sed '/^$/d'; }
|
|
156
|
-
wt_ctl_before=$(eval_src_worktrees); wt_ctl_dir=$(mktemp -d "${TMPDIR:-/tmp}/somi-eval-src-XXXXXX"); git worktree add --detach --quiet "$wt_ctl_dir" HEAD
|
|
157
|
-
check "positive control: a leaked somi-eval-src-* worktree is detected" "$(new_eval_src_worktrees "$wt_ctl_before")" "$wt_ctl_dir"
|
|
158
|
-
git worktree remove --force "$wt_ctl_dir"; rm -rf "$wt_ctl_dir"
|
|
159
|
-
# --dry-run leaves no worktree behind (resolveSource's own cleanup, exercised through this CLI).
|
|
160
|
-
wt_before=$(eval_src_worktrees)
|
|
161
|
-
node "$CVD" --dry-run --source HEAD >/dev/null
|
|
162
|
-
check "--dry-run cleans up its resolved worktree (no leak)" "$(new_eval_src_worktrees "$wt_before")" ""
|
|
163
|
-
|
|
164
|
-
# --- --dry-run: zero model calls, proven by execution (the same technique as eval-runner.sh), not by reading ---
|
|
165
|
-
# A stub `claude` on PATH proves NO route reaches the model -- not just that reading the dry-run
|
|
166
|
-
# branch shows no invokeCommand() call.
|
|
167
|
-
stub_bin=$(mktemp -d)
|
|
168
|
-
stub_sentinel="$stub_bin/touched"
|
|
169
|
-
printf '#!/bin/sh\n%s "%s"\nexit 1\n' "$(command -v touch)" "$stub_sentinel" > "$stub_bin/claude"
|
|
170
|
-
chmod +x "$stub_bin/claude"
|
|
171
|
-
PATH="$stub_bin:$PATH" node "$CVD" --dry-run --source HEAD >/dev/null 2>&1
|
|
172
|
-
check "no route from --dry-run reaches a stub claude on PATH (sentinel stays absent)" \
|
|
173
|
-
"$([ -e "$stub_sentinel" ] && echo TOUCHED || echo ABSENT)" "ABSENT"
|
|
174
|
-
# Positive control (same technique as eval-runner.sh): proves the stub is reachable on PATH at all.
|
|
175
|
-
PATH="$stub_bin" claude >/dev/null 2>&1
|
|
176
|
-
check "positive control: claude invoked directly under the same stub touches the sentinel" \
|
|
177
|
-
"$([ -e "$stub_sentinel" ] && echo TOUCHED || echo ABSENT)" "TOUCHED"
|
|
178
|
-
rm -rf "$stub_bin"
|
|
179
|
-
|
|
180
|
-
# --- live mode preflights BEFORE resolveSource's worktree checkout ------------------------------
|
|
181
|
-
# Simulated by stripping PATH/HOME so neither the CLI nor a credential resolves (the same technique as
|
|
182
|
-
# eval-runner.sh), never by mocking preflight() itself. A worktree created despite this would
|
|
183
|
-
# mean the CLI paid for a checkout it could never use.
|
|
184
|
-
NODE_BIN=$(command -v node)
|
|
185
|
-
wt_before2=$(eval_src_worktrees)
|
|
186
|
-
preflight_msg=$(env -i "PATH=$(dirname "$NODE_BIN")" HOME=/nonexistent "$NODE_BIN" "$CVD" --source HEAD --runs 1 2>&1)
|
|
187
|
-
case "$preflight_msg" in
|
|
188
|
-
*"not ready to draw"*) ok "live mode preflights before spending any quota (message names the reason)" ;;
|
|
189
|
-
*) bad "live mode preflights before spending any quota (got: ${preflight_msg:0:120})" ;;
|
|
190
|
-
esac
|
|
191
|
-
check "the preflight failure above never reached resolveSource -- no worktree was created" "$(new_eval_src_worktrees "$wt_before2")" ""
|
|
192
|
-
|
|
193
|
-
# --- --merge / --certify: fold shards already on disk, no live draw -----------------------------
|
|
194
|
-
MERGE_SHA="deadbeefcafe1234567890"
|
|
195
|
-
cj "
|
|
196
|
-
const occ = new Set();
|
|
197
|
-
M.writeNextShard('$MERGE_SHA', M.TASK_ID, 15, occ, 0, 2);
|
|
198
|
-
M.writeNextShard('$MERGE_SHA', M.TASK_ID, 15, occ, 1, 3);
|
|
199
|
-
M.writeNextShard('$MERGE_SHA', M.TASK_ID, 15, occ, 2, 1);
|
|
200
|
-
" >/dev/null
|
|
201
|
-
merge_out=$(node "$CVD" --merge "$MERGE_SHA" --runs 15)
|
|
202
|
-
check "--merge folds 3 shards into an arm of 3 usable draws" \
|
|
203
|
-
"$(printf '%s' "$merge_out" | grep -c '^deadbeefcafe: 3/15 usable draw(s) on disk$')" "1"
|
|
204
|
-
check "--merge computes the arm's mean correctly ([2,3,1] -> 2.0000)" \
|
|
205
|
-
"$(printf '%s' "$merge_out" | grep -c 'mean: 2.0000$')" "1"
|
|
206
|
-
check "--merge computes the arm's sample sd correctly ([2,3,1], n-1 denominator -> 1.0000)" \
|
|
207
|
-
"$(printf '%s' "$merge_out" | grep -c 'sd: 1.0000$')" "1"
|
|
208
|
-
certify_out=$(node "$CVD" --certify "$MERGE_SHA" --runs 15)
|
|
209
|
-
check "--certify is the SAME report as --merge (folding IS the report, no second scope here)" \
|
|
210
|
-
"$certify_out" "$merge_out"
|
|
211
|
-
rm -rf "$ROOT/tests/evals/results/$MERGE_SHA"
|
|
212
|
-
|
|
213
|
-
check "--merge on a sha with zero shards on disk reports 0/N, mean/sd n/a rather than throwing" \
|
|
214
|
-
"$(node "$CVD" --merge deadbeef00 --runs 15 | tr '\n' '|')" \
|
|
215
|
-
"deadbeef00: 0/15 usable draw(s) on disk| arm: []| mean: n/a| sd: n/a (need >= 2 draws)|"
|
|
216
|
-
|
|
217
|
-
check "--merge with an invalid sha is rejected before anything is read (F-251, at the CLI itself)" \
|
|
218
|
-
"$(node "$CVD" --merge '../../../etc/passwd' >/dev/null 2>&1; echo $?)" "1"
|
|
219
|
-
|
|
220
|
-
# --- shards carry the loop's terminal verdict alongside its pass count -------------------
|
|
221
|
-
# The first live batch showed task02-code sitting at
|
|
222
|
-
# the pass-count floor (arm [1,1,1], mean 1.0, sd 0.0) with no retained artifact able to say WHY
|
|
223
|
-
# -- the shard carried only `pass`, and cleanup() correctly destroys the workDir the
|
|
224
|
-
# instant a draw completes. terminalVerdict() (lib/convergence.mjs) is the read side;
|
|
225
|
-
# writeNextShard()'s new `verdict` param and makeShardWriter() (this module) are the write side
|
|
226
|
-
# that threads it into the shard.
|
|
227
|
-
LCONV=tests/evals/lib/convergence.mjs
|
|
228
|
-
lj() { node --input-type=module -e "const L = await import('$ROOT/$LCONV'); $1" 2>&1; }
|
|
229
|
-
|
|
230
|
-
# terminalVerdict() fails safe, same posture as passesToApprove()/capBreached() -- those two's own
|
|
231
|
-
# extractor-level tests live in eval-runner.sh's extractor section; terminalVerdict() is pinned here
|
|
232
|
-
# instead per this file's own exception above.
|
|
233
|
-
check "terminalVerdict(null) is null (fails safe)" \
|
|
234
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict(null)));")" "null"
|
|
235
|
-
check "terminalVerdict(undefined) is null" \
|
|
236
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict(undefined)));")" "null"
|
|
237
|
-
check "terminalVerdict(42) is null (non-object input, not coerced)" \
|
|
238
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict(42)));")" "null"
|
|
239
|
-
check "terminalVerdict({}) is null (no history field at all -- the three real F-266 shards' own shape, pre-F-267)" \
|
|
240
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({})));")" "null"
|
|
241
|
-
check "terminalVerdict({history:[]}) is null (empty history)" \
|
|
242
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({history:[]})));")" "null"
|
|
243
|
-
check "terminalVerdict({history:'nope'}) is null (history not an array, not coerced)" \
|
|
244
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({history:'nope'})));")" "null"
|
|
245
|
-
check "terminalVerdict({history:[{pass:1}]}) is null (entry present, no verdict field)" \
|
|
246
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({history:[{pass:1}]})));")" "null"
|
|
247
|
-
check "terminalVerdict({history:[{verdict:7}]}) is null (verdict not a string, not coerced)" \
|
|
248
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({history:[{verdict:7}]})));")" "null"
|
|
249
|
-
check "terminalVerdict on a single-pass history returns that pass's verdict" \
|
|
250
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({history:[{pass:1,verdict:'approve'}]})));")" "approve"
|
|
251
|
-
check "terminalVerdict on a two-pass history returns the LAST entry's verdict, not the first -- 'terminal', not 'initial'" \
|
|
252
|
-
"$(lj "process.stdout.write(String(L.terminalVerdict({history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve'}]})));")" "approve"
|
|
253
|
-
|
|
254
|
-
# Mutation: prove the "LAST, not first" assertion above can actually fail. Staged on a scratch
|
|
255
|
-
# copy (mktemp -d), never the tracked file.
|
|
256
|
-
F267_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
257
|
-
trap 'rm -rf "$F267_MUT_DIR"' EXIT
|
|
258
|
-
F267_MUT="$F267_MUT_DIR/convergence.mjs"
|
|
259
|
-
cp "$ROOT/$LCONV" "$F267_MUT"
|
|
260
|
-
node -e "
|
|
261
|
-
const fs = require('fs'); const p = '$F267_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
262
|
-
const FROM = 'const last = history[history.length - 1];';
|
|
263
|
-
const TO = 'const last = history[0]; // MUTANT (F-267): reads the FIRST pass, not the terminal one';
|
|
264
|
-
if (!s.includes(FROM)) throw new Error('F-267 mutant pattern not found in lib/convergence.mjs -- source moved, update this mutation');
|
|
265
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
266
|
-
"
|
|
267
|
-
mutant_verdict=$(node --input-type=module -e "
|
|
268
|
-
const L = await import('$F267_MUT');
|
|
269
|
-
process.stdout.write(String(L.terminalVerdict({history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve'}]})));
|
|
270
|
-
")
|
|
271
|
-
check "mutant (F-267: terminalVerdict reads history[0]) returns the FIRST verdict ('request-changes'), catching the exact regression the 'LAST, not first' test above exists for" \
|
|
272
|
-
"$mutant_verdict" "request-changes"
|
|
273
|
-
pristine_verdict=$(lj "process.stdout.write(String(L.terminalVerdict({history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve'}]})));")
|
|
274
|
-
check "pristine lib/convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still returns the terminal verdict ('approve')" \
|
|
275
|
-
"$pristine_verdict" "approve"
|
|
276
|
-
rm -rf "$F267_MUT_DIR"
|
|
277
|
-
trap - EXIT
|
|
278
|
-
|
|
279
|
-
# --- terminalVerdict() alone can't tell a real coder/reviewer round trip from a loop that
|
|
280
|
-
# approved an untouched tree ({pass:1, verdict:'approve'} is exactly what a do-nothing loop would
|
|
281
|
-
# also write) -- terminalOutcome() widens the extraction to the whole terminal entry. Same
|
|
282
|
-
# fail-safe posture, each field independently null -- a missing count reads as "unknown", not 0.
|
|
283
|
-
check "terminalOutcome(null) is null (fails safe)" \
|
|
284
|
-
"$(lj "process.stdout.write(String(L.terminalOutcome(null)));")" "null"
|
|
285
|
-
check "terminalOutcome({}) is null (no history -- the three real F-266 shards' own shape)" \
|
|
286
|
-
"$(lj "process.stdout.write(String(L.terminalOutcome({})));")" "null"
|
|
287
|
-
check "terminalOutcome({history:[]}) is null (empty history)" \
|
|
288
|
-
"$(lj "process.stdout.write(String(L.terminalOutcome({history:[]})));")" "null"
|
|
289
|
-
check "terminalOutcome extracts all four fields from the TERMINAL (not first) entry" \
|
|
290
|
-
"$(lj "process.stdout.write(JSON.stringify(L.terminalOutcome({history:[{pass:1,verdict:'request-changes',blockers:2,majors:1,diff_lines:40},{pass:2,verdict:'approve',blockers:0,majors:0,diff_lines:58}]})));")" \
|
|
291
|
-
'{"verdict":"approve","blockers":0,"majors":0,"diffLines":58}'
|
|
292
|
-
check "terminalOutcome: entry missing blockers/majors/diff_lines -- each independently null, not defaulted to 0" \
|
|
293
|
-
"$(lj "process.stdout.write(JSON.stringify(L.terminalOutcome({history:[{verdict:'approve'}]})));")" \
|
|
294
|
-
'{"verdict":"approve","blockers":null,"majors":null,"diffLines":null}'
|
|
295
|
-
check "terminalOutcome: wrong-typed/negative counts are not coerced -- null, not passed through" \
|
|
296
|
-
"$(lj "process.stdout.write(JSON.stringify(L.terminalOutcome({history:[{verdict:'approve',blockers:'2',majors:-1,diff_lines:1.5}]})));")" \
|
|
297
|
-
'{"verdict":"approve","blockers":null,"majors":null,"diffLines":null}'
|
|
298
|
-
|
|
299
|
-
# --- writeNextShard(): the new `verdict` parameter, and backward compatibility for every
|
|
300
|
-
# pre-verdict 6-arg call site (this file's own MERGE_SHA writes above, eval-runner.sh's shard-write tests) -
|
|
301
|
-
F267_SHA1="f267verdict$(date +%s)"
|
|
302
|
-
verdict_written=$(cj "
|
|
303
|
-
const fs = await import('node:fs');
|
|
304
|
-
const occ = new Set();
|
|
305
|
-
const idx = M.writeNextShard('$F267_SHA1', M.TASK_ID, 5, occ, 0, 2, 'approve');
|
|
306
|
-
const rec = JSON.parse(fs.readFileSync(M.loopShardPath('$F267_SHA1', M.TASK_ID, idx), 'utf8'));
|
|
307
|
-
process.stdout.write(JSON.stringify(rec.run));
|
|
308
|
-
")
|
|
309
|
-
check "writeNextShard(..., verdict) writes it into run.verdict (run.terminal an explicit null, F-268, when not passed)" \
|
|
310
|
-
"$verdict_written" '{"index":0,"pass":2,"verdict":"approve","terminal":null}'
|
|
311
|
-
rm -rf "$ROOT/tests/evals/results/$F267_SHA1"
|
|
312
|
-
|
|
313
|
-
F267_SHA2="f267noverdict$(date +%s)"
|
|
314
|
-
verdict_defaulted=$(cj "
|
|
315
|
-
const fs = await import('node:fs');
|
|
316
|
-
const occ = new Set();
|
|
317
|
-
const idx = M.writeNextShard('$F267_SHA2', M.TASK_ID, 5, occ, 0, 3);
|
|
318
|
-
const rec = JSON.parse(fs.readFileSync(M.loopShardPath('$F267_SHA2', M.TASK_ID, idx), 'utf8'));
|
|
319
|
-
process.stdout.write(JSON.stringify(rec.run) + '|' + ('verdict' in rec.run) + '|' + ('terminal' in rec.run));
|
|
320
|
-
")
|
|
321
|
-
check "writeNextShard called with NO verdict/terminal arg (every pre-F-267 call site's own shape) still writes both as explicit null keys, not omitted ones" \
|
|
322
|
-
"$verdict_defaulted" '{"index":0,"pass":3,"verdict":null,"terminal":null}|true|true'
|
|
323
|
-
rm -rf "$ROOT/tests/evals/results/$F267_SHA2"
|
|
324
|
-
|
|
325
|
-
# --- makeShardWriter(): the real onDraw wiring drawArmForSha() uses, driven through the REAL
|
|
326
|
-
# fillArm() with a synthetic (non-live) draw handle -- no /code-loop invocation, no quota spent ---
|
|
327
|
-
F267_SHA3="f267wiring$(date +%s)"
|
|
328
|
-
wiring_check=$(cj "
|
|
329
|
-
const fs = await import('node:fs');
|
|
330
|
-
const state = { status: 'done', pass: 2, history: [{ pass: 1, verdict: 'request-changes' }, { pass: 2, verdict: 'approve', blockers: 0, majors: 0, diff_lines: 58 }] };
|
|
331
|
-
const makeDraw = () => ({ read: () => state, retry() {}, cleanup() {} });
|
|
332
|
-
const occ = new Set();
|
|
333
|
-
const { newDraw, onDraw } = M.makeShardWriter(makeDraw, '$F267_SHA3', M.TASK_ID, 1, occ, 0);
|
|
334
|
-
const r = M.fillArm(newDraw, { n: 1, onDraw });
|
|
335
|
-
const rec = JSON.parse(fs.readFileSync(M.loopShardPath('$F267_SHA3', M.TASK_ID, 0), 'utf8'));
|
|
336
|
-
process.stdout.write(JSON.stringify({ arm: r.arm, verdict: rec.run.verdict, terminal: rec.run.terminal }));
|
|
337
|
-
")
|
|
338
|
-
check "makeShardWriter()'s onDraw, driven for real through fillArm(), writes the TERMINAL verdict AND the widened terminal object (F-268) from a two-entry history -- the exact assembly drawArmForSha() uses, without a live draw" \
|
|
339
|
-
"$wiring_check" '{"arm":[2],"verdict":"approve","terminal":{"verdict":"approve","blockers":0,"majors":0,"diffLines":58}}'
|
|
340
|
-
rm -rf "$ROOT/tests/evals/results/$F267_SHA3"
|
|
341
|
-
|
|
342
|
-
# --- constraint 1: a shard with NO run.verdict key at all (the real, pre-fix shape -- see
|
|
343
|
-
# diary.md, 2026-09-05; independently checked by hand against the actual quota-paid shards at
|
|
344
|
-
# tests/evals/results/39411eb.../convergence/, gitignored and session-specific, so NOT reproduced
|
|
345
|
-
# here as a committed dependency -- see the coder's own report) must still fold as a usable draw:
|
|
346
|
-
# never discarded, never an error. Staged as a synthetic legacy shard so this guard stays hermetic
|
|
347
|
-
# and portable across clones/CI that don't carry that local, gitignored quota-paid data.
|
|
348
|
-
F267_LEGACY_SHA="f267legacy$(date +%s)"
|
|
349
|
-
cj "
|
|
350
|
-
const fs = await import('node:fs');
|
|
351
|
-
const path = await import('node:path');
|
|
352
|
-
const p = M.loopShardPath('$F267_LEGACY_SHA', M.TASK_ID, 0);
|
|
353
|
-
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
354
|
-
fs.writeFileSync(p, JSON.stringify({ sha: '$F267_LEGACY_SHA', taskId: M.TASK_ID, schema: M.LOOP_SCHEMA_VERSION, run: { index: 0, pass: 1 } }) + '\n');
|
|
355
|
-
" >/dev/null
|
|
356
|
-
legacy_resume() { cj "process.stdout.write(JSON.stringify(M.resumeArm('$F267_LEGACY_SHA', M.TASK_ID, 1).resume));"; }
|
|
357
|
-
check "F-267/constraint 1: a shard with NO run.verdict key at all (the real, pre-fix shape) still folds as a usable draw" \
|
|
358
|
-
"$(legacy_resume)" "[1]"
|
|
359
|
-
|
|
360
|
-
# Mutation: prove the guard above can actually fail. readLoopShard()'s schema gate is mutated to
|
|
361
|
-
# ALSO require a verdict -- the exact shape of regression constraint 1 forbids -- staged on a
|
|
362
|
-
# scratch copy, read against the SAME on-disk legacy shard (read-only; confirmed untouched by the
|
|
363
|
-
# final re-check below).
|
|
364
|
-
F267_C1_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
365
|
-
trap 'rm -rf "$F267_C1_DIR"' EXIT
|
|
366
|
-
F267_C1="$F267_C1_DIR/convergence.mjs"
|
|
367
|
-
cp "$ROOT/$CVD" "$F267_C1"
|
|
368
|
-
ln -s "$ROOT/tests/evals/lib" "$F267_C1_DIR/lib"
|
|
369
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F267_C1_DIR/run.mjs"
|
|
370
|
-
node -e "
|
|
371
|
-
const fs = require('fs'); const p = '$F267_C1'; const s = fs.readFileSync(p, 'utf8');
|
|
372
|
-
const FROM = 'return rec?.schema === LOOP_SCHEMA_VERSION ? rec : null;';
|
|
373
|
-
const TO = 'return rec?.schema === LOOP_SCHEMA_VERSION \&\& rec.run?.verdict != null ? rec : null; // MUTANT (F-267): wrongly requires a verdict to fold';
|
|
374
|
-
if (!s.includes(FROM)) throw new Error('F-267 constraint-1 mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
375
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
376
|
-
"
|
|
377
|
-
mutant_resume=$(node --input-type=module -e "
|
|
378
|
-
const M = await import('$F267_C1');
|
|
379
|
-
process.stdout.write(JSON.stringify(M.resumeArm('$F267_LEGACY_SHA', M.TASK_ID, 1).resume));
|
|
380
|
-
")
|
|
381
|
-
check "mutant (F-267: readLoopShard wrongly requires a verdict) discards the legacy shard -- [] not [1], catching the exact regression constraint 1 forbids" \
|
|
382
|
-
"$mutant_resume" "[]"
|
|
383
|
-
pristine_resume=$(legacy_resume)
|
|
384
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still folds the legacy shard, [1]" \
|
|
385
|
-
"$pristine_resume" "[1]"
|
|
386
|
-
rm -rf "$F267_C1_DIR"
|
|
387
|
-
trap - EXIT
|
|
388
|
-
rm -rf "$ROOT/tests/evals/results/$F267_LEGACY_SHA"
|
|
389
|
-
|
|
390
|
-
# --- a censored draw retains a diagnostic record (elapsed wall-clock, wait attempts, ------
|
|
391
|
-
# last-seen loop state) -- the first live batch showed three draws
|
|
392
|
-
# read back as still-`running`; once the wait budget is exhausted, fillArm() previously discarded
|
|
393
|
-
# the last-read state entirely -- no shard is written and the workDir is cleaned up, so "the loop
|
|
394
|
-
# was genuinely slow" (cost-correlated) and "the subprocess died in thirty seconds"
|
|
395
|
-
# (uncorrelated with cost) were indistinguishable from any retained artifact. censoredDrawSnapshot()
|
|
396
|
-
# (lib/convergence.mjs) is the read side; fillArm()'s new `censor` field and writeCensorRecord()
|
|
397
|
-
# (this module) are the write side. Does NOT change what counts as a usable draw or the censoring
|
|
398
|
-
# policy itself (still exactly `waitAttempts > maxWaitAttempts`) -- only what gets recorded.
|
|
399
|
-
MK_SEQ_DRAW='
|
|
400
|
-
function mkSeqDraw(seq) {
|
|
401
|
-
let i = 0;
|
|
402
|
-
return () => {
|
|
403
|
-
const states = seq[i++]; let idx = 0;
|
|
404
|
-
return { read: () => states[idx], retry: () => { idx = Math.min(idx + 1, states.length - 1); } };
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
'
|
|
408
|
-
|
|
409
|
-
# censoredDrawSnapshot() fails safe, same posture as terminalVerdict()/terminalOutcome() above --
|
|
410
|
-
# always an object (the caller only calls this once a censoring event is already known to have
|
|
411
|
-
# happened); status/historyEmpty independently null on an unrecognised shape, stateReadable always
|
|
412
|
-
# a determinate boolean. `pass`/`lastVerdict` are added below, same fail-safe posture -- see the function's own docstring.
|
|
413
|
-
# `completedPasses` added alongside: `pass` alone is the pass most recently
|
|
414
|
-
# STARTED, possibly still in progress, never "the last completed pass" -- `completedPasses`
|
|
415
|
-
# (`history.length`) is the disambiguator that says which pass `lastVerdict` actually belongs to.
|
|
416
|
-
check "censoredDrawSnapshot(null) is {status:null,historyEmpty:null,stateReadable:false,pass:null,completedPasses:null,lastVerdict:null} (fails safe)" \
|
|
417
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot(null)));")" \
|
|
418
|
-
'{"status":null,"historyEmpty":null,"stateReadable":false,"pass":null,"completedPasses":null,"lastVerdict":null}'
|
|
419
|
-
check "censoredDrawSnapshot(undefined) is the same" \
|
|
420
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot(undefined)));")" \
|
|
421
|
-
'{"status":null,"historyEmpty":null,"stateReadable":false,"pass":null,"completedPasses":null,"lastVerdict":null}'
|
|
422
|
-
check "censoredDrawSnapshot(42) is the same (non-object input, not coerced)" \
|
|
423
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot(42)));")" \
|
|
424
|
-
'{"status":null,"historyEmpty":null,"stateReadable":false,"pass":null,"completedPasses":null,"lastVerdict":null}'
|
|
425
|
-
check "censoredDrawSnapshot({}) -- stateReadable true (it IS an object), status/historyEmpty/pass/completedPasses/lastVerdict still null (no fields to read)" \
|
|
426
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({})));")" \
|
|
427
|
-
'{"status":null,"historyEmpty":null,"stateReadable":true,"pass":null,"completedPasses":null,"lastVerdict":null}'
|
|
428
|
-
check "censoredDrawSnapshot({status:'running'}) reports the status; historyEmpty/pass/completedPasses/lastVerdict null (no history or pass field to read)" \
|
|
429
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running'})));")" \
|
|
430
|
-
'{"status":"running","historyEmpty":null,"stateReadable":true,"pass":null,"completedPasses":null,"lastVerdict":null}'
|
|
431
|
-
check "censoredDrawSnapshot({status:'running',history:[]}) -- empty history means no pass has COMPLETED yet (scripts/somi-loop.mjs init's own pre-work state), NOT proof the loop died immediately -- a stalled pass 1 reads identically (F-277, code-loop pass 2 review); completedPasses:0, the same 'no pass finished yet' fact historyEmpty already states, read off history.length directly" \
|
|
432
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',history:[]})));")" \
|
|
433
|
-
'{"status":"running","historyEmpty":true,"stateReadable":true,"pass":null,"completedPasses":0,"lastVerdict":null}'
|
|
434
|
-
check "censoredDrawSnapshot({status:'running',history:[{pass:1}]}) -- non-empty history is the 'at least one pass completed' shape; pass stays null (the top-level pass field, not history[i].pass, is what passesToApprove() reads); completedPasses:1 (one history entry); lastVerdict stays null (the entry has no verdict field)" \
|
|
435
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',history:[{pass:1}]})));")" \
|
|
436
|
-
'{"status":"running","historyEmpty":false,"stateReadable":true,"pass":null,"completedPasses":1,"lastVerdict":null}'
|
|
437
|
-
check "censoredDrawSnapshot: wrong-typed status/history are not coerced -- null, not passed through; stateReadable still true (an object WAS read, however malformed its fields); completedPasses null too (history isn't a readable array)" \
|
|
438
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:7,history:'nope'})));")" \
|
|
439
|
-
'{"status":null,"historyEmpty":null,"stateReadable":true,"pass":null,"completedPasses":null,"lastVerdict":null}'
|
|
440
|
-
check "F-279: stateReadable now separates 'no readable state at all' (null) from 'state read but malformed' ({status:7,...}) -- previously both collapsed to the identical {status:null,historyEmpty:null} record" \
|
|
441
|
-
"$(lj "process.stdout.write(JSON.stringify([L.censoredDrawSnapshot(null).stateReadable, L.censoredDrawSnapshot({status:7,history:'nope'}).stateReadable]));")" \
|
|
442
|
-
'[false,true]'
|
|
443
|
-
# a draw that HAS iterated (a real top-level pass count, a real prior verdict in
|
|
444
|
-
# history) surfaces the new fields with real, non-null values -- not merely a null-shaped
|
|
445
|
-
# addition every case above would also pass if pass/lastVerdict were wired to always return null.
|
|
446
|
-
# This case's history has exactly ONE entry (completedPasses:1), so `pass:2` reads as "mid-pass 2"
|
|
447
|
-
# -- lastVerdict belongs to the ALREADY-completed pass 1, not to `pass` itself.
|
|
448
|
-
check "censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'approve-with-comments'}]}) reports the real pass count and the real last verdict; completedPasses:1 -- pass 2 is still IN PROGRESS, one pass behind pass" \
|
|
449
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'approve-with-comments'}]})));")" \
|
|
450
|
-
'{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":1,"lastVerdict":"approve-with-comments"}'
|
|
451
|
-
# the OTHER ambiguous case `pass` alone cannot distinguish from the one above -- pass 2
|
|
452
|
-
# has ALSO just been recorded (completedPasses:2 == pass), and lastVerdict is pass 2's OWN verdict,
|
|
453
|
-
# not pass 1's. Two-entry history with DIFFERING verdicts also closes the terminal-entry case (a mutant reading
|
|
454
|
-
# history[0] instead of the terminal entry would report 'request-changes', the FIRST verdict, not
|
|
455
|
-
# 'approve-with-comments').
|
|
456
|
-
check "censoredDrawSnapshot({status:'running',pass:2,history:[pass1,pass2]}) -- completedPasses:2 (pass 2 already recorded), lastVerdict is pass 2's OWN verdict (the LAST entry), not pass 1's -- the case F-296's disambiguation exists to distinguish from the completedPasses:1 case above" \
|
|
457
|
-
"$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve-with-comments'}]})));")" \
|
|
458
|
-
'{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":2,"lastVerdict":"approve-with-comments"}'
|
|
459
|
-
|
|
460
|
-
# Mutation: prove pass/lastVerdict can actually fail to be extracted, not merely present-as-null.
|
|
461
|
-
# Staged on a scratch copy of lib/convergence.mjs, never the tracked file.
|
|
462
|
-
F295_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
463
|
-
trap 'rm -rf "$F295_MUT_DIR"' EXIT
|
|
464
|
-
F295_MUT="$F295_MUT_DIR/convergence.mjs"
|
|
465
|
-
cp "$ROOT/$LCONV" "$F295_MUT"
|
|
466
|
-
node -e "
|
|
467
|
-
const fs = require('fs'); const p = '$F295_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
468
|
-
const FROM = 'const pass = passesToApprove(loopStateJson);\n const lastVerdict = terminalVerdict(loopStateJson);';
|
|
469
|
-
const TO = 'const pass = null; const lastVerdict = null; // MUTANT (F-295): forced null, reproducing the pre-fix gap';
|
|
470
|
-
if (!s.includes(FROM)) throw new Error('F-295 mutant pattern not found in lib/convergence.mjs -- source moved, update this mutation');
|
|
471
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
472
|
-
"
|
|
473
|
-
mutant_pass_verdict=$(node --input-type=module -e "
|
|
474
|
-
const L = await import('$F295_MUT');
|
|
475
|
-
process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'approve-with-comments'}]})));
|
|
476
|
-
")
|
|
477
|
-
check "mutant (F-295: pass/lastVerdict forced null) reproduces the exact pre-fix gap -- a real pass 2/real verdict draw reads null,null, catching the regression the check above exists for" \
|
|
478
|
-
"$mutant_pass_verdict" '{"status":"running","historyEmpty":false,"stateReadable":true,"pass":null,"completedPasses":1,"lastVerdict":null}'
|
|
479
|
-
pristine_pass_verdict=$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'approve-with-comments'}]})));")
|
|
480
|
-
check "pristine lib/convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still reports the real pass and verdict" \
|
|
481
|
-
"$pristine_pass_verdict" '{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":1,"lastVerdict":"approve-with-comments"}'
|
|
482
|
-
rm -rf "$F295_MUT_DIR"
|
|
483
|
-
trap - EXIT
|
|
484
|
-
|
|
485
|
-
# Mutation: prove completedPasses can actually fail to be extracted -- forced null, the
|
|
486
|
-
# exact ambiguity this field exists to resolve. Staged on a scratch copy, never the tracked file.
|
|
487
|
-
F296_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
488
|
-
trap 'rm -rf "$F296_MUT_DIR"' EXIT
|
|
489
|
-
F296_MUT="$F296_MUT_DIR/convergence.mjs"
|
|
490
|
-
cp "$ROOT/$LCONV" "$F296_MUT"
|
|
491
|
-
node -e "
|
|
492
|
-
const fs = require('fs'); const p = '$F296_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
493
|
-
const FROM = 'const completedPasses = Array.isArray(history) ? history.length : null;';
|
|
494
|
-
const TO = 'const completedPasses = null; // MUTANT (F-296): forced null, reproducing the pass-vs-completedPasses ambiguity this field exists to resolve';
|
|
495
|
-
if (!s.includes(FROM)) throw new Error('F-296 mutant pattern not found in lib/convergence.mjs -- source moved, update this mutation');
|
|
496
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
497
|
-
"
|
|
498
|
-
mutant_completed_passes=$(node --input-type=module -e "
|
|
499
|
-
const L = await import('$F296_MUT');
|
|
500
|
-
process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve-with-comments'}]})));
|
|
501
|
-
")
|
|
502
|
-
check "mutant (F-296: completedPasses forced null) reads completedPasses:null on a real 2-entry-history draw, reproducing the exact ambiguity ('pass:2' alone can't say whether pass 2 is in progress or already recorded) that this field exists to resolve -- historyEmpty also reads null, since it is defined in terms of completedPasses, not independently" \
|
|
503
|
-
"$mutant_completed_passes" '{"status":"running","historyEmpty":null,"stateReadable":true,"pass":2,"completedPasses":null,"lastVerdict":"approve-with-comments"}'
|
|
504
|
-
pristine_completed_passes=$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve-with-comments'}]})));")
|
|
505
|
-
check "pristine lib/convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still reports completedPasses:2" \
|
|
506
|
-
"$pristine_completed_passes" '{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":2,"lastVerdict":"approve-with-comments"}'
|
|
507
|
-
rm -rf "$F296_MUT_DIR"
|
|
508
|
-
trap - EXIT
|
|
509
|
-
|
|
510
|
-
# Mutation: prove lastVerdict actually reads the TERMINAL entry, not the first one -- every
|
|
511
|
-
# censoredDrawSnapshot() case above the two-entry one has at most ONE history entry, so a mutant
|
|
512
|
-
# that reads history[0] instead of the last entry is indistinguishable from the correct
|
|
513
|
-
# implementation on all of them; only the differing-verdicts two-entry case above can tell them
|
|
514
|
-
# apart. Staged on a scratch copy, never the tracked file.
|
|
515
|
-
F297_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
516
|
-
trap 'rm -rf "$F297_MUT_DIR"' EXIT
|
|
517
|
-
F297_MUT="$F297_MUT_DIR/convergence.mjs"
|
|
518
|
-
cp "$ROOT/$LCONV" "$F297_MUT"
|
|
519
|
-
node -e "
|
|
520
|
-
const fs = require('fs'); const p = '$F297_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
521
|
-
const FROM = 'const lastVerdict = terminalVerdict(loopStateJson);';
|
|
522
|
-
const TO = 'const lastVerdict = (stateReadable && Array.isArray(loopStateJson.history) && loopStateJson.history.length && typeof loopStateJson.history[0].verdict === \"string\") ? loopStateJson.history[0].verdict : null; // MUTANT (F-297): reads the FIRST entry, not the terminal one';
|
|
523
|
-
if (!s.includes(FROM)) throw new Error('F-297 mutant pattern not found in lib/convergence.mjs -- source moved, update this mutation');
|
|
524
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
525
|
-
"
|
|
526
|
-
mutant_first_verdict=$(node --input-type=module -e "
|
|
527
|
-
const L = await import('$F297_MUT');
|
|
528
|
-
process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve-with-comments'}]})));
|
|
529
|
-
")
|
|
530
|
-
check "mutant (F-297: lastVerdict reads history[0]) returns the FIRST verdict ('request-changes') on the differing-verdicts two-entry case, catching the exact regression that case exists for" \
|
|
531
|
-
"$mutant_first_verdict" '{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":2,"lastVerdict":"request-changes"}'
|
|
532
|
-
pristine_first_verdict=$(lj "process.stdout.write(JSON.stringify(L.censoredDrawSnapshot({status:'running',pass:2,history:[{pass:1,verdict:'request-changes'},{pass:2,verdict:'approve-with-comments'}]})));")
|
|
533
|
-
check "pristine lib/convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still returns the terminal verdict ('approve-with-comments')" \
|
|
534
|
-
"$pristine_first_verdict" '{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":2,"lastVerdict":"approve-with-comments"}'
|
|
535
|
-
rm -rf "$F297_MUT_DIR"
|
|
536
|
-
trap - EXIT
|
|
537
|
-
|
|
538
|
-
# fillArm(): the `censor` field on the wait-exhausted path. `now` is injectable (defaults to
|
|
539
|
-
# Date.now) so elapsedMs is deterministic under test, the same seam newDraw/report/resume already
|
|
540
|
-
# are.
|
|
541
|
-
check "fillArm: wait-exhaustion returns a real censor record -- elapsedMs from the injected clock, waitAttempts the loop's own count, lastState from the last-read (still-running) state" \
|
|
542
|
-
"$(cj "$MK_SEQ_DRAW
|
|
543
|
-
let t = 1000;
|
|
544
|
-
const now = () => (t += 1000);
|
|
545
|
-
const seq = [[{status:'running'}, {status:'running'}, {status:'running'}]];
|
|
546
|
-
const r = M.fillArm(mkSeqDraw(seq), { n: 1, maxWaitAttempts: 2, report: () => {}, now });
|
|
547
|
-
process.stdout.write(JSON.stringify(r.censor));
|
|
548
|
-
")" '{"elapsedMs":1000,"waitAttempts":3,"lastState":{"status":"running","historyEmpty":null,"stateReadable":true,"pass":null,"completedPasses":null,"lastVerdict":null}}'
|
|
549
|
-
check "fillArm: censor.lastState.historyEmpty is true when the last-read state's history is empty (no pass has completed yet -- not proof nothing started; see censoredDrawSnapshot()'s docstring, F-277); completedPasses:0 for the same reason" \
|
|
550
|
-
"$(cj "$MK_SEQ_DRAW
|
|
551
|
-
const seq = [[{status:'running',history:[]}]];
|
|
552
|
-
const r = M.fillArm(mkSeqDraw(seq), { n: 1, maxWaitAttempts: 0, report: () => {} });
|
|
553
|
-
process.stdout.write(JSON.stringify(r.censor.lastState));
|
|
554
|
-
")" '{"status":"running","historyEmpty":true,"stateReadable":true,"pass":null,"completedPasses":0,"lastVerdict":null}'
|
|
555
|
-
check "fillArm: elapsedMs includes the span newDraw() itself consumes before returning a handle, not just the retries after it (F-278, code-loop pass 2 review -- mkSeqDraw above can't pin this, since its newDraw() never calls now() and is instantaneous either way)" \
|
|
556
|
-
"$(cj "
|
|
557
|
-
let f278t = 0;
|
|
558
|
-
const f278NewDraw = () => { f278t += 60000; return { read: () => ({ status: 'running' }), retry: () => {}, cleanup: () => {} }; };
|
|
559
|
-
const r = M.fillArm(f278NewDraw, { n: 1, maxWaitAttempts: 0, report: () => {}, now: () => f278t });
|
|
560
|
-
process.stdout.write(String(r.censor.elapsedMs));
|
|
561
|
-
")" "60000"
|
|
562
|
-
check "fillArm: censor is null on the breach path (only the wait-exhausted path retains anything)" \
|
|
563
|
-
"$(cj "$MK_SEQ_DRAW
|
|
564
|
-
const r = M.fillArm(mkSeqDraw([[{status:'max-passes-exceeded',pass:6}]]), { n: 1, report: () => {} });
|
|
565
|
-
process.stdout.write(String(r.censor));
|
|
566
|
-
")" "null"
|
|
567
|
-
check "fillArm: censor is null on the done path" \
|
|
568
|
-
"$(cj "$MK_SEQ_DRAW
|
|
569
|
-
const r = M.fillArm(mkSeqDraw([[{status:'done',pass:2}]]), { n: 1, report: () => {} });
|
|
570
|
-
process.stdout.write(String(r.censor));
|
|
571
|
-
")" "null"
|
|
572
|
-
|
|
573
|
-
# writeCensorRecord()/censorRecordPath(): persisting the record, own namespace, self-healing slot.
|
|
574
|
-
F276_SHA="f276censor$(date +%s)"
|
|
575
|
-
censor_written=$(cj "
|
|
576
|
-
const fs = await import('node:fs');
|
|
577
|
-
const seq = M.writeCensorRecord('$F276_SHA', M.TASK_ID, { elapsedMs: 278000, waitAttempts: 3, lastState: { status: 'running', historyEmpty: true } });
|
|
578
|
-
const p = M.censorRecordPath('$F276_SHA', M.TASK_ID, seq);
|
|
579
|
-
const rec = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
580
|
-
process.stdout.write(JSON.stringify({ seq, sha: rec.sha, taskId: rec.taskId, schema: rec.schema, censor: rec.censor }));
|
|
581
|
-
")
|
|
582
|
-
check "writeCensorRecord() persists the record at seq 0 with the module's schema, sha and taskId alongside it" \
|
|
583
|
-
"$censor_written" \
|
|
584
|
-
"{\"seq\":0,\"sha\":\"$F276_SHA\",\"taskId\":\"loop-code-loop\",\"schema\":1,\"censor\":{\"elapsedMs\":278000,\"waitAttempts\":3,\"lastState\":{\"status\":\"running\",\"historyEmpty\":true}}}"
|
|
585
|
-
check "writeCensorRecord() called again for the same sha self-heals to the NEXT free slot (seq 1), never overwriting the first" \
|
|
586
|
-
"$(cj "
|
|
587
|
-
const seq = M.writeCensorRecord('$F276_SHA', M.TASK_ID, { elapsedMs: 1000, waitAttempts: 1, lastState: { status: 'running', historyEmpty: false } });
|
|
588
|
-
process.stdout.write(String(seq));
|
|
589
|
-
")" "1"
|
|
590
|
-
check "a censored draw's record lives OUTSIDE the numbered shard namespace -- resumeArm() sees no usable draw from it (F-276 does not change what counts as usable, constraint 1)" \
|
|
591
|
-
"$(cj "process.stdout.write(JSON.stringify(M.resumeArm('$F276_SHA', M.TASK_ID, 15).resume));")" \
|
|
592
|
-
"[]"
|
|
593
|
-
rm -rf "$ROOT/tests/evals/results/$F276_SHA"
|
|
594
|
-
|
|
595
|
-
# The exact assembly drawArmForSha() uses (fillArm's censor return, persisted via
|
|
596
|
-
# writeCensorRecord()) -- without a live /code-loop invocation, no quota spent.
|
|
597
|
-
F276_WIRING_SHA="f276wiring$(date +%s)"
|
|
598
|
-
wiring_censor=$(cj "
|
|
599
|
-
const fs = await import('node:fs');
|
|
600
|
-
const makeDraw = () => ({ read: () => ({ status: 'running', history: [] }), retry() {}, cleanup() {} });
|
|
601
|
-
const occ = new Set();
|
|
602
|
-
const { newDraw, onDraw } = M.makeShardWriter(makeDraw, '$F276_WIRING_SHA', M.TASK_ID, 1, occ, 0);
|
|
603
|
-
const r = M.fillArm(newDraw, { n: 1, maxWaitAttempts: 1, onDraw, report: () => {} });
|
|
604
|
-
const seq = r.censor ? M.writeCensorRecord('$F276_WIRING_SHA', M.TASK_ID, r.censor) : null;
|
|
605
|
-
const rec = seq === null ? null : JSON.parse(fs.readFileSync(M.censorRecordPath('$F276_WIRING_SHA', M.TASK_ID, seq), 'utf8'));
|
|
606
|
-
process.stdout.write(JSON.stringify({ arm: r.arm, waitExhausted: r.waitExhausted, persisted: rec ? rec.censor.lastState : null }));
|
|
607
|
-
")
|
|
608
|
-
check "the exact assembly drawArmForSha() uses (fillArm's censor return + writeCensorRecord) persists a censored draw's evidence, without a live draw" \
|
|
609
|
-
"$wiring_censor" '{"arm":[],"waitExhausted":true,"persisted":{"status":"running","historyEmpty":true,"stateReadable":true,"pass":null,"completedPasses":0,"lastVerdict":null}}'
|
|
610
|
-
rm -rf "$ROOT/tests/evals/results/$F276_WIRING_SHA"
|
|
611
|
-
|
|
612
|
-
# the SAME real assembly, but the synthetic draw HAS iterated (a real pass count, a
|
|
613
|
-
# real prior verdict) -- proving pass/lastVerdict aren't just structurally present-and-null through
|
|
614
|
-
# this path, they carry the REAL returned snapshot's values end to end.
|
|
615
|
-
F295_WIRING_SHA="f295wiring$(date +%s)"
|
|
616
|
-
wiring_pass_verdict=$(cj "
|
|
617
|
-
const fs = await import('node:fs');
|
|
618
|
-
const makeDraw = () => ({ read: () => ({ status: 'running', pass: 2, history: [{ pass: 1, verdict: 'approve-with-comments' }] }), retry() {}, cleanup() {} });
|
|
619
|
-
const occ = new Set();
|
|
620
|
-
const { newDraw, onDraw } = M.makeShardWriter(makeDraw, '$F295_WIRING_SHA', M.TASK_ID, 1, occ, 0);
|
|
621
|
-
const r = M.fillArm(newDraw, { n: 1, maxWaitAttempts: 1, onDraw, report: () => {} });
|
|
622
|
-
const seq = r.censor ? M.writeCensorRecord('$F295_WIRING_SHA', M.TASK_ID, r.censor) : null;
|
|
623
|
-
const rec = seq === null ? null : JSON.parse(fs.readFileSync(M.censorRecordPath('$F295_WIRING_SHA', M.TASK_ID, seq), 'utf8'));
|
|
624
|
-
process.stdout.write(JSON.stringify({ persisted: rec ? rec.censor.lastState : null }));
|
|
625
|
-
")
|
|
626
|
-
check "F-295: a censored draw that HAS iterated persists BOTH new fields with real values through the real makeShardWriter -> fillArm -> writeCensorRecord assembly, not a hand-typed literal; completedPasses:1 -- pass 2 still IN PROGRESS, one behind pass" \
|
|
627
|
-
"$wiring_pass_verdict" '{"persisted":{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":1,"lastVerdict":"approve-with-comments"}}'
|
|
628
|
-
rm -rf "$ROOT/tests/evals/results/$F295_WIRING_SHA"
|
|
629
|
-
|
|
630
|
-
# the SAME real assembly again, but with a two-entry history whose verdicts differ --
|
|
631
|
-
# completedPasses:2 (pass 2 already recorded, not merely in progress) and lastVerdict is pass 2's
|
|
632
|
-
# OWN verdict, distinguishing this real end-to-end case from the completedPasses:1 case above the
|
|
633
|
-
# same way the two unit-level censoredDrawSnapshot() cases distinguish each other.
|
|
634
|
-
F296_WIRING_SHA="f296wiring$(date +%s)"
|
|
635
|
-
wiring_completed_passes=$(cj "
|
|
636
|
-
const fs = await import('node:fs');
|
|
637
|
-
const makeDraw = () => ({ read: () => ({ status: 'running', pass: 2, history: [{ pass: 1, verdict: 'request-changes' }, { pass: 2, verdict: 'approve-with-comments' }] }), retry() {}, cleanup() {} });
|
|
638
|
-
const occ = new Set();
|
|
639
|
-
const { newDraw, onDraw } = M.makeShardWriter(makeDraw, '$F296_WIRING_SHA', M.TASK_ID, 1, occ, 0);
|
|
640
|
-
const r = M.fillArm(newDraw, { n: 1, maxWaitAttempts: 1, onDraw, report: () => {} });
|
|
641
|
-
const seq = r.censor ? M.writeCensorRecord('$F296_WIRING_SHA', M.TASK_ID, r.censor) : null;
|
|
642
|
-
const rec = seq === null ? null : JSON.parse(fs.readFileSync(M.censorRecordPath('$F296_WIRING_SHA', M.TASK_ID, seq), 'utf8'));
|
|
643
|
-
process.stdout.write(JSON.stringify({ persisted: rec ? rec.censor.lastState : null }));
|
|
644
|
-
")
|
|
645
|
-
check "F-296: the real assembly with a two-entry, differing-verdicts history persists completedPasses:2 and pass 2's OWN verdict, not pass 1's" \
|
|
646
|
-
"$wiring_completed_passes" '{"persisted":{"status":"running","historyEmpty":false,"stateReadable":true,"pass":2,"completedPasses":2,"lastVerdict":"approve-with-comments"}}'
|
|
647
|
-
rm -rf "$ROOT/tests/evals/results/$F296_WIRING_SHA"
|
|
648
|
-
|
|
649
|
-
# Mutation: prove the retained record can actually fail to be retained. Staged on a scratch copy,
|
|
650
|
-
# never the tracked file.
|
|
651
|
-
F276_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
652
|
-
trap 'rm -rf "$F276_MUT_DIR"' EXIT
|
|
653
|
-
F276_MUT="$F276_MUT_DIR/convergence.mjs"
|
|
654
|
-
cp "$ROOT/$CVD" "$F276_MUT"
|
|
655
|
-
ln -s "$ROOT/tests/evals/lib" "$F276_MUT_DIR/lib"
|
|
656
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F276_MUT_DIR/run.mjs"
|
|
657
|
-
node -e "
|
|
658
|
-
const fs = require('fs'); const p = '$F276_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
659
|
-
const FROM = 'const censor = { elapsedMs: now() - drawStartedAt, waitAttempts, lastState: censoredDrawSnapshot(state) };';
|
|
660
|
-
const TO = 'const censor = null; // MUTANT (F-276): the censored draw retains nothing, same as before this pass';
|
|
661
|
-
if (!s.includes(FROM)) throw new Error('F-276 mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
662
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
663
|
-
"
|
|
664
|
-
mutant_censor=$(node --input-type=module -e "
|
|
665
|
-
const M = await import('$F276_MUT');
|
|
666
|
-
$MK_SEQ_DRAW
|
|
667
|
-
const r = M.fillArm(mkSeqDraw([[{status:'running'}, {status:'running'}, {status:'running'}]]), { n: 1, maxWaitAttempts: 2, report: () => {} });
|
|
668
|
-
process.stdout.write(String(r.censor));
|
|
669
|
-
")
|
|
670
|
-
check "mutant (F-276: censor forced to null) reproduces the exact pre-fix gap -- a censored draw retains nothing, catching the regression the tests above exist for" \
|
|
671
|
-
"$mutant_censor" "null"
|
|
672
|
-
pristine_censor=$(cj "$MK_SEQ_DRAW
|
|
673
|
-
const r = M.fillArm(mkSeqDraw([[{status:'running'}, {status:'running'}, {status:'running'}]]), { n: 1, maxWaitAttempts: 2, report: () => {} });
|
|
674
|
-
process.stdout.write(String(r.censor !== null));
|
|
675
|
-
")
|
|
676
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still retains a real censor record" \
|
|
677
|
-
"$pristine_censor" "true"
|
|
678
|
-
rm -rf "$F276_MUT_DIR"
|
|
679
|
-
trap - EXIT
|
|
680
|
-
|
|
681
|
-
# --- argument parsing ----------------------------------------------------------------------------
|
|
682
|
-
help_out=$(node "$CVD" --help)
|
|
683
|
-
help_flags_present=true
|
|
684
|
-
for flag in --source --fixture --runs --max-wait-attempts --merge --certify --dry-run; do
|
|
685
|
-
printf '%s' "$help_out" | grep -qF -- "$flag" || help_flags_present=false
|
|
686
|
-
done
|
|
687
|
-
check "--help prints usage naming every documented flag" "$help_flags_present" "true"
|
|
688
|
-
check "an unknown argument exits non-zero" "$(node "$CVD" --bogus >/dev/null 2>&1; echo $?)" "1"
|
|
689
|
-
check "--runs 0 is rejected (must be a positive integer)" "$(node "$CVD" --dry-run --runs 0 >/dev/null 2>&1; echo $?)" "1"
|
|
690
|
-
check "--runs -1 is rejected" "$(node "$CVD" --dry-run --runs -1 >/dev/null 2>&1; echo $?)" "1"
|
|
691
|
-
# same validation SHAPE as --runs above, not a second hand-rolled check.
|
|
692
|
-
check "--max-wait-attempts 0 is rejected (must be a positive integer)" "$(node "$CVD" --dry-run --max-wait-attempts 0 >/dev/null 2>&1; echo $?)" "1"
|
|
693
|
-
check "--max-wait-attempts -1 is rejected" "$(node "$CVD" --dry-run --max-wait-attempts -1 >/dev/null 2>&1; echo $?)" "1"
|
|
694
|
-
check "--max-wait-attempts 1.5 is rejected (not an integer)" "$(node "$CVD" --dry-run --max-wait-attempts 1.5 >/dev/null 2>&1; echo $?)" "1"
|
|
695
|
-
check "--max-wait-attempts 3 is accepted" "$(node "$CVD" --dry-run --max-wait-attempts 3 >/dev/null 2>&1; echo $?)" "0"
|
|
696
|
-
for flag in --source --fixture --runs --model --max-wait-attempts --merge --certify; do check "$flag with no operand is rejected, not silently defaulted (F-252/F-253)" "$(node "$CVD" "$flag" >/dev/null 2>&1; echo $?)" "1"; done
|
|
697
|
-
for flag in --merge --certify; do check "$flag with an empty operand is rejected (F-259)" "$(node "$CVD" "$flag" "" >/dev/null 2>&1; echo $?)" "1"; done
|
|
698
|
-
|
|
699
|
-
# --- --fixture/--source/--model have exactly ONE defender (val()'s own `v === ''` clause),
|
|
700
|
-
# no downstream validator the way --merge/--certify have (val() + the `!== null` guard +
|
|
701
|
-
# validateSha()) -- so this case, unlike the --merge case, had no committed test at all before this pass.
|
|
702
|
-
for flag in --source --fixture --model; do check "$flag with an empty operand is rejected" "$(node "$CVD" --dry-run "$flag" "" >/dev/null 2>&1; echo $?)" "1"; done
|
|
703
|
-
check "--fixture -h is rejected as a flag-shaped operand, not silently accepted as a literal value (F-262)" \
|
|
704
|
-
"$(node "$CVD" --dry-run --fixture -h >/dev/null 2>&1; echo $?)" "1"
|
|
705
|
-
check "--max-wait-attempts with an empty operand is rejected (F-294, same val() layer as --runs)" \
|
|
706
|
-
"$(node "$CVD" --dry-run --max-wait-attempts "" >/dev/null 2>&1; echo $?)" "1"
|
|
707
|
-
check "--max-wait-attempts -h is rejected as a flag-shaped operand, not silently accepted as a literal value" \
|
|
708
|
-
"$(node "$CVD" --dry-run --max-wait-attempts -h >/dev/null 2>&1; echo $?)" "1"
|
|
709
|
-
|
|
710
|
-
stub_bin=$(mktemp -d)
|
|
711
|
-
stub_sentinel="$stub_bin/touched"
|
|
712
|
-
printf '#!/bin/sh\n%s "%s"\nexit 1\n' "$(command -v touch)" "$stub_sentinel" > "$stub_bin/claude"
|
|
713
|
-
chmod +x "$stub_bin/claude"
|
|
714
|
-
PATH="$stub_bin:$PATH" node "$CVD" --merge "" >/dev/null 2>&1
|
|
715
|
-
check "F-259: --merge with an empty operand no longer reaches a stub claude on PATH (sentinel stays absent)" "$([ -e "$stub_sentinel" ] && echo TOUCHED || echo ABSENT)" "ABSENT"
|
|
716
|
-
PATH="$stub_bin" claude >/dev/null 2>&1
|
|
717
|
-
check "positive control: same stub still reachable (F-259 re-confirmation)" "$([ -e "$stub_sentinel" ] && echo TOUCHED || echo ABSENT)" "TOUCHED"
|
|
718
|
-
rm -rf "$stub_bin"
|
|
719
|
-
|
|
720
|
-
# Mutation: prove the empty-operand cases above actually depend on val()'s `v === ''` clause -- the
|
|
721
|
-
# measurement was that they would NOT redden if it were removed. Staged on a
|
|
722
|
-
# scratch copy, never the tracked file.
|
|
723
|
-
F263_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
724
|
-
trap 'rm -rf "$F263_MUT_DIR"' EXIT
|
|
725
|
-
F263_MUT="$F263_MUT_DIR/convergence.mjs"
|
|
726
|
-
cp "$ROOT/$CVD" "$F263_MUT"
|
|
727
|
-
ln -s "$ROOT/tests/evals/lib" "$F263_MUT_DIR/lib"
|
|
728
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F263_MUT_DIR/run.mjs"
|
|
729
|
-
node -e "
|
|
730
|
-
const fs = require('fs'); const p = '$F263_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
731
|
-
const FROM = \"v === undefined || v === '' || /^-/.test(v)\";
|
|
732
|
-
const TO = \"v === undefined || /^-/.test(v)\"; // MUTANT (F-263): empty-string operand no longer rejected
|
|
733
|
-
if (!s.includes(FROM)) throw new Error('F-263 mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
734
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
735
|
-
"
|
|
736
|
-
mutant_exit=$(node "$F263_MUT" --dry-run --source "" >/dev/null 2>&1; echo $?)
|
|
737
|
-
check "mutant (F-263: val()'s v === '' clause removed) lets --source \"\" through -- the F-261 case above would now go GREEN on a broken guard, confirming it currently depends on this exact clause" \
|
|
738
|
-
"$mutant_exit" "0"
|
|
739
|
-
pristine_exit=$(node "$CVD" --dry-run --source "" >/dev/null 2>&1; echo $?)
|
|
740
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still rejects --source \"\"" \
|
|
741
|
-
"$pristine_exit" "1"
|
|
742
|
-
rm -rf "$F263_MUT_DIR"
|
|
743
|
-
trap - EXIT
|
|
744
|
-
|
|
745
|
-
# --- --max-wait-attempts reaches fillArm(), not just parseArgs() -------------------------
|
|
746
|
-
# "This repo has repeatedly had flags that parse correctly and do nothing" (a standing instruction) -- so this drives the REAL parseArgs() output into the REAL fillArm(),
|
|
747
|
-
# rather than asserting only that parseArgs() produces the right field under the right key. A
|
|
748
|
-
# synthetic single-slot arm reports 'running' three times before completing: at the DEFAULT budget
|
|
749
|
-
# (DEFAULT_MAX_WAIT_ATTEMPTS = 2) it exhausts (waitAttempts 3 > 2); parsed through
|
|
750
|
-
# --max-wait-attempts 5, the SAME draw completes -- proving the parsed value changed fillArm()'s
|
|
751
|
-
# own control flow, not merely parseArgs()'s output.
|
|
752
|
-
F294_SEQ='[[{status:"running"},{status:"running"},{status:"running"},{status:"done",pass:1}]]'
|
|
753
|
-
check "no --max-wait-attempts (parses to null): fillArm falls through to its own DEFAULT_MAX_WAIT_ATTEMPTS (2) -- a draw needing 3 waits censors" \
|
|
754
|
-
"$(cj "$MK_SEQ_DRAW
|
|
755
|
-
const args = M.parseArgs(['--dry-run']);
|
|
756
|
-
const seq = $F294_SEQ;
|
|
757
|
-
const r = M.fillArm(mkSeqDraw(seq), { n: 1, maxWaitAttempts: args.maxWaitAttempts, report: () => {} });
|
|
758
|
-
process.stdout.write(JSON.stringify({ waitExhausted: r.waitExhausted, arm: r.arm }));
|
|
759
|
-
")" '{"waitExhausted":true,"arm":[]}'
|
|
760
|
-
check "--max-wait-attempts 5 (parsed via the real parseArgs()): the SAME synthetic draw now completes" \
|
|
761
|
-
"$(cj "$MK_SEQ_DRAW
|
|
762
|
-
const args = M.parseArgs(['--dry-run', '--max-wait-attempts', '5']);
|
|
763
|
-
const seq = $F294_SEQ;
|
|
764
|
-
const r = M.fillArm(mkSeqDraw(seq), { n: 1, maxWaitAttempts: args.maxWaitAttempts, report: () => {} });
|
|
765
|
-
process.stdout.write(JSON.stringify({ waitExhausted: r.waitExhausted, arm: r.arm }));
|
|
766
|
-
")" '{"waitExhausted":false,"arm":[1]}'
|
|
767
|
-
|
|
768
|
-
# --- the anchor above USED TO BE a `grep -c` for the literal substring
|
|
769
|
-
# 'maxWaitAttempts: args.maxWaitAttempts' -- a substring match a mutant can satisfy while changing
|
|
770
|
-
# what the code DOES: `args.maxWaitAttempts && 0` still contains that exact text (the review's own
|
|
771
|
-
# measurement: this mutant survived the full 134/0 suite untouched) while silently collapsing any
|
|
772
|
-
# real, truthy --max-wait-attempts value to 0, censoring every draw on its first `running` read.
|
|
773
|
-
# Fixed by extracting the opts-building step into `liveDrawOpts()` (exported, same reasoning
|
|
774
|
-
# `validateSha()`/`parseArgs()` were already exported for) so a test drives the REAL function and
|
|
775
|
-
# checks the REAL value it returns, not a text pattern main() happens to still contain.
|
|
776
|
-
check "liveDrawOpts() carries a real --max-wait-attempts value through unchanged" \
|
|
777
|
-
"$(cj "process.stdout.write(JSON.stringify(M.liveDrawOpts(M.parseArgs(['--dry-run', '--runs', '15', '--max-wait-attempts', '5']))));")" \
|
|
778
|
-
'{"n":15,"model":null,"maxWaitAttempts":5}'
|
|
779
|
-
check "liveDrawOpts() carries null through when --max-wait-attempts is absent (fillArm's own default then applies)" \
|
|
780
|
-
"$(cj "process.stdout.write(JSON.stringify(M.liveDrawOpts(M.parseArgs(['--dry-run', '--runs', '15']))));")" \
|
|
781
|
-
'{"n":15,"model":null,"maxWaitAttempts":null}'
|
|
782
|
-
|
|
783
|
-
# Mutation: `args.maxWaitAttempts && 0` -- the EXACT mutant the review found surviving the old
|
|
784
|
-
# grep-anchored test. A real (truthy) value collapses to 0; parseArgs() itself never produces a
|
|
785
|
-
# literal 0 (rejected by the positive-integer check), so this corruption is reachable ONLY through
|
|
786
|
-
# a broken liveDrawOpts(), never through a value parseArgs() would emit on its own. Staged on a
|
|
787
|
-
# scratch copy, never the tracked file.
|
|
788
|
-
F298_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
789
|
-
trap 'rm -rf "$F298_MUT_DIR"' EXIT
|
|
790
|
-
F298_MUT="$F298_MUT_DIR/convergence.mjs"
|
|
791
|
-
cp "$ROOT/$CVD" "$F298_MUT"
|
|
792
|
-
ln -s "$ROOT/tests/evals/lib" "$F298_MUT_DIR/lib"
|
|
793
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F298_MUT_DIR/run.mjs"
|
|
794
|
-
node -e "
|
|
795
|
-
const fs = require('fs'); const p = '$F298_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
796
|
-
const FROM = 'return { n: args.runs, model: args.model, maxWaitAttempts: args.maxWaitAttempts };';
|
|
797
|
-
const TO = 'return { n: args.runs, model: args.model, maxWaitAttempts: args.maxWaitAttempts && 0 }; // MUTANT (F-298): a real value collapses to 0, censoring every draw on its first running read';
|
|
798
|
-
if (!s.includes(FROM)) throw new Error('F-298 mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
799
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
800
|
-
"
|
|
801
|
-
mutant_livedrawopts=$(node --input-type=module -e "
|
|
802
|
-
const M = await import('$F298_MUT');
|
|
803
|
-
process.stdout.write(JSON.stringify(M.liveDrawOpts(M.parseArgs(['--dry-run', '--max-wait-attempts', '5']))));
|
|
804
|
-
")
|
|
805
|
-
check "mutant (F-298: args.maxWaitAttempts && 0) collapses a real --max-wait-attempts 5 down to 0, catching the exact regression a text anchor could not" \
|
|
806
|
-
"$mutant_livedrawopts" '{"n":15,"model":null,"maxWaitAttempts":0}'
|
|
807
|
-
pristine_livedrawopts=$(cj "process.stdout.write(JSON.stringify(M.liveDrawOpts(M.parseArgs(['--dry-run', '--max-wait-attempts', '5']))));")
|
|
808
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still carries maxWaitAttempts:5 through liveDrawOpts() unchanged" \
|
|
809
|
-
"$pristine_livedrawopts" '{"n":15,"model":null,"maxWaitAttempts":5}'
|
|
810
|
-
rm -rf "$F298_MUT_DIR"
|
|
811
|
-
trap - EXIT
|
|
812
|
-
|
|
813
|
-
# The one link liveDrawOpts()'s own tests above still can't close by execution: whether main()'s
|
|
814
|
-
# live-draw branch actually CALLS liveDrawOpts(args) and forwards its return value into
|
|
815
|
-
# drawArmForSha() -- main() itself isn't exported and spends quota, so it can't be driven directly.
|
|
816
|
-
# Pure argument-passing has no value transform left to mutate the way the opts VALUES above did, so
|
|
817
|
-
# a source anchor on the exact call expression is the honest residual, not a value-changing gap: it
|
|
818
|
-
# proves the wiring exists, not that liveDrawOpts()'s output is correct (that part is covered above).
|
|
819
|
-
check "main()'s live-draw branch literally calls drawArmForSha(source.dir, fixtureDir, source.sha, liveDrawOpts(args))" \
|
|
820
|
-
"$(grep -c 'drawArmForSha(source.dir, fixtureDir, source.sha, liveDrawOpts(args))' "$ROOT/$CVD")" "1"
|
|
821
|
-
|
|
822
|
-
# Mutation 1: prove --max-wait-attempts's positive-integer guard actually depends on the check
|
|
823
|
-
# added this pass. Staged on a scratch copy, never the tracked file.
|
|
824
|
-
F294_VALIDATE_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
825
|
-
trap 'rm -rf "$F294_VALIDATE_MUT_DIR"' EXIT
|
|
826
|
-
F294_VALIDATE_MUT="$F294_VALIDATE_MUT_DIR/convergence.mjs"
|
|
827
|
-
cp "$ROOT/$CVD" "$F294_VALIDATE_MUT"
|
|
828
|
-
ln -s "$ROOT/tests/evals/lib" "$F294_VALIDATE_MUT_DIR/lib"
|
|
829
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F294_VALIDATE_MUT_DIR/run.mjs"
|
|
830
|
-
node -e "
|
|
831
|
-
const fs = require('fs'); const p = '$F294_VALIDATE_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
832
|
-
const FROM = 'a.maxWaitAttempts !== null && (!Number.isInteger(a.maxWaitAttempts) || a.maxWaitAttempts <= 0)';
|
|
833
|
-
const TO = 'false /* MUTANT (F-294): positive-integer guard neutered */';
|
|
834
|
-
if (!s.includes(FROM)) throw new Error('F-294 validation mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
835
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
836
|
-
"
|
|
837
|
-
mutant_validate_exit=$(node "$F294_VALIDATE_MUT" --dry-run --max-wait-attempts 0 >/dev/null 2>&1; echo $?)
|
|
838
|
-
check "mutant (F-294: positive-integer guard neutered) lets --max-wait-attempts 0 through -- confirming the check above currently depends on it" \
|
|
839
|
-
"$mutant_validate_exit" "0"
|
|
840
|
-
pristine_validate_exit=$(node "$CVD" --dry-run --max-wait-attempts 0 >/dev/null 2>&1; echo $?)
|
|
841
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still rejects --max-wait-attempts 0" \
|
|
842
|
-
"$pristine_validate_exit" "1"
|
|
843
|
-
rm -rf "$F294_VALIDATE_MUT_DIR"
|
|
844
|
-
trap - EXIT
|
|
845
|
-
|
|
846
|
-
# Mutation 2: prove fillArm()'s own read of opts.maxWaitAttempts is what the "reaches fillArm()"
|
|
847
|
-
# checks above depend on, not some other unrelated path to the same numbers.
|
|
848
|
-
F294_WIRING_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
849
|
-
trap 'rm -rf "$F294_WIRING_MUT_DIR"' EXIT
|
|
850
|
-
F294_WIRING_MUT="$F294_WIRING_MUT_DIR/convergence.mjs"
|
|
851
|
-
cp "$ROOT/$CVD" "$F294_WIRING_MUT"
|
|
852
|
-
ln -s "$ROOT/tests/evals/lib" "$F294_WIRING_MUT_DIR/lib"
|
|
853
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F294_WIRING_MUT_DIR/run.mjs"
|
|
854
|
-
node -e "
|
|
855
|
-
const fs = require('fs'); const p = '$F294_WIRING_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
856
|
-
const FROM = 'const maxWaitAttempts = opts.maxWaitAttempts ?? DEFAULT_MAX_WAIT_ATTEMPTS;';
|
|
857
|
-
const TO = 'const maxWaitAttempts = DEFAULT_MAX_WAIT_ATTEMPTS; // MUTANT (F-294): opts.maxWaitAttempts ignored entirely';
|
|
858
|
-
if (!s.includes(FROM)) throw new Error('F-294 wiring mutant pattern not found in convergence.mjs -- source moved, update this mutation');
|
|
859
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
860
|
-
"
|
|
861
|
-
mutant_wiring=$(node --input-type=module -e "
|
|
862
|
-
const M = await import('$F294_WIRING_MUT');
|
|
863
|
-
$MK_SEQ_DRAW
|
|
864
|
-
const args = M.parseArgs(['--dry-run', '--max-wait-attempts', '5']);
|
|
865
|
-
const seq = $F294_SEQ;
|
|
866
|
-
const r = M.fillArm(mkSeqDraw(seq), { n: 1, maxWaitAttempts: args.maxWaitAttempts, report: () => {} });
|
|
867
|
-
process.stdout.write(JSON.stringify({ waitExhausted: r.waitExhausted, arm: r.arm }));
|
|
868
|
-
")
|
|
869
|
-
check "mutant (F-294: fillArm ignores opts.maxWaitAttempts) reproduces the exact pre-fix gap -- --max-wait-attempts 5 no longer prevents censoring, catching the regression the checks above exist for" \
|
|
870
|
-
"$mutant_wiring" '{"waitExhausted":true,"arm":[]}'
|
|
871
|
-
pristine_wiring=$(cj "$MK_SEQ_DRAW
|
|
872
|
-
const args = M.parseArgs(['--dry-run', '--max-wait-attempts', '5']);
|
|
873
|
-
const seq = $F294_SEQ;
|
|
874
|
-
const r = M.fillArm(mkSeqDraw(seq), { n: 1, maxWaitAttempts: args.maxWaitAttempts, report: () => {} });
|
|
875
|
-
process.stdout.write(JSON.stringify({ waitExhausted: r.waitExhausted, arm: r.arm }));
|
|
876
|
-
")
|
|
877
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still lets --max-wait-attempts 5 prevent censoring" \
|
|
878
|
-
"$pristine_wiring" '{"waitExhausted":false,"arm":[1]}'
|
|
879
|
-
rm -rf "$F294_WIRING_MUT_DIR"
|
|
880
|
-
trap - EXIT
|
|
881
|
-
|
|
882
|
-
# --- the shard namespace carries no fixture identity.
|
|
883
|
-
# Before this, loopShardPath() took no fixture component at all -- task02's draw 0 and a NEW
|
|
884
|
-
# fixture's draw 0 landed at the byte-identical path, and resumeArm() folded both as one arm,
|
|
885
|
-
# mixing two fixtures' draws into a single mean/sd. Demonstrated below by construction, then by a
|
|
886
|
-
# mutation that reproduces the exact collision.
|
|
887
|
-
F284_SHA="f284ns$(date +%s)"
|
|
888
|
-
check "loopShardPath: two DIFFERENT fixtureIds at the SAME sha/index now resolve to DIFFERENT paths -- the collision is gone" \
|
|
889
|
-
"$(cj "process.stdout.write(String(M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code') !== M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code-degraded')));")" \
|
|
890
|
-
"true"
|
|
891
|
-
check "loopShardPath: fixtureId OMITTED still reads the flat path -- unchanged from every shard on disk before this iteration (constraint 1)" \
|
|
892
|
-
"$(cj "process.stdout.write(String(M.loopShardPath('$F284_SHA', M.TASK_ID, 0) === M.loopShardPath('$F284_SHA', M.TASK_ID, 0, null)));")" \
|
|
893
|
-
"true"
|
|
894
|
-
|
|
895
|
-
# resumeArm folds STRICTLY per fixtureId -- two fixtures' shards written at the SAME index of the
|
|
896
|
-
# SAME sha never merge into one arm.
|
|
897
|
-
cj "
|
|
898
|
-
const occA = new Set(); M.writeNextShard('$F284_SHA', M.TASK_ID, 5, occA, 0, 3, null, null, 'task02-code');
|
|
899
|
-
const occB = new Set(); M.writeNextShard('$F284_SHA', M.TASK_ID, 5, occB, 0, 9, null, null, 'task02-code-degraded');
|
|
900
|
-
" >/dev/null
|
|
901
|
-
check "resumeArm(sha, taskId, n, 'task02-code') folds only its OWN fixture's shard, [3] -- not the OTHER fixture's [9] written at the same index" \
|
|
902
|
-
"$(cj "process.stdout.write(JSON.stringify(M.resumeArm('$F284_SHA', M.TASK_ID, 5, 'task02-code').resume));")" "[3]"
|
|
903
|
-
check "resumeArm(sha, taskId, n, 'task02-code-degraded') folds only [9], not [3]" \
|
|
904
|
-
"$(cj "process.stdout.write(JSON.stringify(M.resumeArm('$F284_SHA', M.TASK_ID, 5, 'task02-code-degraded').resume));")" "[9]"
|
|
905
|
-
check "writeNextShard: the record itself carries fixture identity (F-284), not only the path -- rec.fixture" \
|
|
906
|
-
"$(cj "const fs = await import('node:fs'); const rec = JSON.parse(fs.readFileSync(M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code'), 'utf8')); process.stdout.write(rec.fixture);")" \
|
|
907
|
-
"task02-code"
|
|
908
|
-
rm -rf "$ROOT/tests/evals/results/$F284_SHA"
|
|
909
|
-
|
|
910
|
-
# makeShardWriter()/writeNextShard(): fixtureId threads through the EXACT assembly drawArmForSha()
|
|
911
|
-
# uses, without a live draw -- same style as the shard-verdict wiring checks above.
|
|
912
|
-
F284_WIRING_SHA="f284wiring$(date +%s)"
|
|
913
|
-
check "the exact assembly drawArmForSha() uses threads fixtureId into both the shard's path and its record" \
|
|
914
|
-
"$(cj "
|
|
915
|
-
const fs = await import('node:fs');
|
|
916
|
-
const makeDraw = () => ({ read: () => ({ status: 'done', pass: 2 }), retry() {}, cleanup() {} });
|
|
917
|
-
const occ = new Set();
|
|
918
|
-
const { newDraw, onDraw } = M.makeShardWriter(makeDraw, '$F284_WIRING_SHA', M.TASK_ID, 1, occ, 0, 'task02-code');
|
|
919
|
-
M.fillArm(newDraw, { n: 1, onDraw });
|
|
920
|
-
const p = M.loopShardPath('$F284_WIRING_SHA', M.TASK_ID, 0, 'task02-code');
|
|
921
|
-
process.stdout.write(JSON.stringify({ shardAtFixturePath: fs.existsSync(p), recordFixture: JSON.parse(fs.readFileSync(p, 'utf8')).fixture }));
|
|
922
|
-
")" '{"shardAtFixturePath":true,"recordFixture":"task02-code"}'
|
|
923
|
-
rm -rf "$ROOT/tests/evals/results/$F284_WIRING_SHA"
|
|
924
|
-
|
|
925
|
-
# writeCensorRecord() also records fixture identity -- the censored/ evidence stream gets
|
|
926
|
-
# the same honesty about which fixture it came from, even though (unlike numbered shards) it stays
|
|
927
|
-
# unqualified by directory, since nothing folds censor records back into an arm (a known gap).
|
|
928
|
-
F284_CENSOR_SHA="f284censor$(date +%s)"
|
|
929
|
-
check "writeCensorRecord(..., fixtureId) persists it alongside the censor payload" \
|
|
930
|
-
"$(cj "
|
|
931
|
-
const fs = await import('node:fs');
|
|
932
|
-
const seq = M.writeCensorRecord('$F284_CENSOR_SHA', M.TASK_ID, { elapsedMs: 1, waitAttempts: 1, lastState: { status: 'running', historyEmpty: true, stateReadable: true } }, 'task02-code');
|
|
933
|
-
process.stdout.write(JSON.parse(fs.readFileSync(M.censorRecordPath('$F284_CENSOR_SHA', M.TASK_ID, seq), 'utf8')).fixture);
|
|
934
|
-
")" "task02-code"
|
|
935
|
-
rm -rf "$ROOT/tests/evals/results/$F284_CENSOR_SHA"
|
|
936
|
-
|
|
937
|
-
# Legacy shards (every shard written before fixture identity existed, including the five quota-paid ones
|
|
938
|
-
# the committed baseline rests on) carry NO fixture key at all -- taken to mean UNKNOWN, never assumed to be
|
|
939
|
-
# task02-code (the default) or any other fixture. Staged as a synthetic legacy shard so this stays
|
|
940
|
-
# hermetic and portable across clones/CI that don't carry the real, gitignored quota-paid data.
|
|
941
|
-
F284_LEGACY_SHA="f284legacy$(date +%s)"
|
|
942
|
-
cj "
|
|
943
|
-
const fs = await import('node:fs'); const path = await import('node:path');
|
|
944
|
-
const p = M.loopShardPath('$F284_LEGACY_SHA', M.TASK_ID, 0);
|
|
945
|
-
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
946
|
-
fs.writeFileSync(p, JSON.stringify({ sha: '$F284_LEGACY_SHA', taskId: M.TASK_ID, schema: M.LOOP_SCHEMA_VERSION, run: { index: 0, pass: 1 } }) + '\n');
|
|
947
|
-
" >/dev/null
|
|
948
|
-
check "a legacy shard (no fixture key at all) still folds via resumeArm() with fixtureId OMITTED -- the unqualified/unknown bucket" \
|
|
949
|
-
"$(cj "process.stdout.write(JSON.stringify(M.resumeArm('$F284_LEGACY_SHA', M.TASK_ID, 1).resume));")" "[1]"
|
|
950
|
-
check "the SAME legacy shard is invisible when a REAL fixtureId is asked for -- 'unknown' is never silently treated as 'task02-code'" \
|
|
951
|
-
"$(cj "process.stdout.write(JSON.stringify(M.resumeArm('$F284_LEGACY_SHA', M.TASK_ID, 1, 'task02-code').resume));")" "[]"
|
|
952
|
-
rm -rf "$ROOT/tests/evals/results/$F284_LEGACY_SHA"
|
|
953
|
-
|
|
954
|
-
# Mutation: revert loopShardPath() to its pre-fix shape (fixtureId accepted but ignored) and
|
|
955
|
-
# reproduce the EXACT collision the original defect demonstrated by hand -- two different fixtures'
|
|
956
|
-
# draw 0 landing at the byte-identical path. Staged on a scratch copy, never the tracked file.
|
|
957
|
-
# Occurrence count asserted, not just presence (standing discipline): this exact anchor is unique
|
|
958
|
-
# in the file, unlike e.g. `mkdirSync(dirname(p), { recursive: true });`, which occurs twice and
|
|
959
|
-
# would select the wrong one positionally under a plain .replace().
|
|
960
|
-
F284_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
961
|
-
trap 'rm -rf "$F284_MUT_DIR"' EXIT
|
|
962
|
-
F284_MUT="$F284_MUT_DIR/convergence.mjs"
|
|
963
|
-
cp "$ROOT/$CVD" "$F284_MUT"
|
|
964
|
-
ln -s "$ROOT/tests/evals/lib" "$F284_MUT_DIR/lib"
|
|
965
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F284_MUT_DIR/run.mjs"
|
|
966
|
-
node -e "
|
|
967
|
-
const fs = require('fs'); const p = '$F284_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
968
|
-
const FROM = 'const dir = fixtureId == null ? loopShardDir(sha) : join(loopShardDir(sha), fixtureId);';
|
|
969
|
-
const TO = 'const dir = loopShardDir(sha); // MUTANT (F-284): fixtureId accepted but ignored, the pre-fix shape';
|
|
970
|
-
const count = s.split(FROM).length - 1;
|
|
971
|
-
if (count !== 1) throw new Error('F-284 mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
972
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
973
|
-
"
|
|
974
|
-
mutant_collision=$(node --input-type=module -e "
|
|
975
|
-
const M = await import('$F284_MUT');
|
|
976
|
-
process.stdout.write(String(M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code') === M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code-degraded')));
|
|
977
|
-
")
|
|
978
|
-
check "mutant (F-284: fixtureId ignored, the pre-fix shape) reproduces the EXACT collision the original defect demonstrated by hand -- task02's draw 0 and a NEW fixture's draw 0 land at the SAME path" \
|
|
979
|
-
"$mutant_collision" "true"
|
|
980
|
-
pristine_collision=$(cj "process.stdout.write(String(M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code') === M.loopShardPath('$F284_SHA', M.TASK_ID, 0, 'task02-code-degraded')));")
|
|
981
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) no longer collides" \
|
|
982
|
-
"$pristine_collision" "false"
|
|
983
|
-
rm -rf "$F284_MUT_DIR"
|
|
984
|
-
trap - EXIT
|
|
985
|
-
|
|
986
|
-
# --- --merge/--certify ignored --fixture entirely, so a fixture-qualified arm on
|
|
987
|
-
# disk silently underreported as 0/N through the unqualified read -- disjoint from the write side.
|
|
988
|
-
F285_SHA="f285$(date +%s)"
|
|
989
|
-
cj "const occ = new Set(); M.writeNextShard('$F285_SHA', M.TASK_ID, 5, occ, 0, 4, null, null, 'tests/evals/fixtures/task02-code');" >/dev/null
|
|
990
|
-
check "--merge --fixture <id> folds that fixture's own arm, [4] -- the read side now agrees with the write side (F-285)" \
|
|
991
|
-
"$(node "$CVD" --merge "$F285_SHA" --fixture tests/evals/fixtures/task02-code --runs 5 | grep -c 'arm: \[4\]')" "1"
|
|
992
|
-
check "--merge WITHOUT --fixture on the SAME sha now WARNS a fixture-qualified sibling exists, instead of silently reading 0/N (F-285)" \
|
|
993
|
-
"$(node "$CVD" --merge "$F285_SHA" --runs 5 2>&1 >/dev/null | grep -c 'also has fixture-qualified draws')" "1"
|
|
994
|
-
|
|
995
|
-
# Mutation: drop --fixture from reportArm()'s call site, reproducing the disjoint read.
|
|
996
|
-
F285_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
997
|
-
trap 'rm -rf "$F285_MUT_DIR"' EXIT
|
|
998
|
-
F285_MUT="$F285_MUT_DIR/convergence.mjs"
|
|
999
|
-
cp "$ROOT/$CVD" "$F285_MUT"
|
|
1000
|
-
ln -s "$ROOT/tests/evals/lib" "$F285_MUT_DIR/lib"
|
|
1001
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F285_MUT_DIR/run.mjs"
|
|
1002
|
-
node -e "
|
|
1003
|
-
const fs = require('fs'); const p = '$F285_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1004
|
-
const FROM = 'reportArm(validateSha(args.merge ?? args.certify), args.runs, resolveFixtureId(args.fixture));';
|
|
1005
|
-
const TO = 'reportArm(validateSha(args.merge ?? args.certify), args.runs); // MUTANT (F-285): --fixture never threaded';
|
|
1006
|
-
const count = s.split(FROM).length - 1;
|
|
1007
|
-
if (count !== 1) throw new Error('F-285 mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1008
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1009
|
-
"
|
|
1010
|
-
mutant_merge=$(node "$F285_MUT" --merge "$F285_SHA" --fixture tests/evals/fixtures/task02-code --runs 5 | grep -c 'arm: \[4\]')
|
|
1011
|
-
check "mutant (F-285: --fixture dropped before reportArm) can no longer see the fixture-qualified arm -- 0, not 1" \
|
|
1012
|
-
"$mutant_merge" "0"
|
|
1013
|
-
pristine_merge=$(node "$CVD" --merge "$F285_SHA" --fixture tests/evals/fixtures/task02-code --runs 5 | grep -c 'arm: \[4\]')
|
|
1014
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) sees it again, 1" \
|
|
1015
|
-
"$pristine_merge" "1"
|
|
1016
|
-
rm -rf "$F285_MUT_DIR"
|
|
1017
|
-
trap - EXIT
|
|
1018
|
-
rm -rf "$ROOT/tests/evals/results/$F285_SHA"
|
|
1019
|
-
|
|
1020
|
-
# --- --fixture is now pinned to the drawn SHA's own worktree, refused (not
|
|
1021
|
-
# warned) if it escapes that tree or is git-dirty there. assertFixturePinned() is the guard;
|
|
1022
|
-
# resolveFixtureDir()/drawArmForSha() are its call sites.
|
|
1023
|
-
PIN_SRC=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1024
|
-
trap 'rm -rf "$PIN_SRC"' EXIT
|
|
1025
|
-
mkdir -p "$PIN_SRC/fixtures/task02-code"
|
|
1026
|
-
echo hello > "$PIN_SRC/fixtures/task02-code/a.txt"
|
|
1027
|
-
check "assertFixturePinned: a fixture path INSIDE sourceDir is accepted (unversioned source, sha null -- no git-dirty check applies)" \
|
|
1028
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_SRC/fixtures/task02-code', null); process.stdout.write('ok'); } catch (e) { process.stdout.write('threw: ' + e.message); }")" \
|
|
1029
|
-
"ok"
|
|
1030
|
-
PIN_OUTSIDE=$(mktemp -d)
|
|
1031
|
-
check "assertFixturePinned: a fixture path OUTSIDE sourceDir is refused, not silently accepted" \
|
|
1032
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_OUTSIDE', null); process.stdout.write('NO THROW'); } catch { process.stdout.write('threw'); }")" \
|
|
1033
|
-
"threw"
|
|
1034
|
-
rm -rf "$PIN_OUTSIDE"
|
|
1035
|
-
|
|
1036
|
-
# The git-dirty half needs a REAL repo (git status is the assertion, not a comment claiming
|
|
1037
|
-
# nothing touches the worktree) -- built and torn down here, never the tracked repo.
|
|
1038
|
-
(cd "$PIN_SRC" && git init -q -b main && git config user.email x@x.invalid && git config user.name x && git add -A && git commit -qm baseline) >/dev/null 2>&1
|
|
1039
|
-
check "assertFixturePinned: a CLEAN worktree (freshly committed, nothing touched since) passes even with a real sha" \
|
|
1040
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_SRC/fixtures/task02-code', 'deadbeef'); process.stdout.write('ok'); } catch (e) { process.stdout.write('threw: ' + e.message); }")" \
|
|
1041
|
-
"ok"
|
|
1042
|
-
echo modified > "$PIN_SRC/fixtures/task02-code/a.txt"
|
|
1043
|
-
check "assertFixturePinned: an uncommitted edit to the fixture inside the worktree is refused as DIRTY relative to the drawn SHA" \
|
|
1044
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_SRC/fixtures/task02-code', 'deadbeef'); process.stdout.write('NO THROW'); } catch (e) { process.stdout.write(/dirty/.test(e.message) ? 'threw-dirty' : 'threw-other: ' + e.message); }")" \
|
|
1045
|
-
"threw-dirty"
|
|
1046
|
-
check "assertFixturePinned: the SAME dirty worktree is NOT checked when the source is unversioned (sha null) -- resolveSource() already documents that case as non-reproducible" \
|
|
1047
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_SRC/fixtures/task02-code', null); process.stdout.write('ok'); } catch (e) { process.stdout.write('threw: ' + e.message); }")" \
|
|
1048
|
-
"ok"
|
|
1049
|
-
|
|
1050
|
-
# --fixture IS sourceDir -- relative() returns '', join()'s no-op aliases onto the bucket.
|
|
1051
|
-
check "assertFixturePinned: --fixture . (rel === '') is refused, not aliased onto the unqualified bucket (F-286)" \
|
|
1052
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_SRC', null); process.stdout.write('NO THROW'); } catch { process.stdout.write('threw'); }")" \
|
|
1053
|
-
"threw"
|
|
1054
|
-
mkdir -p "$PIN_SRC/..scratch" # a CONTAINED sibling merely named like a parent ref
|
|
1055
|
-
check "assertFixturePinned: a CONTAINED dir named ..scratch is accepted, not falsely refused as an escape (F-287)" \
|
|
1056
|
-
"$(cj "try { M.assertFixturePinned('$PIN_SRC', '$PIN_SRC/..scratch', null); process.stdout.write('ok'); } catch (e) { process.stdout.write('threw: ' + e.message); }")" \
|
|
1057
|
-
"ok"
|
|
1058
|
-
rm -rf "$PIN_SRC"
|
|
1059
|
-
trap - EXIT
|
|
1060
|
-
|
|
1061
|
-
# CLI integration: an explicit --fixture given as a path RELATIVE TO THE SOURCE TREE resolves
|
|
1062
|
-
# inside the checked-out worktree (not this shell's cwd) -- the SHA-pin actually takes effect, not
|
|
1063
|
-
# merely accepted.
|
|
1064
|
-
dryrun_pinned=$(node "$CVD" --dry-run --source HEAD --fixture tests/evals/fixtures/task02-code)
|
|
1065
|
-
dryrun_pinned_fixture=$(printf '%s' "$dryrun_pinned" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>process.stdout.write(JSON.parse(s).fixture))")
|
|
1066
|
-
check "--dry-run --fixture <source-relative path> resolves to a path INSIDE the checked-out worktree, not \$ROOT (F-284 actually took effect, not merely accepted)" \
|
|
1067
|
-
"$(case "$dryrun_pinned_fixture" in "$ROOT"/*) echo "still-rooted-at-ROOT" ;; *task02-code) echo "inside-worktree" ;; *) echo "unexpected: $dryrun_pinned_fixture" ;; esac)" \
|
|
1068
|
-
"inside-worktree"
|
|
1069
|
-
# assert the MESSAGE -- git itself refuses an out-of-worktree pathspec independent of our
|
|
1070
|
-
# guard, so exit 1 alone can't attribute the refusal (neutering the check below still exits 1).
|
|
1071
|
-
escape_head_out=$(node "$CVD" --dry-run --source HEAD --fixture /tmp 2>&1 >/dev/null)
|
|
1072
|
-
check "--dry-run --fixture <path escaping the resolved source tree> is refused BY OUR OWN GUARD, not merely exit 1 (F-288)" \
|
|
1073
|
-
"$(printf '%s' "$escape_head_out" | grep -c 'must resolve to a real subdirectory')" "1"
|
|
1074
|
-
|
|
1075
|
-
# Mutation: neuter assertFixturePinned()'s containment check and confirm the escape above is no
|
|
1076
|
-
# longer refused -- the guard is load-bearing, not decorative.
|
|
1077
|
-
F284_PIN_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1078
|
-
trap 'rm -rf "$F284_PIN_MUT_DIR"' EXIT
|
|
1079
|
-
F284_PIN_MUT="$F284_PIN_MUT_DIR/convergence.mjs"
|
|
1080
|
-
cp "$ROOT/$CVD" "$F284_PIN_MUT"
|
|
1081
|
-
ln -s "$ROOT/tests/evals/lib" "$F284_PIN_MUT_DIR/lib"
|
|
1082
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F284_PIN_MUT_DIR/run.mjs"
|
|
1083
|
-
node -e "
|
|
1084
|
-
const fs = require('fs'); const p = '$F284_PIN_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1085
|
-
const FROM = \"if (rel === '' || rel === '..' || rel.startsWith('..' + sep)) {\";
|
|
1086
|
-
const TO = 'if (false) { // MUTANT (F-284/F-286/F-287): the containment check never fires';
|
|
1087
|
-
const count = s.split(FROM).length - 1;
|
|
1088
|
-
if (count !== 1) throw new Error('F-284 pin mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1089
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1090
|
-
"
|
|
1091
|
-
# Unversioned source (--source ., sha null) so the git-dirty defense-in-depth check (which itself
|
|
1092
|
-
# refuses a path outside the repo, git's own error, not this module's) is out of the picture --
|
|
1093
|
-
# containment is the ONLY guard standing, isolating exactly what this mutation tests.
|
|
1094
|
-
mutant_pin_exit=$(node "$F284_PIN_MUT" --dry-run --source . --fixture /tmp >/dev/null 2>&1; echo $?)
|
|
1095
|
-
check "mutant (F-284/F-286/F-287: assertFixturePinned's containment check neutered) lets --fixture /tmp through -- confirming the guard above currently depends on this exact check" \
|
|
1096
|
-
"$mutant_pin_exit" "0"
|
|
1097
|
-
pristine_pin_exit=$(node "$CVD" --dry-run --source . --fixture /tmp >/dev/null 2>&1; echo $?)
|
|
1098
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still refuses --fixture /tmp" \
|
|
1099
|
-
"$pristine_pin_exit" "1"
|
|
1100
|
-
rm -rf "$F284_PIN_MUT_DIR"
|
|
1101
|
-
trap - EXIT
|
|
1102
|
-
|
|
1103
|
-
# --- committed hash baseline for the five quota-paid shards the baseline rests on (results/ is
|
|
1104
|
-
# gitignored, so a git-diff check there is vacuously empty) -- MANIFEST.sha256 (`git add -f`'d past
|
|
1105
|
-
# the ignore) is verified when present, skipped VISIBLY when absent, never silently.
|
|
1106
|
-
CONV_DIR="$ROOT/tests/evals/results/39411eb4d2785c47e1491e0b6c54be174a3ac753/convergence"
|
|
1107
|
-
conv_n=$(ls "$CONV_DIR"/loop-code-loop-*.json 2>/dev/null | wc -l | tr -d ' ')
|
|
1108
|
-
if [ "$conv_n" = "5" ]; then
|
|
1109
|
-
(cd "$CONV_DIR" && sha256sum -c --status MANIFEST.sha256)
|
|
1110
|
-
check "F-289: the five quota-paid shards match the committed MANIFEST.sha256 baseline" "$?" "0"
|
|
1111
|
-
elif [ "$conv_n" = "0" ]; then
|
|
1112
|
-
echo " (skipped: $CONV_DIR's shards not present -- results/ is gitignored except MANIFEST.sha256, expected on a fresh clone/CI)"
|
|
1113
|
-
else
|
|
1114
|
-
bad "F-289: $CONV_DIR has $conv_n of 5 quota-paid shards on disk -- a real gap, not the expected all-or-nothing fresh-clone absence"
|
|
1115
|
-
fi
|
|
1116
|
-
# Guard shown to fail: verified BY HAND against a mktemp -d copy of the real shards, never the
|
|
1117
|
-
# tracked files (sha256sum -c is external, already battle-tested, not re-proven here) -- corrupt
|
|
1118
|
-
# flips OK to FAILED, restore flips back; real shards hashed identical before/after. Coder's report.
|
|
1119
|
-
|
|
1120
|
-
# --- a session-limit (or other hard-invocation-failure) exit must not be recorded as draw --
|
|
1121
|
-
# data. `startDraw()`'s `retry` used to discard `invokeCommand()`'s result outright, so a spawned
|
|
1122
|
-
# `claude` that hit the account's session limit read as `malformed` (before loop state existed) or
|
|
1123
|
-
# `running` (after) -- both a harness-EXTERNAL condition misrecorded as a fact about the definition
|
|
1124
|
-
# set. Hermetic throughout: every invocation below is a canned {ok,status,timedOut,stdout,stderr,
|
|
1125
|
-
# error} object or a stub `claude` binary that never reaches a model -- no live draw anywhere here.
|
|
1126
|
-
MK_INVOCATION_DRAW='
|
|
1127
|
-
function mkInvocationDraw(steps) {
|
|
1128
|
-
// steps[0] covers the OPENING invocation (mirrors startDraw()'"'"'s own eager retry() call);
|
|
1129
|
-
// steps[i] covers the i-th LATER retry() call. An exhausted sequence repeats its last step.
|
|
1130
|
-
return () => {
|
|
1131
|
-
let i = 0;
|
|
1132
|
-
let cur = steps[0];
|
|
1133
|
-
return {
|
|
1134
|
-
read: () => cur.state,
|
|
1135
|
-
retry: () => { i = Math.min(i + 1, steps.length - 1); cur = steps[i]; },
|
|
1136
|
-
cleanup() {},
|
|
1137
|
-
lastInvocation: () => cur.invocation,
|
|
1138
|
-
};
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
'
|
|
1142
|
-
|
|
1143
|
-
check "isHardInvocationFailure: undefined/null (every EXISTING synthetic handle in this suite -- none implement lastInvocation) reads as no info, never a failure" \
|
|
1144
|
-
"$(cj "process.stdout.write(JSON.stringify([M.isHardInvocationFailure(undefined), M.isHardInvocationFailure(null)]));")" \
|
|
1145
|
-
"[false,false]"
|
|
1146
|
-
|
|
1147
|
-
check "isHardInvocationFailure({}): an invocation object with NO recognizable field actually set reads the same as no info (F-326 -- the docstring's promise, now true of the code: status must be genuinely present and non-zero to count, not merely undefined !== 0)" \
|
|
1148
|
-
"$(cj "process.stdout.write(String(M.isHardInvocationFailure({})));")" "false"
|
|
1149
|
-
|
|
1150
|
-
# Staged: revert the status fix (invocation.status ?? 0 -> bare invocation.status) and confirm the
|
|
1151
|
-
# {} case above flips from false to true -- undefined !== 0 reads as a failure again.
|
|
1152
|
-
F326_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1153
|
-
trap 'rm -rf "$F326_MUT_DIR"' EXIT
|
|
1154
|
-
F326_MUT="$F326_MUT_DIR/convergence.mjs"
|
|
1155
|
-
cp "$ROOT/$CVD" "$F326_MUT"
|
|
1156
|
-
ln -s "$ROOT/tests/evals/lib" "$F326_MUT_DIR/lib"
|
|
1157
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F326_MUT_DIR/run.mjs"
|
|
1158
|
-
node -e "
|
|
1159
|
-
const fs = require('fs'); const p = '$F326_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1160
|
-
const FROM = \"if ((invocation.status ?? 0) !== 0 || Boolean(invocation.error)) return true;\";
|
|
1161
|
-
const TO = 'if (invocation.status !== 0 || Boolean(invocation.error)) return true; // MUTANT (F-326): absent-status guard removed';
|
|
1162
|
-
const count = s.split(FROM).length - 1;
|
|
1163
|
-
if (count !== 1) throw new Error('F-326 mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1164
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1165
|
-
"
|
|
1166
|
-
mutant_326=$(node --input-type=module -e "
|
|
1167
|
-
const M = await import('$F326_MUT');
|
|
1168
|
-
process.stdout.write(String(M.isHardInvocationFailure({})));
|
|
1169
|
-
")
|
|
1170
|
-
check "mutant (F-326: absent-status guard reverted to bare !== 0) reintroduces the false positive -- isHardInvocationFailure({}) reads true again" \
|
|
1171
|
-
"$mutant_326" "true"
|
|
1172
|
-
pristine_326=$(cj "process.stdout.write(String(M.isHardInvocationFailure({})));")
|
|
1173
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still reads false" \
|
|
1174
|
-
"$pristine_326" "false"
|
|
1175
|
-
rm -rf "$F326_MUT_DIR"
|
|
1176
|
-
trap - EXIT
|
|
1177
|
-
|
|
1178
|
-
check "fillArm: the OPENING invocation hitting the session-limit text throws HardInvocationFailureError immediately, distinguishable message, reason:'session-limit' (F-323)" \
|
|
1179
|
-
"$(cj "$MK_INVOCATION_DRAW
|
|
1180
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'prefix ' + M.SESSION_LIMIT_SIGNATURE + ' suffix', stderr:'', error:null };
|
|
1181
|
-
let caught = null;
|
|
1182
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1183
|
-
process.stdout.write(JSON.stringify({ isHardFailure: caught instanceof M.HardInvocationFailureError, reason: caught ? caught.reason : null, message: caught ? caught.message : null }));
|
|
1184
|
-
")" \
|
|
1185
|
-
'{"isHardFailure":true,"reason":"session-limit","message":"convergence: invocation hard-failed (account session limit) -- stopping the arm now; not recorded as a censored or malformed draw, and no replacement is drawn for it (F-308)"}'
|
|
1186
|
-
|
|
1187
|
-
check "fillArm: a LATER retry() hitting the session-limit text (after one genuine 'running' read) also throws HardInvocationFailureError -- the same check, not just an opening-call special case" \
|
|
1188
|
-
"$(cj "$MK_INVOCATION_DRAW
|
|
1189
|
-
const okInv = { ok:true, status:0, timedOut:false, stdout:'', stderr:'', error:null };
|
|
1190
|
-
const badInv = { ok:false, status:0, timedOut:false, stdout: M.SESSION_LIMIT_SIGNATURE, stderr:'', error:null };
|
|
1191
|
-
const seq = [{ invocation: okInv, state: { status:'running' } }, { invocation: badInv, state: { status:'running' } }];
|
|
1192
|
-
let caught = null;
|
|
1193
|
-
try { M.fillArm(mkInvocationDraw(seq), { n: 1, maxWaitAttempts: 3, report: () => {} }); } catch (e) { caught = e; }
|
|
1194
|
-
process.stdout.write(String(caught instanceof M.HardInvocationFailureError));
|
|
1195
|
-
")" "true"
|
|
1196
|
-
|
|
1197
|
-
check "fillArm: a non-zero status with NO session-limit text is the SAME failure class, message names the status, reason:'nonzero-exit'" \
|
|
1198
|
-
"$(cj "$MK_INVOCATION_DRAW
|
|
1199
|
-
const inv = { ok:false, status:1, timedOut:false, stdout:'', stderr:'', error:null };
|
|
1200
|
-
let caught = null;
|
|
1201
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1202
|
-
process.stdout.write(JSON.stringify({ isHardFailure: caught instanceof M.HardInvocationFailureError, reason: caught ? caught.reason : null, namesStatus: /status 1/.test(caught ? caught.message : '') }));
|
|
1203
|
-
")" '{"isHardFailure":true,"reason":"nonzero-exit","namesStatus":true}'
|
|
1204
|
-
|
|
1205
|
-
check "fillArm: a set spawn-level error with no text/status signal is ALSO the same failure class, message names it, reason:'spawn-error'" \
|
|
1206
|
-
"$(cj "$MK_INVOCATION_DRAW
|
|
1207
|
-
const inv = { ok:false, status:null, timedOut:false, stdout:'', stderr:'', error:'ENOENT' };
|
|
1208
|
-
let caught = null;
|
|
1209
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1210
|
-
process.stdout.write(JSON.stringify({ isHardFailure: caught instanceof M.HardInvocationFailureError, reason: caught ? caught.reason : null, namesError: /spawn error: ENOENT/.test(caught ? caught.message : '') }));
|
|
1211
|
-
")" '{"isHardFailure":true,"reason":"spawn-error","namesError":true}'
|
|
1212
|
-
|
|
1213
|
-
check "isHardInvocationFailure: status GENUINELY omitted (undefined) but every other field present and normal reads as no failure, same as F-326's fully-empty {} -- (invocation.status ?? 0) !== 0 only neutralises an ABSENT status, it is not fooled into treating undefined as some nonzero value" \
|
|
1214
|
-
"$(cj "process.stdout.write(String(M.isHardInvocationFailure({ ok:true, timedOut:false, stdout:'', stderr:'', error:null })));")" "false"
|
|
1215
|
-
|
|
1216
|
-
# F-324b: the text branch alone is gated on the draw's OWN resulting state not already showing a
|
|
1217
|
-
# completed pass -- a healthy draw's own closing summary IS this invocation's stdout under
|
|
1218
|
-
# --print, and can echo SESSION_LIMIT_SIGNATURE as prose (about this very guard) without that
|
|
1219
|
-
# being the incident. status/error stay unconditional regardless of state, checked separately
|
|
1220
|
-
# above. Uses the committed `done` golden (tests/scripts/goldens/loop-state-done.json) --
|
|
1221
|
-
# real data, not a hand-typed shape that could drift from what classifyDraw() actually requires.
|
|
1222
|
-
F324_DONE_STATE=$(node -e "process.stdout.write(JSON.stringify(JSON.parse(require('fs').readFileSync('$ROOT/tests/scripts/goldens/loop-state-done.json','utf8'))))")
|
|
1223
|
-
check "isHardInvocationFailure: text match ALONE is suppressed when the resulting state already shows a completed draw (a real 'done' golden, pass 2) -- the false-positive surface F-324 exists to close" \
|
|
1224
|
-
"$(cj "
|
|
1225
|
-
const doneState = $F324_DONE_STATE;
|
|
1226
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'Done. Added a guard for the text \"' + M.SESSION_LIMIT_SIGNATURE + '\" per the plan.', stderr:'', error:null };
|
|
1227
|
-
process.stdout.write(String(M.isHardInvocationFailure(inv, doneState)));
|
|
1228
|
-
")" "false"
|
|
1229
|
-
check "isHardInvocationFailure: the SAME text match is NOT suppressed when the resulting state is still running (not done) -- the gate narrows to completed draws only, it does not blunt the branch generally" \
|
|
1230
|
-
"$(cj "
|
|
1231
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: M.SESSION_LIMIT_SIGNATURE, stderr:'', error:null };
|
|
1232
|
-
process.stdout.write(String(M.isHardInvocationFailure(inv, { status:'running' })));
|
|
1233
|
-
")" "true"
|
|
1234
|
-
check "isHardInvocationFailure: a non-zero status is NOT suppressed by a completed state -- only the text branch is gated, status/error stay unconditional per the review's own instruction" \
|
|
1235
|
-
"$(cj "
|
|
1236
|
-
const doneState = $F324_DONE_STATE;
|
|
1237
|
-
const inv = { ok:false, status:1, timedOut:false, stdout:'', stderr:'', error:null };
|
|
1238
|
-
process.stdout.write(String(M.isHardInvocationFailure(inv, doneState)));
|
|
1239
|
-
")" "true"
|
|
1240
|
-
|
|
1241
|
-
# Staged: revert the F-324b gate (text branch reads unconditionally again, the pre-fix shape) and
|
|
1242
|
-
# confirm the healthy-draw false positive above flips from suppressed to thrown.
|
|
1243
|
-
F324_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1244
|
-
trap 'rm -rf "$F324_MUT_DIR"' EXIT
|
|
1245
|
-
F324_MUT="$F324_MUT_DIR/convergence.mjs"
|
|
1246
|
-
cp "$ROOT/$CVD" "$F324_MUT"
|
|
1247
|
-
ln -s "$ROOT/tests/evals/lib" "$F324_MUT_DIR/lib"
|
|
1248
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F324_MUT_DIR/run.mjs"
|
|
1249
|
-
node -e "
|
|
1250
|
-
const fs = require('fs'); const p = '$F324_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1251
|
-
const FROM = \"if (loopStateJson != null && isTerminalDrawKind(classifyDraw(loopStateJson).kind)) return false;\";
|
|
1252
|
-
const TO = 'if (false) return false; // MUTANT (F-324b): completion gate removed';
|
|
1253
|
-
const count = s.split(FROM).length - 1;
|
|
1254
|
-
if (count !== 1) throw new Error('F-324b gate mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1255
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1256
|
-
"
|
|
1257
|
-
mutant_324=$(node --input-type=module -e "
|
|
1258
|
-
const M = await import('$F324_MUT');
|
|
1259
|
-
const doneState = $F324_DONE_STATE;
|
|
1260
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'Done. Added a guard for the text \"' + M.SESSION_LIMIT_SIGNATURE + '\" per the plan.', stderr:'', error:null };
|
|
1261
|
-
process.stdout.write(String(M.isHardInvocationFailure(inv, doneState)));
|
|
1262
|
-
")
|
|
1263
|
-
check "mutant (F-324b: completion gate removed) reintroduces the false positive -- a healthy, completed draw now reads as a hard failure again" \
|
|
1264
|
-
"$mutant_324" "true"
|
|
1265
|
-
pristine_324=$(cj "
|
|
1266
|
-
const doneState = $F324_DONE_STATE;
|
|
1267
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'Done. Added a guard for the text \"' + M.SESSION_LIMIT_SIGNATURE + '\" per the plan.', stderr:'', error:null };
|
|
1268
|
-
process.stdout.write(String(M.isHardInvocationFailure(inv, doneState)));
|
|
1269
|
-
")
|
|
1270
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still suppresses it" \
|
|
1271
|
-
"$pristine_324" "false"
|
|
1272
|
-
rm -rf "$F324_MUT_DIR"
|
|
1273
|
-
trap - EXIT
|
|
1274
|
-
|
|
1275
|
-
check "fillArm: timedOut:true stays on the EXISTING running/censor path -- never this new outcome, even though a real timeout also sets its own error field" \
|
|
1276
|
-
"$(cj "$MK_INVOCATION_DRAW
|
|
1277
|
-
const inv = { ok:false, status:null, timedOut:true, stdout:'', stderr:'', error:'ETIMEDOUT' };
|
|
1278
|
-
const r = M.fillArm(mkInvocationDraw([{ invocation: inv, state: { status:'running' } }]), { n: 1, maxWaitAttempts: 0, report: () => {} });
|
|
1279
|
-
process.stdout.write(JSON.stringify({ waitExhausted: r.waitExhausted, censorPresent: r.censor !== null }));
|
|
1280
|
-
")" '{"waitExhausted":true,"censorPresent":true}'
|
|
1281
|
-
|
|
1282
|
-
# The exact assembly drawArmForSha() uses (makeShardWriter -> fillArm -> conditional persistence),
|
|
1283
|
-
# same style as the shard/censor/fixture wiring checks above: (a) the arm stops (throws), (b) no censor
|
|
1284
|
-
# record is written, (c) no replacement/shard slot is consumed -- resumeArm() sees nothing.
|
|
1285
|
-
F308_SHA="f308quota$(date +%s)"
|
|
1286
|
-
f308_assembly=$(node --input-type=module -e "
|
|
1287
|
-
const M = await import('$ROOT/$CVD');
|
|
1288
|
-
const fs = await import('node:fs');
|
|
1289
|
-
const path = await import('node:path');
|
|
1290
|
-
$MK_INVOCATION_DRAW
|
|
1291
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: M.SESSION_LIMIT_SIGNATURE, stderr:'', error:null };
|
|
1292
|
-
const makeDraw = mkInvocationDraw([{ invocation: inv, state: null }]);
|
|
1293
|
-
const occ = new Set();
|
|
1294
|
-
const { newDraw, onDraw } = M.makeShardWriter(makeDraw, '$F308_SHA', M.TASK_ID, 1, occ, 0);
|
|
1295
|
-
let caught = null;
|
|
1296
|
-
try {
|
|
1297
|
-
const result = M.fillArm(newDraw, { n: 1, onDraw, report: () => {} });
|
|
1298
|
-
if (result.censor) M.writeCensorRecord('$F308_SHA', M.TASK_ID, result.censor);
|
|
1299
|
-
if (result.breach) M.writeBreachRecord('$F308_SHA', M.TASK_ID, result.breachReason);
|
|
1300
|
-
} catch (e) { caught = e; }
|
|
1301
|
-
const shardPath = M.loopShardPath('$F308_SHA', M.TASK_ID, 0);
|
|
1302
|
-
const censorDir = path.join(path.dirname(shardPath), 'censored');
|
|
1303
|
-
process.stdout.write(JSON.stringify({
|
|
1304
|
-
threwHardFailure: caught instanceof M.HardInvocationFailureError,
|
|
1305
|
-
shardExists: fs.existsSync(shardPath),
|
|
1306
|
-
censorDirExists: fs.existsSync(censorDir),
|
|
1307
|
-
resume: M.resumeArm('$F308_SHA', M.TASK_ID, 1).resume,
|
|
1308
|
-
}));
|
|
1309
|
-
" 2>&1)
|
|
1310
|
-
check "the exact assembly drawArmForSha() uses: a quota-exhausted opening invocation throws, writes NO shard, NO censor record, and consumes NO replacement slot (resumeArm sees nothing)" \
|
|
1311
|
-
"$f308_assembly" \
|
|
1312
|
-
'{"threwHardFailure":true,"shardExists":false,"censorDirExists":false,"resume":[]}'
|
|
1313
|
-
rm -rf "$ROOT/tests/evals/results/$F308_SHA"
|
|
1314
|
-
|
|
1315
|
-
# "The driver exits non-zero" (the acceptance point for the driver), proven WITHOUT a live-mode
|
|
1316
|
-
# CLI invocation of this file's own --source/--fixture/--runs shape -- evals-packaging.sh's
|
|
1317
|
-
# check audits every CLI call in this file for a dry-run/merge/certify/help/negative-argument
|
|
1318
|
-
# exemption specifically so nothing here can reach a real model unnoticed, and a PATH-stubbed live
|
|
1319
|
-
# call would need a whole new exemption category to stay honestly covered by that audit. Proven two
|
|
1320
|
-
# cheaper ways instead, for a property this module already establishes structurally:
|
|
1321
|
-
check "letting a hard invocation failure escape fillArm() UNCAUGHT (exactly what main() below does -- it has no try/catch of its own around drawArmForSha()) makes the PROCESS exit non-zero, Node's own default for an uncaught exception" \
|
|
1322
|
-
"$(node --input-type=module -e "
|
|
1323
|
-
const M = await import('$ROOT/$CVD');
|
|
1324
|
-
$MK_INVOCATION_DRAW
|
|
1325
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'prefix ' + M.SESSION_LIMIT_SIGNATURE + ' suffix', stderr:'', error:null };
|
|
1326
|
-
M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} });
|
|
1327
|
-
" >/dev/null 2>&1; echo $?)" "1"
|
|
1328
|
-
F308_MAIN_CATCH='.catch((err) => { process.stderr.write(`convergence: ${err.message}\n`); process.exit(1); });'
|
|
1329
|
-
check "the module-level .catch(...) chain (below main()'s own closing brace) is present exactly once -- this alone is a PRESENCE fact, not proof that nothing upstream of it intercepts a hard-invocation-failure throw first (see F-320's absence checks below for that)" \
|
|
1330
|
-
"$(grep -cF "$F308_MAIN_CATCH" "$ROOT/$CVD")" "1"
|
|
1331
|
-
|
|
1332
|
-
# the presence check above was staged against wrapping main()'s own
|
|
1333
|
-
# drawArmForSha() call in `catch (e) { if (e instanceof HardInvocationFailureError) return 0; throw
|
|
1334
|
-
# e; }` -- exit 0 on a quota wall, violating acceptance (c)/(d) -- and stayed green: a PRESENCE count
|
|
1335
|
-
# cannot prove an ABSENCE. Fixed with absence assertions in the two places such a catch could be
|
|
1336
|
-
# added: drawArmForSha()'s own body, and main()'s live-draw branch (the only branch that calls it).
|
|
1337
|
-
# awk-extracted from the real function boundary (this file's own convention: every top-level
|
|
1338
|
-
# function/branch closes flush left; nothing nested does), not eyeballed off a line range that could
|
|
1339
|
-
# drift as the file changes.
|
|
1340
|
-
extract_fn_body() {
|
|
1341
|
-
# $1 = file, $2 = a substring unique to the FIRST line of the body to extract. Prints from that
|
|
1342
|
-
# line through the next column-0 '}' (inclusive) -- the same brace-flush-left convention this
|
|
1343
|
-
# file's own mutation-staging code relies on elsewhere (e.g. the sha scratch-copy checks above).
|
|
1344
|
-
awk -v pat="$2" 'index($0, pat) && !p {p=1} p{print} p && /^}/{exit}' "$1"
|
|
1345
|
-
}
|
|
1346
|
-
# extract_fn_body prints NOTHING when its anchor matches no line, and
|
|
1347
|
-
# `grep -c` over nothing is 0 -- which is exactly what the check below asserts, so a drifted anchor
|
|
1348
|
-
# (e.g. the signature gaining `async`) would pass green forever. Link C is already controlled by its
|
|
1349
|
-
# paired mutant check asserting 1; link A had nothing. Pin the extraction non-empty first.
|
|
1350
|
-
dafs_body=$(extract_fn_body "$ROOT/$CVD" 'export function drawArmForSha(')
|
|
1351
|
-
check "F-328: drawArmForSha()'s body actually extracted (sentinel present, so the 0-catch count below cannot pass on an empty extraction)" \
|
|
1352
|
-
"$(printf '%s\n' "$dafs_body" | grep -c 'const pf = preflight();')" "1"
|
|
1353
|
-
dafs_catches=$(printf '%s\n' "$dafs_body" | grep -c 'catch')
|
|
1354
|
-
check "drawArmForSha()'s own body has zero catch clauses (awk-extracted, not eyeballed) -- nothing here could intercept fillArm()'s F-308 throw before it leaves this function (link A is closed structurally, not by a presence count)" \
|
|
1355
|
-
"$dafs_catches" "0"
|
|
1356
|
-
main_live_catches=$(extract_fn_body "$ROOT/$CVD" "Checked BEFORE resolveSource's worktree checkout" | grep -c 'catch')
|
|
1357
|
-
check "main()'s live-draw branch (awk-extracted from its own preflight comment through main()'s closing brace) has zero catch clauses -- nothing here could intercept drawArmForSha()'s F-308 throw before it reaches the module-level .catch() above (link C, the gap F-320 named, is now closed structurally)" \
|
|
1358
|
-
"$main_live_catches" "0"
|
|
1359
|
-
|
|
1360
|
-
# Staged against the EXACT mutation that exposed the gap: wrap main()'s own drawArmForSha() call so a
|
|
1361
|
-
# HardInvocationFailureError exits 0 instead of propagating. The presence check above (re-run here
|
|
1362
|
-
# on the mutant) must stay green, unchanged -- reproducing why it was insensitive; the new
|
|
1363
|
-
# live-draw-branch absence check must go red.
|
|
1364
|
-
F320_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1365
|
-
trap 'rm -rf "$F320_MUT_DIR"' EXIT
|
|
1366
|
-
F320_MUT="$F320_MUT_DIR/convergence.mjs"
|
|
1367
|
-
cp "$ROOT/$CVD" "$F320_MUT"
|
|
1368
|
-
ln -s "$ROOT/tests/evals/lib" "$F320_MUT_DIR/lib"
|
|
1369
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F320_MUT_DIR/run.mjs"
|
|
1370
|
-
node -e "
|
|
1371
|
-
const fs = require('fs'); const p = '$F320_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1372
|
-
const FROM = 'const result = drawArmForSha(source.dir, fixtureDir, source.sha, liveDrawOpts(args));';
|
|
1373
|
-
const TO = 'let result; try { result = drawArmForSha(source.dir, fixtureDir, source.sha, liveDrawOpts(args)); } catch (e) { if (e instanceof HardInvocationFailureError) return 0; throw e; } // MUTANT (F-320): exit 0 on a quota wall';
|
|
1374
|
-
const count = s.split(FROM).length - 1;
|
|
1375
|
-
if (count !== 1) throw new Error('F-320 mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1376
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1377
|
-
"
|
|
1378
|
-
mutant_320_presence=$(grep -cF "$F308_MAIN_CATCH" "$F320_MUT")
|
|
1379
|
-
mutant_320_live=$(extract_fn_body "$F320_MUT" "Checked BEFORE resolveSource's worktree checkout" | grep -c 'catch')
|
|
1380
|
-
check "mutant (F-320: main() swallows HardInvocationFailureError and returns 0 -- exit 0 on a quota wall) -- the OLD presence check stays green, unchanged (reproducing the exact insensitivity the review found)" \
|
|
1381
|
-
"$mutant_320_presence" "1"
|
|
1382
|
-
check "mutant (F-320, same mutation): the NEW live-draw-branch absence check goes red -- a catch now exists where the review's own staged mutation put one" \
|
|
1383
|
-
"$mutant_320_live" "1"
|
|
1384
|
-
rm -rf "$F320_MUT_DIR"
|
|
1385
|
-
trap - EXIT
|
|
1386
|
-
pristine_320_live=$(extract_fn_body "$ROOT/$CVD" "Checked BEFORE resolveSource's worktree checkout" | grep -c 'catch')
|
|
1387
|
-
check "pristine convergence.mjs (a fresh read of the tracked file, not the mutated scratch copy) still reads zero -- the mutation above never touched the tracked file" \
|
|
1388
|
-
"$pristine_320_live" "0"
|
|
1389
|
-
|
|
1390
|
-
# Mutation 1 (the load-bearing one): remove BOTH failOnHardInvocationFailure() call sites in
|
|
1391
|
-
# fillArm() -- reproduces the EXACT pre-fix bug this guard exists to catch: a session-limit
|
|
1392
|
-
# exit falls through to classifyDraw(null), reads 'malformed', and after maxReplacements is
|
|
1393
|
-
# exhausted throws the OLD generic harness-fault Error, not HardInvocationFailureError. Staged on a
|
|
1394
|
-
# scratch copy, never the tracked file.
|
|
1395
|
-
F308_GUARD_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1396
|
-
trap 'rm -rf "$F308_GUARD_MUT_DIR"' EXIT
|
|
1397
|
-
F308_GUARD_MUT="$F308_GUARD_MUT_DIR/convergence.mjs"
|
|
1398
|
-
cp "$ROOT/$CVD" "$F308_GUARD_MUT"
|
|
1399
|
-
ln -s "$ROOT/tests/evals/lib" "$F308_GUARD_MUT_DIR/lib"
|
|
1400
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F308_GUARD_MUT_DIR/run.mjs"
|
|
1401
|
-
node -e "
|
|
1402
|
-
const fs = require('fs'); const p = '$F308_GUARD_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1403
|
-
const FROM = 'failOnHardInvocationFailure(draw);';
|
|
1404
|
-
const TO = '/* MUTANT (F-308): guard removed */;';
|
|
1405
|
-
const count = s.split(FROM).length - 1;
|
|
1406
|
-
if (count !== 2) throw new Error('F-308 guard mutant anchor occurs ' + count + ' time(s), not exactly 2 -- update this mutation');
|
|
1407
|
-
fs.writeFileSync(p, s.split(FROM).join(TO));
|
|
1408
|
-
"
|
|
1409
|
-
mutant_guard=$(node --input-type=module -e "
|
|
1410
|
-
const M = await import('$F308_GUARD_MUT');
|
|
1411
|
-
$MK_INVOCATION_DRAW
|
|
1412
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'prefix ' + M.SESSION_LIMIT_SIGNATURE + ' suffix', stderr:'', error:null };
|
|
1413
|
-
let caught = null;
|
|
1414
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1415
|
-
process.stdout.write(JSON.stringify({ isHardFailure: caught instanceof M.HardInvocationFailureError, isOldHarnessFault: /malformed loop-state draws/.test(caught ? caught.message : '') }));
|
|
1416
|
-
")
|
|
1417
|
-
check "mutant (F-308: both failOnHardInvocationFailure() call sites removed) reproduces the EXACT pre-fix misclassification -- a session-limit exit becomes '6 malformed loop-state draws ... harness fault', not HardInvocationFailureError" \
|
|
1418
|
-
"$mutant_guard" '{"isHardFailure":false,"isOldHarnessFault":true}'
|
|
1419
|
-
pristine_guard=$(cj "$MK_INVOCATION_DRAW
|
|
1420
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'prefix ' + M.SESSION_LIMIT_SIGNATURE + ' suffix', stderr:'', error:null };
|
|
1421
|
-
let caught = null;
|
|
1422
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1423
|
-
process.stdout.write(JSON.stringify({ isHardFailure: caught instanceof M.HardInvocationFailureError, isOldHarnessFault: /malformed loop-state draws/.test(caught ? caught.message : '') }));
|
|
1424
|
-
")
|
|
1425
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still throws HardInvocationFailureError on the very first attempt" \
|
|
1426
|
-
"$pristine_guard" '{"isHardFailure":true,"isOldHarnessFault":false}'
|
|
1427
|
-
rm -rf "$F308_GUARD_MUT_DIR"
|
|
1428
|
-
trap - EXIT
|
|
1429
|
-
|
|
1430
|
-
# Mutation 2: neuter isHardInvocationFailure()'s TEXT-match branch alone (status/error checks left
|
|
1431
|
-
# intact). Correction: no observed session-limit incident records its exit
|
|
1432
|
-
# status through THIS harness's OWN invocation capture -- the old code discarded that value
|
|
1433
|
-
# outright, which is the defect being guarded -- so the status:0/error:null pairing used
|
|
1434
|
-
# below is an ASSUMED test shape, not an evidenced one (a prior version of this comment claimed
|
|
1435
|
-
# otherwise). `run.mjs:733-740` records a real counter-example the other way: four session-limit
|
|
1436
|
-
# exits it caught arrived `ok:false` via its own `!run.ok` gate. The text branch is therefore the
|
|
1437
|
-
# UNPROVEN half of this detector, kept as defence in depth against a shape this harness has not
|
|
1438
|
-
# itself captured -- this mutation proves the branch is load-bearing for THAT assumed shape, not
|
|
1439
|
-
# that the shape is confirmed real.
|
|
1440
|
-
F308_TEXT_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1441
|
-
trap 'rm -rf "$F308_TEXT_MUT_DIR"' EXIT
|
|
1442
|
-
F308_TEXT_MUT="$F308_TEXT_MUT_DIR/convergence.mjs"
|
|
1443
|
-
cp "$ROOT/$CVD" "$F308_TEXT_MUT"
|
|
1444
|
-
ln -s "$ROOT/tests/evals/lib" "$F308_TEXT_MUT_DIR/lib"
|
|
1445
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F308_TEXT_MUT_DIR/run.mjs"
|
|
1446
|
-
node -e "
|
|
1447
|
-
const fs = require('fs'); const p = '$F308_TEXT_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1448
|
-
const FROM = 'if (text.includes(SESSION_LIMIT_SIGNATURE)) return true;';
|
|
1449
|
-
const TO = 'if (false) return true; // MUTANT (F-308): text signature match disabled';
|
|
1450
|
-
const count = s.split(FROM).length - 1;
|
|
1451
|
-
if (count !== 1) throw new Error('F-308 text mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1452
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1453
|
-
"
|
|
1454
|
-
mutant_text=$(node --input-type=module -e "
|
|
1455
|
-
const M = await import('$F308_TEXT_MUT');
|
|
1456
|
-
$MK_INVOCATION_DRAW
|
|
1457
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'prefix ' + M.SESSION_LIMIT_SIGNATURE + ' suffix', stderr:'', error:null };
|
|
1458
|
-
let caught = null;
|
|
1459
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1460
|
-
process.stdout.write(String(caught instanceof M.HardInvocationFailureError));
|
|
1461
|
-
")
|
|
1462
|
-
check "mutant (F-308: text-signature branch disabled) misses an assumed status:0/error:null shape where only the text signals it (unproven, not evidenced -- see comment above) -- no longer throws HardInvocationFailureError" \
|
|
1463
|
-
"$mutant_text" "false"
|
|
1464
|
-
pristine_text=$(cj "$MK_INVOCATION_DRAW
|
|
1465
|
-
const inv = { ok:false, status:0, timedOut:false, stdout: 'prefix ' + M.SESSION_LIMIT_SIGNATURE + ' suffix', stderr:'', error:null };
|
|
1466
|
-
let caught = null;
|
|
1467
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: null }]), { n: 1, report: () => {} }); } catch (e) { caught = e; }
|
|
1468
|
-
process.stdout.write(String(caught instanceof M.HardInvocationFailureError));
|
|
1469
|
-
")
|
|
1470
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still catches it" \
|
|
1471
|
-
"$pristine_text" "true"
|
|
1472
|
-
rm -rf "$F308_TEXT_MUT_DIR"
|
|
1473
|
-
trap - EXIT
|
|
1474
|
-
|
|
1475
|
-
# Mutation 3: remove the timedOut carve-out -- proves it is load-bearing, not decorative. A real
|
|
1476
|
-
# timeout also sets its own `error` field, so without this carve-out FIRST the status/error fallback
|
|
1477
|
-
# would wrongly promote a genuinely still-running (merely slow) draw into HardInvocationFailureError.
|
|
1478
|
-
F308_TIMEOUT_MUT_DIR=$(mktemp -d) || { bad "mktemp failed"; exit 1; }
|
|
1479
|
-
trap 'rm -rf "$F308_TIMEOUT_MUT_DIR"' EXIT
|
|
1480
|
-
F308_TIMEOUT_MUT="$F308_TIMEOUT_MUT_DIR/convergence.mjs"
|
|
1481
|
-
cp "$ROOT/$CVD" "$F308_TIMEOUT_MUT"
|
|
1482
|
-
ln -s "$ROOT/tests/evals/lib" "$F308_TIMEOUT_MUT_DIR/lib"
|
|
1483
|
-
ln -s "$ROOT/tests/evals/run.mjs" "$F308_TIMEOUT_MUT_DIR/run.mjs"
|
|
1484
|
-
node -e "
|
|
1485
|
-
const fs = require('fs'); const p = '$F308_TIMEOUT_MUT'; const s = fs.readFileSync(p, 'utf8');
|
|
1486
|
-
const FROM = 'if (invocation == null || invocation.timedOut) return false;';
|
|
1487
|
-
const TO = 'if (invocation == null) return false; // MUTANT (F-308): timedOut carve-out removed';
|
|
1488
|
-
const count = s.split(FROM).length - 1;
|
|
1489
|
-
if (count !== 1) throw new Error('F-308 timeout mutant anchor occurs ' + count + ' time(s), not exactly 1 -- update this mutation');
|
|
1490
|
-
fs.writeFileSync(p, s.replace(FROM, TO));
|
|
1491
|
-
"
|
|
1492
|
-
mutant_timeout=$(node --input-type=module -e "
|
|
1493
|
-
const M = await import('$F308_TIMEOUT_MUT');
|
|
1494
|
-
$MK_INVOCATION_DRAW
|
|
1495
|
-
const inv = { ok:false, status:null, timedOut:true, stdout:'', stderr:'', error:'ETIMEDOUT' };
|
|
1496
|
-
let caught = null;
|
|
1497
|
-
try { M.fillArm(mkInvocationDraw([{ invocation: inv, state: { status:'running' } }]), { n: 1, maxWaitAttempts: 0, report: () => {} }); } catch (e) { caught = e; }
|
|
1498
|
-
process.stdout.write(String(caught instanceof M.HardInvocationFailureError));
|
|
1499
|
-
")
|
|
1500
|
-
check "mutant (F-308: timedOut carve-out removed) wrongly promotes a genuine timeout into HardInvocationFailureError, via the status/error fallback its own error field trips" \
|
|
1501
|
-
"$mutant_timeout" "true"
|
|
1502
|
-
pristine_timeout=$(cj "$MK_INVOCATION_DRAW
|
|
1503
|
-
const inv = { ok:false, status:null, timedOut:true, stdout:'', stderr:'', error:'ETIMEDOUT' };
|
|
1504
|
-
const r = M.fillArm(mkInvocationDraw([{ invocation: inv, state: { status:'running' } }]), { n: 1, maxWaitAttempts: 0, report: () => {} });
|
|
1505
|
-
process.stdout.write(JSON.stringify({ waitExhausted: r.waitExhausted, censorPresent: r.censor !== null }));
|
|
1506
|
-
")
|
|
1507
|
-
check "pristine convergence.mjs (mutation reverted -- a fresh copy, not the mutated scratch file) still routes a genuine timeout through the normal censor path" \
|
|
1508
|
-
"$pristine_timeout" '{"waitExhausted":true,"censorPresent":true}'
|
|
1509
|
-
rm -rf "$F308_TIMEOUT_MUT_DIR"
|
|
1510
|
-
trap - EXIT
|
|
1511
|
-
|
|
1512
|
-
echo
|
|
1513
|
-
printf ' %d passed, %d failed\n' "$pass" "$fail"
|
|
1514
|
-
[ "$fail" -eq 0 ]
|