ADR-0040: Code sizes a memory proposal from the metrics, and the pull request shows the evidence¶
- Status: Accepted
- Date: 2026-11-14
This ADR amends ADR-0026 (the model sees the policy bounds) and settles the deferred alternative named there. Issues #508 (sizing in code) and #506 (evidence in the pull request) are one decision, so they share this page. Metrics as evidence for the outcome check of ADR-0030 (verification) moved to #741: #508 and #506 now cover sizing only, so the ADR-0030 sentences that say KEDA requests cannot succeed "until metrics are evidence (#508, #506)" are no longer true of these two issues (the amendment entry of ADR-0030 points at #741). ADR-0034 asks in its open question 2 to revisit pack-named values "when sizing by code exists"; this ADR is that sizing for memory, and the two pages link each other.
Each statement is marked Decided (2026-11-14: in the comments of #508 and #506, or accepted with this ADR) or Open (a question this ADR does not answer). The sizing rule is decided but not built: the text describes what the code will do.
Context¶
In the lab run of 2026-11-07 the model proposed 96Mi for a container limited to 48Mi, and the policy refused the step. ADR-0026 answered by showing the model the bounds, and says what that costs: injected text that steers the model now gets a proposal at the exact maximum step, which passes the policy; "within the bounds, the person approving is now the only check on the size of the step". The pull request body says only that the policy bounds the step and that the model's reason is in the analysis record. ADR-0026 deferred deterministic sizing to #508 because it needs a rule per action and metrics the analyzer may not have.
What the code has today (at 0220bc9b):
- The size is the model's.
MemoryLimitChange.Desiredis an argument of the result schema (internal/analysis/result.go). The loop replacespreviouswith the pod template's limit (#494,previousFromTemplate), and checks the direction andNoChange, but never the size.policy.CheckActionis a catalog check only. - The metrics are text. The context builder (
internal/incidentcontext/metrics.go) asks the source for the approved templates, among themcontainer_memory_working_set_bytes(a range query over the window,max by (pod, container, cluster)per step),container_memory_limit_bytes(an instant query) andcontainer_last_terminated_oomkilled, and renders the series as lines of a block. The samples are not kept as numbers;Contextholds blocks, the template containers and the ScaledObject snapshot. - The window is
windowOf: from ten minutes beforefirstSeento now, at least 15 minutes and at most 6 hours, one hour withoutfirstSeen. The step is about 60 points, at least one minute. At most 16 pods are asked (MaxMetricPods), and an answer can be partial or too large. - The analysis loop has no policy. The bounds block is built by the context builder from the named policies with
policy.BoundsForandpolicy.AllowedMemory; the loop sees the text only. - The request has
action.setContainerMemoryLimit(container,previous,desired) and no field for how the value was found.specis immutable by CEL. The executor'spullRequestBodyprints the change, the policy, the plan digest and a size sentence (stepSize), computed from the typed fields. - The policy (
MemoryLimitBounds):min,max,maxIncreasePercent(default 50),maxDecreasePercent(default 0, which refuses every decrease).
Decision¶
Decided on 2026-11-14¶
- Code sets the size. For
SetContainerMemoryLimitthe desired limit is computed from the metrics the context builder read: the peak working set plus headroom, rounded, clamped to the policy range. The model chooses the action and the container only. A size it suggests is not used. It may name the action and the container only where code observed memory pressure for that same container (item 6a). - No metrics, no proposal. Without a measurement for the container the Incident is handed off with the reason
MissingData. There is no fixed step and no fallback to a model value. - The request carries the evidence. Typed, bounded fields hold the numbers code used: the metric, the observed peak, the window, the headroom and the resulting value. They are values the context builder read, never model prose. The field is optional in the schema (item 14). The executor prints them in the pull request body (#506).
Decided: the sizing rule¶
- Source. The
container_memory_working_set_bytestemplate over the analysis window, as the builder already asks for it. The measurement is the maximum over all samples and all pods of the container the proposal names. The builder keeps it as a typed value beside the block (a new field ofContext), from the same answer the model sees, so the evidence and the context cannot differ. Values the model fetched with a tool are not used: only what the builder read. - Peak, not a percentile. A container is killed at its peak, not at its 99th percentile, so a percentile would size below the point that fails. The window is the one the analysis already has, so the rule adds no query and no template. The cost is that one transient spike sets the size; the headroom and the policy range limit what that can do (threats below).
-
"At the limit" makes the peak a lower bound. The working set cannot exceed the limit, so a container that was killed shows a peak at or just under the old limit, and the measured peak understates the need. The "at the limit" step (need at least limit x 1.5) applies only in one of two cases:
- the Incident being analyzed carries a code-observed
OOMKilledsymptom for that container, inside the analysis window: the collector's own observation of container status (never model output). The collector also readsLastTerminationState(internal/analyzer/collector/pods.go,terminations), which stays after the fault is gone, so the symptom counts only if its last-seen time is not before the start of the analysis window. Both are recorded state: the last-seen time is the arrival time the collector recorded, and the window start is whatwindowOfderives from the Incident'sfirstSeen, another arrival time of the same collector. No sample time and no time from the container's own status (finishedAt, which is the node's clock) is compared with either. The symptom's last-seen time is the Incident'sstatus.lastSeenuntil ADR-0039 gives each symptom its own; or - the measured peak in the window, for that container, is at least 90% of the limit of the same pod (item 11).
container_last_terminated_oomkilledis not the signal. It is an instant query over kube-state-metrics' last termination reason (kube_pod_container_status_last_terminated_reason), which stays 1 from the kill until the next termination, so it does not show a kill inside the window; thelastStateof the container status is sticky in the same way. A container that was OOM-killed days ago and is idle now must not get a step (threats below). The 1.5 and the 90% are starting values to tune on lab runs, not read from the model. The factor equals the defaultmaxIncreasePercent, so that a default policy allows the step. Dependency on ADR-0039: the Incident has to name the container for the symptom to be matched to it (ADR-0039, Accepted on its branch in PR #739, not built; it is not on this branch, so it is not linked yet). Until an Incident names the container, an unattributedOOMKilledsymptom opens the gate for no container the model names, and the result isNoMemoryPressure(item 6a). Only the peak at or above 90% of the limit can open it then. 6a. The evidence gate. ASetContainerMemoryLimitfor a container is accepted from the model only when code observed memory pressure for that same container: theOOMKilledsymptom of item 6 on the Incident that names that container (so, until ADR-0039 is built, only the peak path), or a peak at or above 90% of the limit. Otherwise there is no request and the Incident is handed off with the new reasonNoMemoryPressure(a measurement exists and shows no pressure; with no measurement, decision 2 givesMissingData). The gate decides from recorded state: the symptom and the typed measurement. 7. Headroom.need = ceil(peak x (1 + headroomPercent / 100)), default 25. It is configured on the policy, as an optionalheadroomPercentofMemoryLimitBounds(1 to 100): the policy is the object the admin owns and the analyzer already reads for the bounds (ADR-0026), and the executor ignores the field, so the executor's decision does not change. A flag of the analyzer would apply one number to every policy, so the policy field is the choice. 8. Rounding. The unit is 8Mi, a starting value to tune on lab runs like the other constants (items 6 and 11). Quantities are written in the binary form the action's pattern accepts. 9. The arithmetic, in this order. 1.need = max(ceil(peak x (1 + headroomPercent / 100)), limit x 1.5), the second term only when the "at the limit" rule of item 6 applies. This is the unrounded need. 2. If the unroundedneedis above the policymax:PolicyMaxBelowNeed(item 10). 3. Roundneedup to the unit. If the rounded need is abovemaxbut the unrounded one is not, the value ismaxitself,limitedBy: None:maxcovers the measured need, and only the rounding exceeded it. This value is kept as it is, even wheremaxis not a multiple of the unit. 4. Clamp to the rangepolicy.AllowedMemoryreturns for an increase from the template's limit: at leastmin, at mostmax, and at mostlimit + floor(limit x maxIncreasePercent / 100), the arithmetic ofmaxDeltaininternal/policy/bounds.go, the one the executor's decision uses. One function means that the analyzer and the policy cannot disagree. A value that the step ceiling lowered is rounded down to the unit, so it is a multiple of 8Mi and below the ceiling, never above it. Otherwise the result is a multiple of 8Mi except themaxof step 3. 5. If the result is not above the current limit, or no range is allowed:SizeNotAnIncrease.Worked, with the default policy (+50%), a
maxhigh enough not to bind (1Gi) in examples 1 and 2, andlimitedByfor the evidence. Example 1: limit 48Mi, peak 47.9Mi, at the limit. Headroom term: ceil(47.9Mi x 1.25) = 59.875Mi. Limit term: 72Mi. Need 72Mi, already a multiple of 8Mi. The step ceiling is 48Mi + floor(48Mi x 50 / 100) = 72Mi, so nothing is clamped: 72Mi,limitedBy: None. Example 2, not a multiple: limit 100Mi, peak 100Mi, at the limit. Headroom term 125Mi, limit term 150Mi, need 150Mi, rounded up to 152Mi. The ceiling is 100Mi + 50Mi = 150Mi, so 152Mi is clamped to 150Mi and rounded down to 144Mi: 144Mi,limitedBy: Step. Both results are above their limit, so neither isSizeNotAnIncrease. Example 3, rounding abovemax: policymax150Mi,maxIncreasePercent100,headroomPercent100, limit 80Mi, peak 72.5Mi (90.6% of the limit, so at the limit). Headroom term 145Mi, limit term 120Mi, need 145Mi, belowmax. Rounded up it is 152Mi, abovemax, so the value ismaxitself: 150Mi (the step ceiling is 160Mi, so nothing else clamps it),limitedBy: None. Comparing the rounded need withmaxwould have handed off withPolicyMaxBelowNeedalthough 150Mi covers the need. 10. No proposal, with a reason. - The unrounded need is above the policymax: hand-off with the new reasonPolicyMaxBelowNeed. The text says that the policy bound is too low for the measured need, with the numbers, so an admin can see what to change. A value at the policymaxwould be Allowed and would not fix the fault, which is worse than a hand-off. - The clamped value is not above the current limit (the measured need is below it, or no increase is allowed): hand-off with the new reasonSizeNotAnIncrease. Decreases are not proposed (item 17). - The need is above the step limit but not abovemax: Decided (2026-11-14): propose the clamped value and showlimitedBy: Stepin the evidence. Repeated bounded steps, each followed by the outcome verification (ADR-0030), are how the limit converges on the need, and the next Incident for the same container may step again. A hand-off, as withmax, was the alternative and was not chosen. - The new reasonsPolicyMaxBelowNeed,SizeNotAnIncreaseandNoMemoryPressuremust join every closed list of reasons: theHint.reasonenum andHintDeclineReasons(api/v1alpha1/hint_types.go, where the marker and the Go list must stay equal),declineTextininternal/controller/hintreply.go(the three belong with the "made no proposal" group), the outcome messages ininternal/analysis/controller.go(outcomeMessages, with theReasonconstants ofinternal/analysis/loop.go), and the reason table ofdocs/troubleshooting.md(the table of reasons of an analysis that ends without a request). The CRD and chart CRD are regenerated and the API reference refreshed. 11. Measurements that do not count. A partial answer, a capped pod set (more than 16 pods), too few recent samples for the container, or a failed read gives no measurement, so decision 2 applies. A failed read is a source failure the builder already reports for a retry; it is never turned into "no series". No decision compares a sample time with the analyzer's clock. Freshness is shown by the samples themselves: a count over a window of up to six hours says nothing about whether the container was still observed near its end, so the measurement needs samples in the last part of the window, proposed as the last quarter, at least two of them (the fraction and the minimum are starting values to tune on lab runs), plus the answer's ownPartialflag. Where the last quarter has none, the container is handed off withMissingData. For the "at the limit" comparison, the limit is the value ofcontainer_memory_limit_bytesfor the same pod as the peak sample, not the template's value: a pod from before a rollout can still carry the old limit. Today that template is an instant query, so the plan entry for it becomes a range query over the window (overWindow) and the comparison uses the limit at the peak sample's step. Thepreviousof the request stays the template's limit (#494). - the Incident being analyzed carries a code-observed
Decided: where it runs, and the policy engine¶
- In the analysis loop, in
finish, after the reply is decoded and before the request is created. It sits next topreviousFromCluster: that function already takespreviousfrom the template, and the sizing function takesdesiredfrom the measurement. The loop needs the policy's typed bounds, which only the context builder reads today, so the builder returns the bounds it used as typed values with the block text (one read, the same one the model's block was made from). - The policy engine still decides every request in the executor (invariant 1). The computation proposes; it does not authorize. The executor reads the policy again, and a value outside the bounds is Denied exactly as now. The evidence fields are not part of the decision and not read by it (invariant 2: no new action, no new parameter that changes what is applied).
Decided: the API and the pull request¶
-
Evidence on the request. A new optional
spec.sizingnext toaction, set only by the analyzer for a memory proposal. Illustrative, not final:spec: action: type: SetContainerMemoryLimit setContainerMemoryLimit: container: web previous: 48Mi desired: 72Mi sizing: metric: container_memory_working_set_bytes # an enum of approved templates observedPeak: 50331648 # whole bytes window: {start: "2026-11-14T08:00:00Z", end: "2026-11-14T09:00:00Z"} samples: 58 atLimit: true # the "at the limit" rule applied: the peak is a lower bound headroomPercent: 25 limitedBy: None # None, Step, MinThe bounds:
metrican enum,observedPeaka bounded integer,samples1 to 100000,headroomPercent1 to 100, times asmetav1.Time, no free strings. The resulting value isaction.setContainerMemoryLimit.desired, not repeated. The spec is already immutable, so the evidence cannot change after the policy check.sizingis optional in the schema: CEL cannot see who created a request, and requests are also written by hand, so it cannot be required "for requests the analyzer made". CEL can only allow it withSetContainerMemoryLimit. The analyzer always sets it for a memory proposal, and a test asserts that. When it is absent, the executor's pull request body says that no sizing evidence was recorded (item 15). Open: whether the plan digest coverssizing(the digest then changes when only the evidence changes) or stays on the action alone, which keeps the executor's baseline and freshness checks as they are. 15. The pull request body gets one section from these fields: the observed peak, the window and the number of samples, the headroom, whether the "at the limit" rule applied, whether the policy step limited the size, and the resulting value. Withoutsizingit prints that sentence instead. It replaces the sentence of ADR-0026 that sends the reader to the model's unverified reason: there is no model reason for the size any more. The body prints the typed fields only, redacted as the rest of the body is.
Decided: what the model sees¶
- The model no longer needs the policy bounds to size, and ADR-0026's block stays only if another use appears: with this ADR, the model does not pick a number, so the block that was added so the model could stay inside the policy has no job. Decided: stop adding the block for
SetContainerMemoryLimit, and keep the analyzer'sgeton the named policies, which the loop now needs for the bounds (decision 12). The amendment of ADR-0026 says so. Open: whether the model should keep seeing that a policy exists for the action at all (NoPolicyForActionstays decided in code). The tool schema losesdesiredandpreviousofMemoryLimitChange; it keepscontainer. The prompt rule about the size ("the smallest change the evidence supports") is removed, and the catalog text says that the system sets the size. Themetricsblock stays, as evidence for the diagnosis.
Out of scope, named¶
- Decreases. Not proposed. They need their own rule (a low peak is not a reason to cut a limit while the workload may be seasonal) and
maxDecreasePercentis 0 by default. A follow-up may use the same measurement. AdjustKedaMaxReplicas(#497). That issue fillspreviousValuefrom the ScaledObject; the size ofmaxReplicaCounthas no measurement in this ADR (the template isdeployment_replicas_unavailable, and the backlog is not a template). A follow-up ADR when a sizing rule for replicas exists. The model keeps choosing that value until then, with ADR-0026 unchanged for that action.
Evaluation and verification¶
- Evaluation (ADR-0025). This changes the model's input (no bounds block for memory) and its output schema (no size), so the manifest digest changes and a new recorded evaluation is needed before the loop is used with the change. The cases assert different things: the model's reply is scored for the action, the container and the diagnosis; the size is asserted on the code's output for the recorded context, as a unit test of the rule with exact numbers (for example
oom: peak at the 48Mi limit gives 72Mi; the 100Mi case gives 144Mi withlimitedBy: Step). The "oversized proposal" score planned in #505 has nothing to score for memory and moves to the rule's tests. A recorded case with no metrics must endMissingData. - Outcome verification (ADR-0030). The recorded peak, window and headroom give a later "cleared" check a baseline to read, for example that the new working set stays below the new limit. Pointer only: the verifier's evidence stays container status in v0.5.0 (ADR-0030 decision 2) and nothing here changes it.
Decided on 2026-11-14: evidence tiers¶
The question raised on 2026-11-14: the Kubernetes metrics server (metrics.k8s.io) is installed on most clusters (AKS ships it) and Prometheus is not. Should it be a metrics source? Decided on 2026-11-14 (last comment of #508): tier 2 is accepted. Where there is no Prometheus, the code-observed OOMKilled symptom, cross-checked with the container status and corroborated by the metrics server, counts as the measurement for the "at the limit" step. Decisions 1 to 3 and the rule above stay as they are.
What the code does today without Prometheus: --prometheus-url empty means no metrics source, and the builder renders the metrics block as "not available: no metrics source is configured". Nothing in the loop turns that into a hand-off. The status block still shows the container's last termination (reason OOMKilled, which is sticky until the next termination) and the pod's own memory limit, so the model can propose a size, and today it is the model's. A hand-off with MissingData happens only if the model lists missing data in its reply (internal/analysis/loop.go). Decision 2 is what adds the hand-off for a missing measurement, so it holds only once this ADR is built.
- What the metrics server can and cannot say. The current working set of each container, sampled over a short window. It has no history: no peak, and nothing from before a restart. After an OOM kill it describes the new container instance only.
- A second adapter behind the same interface.
MetricsSourcehas one method,Query, with approved templates (ADR-0013, ADR-0017). A metrics server adapter answers the working set template only and returnsErrNotFoundfor every other template. It reads withgetandlistonpods.metrics.k8s.io(API groupmetrics.k8s.io, resourcepods), granted to the analyzer by a Role and RoleBinding in each watched namespace and never cluster-wide. It is off unless the API is present and a chart value allows it (name not fixed here). This adds a grant to the analyzer, so invariant 6 inAGENTS.mdis amended with it in the code PR. -
Three tiers of evidence for a memory size.
- Prometheus: the peak over the window, the full rule of items 4 to 11.
- Metrics server only: the Incident's code-observed
OOMKilledsymptom for the container proves that the need was above the limit (the symptom comes from container status, and the limit is that of the pod's own spec). As a cross-check, the termination occurrence the symptom recorded (the occurrence ID is a hash of the pod UID, the container and the termination's container ID,occurrenceininternal/analyzer/collector/pods.go) must be the one in that container's status now,LastTerminationStateorState; if the container has since been killed again or restarted so that it is not, the symptom is not used and the container is handed off. No time is compared:firstSeenis when the observation arrived (api/v1alpha1/incident_types.go), so the kill always precedes it, and item 11 forbids comparing a sample time with the analyzer's clock. The same window test as in item 6 applies to the symptom. The "at the limit" step of item 6 then applies without a peak: the need is the limit times 1.5, clamped as in item 9. The current working set from the metrics server is recorded as corroboration (for example, already above some share of the limit again), never used as the peak and never as the size. For a container without that symptom, the metrics server alone gives no size and no pressure evidence (item 6a), and the Incident is handed off.
A metrics server answer is required (decided 2026-11-14). The reading is used for the corroboration recorded in the evidence (item 25), so that the person merging sees a current figure next to the kill; it sets no size. If the metrics API is absent, or the read fails, there is no proposal: the Incident is handed off with the existing reason
MissingData, and the step is never taken from the symptom alone. A failed read is a source failure reported for a retry (item 11);MissingDatais for the API being absent or the retries ending. 3. Neither: hand-off withMissingData, as decided (decision 2). 24. Tier 2 revises nothing decided. There is still no model value and no guessed number, but it widens what counts as a measurement from a series of samples to the OOM symptom the collector observed. The maintainer accepted this on 2026-11-14. 25. The evidence fields name the tier.spec.sizinggets asourcevalue (Prometheus,MetricsServer,ContainerStatusor similar, an enum), and the pull request body prints it, so the person merging sees how strong the evidence is. For tier 2,observedPeakis the working set that was read, labelled as current, andatLimitis true because of the symptom. 26. Model context (follow-up, not decided here). The same adapter would give the model a current usage figure on installs without Prometheus. That changes the model's input, so it needs an evaluation (ADR-0025) and belongs to a separate decision.
Invariants¶
- Model output is never authorization: the model chooses less than before, and the policy engine decides as before.
- The catalog is closed and
SetContainerMemoryLimitkeeps its bounds and its test;sizingadds no action and no parameter that is applied. - Changes still go through Git by pull request.
- The measurement is read from the metrics source by an approved template with no free-form query text, and the evidence fields are bounded values, redacted in the body; metric text from the source is never copied as prose (series labels are not in the evidence).
- The request name and the pull request marker derive from the UID and the plan digest as before. If the digest covers
sizing, the same request still maps to the same pull request. - No new identity. One new read grant: the analyzer gets
getandlistonpods.metrics.k8s.ioin the watched namespaces (tier 2, item 22, decided on 2026-11-14), through a Role and RoleBinding per namespace, never cluster-wide. Besides that, the decisions above need no grant: the analyzer already reads the metrics source and the named policies, and the executor reads only the request. The grant onremediationpoliciesstays but its purpose changes: invariant 6 inAGENTS.mdjustifies the analyzer'sgeton them by showing the model the bounds (ADR-0026), and the grant is now for sizing (decision 12). This PR changes neitherAGENTS.mdnor the RBAC: the amendment of invariant 6 (the new grant and the changed purpose) and the RBAC change (marker, chart Role and kustomize) are acceptance items of the code PR.
Consequences¶
- The model no longer supplies the number. Injected text can pick the action and the container only where code saw pressure for that container (item 6a). The size is then computed, but in the OOM case it is the fixed factor, 1.5 x the limit, which with default policy settings equals the maximum step. So the weakness of ADR-0026 (a proposal at the exact maximum step) is narrowed to containers with observed pressure, not closed; the threats name what bounds it.
- A reviewer sees how the number was found, in numbers they can compare with their own dashboard, instead of a model's reason.
- The analyzer needs a metrics source to propose a memory change, and what it can propose depends on which one it has. With Prometheus, a container with a fresh measurement and observed pressure gets the full rule (tier 1). With the metrics server only, a container gets a proposal only when its
OOMKilledsymptom passes the checks of item 23, and every other memory Incident is handed off (tier 2). With neither, every memory Incident is handed off withMissingData, as decision 2 intends. - The Incident must name the container (ADR-0039, not built), or the OOM symptom cannot be matched to the proposal: until then an unattributed symptom opens no gate and only the peak path of item 6 works, so tier 2 cannot yield a proposal.
- One more rule to keep right: the constants (90%, 1.5, 25%, 8Mi, the last quarter) are now code that an evaluation does not cover, and need tests with exact values.
- The analyzer's context builder returns typed values, and the loop reads the policy bounds: a larger change to
internal/incidentcontextandinternal/analysisthan a prompt change. - A CRD change (
spec.sizing,headroomPercent, three new reasons in the closed lists of item 10) needs the usual API review and a chart CRD update.
Threats¶
- A tenant inflates its own working set to get a bigger limit. A workload that allocates memory raises its peak and so the proposal. This is limited by the policy (
max, step), by the headroom, and by the person who merges; the pull request now shows the peak next to the size, which makes it visible. It is within what the tenant could already do by asking for a larger limit in its own manifest. Accepted. - Stale or missing metrics. Decision 11: no measurement, no proposal. The freshness test is the presence of samples in the last part of the window (item 11), not a comparison of a sample time with the analyzer's clock.
- A Prometheus that lies. It can make the peak small (a proposal that is too low, which does not fix the fault, and the Incident returns) or large (a proposal at the policy
max, which is Allowed and which a person reads). It cannot make a value outside the policy pass. The source is configured by the operator and the adapter uses approved templates only (ADR-0017); a second source would be a different ADR. - The peak understates when the container is at its limit. Item 6.
- A container OOM-killed days ago and idle now. The last termination reason stays
OOMKilleduntil the next termination, so a signal read from it would give a step for a container that is fine. The step needs theOOMKilledsymptom of the Incident being analyzed, or a peak at or above 90% of the limit in the window; neither holds here, so the result isNoMemoryPressure, not a request. Needs a test with exactly this case (the template says 1, the window peak is low, the Incident has no symptom for the container). - The steered action lands on the maximum step. An injected text cannot set the number, but it can ask for the action on a container that was OOM-killed, and the computed size is then 1.5 x the limit, which equals the maximum step with default policy settings. What bounds it: the policy range (
min,max,maxIncreasePercent), the evidence gate (no pressure observed by code for that container, no request), and the person merging, who sees the evidence (symptom, peak, window) in the pull request body. - Tier 2: current usage shaped at the moment of the read. A tenant can shape its working set at the instant the metrics server is sampled more easily than a peak over hours. In tier 2 the size comes from the kill and the limit, not from that number, which is only corroboration; the policy range bounds the result in any case.
- A sample taken between two scrapes. The step is at least a minute, so a spike shorter than the step can be missed; the headroom is the margin, and the next kill gives a new Incident.
Alternatives considered¶
- The model's value, cross-checked by code. Code computes the size and hands off when the model's differs by more than a tolerance. It keeps the model's say, but the model still has to be shown the bounds and can still be steered up to the tolerance; and a disagreement ends in a hand-off for a number the code already knows. Rejected.
- A fixed step (always the maximum step, or always +50%). No measurement is needed, but the size has no relation to the need, and the maintainer decided on 2026-11-14 against a fixed step as a fallback. Rejected.
- Link to the analysis record instead of printing the evidence. Keeps the request small, but the record is outside the pull request and the reviewer has to look for it. Rejected for the body; the record stays the place for the diagnosis.
- Headroom in a flag of the analyzer. One number for all policies, no CRD change. Kept as the fallback if the policy field is refused.
- A percentile of the working set. Item 5.
- The metrics server as the only source for the full rule. It has no history, so there is no peak over the window and nothing from before a restart. Rejected; it is used only for tier 2.
Open questions¶
- Whether the plan digest covers
sizing(item 14). - Whether the model keeps seeing that a policy exists for the action (item 16).
- Whether one analysis of a workload with several containers may size more than one (the action names one container today).
Amendments¶
- 2026-11-15 (#480): decision 18 says the backlog is not a template. The HPA's current and target metric now are:
hpa_metric_currentandhpa_metric_targetread them from kube-state-metrics for the HPA a ScaledObject'sstatus.hpaNamenames, and the context shows them to the model (ADR-0036, amendment of the same date). They are evidence in the context only: sizingmaxReplicaCountstays undecided, and the model keeps choosing that value, as decision 18 says.