Proof success and fix verification are decided in several places

Ouverte
#30 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
15/100
Type d'issue
Refactorisation
Clarté
Plutôt claire
Activité
Active
Stack technique
go
Domaine
backend, security

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
Go
Étoiles
0
Forks
1
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TMHSDigital/Spackle

Toutes les issues de TMHSDigital/Spackle

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.