Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/src/content/docs/lexicon-authoring/post-synth-checks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ Keep helpers in a `*-helpers.ts` file — the barrel generator skips them (they

This join is the pattern behind conformance checks generally — a custom resource against the schema that defines it, a composition against the kinds it references. Any check that needs to know about *other* resources in the output is a post-synth check, and this is its shape.

### One build root at a time (chant #1939)

A bundle-join check only sees the build root of the *current* `chant build` invocation, since `ctx.outputs`, `ctx.docs` and `ctx.entities` are all scoped to that one invocation. Split the two halves of a join across separate build roots and the check goes silent rather than wrong, because a `PostSynthContext` has no way to tell "wired up in the other build" apart from "forgotten entirely."

The k8s lexicon's `WK8505` (`lint/post-synth/wk8505.ts`) shows why this matters. It warns when a committed-encrypted secret has no Flux `Kustomization` setting `spec.decryption`, and that join needs the secret and the Kustomization declared in the same build root. A project that splits workload and Flux wiring into separate roots, a common shape as a project grows, gets no warning even when the decryption wiring is genuinely missing.

Chant #1939 tracks whether checks like this should get an opt-in project-level mode that runs across every build root. Until that lands, a check that joins across resources stays single-build-root-scoped by construction, and an author has two options today: keep the resources a check joins across in the same build root, or accept that the check will not fire once those resources live apart.

## Universal Check Patterns

These patterns apply to most IaC formats:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/lint-rules/audit-rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ Point `file` at the committed ciphertext, make its metadata.name match the decla

**committed-encrypted secret with no Flux decryption wiring** — report-only · guidance

Add decryption: "sops" to the FluxAppFor reconciling the path that carries the ciphertext sidecar, or ignore if that Kustomization is declared in a different build.
Add decryption: "sops" to the FluxAppFor reconciling the path that carries the ciphertext sidecar, or ignore if that Kustomization is declared in a different build. This check sees one build root at a time, so it goes silent once the secret and the Kustomization live in different build roots (chant #1939).

| | |
|---|---|
Expand Down
2 changes: 1 addition & 1 deletion lexicons/k8s/docs/src/content/docs/rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ Post-synth checks validate the serialized output after the build pipeline comple
| `WK8502` | Custom resource spec field has the wrong type or a value outside its enum |
| `WK8503` | Workload consumes a Secret nothing in the output produces — produce it (Secret, ExternalSecret, InfisicalSecret, Certificate) or declare its provenance with declareSecret() |
| `WK8504` | committed-encrypted secret declaration does not resolve — the declared file is missing, is not the named Secret, or is not encrypted |
| `WK8505` | committed-encrypted secret with no Flux decryption wiring — add decryption: 'sops' to the FluxAppFor reconciling the path that carries it |
| `WK8505` | committed-encrypted secret with no Flux decryption wiring — add decryption: 'sops' to the FluxAppFor reconciling the path that carries it. Sees one build root at a time, so it goes silent when that Kustomization lives in a different build root (chant #1939). |
2 changes: 1 addition & 1 deletion lexicons/k8s/src/lint/audit-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const k8sAuditCatalog: Record<string, RuleMeta> = {
WK8502: auditRule("WK8502", "merge-worthy", "guidance", "Custom resource spec field has the wrong type or enum value", "Match the CRD schema: use the declared scalar type and one of the enum values.", { category: "correctness" }),
WK8503: auditRule("WK8503", "merge-worthy", "guidance", "Workload consumes a Secret nothing in the output produces", "Produce the Secret in the same build (Secret, ExternalSecret, InfisicalSecret, cert-manager Certificate), or declare its provenance with declareSecret() if it exists out of band.", { category: "correctness" }),
WK8504: auditRule("WK8504", "merge-worthy", "guidance", "committed-encrypted secret declaration does not resolve", "Point `file` at the committed ciphertext, make its metadata.name match the declaration, and re-run `sops -e -i` so every data/stringData value is ENC[...].", { authority: [K8S_SECRETS] }),
WK8505: auditRule("WK8505", "report-only", "guidance", "committed-encrypted secret with no Flux decryption wiring", "Add decryption: \"sops\" to the FluxAppFor reconciling the path that carries the ciphertext sidecar, or ignore if that Kustomization is declared in a different build.", { category: "correctness" }),
WK8505: auditRule("WK8505", "report-only", "guidance", "committed-encrypted secret with no Flux decryption wiring", "Add decryption: \"sops\" to the FluxAppFor reconciling the path that carries the ciphertext sidecar, or ignore if that Kustomization is declared in a different build. This check sees one build root at a time, so it goes silent once the secret and the Kustomization live in different build roots (chant #1939).", { category: "correctness" }),
};

// Prior art credits live beside the rules in ./audit-lineage.ts (see core audit/prior-art.ts).
Expand Down
6 changes: 4 additions & 2 deletions lexicons/k8s/src/lint/post-synth/wk8505.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
* invocations, so "no Kustomization in THIS build sets spec.decryption" can
* mean "wired up in the other build" as easily as "forgotten" — the design
* doc's §4 explains why no path-to-build-target join exists to tell those
* apart. Promote to error if that join ever becomes available.
* apart. Single-build-root scoped, tracked by chant #1939 as a candidate for
* an opt-in project-level mode; promote to error if that join ever becomes
* available.
*
* Fires only on claims that actually resolved (`problems.length === 0`, via
* `resolveEncryptedSecretClaims`), not on every raw declaration. An
Expand All @@ -39,7 +41,7 @@ function fluxKustomizations(manifests: K8sManifest[]): K8sManifest[] {
export const wk8505: PostSynthCheck = {
id: "WK8505",
description:
"committed-encrypted secret with no Flux decryption wiring — add decryption: 'sops' to the FluxAppFor reconciling the path that carries it",
"committed-encrypted secret with no Flux decryption wiring — add decryption: 'sops' to the FluxAppFor reconciling the path that carries it. Sees one build root at a time, so it goes silent when that Kustomization lives in a different build root (chant #1939).",

check(ctx: PostSynthContext): PostSynthDiagnostic[] {
const kustomizations = fluxKustomizations(allManifests(ctx));
Expand Down
Loading