@recallnet/remark-lint-docs-reachability 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +6 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recallnet/remark-lint-docs-reachability",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Remark plugin that flags markdown docs not reachable from policy roots.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -170,6 +170,8 @@ export function buildReachabilityReport(options = {}) {
170
170
  }
171
171
 
172
172
  export default function remarkLintDocsReachability(options = {}) {
173
+ let cachedReport = null;
174
+
173
175
  return (_tree, file) => {
174
176
  const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
175
177
  const filePath = file.path ? normalizePath(relative(cwd, file.path)) : "";
@@ -178,7 +180,10 @@ export default function remarkLintDocsReachability(options = {}) {
178
180
  return;
179
181
  }
180
182
 
181
- const report = buildReachabilityReport({ cwd, policyPath: options.policyPath });
183
+ // @context decision !high [verified:2026-03-27] — Cache the reachability report for the lifetime of one remark process.
184
+ // remark invokes this rule once per file, but the orphan graph is repo-global. Rebuilding it per file turned 100-doc hooks into dozens of redundant full-doc parses.
185
+ cachedReport ??= buildReachabilityReport({ cwd, policyPath: options.policyPath });
186
+ const report = cachedReport;
182
187
  if (report.orphanDocuments.includes(filePath)) {
183
188
  file.message(`Document is not reachable from policy roots: ${filePath}`, {
184
189
  ruleId: RULE_ID,