FA-7781 / Connection lifecycle / Open access
Graceful drain completes when active stream count reaches zero · case 01
Graceful drain completes when active stream count reaches zero.
ROOT CAUSE
The faulty implementation uses `"complete" if active == 0 else "wait"` for the graceful-drain-completes-when-active-stream-count-reaches-zero decision.
VERIFIED REPAIR
Apply the explicit graceful-drain-completes-when-active-stream-count-reaches-zero contract, including the tested boundary and negative cases.
Unsuccessful approach: The attempted repair uses `"idle" if not draining else ("complete" if active == 0 else "wait")` and still violates a separate fixture.
Case contract
Given draining, active, expired, graceful drain completes when active stream count reaches zero. Return the protocol decision or transformed value; fields are validated and fixtures state boundary outcomes.
Why this case matters
This deterministic connection lifecycle model isolates the graceful-drain-completes-when-active-stream-count-reaches-zero policy at a network component boundary.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import ipaddress
import re
from urllib.parse import urlsplit, urljoin
N = 1
observations = []
def solve(draining, active, expired):
return "complete" if active == 0 else "wait"
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_fixtures = ["check('fixture 1', solve(False, 0, False), 'idle')", "check('fixture 2', solve(True, 1, True), 'force')", "check('fixture 3', solve(True, 0, False), 'complete')", "check('fixture 4', solve(True, 1, False), 'wait')"]
for _line in _fixtures[N % len(_fixtures):] + _fixtures[:N % len(_fixtures)]:
exec(_line)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 2 | wait | force | Failed |
| fixture 3 | complete | complete | Passed |
| fixture 4 | wait | wait | Passed |
| fixture 1 | complete | idle | Failed |
SHA-256 / aea7037f080ccf11813abc2244c42f7ed67dc442ec2115f2ec943281bfdb91af
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import ipaddress
import re
from urllib.parse import urlsplit, urljoin
N = 1
observations = []
def solve(draining, active, expired):
return "idle" if not draining else ("complete" if active == 0 else "wait")
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_fixtures = ["check('fixture 1', solve(False, 0, False), 'idle')", "check('fixture 2', solve(True, 1, True), 'force')", "check('fixture 3', solve(True, 0, False), 'complete')", "check('fixture 4', solve(True, 1, False), 'wait')"]
for _line in _fixtures[N % len(_fixtures):] + _fixtures[:N % len(_fixtures)]:
exec(_line)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 2 | wait | force | Failed |
| fixture 3 | complete | complete | Passed |
| fixture 4 | wait | wait | Passed |
| fixture 1 | idle | idle | Passed |
SHA-256 / d6e3981375727146d4d09e3e2ae8da6949ce27d7efd0128934e4d065fd68f4a5
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import ipaddress
import re
from urllib.parse import urlsplit, urljoin
N = 1
observations = []
def solve(draining, active, expired):
return "idle" if not draining else ("complete" if active == 0 else ("force" if expired else "wait"))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_fixtures = ["check('fixture 1', solve(False, 0, False), 'idle')", "check('fixture 2', solve(True, 1, True), 'force')", "check('fixture 3', solve(True, 0, False), 'complete')", "check('fixture 4', solve(True, 1, False), 'wait')"]
for _line in _fixtures[N % len(_fixtures):] + _fixtures[:N % len(_fixtures)]:
exec(_line)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 2 | force | force | Passed |
| fixture 3 | complete | complete | Passed |
| fixture 4 | wait | wait | Passed |
| fixture 1 | idle | idle | Passed |
SHA-256 / b29f5b82b1d121154c2be897f8b3c06d6a3eea35a93b6c86e86585a610dfcba6
Verification & scope
Bounded deterministic policy model over validated inputs; not a complete protocol stack or an interoperability claim. The five variants rotate the same explicit fixture set. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:38:15.237978+00:00.
Case digest / 296233a7741d5c71b2a0fe8430390cab7847d3a3a963bf5ebb0fa14abfa8cebe