DR-002-Arch: Target Composition#
Date: 2026-11-03 Status: Accepted
This record follows the Eclipse S-CORE Decision Record convention; see the ITF decision-record index.
Context#
ITF models a test target as one class, Target, subclassed per environment and created by one pytest plugin per
environment. Bring-up order lives in each plugin, tests call fixed methods, and every mistake shows up at run
time.
The design rests on four principles: a planner (OCTO) that plans from declarations only, parts that meet only through names, probes as evidence, and teardown from observed state. This record decides how a target is described and how parts declare themselves. The words are defined in the glossary of the model.
Decisions#
Vocabulary. A target is what ITF builds for tests to use: the system under test with everything needed to reach it. A target file (
*.itf.yaml) describes it, the Bazel ruleitf_targetcompiles it, and tests use it astarget.<role>. ITF composes a target from parts: “composition” names the mechanism, never a file or a rule. A part is a capability factory or an action. Contracts are of two kinds: capability contracts, fulfilled by capability factories (@capability), and state contracts, fulfilled by actions (@state, with probes). A target file lists capabilities by role and states as goals.ITF knows no contracts. A contract is whatever name two parts agree on, with whatever shape they publish and expect. ITF lets projects discover (
itf contracts map), define (optional definition files,itf contracts new --from-usage) and enforce (itf contracts check --rules) their contracts. It does not ship a vocabulary everyone must follow. The ITF team maintains the contracts its own packs use, with conformance checks, as a supported set, not a standard.A target file is keyed by role.
capabilities:maps a role to a factory label (command: docker.exec) or to a mapping withfactory,with,bindorremove: true. A role is the stable key for duplicates (two consoles on one board), overrides, includes, scopes and tests (target.debug). Docker Compose does the same.Everything is explicit, and nothing is required. Goals are listed, not inferred (
state, plusbywhen two actions could make one state true). No part enters a target unless the target file lists it. An empty target file is valid. A slot with one candidate is bound to it; a slot with several says which withbind:(factories) oractions:(actions). Nothing is derived.Actions are bound like factories. An action fills each slot with the role that
actions:names, else the one role of the slot’s contract in the scope, else it cannot run there. It is a candidate for a state only if all its slots can be filled.A target file states the orderings between packs. An action carries only the
afterandbreaksof the states it itself depends on. A pack does not know which other pack a project combines it with, so no pack hard-wires an ordering on another pack’s state. The target file’srelations:add those orderings. A relation on a state that no listed action makes true, and that is not assumed, is a compile error.The command line is the lifecycle:
itf validate,plan,graph,up [--detach],downandtest, plusdoctor,diff,evidenceanditf contracts map|new|check|reference. Nothing beforeuptouches hardware.downunwinds from observed state, never by replaying the plan.Parts declare themselves in code.
@capability("exec.command")wraps a factory, and@state("platform.up", after=..., breaks=...)wraps an action with@<action>.probe. A slot is a parameter whose annotation, the consumer’s own Protocol, carries__contract__.config: <dataclass>is the settings schema. The label is<pack>.<function>; the project’s own parts arelocal.<function>(decision 14). Shapes check call structure, not type assignability or semantics. Capability-provider majors are checked by preflight and policy. State@majoris part of the exact full runtime token, never stripped or resolved to an implicit latest; reports retain the state major.Override files are target files that hold only what changes, merged by role.
remove: truetakes a role out. A different factory in the same role starts from no settings.Tests ask for roles:
@itf.requires("<role>", shape=YourProtocol)andtarget.<role>; the consumer owns the Protocol with its__contract__. Older member-name lists remain supported without call-structure checks. A requirement can also sit on a test class, a module or a package (itf_requires = itf.requires(...)); a test needs every requirement on it and above it. Collection preflight groups exact consumer profiles by scope, role, contract and required major without merging different signatures. Loose gating deselects incompatible or unknown tests;--itf-strict-gatingrejects collection for applicable incompatible or unknown APIs. Missing roles/scopes and explicit contract/major differences remain not applicable and deselected; missing provider-major metadata is unknown for a pinned major.One session, one discovery.
Session(target=..., overrides=...)is the one session of every front.resolve()plans and builds nothing.bring_up()runs the actions.reach,discard,renewandprobechange and read state during tests, always through the planner. The target file is found in the same order by pytest, the command line and Bazel: explicit value,ITF_TARGET,pytest.ini,pyproject.toml.Packs load from labels.
docker.execloads the packdocker, from ITF, from an installed entry point, or from the target file’spacks:key.Bazel:
itf_targetcompiles the target file during the build, so a target file that does not compile failsbazel build.py_itf_test(target = ...)runs tests against it. The target file reaches the test as written; no document is generated.itf_targetsupplies the target file’s${NAME}values (filesfor built files,envfor the rest).Existing tests keep running. The compatibility layer,
score/itf/compat, serves the original plugins, fixtures, options, imports and Bazel labels over the packs, whose classes carry the original names.The project’s policy. A project’s own ITF code (
itf_verify,itf_teardown, its own capability factories and actions) is its policy: Python modules explicitly listed in YAMLpolicies:, not discovered from directories. Relative paths are YAML-relative; absolute paths remain absolute, and inline YAML uses invocation CWD. Direct Session, CLI and pytest share this selection; see the authoring guide. Conftests stay pytest’s, for fixtures. The policy’s parts are labelledlocal.<name>, andlocalis reserved: no pack may be namedlocal, solocal.xalways means this project’s policy. The policy outranks the target file, which outranks the packs. The pack for the test host islocalhost. A project’s rules over contracts are contract rules (itf contracts check --rules rules.yaml). API baselines useitf_expect = [YourProtocol]: all matching capabilities in every scope are checked during resolution, even without test consumers; missing contracts are not required. Baseline violations reject resolution independently of strict/loose test gating.
No trust#
Nothing is accepted because a name matches. Each rule comes from the party that cares about it:
Rule |
Checked against |
When |
|---|---|---|
a slot’s expected shape |
the shape the offering factory publishes |
target file |
an action’s |
every other action’s claims and the target file’s relations |
target file |
a part’s settings schema |
the target file and override values |
target file |
a pack’s host prerequisites |
the host ( |
before bring-up |
a test’s requirement |
the composed target |
collection |
an action’s claim to have made a state true |
its own probe |
after it runs, before reuse, at teardown |
a contract’s conformance checks |
each part claiming the contract |
CI |
Alternatives#
Option |
Rejected because |
|---|---|
Compose the target entirely with pytest fixtures |
Fixtures already handle test setup and teardown, but their dependency graph is tied to pytest execution. A fixture-based implementation would need additional machinery for target-file compilation without pytest, explicit state goals and probes, re-planning after changes, and standalone CLI lifecycle operations. The two mechanisms overlap; the separate planner is justified only if these additional workflows are needed. |
Keep |
Keeps fixed methods and per-plugin ordering; checks stay at run time |
A target file keyed by part label, or a list of parts |
No stable name when a part is used twice, and none for overrides and tests |
Derive missing parts when one fits |
Hidden parts in a plan; explicit lists are easier to review |
A fixed contract vocabulary with a registry and namespaces |
ITF cannot know every project’s devices; a registry needs governance nobody asked for |
Names owned by contracts ( |
Turned target file into filling fixed slots and lost OCTO’s idea of building from parts |
Starlark recipes compiled to a document read by hooks |
A second format, and target files must work without Bazel |
Naming the file and rule after the mechanism ( |
The first names how ITF works, not what a test gets; the second adds a word next to |
Orderings declared by packs ( |
Wrong for a machine that is already running; the target file knows, the pack does not |
Consequences#
A project that wants its own contracts needs no registration or release. It names them, maps them, and adds definitions when it wants meaning, versions or conformance.
Every target file states the orderings between the packs it combines. The starters show the common ones.
Two actions that could make one state true, or a slot with two candidates, are errors at target file time. The error names both and the line to write.
Common original plugin entry points and
Targetmethods are served by the compatibility layer (score/itf/compat); migration differences are listed indocs/how-to/migrate.md.A different kind of target is a different target file;
include:shares the common part.