Skip to content

fix: preserve imported operands and supported arities - #50

Merged
altaywtf merged 2 commits into
mainfrom
fix/imported-operands
Sep 5, 2026
Merged

fix: preserve imported operands and supported arities#50
altaywtf merged 2 commits into
mainfrom
fix/imported-operands

Conversation

@altaywtf

@altaywtf altaywtf commented Sep 5, 2026

Copy link
Copy Markdown
Member

Problem

Imported scalar and nested operands were hidden and could be discarded during editing. Validation rejected supported three-argument ranges and conditionals without an else.

The workflow used third-party runners in a public repository, including a release runner unsupported by npm trusted publishing.

Solution

Preserve defined shorthand operands through rendering and controlled updates, including explicit null. Allow three arguments for </<= and two for if, retaining the existing UI defaults. Removal uses the actual operand count so a two-argument conditional cannot lose a required operand. Add regression coverage and import examples in the demo.

Run verification and publication on GitHub-hosted ubuntu-latest runners under the public-repository policy. This also meets the npm trusted publishing runner requirement.

Proof

The new regression suite failed 16 cases against the original source. Final pnpm verify passes 111 tests, coverage thresholds, library packaging and demo build. React Doctor reports no introduced issues against origin/main.

Browser edits preserved these shapes:

{"-": [6]}
{"!": [{"===": [1, 1]}]}
{"<=": [18, {"var": "user.age"}, 20]}
{"if": [true, "ok"]}

Evaluation returned -6, false, false, and "ok". The conditional has no Remove controls at two operands; adding a third and removing it by keyboard returns to two without allowing further removal. actionlint and offline zizmor passed for the workflow.

Keyboard removal retained the first two range operands; the 375×812 view had no document overflow.

Copilot AI lite review requested due to automatic review settings September 5, 2026 15:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T16:34:24.209658Z 8042295 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

🟢 Approval recommended

Changes are consistent across the operator table, validator, UI operand handling, and are backed by targeted regression tests and demo examples.

Pull request overview

Fixes a builder/validator mismatch where imported shorthand operands (scalar, null, and nested operator objects) could be hidden and lost during edits, and updates arity validation to accept evaluator-supported forms (</<= with 3 operands; if without an else).

Changes:

  • Preserve non-array operand shorthands by normalizing operand access/update paths in the recursive Any renderer.
  • Expand operator arity contracts for if, <, and <=, and align validator expectations with evaluator behavior.
  • Add regression tests for shorthand operand preservation and supported arities; add demo samples covering the imported shapes.
File summaries
File Description
packages/react-json-logic/src/components/any.tsx Normalizes operand handling so scalar/nested shorthands render and survive add/remove/edit flows.
packages/react-json-logic/src/operators.ts Updates fieldCount to allow if (min 2) and </<= (max 3).
packages/react-json-logic/tests/validator.test.ts Adds regression cases ensuring validator accepts evaluator-supported arities and updates max-arity failure expectation.
packages/react-json-logic/tests/json-logic-builder.test.tsx Adds regression coverage for preserving imported shorthand operands (including explicit null) and editing 3-operand ranges / if without else.
packages/react-json-logic/tests/edge-cases.test.tsx Updates a nested-arity failure case to reflect the new < max arity.
apps/example/src/app.tsx Adds sample rules demonstrating imported shorthand/nested operands, 3-operand ranges, and if without else.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@slopzapper slopzapper Bot 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.

⚡ SLOPS ZAPPED: 1

Verdict: Non-blocking slop

Imported non-array operands and between-style < / <= arities match the evaluator. The if minimum is now 2 but the operator still seeds three slots, so Remove can drop below that minimum.

Findings

  1. 🧹 SMOLSLOP · P2 — if keeps a 3-slot template after min 2 — Remove's floor is bogus (packages/react-json-logic/src/operators.ts:85)

Comment thread packages/react-json-logic/src/operators.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 840aedbcb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/react-json-logic/src/operators.ts

@slopzapper slopzapper Bot 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.

✨ CLEAN

Prior threads: 1 addressed · 0 still present

Imported-operand handling and the if / range arity updates match the evaluator. The prior if-Remove floor bug is fixed.

@altaywtf
altaywtf merged commit 7a8e884 into main Sep 5, 2026
6 checks passed
@altaywtf
altaywtf deleted the fix/imported-operands branch September 5, 2026 16:36
@uinaf-releaser

uinaf-releaser Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants