Skip to content

herta: Lean 1–4 study, Lean 4 model of the retry/deadline contract, herta trust ledger - #15

Open
arahe-dev wants to merge 5 commits into
devin/herta-closed-worldfrom
devin/1795110536-herta-lean
Open

arahe-dev wants to merge 5 commits into
devin/herta-closed-worldfrom
devin/1795110536-herta-lean

Conversation

@arahe-dev

@arahe-dev arahe-dev commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

What does this change?

  • herta/formal/: a Lean 4 package with no dependencies (305 lines) that models hertasdk's retry, deadline and effect semantics, with source citations. It proves:
    • T1: a nonidempotent op that does not retry Uncertain applies its effect at most once, as long as every attempt classified Transient applied nothing. T1_assumption_necessary shows the run is unsafe without that assumption.
    • T2: if the attempt's own deadline is tagged Transient, a backend that applies its effect and then times out applies it twice. This is the mechanism behind all 23 pilot r1 failures.
    • T3: for the r1 numbers, the transient tag gives 4 calls and 1000 ms. The SDK default gives 1 call and 300 ms (≤ 550), which is exactly the oracle's rule.
    • T4: a nested same-key acquire can never succeed. A pure or idempotent outer op that retries over a nonidempotent inner op applies the inner effect more than once.
    • T5: the closed-world Policy.Classify path never retries after the attempt's own deadline, so it removes the T2 failure mode by construction.
    • check.sh builds the package in about 2 s. It fails on sorry or on any axiom other than propext, Classical.choice and Quot.sound.
  • herta trust [-closed] [-json] [-strict] file.he: a per-op list of trust assumptions, modelled on Lean's #print axioms. Assumptions propagate through call edges, and each one links to the theorem behind it. Kinds: opaque-handler, transient-honest, legacy-tag-path, nested-retry-amplification, same-serialize-key, unresolved-callee. Docs are in herta/docs/TRUST.md.
  • herta/eval/trust/: a script and summary that run the ledger over the 20 closed-world inputs, the 20 migrated programs and 121 composition corpus files.
  • herta/docs/LEAN.md: the study. It covers the pilot mechanism, a Lean 1→4 timeline, Lean's primitives, ranked reasons Lean succeeded, a Lean→Herta mapping, a short note on the Bend analogy, limits, and next experiments that could disprove each proposal.

Why?

The pilot found no measurable Herta benefit. Its failures came from one contested deadline rule, and the checker could not see raw Go handler bodies. This PR turns that rule into proved statements. It also borrows Lean's way of making trust boundaries explicit and checkable (a small kernel plus an axiom audit) for opaque Go code.

Limits:

  • opaque-handler and legacy-tag-path flag 100% of legacy programs, so they do not tell programs apart. Only transient-honest is selective (10/20).
  • The ledger misses R/t3 (missing retry on Uncertain) and R/t4 (dynamic key collision).
  • Nothing here measures an agent benefit yet.

Tests: go test ./herta/... passes, including the new trust goldens, within the runner caps (200 cases, 5 s/case, 60 s total). herta/formal/check.sh passes.

Scope check

  • Runtime changes keep docs/contract.md true (no runtime changes)
  • go test -race -count=1 . passes with 100% coverage; cd lab && go test -race -count=1 ./... passes (root untouched; not rerun)
  • No adoption claims, benchmarks without methodology, or marketing language
  • Links valid; SVG renders in both GitHub light and dark mode (if touched)
  • Linked issue (if any): #

Herta opened this PR for Abdur
Implemented in session Study Lean 1 through 4 for Herta
Review with Devin · Open in Devin Desktop


devin-ai-integration Bot and others added 3 commits November 19, 2026 17:51
Co-Authored-By: Abdur Raheem Imami <araheemimami@gmail.com>
Co-Authored-By: Abdur Raheem Imami <araheemimami@gmail.com>
Co-Authored-By: Abdur Raheem Imami <araheemimami@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 18:00
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

devin-ai-integration Bot and others added 2 commits November 19, 2026 18:06
Co-Authored-By: Abdur Raheem Imami <araheemimami@gmail.com>
Co-Authored-By: Abdur Raheem Imami <araheemimami@gmail.com>
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.

2 participants