# HZ-QUEUE-01 / MIT-QUEUE-01 fictional teaching contract

This is an authored engineering decision for this example, not approved customer intent, a WebSocket protocol or safety/risk acceptance. The old article's slow-tab table was an unexecuted plan; it did not supply observations inherited here.

Topology: one single-threaded deterministic producer and exactly two distinct in-memory deque-backed consumer queues, healthy and slow. Each queue has capacity3 messages. Each supplied payload is exactly4 bytes (a caller precondition, not a runtime validator); hence the declared maximum queued logical payload is12bytes per queue. Logical payload bytes are the sum of queued payload lengths. This excludes Python object/allocator overhead, delivery-history/observer memory, total heap/RSS, transport buffers and other consumers. Separate deque references to the same bytes still count per logical queue; this is not physical-allocation measurement.

Schedule: publish messages1..6, drain healthy after each, never drain slow during the burst. Observe both immediately after each publish and after each drain. Then explicitly replace/rejoin slow and publish message7; drain healthy and new slow. These are seven selected publications per variant, not a measured2x-rate benchmark, duration/load sweep or scheduler/interleaving test.

Overflow policy: before enqueuing a fourth message to a full queue, clear its three queued messages (12logicalpayloadbytes), mark ONLY that consumer inactive with reason overflow, report disconnected-overflow with enqueued:false, cleared_messages:3 and cleared_payload_bytes:12. The triggering offered message is not enqueued. Later publications skip that inactive consumer and report inactive. Healthy enqueue/drain and all seven healthy deliveries must continue. Disconnect is a local state transition, not an actual network/socket close.

Rejoin: an explicit join of an existing consumer replaces its old session whether active or inactive, closes/clears the old queue and increments generation1→2. It preserves an existing overflow reason; otherwise reason becomes replaced. The new generation starts active with an empty queue. Only future message7 is delivered to rejoined slow; no replay of messages1..6 or automatic reconnection is promised. The audit observer keeps an old-session reference to inspect its cleared state; the core stores only the current session mapping, no unbounded retired-session registry.

Input payloads and full literal expected receipts, queue contents, count/byte fields, generation/active/reason, delivered histories and retired-session state are fixed in expected.json before execution. The oracle must not infer expected behavior from Baseline/Corrected/RejectAllControl. Compare exact JSON types/keys/values. Constructor/setup/drain/rejoin/publish units and snapshot observations are distinct. Resource-only assessment of these same observations is a deliberately weaker gate; rejection of all publications can satisfy bounds while violating required healthy progress.

The baseline's unguarded append is a seeded implementation defect relative to this teaching contract. The corrected implementation enforces this one chosen policy. RejectAllControl is an intentionally inadequate implementation variant, not a discovered production bug. No alternative overflow policies, authentication, real IPC/WebSocket/browser behavior, concurrent invariants, partial subscribe/connect atomicity, cache coherence, persistent queues, arbitrary payloads, unbounded client counts, universal memory safety, exhaustion/crash recovery or certification is claimed.

The hazard chain must preserve three different decisions: applicability/ACCEPT means mitigation work is required; selected technical evidence can pass this contract; authorized residual-risk acceptance remains NOT ASSESSED. Lost slow-consumer messages, fresh-session-only rejoin and the excluded scenarios remain explicit residuals. A passing fixture or catalog check does not grant risk authority or approve a release.
