Repository navigation
#256, #258: quotaBelowRequested reads the pods' live use; the team label is configurable (teamKey) - #771
Merged
Conversation
…bel is metadata-keys.yaml teamKey #256: TierCatalog.compare takes the use, and neither caller passed it, so quotaBelowRequested was always false. Pipeline.quota_used reads the status.used of the live ResourceQuota that Git's quota is, from the watch cache that the capacity check reads, and the plan and the revert pass it. A key that the change lowers and whose use cannot be read (no live quota, a watch that has not listed, is stale or refused) counts as below: fail closed, logged quota_used_unknown. A key that the change does not lower never does. #258: cmapi.net/team was hard-coded for placement, the fact team, the daily allowance per team, change_requests.team and the list views. The new stanza teamKey names the label, cmapi.net/team by default; a named key must be a declared label. The company example names company.net/mnemonic. Contract, portal types, Helm schema, docs/02, docs/18 and the glossary follow.
…wly added); scoped quota is unknown; default approver when no rule reads quotaBelowRequested; deletes count against the team allowance; company portal places with its team key Reviewer 1 (Codex gpt-6.2-astra) and reviewer 2 (Fable) findings, plus one coordinator finding fixed by reviewer 2. Record: docs/reviews/2026-12-01-issue-256-258/.
…1 pipeline citation moved by one line)
…ent for that case; docs/01, #710) Reviewer 2 (Fable) amend2.diff, applied by the coordinator.
…ons relocated, spans checked)
…ions relocated, docs/14 pipeline.py:298 corrected by hand
14 tasks
ephico2real2
added a commit
that referenced
this pull request
Dec 1, 2026
…iew record: 0014 revises 0013
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #256
Closes #258
Two Medium defects in the approval facts. Both were found by the Sonnet 5.5 documentation pass of PR #254 and stated as gaps in docs/18.
#256:
quotaBelowRequestedwas always falseWhat was wrong.
TierCatalog.comparetakesusedand setsquotaBelowRequestedwhen a new hard value is below it. Both callers,Pipeline._plan_namespaceandPipeline.restore_facts(the revert), called it withoutused. So the fact was always false and the shipped rulewhen: quotaBelowRequested(approval-rules.yaml) never fired. docs/01, "Quota changes on existing namespaces", says: "A decrease below what pods already request is refused unless approver-platform approve, because new pods would be rejected at admission."The fix.
Pipeline.quota_usedreads what the pods request now. This is thestatus.usedof the live ResourceQuota that Git's quota is, read from the cluster's watch cache. The capacity check reads the same cache. A short name (cpu,memory) stands in for its long one, as incapacity_ledger. Both callers pass the result tocompare.comparecounts a key that the change lowers as below (fail closed,QuotaChange.unknown_lowered). The use cannot be known when there is no quota in Git or no watch cache. It also cannot be known when the Namespace or ResourceQuota watch has not listed, is stale or is refused (401 or 403, the same test ascapacity_backend._read_cached_quotas), or when the live namespace has no such quota. A key that the change does not lower is never counted for want of a read. A namespace that a fresh watch does not hold has no pods, so it requests nothing. The planner logsquota_used_unknownwith the reason.Why fail closed. Each source is quoted, with its URL and the date it was read:
403 Forbidden." So a quota lowered below the use keeps the pods that are running and refuses new ones.status.usedas: "Used is the current observed total usage of the resource in the namespace."ApprovalRules._addedadds approver-platform. A delete's workload count is "unknown is 503, never 0".#258:
cmapi.net/teamwas hard-codedWhat was wrong. The pipeline read the
cmapi.net/teamlabel for placement, the factteam, the daily auto-approval allowance per team (auto_approvals_today) andchange_requests.team. Placement's team count, the quota, namespace and expiration list views, and the revert job read it too. The owner's company example declares nocmapi.net/team. With it, no namespace had a team, so the allowance never applied.The fix. metadata-keys.yaml gains the stanza
teamKey, read byMetadataKeys.team_keyandteam_of(). Every reader above now goes through it.cmapi.net/team. A file written before the stanza keeps its behaviour, declared or not.teamKeymust declare it as a label inrequiredLabelsorextraLabels.keys, or the loader refuses the file. Otherwise the key would be read on no namespace, and the allowance would silently apply to none.teamKey: company.net/mnemonic. The reference file and the chart file namecmapi.net/teamexplicitly.values.schema.jsontakesteamKeyas optional, as it takesliveOnlyKeys.teamquery parameters,NamespaceView.team,PlacementRequest.teamand theplacement-mismatchfix text) now name the team label. The contract and the portal types were generated again (CMAPI_WRITE_CONTRACT=1,npm run api:types);scripts/api-examples-doc.py --checkpasses.Tests: fail before, pass after
Before: the new tests copied onto
origin/main0030e34 (record:workbench/cmapi/impl-256-264/before-256/before-run.txt). After: this branch.tests/service/test_quota_below_requested_256.py: below the use (plan), unknown use, stale watch, revert['dev change: 0 from approver-platform'], no rule; the revert'squotaBelowRequestedFalse)tests/service/test_quota_below_requested_256.py: above the usetests/core/test_quota_below_requested_256.pytests/service/test_team_key_258.py: company file, allowance 1, second createassert 'approved' == 'pending_approval'tests/core/test_team_key_258.pyDEFAULT_TEAM_KEY)Measured here, locally, against PostgreSQL 16 on 127.0.0.1:55432:
tests/core): 1027 passed, 117 skipped;test_quota_below_requested_256.py5 passed,test_team_key_258.py1 passed,test_catalog_drift_710.py8 passed,test_revert_sizing.py9 passed,test_helm_metadata_values.py83 passed,test_api_docs.py -k committed_contract1 passed. (A broader local run was stopped at the coordinator's request because of machine load.)The full service suite was not run locally. CI is the gate.
Not tested
status.usedis inferred from the API reference, not measured here.contract/lint.sh(Spectral) was not run locally. Only descriptions changed. CI'sapi-contractjob runs it.schema.generated.tscomments changed.Who wrote what
All commits are by Opus 5.5 at high, the implementer. No reviewer has seen it yet. The review goes to reviewer 1 and reviewer 2, because the change is over 50 lines and touches the approval gate.