2dfa96939e
The first environment shipped through .claude/workflows/new-environment.js: specification, three adversarial reviews (all 'fixable', none fatal), the Python environment, the TypeScript port, captured rollouts, and the demo page. Eleven agents, no errors. The proof that the platform scales is one line long. Alert Triage has a completely different shape from Word Five — JSON actions, priced lookups, an analyst screen instead of a grid — and the only change under src/components/demo/ is a comment edit, because the isolation lint refused the word "wordle" there. Zero shell code changed. 415 contract checks now pass against two demos, up from 206 against one. The environment is honest by construction. Every alert is synthetic, generated from the seed, and the banner saying so sits inside the board surface. Two of the eleven scenario templates are hidden-suspicious: generated by the same code as their benign twin with the signal overlaid only in lookup data, so the free screen is identically distributed and a screen-only policy STRUCTURALLY cannot tell them apart. The probe ladder measures it: `fast` catches 0.0 of hidden seeds. That is the counterweight made real rather than asserted. Twelve policies, thirteen ladder assertions, a genuine three-way trade: fast 0.846 wins hours (0.85), misses every hidden case targeted 0.894 wins the shipped total thorough 0.820 wins evidence (1.00), spends 2.9 hours None dominates. 92 Python tests, 35 TypeScript tests, 65 fixtures replaying at delta 0, and conformance gated on world + scorer + protocol so the browser shows the same alert for ?seed= that Python generated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019mt6sHQHEnEYrJZvoMCJSB
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""The portable primitives, pinned so the TypeScript port has vectors to hit."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from alert_triage.rng import (
|
|
XorShift32,
|
|
civil_from_days,
|
|
days_from_civil,
|
|
days_in_month,
|
|
fnv1a32,
|
|
iso_date,
|
|
)
|
|
|
|
# fnv1a32 over the decimal seed — identical to wordle_five's and to engine.ts.
|
|
FNV_VECTORS = {"0": 0x350CA8AF, "1": 0x340CA71C, "42": 0x87E38583, "4095": 0x43875F5F}
|
|
|
|
|
|
def test_fnv1a_vectors() -> None:
|
|
for text, expect in FNV_VECTORS.items():
|
|
assert fnv1a32(text) == expect, text
|
|
|
|
|
|
def test_xorshift_sequence_is_pinned() -> None:
|
|
rng = XorShift32(fnv1a32("0"))
|
|
first = [rng.next() for _ in range(5)]
|
|
assert first == XORSHIFT_FROM_SEED_0
|
|
|
|
|
|
XORSHIFT_FROM_SEED_0 = [2738490563, 3068243922, 3765331391, 3085691315, 2439018365]
|
|
|
|
|
|
def test_zero_seed_is_replaced() -> None:
|
|
assert XorShift32(0).state != 0
|
|
|
|
|
|
def test_sample_is_distinct_and_partial_shuffle() -> None:
|
|
rng = XorShift32(7)
|
|
out = rng.sample(list(range(10)), 4)
|
|
assert len(out) == 4 and len(set(out)) == 4
|
|
|
|
|
|
def test_civil_dates_round_trip() -> None:
|
|
for day in range(days_from_civil(1999, 12, 25), days_from_civil(2030, 3, 2)):
|
|
y, m, d = civil_from_days(day)
|
|
assert days_from_civil(y, m, d) == day
|
|
|
|
|
|
def test_known_dates() -> None:
|
|
assert days_from_civil(1970, 1, 1) == 0
|
|
assert iso_date(days_from_civil(2026, 3, 1)) == "2026-03-01"
|
|
assert days_in_month(2024, 2) == 29 and days_in_month(2026, 2) == 28
|
|
assert days_in_month(2026, 12) == 31
|