Skip to content

[wildcard] Compile a fair roster draw from a validator with hidden choices #4896

Backlog

Description

@Pineapple00000

The idea, in a paragraph

Eight shifts must be assigned to volunteers A, B and C. Nobody serves twice in a row, C can take at most two shifts, and one A-to-B handoff must be designated for training. The coordinator publishes the roster and chooses the training slot later. Drawing uniformly from valid roster-and-handoff pairs gives ABABABAB four chances to win and ABACACBA only one. Could Hybrid compile the policy itself into a draw with exactly one ticket per publishable roster?

Which assumption it breaks

Hybrid currently emits Go that runs the function its author wrote. A bounded, pure .hy step function could also define the population that a generated Go caller can draw from. For the first experiment, the checker would admit only a fixed horizon, small finite input alphabets, scalar state with explicit bounds, and deterministic transitions over a visible symbol and a private choice. The roster rule uses the previous volunteer, the number of C shifts and a Boolean for whether the handoff was selected. The compiler can read this typed control flow and reject unsupported effects. A Go library receiving an opaque predicate must instead enumerate all inputs or ask its caller for a separate model of the policy.

Why this is a breakthrough, not an increment

The contract is that adding a second private justification for an already feasible public schedule must leave that schedule's odds unchanged. After each visible symbol, collect the set of possible private states. Count accepting visible suffixes from that set using arbitrary-precision integers. Those counts partition ranks into consecutive blocks for each next volunteer. An unbiased integer draw in the total range then chooses one roster. Determinization and counting are established techniques. The research question is whether Hybrid can derive this contract from a useful source fragment economically. Issue #4787 uses a rank to recover the particular input that produced a retained output. Here the private history is disposable, and counting extra histories would give the wrong odds.

How we would know it works (or doesn't)

Codex implemented and ran a stand-alone Python model. For eight shifts there were 151 visible rosters and 284 valid roster-and-handoff pairs. Of the rosters, 43 had one handoff choice, 84 had two, 23 had three and one had four. Every roster occurred exactly once when decoding ranks 0 through 150. An independent whole-roster enumerator agreed on the complete lexicographic list at every length from zero to nine, covering 29,524 candidate rosters. The test also checked empty populations and out-of-range ranks.

M1 would extract transitions from one real .hy policy and emit ordinary Go with count and rank-decoding functions. Compare every rank against the independent oracle. M2 would give every private training branch two equivalent encodings, rebuild, and require identical counts and identical decoded rosters for every rank. A single difference falsifies the contract. In Go, draw from [0,N) with crypto/rand.Int and a big.Int bound. An empty population returns an error.

Cost honesty (optional but powerful)

The measured result covers the model. Source extraction and generated Go remain untested. The reachable sets can grow exponentially. Measure peak states, count storage, build time and draw time against a hand-written generator and brute-force enumeration. Cap the first spike at 4,096 reachable subsets and 64 MiB of count storage. If extraction sees a foreign call, unbounded state or an exceeded cap, decline generation with a diagnostic. Publishing the first small policy on which this loses to enumeration would give the experiment a useful stopping point.

Reproduce the standalone experiment (Python 3.10+)

Save as roster_draw.py and run python3 roster_draw.py. Uses the standard library.

"""Enumerate visible rosters fairly despite multiple valid training-handoff choices.

Run with Python 3.10+ using only the standard library.
"""
from collections import Counter
from functools import cache
from itertools import product
from secrets import randbelow


VOLUNTEERS = "ABC"
START = frozenset({("", 0, False)})


@cache
def advance(states, volunteer):
    """Consume one visible symbol, collecting every possible private witness state."""
    next_states = set()
    for previous, reserves, selected_handoff in states:
        if volunteer == previous:
            continue
        next_reserves = reserves + (volunteer == "C")
        if next_reserves > 2:
            continue
        next_states.add((volunteer, next_reserves, selected_handoff))
        if previous == "A" and volunteer == "B" and not selected_handoff:
            next_states.add((volunteer, next_reserves, True))
    return frozenset(next_states)


@cache
def completions(states, shifts_left):
    if not states:
        return 0
    if shifts_left == 0:
        return int(any(selected for _, _, selected in states))
    return sum(completions(advance(states, who), shifts_left - 1) for who in VOLUNTEERS)


def roster_at(length, rank):
    if length < 0 or not 0 <= rank < completions(START, length):
        raise ValueError("Rank is outside the feasible roster population.")
    state = START
    roster = []
    for remaining in reversed(range(length)):
        for who in VOLUNTEERS:
            after = advance(state, who)
            count = completions(after, remaining)
            if rank < count:
                roster.append(who)
                state = after
                break
            rank -= count
    return "".join(roster)


def draw(length):
    if length < 0:
        raise ValueError("Roster length must be nonnegative.")
    count = completions(START, length)
    if count == 0:
        raise ValueError("This policy has no feasible roster of the requested length.")
    return roster_at(length, randbelow(count))


def witness_count(roster):
    """Independent whole-roster oracle; each A→B boundary may be the designated one."""
    if roster.count("C") > 2 or any(a == b for a, b in zip(roster, roster[1:])):
        return 0
    return sum(a == "A" and b == "B" for a, b in zip(roster, roster[1:]))


def check():
    checked = 0
    for length in range(10):
        rosters = ("".join(xs) for xs in product(VOLUNTEERS, repeat=length))
        wanted = {r: n for r in rosters if (n := witness_count(r))}
        total = completions(START, length)
        assert total == len(wanted)
        assert [roster_at(length, r) for r in range(total)] == sorted(wanted)
        for invalid in (-1, total):
            try:
                roster_at(length, invalid)
            except ValueError:
                pass
            else:
                raise AssertionError("Invalid rank accepted")
        if total == 0:
            try:
                draw(length)
            except ValueError:
                pass
            else:
                raise AssertionError("An impossible roster was drawn")
        if length == 8:
            print(f"8 shifts: {total} visible rosters, {sum(wanted.values())} witness-bearing assignments.")
            print("Rosters per witness multiplicity:", sorted(Counter(wanted.values()).items()))
            for distinct in sorted(set(wanted.values())):
                example = next(r for r, witnesses in wanted.items() if witnesses == distinct)
                print(f"{example}: {distinct} witness(es)")
        checked += 3 ** length
    print(f"Oracle examined {checked:,} candidate rosters across lengths 0–9.")


if __name__ == "__main__":
    check()

Track terms

  • I understand no prototype is required and failure-with-knowledge is a valid, paid outcome
  • I understand all outcomes (including declines and failures) are published in MOONSHOT.md

Activity

  1. added
    💎 Bounty
    wildcard
    on Nov 28, 2026
  2. t3ratech commented on Nov 28, 2026

    @t3ratech

    /attempt

  3. LuoqingGu commented on Nov 28, 2026

    @LuoqingGu

    /attempt #4896

    Spike in progress: independent exhaustive enumeration to check the 151 rosters / 284 valid (roster, handoff) pairs, then the determinised counting draw the proposal describes, plus two deliberately wrong implementations (uniform over pairs, roster-then-handoff) sampled 100k times so the bias is measured rather than asserted.

  4. LuoqingGu commented on Nov 28, 2026

    @LuoqingGu

    Spike landed: PR #4910 -- spikes/w-roster-draw-4896/ (Python standard library only).

    Your numbers reproduce exactly, by three independent routes (DFS over the constraint, filtering all 3^8 words, subset construction): 151 rosters, 284 valid (roster, handoff) pairs, multiplicity 1×43 / 2×84 / 3×23 / 4×1; rank 0..150 decodes to 151 distinct rosters in lexicographic order and rank_of inverts it. Counts agree at every length 0..9 (29,524 candidate words).

    100,000 draws each, seed 20261128:

    implementation χ² p f(ABABABAB) f(ABACACBA) ratio [95% CI] H(reveal|roster)
    uniform over pairs 13008 <1e-300 0.01531 0.00335 4.570 [4.062, 5.142] 1.0048
    path-uniform 12946 <1e-300 0.01388 0.00370 3.751 [3.346, 4.206] 1.0048
    roster-then-boundary 158.3 0.306 0.00659 0.00657 1.003 0.8110
    determinised 120.0 0.966 0.00671 0.00648 1.036 [0.930, 1.153] 0.0000

    The middle row is the one worth keeping: sampling a roster uniformly first fixes the roster marginal (p=0.306) while the revealed handoff still leaks 0.811 bits of the private choice, and repeat reveals agree only 61.5% of the time. Only determinisation both keeps the roster uniform and leaks nothing.

    The contract test (write the private branch twice, visible language unchanged): determinisation holds the probability at 0.952 [0.854, 1.061]; path counting inflates it to 0.693 [0.630, 0.762] — falsified, as the proposal predicted.

    One pre-registered hypothesis is partially falsified and reported that way: "≤1000 subset states" holds only to n=20 once the state carries handoff age (n=24: 114,204 subsets / 11.8 s; n=32: 32.8 s / 401,902 subsets). With the boolean state the issue actually specifies, n=64 costs 3,007 subsets / 0.13 s.

    Also recorded: the first-run ratio CI excludes 4 (merged over 200k draws: 4.140 [3.814, 4.494]), and three implementation bugs the tests caught before any number was quoted.

    RESULTS.md: https://github.com/limitlessprojects/Go-Hybrid/blob/spike/w4896-roster-draw/spikes/w-roster-draw-4896/RESULTS.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wildcard💎 Bounty

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions