Powered by

Safety layer for Daml & Canton developers

The safety layer between LLM drafts and ledger code.

1,461
Curated patterns
3
Official ecosystem repos
392
Test oracles
0
Weak hits on abstain

Input · intent

Give it business intent

It searches a promoted corpus of compiler-validated Daml patterns, returning high-confidence, sourced patterns — or an honest not covered.

suggest_patterns delegate

Input · intent + code

Give it intent plus draft code

It returns a definitive verdict on the draft: not acceptable yet, aligned enough to compile, or verified against a clean client build.

fail ready_to_compile pass

The gate

It tells your agent when to proceed, when to revise, and when to stop.

The developer maintains complete build ownership

Not an LLM code generator

Generation stays inside your editor. Daml Reason never writes your templates for you.

Not a compiler

daml build runs on your machine or in CI. The server consumes your result; it never produces one.

A gatekeeper between your agent and the compiler

Daml Reason is a safety layer for Daml and Canton developers that helps ensure sound builds. AI agents draft code quickly, but ledger logic demands strict soundness.

Retrieve, gate, verdict

Agents in Cursor and automated jobs in CI share the exact same daml_reason protocol. Generation stays inside your editor; the server evaluates drafts against a promoted bundle and refuses weak recall.

Phase A

Intent only

Send businessIntent. Cross-encoder retrieval returns up to five pinned canonical patterns with complete provenance.

  • ✓suggest_patternsHigh-confidence matches from corpus_v2 (similarity floor 0.68, margin 0.04).
  • ✓propose_search_queryTransparent query rewrite when intent needs sharper calibration. You must acknowledge proposedSearchQuery or refuse it.
  • ✓delegateIntent is ambiguous or out of scope. The tool abstains honestly rather than hallucinating patterns.

Phase B

Intent plus code

Submit damlCode alongside local compilationResult from your machine or CI pipeline. The server never compiles code for you — it uses your client build results as a ground-truth signal.

  • ✓failCode misaligns with pattern standards or logic breaks. Returns remediation patterns.
  • ✓ready_to_compileSemantic alignment meets the threshold. Prompts the agent to run local build validation.
  • ✓passGranted strictly after a clean client build and gate verification. Every response includes an explicit alignmentScore.

Sound builds come from tight iterative gates

Not one-shot generation. Orient on intent, draft, gate, revise from strong patterns, compile on the client, then submit diagnostics for the final verdict. The human owns ship.

  1. 1 Orient

    Query businessIntent via Phase A.

  2. 2 Draft

    Agent generates initial damlCode.

  3. 3 Refine

    Run Phase B iteratively until reaching ready_to_compile.

  4. 4 Compile

    Run daml build locally on the client machine.

  5. 5 Verify

    Submit compile diagnostics back through Phase B for the final verdict.

daml_reason · Phase B
// request (shape)
{
  "businessIntent": "Batch settlement for two asset legs",
  "damlCode": "...",
  "compilationResult": {
    "succeeded": false,
    "exitCode": 1
  }
}

// response (excerpt)
{
  "outcome": "fail",
  "alignmentScore": 0.52,
  "patterns": [ "... strong corpus hits ..." ]
}
pass is forbidden without a successful client compile signal.

A corpus with a release process

Daml Reason operates strictly read-only against immutable release bundles (manifest + chroma_db + slices + oracles). Active production target: corpus_v2 (fingerprint 2563231711cd048f).

Pinned source

daml-finance

Interfaces, instruments, lifecycling, settlement flows, and holding rules.

634 patterns

Pinned source

Splice

Amulet token standards, wallet implementations, and DSO governance mechanics.

479 patterns

Pinned source

Daml SDK

Reference tutorials and Daml Script workflows.

348 patterns

Release criteria

  • ≥ 90% parse rate across all template slices.
  • 100% daml build pass rate.
  • Mean recall@5 ≥ 0.50 with zero anti-pattern leakage.
  • Mandatory human editorial sign-off via decision.yaml.

Fix the corpus once; every downstream agent session inherits sound practice

Retrieval benchmarks

Numbers we ship with the gates

Evaluated against 37 golden queries on corpus_v2. Retrieval metrics track bundle health across releases, not individual user prompt scores.

Mean recall@5 (+0.027 vs baseline)
0.550
Mean precision@5 (diagnostic)
0.373
Golden queries that delegate
12 / 37

Retrieval requires bge-reranker-v2-m3 cross-encoders at serve time. If coverage is missing, the corpus is improved and re-promoted. The retrieval gates are never artificially lowered.

Daml Reason runs where you build

Run it locally in your development environment, or point your editor at the authenticated hosted service. Same daml_reason contract either way.

  1. 1 Get an API key

    Sign in with email (magic link) and issue a Bearer API key for your account.

  2. 2 Add the server

    Add the server entry to ~/.cursor/mcp.json.

  3. 3 Make the first call

    Call Phase A with a businessIntent to warm the cross-encoder.

For hosted endpoints, authenticate using an account Bearer token. Usage is tracked against monthly allowances with explicit quota resets — when an allowance is spent the tool returns over_quota as a normal result, not a dropped connection.

Read the developer guide →
~/.cursor/mcp.json
{
  "mcpServers": {
    "daml-reason": {
      "url": "https://<hosted-endpoint>/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}
Never commit a real API key. Keys are scoped per account.

Turn source code into agent guardrails

Most Daml coding sessions lack verified reference material. If your team maintains production templates, reference libraries, or audited Canton protocols, bring them into the promoted corpus.

01 You provide

Pinned repositories, Daml Script test oracles, and audited templates.

02 Corpus gates run

Automated parsing, compilation checks, and golden-query evals.

03 Agents receive

Semantic routing directly to your canonical pattern slices — or honest refusal when an ask falls outside your framework.

Infrastructure for a developer community

Daml Reason is a shared checkpoint on a promoted canton-corpus bundle: retrieve, gate, and say whether to continue. When the corpus is wrong or thin, you improve the corpus once. We take precautions, not shortcuts.