Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto eol=lf

*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
32 changes: 32 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## What this delivers

Launches Universal Sports Engine 0.3.0: a deterministic, high-throughput,
multi-league simulation platform with exact replay, bounded recursive calibration,
online expert weighting, drift-aware shadow monitoring, and content-addressed
champion governance.

## Why it matters

- Unifies MLB, NBA, WNBA, NCAA MBB, NFL, NCAA Football, and NHL behind a neutral kernel.
- Preserves sport-specific rules and mechanics in isolated league packs.
- Separates fast analytical distributions from interpretable event simulation.
- Makes every autonomous promotion, rejection, weight update, and rollback auditable.
- Fails closed when integrity, calibration, drift, or reproducibility gates fail.

## Verified evidence

- [ ] Ruff passes.
- [ ] Strict MyPy passes.
- [ ] All 67 integration and invariant tests pass.
- [ ] Release evidence gates pass across all seven leagues.
- [ ] The 49-control negative and mechanism suite reports zero failures.
- [ ] The 14,000-game stress audit reports zero failures.
- [ ] The autonomy audit verifies champion, ledger, shadow-update, and rollback integrity.
- [ ] A clean wheel rebuild reproduces the expected package contents.

## Evidence boundary

This release verifies mechanics, determinism, replay integrity, autonomy governance,
and measured local throughput. It does not claim real-world predictive supremacy.
That requires licensed point-in-time game, roster, injury, event, and tracking data
plus held-out and prospective validation.
54 changes: 54 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Quality

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

concurrency:
group: quality-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Python 3.12 verification
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Check out source
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Install project
run: python -m pip install --upgrade pip && python -m pip install -e ".[dev]"

- name: Lint
run: python -m ruff check .

- name: Type-check
run: python -m mypy src scripts

- name: Test
run: python -m pytest -q

- name: Build wheel
run: python -m pip wheel . --no-deps --wheel-dir dist

- name: Verify release gates
run: >-
python scripts/build_release_evidence.py
--games 500
--benchmark-games 100
--seed 20260718
--workers 2
--output "${{ runner.temp }}/release-evidence"
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.venv/
.repro-venv/
.repro-v3-venv/
__pycache__/
.pytest_cache/
.ruff_cache/
.mypy_cache/
*.egg-info/
build/
dist/
reports/archive/
reports/COPY_PROOF.json
reports/HANDOFF_PROOF.json
reports/COMPREHENSIVE_AUDIT_V2.md
reports/PERFORMANCE_AUDIT_V2.json
reports/PERFORMANCE_AUDIT_V3.json
reports/RECOVERY_AND_COMPLETION_REPORT.md
reports/STRESS_AUDIT_V2.json
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Universal Sports Engine Rules

- Keep the simulation truth independent from rendering.
- Preserve deterministic replay: identical versions, inputs, and seed must produce identical events.
- Keep sport semantics in league packs; the core API must remain domain-neutral.
- Fail explicitly on invalid state, unknown league IDs, corrupted event chains, and invalid rules.
- Do not claim real-world calibration from synthetic fixtures or reference anchors.
- Do not add wagering, sportsbook, brokerage, or live-capital behavior.
- Keep changes typed, functional, minimal, and covered by integration or replay tests.
- Never weaken a quality gate because a candidate or league pack fails it.
64 changes: 64 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Architecture

## Decision

The kernel uses immutable event drafts and a content-addressed event log as the
source of truth, pure reducers for replay, fixed phase ordering, and label-addressed random draws. This
combines the strongest parts of the two architectures recovered from the stalled
Kimi build:

1. Event-sourced state plus hierarchical domain state.
2. Explicit `PERCEIVE -> DECIDE -> ARBITRATE -> RESOLVE -> APPLY -> PUBLISH` phases.
3. Independent random namespaces and common-random-number counterfactuals.
4. Game-granularity parallelism; a single game timeline remains deterministic.
5. A result-envelope hash that commits to league, final score, seed, event chain,
and evidence metadata.

## Layers

```text
CLI / SDK / domain-neutral bridge
|
Champion governance, recursive calibration, adaptive weights, drift quarantine
|
F0/F1 routing, batch, historical evaluation, counterfactuals
|
League packs and sport-family resolvers
|
Domain-neutral event log, state, rules, RNG, replay
```

League packs own scoring, timing, possession/inning/drive/shift semantics, and
reference anchors. The kernel contains no player, ball, puck, inning, possession,
or scoreboard type.

## Fidelity

- F0: analytical/batch score distribution (implemented; no event path).
- F1: event-level paths (implemented for every league).
- F2: spatial-agent contracts and escalation interface (API complete; no tracking calibration).
- F3: rendering/physics adapter boundary (not implemented without tracking/physics evidence).

The fidelity router selects the lowest evidence-supported fidelity and rejects
unsupported F2/F3 requests. It never uses visual
plausibility as a substitute for held-out calibration.

## Integrity and performance

League packs accumulate immutable drafts locally and content-address them once in
linear time. External replay import recomputes the event chain and result envelope.
The RNG maps semantic labels directly to BLAKE2b uniform draws, so unrelated model
changes do not perturb other random namespaces.

## Recursive model governance

The adaptive layer is outside the neutral kernel. Profiles, expert mixtures,
online calibration state, champion bundles, and decision ledgers are immutable
and content-addressed. Search may mutate only bounded analytical parameters.
Promotion is decided on chronological calibration forecasts made before each
outcome is revealed. Test data, rule packs, evaluators, and quality gates are not
mutable search inputs.

Online shadow adaptation changes expert weights and interval scale, while two
loss EWMAs monitor drift. Drifted checkpoints remain auditable but are rejected
by adaptive simulation until a healthy successor or rollback is selected.
80 changes: 80 additions & 0 deletions AUTONOMOUS_IMPROVEMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Autonomous recursive improvement

Version 0.3 adds a bounded model-improvement system around the deterministic
simulation kernel. It changes analytical model parameters and ensemble weights;
it cannot edit source code, official rule packs, historical outcomes, split
boundaries, evaluators, promotion gates, or live-action interfaces.

## Evidence loop

```text
point-in-time train block
-> deterministic population search
-> diverse bounded expert pool
-> chronological calibration predictions
-> outcome revealed once
-> expert weights and interval scale updated
-> challenger compared with incumbent
-> promote or retain
-> content-addressed checkpoint and chained ledger
-> shadow outcomes update weights and drift state
-> healthy, quarantine, recalibrate, or roll back
```

Training outcomes select bounded score-model parameters. Calibration outcomes
are consumed prequentially: the ensemble predicts first, then receives the
outcome exactly once. Test outcomes are excluded from tuning and promotion.
Shadow outcomes may update an already selected champion but cannot rewrite its
lineage or erase prior decisions.

## Adjustable state

Each expert contains league-specific home and away score locations, total and
margin dispersion, and strength-response exponents. Recursive search uses
deterministic log-space mutations, retains a diverse elite set, and reduces the
mutation radius by generation.

The selected ensemble applies multiplicative expert weighting using joint score
likelihood and home-win Brier loss. A separate online calibration state adjusts
the 90% interval radius. Short- and long-horizon loss estimates produce a drift
score. A drift alert blocks adaptive simulation until a new governed checkpoint
or explicit rollback is selected.

## Promotion gates

A challenger must satisfy every preregistered requirement in
`AUTONOMY_CONFIG.json`:

- minimum composite-loss improvement;
- no excessive Brier deterioration;
- no excessive interval-coverage deterioration;
- finite scores and normalized non-negative weights;
- healthy calibration state;
- sufficient non-overlapping train and calibration evidence;
- valid profile, ensemble, adaptive-state, bundle, and ledger hashes.

Synthetic fixtures can validate learning mechanics but can never certify
real-world accuracy. Real promotion claims require licensed point-in-time data
and an untouched test audit after the champion is frozen.

## Commands

```powershell
.\.venv\Scripts\sports-engine.exe auto-improve `
--csv data\point-in-time\historical.csv `
--config AUTONOMY_CONFIG.json `
--output reports\improvement-run-001

.\.venv\Scripts\sports-engine.exe simulate-adaptive `
--bundle reports\improvement-run-001\champion_bundle.json `
--league nba --seed 42 --home-strength 1.0 --away-strength 1.0

.\.venv\Scripts\sports-engine.exe adapt-online `
--csv data\point-in-time\shadow.csv `
--config AUTONOMY_CONFIG.json `
--bundle reports\improvement-run-001\champion_bundle.json `
--league nba --output reports\nba-shadow-checkpoint-001.json
```

Output paths are fail-closed: existing improvement artifacts and adaptive
checkpoints are not overwritten.
22 changes: 22 additions & 0 deletions AUTONOMY_CONFIG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"brier_weight": 2.0,
"coverage_weight": 2.0,
"drift_threshold": 0.12,
"elite_count": 6,
"experts_per_ensemble": 6,
"generations": 8,
"interval_learning_rate": 0.04,
"long_decay": 0.03,
"maximum_brier_deterioration": 0.01,
"maximum_coverage_error_deterioration": 0.03,
"minimum_calibration_games": 50,
"minimum_drift_observations": 40,
"minimum_relative_improvement": 0.01,
"minimum_train_games": 100,
"mutation_scale": 0.12,
"online_learning_rate": 0.25,
"population_size": 32,
"seed": 20260718,
"short_decay": 0.20,
"target_coverage": 0.90
}
22 changes: 22 additions & 0 deletions DATA_RIGHTS_AND_PROVENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Data Rights and Provenance

## Local build inputs

No licensed event feed, tracking feed, private injury feed, sportsbook feed, or
proprietary roster database is present in this repository.

The shipped engine uses:

- deterministic synthetic events generated by the versioned league packs;
- transparent league-level reference anchors for broad output sanity checks;
- official rule-source links as provenance pointers for the minimal rule manifests.

The reference anchors are approximate research fixtures. They are not an ingested,
point-in-time dataset and are labeled `provisional_reference_anchor` everywhere.

## Prohibited promotion

These inputs cannot support a claim of held-out player, team, game, season, spatial,
or counterfactual accuracy. Such claims require separately licensed data manifests,
earliest-available timestamps, revisions, train/calibration/test boundaries, and
independent reproduction.
12 changes: 12 additions & 0 deletions DOMAIN_NEUTRAL_ADAPTATION_READINESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Domain-neutral adaptation readiness

No external project was inspected, imported, or modified during this build.

The reusable boundary consists only of immutable state, action, observation,
scenario, counterfactual, uncertainty, fidelity, and evidence contracts. A future
consumer must implement its own domain pack and validation program. Sports rule
packs, reference anchors, league identities, and generated scores must not cross
that boundary.

Compatibility is demonstrated by the included non-sports inventory-control fixture.
There is no live-action, capital, brokerage, sportsbook, or wagering adapter.
22 changes: 22 additions & 0 deletions DOMAIN_NEUTRAL_KERNEL_SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Domain-neutral kernel specification

The kernel owns only immutable events, world-state payloads, phase ordering,
versioned rules, deterministic random draws, replay verification, fidelity routing,
and evidence metadata. It contains no sports entities or timing assumptions.

## Invariants

- Sequence numbers are contiguous and zero-based.
- Every event hash commits to its body and prior event hash.
- Identical root seed and semantic labels produce the same draw.
- An unavailable fidelity raises instead of silently returning a lower-fidelity answer.
- A league pack must verify its event stream before publishing a result.
- Portable replay import verifies the complete chain before returning a result.

## Extension points

- League pack: complete-game resolver and rule manifest.
- Learned transition: replaces a league transition function without changing evidence contracts.
- Spatial adapter: produces `SpatialState` values only after league-specific validation.
- Physics adapter: remains independent of rendering and uses the same event sink.
- Policy adapter: consumes observations and permitted actions, never omniscient state by default.
22 changes: 22 additions & 0 deletions KNOWN_LIMITATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Known Limitations

- The stalled remote Kimi repository was not exported; this is an independent local reconstruction.
- F1 event paths are calibrated only to broad reference anchors, not licensed held-out data.
- Player identities, rosters, coaching policies, officials, injuries, fatigue, venues, and weather are contract surfaces rather than calibrated models.
- F2 spatial trajectories and F3 physics/rendering are intentionally not fabricated without tracking evidence.
- Rule manifests cover complete-game flow but are not a complete executable transcription of every official rulebook edge case.
- Generic F1 games resolve a winner; competition-specific regular-season tie and
postseason context is not yet a first-class scenario input.
- The analytical F0 model matches provisional aggregate moments but does not emit
sport-valid event sequences or prove game-level predictive skill.
- Historical evaluation is implemented, but no licensed point-in-time test manifest
was supplied, so CRPS, Brier, and coverage results on real games remain unavailable.
- Recursive tuning currently adjusts F0 analytical score distributions and ensemble
weights. It does not fabricate player, tracking, tactical, F2, or F3 calibration.
- The bundled autonomy audit uses labeled synthetic fixtures solely to prove search,
weighting, gating, checkpoint, and replay mechanics. Its promotions are not
real-world champions.
- Windows multi-process calls require an importable script or CLI entrypoint; an
interactive/stdin caller receives an explicit error and should use F0 or one worker.
- Counterfactual pairing reduces simulation noise but does not by itself establish causality.
- No live feed, wagering, sportsbook, trading, or capital interface exists.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 ObtuseAI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading