Skip to content

Add Agda certifier integration with source location tracking#7660

Open
zeme-wana wants to merge 10 commits intomasterfrom
agda-certifier
Open

Add Agda certifier integration with source location tracking#7660
zeme-wana wants to merge 10 commits intomasterfrom
agda-certifier

Conversation

@zeme-wana
Copy link
Copy Markdown
Collaborator

  • Refactor source location tracking in plutus-tx-plugin to flow through ReaderT
    CompileContext (ccCurrentLoc) instead of invasive function parameters on
    compileExpr.
  • Add --certify[=DIR] plugin option that invokes the Agda certifier for each
    compiled Plutus script, embedding package name, module name, and source location in
    the certificate metadata.
  • Simplify compileMarkedExprs (remove stateful go lastLoc loop), stripAnchors
    (single pattern match instead of recursive go), and package name resolution
    (lookupUnit / thisPackageName / stripVersionFromUnitId fallback chain).
  • Improve Certifier.hs: include certifier report in error messages, use
    createDirectoryIfMissing, remove noisy console output.
  • Encode TH source locations in structured format (encodeTHLoc) so the plugin can
    recover RealSrcSpan from the type-level string.
  • Add CI workflow (plinth-certifier-tests.yml) and test script
    (scripts/plinth-certifier-tests.py).

@zeme-wana zeme-wana marked this pull request as ready for review March 18, 2026 08:56
@zeme-wana zeme-wana requested a review from zliu41 March 18, 2026 14:12
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Execution Budget Golden Diff

c73873c (master) vs c13e7be

output

plutus-tx-plugin/test/CallTrace/9.6/successfullEvaluationYieldsNoTraceLog.golden.eval

Metric Old New Δ%
Flat Size 514 348 -32.30%

This comment will get updated when changes are made.

Copy link
Copy Markdown
Collaborator

@SeungheonOh SeungheonOh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, mainly over the compiler part. Second pair of eyes on certifier part would be nice since I'm not too familiar with that area

@@ -6,4 +6,4 @@ Trace:
-> func (test/CallTrace/Spec.hs:79:1-79:4)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All test golden in test/CallTrace/* needs to be reverted. The call srcspan gets erased when we build from compilation cache.

Also, I think this can be fixed now. made an issue #7722

consume _ = err
in
consume li >>= traverse (compileExpr Nothing)
consume li >>= traverse (compileExpr)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this didn't get caught by hlint? I'm surprised

, ccCurrentLoc :: Maybe GHC.RealSrcSpan
, ccPackageName :: String
, ccModuleName :: String
, ccSourceLoc :: Maybe GHC.RealSrcSpan
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's for ccSourceLoc and what's for ccCurrentLoc?

I see ccSourceLoc is only used for verifier related stuff; can we not only have ccCurrentLoc and use that for verifier stuff?

other -> other
{-| Strip a single @anchor@ application (and any surrounding ticks),
returning the decoded source span if present. -}
stripAnchors :: GHC.Name -> GHC.CoreExpr -> (Maybe GHC.RealSrcSpan, GHC.CoreExpr)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to have separate getAnchorSrcSpan function instead of adding it to stripAnchors; or, give it some better name.

Copy link
Copy Markdown
Contributor

@ana-pantilie ana-pantilie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The certifier changes are awesome, thanks @zeme-wana! The only issue I have with this PR is, as @SeungheonOh pointed out:

All test golden in test/CallTrace/* needs to be reverted. The call srcspan gets erased when we build from compilation cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants