W5b-1: immutable schema (C7) + no compat re-exports (C13) - #41
Merged
Merged
Conversation
set_constraints becomes a real __init__ parameter (default ()) so the frozen-dataclass clone is the idiomatic replace(self, set_constraints=frozen_tuple); the __new__ + object.__setattr__ copy loop is gone.
This was referenced Sep 18, 2026
bnsd55
added a commit
that referenced
this pull request
Sep 19, 2026
…metry in W5-D tests, CalibrationBundle in openai path - _prior_cache_key no longer puts weakref.ref objects in the key tuple: hash(ref) delegates to the referent and mlx models are unhashable, so every prior-corrected run crashed with TypeError. Key by ids (refs stay alongside the value for the live check). Pre-existing on merged main 649ba70 — reproduced on a clean checkout. - openai_slots._decide_multi_field consumes the typed CalibrationBundle - test_w5d count-row test reads internal_telemetry (finding 24) - rebased onto 2500cf5 (PRs 37, 41, 42-44): compile_set_constraints keeps the frozen dataclasses.replace contract; satisfiability check = solver
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.
Implements GPT-REVIEW-2 section C items 7 and 13 on
w5b-immutable, rebased on origin/main 649ba70 (post-#37/#38/#39 merges).C7 — StructuredSchema / FieldDefinition immutable after construction
FieldDefinitionis a frozen slots dataclass: every attribute set exactly once at construction; mutation raisesFrozenInstanceError(dataclasses.FrozenInstanceErrorvia the slots descriptors).choicesis a tuple (copied from the caller's list),choice_descriptionsa MappingProxyType over a copy,set_constraintsa tuple of MappingProxyType constraint views — validated copies, nothing caller-mutable reachable.compile_set_constraints(constraints)validates exactly as before (same SchemaCompileError set: unknown types, non-multi fields, implies cycles, cross-group contradictions, exact_k=0 exclusions) and returns a NEW frozen field (validated deep-frozen constraints);StructuredSchema.__init__swaps it into the dict.compile_set_constraints(None)returns the same field.compile_set_constraintsitself is otherwise untouched for coder3's W5-C.StructuredSchema.fieldsis exposed as a read-only mapping (insert/delete/clear/pop raise TypeError/AttributeError);__getitem__/__len__unchanged.compile_slot_plan/compile_labels_planand their cache) are deep-frozen once at compile time (_freeze_plan: dicts→MappingProxyType, lists→tuples). Cache identity is preserved — the cached object IS the frozen one, so cache-hit tests still assertis. Consumers see identical content; the engine's row-assembly concatenations now wrap plan reads inlist(...)(4 sites).plan_hashnow thaws the frozen plan (mappingproxy→dict) before hashing: the stdlibdefault=listpath silently collapsed mappingproxies to their key lists, which hashed slots and labels plans identically — the existing mode-sensitivity test caught this.to_dict()unchanged in shape (returns plain copies).C13 — api.py: zero backward-compatibility re-exports
__all__entries forresolve_model/MODEL_ALIASES(jevmlx.modelsis the import home; ARCHITECTURE rule "no backward compatibility" stays).api.__all__now lists exactly the API's own surface (decide,decide_many,schema_from_model,Decision,FieldResult,NONE_OF_ABOVE,NONE_OF_ABOVE_DESCRIPTION,DEFAULT_MODEL).api.py's unusedMODEL_ALIASES/resolve_modelimports; updated the one stale docstring pointer (jevmlx.api.resolve_model→jevmlx.models.resolve_modelin engine.py). No callers referenced the deleted re-exports (verified repo-wide).Tests
tests/test_w5b1_immutable.py(12 tests): attribute/choices/descriptions/fields mutation raises; caller dicts not shared; set-constraints frozen + caller copies; compile returns new frozen field / same field on None; plans read-only incl. count sub-plan; cache identity on frozen plans; C13__all__contract.test_trie.py,test_multi.py,test_w2e_rowcodes.py,test_w2c_codebook.py,test_w5a.py,test_api.py,test_w2_setcons.py).parity_real_model_twin, 0.071 vs 0.05s perf bound) reproduces on cleanorigin/main— pre-existing, not from this branch.Coordination
compile_set_constraintstouched only to freeze its output (per the W5-C/coder3 note); its validation logic is byte-identical.origin/main649ba70 after W5-D's engine changes; the single conflict was my docstring pointer against the rewritten_load_engine_resolveddocstring — resolved by keeping W5-D's text and re-adding the pointer.