feat(jlvm): set + unset map opcodes + conformance vectors#57
Merged
scasplte2 merged 1 commit intoJun 19, 2026
Merged
Conversation
Immutable dynamic-key map write/delete in the canonical Scala evaluator, wired inline like get/has/merge. `set [map, key, value]` -> MapValue(m + (k -> value)) (immutable, last-wins); `unset [map, key]` -> MapValue(m - k) (no-op if absent). The key is an evaluated argument, so a computed runtime key is expressible — closing the audit's "no JLVM op synthesizes a runtime map key" gap. Dicts stay the data model; apps' setKey/deleteKey become set/unset. Errors (non-map arg0 / non-string key / wrong arity) -> JsonLogicException. Gas = GasCost(5) (= merge). JsonLogicOp.scala (enum), JsonLogicSemantics.scala (dispatch + handleSetOp/ handleUnsetOp), GasMetering.scala + JsonLogicGasEstimator.scala (gas), test MapSetUnsetOpsSuite.scala (20 cases). Synced the cross-language conformance vectors (conformance/json_logic_test_vectors.json -> 1.6.0) so Scala runs the same set/unset vectors as Rust + TS. Verified: 857 json_logic tests + SharedVectorConformanceSuite [set]/[unset] (23/23); scalafmtCheckAll clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1bebb39 to
9380692
Compare
scasplte2
approved these changes
Jun 19, 2026
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
New JLVM map opcodes
setandunsetin the canonical Scala evaluator. Sister PR for the Rust + TS ports + shared vectors:Constellation-Labs/metakit-sdk#63(branchfeat/jlvm-map-set-unset).Motivation: the fiber-app audit treated dynamic-key map writes (
votes[sender]=v,signatures[signer]=…, etc.) as impossible in JLVM → migrate to arrays (its hardest Tier-iii item). But{"merge":{[expr]:v}}is inexpressible only because a JSON object-literal key is a static AST string — a write opcode takes the key as an evaluated argument, so{"set":[{"var":"state.votes.voters"},{"var":"event.agent"},voteRecord]}synthesizes the runtime key. This collapses the Tier-iii refactor into one opcode pair; dicts stay the data model.Semantics (inline, modeled on
get/merge):set [map, key, value]→MapValue(m + (k -> value))(immutable, last-wins).unset [map, key]→MapValue(m - k)(immutable; absent key = no-op).JsonLogicException. Gas =GasCost(5)(=merge).Changes:
JsonLogicOp.scala(enum),JsonLogicSemantics.scala(dispatch +handleSetOp/handleUnsetOp),GasMetering.scala+JsonLogicGasEstimator.scala(gas),MapSetUnsetOpsSuite.scala(20 cases) + synced conformance vectors (conformance/json_logic_test_vectors.json→ 1.6.0) so Scala runs the sameset/unsetvectors as Rust + TS.Verification: 857
json_logictests +SharedVectorConformanceSuite [set]/[unset](23/23);scalafmtCheckAllclean. (Pre-existing, unrelated:project/Dependencies.scalascalafmt drift — untouched.)🤖 Generated with Claude Code