DSL reference
Import public declarations from analint. The
first-spec tutorial is a complete runnable model; snippets
below illustrate individual declarations and may refer to names defined there
or in the linked examples.
Migrating to 0.3.0
The 0.3.0 analint.check/v1 report is not fully backward-compatible with
0.2.0. Required keys and field types are unchanged. Update consumers that
rely on the previous sliced-report behavior:
- Accept an absent
sliceon projection-decided results. - Treat
states_exploredas a reported graph count. It can count a smaller proof graph. Usemodel.relationandmodel.attemptsto identify the proof and its graph counts. - Accept
selected_slices_from_verification_rootsinmodel_coverage.scopefor sliced selections. Readselection.covered_actionsandselection.unassessed_actionsbefore comparing coverage. - Expect sliced selections to omit unrelated transition defects from
model_findings. Keep usingverdictfor the run outcome.
See the selection contract.
Migrating to 0.2.0
When upgrading from 0.1.0, review these changes before comparing old results.
- Queries whose
max_statesis omitted orNonenow inheritSpec.max_states. An explicit query budget still takes precedence over the spec, and an invocation override takes precedence over both. Setmax_states=10_000on a query to keep the previous independent default. A changed budget can change whether a check completes; INCONCLUSIVE is still not a proof. saturate=Truenow enforcesvaluesand exclusivegt/ltconstraints after clamping. Models that previously relied on those constraints being skipped can report transition defects. The newsaturate="low"andsaturate="high"modes clamp only the selected inclusive bound and keep other constraints hard.- Multi-root
Reachablerequires a path from every admissible root. A witness from only one root no longer proves the query. Invalid roots remain blocking failures; their diagnostics now explain why exploration did not expand them. - Native checks support composing
Lookupand//. TLC supports a narrower, provable integer domain: it refusesLookup(...) // n, division of a field written byLookup, and dynamic divisors. Unsupported exports remain INCONCLUSIVE instead of approximating the expression.
The older 0.1.0 migration notes still apply when upgrading from 0.0.x. Stable check ids and CLI exit codes are unchanged.
Migrating to 0.1.0
When upgrading from 0.0.x, review these changes to the verification contract.
- Operand literals are limited to
None,bool,int,float,str,Enumand instance references. DeclaredEntityclasses remain valid identities in parameter filters. Opaque Python objects are structural errors, includingDecimalanddatevalues that previously worked in native comparisons. Convert both literals and model field values consistently: for example, represent fixed-precision amounts as integer minor units with explicit rounding at the input boundary, and calendar dates as integer day ordinals or an explicit finite enum. Do not replace exact decimal arithmetic with floats indiscriminately. Define finite bounds for explored numeric domains. These are modeling choices; the checker does not convert values automatically. - Use
And,OrandNotfor symbolic expressions. Replace Pythonand/or/notand chained comparisons such as0 <= Account.balance <= 100withAnd(0 <= Account.balance, Account.balance <= 100). Boolean conversion now raises instead of silently losing part of a condition. - Selected checks put unrelated defects encountered during exploration in
model_findings, outside the selected verdict. 0.3.0: sliced selections list actions outside action coverage inselection.unassessed_actions. Readmodel_coveragefor the bounds on coverage. - Handle INCONCLUSIVE (CLI exit 4), including when excluded event-subscriber actions prevent a proof. Do not infer success from an absence of counterexamples.
- TLC can find a transition defect while the target property stays INCONCLUSIVE. The overall check can still FAIL (exit 1). Property and aggregate sections may repeat that defect for attribution; their counts are not a unique-defect total.
State: Entity and Field
Subclass Entity and annotate fields. An instance carries values; a class-level
field is an expression used in predicates and effects.
from analint import Entity, Field
class Wallet(Entity):
balance: int = Field(0, ge=0, le=5)
Wallet(balance=3) # concrete snapshot
Wallet.balance >= 1 # predicate, evaluated against a state later
Fields without defaults are required in snapshots. Unknown, missing required or constraint-violating values are rejected at construction.
| Field option | Meaning |
|---|---|
Field(default, ge=..., gt=..., le=..., lt=...) |
Numeric constraints, checked on snapshots and transitions |
Field(default, values=[...]) |
Explicit finite scalar domain |
Field(default, ge=..., le=..., saturate=True) |
Clamp numeric effects at both bounds |
Field(default, ge=..., le=..., saturate="low" / "high") |
Clamp only the selected bound; other constraints remain hard |
Lifecycle(...) as a field default |
Initial value, allowed edges and terminal states for a state field |
Booleans, enums, lifecycle states, bounded integers and explicit value domains
can supply finite choices to Initial. Numeric bounds define the abstraction:
use thresholds deliberately, especially with saturation.
Predicates and expressions
Comparisons ==, !=, <, <=, > and >= build predicate values. Fields and
arithmetic expressions support +, - and *. Name expressions and predicates
to reuse them; they are data, not callbacks.
from analint import And, Implies, In, IsNotNull, IsNull, Not, Or
can_pay = And(Wallet.balance >= Order.total, Order.total > 0)
remaining = Wallet.balance - Order.total
Use And(...), Or(...), Not(...) and Implies(a, b), rather than Python
and, or, not or chained comparisons. In(field, values), IsNull(field)
and IsNotNull(field) cover membership and null checks. Boolean fields can
appear directly in predicate positions, such as pre=[Client.active].
Invariant
Invariant(predicate, id="", label="") describes a state relationship.
from analint import Implies, Invariant
resolved_leaves_no_open_ticket = Invariant(
Implies(Ticket.status != Status.NEW, Queue.open_tickets == 0),
label="Resolving the only ticket clears the queue counter",
)
Listed invariants are automatically verified from the canonical roots and
checked before and after scenario/flow actions where applicable. Direct reads
of a missing instance make an invariant inapplicable to that snapshot. Quantified
reads follow present scope members. Keep one-field constraints in Field;
use invariants for relationships between fields or entities.
0.1.0: symbolic predicates, fields and arithmetic expressions reject
Python truth-value conversion with a TypeError. Use And/Or/Not, and
write And(0 <= Account.balance, Account.balance <= 100) instead of a chained
comparison. This prevents Python from silently discarding part of a condition.
Action and effects
Action(pre=[...], effect=[...], post=[...], emits=[...]) declares a transition.
Metadata includes id, name, description and tags.
from analint import Action, Set, Subtract
pay = Action(
pre=[Wallet.balance >= Order.total],
effect=[
Subtract(Wallet.balance, Order.total),
Set(Order.paid, True),
],
post=[Order.paid],
)
| Effect | Meaning |
|---|---|
Set(field, value_or_expression) |
The field has this value in the next state |
Add(field, amount) / Subtract(field, amount) |
Arithmetic forms of Set |
Create(ref, **fields) |
An absent scoped slot becomes present; omitted fields take defaults |
Delete(ref) |
A present scoped slot becomes absent |
Effects are simultaneous: every right-hand side reads the pre-state, so list order cannot express a sequence. Two writes to one field are invalid. A slot cannot be created/deleted and also written by another effect in the same action. Use multiple actions in a flow when intermediate states matter.
Lifecycle
Declare a lifecycle inline as a field default:
from analint import Lifecycle
status: Status = Lifecycle(
initial=Status.NEW,
transitions={
Status.NEW: [Status.RESOLVED],
Status.RESOLVED: [Status.ARCHIVED],
},
terminal=[Status.ARCHIVED],
)
Effects that change the field must follow a declared edge. terminal freezes
the whole entity, including its other fields and deletion. Missing outgoing
edges do not implicitly declare a terminal state. A declared edge out of a
terminal state is a structural error.
Scope, presence and instance references
A Scope(EntityClass, keys=[...]) allocates a fixed finite universe. Indexing
returns an InstanceRef; ref.field addresses a particular instance and
ref(field=value) creates its snapshot.
from analint import Absent, Present, Scope
wallets = Scope(Wallet, keys=["alice", "bob"])
alice = wallets["alice"]
bob = wallets["bob"]
alice_has_funds = alice.balance > 0
alice_exists = Present(alice)
# Snapshot entries: alice(balance=3), Absent(bob)
Use instance fields rather than ambiguous Wallet.balance once Wallet is scoped.
Only one scope per entity type is supported. Absent(ref) marks a slot absent;
Present(ref_or_bound_or_param) tests membership. Scenarios/flows omit slots as
absent, while exploration defaults them to present unless overridden.
Ordinary field reads and writes need a present slot. Create requires absence,
Delete requires presence; a mismatch rejects the action before effects. Keys
never grow dynamically. Guard a possibly absent field read with
And(Present(ref), ref.field == value) so absence does not cause an evaluation
error.
Declared keys and initial presence
The following APIs are available since 0.0.4.
Key(ref_or_param_or_bound) is a value expression returning the slot's declared
key, with its original type. It accepts an InstanceRef, a Param whose entire
domain consists of instance references, or a quantified Bound. Values may be
None, booleans, integers, finite floats, strings or Enum members. Other hashable
scope keys remain supported as identities but cannot be used with Key.
Identity is independent of presence: Key(ref) works for an absent slot and
reads no state. A Bound needs an enclosing quantifier/aggregate; an instance
Param is substituted during action expansion. Static Action.where filters
can compare keys. There is no automatic conversion between a scope key and a
foreign-key field: use the same domain values, such as Enum members, in both.
Scope(..., initially_present=False) makes omitted slots absent when building
canonical and query roots. The default is True, preserving existing models.
Explicit ref(...) and Absent(ref) snapshots override the policy. Each
query-owned given, given_any world or Initial is built independently from
the scope defaults and its own snapshots; it does not merge canonical snapshots.
Queries without their own source inherit the canonical worlds. Scenarios and
flows continue to treat omitted slots as absent regardless of this policy.
Varying a field of an absent slot remains an error; supply a present snapshot
before including that field in Initial.vary.
This complete example starts with an empty scope, then records an absent slot's identity as the owner of a created slot:
from analint import (
Absent, Action, And, Bound, Create, Delete, Entity, ForAll, In,
Invariant, Key, Not, Present, Reachable, Scenario, Scope, Spec,
)
class Item(Entity):
owner: str = "none"
slots = Scope(Item, keys=["a", "b"], initially_present=False)
a, b = slots["a"], slots["b"]
x = Bound("x", slots)
create = Action(effect=[Create(b, owner=Key(a))])
delete = Action(effect=[Delete(b)])
safe = Invariant(ForAll(x, In(x.owner, ["none", Key(a)])))
query = Reachable(And(Present(b), b.owner == Key(a)))
created = Scenario(
name="Create with the declared owner", action=create, given=[Absent(b)],
then=[Present(b), b.owner == "a"],
)
deleted = Scenario(
name="Delete an owned slot", action=delete, given=[b(owner="a")],
then=[Not(Present(b))],
)
spec = Spec(
id="scope-identity", name="Declared identity and empty initial scope",
actions=[create, delete], invariants=[safe], queries=[query],
scenarios=[created, deleted],
)
check proves the invariant and reaches the query through create; the complete
graph contains two states. trace query shows Item['b'].owner becoming "a".
The exploration/trace JSON schemas keep their existing scalar representation
(Enum values use Type.MEMBER); model views add initially_present to scope
metadata. TLC exports keys through its existing literal encoding. Unsupported
values such as floating-point keys cause an explicit export refusal and leave
the check INCONCLUSIVE; they are never approximated.
Param: finite action families
Param(name, *domain) accepts explicit values, entity classes, enums, booleans
or a scope. Param(name, ge=N, le=M) declares an inclusive integer range.
from analint import Action, Add, Param, Subtract
src = Param("src", wallets)
dst = Param("dst", wallets)
transfer = Action(
params=[src, dst],
where=[src != dst],
pre=[src.balance >= 1, dst.balance < 5],
effect=[Subtract(src.balance, 1), Add(dst.balance, 1)],
)
alice_pays_bob = transfer.bind(src=alice, dst=bob)
The declaration expands into ordinary bound actions when the Spec is built.
where filters static parameter combinations; state-dependent conditions,
including Present, belong in pre. List the family on Spec.actions.
Param and parameter fields support +, -, * (including reflected forms)
and all six comparisons directly; p + 0 wrappers are unnecessary. Use
.bind(...) to select the concrete action for a scenario or flow. Do not generate
model elements with Python factory loops; finite families belong in Param.
0.1.0: binding refreshes the concrete action from the current family
declaration, including nested guard/effect/payload edits. Rebinding the same
family and arguments preserves the action's identity so existing scenario and
flow references still match Spec expansion. Those references see the refreshed
contents; this is not an immutable model snapshot. Copied families own separate
binding memos. Rebinding preserves established action IDs and family labels,
including IDs assigned to bound variables by the loader. Unnamed bindings are
named once their family is named. A discarded family no longer leaves its memo
in a global store.
Refresh happens on .bind(...) or a new family expansion, not automatically when
an existing Spec is validated. Rebuild the Spec after changing parameter domains,
where, or referenced model elements so membership/reference closure is current.
Do not edit declarations during an active verification run.
Bound, quantifiers and aggregates
Bound(name, scope) binds a variable over present instances of that scope.
from analint import Bound, Count, Exists, ForAll, Max, Min, Sum
wallet = Bound("wallet", wallets)
all_nonnegative = ForAll(wallet, wallet.balance >= 0)
someone_has_funds = Exists(wallet, wallet.balance > 0)
funded_count = Count(wallet, wallet.balance > 0)
total_balance = Sum(wallet, wallet.balance)
ForAll and Exists are predicates. Count, Sum, Min and Max are arithmetic
expressions usable in comparisons or effect right-hand sides. A bound field must
occur within its quantifier/aggregate, or in the supported Initial.vary position.
| Empty present set | Result |
|---|---|
ForAll |
True |
Exists |
False |
Count, Sum |
0 |
Min, Max |
Evaluation error |
Initial
Initial(vary=[...], where=[...], given=[...], max_candidates=10000) enumerates
admissible roots. given fixes values, and where filters combinations with
ordinary predicates and aggregates.
Since 0.0.4: vary can be omitted or empty. Initial(given=[...]) starts
with one candidate built from defaults plus the supplied snapshots, then applies
where. Initial() uses the defaults alone. A rejected candidate leaves no roots
and fails validation; an evaluation error also fails. Versions before 0.0.4 require at least one varying field.
from analint import Initial
starting_balances = Initial(
vary=[alice.balance],
where=[alice.balance >= 1],
given=[bob(balance=0)],
)
Attach it to Spec.initial for canonical verification or to a query's initial
for that query only. Candidate overflow and evaluation errors fail rather than
silently removing combinations. See initial states.
Fixed-root example
Save this complete source as spec.py with analint 0.0.4 or newer installed and run
analint check .. Both slots start absent; creating one increments the counter.
The required Limit value comes from given. An independent noise action shows
why property slices can be smaller than analint explore .'s whole-model graph.
already_created supplies its own fixed root and needs no action to find a witness.
from analint import (
Absent, Action, Add, Bound, Create, Entity, Field, Initial,
Invariant, Not, Present, Reachable, Scenario, Scope, Set, Spec, Sum,
)
class Limit(Entity):
max_created: int
class Counter(Entity):
n: int = Field(0, ge=0, le=1)
class Item(Entity):
units: int = Field(1, ge=1, le=1)
class Noise(Entity):
on: bool = False
items = Scope(Item, keys=["one", "spare"])
one = items["one"]
spare = items["spare"]
item = Bound("item", items)
create = Action(
pre=[Counter.n < Limit.max_created],
effect=[Create(one), Add(Counter.n, 1)],
)
flip_noise = Action(pre=[Not(Noise.on)], effect=[Set(Noise.on, True)])
balanced = Invariant(Sum(item, item.units) == Counter.n)
created = Reachable(Present(one))
already_created = Reachable(
Present(one),
initial=Initial(given=[Limit(max_created=1), Counter(n=1), one(), Absent(spare)]),
)
create_once = Scenario(
action=create,
given=[Limit(max_created=1), Counter(), Absent(one), Absent(spare)],
then=[Present(one), Counter.n == 1],
)
noise_once = Scenario(action=flip_noise, given=[Noise()], then=[Noise.on])
spec = Spec(
id="fixed_initial",
name="Fixed initial world",
initial=Initial(given=[Limit(max_created=1), Absent(one), Absent(spare)]),
actions=[create, flip_noise],
scenarios=[create_once, noise_once],
invariants=[balanced],
queries=[created, already_created],
)
The canonical whole-model graph has one root and four states; the invariant and
created each need only two states in their slices. Use analint trace created
with -p . for the create witness, or analint trace already_created -p . for
the query-specific initial-state witness.
Event and Emitted
Event uses typed fields like Entity. Action.emits accepts an event class or a
payload template whose fields bind to state expressions:
from analint import Emitted, Event
class PaymentRecorded(Event):
amount: int
# On an action: emits=[PaymentRecorded(amount=Order.total)]
# In Scenario.then or Flow.steps: Emitted(PaymentRecorded)
Payload templates are type-checked and materialized against the post-state. Emission
does not dispatch another action. A scenario can supply an Event instance in
given to test an action with payload preconditions; such external inputs are
not generated by reachability exploration. They are reported as unassessed.
0.1.0: a materialized payload that violates its event's Field
constraints produces a transition.field_constraint defect rather than raising
an exception. Scenarios and flows fail, including scenarios with Expect.FAIL;
exploration reports the path and attempted action without adding an invalid
transition. Resolution or constructor errors use transition.evaluation_error.
Event payloads are validated without clamping, even with saturate=True; that
option clamps state updates, not event construction. Bare event classes still
carry no payload. TLC exports supported payload bounds and enumerated values as
transition-defect checks over the post-state, including the kernel's acceptance
of None. Invalid payloads reject the transition without clamping. A reachable
TLC transition defect makes the run FAIL even if the requested predicate remains
INCONCLUSIVE because TLC stopped at that defect; its diagnostic includes the
attempted action. Custom event constructors, unsupported scalar bounds such as
floats, and literal strings equal to the reserved __null__ sentinel are refused
with tlc.not_exported rather than approximated.
One-sided saturation applies to effect results and Create, before postconditions.
"low" requires ge; "high" requires le; True still requires both.
The opposite bound, exclusive bounds and values remain checked after clamping.
Initial snapshots and event payloads are validated without clamping.
Boolean predicate values (unreleased)
BoolValue(predicate) turns a DSL predicate into an ordinary boolean operand.
It also accepts a bare boolean field. This lets a parameterized action update
flags without duplicating an action for each enum value:
from enum import Enum
from analint import Action, BoolValue, Entity, Or, Param, Set
class Method(Enum):
CARD = "card"
WALLET = "wallet"
class Client(Entity):
card_deposited: bool = False
method = Param("method", Method)
deposit = Action(
id="deposit",
params=[method],
effect=[Set(Client.card_deposited,
BoolValue(Or(Client.card_deposited, method == Method.CARD)))],
)
CARD sets the flag; WALLET preserves its previous value. Every effect RHS reads
the pre-state, including predicates inside BoolValue. Create fields use the
same rule; emitted payload templates still read the post-state. Scope Params,
quantifiers and presence guards bind normally. Reading an absent instance without
a guard remains an evaluation defect. References inside the predicate participate
in model closure, impact reports, slicing and cache identity.
Use True/False directly for constants. BoolValue does not accept Python
callbacks or coerce Python truthiness. A raw predicate in Set remains invalid:
wrap it explicitly. Duplicate writes to one target remain invalid; this API adds
values, not conditional effect lists.
Structural validation reports structural.type_conflict for provable boolean
and integer assignment conflicts in Set, Create and emitted payloads.
For example, a boolean value cannot be written to a declared integer field, and
an integer cannot be written to a declared boolean field. Add and
Subtract reject boolean targets and directly known boolean amounts.
Writing an arithmetic expression or a Sum, Min or Max whose operand
is a BoolValue also fails the structural check.
The check uses supported declared scalar and union types. It leaves fields
annotated as Any, unresolved annotations, and operands with unknown
results to ordinary validation. Defaults and bounds do not establish a type,
annotation expressions are not executed, and operators such as + are not
assumed to return numbers. Native state evaluation and TLC retain their
existing limits on what they can evaluate or export.
For ordered comparisons (<, <=, >, >=) involving BoolValue, native
evaluation retains standard Python comparison semantics (False < True), whereas
TLC export refuses ordered comparisons (ExportError) because TLA+ booleans have no
ordered relation. Equality and inequality (==, !=) are supported natively and in TLC.
TLC exports boolean values and equality/membership within proven boolean domains; it checks roots
and writes instead of trusting annotations. It explicitly refuses numeric uses
of BoolValue, mixed boolean/integer domains, ordered or null comparisons, and
numeric field constraints on these values. Existing unsupported predicates (for
example a Min/Max expression) still refuse export. A refused fallback remains
INCONCLUSIVE with tlc.not_exported, never an approximated proof.
Enum constant lookup
Lookup(Account.kind, {Kind.STANDARD: 60, Kind.PRO: 30}) is an integer-valued
expression that composes with arithmetic, predicates and effects. The table must
cover every member of one enum; values must be integer constants, excluding bool.
The constructor copies the table. Params and quantified/scoped fields work as
selectors. An unmatched selector raises an evaluation error, with no default arm.
Scalar enums retain Python equality (IntEnum/StrEnum match their underlying
values), consistent with ordinary DSL comparisons and state identity.
TLC exports literal enum selectors and fields whose roots and writes are known to contain members of that enum. It explicitly refuses other selector domains; this prevents scalar-enum encoding from hiding an invalid native selector.
Integer floor division
Integer expressions support // and reflected forms (100 // Account.leverage),
including Params, scoped fields and aggregates. The result rounds toward negative
infinity: -5 // 2 == -3, 5 // -2 == -3. Integer operands produce integer results. Native evaluation follows Python numeric
semantics, including bool/int and equal integer/float values; other operand types
are rejected. TLC retains its existing integer-only numeric domain. A literal zero divisor is a structural error;
a state-dependent zero divisor becomes an evaluation finding and fails the check.
TLC supports provably integer numerators and nonzero constant integer divisors
(including bound Params). It checks root values and writes rather than trusting
annotations; bool/float numerator domains and dynamic divisors are explicitly refused, leaving a capped check INCONCLUSIVE; no
approximate division or ignored zero case is exported. / and % are not added.
Scenario and Flow
Scenario(action=..., given=[...], then=[...], expected=Expect.PASS) checks one
action. then accepts predicates and Emitted checks. Expect.FAIL expects
pre-execution rejection, not a runtime defect.
Flow(given=[...], steps=[...]) executes a journey. Steps mix actions with
Assert(predicate) and Emitted(EventClass) checkpoints. given is required;
given=[] starts with an empty world. Only present instances are available, and
each accepted step's state feeds the next step. A rejection or defect fails the
flow. Both declarations accept id, name and description. A flow name is
a display label in terminal, JSON and show flow; selection still uses its id.
Unnamed flows retain their previous report shape. The tutorial shows complete examples.
Queries
| Declaration | Requirement |
|---|---|
Reachable(predicate) |
A matching state can be reached from each root |
Unreachable(predicate) |
No matching state can be reached |
AlwaysHolds(predicate) |
The predicate holds in every applicable reachable state |
NoDeadEnd(goal=predicate) |
A goal state remains reachable from every reachable state |
DeadActions() |
Assess which actions can never fire in the explored model |
Each accepts id, label, max_states and one optional initial source:
given, given_any or initial. Queries with none inherit the canonical roots.
NoDeadEnd is recoverability, not a guarantee that every execution terminates.
Excluded event-input actions are unassessed, not dead.
0.3.0. With slicing, NoDeadEnd can prove recovery on a projection using
intact actions that reduce the rank to a goal. If that certificate fails,
the exact path can omit local boolean disablers
when every affected flag has an always-available action that restores it. The
goal and invariants must be independent of those flags, and terminal-lock
dependencies are preserved. A complete, clean proof within the budget reports
the smaller graph, with restorable_flags in its JSON slice summary. When
the smaller graph cannot certify a pass, the full slice determines the verdict
and any shortest counterexample and its diagnostics.
Spec, Contract and loading
Spec(id=..., name=..., actions=[...], invariants=[...], scenarios=[...],
flows=[...], queries=[...]) is the root. It can additionally list entities, events,
scopes and lifecycles, which are otherwise derived from referenced behaviour.
Spec.initial supplies canonical roots; Spec.max_states sets the canonical
exploration budget and the default query budget (default 10,000). A query with
max_states=None (the default) inherits this value, including with its own roots.
An explicit query budget wins; check --max-states N overrides both for one run.
0.2.0: omitted query budgets inherit Spec.max_states rather than
always using 10,000. Use an explicit max_states=10_000 on a query to retain
the old budget. Inheritance is resolved per check, so a shared query can be used
with different Specs without being mutated.
Contract(id=..., actions=[...], ...) is an explicit reusable fragment with the
same content lists. Spec(imports=[contract, ...], ...) combines those lists
with the root's own. Contract version is descriptive metadata, not a resolver
that downloads dependencies.
Load one entry point: a spec.py directory or an explicit Python file. Multi-file
models should be packages with __init__.py and relative imports. List behaviour
explicitly: merely importing a file does not register its actions or properties.
The loader names empty ids from variable names, warns about unlisted behaviour
and unreachable files, and rejects multiple Spec roots in one import graph.
An empty behaviour model is an error.
The taskboard and broker examples show composition. Use
analint show contract ID -p PATH to inspect a contract's public surface.
Reusing a Spec with invocation settings
Available in 0.1.0.
Keep actions, constraints, flows and properties in one root model. The Python verification functions take selection and budgets separately from that model:
from analint.validator import validate_spec
# spec is the same already-declared Spec on every call; explicit ids are required.
checkout_result = validate_spec(spec, checks=["flow:checkout"])
property_result = validate_spec(
spec, checks=["query:shipment_keeps_reservation"], max_states=100, cache=True
)
full_result = validate_spec(spec)
validate(path, checks=[...]) provides the same contract for a loaded file.
Neither function edits the declaration lists, query budgets or fixtures. Results
with a selection describe its scope; only that scope is established by PASS.
Structural checks always cover the whole model, and reachability checks retain
dependency-related invariant proofs and action-defect coverage. 0.3.0:
sliced selections report actions outside that coverage in
selection.unassessed_actions. Unrelated defects encountered during exploration
go into model_findings with model_coverage, outside the selected verdict.
An unfiltered run still aggregates all checks and defects. See the
CLI selection contract for
supporting checks, scenario/tag compatibility and trace settings. A static shared
model for two flows and cross-flow properties is in benchmarks/shared_checks.py.
0.2.0: repeated checks and traces observe edits to nested
invariant expressions and lists as well as replacement of the whole expression.
Compiled invariant checks and applicability plans live only for one synchronous
exploration or verification scan; they are not stored on declarations or carried
into model copies. Do not edit a model during a running check. A shallow Python
or model_copy() copy still shares its nested declarations; changing them also
changes the original. This repair does not re-expand parameter families or add
newly referenced entities to an existing Spec automatically; see
parameterized actions.
A second example, benchmarks/independent_checks.py, has an independent failed
invariant: selecting safe_a succeeds while the full check fails. The report
preserves the B findings without treating them as a failure of A's selected check.