Skip to content

refactor(ci): reform zombie-import gate (ADR 0005 H3)#2357

Merged
alexey-pelykh merged 1 commit intomainfrom
chore/h3-zombie-import-gate-reform
Apr 14, 2026
Merged

refactor(ci): reform zombie-import gate (ADR 0005 H3)#2357
alexey-pelykh merged 1 commit intomainfrom
chore/h3-zombie-import-gate-reform

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

Three-part reform of the zombie-import CI gate, implementing H3 from ADR 0005 (Fork Sync Hardening):

  • Registry-derived patterns: Dead module patterns derived from `scripts/data/tombstones.json` (generated from HQ disposition registry) + 8 fallback directory-level patterns. Eliminates hardcoded pattern drift.
  • Tombstone existence scan: Checks each tombstoned path on disk. Re-introduced files caught even without importers. Baselined at 12 (chore: delete 12 tombstoned files surviving from v2026.3.7 sync #2356).
  • Allowlist sunset: Hardcoded `allowedCallsites` Set replaced by `scripts/data/zombie-import-allowlist.json` with mandatory issue URLs. Growth prevented by baseline file. 71 entries baselined (chore: clean up zombie-import allowlist debt (10 entries) #2355).

Critical bug fix: The original gate used `resolveRepoRoot()` (designed for `scripts/lib/`) which resolved 2 levels up from `scripts/` — pointing to the repo's PARENT directory. The gate scanned zero files and vacuously passed on every run since it was added (#2247). Fixed to `resolveRepoRootFromScript()` (1 level up), consistent with `check-stub-debt.mjs`.

Changes

File Description
`scripts/check-no-zombie-imports.mjs` Full rewrite: registry-derived patterns, existence scan, allowlist from JSON, baseline enforcement, fixed repo root
`scripts/data/tombstones.json` New: 36 tombstoned file paths from HQ disposition registry
`scripts/data/zombie-import-allowlist.json` New: 71 legacy callsites with issue references (declining debt register)
`.zombie-tombstone-baseline` New: baseline count (12) of known existing tombstoned files
`.zombie-import-allowlist-baseline` New: baseline count (71) of allowlisted callsites

Test plan

  • Gate passes on current fork (exit 0)
  • Gate runs in 2.5s (AC: <5s)
  • `pnpm check` passes (format + types + lint)
  • Stub-debt gate unaffected
  • All 71 allowlist entries have issue references
  • All 71 entries correspond to real zombie imports (verified via TypeScript AST scan)
  • 12 tombstoned files detected and baselined
  • Stale entries from old allowlist removed (6 entries: deleted file, shifted lines, non-matching imports)

Refs: remoteclaw/hq#24, ADR 0005
Tracked debt: #2355 (71 allowlisted imports), #2356 (12 tombstoned files on disk)

🤖 Generated with Claude Code

… existence scan + allowlist sunset (ADR 0005 H3)

Three-part reform of the zombie-import CI gate:

1. **Registry-derived patterns**: Dead module patterns are now derived from
   scripts/data/tombstones.json (generated from HQ disposition registry)
   combined with 8 fallback directory-level patterns. Eliminates hardcoded
   pattern drift — adding a tombstone to the registry automatically extends
   gate coverage.

2. **Tombstone existence scan**: For each tombstoned path, the gate checks
   whether the file exists on disk. Re-introduced files are caught even
   when nothing imports them. Uses .zombie-tombstone-baseline (currently 12)
   to track known debt (#2356) while preventing growth.

3. **Allowlist sunset**: The hardcoded allowedCallsites Set is replaced by
   scripts/data/zombie-import-allowlist.json — each entry requires a tracked
   issue URL. Growth is prevented by .zombie-import-allowlist-baseline.
   Stale entries removed; 71 live entries baselined with #2355.

**Critical bug fix**: The original gate used resolveRepoRoot() (designed for
scripts/lib/) which resolved 2 levels up from scripts/ — pointing to the
repo's PARENT directory. Source roots didn't exist there, so the gate
scanned zero files and vacuously passed. Fixed to resolveRepoRootFromScript()
(1 level up), consistent with check-stub-debt.mjs.

Gate runs in ~2.5s on current fork (AC: <5s).

Refs: remoteclaw/hq#24
Tracked debt: #2355 (71 allowlisted imports), #2356 (12 tombstoned files)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexey-pelykh alexey-pelykh merged commit af4169b into main Apr 14, 2026
11 checks passed
@alexey-pelykh alexey-pelykh deleted the chore/h3-zombie-import-gate-reform branch April 14, 2026 15:31
alexey-pelykh added a commit that referenced this pull request Apr 21, 2026
… + rebaseline allowlist (#2355)

Restore ADR 0005 H3 (PR #2357) after it was reverted by the
v2026.3.7→v2026.3.8 sync (PR #2360, `fc2cefeeab`), which rolled
`scripts/check-no-zombie-imports.mjs` back to its pre-H3 hardcoded form
and orphaned the JSON allowlist + baselines.

Changes:

1. Restore H3 gate script with registry-derived `deadModulePatterns`,
   JSON allowlist loader, tombstone existence scan, and baseline
   comparison — identical to `af4169bf9a` minus the targeted narrowing
   in point 2.

2. Narrow `acp/runtime` fallback pattern: split broad `acp/runtime`
   into `acp/runtime/session-meta` and `acp/runtime/session-identifiers`
   (the only 4-line stubs in that namespace). `acp/runtime/errors`,
   `acp/runtime/registry`, and `acp/runtime/types` are live public API
   re-exported by `src/plugin-sdk` — the broad pattern was catching
   them as false positives.

3. Rebaseline allowlist JSON from 68 → 23 entries:
   - 42 stale entries removed (line drift during H3's offline period)
   - 11 false-positive entries removed post-narrowing
   - 8 previously-unallowed new violations retained
   - Remaining 23: 13 `agents/model-selection`, 7 `agents/sandbox`,
     3 `acp/runtime/session-meta`, 1 `agents/skills`

4. Decrement baselines:
   - `.zombie-import-allowlist-baseline`: 71 → 23
   - `.zombie-tombstone-baseline`: 12 → 0 (all tombstoned files already
     absent; #2356 is auto-satisfied)

`agents/model-selection` broad pattern is KEPT despite the file having
live H9-attested functions — those are pending gutting per the
Middleware Boundary Principle, tracked debt rather than gate false
positives. Follow-up gutting issue to be filed.

Gate passes locally: `Zombie-import gate: 36 tombstones, 45 patterns,
23 allowlisted callsites. Import scan: clean.`

Refs: ADR 0005 H3 (engineering/decisions/0005-fork-sync-hardening.md)
Regression source: #2360 (sync v2026.3.7→v2026.3.8)
Auto-satisfied: #2356 (0 tombstoned files exist)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
alexey-pelykh added a commit that referenced this pull request Apr 21, 2026
… + rebaseline allowlist (#2355) (#2454)

Restore ADR 0005 H3 (PR #2357) after it was reverted by the
v2026.3.7→v2026.3.8 sync (PR #2360, `fc2cefeeab`), which rolled
`scripts/check-no-zombie-imports.mjs` back to its pre-H3 hardcoded form
and orphaned the JSON allowlist + baselines.

Changes:

1. Restore H3 gate script with registry-derived `deadModulePatterns`,
   JSON allowlist loader, tombstone existence scan, and baseline
   comparison — identical to `af4169bf9a` minus the targeted narrowing
   in point 2.

2. Narrow `acp/runtime` fallback pattern: split broad `acp/runtime`
   into `acp/runtime/session-meta` and `acp/runtime/session-identifiers`
   (the only 4-line stubs in that namespace). `acp/runtime/errors`,
   `acp/runtime/registry`, and `acp/runtime/types` are live public API
   re-exported by `src/plugin-sdk` — the broad pattern was catching
   them as false positives.

3. Rebaseline allowlist JSON from 68 → 23 entries:
   - 42 stale entries removed (line drift during H3's offline period)
   - 11 false-positive entries removed post-narrowing
   - 8 previously-unallowed new violations retained
   - Remaining 23: 13 `agents/model-selection`, 7 `agents/sandbox`,
     3 `acp/runtime/session-meta`, 1 `agents/skills`

4. Decrement baselines:
   - `.zombie-import-allowlist-baseline`: 71 → 23
   - `.zombie-tombstone-baseline`: 12 → 0 (all tombstoned files already
     absent; #2356 is auto-satisfied)

`agents/model-selection` broad pattern is KEPT despite the file having
live H9-attested functions — those are pending gutting per the
Middleware Boundary Principle, tracked debt rather than gate false
positives. Follow-up gutting issue to be filed.

Gate passes locally: `Zombie-import gate: 36 tombstones, 45 patterns,
23 allowlisted callsites. Import scan: clean.`

Refs: ADR 0005 H3 (engineering/decisions/0005-fork-sync-hardening.md)
Regression source: #2360 (sync v2026.3.7→v2026.3.8)
Auto-satisfied: #2356 (0 tombstoned files exist)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant