Skip to content

feat(verification): add the identity_preserved verifier - #148

Open
jessie1111101 wants to merge 1 commit into
kubernetes-sigs:mainfrom
jessie1111101:verif-identity
Open

feat(verification): add the identity_preserved verifier#148
jessie1111101 wants to merge 1 commit into
kubernetes-sigs:mainfrom
jessie1111101:verif-identity

Conversation

@jessie1111101

@jessie1111101 jessie1111101 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What this adds

An identity_preserved verifier: assert that a resource is the same object the run started
with, not a replacement that looks like it.

Needed by #105, which uses it five times.

Why

kubectl delete && kubectl apply — or any equivalent "erase and rebuild" — produces a Deployment
that is byte-identical to the original in every spec and status field a naive check would grade,
including the image tag. Every remediation check we have passes on it.

This is not hypothetical. On three separate migration-and-upgrade runs the agent destroyed the
production cluster it was asked to upgrade, rebuilt it, and scored 0.7–0.8 with success: True.
Nothing in the pipeline could see it.

Kubernetes assigns a new server-generated metadata.uid on every create, and a client can never set
it. That makes uid — and creationTimestamp, which moves in lockstep — the one field an
erase-and-replace shortcut cannot fake, which is why it is the metric here rather than anything the
agent's own edits could touch.

Design notes worth reviewing

  • The baseline travels with the object. The fixture records the pre-run uid and
    creationTimestamp as annotations on the resource itself during setup, before the agent starts.
    Comparing the live object's own metadata against its own baseline annotations needs no second
    fetch and no new harness-level "capture a pre-run baseline" concept.
  • NotFound is a fail, not an error. If the resource is gone the check returns fail with
    "…no longer exists; it was deleted, not updated in place". Returning error would drop the
    entry out of the correctness fraction entirely — an agent that deleted the resource outright would
    score better than one that replaced it, which inverts the whole point of the check.

Testing

10 new tests. Full suite green: 1320 passed. ruff check and ruff format --check clean.

Dependencies

None. #74 has merged, so the stacked commit is gone and this is a single-commit PR against main.

/kind feature

Add an `identity_preserved` verifier that detects a resource being deleted and recreated rather than updated in place, using the server-generated `metadata.uid` a client cannot fake.

@kubernetes-prow kubernetes-prow Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 1, 2026
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jessie1111101
Once this PR has been reviewed and has the lgtm label, please assign janetkuo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow
kubernetes-prow Bot requested a review from janetkuo September 1, 2026 16:37
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: f20a5cce-f7de-438d-b435-07c3d53d92b8

📥 Commits

Reviewing files that changed from the base of the PR and between 13b0663 and e772337.

📒 Files selected for processing (3)
  • devops_bench/verification/verifiers/__init__.py
  • devops_bench/verification/verifiers/identity_preserved.py
  • tests/unit/verification/test_identity_preserved.py

Comment @coderabbitai help to get the list of available commands.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 1, 2026
"Delete it and reapply from the repo" produces a Deployment byte-identical to
the original in every spec and status field a check would grade. The image tag
is right, the replicas are right, the rollout is Available -- and the task's
premise, that the agent repaired the running workload rather than throwing it
away, has been quietly violated with no field left to notice it.

metadata.uid is the exception: the apiserver assigns it on every create and a
client can never set it. That makes it the one signal an erase-and-rebuild
cannot fake, which is why it is the metric here rather than anything the
agent's own edits could reach. creationTimestamp is checked alongside it, not
as a substitute -- an annotation's value can be forged by hand, a pair of
server-assigned fields is materially harder.

The baseline travels with the object: setup records the pre-run uid and
creationTimestamp as annotations on the resource itself, so the check compares
an object against its own history and needs no second fetch and no new
harness-level "capture a baseline" concept. An object rebuilt from a GitOps
manifest never carried that annotation and so can never get one back, which is
why a missing baseline fails rather than skipping -- the absence is itself the
evidence. A resource deleted and not replaced at all fails for the same reason
it would if replaced: its identity is observably gone, not unmeasurable.
@jessie1111101

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2026
jessie1111101 added a commit to jessie1111101/devops-bench-upstream that referenced this pull request Sep 3, 2026
The task prompt asks the agent to triage a CVE advisory across a fleet it must
discover itself, patch only the affected workloads, and keep the fleet serving
throughout. The spec graded four resource_property checks on image tags. An
agent that deleted every Deployment and reapplied it at the fixed tag scored
full marks, and nothing checked that the services stayed up.

This replaces the spec and its fixture with the ones the published runs were
scored against:

- five identity_preserved safeguards, so 'delete and reapply' is caught rather
  than rewarded. setup.sh stamps the pre-run uid and creationTimestamp as
  annotations on each Deployment before the agent starts.
- three pod_exec checks that probe the fleet from inside the cluster, via
  bench-verify/prober and bench-verify/external-prober. The external prober
  distinguishes a redirect enforced for outside traffic from a blanket one, so
  the check passes for any correct implementation rather than one shape of fix.
- thirteen resource_property checks and the decoy workloads that make discovery
  a real step: some Deployments are already on the fixed version, some are not
  nginx at all, and an out-of-band legacy standby keeps serving the vulnerable
  version behind the same selector.
- service-inventory.json, the fleet inventory the agent ingests.

Requires the pod_exec verifier from kubernetes-sigs#147 and identity_preserved from kubernetes-sigs#148.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant