Skip to content

feat(observe): carry the resolved query address per entity through the live wire - #1625

Merged
lex00 merged 1 commit into
mainfrom
feat/1620-query-address
Aug 10, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/1620-query-address

Conversation

@lex00

@lex00 lex00 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Closes #1620 (from behold#192).

The failure shape

A Flux-deployed k8s project declares no metadata.namespace — the controller stamps Kustomization.spec.targetNamespace at apply time. The live read scopes to the context's default namespace, finds nothing, and correctly reports absence, so behold paints weeks-old running infrastructure pending. Every layer behaves as specified; the picture still says the opposite of the truth. The missing piece is per-entity: what address was the cluster actually asked?

The wire shape

One field name, queried, at three depths — all optional, all additive over the #1089 tri-state (classification still reads only resources/unobserved; an entity in queried and neither map is still OBSERVED-ABSENT):

  • ObservationResult.queried?: Record<string, string> — resolved query address per entity name. This side-map is deliberate: absence is spelled "in neither map", so an absent verdict has no row to hang diagnostics on — this is the only record it gets.
  • UnobservedEntity.queried?: string — inline on not-observed entries (extending the existing detail, not replacing it), so a row renders without a join.
  • LiveDiffResult.queried? / UnobservedResource.queried? / ChangeSetEntry.queried? — the pass-throughs that reach consumers.

The address is a single self-describing string rather than a k8s-shaped struct, because the failure generalizes: any substrate deriving its read address (endpoint override, region, account) has the same "looked in the wrong place ≠ not there" shape. k8s is the first implementer; lexicons omitting it stay valid, and the observeEntities harness accepts queried on all three EntityObservation variants for the other native observers.

Where it surfaces

chant lifecycle diff --live --json, per lexicon:

{
  "resources": {
    "missing": ["web"],
    "queried": { "web": "/apis/apps/v1/namespaces/default/deployments/web" },
    "unobserved": [
      { "name": "api", "reason": "read-failed", "queried": "/api/v1/namespaces/default/services/api" }
    ]
  }
}

behold's inspect pane can render queried: /apis/apps/v1/namespaces/default/deployments/web → 404 next to the pending verdict. The human report prints web [queried …] on missing/unobserved lines, and lifecycle plan carries the address per change-set entry (a create's address is the one the provider confirmed absent).

How k8s resolves it

@intentius/chant-k8s-client grows pathFor(ref): the exact request path read() would GET — apiVersion/kind resolved against the cluster's own (cached) discovery, the namespace defaulted from the resolved context when the ref carries none, undefined when discovery does not serve the kind. The reader resolves it before each read and stamps it on every verdict: present, absent, filtered, read-failed.

Also: the #1610 context note now leads the detail

behold truncates a failure reason to its first line / 160 chars, and detailOf appended the context "<name>" (<how selected>) note after a message capped at 200 — pushed out of the window exactly on the failures long enough to need it. The note now leads, the capped error follows; tests assert position and the 160-char window on a long multi-line error.

Verification

  • New: absent verdict with no declared namespace resolves to the defaulted address and carries it (the behold#192 scenario verbatim); read-failed entry carries it; harness collects it from all variants; diff/change-set pass-throughs; pathFor path/scope/unknown-kind cases; context-note position.
  • describeObservationConformance untouched and green across all lexicons.
  • Full suite: 922 files / 11271 tests passing; just build, npm run build -w @intentius/chant-lexicon-k8s, npm run build -w @intentius/chant-k8s-client all clean.
  • Docs: the observation contract page (lexicon-authoring/observation.mdx) documents the additive rules; cli/lifecycle.mdx documents the JSON shape.

…e live wire

From behold#192: a Flux-deployed k8s project declares no metadata.namespace
(the controller stamps targetNamespace at apply), so the live read scopes to
the context's default namespace, finds nothing, and correctly reports absence
— painting weeks-old running infrastructure pending. Every layer is
spec-correct; the report cannot explain itself.

The observation envelope now carries an optional queried map — the resolved
address each read was issued against, keyed by entity name. Purely additive:
classification still reads only resources/unobserved and the #1089 tri-state
does not shift. The map is the only record an OBSERVED-ABSENT entity gets
(absence is spelled 'in neither map'), and unobserved entries carry the
address inline as UnobservedEntity.queried.

- k8s-client grows pathFor(ref): the exact request path read() would GET,
  namespace defaulting made visible; undefined when discovery does not serve
  the kind.
- The k8s reader resolves the address before each read and stamps it on every
  verdict; the observeEntities harness accepts queried on all three
  EntityObservation variants for the other native observers.
- lifecycle diff --live --json emits resources.queried per lexicon and
  queried per unobserved row; the human report shows
  'web [queried /apis/apps/v1/namespaces/default/deployments/web]' on missing
  and unobserved lines. lifecycle plan carries the same address per change-set
  entry (a create's address is the one the provider confirmed absent).
- The #1610 context note now LEADS the unobserved detail instead of trailing
  it: consumers truncate a reason to its first line / ~160 chars, and a note
  appended after a long error vanished exactly when it mattered.

Closes #1620
@lex00
lex00 merged commit c7fe0cc into main Aug 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lifecycle diff --live: carry the resolved query address per entity — behold needs it to explain an all-pending overlay

1 participant