Skip to content

fix(roadmap): the row guard refuses each label not on a safe list #6632

Done

Description

@dan-petty

Problem

PR #6629 (#6615) adds a guard to the project review dispatcher (_foreign_workload in src/devops_cli/roadmap/project_review/dispatch.py). It checks the result rows of each Prometheus and Loki rows fact. A row fails when a label of _NAMESPACE_LABELS (namespace, exported_namespace, dest_namespace) has a value outside the project namespaces, or when the row holds a label of _WORKLOAD_LABELS (pod, container, service and others) and no namespace.

The guard is a list of labels to refuse. A row passes when it names a workload or a namespace of another project in a label that is not on the list: a label that label_replace or group_left writes, or the Argo CD label name. The verify review of PR #6629 found this, and the PR documents that the guard checks only the labels in its lists. No shipped fact gives such a row today. A new catalog fact can give one, and the guard will not see it.

Expected

  • The guard refuses by default. A row with a namespace label in the project namespaces can hold any label. A row with no project namespace can hold only labels from a list of safe labels, for example resource, code_class, le and quantile, taken from the labels that the shipped rows facts keep.
  • A refusal names the fact id and the label name, never a label value, as now.
  • The docs (the dispatch.py docstring, the catalog header, docs/ROADMAP_WORKFLOW.md and the spec) say that the guard refuses each label that is not on the safe list.

Acceptance criteria

  • Test first: a row with no namespace and a label that is not on the safe list (for example name) marks the fact error. The test fails on the base.
  • A test: a row of a project namespace with any label passes, and a row by resource only passes.
  • A test: the shipped catalog loads, and a fixture run of each shipped rows fact gives no guard error.

Dependencies

Source

Source: #6629

Alternatives check of 2026-11-21: none.
Tool: none found.
Reason: Searches found no library that validates Prometheus or Loki result rows against a safe-label list; the change is inside the project's own _foreign_workload guard, so only its code and docs can cover it.

Lacks:

  • Default-refusal allowlist of safe row labels
  • Refusal naming fact id and label name only
  • Tests for a project-namespace row with any label
  • Docs and spec wording of the allowlist rule

Proposed design

Problem statement

The row guard of the project review dispatcher refuses only the labels on two lists. A row that names a workload or a namespace of another project in a label that is not on a list passes, such as a label that label_replace writes or the Argo CD label name. The fix makes the guard refuse by default: a row with a project namespace passes with any label, and a row with no project namespace may hold only labels of a safe list.

Acceptance criteria

Requirement: Row guard refuses an unknown label by default

The row guard SHALL mark a rows fact error when a row holds no project namespace and a label that is not on the safe list.

Scenario: Row with an unknown label and no namespace

  • WHEN A test gives _read_fact a rows fact and a Prometheus answer with one series that holds the label name and no namespace label.
  • THEN The fact status is error, the reason names the fact id and name, and the same test gives ok on the base commit.

Requirement: Row of a project namespace passes with any label

The row guard SHALL pass a row whose namespace labels all hold project namespaces, whatever other labels it holds.

Scenario: Row with a project namespace and the Argo CD label

  • WHEN A test gives a rows fact a series with namespace set to a project namespace and the label name.
  • THEN The guard returns None and the fact status is ok.

Requirement: Row of safe labels passes

The row guard SHALL pass a row that holds no namespace label and only labels of the safe list.

Scenario: Row by resource and le

  • WHEN A test gives a rows fact a series with the labels resource and le and no namespace label.
  • THEN The guard returns None and the fact status is ok.

Requirement: Shipped rows facts give no guard error

Each shipped rows fact SHALL give no guard error when a row of the labels that it keeps goes through the guard.

Scenario: Guard run over each shipped rows fact

  • WHEN A test loads src/devops_cli/roadmap/project_review/catalog.yaml and builds one row from the labels that each fact of shape: rows keeps.
  • THEN The guard returns None for each fact, and no shipped rows fact keeps a label that is not on the safe list.

Requirement: Docs state the default refusal

The dispatcher docstring, the catalog header and docs/ROADMAP_WORKFLOW.md SHALL state that the guard refuses each label that is not on the safe list.

Scenario: Rule stated in each document

  • WHEN A test reads the module docstring of src/devops_cli/roadmap/project_review/dispatch.py, the header of src/devops_cli/roadmap/project_review/catalog.yaml and docs/ROADMAP_WORKFLOW.md.
  • THEN Each text states that the guard refuses each label that is not on the safe list.

Existing Tool Considered

The alternatives check of 2026-11-21 in the issue body records verdict none and names no tool, and its Lacks: list holds what the change must add. No open, maintained library validates Prometheus or Loki result rows against a safe-label list, so the change builds its own code in _foreign_workload of src/devops_cli/roadmap/project_review/dispatch.py. Cost: about 15k tokens to write the guard and its tests, about 4k tokens a year to keep and fix, and half a day of elapsed time. A library would add a dependency and its upgrade churn for about 25 lines of code.

Key questions

  • Which labels are on the safe list, and where does the list live?: A hand-kept constant _SAFE_ROW_LABELS in dispatch.py holds resource, code_class, le and quantile. The shipped-catalog test proves the list complete. A list derived from the catalog would change with a new fact and hide the new label. (best practice) [sources: src/devops_cli/roadmap/project_review/dispatch.py:131, src/devops_cli/roadmap/project_review/catalog.yaml]
    • Chosen: Hand-kept constant. The list is visible in one place, and a new catalog label fails the shipped-catalog test until a person adds it.
    • Rejected: Derive the list from the catalog clauses at load time. A new fact would widen the guard with no review, and the loader reads the by and on clauses for another purpose.
  • Does the guard check the __name__ label?: No. The guard skips __name__, because it is the metric name and _vector_value already drops it from a row's labels. A check of it would refuse each row. (best practice) [sources: src/devops_cli/roadmap/project_review/dispatch.py]
    • Chosen: Skip __name__. The metric name is no dimension of a row, and _vector_value drops it from the row labels that a fact keeps.
    • Rejected: Put __name__ on the safe list. The safe list would hold a label that no fact keeps, and the rule would read as if a metric name were safe data.
  • What happens to _WORKLOAD_LABELS in dispatch.py?: The change removes it from dispatch.py. The default refusal covers each of its labels because none is on the safe list. catalog.py keeps its own copy for the loader. (best practice) [sources: src/devops_cli/roadmap/project_review/dispatch.py:131, src/devops_cli/roadmap/project_review/catalog.py:78]
    • Chosen: Remove the copy in dispatch.py. One rule refuses the labels, so a second list cannot drift from it.
    • Rejected: Keep both rules. Two lists give two reasons for one row and need a second update for each new workload label.
  • Which label does a refusal name when several labels are off the safe list?: The first label in sorted order, as min(named) does today. The order is deterministic and the reason names one label. (best practice) [sources: src/devops_cli/roadmap/project_review/dispatch.py:328]
    • Chosen: Sorted first label. The same row gives the same reason on each run, whatever the order of the labels in the answer.
    • Rejected: First label in the answer order. The order comes from the JSON answer and can change between readers.
  • Does the refusal message change?: No. MESSAGES.roadmap.review_foreign_workload takes the fact id and the label name and no label value. [sources: src/devops_cli/roadmap/project_review/dispatch.py]
  • Does the guard still refuse a foreign namespace when the row also holds a project namespace?: Yes. The namespace check runs first, so a namespace label whose value is not in roadmap.project_review.namespaces gives error, as it does now. (best practice) [sources: src/devops_cli/roadmap/project_review/dispatch.py:328]
    • Chosen: Namespace check first. The reason names the namespace label, and the rule of a foreign namespace stays the same.
    • Rejected: Default refusal first. A row with a foreign namespace would give a reason about the safe list, not about the namespace.
  • Is fix(roadmap): keep other projects' workload names out of the review #6615 still a dependency?: No. _foreign_workload is at src/devops_cli/roadmap/project_review/dispatch.py:328 in the base, so PR fix(roadmap): keep other projects' workload names out of the review #6629 delivered the guard. [sources: src/devops_cli/roadmap/project_review/dispatch.py:328]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    on Nov 21, 2026
  2. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor
  3. added
    scope/roadmap
    status/new
    value/medium
    effort/medium
    priority/p2-medium
    on Nov 21, 2026
  4. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (2)

    Searches run:

    • open source tool enforce safe label names on metrics rows policy, results: 5
    • python library validate Prometheus query result labels allowlist, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Nov 22, 2026
  6. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 25, 2026
  8. added
    status/in-review
    and removed
    status/in-progress
    on Nov 25, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 25, 2026
  10. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 17:09 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions