Task: Read a structure's version from its legs
Table of Contents
This page documents a task in the Model trade structures story. It captures the goal, current status, acceptance, and any notes or results.
1. Goal
A structure's internal version is computed from its legs and membership, never stored.
2. Status
| Field | Value |
|---|---|
| State | DONE |
| Parent story | Model trade structures |
| Now | Nothing. |
| Waiting on | Nothing. |
| Next | Nothing. |
| Last touched | 2026-10-05 |
3. Acceptance
- A read returns a structure's internal version, which moves when a leg's component version or the membership changes.
- The story records that the external version lives on the agreement, which the authorisation and agreement work owns.
4. Plan
(Implementation strategy. Written when work starts; key decisions
are distilled into the parent story's * Decisions at close, but the
plan itself stays — it is the historical record of what we did.)
5. Measurements
Every number this task claims about a tree, with the command that produced it
and the commit it was measured at. A number without both is not a measurement,
because a clean-up record describes a tree and trunk moves under a branch: a
consumer count, a gate's component count and a suite's size all change with no
code changing, and the reader of a bare number cannot tell which tree it came
from. Where the raw output matters, put it in an evidence/ file beside the
task and name that file in the Command column.
| What | Value | Command | Commit |
|---|---|---|---|
| static checks | 4 of 4 pass | compass check --only sql-reachability --only handler-permissions --only model-drift --only sql-hygiene |
feature/read-a-structures-version-from-its-legs |
6. Notes
7. Test Scenarios
Manual QA scenarios (scaffolded via compass add test_scenario)
that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.
| Scenario | State | Notes |
|---|---|---|
8. PRs
9. Review
| Comment summary | File | Decision | Notes |
|---|---|---|---|
10. Result
ores_trading_structure_version_fn returns a structure's internal version by
folding its legs rather than storing a counter beside them. A leg's version
moves when any of its components is written, because the component tables now
bump the trade's version, and the membership carries its own version, so
linking or unlinking a leg moves the deal too.
The external version stays on the agreement, which the authorisation and agreement work owns.
This needed :parent_entity: trade and :bump_parent_version: true on the
seven children of the trade. Without it a component write did not move the
trade's version, so the fold would have missed exactly the case the acceptance
names. trade_link is left alone: it holds no facts, so its writes are not a
change to a trade's terms.