Repository navigation
feat(rules): add template and copy rules over several paths - #54
Merged
Merged
Conversation
This was referenced Oct 20, 2026
Mearman
force-pushed
the
feat/multi-path-rules
branch
from
October 20, 2026 23:11
c013290 to
5757339
Compare
Mearman
force-pushed
the
feat/element-when
branch
from
October 20, 2026 23:11
3c25c6c to
0d7b1c2
Compare
Mearman
force-pushed
the
feat/multi-path-rules
branch
from
October 21, 2026 00:09
5757339 to
7ee9125
Compare
Mearman
force-pushed
the
feat/element-when
branch
from
October 21, 2026 00:09
0d7b1c2 to
0512e9e
Compare
A template rule renders several string fields into one text through a
template of {name} placeholders and splits it back on decode. The
schema refuses a template without a unique inverse (a field used twice
or not at all, an unknown placeholder, adjacent placeholders), and
encode splits its own rendering back and throws for a value holding
the literal that follows its placeholder.
A copy rule writes one value to two or more paths; decode reads every
copy and throws unless they are deeply equal.
The executor reads every read-side path of a rule, pairs their matches
element by element (throwing when they address different elements),
and writes each result to its write-side path. ruleSides lists a
rule's paths for the executor and validateCrosswalk, which checks the
wildcard count, uniqueness and array feeding of every path and that a
template's fields come from the same element.
Adds both rules to the two-way table with the condition under which each inverts, an example of each, and drops templates and one rule writing several targets from "Not in this version".
Mearman
force-pushed
the
feat/multi-path-rules
branch
from
October 21, 2026 04:50
7ee9125 to
d992670
Compare
Mearman
marked this pull request as ready for review
October 21, 2026 05:54
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex security review |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
|
🎉 This PR is included in version 0.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Adds two two-way rules that touch more than one path:
template, which renders several string fields into one text and splits it back, andcopy, which writes one value to several places.A template is
{ op: "template", from: { given: "people[].given", family: "people[].family" }, to: "names[]", template: "{family}, {given}" }, with{{and}}for literal braces. The schema refuses a template that cannot be inverted (a field used twice or not at all, a placeholder naming no field, adjacent placeholders). Decode strips the leading and trailing literals and cuts each field at the first occurrence of the literal after it. Encode splits its own rendering back before returning it and throws for a value that contains the literal following its placeholder, so the round trip holds for everything encode accepts.copytakes two or moretopaths. Decode reads every copy and throws unless they are deeply equal, since copies edited apart have no single preimage. Before this, one value could not be written to two places at all:validateCrosswalkrejects two rules reading the samefrom.The executor now reads every read-side path of a rule, pairs the matches element by element (throwing when the paths address different elements), and writes each result to its write-side path.
ruleSideslists a rule's paths for the executor and forvalidateCrosswalk, which applies the wildcard, uniqueness and array-feeding checks to every path and requires a template's fields to come from the same element. The single-path ops go through the same loop unchanged.Stacked on #53. The new tests were checked to discriminate by reverting the render check, the copy equality check, the element pairing check, the shared-array validation, the adjacency check and the empty-array materialisation on every write path.
pnpm run prepublishOnlypasses locally.Fixes #36
Fixes #45