Repository navigation
Conversation
A review of the interpreter, importer, actor runtime, and CLI found seven divergences from OTP 29 and unvalidated input paths: - byte_size/1 now rounds a partial trailing byte up instead of raising badarg, matching documented OTP behavior. - iolist_to_binary/1 now rejects a bare integer operand and an integer list tail with badarg; a binary operand or binary tail is still accepted. - maps:iterator(Map, ordered | reversed), maps:keys/1, and maps:values/1 previously exposed internal canonical storage order, which is not Erlang term order (e.g. it placed negative integers after nonnegative ones and [] before tuples). Added Erlean/Core/TermOrder.lean, which defines Erlang's standard term order on the supported key kinds, and wired it into these functions. - maps:iterator(Map, undefined) is now accepted (unspecified order), an ordering fun is reported as an explicit unsupported operation instead of badarg, and maps:next(none) returns none as in OTP. - erlang:demonitor/1 with a reference owned by another process is now a no-op returning true, since OTP only searches the caller's own monitors; it previously raised badarg. - RawCore integers, bitstring lengths, and the CLI fuel argument now accept only canonical ASCII decimal text. Lean's String.toNat?/toInt? also accepted "_" digit separators, which are not part of the RawCore schema. - CLI emit now rejects declaration names that are Lean keywords or do not start with a letter, and run-linked requires at least one artifact. Each fix keeps the existing proofs and axiom audit intact: two new lemmas (termCompare_self, termOrdered_length) were added and proved without sorry. New regression cases cover every fix in tests/semantics/Regression.lean, tests/semantics/ActorChecks.lean, and tests/import/Smoke.lean, plus new OTP differential cases in tools/check_scalar_bifs.mjs for the scalar BIF fixes. Verified: full serialized build (node tools/build.mjs) succeeds, and the Lean-only regression, smoke, and actor-check suites pass, with a clean axiom audit (no sorry, no unsound axioms). The OTP differential scripts in tools/check_all.mjs were not run in this environment and remain to be confirmed against the pinned Erlang/Elixir/Gleam toolchain. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A review of the interpreter, importer, actor runtime, and CLI (
Main.lean) found seven places where the model disagreed with OTP 29 or accepted invalid input. Each fix keeps the existing proofs and axiom audit intact — nosorry, no new unsound axioms.byte_size/1raisedbadargon a bitstring that doesn't end on a byte boundary. OTP rounds up instead (byte_size(<<1:1>>)is1). Fixed inErlean/Semantics/Machine.lean.iolist_to_binary/1accepted a bare integer (iolist_to_binary(65)) and an integer as the list tail ([65|66]). OTP raisesbadargfor both; a binary on its own or as the list tail is still accepted.maps:iterator(M, ordered | reversed),maps:keys/1, andmaps:values/1returned the model's internal storage order, which is not Erlang term order (e.g. it put negative integers after positive ones and[]before tuples). AddedErlean/Core/TermOrder.lean, defining Erlang's term order for the supported key types, and wired it into these functions.mapsgaps:maps:next(none)now returnsnone, as in OTP.maps:iterator(M, undefined)is now accepted.maps:iterator/2is now reported as unsupported instead of wrongly raisingbadarg.demonitor/1with a monitor reference owned by another process raisedbadarg. OTP only looks at the caller's own monitors, so it now does nothing and returnstrue(Erlean/Runtime/Actors.lean).toNat?/toInt?, which also accept_separators such as"1_000". Added strict decimal parsers inErlean/Import/RawCore.lean.emitproduced a broken Lean file when the declaration name was a Lean keyword (e.g.end); it now rejects such names and names not starting with a letter.run-linkedwith no artifact files now gives a clear error.Testing
tests/semantics/Regression.lean,tests/semantics/ActorChecks.lean, andtests/import/Smoke.lean. The old test that expectedbyte_sizeto reject a partial byte now expects the OTP result.byte_sizeandiolist_to_binaryfixes intools/check_scalar_bifs.mjs.sorry, added totests/semantics/Axioms.lean: every key compares equal to itself (termCompare_self), and sorting keeps the number of entries (termOrdered_length). No existing proof needed changes.Test plan
node tools/build.mjs— full serialized dependency-ordered build succeedslake env lean -j1 -M2048 --run tests/import/Smoke.leanpasseslake env lean -j1 -M2048 --run tests/semantics/Regression.leanpasseslake env lean -j1 -M2048 --run tests/semantics/ActorChecks.leanpasseslake env lean -j1 -M2048 tests/semantics/Axioms.lean— clean axiom audit (nosorryAx,ofReduceBool, ornative_decide)node tools/check_all.mjs(full OTP/Elixir/Gleam differential suite) — not run; this environment does not have the pinned Erlang/Elixir/Gleam toolchain installed, so the OTP-side behavior changes are not yet differentially confirmed. Please run this before merging on a machine with OTP 29.0.6, Elixir 1.20.0, and Gleam 1.18.1 installed per.tool-versions.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.