Skip to content

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.Desired is an argument of the result schema (internal/analysis/result.go). The loop replaces previous with the pod template's limit (#494, previousFromTemplate), and checks the direction and NoChange, but never the size. policy.CheckAction is a catalog check only.
  • The metrics are text. The context builder (internal/incidentcontext/metrics.go) asks the source for the approved templates, among them container_memory_working_set_bytes (a range query over the window, max by (pod, container, cluster) per step), container_memory_limit_bytes (an instant query) and container_last_terminated_oomkilled, and renders the series as lines of a block. The samples are not kept as numbers; Context holds blocks, the template containers and the ScaledObject snapshot.
  • The window is windowOf: from ten minutes before firstSeen to now, at least 15 minutes and at most 6 hours, one hour without firstSeen. 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.BoundsFor and policy.AllowedMemory; the loop sees the text only.
  • The request has action.setContainerMemoryLimit (container, previous, desired) and no field for how the value was found. spec is immutable by CEL. The executor's pullRequestBody prints 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

Sizing from metrics: the context builder reads the memory working set and the limit from the metrics source and keeps the numbers, and the Incident's own OOMKilled symptom is the other pressure evidence; code takes only the action and the container from the model and accepts them only where it saw memory pressure for that container; it computes the size from the peak plus headroom (a multiplicative step when at the limit, which without Prometheus rests on the OOMKilled symptom corroborated by the metrics server), rounds, clamps to the policy and rounds down; no measurement, no pressure or no room under the policy ends without a proposal; the request carries the new limit and optional typed evidence; the policy engine decides as before; the executor prints the evidence in the pull request body; the model sits beside the path

Decided on 2026-11-14

  1. Code sets the size. For SetContainerMemoryLimit the 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).
  2. 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.
  3. 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

  1. Source. The container_memory_working_set_bytes template 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 of Context), 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.
  2. 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).
  3. "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 OOMKilled symptom for that container, inside the analysis window: the collector's own observation of container status (never model output). The collector also reads LastTerminationState (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 what windowOf derives from the Incident's firstSeen, 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's status.lastSeen until 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_oomkilled is 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; the lastState of 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 default maxIncreasePercent, 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 unattributed OOMKilled symptom opens the gate for no container the model names, and the result is NoMemoryPressure (item 6a). Only the peak at or above 90% of the limit can open it then. 6a. The evidence gate. A SetContainerMemoryLimit for a container is accepted from the model only when code observed memory pressure for that same container: the OOMKilled symptom 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 reason NoMemoryPressure (a measurement exists and shows no pressure; with no measurement, decision 2 gives MissingData). 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 optional headroomPercent of MemoryLimitBounds (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 unrounded need is above the policy max: PolicyMaxBelowNeed (item 10). 3. Round need up to the unit. If the rounded need is above max but the unrounded one is not, the value is max itself, limitedBy: None: max covers the measured need, and only the rounding exceeded it. This value is kept as it is, even where max is not a multiple of the unit. 4. Clamp to the range policy.AllowedMemory returns for an increase from the template's limit: at least min, at most max, and at most limit + floor(limit x maxIncreasePercent / 100), the arithmetic of maxDelta in internal/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 the max of 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 max high enough not to bind (1Gi) in examples 1 and 2, and limitedBy for 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 is SizeNotAnIncrease. Example 3, rounding above max: policy max 150Mi, maxIncreasePercent 100, headroomPercent 100, limit 80Mi, peak 72.5Mi (90.6% of the limit, so at the limit). Headroom term 145Mi, limit term 120Mi, need 145Mi, below max. Rounded up it is 152Mi, above max, so the value is max itself: 150Mi (the step ceiling is 160Mi, so nothing else clamps it), limitedBy: None. Comparing the rounded need with max would have handed off with PolicyMaxBelowNeed although 150Mi covers the need. 10. No proposal, with a reason. - The unrounded need is above the policy max: hand-off with the new reason PolicyMaxBelowNeed. 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 policy max would 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 reason SizeNotAnIncrease. Decreases are not proposed (item 17). - The need is above the step limit but not above max: Decided (2026-11-14): propose the clamped value and show limitedBy: Step in 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 with max, was the alternative and was not chosen. - The new reasons PolicyMaxBelowNeed, SizeNotAnIncrease and NoMemoryPressure must join every closed list of reasons: the Hint.reason enum and HintDeclineReasons (api/v1alpha1/hint_types.go, where the marker and the Go list must stay equal), declineText in internal/controller/hintreply.go (the three belong with the "made no proposal" group), the outcome messages in internal/analysis/controller.go (outcomeMessages, with the Reason constants of internal/analysis/loop.go), and the reason table of docs/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 own Partial flag. Where the last quarter has none, the container is handed off with MissingData. For the "at the limit" comparison, the limit is the value of container_memory_limit_bytes for 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. The previous of the request stays the template's limit (#494).

Decided: where it runs, and the policy engine

  1. In the analysis loop, in finish, after the reply is decoded and before the request is created. It sits next to previousFromCluster: that function already takes previous from the template, and the sizing function takes desired from 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).
  2. 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

  1. Evidence on the request. A new optional spec.sizing next to action, 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, Min
    

    The bounds: metric an enum, observedPeak a bounded integer, samples 1 to 100000, headroomPercent 1 to 100, times as metav1.Time, no free strings. The resulting value is action.setContainerMemoryLimit.desired, not repeated. The spec is already immutable, so the evidence cannot change after the policy check. sizing is 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 with SetContainerMemoryLimit. 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 covers sizing (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. Without sizing it 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

  1. 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's get on 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 (NoPolicyForAction stays decided in code). The tool schema loses desired and previous of MemoryLimitChange; it keeps container. 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. The metrics block stays, as evidence for the diagnosis.

Out of scope, named

  1. 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 maxDecreasePercent is 0 by default. A follow-up may use the same measurement.
  2. AdjustKedaMaxReplicas (#497). That issue fills previousValue from the ScaledObject; the size of maxReplicaCount has no measurement in this ADR (the template is deployment_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

  1. 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 with limitedBy: 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 end MissingData.
  2. 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.

  1. 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.
  2. A second adapter behind the same interface. MetricsSource has one method, Query, with approved templates (ADR-0013, ADR-0017). A metrics server adapter answers the working set template only and returns ErrNotFound for every other template. It reads with get and list on pods.metrics.k8s.io (API group metrics.k8s.io, resource pods), 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 in AGENTS.md is amended with it in the code PR.
  3. Three tiers of evidence for a memory size.

    1. Prometheus: the peak over the window, the full rule of items 4 to 11.
    2. Metrics server only: the Incident's code-observed OOMKilled symptom 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, occurrence in internal/analyzer/collector/pods.go) must be the one in that container's status now, LastTerminationState or State; 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: firstSeen is 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); MissingData is for the API being absent or the retries ending. 3. Neither: hand-off with MissingData, 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.sizing gets a source value (Prometheus, MetricsServer, ContainerStatus or similar, an enum), and the pull request body prints it, so the person merging sees how strong the evidence is. For tier 2, observedPeak is the working set that was read, labelled as current, and atLimit is 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

  1. Model output is never authorization: the model chooses less than before, and the policy engine decides as before.
  2. The catalog is closed and SetContainerMemoryLimit keeps its bounds and its test; sizing adds no action and no parameter that is applied.
  3. Changes still go through Git by pull request.
  4. 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).
  5. 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.
  6. No new identity. One new read grant: the analyzer gets get and list on pods.metrics.k8s.io in 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 on remediationpolicies stays but its purpose changes: invariant 6 in AGENTS.md justifies the analyzer's get on them by showing the model the bounds (ADR-0026), and the grant is now for sizing (decision 12). This PR changes neither AGENTS.md nor 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 OOMKilled symptom passes the checks of item 23, and every other memory Incident is handed off (tier 2). With neither, every memory Incident is handed off with MissingData, 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/incidentcontext and internal/analysis than 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 OOMKilled until the next termination, so a signal read from it would give a step for a container that is fine. The step needs the OOMKilled symptom of the Incident being analyzed, or a peak at or above 90% of the limit in the window; neither holds here, so the result is NoMemoryPressure, 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

  1. Whether the plan digest covers sizing (item 14).
  2. Whether the model keeps seeing that a policy exists for the action (item 16).
  3. 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_current and hpa_metric_target read them from kube-state-metrics for the HPA a ScaledObject's status.hpaName names, and the context shows them to the model (ADR-0036, amendment of the same date). They are evidence in the context only: sizing maxReplicaCount stays undecided, and the model keeps choosing that value, as decision 18 says.