Skip to content

refactor(simulate): separate health state, summary and display #612

Backlog

Description

@jcogilvie

What problem are you facing?

Raised by @adamwg in review of #554. Simulate's health reporting (#539, #546, #554, #566) spreads three concerns across several packages:

  • State tracking: which resources are unhealthy and which XR owns them. This lives in internal/diff/types (CompositeHealth, RenderedResources.Health()), internal/diff/result and internal/simulate/report.go.
  • Summarization: the Health: counts and which XR lists a shared resource (health.Tally, health.OwnedElsewhere). Each renderer calls these itself: internal/plan/output.go, internal/simulate/result.go, and internal/diff/renderer (diff_renderer.go, comp_diff_renderer.go, health.go).
  • Display: the ⚠ marker, one-line and --full-messages text, and the unhealthy-resources block (health.Lines, health.Block). These are called from the same three renderers, and each builds its own block and tally around them.

So a rule such as "list each unhealthy resource once, under the deepest XR with health of its own" has to be applied separately in each output path. #554 had to fix a case where xr -o diff grouped output missed it. Changing the health output means touching every renderer.

How could Crossplane help solve your problem?

Refactor so that:

  1. The diff and simulate engines produce one health model per run: per-XR health, the unhealthy resources each XR lists (ownership already resolved) and the run's tally.
  2. Summarization happens once, when that model is built, not in each renderer.
  3. Renderers (plan text, -o diff for xr and composition, resource simulate) only format that model.

This should not change behaviour. The existing plan, diff and integration tests' expected output should pass unchanged.


Filed by an AI agent (Claude Code) on behalf of @jcogilvie.

Activity

  1. added
    enhancement
    on Nov 25, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions