merge: recognize Wrangler-style generated banners (CG-25)

A generated Cloudflare Wrangler ambient-types file was not flagged generated, so
it ranked with no penalty and competed with hand-written source on generic token
overlap. The banner shape it uses — "Generated by <tool> by running <command>" —
matched none of the existing content patterns, all of which require DO NOT EDIT,
a standalone @generated, or the "auto(matically) generated by" phrasings.

Precision is held by requiring TWO 'by' clauses: the banner must name a tool and
then say 'by running'. Ordinary prose ("the report is generated by running the
nightly job") has only one and does not match.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Colby McHenry
2026-08-06 11:17:15 -05:00
co-authored by Claude Opus 5
3 changed files with 25 additions and 0 deletions
+16
View File
@@ -118,6 +118,14 @@ describe('hasGeneratedHeader — per-marker coverage (#1500)', () => {
'/* automatically generated by rust-bindgen 0.59.2 */\n\npub const FOO: u32 = 1;\n',
],
['ANTLR — "Generated from … -- DO NOT EDIT"', '// Generated from Expr.g4 by ANTLR 4.9.2 -- DO NOT EDIT\npackage parser;\n'],
[
'Wrangler — "Generated by Wrangler by running `wrangler types`" (CG-25)',
'/* eslint-disable */\n// Generated by Wrangler by running `wrangler types` (hash: adcfde101dd7d9077590b6b39d3eaf8d)\n// Runtime types generated with workerd@1.20260708.1 2026-07-12\ndeclare namespace Cloudflare {\n\tinterface Env {}\n}\n',
],
[
'the same "regenerate by running" shape from an in-house CLI',
'# Generated by ./scripts/schema-gen.py by running `make schema`\n\nfrom typing import Any\n',
],
[
'banner on an unprefixed line INSIDE a block comment',
'/*\n Code generated by ent. DO NOT EDIT.\n*/\npackage ent\n',
@@ -155,6 +163,14 @@ describe('hasGeneratedHeader — per-marker coverage (#1500)', () => {
],
['an email address that happens to contain "@generated"', '// Contact: build@generated.example.com for issues.\npackage main\n'],
['"DO NOT EDIT" with no generation claim', '// DO NOT EDIT THIS FILE BY HAND — run `make fmt` instead.\npackage main\n'],
[
'prose: bare "generated by" naming no tool and no reproduction command (CG-25)',
'// The table below is generated by the build at runtime, so the\n// literal values here are only a fallback.\npackage main\n',
],
[
'prose: "generated by running …" — one "by" clause, not the Wrangler shape (CG-25)',
'// The nightly summary is generated by running the ETL job against\n// yesterday\'s partition.\npackage main\n',
],
['empty file', ''],
];