Repository navigation
Stringent v2: arktype-based type system and grammar compilation - #5
Closed
eralmansouri wants to merge 1 commit into
Closed
eralmansouri wants to merge 1 commit into
eralmansouri wants to merge 1 commit into
Conversation
eralmansouri
pushed a commit
that referenced
this pull request
Jul 7, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GQrzid8mJPWM4HMb6Cf6C
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GQrzid8mJPWM4HMb6Cf6C
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.
Summary
This PR implements Stringent v2, a major redesign that replaces the custom type vocabulary system with arktype as the runtime type engine, adds compile-time grammar validation, and derives associativity from pattern shape rather than explicit configuration.
Key Changes
Type System (arktype integration)
extendsoperator (directional subtype check) and a newoverlaps()function for symmetric equality-style operators.sameAs()andfromBinding()are replaced with plain string references to earlier bindings in the pattern.type.validate()and at runtime by compiling the def. Identifier/path resolution uses arktype'sType.get()instead of hand-rolled traversal.createParser()accepts ascopeoption to extend the type vocabulary with user-defined aliases, making arktype's keyword library (string.email,number.integer, etc.) available in constraints.Grammar Compilation (
src/runtime/compile.ts)rhs()) → right-associative; tail at tighter level (lhs()) or closed pattern → left-associative fold.Parser Runtime (
src/runtime/parser.ts)OUTPUT_TYPE): parsed subexpressions carry their arktype Type non-enumerably so constraint checks compose without polluting the serializable AST.ParseEnvobject containing the compiled grammar, schema Type, and diagnostics, replacing scattered parameters.Type-Level Engine (
src/parse/index.ts)type.infer<"number > 0">automatically reduces tonumberfor constraint matching.safeParseor cast).Schema & Node Definition
precedence: "atom"sentinel: precedence is now a plain number; the highest precedence level is the leaf level.associativityproperty: derived from pattern tail shape instead.overlapping()function: symmetric constraint for equality operators (checks type overlap, not subtype).true,false,null,undefinedadded alongside number/string.\n \t \r \\ \" \' \0 \b \f \v \xHH \uHHHHescapes.API Changes
createParser()no longer exposestypeNamesproperty; type vocabulary is now implicit in the scope.InferValues<TSchema>now delegates totype.infer<TSchema>instead of custom recursion.Testing & Documentation
src/types.typetest.ts)https://claude.ai/code/session_017GQrzid8mJPWM4HMb6Cf6C