--- id: architecture/oq-13-cas-failfast name: Backlog — CAS-before-unpack fail-fast pre-check on push status: pending depends_on: [] scope: narrow risk: low impact: component level: implementation tags: [optimization-backlog] --- ## Description Optimization backlog item from ADR-013 (§7, §Consequences): a pre-unpack CAS pre-check on receive-pack — reject commands with obviously-wrong old-ids before reading the pack body, failing fast instead of ingesting a pack whose refs would be rejected anyway. The protocol-correct order (unpack-first, then per-ref checks) is what v1 implements; this is an optimization, additive, and two-way (internal behavior, not wire shape — the report shape is unchanged). ## Work When receive-pack implementation is on the critical path for a deployment with heavy stale-push traffic (measured, not hypothetical): add the pre-check to the transport push state machine, after command parse and before ingestion. Rejected refs report the same `ng `; the pack body is then drained (or the connection closed per the substrate's error rule). ## Verification - All existing push tests still pass (real `git push` against the transport). - A stale-old push errors before the pack body is fully read (observable via the body-budget counters or a truncated-body test). ## Out of scope - Changing the report shape or the protocol order (ADR-013 §7 stands). ## Summary > Filled on completion.