Skip to content

lifecycle: the claimed-field set — a live value on a property you never declared is theirs, not drift #2160

Closed

Description

@lex00

Sub-issue 1 of #2159.

observeResourcesDeep() compares the declared property tree against the live one, and DeepNormalizationHooks (packages/core/src/deep-observation.ts) gives a lexicon four ways to quiet the result: prune, orderKey, unresolved, mask. Three of the four exist because the live tree carries fields the declaration never mentioned, and every lexicon answers that with knowledge it had to write down separately. Kubernetes is the exception: lexicons/k8s/src/deep-observe.ts reads metadata.managedFields, so a foreign manager's write to a field source never declared is controller noise, while a foreign write to a field chant does declare stays visible and names the manager. GCP and fountain cannot do that. lexicons/gcp/src/deep-observe.ts says why in the code: "a REST payload carries no field ownership", so its noise rules are a static per-kind table maintained by hand.

The declaration is the missing table. A ResourceDeclarable's props are exactly the fields chant set, and they are available on every substrate, from the same build that produced the entity. Nothing needs to come back from the provider.

Build the claimed-field set as a first-class part of observation. For a declared entity, walk its props to a set of property paths (spec.replicas, tags["Name"], ingress[0].fromPort, with the same path grammar the deep diff already uses). Carry it on the deep observation result so a consumer can classify each live value three ways rather than two: declared and equal, declared and different (drift, the only case that may become an update), and undeclared (a value that exists and that chant never set). An undeclared value is reported as held by someone else, never proposed for change, and never counted as drift in the summary.

Where the substrate does carry ownership, keep using it and say which source answered. On Kubernetes the manager name is strictly better than "undeclared", because it names who: report the manager where managedFields has it, fall back to the claimed-field set where it does not. The two are compatible, and the k8s hook should end up thinner rather than removed.

This changes what chant lifecycle diff --live prints and what lifecycle plan proposes, so both need a line in their reference pages, and the observation authoring guide (docs/src/content/docs/lexicon-authoring/observation.mdx) needs the claimed-field concept beside the hooks it partly replaces. Do not delete any hook in this issue: prune is still right for genuinely server-populated fields like status, and removing hand-written prune tables is a follow-up per lexicon once the classification is trusted.

Runs first. #2161 needs this classification to know which fields are worth tracing.

Acceptance

  • A claimed-field set is derived from a declaration's props and carried on the deep observation result, with the same path grammar as the diff.
  • A live value on an undeclared path is reported as held elsewhere, is not drift, and is never proposed for update; tested on a substrate with no field-ownership metadata (gcp or fountain).
  • A live value on a declared path that differs is still drift, unchanged.
  • On Kubernetes, managedFields still names the manager where it has one, and the claimed-field set answers where it does not; a test covers both.
  • The diff and plan reference pages, and the observation authoring guide, describe the three-way classification.
  • No hand-written prune table is deleted in this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:lifecycleenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions