enhance(#3545): widen no-source-grep with fold+hooks, migrate 76 sites (#4161)

* feat(#3545): widen no-source-grep with one-hop path-fold and hooks dir

Resolve a readFileSync() path argument that is a bare Identifier one hop
back to its VariableDeclarator initializer before classification, and
recognize `hooks` as a source directory alongside bin/lib/gsd-core/src.

Measured (epic #3464 phase 7): fold+hooks together newly flag 76
unsuppressed sites across 18 files that were previously invisible to
identifier-indirected or hooks/-rooted source reads. Neither widening
alone is sufficient — hooks-only surfaces 0 new sites, confirming #3520's
prior finding that the identifier-indirection gap must close first.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(#3545): migrate 76 sites newly flagged by the fold+hooks widening

Per-site classification: rewrite behaviorally (require() the real module,
assert on its actual exported behavior) wherever the read was a proxy for
code behavior; add a site-scoped `// allow-test-rule: <reason> (#3545)`
marker only where the raw source text genuinely is the product under test
(codex-config.test.cjs's adapter-header-contract checks, install.js
structural-wiring guards with no exported symbol, AST-parse fixture
inputs, etc.) — each marker cites an existing repo-sanctioned category
from CONTRIBUTING.md's allow-test-rule exception table.

Also converts two try/finally test bodies (introduced during this same
migration) to the required t.after() cleanup pattern per CONTRIBUTING.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore(#3545): re-baseline effective-exemption ceiling to 81

The fold+hooks widening's own newly-detected sites are now suppressed by
site-scoped markers, moving them from invisible into the tightly-ratcheted
effective-exemption count. Ceiling rises from 10 to 81 (the exact measured
high-water mark, grace unchanged at 2) — a deliberate, measured re-baseline
per the widening working as intended, not an ordinary ceiling bump.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(#3545): use canonical allow-test-rule category tokens

4 markers added during migration cited an issue ref correctly but didn't
use one of CONTRIBUTING.md's seven recognized category tokens, unlike
every other marker in this change. Cosmetic only — same suppression
lines, same effective/live counts (81/81, 0 live).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(#3545): correct stale phase-artifact path in test comment

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: sim <sim@local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-09-01 21:40:38 -04:00
committed by GitHub
parent ff0361071d
commit f16ff7d1b3
21 changed files with 360 additions and 83 deletions

View File

@@ -477,18 +477,15 @@ describe('Issue #815: --next dist-tag support', () => {
* 4. Single-source: check-latest-version's PACKAGE_NAME === the seam's
* packageName === the scoped '@opengsd/gsd-core'.
*
* Source-grep policy: this test reads hook source via readFileSync. The repo's
* lint-no-source-grep rule targets bin/lib/gsd-core — hooks/ is out of
* scope. The behavior (correct name → no E404) only manifests at runtime
* Source-grep policy: this test reads hook source via readFileSync. Since
* #3545 lint-no-source-grep also covers hooks/, not just bin/lib/gsd-core.
* The behavior (correct name → no E404) only manifests at runtime
* against the live registry; structural assertions are the minimum-cost
* contract for the worker, the same rationale #378 carried.
* contract for the worker, the same rationale #378 carried. See the
* site-scoped `allow-test-rule` marker directly above the readFileSync()
* call in workerCodeOnly() below.
*/
// allow-test-rule: structural-regression-guard (see #378)
// structural assertion on hook delegation; the behavior being
// tested (correct package name → no E404) only manifests at runtime against the
// live npm registry, which CI does not call.
'use strict';
const { test, describe } = require('node:test');
@@ -502,6 +499,11 @@ const SEAM = require('../gsd-core/bin/lib/package-identity.cjs');
const { PACKAGE_NAME } = require('../gsd-core/bin/check-latest-version.cjs');
function workerCodeOnly() {
// allow-test-rule: structural-regression-guard (see #378) — the behavior
// being tested (correct scoped package name → no E404) only manifests at
// runtime against the live npm registry, which CI does not call; the
// stripped-source text is the minimum-cost contract for this worker
// (#3545 widening brings hooks/ into the rule's scope)
const src = fs.readFileSync(WORKER_PATH, 'utf8');
return src
// eslint-disable-next-line local/no-unbounded-quantifier -- parses this repo's own bounded hooks source, not adversarial input
@@ -566,10 +568,11 @@ describe('bug #378 / #498: update worker queries the scoped name via the seam',
{
const { describe: __foldDescribe } = require('node:test');
__foldDescribe("folded:bug-2784-update-cache-clear-path (consolidation epic #1969 B5 #1974)", () => {
// allow-test-rule: structural-regression-guard (see #2784)
// Reads hook .js or bin/install.js source to assert structural invariants
// (search array order, function wiring, path constants) that cannot be
// verified by observing runtime outputs alone. Per CONTRIBUTING.md exception matrix.
// verified by observing runtime outputs alone. Per CONTRIBUTING.md exception
// matrix. See the site-scoped `allow-test-rule` marker directly above the
// readFileSync() call below (#3545 widening brings hooks/ into scope).
/**
* Regression test for bug #2784
@@ -603,6 +606,9 @@ const CHECK_UPDATE_HOOK = path.join(REPO_ROOT, 'hooks', 'gsd-check-update.js');
describe('bug-2784: update.md cache-clear covers shared cache path', () => {
test('gsd-check-update.js hook constructs cache dir from .cache and gsd path segments', () => {
// allow-test-rule: structural-regression-guard (see #2784) — asserts
// the path.join() segment structure that cannot be verified by
// observing runtime outputs alone (#3545)
const hookContent = fs.readFileSync(CHECK_UPDATE_HOOK, 'utf-8');
// Parse the path.join() call structurally rather than text-grepping.
// eslint-disable-next-line local/no-unbounded-quantifier -- parses this repo's own bounded hooks/gsd-check-update.js source, not adversarial input