Skip to content

Add schema versioning for expressions#54

Open
robertvansteen wants to merge 4 commits into
0.xfrom
claude/strict-type-mode-KZpqa
Open

Add schema versioning for expressions#54
robertvansteen wants to merge 4 commits into
0.xfrom
claude/strict-type-mode-KZpqa

Conversation

@robertvansteen
Copy link
Copy Markdown
Contributor

@robertvansteen robertvansteen commented May 5, 2026

Persisted source trees now carry a SchemaVersion so future behavior changes (planned: strict typing in V2) won't silently change the meaning of existing schemas.

  • SchemaVersion enum (V1 only for now)
  • Schema envelope pairing a version with a Source tree
  • ResolverPreset builder owns version-sensitive resolver/overloader/matcher
    bindings; consumers can extend with custom source types and matchers
    but cannot override version-locked bindings (throws)
  • Expression::fromSchema() factory derives the resolver stack from the
    envelope's version via the preset; the legacy constructor still works
    but does not provide version guarantees

V2 (StrictValueResolver, preflight typing) lands in a follow-up PR.

https://claude.ai/code/session_01Mc5Bp2XTGyNTwNUXjxyuDR

claude added 4 commits May 5, 2026 06:32
Persisted source trees now carry a SchemaVersion so future behavior
changes (planned: strict typing in V2) won't silently change the
meaning of existing schemas.

- SchemaVersion enum (V1 only for now)
- Schema envelope pairing a version with a Source tree
- ResolverPreset builder owns version-sensitive resolver/overloader/matcher
  bindings; consumers can extend with custom source types and matchers
  but cannot override version-locked bindings (throws)
- Expression::fromSchema() factory derives the resolver stack from the
  envelope's version via the preset; the legacy constructor still works
  but does not provide version guarantees

V2 (StrictValueResolver, preflight typing) lands in a follow-up PR.

https://claude.ai/code/session_01Mc5Bp2XTGyNTwNUXjxyuDR
Lead all Quick Start examples with Schema + Expression::fromSchema()
instead of manual DelegatingResolver wiring. Add an "Extending the
resolver preset" section showing the customize closure as the way to
plug in custom resolvers, matchers, and overloaders.

Add "Schema and SchemaVersion" and "Persisting and replaying schemas"
subsections to Core Concepts, covering version semantics and codec
patterns (PHP serialize for caches, tagged JSON for durable storage,
tryFrom for forward-compatible decoders).

Move the manual DelegatingResolver wiring example to "Manual resolver
wiring (escape hatch)" under Advanced Usage with a note that it does
not provide version guarantees.

https://claude.ai/code/session_01Mc5Bp2XTGyNTwNUXjxyuDR
Make the schema-versioning narrative abstract and non-time-bound:
describe the version contract in terms of the general guarantee
(each enum case pins a coherent set of resolver semantics; new
cases are added when behavior would otherwise drift) rather than
naming a specific upcoming version or behavior change.

https://claude.ai/code/session_01Mc5Bp2XTGyNTwNUXjxyuDR
ExpressionFromSchemaTest is risky on prefer-lowest because every
fromSchema() call constructs an ExpressionMatcher via ResolverPreset::build()
but the class isn't declared in #[UsesClass]. Add the attribute so PHPUnit's
strict coverage metadata mode is satisfied.

Also add a test that resolves a MatchExpression through the default V1
preset using both LiteralPattern and WildcardPattern arms. This exercises
the default WildcardMatcher and LiteralMatcher wired by build(), killing
three escaped mutations that removed or trimmed the defaultMatchers list.

https://claude.ai/code/session_01Mc5Bp2XTGyNTwNUXjxyuDR
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.

2 participants