Repository navigation
feat(python): read and enforce the reference facet in the Python loader - #698
Merged
Merged
Conversation
The spec reader validates `ref` on an attr entry and carries it to AttrSchema.ref; the registry-derived walk enforces it through a kind-typed symbol table (System.child, pkg::System.child, bare values found in the referrer's containers first, untyped lookup only for the wrong-kind code); the reference pass binds facet attributes to the walked path and keeps a value as written when its canonical spelling would not reload to the same target; the registry manifest writes `ref` only when present. Provider codes keep their spelling in MetaError.provider_code. Mirrors the TypeScript and C# loaders; no definition file uses the facet, so no registry, manifest or generated output changes.
… code Review finding from the first gate run: both still formatted MetaError.code, so a facet's own code (code ERR_UNKNOWN plus provider_code) printed as ERR_UNKNOWN.
# Conflicts: # spec/metamodel-definitions.md
# Conflicts: # spec/metamodel-definitions.md
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.
What Changed
refon atype: "attr"entry in a provider definition) and carries it toAttrSchema.ref.resolve_referencestakes an optional registry and resolves facet attributes through a newSymbolTable(loader/symbol_table.py). Unresolved, wrong-kind, and cross-system values are refused (ERR_REF_UNRESOLVED,ERR_REF_WRONG_KIND). Canonical values are the path the lookup walked; values that would not re-resolve to the same target are kept as written.ReferenceDescriptorbecomes(attr, facet), withtarget_type,error_code,target_sub_types, andfield_pathmoved ontoReferenceFacet.SymbolTablemoves fromregistered_validationtoloader/symbol_table.py. The registry manifest writesrefonly on attributes that declare one. A provider's own non-ErrorCodecode keeps its spelling inMetaError.provider_code.tests/unit/test_reference_facet.pyand thechangelog.d/python-reference-facet.mdentry.spec/metamodel-definitions.mdis updated to match. No definition file uses the facet yet, so no generated output changes.Validation
Risk Assessment
✅ Low: approval carried from an earlier review
Testing
Broad regression came from the configured test command
scripts/ci-local.sh --affected --strict-toolchains, which passed at this target commit. Here I drove two scenarios. The valid loader code is accepted, and the trailing-newline code is refused with a ValueError. The 48 focused reference-facet unit tests pass. No source changed in this turn, so the broad run was not repeated. No background processes were started.Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
♻️ **Review** - review carried from run 01M8XQ5PD53YN9BK42T2MK7S5Y at 348c635 (no new branch work since the approved head; the base changes merged since touch no reviewed code)
♻️ review carried from run 01M8XQ5PD53YN9BK42T2MK7S5Y at 348c635 (no new branch work since the approved head; the base changes merged since touch no reviewed code)
✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainscd server/python && python3 -m pytest tests/unit/test_reference_facet.py -q (48 passed)PYTHONPATH=src python3 -c importing metaobjects.spec_metamodel._to_reference_facet and calling it with errorCode 'ERR_X' (accepted) and 'ERR_X\n' (refused)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.