Proof success and fix verification are decided in several places

未关闭
#30 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
15/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
go
领域
backend, security

调研方向

Start by comparing the five proof-success expressions listed in the issue, at internal/agent/prover.go:245, internal/agent/debugger.go:160, internal/engine/verify.go:137, internal/agent/fixer.go:251 and internal/engine/debug.go:422, to see where the exit-code check differs. The fix-verification logic in internal/agent/fixer.go (verifyFix) and internal/engine/debug.go (debugRun.check) is the other half. Done means one shared outcome function with a table test over timeout, exit code and marker, and an agreed decision on the looser rule.

由索引模型根据 Issue 内容生成。

描述

severity: medium tech-debt

Summary

"Did the proof succeed" is evaluated in five places with two rules, and fix verification exists twice (scan fixer and debug mode) with different checks, so "demonstrated" and "verified" mean different things per command.

Where

  • internal/agent/prover.go:245
  • internal/agent/debugger.go:159-160
  • internal/engine/verify.go:137
  • internal/agent/fixer.go:251
  • internal/engine/debug.go:420-425
  • internal/agent/prover.go:191-267
  • internal/agent/debugger.go:110-181
  • internal/agent/fixer.go:201-280
  • internal/agent/debugger.go:331-373
  • internal/engine/debug.go:689-740
  • internal/engine/debug.go:85-97
  • internal/agent/fixer.go:81-95
  • internal/agent/prover.go:57-72
  • internal/engine/debug.go:390-403

Details

The oracle for a marker-based proof is an inline expression at each call site. Three require exit code 0: !run.TimedOut && run.ExitCode == 0 && strings.Contains(run.Stdout+run.Stderr, marker) (prover.go:245, debugger.go:160, verify.go:137). Two do not: !run.TimedOut && strings.Contains(run.Stdout+run.Stderr, in.PoC.Marker) (fixer.go:251) and !res.TimedOut && strings.Contains(res.Stdout+res.Stderr, rep.poc.Marker) (engine/debug.go:422). So a proof that prints the marker and then exits non-zero against patched code is "still succeeds, patch rejected" for the fixer and for debug's fix check, but "no longer succeeds" for spackle verify, which then sets f.Status = finding.StatusFixed (verify.go:148-151). Separately, Prove (prover.go:191-267) and Reproduce (debugger.go:110-181) are the same 60-line two-attempt loop (stop reasons, decode, validatePoC, box.run, redact+clip to 4000, build PoC, classify the failure into three reasons, re-prompt) differing only in nouns, the reply struct (can_prove vs can_reproduce) and how the brief is built.

"Take the model's files, load originals, build the unified diff, refuse over 400 changed lines, compile-check, re-run the reproduction, run the test suite, compose a verified: / unverified: sentence" is implemented once as verifyFix (fixer.go:201-280) and a second time split across Diagnosis.consider (debugger.go:343-359, the same sort/diff/400-line block as fixer.go:206-223) and debugRun.check (engine/debug.go:689-740). debugCompileCheck (debug.go:85-97) is a line-for-line copy of compileCheck (fixer.go:81-95) and its comment says so ("mirrors the fixer's compile check"). debugRun.run (debug.go:390-403) re-implements Box.run (prover.go:57-72) because Box.run is unexported and pinned to b.Root, and bisect needs another source directory. The copies have drifted in behaviour, not only wording: (1) test-suite policy: the fixer only runs the suite when the baseline passed and then rejects the patch on failure (fixer.go:258-273); debug mode never takes a baseline, runs the suite regardless, and on failure keeps the patch as "unverified" (debug.go:726-737). (2) "still reproduces" is !TimedOut && marker in both, but see the next finding for the other three call sites.

Impact

The meaning of the product's central claim, "demonstrated" / "fixed", depends on which command evaluated it. Anyone tightening the oracle (for example to stdout only, or to require exit 0 everywhere) has to find five expressions in two packages. A change to the retry loop (a third attempt, different clipping) must be made twice.

Any change to what "verified" means (a new language's compile check, a lint step, a different patch-size limit, how a broken baseline is treated) must be made in two packages, and the user-visible claim "verified" already means different things in scan and debug. The 6-value return of verifyFix (fixer.go:201) makes it awkward to extend.

Suggested fix

(1) Add func (p *PoC) Succeeded(res sandbox.Result) bool in internal/agent with the strict rule, plus a table test over (timed out, exit code, marker present). (2) Replace prover.go:245, debugger.go:160 and verify.go:137 with it (no behaviour change). (3) Decide deliberately for fixer.go:251 and debug.go:422: either add func (p *PoC) MarkerSeen(res) bool and name the looser rule, or switch them to Succeeded; record the decision in a comment and a test. (4) Then fold Prove and Reproduce into one unexported attemptPoC(ctx, r, parent, sealer, reg, box, language, image, spec) where spec carries the system prompt, the base user text, the purpose ("poc"/"repro"), the nouns, and a decode(text) (ok bool, reason string, files, cmd, explanation) function. Tests to have before starting: TestProveThenFixThenVerify, TestVerifyRerunsStoredProofs, TestReproduceRunsTheScriptAndKeepsTheIssueInOneEnvelope, TestReproduceReportsWhenItCannotAndWhenTheScriptFails, TestModelCannotAwardItselfDemonstrated (names seen in the listing).

(1) Characterize first: keep TestPatchThatBreaksTheBuildIsRejected, TestPatchThatDoesNotCloseTheProofIsRejected, TestDebugFixThatBreaksTheSuiteIsUnverified, TestDebugFixThatDoesNotMakeTheTestPassIsRejected, TestDiagnoseFeedsARejectionBackAndComputesThePatch green (names seen in the listing); add a test that pins the fixer's feedback message shape. (2) Export one agent.CompileCheck and delete debugCompileCheck. (3) Extract agent.buildPatch(root, files) (clean map[string]string, patch string, problem string) from fixer.go:206-223 and use it in consider. (4) Give Box an exported Run(ctx, purpose, image, cmd, files, sourceDir) (empty sourceDir means b.Root) and make debugRun.run a thin call to it. (5) Introduce type Candidate struct{Files map[string]string; Patch string} and type Verdict struct{Problem, Verification string; Verified bool}; rewrite verifyFix to return (Candidate, Verdict, error). (6) Express the fixer's sandbox checks as an agent.Check (the type already exists, debugger.go:208) built by a constructor taking compile command, reproduction oracle and suite policy; have the engine's debugRun.check use the same constructor with its own oracle. (7) Decide the suite policy once and document it; if debug should keep its looser rule, make that an explicit parameter. (8) Wrap the fixer's feedback with sealer.Wrap as Diagnose does.

Acceptance criteria

  • One function decides proof outcome, with an explicit inconclusive result
  • Scan and debug share one fix verification path
  • make lint, make test and make build pass

Related: the bug about timed-out proofs being recorded as fixed would be removed by this refactor.

Getting started

  • Relevant files: internal/agent/prover.go, internal/agent/debugger.go, internal/engine/verify.go, internal/agent/fixer.go, internal/engine/debug.go
  • How to run tests: make test (Unix) or .\make.ps1 test (Windows PowerShell); lint with make lint
  • Related docs: CONTRIBUTING.md, AGENTS.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 35948f7. Severity: medium. Effort: M. audit-key: tech-debt|internal/agent/prover.go|Prove

主要语言
Go
星标
0
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/Spackle 的其他 Issue

查看 TMHSDigital/Spackle 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。