Paddock lockdown
A staff member supplies a paddock number and asks to lock it down. Three modules and a system file define the permitted operations.
What the interface says
Read park/doors.brass without its bodies:
- What
lockdown_requestmay do. Read an enclosure and close a door throughdoors, and nothing else:doorsis its only access parameter.system.brasspermits paddocks 1 to 3 and gives each call two seconds. - Who may cause the effect.
closetakes aDoorOperator. Nothing that holdsDoorscan close a door without one.lockdown_requesttakes plainStaffand a paddock id. Before callingclose, its helpers testwho is staff.DoorOperatorandp is enclosures.OpenPaddock. - What it promises. The paddock that comes back has the id that was asked for, and its enclosure is
Secured: that is the return type.
Read park/enclosures.brass: Enclosure says which states a paddock may enter. Breached has no edge out; repair is outside this program. Secured has no edge to itself: locking down a secured paddock is not a transition this machine declares.
The body tries close up to three times, retrying every failure, including Unauthorized. The range bounds the attempts even if the loop never breaks. last starts before the loop and holds each attempt's result. This retry policy is not in the interface.
The paddock's state enters the program through enclosure, an allow whose result type carries the machine. The runtime checks that the reply fits the type. Whether it describes the actual enclosure is assumed.
What breaks if it changes.
- Change
closeto takeStaff→ still checks. The operation no longer requires a door operator. The helper's stricter parameter and test remain, but any holder ofDoorscan callclosewith plainStaff. - Change
OpenPaddocktoPaddockinlockdown→ rejected; the wrong edit below.
Which promises are checked, and where?
Proven
lockdown's transitionOpen enters Secured:pis anOpenPaddock, and the edge is declared.lockdown'safter:withcopies every field it does not name.- The return type
SecuredPaddock: the checker seesstatus enters Enclosure.Securedin thewith. - The loop runs at most three times:
for attempt in 1 to 3is bounded by its range.
Enforced
enclosure's andclose'sbefore paddock in paddocks: authority checks; an id outside the grant is refused withUnauthorizedbefore the call is sent.enclosure'safter result.id == paddock: the runtime checks the successful reply; a violation aborts.lockdown_as's andlockdown_request'safter result.id == paddock: they rest onenclosure'safter.- Each
closecall ends withindeadline_ms, with a reply,Unavailable, orUnknown. - 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 paddock
enclosurereturns is reallyOpenin the park: the reply's shape is checked; its truth is the host's. - That
whois entitled to act as a door operator: a refined record is not a credential; the host's authentication supplies that. - That the door is physically closed when
closereturnsOk. - That a retry after
Unknownis safe: closing a closed door is harmless, and nothing in Brass checks that anallowis idempotent. The spec's convention (§5.2) asks a key parameter of anallowwhose repeat would be a second effect; a repeated close is the same effect, soclosedeclares none.
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 lets any paddock be locked down:
# park/doors.brass — wrong edit
fn lockdown(doors: Doors, operator: staff.DoorOperator, p: enclosures.Paddock) -> Outcome<enclosures.SecuredPaddock>
The body's transition no longer has an edge from every possible source state:
fault edge not established: p.status enters enclosures.Enclosure.Secured
source states not covered: Secured, Breached
at park/doors.brass: fn lockdown
fix: narrow p to a state with that edge, or test p is enclosures.OpenPaddock first
The machine declares no move from Breached or Secured into Secured. Closing a door does not repair a breached enclosure, and this program has no transition for locking down an already secured paddock.
What these declarations leave open
- That the paddock is still open in the park's records when the door closes.
OpenPaddockdescribes the value read. - That the same paddock's state moved. The machine enforces the state graph, not the history of one entity;
after result.id == paddockis what ties the result to the request here. - A door operator's assigned paddocks. This program checks the role but declares no assignment check. A
beforeonclosecould require one. - Which failure
closereturned on the last attempt. The retry replaces it with its ownUnavailable; the transcript holds the original.