M1: Implement normalized capacity contract v1 #5
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
P1
P2
P3
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Creatidy/scarcity-router!5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "m1-capacity-model-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #4.
Summary
Implements the frozen v1 normalized capacity contract from
docs/capacity-model.mdas pure, provider-independent, standard-library-only product code, plus the repository quality gate. Incorporates all fixes from both review rounds.Contract implementation (
scarcity_router/)capacity.py— the four v1 dataclasses (CapacitySnapshot,CapacityWindow,LocalRuntime,CapacityDiagnostic), the_v_*validators as the single source of truth,_v_exact_shapefor serialized-shape validation, deterministic JSON-compatibleto_dict,SCHEMA_VERSION = 1.errors.py—CapacityError/CapacityValidationError.__init__.py— public API exports.Review fixes
__post_init__on all four dataclasses, so an invalid value can never exist as a public/serializable object — viafrom_dict()or a direct constructor call.from_dictraisesCapacityValidationError(never a rawKeyError) and rejects unknown keys; one validation path, shared by both construction routes.Quality gate (repo-managed basedpyright)
pyproject.tomlis tooling-only:[dependency-groups] dev = ["basedpyright>=1.0.0"]+[tool.basedpyright]withtypeCheckingMode = "recommended"(basedpyright's default; all rules enabled, less severe findings as warnings, and the default CLI policy fails on warnings — so all reported diagnostics are blocking), scoped toscarcity_router/+tests/.[project]table: package name/version/publishing metadata intentionally absent; U-008 remains unresolved (__version__stays0.0.0).uv.lockpins basedpyright==1.39.10; the gate invokesuv run basedpyright— the repo-managed environment, never a global executable; plainpyrightis not a substitute.Makefile:make test(full-suite unittest discovery overtests/),make typecheck,make check(test + typecheck, required exit 0).AGENTS.mdadditions: one-issue/one-branch/one-PR workflow invariants and type-checking governance (gate findings must be resolved at the defaultrecommendedruleset; no mode downgrades, broadreportXxx = nonesuppressions, baselines, or product-code exclusions; narrow suppressions require reported justification).Verification
make check: 84 tests OK + basedpyright 0 errors / 0 warnings / 0 notes, exit 0.# pyright: ignore/# type: ignore) in the repo.main:AGENTS.md,Makefile(new),pyproject.toml(new),uv.lock(new),scarcity_router/__init__.py,scarcity_router/capacity.py,scarcity_router/errors.py,tests/test_capacity.py.Scope boundaries
kilo referenced this pull request2026-10-25 19:10:32 +00:00