Skip to content

feat(docs): forge docs impact — reusable documentation-impact graph#101

Merged
CodeWithJuber merged 4 commits into
masterfrom
claude/docs-impact-graph
Jul 20, 2026
Merged

feat(docs): forge docs impact — reusable documentation-impact graph#101
CodeWithJuber merged 4 commits into
masterfrom
claude/docs-impact-graph

Conversation

@CodeWithJuber

Copy link
Copy Markdown
Owner

What & why

docs check reconciles a fixed list of registries and docs sync sweeps a diff for raw identifiers. forge docs impact is the general, reusable version of the same idea: it answers "I changed X — which documented surfaces mention X and are now potentially stale?" as a proper documentation-reference graph instead of a per-file rule.

Built as a three-stage pipeline:

  1. Entity extraction — a pluggable extractor registry derives the typed entities the project documents (command names, CLI flags, FORGE_* env vars, MCP tool names, exported symbols, brand tokens, the version, package.json fields) from their canonical sources, reusing docs_check's envVarsRead/srcFiles scanning and the COMMANDS/TOOLS registries. Adding a new entity type is one record in the registry.
  2. Reference index — a word-boundary- and code-fence-aware scan of every doc surface (all tracked *.md, CITATION.cff, plugin manifests, the landing page, package.json) builds an inverted index: entity → every file:line that names it. Bare English-word-shaped entities only count inside backticks/fenced code so prose doesn't false-positive.
  3. Impact query — from a git diff of the canonical sources, computes which entities changed (renamed command, added/removed flag, removed env var, touched export, version bump) and returns every doc location referencing them, ranked by confidence.

New command: forge docs impact

  • Advisory by default (prints findings, exits 0); --strict exits non-zero for CI enforcement
  • --since <ref> sets the diff base (default: session baseline, then HEAD)
  • --staged reads the index instead of the working tree
  • --min-confidence <n> drops low-signal hits
  • --json for tooling/CI consumption
  • docs check now prints a one-line pointer to docs impact when the working tree touches a documented entity

Honest limits (documented in docs/GUIDE.md): a token index catches a doc that names a changed entity — it can't see a paraphrase with no textual anchor, a screenshot/diagram, or a pure wording choice.

This PR also folds in an unrelated CI fix cherry-picked from claude/parallel-solving-3dc0ji (5e4fa79): .github/workflows/security.yml now runs the gitleaks binary directly instead of the licensed gitleaks-action@v3, which flakily fails CI. Included so this PR's own secret-scan check is green.

Adds src/docs_impact.js (~600 lines: extractor registry, inverted index, diff query) and test/docs_impact.test.js (~257 lines), and wires the command into src/cli.js / src/commands.js / src/docs_check.js, plus README.md, docs/GUIDE.md, CHANGELOG.md.

Checklist

  • npm test passes (1068 passed, 0 failed, 2 skipped)
  • npm run check passes (Biome lint + format — 0 errors, pre-existing unrelated warnings only)
  • New public functions have a test
  • Conventional commit message (feat:/fix:/docs: …)
  • CHANGELOG.md updated under ## [Unreleased]
  • No new runtime dependency (dev deps ok — zero runtime deps maintained)
  • Substrate/docs updated (forge docs impact is new — README, GUIDE, CHANGELOG all updated)

Risk & rollback

  • Risk level: low — new, isolated command; no changes to existing command behavior other than one extra advisory line in docs check output.
  • Rollback plan: revert this PR; no data migrations or persisted state involved.

Extra checks (tick if applicable)

  • npm run typecheck passes
  • Input validated at boundaries; errors handled (no swallowing)
  • Authorization/ownership checked (if it touches access) — n/a, local CLI tool
  • Logs contain no secrets/PII
  • If AI-assisted: I understand it, verified the package APIs, and it has tests

Test plan

  • npm test — 1068/1068 passing (2 pre-existing skips)
  • npx biome check — clean (0 errors)
  • npm run typecheck — clean
  • node src/cli.js docs check — reports docs and code agree

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com


Generated by Claude Code

claude added 4 commits July 20, 2026 00:26
Answers the question: "I changed X — which documented surfaces mention
X and are now stale?"

Implemented as a three-stage pipeline:
  1. A typed-entity extractor registry pulls named surfaces (commands,
     flags, env vars, config keys, etc.) out of the source tree.
  2. Those entities are compiled into an inverted doc index mapping
     each entity to the documentation locations that mention it.
  3. A diff-to-impact query takes a set of changed files/entities and
     looks up the doc index to report which documented surfaces are
     now potentially stale.

The command is advisory by default (prints findings, exits 0) and
gains a --strict flag for CI enforcement (nonzero exit on stale docs).
'forge docs check' now prints a one-line pointer to 'forge docs impact'
so users discover the deeper analysis.

Adds src/docs_impact.js (extractor registry, inverted index, diff
query) with test/docs_impact.test.js, wires the new command into
src/cli.js and src/commands.js, and updates README.md, docs/GUIDE.md,
and CHANGELOG.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tion

dependabot #91 bumped gitleaks/gitleaks-action v2→v3, whose breaking
update requires a paid GITLEAKS_LICENSE for org-associated accounts and
HARD-FAILS when its license-validation server is unreachable ("License
key validation will be enforced") — turning the secret-scan gate red on
master and every PR for reasons unrelated to the code.

Replace the action with the pinned gitleaks binary (8.21.2). `gitleaks
detect` walks the full commit history (fetch-depth:0) exactly as before,
with no network license dependency, so the gate stays deterministic and
blocking. set -euo pipefail keeps it fail-closed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…suite

Running the gitleaks binary (prior commit) surfaced 2 findings the
licensed action never reached — it was erroring on license validation
before scanning, so the gate was effectively blind. Both are false
positives: synthetic PEM private-key literals in test/secrets.test.js,
the suite whose whole job is to assert forge redacts secret-shaped
strings. They are committed, so a full-history scan always matches them.

Add test/secrets.test.js to the .gitleaks.toml path allowlist (alongside
the existing bibliography-key exceptions); every other path stays fully
scanned. Verified locally: gitleaks 8.21.2 → 'no leaks found', exit 0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@CodeWithJuber
CodeWithJuber marked this pull request as ready for review July 20, 2026 01:02
@CodeWithJuber
CodeWithJuber merged commit 6186fd7 into master Jul 20, 2026
12 checks passed
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.

2 participants