feat(verifier): Add --keep-all-files option - #456
Open
olivier-aws wants to merge 1 commit into
Open
Conversation
Add a --keep-all-files CLI option that forwards a directory to Strata so the intermediate Laurel and Core IR emitted after each pipeline phase is retained for debugging. The directory is resolved to an absolute path and used as a "<dir>/program" prefix when invoking the Strata backend. Thread the new keepAllFilesDir field through VerifierOptions and update the test engine and EmitLaurelWorkflowTest call sites accordingly.
fabiomadge
approved these changes
Jun 22, 2026
fabiomadge
left a comment
Collaborator
There was a problem hiding this comment.
Approve — sound and correct. Debug-only flag; unset → command line byte-identical. /program prefix + toAbsolutePath() both right (process runs from StrataCLI). All three VerifierOptions sites updated. Verified locally on a rebuilt backend.
Two non-blocking points:
- Silently ignored with
--emit-laurel— emit-only mode returns beforerunVerifier. Worth a help-text note. - No test. Proposing this (passes locally): positive case asserts a verified method is counted; negative case (
check(1 == 2)) proves the round-trip preserves the obligation; keep-all-files case asserts the dir is created and both Laurel and Core dumps land in it. Suffixes/prefix only, so it survives pipeline changes. Spawns the real Strata process, like the existing test.
@Test
public void emittedLaurelVerifiesAndCountsAVerifiedMethod() throws Exception {
var result = emitThenVerify("""
import static org.strata.jverify.JVerify.*;
class Emit {
static void trueCheck() { check(1 == 1); }
}
""");
assertEquals(0, result.exitCode(), "true program should verify");
assertNotNull(result.verificationResults());
assertTrue(result.verificationResults().verificationPassedMethods() > 0,
"the verified method must be counted, not vacuously skipped");
assertEquals(0, result.verificationResults().verificationFailedAssertions());
}
@Test
public void emittedLaurelStillCatchesAFalseObligation() throws Exception {
var result = emitThenVerify("""
import static org.strata.jverify.JVerify.*;
class Emit {
static void falseCheck() { check(1 == 2); }
}
""");
assertNotEquals(0, result.exitCode(), "false program must not verify clean");
assertTrue(result.verificationResults().verificationFailedAssertions() > 0,
"the false check must produce a failed assertion");
}
@Test
public void keepAllFilesWritesIntermediateIrIntoRequestedDir() throws Exception {
var keepDir = Files.createTempDirectory("keep-all-files-test")
.resolve("nested-not-yet-created");
assertFalse(Files.exists(keepDir), "precondition: dir does not exist yet");
var source = """
import static org.strata.jverify.JVerify.*;
class Emit { static void trivial() { check(1 == 1); } }
""";
var driver = Driver.getDriver(withKeepAllFiles(baseOptions(), keepDir));
driver.verifyJavaFiles(new java.util.ArrayList<>(List.of(
new SourceFile(Path.of("Emit.java"), source))));
assertTrue(Files.isDirectory(keepDir),
"--keep-all-files must create the requested directory");
try (Stream<Path> files = Files.list(keepDir)) {
var names = files.map(p -> p.getFileName().toString()).sorted().toList();
assertFalse(names.isEmpty(), "intermediate IR files should have been written");
assertTrue(names.stream().allMatch(n -> n.startsWith("program.")),
"emitted files should use the 'program' prefix: " + names);
// Both IR families kept (the feature claim), decoupled from phase names/counts.
assertTrue(names.stream().anyMatch(n -> n.endsWith(".laurel.st")),
"a Laurel-phase dump should be present: " + names);
assertTrue(names.stream().anyMatch(n -> n.endsWith(".core.st")),
"a Core-phase dump should be present: " + names);
}
}Helpers (emitThenVerify, withKeepAllFiles, baseOptions) omitted for brevity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a --keep-all-files CLI option that forwards a directory to Strata so the intermediate Laurel and Core IR emitted after each pipeline phase is retained for debugging. The directory is resolved to an absolute path and used as a
<dir>prefix when invoking the Strata backend.Thread the new keepAllFilesDir field through VerifierOptions and update the test engine and EmitLaurelWorkflowTest call sites accordingly.
What was changed?
How has this been tested?
Manually tested.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0.