Modeling a target#
How to decide what to write where. Short rules; every word is defined in the glossary of the model.
Decide what each fact is#
Fact |
It is |
Written as |
|---|---|---|
a thing tests use (a command runner, a console, a log stream) |
a capability |
a factory, |
a condition that is made true and checked (the container runs, the session is open) |
a state |
an action with a probe, |
what a target is made of |
a target file |
|
what you want true when the target is up |
a goal |
a state under |
something that holds without ITF (the rack is powered) |
an assumption |
|
an order between states that no part knows about |
a relation |
|
a value that differs per setup |
a setting |
an override file |
a check that needs code |
project code |
|
Design a capability#
Name the contract after what a test does with it, not after the machine:
exec.command, notdocker.run.Publish what the object offers by its return type; members starting with
_are not part of the shape.Take what you need through slots: a parameter annotated with your own Protocol that sets
__contract__and lists only the members you use. Never import another pack.Settings go in a frozen dataclass named
config. Every field has a type; secrets are marked.Construction starts nothing. Starting is an action’s job, so the plan can order and verify it.
Design a state#
One action makes the state true; its probe says whether it holds, and is cheap and safe to repeat.
after=lists what must hold first;breaks=lists what the action destroys (a restart breaksnetwork.reachable). Only name states the action itself depends on: an ordering between your action and another pack’s belongs to the target file (relations:), because the pack cannot know which other packs are listed.Several states from one action:
also=with a probe per state (@action.probe_for("network.reachable")).Never let a probe change anything.
Choose roles and scopes#
A role is the name tests use. Use the contract’s usual name (
command,files,console) unless a target has two of the same kind (consoleanddebug).Two candidates for one slot of a factory:
bind:on the role says which role the slot uses.Two candidates for one slot of an action:
actions:withbind:says which role the slot uses.Two actions that could make one state true:
by:on the goal says which.An order between states that the actions do not state:
relations:.One device is one scope:
scopes: gw:with its own roles,share:for the root roles it uses.
Project parts#
Code in the project’s policy (policy.py) belongs to the pack local: the label is local.<function>. Use it for
what is specific to this project and does not deserve a pack: waiting for a daemon, a status LED. A project
action is always considered when planning, if all its slots can be filled in the scope: if it makes a state true
that a pack’s action also makes true, every target file that uses the state names one with by:.
Quick review before adopting a pack#
Read its README: label table, prerequisites, target file excerpt.
itf validatea target file with it; read the plan.Run
itf contracts map: which names does it offer and expect, and do your tests agree?Run its conformance checks against your own fulfilling parts.