Skip to content

feat: estate-read batch 1, discover, manifests kind, reference catalog, finding identity, parser notice, untyped import (#5095 #5096 #5097 #5106 #5083 #5070) - #5121

Merged
lex00 merged 12 commits into
mainfrom
estate/int-chant-1
Nov 15, 2026
Merged

lex00 merged 12 commits into
mainfrom
estate/int-chant-1

Conversation

@lex00

@lex00 lex00 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Closes #5095
Closes #5096
Closes #5097
Closes #5106
Closes #5083
Closes #5070

Batch 1 of the estate-read work in chant (#5105). Six issues, each built on its own branch and merged here. This branch holds the build and the full suite for the batch.

#5095: chant workspace graph <dir> --discover

The kinds' probes find a directory's members with no declaration and nothing written. The document is an ordinary contract-1 graph with one new optional field, discovered, one entry per claimed directory (member, tie, module or inside-member). Docs: cli/workspace-graph.mdx, "Discovering members".

  • On fixture fx/, a contract-1 document with members for infra/net and argo and none for the module (discover.e2e.test.ts). Member names cannot hold /, so the members are named infra-net and argo, and their dir fields are infra/net and argo.
  • File listing and content hashes of fx/ (mode, size, mtime, sha256) are identical before and after, and chant's refs and .git/chant are unchanged.
  • A directory claimed by two kinds of equal precedence is listed in discovered with both kinds and not read (unit test, plus the real flyway and golang-migrate kinds).
  • With no declaration and no --discover, the command still fails with declaration-missing.
  • The output validates against graph.schema.json.

#5096: a manifests workspace kind for plain manifest directories

The new kind sits at precedence 305 and probes any *.yaml/*.yml with apiVersion and kind. argo-app now also claims ApplicationSet and AppProject. A file holding template syntax is named in a warning and skipped. A directory a kustomization lists in resources or bases is skipped and reported as coveredBy.

  • fx/plain/ (Deployment, Service, external-secrets.io/v1 ExternalSecret) prints three nodes at --detail 3, and the ExternalSecret carries its spec.
  • fx/argo/ prints an Application, an ApplicationSet and an AppProject.
  • A file holding {{ .Values.x }} is named in the warnings, and the other files' nodes still print.
  • A directory with a kustomization.yaml is still claimed by kustomize.

#5097: the reference catalog on declared graphs and across members

Derived edges carry rule, relation and grain. dangling entries gain rule and targetKind, a new ambiguous list records candidates, and a catalog object names each rule the document uses. Adding a rule is one entry in a catalog's refs. New floor: WORKSPACE_GRAPH_CATALOG_FLOOR. Docs: cli/workspace-graph.mdx ("Derived edges") and lexicon-authoring/observation-contract.mdx.

  • readPath returns ["x"] for a quoted annotation key, and the existing catalog tests pass unchanged.
  • The app Deployment to rbac ServiceAccount runner edge prints with rule k8s:K8s::Apps::Deployment:spec.template.spec.serviceAccountName.
  • Renamed to missing, the reference appears in dangling with that rule.
  • Two members holding runner give no edge and two recorded candidates.
  • --detail 0 output still has the derived edges, mapped onto the members' stack nodes.

#5106: audit findings carry a stable identity

findings[].identity is a hash of the rule, the file, the entity, an optional locator (a container's place, for example) and the secret fingerprint. Message text and line numbers are not inputs. SARIF results carry it as partialFingerprints["chantFindingIdentity/v1"]. An aliased Terraform provider is keyed provider.<name>~<alias>, so adding an earlier block no longer renumbers it.

  • The identity is on every JSON finding and stays put when only text or display names change. audit-identity.test.ts renames a container: every message changes and no identity does.
  • SARIF partialFingerprints equals the JSON identity.
  • Terraform entity keys for duplicate addresses do not shift when an unrelated block is added (parse.test.ts).
  • Renaming the object itself may change the identity; the test confirms renaming the Deployment does.

#5083: audit says when the HCL parser is missing

chant audit prints a notice naming the lexicon, the package, the directories it could not read and the install command. Text reports lead with it, and the JSON report has a top-level skipped list ({lexicon, reason: "parser-not-installed", package, install, paths}). The list is absent when every lexicon was read. Any lexicon can report a missing optional parser the same way.

  • Notice on stderr and in the text, markdown and HTML reports (audit-parser-notice.test.ts).
  • Machine-readable skipped in the JSON report.
  • Malformed HCL is not counted as a skip.

#5070: k8s import writes no class the lexicon does not export

A kind with no exported class is written as k8sManifest({ apiVersion, kind, ... }), which builds and round-trips. Each such kind gets one warning naming k8s.crds and chant generate. The same check also stops two classes that loaded but were the wrong type: kustomize's Kustomization had become Flux's, and Kyverno Policy had become K8s::Iam::Policy.

  • Import checks the class exists before writing it.
  • An untyped resource builds and round-trips (roundtrip-build.test.ts).
  • One warning per kind.
  • The output always loads: on the 279 manifest files of the kubernetes/k8s.io corpus, files that wrote a missing class went from 51 to 0, and so did builds that failed to load.

Gates on this branch

  • just build: passed. Core tsc: clean.
  • Full just test: 24 failures in 14 files on the first run under load. Re-run alone, 7 of those files pass. The other 7 are git, tofu, signing and lock tests, none touched here. They fail on clean origin/main the same way on this machine, from the per-test time budget under load. CI is the arbiter for those.
  • npx tsx scripts/typecheck.ts reports the same six files on clean origin/main in a fresh worktree as on this branch (generated artifacts a fresh worktree lacks). Main's CI is green.
  • The main checkout's chant/lifecycle, ci/* tags and .git/chant were unchanged before and after every test run.

Findings for the plan (also on #5105)

lex00 added 12 commits November 15, 2026 10:50
…5106)

A finding now carries an identity built from the rule, the file, the object,
the finding's place in the object and, for a secret, its fingerprint. The
message is not an input, so renaming a container leaves it alone. SARIF
results publish it as partialFingerprints. Diagnostics gain an optional
locator, which the k8s container checks set. An aliased Terraform provider
is keyed by its alias instead of its order among the provider's blocks.
…tory with no declaration (#5095)

The kinds' probes find the members under <dir>, and the read goes through
the declared path with the found declaration held in memory and laid over
the tree. Nothing is written inside <dir>. A directory a .tf file calls
through a local module source is a module, two kinds at one precedence are
a tie, and a claimed directory inside another member is left out; each is
listed in the new additive discovered field with its outcome. Kinds come
from the @INTENTIUS packages installed beside chant. Member names come
from the path. --at, --member, --detail, --no-cache and --dry-run work;
a declaration in <dir> itself is read as declared. (#5095)
…ers (#5097)

chant workspace graph runs each lexicon's reference catalog over the
composed declared graph (reconstructIndexedEdges), so a reference joins
nodes of two members. The members are read at --detail 3 for the pass
whatever tier the document is printed at; at --detail 1 and 0 the results
move to the nodes they are drawn as. Derived edges go in edges with
origin, rule and relation; references to no node go in dangling with their
rule and targetKind; references to several nodes go in the new ambiguous
list with every candidate; and catalog names the lexicons and members read,
each rule named, and per node the arguments not read because not literal.
Not run with --live.

A catalog takes scopes, kinds whose names are unique inside a scope the
node names (the k8s catalog's namespaced kinds and metadata.namespace), and
declaredNode, the node the rules read (terraform: the provider type and the
literal arguments). readPath takes a quoted key,
metadata.annotations["iam.gke.io/gcp-service-account"].

Floor WORKSPACE_GRAPH_CATALOG_FLOOR.
# Conflicts:
#	packages/core/src/workspace/graph-cli.ts
…og and the JSON report (#5083)

A Terraform root read without @cdktn/hcl2json produced no entities and so no
findings, which read as a clean directory. The terraform entities hook now
lets a missing-parser error (one carrying parserPackage) through, auditFiles
records each affected lexicon, package, install command and directories, and
chant audit prints it on stderr, as a note in text reports, and as a skipped
list in the JSON report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment