M1: Implement normalized capacity contract v1 #4
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#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
M1: Implement normalized capacity contract v1
Objective
Provide one small, provider-independent Python implementation that:
unknown);This is the implementation target for later provider adapters (the Z.ai/Codex parsers are separate, follow-on tasks that emit this model).
Contract reference (authoritative for schema v1):
docs/capacity-model.md— the "Freeze normalized capacity contract v1" work, accepted as decisionU-002indocs/decisions.mdand shipped onorigin/mainvia PR #2.Exact scope
A new small Python module (standard library only) that defines and enforces the frozen v1 schema:
schema_versioninteger1(reject any other value or type);provider,source,plan(optional),retrieved_at,status,windows, optionallocal_runtime,diagnostics;ok,unavailable,auth_required,unsupported,schema_changed,unknown) — provider-specific error types must not appear as new statuses;window_idallowed) vs. snapshot-scoped codes (must have nowindow_id), and the required status-to-code coupling for non-oksnapshots;YYYY-MM-DDTHH:MM:SS.sssZ(exactly three fractional digits, literalZ); reject offsets, local times, and non-canonical forms;resource(tokens|time|unknown) andkind(five_hour|weekly|unknown); optionalduration_seconds(positive integer; fixed 18000 forfive_hourand 604800 forweekly); optional complementaryused_percent/remaining_percentpair; optional canonicalresets_at; optional safeprovider_metadata.window_id;used=0/remaining=100(known empty) andused=100/remaining=0(known exhausted) are distinct from an omitted pair (unknown);unavailable,auth_required,unsupported,schema_changedsnapshots must have an emptywindowsarray;[a-z0-9][a-z0-9._:-]*, max 64 chars) forprovider,source,plan,model_name,window_id;Explicit non-scope
status,doctor,selector any CLI/REST/MCP command;Does not resolve
U-001,U-003,U-005,U-006, orU-007.U-004evidence is input, not work for this change.Tests required
Deterministic, self-contained tests covering the contract invariants. At minimum:
Valid cases
used_percent = 0(known empty window);remaining_percent = 0(known exhausted window);Invalid cases (must be rejected)
schema_version;used_percent/remaining_percentpresent;used_percent/remaining_percentpair (sum not 100);auth_required,unsupported, orschema_changed;Additionally, tests must demonstrate explicitly that these are distinct states: a known
used_percent = 0, a knownremaining_percent = 0, and an absent percentage pair.AGENTS workflow hardening (corrective governance change)
The M1 reconnaissance task left valuable uncommitted work on
mainthat a dependent agent then bypassed with a secondary worktree.AGENTS.mdgains a concise repository workflow section so this cannot silently recur. Invariants to be captured:main;main;origin/main..HEADcontains only this task's diff (no unintended merge commits, no unrelated files).Acceptance criteria
git diff --checkclean over the changed/new files; secret-pattern scan over the changed/new files is clean.AGENTS.mdcontains the new repository-workflow section with the invariants above.origin/main..HEADcontains only this issue's changes, no merge commit, no unrelated files, and no credential or raw sensitive provider material.main, left unmerged, withCloses #<issue>in its body.kilo referenced this issue2026-10-25 16:08:23 +00:00