Skip to content

docs: adversarial audit of the fold / TypeScript-as-Data feature across core + all lexicons (#1019 follow-up) #1038

Closed

Description

@lex00

Follow-up to the fold epic #1019. A fundamental capability changed — chant build --fold reduces TypeScript-as-Data statically instead of running it — and the docs largely predate it. This is an adversarial audit: assume every relevant page is stale until verified against shipped behavior.

This issue body was re-verified against the tree at 9b1beaf. Two claims in the original filing were wrong and are corrected below.

Ground truth to audit against

Code of record: packages/core/src/fold/{fold,subset}.ts, packages/core/src/discovery/fold-import.ts, packages/core/src/lint/rules/evl*, CLI flag at packages/core/src/cli/main.ts:219 and help text at :410.

Correction 1 — there IS a central section, and it is stale

The original filing said a grep for --fold returns essentially nothing. Wrong. docs/src/content/docs/concepts/typescript-as-data.mdx has a ## Folded vs Run section (~lines 197–210). It is the only page in the entire doc base that mentions fold (verified: 1 file matches --fold|run-fallback across docs/ and all lexicons/*/docs/).

It is also factually stale. Line ~201 reads:

Only the leaf pattern folds today: export const x = new Type({...}). Anything outside that subset — most notably a composite factory call (export const stack = MyStack({...})) ... makes the whole file fall back

#1023 shipped composite factory folding. That sentence is now false, and its example is exactly the case that now folds. Line ~210 ("As more of it is covered statically (cross-file resolution, composite interpretation), more files fold") is likewise half-stale — composite interpretation landed; cross-file (#1020) has not.

So the job is not "create a central home" — it is fix and complete the one that exists, then link other pages to it rather than duplicating.

Correction 2 — the lexicon surface is 8 pages, not 22

The original filing said "every lexicon ships intrinsics.mdx and composites.mdx". Wrong. The complete fold-affected lexicon set is:

lexicons/aws/docs/src/content/docs/{composites,intrinsics}.mdx
lexicons/azure/docs/src/content/docs/{composites,intrinsics}.mdx
lexicons/gitlab/docs/src/content/docs/intrinsics.mdx
lexicons/helm/docs/src/content/docs/{composites,intrinsics}.mdx
lexicons/github/docs/src/content/docs/composites.mdx

Audit those eight. Do not go looking for files that do not exist.

Scope

Core pages to audit (docs/src/content/docs/): concepts/{typescript-as-data,evaluation-pipeline,philosophy,comparison,overview,where-values-come-from}.mdx, lint-rules/evaluability.mdx, guide/{writing-resources,linting}.mdx, cli/{build,run}.mdx, getting-started/quick-start.mdx, serialization/output-formats.mdx, troubleshooting/*.

Verified leads to start from:

  • cli/build.mdx — zero mentions of --fold. The flag and build.fold are undocumented in the CLI reference.
  • Absolute "never runs" / "not enforced" claims live in cli/run.mdx, lint-rules/audit-rules.mdx, and concepts/typescript-as-data.mdx. Every such claim is a prime suspect: precise only under --fold, since the default still runs.
  • #1024's agent explicitly left the "not enforced by chant build" framing in evaluation-pipeline.mdx and typescript-as-data.mdx unaudited. Folding is the enforcement under --fold.
  • lint-rules/evaluability.mdx — does it describe EVL as a diagnostic over the shared subset, and the divergences?

Coordination with #1039

#1039 (in flight) fixes the CLI fold path never threading lexicon intrinsics through, plus per-lexicon isTag registration. Until it lands, intrinsic tagged templates fall back in practice even though the folder supports them.

Write the docs to the designed behavior — "a registered intrinsic tagged template folds" — and do not assert per-lexicon specifics like "AWS Sub folds" or "AWS Sub does not fold", since #1039 is actively changing exactly that. Keep the intrinsics note general.

Method

  • Do not trust a page because it reads plausibly. Cross-check each claim against the code paths listed above.
  • Any "never/always/only" about running or folding is a suspect.
  • Prefer a small number of authoritative pages plus cross-links over scattered half-updates.
  • Where you assert behavior, verify it: run chant build <dir> --fold on a real example and read the [fold:*] lines, or run just fold-differential.

Acceptance criteria

  • Findings table: every audited page (13 core + 8 lexicon) marked accurate / stale / missing, with the specific stale claim and the fix.
  • concepts/typescript-as-data.mdx's ## Folded vs Run is corrected (composites fold; feat(core): fold — resolve identifiers across the module graph #1020 cross-file is the remaining gap) and is complete enough to be the single canonical home other pages link to.
  • cli/build.mdx documents --fold and build.fold.
  • lint-rules/evaluability.mdx describes EVL-as-diagnostic plus the fold/EVL divergences.
  • A before/after explainer: default run-based (deterministic by lint discipline) vs opt-in fold-based (deterministic by construction, with run-fallback); what changed for the author (nothing — it is opt-in); how to see it (--fold logs, the test(core): differential conformance corpus — fold-output === run-output #1025 differential).
  • The eight lexicon pages carry a fold note where behavior is non-obvious.
  • No page makes an absolute "never runs" claim without the --fold qualifier.

Verification

Docs are a separate Astro build. cd docs && npm run build must pass, and CI runs a link check — do not leave links to pages or anchors that do not exist.

Activity

  1. added
    documentation
    on Jul 25, 2026
  2. lex00 commented on Jul 25, 2026

    @lex00
    ContributorAuthor

    Audit complete — consolidated findings (4 parallel auditors, code-verified)

    ⚠️ Ground-truth correction (this issue's premise was wrong)

    This issue stated "registered intrinsic tagged templates fold." They don't, in the wired CLI path — --fold hardcodes an empty intrinsics array (fold-import.ts), so every intrinsic tagged template falls back to run. Filed as #1039. Consequence for the fix wave: no doc may claim intrinsics fold today. The honest note is "intrinsic-using files fall back to run under --fold." Empirically: 0/~20 AWS, 0/~9 Azure, 0/~8 GCP examples fold; the 14/98 that fold are intrinsic-free leaf/composite/destructure examples.

    The pattern: the epic touched exactly ONE doc file, and #1023 landed after even that

    git show of the epic commit edited only lint-rules/evaluability.mdx (2 lines). Composite folding (#1023) merged after the epic's doc pass, so the one fold section that exists (typescript-as-data.mdx "Folded vs Run") is now factually wrong — it says composite calls don't fold.

    Q1 — central home

    concepts/typescript-as-data.mdx is the right home (keep it; don't fork), but currently stale + incomplete: line ~201 wrongly says composite calls fall back; missing the EVL-shared-subset (#1024), the documented fold/EVL divergences, and the #1025 differential/parity claim. Its own [fold:run] example is a case that now folds.

    Q2 — references to fix (per-page verdicts)

    Stale / wrong (highest priority):

    • guide/writing-resources.mdx — "It never executes your code" — FALSE for default path.
    • getting-started/quick-start.mdx — "chant reads your TypeScript as data, it never executes it" — same.
    • concepts/comparison.mdx — "Code as Data / without being executed" stated as flat external fact; the "execution model difference" section is the biggest missing --fold fact.
    • concepts/philosophy.mdx — "Synthesis does run your code … EVL reject anything" (determinism-only-by-lint framing).
    • concepts/typescript-as-data.mdx — the stale composite claim (above).

    Missing (critical):

    • cli/build.mdx — zero --fold coverage (grep-verified). configuration/config-file.mdx — zero build.fold.
    • concepts/evaluation-pipeline.mdx — single run-only pipeline, no fold path.

    Incomplete:

    • lint-rules/evaluability.mdx — the one edited page: only names EVL001 (not EVL003), overclaims "exactly the same" (ignores 5+ documented divergences), and "the folder actually enforces it" lacks the opt-in --fold qualifier.
    • troubleshooting/common-errors.mdx — no [fold:run]/FoldError guidance.
    • concepts/overview.mdx, concepts/where-values-come-from.mdx — minor default-only framing.

    Accurate (no change): cli/run.mdx, guide/linting.mdx, serialization/output-formats.mdx, troubleshooting/type-errors.mdx, lint-rules/audit-rules.mdx.

    Lexicons (all additive — no false claims found, only silence):

    • Root cause is uniform: nested-new-as-value (gitlab new Image(), github new Step(), fly new MachineConfig()), pseudo-param proxy on unresolved imports (CI.*, Fly.*, helm values.*), and intrinsic calls (bug(core): --fold never threads lexicon intrinsics through, so intrinsic tagged templates never fold in production #1039) — all fall back today.
    • Fix shape: one general paragraph on the central page (the three rejection shapes) + a single callout per affected lexicon linking back (gitlab pipeline-concepts, github workflow-concepts, helm helm-concepts — strongest case, it's the core idiom, fly resources, docker interpolation scoped to env(), aws/azure intrinsics+composites with the "falls back today" caveat).
    • Positive cases (can honestly say "these fold"): k8s composite-examples.mdx (destructuring shape — 4 of the 14 folding entries) and gcp composite-examples.mdx.
    • Unaffected: temporal (literal resources fold; Ops out of fold scope), forgejo (inherits github).
    • Metadata bug to note: gitlab reference() is isTag:true but invoked as a plain call; AWS Sub is isTag:false — both feed bug(core): --fold never threads lexicon intrinsics through, so intrinsic tagged templates never fold in production #1039.
    • Shared nit: getting-started.mdx "TypeScript-to-X compiler" boilerplate (azure/gcp/k8s, identical) nudges a static-transform model true only under --fold — one shared softening.

    Q3 — before/after

    No page narrates the run→fold shift. Recommendation: expand typescript-as-data.mdx's "Folded vs Run" into it — "deterministic by lint discipline" (default) → "deterministic by construction" (--fold), nothing required of the author, [fold:fold]/[fold:run] logs + #1025 to verify — and have philosophy/comparison/overview/evaluation-pipeline each carry one linking sentence back.

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

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions