jacopy.PropertyRegistry¶
- class jacopy.PropertyRegistry(*, strict_axioms_only=False)¶
Bases:
objectStores properties keyed by expression, class, or predicate.
Lookup order in
get():Exact expression match.
Class-based: walks
type.__mro__from most specific toExpr.Predicate-based: first registered predicate whose property type matches wins.
An expression or class may hold multiple distinct property types, but at most one of any given property-type from the same source (exact / class / predicate). Duplicate declarations at the same source raise
ValueError, the intended fix is an explicitretract().- Parameters:
strict_axioms_only (bool)
Methods
__init__(*[, strict_axioms_only])all_for(expr)Yield every property visible for
expr(after filters).axioms(allowed)Narrow the visible property types to
allowedduring the block.declare(expr, prop)Attach
propto the exact expressionexpr.declare_for_class(cls, prop)Attach
propto every instance ofcls(subclasses inherit).declare_for_predicate(predicate, prop)Attach
propto every expression satisfyingpredicate.get(expr, prop_cls)Return the property of type
prop_clsonexpr, orNone.has(expr, prop_cls)lookup(expr, prop_cls, *[, record])The
Declaration(prop, level, rank)of the RAW declaration (no visibility filter, no shadowing) that answersprop_clsforexpr:levelis"exact","class"or"predicate",rankthe comparable specificity tuple (smaller = more specific; class level carries the MRO depth), or(None, None, None).peek(expr, prop_cls)get()'s answer WITHOUT recording a read: a pre-filter for a caller whose result depends only on a POSITIVE answer, which it then re-queries withget()so the answer becomes the step's hypothesis (negative answers do not pile up).retract(expr, prop_cls)Remove the exact-expression property of type
prop_cls.retract_for_class(cls, prop_cls)scope()Roll back every registry mutation made inside the block.
set_strict(strict)Suspend read recording on this thread for the block (the model oracle restates registry data without minting hypotheses;
peek()).Attributes
everything visible) — public read access for independent restatements of the visibility rule (the model oracle).
strict_axioms_only- property axiom_whitelist: Set[type] | None¶
everything visible) — public read access for independent restatements of the visibility rule (the model oracle).
- Type:
The active
axioms()whitelist (None
- declare(expr, prop)¶
Attach
propto the exact expressionexpr.- Parameters:
expr (Expr)
prop (Property)
- Return type:
None
- lookup(expr, prop_cls, *, record=False)¶
The
Declaration(prop, level, rank)of the RAW declaration (no visibility filter, no shadowing) that answersprop_clsforexpr:levelis"exact","class"or"predicate",rankthe comparable specificity tuple (smaller = more specific; class level carries the MRO depth), or(None, None, None). Public read access to the declaration data for consumers that must restate the Scalar contract independently (the model oracle) or decide it on the raw answers (the predicate’s clash check: a visibility filter never turns a declared graded element into a constant). Withrecord=Truethe raw answer is appended to the open read log as a RAW fact — a hypothesis checked against the raw declarations of the citing registry.
- retract(expr, prop_cls)¶
Remove the exact-expression property of type
prop_cls. A retract that would EXPOSE a Scalar contradiction (the removed declaration was shadowing one, or was theGraded(0)hiding a class-levelGraded(k)) is refused and leaves the registry unchanged.
- declare_for_class(cls, prop)¶
Attach
propto every instance ofcls(subclasses inherit).Exact-expression declarations still take priority over class-based ones. An explicit
retract()on a particular expression does NOT remove the class-based fallback, it only clears an exact binding.
- declare_for_predicate(predicate, prop)¶
Attach
propto every expression satisfyingpredicate.Predicates are matched in registration order; the first matching entry whose property type is being queried wins. Use sparingly, a badly-written predicate is the usual way to silently poison a registry.
- get(expr, prop_cls)¶
Return the property of type
prop_clsonexpr, orNone.Lookup cascades: exact → class (MRO) → predicate. The first hit, after applying visibility filters, is returned — except that a class/predicate-level
Scalarshadowed by a strictly more specificGraded/NonCommuting/AntiCommutingdeclaration answersNone(the Scalar contract’s specificity rule).
- peek(expr, prop_cls)¶
get()’s answer WITHOUT recording a read: a pre-filter for a caller whose result depends only on a POSITIVE answer, which it then re-queries withget()so the answer becomes the step’s hypothesis (negative answers do not pile up).
- untracked()¶
Suspend read recording on this thread for the block (the model oracle restates registry data without minting hypotheses;
peek()).
- all_for(expr)¶
Yield every property visible for
expr(after filters).Collects candidate property types across all three sources and resolves each via
get()so priority and filters apply uniformly.
- scope()¶
Roll back every registry mutation made inside the block.
Designed for hypothetical edits: declare a property, run a proof, and have the declaration vanish afterwards even if the proof raised. Safe to nest.
- axioms(allowed)¶
Narrow the visible property types to
allowedduring the block.Within the block,
get()returnsNonefor any property whose type is not inallowed, as if it had not been declared. Complementsstrict_axioms_only, which filters by provenance rather than type.Nests correctly: an inner
axioms()overrides the outer whitelist for its scope and restores on exit.