Skip to content

PenghaoJiang/PACT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

PACT

PACT (JAWS): Proactive Semantic Checklists for Robust Code Translation

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).


What this framework is

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.


Why proactive semantic guidance?

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.


Method at a glance (paper → implementation)

PACT follows the pipeline illustrated in the paper (Fig. 2):

  1. Semantics Architect

    • Builds a semantic summary of the source code (program/function/operator/variable-level).
    • Produces structured context that is stable across translation attempts.
  2. 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
  3. 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.

About

A modular framework for code translation with proactive semantic guidance. It combines semantic summaries and static analysis to infer pitfalls before translating. Features an automated test-driven repair loop with early-exit and diagnostic feedback. Organized into distinct agents (semantic, inference, execution) to facilitate ablation studies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors