Feeding delivery
A keeper delivers the pending feeding for a paddock. The delivered feeding records who signed for it; a planned feeding has no signer. Four modules and a system file define the workflow.
What the interface says
Read park/feeding.brass without its bodies:
- A field that exists in one state.
delivered_byis present exactly whenstatusisDelivered. Reading a signer from aPlannedfeeding is rejected. - How a value enters that state.
delivertakes aPendingFeedingand aDelivererand returns aDeliveredFeedingwhose signer is the deliverer's badge. Itsaftermay nameresult.delivered_bybecauseresultis known to beDelivered. - Who may deliver.
Delivereris a keeper.delivercannot be called with plainStaff. - Library functions.
plan,skip, andsignerhave no caller in this program; they are the module's other operations, shown so the machine's three states each have a use.
In park/control.brass, deliver_feeding holds one access, registry, for paddocks 1 to 5. It tests that who is a Deliverer, then calls a private helper to read, deliver and save the feeding.
Its after promises that the result is for the requested paddock and signed by who.
Adding delivered_by connects the state declaration to the caller:
- The field's
whenattaches it toDelivered. deliveracceptsbyand supplies the badge in itswith.deliver'safterties the badge toby.controlestablishes aDelivererand includes the signer in its result contract.
plan is untouched because a Planned feeding must not mention the field. The trials behind this design are described in principles §4.
What breaks if it changes.
- Add a state to
FeedingStatus→ still checks:deliver'swithtransitions fromPlannedonly; the interface hash changes, so the change is detectable. - Rename
delivered_bywithout updating its uses → rejected:signer's body,deliver'safterand body, anddeliver_feeding'safterstill name the old field. - Drop the
istest fromsigner→ rejected; the wrong edit below.
Which promises are checked, and where?
Proven
deliver's andskip's transitions fromPlanned: a declared edge from the one source state.deliver'safter,delivered_byincluded: thewithsupplies the field on enteringDelivered.skip'safter:withcopies the rest.plan'safterand itsPendingFeedingreturn type: the literal's fields are known to the checker, so it satisfies the refinement on the line (spec §7.2).signerreadsdelivered_byonly insideif f is DeliveredFeeding: anywhere else is a rejection.
Enforced
pending's andsave'sbefore … in paddocks: authority checks; the runtime refuses withUnauthorized.pending'safter result.paddock == paddock: the runtime checks the successful reply; a violation aborts.deliver_feeding's anddeliver_as'safter:result.paddock == paddockrests onpending'safter, an enforced fact;result.delivered_by == who.badgefollows fromdeliver's.- The boundary check of
whoandpaddockagainst their types. - CPU and memory limits abort the task on excess. The transcript limit drops the oldest records (spec §10.1).
Assumed
- That the registry holds the feeding it saved, and that the feeding
pendingreturns is really pending there: the host implements both; the reply's shape is checked, its truth is not. - That
whois the keeper the badge says: the host's authentication.
The optional impact_modules policy reports changes that exceed the configured scope. It is separate from the promise tiers and does not reject a program. Its count is provisional (spec §10.1).
The wrong edit, rejected
A model simplifies signer:
# park/feeding.brass — wrong edit
fn signer(f) = Ok(f.delivered_by)
fault field not present on this path: delivered_by needs status in {FeedingStatus.Delivered}
at park/feeding.brass: fn signer
in scope: f: Feeding (not narrowed)
fix: test f is DeliveredFeeding first, or take a DeliveredFeeding
Writing delivered_by into a Planned literal is also rejected. The field exists only in the Delivered state.
What these declarations leave open
- Which failure
pendingreturned: not found, unavailable, or refused. A body testsx is Errand passes it on. - That the feeding is still pending in the registry when
saveruns.PendingFeedingdescribes the value read. - Two signers, or a signer on a
Skippedfeeding. Either requires changing the record declaration.