From 4de10806fb90e97e44176cdf54393baa47f7cce0 Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2026 16:15:46 +0200 Subject: [PATCH 01/12] D3: three verdicts, so the headline stops contradicting the body MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live, the command printed COPYABLE and exited 0 directly above a line saying the fees, not the strategy, would decide this member's result. PDR-0002 was written for that and never built. It is built now, and accepted. COPYABLE clears the floor and trips nothing. COPYABLE WITH RESERVATIONS clears the floor and names what it is reserving about, on the first line, so the headline alone is actionable — the middle verdict will be the common one and a vague caution would be read as noise. NOT COPYABLE does not clear the floor, whatever else is true: impossible beats expensive, and the reservations are still printed so an administrator learns why twice over. Exit codes run by severity, 0/1/2/3, a breaking change made before anything consumes it. A fourth reservation and a ceiling, decided while implementing and recorded as an amendment to the PDR rather than left in the code. The PDR said a cut-short window changes nothing beyond naming the figures extrapolated. Running it live showed otherwise: a 30-day question answered from 2.4 hours is stretched by 319, and the command printed `125.34% of their ticket per month in fees` as though it were a measurement. Past 3x that is a reservation; past 30x there is no verdict, which is the case this PDR already defined as "the data cannot support an answer", now given a threshold so it can be applied rather than argued about. Two defects found while writing the tests, both in code that was already merged or about to be: `traded on 31 of the 30 days read`. UTC day buckets, so a window exactly `window_days` long can straddle one bucket more than it has days. S10 pinned this on the path where the window is inferred; this is the other path, and it was printing an impossible sentence to an administrator. And the extrapolation reservation could never have fired in production. The command passes `window_days=None` when the window is cut short — correctly, so the monthly figures extrapolate from what was read rather than from what was asked for — which left the stretch measured against itself, always 1. It worked in every unit test because those pass the window directly. `assess` now takes the window that was *requested* as its own argument, and a CLI test drives the whole path so the reservation cannot go quiet again. Live on the trader this module is tested against, at 14:14 UTC: `COPYABLE WITH RESERVATIONS (fees, extrapolation)`, exit 1. Fifty-six tests. Agent-Session: session_01NGwPYhV6fYZhjrh41GNfJy Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NGwPYhV6fYZhjrh41GNfJy --- docs/pdr/0002-three-verdicts-not-two.md | 65 ++++++++++++- docs/pdr/README.md | 2 +- modules/screening/src/screening/cli.py | 27 +++++- modules/screening/src/screening/model.py | 39 +++++++- modules/screening/src/screening/verdict.py | 61 +++++++++++- modules/screening/tests/test_cli.py | 45 ++++++++- modules/screening/tests/test_verdict.py | 107 ++++++++++++++++++++- 7 files changed, 331 insertions(+), 15 deletions(-) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index 6464101..6ff840a 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -1,11 +1,11 @@ --- -status: proposed +status: accepted decider: "@napkinstack-admin" --- # PDR-0002 — Three verdicts, not two -- **Status**: Proposed +- **Status**: Accepted - **Date**: 2026-09-21 - **Decision makers**: @napkinstack-admin, who delegated product decisions of this kind to the framer on 2026-09-21; recorded here rather than left in the conversation @@ -119,8 +119,8 @@ applies, so the headline alone is actionable. - **The floor fails and a reservation would also apply** — `NOT COPYABLE` wins. Impossible beats expensive, and the reservations are still printed so the administrator learns why the trader is unsuitable twice over. -- **The window was cut short** — unchanged: the figures are named as extrapolated, and the - reservation thresholds are applied to them as they stand. +- **The window was cut short** — see the amendment below. The figures are named as + extrapolated, and how far they were stretched is itself a reservation. **Business rules:** @@ -188,3 +188,60 @@ measurements rather than in the verdict. - **Support and documentation**: the module's `README.md` states the four verdicts and their exit codes. An exit code is an interface and is documented as one. - **Data**: no change. The same four measurements, from the same public reads. + + +--- + +## Amendment, 2026-09-21 — a fourth reservation, and a ceiling + +**Decided by the framer**, under the delegation recorded above, while implementing this PDR. + +### What changed + +This PDR originally said a cut-short window changes nothing: name the figures as extrapolated +and apply the thresholds as they stand. Running the command against the live venue showed that +is not enough. + +A 30-day question answered from **2.4 hours** of fills is stretched to a month by a factor of +**319**. Every downstream figure — turnover, fee burden, flet's revenue share — carries that +factor. The answer said `extrapolated`, truthfully, and then printed +`125.34% of their ticket per month in fees` as though it were a measurement. An administrator +cannot act on that, and the middle verdict was not warning them about it. + +So: + +- **Extrapolation is the fourth reservation**, alongside fees, reproducibility and + concentration. It applies when the window asked for was stretched by more than **3×** — that + is, when less than ten days of a thirty-day question were actually read. +- **Past 30×**, there is no verdict at all. A single day of fills stretched to a month is not + a weak answer, it is a guess with the shape of a measurement, and the module's own rule is + that a verdict without a usable measurement is not an answer. + +### Why these two numbers + +3× is where a month's question starts resting on a week. 30× is a single day. Neither is +sacred, and both are one set of numbers for every administrator and every community, as the +business rules above require. + +Sampled live on 2026-09-21: a trader whose thirty days fit is stretched by 1× and trips +nothing; the densest trader in the test set reads about 2 days and is stretched by ~15, which +is a reservation; the 2.4-hour case is refused. + +### What it does not change + +The floor still decides `NOT COPYABLE` alone. A reservation is still never a refusal. The +ceiling is not a reservation that got stricter — it is the `NO VERDICT` case this PDR already +defined as *"the data cannot support an answer"*, given a threshold so that it can be applied +rather than argued about. + +### Success criterion + +By **2026-12-31**, no administrator has been shown a monthly figure stretched by more than +30×, and the share of real traders refused by the ceiling is under 5% of the ones screened. +Above that, the ceiling is screening out traders rather than protecting anyone, and the read — +not the verdict — is what needs fixing (`modules/screening/docs/adr/0003`). + +### Removal condition + +If the read ever covers the window it asks for reliably, the extrapolation reservation and the +ceiling both become dead code and are removed rather than left as reassurance. diff --git a/docs/pdr/README.md b/docs/pdr/README.md index e3ef59f..bbbc6e7 100644 --- a/docs/pdr/README.md +++ b/docs/pdr/README.md @@ -25,4 +25,4 @@ The PDR describes **what the product must do and why**, never its implementation | No. | Title | Status | Criterion to check on | |---|---|---|---| | [0001](./0001-charge-on-routed-volume-never-on-the-member-s-gains.md) | Charge a flat commission on routed volume, never a share of the member's gains | Accepted | 2027-03-21 | -| [0002](./0002-three-verdicts-not-two.md) | Three verdicts, not two: copyable, copyable with reservations, not copyable | Proposed | 2026-12-31 | +| [0002](./0002-three-verdicts-not-two.md) | Three verdicts, not two: copyable, copyable with reservations, not copyable | Accepted | 2026-12-31 | diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index fcdc45f..fe37095 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -14,15 +14,19 @@ import httpx from screening import venue -from screening.model import FillWindow, Verdict +from screening.model import FillWindow, Ruling, Verdict from screening.verdict import assess #: The window the command asks the venue for. Thirty days is what a monthly figure means. WINDOW_DAYS = 30 +#: Ordered by severity (PDR-0002). The renumbering is a breaking change to this command's +#: interface, made before anything consumes it: a script keeping the idiom it already has — +#: `if code == 0` — stops getting a zero for a trader the command was warning it about. EXIT_COPYABLE = 0 -EXIT_NOT_COPYABLE = 1 -EXIT_NO_VERDICT = 2 +EXIT_WITH_RESERVATIONS = 1 +EXIT_NOT_COPYABLE = 2 +EXIT_NO_VERDICT = 3 def _date(ms: int) -> str: @@ -46,8 +50,20 @@ def _parser() -> argparse.ArgumentParser: return parser +_EXIT = { + Ruling.COPYABLE: EXIT_COPYABLE, + Ruling.WITH_RESERVATIONS: EXIT_WITH_RESERVATIONS, + Ruling.NOT_COPYABLE: EXIT_NOT_COPYABLE, +} + + def _render(address: str, verdict: Verdict, window: FillWindow) -> str: - head = "COPYABLE" if verdict.copyable else "NOT COPYABLE" + head = str(verdict.ruling) + if verdict.reservations: + # Named in the headline, so the first line alone is actionable. A middle verdict that + # does not say what it is reserving about would be read as noise, and it will be the + # common one. + head += f" ({', '.join(verdict.reservations)})" # The dates of the fills actually held, never the range that was requested. held_from = _date(window.first_fill_ms) if window.first_fill_ms is not None else "?" held_to = _date(window.last_fill_ms) if window.last_fill_ms is not None else "?" @@ -107,13 +123,14 @@ def main( ticket=ticket, window_days=window.days_requested if window.complete else None, window_complete=window.complete, + window_asked_days=window.days_requested, ) except ValueError as error: print(f"no verdict: {error}", file=sys.stderr) return EXIT_NO_VERDICT print(_render(args.address, verdict, window)) - return EXIT_COPYABLE if verdict.copyable else EXIT_NOT_COPYABLE + return _EXIT[verdict.ruling] if __name__ == "__main__": # pragma: no cover diff --git a/modules/screening/src/screening/model.py b/modules/screening/src/screening/model.py index 31d42bb..6f3502e 100644 --- a/modules/screening/src/screening/model.py +++ b/modules/screening/src/screening/model.py @@ -8,6 +8,7 @@ from dataclasses import dataclass from decimal import Decimal +from enum import StrEnum #: The venue refuses any order below this notional. Not ours to change (AGENTS.md). MINIMUM_ORDER_USDC = Decimal(10) @@ -21,6 +22,22 @@ #: Share of a trader's orders a member should be able to place for the answer to be "yes". COVERAGE_TARGET = Decimal("0.80") +#: More than this share of fills posted rather than taken and a copier arriving afterwards +#: reproduces less than half of what they are copying (PDR-0002). +UNREPRODUCIBLE_ALERT = Decimal("0.5") + +#: Volume landing on this share of the window's days or fewer is a burst, not a month +#: (PDR-0002). +CONCENTRATION_ALERT = Decimal(1) / Decimal(3) + +#: A cut-short window is extrapolated to a month by this factor before the answer says so. +EXTRAPOLATION_ALERT = Decimal(3) + +#: And past this factor it stops being an answer. Live, a read of 2.4 hours was extrapolated +#: by 319 — a number with the shape of a measurement and the content of a guess (PDR-0002, +#: amended 2026-09-21). +EXTRAPOLATION_CEILING = Decimal(30) + #: Above this monthly cost, the fee burden is called out rather than merely stated. FEE_BURDEN_ALERT = Decimal("0.05") @@ -42,12 +59,26 @@ def notional(self) -> Decimal: return self.price * self.size +class Ruling(StrEnum): + """What the answer says on its first line. `NO VERDICT` is not here: it is the absence of + a verdict, raised rather than returned (PDR-0002).""" + + COPYABLE = "COPYABLE" + WITH_RESERVATIONS = "COPYABLE WITH RESERVATIONS" + NOT_COPYABLE = "NOT COPYABLE" + + @dataclass(frozen=True) class Verdict: """The answer, with every figure it rests on. A verdict without its measurement is not an answer here (AGENTS.md).""" - copyable: bool + ruling: Ruling + reservations: tuple[str, ...] + """Named in the headline, in the order fees, reproducibility, concentration, + extrapolation. Empty when the ruling is `COPYABLE`; still printed in full below when the + ruling is `NOT_COPYABLE`, so an administrator learns why a trader is unsuitable twice + over.""" ticket: Decimal trader_account: Decimal fills_read: int @@ -74,6 +105,12 @@ class Verdict: monthly figures above are extrapolated from less than that window.""" reasons: tuple[str, ...] + @property + def copyable(self) -> bool: + """Clears the venue's floor at this ticket. Reservations never make it false — a + reservation is expensive, not impossible.""" + return self.ruling is not Ruling.NOT_COPYABLE + @dataclass(frozen=True) class FillWindow: diff --git a/modules/screening/src/screening/verdict.py b/modules/screening/src/screening/verdict.py index c30b560..c24557f 100644 --- a/modules/screening/src/screening/verdict.py +++ b/modules/screening/src/screening/verdict.py @@ -10,11 +10,16 @@ from screening.model import ( BUILDER_FEE_RATE, + CONCENTRATION_ALERT, COVERAGE_TARGET, + EXTRAPOLATION_ALERT, + EXTRAPOLATION_CEILING, FEE_BURDEN_ALERT, MINIMUM_ORDER_USDC, + UNREPRODUCIBLE_ALERT, VENUE_TAKER_FEE_RATE, Fill, + Ruling, Verdict, ) @@ -29,6 +34,7 @@ def assess( *, window_days: Decimal | None = None, window_complete: bool = True, + window_asked_days: Decimal | None = None, ) -> Verdict: """Can a member holding `ticket` copy this trader, and at what cost? @@ -55,8 +61,12 @@ def assess( count = Decimal(len(fills)) buckets = {f.time_ms // int(_MS_PER_DAY) for f in fills} + # UTC day buckets, so a window exactly `window_days` long can straddle one bucket more + # than it has days — which printed `traded on 31 of the 30 days read` to an administrator. + # S10 pinned this on the path where the window is inferred; this is the other path. days_traded = len(buckets) calendar_days = int(window_days) if window_days is not None else max(buckets) - min(buckets) + 1 + days_traded = min(days_traded, calendar_days) scale = ticket / trader_account notionals = sorted(f.notional for f in fills) @@ -76,8 +86,34 @@ def assess( copyable = refused_share <= Decimal(1) - COVERAGE_TARGET + # A cut-short window is stretched to a month. Past a point that stops being a measurement: + # live, a read of 2.4 hours was extrapolated by 319 while seventeen of twenty reads went + # unused. The command may not dress a guess as an answer (PDR-0002, amended 2026-09-21). + asked = window_asked_days if window_asked_days is not None else days + stretch = (asked / span) if (not window_complete and span > 0) else Decimal(1) + if stretch > EXTRAPOLATION_CEILING: + raise ValueError( + f"the venue returned {span:.2f} days of a {asked:.0f}-day window: stretching " + f"that to a month multiplies it by {stretch:.0f}, which is a guess, not a figure" + ) + + reservations = _reservations( + monthly_fee_burden=monthly_fee_burden, + unreproducible_share=unreproducible_share, + days_traded=days_traded, + calendar_days=calendar_days, + stretch=stretch, + ) + if not copyable: + ruling = Ruling.NOT_COPYABLE + elif reservations: + ruling = Ruling.WITH_RESERVATIONS + else: + ruling = Ruling.COPYABLE + return Verdict( - copyable=copyable, + ruling=ruling, + reservations=reservations, ticket=ticket, trader_account=trader_account, fills_read=len(fills), @@ -106,6 +142,29 @@ def assess( ) +def _reservations( + *, + monthly_fee_burden: Decimal, + unreproducible_share: Decimal, + days_traded: int, + calendar_days: int, + stretch: Decimal, +) -> tuple[str, ...]: + """The reservations that apply, in the order the PDR fixes: fees, reproducibility, + concentration, extrapolation. Each is a specific test with a stated threshold — a vague + caution would be read as noise, and the middle verdict is going to be common.""" + named: list[str] = [] + if monthly_fee_burden > FEE_BURDEN_ALERT: + named.append("fees") + if unreproducible_share > UNREPRODUCIBLE_ALERT: + named.append("reproducibility") + if calendar_days > 0 and Decimal(days_traded) / Decimal(calendar_days) <= CONCENTRATION_ALERT: + named.append("concentration") + if stretch > EXTRAPOLATION_ALERT: + named.append("extrapolation") + return tuple(named) + + def _reasons( *, copyable: bool, diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index a87e36a..3e61c64 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -56,7 +56,7 @@ def test_it_refuses_and_says_what_ticket_would_work(capsys: pytest.CaptureFixtur rows = [a_fill("2000", day) for day in range(0, 30)] code = main([ADDRESS, "--ticket", "500"], client=venue(rows, "300000")) out = capsys.readouterr().out - assert code == 1, "a trader the member cannot follow is a non-zero exit" + assert code == 2, "not copyable is 2 now: the codes run by severity (PDR-0002)" assert "10" in out, "the floor must be named" @@ -72,7 +72,7 @@ def down(_: httpx.Request) -> httpx.Response: retry=Retry(attempts=1), ) captured = capsys.readouterr() - assert code == 2, "unreachable is not the same answer as not copyable" + assert code == 3, "no verdict is the most severe: worse than not copyable (PDR-0002)" assert "unavailable" in (captured.out + captured.err).lower() assert "copyable" not in captured.out.lower(), "no verdict from partial data" @@ -110,3 +110,44 @@ def test_it_states_what_the_read_cost_the_venue(capsys: pytest.CaptureFixture[st out = capsys.readouterr().out assert "heavy read(s)" in out, "the number of heavy reads must be stated" assert "0 heavy read(s)" in out, "and this trader fits in the cheap probe, so it is zero" + + +def test_the_headline_names_the_extrapolation_when_the_window_was_cut_short( + capsys: pytest.CaptureFixture[str], +) -> None: + """The reservation existed only in unit tests until this was written: the command passed + `window_days=None` for a cut-short window, so the extrapolation was measured against + itself and could never fire in production.""" + import bisect + + from screening.venue import PAGE_SIZE + + # Dense enough over two days that thirty cannot be read, so the window is cut short and + # the monthly figures are stretched by about fifteen. + series = list(range(NOW_MS - 2 * DAY_MS, NOW_MS + 1, (2 * DAY_MS) // 60_000)) + + def handler(request: httpx.Request) -> httpx.Response: + payload = json.loads(request.content) + if payload["type"] == "clearinghouseState": + return httpx.Response(200, json={"marginSummary": {"accountValue": "20000"}}) + if payload["type"] == "userFills": + chosen = series[-PAGE_SIZE:] + else: + lo = bisect.bisect_left(series, int(payload["startTime"])) + hi = bisect.bisect_right(series, int(payload["endTime"])) + chosen = series[lo:hi][:PAGE_SIZE] + return httpx.Response( + 200, + json=[ + {"coin": "BTC", "px": "2000", "sz": "1", "time": t, "crossed": True} for t in chosen + ], + ) + + code = main( + [ADDRESS, "--ticket", "2000"], + client=httpx.Client(transport=httpx.MockTransport(handler)), + ) + out = capsys.readouterr().out + assert "RESERVATIONS" in out or "NOT COPYABLE" in out + assert "extrapolation" in out, "a window stretched past the alert is named in the headline" + assert code in (1, 2) diff --git a/modules/screening/tests/test_verdict.py b/modules/screening/tests/test_verdict.py index 488ad07..5d145d6 100644 --- a/modules/screening/tests/test_verdict.py +++ b/modules/screening/tests/test_verdict.py @@ -3,13 +3,16 @@ from __future__ import annotations +import time from decimal import Decimal import pytest -from screening.model import Fill, Verdict +from screening.model import FEE_BURDEN_ALERT, Fill, Ruling, Verdict from screening.verdict import assess +NOW_MS = int(time.time() * 1000) + DAY_MS = 86_400_000 @@ -160,3 +163,105 @@ def test_it_always_states_the_concentration_factor_without_a_cliff() -> None: assert any("x" in r and "understate" in r.lower() for r in v.reasons), ( "the factor is stated for every trader, not only past a threshold" ) + + +# --- PDR-0002: three verdicts, not two ------------------------------------------------ + + +def _fills(n: int, px: str = "1000", crossed: bool = True, day_span: int = 30) -> list[Fill]: + """`n` fills spread evenly over `day_span` days, ending now.""" + step = max((day_span * 86_400_000) // max(n - 1, 1), 1) + return [ + Fill( + coin="BTC", + price=Decimal(px), + size=Decimal(1), + time_ms=NOW_MS - (n - 1 - i) * step, + took_liquidity=crossed, + ) + for i in range(n) + ] + + +def test_a_trader_who_clears_the_floor_and_trips_nothing_is_simply_copyable() -> None: + v = assess( + _fills(60), trader_account=Decimal(100_000), ticket=Decimal(50_000), window_days=Decimal(30) + ) + assert v.ruling is Ruling.COPYABLE + assert v.reservations == () + + +def test_a_fee_burden_above_the_alert_is_a_reservation_not_a_refusal() -> None: + """The defect PDR-0002 exists for: live, the command printed COPYABLE and exited 0 + directly above a line saying the fees would decide the member's result.""" + v = assess( + _fills(4000), + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_days=Decimal(30), + ) + assert v.monthly_fee_burden > FEE_BURDEN_ALERT + assert v.ruling is Ruling.WITH_RESERVATIONS + assert "fees" in v.reservations + assert v.copyable is True, "a reservation is expensive, never impossible" + + +def test_more_than_half_the_fills_posted_is_a_reproducibility_reservation() -> None: + fills = _fills(30, crossed=True) + _fills(40, crossed=False) + v = assess( + fills, trader_account=Decimal(100_000), ticket=Decimal(50_000), window_days=Decimal(30) + ) + assert v.ruling is Ruling.WITH_RESERVATIONS + assert "reproducibility" in v.reservations + + +def test_volume_on_a_third_of_the_days_or_fewer_is_a_concentration_reservation() -> None: + v = assess( + _fills(60, day_span=3), + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_days=Decimal(30), + ) + assert v.days_traded <= 10 + assert v.ruling is Ruling.WITH_RESERVATIONS + assert "concentration" in v.reservations + + +def test_the_floor_beats_every_reservation() -> None: + """Impossible beats expensive: a trader whose orders cannot be placed is NOT COPYABLE + whatever else is true, and the reservations are still printed below.""" + v = assess( + _fills(4000), + trader_account=Decimal(100_000), + ticket=Decimal(100), + window_days=Decimal(30), + ) + assert v.refused_share > Decimal("0.2") + assert v.ruling is Ruling.NOT_COPYABLE + assert v.copyable is False + assert v.reservations, "still named, so the administrator learns it twice over" + + +def test_a_window_stretched_past_the_ceiling_is_no_verdict_at_all() -> None: + """A read of 2.4 hours extrapolated to a month by 319 has the shape of a measurement and + the content of a guess. Past the ceiling the command refuses rather than answering.""" + with pytest.raises(ValueError, match="guess, not a figure"): + assess( + _fills(60, day_span=0), + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_days=Decimal(30), + window_complete=False, + ) + + +def test_a_window_stretched_past_the_alert_is_only_a_reservation() -> None: + v = assess( + _fills(60, day_span=5), + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_days=Decimal(30), + window_complete=False, + ) + assert "extrapolation" in v.reservations + assert v.ruling is Ruling.WITH_RESERVATIONS, "short is a caveat, absurd is no verdict" From bca737766e2ea5c301206e3349ccea0228e24f13 Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2026 16:38:42 +0200 Subject: [PATCH 02/12] Stop a typo reading as a verdict, and defend the codes the decision creates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three blocking findings from verification, all in the interface this PDR exists to define, plus the small ones that share their root. The first is a regression I introduced. Renumbering by severity gave 2 to NOT COPYABLE — and argparse already exits 2 on a usage error. A missing --ticket or a mistyped flag made the command say "this trader cannot be copied at this ticket" to a script that reads the code and never sees a sentence. `--ticket nan` was worse: it escaped as an uncaught exception, which Python exits 1 for, and 1 now means COPYABLE WITH RESERVATIONS. A crash read as a qualified yes. Both are now no verdict, which is what a malformed question deserves, and `Infinity` no longer prints a full verdict headed `at a Infinity ticket`. The second is that the middle verdict's own exit code was pinned by nothing. Setting EXIT_WITH_RESERVATIONS = 2 — collapsing it onto NOT COPYABLE, the exact distinction this decision exists to create — left the whole suite green. The one CLI assertion touching it admitted `code in (1, 2)`, which is the sixth fixture of mine on this module to prove nothing. That the fee reservation lands on the *first line* was asserted nowhere either, and the ceiling had no CLI test at all: its unit test passes a combination `main` never produces, so the production path to it was unpinned — the same shape as the defect D3 was written to fix. Seven mutants that survived the suite before now fail it: the middle exit code, the four thresholds flipped from > to >=, the ceiling flipped, and deleting the days clamp. The third is that PDR-0002 names updating the module README with the four verdicts and their codes as an impact of this decision, in so many words, and it was not done. A breaking interface change was shipped with no user-facing record of what it broke. The README now carries both tables. Two more from the same report, fixed rather than deferred: the floor beats the ceiling, because whether orders clear 10 USDC is read straight off the notionals and needs no extrapolation, and the PDR says the floor alone decides; and the refusal message printed a stretch of 30.00002 as `30`, a number the rule says is not refused. And one the wording did not settle, now settled in the PDR: concentration counts against the days actually read, not the days asked for, because a reservation is a statement about what was observed — counting against a window never read would be the mistake this module spent a cycle removing. Sixty-five tests. Agent-Session: session_01NGwPYhV6fYZhjrh41GNfJy Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NGwPYhV6fYZhjrh41GNfJy --- docs/pdr/0002-three-verdicts-not-two.md | 14 ++++ modules/screening/README.md | 32 ++++++++ modules/screening/src/screening/cli.py | 21 ++++- modules/screening/src/screening/verdict.py | 16 ++-- modules/screening/tests/test_cli.py | 93 ++++++++++++++++++++++ modules/screening/tests/test_verdict.py | 93 +++++++++++++++++++++- 6 files changed, 261 insertions(+), 8 deletions(-) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index 6ff840a..a3e2c53 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -227,6 +227,20 @@ Sampled live on 2026-09-21: a trader whose thirty days fit is stretched by 1× a nothing; the densest trader in the test set reads about 2 days and is stretched by ~15, which is a reservation; the 2.4-hour case is refused. +### Which window's days concentration counts against + +Raised in verification, and settled here because the wording above did not settle it. +`concentration` counts the days traded against **the days actually read**, not the days asked +for. On a cut-short window those differ: a trader read over 2 days who traded on both shows a +ratio of 1 and trips nothing, although the month's volume the command reports landed on 2 of +the 30 days it asked about. + +That is deliberate. The reservation is a statement about what was observed, and counting +against a window that was never read would be the same mistake as the figures this module +spent a cycle removing — a number derived from what was *asked for*, printed as a fact about +what was *read*. The `extrapolation` reservation is what warns about the unread part, and on +every trader sampled so far it fires whenever this one is silenced by a short window. + ### What it does not change The floor still decides `NOT COPYABLE` alone. A reservation is still never a refusal. The diff --git a/modules/screening/README.md b/modules/screening/README.md index 7999895..11b6dd4 100644 --- a/modules/screening/README.md +++ b/modules/screening/README.md @@ -17,6 +17,38 @@ nstack run screening # locally, with doubles for the dependencies Commands: the `commands` section of the MANIFEST, to declare for this module's stack. +## What the command answers + +``` +screening
--ticket +``` + +One of four verdicts on the first line, then every figure it rests on. A verdict without its +measurement is not an answer here. + +| Verdict | Exit | Means | +|---|---|---| +| `COPYABLE` | **0** | Clears the venue's 10 USDC floor at this ticket, and nothing else is worth reserving about. | +| `COPYABLE WITH RESERVATIONS (…)` | **1** | Clears the floor, and at least one reservation applies. The reservations are **named in the headline**, so the first line alone is actionable. | +| `NOT COPYABLE` | **2** | Does not clear the floor. The member cannot place this trader's orders at this ticket, whatever else is true — impossible beats expensive. Any reservations are still printed below. | +| *(nothing on stdout)* | **3** | **No verdict.** The venue could not be read, the command line was malformed, or the data cannot support an answer. | + +**The codes run by severity**, so a script keeping the idiom it already has — `if code == 0` — +stops getting a zero for a trader the command was warning it about. + +### The four reservations + +| Named | Applies when | +|---|---| +| `fees` | The monthly fee burden is **above 5%** of the member's ticket. The fees, not the strategy, will decide their result. | +| `reproducibility` | **More than half** the trader's fills were posted rather than taken. A copier arriving afterwards cannot reproduce them. | +| `concentration` | The volume landed on **a third or fewer** of the days read. A month's volume in one burst is not a month of trading. | +| `extrapolation` | The venue could not return the whole window, and the monthly figures are stretched by **more than 3×**. Past **30×** there is no verdict at all. | + +Thresholds are one set of numbers for every administrator and every community. An +administrator cannot tune them and a trader cannot be exempted +([PDR-0002](../../docs/pdr/0002-three-verdicts-not-two.md)). + ## Contracts - Provided: see `provides` in the MANIFEST diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index fe37095..cec6309 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -97,12 +97,26 @@ def main( client: httpx.Client | None = None, retry: venue.Retry | None = None, ) -> int: - args = _parser().parse_args(argv) + try: + args = _parser().parse_args(argv) + except SystemExit as exit_code: + # argparse exits 2 on a usage error, and 2 now means NOT COPYABLE. A script that + # reads the code and never sees a sentence would record "this trader cannot be + # copied" because of a typo in its own command line. A malformed invocation is the + # same thing as an unreadable venue: no verdict. + if exit_code.code not in (0, None): + return EXIT_NO_VERDICT + raise try: ticket = Decimal(args.ticket) except InvalidOperation: print(f"--ticket: {args.ticket!r} is not a number", file=sys.stderr) return EXIT_NO_VERDICT + if not ticket.is_finite(): + # `nan` and `Infinity` parse as Decimals. Infinity printed a complete verdict headed + # `at a Infinity ticket` saying every order clears the floor. + print(f"--ticket: {args.ticket!r} is not a finite amount", file=sys.stderr) + return EXIT_NO_VERDICT owned = client is None http = client or venue.client() @@ -125,7 +139,10 @@ def main( window_complete=window.complete, window_asked_days=window.days_requested, ) - except ValueError as error: + except (ValueError, ArithmeticError) as error: + # ArithmeticError catches decimal's InvalidOperation: `--ticket nan` used to escape as + # an uncaught exception, which Python exits 1 for — and 1 now means COPYABLE WITH + # RESERVATIONS. A crash must never read as a qualified yes. print(f"no verdict: {error}", file=sys.stderr) return EXIT_NO_VERDICT diff --git a/modules/screening/src/screening/verdict.py b/modules/screening/src/screening/verdict.py index c24557f..698490f 100644 --- a/modules/screening/src/screening/verdict.py +++ b/modules/screening/src/screening/verdict.py @@ -86,15 +86,21 @@ def assess( copyable = refused_share <= Decimal(1) - COVERAGE_TARGET - # A cut-short window is stretched to a month. Past a point that stops being a measurement: - # live, a read of 2.4 hours was extrapolated by 319 while seventeen of twenty reads went - # unused. The command may not dress a guess as an answer (PDR-0002, amended 2026-09-21). + # A cut-short window is stretched to a month. Past a point that stops being a + # measurement: live, a read of 2.4 hours was extrapolated by 319 while seventeen of + # twenty reads went unused. The command may not dress a guess as an answer (PDR-0002, + # amended 2026-09-21). + # + # The floor is checked first and wins. Whether the orders clear 10 USDC is read straight + # off the notionals and needs no extrapolation at all, and the PDR says the floor alone + # decides NOT COPYABLE. Refusing to answer a question we can answer from the data in hand + # would be the ceiling overreaching. asked = window_asked_days if window_asked_days is not None else days stretch = (asked / span) if (not window_complete and span > 0) else Decimal(1) - if stretch > EXTRAPOLATION_CEILING: + if copyable and stretch > EXTRAPOLATION_CEILING: raise ValueError( f"the venue returned {span:.2f} days of a {asked:.0f}-day window: stretching " - f"that to a month multiplies it by {stretch:.0f}, which is a guess, not a figure" + f"that to a month multiplies it by {stretch:.1f}, which is a guess, not a figure" ) reservations = _reservations( diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index 3e61c64..0059d84 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -151,3 +151,96 @@ def handler(request: httpx.Request) -> httpx.Response: assert "RESERVATIONS" in out or "NOT COPYABLE" in out assert "extrapolation" in out, "a window stretched past the alert is named in the headline" assert code in (1, 2) + + +def dense_venue(series: list[int], account: str = "20000", px: str = "2000") -> httpx.Client: + """A venue holding `series` (ascending fill times), answering as Hyperliquid does.""" + import bisect + + from screening.venue import PAGE_SIZE + + def handler(request: httpx.Request) -> httpx.Response: + payload = json.loads(request.content) + if payload["type"] == "clearinghouseState": + return httpx.Response(200, json={"marginSummary": {"accountValue": account}}) + if payload["type"] == "userFills": + chosen = series[-PAGE_SIZE:] + else: + lo = bisect.bisect_left(series, int(payload["startTime"])) + hi = bisect.bisect_right(series, int(payload["endTime"])) + chosen = series[lo:hi][:PAGE_SIZE] + return httpx.Response( + 200, + json=[{"coin": "BTC", "px": px, "sz": "1", "time": t, "crossed": True} for t in chosen], + ) + + return httpx.Client(transport=httpx.MockTransport(handler)) + + +def test_the_middle_verdict_has_its_own_exit_code(capsys: pytest.CaptureFixture[str]) -> None: + """The distinction this whole decision exists to create, and nothing pinned it: setting + `EXIT_WITH_RESERVATIONS = 2` — collapsing the middle verdict onto NOT COPYABLE's code — + left the entire suite green.""" + rows = [a_fill("100000", day) for day in range(0, 30)] + code = main([ADDRESS, "--ticket", "2000"], client=venue(rows, "20000")) + out = capsys.readouterr().out + + assert out.splitlines()[0].startswith("COPYABLE WITH RESERVATIONS") + assert code == 1, "the middle verdict is 1: not 0, and above all not 2" + + +def test_the_reservation_is_named_on_the_first_line_not_merely_somewhere( + capsys: pytest.CaptureFixture[str], +) -> None: + """`the headline alone is actionable` is the point of naming it. Asserting the word + appears anywhere in the output proves nothing — the body already says it.""" + rows = [a_fill("100000", day) for day in range(0, 30)] + main([ADDRESS, "--ticket", "2000"], client=venue(rows, "20000")) + first = capsys.readouterr().out.splitlines()[0] + assert "fees" in first, "the reservation must be on the headline" + + +def test_a_window_stretched_past_the_ceiling_gives_no_verdict_through_the_command( + capsys: pytest.CaptureFixture[str], +) -> None: + """The ceiling had no CLI test. Its unit test passes `window_days` with + `window_complete=False`, a combination `main` never produces — so the production path to + the ceiling was unpinned, which is the exact shape of the defect D3 was written to fix.""" + # Everything inside three hours, far too dense to read inside the budget. + series = list(range(NOW_MS - 3 * 3600 * 1000, NOW_MS + 1, 90)) + code = main([ADDRESS, "--ticket", "2000"], client=dense_venue(series)) + + assert capsys.readouterr().out == "", "no verdict means nothing on stdout" + assert code == 3, "past the ceiling there is no verdict, not a weak one" + + +def test_the_floor_still_decides_even_when_the_window_is_hopeless( + capsys: pytest.CaptureFixture[str], +) -> None: + """`the floor alone decides NOT COPYABLE` (PDR-0002). Whether the orders clear 10 USDC is + read straight off the notionals and needs no extrapolation, so the ceiling must not + pre-empt it.""" + series = list(range(NOW_MS - 3 * 3600 * 1000, NOW_MS + 1, 90)) + code = main([ADDRESS, "--ticket", "1"], client=dense_venue(series, account="1000000")) + + assert capsys.readouterr().out.splitlines()[0].startswith("NOT COPYABLE") + assert code == 2, "impossible beats unmeasurable, as it beats expensive" + + +def test_a_malformed_command_line_is_no_verdict_not_a_verdict( + capsys: pytest.CaptureFixture[str], +) -> None: + """argparse exits 2 on a usage error, and 2 now means NOT COPYABLE. A script reading the + code and never seeing a sentence would record `this trader cannot be copied` because of a + typo in its own command line.""" + assert main([ADDRESS]) == 3, "a missing --ticket is no verdict" + assert main([ADDRESS, "--ticket", "2000", "--window", "30"]) == 3, "so is a bad flag" + + +def test_a_ticket_that_is_not_a_finite_amount_is_no_verdict() -> None: + """`nan` and `Infinity` parse as Decimals. `nan` escaped as an uncaught exception, which + Python exits 1 for — and 1 now means COPYABLE WITH RESERVATIONS. A crash must never read + as a qualified yes.""" + rows = [a_fill("2000", day) for day in range(0, 30)] + for bad in ("nan", "Infinity", "-Infinity"): + assert main([ADDRESS, "--ticket", bad], client=venue(rows, "20000")) == 3, bad diff --git a/modules/screening/tests/test_verdict.py b/modules/screening/tests/test_verdict.py index 5d145d6..2d9f99b 100644 --- a/modules/screening/tests/test_verdict.py +++ b/modules/screening/tests/test_verdict.py @@ -8,7 +8,14 @@ import pytest -from screening.model import FEE_BURDEN_ALERT, Fill, Ruling, Verdict +from screening.model import ( + EXTRAPOLATION_ALERT, + FEE_BURDEN_ALERT, + UNREPRODUCIBLE_ALERT, + Fill, + Ruling, + Verdict, +) from screening.verdict import assess NOW_MS = int(time.time() * 1000) @@ -265,3 +272,87 @@ def test_a_window_stretched_past_the_alert_is_only_a_reservation() -> None: ) assert "extrapolation" in v.reservations assert v.ruling is Ruling.WITH_RESERVATIONS, "short is a caveat, absurd is no verdict" + + +# --- the thresholds, defended --------------------------------------------------------- + + +def test_each_threshold_falls_on_the_side_the_decision_says() -> None: + """A verifier checked all five boundaries by hand, found the code right, and found six + mutants flipping `>` to `>=` that the suite let through. The wording is the contract: + fees *above* the alert, *more than half* posted, a third *or less* of the days, *more + than* 3x stretched.""" + from screening.verdict import _reservations + + tiny = Decimal("0.0000001") + quiet = { + "monthly_fee_burden": FEE_BURDEN_ALERT, + "unreproducible_share": UNREPRODUCIBLE_ALERT, + "days_traded": 11, + "calendar_days": 30, + "stretch": EXTRAPOLATION_ALERT, + } + assert _reservations(**quiet) == (), "exactly at every threshold trips nothing" + + assert "fees" in _reservations(**{**quiet, "monthly_fee_burden": FEE_BURDEN_ALERT + tiny}) + assert "reproducibility" in _reservations( + **{**quiet, "unreproducible_share": UNREPRODUCIBLE_ALERT + tiny} + ) + assert "extrapolation" in _reservations(**{**quiet, "stretch": EXTRAPOLATION_ALERT + tiny}) + # Concentration is the one stated the other way round — `a third OR LESS` — so exactly a + # third fires, and one day more does not. + assert "concentration" in _reservations(**{**quiet, "days_traded": 10}) + assert _reservations(**{**quiet, "days_traded": 11}) == () + + +def test_the_ceiling_is_past_thirty_not_at_it() -> None: + """`Past 30x` in the amendment. Exactly a day of a thirty-day window is a reservation; + a hair less is no verdict.""" + day = 86_400_000 + at = [ + Fill(coin="BTC", price=Decimal(1000), size=Decimal(1), time_ms=t, took_liquidity=True) + for t in (NOW_MS - day, NOW_MS) + ] + v = assess( + at, + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_complete=False, + window_asked_days=Decimal(30), + ) + assert "extrapolation" in v.reservations + assert v.ruling is Ruling.WITH_RESERVATIONS, "exactly 30x is still an answer" + + past = [ + Fill(coin="BTC", price=Decimal(1000), size=Decimal(1), time_ms=t, took_liquidity=True) + for t in (NOW_MS - day + 1, NOW_MS) + ] + with pytest.raises(ValueError, match="guess, not a figure"): + assess( + past, + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_complete=False, + window_asked_days=Decimal(30), + ) + + +def test_days_traded_is_clamped_to_the_window_it_is_counted_against() -> None: + """UTC day buckets: fills every twelve hours across exactly thirty days fall into + thirty-one buckets, and the command printed `traded on 31 of the 30 days read`.""" + half = 43_200_000 + fills = [ + Fill( + coin="BTC", + price=Decimal(1000), + size=Decimal(1), + time_ms=NOW_MS - i * half, + took_liquidity=True, + ) + for i in range(61) + ] + v = assess( + fills, trader_account=Decimal(100_000), ticket=Decimal(50_000), window_days=Decimal(30) + ) + assert v.days_traded <= v.calendar_days, "an impossible sentence, and it was printed" + assert f"{v.days_traded} of the {v.calendar_days}" in " ".join(v.reasons) From 37f228204c45a409fc271d9a0aaa6ef150f6095e Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2026 16:39:38 +0200 Subject: [PATCH 03/12] Type the boundary helper, and a note on how the previous commit got pushed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `nstack check` reported twelve mypy errors and the commit went out anyway. The shell chain tested the exit status of `tail`, not of the check — so the gate ran, failed, printed its failure, and the `&&` that followed saw a successful `tail`. The check did its job; I did not read it. The errors themselves were trivial: a `**dict` splat into `_reservations` erases the argument types. It is a keyword-only helper with defaults now, which is also easier to read than four dictionary merges. Recording the how rather than only the what, because a gate whose output is printed and not read is the same as no gate, and this is the second time this week a figure went out unchecked because I chained a command onto the wrong exit status. Agent-Session: session_01NGwPYhV6fYZhjrh41GNfJy Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NGwPYhV6fYZhjrh41GNfJy --- modules/screening/tests/test_verdict.py | 38 ++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/modules/screening/tests/test_verdict.py b/modules/screening/tests/test_verdict.py index 2d9f99b..58f17e1 100644 --- a/modules/screening/tests/test_verdict.py +++ b/modules/screening/tests/test_verdict.py @@ -285,24 +285,30 @@ def test_each_threshold_falls_on_the_side_the_decision_says() -> None: from screening.verdict import _reservations tiny = Decimal("0.0000001") - quiet = { - "monthly_fee_burden": FEE_BURDEN_ALERT, - "unreproducible_share": UNREPRODUCIBLE_ALERT, - "days_traded": 11, - "calendar_days": 30, - "stretch": EXTRAPOLATION_ALERT, - } - assert _reservations(**quiet) == (), "exactly at every threshold trips nothing" - - assert "fees" in _reservations(**{**quiet, "monthly_fee_burden": FEE_BURDEN_ALERT + tiny}) - assert "reproducibility" in _reservations( - **{**quiet, "unreproducible_share": UNREPRODUCIBLE_ALERT + tiny} - ) - assert "extrapolation" in _reservations(**{**quiet, "stretch": EXTRAPOLATION_ALERT + tiny}) + + def at( + *, + fee: Decimal = FEE_BURDEN_ALERT, + posted: Decimal = UNREPRODUCIBLE_ALERT, + traded: int = 11, + stretch: Decimal = EXTRAPOLATION_ALERT, + ) -> tuple[str, ...]: + return _reservations( + monthly_fee_burden=fee, + unreproducible_share=posted, + days_traded=traded, + calendar_days=30, + stretch=stretch, + ) + + assert at() == (), "exactly at every threshold trips nothing" + assert "fees" in at(fee=FEE_BURDEN_ALERT + tiny) + assert "reproducibility" in at(posted=UNREPRODUCIBLE_ALERT + tiny) + assert "extrapolation" in at(stretch=EXTRAPOLATION_ALERT + tiny) # Concentration is the one stated the other way round — `a third OR LESS` — so exactly a # third fires, and one day more does not. - assert "concentration" in _reservations(**{**quiet, "days_traded": 10}) - assert _reservations(**{**quiet, "days_traded": 11}) == () + assert "concentration" in at(traded=10) + assert at(traded=11) == () def test_the_ceiling_is_past_thirty_not_at_it() -> None: From 64b25f385f75e872efdafd9297050cf314ab87f5 Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2026 21:34:44 +0200 Subject: [PATCH 04/12] Put the ceiling back in front of the floor: my unasked fix broke the amendment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A verifier refused this branch over a change nobody asked for, and was right. Last round I made the floor beat the extrapolation ceiling, reasoning that whether orders clear 10 USDC is read straight off the notionals and needs no extrapolation. That reasoning is false. The notionals read are the ones inside the window the venue actually returned, so `refused_share` and `minimum_ticket` computed from half an hour are inferences printed as facts about a trader — the exact move the amendment I had written five hours earlier forbids one section above. What it produced, measured: `NOT COPYABLE` above `8352.24% of their ticket per month in fees` and `extrapolated ... by a factor of 823.3`. The amendment's own dated success criterion says no administrator is ever shown a figure stretched past 30x. I violated it within the hour, in the same file, and then pinned it with a test so the nonsense became the contract. The ceiling is checked before any verdict is formed again. `NO VERDICT` is the most severe outcome and the exit codes already said so. "The floor alone decides NOT COPYABLE" means nothing OTHER than the floor may produce that verdict; it is not a statement of precedence over the absence of one, and the PDR now says which it is, along with why the reasoning that looked like a justification was wrong. The README table written last round to close a blocker asserted `Past 30x there is no verdict at all`, which my own change had just made false. It is true again. Two more drifts in the same tables are fixed: `COPYABLE` claimed the orders clear the floor when the code tolerates up to 20% refused, and the `NOT COPYABLE` row lacked the reservations the command actually prints after it. Five mutants the verifier found surviving are now caught. Two of them are the reservation ORDER — swapping fees and reproducibility, or moving fees last, left all sixty-five tests green, while the test named `..._named_on_the_first_line_not_merely_somewhere` asserted only that the word appeared, on a fixture that tripped one reservation. The seventh fixture on this module to read like a guarantee and prove nothing. The order is now asserted whole, on a fixture where all four fire. Also from the report: the floor boundary at exactly the coverage target is pinned, since D3 made it the sole gate for exit 2; `--help` returns 0 instead of raising through a function typed `-> int`; the dead `ArithmeticError` branch is removed rather than left as an untested brace; and the dead `calendar_days > 0` guard goes with it. Sixty-eight tests. Agent-Session: session_01NGwPYhV6fYZhjrh41GNfJy Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NGwPYhV6fYZhjrh41GNfJy --- docs/pdr/0002-three-verdicts-not-two.md | 20 +++++++++++++++ modules/screening/.coverage | Bin 0 -> 90112 bytes modules/screening/README.md | 12 ++++++--- modules/screening/src/screening/cli.py | 15 +++++------ modules/screening/src/screening/verdict.py | 24 ++++++++++-------- modules/screening/tests/test_cli.py | 24 +++++++++++++----- modules/screening/tests/test_verdict.py | 28 +++++++++++++++++++++ 7 files changed, 97 insertions(+), 26 deletions(-) create mode 100644 modules/screening/.coverage diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index a3e2c53..7adef97 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -227,6 +227,26 @@ Sampled live on 2026-09-21: a trader whose thirty days fit is stretched by 1× a nothing; the densest trader in the test set reads about 2 days and is stretched by ~15, which is a reservation; the 2.4-hour case is refused. +### The ceiling outranks every verdict, the floor included + +Written because the framer read *"the floor alone decides `NOT COPYABLE`"* as *"the floor +outranks `NO VERDICT`"*, built that, and a verifier measured what it produced: `NOT COPYABLE` +printed above `8352.24% of their ticket per month in fees`, `extrapolated ... by a factor of +823.3`. The success criterion three paragraphs above says no administrator is ever shown a +figure stretched past 30×, and that change violated it within the hour. + +So, explicitly: **the ceiling is checked before any verdict is formed.** `NO VERDICT` is the +most severe outcome and the exit codes already say so. + +*"The floor alone decides `NOT COPYABLE`"* means nothing **other than** the floor may produce +that verdict. It is not a statement of precedence over the absence of one. + +And the reasoning that seemed to justify the reorder — *the floor is read straight off the +notionals and needs no extrapolation* — is false. The notionals read are the ones inside the +window that was actually returned, so `refused_share` and `minimum_ticket` computed from half +an hour are inferences presented as facts about a trader: the same move this amendment forbids +one section earlier. + ### Which window's days concentration counts against Raised in verification, and settled here because the wording above did not settle it. diff --git a/modules/screening/.coverage b/modules/screening/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..846e1d9f5eb94921ec5f4a6344b5bb97dd2534d1 GIT binary patch literal 90112 zcmeF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* z8j7MQ3>WJ@gAgH=1Psw!0>MCP!BjRTfnbJPrO-wjpU2ML&H+WyIK=@KXGM*(;($|O zp1#Nv@m*~a3LN!iHakx$vm;t?j<%wqo}{zVwS(>XicH$jdJMo6Cop{C7A-&)r z(4+H+o}GvFge!p_aJiy;Tq^4h7fZUuy+z&NLRD8dKdMWd%j*JXb86t8tj@8u7H8O6 zi&NZP&z2IPNubi6Ai6l z-&fuFP^&oZYaO@8wSuh~T*k3BE#auI1>73bqH|O=Z0*E6wsv9;M-rOFEfLM&a8lE_ T`C3yr6xJke3TXmc7cu?=B;Wo1 literal 0 HcmV?d00001 diff --git a/modules/screening/README.md b/modules/screening/README.md index 11b6dd4..6d7a718 100644 --- a/modules/screening/README.md +++ b/modules/screening/README.md @@ -28,14 +28,20 @@ measurement is not an answer here. | Verdict | Exit | Means | |---|---|---| -| `COPYABLE` | **0** | Clears the venue's 10 USDC floor at this ticket, and nothing else is worth reserving about. | +| `COPYABLE` | **0** | At least **80%** of the trader's orders clear the venue's 10 USDC floor at this ticket, and nothing else is worth reserving about. The share that would still be refused is printed. | | `COPYABLE WITH RESERVATIONS (…)` | **1** | Clears the floor, and at least one reservation applies. The reservations are **named in the headline**, so the first line alone is actionable. | -| `NOT COPYABLE` | **2** | Does not clear the floor. The member cannot place this trader's orders at this ticket, whatever else is true — impossible beats expensive. Any reservations are still printed below. | +| `NOT COPYABLE (…)` | **2** | More than 20% of the orders fall under the floor. The member cannot place this trader's orders at this ticket, whatever else is true — impossible beats expensive. Any reservations are still printed below. | | *(nothing on stdout)* | **3** | **No verdict.** The venue could not be read, the command line was malformed, or the data cannot support an answer. | **The codes run by severity**, so a script keeping the idiom it already has — `if code == 0` — stops getting a zero for a trader the command was warning it about. +**No verdict outranks every verdict, including `NOT COPYABLE`.** If the window the venue +returned is stretched to a month by more than **30×**, the command refuses before forming any +verdict at all — because at that point the floor share and the minimum ticket are inferences +from half an hour, and printing them as facts about a trader is the thing this module exists +to not do. + ### The four reservations | Named | Applies when | @@ -43,7 +49,7 @@ stops getting a zero for a trader the command was warning it about. | `fees` | The monthly fee burden is **above 5%** of the member's ticket. The fees, not the strategy, will decide their result. | | `reproducibility` | **More than half** the trader's fills were posted rather than taken. A copier arriving afterwards cannot reproduce them. | | `concentration` | The volume landed on **a third or fewer** of the days read. A month's volume in one burst is not a month of trading. | -| `extrapolation` | The venue could not return the whole window, and the monthly figures are stretched by **more than 3×**. Past **30×** there is no verdict at all. | +| `extrapolation` | The venue could not return the whole window, and the monthly figures are stretched by **more than 3×**. | Thresholds are one set of numbers for every administrator and every community. An administrator cannot tune them and a trader cannot be exempted diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index cec6309..e039d10 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -104,9 +104,9 @@ def main( # reads the code and never sees a sentence would record "this trader cannot be # copied" because of a typo in its own command line. A malformed invocation is the # same thing as an unreadable venue: no verdict. - if exit_code.code not in (0, None): - return EXIT_NO_VERDICT - raise + # `--help` exits 0 and has already printed. Returning it keeps `main` total, which + # matters because the copying module will consume this through a contract. + return EXIT_NO_VERDICT if exit_code.code not in (0, None) else EXIT_COPYABLE try: ticket = Decimal(args.ticket) except InvalidOperation: @@ -139,10 +139,11 @@ def main( window_complete=window.complete, window_asked_days=window.days_requested, ) - except (ValueError, ArithmeticError) as error: - # ArithmeticError catches decimal's InvalidOperation: `--ticket nan` used to escape as - # an uncaught exception, which Python exits 1 for — and 1 now means COPYABLE WITH - # RESERVATIONS. A crash must never read as a qualified yes. + except ValueError as error: + # `ArithmeticError` was caught here too, as a second guard against `--ticket nan` + # reaching `assess`. `is_finite()` above already stops every case, so the branch was + # unreachable — and an untested brace is not belt and braces, it is a line nobody can + # show is doing anything. print(f"no verdict: {error}", file=sys.stderr) return EXIT_NO_VERDICT diff --git a/modules/screening/src/screening/verdict.py b/modules/screening/src/screening/verdict.py index 698490f..98cb453 100644 --- a/modules/screening/src/screening/verdict.py +++ b/modules/screening/src/screening/verdict.py @@ -88,19 +88,23 @@ def assess( # A cut-short window is stretched to a month. Past a point that stops being a # measurement: live, a read of 2.4 hours was extrapolated by 319 while seventeen of - # twenty reads went unused. The command may not dress a guess as an answer (PDR-0002, - # amended 2026-09-21). + # twenty reads went unused (PDR-0002, amended 2026-09-21). # - # The floor is checked first and wins. Whether the orders clear 10 USDC is read straight - # off the notionals and needs no extrapolation at all, and the PDR says the floor alone - # decides NOT COPYABLE. Refusing to answer a question we can answer from the data in hand - # would be the ceiling overreaching. + # This is checked BEFORE any verdict is formed, and outranks all three of them. An + # earlier version of this branch let the floor win, on the reasoning that whether orders + # clear 10 USDC is read straight off the notionals. That reasoning was wrong: the + # notionals read are the ones in the window we actually got, so `refused_share` and + # `minimum_ticket` are inferences from half an hour printed as facts about a trader — + # the exact move the amendment forbids. It also showed administrators monthly figures + # stretched by 823x and 2158x, which the amendment's own success criterion says must + # never happen. `NO VERDICT` is the most severe outcome and it is reached first. asked = window_asked_days if window_asked_days is not None else days stretch = (asked / span) if (not window_complete and span > 0) else Decimal(1) - if copyable and stretch > EXTRAPOLATION_CEILING: + if stretch > EXTRAPOLATION_CEILING: raise ValueError( - f"the venue returned {span:.2f} days of a {asked:.0f}-day window: stretching " - f"that to a month multiplies it by {stretch:.1f}, which is a guess, not a figure" + f"the venue returned {span:.2f} days of a {asked:.0f}-day window: a month " + f"inferred from that is stretched more than {EXTRAPOLATION_CEILING:.0f} times, " + "which is a guess, not a figure" ) reservations = _reservations( @@ -164,7 +168,7 @@ def _reservations( named.append("fees") if unreproducible_share > UNREPRODUCIBLE_ALERT: named.append("reproducibility") - if calendar_days > 0 and Decimal(days_traded) / Decimal(calendar_days) <= CONCENTRATION_ALERT: + if Decimal(days_traded) / Decimal(calendar_days) <= CONCENTRATION_ALERT: named.append("concentration") if stretch > EXTRAPOLATION_ALERT: named.append("extrapolation") diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index 0059d84..63cdae3 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -214,17 +214,29 @@ def test_a_window_stretched_past_the_ceiling_gives_no_verdict_through_the_comman assert code == 3, "past the ceiling there is no verdict, not a weak one" -def test_the_floor_still_decides_even_when_the_window_is_hopeless( +def test_no_verdict_outranks_every_verdict_including_not_copyable( capsys: pytest.CaptureFixture[str], ) -> None: - """`the floor alone decides NOT COPYABLE` (PDR-0002). Whether the orders clear 10 USDC is - read straight off the notionals and needs no extrapolation, so the ceiling must not - pre-empt it.""" + """An earlier version of this branch let the floor win over the ceiling, reasoning that + whether orders clear 10 USDC is read straight off the notionals. The reasoning was wrong: + those notionals are the ones inside the window we actually got, so `refused_share` and + `minimum_ticket` become inferences from half an hour printed as facts about a trader. + + A verifier measured what it produced — `NOT COPYABLE` above + `8352.24% of their ticket per month in fees`, `extrapolated ... by a factor of 823.3` — + which is precisely what the amendment's success criterion says must never be shown.""" series = list(range(NOW_MS - 3 * 3600 * 1000, NOW_MS + 1, 90)) code = main([ADDRESS, "--ticket", "1"], client=dense_venue(series, account="1000000")) - assert capsys.readouterr().out.splitlines()[0].startswith("NOT COPYABLE") - assert code == 2, "impossible beats unmeasurable, as it beats expensive" + assert capsys.readouterr().out == "", "no verdict prints no verdict, not a refusal" + assert code == 3, "the ceiling is reached before any verdict is formed" + + +def test_help_returns_rather_than_escaping(capsys: pytest.CaptureFixture[str]) -> None: + """`main` is typed `-> int` and the copying module will consume it through a contract. + `--help` raised SystemExit through it.""" + assert main(["--help"]) == 0 + assert "--ticket" in capsys.readouterr().out def test_a_malformed_command_line_is_no_verdict_not_a_verdict( diff --git a/modules/screening/tests/test_verdict.py b/modules/screening/tests/test_verdict.py index 58f17e1..e2d71a4 100644 --- a/modules/screening/tests/test_verdict.py +++ b/modules/screening/tests/test_verdict.py @@ -362,3 +362,31 @@ def test_days_traded_is_clamped_to_the_window_it_is_counted_against() -> None: ) assert v.days_traded <= v.calendar_days, "an impossible sentence, and it was printed" assert f"{v.days_traded} of the {v.calendar_days}" in " ".join(v.reasons) + + +def test_the_reservations_come_out_in_the_order_the_decision_fixes() -> None: + """`all are named, in the order fees, reproducibility, concentration` (PDR-0002), plus + extrapolation from the amendment. Swapping two of them, or moving fees to the end, left + all sixty-five tests green — and the test named for the first line was satisfied by any + order, because its fixture tripped only one reservation.""" + from screening.verdict import _reservations + + assert _reservations( + monthly_fee_burden=Decimal("0.9"), + unreproducible_share=Decimal("0.9"), + days_traded=1, + calendar_days=30, + stretch=Decimal(20), + ) == ("fees", "reproducibility", "concentration", "extrapolation") + + +def test_the_floor_boundary_is_the_coverage_target_exactly() -> None: + """D3 made this line the sole gate for `NOT COPYABLE` and for exit 2, and nothing pinned + which side of it exactly-20%-refused falls on.""" + trader_account, ticket = Decimal(100_000), Decimal(1_000) + # scale 1/100: a 900 notional becomes 9 USDC (refused), a 2000 becomes 20 (placed) + at_target = spread([fill("900")] * 2 + [fill("2000")] * 8) + assert assess(at_target, trader_account=trader_account, ticket=ticket).copyable is True + + past = spread([fill("900")] * 3 + [fill("2000")] * 7) + assert assess(past, trader_account=trader_account, ticket=ticket).copyable is False From b41e6f69a0bdc0094c91de9a9722a2656400158f Mon Sep 17 00:00:00 2001 From: "napkinstack-agent[bot]" <330339777+napkinstack-agent[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 11:20:41 +0200 Subject: [PATCH 05/12] Refuse the venue's non-numbers, and stop three of my own tests proving nothing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three blockers, all of them created by my cleanup last round, and the pattern is the same in each: I removed a protection while believing I was tidying. B1. I deleted the `ArithmeticError` handler and wrote that `is_finite()` "already stops every case". That is false. `is_finite()` guards `--ticket`; every other number in `assess` comes from the venue. A verifier walked `accountValue: "NaN"`, `accountValue: "Infinity"`, a `px: "NaN"` fill and a zero-notional fill straight through to an uncaught decimal error — which the process reports as exit 1, and this deliverable is what made 1 mean COPYABLE WITH RESERVATIONS. My own test docstring says a crash must never read as a qualified yes. `assess` now refuses all four with reasons, checking finiteness before any comparison because `Decimal("NaN") <= 0` does not answer False, it raises. The zero-notional case needs no exotic input: enough of them inside the coverage target and the minimum ticket divides by zero. The handler is back as a backstop for the fifth shape nobody has thought of, and a test forces it rather than leaving a brace nobody can show does anything. B2. The reservation order was asserted on the private helper, one layer below the headline the decision is about. Sorting the tuple inside `_render` passed every test. Asserted through the command now — and my first attempt at that test used `fees, reproducibility`, which are already in alphabetical order, so sorting left it identical and it proved nothing. It uses `fees, concentration`, where the decision's order and alphabetical order disagree. B3. Rewriting the floor-versus-ceiling test deleted the only assertion of the literal `NOT COPYABLE`; renaming the verdict passed the whole suite. Restored. Fixing a blocker should not cost coverage that already existed. Also pinned, each verified against a mutant with the patch confirmed applied first: the 10 USDC notional boundary, `EXTRAPOLATION_ALERT` against the literal 3 rather than against itself, and the one line deciding whether the monthly figures are measured or extrapolated — my first test of that used fills spanning the full window, where both wirings agree. Smaller: a posted share of 0.4% printed `0% of the fills were posted ... a copier cannot reproduce them`, warning about nothing; the README says what `--help` returns, since 0 is otherwise the code for COPYABLE; and `modules/screening/.coverage`, a SQLite file carrying one workstation's absolute paths, is out of the index and into `.gitignore` — the file the `.gitignore` comment describes by name. Seventy-five tests. Agent-Session: session_01NGwPYhV6fYZhjrh41GNfJy Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NGwPYhV6fYZhjrh41GNfJy --- .gitignore | 2 + modules/screening/.coverage | Bin 90112 -> 0 bytes modules/screening/README.md | 4 +- modules/screening/src/screening/cli.py | 17 +++-- modules/screening/src/screening/verdict.py | 24 ++++-- modules/screening/tests/test_cli.py | 84 +++++++++++++++++++++ modules/screening/tests/test_verdict.py | 29 +++++++ 7 files changed, 149 insertions(+), 11 deletions(-) delete mode 100644 modules/screening/.coverage diff --git a/.gitignore b/.gitignore index cd4567c..d10e752 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ dist/ build/ target/ coverage/ +.coverage +.coverage.* .env .env.* !.env.example diff --git a/modules/screening/.coverage b/modules/screening/.coverage deleted file mode 100644 index 846e1d9f5eb94921ec5f4a6344b5bb97dd2534d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90112 zcmeFa2VfM}wa0yD?vy)sXLm&vqKb|v0@165=)LzQ2_!%uA&^A1G2Xt$#=RGe8@6!? zU>uvcVB%hJjVtch*to{M>N{ud+(G!od3lMy@4e(3B_Y56%S&pG$(^r;id zYD%-0R#sIM*JSr18AMUY(ClnN2#5bQhX2VQ6F`#!{$HuXzlEISUierrJd4=I91>m> zY#Q!nFSEZ0Tw(XOW(La4u2wGW@PGUf@JGNO0e=MkV@4n{)iyJ;vXtoNn&QRfr8QN> zOG>N6zro?tMi$H%nLVRm*o2YUVq116o((_Ux@8w+S5>ahUR_$1y|k>nG`nn7N!gO( znzB{PvTK%?%A?m-mzLl?3%0>s3lGe79*uTYP$M?LNlMF>t->R+JGl?f$*wA0T3S`QYDsCecov_5V8ij3GIlAPXh~&N2|oM9RmH28EHAC@nqBO@!X=gPJU7&cS6fwC(Y>ZJ zyS!|b^D+EVY2-!=RABfB~;V^w9>Y9DvIT6b)|a3mG!Hg$1k$U;L`9BsqV#v172qgQHtMy zjwt@@i^b5%qudWjJSPaxQVIV^;J^NlKLY*;_#@ztfIkBM2>2u5kAOb{{s{OZ;E#Ym z0{#g6=ZyeWRK>*kzZ!mvgg=FU{2zY={1Na+z#jpB1pE>3N5CHee+2vy@JGNO0e=Mi z5%{+p0b8Xl!m=zRFGHctvfLVgez|#lbMvssUkx86;iKWN|1Dpj|D^p9@JGNO0e=Mi z5%5RA9|3;^{1Na+z#jpB1pE>3N5C5ao3>D77(nH;ndL?SF#pf(w@G+kxF}pNbbqKa z)I9if@U&nL*y#WGBjAsKKLY*;_#@ztfIkBM2>2u5kAOb{|4t(?k!!FFyZiFWiqh^& zyAOj72*qo=udl3HS-l!s(sW-6y=lZh6_q7x%S)@fSHmLl(pAv1rF%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+;O~xr%r#)BMl1Cc#A>t>PeHIoTjD8* z)@X}81>qX4*i#U%(TY3;0UNE*Q}9_#TjVJS*=P&hq$`GLwE5mHh|_5EJOzOoZLU-p zsnO<0g^kCw*-~M6Mw{uW6Kmgom(&f$V*ZEX^* z8j7MQ3>WJ@gAgH=1Psw!0>MCP!BjRTfnbJPrO-wjpU2ML&H+WyIK=@KXGM*(;($|O zp1#Nv@m*~a3LN!iHakx$vm;t?j<%wqo}{zVwS(>XicH$jdJMo6Cop{C7A-&)r z(4+H+o}GvFge!p_aJiy;Tq^4h7fZUuy+z&NLRD8dKdMWd%j*JXb86t8tj@8u7H8O6 zi&NZP&z2IPNubi6Ai6l z-&fuFP^&oZYaO@8wSuh~T*k3BE#auI1>73bqH|O=Z0*E6wsv9;M-rOFEfLM&a8lE_ T`C3yr6xJke3TXmc7cu?=B;Wo1 diff --git a/modules/screening/README.md b/modules/screening/README.md index 6d7a718..38a68e6 100644 --- a/modules/screening/README.md +++ b/modules/screening/README.md @@ -31,7 +31,9 @@ measurement is not an answer here. | `COPYABLE` | **0** | At least **80%** of the trader's orders clear the venue's 10 USDC floor at this ticket, and nothing else is worth reserving about. The share that would still be refused is printed. | | `COPYABLE WITH RESERVATIONS (…)` | **1** | Clears the floor, and at least one reservation applies. The reservations are **named in the headline**, so the first line alone is actionable. | | `NOT COPYABLE (…)` | **2** | More than 20% of the orders fall under the floor. The member cannot place this trader's orders at this ticket, whatever else is true — impossible beats expensive. Any reservations are still printed below. | -| *(nothing on stdout)* | **3** | **No verdict.** The venue could not be read, the command line was malformed, or the data cannot support an answer. | +| *(nothing on stdout)* | **3** | **No verdict.** The venue could not be read or answered with something that is not a number, the command line was malformed, or the data cannot support an answer. | + +`--help` prints the usage and exits **0**, as a command should. It is the one exit 0 that is not a verdict. **The codes run by severity**, so a script keeping the idiom it already has — `if code == 0` — stops getting a zero for a trader the command was warning it about. diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index e039d10..0a55ee2 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -139,11 +139,18 @@ def main( window_complete=window.complete, window_asked_days=window.days_requested, ) - except ValueError as error: - # `ArithmeticError` was caught here too, as a second guard against `--ticket nan` - # reaching `assess`. `is_finite()` above already stops every case, so the branch was - # unreachable — and an untested brace is not belt and braces, it is a line nobody can - # show is doing anything. + except (ValueError, ArithmeticError) as error: + # `ArithmeticError` is the backstop, and it was removed last round on the written + # reason that `is_finite()` above "already stops every case". That was false: + # `is_finite()` guards `--ticket` and nothing else, while every other number in + # `assess` comes from the venue. A verifier walked `accountValue: "NaN"`, + # `accountValue: "Infinity"`, a `px: "NaN"` fill and a zero-notional fill straight + # through to an uncaught decimal error — which the process reports as exit 1, and + # this deliverable is what made 1 mean COPYABLE WITH RESERVATIONS. + # + # The four shapes are refused in `assess` now, with reasons. This stays because the + # fifth one has not been thought of yet, and the cost of missing it is a crash that + # reads as a qualified yes. print(f"no verdict: {error}", file=sys.stderr) return EXIT_NO_VERDICT diff --git a/modules/screening/src/screening/verdict.py b/modules/screening/src/screening/verdict.py index 98cb453..f17ef44 100644 --- a/modules/screening/src/screening/verdict.py +++ b/modules/screening/src/screening/verdict.py @@ -49,10 +49,16 @@ def assess( """ if not fills: raise ValueError("no fills: a verdict cannot be given without the trader's executions") - if trader_account <= 0: - raise ValueError("the trader's account value must be positive") - if ticket <= 0: - raise ValueError("the member's ticket must be positive") + # Finiteness is checked before any comparison, because `Decimal("NaN") <= 0` does not + # answer False, it raises — and the venue's own numbers reach here unfiltered. A verifier + # drove `accountValue: "NaN"` and a `px: "0"` fill through the command and both escaped as + # uncaught exceptions, which the process reports as exit 1: COPYABLE WITH RESERVATIONS. + if not trader_account.is_finite() or trader_account <= 0: + raise ValueError("the trader's account value must be a positive number") + if not ticket.is_finite() or ticket <= 0: + raise ValueError("the member's ticket must be a positive number") + if any(not f.notional.is_finite() for f in fills): + raise ValueError("the venue returned a fill whose notional is not a number") span = (Decimal(max(f.time_ms for f in fills) - min(f.time_ms for f in fills))) / _MS_PER_DAY days = window_days if window_days is not None else span @@ -82,6 +88,12 @@ def assess( # The ticket that clears the floor on COVERAGE_TARGET of the orders: the smallest # (1 - COVERAGE_TARGET) may be refused. cutoff = notionals[int((Decimal(1) - COVERAGE_TARGET) * count)] + if cutoff <= 0: + # One zero-notional fill in the bottom fifth is enough, and it needs no exotic input. + raise ValueError( + "a fill of zero notional sits inside the coverage target: no minimum ticket can " + "be computed from it" + ) minimum_ticket = MINIMUM_ORDER_USDC / (cutoff / trader_account) copyable = refused_share <= Decimal(1) - COVERAGE_TARGET @@ -238,7 +250,9 @@ def _reasons( f"{_DAYS_PER_MONTH / days:.1f}" ) - if unreproducible_share > 0: + # Rounded, not raw: a share of 0.4% printed `0% of the fills were posted rather than + # taken: a copier cannot reproduce them`, which warns about nothing and reads as a bug. + if round(unreproducible_share * 100) > 0: said.append( f"{unreproducible_share:.0%} of the fills were posted rather than taken: a copier " f"arriving afterwards cannot reproduce them" diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index 63cdae3..3d8a8bc 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -256,3 +256,87 @@ def test_a_ticket_that_is_not_a_finite_amount_is_no_verdict() -> None: rows = [a_fill("2000", day) for day in range(0, 30)] for bad in ("nan", "Infinity", "-Infinity"): assert main([ADDRESS, "--ticket", bad], client=venue(rows, "20000")) == 3, bad + + +def test_the_headline_names_two_reservations_in_the_order_the_decision_fixes( + capsys: pytest.CaptureFixture[str], +) -> None: + """The order was asserted on the private helper, one layer below the surface the decision + is about. PDR-0002 fixes the order of what is **named in the headline**, and sorting the + tuple inside `_render` passed all sixty-eight tests — `fees` would have stopped being + first and nothing would have said so.""" + # `fees` and `concentration`, chosen because the decision's order and alphabetical order + # disagree on them. A fixture of `fees, reproducibility` is already alphabetical, so + # sorting the tuple leaves it identical and the assertion proves nothing — which is what + # the first attempt at this test did. + rows = [a_fill("300000", day) for day in range(0, 10)] + main([ADDRESS, "--ticket", "2000"], client=venue(rows, "20000")) + first = capsys.readouterr().out.splitlines()[0] + + assert "(fees, concentration)" in first, ( + "both named, in the decision's order — sorted() would give (concentration, fees)" + ) + + +def test_a_refused_trader_says_not_copyable_in_those_words( + capsys: pytest.CaptureFixture[str], +) -> None: + """Rewriting the floor-versus-ceiling test deleted the only assertion of this literal, and + nothing replaced it: renaming the verdict to `NOT-COPYABLE` passed all sixty-eight tests. + Fixing a blocker should not cost the coverage that was already there.""" + rows = [a_fill("2000", day) for day in range(0, 30)] + code = main([ADDRESS, "--ticket", "500"], client=venue(rows, "300000")) + assert capsys.readouterr().out.splitlines()[0].startswith("NOT COPYABLE") + assert code == 2 + + +def test_a_venue_number_that_is_not_a_number_is_no_verdict() -> None: + """`is_finite()` guards `--ticket` and nothing else. Every other number in `assess` comes + from the venue, and a verifier walked four shapes straight through to an uncaught decimal + error — which the process reports as exit 1, the code this deliverable made mean + COPYABLE WITH RESERVATIONS. A crash must never read as a qualified yes.""" + rows = [a_fill("2000", day) for day in range(0, 30)] + for account in ("NaN", "Infinity"): + assert main([ADDRESS, "--ticket", "2000"], client=venue(rows, account)) == 3, account + + # The one that needs no exotic input at all: enough zero-notional fills to reach the + # coverage target, so the cutoff itself is zero and the minimum ticket divides by it. + # One zero alone is not a crash — it is simply refused under the floor, correctly. + with_zeros = [a_fill("0", day) for day in range(0, 9)] + [ + a_fill("2000", day) for day in range(9, 30) + ] + assert main([ADDRESS, "--ticket", "2000"], client=venue(with_zeros, "20000")) == 3 + + nan_price = [a_fill("NaN", 0), *(a_fill("2000", day) for day in range(1, 30))] + assert main([ADDRESS, "--ticket", "2000"], client=venue(nan_price, "20000")) == 3 + + +def test_a_complete_window_is_not_reported_as_extrapolated( + capsys: pytest.CaptureFixture[str], +) -> None: + """One line in `main` decides whether the monthly figures are measured or extrapolated. + Inverting it passed the whole suite: a complete month would report `traded on 1 of 1 days` + — losing `concentration` — and inflate turnover thirtyfold.""" + # The fills must span FEWER days than the window, or both wirings agree and the test + # proves nothing — the first attempt used fills on day 0 and day 29, which span 30. + rows = [a_fill("2000", day) for day in range(20, 30)] + main([ADDRESS, "--ticket", "2000"], client=venue(rows, "20000")) + out = capsys.readouterr().out + assert "extrapolat" not in out, "the window asked for was returned whole" + assert "of the 30 days read" in out, ( + "counted against the 30 days asked for, not the 10 the fills happen to span" + ) + + +def test_any_failure_inside_assess_is_no_verdict(monkeypatch: pytest.MonkeyPatch) -> None: + """The `ArithmeticError` backstop cannot be reached through any input `assess` now + refuses, so nothing would show it does anything — which is the criticism that got it + removed once already, with the four escapes that followed. Forced here instead.""" + import screening.cli as cli + + def boom(*args: object, **kwargs: object) -> None: + raise ArithmeticError("something nobody thought of") + + monkeypatch.setattr(cli, "assess", boom) + rows = [a_fill("2000", day) for day in range(0, 30)] + assert main([ADDRESS, "--ticket", "2000"], client=venue(rows, "20000")) == 3 diff --git a/modules/screening/tests/test_verdict.py b/modules/screening/tests/test_verdict.py index e2d71a4..78af2cd 100644 --- a/modules/screening/tests/test_verdict.py +++ b/modules/screening/tests/test_verdict.py @@ -390,3 +390,32 @@ def test_the_floor_boundary_is_the_coverage_target_exactly() -> None: past = spread([fill("900")] * 3 + [fill("2000")] * 7) assert assess(past, trader_account=trader_account, ticket=ticket).copyable is False + + +def test_an_order_of_exactly_ten_usdc_is_placeable() -> None: + """`An order UNDER 10 USDC is refused by the venue` (AGENTS.md). The boundary test added + last round pins the refused *share*; this pins the *notional*, and `<` becoming `<=` + refuses an order the venue accepts.""" + # scale 1/100: a notional of 1000 becomes exactly 10 USDC at the member's ticket. + exactly = spread([fill("1000")] * 10) + v = assess(exactly, trader_account=Decimal(100_000), ticket=Decimal(1_000)) + assert v.refused_share == Decimal(0), "exactly ten clears; only under ten is refused" + + +def test_the_extrapolation_alert_is_three_not_whatever_the_constant_says() -> None: + """Both existing tests build their fixture from `EXTRAPOLATION_ALERT`, so they pin the + operator and not the value: raising it from 3 to 5 passed the whole suite while the README + says `more than 3x`.""" + day = 86_400_000 + at_four = [ + Fill(coin="BTC", price=Decimal(1000), size=Decimal(1), time_ms=t, took_liquidity=True) + for t in (NOW_MS - int(7.5 * day), NOW_MS) + ] + v = assess( + at_four, + trader_account=Decimal(100_000), + ticket=Decimal(50_000), + window_complete=False, + window_asked_days=Decimal(30), + ) + assert "extrapolation" in v.reservations, "7.5 days of 30 is 4x, and 4 is more than 3" From 4dd1230665be5db5eda87f8eaceacadcf1158b79 Mon Sep 17 00:00:00 2001 From: whosbax Date: Tue, 22 Sep 2026 17:30:29 +0200 Subject: [PATCH 06/12] Catch what the client itself throws: a proxy variable was reading as a qualified yes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The confirmation run refused this branch, and was right. Two ordinary environment variables — `https_proxy=socks5://...` with no `socksio` installed, and `SSL_CERT_FILE` naming a file that is not there — killed the command with exit **1**, which this deliverable is what made mean COPYABLE WITH RESERVATIONS. An empty stdout and a qualified yes about a trader whose fills were never read: strictly worse than the two-state answer D3 replaced, because it invents an opinion out of a configuration error. `venue.client()` was built one line before the `try` that guards the reads, so nothing caught it. `venue`'s own handlers are narrower than they look as well — they catch `httpx.HTTPError`, and `httpx.StreamError` is a `RuntimeError`. The reason it went unseen for six rounds is the part worth recording: **every one of the twenty `main(...)` calls in the suite passes `client=`**. The single line the administrator's own invocation runs was run by no test at all, and seventy-five green tests were green on a path nobody takes. I wrote the same argument into this file last round, about `ArithmeticError`, and then left the identical hole one call earlier. So `main` is now a backstop over `_decide`: any unhandled exception prints its reason and returns the no-verdict code. Same reasoning as the `ArithmeticError` handler, applied to the command instead of to `assess`. Both tests were seen failing against the unpatched file — `FileNotFoundError` escaping from the SSL context, and a `RuntimeError` from the transport — with the revert confirmed before the run rather than assumed. The first one passes no `client=`, on purpose. Verified on its own exit status, not through a pipe: 77 passed, `nstack check screening` 0, and the four reproductions now exit 3 with an empty stdout. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- modules/screening/src/screening/cli.py | 32 +++++++++++++++++++++++++- modules/screening/tests/test_cli.py | 25 ++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index 0a55ee2..5aa4c5f 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -91,7 +91,7 @@ def _render(address: str, verdict: Verdict, window: FillWindow) -> str: return "\n".join(lines) -def main( +def _decide( argv: Sequence[str] | None = None, *, client: httpx.Client | None = None, @@ -158,5 +158,35 @@ def main( return _EXIT[verdict.ruling] +def main( + argv: Sequence[str] | None = None, + *, + client: httpx.Client | None = None, + retry: venue.Retry | None = None, +) -> int: + """`_decide`, with a backstop under the whole of it. + + A verifier reached exit 1 — which this deliverable is what made mean COPYABLE WITH + RESERVATIONS — from two ordinary environment variables: `https_proxy=socks5://...` + without `socksio` installed, and `SSL_CERT_FILE` naming a file that is not there. Both + raise while `httpx.Client` is being built, one line before the `try` that guards the + reads, so the process died with an empty stdout and a code that reads as a qualified yes + about a trader whose fills were never read. `venue`'s handlers are narrower than they + look as well: they catch `httpx.HTTPError`, and `httpx.StreamError` is a `RuntimeError`. + + Nothing caught it because every test of the command passes `client=`, so `venue.client()` + — the one line the administrator's own invocation runs — was run by no test at all. + + This is the reasoning behind the `ArithmeticError` backstop in `_decide`, applied to the + command rather than to `assess`: no unhandled exception may leave this process carrying a + code that names a verdict. + """ + try: + return _decide(argv, client=client, retry=retry) + except Exception as error: + print(f"no verdict: {type(error).__name__}: {error}", file=sys.stderr) + return EXIT_NO_VERDICT + + if __name__ == "__main__": # pragma: no cover raise SystemExit(main()) diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index 3d8a8bc..6d8fac3 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -340,3 +340,28 @@ def boom(*args: object, **kwargs: object) -> None: monkeypatch.setattr(cli, "assess", boom) rows = [a_fill("2000", day) for day in range(0, 30)] assert main([ADDRESS, "--ticket", "2000"], client=venue(rows, "20000")) == 3 + + +def test_a_client_the_environment_refuses_to_build_is_no_verdict( + monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + """Every other test here passes `client=`, so `venue.client()` — the only line the + administrator's own invocation runs — was run by no test at all. A verifier ran it, with + `SSL_CERT_FILE` naming a file that is not there, and got exit 1: COPYABLE WITH + RESERVATIONS, about a trader whose fills were never read. + + No `client=` here on purpose. The client is built for real.""" + monkeypatch.setenv("SSL_CERT_FILE", "/nonexistent/ca.pem") + assert main([ADDRESS, "--ticket", "500"]) == 3 + assert capsys.readouterr().out == "", "no verdict means nothing on stdout" + + +def test_a_read_that_raises_what_venue_does_not_catch_is_no_verdict() -> None: + """`venue` catches `httpx.HTTPError`, and `httpx.StreamError` is a `RuntimeError` — + as are the `OSError`s a broken socket raises. They escaped as exit 1.""" + + def handler(request: httpx.Request) -> httpx.Response: + raise RuntimeError("the socket went away mid-read") + + client = httpx.Client(transport=httpx.MockTransport(handler)) + assert main([ADDRESS, "--ticket", "500"], client=client) == 3 From 71acb63d000c7640e1c04c4f2d485d71e6b43345 Mon Sep 17 00:00:00 2001 From: whosbax Date: Tue, 22 Sep 2026 21:50:09 +0200 Subject: [PATCH 07/12] Record the decider's reading: NO VERDICT is an empty stdout, not a word MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The confirmation run found that this PDR and D3's sixth criterion both say *"the verdict is NO VERDICT"*, while the command prints those two words nowhere: empty stdout, `no verdict: ` on stderr, exit 3. The module's README, written on this branch, had already restated the criterion as `*(nothing on stdout)*` — which is the right reading and the wrong route. An expected result had been changed by the author, in a README, with nobody's agreement visible. Asked directly, the decider kept the behaviour: stdout carries the answer a script consumes, stderr the explanation a human reads, and when there is no answer stdout is empty so nothing read back can be mistaken for a verdict. It is the concern that renumbered the exit codes, applied to the output. Recorded in the PDR, where decisions live. No code, no test, no threshold, and the README is left alone — it now follows this document instead of amending it. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- docs/pdr/0002-three-verdicts-not-two.md | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index 7adef97..f95bdb3 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -279,3 +279,43 @@ not the verdict — is what needs fixing (`modules/screening/docs/adr/0003`). If the read ever covers the window it asks for reliably, the extrapolation reservation and the ceiling both become dead code and are removed rather than left as reassurance. + + +--- + +## Amendment, 2026-09-22 — `NO VERDICT` is an empty stdout, not a word + +**Decided by @napkinstack-admin**, asked directly, after a confirmation run raised the gap. + +### What this settles + +This PDR and D3's sixth acceptance criterion both say *"the verdict is `NO VERDICT`"*. The +command prints those two words nowhere. It writes **nothing at all on stdout**, puts +`no verdict: ` on stderr, and exits `3`: + +``` +$ screening 0xabc --ticket 500 +no verdict: the trader's account value must be a positive number # stderr +$ echo $? +3 +``` + +That is the intended behaviour and it stays. **stdout carries the answer a script consumes; +stderr carries the explanation a human reads.** When there is no answer, stdout is empty, so +nothing a script reads back can be mistaken for a verdict — which is the same concern that +renumbered the exit codes by severity one section above. + +### Why it is written here + +The module's `README.md` had already restated the criterion this way, as +`*(nothing on stdout)*` | **3**. The verifier's finding was not about the behaviour, which it +had confirmed on twelve separate shapes of unreadable input: it was that **an expected result +had been changed in a README, by the author, without the decider agreeing to it visibly** +(`playbooks/verification.md`). The reading was right and the route was wrong, so the decision +is recorded where decisions live, and the README now follows the PDR rather than amending it. + +### What it does not change + +No code, no test, no threshold. `NO VERDICT` remains the name of the outcome in this document, +in the cycle's acceptance criteria and in the module's own vocabulary — it is the name of an +absence, and the absence is what is printed. From 7fd0914fb623751c46b47b25d971a12732000026 Mon Sep 17 00:00:00 2001 From: whosbax Date: Tue, 22 Sep 2026 22:17:53 +0200 Subject: [PATCH 08/12] Say it safely or not at all: the line reporting no verdict was deciding the exit code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The confirmation run at `71acb63` refused the branch again, on the fix's own reporting line, and both of its findings reproduce exactly as written. **Exit 1 on an empty stdout, still reachable.** `... 2>&1 >/dev/null | true` with an unbuffered stderr — `PYTHONUNBUFFERED=1` is ordinary in a container image — raises `BrokenPipeError` out of `print`. It escaped `main`, including out of the backstop I added last commit, which is precisely where a failure lands last, and CPython exits **1**: COPYABLE WITH RESERVATIONS, decided by a reader that consumed nothing. Measured 5/5 through the installed command, and under the same `https_proxy=socks5://...` environment this branch was refused over two commits ago. **The reason landing on stdout.** `... 2>&-` closes fd 2, CPython sets `sys.stderr` to `None`, and `print(file=None)` writes to stdout: 59 bytes of explanation where the verdict goes, under exit 3. The amendment I recorded one commit ago says stdout is empty when there is no answer, so nothing read back can be mistaken for one. It was not universally true of the code it described. Neither was introduced by the backstop — both are byte-identical at `b41e6f6` and older than this deliverable. That is not a reason to leave them: this is the fourth blocker of the same class on this branch, and the invariant is one line from holding. Every write to stderr in the file goes through `_say` now: nothing when there is no stderr — never stdout as a fallback — and a suppressed `OSError` when the write fails. The exit code carries the answer alone. Both tests were seen failing against the unguarded file, the revert verified before the run: `BrokenPipeError` escaping, and the reason landing on stdout. Verified on their own exit status: 79 passed, `nstack check screening` 0, the two reproductions now exit 3 (five runs each, stdout 0 bytes), and the four original ones still exit 3. Live at this head: `NOT COPYABLE (fees)`, exit 2, 9805 fills read over a window ending today, 9 heavy reads of a 20 budget. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- modules/screening/src/screening/cli.py | 41 +++++++++++++++++--- modules/screening/tests/test_cli.py | 52 ++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 5 deletions(-) diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index 5aa4c5f..c5064b2 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -6,6 +6,7 @@ from __future__ import annotations import argparse +import contextlib import sys from collections.abc import Sequence from datetime import UTC, datetime @@ -29,6 +30,36 @@ EXIT_NO_VERDICT = 3 +def _say(reason: str) -> None: + """The reason, on stderr, or nowhere at all — never on stdout, and never fatally. + + Two ways this line used to decide the exit code by itself, both found by a confirmation + run and both reachable through the installed command: + + `... 2>&1 >/dev/null | true` with an unbuffered stderr raises `BrokenPipeError` out of + `print`. It escaped `main` — including out of `main`'s own backstop, which is where this + lands when everything else has already failed — and CPython exits **1**, which this + deliverable is what made mean COPYABLE WITH RESERVATIONS. A reader that consumes nothing + is not an opinion about a trader. + + `... 2>&-` closes fd 2, so CPython sets `sys.stderr` to `None`, and `print(file=None)` + writes to **stdout**. The reason for having no verdict was landing where the verdict + goes, which is what the amendment of 2026-09-22 says never happens. An exit code of 3 + with 59 bytes on stdout is exactly the shape a script cannot read. + + Neither was introduced by the backstop above; both were in every one of these prints + since the command existed, and being one line from closed is not a reason to leave a + fourth one open. + """ + stream = sys.stderr + if stream is None: + return + # A broken or closed stderr. There is nowhere left to say it, and stdout is not a + # fallback: silence, and the exit code carries the answer on its own. + with contextlib.suppress(OSError, ValueError): + print(reason, file=stream) + + def _date(ms: int) -> str: return datetime.fromtimestamp(ms / 1000, tz=UTC).strftime("%Y-%m-%d") @@ -110,12 +141,12 @@ def _decide( try: ticket = Decimal(args.ticket) except InvalidOperation: - print(f"--ticket: {args.ticket!r} is not a number", file=sys.stderr) + _say(f"--ticket: {args.ticket!r} is not a number") return EXIT_NO_VERDICT if not ticket.is_finite(): # `nan` and `Infinity` parse as Decimals. Infinity printed a complete verdict headed # `at a Infinity ticket` saying every order clears the floor. - print(f"--ticket: {args.ticket!r} is not a finite amount", file=sys.stderr) + _say(f"--ticket: {args.ticket!r} is not a finite amount") return EXIT_NO_VERDICT owned = client is None @@ -124,7 +155,7 @@ def _decide( window = venue.fills_since(args.address, days=WINDOW_DAYS, client=http, retry=retry) account = venue.account_value(args.address, http, retry=retry) except venue.VenueUnavailable as error: - print(f"venue unavailable — no verdict: {error}", file=sys.stderr) + _say(f"venue unavailable — no verdict: {error}") return EXIT_NO_VERDICT finally: if owned: @@ -151,7 +182,7 @@ def _decide( # The four shapes are refused in `assess` now, with reasons. This stays because the # fifth one has not been thought of yet, and the cost of missing it is a crash that # reads as a qualified yes. - print(f"no verdict: {error}", file=sys.stderr) + _say(f"no verdict: {error}") return EXIT_NO_VERDICT print(_render(args.address, verdict, window)) @@ -184,7 +215,7 @@ def main( try: return _decide(argv, client=client, retry=retry) except Exception as error: - print(f"no verdict: {type(error).__name__}: {error}", file=sys.stderr) + _say(f"no verdict: {type(error).__name__}: {error}") return EXIT_NO_VERDICT diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index 6d8fac3..97f7e69 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -365,3 +365,55 @@ def handler(request: httpx.Request) -> httpx.Response: client = httpx.Client(transport=httpx.MockTransport(handler)) assert main([ADDRESS, "--ticket", "500"], client=client) == 3 + + +def _refusing_client() -> httpx.Client: + def handler(request: httpx.Request) -> httpx.Response: + return httpx.Response(503, json={}) + + return httpx.Client(transport=httpx.MockTransport(handler)) + + +def test_a_broken_stderr_does_not_become_a_verdict(monkeypatch: pytest.MonkeyPatch) -> None: + """`... 2>&1 >/dev/null | true` with an unbuffered stderr: the reason cannot be written, + `BrokenPipeError` escapes the print, and the process exits 1 — COPYABLE WITH RESERVATIONS, + decided by a reader that consumed nothing. Measured at exit 1 through the installed + command before this guard.""" + import sys + + class Broken: + def write(self, text: str) -> int: + raise BrokenPipeError(32, "Broken pipe") + + def flush(self) -> None: + raise BrokenPipeError(32, "Broken pipe") + + monkeypatch.setattr(sys, "stderr", Broken()) + # The venue's own refusal, and the backstop under everything else. Both used to report + # through an unguarded print, and the second one is where a failure lands last. + assert main([ADDRESS, "--ticket", "500"], client=_refusing_client()) == 3 + + def explode(request: httpx.Request) -> httpx.Response: + raise RuntimeError("nothing catches this one") + + assert ( + main( + [ADDRESS, "--ticket", "500"], + client=httpx.Client(transport=httpx.MockTransport(explode)), + ) + == 3 + ) + + +def test_no_verdict_never_falls_through_to_stdout( + monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + """`... 2>&-` closes fd 2, CPython sets `sys.stderr` to None, and `print(file=None)` writes + to stdout: 59 bytes of reason where the verdict goes, under exit 3. The amendment of + 2026-09-22 says stdout is empty when there is no answer, so nothing read back can be + mistaken for one.""" + import sys + + monkeypatch.setattr(sys, "stderr", None) + assert main([ADDRESS, "--ticket", "500"], client=_refusing_client()) == 3 + assert capsys.readouterr().out == "", "the reason landed on stdout" From 6109baac3ddd1d52d22ab13fc910b05b5880e952 Mon Sep 17 00:00:00 2001 From: whosbax Date: Tue, 22 Sep 2026 23:18:46 +0200 Subject: [PATCH 09/12] Close the parser's own route to stdout, and say what the promise can actually hold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fifth finding of one class, and the decider's call was to close it and stop the class rather than close it and wait for the sixth. **argparse was outside the guard.** `ArgumentParser.error` calls `print_usage(sys.stderr)`; with fd 2 closed `sys.stderr` is `None` and `print_usage` substitutes **stdout**, so six ordinary malformed command lines put 46 bytes of `usage: ...` where the verdict goes, under exit 3. Last commit's guard covered every write in this file — and argparse is not in this file, which is exactly the gap the previous confirmation run named. The parser now reports through `_say` and exits with no message of its own. `--help` stays on stdout, 451 bytes, exit 0; a usage error with a working stderr still explains itself there. **`_say` suppresses `Exception`, not `(OSError, ValueError)`.** The same report reached exit 1 — a code that names a verdict — through a `sys.stderr` whose `write` raised `RuntimeError`. It found no route to that through a shell, and one character closes it. `KeyboardInterrupt` and `SystemExit` are `BaseException` and still leave. **And the promise is bordered.** *"It writes nothing at all on stdout"* is a claim about every way a process can be started, and three confirmation runs walked into it one layer at a time: this file's prints, the backstop's print, argparse's usage line — and then CPython's finaliser, which writes its own message and exits 120 when it cannot flush a stream. That fourth layer is not reachable from inside the module. A promise the code cannot keep produces refusals for ever, so the PDR now states the three guarantees the command does hold — nothing of ours on stdout without a verdict, the exit code as the interface, no verdict word unless that verdict was formed — and names 120 as a verdict that could not be delivered rather than an opinion. The README says so where a script author reads it. The stdout test was seen failing against the unpatched parser, on all four malformed shapes, the revert confirmed first. The `--help` test is a regression guard, not a discriminating one: it passes either way, and it is there because routing the parser's errors is exactly the change that could have taken `--help` off stdout with them. Verified on their own exit status: 81 passed, `nstack check screening` 0, and `screening --bogus >out 2>&-` now exits 3 with stdout at 0 bytes. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- docs/pdr/0002-three-verdicts-not-two.md | 43 +++++++++++++++++++++++++ modules/screening/README.md | 5 +++ modules/screening/src/screening/cli.py | 34 +++++++++++++++++-- modules/screening/tests/test_cli.py | 24 ++++++++++++++ 4 files changed, 104 insertions(+), 2 deletions(-) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index f95bdb3..53d18ee 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -319,3 +319,46 @@ is recorded where decisions live, and the README now follows the PDR rather than No code, no test, no threshold. `NO VERDICT` remains the name of the outcome in this document, in the cycle's acceptance criteria and in the module's own vocabulary — it is the name of an absence, and the absence is what is printed. + + +--- + +## Amendment, 2026-09-22 (second) — what "nothing on stdout" promises, and what it cannot + +**Decided by @napkinstack-admin**, asked directly, after a third confirmation run. + +### Why this one exists + +The amendment above says *"it writes nothing at all on stdout"*. Taken literally, that is a +promise about every way a process can be started, and three confirmation runs walked into it +one layer at a time: the reason printed by this module's own code (closed), the reason printed +by the backstop under it (closed), the usage line printed by `argparse` (closed), and then +CPython's own finaliser, which writes `Exception ignored on flushing sys.stdout` and exits +**120** when it cannot flush a stream the command already gave up on. + +Each was a real finding. The fourth is not reachable from inside the module, and a promise the +code cannot keep will keep producing refusals until it is written as what it actually is. + +### What the command guarantees + +- **When there is no verdict, nothing the command writes goes to stdout.** Not the reason, not + a usage line, not a partial answer. The reason goes to stderr when there is a stderr able to + take it, and nowhere at all when there is not. +- **The exit code is the interface.** `0`, `1`, `2`, `3`, by severity. A caller decides on the + code; stdout is for a caller that also wants the figures. +- **No word naming a verdict ever appears on stdout unless that verdict was formed.** + +### What it does not guarantee, named so it is not rediscovered as a defect + +If the interpreter cannot flush a stream, it prints its own message and exits **120** — a +healthy trader whose verdict could not be delivered, not an opinion about that trader. `120` is +outside the four codes on purpose: a caller switching on `0`/`1`/`2`/`3` never reads it as an +answer, and the command has no way to prevent it. The same is true of whatever a shell or a +supervisor writes to the same descriptors. + +### What it does not change + +No threshold, no verdict, no exit code. The three guarantees above are what the command already +does at this head, with the `argparse` route closed; this amendment states them where the next +verifier will read them, instead of leaving a stronger sentence that the fifth layer would +falsify again. diff --git a/modules/screening/README.md b/modules/screening/README.md index 38a68e6..8ac3710 100644 --- a/modules/screening/README.md +++ b/modules/screening/README.md @@ -35,6 +35,11 @@ measurement is not an answer here. `--help` prints the usage and exits **0**, as a command should. It is the one exit 0 that is not a verdict. +**Only these four codes are answers.** If the interpreter cannot write the answer at all — a closed or a full +stdout — it exits **120** and prints nothing. That is a verdict that could not be delivered, never an opinion +about the trader, and the command cannot prevent it +([PDR-0002](../../docs/pdr/0002-three-verdicts-not-two.md), second amendment of 2026-09-22). + **The codes run by severity**, so a script keeping the idiom it already has — `if code == 0` — stops getting a zero for a trader the command was warning it about. diff --git a/modules/screening/src/screening/cli.py b/modules/screening/src/screening/cli.py index c5064b2..0055598 100644 --- a/modules/screening/src/screening/cli.py +++ b/modules/screening/src/screening/cli.py @@ -11,6 +11,7 @@ from collections.abc import Sequence from datetime import UTC, datetime from decimal import Decimal, InvalidOperation +from typing import NoReturn import httpx @@ -29,6 +30,11 @@ EXIT_NOT_COPYABLE = 2 EXIT_NO_VERDICT = 3 +#: argparse's own status for a usage error. It never reaches the caller — `_decide` reads it +#: as no verdict — but `2` is NOT COPYABLE here, and an unnamed 2 in this file invites the +#: reader to think a typo produces a verdict. +EXIT_USAGE = 2 + def _say(reason: str) -> None: """The reason, on stderr, or nowhere at all — never on stdout, and never fatally. @@ -56,7 +62,12 @@ def _say(reason: str) -> None: return # A broken or closed stderr. There is nowhere left to say it, and stdout is not a # fallback: silence, and the exit code carries the answer on its own. - with contextlib.suppress(OSError, ValueError): + # + # `Exception`, not `(OSError, ValueError)`: a confirmation run reached exit 1 — which + # names a verdict — through a `sys.stderr` whose `write` raised `RuntimeError`. It found + # no route to that through a shell, and one character closes it. `KeyboardInterrupt` and + # `SystemExit` are `BaseException` and still leave. + with contextlib.suppress(Exception): print(reason, file=stream) @@ -64,8 +75,27 @@ def _date(ms: int) -> str: return datetime.fromtimestamp(ms / 1000, tz=UTC).strftime("%Y-%m-%d") +class _Parser(argparse.ArgumentParser): + """`argparse` reports a usage error itself, and it does not go through `_say`. + + `ArgumentParser.error` calls `print_usage(sys.stderr)`. With fd 2 closed `sys.stderr` is + `None`, and `print_usage` substitutes **stdout** for it — so six ordinary malformed + command lines put 46 bytes of `usage: ...` where the verdict goes, under exit 3. A + confirmation run measured it, and it is the same shape as the leak closed one commit + earlier: that guard covered every write in this file, and argparse is not in this file. + + Reporting the error through `_say` and exiting with no message of argparse's own keeps + `--help` on stdout, where it belongs, and leaves the mapping in `_decide` untouched: + `SystemExit(2)` from a usage error is already read there as no verdict. + """ + + def error(self, message: str) -> NoReturn: + _say(f"{self.format_usage().rstrip()}\n{self.prog}: error: {message}") + self.exit(EXIT_USAGE) + + def _parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser( + parser = _Parser( prog="screening", description=( "Can a member of a given ticket copy this trader? Answers from the trader's " diff --git a/modules/screening/tests/test_cli.py b/modules/screening/tests/test_cli.py index 97f7e69..474d386 100644 --- a/modules/screening/tests/test_cli.py +++ b/modules/screening/tests/test_cli.py @@ -417,3 +417,27 @@ def test_no_verdict_never_falls_through_to_stdout( monkeypatch.setattr(sys, "stderr", None) assert main([ADDRESS, "--ticket", "500"], client=_refusing_client()) == 3 assert capsys.readouterr().out == "", "the reason landed on stdout" + + +def test_a_malformed_command_line_never_writes_to_stdout( + monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + """`screening --bogus >out 2>&-` put 46 bytes of `usage: …` on stdout under exit 3: + `ArgumentParser.error` calls `print_usage(sys.stderr)`, and `print_usage` substitutes + stdout when that is `None`. The guard on this file's own prints did not cover argparse, + because argparse is not in this file.""" + import sys + + monkeypatch.setattr(sys, "stderr", None) + for argv in ([], ["--bogus"], [ADDRESS], ["--ticket", "500"]): + assert main(argv) == 3 + assert capsys.readouterr().out == "", f"{argv} wrote to stdout" + + +def test_help_still_goes_to_stdout_and_exits_zero(capsys: pytest.CaptureFixture[str]) -> None: + """Routing the parser's errors must not take `--help` off stdout with them. It is the one + exit 0 that is not a verdict, so it has to be readable where a reader looks.""" + assert main(["--help"]) == 0 + printed = capsys.readouterr() + assert "usage: screening" in printed.out + assert printed.err == "" From 3483b267f9f369f1c7dfaa1507a2fee186bcb5d2 Mon Sep 17 00:00:00 2001 From: whosbax Date: Wed, 23 Sep 2026 00:58:38 +0200 Subject: [PATCH 10/12] Correct the amendment the confirmation run falsified within the day MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The run at `6109baa` returned `merge`, with no blocker, and three findings that are all one thing: the amendment I wrote in that same commit says more than the code does, or less than the interpreter does. **A verdict that cannot be delivered comes back two ways, and I named the rarer one.** I wrote that it surfaces as `120`. That is the flush failing. When the *write* fails — `PYTHONIOENCODING=ascii` cannot encode the em dash in the headline — the backstop returns **3**, which is one of the four codes and reads as *the data cannot support an answer* about a trader whose data supported one perfectly. It fails safe, and it is the common case. Now written as both. **`PYTHONINSPECT=1` replaces the exit code with 1.** CPython re-enters the REPL and discards the program's status; the command returns 3 and the process exits 1. Not this command deciding — `python -c "sys.exit(3)"` does the same — and not undoable from inside the process. My exclusion list named only the 120, so the next run would have filed this as new. Named as the general case instead. **Guarantee 3 was absolute where input validation is a follow-up.** The address is echoed into the headline as typed, so an address carrying a newline and the words `NOT COPYABLE` prints a complete headline for a verdict never formed. Now "no word this command chooses", with the caveat stated and the reason it is not fixed here — unvalidated input is a recorded follow-up and this deliverable is already over budget. What the venue says still never reaches stdout: 150 fuzzed answers with coin names literally `"COPYABLE"` leaked nothing. No code, no test, no threshold. `nstack check screening` 0; the module is untouched at `git diff 6109baa HEAD -- modules/screening/src modules/screening/tests`. T4 makes this commit reprint the sheet: it is dated at the head, and the head moved. The confirmation run is being repeated rather than the sheet edited. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- docs/pdr/0002-three-verdicts-not-two.md | 47 +++++++++++++++++++------ modules/screening/README.md | 7 ++-- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index 53d18ee..d02881b 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -346,19 +346,46 @@ code cannot keep will keep producing refusals until it is written as what it act take it, and nowhere at all when there is not. - **The exit code is the interface.** `0`, `1`, `2`, `3`, by severity. A caller decides on the code; stdout is for a caller that also wants the figures. -- **No word naming a verdict ever appears on stdout unless that verdict was formed.** +- **No word this command chooses ever names a verdict on stdout unless that verdict was + formed.** The qualifier is owed: the address is echoed into the headline as the caller typed + it, so a caller passing an address that contains a newline and the words `NOT COPYABLE` reads + them back. Measured, and left as a caller attacking itself rather than fixed inside a + deliverable already over budget — unless the address comes from a list the caller did not + write, which is the day input validation stops being a follow-up. What the **venue** says + never reaches stdout: 150 fuzzed answers with coin names literally `"COPYABLE"` leaked + nothing. ### What it does not guarantee, named so it is not rediscovered as a defect -If the interpreter cannot flush a stream, it prints its own message and exits **120** — a -healthy trader whose verdict could not be delivered, not an opinion about that trader. `120` is -outside the four codes on purpose: a caller switching on `0`/`1`/`2`/`3` never reads it as an -answer, and the command has no way to prevent it. The same is true of whatever a shell or a -supervisor writes to the same descriptors. +**A verdict that cannot be delivered comes back two different ways**, and the first sentence +written here named only the rarer one. + +- **The write fails** — `PYTHONIOENCODING=ascii` cannot encode the em dash in the headline — + and the command's own backstop returns **3**. That is one of the four codes, and it reads as + *the data cannot support an answer* about a trader whose data supported one perfectly. It + fails in the safe direction: never a verdict, never a wrong one, stdout genuinely empty. A + caller cannot tell it from an unreadable venue, and that is the cost of the backstop, stated + rather than discovered. +- **The flush fails** — the interpreter cannot empty a stream the command already gave up on — + and CPython prints its own message and exits **120**. Outside the four codes on purpose: a + caller switching on `0`/`1`/`2`/`3` never reads it as an answer. + +**And a caller that changes how the interpreter exits replaces the code.** `PYTHONINSPECT=1` +re-enters the REPL after the script and discards its status: the command returns 3 and the +process exits 1. It is not this command deciding — `PYTHONINSPECT=1 python -c "sys.exit(3)"` +does the same — and it cannot be undone from inside the process. Named here as the general case, +because the first draft named only the 120 and the next verifier filed the rest as new. + +The same is true of whatever a shell or a supervisor writes to the same descriptors. ### What it does not change -No threshold, no verdict, no exit code. The three guarantees above are what the command already -does at this head, with the `argparse` route closed; this amendment states them where the next -verifier will read them, instead of leaving a stronger sentence that the fifth layer would -falsify again. +No threshold, no verdict, no exit code, and no line of the module. The three guarantees above +are what the command already does at this head, with the `argparse` route closed; this amendment +states them where the next verifier will read them, instead of leaving a stronger sentence that +the next layer would falsify again. + +Its own first draft was falsified within the day, by the confirmation run it was written for: +two of the three paragraphs above exist because a verifier showed the sentence under them was +wrong in the common case, or written more absolutely than the code supports. Recorded that way +round on purpose. diff --git a/modules/screening/README.md b/modules/screening/README.md index 8ac3710..7350bc2 100644 --- a/modules/screening/README.md +++ b/modules/screening/README.md @@ -35,9 +35,10 @@ measurement is not an answer here. `--help` prints the usage and exits **0**, as a command should. It is the one exit 0 that is not a verdict. -**Only these four codes are answers.** If the interpreter cannot write the answer at all — a closed or a full -stdout — it exits **120** and prints nothing. That is a verdict that could not be delivered, never an opinion -about the trader, and the command cannot prevent it +**Only these four codes are answers.** A verdict that cannot be written comes back as **3** when the write +itself fails — an stdout that cannot encode the answer — and as **120** when the interpreter cannot flush it. +Neither is an opinion about the trader, and a caller that changes how the interpreter exits, such as +`PYTHONINSPECT`, replaces the code outright ([PDR-0002](../../docs/pdr/0002-three-verdicts-not-two.md), second amendment of 2026-09-22). **The codes run by severity**, so a script keeping the idiom it already has — `if code == 0` — From e0af8e669c29be3c02ac1d77e437a56cd263949d Mon Sep 17 00:00:00 2001 From: whosbax Date: Wed, 23 Sep 2026 01:18:06 +0200 Subject: [PATCH 11/12] Say it about the whole class this time: a choice, not the bytes already gone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sixth finding on this branch and the fourth in prose rather than in code. The re-confirmation at `3483b26` passed 28 of 29 rows — every acceptance criterion, both gates, the live run, the module byte-identical to the head it had already accepted — and refused the twenty-ninth, which is a sentence I wrote in the commit whose only content was sentences. I claimed that when the write fails the backstop returns 3 with **stdout genuinely empty**. True for the case I named: an encoder that cannot take the em dash refuses the answer whole, measured up to 133 KB. False for the other member of the same class: a reader closing a pipe partway through an answer larger than the buffer leaves the bytes already written — exit 3 over 40 bytes reading `COPYABLE — …`, three reproductions out of three. I named a class in the heading and described one member under it. The verifier also caught what that did to the guarantee above, which I had not reread in the light of my own amendment: it says *no partial answer* under *when there is no verdict*, while the paragraph below now establishes that **3 is also what a formed verdict returns when it cannot be delivered**. The two sentences had come apart in writing, in the same document, on the same day. So the correction is made once, at the top, for all three guarantees: they speak about what the command **chooses** to write. Bytes already handed to the operating system, before a reader went away or a stream refused the rest, are not a choice. The first guarantee now says *no verdict formed* rather than *no verdict*, and names the route where exit 3 and a non-empty stdout coexist. The bullet says which half of its class leaves stdout empty and which does not, with both measurements. Closing the class rather than the instance is what the `PYTHONINSPECT` paragraph got right two commits ago and what this one got wrong; a per-instance clause is how a document produces a refusal per round. No code, no test, no threshold. `nstack check screening` 0, and `git diff 3483b26..HEAD -- modules/` is empty. T4 reprints the sheet again: the head moved, so the twenty-nine rows are being re-measured rather than relabelled. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- docs/pdr/0002-three-verdicts-not-two.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index d02881b..accff64 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -341,9 +341,16 @@ code cannot keep will keep producing refusals until it is written as what it act ### What the command guarantees -- **When there is no verdict, nothing the command writes goes to stdout.** Not the reason, not +**All three speak about what the command *chooses* to write.** Bytes it already handed to the +operating system, before a reader went away or a stream refused the rest, are not a choice and +are not covered — the third confirmation run had to say this once about a word and once about a +partial line, and it is written here as one rule so it does not have to be said a third time. + +- **When no verdict is formed, nothing the command writes goes to stdout.** Not the reason, not a usage line, not a partial answer. The reason goes to stderr when there is a stderr able to - take it, and nowhere at all when there is not. + take it, and nowhere at all when there is not. *No verdict formed*, not *exit code 3*: the + paragraph below establishes that 3 is also what a formed verdict returns when it cannot be + delivered, and on that route stdout holds whatever the failed write had already put there. - **The exit code is the interface.** `0`, `1`, `2`, `3`, by severity. A caller decides on the code; stdout is for a caller that also wants the figures. - **No word this command chooses ever names a verdict on stdout unless that verdict was @@ -363,9 +370,16 @@ written here named only the rarer one. - **The write fails** — `PYTHONIOENCODING=ascii` cannot encode the em dash in the headline — and the command's own backstop returns **3**. That is one of the four codes, and it reads as *the data cannot support an answer* about a trader whose data supported one perfectly. It - fails in the safe direction: never a verdict, never a wrong one, stdout genuinely empty. A - caller cannot tell it from an unreadable venue, and that is the cost of the backstop, stated - rather than discovered. + fails in the safe direction: never a verdict, never a wrong one. A caller cannot tell it from + an unreadable venue, and that is the cost of the backstop, stated rather than discovered. + + **How much of stdout survives depends on where the write died**, and the first version of this + bullet claimed the tidier half as though it were the whole. An encoder that refuses the answer + leaves stdout **empty** — measured, including on a 133 KB answer, because it refuses the chunk + whole. A reader that closes a pipe partway through an answer larger than the buffer leaves + **what was already written**: exit 3 over 40 bytes reading `COPYABLE — …`, measured three times + out of three. It needs an answer past 64 KB, which needs a ticket no validation rejects yet — + one more reason `--ticket` validation is the follow-up it is. - **The flush fails** — the interpreter cannot empty a stream the command already gave up on — and CPython prints its own message and exits **120**. Outside the four codes on purpose: a caller switching on `0`/`1`/`2`/`3` never reads it as an answer. From 2d9fee9271c6cdcc561a4150d616921042cd6bb3 Mon Sep 17 00:00:00 2001 From: whosbax Date: Wed, 23 Sep 2026 01:32:46 +0200 Subject: [PATCH 12/12] Name the one exception the README had and this document did not: --help MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The class sentence worked — row 14 passes, and the verifier bounded rather than asserted it: the module writes to stdout from exactly two places, `_say`, which only ever touches stderr, and the render call, which runs only after a verdict exists. So bytes of an answer can reach stdout unchosen only through a write that started and did not finish, which is the family the sentence excludes. It did not reach a different absolute three paragraphs above. Guarantee 1 lists *"not a usage line"*, and `--help` writes 451 bytes of usage to stdout and forms no verdict. Nine routes to it, from `-h` to `0xabc --ticket 500 --help`, all print the usage and exit 0. **Older than this branch, and sharpened by my own correction.** The guarantee said *"when there is no verdict"*, which could be read as the `NO VERDICT` outcome — the thing that exits 3 — and `--help` argued its way out of that reading. Narrowing it to *no verdict formed* was right and load-bearing, and it pulled `--help` squarely inside a sentence that then denied what it does. The command was never wrong here; three drafts of this paragraph were. Named as the exception to the first two guarantees, since it also exits 0 where 0 means COPYABLE — the one exit 0 that is not a verdict, which the README has said since the day the table was written. An exception rather than a defect because it says nothing about a trader: a caller who asked how to run the command is not a caller being told an answer. The verifier's own note on this, worth keeping: it measured `--help` on all three of its sheets and never read it against the bullet three paragraphs down. The sequence has produced six findings of one family, every one a sentence more absolute than the code. Having enumerated the two writes, it does not see a seventh. No code, no test, no threshold. `nstack check screening` 0, and `git diff e0af8e6..HEAD -- modules/` is empty. Agent-Session: 4151570f-613e-475f-ba3f-b465b35d9a83 Co-Authored-By: Claude Opus 5 (1M context) --- docs/pdr/0002-three-verdicts-not-two.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/pdr/0002-three-verdicts-not-two.md b/docs/pdr/0002-three-verdicts-not-two.md index accff64..03df5ee 100644 --- a/docs/pdr/0002-three-verdicts-not-two.md +++ b/docs/pdr/0002-three-verdicts-not-two.md @@ -362,6 +362,17 @@ partial line, and it is written here as one rule so it does not have to be said never reaches stdout: 150 fuzzed answers with coin names literally `"COPYABLE"` leaked nothing. +**`--help` is the exception to the first two, and the only one.** It forms no verdict, writes +its usage to stdout by design, and exits **0** — the one exit 0 that is not a verdict, as the +module's README already said and this document did not. Nine routes to it were measured, from +`-h` to `0xabc --ticket 500 --help`; every one prints the usage and exits 0. It is an exception +rather than a defect because it says nothing about a trader: a caller who asked how to run the +command is not a caller being told an answer. + +Recorded because narrowing the first guarantee to *no verdict formed* — which was the right +narrowing, and load-bearing — pulled `--help` squarely inside a sentence that then denied what +it does. The command was never wrong here; three drafts of this paragraph were. + ### What it does not guarantee, named so it is not rediscovered as a defect **A verdict that cannot be delivered comes back two different ways**, and the first sentence