Status: We are currently cleaning up and documenting the repository. We will release the full code soon (after organizing).
This project accompanies our paper:
“Fixing Less by Preventing More: Semantic Checklists for Robust Code Translation” (see JAWS.pdf in this release).
PACT is a modular, agentic framework for LLM-based code translation that shifts from reactive “translate-then-repair” to proactive semantic guidance.
Instead of relying on multiple repair iterations after failures, PACT:
- extracts multi-granularity semantics from the source program,
- runs static analysis to surface cross-language semantic risk factors,
- infers a prioritized checklist of likely translation pitfalls,
- translates under explicit constraints,
- validates via compilation/execution tests,
- early-exits when the first translation passes,
- otherwise enters a bounded diagnose-and-repair loop using diagnostic feedback.
The codebase is designed for research: ablations, alternative checklists/verifiers, and dataset extensions are first-class goals.
Many translation errors are semantic (e.g., type width, operator meaning, control-flow corner cases). Traditional translate-then-repair often fixes “surface failures” (missing imports, minor compile issues), while the root semantic mismatch persists.
PACT prevents these errors by surfacing cross-language semantic constraints before generation, and requiring the translation to satisfy them.
PACT follows the pipeline illustrated in the paper (Fig. 2):
-
Semantics Architect
- Builds a semantic summary of the source code (program/function/operator/variable-level).
- Produces structured context that is stable across translation attempts.
-
Quality Assurance Architect
- Infers a hierarchical semantic checklist of potential translation issues.
- Labels items by severity:
- CRITICAL = must be enforced as hard constraints
- WARNING = best-effort improvements
-
Translation Synthesizer
- Generates the target code under checklist constraints.
- Runs compilation/execution validation.
- Uses early-exit if the first attempt passes all tests.
- Otherwise activates an optional bounded loop that incorporates diagnostic feedback until convergence or the attempt budget is exhausted.