0033. Corrections from the 2026-10-05 docs audit
Status
Accepted. Amends the behaviour described in ADR 0012, ADR 0020 and ADR 0027 without editing them; where this record and one of those disagree, this record wins.
Context
The 2026-10-05 documentation refresh traced each use case and spec against the code and found four defects that touch contracts or atomicity:
- Partial write behind a 409.
RequireIdempotencyKeybinds its transaction into the request context and, after the wrapped handler returns, commits that transaction for every non-panic response so the response can be stored against the key. The use cases join that transaction (UnitOfWork.Executeis a no-op join when one is already bound), so nothing else rolls their writes back.AssignLaboron a reassignment saves the associate (closed-interval hours) and then the assignment; if the secondSaveloses an optimistic-concurrency race (ADR 0021,409 concurrent-modification), the associate's hours write from the same request was committed anyway. - Unit mix-up in the measured-rate fallback.
ProposePathPlanfed labor-performance'smeanActualSeconds(a duration per task) straight intoceil(charge / rate), whererateis units per head per hour (the caller'splannedRate). A 36 s task proposed 100 heads for 3600 units instead of 36. - Misleading name on a published field.
observedIdlePcton the staffing-gap responses carries a fraction in[0, 1], not a 0–100 percentage. GET /readyzserved but undeclared inapis/openapi.yaml.
Decision
- Run the wrapped handler inside a savepoint. The middleware keeps its
outer transaction and the idempotency row inserted at the start, then
begins a savepoint and binds that into the request context. A
2xxresponse releases the savepoint (domain writes and outbox rows commit together with the idempotency row, as before). Any other status rolls back to the savepoint — the request's domain writes and outbox rows vanish — and the idempotency row is then updated with the failed response and committed, so replay of the same key and body returns the same error (ADR 0027's stored-response semantics are unchanged). A panic still rolls back the whole outer transaction. - Convert the measured duration to a per-head hourly rate.
resolvedRate = 3600 / meanActualSeconds, assuming one task is one unit ofcharge. A non-positive or non-finitemeanActualSecondscannot be converted and is treated exactly likeErrMeasuredRateUnavailable(fail-open: rate 0, 0 heads,rateSourcecaller).resolvedRatekeeps its field name and type; its value forrateSource=measuredis now in the same unit as a caller-suppliedplannedRate. TheShiftPlanProposedevent'splannedRatecarries that same resolved value, so its documented unit ("units per head per hour") is now true for measured proposals too. - Add
observedIdleShare, deprecateobservedIdlePct(additive). Both fields carry the same fraction, are present together and omitted together when no signal exists.observedIdlePctstays on the wire with an unchanged value so no consumer breaks and is markeddeprecated: truein the OpenAPI schema; removal needs a future ADR. The Go port methodports.IdleShareClient.IdleSharePctand the use-case fieldStaffingGap.ObservedIdlePctkeep their names (internal, documented as a fraction) to keep this change surgical. - Declare
GET /readyz(200 {"status":"ready"}/503 {"status":"not_ready"}) in the OpenAPI spec, and add a router↔spec drift test so a served route can no longer be missing from the spec.
Consequences
- A failed idempotent request leaves no partial state. The stored
409is still replayed for the same key, so a client that wants a fresh attempt must still use a newIdempotency-Key(unchanged). - Savepoints add one round trip each way per protected request; the two creation POSTs are low-volume.
- Measured-rate proposals change relative to the pre-fix output (which
divided the charge by raw seconds per task): a 36 s task now proposes
ceil(charge / 100)heads instead ofceil(charge / 36). Callers who relied on the old (wrong) numbers see a one-time change. Caller-suppliedplannedRateis unaffected. The "one task = one unit of charge" assumption is recorded here; if charge is ever measured in a different unit than labor-performance's tasks, the conversion needs a unit factor (a product decision, not made here). observedIdlePctis a deprecated alias until a future ADR removes it.- Not changed, deliberately: the staffing gap still counts active
assignments across every building (the assignment model carries no
building or shift), and the unused
domain_eventtable remains (additive migrations only). Both are reported for a product decision.