Skip to content

docs: refresh design doc to current architecture#348

Open
jcogilvie wants to merge 1 commit into
mainfrom
doc-update
Open

docs: refresh design doc to current architecture#348
jcogilvie wants to merge 1 commit into
mainfrom
doc-update

Conversation

@jcogilvie

Copy link
Copy Markdown
Collaborator

Description of your changes

The design doc at design/design-doc-cli-diff.md had drifted significantly from the current implementation — most interface signatures were stale, the comp subcommand and its entire processor were undocumented, and the render.Outputs narrative referred to a struct that has since been renamed and restructured upstream. This PR brings every section, interface block, and diagram in sync with the current cmd/diff/ tree.

It also adds a "Keeping Documentation in Sync" section and a "Git, Commits, Issues, and Pull Requests" section to CLAUDE.md so future code changes prompt corresponding doc updates and PRs follow project conventions (DCO sign-off, draft PRs, template compliance). The mermaid SVG regeneration recipe points at the minlag/mermaid-cli Docker image for portability.

What's new in the doc:

  • Document the comp subcommand and CompDiffProcessor (entirely missing).
  • Rewrite all interface blocks in §6 to current signatures; add FunctionProvider, CompDiffRenderer, and the structured-output types.
  • Replace the obsolete render.Outputs / RenderWithRequirements narrative with the upstream CompositionOutputs / RenderToStableState reality, including --eventual-state mode.
  • Cover nested-XR recursion, the two-phase diff calculation, claim-with-spec.claimRef synthesis, and Cleanup semantics.
  • Drop §10.15 (--namespace flag is complete: xr reads namespace from YAML; comp's -n filter has shipped).
  • Add §4 test-case categories for comp, structured output, nested XRs, eventual state, and claim edge cases.
  • Update §12 layout and §8 CLI examples for xr / comp / --output / etc.
  • Refresh all 10 mermaid sources and regenerate SVGs.

I have:

  • Read and followed Crossplane's contribution process.
  • Run earthly -P +reviewable to ensure this PR is ready for review. Docs-only change; no code paths exercised.
  • Added or updated unit tests. Docs-only change.
  • Added or updated e2e tests. Docs-only change.
  • Documented this change as needed.
  • Followed the API promotion workflow if this PR introduces, removes, or promotes an API. No API changes.

@jcogilvie jcogilvie force-pushed the doc-update branch 4 times, most recently from 8d1f609 to a10c7c7 Compare June 17, 2026 18:58
The design doc had drifted significantly from the implementation. This
brings every section, interface block, and diagram in sync with the
current cmd/diff/ tree, and adds guidance to CLAUDE.md so future code
changes prompt corresponding doc updates.

Highlights:
- Document the comp subcommand and CompDiffProcessor (entirely missing).
- Rewrite all interface blocks in §6 to current signatures, add
  FunctionProvider, CompDiffRenderer, and structured-output types.
- Replace the obsolete render.Outputs / RenderWithRequirements narrative
  with the upstream CompositionOutputs / RenderToStableState reality,
  including --eventual-state mode.
- Cover nested-XR recursion, the two-phase diff calculation, claim-with-
  spec.claimRef synthesis, and Cleanup semantics.
- Drop §10.15 (--namespace flag is complete: xr reads namespace from
  YAML; comp's -n filter has shipped).
- Add §4 test-case categories for comp, structured output, nested XRs,
  eventual state, and claim edge cases.
- Update §12 layout and §8 CLI examples for xr / comp / --output / etc.
- Refresh all 10 mermaid sources (and regenerate SVGs via the
  minlag/mermaid-cli Docker image).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@jcogilvie jcogilvie marked this pull request as ready for review June 17, 2026 22:10
@jcogilvie jcogilvie requested a review from tampakrap as a code owner June 17, 2026 22:10
Copilot AI review requested due to automatic review settings June 17, 2026 22:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

Multiple updated mermaid diagrams and a design-doc section still describe structured output and interface signatures that don’t match the current Go implementation.

Pull request overview

This PR refreshes the CLI diff design documentation and related diagrams to reflect the current cmd/diff/ architecture, and expands user-facing docs (README) plus contributor guidance (CLAUDE) to help prevent future doc drift.

Changes:

  • Adds a detailed README section describing schema-validation failures (stderr behavior, exit code 2, and structured errors[]/validationFailures[] schema).
  • Updates the design doc and mermaid diagrams to cover the comp subcommand, nested XR recursion / eventual-state behavior, structured output, and revised interfaces.
  • Adds “Keeping Documentation in Sync” and PR/commit conventions guidance to CLAUDE.md, including a diagram regeneration recipe.
File summaries
File Description
README.md Documents validation-error behavior and the structured OutputError schema with examples.
design/design-doc-cli-diff/package-overview-fixed.mermaid Updates high-level class diagram for new components and signatures.
design/design-doc-cli-diff/loader-validator-architecture.mermaid Extends validator diagram to include scope-constraint validation.
design/design-doc-cli-diff/layered-architecture.mermaid Updates layered architecture to include CompDiffProcessor, function provider, and new clients.
design/design-doc-cli-diff/diff-rendering-architecture.mermaid Updates rendering diagram to include structured output and comp rendering.
design/design-doc-cli-diff/diff-processor-architecture.mermaid Updates processor diagram for comp diff and two-phase diffing.
design/design-doc-cli-diff/diff-data-flow.svg Regenerated diagram asset to match updated mermaid source.
design/design-doc-cli-diff/diff-call-sequence.mermaid Updates call-sequence diagram to reflect xr vs comp flows and eventual-state.
design/design-doc-cli-diff/conceptual-layers.mermaid Updates conceptual layer notes to include comp diff and new components/clients.
design/design-doc-cli-diff/client-architecture.mermaid Adds CompositionRevision and Credential clients to the diagram.
design/design-doc-cli-diff/clear-layered-architecture.svg Regenerated diagram asset to match updated mermaid source.
design/design-doc-cli-diff/clear-layered-architecture.mermaid Updates simplified architecture diagram to include new components.
design/design-doc-cli-diff.md Major refresh of design doc narrative, workflows, and interface blocks.
CLAUDE.md Adds documentation-sync triggers and PR/commit conventions; includes a diagram regeneration recipe.

Copilot's findings

  • Files reviewed: 12/22 changed files
  • Comments generated: 9

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +57
+CalculateDiff(ctx, composite, desired) (Diff, error)
+CalculateDiffs(ctx, xr, desired) (map, error)
+CalculateNonRemovalDiffs(ctx, xr, parent, desired) (map, set, error)
+CalculateRemovedResourceDiffs(ctx, xr, rendered) (map, error)
+Cleanup(ctx) error
+PerformDiff(ctx, resources, compositionProvider) (bool, error)
+DiffSingleResource(ctx, res, compositionProvider) (map, error)
+RenderToStableState(ctx, xr, comp, fns, id, observed, synthReady) (Outputs, error)
Comment on lines +83 to +86
+CalculateDiff(ctx, composite, desired) (Diff, error)
+CalculateDiffs(ctx, xr, desired) (map, error)
+CalculateNonRemovalDiffs(ctx, xr, parent, desired) (map, set, error)
+CalculateRemovedResourceDiffs(ctx, xr, rendered) (map, error)
Comment on lines +61 to +63
+Diffs map
+Summary Summary
+Errors OutputError slice
Comment on lines +88 to +90
XRStatusChanged
XRStatusUnchanged
XRStatusErrored
Comment on lines +94 to +97
+Total int
+Changed int
+Unchanged int
+Errored int
Comment on lines +67 to +70
+CompositionDiff *CompositionDiff
+AffectedResources AffectedResourcesSummary
+XRImpacts []XRImpact
+Errors []OutputError
Comment on lines +763 to +781
The structured types (in `cmd/diff/renderer/types/`) are part of the public output contract:

- `StructuredDiffOutput` — XR diff: per-resource diffs with field-level old/new, summary counts, errors.
- `CompDiffOutput` — composition diff: top-level `CompositionDiff`, list of `XRImpact`, `AffectedResourcesSummary`,
`DownstreamChanges`.
- `XRImpact`, `XRStatus`, `DownstreamChanges`, `AffectedResourcesSummary` — finer-grained components used by the test
harness for field-level assertions.
- `OutputError` — error envelope used by both XR and comp diff outputs. Carries:
- `ResourceID`: which user-supplied input the diff was processing (one entry per batched run)
- `Message`: human-readable error string
- `ValidationFailures`: optional `[]ResourceValidationFailure`, populated when the error originated from schema
validation. Lets machine consumers inspect typed failures without parsing `Message`.
- `ResourceValidationFailure` — per-resource view inside `ValidationFailures`. Mirrors upstream
`pkg/validate.ResourceValidationResult` (apiVersion / kind / name / namespace / status), but is owned by
`crossplane-diff` so the public JSON schema can evolve independently of upstream's. `Status` surfaces `"invalid"` and
`"missingSchema"`; valid entries are filtered out so consumers iterating `ValidationFailures` see only failure rows.
- `FieldValidationError` — single field-level error inside `ResourceValidationFailure.Errors`. Carries `Type`
(`"schema"` / `"cel"` / `"unknownField"` / `"defaulting"`), `Field` (JSONPath, when locatable), `Message`, and
`Value` (typed: string, number, bool, or struct).
Comment thread CLAUDE.md
Comment on lines +405 to +413
mermaid file, regenerate its `.svg` so the rendered doc matches. Prefer the official mermaid-cli Docker image for
portability across machines and CI:

```bash
cd design/design-doc-cli-diff
for f in *.mermaid; do
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/data" minlag/mermaid-cli \
-i "/data/$f" -o "/data/${f%.mermaid}.svg"
done
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.

2 participants