Skip to content

feat: schemas - #7

Merged
fahad19 merged 21 commits into
mainfrom
schemas-package
Nov 30, 2026
Merged

fahad19 merged 21 commits into
mainfrom
schemas-package

Conversation

@fahad19

@fahad19 fahad19 commented Nov 30, 2026

Copy link
Copy Markdown
Member

Datafiles can carry sections beside the SDK's own keys, such as
schemas. The SDK now keeps them through every replace and merge,
merging a section by entry as segments merge, and datafile_set details
list the changed entries of each section.

The module API gains getEntry, getEntryKeys and matchConditions. The
last answers a package's conditions, as JSON text or trees, with the
instance's engine, in one dependency session whose root is the
package's entry, and reads leaves only the package knows, such as
input, through readers that tell an absent value from null.
Readers return MISSING for no value, and the session names a package
entry as {type, key}.

The new featurevisor.schemas subpackage validates data against those
schemas with the rules, messages, mutations and issues of
@featurevisor/schemas, and describes fields for forms through
handles, with validate and avalidate for checks in code.

It passes the 85 cases of conformance/schemas-validation.json twice
and matches the JavaScript package on a datafile the CLI built, issues,
messages and handle members included. A schema that references itself
follows the value, and one that loops fails closed after 128 nested
references with schema_reference_depth.
…t does

Without the m flag, $ now matches only at the end of a value, never
before a final line break. \s and \S follow JavaScript's whitespace, with
the BOM and without U+001C to U+001F, and without the s flag a dot refuses
only JavaScript's line terminators. Numbers compare as doubles, so integers
above 2^53 that JavaScript cannot tell apart are equal. sdk-conditions.json
pins each, and sdk-package-conditions.json now runs match_conditions with
readers.
…cript does

Patterns now mean what JavaScript means with the u flag, so what u
rejects, such as an escape without a meaning or a lone brace, fails every
value, and \u{...} escapes compile. format holds issue entries back, and
additionalProperties other than true or a schema takes no extra key. The
conformance runner checks diagnostics, and the differential test reads the
shared schemas-datafile.json instead of its own copies.
The module API's evaluate runs every module's beforeEvaluation for a
package's own entry, with the entry's type and key, and answers the
conditions its callback matches with the context the modules leave, in
one dependency session. Schemas validate and describe views inside it,
so context a module adds reaches mutations and issue entries as it
reaches flags. Nested feature and variable reads never carry the
package's key.

The shared fixtures gain package condition cases with a module that
adds context, and drop the case that counted references at one value
to exactly 128.
The test runner asks for schema specs and validates each assertion's
value as the JavaScript CLI does, against the datafile of its
environment and Target, under its context. A Node.js CLI from before
schema specs rejects the option, so the runner asks again without it.
…once

The modules manager records which phases its modules take part in, so
evaluations skip before and after evaluation, bucket key and bucket
value when no module has them. A module that only reads the datafile,
such as the schemas package's, no longer makes flags slower. Package
conditions given as JSON text are parsed once per datafile, with
conditions_parse_error reported for text that does not parse, and the
cache is cleared when it reaches 1000 entries.

Two mypy errors from the last round are fixed: a schemas run always has
a matcher, and the tester no longer reuses a name for another type.
The README now has the JavaScript SDK page's sections in its order:
install, create an instance with an options table, context, flags,
variations and variables with typed methods and composition, default
values, evaluating everything at once, sticky values, datafile updates
with merging and an interval refresh, child instances, events,
diagnostics, evaluation details with the reasons table, modules, and
schemas from creating an instance to patterns. Examples use the docs'
running example, checkout, pricing, buyButton and supportEmail for
user-4 in the Netherlands, and the signUp schema, so each page reads
like the others in its own language. The README test reads the example
under its new heading.
context_set details now carry keys, the top level keys whose values
changed, compared by value: numbers by numeric value, though a bool is
never a number, dicts key by key and lists item by item, with a dict or
list given again as the same object counted as changed, and every key
when the stored context itself comes back. A merge compares only the
keys it carries, a replace every key of either context, and a child its
own context. The keys are worked out only when a listener or a debug
diagnostic receiver reads them.

datafile_set details now carry segments, the segments whose definitions
were added, changed or, on replace, removed, which the SDK already
worked out to find the features and variables they affect.

conformance/sdk-events.json pins both, as in JavaScript, and the README
documents them as the JavaScript page does. Its contents list links
datafile_set by GitHub's anchor.
set_datafile worked out the changed features, variables, segments and
sections, and their dependency closure, on every call, even when no
listener and no diagnostic at info received them. It now does only when
a datafile_set listener, a child's among them, or an info diagnostic
receiver exists, and otherwise skips the details, the diagnostic and the
event, and the new provider keeps no dependency index, which the next
update that is read builds again from the datafile it has. What the SDK
answers is unchanged, and so are the details whenever someone receives
them.

The incremental index tests subscribe a listener, since only then is
there an index to inspect.
…les internal

The JavaScript package exports none of them. fields gives the fields' handles, each with its name, and validate is the one way to validate.
…called

JavaScript keeps both for its React hooks, and Python has none.
… only

The instance's avalidate answered as validate does, since its handles have no checks, and aparse was a second asynchronous way to parse.
The shared fixture's sign up form gives accountType and a newsletter box a default, which the business mutation turns off, and the built datafile test reads both.
The README says what default is and that a handle from with input has the one a mutation sets, as the JavaScript page does.
…and unlisted fields come in name order

An issues entry waited for any issue of shape in its object. It now waits only while one sits at or inside its path, or anywhere in the object without a path, or in a field its conditions read, as JavaScript's does. Fields an order leaves out come in name order by Unicode code point, and the built datafile test compares field order exactly. The README says Schemas are experimental, as JavaScript's does, and that unlisted fields come in name order.
The JavaScript package was simplified for review with no change in behaviour, and this port follows it where it has the same structure: one position for report, an issue entry's path split once, inputsOf keeping only strings, a oneOf branch chosen from a map of kinds, attribution worked out once per issue, and one classifier for path steps. Compiled validators and mutated rules are kept per instance by node, in two generations, so an unchanged schema keeps its validator across a datafile change while memory holds two datafiles at most.

An application or form message that is neither text nor a function is passed over, and child gives a key such as 2fa the handle at gives, each with a test. The shared schemas-validation.json gains two cases for a field a mutation adds by schema reference, which pass. The README follows the JavaScript page: the data is value beside the handle, Follow the values typed so far comes after Read annotations, Check in code names its optional fields, and the constraints and options rows say which member is keyed by field path.
The Modules section said beforeEvaluation and afterEvaluation run for flags,
variations and both kinds of variable, while a schema validation also
runs every module's beforeEvaluation, with type and key naming the
schema instead of a feature key, and never runs afterEvaluation. It now
says so, and to check the type before reading the keys, as the JavaScript
SDK's page does.
A schema used twice, such as an address for billing and for shipping, lost
its constraints and choices the second time, since walks stopped at any
schema already seen. The port now follows the JavaScript package's release
fixes. Walks guard only the current path, and kind stops on a list of itself.
A missing field reports no missing schema, the message translator runs last,
and required applies without properties. A value nested more than 128
references deep fails closed at the 129th, and a check that throws fails
closed with schema_check_error. Every diagnostic's dedupe resets with a new
datafile, no handle is kept for a key the datafile lacks, patterns compile
once into a cache capped at 4096 that holds failures, and an unknown type
fails every value.

Both conformance fixtures are copied again from the monorepo, with 150
validation cases and an address schema used twice. The README says how a
field's handle treats a missing value and when schema_check_error is
reported, and gives no minimum CLI version.

An integer too large for a double now fails as Infinity does rather than
raising OverflowError, and a deeply nested value is read without recursion,
so it no longer raises RecursionError. Caches rotate on datafile_set, a
view's memo follows the context and sticky values, and the README's stale
second Schemas section is gone.
Test specs already use at for a bucket position, and schema specs may need
it too once their conditions read rollouts, so at(path) on a handle read as
one more meaning of the same word. The port follows the JavaScript package:
field(path) pairs with fields and is what the docs call the result, a
field's handle. Nothing is released yet, so the rename needs no deprecation.
The README's Schemas section, the tests and the comments say field now.
…as, not kind

kind named what a field's rules say it renders as, such as select or list,
but the word told a reader nothing without the docs and already names
condition kinds. The port follows the JavaScript package, which calls it
renderAs. The values are unchanged, and nothing is released yet, so the
rename needs no deprecation.

The handle's property is render_as. The README's Schemas section, the
tests, the comments and the datafile fixture, whose member is renderAs,
follow.
4.1.0 ships the extension seam and the schemas subpackage, as each SDK's
next minor does. pyproject.toml says 4.1.0, which the publish workflow
checks against the tag, and the README's release note names it.
@fahad19 fahad19 self-assigned this Nov 30, 2026
@fahad19
fahad19 merged commit c2386b6 into main Nov 30, 2026
8 checks passed
@fahad19
fahad19 deleted the schemas-package branch November 30, 2026 23: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