Skip to content

Add JsonLogic public entry point; full fixture contract green on all targets - #10

Merged
sjaramillo10 merged 4 commits into
mainfrom
kmp/entry-point
Jul 27, 2026
Merged

sjaramillo10 merged 4 commits into
mainfrom
kmp/entry-point

Conversation

@sjaramillo10

Copy link
Copy Markdown

WS-G — public entry point + full fixture replay

What was done

Workstream WS-G of KMP-MIGRATION.md: the public JsonLogic class, and the migration's acceptance milestone — the complete fixture contract running unfiltered on every target.

  • JsonLogic.kt ports JsonLogic.java's surface with the two sanctioned design fixes (no behavior change to any evaluation result):
  • Default table = the exact 34 registrations of JsonLogic.java:21-54, same order. truthy re-exposed on the companion. The lambda addOperation convenience adapted from Java's Object[] to the port's List<Any?>.
  • KDoc states the real contracts: unchecked exceptions (a deviation from upstream's checked JsonLogicException, called out explicitly), configure-then-share thread-safety with genuine safe-publication guidance, and the Infinity/NaN re-encoding sharp edge.
  • JsonLogicFixtureReplayTest — all fixtures, no operator filter, exact counts asserted; JsonLogicApiTest — 13 API tests.

How it was validated

Independently by the orchestrator; the milestone numbers:

Lane Full replay Suite
jvmTest 289/289 value + 46/46 error 329 tests, 0 failures
testAndroidHostTest 289/289 + 46/46 325 tests, 0 failures
wasmJsNodeTest 289/289 + 46/46 325 tests, 0 failures
iosSimulatorArm64Test 289/289 + 46/46 325 tests, 0 failures

Zero fence-gated fixes were needed — the assembled engine passed its entire correctness contract on the first full run, on all four targets. Head fee20ce (branch on current origin/main; the two commits after the lane run are KDoc-only).

  • Mechanical checks: ownership = JsonLogic.kt + two test files; nothing else; tree clean.
  • CI: three required lanes on this PR — see checks.

Codex adversarial review (2 rounds + orchestrator verification)

Round Finding Adjudication Outcome
1 Medium: thread-safety KDoc promised visibility/race-freedom that the unsynchronized lateinit rebuild cannot deliver (concurrent registrations can publish a stale snapshot) Confirmed against the code Fixed documentation-only per the decided design (concurrent registration is unsupported; configure-then-use is upstream's model) — contract narrowed, exact failure modes named
2 Residual: the fix's own safe-publication example (val hand-off) doesn't establish happens-before; method KDoc still overclaimed Confirmed — same finding, incomplete fix Wording completed (real happens-before mechanisms; method guarantee scoped to the configuring thread); final text verified against the code by the orchestrator

This PR also flips WS-G's tracking-doc checkbox.

Ports JsonLogic.java's surface with two deliberate deviations: no
unbounded parse cache (parsing is now explicit via parse()/apply
overloads) and no lazily-nulled evaluator field (addOperation rebuilds
the complete evaluator snapshot eagerly, so applying is race-free
without synchronization). Registers the same 34 default operations in
the same order and preserves upstream's last-registration-wins
behavior for duplicate operator keys.

Adds a commonTest suite that replays the entire fixture corpus
(289 value fixtures, 46 error fixtures) through a default-configuration
engine on every KMP target, plus API tests covering both addOperation
overloads, duplicate-key resolution, parse+apply round trips, the
truthy companion, and undefined-operation error parity.
The prior wording promised a visibility guarantee and a "never
half-built" property for concurrent addOperation/apply use that the
plain MutableMap + lateinit var evaluator fields do not provide.
Rewrites the paragraph to state the actual contract: configure on a
single thread, then safely publish before concurrent apply use;
concurrent addOperation (with itself or with apply) is unsupported and
can race. Also drops the public KDoc's link to the internal
valueToJsonElement symbol.
The class KDoc's safe-publication example named a Kotlin val, which
only prevents reassignment and establishes no happens-before edge for
the evaluator writes addOperation performs after construction.
Replaces it with mechanisms that actually publish across threads.
addOperation(JsonLogicExpression)'s method KDoc still claimed the
instance was race-free to apply against "as soon as this call
returns"; qualifies that to same-thread visibility only, pointing to
the class KDoc for what cross-thread visibility requires.
@sjaramillo10
sjaramillo10 marked this pull request as ready for review July 27, 2026 20:31
@sjaramillo10
sjaramillo10 merged commit 6d0e907 into main Jul 27, 2026
3 checks passed
@sjaramillo10
sjaramillo10 deleted the kmp/entry-point branch July 27, 2026 20:31
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.

1 participant