Execution¶
Named, checked execution for whole modules.
execution
¶
Named, checked execution for whole QIEC modules.
The evaluator deliberately operates on core terms and process-local attachments. This module supplies the user-facing boundary above it: it selects a named computation, specializes its static telescope, validates host arguments and results, creates a new attachment table for every invocation, and reports failures with stable diagnostic codes.
Runtime providers are explicit. A configuration names registered provider
factories (or carries provider objects when used from Python); no module import
or ambient attachment registry is consulted by run_named.
TraceObserver
¶
A callback receiving each event an execution emits, in order.
RuntimeProviderFactory
¶
RuntimeProviderFactory = Callable[[Mapping[str, object]], RuntimeProvider]
Build a runtime provider from the options its configuration entry records.
ExecutionTraceEvent
dataclass
¶
ExecutionTraceEvent(sequence: int, event: str, computation: str, detail: Mapping[str, object] = dict())
One stable event emitted by a named QIEC invocation.
| PARAMETER | DESCRIPTION |
|---|---|
sequence
|
The event's position in the invocation's trace, from zero.
TYPE:
|
event
|
The stable event name, such as
TYPE:
|
computation
|
The name of the computation being run.
TYPE:
|
detail
|
JSON-compatible event data; frozen on construction.
TYPE:
|
__post_init__
¶
to_data
¶
Render the event as JSON-compatible data.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
The sequence number, event name, computation name, and detail mapping, with every detail value made JSON-compatible. |
Source code in src/quivers/qiec/execution.py
ExecutionTraceRecorder
dataclass
¶
ExecutionTraceRecorder(events: list[ExecutionTraceEvent] = list())
Collect events while also satisfying the :class:TraceObserver API.
| PARAMETER | DESCRIPTION |
|---|---|
events
|
The recorded events, in order; empty to start.
TYPE:
|
__call__
¶
__call__(event: ExecutionTraceEvent) -> None
Record one event.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
The event the invocation just emitted.
TYPE:
|
ExecutionDiagnostic
dataclass
¶
ExecutionDiagnostic(code: str, message: str, computation: str | None = None, origin: SourceOrigin | None = None, severity: Literal['error', 'warning', 'note'] = 'error')
A stable failure at the source-to-host execution boundary.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
The stable diagnostic code, such as
TYPE:
|
message
|
The human-readable explanation.
TYPE:
|
computation
|
The named computation involved, if any.
TYPE:
|
origin
|
The source location involved, if any.
TYPE:
|
severity
|
TYPE:
|
to_data
¶
Render the diagnostic as JSON-compatible data.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
The code, severity, message, computation name, and origin (or
|
Source code in src/quivers/qiec/execution.py
ExecutionFailure
¶
ExecutionFailure(diagnostic: ExecutionDiagnostic)
Bases: EvaluationError
Raised with a serializable diagnostic when named execution cannot run.
| PARAMETER | DESCRIPTION |
|---|---|
diagnostic
|
The failure, kept on the error as
TYPE:
|
Source code in src/quivers/qiec/execution.py
RuntimeProvider
¶
Bases: Protocol
An explicit source of process-local handlers and type validators.
attach
¶
attach(module: QiecModule, attachments: RuntimeAttachments) -> None
Bind this provider's handlers into a fresh attachment table.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The validated module whose handlers and effects are being served.
TYPE:
|
attachments
|
The per-invocation table receiving runtime handlers.
TYPE:
|
Source code in src/quivers/qiec/execution.py
validator_for
¶
validator_for(type_: TypeExpr) -> RuntimeValidator | None
Supply a host validator for a runtime type, if this provider has one.
| PARAMETER | DESCRIPTION |
|---|---|
type_
|
The closed QIEC type an argument or result must inhabit.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeValidator | None
|
A predicate over host values, or |
Source code in src/quivers/qiec/execution.py
CoreRuntimeProvider
dataclass
¶
Primitive validators plus explicitly configured structural handlers.
options.handlers maps authored handler names to either
{"kind": "passthrough"}, {"kind": "state", "initial": ...},
or {"kind": "scripted", "responses": {"op": [...]}}. The source
handler still controls types, coverage, and resumption grades; options
supply only process-local clause behavior and state.
| PARAMETER | DESCRIPTION |
|---|---|
options
|
JSON-compatible configuration; frozen on construction.
TYPE:
|
name
|
The provider's name, reported in traces and result labels.
TYPE:
|
__post_init__
¶
attach
¶
attach(module: QiecModule, attachments: RuntimeAttachments) -> None
Bind one structural handler per configured authored handler.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The validated module whose handlers the configuration names.
TYPE:
|
attachments
|
The per-invocation table receiving the constructed handlers.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/qiec/execution.py
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | |
validator_for
¶
validator_for(type_: TypeExpr) -> RuntimeValidator | None
Supply the primitive validator for a closed runtime type.
| PARAMETER | DESCRIPTION |
|---|---|
type_
|
The closed QIEC type an argument or result must inhabit.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeValidator | None
|
The core validator, or |
Source code in src/quivers/qiec/execution.py
RuntimeSelection
dataclass
¶
One named provider and its JSON-compatible construction options.
| PARAMETER | DESCRIPTION |
|---|---|
provider
|
The registered or entry-point name of the provider; must be non-empty.
TYPE:
|
options
|
The options passed to the provider's factory; frozen on construction.
TYPE:
|
__post_init__
¶
Reject empty provider names and freeze the options.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/qiec/execution.py
RuntimeConfiguration
dataclass
¶
RuntimeConfiguration(selections: tuple[RuntimeSelection, ...] = (RuntimeSelection('core'),), providers: tuple[RuntimeProvider, ...] = ())
Complete, explicit runtime selection for one or more invocations.
| PARAMETER | DESCRIPTION |
|---|---|
selections
|
Providers to build by name for every invocation; the core provider alone by default.
TYPE:
|
providers
|
Already-built provider objects, appended after the selections when used from Python.
TYPE:
|
label
property
¶
A +-joined label naming every selected and supplied provider.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The provider names in order, or |
instantiate
¶
instantiate() -> tuple[RuntimeProvider, ...]
Build every named provider and append the programmatic ones.
| RETURNS | DESCRIPTION |
|---|---|
tuple[RuntimeProvider, ...]
|
The providers in selection order, followed by |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/qiec/execution.py
to_data
¶
Render the configuration as JSON-compatible data.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
The named selections with their options, and the names of any programmatic providers. |
Source code in src/quivers/qiec/execution.py
ExecutionResult
dataclass
¶
ExecutionResult(computation: str, value: object, result_type: TypeExpr, runtime: str, trace: tuple[ExecutionTraceEvent, ...])
The checked value and trace produced by one named invocation.
| PARAMETER | DESCRIPTION |
|---|---|
computation
|
The name of the computation run.
TYPE:
|
value
|
The validated host result.
TYPE:
|
result_type
|
The computation's result type under its specialization.
TYPE:
|
runtime
|
The label of the runtime configuration used.
TYPE:
|
trace
|
Every event the invocation emitted, in order.
TYPE:
|
to_data
¶
Render the result as JSON-compatible data.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
|
Source code in src/quivers/qiec/execution.py
available_runtime_providers
¶
Return built-in and installed quivers.qiec_runtime entry points.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
Every selectable provider name, sorted. |
Source code in src/quivers/qiec/execution.py
register_runtime_provider
¶
register_runtime_provider(name: str, factory: RuntimeProviderFactory) -> None
Register a provider factory for explicit configuration by name.
Registration makes a provider selectable; it never activates that provider for an invocation. Replacing an existing name is rejected so plugin load order cannot silently change execution semantics.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name a configuration uses to select the provider.
TYPE:
|
factory
|
The callable building a provider from JSON-compatible options.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/qiec/execution.py
runtime_configuration_from_data
¶
runtime_configuration_from_data(data: object) -> RuntimeConfiguration
Decode the non-executable JSON runtime configuration format.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The decoded JSON document;
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeConfiguration
|
The selections in document order, with no programmatic providers. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/quivers/qiec/execution.py
load_runtime_configuration
¶
load_runtime_configuration(path: str | Path) -> RuntimeConfiguration
Load an explicit runtime selection without importing executable code.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A JSON file in the format :func:
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeConfiguration
|
The decoded selection. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the file cannot be read, is not valid JSON, or does not decode as a runtime configuration. |
Source code in src/quivers/qiec/execution.py
parse_static_arguments
¶
parse_static_arguments(module: QiecModule, computation: str, assignments: tuple[str, ...]) -> tuple[StaticArgument, ...]
Resolve CLI NAME=TERM specializations in telescope order.
This intentionally accepts only closed, nominal terms available in the module: primitive or declared types, closed index constructors/literals, and declared effect applications. Static variables and inferred holes are not runtime configuration values.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The module declaring
TYPE:
|
computation
|
The named computation whose telescope is being instantiated.
TYPE:
|
assignments
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[StaticArgument, ...]
|
The parsed arguments in the telescope's order. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/qiec/execution.py
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 | |
run_named
¶
run_named(module: QiecModule, computation: str, arguments: tuple[object, ...] = (), *, static_arguments: tuple[StaticArgument, ...] = (), runtime: RuntimeConfiguration | None = None, observer: TraceObserver | None = None, fuel: int | None = None) -> ExecutionResult
Validate and execute one named computation from module.
The attachment table and every configured provider instance are allocated inside this call. Mutable handler state can thus never leak from one named invocation to the next.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The module declaring the computation; it is validated before the body is evaluated.
TYPE:
|
computation
|
The name of the computation to run.
TYPE:
|
arguments
|
Host values for the computation's value parameters, in order.
TYPE:
|
static_arguments
|
Closed terms instantiating the computation's telescope, in order; required whenever the telescope is non-empty.
TYPE:
|
runtime
|
The providers to attach; defaults to the core provider alone.
TYPE:
|
observer
|
A callback receiving every trace event as it is emitted.
TYPE:
|
fuel
|
The number of machine steps the run may take, or
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExecutionResult
|
The validated result value, its specialized type, the runtime label, and the full trace. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/qiec/execution.py
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 | |