v3: Declarative constraint engine, forward check, and FNV-1a hash sorter#43
Merged
v3: Declarative constraint engine, forward check, and FNV-1a hash sorter#43
Conversation
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.
v3: Declarative Constraint Engine + FNV-1a Hash Sorter
TypeScript: v3 Core
Declarative constraints (
constraints: Condition[])eq,ne,gt,lt,gte,lte,in), logical (and,or,not), andcustom(escape hatch with dependency keys)target(e.g.{ operator: 'ne', field: 'A', target: 'B' })Comparerinterface to override comparison behaviorpreFilter/postFilterfunction-based approachThree-valued evaluation (
evaluate.ts)true(satisfied),false(violated),null(deferred — field not yet set)extractKeys()for dependency tracking per conditionfalse, OR short-circuits ontrue, NOT propagatesnullForward check (constraint propagation)
falseimmediately when any domain emptiesController rewrite
setPair()— snapshot-based validation; row unchanged on failurestorableCheck()/markPassedConstraints()withpassedIndexesoptimizationRow.invalidPairs— prevents greedy from re-attempting failed pairsclose()rewritten with depth-first backtracking returningconflictKeysstatsgetter:totalPairs,prunedPairs,coveredPairs,progress,rowCount,uncoveredPairs,completionsisCompletetreatsnullas satisfied (null tolerance)diagnoseUncoveredPairs()for constraint failure reportingGreedy criterion optimization
arr[i] * arr[j](4x speedup on hot path)rowCoveredexclusion setinvalidPairsskipisCompatible()fast check before fullstorable()PictModel rewrite
_modelConstraints()converts lexer filters + negative rules toCondition[]_buildOptions()passesconstraints(notpreFilter)_applyNegativePrefix()for~outputstats/progressgetters#) in constraint section ignoredBuild tooling: webpack → vite, tslint removed, pnpm
Python: v3 Port
All TypeScript v3 features ported:
evaluate.py— Three-valued constraint evaluation (same Kleene logic)constraints/comparerparams,set_pair(),_forward_check(),_storable_check(),_mark_passed_constraints(), two-pass pruning,Row.invalid_pairs, rescue phase,_close()with backtracking,stats, null-tolerantis_complete,_diagnose_uncovered_pairs()row_covered,invalid_pairsskip,is_compatible()_model_constraints(),_apply_negative_prefix(),stats/progress, comment ignorefilter_keystracking for dependency-aware constraint indexingpre_filter/post_filterstill work;constraintsis optionalFNV-1a Hash Sorter
hashlibin Python,md5/ts-md5in TypeScript)