Repository navigation
Description
Part of #9
Story
As a platform operator, I want to place requests without synchronous monitoring dependencies.
Business value
The plan (#6) sets this release exit for phase 3: "prod placement uses stored snapshots without a Thanos call; fresh-capacity rnd medium auto-approval succeeds; oversized quota change requires platform approval."
Context
cmapi/src/cmapi/core/capacity_backend.py simulates capacity (#62). cmapi-capacity is not built (build-tracker.md, "Not built, by area").
Acceptance criteria
- Internal capacity service stores snapshots at configured intervals; gateway enforces scope, shown by a new test in
cmapi/tests/service/, not written yet - Placement checks CPU and memory separately, freshness, reservations and zone-failure headroom, shown by a new test in
cmapi/tests/service/, not written yet - Concurrent reservations cannot overbook; expired reservations are reclaimed, shown by a new test in
cmapi/tests/service/, not written yet - Namespace creation makes no Thanos query, shown by a new test in
cmapi/tests/service/, not written yet
Tasks
- Build
cmapi-capacityand the real capacity guard (Wave 7). - Fix BUG-10: Capacity is simulated, so the auto-approval capacity guard always passes; delete thresholds lack requestToPeakRatio and openRequestOnNamespace #62.
Out of scope
- The source states none for this story.
Evidence
- None yet.
Definition of done
- Mockup approved, or the work has no screen and no API shape
- Draft pull request open
- Build: tests fail before the change and pass after it
- Documented where a reader looks for it
- Review ruled
- Merged with its proof
- Released on the default branch
- The owner approves, after a comment cites the proof for each criterion and its cluster
Class
INV. The story adds a new capability to the product.
Source
Status: Draft backlog. No sprint commitment.
Owner in Paperclip: Ahsoka. Ahsoka mentors Luke and assigns bounded engineering work after technical review.
Source: OBI-32.
Epic: #9. Plan, release windows, and review gates: #6.
Dependencies: #8 (OBI-26), OBI-19, OBI-20.
Planned story; phase 3, provisional 8 points (Ahsoka/Yoda to validate).
- Attach automated or reproducible evidence for each criterion; cover denial/failure paths.
- Read the plan; Yoda owns design choices. Keep this in backlog until prerequisite phase evidence is accepted. Ahsoka may split and delegate to Luke with mentorship.
Language acceptance criterion
Before sprint entry, the owner must define technical terms and attach language review evidence for this text revision.
Use simple-english 2.1.1, Strict mode. Index #6 records the vocabulary source and review limits.
The source criteria remain unchanged. Language review remains open.
Activity
ephico2real2 commentedon Nov 19, 2026
Work tag In-Progress. Evidence: merged part(s) of this issue: #305. The issue stays open for the rest; status:partly-fixed. Moved up from Backlog (records sweep 2026-11-19).
#21 review fixes: one capacity arithmetic for node-sized clusters, a …
#21 docs/14 citations relocated after the review fixes
#21 after merging main: samples, openapi.json, docs/04 and API types …
#21 after merging #733: samples, openapi.json (46 operations), docs/0…
#21 CI: accept the snapshotState break, capacity's writes in WRITERS,…
#21 docs/21's 15 citations relocated after placement moved registry.p…
Merge pull request #738 from ephico2real2/feat/21-placement
ephico2real2 commentedon Nov 27, 2026
The owner approved closing this story on 2026-11-27, after CRC run 45 (main 96b1621). The coordinator first overstated which criteria run 45 proved live, corrected it, and the owner approved again on the corrected picture: each criterion's named test is its proof (as the criterion says), live CRC evidence is added where it exists, and each test-only part is marked below.
Story #21, Capacity snapshots and safe placement: proof for each acceptance criterion.
Part of #9. Built by #725 (reservations, migration 0011, also closes #62) and #738 (snapshots, placement, migration 0012, also closes #303). Both merged on 2026-11-26.
Where the proof comes from:
workbench/cmapi/ob1-run45/resume.md, logs inob1-run45/logs/. Read-only beyond the deploy: dry runs only, noIdempotency-Key, no object created by hand.docs/reviews/2026-11-26-issue-21/README.md(D1 to D13) anddocs/reviews/2026-11-26-issue-62/README.md.Summary:
Criterion 1
Built by: #738. Worker job
capacity_snapshotruns in embedded mode (decision D1; docs/01 "One interface, two modes"). It writes rows for the cluster, each zone and each node role, everysnapshotIntervalofcapacity.yaml(15 to 60 minutes, 30 default).GET /api/v1/clusters/{id}/capacityneedscapacity:readin the cluster's environment, else 404.POST .../capacity/snapshots:runneedsoperations:run. Migration 0012 addscapacity_snapshots.Tests, all in
cmapi/tests/service/test_placement_21.py:test_the_snapshot_job_stores_the_cluster_its_zones_and_roles_at_the_configured_intervaltest_with_thanos_the_snapshot_measures_requests_and_use_per_nodetest_a_failed_query_or_a_gap_over_5_percent_marks_the_snapshot_incompletetest_the_gateway_answers_a_cluster_s_snapshot_only_within_the_caller_s_environmentstest_the_capacity_tab_shows_each_cluster_s_snapshot(the Capacity tab)Counts: before the change the file had 21 failed, after it 21 passed (PR #738). After review, reviewer 2's final tree: 349 service tests passed,
tests/core856 passed, portal 199 ok.Live proof, cluster CRC.
logs/cap45-end.txt,logs/c45-capacity.out. Job 10845capacity_snapshotdone 2026-11-27 03:00:22Z; next job 10847 due 03:30:00Z. Incapacity_snapshots: "3 rows at 2026-11-27T03:00:00Z:cluster,role:master,role:worker", sourcethanos, complete.logs/c45-capacity/.GET /api/v1/clusters/CRC/capacityascmapi.requesterandcmapi.operator: 200, snapshotok, takenAt 03:00:00Z, CPU allocatable 7800 m, requested 6733, usedAvg 1722, usedPeak 2351, quotaCommitted 80000; memory allocatable 20493352960 B; pods 112/250.logs/c45b-sweep.out. "capacity_snapshot: 28 job rows, every one since 03:00Z done on attempt 1, eachcapacity_snapshotlog linerows 3, source thanos, complete true; next 11614 at 15:00Z." That shows the 30-minute interval holding for about 12 hours.logs/ui45b-capacity.out: Capacity tab, 6 checks, ALL PASSED, in the installed Chrome at 1440 and 390 px. CRC's Snapshot cell14:30equals the answer's snapshot (ok, takenAt 14:30:00Z, source thanos); pill "snapshot 14:30 · every 30 min".Not proven live:
cmapi.requesterandcmapi.operatorand got 200 for both. No out-of-scope call was made.topology.kubernetes.io/zonelabel (measured), and snapshots.py:249 writes a zone row only for a labelled zone." Zone rows are proven by the service test only.POST .../capacity/snapshots:runwas not called live.Criterion 2
Built by: #738 (
POST /api/v1/capacity:place,core/placement.py,plugins/capacity/placement.py): docs/02's hard filters, each with a named reason; the score; a 15-minute hold on the first cluster that still fits, under its advisory lock (201).dryRun=trueranks and holds nothing. A create'splacementIdturns the hold into the request's own. #725 adds the holds that placement counts.Tests, in
cmapi/tests/service/test_placement_21.pyunless named:test_cpu_and_memory_are_checked_separatelytest_a_stale_or_incomplete_snapshot_excludes_the_clustertest_placement_counts_the_holds_of_requests_and_of_other_placementstest_zone_failure_headroom_excludes_a_cluster_that_would_not_survive_losing_its_largest_zonetest_placement_ranks_from_a_fresh_snapshot_and_holds_the_winner_for_15_minutestest_a_create_with_its_placement_turns_the_hold_into_the_request_s_owntest_a_team_holds_at_most_three_placements_in_an_environment,test_with_no_team_the_cap_of_three_placements_is_the_caller_s,test_ranking_needs_capacity_read_and_the_hold_needs_namespaces_createcmapi/tests/core/test_placement_21.py(14 passed in the PR; 33 with the rate-limit tests)Counts as for criterion 1. The review fixed F1 (High: one capacity arithmetic for node-sized clusters), F3, F4 (Medium) and five Low findings. F2 was refuted against docs/02 and is owner question B1 in #737.
Live proof, cluster CRC.
logs/c45-place.out.POST /api/v1/capacity:place?dryRun=trueascmapi.requester, body {dev, team cmapi-live, small}: "200; CRC ranked, score 34, reserved false, placementId null", basis simulated, bound by CPU (48000 to 40000 m) and memory (160 to 144 GiB), usage p95 CPU 0.2208 / memory 0.8103. Holds before and after: 1 reservation, 0 active, 0 placement holds.logs/ui45b-new.out: the New namespace tab's placement preview, 6 checks, ALL PASSED: the page'sPOST /api/v1/capacity:place?dryRun=true, noIdempotency-Key, 200, placementId null. "Ranked clusters":1 CRC cpu 48 → 32 cores · memory 160 → 128 Gi · p95 0.81 30. No Check and no Submit pressed.Not proven live:
Criterion 3
Built by: #725 (migration 0011
capacity_reservations;Pipeline.submitchecks every hold taken since the plan, under the cluster'spg_advisory_xact_lock; the last:approveand a:retryfromfailedcheck again; expired holds stop counting and are markedexpiredby the next hold). #738 adds the same for placements.Tests:
cmapi/tests/service/test_capacity_reservations_62.py:test_concurrent_submits_cannot_overbook,test_two_plans_made_before_either_submits_are_checked_again_under_the_lock,test_an_expired_hold_is_reclaimed,test_a_request_holds_its_increase_and_a_second_that_fits_alone_is_refused,test_a_request_for_more_than_the_cluster_has_free_is_refused,test_the_last_approval_checks_the_hold_again,test_a_retry_from_failed_holds_again_only_when_it_still_fits,test_a_request_that_ends_releases_its_hold,test_a_synced_request_releases_its_hold_and_its_quota_is_counted_once.cmapi/tests/service/test_placement_21.py:test_concurrent_placements_cannot_overbook,test_an_expired_placement_is_reclaimed_and_holds_nothing,test_a_placement_used_or_lapsed_between_the_plan_and_the_submit_records_nothing.Counts (PR #725, PostgreSQL 16): before the fix 11 failed, 3 passed (the 3 are guards), including "8 of 8 concurrent submits held on room for 3"; with the fix 14 passed. Review record: 57 service tests plus reviewer 2's 261 service tests and 843 core tests passed; 5 of 5 mutants caught. Fixed after review: H1a, H1b, H2 (approval part), H3 (the 40P01 deadlock, now 409), H4 (migration 0011 fills holds for requests in flight), and the M1 rounding. M2 was refuted. PR #738: the race, rollback and migration 0012 were checked on PostgreSQL by reviewer 2.
Live proof, cluster CRC: the schema only.
logs/migrator.txt,logs/readiness-0012.txt. The worker'smigrateapplied 0011 and 0012 at 03:00:12.97Z (from_revision0010,revision0012). The API became Ready at 03:00:25Z after the database reached 0012./readyz200,{"status":"ok","database":"ok","schema":"ok"}.logs/cap45-end.txt. Tablecapacity_reservationsexists. Migration 0011's backfill made one hold,req-20261115-0002(the onefailedrequest), released at 03:00:12.70Z withreleased_why failed. Active holds: 0. Run 45b end: "Reservations 1, active 0 (no hold taken)".Not proven live: concurrent holds and expiry. A hold needs a real request or a real placement, and run 45 allowed none. This criterion has service-test proof only.
Criterion 4
Built by: #738. The create path reads only the stored snapshot (decision D1).
Test:
cmapi/tests/service/test_placement_21.py::test_placing_and_creating_a_namespace_make_no_thanos_query(a fake metrics source that counts queries). Reviewer 2 re-checked "zero Thanos on create" on PostgreSQL (docs/reviews/2026-11-26-issue-21/README.md).Not proven live. No create ran in run 45 or 45b (no write, no
Idempotency-Key). The story audit cites older creates on CRC with monitoring scaled to 0 (run 32); they predate #738 and do not show that a create sends no query now. This criterion has service-test proof only.Open follow-ups
reserved.unknown PostgreSQL timezone: 'Etc/UTC'. No value changes.For the owner