letitloop 0.2.0__py3-none-any.whl
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.
- letitloop-0.2.0.dist-info/METADATA +232 -0
- letitloop-0.2.0.dist-info/RECORD +175 -0
- letitloop-0.2.0.dist-info/WHEEL +5 -0
- letitloop-0.2.0.dist-info/entry_points.txt +4 -0
- letitloop-0.2.0.dist-info/licenses/LICENSE +21 -0
- letitloop-0.2.0.dist-info/top_level.txt +1 -0
- orchestrator/SKILL.md +292 -0
- orchestrator/__init__.py +151 -0
- orchestrator/anti_ouroboros.py +78 -0
- orchestrator/approval.py +139 -0
- orchestrator/ast_node_splicer.py +130 -0
- orchestrator/ast_splicer.py +94 -0
- orchestrator/audit.py +88 -0
- orchestrator/budget.py +195 -0
- orchestrator/checkpoint.py +248 -0
- orchestrator/cli.py +1971 -0
- orchestrator/codebase_introspector.py +66 -0
- orchestrator/component_slicer.py +185 -0
- orchestrator/config.py +152 -0
- orchestrator/contract.py +404 -0
- orchestrator/dag_validator.py +172 -0
- orchestrator/elasticity_governor.py +80 -0
- orchestrator/env_doctor.py +166 -0
- orchestrator/errors.py +211 -0
- orchestrator/events.py +120 -0
- orchestrator/evidence.py +203 -0
- orchestrator/exceptions.py +37 -0
- orchestrator/experimental/arena_arbiter.py +260 -0
- orchestrator/experimental/fuzz_engine.py +206 -0
- orchestrator/experimental/mutation_tester.py +382 -0
- orchestrator/failure.py +226 -0
- orchestrator/fast_sandbox.py +126 -0
- orchestrator/feasibility_gate.py +115 -0
- orchestrator/feedback.py +302 -0
- orchestrator/fixtures/__init__.py +0 -0
- orchestrator/fixtures/example_contract.json +50 -0
- orchestrator/fixtures/generated/evidence-cli-run-test-step-1.json +47 -0
- orchestrator/fixtures/generated/evidence-cli-run-test-step-2.json +47 -0
- orchestrator/fixtures/generated/evidence-inject-test-a.json +47 -0
- orchestrator/fixtures/generated/evidence-inject-test-b.json +47 -0
- orchestrator/fixtures/generated/evidence-inject-test-c.json +47 -0
- orchestrator/fixtures/generated/evidence-json-test-a.json +47 -0
- orchestrator/fixtures/generated/evidence-json-test-b.json +47 -0
- orchestrator/fixtures/generated/fail-report-fail-task-1.json +47 -0
- orchestrator/fixtures/generated/fail-report-json-task-1.json +47 -0
- orchestrator/fixtures/generated/fail-report-success-task-1.json +47 -0
- orchestrator/fixtures/generated/fuzz-engine-design.json +63 -0
- orchestrator/fixtures/generated/fuzz-engine-impl.json +62 -0
- orchestrator/fixtures/generated/fuzz-engine-tests.json +62 -0
- orchestrator/fixtures/generated/fuzz-engine-verify.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-1.json +63 -0
- orchestrator/fixtures/generated/goal-orch-step-2.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-3.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-4.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-5.json +62 -0
- orchestrator/fixtures/generated/goal-orch-step-6.json +63 -0
- orchestrator/fixtures/generated/implement-a-thread-safe-token-bucket-rat-task-1.json +53 -0
- orchestrator/fixtures/generated/orchestrator-checkpoint-rollback-3.json +63 -0
- orchestrator/fixtures/generated/orchestrator-checkpoint-rollback.json +62 -0
- orchestrator/fixtures/generated/orchestrator-live-telemetry-2.json +62 -0
- orchestrator/fixtures/generated/orchestrator-live-telemetry.json +62 -0
- orchestrator/fixtures/generated/orchestrator-spec-synthesis-1.json +62 -0
- orchestrator/fixtures/generated/orchestrator-spec-synthesis.json +62 -0
- orchestrator/fixtures/generated/orchestrator-test-verification-4.json +62 -0
- orchestrator/fixtures/generated/orchestrator-test-verification.json +62 -0
- orchestrator/fixtures/generated/perf-step-1.json +61 -0
- orchestrator/fixtures/generated/perf-step-2.json +62 -0
- orchestrator/fixtures/generated/perf-step-3.json +62 -0
- orchestrator/fixtures/generated/perf-step-4.json +62 -0
- orchestrator/fixtures/generated/perf-step-5.json +63 -0
- orchestrator/fixtures/generated/phase2-proof-two-step-step-1.json +47 -0
- orchestrator/fixtures/generated/phase2-proof-two-step-step-2.json +47 -0
- orchestrator/fixtures/generated/planner-spec-synthesis-impl.json +59 -0
- orchestrator/fixtures/generated/self-evolution-ast-formatter.json +69 -0
- orchestrator/fixtures/generated/self-evolution-checkpoint-rollback.json +70 -0
- orchestrator/fixtures/generated/self-evolution-spec-synthesis.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-1.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-2.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-3.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-4.json +70 -0
- orchestrator/fixtures/generated/self-evolution-step-5.json +65 -0
- orchestrator/fixtures/generated/self-evolution-telemetry.json +70 -0
- orchestrator/fixtures/generated/self-evolution-tests.json +71 -0
- orchestrator/fixtures/generated/spec-telemetry-research-design.json +64 -0
- orchestrator/fixtures/generated/spec-telemetry-step-1.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-2.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-3.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-4.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-step-5.json +62 -0
- orchestrator/fixtures/generated/spec-telemetry-verification.json +58 -0
- orchestrator/fixtures/generated/token-bucket-impl.json +69 -0
- orchestrator/fixtures/generated/token-bucket-step-1.json +70 -0
- orchestrator/fixtures/generated/token-bucket-step-2.json +70 -0
- orchestrator/fixtures/generated/token-bucket-step-3.json +60 -0
- orchestrator/fixtures/generated/token-bucket-tests.json +70 -0
- orchestrator/fixtures/generated/token-bucket-verify.json +61 -0
- orchestrator/fixtures/generated/trace-ux-tests-step-1.json +64 -0
- orchestrator/fixtures/generated/trace-ux-tests-step-2.json +64 -0
- orchestrator/fixtures/generated/trace-ux-tests-step-3.json +62 -0
- orchestrator/fixtures/generated/tui-live-telemetry-impl.json +59 -0
- orchestrator/fixtures/phase1_proof_escalation_contract.json +41 -0
- orchestrator/fixtures/phase1_proof_happy_path_contract.json +83 -0
- orchestrator/fixtures/phase1_proof_qc_contract.json +41 -0
- orchestrator/fixtures/phase1_proof_repair_contract.json +41 -0
- orchestrator/fixtures/phase2_proof_two_step_goal.json +15 -0
- orchestrator/fixtures/run_proofs.py +299 -0
- orchestrator/fixtures/test_normalizer.py +16 -0
- orchestrator/generator.py +239 -0
- orchestrator/goal.py +245 -0
- orchestrator/handoff.py +86 -0
- orchestrator/hybrid_worker.py +840 -0
- orchestrator/impossibility.py +162 -0
- orchestrator/limits.py +60 -0
- orchestrator/live_evolution_engine.py +247 -0
- orchestrator/llm.py +291 -0
- orchestrator/local_tool_calling.py +285 -0
- orchestrator/lock.py +404 -0
- orchestrator/mcp_client.py +571 -0
- orchestrator/mcp_server.py +344 -0
- orchestrator/memory_bridge.py +182 -0
- orchestrator/metrics.py +159 -0
- orchestrator/micro_epoch.py +42 -0
- orchestrator/models.py +350 -0
- orchestrator/parsing.py +237 -0
- orchestrator/patch_applier.py +154 -0
- orchestrator/plan_preview.py +138 -0
- orchestrator/plan_quality.py +357 -0
- orchestrator/planner.py +532 -0
- orchestrator/preferences.py +115 -0
- orchestrator/preflight.py +141 -0
- orchestrator/process_guard.py +357 -0
- orchestrator/prometheus_exporter.py +207 -0
- orchestrator/prompts.py +275 -0
- orchestrator/proposal_ledger.py +194 -0
- orchestrator/provenance.py +263 -0
- orchestrator/provider_scheduler.py +394 -0
- orchestrator/qc/__init__.py +153 -0
- orchestrator/qc/aggregator.py +330 -0
- orchestrator/qc/parsing.py +287 -0
- orchestrator/qc/personas.py +242 -0
- orchestrator/qc/runner.py +569 -0
- orchestrator/qc_overrule.py +87 -0
- orchestrator/qc_review.py +282 -0
- orchestrator/quality_lenses.py +314 -0
- orchestrator/quality_plan.py +449 -0
- orchestrator/quality_plane.py +103 -0
- orchestrator/reconcile.py +191 -0
- orchestrator/replanner.py +433 -0
- orchestrator/research.py +176 -0
- orchestrator/review_artifact.py +672 -0
- orchestrator/safety.py +271 -0
- orchestrator/schemas.py +230 -0
- orchestrator/scope.py +466 -0
- orchestrator/sensory_radar.py +79 -0
- orchestrator/skill_installer.py +140 -0
- orchestrator/sse_server.py +160 -0
- orchestrator/state.py +871 -0
- orchestrator/subprocess_helper.py +131 -0
- orchestrator/supervisor/__init__.py +184 -0
- orchestrator/supervisor/_shared.py +164 -0
- orchestrator/supervisor/cleanup.py +185 -0
- orchestrator/supervisor/core.py +1680 -0
- orchestrator/supervisor/recovery.py +367 -0
- orchestrator/supervisor/reporting.py +251 -0
- orchestrator/surgical_extractor.py +119 -0
- orchestrator/telemetry.py +61 -0
- orchestrator/templates.py +268 -0
- orchestrator/token_gate.py +245 -0
- orchestrator/tui.py +649 -0
- orchestrator/verifier.py +1103 -0
- orchestrator/webhooks.py +168 -0
- orchestrator/worker.py +469 -0
- orchestrator/worker_adapters.py +815 -0
- orchestrator/worker_pool.py +121 -0
- orchestrator/worktree.py +364 -0
orchestrator/verifier.py
ADDED
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
"""Deterministic verifier: command exit, file exists/nonempty, JSON parse, content regex/exact."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
import functools
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import shlex
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
from typing import Optional, Tuple
|
|
14
|
+
|
|
15
|
+
from .exceptions import VerifierError as VerifierError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class VerifierResult:
|
|
19
|
+
"""Result of a single verification check."""
|
|
20
|
+
|
|
21
|
+
def __init__(self, check_id, kind, passed, message="", stdout="", stderr="", exit_code=None):
|
|
22
|
+
self.check_id = check_id
|
|
23
|
+
self.kind = kind
|
|
24
|
+
self.passed = passed
|
|
25
|
+
self.message = message
|
|
26
|
+
self.stdout = stdout
|
|
27
|
+
self.stderr = stderr
|
|
28
|
+
self.exit_code = exit_code
|
|
29
|
+
|
|
30
|
+
def to_dict(self):
|
|
31
|
+
return {
|
|
32
|
+
"check_id": self.check_id,
|
|
33
|
+
"kind": self.kind,
|
|
34
|
+
"passed": self.passed,
|
|
35
|
+
"message": self.message,
|
|
36
|
+
"stdout": self.stdout,
|
|
37
|
+
"stderr": self.stderr,
|
|
38
|
+
"exit_code": self.exit_code,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def __repr__(self):
|
|
42
|
+
status = "PASS" if self.passed else "FAIL"
|
|
43
|
+
return f"<VerifierResult {self.check_id} {status}>"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
_SECRET_ENV_NAMES = (
|
|
47
|
+
"AWS_ACCESS_KEY_ID",
|
|
48
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
49
|
+
"AWS_SESSION_TOKEN",
|
|
50
|
+
"GITHUB_TOKEN",
|
|
51
|
+
"GH_TOKEN",
|
|
52
|
+
"OPENAI_API_KEY",
|
|
53
|
+
"ANTHROPIC_API_KEY",
|
|
54
|
+
"GEMINI_API_KEY",
|
|
55
|
+
"API_KEY",
|
|
56
|
+
"SECRET",
|
|
57
|
+
"TOKEN",
|
|
58
|
+
)
|
|
59
|
+
# QC 2026-08-02 (P1-1): the exact-name denylist missed repo secrets such as
|
|
60
|
+
# Scrub any var whose underscore-separated name
|
|
61
|
+
# contains a secret-ish segment, plus known prefixes and common composites.
|
|
62
|
+
_SECRET_ENV_SEGMENTS = (
|
|
63
|
+
"KEY",
|
|
64
|
+
"KEYS",
|
|
65
|
+
"TOKEN",
|
|
66
|
+
"TOKENS",
|
|
67
|
+
"SECRET",
|
|
68
|
+
"SECRETS",
|
|
69
|
+
"PASSWORD",
|
|
70
|
+
"PASSWORDS",
|
|
71
|
+
"CREDENTIAL",
|
|
72
|
+
"CREDENTIALS",
|
|
73
|
+
"AUTH",
|
|
74
|
+
"DATABASE_URL",
|
|
75
|
+
"MONGODB_URI",
|
|
76
|
+
"REDIS_URL",
|
|
77
|
+
"DSN",
|
|
78
|
+
)
|
|
79
|
+
_SECRET_ENV_PREFIXES = (
|
|
80
|
+
"NVIDIA_API_KEY",
|
|
81
|
+
"CUSTOM_SERVICE_KEY",
|
|
82
|
+
"LLM_API_KEY",
|
|
83
|
+
"BACKEND_API_KEY",
|
|
84
|
+
"TOKEN_GATE",
|
|
85
|
+
"WORKER_TOKEN",
|
|
86
|
+
"HF_TOKEN",
|
|
87
|
+
)
|
|
88
|
+
_MAX_OUTPUT_CHARS = 100_000
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _is_secret_env_name(name):
|
|
92
|
+
upper = name.upper()
|
|
93
|
+
if any(upper == exact.upper() for exact in _SECRET_ENV_NAMES):
|
|
94
|
+
return True
|
|
95
|
+
if any(upper.startswith(prefix) for prefix in _SECRET_ENV_PREFIXES):
|
|
96
|
+
return True
|
|
97
|
+
if any(seg in upper.split("_") for seg in _SECRET_ENV_SEGMENTS):
|
|
98
|
+
return True
|
|
99
|
+
no_delim = upper.replace("_", "").replace("-", "")
|
|
100
|
+
for seg in ("PASSWORD", "SECRET", "TOKEN", "APIKEY", "CREDENTIAL"):
|
|
101
|
+
if seg in no_delim:
|
|
102
|
+
return True
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _get_scrubbed_env():
|
|
107
|
+
env = os.environ.copy()
|
|
108
|
+
for k in list(env.keys()):
|
|
109
|
+
if _is_secret_env_name(k):
|
|
110
|
+
env.pop(k, None)
|
|
111
|
+
return env
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
_CODE_ARG_FLAGS = {"-c", "-e", "--eval", "-m", "-J", "-E"}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _normalize_win_args(tokens):
|
|
118
|
+
"""Reconcile shlex(posix=False) tokens with Windows CRT argv semantics
|
|
119
|
+
(QC 2026-08-02, P1-3).
|
|
120
|
+
|
|
121
|
+
- A token fully wrapped in DOUBLE quotes is a CRT quoting-delimiter pair:
|
|
122
|
+
CommandLineToArgvW strips it, so we strip it unconditionally. This makes
|
|
123
|
+
`grep "ERROR" file` deliver ERROR (not literal `"ERROR"`) to the child.
|
|
124
|
+
- A token fully wrapped in SINGLE quotes is literal on cmd.exe (' is not a
|
|
125
|
+
quote char), so it is preserved UNLESS shlex used it for grouping a code
|
|
126
|
+
argument (whitespace inside, or immediately after a code flag like
|
|
127
|
+
-c/-e/--eval/-m) — in that case the quotes were syntactic, not payload.
|
|
128
|
+
"""
|
|
129
|
+
args = []
|
|
130
|
+
prev = None
|
|
131
|
+
for tok in tokens:
|
|
132
|
+
if len(tok) >= 2 and ((tok[0] == "'" and tok[-1] == "'") or (tok[0] == '"' and tok[-1] == '"')):
|
|
133
|
+
inner = tok[1:-1]
|
|
134
|
+
if tok[0] == '"':
|
|
135
|
+
tok = inner
|
|
136
|
+
elif any(c.isspace() for c in inner) or prev in _CODE_ARG_FLAGS:
|
|
137
|
+
tok = inner
|
|
138
|
+
args.append(tok)
|
|
139
|
+
prev = tok
|
|
140
|
+
return args
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _cap_output(text: str, max_chars: Optional[int] = None) -> str:
|
|
144
|
+
if max_chars is None:
|
|
145
|
+
max_chars = _MAX_OUTPUT_CHARS
|
|
146
|
+
if not text:
|
|
147
|
+
return ""
|
|
148
|
+
if len(text) > max_chars:
|
|
149
|
+
return text[:max_chars] + "\n...[truncated]"
|
|
150
|
+
return text
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _kill_process_tree(proc):
|
|
154
|
+
if proc.poll() is not None:
|
|
155
|
+
return
|
|
156
|
+
if os.name == "nt":
|
|
157
|
+
try:
|
|
158
|
+
subprocess.run(
|
|
159
|
+
["taskkill", "/F", "/T", "/PID", str(proc.pid)],
|
|
160
|
+
capture_output=True,
|
|
161
|
+
timeout=10,
|
|
162
|
+
)
|
|
163
|
+
except (ProcessLookupError, PermissionError, OSError, subprocess.SubprocessError):
|
|
164
|
+
try:
|
|
165
|
+
proc.kill()
|
|
166
|
+
except (ProcessLookupError, OSError):
|
|
167
|
+
pass
|
|
168
|
+
else:
|
|
169
|
+
try:
|
|
170
|
+
import signal
|
|
171
|
+
|
|
172
|
+
pgid = os.getpgid(proc.pid)
|
|
173
|
+
os.killpg(pgid, signal.SIGKILL)
|
|
174
|
+
except (ProcessLookupError, PermissionError, OSError, AttributeError):
|
|
175
|
+
try:
|
|
176
|
+
proc.kill()
|
|
177
|
+
except (ProcessLookupError, OSError):
|
|
178
|
+
pass
|
|
179
|
+
try:
|
|
180
|
+
proc.wait(timeout=5)
|
|
181
|
+
except (subprocess.TimeoutExpired, ProcessLookupError, OSError):
|
|
182
|
+
pass
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _run_command_check(command, expected, workspace_root, timeout_sec=60):
|
|
186
|
+
"""Run a shell command and check exit code equals expected."""
|
|
187
|
+
if not command:
|
|
188
|
+
return VerifierResult(
|
|
189
|
+
check_id="command", kind="command", passed=False, message="empty command string", exit_code=-1
|
|
190
|
+
)
|
|
191
|
+
kwargs = {
|
|
192
|
+
"stdout": subprocess.PIPE,
|
|
193
|
+
"stderr": subprocess.PIPE,
|
|
194
|
+
"text": True,
|
|
195
|
+
"cwd": workspace_root,
|
|
196
|
+
"encoding": "utf-8",
|
|
197
|
+
"errors": "replace",
|
|
198
|
+
"env": _get_scrubbed_env(),
|
|
199
|
+
}
|
|
200
|
+
if os.name == "nt":
|
|
201
|
+
kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP
|
|
202
|
+
else:
|
|
203
|
+
kwargs["start_new_session"] = True
|
|
204
|
+
|
|
205
|
+
try:
|
|
206
|
+
if os.name == "nt":
|
|
207
|
+
# AUT-005 (verified empirically on Windows 2026-07-31): direct
|
|
208
|
+
# exec via shlex.split preserves single/double/nested quotes that
|
|
209
|
+
# `cmd /c` mangles (e.g. python -c "import sys; print('ok')").
|
|
210
|
+
# cmd builtins (echo, dir, ...) are not executables, so fall back
|
|
211
|
+
# to `cmd /c` only when direct exec cannot find the program.
|
|
212
|
+
# CRITICAL: on Windows, posix=False is mandatory to preserve backslashes.
|
|
213
|
+
# Stripping matching outer quotes from args ensures Python receives clean code
|
|
214
|
+
# rather than quoted string literals.
|
|
215
|
+
try:
|
|
216
|
+
if isinstance(command, str):
|
|
217
|
+
raw = shlex.split(command, posix=False)
|
|
218
|
+
args = _normalize_win_args(raw)
|
|
219
|
+
else:
|
|
220
|
+
args = list(command)
|
|
221
|
+
if args and args[0] in ("python", "python3") and sys.executable:
|
|
222
|
+
args[0] = sys.executable
|
|
223
|
+
proc = subprocess.Popen(args, **kwargs)
|
|
224
|
+
except (FileNotFoundError, OSError):
|
|
225
|
+
proc = subprocess.Popen(["cmd", "/c", command], **kwargs)
|
|
226
|
+
else:
|
|
227
|
+
args = shlex.split(command) if isinstance(command, str) else list(command)
|
|
228
|
+
if args and args[0] in ("python", "python3") and sys.executable:
|
|
229
|
+
args[0] = sys.executable
|
|
230
|
+
proc = subprocess.Popen(args, **kwargs)
|
|
231
|
+
|
|
232
|
+
try:
|
|
233
|
+
stdout, stderr = proc.communicate(timeout=timeout_sec)
|
|
234
|
+
except subprocess.TimeoutExpired:
|
|
235
|
+
_kill_process_tree(proc)
|
|
236
|
+
return VerifierResult(
|
|
237
|
+
check_id="command",
|
|
238
|
+
kind="command",
|
|
239
|
+
passed=False,
|
|
240
|
+
message=f"command timed out ({timeout_sec}s)",
|
|
241
|
+
exit_code=-1,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
stdout = _cap_output(stdout or "")
|
|
245
|
+
stderr = _cap_output(stderr or "")
|
|
246
|
+
exit_code = proc.returncode
|
|
247
|
+
try:
|
|
248
|
+
expected_code = int(expected)
|
|
249
|
+
passed = exit_code == expected_code
|
|
250
|
+
except (ValueError, TypeError):
|
|
251
|
+
passed = str(exit_code) == str(expected)
|
|
252
|
+
msg = f"exit code {exit_code}, expected {expected}" if not passed else f"exit code {exit_code} matches expected"
|
|
253
|
+
return VerifierResult(
|
|
254
|
+
check_id="command",
|
|
255
|
+
kind="command",
|
|
256
|
+
passed=passed,
|
|
257
|
+
message=msg,
|
|
258
|
+
stdout=stdout,
|
|
259
|
+
stderr=stderr,
|
|
260
|
+
exit_code=exit_code,
|
|
261
|
+
)
|
|
262
|
+
except OSError as e:
|
|
263
|
+
return VerifierResult(check_id="command", kind="command", passed=False, message=str(e), exit_code=-1)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _run_file_exists_check(path, expected_nonempty, workspace_root):
|
|
267
|
+
"""Check file exists; optionally non-empty."""
|
|
268
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
269
|
+
exists = os.path.isfile(full_path)
|
|
270
|
+
if not exists:
|
|
271
|
+
return VerifierResult(
|
|
272
|
+
check_id="file_exists", kind="file_exists", passed=False, message=f"file not found: {path}"
|
|
273
|
+
)
|
|
274
|
+
if expected_nonempty:
|
|
275
|
+
size = os.path.getsize(full_path)
|
|
276
|
+
if size == 0:
|
|
277
|
+
return VerifierResult(
|
|
278
|
+
check_id="file_exists", kind="file_exists", passed=False, message=f"file is empty: {path}"
|
|
279
|
+
)
|
|
280
|
+
return VerifierResult(
|
|
281
|
+
check_id="file_exists",
|
|
282
|
+
kind="file_exists",
|
|
283
|
+
passed=True,
|
|
284
|
+
message=f"file exists: {path} ({os.path.getsize(full_path)} bytes)",
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def _run_json_schema_check(path, schema, workspace_root):
|
|
289
|
+
"""Check file parses as JSON; optionally validate against schema."""
|
|
290
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
291
|
+
if not os.path.isfile(full_path):
|
|
292
|
+
return VerifierResult(
|
|
293
|
+
check_id="json_schema", kind="json_schema", passed=False, message=f"file not found: {path}"
|
|
294
|
+
)
|
|
295
|
+
try:
|
|
296
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
297
|
+
data = json.load(f)
|
|
298
|
+
except (json.JSONDecodeError, OSError) as e:
|
|
299
|
+
return VerifierResult(
|
|
300
|
+
check_id="json_schema", kind="json_schema", passed=False, message=f"JSON parse error: {e}"
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
if schema is not None:
|
|
304
|
+
if not isinstance(data, dict):
|
|
305
|
+
return VerifierResult(
|
|
306
|
+
check_id="json_schema", kind="json_schema", passed=False, message="JSON root is not a dict"
|
|
307
|
+
)
|
|
308
|
+
if isinstance(schema, dict):
|
|
309
|
+
for key in schema.get("required", []):
|
|
310
|
+
if key not in data:
|
|
311
|
+
return VerifierResult(
|
|
312
|
+
check_id="json_schema",
|
|
313
|
+
kind="json_schema",
|
|
314
|
+
passed=False,
|
|
315
|
+
message=f"JSON missing required key: {key}",
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
return VerifierResult(check_id="json_schema", kind="json_schema", passed=True, message="JSON parse OK")
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def _run_content_check(path, pattern, kind, workspace_root):
|
|
322
|
+
"""Check file content matches exact string or regex."""
|
|
323
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
324
|
+
if not os.path.isfile(full_path):
|
|
325
|
+
return VerifierResult(check_id="content", kind=kind, passed=False, message=f"file not found: {path}")
|
|
326
|
+
try:
|
|
327
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
328
|
+
content = f.read()
|
|
329
|
+
except OSError as e:
|
|
330
|
+
return VerifierResult(check_id="content", kind=kind, passed=False, message=str(e))
|
|
331
|
+
|
|
332
|
+
if kind == "content_exact":
|
|
333
|
+
if content == pattern:
|
|
334
|
+
return VerifierResult(check_id="content", kind=kind, passed=True, message="content matches exact")
|
|
335
|
+
else:
|
|
336
|
+
return VerifierResult(check_id="content", kind=kind, passed=False, message="content does not match exact")
|
|
337
|
+
elif kind == "content_regex":
|
|
338
|
+
if re.search(pattern, content, re.DOTALL):
|
|
339
|
+
return VerifierResult(check_id="content", kind=kind, passed=True, message=f"regex matches: {pattern}")
|
|
340
|
+
else:
|
|
341
|
+
return VerifierResult(check_id="content", kind=kind, passed=False, message=f"regex no match: {pattern}")
|
|
342
|
+
|
|
343
|
+
return VerifierResult(check_id="content", kind=kind, passed=False, message=f"unknown content kind: {kind}")
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
_PLACEHOLDER_PATTERN = re.compile(r"(?i)\b(TODO|FIXME|XXX|HACK|TEMP|TBD|PLACEHOLDER|YOUR_CODE_HERE|IMPLEMENT_ME)\b")
|
|
347
|
+
_CONVERSATIONAL_PATTERN = re.compile(
|
|
348
|
+
r"(?i)^\s*(sure!|here is the|i cannot|as an ai language model|i hope the)",
|
|
349
|
+
re.MULTILINE,
|
|
350
|
+
)
|
|
351
|
+
_MARKDOWN_FENCE_START = re.compile(r"^\s*```")
|
|
352
|
+
_NOT_IMPLEMENTED_ERROR = re.compile(r"raise\s+NotImplementedError")
|
|
353
|
+
_DEBUG_PYTHON = re.compile(r"\b(breakpoint\(\)|pdb\.set_trace\(\))")
|
|
354
|
+
_SECRET_AWS = re.compile(r"\b(AKIA|ASIA)[0-9A-Z]{16}\b")
|
|
355
|
+
_SECRET_KEY_HEADER = re.compile(
|
|
356
|
+
r"-----BEGIN\s+(?:[A-Z0-9_\-]+\s+)?(?:ENCRYPTED\s+)?(?:PRIVATE\s+KEY|(?:RSA|OPENSSH|EC|PGP|DSA)\s+(?:PRIVATE\s+)?KEY)-----",
|
|
357
|
+
re.IGNORECASE,
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
_AST_CACHE: dict = {}
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
@functools.lru_cache(maxsize=2048)
|
|
365
|
+
def _cached_ast_parse(source_code: str, filename: str = "") -> Tuple[bool, str]:
|
|
366
|
+
try:
|
|
367
|
+
ast.parse(source_code, filename=filename or "<memory>")
|
|
368
|
+
return (True, "Python syntax valid")
|
|
369
|
+
except SyntaxError as e:
|
|
370
|
+
return (False, f"Python SyntaxError line {e.lineno}: {e.msg}")
|
|
371
|
+
except Exception as e:
|
|
372
|
+
return (False, f"AST parse failed: {e}")
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def fast_ast_verify(source_code: str, filename: str = "") -> Tuple[bool, str]:
|
|
376
|
+
"""Tier-0 in-memory AST syntax validation with C-level LRU caching (<0.1ms)."""
|
|
377
|
+
return _cached_ast_parse(source_code, filename)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _run_syntax_check(path, expected_language, workspace_root, optional=False):
|
|
381
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
382
|
+
if not os.path.isfile(full_path):
|
|
383
|
+
return VerifierResult(check_id="syntax", kind="syntax", passed=False, message=f"file not found: {path}")
|
|
384
|
+
try:
|
|
385
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
386
|
+
content = f.read()
|
|
387
|
+
except OSError as e:
|
|
388
|
+
return VerifierResult(check_id="syntax", kind="syntax", passed=False, message=str(e))
|
|
389
|
+
|
|
390
|
+
lang = expected_language or _detect_language(path)
|
|
391
|
+
import shutil
|
|
392
|
+
|
|
393
|
+
if lang == "python":
|
|
394
|
+
passed, msg = fast_ast_verify(content, filename=full_path)
|
|
395
|
+
return VerifierResult(check_id="syntax", kind="syntax", passed=passed, message=msg)
|
|
396
|
+
elif lang == "json":
|
|
397
|
+
try:
|
|
398
|
+
json.loads(content)
|
|
399
|
+
return VerifierResult(check_id="syntax", kind="syntax", passed=True, message="JSON syntax valid")
|
|
400
|
+
except json.JSONDecodeError as e:
|
|
401
|
+
return VerifierResult(check_id="syntax", kind="syntax", passed=False, message=f"JSON parse error: {e.msg}")
|
|
402
|
+
elif lang in ("javascript", "js"):
|
|
403
|
+
node_bin = shutil.which("node")
|
|
404
|
+
if node_bin:
|
|
405
|
+
try:
|
|
406
|
+
proc = subprocess.run(
|
|
407
|
+
[node_bin, "--check", full_path],
|
|
408
|
+
capture_output=True,
|
|
409
|
+
text=True,
|
|
410
|
+
timeout=10,
|
|
411
|
+
cwd=workspace_root,
|
|
412
|
+
encoding="utf-8",
|
|
413
|
+
errors="replace",
|
|
414
|
+
)
|
|
415
|
+
if proc.returncode == 0:
|
|
416
|
+
return VerifierResult(
|
|
417
|
+
check_id="syntax", kind="syntax", passed=True, message="JavaScript syntax valid (node)"
|
|
418
|
+
)
|
|
419
|
+
return VerifierResult(
|
|
420
|
+
check_id="syntax",
|
|
421
|
+
kind="syntax",
|
|
422
|
+
passed=False,
|
|
423
|
+
message=f"JavaScript syntax error: {proc.stderr[:200]}",
|
|
424
|
+
)
|
|
425
|
+
except Exception as e:
|
|
426
|
+
return VerifierResult(
|
|
427
|
+
check_id="syntax", kind="syntax", passed=False, message=f"JavaScript syntax check failed: {e}"
|
|
428
|
+
)
|
|
429
|
+
if optional:
|
|
430
|
+
return VerifierResult(
|
|
431
|
+
check_id="syntax", kind="syntax", passed=True, message="syntax check skipped: node not found (optional)"
|
|
432
|
+
)
|
|
433
|
+
return VerifierResult(
|
|
434
|
+
check_id="syntax",
|
|
435
|
+
kind="syntax",
|
|
436
|
+
passed=False,
|
|
437
|
+
message="syntax check failed: node unavailable for javascript",
|
|
438
|
+
)
|
|
439
|
+
elif lang in ("typescript", "ts"):
|
|
440
|
+
tsc_bin = shutil.which("tsc") or shutil.which("npx")
|
|
441
|
+
if tsc_bin:
|
|
442
|
+
try:
|
|
443
|
+
cmd = (
|
|
444
|
+
[tsc_bin, "--noEmit", "--pretty", "false", full_path]
|
|
445
|
+
if "tsc" in tsc_bin
|
|
446
|
+
else ["npx", "tsc", "--noEmit", "--pretty", "false", full_path]
|
|
447
|
+
)
|
|
448
|
+
proc = subprocess.run(
|
|
449
|
+
cmd,
|
|
450
|
+
capture_output=True,
|
|
451
|
+
text=True,
|
|
452
|
+
timeout=15,
|
|
453
|
+
cwd=workspace_root,
|
|
454
|
+
encoding="utf-8",
|
|
455
|
+
errors="replace",
|
|
456
|
+
)
|
|
457
|
+
if proc.returncode == 0:
|
|
458
|
+
return VerifierResult(
|
|
459
|
+
check_id="syntax", kind="syntax", passed=True, message="TypeScript syntax valid (tsc)"
|
|
460
|
+
)
|
|
461
|
+
return VerifierResult(
|
|
462
|
+
check_id="syntax",
|
|
463
|
+
kind="syntax",
|
|
464
|
+
passed=False,
|
|
465
|
+
message=f"TypeScript syntax error: {proc.stdout[:200] or proc.stderr[:200]}",
|
|
466
|
+
)
|
|
467
|
+
except Exception as e:
|
|
468
|
+
return VerifierResult(
|
|
469
|
+
check_id="syntax", kind="syntax", passed=False, message=f"TypeScript syntax check failed: {e}"
|
|
470
|
+
)
|
|
471
|
+
if optional:
|
|
472
|
+
return VerifierResult(
|
|
473
|
+
check_id="syntax", kind="syntax", passed=True, message="syntax check skipped: tsc not found (optional)"
|
|
474
|
+
)
|
|
475
|
+
return VerifierResult(
|
|
476
|
+
check_id="syntax",
|
|
477
|
+
kind="syntax",
|
|
478
|
+
passed=False,
|
|
479
|
+
message="syntax check failed: tsc unavailable for typescript",
|
|
480
|
+
)
|
|
481
|
+
elif lang == "go":
|
|
482
|
+
go_bin = shutil.which("go")
|
|
483
|
+
if go_bin:
|
|
484
|
+
try:
|
|
485
|
+
proc = subprocess.run(
|
|
486
|
+
[go_bin, "vet", full_path],
|
|
487
|
+
capture_output=True,
|
|
488
|
+
text=True,
|
|
489
|
+
timeout=15,
|
|
490
|
+
cwd=workspace_root,
|
|
491
|
+
encoding="utf-8",
|
|
492
|
+
errors="replace",
|
|
493
|
+
)
|
|
494
|
+
if proc.returncode == 0:
|
|
495
|
+
return VerifierResult(
|
|
496
|
+
check_id="syntax", kind="syntax", passed=True, message="Go syntax valid (go vet)"
|
|
497
|
+
)
|
|
498
|
+
return VerifierResult(
|
|
499
|
+
check_id="syntax", kind="syntax", passed=False, message=f"Go syntax error: {proc.stderr[:200]}"
|
|
500
|
+
)
|
|
501
|
+
except Exception as e:
|
|
502
|
+
return VerifierResult(
|
|
503
|
+
check_id="syntax", kind="syntax", passed=False, message=f"Go syntax check failed: {e}"
|
|
504
|
+
)
|
|
505
|
+
if optional:
|
|
506
|
+
return VerifierResult(
|
|
507
|
+
check_id="syntax", kind="syntax", passed=True, message="syntax check skipped: go not found (optional)"
|
|
508
|
+
)
|
|
509
|
+
return VerifierResult(
|
|
510
|
+
check_id="syntax", kind="syntax", passed=False, message="syntax check failed: go unavailable"
|
|
511
|
+
)
|
|
512
|
+
elif lang == "rust":
|
|
513
|
+
cargo_bin = shutil.which("cargo") or shutil.which("rustc")
|
|
514
|
+
if cargo_bin:
|
|
515
|
+
try:
|
|
516
|
+
cmd = [cargo_bin, "check"] if "cargo" in cargo_bin else [cargo_bin, "--parse-only", full_path]
|
|
517
|
+
proc = subprocess.run(
|
|
518
|
+
cmd,
|
|
519
|
+
capture_output=True,
|
|
520
|
+
text=True,
|
|
521
|
+
timeout=15,
|
|
522
|
+
cwd=workspace_root,
|
|
523
|
+
encoding="utf-8",
|
|
524
|
+
errors="replace",
|
|
525
|
+
)
|
|
526
|
+
if proc.returncode == 0:
|
|
527
|
+
return VerifierResult(check_id="syntax", kind="syntax", passed=True, message="Rust syntax valid")
|
|
528
|
+
return VerifierResult(
|
|
529
|
+
check_id="syntax", kind="syntax", passed=False, message=f"Rust syntax error: {proc.stderr[:200]}"
|
|
530
|
+
)
|
|
531
|
+
except Exception as e:
|
|
532
|
+
return VerifierResult(
|
|
533
|
+
check_id="syntax", kind="syntax", passed=False, message=f"Rust syntax check failed: {e}"
|
|
534
|
+
)
|
|
535
|
+
if optional:
|
|
536
|
+
return VerifierResult(
|
|
537
|
+
check_id="syntax",
|
|
538
|
+
kind="syntax",
|
|
539
|
+
passed=True,
|
|
540
|
+
message="syntax check skipped: rust tooling not found (optional)",
|
|
541
|
+
)
|
|
542
|
+
return VerifierResult(
|
|
543
|
+
check_id="syntax", kind="syntax", passed=False, message="syntax check failed: rust tooling unavailable"
|
|
544
|
+
)
|
|
545
|
+
else:
|
|
546
|
+
if optional:
|
|
547
|
+
return VerifierResult(
|
|
548
|
+
check_id="syntax",
|
|
549
|
+
kind="syntax",
|
|
550
|
+
passed=True,
|
|
551
|
+
message=f"syntax check skipped: unsupported language {lang} (optional)",
|
|
552
|
+
)
|
|
553
|
+
return VerifierResult(
|
|
554
|
+
check_id="syntax", kind="syntax", passed=False, message=f"syntax check skipped: unsupported language {lang}"
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
def _detect_language(path):
|
|
559
|
+
ext = os.path.splitext(path)[1].lower()
|
|
560
|
+
return {
|
|
561
|
+
".py": "python",
|
|
562
|
+
".json": "json",
|
|
563
|
+
".js": "javascript",
|
|
564
|
+
".ts": "typescript",
|
|
565
|
+
".yaml": "yaml",
|
|
566
|
+
".yml": "yaml",
|
|
567
|
+
".go": "go",
|
|
568
|
+
".rs": "rust",
|
|
569
|
+
}.get(ext, "unknown")
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def _run_hygiene_check(path, expected, workspace_root):
|
|
573
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
574
|
+
if not os.path.isfile(full_path):
|
|
575
|
+
return VerifierResult(check_id="hygiene", kind="hygiene", passed=False, message=f"file not found: {path}")
|
|
576
|
+
try:
|
|
577
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
578
|
+
content = f.read()
|
|
579
|
+
except OSError as e:
|
|
580
|
+
return VerifierResult(check_id="hygiene", kind="hygiene", passed=False, message=str(e))
|
|
581
|
+
|
|
582
|
+
content.splitlines()
|
|
583
|
+
|
|
584
|
+
if _MARKDOWN_FENCE_START.match(content.strip()):
|
|
585
|
+
return VerifierResult(
|
|
586
|
+
check_id="hygiene", kind="hygiene", passed=False, message="file starts with markdown code fence"
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
if _CONVERSATIONAL_PATTERN.search(content):
|
|
590
|
+
return VerifierResult(
|
|
591
|
+
check_id="hygiene", kind="hygiene", passed=False, message="conversational LLM preamble detected"
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
if _PLACEHOLDER_PATTERN.search(content):
|
|
595
|
+
return VerifierResult(
|
|
596
|
+
check_id="hygiene", kind="hygiene", passed=False, message="placeholder token detected (TODO/FIXME/etc)"
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
if _NOT_IMPLEMENTED_ERROR.search(content):
|
|
600
|
+
return VerifierResult(
|
|
601
|
+
check_id="hygiene", kind="hygiene", passed=False, message="raise NotImplementedError detected"
|
|
602
|
+
)
|
|
603
|
+
|
|
604
|
+
lang = _detect_language(path)
|
|
605
|
+
if lang == "python":
|
|
606
|
+
if _DEBUG_PYTHON.search(content):
|
|
607
|
+
return VerifierResult(
|
|
608
|
+
check_id="hygiene", kind="hygiene", passed=False, message="debug statement detected (breakpoint/pdb)"
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
if _SECRET_AWS.search(content):
|
|
612
|
+
return VerifierResult(
|
|
613
|
+
check_id="hygiene", kind="hygiene", passed=False, message="AWS credential pattern detected"
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
if _SECRET_KEY_HEADER.search(content):
|
|
617
|
+
return VerifierResult(check_id="hygiene", kind="hygiene", passed=False, message="private key header detected")
|
|
618
|
+
|
|
619
|
+
return VerifierResult(check_id="hygiene", kind="hygiene", passed=True, message="hygiene checks passed")
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
def _run_min_size_check(path, min_size, workspace_root):
|
|
623
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
624
|
+
if not os.path.isfile(full_path):
|
|
625
|
+
return VerifierResult(check_id="min_size", kind="min_size", passed=False, message=f"file not found: {path}")
|
|
626
|
+
try:
|
|
627
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
628
|
+
content = f.read()
|
|
629
|
+
except OSError as e:
|
|
630
|
+
return VerifierResult(check_id="min_size", kind="min_size", passed=False, message=str(e))
|
|
631
|
+
|
|
632
|
+
size = len(content)
|
|
633
|
+
threshold = int(min_size) if min_size else 1
|
|
634
|
+
if size >= threshold:
|
|
635
|
+
return VerifierResult(
|
|
636
|
+
check_id="min_size", kind="min_size", passed=True, message=f"content length {size} >= {threshold}"
|
|
637
|
+
)
|
|
638
|
+
else:
|
|
639
|
+
return VerifierResult(
|
|
640
|
+
check_id="min_size", kind="min_size", passed=False, message=f"content length {size} < {threshold}"
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
_SUPPORTED_RENDER_FORMATS = {"markdown", "html"}
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
def _get_markdown_headings(content: str) -> list:
|
|
648
|
+
"""Extract all markdown heading texts (## and ###) from content, excluding code blocks."""
|
|
649
|
+
lines = content.split("\n")
|
|
650
|
+
headings = []
|
|
651
|
+
in_code_block = False
|
|
652
|
+
for line in lines:
|
|
653
|
+
stripped = line.strip()
|
|
654
|
+
if stripped.startswith("```"):
|
|
655
|
+
in_code_block = not in_code_block
|
|
656
|
+
continue
|
|
657
|
+
if in_code_block:
|
|
658
|
+
continue
|
|
659
|
+
if re.match(r"^#{1,6}\s+", stripped):
|
|
660
|
+
heading_text = re.sub(r"^#{1,6}\s+", "", stripped).strip()
|
|
661
|
+
if heading_text:
|
|
662
|
+
headings.append(heading_text)
|
|
663
|
+
return headings
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
def _run_required_sections_check(path, required_sections, workspace_root):
|
|
667
|
+
"""Check file contains all required section headings.
|
|
668
|
+
|
|
669
|
+
JSON outputs: required sections are matched against top-level object keys
|
|
670
|
+
(case-insensitive). Markdown/text outputs: matched against markdown
|
|
671
|
+
headings (## / ###). This prevents false failures when required_sections
|
|
672
|
+
is applied to a JSON-output contract (self-audit discovery 2026-07-31).
|
|
673
|
+
"""
|
|
674
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
675
|
+
if not os.path.isfile(full_path):
|
|
676
|
+
return VerifierResult(
|
|
677
|
+
check_id="required_sections", kind="required_sections", passed=False, message=f"file not found: {path}"
|
|
678
|
+
)
|
|
679
|
+
try:
|
|
680
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
681
|
+
content = f.read()
|
|
682
|
+
except OSError as e:
|
|
683
|
+
return VerifierResult(check_id="required_sections", kind="required_sections", passed=False, message=str(e))
|
|
684
|
+
if not required_sections:
|
|
685
|
+
return VerifierResult(
|
|
686
|
+
check_id="required_sections", kind="required_sections", passed=True, message="no required sections to check"
|
|
687
|
+
)
|
|
688
|
+
|
|
689
|
+
candidates = []
|
|
690
|
+
try:
|
|
691
|
+
data = json.loads(content)
|
|
692
|
+
except (json.JSONDecodeError, ValueError):
|
|
693
|
+
data = None
|
|
694
|
+
if isinstance(data, dict):
|
|
695
|
+
candidates = list(data.keys())
|
|
696
|
+
for key, value in data.items():
|
|
697
|
+
if isinstance(value, dict):
|
|
698
|
+
candidates.extend(value.keys())
|
|
699
|
+
else:
|
|
700
|
+
candidates = _get_markdown_headings(content)
|
|
701
|
+
|
|
702
|
+
missing = []
|
|
703
|
+
for section in required_sections:
|
|
704
|
+
if not isinstance(section, str):
|
|
705
|
+
continue
|
|
706
|
+
sec_lower = section.lower().strip()
|
|
707
|
+
# Direct match or substring match in any candidate heading
|
|
708
|
+
found = any(sec_lower in c.lower() or c.lower() in sec_lower for c in candidates)
|
|
709
|
+
if not found:
|
|
710
|
+
# Also check if section title keywords appear in candidate headers
|
|
711
|
+
words = [w for w in re.split(r"\W+", sec_lower) if len(w) > 2]
|
|
712
|
+
found = bool(words and any(all(w in c.lower() for w in words) for c in candidates))
|
|
713
|
+
if not found:
|
|
714
|
+
# Check if section title is present as bold or header anywhere in the text
|
|
715
|
+
found = bool(re.search(r"(?i)(?:^#{1,6}\s+|\*\*)[^\n]*" + re.escape(sec_lower), content))
|
|
716
|
+
if not found:
|
|
717
|
+
missing.append(section)
|
|
718
|
+
if missing:
|
|
719
|
+
return VerifierResult(
|
|
720
|
+
check_id="required_sections", kind="required_sections", passed=False, message=f"missing sections: {missing}"
|
|
721
|
+
)
|
|
722
|
+
return VerifierResult(
|
|
723
|
+
check_id="required_sections",
|
|
724
|
+
kind="required_sections",
|
|
725
|
+
passed=True,
|
|
726
|
+
message=f"all {len(required_sections)} required sections found",
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
def _run_render_check(path, expected_format, workspace_root):
|
|
731
|
+
"""Source-level validation for content structure and formatting.
|
|
732
|
+
|
|
733
|
+
This is NOT a full renderer — it performs heuristic checks on the source
|
|
734
|
+
content to detect common issues. Supported formats: markdown, html.
|
|
735
|
+
"""
|
|
736
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
737
|
+
if expected_format not in _SUPPORTED_RENDER_FORMATS:
|
|
738
|
+
return VerifierResult(
|
|
739
|
+
check_id="render",
|
|
740
|
+
kind="render",
|
|
741
|
+
passed=False,
|
|
742
|
+
message=f"unsupported render format: {expected_format!r} (supported: {sorted(_SUPPORTED_RENDER_FORMATS)})",
|
|
743
|
+
)
|
|
744
|
+
if not os.path.isfile(full_path):
|
|
745
|
+
return VerifierResult(check_id="render", kind="render", passed=False, message=f"file not found: {path}")
|
|
746
|
+
try:
|
|
747
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
748
|
+
content = f.read()
|
|
749
|
+
except OSError as e:
|
|
750
|
+
return VerifierResult(check_id="render", kind="render", passed=False, message=str(e))
|
|
751
|
+
if expected_format == "markdown":
|
|
752
|
+
raw_latex = re.findall(r"\$\$(.+?)\$\$|\$([^\$\n]+?)\$|\\\((.*?)\\\)|\\\[(.*?)\\]", content)
|
|
753
|
+
if raw_latex:
|
|
754
|
+
return VerifierResult(
|
|
755
|
+
check_id="render",
|
|
756
|
+
kind="render",
|
|
757
|
+
passed=False,
|
|
758
|
+
message=f"raw LaTeX detected in markdown: {len(raw_latex)} instances",
|
|
759
|
+
)
|
|
760
|
+
unresolved_anchors = re.findall(r"\[([^\]]+)\]\(\)", content)
|
|
761
|
+
if unresolved_anchors:
|
|
762
|
+
return VerifierResult(
|
|
763
|
+
check_id="render", kind="render", passed=False, message=f"unresolved anchors: {unresolved_anchors}"
|
|
764
|
+
)
|
|
765
|
+
elif expected_format == "html":
|
|
766
|
+
if not content.strip().startswith("<"):
|
|
767
|
+
return VerifierResult(
|
|
768
|
+
check_id="render", kind="render", passed=False, message="HTML content does not start with '<'"
|
|
769
|
+
)
|
|
770
|
+
return VerifierResult(
|
|
771
|
+
check_id="render", kind="render", passed=True, message=f"source-level {expected_format} check passed"
|
|
772
|
+
)
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
def _count_regex_matches(content: str, patterns: list) -> int:
|
|
776
|
+
"""Count total regex matches across a list of patterns."""
|
|
777
|
+
total = 0
|
|
778
|
+
for pat in patterns:
|
|
779
|
+
try:
|
|
780
|
+
total += len(re.findall(pat, content))
|
|
781
|
+
except re.error:
|
|
782
|
+
pass
|
|
783
|
+
return total
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
def _run_contradiction_count_check(path, expected_minimum, workspace_root):
|
|
787
|
+
"""Count 'contradiction' or 'contradicts' mentions in file. Must meet minimum."""
|
|
788
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
789
|
+
if not os.path.isfile(full_path):
|
|
790
|
+
return VerifierResult(
|
|
791
|
+
check_id="contradiction_count", kind="contradiction_count", passed=False, message=f"file not found: {path}"
|
|
792
|
+
)
|
|
793
|
+
try:
|
|
794
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
795
|
+
content = f.read()
|
|
796
|
+
except OSError as e:
|
|
797
|
+
return VerifierResult(check_id="contradiction_count", kind="contradiction_count", passed=False, message=str(e))
|
|
798
|
+
count = _count_regex_matches(
|
|
799
|
+
content,
|
|
800
|
+
[
|
|
801
|
+
r"(?i)\bcontradiction\b",
|
|
802
|
+
r"(?i)\bcontrarian\b",
|
|
803
|
+
r"(?i)\btension\s+between\b",
|
|
804
|
+
r"(?i)\bconflicts?\s+with\b",
|
|
805
|
+
r"(?i)\buncomfortable\s+truth\b",
|
|
806
|
+
r"(?i)\binternal(ly)?\s+inconsistent\b",
|
|
807
|
+
],
|
|
808
|
+
)
|
|
809
|
+
threshold = int(expected_minimum) if expected_minimum else 1
|
|
810
|
+
if count >= threshold:
|
|
811
|
+
return VerifierResult(
|
|
812
|
+
check_id="contradiction_count",
|
|
813
|
+
kind="contradiction_count",
|
|
814
|
+
passed=True,
|
|
815
|
+
message=f"found {count} contradiction mentions >= {threshold}",
|
|
816
|
+
)
|
|
817
|
+
return VerifierResult(
|
|
818
|
+
check_id="contradiction_count",
|
|
819
|
+
kind="contradiction_count",
|
|
820
|
+
passed=False,
|
|
821
|
+
message=f"found {count} contradiction mentions < {threshold}",
|
|
822
|
+
)
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
def _run_edge_case_count_check(path, expected_minimum, workspace_root):
|
|
826
|
+
"""Count edge-case or failure-scenario mentions in file."""
|
|
827
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
828
|
+
if not os.path.isfile(full_path):
|
|
829
|
+
return VerifierResult(
|
|
830
|
+
check_id="edge_case_count", kind="edge_case_count", passed=False, message=f"file not found: {path}"
|
|
831
|
+
)
|
|
832
|
+
try:
|
|
833
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
834
|
+
content = f.read()
|
|
835
|
+
except OSError as e:
|
|
836
|
+
return VerifierResult(check_id="edge_case_count", kind="edge_case_count", passed=False, message=str(e))
|
|
837
|
+
count = _count_regex_matches(
|
|
838
|
+
content,
|
|
839
|
+
[
|
|
840
|
+
r"(?i)\bedge\s+case",
|
|
841
|
+
r"(?i)\bfailure\s+(mode|scenario|case)",
|
|
842
|
+
r"(?i)\bcorner\s+case\b",
|
|
843
|
+
r"(?i)\bif\s+.*\b(fails?|breaks?|crashes|dies?|time.?out)\b",
|
|
844
|
+
r"(?i)\bscenario\s+\d+\b",
|
|
845
|
+
],
|
|
846
|
+
)
|
|
847
|
+
threshold = int(expected_minimum) if expected_minimum else 1
|
|
848
|
+
if count >= threshold:
|
|
849
|
+
return VerifierResult(
|
|
850
|
+
check_id="edge_case_count",
|
|
851
|
+
kind="edge_case_count",
|
|
852
|
+
passed=True,
|
|
853
|
+
message=f"found {count} edge case mentions >= {threshold}",
|
|
854
|
+
)
|
|
855
|
+
return VerifierResult(
|
|
856
|
+
check_id="edge_case_count",
|
|
857
|
+
kind="edge_case_count",
|
|
858
|
+
passed=False,
|
|
859
|
+
message=f"found {count} edge case mentions < {threshold}",
|
|
860
|
+
)
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
def _run_schema_count_check(path, expected_minimum, workspace_root):
|
|
864
|
+
"""Count JSON schema or YAML frontmatter blocks in file."""
|
|
865
|
+
full_path = os.path.join(workspace_root, path) if not os.path.isabs(path) else path
|
|
866
|
+
if not os.path.isfile(full_path):
|
|
867
|
+
return VerifierResult(
|
|
868
|
+
check_id="schema_count", kind="schema_count", passed=False, message=f"file not found: {path}"
|
|
869
|
+
)
|
|
870
|
+
try:
|
|
871
|
+
with open(full_path, "r", encoding="utf-8") as f:
|
|
872
|
+
content = f.read()
|
|
873
|
+
except OSError as e:
|
|
874
|
+
return VerifierResult(check_id="schema_count", kind="schema_count", passed=False, message=str(e))
|
|
875
|
+
count = _count_regex_matches(
|
|
876
|
+
content,
|
|
877
|
+
[
|
|
878
|
+
r"```json\s*\{",
|
|
879
|
+
r"```yaml",
|
|
880
|
+
r"```yml",
|
|
881
|
+
r"---\n\w+:\s*\w+",
|
|
882
|
+
r"(?i)\bJSON\s+schema\b",
|
|
883
|
+
r"(?i)\b(tier|level|rank|type|category)\s+(table|matrix|classification)\b",
|
|
884
|
+
],
|
|
885
|
+
)
|
|
886
|
+
threshold = int(expected_minimum) if expected_minimum else 1
|
|
887
|
+
if count >= threshold:
|
|
888
|
+
return VerifierResult(
|
|
889
|
+
check_id="schema_count",
|
|
890
|
+
kind="schema_count",
|
|
891
|
+
passed=True,
|
|
892
|
+
message=f"found {count} schema/structured-artifact indicators >= {threshold}",
|
|
893
|
+
)
|
|
894
|
+
return VerifierResult(
|
|
895
|
+
check_id="schema_count",
|
|
896
|
+
kind="schema_count",
|
|
897
|
+
passed=False,
|
|
898
|
+
message=f"found {count} schema indicators < {threshold}",
|
|
899
|
+
)
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
def _run_undeclared_outputs_check(declared_outputs, scope_snapshot_path, workspace_root, allowed_paths):
|
|
903
|
+
"""Check no files were created outside declared outputs within allowed scope.
|
|
904
|
+
|
|
905
|
+
Excludes the supervisor's own runtime files (under run_dir) and sibling tasks'
|
|
906
|
+
declared outputs during parallel execution.
|
|
907
|
+
"""
|
|
908
|
+
from .scope import FileBackedScopeRegistry, _walk_matching, is_path_exempt, load_snapshot
|
|
909
|
+
|
|
910
|
+
run_dir = os.path.dirname(scope_snapshot_path) if scope_snapshot_path else ""
|
|
911
|
+
before = load_snapshot(run_dir) if scope_snapshot_path else {}
|
|
912
|
+
if not before:
|
|
913
|
+
return VerifierResult(
|
|
914
|
+
check_id="undeclared_outputs",
|
|
915
|
+
kind="undeclared_outputs",
|
|
916
|
+
passed=True,
|
|
917
|
+
message="no scope snapshot available, skipping",
|
|
918
|
+
)
|
|
919
|
+
declared_abs = set()
|
|
920
|
+
for p in declared_outputs:
|
|
921
|
+
full = os.path.join(workspace_root, p) if not os.path.isabs(p) else p
|
|
922
|
+
declared_abs.add(os.path.normcase(os.path.normpath(full)))
|
|
923
|
+
|
|
924
|
+
sibling_outputs = []
|
|
925
|
+
try:
|
|
926
|
+
sibling_outputs = FileBackedScopeRegistry(workspace_root).sibling_declared_outputs()
|
|
927
|
+
except Exception:
|
|
928
|
+
pass
|
|
929
|
+
|
|
930
|
+
# Also load plan.json from goal run_dir if available to exempt all sibling declared outputs
|
|
931
|
+
try:
|
|
932
|
+
plan_path = os.path.join(os.path.dirname(run_dir), "plan.json")
|
|
933
|
+
if os.path.isfile(plan_path):
|
|
934
|
+
with open(plan_path, "r", encoding="utf-8") as f:
|
|
935
|
+
plan_data = json.load(f)
|
|
936
|
+
for c in plan_data.get("contracts", []):
|
|
937
|
+
for o in c.get("outputs", []):
|
|
938
|
+
if o.get("path"):
|
|
939
|
+
sibling_outputs.append(o["path"])
|
|
940
|
+
except Exception:
|
|
941
|
+
pass
|
|
942
|
+
|
|
943
|
+
after = _walk_matching(workspace_root, allowed_paths)
|
|
944
|
+
run_dir_abs = os.path.normcase(os.path.normpath(os.path.abspath(run_dir)))
|
|
945
|
+
goal_run_dir_abs = os.path.normcase(os.path.normpath(os.path.abspath(os.path.dirname(run_dir)))) if run_dir else ""
|
|
946
|
+
undeclared = []
|
|
947
|
+
for rel_path, _ in after.items():
|
|
948
|
+
if (
|
|
949
|
+
"__pycache__" in rel_path.split(os.sep)
|
|
950
|
+
or "generated" in rel_path.split(os.sep)
|
|
951
|
+
or rel_path.endswith((".pyc", ".pyo", ".pyd"))
|
|
952
|
+
):
|
|
953
|
+
continue
|
|
954
|
+
abs_path = os.path.normcase(os.path.normpath(os.path.join(workspace_root, rel_path)))
|
|
955
|
+
if abs_path in declared_abs:
|
|
956
|
+
continue
|
|
957
|
+
# Skip supervisor runtime files (under run_dir or parent goal_run_dir)
|
|
958
|
+
if run_dir_abs and abs_path.startswith(run_dir_abs + os.sep):
|
|
959
|
+
continue
|
|
960
|
+
if goal_run_dir_abs and abs_path.startswith(goal_run_dir_abs + os.sep):
|
|
961
|
+
continue
|
|
962
|
+
# Skip sibling tasks' declared outputs
|
|
963
|
+
if sibling_outputs and is_path_exempt(abs_path, sibling_outputs, workspace_root=workspace_root):
|
|
964
|
+
continue
|
|
965
|
+
old_hash = before.get(rel_path)
|
|
966
|
+
if old_hash is None:
|
|
967
|
+
undeclared.append(rel_path)
|
|
968
|
+
if undeclared:
|
|
969
|
+
return VerifierResult(
|
|
970
|
+
check_id="undeclared_outputs",
|
|
971
|
+
kind="undeclared_outputs",
|
|
972
|
+
passed=False,
|
|
973
|
+
message=f"undeclared output files: {undeclared}",
|
|
974
|
+
)
|
|
975
|
+
return VerifierResult(
|
|
976
|
+
check_id="undeclared_outputs", kind="undeclared_outputs", passed=True, message="no undeclared output files"
|
|
977
|
+
)
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
def run_checks(checks, workspace_root):
|
|
981
|
+
"""Run a list of acceptance checks.
|
|
982
|
+
|
|
983
|
+
Each check dict must have:
|
|
984
|
+
id, kind, and optionally command/path/expected/schema
|
|
985
|
+
|
|
986
|
+
Returns list of VerifierResult.
|
|
987
|
+
"""
|
|
988
|
+
results = []
|
|
989
|
+
for check in checks:
|
|
990
|
+
kind = check["kind"]
|
|
991
|
+
check_id = check.get("id", kind)
|
|
992
|
+
if kind == "command":
|
|
993
|
+
command = check.get("command", "")
|
|
994
|
+
expected = check.get("expected", 0)
|
|
995
|
+
# QC 2026-08-01: per-check timeout — check spec overrides the
|
|
996
|
+
# 60s default, clamped to a 300s ceiling so a mis-specified check
|
|
997
|
+
# cannot hang the supervisor indefinitely.
|
|
998
|
+
# QC 2026-08-02 (P1-2): LLM-generated contracts may carry malformed
|
|
999
|
+
# timeout_sec ("10s", 30.5, null) — fall back to the 60s default
|
|
1000
|
+
# instead of letting int() crash the whole task into BLOCKED.
|
|
1001
|
+
to_sec = check.get("timeout_sec", 60)
|
|
1002
|
+
try:
|
|
1003
|
+
to_sec = int(to_sec)
|
|
1004
|
+
except (ValueError, TypeError):
|
|
1005
|
+
to_sec = 60
|
|
1006
|
+
to_sec = min(max(to_sec, 1), 300)
|
|
1007
|
+
result = _run_command_check(command, expected, workspace_root, timeout_sec=to_sec)
|
|
1008
|
+
elif kind == "file_exists":
|
|
1009
|
+
path = check.get("path", "")
|
|
1010
|
+
exp = check.get("expected", "")
|
|
1011
|
+
if isinstance(exp, bool):
|
|
1012
|
+
nonempty = exp
|
|
1013
|
+
else:
|
|
1014
|
+
nonempty = str(exp).lower() in ("true", "nonempty", "1")
|
|
1015
|
+
result = _run_file_exists_check(path, nonempty, workspace_root)
|
|
1016
|
+
elif kind == "json_schema":
|
|
1017
|
+
path = check.get("path", "")
|
|
1018
|
+
schema = check.get("expected", {})
|
|
1019
|
+
if isinstance(schema, str):
|
|
1020
|
+
try:
|
|
1021
|
+
schema = json.loads(schema)
|
|
1022
|
+
except json.JSONDecodeError:
|
|
1023
|
+
schema = {}
|
|
1024
|
+
result = _run_json_schema_check(path, schema, workspace_root)
|
|
1025
|
+
elif kind in ("content_exact", "content_regex"):
|
|
1026
|
+
path = check.get("path", "")
|
|
1027
|
+
pattern = check.get("expected", "")
|
|
1028
|
+
result = _run_content_check(path, pattern, kind, workspace_root)
|
|
1029
|
+
elif kind == "syntax":
|
|
1030
|
+
path = check.get("path", "")
|
|
1031
|
+
lang = check.get("expected", "")
|
|
1032
|
+
optional = bool(check.get("optional", False))
|
|
1033
|
+
result = _run_syntax_check(path, lang, workspace_root, optional=optional)
|
|
1034
|
+
elif kind == "hygiene":
|
|
1035
|
+
path = check.get("path", "")
|
|
1036
|
+
expected = check.get("expected", True)
|
|
1037
|
+
result = _run_hygiene_check(path, expected, workspace_root)
|
|
1038
|
+
elif kind == "min_size":
|
|
1039
|
+
path = check.get("path", "")
|
|
1040
|
+
min_size = check.get("expected", 1)
|
|
1041
|
+
result = _run_min_size_check(path, min_size, workspace_root)
|
|
1042
|
+
elif kind == "required_sections":
|
|
1043
|
+
path = check.get("path", "")
|
|
1044
|
+
sections = check.get("expected", [])
|
|
1045
|
+
if isinstance(sections, str):
|
|
1046
|
+
sections = [s.strip() for s in sections.split(",")]
|
|
1047
|
+
result = _run_required_sections_check(path, sections, workspace_root)
|
|
1048
|
+
elif kind == "render":
|
|
1049
|
+
path = check.get("path", "")
|
|
1050
|
+
expected_format = check.get("expected", "markdown")
|
|
1051
|
+
result = _run_render_check(path, expected_format, workspace_root)
|
|
1052
|
+
elif kind == "undeclared_outputs":
|
|
1053
|
+
declared = check.get("declared_outputs", [])
|
|
1054
|
+
snapshot = check.get("scope_snapshot_path", "")
|
|
1055
|
+
allowed = check.get("allowed_paths", [])
|
|
1056
|
+
result = _run_undeclared_outputs_check(declared, snapshot, workspace_root, allowed)
|
|
1057
|
+
elif kind == "contradiction_count":
|
|
1058
|
+
path = check.get("path", "")
|
|
1059
|
+
expected = check.get("expected", 1)
|
|
1060
|
+
result = _run_contradiction_count_check(path, expected, workspace_root)
|
|
1061
|
+
elif kind == "edge_case_count":
|
|
1062
|
+
path = check.get("path", "")
|
|
1063
|
+
expected = check.get("expected", 1)
|
|
1064
|
+
result = _run_edge_case_count_check(path, expected, workspace_root)
|
|
1065
|
+
elif kind == "schema_count":
|
|
1066
|
+
path = check.get("path", "")
|
|
1067
|
+
expected = check.get("expected", 1)
|
|
1068
|
+
result = _run_schema_count_check(path, expected, workspace_root)
|
|
1069
|
+
else:
|
|
1070
|
+
result = VerifierResult(check_id=check_id, kind=kind, passed=False, message=f"unknown check kind: {kind}")
|
|
1071
|
+
result.check_id = check_id
|
|
1072
|
+
status = "PASS" if result.passed else "FAIL"
|
|
1073
|
+
print(f"[verify] {result.check_id} ({result.kind}): {status}", file=sys.stderr)
|
|
1074
|
+
results.append(result)
|
|
1075
|
+
return results
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
def run_verification(contract, workspace_root, run_dir):
|
|
1079
|
+
"""Run all acceptance checks from a contract.
|
|
1080
|
+
|
|
1081
|
+
Returns (all_passed, results, evidence_path).
|
|
1082
|
+
"""
|
|
1083
|
+
checks = contract.acceptance_checks
|
|
1084
|
+
print(f"[verify] task={contract.task_id} starting ({len(checks)} checks)", file=sys.stderr)
|
|
1085
|
+
results = run_checks(checks, workspace_root)
|
|
1086
|
+
all_passed = all(r.passed for r in results)
|
|
1087
|
+
passed_count = sum(1 for r in results if r.passed)
|
|
1088
|
+
print(f"[verify] task={contract.task_id} finished ({passed_count}/{len(checks)} passed)", file=sys.stderr)
|
|
1089
|
+
|
|
1090
|
+
evidence = {
|
|
1091
|
+
"task_id": contract.task_id,
|
|
1092
|
+
"verification_results": [r.to_dict() for r in results],
|
|
1093
|
+
"all_passed": all_passed,
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
evidence_path = None
|
|
1097
|
+
if run_dir:
|
|
1098
|
+
os.makedirs(run_dir, exist_ok=True)
|
|
1099
|
+
evidence_path = os.path.join(run_dir, "verification_evidence.json")
|
|
1100
|
+
with open(evidence_path, "w", encoding="utf-8") as f:
|
|
1101
|
+
json.dump(evidence, f, indent=2, ensure_ascii=False)
|
|
1102
|
+
|
|
1103
|
+
return all_passed, results, evidence_path
|