Repository navigation
WitnessCreator 1.0: Python rewrite - #2
Merged
Merged
Conversation
SV-COMP 2027 requires Java violation witnesses in the YAML format,
version 2.3. WitnessCreator now writes witness.yml with one
violation_sequence: a function_return waypoint per recorded
Verifier.nondet*() value (constraint `\result == <java literal>`,
location at the closing parenthesis of the call) and a final target
waypoint at the violating statement. witness.graphml is still written
for the validators that consume the legacy format.
- New marker fields from the executor: call index on the line, type
descriptor and source file (legacy 4-field markers still parse);
new [WITNESS_TARGET] marker carrying the uncaught throwable's stack
trace, resolved to the innermost frame inside the task sources.
- Columns come from the sources: closing `)` of the n-th nondet call
on the line, `assert`/`throw`/first token of the target statement.
- Literals per type: L suffix only when needed, char literals, f
suffix for floats, NaN/Infinity via Float/Double, strings via
`\result.equals("...")` with Java escaping.
- CLI: --input (inputs as given, listed with sha256 hashes),
--property (specification), --out, --producer-version; the legacy
positional form keeps working. Templates are found next to the jar.
- JUnit tests for literals, markers, source resolution and the writer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
witnesscreator is a stdlib-only Python package (>= 3.10) with the
library API agreed with SWAT (Task, Location, NondetReturn, Frame,
Violation, write_witnesses), hand-written YAML 2.3 and GraphML emitters,
and a CLI (`witnesscreator events|legacy`, plus the Java tool's
positional command line for drop-in use).
Ported from the Java branch with these fixes:
- Java string literals escape every non-ASCII character (\uXXXX,
surrogate pairs beyond the BMP); YAML scalars are plain ASCII with
\uXXXX / \UXXXXXXXX escapes; all GraphML text is XML-escaped.
- Target frames need a package match (path or `package` declaration);
java./javax./jdk./sun./de.uzl.its.swat. frames are skipped; name-only
fallback only for value locations. A missing target logs a warning.
- Column heuristics run on source with comments and string/char
literals blanked out; `nondet*(` needs a word boundary.
- GraphML assumptions are `\result = <value>;` / `\result.equals("...");`
(what wit4java parses) instead of a variable name guessed from the
source line.
- Never crashes on bad input; each format is written independently.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unit tests for literals, escaping, markers, events, source resolution and columns; golden end-to-end tests on copies of SV-COMP tasks (the GDart example of sv-witnesses, jbmc-regression, jdart-regression, MinePump) and a synthetic task with an inner class, two nondet calls on one line, a packaged class and a unicode/control-character string. Generated witnesses are parsed with PyYAML / ElementTree, checked for exactly one final target segment and, when available, linted with WitnessLint. CLI tests cover the event file, both marker forms, the Java command line, exit codes and the zipapp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st and pyz Tests run with WitnessLint from the sv-witnesses repository so the generated witnesses are linted in CI. On a v* tag the wheel, the sdist, witnesscreator.pyz and SHA256SUMS are attached to the GitHub release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What / why
WitnessCreator 1.0 replaces the Java/Gradle tool by a standalone, stdlib-only Python package (
witnesscreator, Python >= 3.10, tested on 3.10/3.13/3.14 — 3.14 is the SV-COMP 2027 image). It produces Java violation witnesses in the YAML format 2.3 (required for Java in SV-COMP 2027) and the legacy GraphML format, ports every behaviour of #1 (the Java YAML implementation) and fixes the review findings of that branch. It stays usable by tools other than SWAT: the library API and the event file carry plain data, nothing SWAT-specific.Builds on #1 (branch
feat/yaml-witness-2.3); the Java sources, Gradle files and StringTemplate templates are removed.Library API
Never raises for bad data (logs on
witnesscreator, each format written independently);render_yaml/render_graphmlreturn strings;dump_events/read_eventsfor the event file.Locationadditionally takes an optionalmethod(the caller's descriptor, only used for the GraphMLassumption.scope).CLI
witnesscreator events --events E.jsonl --property P.prp --input PATH... --out-dir D [--format yaml|graphml|both] [--producer-name N --producer-version V]— JSON-lines serialization of the objects above.witnesscreator legacy [<b64>] [--markers-file F] ...— SWAT's[WITNESS]/[WITNESS_TARGET]markers, 4- and 7-field payloads.witnesscreator <b64> <dir> [--input ..] [--property ..] [--out ..] [--producer-version ..]— the Java tool's command line, unchanged (drop-in:witnesscreatorinstead ofjava -jar WitnessCreator.jar).witnesscreator.pyz(zipapp).Fixes vs. the Java branch (#1)
\uXXXX(surrogate pairs beyond the BMP); YAML double-quoted scalars are plain ASCII (\uXXXX,\UXXXXXXXX); GraphML text (assumptions, scopes, paths, producer) is XML-escaped — the Java version wrote e.g.s1.equals("<bad/>")unescaped into the XML (7 securibench runs).packagedeclaration);java.,javax.,jdk.,sun.,de.uzl.its.swat.frames skipped; name-only fallback only for value locations; exactly one finaltargetsegment when a target is known, warning otherwise (schema-valid file still written).nondet*(needs a word boundary;call_index-th call's closing); target column =assert/throwkeyword, else first token (skipping}/{/else).\result = <value>;/\result.equals("…");(what wit4java's parser extracts) instead of a variable name guessed from the source line (x = 3, ortruewhen the line had noVerifier, which made wit4java parsetrueas an int).Lonly outside int range, char literals,fsuffix,Float.isNaN(\result),\result == Double.POSITIVE_INFINITY,-0.0preserved,\result.equals("…").Testing
ExDarko_false.witness-2.3.ymlcontent —, jbmc-regression return2/StringValueOf08 (NumberFormatException thrown in the JDK)/exceptions16, jdart float (NaN/±Infinity/-0.0), MinePump (multi-file + package), a synthetic task (inner class, two calls on one line, unicode/control chars, packaged class); CLI incl. zipapp). All pass on 3.10, 3.13, 3.14. Every YAML is parsed with PyYAML, checked for exactly one final target segment and linted with WitnessLint 2.3 when available (CI installs it); GraphML parsed as XML.feat/yaml-witnessesworktree): 35/35 YAML identical (modulo uuid/creation_time); GraphML structurally identical on 28/35, the 7 differences are the fixes above (unescaped<bad/>in Java's XML; Basic4true→\result = 3;). wit4java verdicts on the GraphML witnesses are identical for Java and Python on all 32 distinct tasks (19 correct, 2 spurious, 11 could-not-validate — same both sides); WitnessLint: 32/32 well-formed.Breaking changes for Java users
witnesses/*.st, no Gradle. Replacejava -jar build/libs/WitnessCreator.jar ARGSbywitnesscreator ARGS(orpython3 witnesscreator.pyz ARGS); arguments unchanged, no particular working directory needed.\result = …;assumptions, XML escaping,sourcecodelang/specificationgraph data. Stricter target resolution (package match). Non-ASCII escaped in Java literals.Release steps
git tag v1.0.0 && git push origin v1.0.0.witnesscreator.pyz+SHA256SUMSand attaches them to the GitHub release.pip install git+https://github.com/SWAT-project/WitnessCreator@v1.0.0or the.pyzfrom the release.🤖 Generated with Claude Code