Skip to content

Generated-file detection is blind to the docs tree: a banner-keyed grep returns a confident zero on ~900 generated pages #293

Closed

Description

@atrawog

The intuitive way to detect a generated file — grep for the generator's banner — is structurally blind to one of the two trees generated files live in, and it fails in the direction of "nothing here is generated".

Measured (per tree, at origin/main)

tree      grep -lEi 'DO[- ]NOT[- ]EDIT'    grep -l 'GENERATED by'
plugins             345                            339
docs                900                              0

The two trees are emitted by different generators with different banners:

plugins  line 1:  <!-- GENERATED by `charly marketplace generate` — DO NOT EDIT. … -->
docs     line 1:  ---                    <- Astro frontmatter
         line 6:  <!-- DO-NOT-EDIT — generated by `charly docs generate`; run `task docs:sync` … -->

Two independent reasons a marketplace-keyed matcher misses every docs page: the banner sits behind frontmatter (so head -1 misses it), and it reads lowercase generated by after a DO-NOT-EDIT — prefix (so a case-sensitive GENERATED by misses it even inside head -12).

And the separators are opposite between trees, which is why case- and separator-tolerance are both load-bearing rather than stylistic:

tree      'DO NOT EDIT' (spaced)   'DO-NOT-EDIT' (hyphenated)
plugins            344                        4
docs                 2                      900

Why this is a defect in the guard rather than a documentation nit

The banner exists to stop someone editing a projection. Anyone auditing plugins naturally writes GENERATED by — it names the generator they are thinking about — gets 339 hits, and carries that instrument to docs, where it returns a confident zero on ~900 generated pages. A guard that fails silently toward "nothing here is generated" converts a question into a false answer — and the cost of that is measured below, not assumed.

This is not hypothetical: two PRs in this repo's history spent multiple review rounds editing generated projections before anyone noticed, and the reusable lesson recorded at the time — "a DO-NOT-EDIT banner only works if you arrive at the top of the file, and a targeted edit never does" — understated it. The banner also does not work if you arrive with the wrong pattern.

The discriminator, stated as a rule rather than a count

A detector keyed on one generator's banner cannot see another generator's tree. Key it on the property all generated files share — DO[- ]NOT[- ]EDIT, case-insensitive — never on the emitter's name.

Stated as a rule because counts move; the property does not.

Candidate remedies (not prescribing one)

  1. Converge the banners so both generators emit an identical, greppable marker line — the durable fix, and it makes the property real rather than conventional.
  2. Ship the detector as a charly verb, so nobody hand-rolls the pattern. Per R4, a probe no charly verb expresses is a gap, and this one has now produced a wrong answer twice.
  3. At minimum, ensure every place that prescribes a detection command prescribes the tolerant form. charly#289 already does this at two sites, with the separator split as its measured justification — so the documented form is correct today; the intuitive form is what fails.

Related

Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)

Activity

  1. atrawog commented on Aug 28, 2026

    @atrawog
    ContributorAuthor

    Validation (2026-08-28) — RESOLVED (superseded)

    Verified against current repos. The detection tooling evolved past the blind grep: the docs generator now has its own header (emit.go:14: "") and detects its own pages via it (prune.go:38), and the docs tree carries that banner on every generated page (verified on docs/src/content/docs/reference/box/arch/*). The marketplace generator checks its own header (emit.go:17). The "confident zero" failure mode is gone because each tree is detected by its own generator's header, not a shared grep.

    Closing as superseded.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions