Astral Primitives
mismatched concrete subclass discriminators raise ValidationError; valid wire round trips remain unchanged.
Composable, serializable UI primitives for Python. Describe UI as plain Python
objects, then serialize them to a dict/JSON for storage or for a server-driven
UI to render.
Install
pip install -e ".[dev]" # editable install with test deps
Quick start
from astralprims import Button
button = Button(
label="the button text",
action="open",
css={"background-color": "white", "color": "#000000"},
)
button.to_dict()
# {
# "type": "button",
# "css": {"background-color": "white", "color": "#000000"},
# "label": "the button text",
# "action": "open",
# "payload": {},
# "variant": "primary",
# }
button.to_json() # -> JSON string
None and empty css are dropped from the output, so payloads stay clean.
Composing layouts
from astralprims import Card, Container, Text, Button
page = Container(css={"display": "flex"}, direction="column").add(
Text(content="Welcome", variant="h1"),
Card(title="Sign up").add(
Text(content="Enter your details below."),
Button(label="Get started", action="signup"),
),
)
page.to_dict() # children/content serialize recursively
Round-tripping from data
Already have a primitive as a dict (from storage or an API)? Rebuild it —
including the full nested tree:
from astralprims import Primitive
spec = {"type": "button", "label": "Buy", "action": "checkout"}
button = Primitive.from_dict(spec) # -> Button(...)
Child dictionary compatibility in 0.7.0
Every child mapping in Container.children, Card.content, Grids.children,
Collapsible.content, TabItem.content and ActionGroup.buttons must carry a
registered, non-empty string type. Missing, empty, malformed and unknown
discriminators raise a Pydantic ValidationError instead of producing an empty
generic primitive. This narrows accepted input and therefore bumps the minor version.
Tagged children retain their concrete type and fields across lists, tuples, deques
and generators, including mapping wrappers. Existing primitive instances retain
their identity. Valid serialized wire dictionaries, aliases, defaults and trusted
attributes precedence remain unchanged; callers using untagged child dictionaries
must add the intended concrete type before upgrading.
Fluent addition compatibility in 0.10.0
Container.add(), Card.add() and Grids.add() (also Grid.add()) validate
every supplied child before changing the existing collection. They accept
primitive instances and tagged mappings, including mapping wrappers, using the
same concrete-type validation as constructors. Invalid scalars, untagged mappings,
malformed or unknown types, and invalid nested children raise ValueError without
partially adding valid siblings or replacing the existing collection.
Valid additions remain chainable, preserve existing primitive identities and
retain serialized defaults, aliases and trusted attributes precedence. Calling
add() without arguments leaves the tree unchanged. Rejecting previously accepted
invalid children narrows the Python API and therefore bumps the minor version;
callers must supply valid primitive instances or tagged mappings when upgrading.
Finite-number compatibility in 0.9.0
Wire serialization rejects NaN, positive infinity and negative infinity with a
field path. The check applies to to_dict(), model_dump(), to_json() and
from_dict(), including nested charts, payloads, trusted attributes, numeric
mapping keys, models and dataclasses after their serializers expand them.
to_json(allow_nan=True) raises
ValueError; callers cannot opt into non-standard numeric tokens.
This narrows accepted input and therefore bumps the minor version. Finite numbers, serialized defaults, aliases, omission rules and trusted attributes precedence retain their existing wire representation. Consumers adopting this package must replace non-finite values with an application-defined finite or nullable value before crossing the wire boundary. This policy does not introduce conversions for other Python objects that standard JSON cannot encode.
JSON-native values in 0.11.0
Arbitrary-valued wire slots (payload, attributes, Table.rows,
Table.source_params, chart datasets, and every other Any-typed field) now
serialize to plain JSON-native values, so to_dict() output is always
JSON-compatible and json.loads(to_json()) equals to_dict(). Accepted
conversions: datetime, date and time become ISO 8601 strings, UUID and
Decimal become strings, bytes and bytearray must decode as UTF-8 and
become strings, and tuples, sets and frozensets become arrays in iteration
order. Non-string mapping keys are stringified with the standard JSON encoding
(2 to "2", 2.5 to "2.5", true to "true", false to "false",
null to "null"); mapping keys of any other type are rejected.
Values that no conversion accepts —arbitrary objects, complex, timedelta,
plain Enum members, non-UTF-8 bytes, and unsupported mapping keys —raise
ValueError naming the type and field path at serialization time, the same
contract as the finite-number policy, instead of failing in a transport encoder.
The policy applies to to_dict(), model_dump(), to_json() and from_dict(),
including nested primitives, models and dataclasses after their serializers
expand them. from_dict() applies the same normalization to its input, and
callers needing the previous Python objects must convert them before
serialization or keep them outside the wire fields.
Trusted attributes keep their merge-last precedence over declared fields, and
accepted conversions apply to the merged values. JSON-native values, serialized
defaults, aliases and omission rules keep their existing wire representation.
Changing the emitted wire values for previously accepted Python objects is a
serialization-contract change and therefore bumps the minor version.
Schemas, generation and A2UI
schema/astralprims.wire.json is the committed, versioned wire schema. schema/astralprims.generation.strict.json is the strict generation profile for decoding grammars: every object is closed, every string, list and number is bounded, and images, audio and download targets are {"handle": ...} objects. a2ui/catalog.json publishes the strict vocabulary as an A2UI v1.0 catalog. Run python scripts/generate_schemas.py to rewrite all three. --check fails when one is stale.
from astralprims import StaticResolver, validate_generated, strict_schema
resolver = StaticResolver(events={"ev1": {"bp": 120}}, capabilities={"cap1"}, handles={"img1"})
errors = validate_generated(tree, resolver) # each error has path, problem and a valid example
validate_generated checks the strict profile plus these rules. A binding {"bind": {"event", "path"}} must resolve. An action capability must be one the surface created. Actionable components (button, input, param_picker, file_upload, color_picker) need capability, accessible_name, spoken and compact, and action_group needs the three forms. Text may not carry links, HTML or reference definitions. Generated nodes may only claim provenance of model, with tool, host and external stamped by trusted code. Trees stay within 8 levels and 300 nodes.
The same fields exist on the permissive models and are omitted when unset: accessible_name, spoken, compact, provenance, capability, source (image, audio) and target (download). Text, alert, badge, metric, progress, gauge and rating values may be a binding.
from_a2ui(messages) imports an A2UI v1.0 surface as primitives. Every node is marked external, unsupported components become muted text, and URLs, styles and capabilities are dropped. to_a2ui(tree, surface_id, catalog="astral" | "basic") exports a tree. The Astral export keeps only fields the catalog defines.
The catalog and exports are checked against the stable A2UI 1.0 schemas at upstream commit 8bf644a, following the November 11, 2026 release. The offline test fixtures retain their upstream license and source identity. Catalog metadata uses metadata.extensions, and anyFunction: false declares that this adapter exposes no RPC functions. Basic-catalog text uses its supported body and caption variants; the Astral catalog preserves richer variants.
Review primitives in 0.12.0
Two primitives describe agent-made changes and structured review findings.
Diff (wire type diff) carries files, each with old_path, new_path, a
status of added/modified/deleted/renamed, a binary marker for files without
hunks, and hunks. Every hunk has a required stable id, an old and new range,
lines typed context, add or delete with optional old_line/new_line
anchors, and optional actions carrying a declared action id and a payload.
Findings (wire type findings) carries findings of title, body, file,
start_line/end_line, a priority of P0-P3 (defaulting to P3), a category,
and an optional diff_ref citing a hunk id.
Counts are bounded: at most 40 files per diff, 40 hunks per file, 200 lines per
hunk and 50 findings. Oversized input is truncated at construction with the
matching truncated flag set on the diff, file, hunk or findings — never
silently dropped. Unknown line kinds, file statuses and priorities are refused
at construction, hunk ids must be non-empty and unique within a diff, and
finding line ranges must satisfy end_line >= start_line >= 0. Renderers,
revert actions and line comments key on the stable hunk ids and diff_ref
values. This release defines and serializes the vocabulary; rendering belongs
to AstralProjection, and diff/findings are not yet in its pinned
contracts/ui_protocol.json component list.
Shipping a response
from astralprims import create_ui_response, Text, Button
create_ui_response([Text(content="hi"), Button(label="ok", action="go")])
# {"_ui_components": [{...}, {...}], "_data": None}
A FastAPI endpoint can return primitive.to_dict() or create_ui_response(...)
directly.
Wire schema
Version 0.8.0 adds the public wire_schema() Python API. It describes the
existing serialized vocabulary; it does not add a primitive or change wire
output. Consumers adopt the new package release through their own version pins.
wire_schema() returns a JSON Schema (draft 2020-12) describing the canonical
to_dict() output of every built-in primitive in this release. Each wire type
gets an entry under $defs, and the root schema validates any serialized
component directly:
from astralprims import wire_schema
schema = wire_schema()
schema["x-astralprims-version"] # matches astralprims.__version__
schema["$defs"]["button"] # the wire shape of Button output
Fields set to None are omitted from wire output entirely, as is an empty
css block, so those properties do not accept an explicit top-level null
in the schema; nested values permitted by a field's own type, such as entries
in unconstrained lists or dictionaries, may still contain null.
Non-None defaults of declared wire properties are always emitted and appear
as the schema default of their property. attributes is a trusted escape
hatch merged last into the top-level object: extra keys are always accepted,
but overriding a declared key, including type, may intentionally produce
output outside this baseline schema. Validating output against this schema is
not sanitization, and never a security boundary, because attributes can
carry any trusted keys — only trusted data may enter it. Custom registered
primitives stay supported through Primitive.from_dict() but are not part of
this versioned baseline.
Built-in primitives
| Group | Primitives |
|---|---|
| Layout | Container, Card, Grid/Grids, Tabs (+ TabItem), Collapsible, Divider |
| Content | Text, Button, ActionGroup, Input, ParamPicker, Image, CodeBlock, Alert, ProgressBar, MetricCard, List_, Table |
| Charts | BarChart, LineChart, PieChart, DonutChart, RadarChart, PlotlyChart (+ ChartDataset) |
| Media/IO | Audio, FileUpload, FileDownload |
| Dashboard | Badge, Hero, KeyValue, Timeline, Rating, StatGroup, Gauge, PipelineStepper, ChatHistory |
| Review | Diff (+ DiffFile, DiffHunk, DiffLine, DiffAction), Findings (+ Finding) |
| Theming | ColorPicker, ThemeApply |
Composite readouts
Six types describe a whole readout rather than a single value, so a server can send the shape it means instead of assembling it from loose parts.
| Primitive | Wire type | What it carries |
|---|---|---|
ActionGroup |
action_group |
buttons (nested Button primitives), align (start/center/end/between), label for the group's accessible name |
StatGroup |
stat_group |
title, items of {label, value, delta?, trend?, hint?, variant?}, columns (clamped 1-6) |
Gauge |
gauge |
label, value on the same 0-1 scale as ProgressBar, display_value, ascending thresholds of {at, variant}, subtitle |
PipelineStepper |
pipeline_stepper |
title, steps of {label, status, detail?} where status is done/active/pending/error, orientation |
DonutChart |
donut_chart |
title, parallel labels/data, and center_label/center_value for the hole |
RadarChart |
radar_chart |
title, axes, datasets of {label, data} parallel to the axes, optional max_value |
from astralprims import ActionGroup, Button, Gauge, StatGroup
Gauge(label="Humidity", value=0.62, display_value="62%",
thresholds=[{"at": 0.0, "variant": "success"},
{"at": 0.8, "variant": "warning"}])
StatGroup(title="This week", columns=3, items=[
{"label": "Requests", "value": "1,284", "delta": "+12%", "trend": "up"},
{"label": "Errors", "value": "3", "trend": "down", "variant": "success"},
{"label": "p95", "value": "412 ms"},
])
ActionGroup(label="Result actions", align="end", buttons=[
Button(label="Save", action="save_result"),
Button(label="Export", action="export_result", variant="secondary"),
])
None of these carry a color. Variant strings name a semantic role and the renderer resolves it from the active theme.
Review primitives
Two types carry review of agent-made changes: a multi-file diff with hunks, and the structured findings that point back into it.
| Primitive | Wire type | What it carries |
|---|---|---|
Diff |
diff |
files of {old_path, new_path, status: added/modified/deleted/renamed, binary?, hunks}; each hunk has a stable id, old_start/old_lines/new_start/new_lines, lines of {kind: context/add/delete, content, old_line?, new_line?} and optional actions of {action, payload?}; counts are bounded with truncated flags on the diff, each file and each hunk |
Findings |
findings |
findings of {title, body, file, start_line, end_line, priority: P0-P3, category, diff_ref?} where diff_ref cites a hunk id; the count is bounded with a truncated flag |
from astralprims import Diff, DiffAction, DiffFile, DiffHunk, DiffLine, Finding, Findings
Diff(files=[
DiffFile(old_path="app.py", new_path="app.py", status="modified", hunks=[
DiffHunk(id="app.py:12", old_start=12, old_lines=2, new_start=12, new_lines=3, lines=[
DiffLine(kind="context", content="def main():", old_line=12, new_line=12),
DiffLine(kind="delete", content=" pass", old_line=13),
DiffLine(kind="add", content=" run()", new_line=13),
], actions=[DiffAction(action="revert_hunk", payload={"hunk_id": "app.py:12"})]),
]),
])
Findings(findings=[
Finding(title="Missing null check", body="config may be absent",
file="app.py", start_line=13, end_line=13, priority="P1",
category="correctness", diff_ref="app.py:12"),
])
Primitive reference
Every primitive serializes to a dict with its wire type first, then the common
fields, then its own fields. Fields left at None and an empty css are
dropped; every other default is emitted and is part of the wire contract. The
wire type does not always match the class name: CodeBlock is code,
ProgressBar is progress, MetricCard is metric, List_ is list,
KeyValue is keyvalue, and Grid is an alias of Grids, which is grid.
In a type, Primitive means any nested primitive; a nested dict is rebuilt as
the class registered for its type.
Common fields
| Field | Type | Default |
|---|---|---|
css |
Optional[Dict[str, str]] |
None |
id |
Optional[str] |
None |
class_name (wire class) |
Optional[str] |
None |
tooltip |
Optional[str] |
None |
accessible_name |
Optional[str] |
None |
spoken |
Optional[str] |
None |
compact |
Optional[str] |
None |
provenance |
Optional[Literal["model", "tool", "host", "external"]] |
None |
attributes |
Dict[str, Any] |
{} |
Primitives
| Class | Wire type | Field | Type | Default |
|---|---|---|---|---|
Container |
container |
children |
List[Primitive] |
[] |
direction |
Optional[str] |
None |
||
Card |
card |
title |
str |
"" |
content |
List[Primitive] |
[] |
||
variant |
str |
"default" |
||
Grids (alias Grid) |
grid |
columns |
int |
2 |
children |
List[Primitive] |
[] |
||
gap |
int |
20 |
||
Tabs |
tabs |
tabs |
List[TabItem] |
[] |
variant |
str |
"default" |
||
Collapsible |
collapsible |
title |
str |
"" |
content |
List[Primitive] |
[] |
||
default_open |
bool |
False |
||
Divider |
divider |
variant |
str |
"solid" |
Text |
text |
content |
Union[str, Binding] |
"" |
variant |
str |
"body" |
||
Button |
button |
label |
str |
"" |
action |
str |
"" |
||
payload |
Dict[str, Any] |
{} |
||
variant |
str |
"primary" |
||
capability |
Optional[Handle] |
None |
||
ActionGroup |
action_group |
buttons |
List[Primitive] |
[] |
align |
str |
"start" |
||
label |
Optional[str] |
None |
||
Input |
input |
placeholder |
str |
"" |
name |
str |
"" |
||
value |
str |
"" |
||
capability |
Optional[Handle] |
None |
||
ParamPicker |
param_picker |
title |
str |
"" |
description |
str |
"" |
||
fields |
List[Dict[str, Any]] |
[] |
||
submit_label |
str |
"Submit" |
||
submit_message_template |
str |
"" |
||
capability |
Optional[Handle] |
None |
||
Image |
image |
url |
str |
"" |
source |
Optional[Handle] |
None |
||
alt |
Optional[str] |
None |
||
width |
Optional[str] |
None |
||
height |
Optional[str] |
None |
||
CodeBlock |
code |
code |
str |
"" |
language |
str |
"text" |
||
show_line_numbers |
bool |
False |
||
Alert |
alert |
message |
Union[str, Binding] |
"" |
variant |
str |
"info" |
||
title |
Optional[str] |
None |
||
ProgressBar |
progress |
value |
Union[float, Binding] |
0.0 |
label |
Optional[str] |
None |
||
variant |
str |
"default" |
||
show_percentage |
bool |
True |
||
MetricCard |
metric |
title |
str |
"" |
value |
Union[str, Binding] |
"" |
||
subtitle |
Optional[str] |
None |
||
icon |
Optional[str] |
None |
||
variant |
str |
"default" |
||
progress |
Optional[float] |
None |
||
List_ |
list |
items |
List[Union[str, Dict[str, Any]]] |
[] |
ordered |
bool |
False |
||
variant |
str |
"default" |
||
Table |
table |
headers |
List[str] |
[] |
rows |
List[List[Any]] |
[] |
||
variant |
str |
"default" |
||
total_rows |
Optional[int] |
None |
||
page_size |
Optional[int] |
None |
||
page_offset |
Optional[int] |
None |
||
page_sizes |
List[int] |
[] |
||
source_tool |
Optional[str] |
None |
||
source_agent |
Optional[str] |
None |
||
source_params |
Dict[str, Any] |
{} |
||
BarChart |
bar_chart |
title |
str |
"" |
labels |
List[str] |
[] |
||
datasets |
List[Dict[str, Any]] |
[] |
||
LineChart |
line_chart |
title |
str |
"" |
labels |
List[str] |
[] |
||
datasets |
List[Dict[str, Any]] |
[] |
||
PieChart |
pie_chart |
title |
str |
"" |
labels |
List[str] |
[] |
||
data |
List[float] |
[] |
||
colors |
List[str] |
[] |
||
DonutChart |
donut_chart |
title |
str |
"" |
labels |
List[str] |
[] |
||
data |
List[float] |
[] |
||
center_label |
Optional[str] |
None |
||
center_value |
Union[str, Binding, None] |
None |
||
RadarChart |
radar_chart |
title |
str |
"" |
axes |
List[str] |
[] |
||
datasets |
List[Dict[str, Any]] |
[] |
||
max_value |
Optional[float] |
None |
||
PlotlyChart |
plotly_chart |
title |
str |
"" |
data |
List[Dict[str, Any]] |
[] |
||
layout |
Dict[str, Any] |
{} |
||
config |
Dict[str, Any] |
{} |
||
Audio |
audio |
src |
str |
"" |
source |
Optional[Handle] |
None |
||
contentType |
Optional[str] |
None |
||
autoplay |
bool |
False |
||
loop |
bool |
False |
||
label |
Optional[str] |
None |
||
showControls |
bool |
True |
||
description |
Optional[str] |
None |
||
FileUpload |
file_upload |
label |
str |
"Upload File" |
accept |
str |
"*/*" |
||
action |
str |
"" |
||
capability |
Optional[Handle] |
None |
||
FileDownload |
file_download |
label |
str |
"Download File" |
url |
str |
"" |
||
target |
Optional[Handle] |
None |
||
filename |
Optional[str] |
None |
||
Badge |
badge |
label |
Union[str, Binding] |
"" |
variant |
str |
"default" |
||
icon |
Optional[str] |
None |
||
Hero |
hero |
title |
str |
"" |
subtitle |
Optional[str] |
None |
||
eyebrow |
Optional[str] |
None |
||
icon |
Optional[str] |
None |
||
variant |
str |
"default" |
||
badges |
List[str] |
[] |
||
KeyValue |
keyvalue |
title |
Optional[str] |
None |
items |
List[Dict[str, Any]] |
[] |
||
columns |
int |
2 |
||
Timeline |
timeline |
title |
Optional[str] |
None |
items |
List[Dict[str, Any]] |
[] |
||
variant |
str |
"default" |
||
StatGroup |
stat_group |
title |
Optional[str] |
None |
items |
List[Dict[str, Any]] |
[] |
||
columns |
int |
4 |
||
Gauge |
gauge |
label |
str |
"" |
value |
Union[float, Binding] |
0.0 |
||
display_value |
Union[str, Binding, None] |
None |
||
thresholds |
List[Dict[str, Any]] |
[] |
||
subtitle |
Optional[str] |
None |
||
PipelineStepper |
pipeline_stepper |
title |
Optional[str] |
None |
steps |
List[Dict[str, Any]] |
[] |
||
orientation |
str |
"horizontal" |
||
Rating |
rating |
value |
Union[float, Binding] |
0.0 |
max_value |
int |
5 |
||
label |
Optional[str] |
None |
||
subtitle |
Optional[str] |
None |
||
show_value |
bool |
True |
||
ChatHistory |
chat_history |
title |
Optional[str] |
"Recent chats" |
items |
List[Dict[str, Any]] |
[] |
||
Diff |
diff |
files |
List[DiffFile] |
[] |
truncated |
bool |
False |
||
Findings |
findings |
findings |
List[Finding] |
[] |
truncated |
bool |
False |
||
ColorPicker |
color_picker |
label |
str |
"" |
color_key |
str |
"" |
||
value |
str |
"#000000" |
||
capability |
Optional[Handle] |
None |
||
ThemeApply |
theme_apply |
preset |
Optional[str] |
None |
colors |
Optional[Dict[str, str]] |
None |
||
color_key |
Optional[str] |
None |
||
color_value |
Optional[str] |
None |
||
message |
str |
"" |
Nested models
| Class | Field | Type | Default |
|---|---|---|---|
BindingRef |
event |
str |
required |
path |
str |
"" |
|
Binding |
bind |
BindingRef |
required |
Handle |
handle |
str |
required |
TabItem |
label |
str |
"" |
content |
List[Primitive] |
[] |
|
value |
Optional[str] |
None |
|
ChartDataset |
label |
str |
"" |
data |
List[float] |
[] |
|
color |
Optional[str] |
None |
|
DiffLine |
kind |
Literal["context", "add", "delete"] |
"context" |
content |
str |
"" |
|
old_line |
Optional[int] |
None |
|
new_line |
Optional[int] |
None |
|
DiffAction |
action |
str |
required |
payload |
Dict[str, Any] |
{} |
|
capability |
Optional[Handle] |
None |
|
DiffHunk |
id |
str |
required |
old_start |
int |
0 |
|
old_lines |
int |
0 |
|
new_start |
int |
0 |
|
new_lines |
int |
0 |
|
lines |
List[DiffLine] |
[] |
|
actions |
List[DiffAction] |
[] |
|
truncated |
bool |
False |
|
DiffFile |
old_path |
str |
"" |
new_path |
str |
"" |
|
status |
Literal["added", "modified", "deleted", "renamed"] |
"modified" |
|
binary |
bool |
False |
|
hunks |
List[DiffHunk] |
[] |
|
truncated |
bool |
False |
|
Finding |
title |
str |
"" |
body |
str |
"" |
|
file |
str |
"" |
|
start_line |
int |
0 |
|
end_line |
int |
0 |
|
priority |
Literal["P0", "P1", "P2", "P3"] |
"P3" |
|
category |
str |
"" |
|
diff_ref |
Optional[str] |
None |
BarChart and LineChart accept ChartDataset instances alongside dictionary
datasets, including in tuples and other supported iterable collections. Helpers
become plain dictionaries in the stored datasets list and on the wire; None
helper fields are omitted. Dictionary datasets retain arbitrary keys and values
under the JSON-native serialization rules above. Other Pydantic models are not
accepted as direct dataset items.
from astralprims import BarChart, ChartDataset
chart = BarChart(datasets=(
ChartDataset(label="Sales", data=[10, 20]),
{"label": "Forecast", "data": [12, 22], "borderWidth": 2},
))
chart.to_dict()
attributes is never emitted as a key: its entries are merged into the top
level last and can overwrite any field, including type, so it must carry only
trusted keys, never user or model input.
This reference is generated from the models. After changing a primitive, run
uv run --frozen python tooling/python-ci/primitive_reference.py to regenerate
it; tests/test_readme_reference.py fails while it is stale.
Defining your own primitive
Primitives are pydantic models; declare the wire type as a Literal default
and subclassing auto-registers it for from_dict — no manual map. Pick a type
string that does not collide with a built-in:
from typing import Literal, Optional
from astralprims import Primitive, rebuild_primitive_union
class Ribbon(Primitive):
type: Literal["ribbon"] = "ribbon" # registered automatically
label: str = ""
count: Optional[int] = None
rebuild_primitive_union() # refresh AnyPrimitive/primitive_adapter
Collision errors and validation
Every primitive subclass must declare a type field with a non-empty string default
that matches any Literal annotation choices. Wire types must be globally unique across
built-in and custom primitives. Attempting to register a wire type that is already bound
to another class raises PrimitiveTypeCollisionError before modifying the registry.
Failed registrations abort cleanly without altering _REGISTRY or existing primitive_adapter
instances.
Unregistering and rebuild ordering
To remove an extension primitive or prepare for a replacement, unregister the wire type name
using unregister_primitive() and then call rebuild_primitive_union():
from astralprims import unregister_primitive, rebuild_primitive_union
unregister_primitive("ribbon")
rebuild_primitive_union()
Reload policy
Re-registering the exact same class object (for example, in interactive environments) is
permitted. However, module reloads create a new, distinct class object for the same wire
type, which triggers PrimitiveTypeCollisionError. To reload a module defining custom
primitives, call unregister_primitive() on the custom wire types before reloading the
module, then call rebuild_primitive_union().
Tests
pytest
License
Apache-2.0
Metadata
Release files for astralprims 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| astralprims-0.13.0.tar.gz | 329.5 kB | With provenance | Details for astralprims-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| astralprims-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for astralprims-0.13.0-py3-none-any.whl |
Total release size: 369.2 kB
Release files / astralprims-0.13.0.tar.gz
| Download URL | astralprims-0.13.0.tar.gz |
|---|---|
| Size | 329.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b5a47dc830c79ecb19b04901aa2b91e04b9b96a53d9a377fadc3398f4095e80
|
|
BLAKE2b-256 checksum How to use checksums |
1788de9e24527a83a99e95f27af3328056353d89628a767219305e99352ecc73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logRelease files / astralprims-0.13.0-py3-none-any.whl
| Download URL | astralprims-0.13.0-py3-none-any.whl |
|---|---|
| Size | 39.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb881cd27baa6f8f21dac04b83302d99c91fd00ab81f2a7815dc19712f3fb84e
|
|
BLAKE2b-256 checksum How to use checksums |
fa59fb4a5f6966dfe22112ac0b77420cdade31fe4a529fd491cf170c501f0d6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logSecurity for astralprims 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for astralprims-0.13.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.