@descent-vtt/spec-graph 0.7.0 → 0.9.0

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 (106) hide show
  1. package/CHANGELOG.md +477 -0
  2. package/README.md +109 -17
  3. package/dist/cli.d.ts +2 -2
  4. package/dist/cli.js +38 -19
  5. package/dist/cli.js.map +1 -1
  6. package/dist/directives.d.ts +9 -2
  7. package/dist/directives.js +15 -4
  8. package/dist/directives.js.map +1 -1
  9. package/dist/extract.d.ts +1 -1
  10. package/dist/extract.js +50 -16
  11. package/dist/extract.js.map +1 -1
  12. package/dist/glob.d.ts +44 -44
  13. package/dist/glob.js +152 -116
  14. package/dist/glob.js.map +1 -1
  15. package/dist/identity.d.ts +12 -4
  16. package/dist/identity.js +32 -8
  17. package/dist/identity.js.map +1 -1
  18. package/dist/index.d.ts +3 -3
  19. package/dist/index.js +4 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/lifecycle.js +10 -2
  22. package/dist/lifecycle.js.map +1 -1
  23. package/dist/markdown.d.ts +53 -161
  24. package/dist/markdown.js +42 -864
  25. package/dist/markdown.js.map +1 -1
  26. package/dist/report.d.ts +23 -0
  27. package/dist/report.js +80 -0
  28. package/dist/report.js.map +1 -1
  29. package/dist/rules.js +48 -14
  30. package/dist/rules.js.map +1 -1
  31. package/dist/sections.d.ts +1 -1
  32. package/dist/sections.js +18 -4
  33. package/dist/sections.js.map +1 -1
  34. package/dist/select.d.ts +2 -2
  35. package/dist/select.js +3 -3
  36. package/dist/select.js.map +1 -1
  37. package/dist/source.d.ts +6 -19
  38. package/dist/source.js +4 -70
  39. package/dist/source.js.map +1 -1
  40. package/dist/types.d.ts +23 -3
  41. package/dist/types.js +1 -1
  42. package/dist/types.js.map +1 -1
  43. package/dist/vendor/spec-core/markdown/frontmatter.d.ts +103 -0
  44. package/dist/vendor/spec-core/markdown/frontmatter.js +459 -0
  45. package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -0
  46. package/dist/vendor/spec-core/markdown/headings.d.ts +45 -0
  47. package/dist/vendor/spec-core/markdown/headings.js +199 -0
  48. package/dist/vendor/spec-core/markdown/headings.js.map +1 -0
  49. package/dist/vendor/spec-core/markdown/index.d.ts +5 -0
  50. package/dist/vendor/spec-core/markdown/index.js +4 -0
  51. package/dist/vendor/spec-core/markdown/index.js.map +1 -0
  52. package/dist/vendor/spec-core/markdown/layout.d.ts +39 -0
  53. package/dist/vendor/spec-core/markdown/layout.js +28 -0
  54. package/dist/vendor/spec-core/markdown/layout.js.map +1 -0
  55. package/dist/vendor/spec-core/markdown/links.d.ts +22 -0
  56. package/dist/vendor/spec-core/markdown/links.js +364 -0
  57. package/dist/vendor/spec-core/markdown/links.js.map +1 -0
  58. package/dist/vendor/spec-core/markdown/lists.d.ts +22 -0
  59. package/dist/vendor/spec-core/markdown/lists.js +127 -0
  60. package/dist/vendor/spec-core/markdown/lists.js.map +1 -0
  61. package/dist/vendor/spec-core/markdown/scan.d.ts +36 -0
  62. package/dist/vendor/spec-core/markdown/scan.js +439 -0
  63. package/dist/vendor/spec-core/markdown/scan.js.map +1 -0
  64. package/dist/vendor/spec-core/markdown/syntax.d.ts +75 -0
  65. package/dist/vendor/spec-core/markdown/syntax.js +181 -0
  66. package/dist/vendor/spec-core/markdown/syntax.js.map +1 -0
  67. package/dist/vendor/spec-core/markdown/tables.d.ts +18 -0
  68. package/dist/vendor/spec-core/markdown/tables.js +86 -0
  69. package/dist/vendor/spec-core/markdown/tables.js.map +1 -0
  70. package/dist/vendor/spec-core/markdown/types.d.ts +287 -0
  71. package/dist/vendor/spec-core/markdown/types.js +9 -0
  72. package/dist/vendor/spec-core/markdown/types.js.map +1 -0
  73. package/dist/vendor/spec-core/path/index.d.ts +1 -0
  74. package/dist/vendor/spec-core/path/index.js +2 -0
  75. package/dist/vendor/spec-core/path/index.js.map +1 -0
  76. package/dist/vendor/spec-core/path/posix.d.ts +83 -0
  77. package/dist/vendor/spec-core/path/posix.js +150 -0
  78. package/dist/vendor/spec-core/path/posix.js.map +1 -0
  79. package/dist/vendor/spec-core/pattern/automaton.d.ts +129 -0
  80. package/dist/vendor/spec-core/pattern/automaton.js +340 -0
  81. package/dist/vendor/spec-core/pattern/automaton.js.map +1 -0
  82. package/dist/vendor/spec-core/pattern/charset.d.ts +58 -0
  83. package/dist/vendor/spec-core/pattern/charset.js +116 -0
  84. package/dist/vendor/spec-core/pattern/charset.js.map +1 -0
  85. package/dist/vendor/spec-core/pattern/glob.d.ts +121 -0
  86. package/dist/vendor/spec-core/pattern/glob.js +481 -0
  87. package/dist/vendor/spec-core/pattern/glob.js.map +1 -0
  88. package/dist/vendor/spec-core/pattern/index.d.ts +6 -0
  89. package/dist/vendor/spec-core/pattern/index.js +4 -0
  90. package/dist/vendor/spec-core/pattern/index.js.map +1 -0
  91. package/dist/{regex.d.ts → vendor/spec-core/pattern/regex.d.ts} +20 -29
  92. package/dist/{regex.js → vendor/spec-core/pattern/regex.js} +40 -49
  93. package/dist/vendor/spec-core/pattern/regex.js.map +1 -0
  94. package/dist/vendor/spec-core/text/index.d.ts +2 -0
  95. package/dist/vendor/spec-core/text/index.js +2 -0
  96. package/dist/vendor/spec-core/text/index.js.map +1 -0
  97. package/dist/vendor/spec-core/text/lines.d.ts +72 -0
  98. package/dist/vendor/spec-core/text/lines.js +156 -0
  99. package/dist/vendor/spec-core/text/lines.js.map +1 -0
  100. package/dist/yaml.d.ts +44 -12
  101. package/dist/yaml.js +115 -206
  102. package/dist/yaml.js.map +1 -1
  103. package/package.json +3 -2
  104. package/src/vendor/spec-core/LICENSE +21 -0
  105. package/src/vendor/spec-core/README.md +8 -0
  106. package/dist/regex.js.map +0 -1
package/dist/rules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAA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IACxG,eAAe,EAAE,mFAAmF;IACpG,qBAAqB,EAAE,iEAAiE;IACxF,gBAAgB,EAAE,2EAA2E;CAC9F,CAAC,CAAC","sourcesContent":["/**\n * The built-in diagnostics.\n *\n * Two of them - the two the whole project exists for - are written as selector\n * queries rather than as bespoke traversals. That is not a stunt: it is the\n * proof that the query language is expressive enough to be worth exposing. A\n * team whose convention spec-graph never anticipated can write the equivalent\n * of a built-in rule on the command line.\n *\n * ```text\n * ghost-handover *[openness!=closed][phase!=retired] -delegates-to,blocked-by-> *[receptivity=sealed]\n * stale-premise *[phase!=retired] -depends-on,assumes,amends,blocked-by-> document[phase=retired]\n * ```\n *\n * The rest are not path queries and are not pretended to be: dangling\n * references never became edges, and a cycle is not a fixed-length path.\n *\n * Every rule here obeys one discipline - **report the place a human can fix**.\n * For a supersession that the superseded document never acknowledged, that is\n * the superseded document, not the one that declared the relation.\n */\n\nimport { OBLIGATION_EDGES, type SpecGraph } from './graph.js';\nimport { dirnamePosix, resolveFrom } from './paths.js';\nimport { renderTemplate, type ProjectRule } from './project-rules.js';\nimport { execute, parseQuery, type QuerySpec } from './select.js';\nimport type { ResolvedCorpus } from './resolve.js';\nimport type {\n AnyRuleId,\n DanglingRef,\n Diagnostic,\n DocumentNode,\n Edge,\n ItemNode,\n RelatedLocation,\n RuleId,\n Severity,\n SourceRef,\n SpecNode,\n} from './types.js';\nimport { EDGE_TRAITS } from './types.js';\n\n/* -------------------------------------------------------------------------- */\n/* Configuration */\n/* -------------------------------------------------------------------------- */\n\nexport const DEFAULT_SEVERITIES: Readonly<Record<RuleId, Severity>> = Object.freeze({\n 'ghost-handover': 'error',\n 'stale-premise': 'error',\n 'broken-reference': 'error',\n 'reference-outside-corpus': 'warn',\n 'ambiguous-reference': 'warn',\n 'circular-delegation': 'error',\n 'orphaned-obligation': 'error',\n 'live-supersession': 'error',\n 'unreciprocated-supersession': 'warn',\n 'state-conflict': 'warn',\n 'self-reference': 'info',\n 'unknown-relation-key': 'warn',\n});\n\nexport const RULE_IDS = Object.keys(DEFAULT_SEVERITIES) as readonly RuleId[];\n\n/** One-line descriptions, printed by `spec-graph rules`. */\nexport const RULE_DESCRIPTIONS: Readonly<Record<RuleId, string>> = Object.freeze({\n 'ghost-handover': 'an open obligation is handed to a document that can no longer absorb it',\n 'stale-premise': 'a live document rests on a decision that has been retired or obviated',\n 'broken-reference': 'a citation names a document or anchor that does not exist',\n 'reference-outside-corpus': 'a citation names a real document the include patterns did not reach',\n 'ambiguous-reference': 'a citation matches more than one document',\n 'circular-delegation': 'obligations or supersessions form a cycle, so none of them can ever land',\n 'orphaned-obligation': 'a retired or frozen document still holds open obligations',\n 'live-supersession': 'a document has been superseded but still presents itself as current',\n 'unreciprocated-supersession': 'a retired document does not say what replaced it',\n 'state-conflict': 'an item declares two states that disagree about whether work remains',\n 'self-reference': 'a document delegates to or depends on itself',\n 'unknown-relation-key': 'a front-matter key reads as a relation but declares none',\n});\n\n/**\n * The decision behind each rule.\n *\n * A rule that fires is a claim about somebody's repository, and the reasoning\n * for the claim is written down - in the ADR that decided it, not in a string\n * table. So the table holds a pointer rather than a paraphrase: a second copy\n * of the reasoning would drift from the first, and the first is the one\n * `npm run selfcheck` keeps honest.\n *\n * Printed by `spec-graph rules --explain`, which is how somebody who has just\n * been told their document is inconsistent finds out why anybody decided that.\n */\nexport const RULE_DECISIONS: Readonly<Record<RuleId, string>> = Object.freeze({\n 'ghost-handover': 'docs/adr/0002-lifecycle-lattice.md',\n 'stale-premise': 'docs/adr/0002-lifecycle-lattice.md',\n 'broken-reference': 'docs/adr/0004-reference-resolution.md',\n 'reference-outside-corpus': 'docs/adr/0004-reference-resolution.md',\n 'ambiguous-reference': 'docs/adr/0004-reference-resolution.md',\n 'circular-delegation': 'docs/adr/0005-rules-are-queries.md',\n 'orphaned-obligation': 'docs/adr/0003-item-state-signals.md',\n 'live-supersession': 'docs/adr/0002-lifecycle-lattice.md',\n 'unreciprocated-supersession': 'docs/adr/0006-false-positives-cost-more.md',\n 'state-conflict': 'docs/adr/0003-item-state-signals.md',\n 'self-reference': 'docs/adr/0006-false-positives-cost-more.md',\n 'unknown-relation-key': 'docs/adr/0014-a-relation-is-spelled-both-ways.md',\n});\n\n/**\n * The severity map `--strict` implies, and which rules it actually moved.\n *\n * Strict raises `warn` to `error` and leaves `info` alone. That asymmetry is\n * deliberate: the `info` rules are advisory by nature - a self-link in a table\n * of contents is a formatting quirk - and promoting them would resurrect\n * precisely the false-positive problem ADR-0006 exists to prevent.\n *\n * An explicit `--rule` always wins over strict, so `--strict --rule x=warn`\n * keeps `x` at warn. That is what makes strict usable: a team can turn it on\n * and exempt the one rule their repository disagrees with, rather than choosing\n * between all of it and none of it.\n */\nexport function resolveStrict(\n overrides: Partial<Record<AnyRuleId, Severity>> = {},\n strict = false,\n projectRules: readonly ProjectRule[] = [],\n): { severities: Partial<Record<AnyRuleId, Severity>>; escalated: ReadonlySet<AnyRuleId> } {\n const severities: Partial<Record<AnyRuleId, Severity>> = { ...overrides };\n const escalated = new Set<AnyRuleId>();\n if (!strict) return { severities, escalated };\n\n // A project rule is escalated on the same terms as a built-in, reading its\n // declared severity as the default. Anything else would mean a team could\n // adopt --strict and quietly keep their own conventions advisory.\n const defaults: [AnyRuleId, Severity][] = [\n ...RULE_IDS.map((id): [AnyRuleId, Severity] => [id, DEFAULT_SEVERITIES[id]]),\n ...projectRules.map((rule): [AnyRuleId, Severity] => [rule.id, rule.severity]),\n ];\n\n for (const [id, level] of defaults) {\n if (overrides[id] !== undefined) continue;\n if (level !== 'warn') continue;\n severities[id] = 'error';\n escalated.add(id);\n }\n return { severities, escalated };\n}\n\nexport interface RuleOptions {\n readonly severities?: Partial<Record<AnyRuleId, Severity>> | undefined;\n /** Cap on related locations attached to one finding. */\n readonly maxRelated?: number | undefined;\n /** Conventions the repository wrote for itself. See ADR-0016. */\n readonly projectRules?: readonly ProjectRule[] | undefined;\n}\n\nconst DEFAULT_MAX_RELATED = 8;\n\n/* -------------------------------------------------------------------------- */\n/* Entry point */\n/* -------------------------------------------------------------------------- */\n\n/** Runs every enabled rule and returns findings in report order. */\nexport function runRules(graph: SpecGraph, corpus: ResolvedCorpus, options: RuleOptions = {}): Diagnostic[] {\n const projectRules = options.projectRules ?? [];\n const severities: Partial<Record<AnyRuleId, Severity>> = { ...DEFAULT_SEVERITIES };\n // A project rule's declared severity is its default, and sits in the same\n // table the built-ins do - so `--rule`, `--strict` and `severities` reach it\n // by exactly the machinery they already had.\n for (const rule of projectRules) severities[rule.id] = rule.severity;\n Object.assign(severities, options.severities ?? {});\n const maxRelated = options.maxRelated ?? DEFAULT_MAX_RELATED;\n const out: Diagnostic[] = [];\n\n const emit = (rule: AnyRuleId, build: () => Built): void => {\n const severity = severities[rule];\n // The `undefined` arm is the type system talking, not a case: the table is\n // seeded from every built-in and every project rule, and nothing emits an\n // id that is in neither. Deliberately untested - a mutant that drops it is\n // equivalent, and a test asserting otherwise would be asserting a fiction.\n if (severity === undefined || severity === 'off') return;\n const body = build();\n if (exempt(graph, rule, body.nodes)) return;\n // `target` ahead of the spread: a rule that names one overrides the default,\n // and the eight that have nothing to name say nothing.\n out.push({ rule, severity, target: null, ...body, related: body.related.slice(0, maxRelated) });\n };\n\n // Ghost handovers are reported first and claim their edges, because\n // `blocked-by` is both obligation-transferring and load-bearing: without this,\n // one open question blocked by an archived decision would produce two\n // findings on the same line, for the same defect, with the same fix.\n const claimed = ghostHandovers(graph, emit);\n stalePremises(graph, emit, claimed);\n brokenReferences(corpus, emit);\n circularDelegations(graph, emit);\n orphanedObligations(graph, emit, maxRelated);\n supersessions(graph, emit);\n stateConflicts(graph, emit);\n misreadKeys(corpus, emit);\n selfReferences(graph, emit);\n projectFindings(graph, projectRules, emit);\n\n return sortDiagnostics(out);\n}\n\n/** What a rule returns: the finding, minus what `emit` knows better. */\ntype Built = Omit<Diagnostic, 'rule' | 'severity' | 'target'> & { readonly target?: string };\n\ntype Emit = (rule: AnyRuleId, build: () => Built) => void;\n\n/**\n * Rules about what a document cites, rather than about what it owes.\n *\n * These are the ones a historical record still answers for. A link that goes\n * nowhere is broken whoever wrote it and whenever they wrote it.\n */\nconst REFERENCE_RULES: ReadonlySet<AnyRuleId> = new Set<AnyRuleId>([\n 'broken-reference',\n 'reference-outside-corpus',\n 'ambiguous-reference',\n // A key that declares no relation is a citation that did not happen, which a\n // journal answers for as squarely as a link that goes nowhere. ADR-0011 keeps\n // a record's obligations out of the report, not its references.\n 'unknown-relation-key',\n]);\n\n/**\n * Whether a finding is about history rather than about work.\n *\n * A record reports that something was decided; it does not decide anything. Its\n * open checkboxes are minutes, its delegations are things that were said, and\n * its lifecycle is not a lifecycle. So a record is never the *subject* of a\n * finding about obligations or lifecycle - though it is still a legitimate\n * target of one, because delegating live work into a log is exactly the ghost\n * handover this tool exists to find.\n *\n * Stated once, here, rather than as a guard repeated in eight rules: the\n * exemption is a property of what counts as a finding, not of any one rule, and\n * a rule added later inherits it without having to remember. See ADR-0011.\n */\nfunction exempt(graph: SpecGraph, rule: AnyRuleId, nodes: readonly string[]): boolean {\n if (REFERENCE_RULES.has(rule)) return false;\n const subject = nodes[0];\n if (subject === undefined) return false;\n return graph.owningDocument(subject)?.phase === 'record';\n}\n\n/* -------------------------------------------------------------------------- */\n/* Ghost handovers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The flagship failure mode: an obligation handed into a closed ledger.\n *\n * The source must still be open and must not itself be retired - a retired\n * document delegating to another retired document is history, not a defect,\n * and reporting it would bury the live findings underneath the archive.\n */\nconst GHOST_HANDOVER: QuerySpec = parseQuery(\n '*[openness!=closed][phase!=retired] -delegates-to,blocked-by-> *[receptivity=sealed]',\n);\n\n/** Emits ghost-handover findings and returns the edges they account for. */\nfunction ghostHandovers(graph: SpecGraph, emit: Emit): Set<string> {\n const claimed = new Set<string>();\n for (const match of execute(graph, GHOST_HANDOVER)) {\n const source = match.nodes[0] as SpecNode;\n const target = match.nodes[1] as SpecNode;\n const edge = match.edges[0] as Edge;\n const targetDocument = graph.owningDocument(target.id);\n if (!targetDocument) continue;\n\n const sealed = SEALED_WORD[targetDocument.phase] ?? 'frozen';\n const what = source.kind === 'item' ? 'open obligation' : 'obligation';\n const verb = EDGE_TRAITS[edge.kind].phrase;\n claimed.add(edgeKey(edge));\n\n emit('ghost-handover', () => ({\n message: `${what} ${verb} ${describe(target)}, which is ${sealed}`,\n at: edge.declaredAt,\n nodes: [source.id, target.id],\n related: [\n related(targetDocument.statusAt ?? targetDocument.at, `${targetDocument.id} is ${sealed}${statusSuffix(targetDocument)}`),\n ...(source.kind === 'item' ? [related(source.at, `the obligation: ${source.text}`)] : []),\n ],\n hint: HANDOVER_HINT[targetDocument.phase]?.(targetDocument.id) ?? FROZEN_HINT(targetDocument.id),\n }));\n }\n return claimed;\n}\n\n/** How a sealed target is described in a ghost-handover message. */\nconst SEALED_WORD: Readonly<Partial<Record<string, string>>> = {\n retired: 'retired',\n record: 'a historical record',\n};\n\nconst FROZEN_HINT = (id: string): string =>\n `${id} is frozen and cannot take on new work - open an amendment, or close this here`;\n\n/** What to do about work handed into each kind of sealed document. */\nconst HANDOVER_HINT: Readonly<Partial<Record<string, (id: string) => string>>> = {\n retired: (id) => `nothing will be read from ${id} again - re-home this in a live document, or close it here`,\n record: (id) => `${id} is a log of what happened and will never act - re-home this in a live document`,\n};\n\n/** Identity of a relation, for the hand-off between overlapping rules. */\nfunction edgeKey(edge: Edge): string {\n return `${edge.kind} ${edge.from} ${edge.to}`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Stale premises */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A live document resting on something that stopped being true.\n *\n * Only load-bearing relations count. A \"See also\" pointing at a superseded ADR\n * is ordinary cross-referencing; `assumes` pointing at the same document means\n * somebody is designing around a constraint that was abolished.\n */\nconst STALE_PREMISE_DOCUMENT: QuerySpec = parseQuery(\n '*[phase!=retired] -depends-on,assumes,amends,blocked-by-> document[phase=retired]',\n);\nconst STALE_PREMISE_ITEM: QuerySpec = parseQuery(\n '*[phase!=retired] -depends-on,assumes,amends,blocked-by-> item[state=obviated]',\n);\n\nfunction stalePremises(graph: SpecGraph, emit: Emit, claimed: ReadonlySet<string>): void {\n const seen = new Set<string>();\n for (const spec of [STALE_PREMISE_DOCUMENT, STALE_PREMISE_ITEM]) {\n for (const match of execute(graph, spec)) {\n const source = match.nodes[0] as SpecNode;\n const target = match.nodes[1] as SpecNode;\n const edge = match.edges[0] as Edge;\n // Already reported as a ghost handover, which says the same thing in the\n // terms the reader needs.\n if (claimed.has(edgeKey(edge))) continue;\n const key = `${source.id}>${target.id}>${edge.kind}`;\n if (seen.has(key)) continue;\n seen.add(key);\n\n const targetDocument = graph.owningDocument(target.id);\n const because =\n target.kind === 'item'\n ? 'that question was obviated - its premise no longer holds'\n : `${target.id} is retired${statusSuffix(targetDocument)}`;\n\n emit('stale-premise', () => ({\n message: `${describe(source)} ${EDGE_TRAITS[edge.kind].phrase} ${describe(target)}, which no longer holds`,\n at: edge.declaredAt,\n nodes: [source.id, target.id],\n // Point at the status line when there is one: that is the sentence that\n // makes the premise stale, and repeating the document's first line\n // underneath it adds nothing.\n related: [related(target.kind === 'document' ? (targetDocument?.statusAt ?? target.at) : target.at, because)],\n hint: `re-check this dependency: the constraint it assumes may have been lifted when ${target.kind === 'item' ? 'the question closed' : `${target.id} was retired`}`,\n }));\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Reference integrity */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Keys that read as relations and declared none.\n *\n * The only rule here that is about the text rather than about the graph, and it\n * earns the place by what its absence costs: the finding is that an edge the\n * author wrote down is *not* in the graph, and a missing edge is invisible in a\n * report that says everything is consistent. Nothing else would ever mention it.\n */\nfunction misreadKeys(corpus: ResolvedCorpus, emit: Emit): void {\n for (const misread of corpus.misreadKeys) {\n emit('unknown-relation-key', () => ({\n message: `\"${misread.key}\" declares no relation`,\n at: misread.at,\n nodes: [misread.from],\n // The key, so two misspellings in one document are two findings rather\n // than one with a count of two - `nodes` names the document and nothing\n // else here names which key.\n target: misread.key,\n related: [],\n hint: `spell it ${misread.suggestion}, or move it out of front matter if it is not a relation`,\n }));\n }\n}\n\nfunction brokenReferences(corpus: ResolvedCorpus, emit: Emit): void {\n for (const ref of corpus.dangling) {\n if (ref.reason === 'ambiguous') {\n emit('ambiguous-reference', () => ({\n message: `\"${ref.target}\" matches ${ref.candidates.length} documents`,\n at: ref.declaredAt,\n nodes: [ref.from],\n target: ref.target,\n related: [],\n hint: `disambiguate it - candidates: ${ref.candidates.join(', ')}`,\n }));\n continue;\n }\n\n // A link to a file that exists but was not included is a configuration\n // problem: the graph is not broken, the corpus is just incomplete. Reporting\n // it as an error means a repository whose specifications live somewhere the\n // default patterns miss fails on its first run, for something the user has\n // not done wrong.\n const rule: RuleId = ref.reason === 'not-a-spec' ? 'reference-outside-corpus' : 'broken-reference';\n\n emit(rule, () => ({\n message: brokenMessage(ref),\n at: ref.declaredAt,\n nodes: [ref.from],\n target: ref.target,\n related: [],\n hint: brokenHint(ref),\n }));\n }\n}\n\nfunction brokenMessage(ref: DanglingRef): string {\n switch (ref.reason) {\n case 'unknown-anchor':\n return `\"${ref.target}\" points at an anchor that does not exist`;\n case 'not-a-spec':\n return `\"${ref.target}\" resolves to a file that is not a specification`;\n default:\n return `\"${ref.target}\" does not resolve to any document`;\n }\n}\n\nfunction brokenHint(ref: DanglingRef): string {\n if (ref.candidates.length > 0) return `did you mean ${ref.candidates.slice(0, 3).join(', ')}?`;\n // A wiki link carries no path, only a name, so whether it means a document at\n // all is a repository convention. Naming the flag here is what keeps that a\n // one-run discovery rather than a support question.\n if (ref.raw.startsWith('[[') && ref.reason === 'unknown-target') {\n return `fix the identifier, or - if [[...]] tags a concept here - exclude it: --ignore-ref \"${suggestReferenceGlob(ref.target)}\"`;\n }\n switch (ref.reason) {\n case 'unknown-anchor':\n return 'check the heading or item id it is meant to address';\n case 'not-a-spec':\n // Name the pattern that would include it: \"widen your patterns\" is advice\n // the reader then has to translate, and this is the translation.\n return `include it, for example: spec-graph \"${suggestPattern(ref)}\"`;\n default:\n return 'fix the identifier, or add the document it names';\n }\n}\n\n/**\n * A glob covering the family of concept tags a target belongs to.\n *\n * `trap 55` suggests `trap *` rather than `trap 55`, because these tags come in\n * numbered series and excluding them one at a time is not a fix anybody would\n * accept. A target with no trailing number is suggested verbatim.\n */\nfunction suggestReferenceGlob(target: string): string {\n const trimmed = target.trim();\n const series = /^(.*?)[\\s._-]*\\d+$/.exec(trimmed);\n const stem = series?.[1]?.trim();\n return stem !== undefined && stem.length > 0 ? `${stem} *` : trimmed;\n}\n\n/**\n * The narrowest include pattern that would reach a target the corpus missed.\n *\n * Built from the *resolved* repository-relative path, not the link as written:\n * `../notes.md` cited from `docs/adr/` needs `docs/**\\/*.md`, and suggesting\n * `../**\\/*.md` would be worse than saying nothing.\n */\nfunction suggestPattern(ref: DanglingRef): string {\n const withoutAnchor = (ref.target.split('#')[0] ?? ref.target).trim();\n const resolved = resolveFrom(ref.declaredAt.file, withoutAnchor);\n const directory = dirnamePosix(resolved);\n return directory.length > 0 ? `${directory}/**/*.md` : '**/*.md';\n}\n\n/* -------------------------------------------------------------------------- */\n/* Cycles */\n/* -------------------------------------------------------------------------- */\n\nfunction circularDelegations(graph: SpecGraph, emit: Emit): void {\n const kinds = [...OBLIGATION_EDGES, 'supersedes' as const];\n // Projected onto documents, so a question handed back and forth between two\n // of them is found even though each delegation runs item -> document and the\n // raw graph therefore contains no cycle at all.\n for (const component of graph.cycles(kinds, { byDocument: true })) {\n const members = component\n .map((id) => graph.document(id))\n .filter((node): node is DocumentNode => node !== undefined);\n if (members.length < 2) continue;\n // A cycle is a set, not a subject, so the exemption at `emit` cannot see it.\n // One record in the loop means the loop is partly a report of what was once\n // said, and nothing in it is owed by anybody.\n if (members.some((member) => member.phase === 'record')) continue;\n\n const edges = cycleEdges(graph, component, kinds);\n const onlySupersession = edges.length > 0 && edges.every((edge) => edge.kind === 'supersedes');\n const head = members[0] as DocumentNode;\n\n emit('circular-delegation', () => ({\n message: onlySupersession\n ? `supersession cycle across ${members.length} documents`\n : `delegation cycle across ${members.length} documents: nothing in it can ever land`,\n at: edges[0]?.declaredAt ?? head.at,\n nodes: component,\n related: edges.map((edge) => related(edge.declaredAt, `${edge.from} ${EDGE_TRAITS[edge.kind].phrase} ${edge.to}`)),\n hint: 'break the loop: one of these must own the work outright, or be closed',\n }));\n }\n}\n\n/**\n * The relations that keep a component strongly connected.\n *\n * Membership is by owning document, because the component is a projection: the\n * edge that closes the loop is usually written on an item, and that is the line\n * the report has to point at.\n */\nfunction cycleEdges(graph: SpecGraph, component: readonly string[], kinds: readonly Edge['kind'][]): Edge[] {\n const inside = new Set(component);\n const owner = (id: string): string => graph.owningDocument(id)?.id ?? id;\n const out: Edge[] = [];\n for (const edge of graph.edges) {\n if (!kinds.includes(edge.kind)) continue;\n const from = owner(edge.from);\n const to = owner(edge.to);\n if (from !== to && inside.has(from) && inside.has(to)) out.push(edge);\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Orphaned obligations */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The black hole itself: a document nobody reads any more, still holding work.\n *\n * Reported once per document rather than once per item. Five findings that all\n * say \"this archived ADR has open questions\" is five times the noise and none\n * of the extra information.\n */\nfunction orphanedObligations(graph: SpecGraph, emit: Emit, maxRelated: number): void {\n for (const document of graph.documents) {\n if (document.phase !== 'retired' && document.phase !== 'frozen') continue;\n const open = graph.itemsOf(document.id).filter((item) => item.openness !== 'closed');\n if (open.length === 0) continue;\n\n const sealed = document.phase === 'retired' ? 'retired' : 'frozen';\n emit('orphaned-obligation', () => ({\n message: `${sealed} document still holds ${open.length} open ${open.length === 1 ? 'obligation' : 'obligations'}`,\n at: document.statusAt ?? document.at,\n nodes: [document.id, ...open.map((item) => item.id)],\n related: open\n .slice(0, maxRelated)\n .map((item) => related(item.at, `${item.disposition}: ${item.text}`)),\n hint: `move each one to a live document or close it - as it stands, ${open.length === 1 ? 'it disappears' : 'they disappear'} with ${document.id}`,\n }));\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Supersession consistency */\n/* -------------------------------------------------------------------------- */\n\nfunction supersessions(graph: SpecGraph, emit: Emit): void {\n for (const edge of graph.edges) {\n if (edge.kind !== 'supersedes' || edge.reflexive) continue;\n const superseded = graph.document(edge.to);\n const superseding = graph.document(edge.from);\n if (!superseded || !superseding) continue;\n // A record narrating \"ADR-0005 replaced ADR-0001\" is reporting a\n // supersession, not declaring one. Both hints below ask somebody to edit\n // the document that made the claim, and a log is the one document nobody\n // can edit - it says what was true when it was written. The exemption at\n // `emit` cannot see this: the subject here is the *other* document.\n if (superseding.phase === 'record') continue;\n\n if (superseded.phase !== 'retired' && superseded.phase !== 'unknown') {\n emit('live-supersession', () => ({\n // The fix belongs in the superseded document, so that is where the\n // finding points - not at the document that made the claim.\n message: `${superseded.id} is superseded by ${superseding.id} but still reads as ${superseded.phase}`,\n at: superseded.statusAt ?? superseded.at,\n nodes: [superseded.id, superseding.id],\n related: [related(edge.declaredAt, `the supersession is declared here`)],\n hint: `mark ${superseded.id} as superseded, or drop the claim in ${superseding.id}`,\n }));\n continue;\n }\n\n if (superseded.phase === 'retired' && !edge.declaredIn.includes(superseded.path)) {\n emit('unreciprocated-supersession', () => ({\n message: `${superseded.id} is retired but never says that ${superseding.id} replaced it`,\n at: superseded.statusAt ?? superseded.at,\n nodes: [superseded.id, superseding.id],\n related: [related(edge.declaredAt, `only ${superseding.id} records the relationship`)],\n hint: `add \"superseded-by: ${superseding.id}\" to ${superseded.path} so a reader who lands there is redirected`,\n }));\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Item state */\n/* -------------------------------------------------------------------------- */\n\nfunction stateConflicts(graph: SpecGraph, emit: Emit): void {\n for (const item of graph.items) {\n if (item.conflicts.length === 0) continue;\n emit('state-conflict', () => ({\n message: `item reads as ${item.disposition} but also carries ${describeSignals(item)}`,\n at: item.evidence.at,\n nodes: [item.id],\n related: item.conflicts.map((signal) =>\n related(signal.at, `${signal.source} says ${signal.disposition}${signal.raw ? `: ${signal.raw}` : ''}`),\n ),\n hint: `make the two agree - spec-graph is treating it as ${item.openness}`,\n }));\n }\n}\n\nfunction describeSignals(item: ItemNode): string {\n const parts = item.conflicts.map((signal) => `a ${signal.source} saying ${signal.disposition}`);\n return parts.length === 1 ? (parts[0] as string) : `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Self references */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A document that delegates to, or depends on, itself.\n *\n * Almost always a copied link that was never repointed. Informational, because\n * a self-link in a table of contents is harmless - but a *delegation* to self\n * means an obligation that looks handed off and was not.\n */\nfunction selfReferences(graph: SpecGraph, emit: Emit): void {\n for (const edge of graph.edges) {\n if (!edge.reflexive || edge.kind === 'contains') continue;\n const traits = EDGE_TRAITS[edge.kind];\n if (!traits.transfersObligation && !traits.loadBearing) continue;\n const node = graph.node(edge.from);\n if (!node) continue;\n\n emit('self-reference', () => ({\n message: `${describe(node)} ${traits.phrase} itself`,\n at: edge.declaredAt,\n nodes: [edge.from],\n related: [],\n hint: traits.transfersObligation\n ? 'this obligation looks delegated but never left - point it at another document, or own it here'\n : 'a document cannot depend on itself - repoint or remove the reference',\n }));\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Project rules */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The conventions a repository wrote for itself.\n *\n * Run last, and through the same `emit` as everything else, which is the whole\n * point: a project rule inherits the record exemption, the severity table,\n * `--strict`, the related-location cap, the sort order and the baseline without\n * any of them being taught about it. See ADR-0016.\n */\nfunction projectFindings(graph: SpecGraph, rules: readonly ProjectRule[], emit: Emit): void {\n for (const rule of rules) {\n const seen = new Set<string>();\n for (const spec of rule.queries) {\n for (const match of execute(graph, spec)) {\n const nodes = match.nodes.map((node) => node.id);\n // Two selectors in one rule are a union, so a path both of them find is\n // one finding. The alternative is a repository being told twice about a\n // convention it broke once.\n const key = nodes.join('>');\n if (seen.has(key)) continue;\n seen.add(key);\n\n const head = match.nodes[0] as SpecNode;\n emit(rule.id, () => ({\n message: renderTemplate(rule.message, match, graph),\n // The line that declares the relation, not the document it points at:\n // that is where a human goes to change the answer. A rule with no\n // steps has no relation, so it points at the node it selected.\n at: match.edges[0]?.declaredAt ?? head.at,\n nodes,\n related: match.edges\n .slice(1)\n .map((edge) => related(edge.declaredAt, `${edge.from} ${EDGE_TRAITS[edge.kind].phrase} ${edge.to}`)),\n hint: renderTemplate(rule.hint, match, graph),\n }));\n }\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------------- */\n\nfunction describe(node: SpecNode): string {\n return node.kind === 'document' ? node.id : `${node.document} \"${truncate(node.text, 48)}\"`;\n}\n\nfunction truncate(text: string, limit: number): string {\n return text.length <= limit ? text : `${text.slice(0, limit - 3)}...`;\n}\n\nfunction statusSuffix(document: DocumentNode | undefined): string {\n return document?.rawStatus ? ` (\"${document.rawStatus}\")` : '';\n}\n\nfunction related(at: SourceRef, note: string): RelatedLocation {\n return { at, note };\n}\n\nconst SEVERITY_ORDER: Readonly<Record<Exclude<Severity, 'off'>, number>> = { error: 0, warn: 1, info: 2 };\n\n/**\n * Total ordering, so two runs on the same corpus produce byte-identical output.\n *\n * CI output that reorders between runs cannot be diffed, and output that cannot\n * be diffed stops being read.\n */\nexport function sortDiagnostics(diagnostics: readonly Diagnostic[]): Diagnostic[] {\n return [...diagnostics].sort((a, b) => {\n const bySeverity = SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity];\n if (bySeverity !== 0) return bySeverity;\n if (a.at.file !== b.at.file) return a.at.file < b.at.file ? -1 : 1;\n if (a.at.span.start.line !== b.at.span.start.line) return a.at.span.start.line - b.at.span.start.line;\n if (a.at.span.start.column !== b.at.span.start.column) return a.at.span.start.column - b.at.span.start.column;\n if (a.rule !== b.rule) return a.rule < b.rule ? -1 : 1;\n return a.message < b.message ? -1 : a.message > b.message ? 1 : 0;\n });\n}\n\n/** The selector equivalent of a rule, for `spec-graph rules --explain`. */\nexport const RULE_QUERIES: Readonly<Partial<Record<RuleId, string>>> = Object.freeze({\n 'ghost-handover': '*[openness!=closed][phase!=retired] -delegates-to,blocked-by-> *[receptivity=sealed]',\n 'stale-premise': '*[phase!=retired] -depends-on,assumes,amends,blocked-by-> document[phase=retired]',\n 'orphaned-obligation': 'document[receptivity=sealed] -contains-> item[openness!=closed]',\n 'self-reference': 'see --format json; reflexive edges are excluded from traversal by default',\n});\n"]}
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,cAAc,EAAoB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;AAelE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,MAAM,CAAC,MAAM,kBAAkB,GAAuC,MAAM,CAAC,MAAM,CAAC;IAClF,gBAAgB,EAAE,OAAO;IACzB,eAAe,EAAE,OAAO;IACxB,kBAAkB,EAAE,OAAO;IAC3B,0BAA0B,EAAE,MAAM;IAClC,qBAAqB,EAAE,MAAM;IAC7B,qBAAqB,EAAE,OAAO;IAC9B,qBAAqB,EAAE,OAAO;IAC9B,mBAAmB,EAAE,OAAO;IAC5B,6BAA6B,EAAE,MAAM;IACrC,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,MAAM;IACxB,sBAAsB,EAAE,MAAM;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAsB,C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AO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAA8C,MAAM,CAAC,MAAM,CAAC;IACnF,gBAAgB,EAAE,sFAAsF;IACxG,eAAe,EAAE,mFAAmF;IACpG,qBAAqB,EAAE,iEAAiE;IACxF,gBAAgB,EAAE,2EAA2E;CAC9F,CAAC,CAAC","sourcesContent":["/**\n * The built-in diagnostics.\n *\n * Two of them - the two the whole project exists for - are written as selector\n * queries rather than as bespoke traversals. That is not a stunt: it is the\n * proof that the query language is expressive enough to be worth exposing. A\n * team whose convention spec-graph never anticipated can write the equivalent\n * of a built-in rule on the command line.\n *\n * ```text\n * ghost-handover *[openness!=closed][phase!=retired] -delegates-to,blocked-by-> *[receptivity=sealed]\n * stale-premise *[phase!=retired] -depends-on,assumes,amends,blocked-by-> document[phase=retired]\n * ```\n *\n * The rest are not path queries and are not pretended to be: dangling\n * references never became edges, and a cycle is not a fixed-length path.\n *\n * Every rule here obeys one discipline - **report the place a human can fix**.\n * For a supersession that the superseded document never acknowledged, that is\n * the superseded document, not the one that declared the relation.\n */\n\nimport { OBLIGATION_EDGES, type SpecGraph } from './graph.js';\nimport { dirnamePosix, resolveFrom } from './paths.js';\nimport { renderTemplate, type ProjectRule } from './project-rules.js';\nimport { execute, parseQuery, type QuerySpec } from './select.js';\nimport type { ResolvedCorpus } from './resolve.js';\nimport type {\n AnyRuleId,\n DanglingRef,\n Diagnostic,\n DocumentNode,\n Edge,\n ItemNode,\n RelatedLocation,\n RuleId,\n Severity,\n SourceRef,\n SpecNode,\n} from './types.js';\nimport { EDGE_TRAITS } from './types.js';\n\n/* -------------------------------------------------------------------------- */\n/* Configuration */\n/* -------------------------------------------------------------------------- */\n\nexport const DEFAULT_SEVERITIES: Readonly<Record<RuleId, Severity>> = Object.freeze({\n 'ghost-handover': 'error',\n 'stale-premise': 'error',\n 'broken-reference': 'error',\n 'reference-outside-corpus': 'warn',\n 'ambiguous-reference': 'warn',\n 'circular-delegation': 'error',\n 'orphaned-obligation': 'error',\n 'live-supersession': 'error',\n 'unreciprocated-supersession': 'warn',\n 'state-conflict': 'warn',\n 'self-reference': 'info',\n 'unknown-relation-key': 'warn',\n});\n\nexport const RULE_IDS = Object.keys(DEFAULT_SEVERITIES) as readonly RuleId[];\n\n/** One-line descriptions, printed by `spec-graph rules`. */\nexport const RULE_DESCRIPTIONS: Readonly<Record<RuleId, string>> = Object.freeze({\n 'ghost-handover': 'an open obligation is handed to a document that can no longer absorb it',\n 'stale-premise': 'a live document rests on a decision that has been retired or obviated',\n 'broken-reference': 'a citation names a document or anchor that does not exist',\n 'reference-outside-corpus': 'a citation names a real document the include patterns did not reach',\n 'ambiguous-reference': 'a citation matches more than one document',\n 'circular-delegation': 'obligations or supersessions form a cycle, so none of them can ever land',\n 'orphaned-obligation': 'a retired or frozen document still holds open obligations',\n 'live-supersession': 'a document has been superseded but still presents itself as current',\n 'unreciprocated-supersession': 'a retired or archived document does not say what replaced it',\n 'state-conflict': 'an item declares two states that disagree about whether work remains',\n 'self-reference': 'a document delegates to or depends on itself',\n 'unknown-relation-key': 'a front-matter key reads as a relation but declares none',\n});\n\n/**\n * The decision behind each rule.\n *\n * A rule that fires is a claim about somebody's repository, and the reasoning\n * for the claim is written down - in the ADR that decided it, not in a string\n * table. So the table holds a pointer rather than a paraphrase: a second copy\n * of the reasoning would drift from the first, and the first is the one\n * `npm run selfcheck` keeps honest.\n *\n * Printed by `spec-graph rules --explain`, which is how somebody who has just\n * been told their document is inconsistent finds out why anybody decided that.\n */\nexport const RULE_DECISIONS: Readonly<Record<RuleId, string>> = Object.freeze({\n 'ghost-handover': 'docs/adr/0002-lifecycle-lattice.md',\n 'stale-premise': 'docs/adr/0002-lifecycle-lattice.md',\n 'broken-reference': 'docs/adr/0004-reference-resolution.md',\n 'reference-outside-corpus': 'docs/adr/0004-reference-resolution.md',\n 'ambiguous-reference': 'docs/adr/0004-reference-resolution.md',\n 'circular-delegation': 'docs/adr/0005-rules-are-queries.md',\n 'orphaned-obligation': 'docs/adr/0003-item-state-signals.md',\n 'live-supersession': 'docs/adr/0002-lifecycle-lattice.md',\n 'unreciprocated-supersession': 'docs/adr/0006-false-positives-cost-more.md',\n 'state-conflict': 'docs/adr/0003-item-state-signals.md',\n 'self-reference': 'docs/adr/0006-false-positives-cost-more.md',\n 'unknown-relation-key': 'docs/adr/0014-a-relation-is-spelled-both-ways.md',\n});\n\n/**\n * The severity map `--strict` implies, and which rules it actually moved.\n *\n * Strict raises `warn` to `error` and leaves `info` alone. That asymmetry is\n * deliberate: the `info` rules are advisory by nature - a self-link in a table\n * of contents is a formatting quirk - and promoting them would resurrect\n * precisely the false-positive problem ADR-0006 exists to prevent.\n *\n * An explicit `--rule` always wins over strict, so `--strict --rule x=warn`\n * keeps `x` at warn. That is what makes strict usable: a team can turn it on\n * and exempt the one rule their repository disagrees with, rather than choosing\n * between all of it and none of it.\n */\nexport function resolveStrict(\n overrides: Partial<Record<AnyRuleId, Severity>> = {},\n strict = false,\n projectRules: readonly ProjectRule[] = [],\n): { severities: Partial<Record<AnyRuleId, Severity>>; escalated: ReadonlySet<AnyRuleId> } {\n const severities: Partial<Record<AnyRuleId, Severity>> = { ...overrides };\n const escalated = new Set<AnyRuleId>();\n if (!strict) return { severities, escalated };\n\n // A project rule is escalated on the same terms as a built-in, reading its\n // declared severity as the default. Anything else would mean a team could\n // adopt --strict and quietly keep their own conventions advisory.\n const defaults: [AnyRuleId, Severity][] = [\n ...RULE_IDS.map((id): [AnyRuleId, Severity] => [id, DEFAULT_SEVERITIES[id]]),\n ...projectRules.map((rule): [AnyRuleId, Severity] => [rule.id, rule.severity]),\n ];\n\n for (const [id, level] of defaults) {\n if (overrides[id] !== undefined) continue;\n if (level !== 'warn') continue;\n severities[id] = 'error';\n escalated.add(id);\n }\n return { severities, escalated };\n}\n\nexport interface RuleOptions {\n readonly severities?: Partial<Record<AnyRuleId, Severity>> | undefined;\n /** Cap on related locations attached to one finding. */\n readonly maxRelated?: number | undefined;\n /** Conventions the repository wrote for itself. See ADR-0016. */\n readonly projectRules?: readonly ProjectRule[] | undefined;\n}\n\nconst DEFAULT_MAX_RELATED = 8;\n\n/* -------------------------------------------------------------------------- */\n/* Entry point */\n/* -------------------------------------------------------------------------- */\n\n/** Runs every enabled rule and returns findings in report order. */\nexport function runRules(graph: SpecGraph, corpus: ResolvedCorpus, options: RuleOptions = {}): Diagnostic[] {\n const projectRules = options.projectRules ?? [];\n const severities: Partial<Record<AnyRuleId, Severity>> = { ...DEFAULT_SEVERITIES };\n // A project rule's declared severity is its default, and sits in the same\n // table the built-ins do - so `--rule`, `--strict` and `severities` reach it\n // by exactly the machinery they already had.\n for (const rule of projectRules) severities[rule.id] = rule.severity;\n Object.assign(severities, options.severities ?? {});\n const maxRelated = options.maxRelated ?? DEFAULT_MAX_RELATED;\n const out: Diagnostic[] = [];\n\n const emit = (rule: AnyRuleId, build: () => Built): void => {\n const severity = severities[rule];\n // The `undefined` arm is the type system talking, not a case: the table is\n // seeded from every built-in and every project rule, and nothing emits an\n // id that is in neither. Deliberately untested - a mutant that drops it is\n // equivalent, and a test asserting otherwise would be asserting a fiction.\n if (severity === undefined || severity === 'off') return;\n const body = build();\n if (exempt(graph, rule, body.nodes)) return;\n // `target` ahead of the spread: a rule that names one overrides the default,\n // and the eight that have nothing to name say nothing.\n out.push({ rule, severity, target: null, ...body, related: body.related.slice(0, maxRelated) });\n };\n\n // Ghost handovers are reported first and claim their edges, because\n // `blocked-by` is both obligation-transferring and load-bearing: without this,\n // one open question blocked by an archived decision would produce two\n // findings on the same line, for the same defect, with the same fix.\n const claimed = ghostHandovers(graph, emit);\n stalePremises(graph, emit, claimed);\n brokenReferences(corpus, emit);\n circularDelegations(graph, emit);\n orphanedObligations(graph, emit, maxRelated);\n supersessions(graph, emit);\n stateConflicts(graph, emit);\n misreadKeys(corpus, emit);\n selfReferences(graph, emit);\n projectFindings(graph, projectRules, emit);\n\n return sortDiagnostics(out);\n}\n\n/** What a rule returns: the finding, minus what `emit` knows better. */\ntype Built = Omit<Diagnostic, 'rule' | 'severity' | 'target'> & { readonly target?: string };\n\ntype Emit = (rule: AnyRuleId, build: () => Built) => void;\n\n/**\n * Rules about what a document cites, rather than about what it owes.\n *\n * These are the ones a historical record still answers for. A link that goes\n * nowhere is broken whoever wrote it and whenever they wrote it.\n */\nconst REFERENCE_RULES: ReadonlySet<AnyRuleId> = new Set<AnyRuleId>([\n 'broken-reference',\n 'reference-outside-corpus',\n 'ambiguous-reference',\n // A key that declares no relation is a citation that did not happen, which a\n // journal answers for as squarely as a link that goes nowhere. ADR-0011 keeps\n // a record's obligations out of the report, not its references.\n 'unknown-relation-key',\n]);\n\n/**\n * Whether a finding is about history rather than about work.\n *\n * A record reports that something was decided; it does not decide anything. Its\n * open checkboxes are minutes, its delegations are things that were said, and\n * its lifecycle is not a lifecycle. So a record is never the *subject* of a\n * finding about obligations or lifecycle - though it is still a legitimate\n * target of one, because delegating live work into a log is exactly the ghost\n * handover this tool exists to find.\n *\n * Stated once, here, rather than as a guard repeated in eight rules: the\n * exemption is a property of what counts as a finding, not of any one rule, and\n * a rule added later inherits it without having to remember. See ADR-0011.\n *\n * All of that is a log's, declared by `historyPatterns` or `@spec-history`. A\n * document that is a record because it says `archived` is a closed round of\n * work, and nothing about it makes its claims history: a supersession it\n * declares, a cycle it closes and a link to itself are still somebody's to\n * correct. What it owes and what it rests on are history, as they were when\n * `archived` read as retired, and that is all it is exempt from.\n */\nfunction exempt(graph: SpecGraph, rule: AnyRuleId, nodes: readonly string[]): boolean {\n if (REFERENCE_RULES.has(rule)) return false;\n const subject = nodes[0];\n if (subject === undefined) return false;\n const owner = graph.owningDocument(subject);\n if (owner?.phase !== 'record') return false;\n return owner.history || CLOSED_ROUND_RULES.has(rule);\n}\n\n/**\n * The rules an archived document is exempt from as their subject: work it\n * hands on and premises it rests on. Their queries left a retired source out,\n * and `archived` was retired until it became a record.\n */\nconst CLOSED_ROUND_RULES: ReadonlySet<AnyRuleId> = new Set<AnyRuleId>(['ghost-handover', 'stale-premise']);\n\n/* -------------------------------------------------------------------------- */\n/* Ghost handovers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The flagship failure mode: an obligation handed into a closed ledger.\n *\n * The source must still be open and must not itself be retired - a retired\n * document delegating to another retired document is history, not a defect,\n * and reporting it would bury the live findings underneath the archive.\n */\nconst GHOST_HANDOVER: QuerySpec = parseQuery(\n '*[openness!=closed][phase!=retired] -delegates-to,blocked-by-> *[receptivity=sealed]',\n);\n\n/** Emits ghost-handover findings and returns the edges they account for. */\nfunction ghostHandovers(graph: SpecGraph, emit: Emit): Set<string> {\n const claimed = new Set<string>();\n for (const match of execute(graph, GHOST_HANDOVER)) {\n const source = match.nodes[0] as SpecNode;\n const target = match.nodes[1] as SpecNode;\n const edge = match.edges[0] as Edge;\n const targetDocument = graph.owningDocument(target.id);\n if (!targetDocument) continue;\n\n const seal = sealOf(targetDocument);\n const sealed = SEALED_WORD[seal] ?? 'frozen';\n const what = source.kind === 'item' ? 'open obligation' : 'obligation';\n const verb = EDGE_TRAITS[edge.kind].phrase;\n claimed.add(edgeKey(edge));\n\n emit('ghost-handover', () => ({\n message: `${what} ${verb} ${describe(target)}, which is ${sealed}`,\n at: edge.declaredAt,\n nodes: [source.id, target.id],\n related: [\n related(targetDocument.statusAt ?? targetDocument.at, `${targetDocument.id} is ${sealed}${statusSuffix(targetDocument)}`),\n ...(source.kind === 'item' ? [related(source.at, `the obligation: ${source.text}`)] : []),\n ],\n hint: HANDOVER_HINT[seal]?.(targetDocument.id) ?? FROZEN_HINT(targetDocument.id),\n }));\n }\n return claimed;\n}\n\n/** Which kind of sealed document this is: its phase, or `archived` for a closed round. */\nfunction sealOf(document: DocumentNode): string {\n return document.phase === 'record' && !document.history ? 'archived' : document.phase;\n}\n\n/** How a sealed target is described in a ghost-handover message. */\nconst SEALED_WORD: Readonly<Partial<Record<string, string>>> = {\n retired: 'retired',\n record: 'a historical record',\n archived: 'archived',\n};\n\nconst FROZEN_HINT = (id: string): string =>\n `${id} is frozen and cannot take on new work - open an amendment, or close this here`;\n\n/** What to do about work handed into each kind of sealed document. */\nconst HANDOVER_HINT: Readonly<Partial<Record<string, (id: string) => string>>> = {\n retired: (id) => `nothing will be read from ${id} again - re-home this in a live document, or close it here`,\n record: (id) => `${id} is a log of what happened and will never act - re-home this in a live document`,\n archived: (id) => `${id} is a closed round of work and will never act - re-home this in a live document`,\n};\n\n/** Identity of a relation, for the hand-off between overlapping rules. */\nfunction edgeKey(edge: Edge): string {\n return `${edge.kind} ${edge.from} ${edge.to}`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Stale premises */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A live document resting on something that stopped being true.\n *\n * Only load-bearing relations count. A \"See also\" pointing at a superseded ADR\n * is ordinary cross-referencing; `assumes` pointing at the same document means\n * somebody is designing around a constraint that was abolished.\n */\nconst STALE_PREMISE_DOCUMENT: QuerySpec = parseQuery(\n '*[phase!=retired] -depends-on,assumes,amends,blocked-by-> document[phase=retired]',\n);\nconst STALE_PREMISE_ITEM: QuerySpec = parseQuery(\n '*[phase!=retired] -depends-on,assumes,amends,blocked-by-> item[state=obviated]',\n);\n\nfunction stalePremises(graph: SpecGraph, emit: Emit, claimed: ReadonlySet<string>): void {\n const seen = new Set<string>();\n for (const spec of [STALE_PREMISE_DOCUMENT, STALE_PREMISE_ITEM]) {\n for (const match of execute(graph, spec)) {\n const source = match.nodes[0] as SpecNode;\n const target = match.nodes[1] as SpecNode;\n const edge = match.edges[0] as Edge;\n // Already reported as a ghost handover, which says the same thing in the\n // terms the reader needs.\n if (claimed.has(edgeKey(edge))) continue;\n const key = `${source.id}>${target.id}>${edge.kind}`;\n if (seen.has(key)) continue;\n seen.add(key);\n\n const targetDocument = graph.owningDocument(target.id);\n const because =\n target.kind === 'item'\n ? 'that question was obviated - its premise no longer holds'\n : `${target.id} is retired${statusSuffix(targetDocument)}`;\n\n emit('stale-premise', () => ({\n message: `${describe(source)} ${EDGE_TRAITS[edge.kind].phrase} ${describe(target)}, which no longer holds`,\n at: edge.declaredAt,\n nodes: [source.id, target.id],\n // Point at the status line when there is one: that is the sentence that\n // makes the premise stale, and repeating the document's first line\n // underneath it adds nothing.\n related: [related(target.kind === 'document' ? (targetDocument?.statusAt ?? target.at) : target.at, because)],\n hint: `re-check this dependency: the constraint it assumes may have been lifted when ${target.kind === 'item' ? 'the question closed' : `${target.id} was retired`}`,\n }));\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Reference integrity */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Keys that read as relations and declared none.\n *\n * The only rule here that is about the text rather than about the graph, and it\n * earns the place by what its absence costs: the finding is that an edge the\n * author wrote down is *not* in the graph, and a missing edge is invisible in a\n * report that says everything is consistent. Nothing else would ever mention it.\n */\nfunction misreadKeys(corpus: ResolvedCorpus, emit: Emit): void {\n for (const misread of corpus.misreadKeys) {\n emit('unknown-relation-key', () => ({\n message: `\"${misread.key}\" declares no relation`,\n at: misread.at,\n nodes: [misread.from],\n // The key, so two misspellings in one document are two findings rather\n // than one with a count of two - `nodes` names the document and nothing\n // else here names which key.\n target: misread.key,\n related: [],\n hint: `spell it ${misread.suggestion}, or move it out of front matter if it is not a relation`,\n }));\n }\n}\n\nfunction brokenReferences(corpus: ResolvedCorpus, emit: Emit): void {\n for (const ref of corpus.dangling) {\n if (ref.reason === 'ambiguous') {\n emit('ambiguous-reference', () => ({\n message: `\"${ref.target}\" matches ${ref.candidates.length} documents`,\n at: ref.declaredAt,\n nodes: [ref.from],\n target: ref.target,\n related: [],\n hint: `disambiguate it - candidates: ${ref.candidates.join(', ')}`,\n }));\n continue;\n }\n\n // A link to a file that exists but was not included is a configuration\n // problem: the graph is not broken, the corpus is just incomplete. Reporting\n // it as an error means a repository whose specifications live somewhere the\n // default patterns miss fails on its first run, for something the user has\n // not done wrong.\n const rule: RuleId = ref.reason === 'not-a-spec' ? 'reference-outside-corpus' : 'broken-reference';\n\n emit(rule, () => ({\n message: brokenMessage(ref),\n at: ref.declaredAt,\n nodes: [ref.from],\n target: ref.target,\n related: [],\n hint: brokenHint(ref),\n }));\n }\n}\n\nfunction brokenMessage(ref: DanglingRef): string {\n switch (ref.reason) {\n case 'unknown-anchor':\n return `\"${ref.target}\" points at an anchor that does not exist`;\n case 'not-a-spec':\n return `\"${ref.target}\" resolves to a file that is not a specification`;\n default:\n return `\"${ref.target}\" does not resolve to any document`;\n }\n}\n\nfunction brokenHint(ref: DanglingRef): string {\n if (ref.candidates.length > 0) return `did you mean ${ref.candidates.slice(0, 3).join(', ')}?`;\n // A wiki link carries no path, only a name, so whether it means a document at\n // all is a repository convention. Naming the flag here is what keeps that a\n // one-run discovery rather than a support question.\n if (ref.raw.startsWith('[[') && ref.reason === 'unknown-target') {\n return `fix the identifier, or - if [[...]] tags a concept here - exclude it: --ignore-ref \"${suggestReferenceGlob(ref.target)}\"`;\n }\n switch (ref.reason) {\n case 'unknown-anchor':\n return 'check the heading or item id it is meant to address';\n case 'not-a-spec':\n // Name the pattern that would include it: \"widen your patterns\" is advice\n // the reader then has to translate, and this is the translation.\n return `include it, for example: spec-graph \"${suggestPattern(ref)}\"`;\n default:\n return 'fix the identifier, or add the document it names';\n }\n}\n\n/**\n * A glob covering the family of concept tags a target belongs to.\n *\n * `trap 55` suggests `trap *` rather than `trap 55`, because these tags come in\n * numbered series and excluding them one at a time is not a fix anybody would\n * accept. A target with no trailing number is suggested verbatim.\n */\nfunction suggestReferenceGlob(target: string): string {\n const trimmed = target.trim();\n const series = /^(.*?)[\\s._-]*\\d+$/.exec(trimmed);\n const stem = series?.[1]?.trim();\n return stem !== undefined && stem.length > 0 ? `${stem} *` : trimmed;\n}\n\n/**\n * The narrowest include pattern that would reach a target the corpus missed.\n *\n * Built from the *resolved* repository-relative path, not the link as written:\n * `../notes.md` cited from `docs/adr/` needs `docs/**\\/*.md`, and suggesting\n * `../**\\/*.md` would be worse than saying nothing.\n */\nfunction suggestPattern(ref: DanglingRef): string {\n const withoutAnchor = (ref.target.split('#')[0] ?? ref.target).trim();\n const resolved = resolveFrom(ref.declaredAt.file, withoutAnchor);\n const directory = dirnamePosix(resolved);\n return directory.length > 0 ? `${directory}/**/*.md` : '**/*.md';\n}\n\n/* -------------------------------------------------------------------------- */\n/* Cycles */\n/* -------------------------------------------------------------------------- */\n\nfunction circularDelegations(graph: SpecGraph, emit: Emit): void {\n const kinds = [...OBLIGATION_EDGES, 'supersedes' as const];\n // Projected onto documents, so a question handed back and forth between two\n // of them is found even though each delegation runs item -> document and the\n // raw graph therefore contains no cycle at all.\n for (const component of graph.cycles(kinds, { byDocument: true })) {\n const members = component\n .map((id) => graph.document(id))\n .filter((node): node is DocumentNode => node !== undefined);\n if (members.length < 2) continue;\n // A cycle is a set, not a subject, so the exemption at `emit` cannot see it.\n // One log in the loop means the loop is partly a report of what was once\n // said, and nothing in it is owed by anybody. An archived document in it\n // is not a log: its half of the loop is a claim it still makes.\n if (members.some((member) => member.history)) continue;\n\n const edges = cycleEdges(graph, component, kinds);\n const onlySupersession = edges.length > 0 && edges.every((edge) => edge.kind === 'supersedes');\n const head = members[0] as DocumentNode;\n\n emit('circular-delegation', () => ({\n message: onlySupersession\n ? `supersession cycle across ${members.length} documents`\n : `delegation cycle across ${members.length} documents: nothing in it can ever land`,\n at: edges[0]?.declaredAt ?? head.at,\n nodes: component,\n related: edges.map((edge) => related(edge.declaredAt, `${edge.from} ${EDGE_TRAITS[edge.kind].phrase} ${edge.to}`)),\n hint: 'break the loop: one of these must own the work outright, or be closed',\n }));\n }\n}\n\n/**\n * The relations that keep a component strongly connected.\n *\n * Membership is by owning document, because the component is a projection: the\n * edge that closes the loop is usually written on an item, and that is the line\n * the report has to point at.\n */\nfunction cycleEdges(graph: SpecGraph, component: readonly string[], kinds: readonly Edge['kind'][]): Edge[] {\n const inside = new Set(component);\n const owner = (id: string): string => graph.owningDocument(id)?.id ?? id;\n const out: Edge[] = [];\n for (const edge of graph.edges) {\n if (!kinds.includes(edge.kind)) continue;\n const from = owner(edge.from);\n const to = owner(edge.to);\n if (from !== to && inside.has(from) && inside.has(to)) out.push(edge);\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Orphaned obligations */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The black hole itself: a document nobody reads any more, still holding work.\n *\n * Reported once per document rather than once per item. Five findings that all\n * say \"this archived ADR has open questions\" is five times the noise and none\n * of the extra information.\n */\nfunction orphanedObligations(graph: SpecGraph, emit: Emit, maxRelated: number): void {\n for (const document of graph.documents) {\n if (document.phase !== 'retired' && document.phase !== 'frozen') continue;\n const open = graph.itemsOf(document.id).filter((item) => item.openness !== 'closed');\n if (open.length === 0) continue;\n\n const sealed = document.phase === 'retired' ? 'retired' : 'frozen';\n emit('orphaned-obligation', () => ({\n message: `${sealed} document still holds ${open.length} open ${open.length === 1 ? 'obligation' : 'obligations'}`,\n at: document.statusAt ?? document.at,\n nodes: [document.id, ...open.map((item) => item.id)],\n related: open\n .slice(0, maxRelated)\n .map((item) => related(item.at, `${item.disposition}: ${item.text}`)),\n hint: `move each one to a live document or close it - as it stands, ${open.length === 1 ? 'it disappears' : 'they disappear'} with ${document.id}`,\n }));\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Supersession consistency */\n/* -------------------------------------------------------------------------- */\n\nfunction supersessions(graph: SpecGraph, emit: Emit): void {\n for (const edge of graph.edges) {\n if (edge.kind !== 'supersedes' || edge.reflexive) continue;\n const superseded = graph.document(edge.to);\n const superseding = graph.document(edge.from);\n if (!superseded || !superseding) continue;\n // A log narrating \"ADR-0005 replaced ADR-0001\" is reporting a\n // supersession, not declaring one. Both hints below ask somebody to edit\n // the document that made the claim, and a log is the one document nobody\n // can edit - it says what was true when it was written. The exemption at\n // `emit` cannot see this: the subject here is the *other* document. An\n // archived brief that says it supersedes another is declaring it.\n if (superseding.history) continue;\n\n // Closed either way: an archived document is not live, and like a retired\n // one it can fail to say what replaced it. A log in its place is the\n // subject, and exempt at `emit`.\n const archived = superseded.phase === 'record';\n if (superseded.phase !== 'retired' && !archived && superseded.phase !== 'unknown') {\n emit('live-supersession', () => ({\n // The fix belongs in the superseded document, so that is where the\n // finding points - not at the document that made the claim.\n message: `${superseded.id} is superseded by ${superseding.id} but still reads as ${superseded.phase}`,\n at: superseded.statusAt ?? superseded.at,\n nodes: [superseded.id, superseding.id],\n related: [related(edge.declaredAt, `the supersession is declared here`)],\n hint: `mark ${superseded.id} as superseded, or drop the claim in ${superseding.id}`,\n }));\n continue;\n }\n\n if ((superseded.phase === 'retired' || archived) && !edge.declaredIn.includes(superseded.path)) {\n emit('unreciprocated-supersession', () => ({\n message: `${superseded.id} is ${archived ? 'archived' : 'retired'} but never says that ${superseding.id} replaced it`,\n at: superseded.statusAt ?? superseded.at,\n nodes: [superseded.id, superseding.id],\n related: [related(edge.declaredAt, `only ${superseding.id} records the relationship`)],\n // Archived and superseded is retired, so that status also tells what\n // rests on the document that it no longer holds, which a\n // `superseded-by` key beside `archived` would not.\n hint: archived\n ? `make the status of ${superseded.path} \"archived, superseded by ${superseding.id}\" so a reader who lands there is redirected`\n : `add \"superseded-by: ${superseding.id}\" to ${superseded.path} so a reader who lands there is redirected`,\n }));\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Item state */\n/* -------------------------------------------------------------------------- */\n\nfunction stateConflicts(graph: SpecGraph, emit: Emit): void {\n for (const item of graph.items) {\n if (item.conflicts.length === 0) continue;\n emit('state-conflict', () => ({\n message: `item reads as ${item.disposition} but also carries ${describeSignals(item)}`,\n at: item.evidence.at,\n nodes: [item.id],\n related: item.conflicts.map((signal) =>\n related(signal.at, `${signal.source} says ${signal.disposition}${signal.raw ? `: ${signal.raw}` : ''}`),\n ),\n hint: `make the two agree - spec-graph is treating it as ${item.openness}`,\n }));\n }\n}\n\nfunction describeSignals(item: ItemNode): string {\n const parts = item.conflicts.map((signal) => `a ${signal.source} saying ${signal.disposition}`);\n return parts.length === 1 ? (parts[0] as string) : `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Self references */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A document that delegates to, or depends on, itself.\n *\n * Almost always a copied link that was never repointed. Informational, because\n * a self-link in a table of contents is harmless - but a *delegation* to self\n * means an obligation that looks handed off and was not.\n */\nfunction selfReferences(graph: SpecGraph, emit: Emit): void {\n for (const edge of graph.edges) {\n if (!edge.reflexive || edge.kind === 'contains') continue;\n const traits = EDGE_TRAITS[edge.kind];\n if (!traits.transfersObligation && !traits.loadBearing) continue;\n const node = graph.node(edge.from);\n if (!node) continue;\n\n emit('self-reference', () => ({\n message: `${describe(node)} ${traits.phrase} itself`,\n at: edge.declaredAt,\n nodes: [edge.from],\n related: [],\n hint: traits.transfersObligation\n ? 'this obligation looks delegated but never left - point it at another document, or own it here'\n : 'a document cannot depend on itself - repoint or remove the reference',\n }));\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Project rules */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The conventions a repository wrote for itself.\n *\n * Run last, and through the same `emit` as everything else, which is the whole\n * point: a project rule inherits the record exemption, the severity table,\n * `--strict`, the related-location cap, the sort order and the baseline without\n * any of them being taught about it. See ADR-0016.\n */\nfunction projectFindings(graph: SpecGraph, rules: readonly ProjectRule[], emit: Emit): void {\n for (const rule of rules) {\n const seen = new Set<string>();\n for (const spec of rule.queries) {\n for (const match of execute(graph, spec)) {\n const nodes = match.nodes.map((node) => node.id);\n // Two selectors in one rule are a union, so a path both of them find is\n // one finding. The alternative is a repository being told twice about a\n // convention it broke once.\n const key = nodes.join('>');\n if (seen.has(key)) continue;\n seen.add(key);\n\n const head = match.nodes[0] as SpecNode;\n emit(rule.id, () => ({\n message: renderTemplate(rule.message, match, graph),\n // The line that declares the relation, not the document it points at:\n // that is where a human goes to change the answer. A rule with no\n // steps has no relation, so it points at the node it selected.\n at: match.edges[0]?.declaredAt ?? head.at,\n nodes,\n related: match.edges\n .slice(1)\n .map((edge) => related(edge.declaredAt, `${edge.from} ${EDGE_TRAITS[edge.kind].phrase} ${edge.to}`)),\n hint: renderTemplate(rule.hint, match, graph),\n }));\n }\n }\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------------- */\n\nfunction describe(node: SpecNode): string {\n return node.kind === 'document' ? node.id : `${node.document} \"${truncate(node.text, 48)}\"`;\n}\n\nfunction truncate(text: string, limit: number): string {\n return text.length <= limit ? text : `${text.slice(0, limit - 3)}...`;\n}\n\nfunction statusSuffix(document: DocumentNode | undefined): string {\n return document?.rawStatus ? ` (\"${document.rawStatus}\")` : '';\n}\n\nfunction related(at: SourceRef, note: string): RelatedLocation {\n return { at, note };\n}\n\nconst SEVERITY_ORDER: Readonly<Record<Exclude<Severity, 'off'>, number>> = { error: 0, warn: 1, info: 2 };\n\n/**\n * Total ordering, so two runs on the same corpus produce byte-identical output.\n *\n * CI output that reorders between runs cannot be diffed, and output that cannot\n * be diffed stops being read.\n */\nexport function sortDiagnostics(diagnostics: readonly Diagnostic[]): Diagnostic[] {\n return [...diagnostics].sort((a, b) => {\n const bySeverity = SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity];\n if (bySeverity !== 0) return bySeverity;\n if (a.at.file !== b.at.file) return a.at.file < b.at.file ? -1 : 1;\n if (a.at.span.start.line !== b.at.span.start.line) return a.at.span.start.line - b.at.span.start.line;\n if (a.at.span.start.column !== b.at.span.start.column) return a.at.span.start.column - b.at.span.start.column;\n if (a.rule !== b.rule) return a.rule < b.rule ? -1 : 1;\n return a.message < b.message ? -1 : a.message > b.message ? 1 : 0;\n });\n}\n\n/** The selector equivalent of a rule, for `spec-graph rules --explain`. */\nexport const RULE_QUERIES: Readonly<Partial<Record<RuleId, string>>> = Object.freeze({\n 'ghost-handover': '*[openness!=closed][phase!=retired] -delegates-to,blocked-by-> *[receptivity=sealed]',\n 'stale-premise': '*[phase!=retired] -depends-on,assumes,amends,blocked-by-> document[phase=retired]',\n 'orphaned-obligation': 'document[receptivity=sealed] -contains-> item[openness!=closed]',\n 'self-reference': 'see --format json; reflexive edges are excluded from traversal by default',\n});\n"]}
@@ -21,7 +21,7 @@
21
21
  * neither declares a status.
22
22
  */
23
23
  import { type Directive } from './directives.js';
24
- import type { Heading, Range, ScannedDocument, TableRow } from './markdown.js';
24
+ import { type Heading, type Range, type ScannedDocument, type TableRow } from './markdown.js';
25
25
  import type { EdgeKind } from './types.js';
26
26
  /** A status as written, and where it was written. */
27
27
  export interface RegionStatus {
package/dist/sections.js CHANGED
@@ -21,8 +21,9 @@
21
21
  * neither declares a status.
22
22
  */
23
23
  import { attr } from './directives.js';
24
- import { isExternal } from './identity.js';
24
+ import { isExternal, parsePrefixedRef } from './identity.js';
25
25
  import { isStatusHeading } from './lifecycle.js';
26
+ import { isMarkdownLine, isOnlyComment, } from './markdown.js';
26
27
  /** Column headers that name the row's identifier. */
27
28
  const ID_COLUMNS = /^(?:id|ids|ref|reference|key|no|number|#|adr|rfc|kep|oi|decision|spec|specification)$/;
28
29
  /** Column headers that name the row's status. */
@@ -89,6 +90,7 @@ fileId) {
89
90
  };
90
91
  const regions = [];
91
92
  const folded = fold(fileId);
93
+ const fileRef = parsePrefixedRef(fileId);
92
94
  for (let i = 0; i < scanned.headings.length; i += 1) {
93
95
  const heading = scanned.headings[i];
94
96
  const declaredId = HEADING_ID.exec(heading.text)?.[1];
@@ -97,6 +99,15 @@ fileId) {
97
99
  // The file's own title heading names the file, not a region inside it.
98
100
  if (fold(declaredId) === folded)
99
101
  continue;
102
+ // Padding is not part of an identity anywhere else - `ADR-40`, `ADR-040`
103
+ // and `ADR-0040` all resolve to one document - so a heading that spells the
104
+ // number differently from the file name is still that file's own title.
105
+ // Comparing the text alone made `# ADR-040` inside `0040-enforce.md` a
106
+ // region within the file it names: one decision, two nodes, and a citation
107
+ // arriving at whichever spelling it happened to use.
108
+ const ref = parsePrefixedRef(declaredId);
109
+ if (ref !== null && fileRef !== null && ref.family === fileRef.family && ref.number === fileRef.number)
110
+ continue;
100
111
  const end = regionEnd(scanned, i);
101
112
  const directive = directiveIn(directives, heading.end, end);
102
113
  const status = readRegionStatus(scanned, heading.end, end);
@@ -299,7 +310,10 @@ function readLabelledStatus(scanned, start, end) {
299
310
  continue;
300
311
  if (line.contentStart >= end)
301
312
  break;
302
- if (line.code || line.blank)
313
+ // A template's commented-out `Status: proposed | accepted` is a hint to
314
+ // whoever fills it in, not a status the region declares, and one in code or
315
+ // a <pre> block is an example.
316
+ if (!isMarkdownLine(line) || line.blank || line.comment)
303
317
  continue;
304
318
  const match = INLINE_STATUS.exec(line.content);
305
319
  if (!match)
@@ -324,9 +338,9 @@ function readHeadedStatus(scanned, start, end) {
324
338
  continue;
325
339
  if (line.contentStart >= end)
326
340
  break;
327
- if (line.blank)
341
+ if (line.blank || isOnlyComment(scanned, line))
328
342
  continue;
329
- if (line.code)
343
+ if (!isMarkdownLine(line))
330
344
  return null;
331
345
  const trimmed = line.content.trim();
332
346
  if (trimmed.startsWith('#'))
@@ -1 +1 @@
1
- {"version":3,"file":"sections.js","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAgDjD,qDAAqD;AACrD,MAAM,UAAU,GAAG,uFAAuF,CAAC;AAE3G,iDAAiD;AACjD,MAAM,cAAc,GAAG,0CAA0C,CAAC;AAElE,gDAAgD;AAChD,MAAM,aAAa,GAAG,6DAA6D,CAAC;AAEpF;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAoE;IACxF,YAAY,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,Q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,MAAM,CAAC,GAAG;YAAE,SAAS;QAC5D,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;YAAE,IAAI,GAAG,MAAM,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Specification regions: the part of a file that one specification occupies.\n *\n * `spec-graph` began by assuming one specification per file, because that is\n * how MADR, KEPs and Rust RFCs are laid out. Plenty of organisations do not\n * work that way. A register, a whitepaper or a living architecture document\n * holds dozens of decisions in one file, each with its own identifier, its own\n * status and its own dependencies - and to an engine that binds a document to a\n * file, every one of them is invisible.\n *\n * The fix is small once stated: **a specification is a region of a file, not a\n * file.** A file yields at least one region - itself - and may yield more.\n * Everything downstream is unchanged, because a region produces exactly the\n * same `DocumentNode` a whole file produced.\n *\n * What this module decides is where those regions begin and end, and it is\n * deliberately hard to convince. A heading has to carry an identifier *and* the\n * section has to declare a status before it counts. One signal is not enough:\n * `## Q3 2026 Roadmap` parses as family `Q`, number 3, and `## v1.2.0` in a\n * changelog parses as family `v`, number 1. Neither is a specification, and\n * neither declares a status.\n */\n\nimport { attr, type Directive } from './directives.js';\nimport { isExternal } from './identity.js';\nimport { isStatusHeading } from './lifecycle.js';\nimport type { Heading, Range, ScannedDocument, Table, TableCell, TableRow } from './markdown.js';\nimport type { EdgeKind } from './types.js';\n\n/** A status as written, and where it was written. */\nexport interface RegionStatus {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\n/** A relation read from a table column rather than from prose. */\nexport interface TableRelation {\n readonly kind: EdgeKind;\n readonly inverted: boolean;\n readonly target: string;\n readonly start: number;\n readonly end: number;\n /** The column header that gave it its meaning, for the diagnostic. */\n readonly column: string;\n}\n\nexport interface SpecificationRegion {\n /** The heading that opens the region, or `null` for the file or a table row. */\n readonly heading: Heading | null;\n /** The table row that is the region, when it is one. */\n readonly row: TableRow | null;\n /** Offset the region starts at. */\n readonly start: number;\n /** Offset just past the region. */\n readonly end: number;\n /** Identifier read from the heading or the identifier column. */\n readonly declaredId: string | null;\n readonly title: string | null;\n readonly status: RegionStatus | null;\n /** A `@spec-node` directive inside the region, when there is one. */\n readonly directive: Directive | null;\n /** Relations declared by column, empty for a heading region. */\n readonly relations: readonly TableRelation[];\n /**\n * Cells whose content is already accounted for as a typed relation.\n *\n * Prose scanning skips these, so a link in a `Depends on` column produces one\n * typed edge rather than a typed edge and a neutral citation beside it.\n */\n readonly claimed: readonly Range[];\n}\n\n/** Column headers that name the row's identifier. */\nconst ID_COLUMNS = /^(?:id|ids|ref|reference|key|no|number|#|adr|rfc|kep|oi|decision|spec|specification)$/;\n\n/** Column headers that name the row's status. */\nconst STATUS_COLUMNS = /^(?:status|state|stage|lifecycle|phase)$/;\n\n/** Column headers that name the row's title. */\nconst TITLE_COLUMNS = /^(?:title|name|summary|description|subject|decision|topic)$/;\n\n/**\n * Column headers that declare a relation.\n *\n * Written the way a header is written - \"Depends on\", \"Superseded by\" - rather\n * than the way a front-matter key is, because that is what an author types at\n * the top of a column.\n */\nconst RELATION_COLUMNS: Readonly<Record<string, { kind: EdgeKind; inverted: boolean }>> = {\n 'depends on': { kind: 'depends-on', inverted: false },\n 'depends-on': { kind: 'depends-on', inverted: false },\n dependencies: { kind: 'depends-on', inverted: false },\n requires: { kind: 'depends-on', inverted: false },\n supersedes: { kind: 'supersedes', inverted: false },\n replaces: { kind: 'supersedes', inverted: false },\n 'superseded by': { kind: 'supersedes', inverted: true },\n 'replaced by': { kind: 'supersedes', inverted: true },\n 'blocked by': { kind: 'blocked-by', inverted: false },\n 'blocked on': { kind: 'blocked-by', inverted: false },\n blocks: { kind: 'blocked-by', inverted: true },\n amends: { kind: 'amends', inverted: false },\n extends: { kind: 'amends', inverted: false },\n assumes: { kind: 'assumes', inverted: false },\n 'delegates to': { kind: 'delegates-to', inverted: false },\n 'delegated to': { kind: 'delegates-to', inverted: false },\n 'tracked in': { kind: 'delegates-to', inverted: false },\n related: { kind: 'relates-to', inverted: false },\n 'related to': { kind: 'relates-to', inverted: false },\n 'see also': { kind: 'relates-to', inverted: false },\n references: { kind: 'references', inverted: false },\n};\n\n/** Cell values that mean \"nothing here\". */\nconst MARKDOWN_LINK = /!?\\[([^\\]]*)\\]\\(([^)]*)\\)/g;\nconst EMPTY_CELL = /^(?:-+|—|–|n\\/?a|none|nil|tbd|\\.|_+)$/i;\n\n/** `## ADR-0007: Sharding` - an identifier at the very start of a heading. */\nconst HEADING_ID = /^\\s*([A-Za-z]{1,15}[\\s._-]?\\d{1,6})\\b/;\n\n/** `**Status:** Accepted`, `Status: Accepted`, `*Status* : Accepted`. */\nconst INLINE_STATUS = /^[ \\t>]*[*_]{0,2}\\s*status\\s*[*_]{0,2}\\s*[::]\\s*(.+?)\\s*$/im;\n\n/**\n * Finds every specification in a file.\n *\n * The first entry is always the file itself, so a caller that ignores the rest\n * behaves exactly as it did before regions existed.\n */\nexport function findSpecificationRegions(\n scanned: ScannedDocument,\n directives: readonly Directive[],\n /** The file's own identifier, so its title heading is not read as a sub-region. */\n fileId: string,\n): SpecificationRegion[] {\n const whole: SpecificationRegion = {\n heading: null,\n row: null,\n start: scanned.bodyStart,\n end: scanned.text.length,\n declaredId: null,\n title: null,\n status: null,\n directive: null,\n relations: [],\n claimed: [],\n };\n\n const regions: SpecificationRegion[] = [];\n const folded = fold(fileId);\n\n for (let i = 0; i < scanned.headings.length; i += 1) {\n const heading = scanned.headings[i] as Heading;\n const declaredId = HEADING_ID.exec(heading.text)?.[1];\n if (declaredId === undefined) continue;\n // The file's own title heading names the file, not a region inside it.\n if (fold(declaredId) === folded) continue;\n\n const end = regionEnd(scanned, i);\n const directive = directiveIn(directives, heading.end, end);\n const status = readRegionStatus(scanned, heading.end, end);\n\n // Two independent signals are required. An identifier alone matches\n // `## Q3 2026 Roadmap` and `## v1.2.0`; a status alone matches every\n // ordinary `## Status` section in a normal ADR.\n if (status === null && directive === null) continue;\n\n regions.push({\n heading,\n row: null,\n start: heading.start,\n end,\n declaredId: (directive ? attr(directive, 'id')?.value : null) ?? declaredId,\n title: heading.text,\n status,\n directive,\n relations: [],\n claimed: [],\n });\n }\n\n return [whole, ...regions, ...findTableRegions(scanned)];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Registers kept as tables */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Reads a table whose columns describe specifications.\n *\n * A table qualifies when it has an identifier column *and* either a status\n * column or at least one relation column. Two signals again, for the same\n * reason: a table of identifiers and prose is a citation list, and promoting\n * every row of it to a specification would invent a register nobody wrote.\n */\nexport function findTableRegions(scanned: ScannedDocument): SpecificationRegion[] {\n const out: SpecificationRegion[] = [];\n\n for (const table of scanned.tables) {\n const schema = readSchema(table);\n if (schema === null) continue;\n\n for (const row of table.rows) {\n const idCell = row.cells[schema.id];\n if (!idCell) continue;\n const id = flatten(idCell.text);\n if (id.length === 0 || EMPTY_CELL.test(id)) continue;\n\n const statusCell = schema.status === null ? undefined : row.cells[schema.status];\n const statusText = statusCell ? flatten(statusCell.text) : '';\n const status: RegionStatus | null =\n statusCell && statusText.length > 0 && !EMPTY_CELL.test(statusText)\n ? { text: statusText, start: statusCell.start, end: statusCell.end }\n : null;\n\n const titleCell = schema.title === null ? undefined : row.cells[schema.title];\n const title = titleCell ? flatten(titleCell.text) : null;\n\n const relations: TableRelation[] = [];\n const claimed: Range[] = [{ start: idCell.start, end: idCell.end }];\n if (statusCell) claimed.push({ start: statusCell.start, end: statusCell.end });\n\n for (const [column, relation] of schema.relations) {\n const cell = row.cells[column];\n if (!cell) continue;\n claimed.push({ start: cell.start, end: cell.end });\n for (const target of splitTargets(cell)) {\n relations.push({\n kind: relation.kind,\n inverted: relation.inverted,\n target: target.text,\n start: target.start,\n end: target.end,\n column: (table.headers[column] as TableCell).text,\n });\n }\n }\n\n out.push({\n heading: null,\n row,\n start: row.start,\n end: row.end,\n declaredId: id,\n title: title !== null && title.length > 0 ? title : null,\n status,\n directive: null,\n relations,\n claimed,\n });\n }\n }\n\n return out;\n}\n\ninterface TableSchema {\n readonly id: number;\n readonly status: number | null;\n readonly title: number | null;\n readonly relations: readonly (readonly [number, { kind: EdgeKind; inverted: boolean }])[];\n}\n\nfunction readSchema(table: Table): TableSchema | null {\n let id: number | null = null;\n let status: number | null = null;\n let title: number | null = null;\n const relations: [number, { kind: EdgeKind; inverted: boolean }][] = [];\n\n table.headers.forEach((header, column) => {\n const name = normaliseHeader(header.text);\n if (id === null && ID_COLUMNS.test(name)) {\n id = column;\n return;\n }\n if (status === null && STATUS_COLUMNS.test(name)) {\n status = column;\n return;\n }\n const relation = RELATION_COLUMNS[name];\n if (relation) {\n relations.push([column, relation]);\n return;\n }\n if (title === null && TITLE_COLUMNS.test(name)) title = column;\n });\n\n if (id === null) return null;\n if (status === null && relations.length === 0) return null;\n return { id, status, title, relations };\n}\n\nfunction normaliseHeader(text: string): string {\n return flatten(text)\n .toLowerCase()\n .replace(/[^a-z0-9/#\\s-]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Splits a cell into the identifiers it lists, keeping each one's offset. */\nfunction splitTargets(cell: TableCell): { text: string; start: number; end: number }[] {\n const out: { text: string; start: number; end: number }[] = [];\n // Every target is reported at the cell's span. A cell is short, and an offset\n // recovered back through a flattening is an offset that can drift.\n const push = (raw: string): void => {\n const target = raw.trim();\n if (target.length === 0 || EMPTY_CELL.test(target)) return;\n out.push({ text: target, start: cell.start, end: cell.end });\n };\n const prose = (segment: string): void => {\n for (const piece of flatten(segment).split(/\\s*(?:[,;]|\\band\\b)\\s*/i)) push(piece);\n };\n\n // Links are taken out whole rather than flattened with everything else: a\n // path would otherwise be cut in half by its own slash, and its underscores\n // stripped as emphasis.\n // A fresh matcher per cell. `prose` calls `flatten`, which drives the shared\n // pattern; one /g regex advanced from inside its own scan resets its cursor\n // and never terminates.\n const links = new RegExp(MARKDOWN_LINK.source, 'g');\n let last = 0;\n for (let match = links.exec(cell.text); match !== null; match = links.exec(cell.text)) {\n prose(cell.text.slice(last, match.index));\n const destination = (match[2] ?? '').trim();\n // A link states where its target lives; its label states only what the\n // target is called (ADR-0008). In a column the author has already typed,\n // the destination is the claim - `[see](adr/0050.md)` is a dependency on\n // that file, not on the word \"see\". An external or in-page destination\n // names no document here, so the label is what is left to try.\n const local = destination.length > 0 && !destination.startsWith('#') && !isExternal(destination);\n push(local ? destination : (match[1] ?? ''));\n last = match.index + match[0].length;\n }\n prose(cell.text.slice(last));\n return out;\n}\n\n/** Reduces a cell to its text: link labels rather than link syntax. */\nfunction flatten(text: string): string {\n return text\n .replace(MARKDOWN_LINK, '$1')\n .replace(/\\[\\[(?:[^\\]|]*\\|)?([^\\]]*)\\]\\]/g, '$1')\n .replace(/[`*_~]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Where a heading's section ends: the next heading at the same level or above. */\nfunction regionEnd(scanned: ScannedDocument, index: number): number {\n const heading = scanned.headings[index] as Heading;\n for (let i = index + 1; i < scanned.headings.length; i += 1) {\n const next = scanned.headings[i] as Heading;\n if (next.level <= heading.level) return next.start;\n }\n return scanned.text.length;\n}\n\n/**\n * Reads a status declared inside a region.\n *\n * Two forms, both common: a labelled line (`**Status:** Accepted`) and a\n * sub-heading (`### Status` with the value beneath it). Only the region is\n * searched, so one decision in a register cannot inherit its neighbour's.\n */\nexport function readRegionStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n const labelled = readLabelledStatus(scanned, start, end);\n if (labelled) return labelled;\n return readHeadedStatus(scanned, start, end);\n}\n\nfunction readLabelledStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n for (const line of scanned.lines) {\n if (line.contentStart < start) continue;\n if (line.contentStart >= end) break;\n if (line.code || line.blank) continue;\n const match = INLINE_STATUS.exec(line.content);\n if (!match) continue;\n // `**Status:** Accepted` closes its emphasis *after* the colon, so the\n // closing marker lands in the captured value. Strip it rather than let it\n // reach the report as part of the status a reader is shown.\n const value = (match[1] as string).replace(/^[*_\\s]+/, '').replace(/[*_\\s]+$/, '');\n if (value.length === 0) continue;\n const offset = line.contentStart + line.content.lastIndexOf(value);\n return { text: value, start: offset, end: offset + value.length };\n }\n return null;\n}\n\nfunction readHeadedStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n const heading = scanned.headings.find((h) => h.start >= start && h.start < end && isStatusHeading(h.text));\n if (!heading) return null;\n\n for (const line of scanned.lines) {\n if (line.line <= heading.line) continue;\n if (line.contentStart >= end) break;\n if (line.blank) continue;\n if (line.code) return null;\n const trimmed = line.content.trim();\n if (trimmed.startsWith('#')) return null;\n // A bullet list under Status is a status history; the first entry is current.\n const cleaned = trimmed.replace(/^[-*+]\\s+/, '');\n const offset = line.contentStart + line.content.indexOf(trimmed) + (trimmed.length - cleaned.length);\n return { text: cleaned, start: offset, end: offset + cleaned.length };\n }\n return null;\n}\n\n/** The last `@spec-node` directive inside a region. */\nfunction directiveIn(directives: readonly Directive[], start: number, end: number): Directive | null {\n let found: Directive | null = null;\n for (const directive of directives) {\n if (directive.name !== 'spec-node') continue;\n if (directive.start < start || directive.end > end) continue;\n if (found === null || directive.start > found.start) found = directive;\n }\n return found;\n}\n\n/** Case- and separator-insensitive comparison, matching reference folding. */\nfunction fold(value: string): string {\n return value.trim().toLowerCase().replace(/[\\s._-]+/g, '');\n}\n\n/** The region containing an offset, innermost first. `null` when only the file does. */\nexport function regionAt(regions: readonly SpecificationRegion[], offset: number): SpecificationRegion | null {\n let best: SpecificationRegion | null = null;\n for (const region of regions) {\n // The whole-file region owns nothing in particular; it is the fallback.\n if (region.heading === null && region.row === null) continue;\n if (offset < region.start || offset >= region.end) continue;\n if (best === null || region.start > best.start) best = region;\n }\n return best;\n}\n"]}
1
+ {"version":3,"file":"sections.js","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,M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E,KAAa,EAAE,GAAW;IAC/E,IAAI,KAAK,GAAqB,IAAI,CAAC;IACnC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,SAAS,CAAC,IAAI,KAAK,WAAW;YAAE,SAAS;QAC7C,IAAI,SAAS,CAAC,KAAK,GAAG,KAAK,IAAI,SAAS,CAAC,GAAG,GAAG,GAAG;YAAE,SAAS;QAC7D,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;YAAE,KAAK,GAAG,SAAS,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,8EAA8E;AAC9E,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,QAAQ,CAAC,OAAuC,EAAE,MAAc;IAC9E,IAAI,IAAI,GAA+B,IAAI,CAAC;IAC5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,wEAAwE;QACxE,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,GAAG,KAAK,IAAI;YAAE,SAAS;QAC7D,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG;YAAE,SAAS;QAC5D,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;YAAE,IAAI,GAAG,MAAM,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Specification regions: the part of a file that one specification occupies.\n *\n * `spec-graph` began by assuming one specification per file, because that is\n * how MADR, KEPs and Rust RFCs are laid out. Plenty of organisations do not\n * work that way. A register, a whitepaper or a living architecture document\n * holds dozens of decisions in one file, each with its own identifier, its own\n * status and its own dependencies - and to an engine that binds a document to a\n * file, every one of them is invisible.\n *\n * The fix is small once stated: **a specification is a region of a file, not a\n * file.** A file yields at least one region - itself - and may yield more.\n * Everything downstream is unchanged, because a region produces exactly the\n * same `DocumentNode` a whole file produced.\n *\n * What this module decides is where those regions begin and end, and it is\n * deliberately hard to convince. A heading has to carry an identifier *and* the\n * section has to declare a status before it counts. One signal is not enough:\n * `## Q3 2026 Roadmap` parses as family `Q`, number 3, and `## v1.2.0` in a\n * changelog parses as family `v`, number 1. Neither is a specification, and\n * neither declares a status.\n */\n\nimport { attr, type Directive } from './directives.js';\nimport { isExternal, parsePrefixedRef } from './identity.js';\nimport { isStatusHeading } from './lifecycle.js';\nimport {\n isMarkdownLine,\n isOnlyComment,\n type Heading,\n type Range,\n type ScannedDocument,\n type Table,\n type TableCell,\n type TableRow,\n} from './markdown.js';\nimport type { EdgeKind } from './types.js';\n\n/** A status as written, and where it was written. */\nexport interface RegionStatus {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\n/** A relation read from a table column rather than from prose. */\nexport interface TableRelation {\n readonly kind: EdgeKind;\n readonly inverted: boolean;\n readonly target: string;\n readonly start: number;\n readonly end: number;\n /** The column header that gave it its meaning, for the diagnostic. */\n readonly column: string;\n}\n\nexport interface SpecificationRegion {\n /** The heading that opens the region, or `null` for the file or a table row. */\n readonly heading: Heading | null;\n /** The table row that is the region, when it is one. */\n readonly row: TableRow | null;\n /** Offset the region starts at. */\n readonly start: number;\n /** Offset just past the region. */\n readonly end: number;\n /** Identifier read from the heading or the identifier column. */\n readonly declaredId: string | null;\n readonly title: string | null;\n readonly status: RegionStatus | null;\n /** A `@spec-node` directive inside the region, when there is one. */\n readonly directive: Directive | null;\n /** Relations declared by column, empty for a heading region. */\n readonly relations: readonly TableRelation[];\n /**\n * Cells whose content is already accounted for as a typed relation.\n *\n * Prose scanning skips these, so a link in a `Depends on` column produces one\n * typed edge rather than a typed edge and a neutral citation beside it.\n */\n readonly claimed: readonly Range[];\n}\n\n/** Column headers that name the row's identifier. */\nconst ID_COLUMNS = /^(?:id|ids|ref|reference|key|no|number|#|adr|rfc|kep|oi|decision|spec|specification)$/;\n\n/** Column headers that name the row's status. */\nconst STATUS_COLUMNS = /^(?:status|state|stage|lifecycle|phase)$/;\n\n/** Column headers that name the row's title. */\nconst TITLE_COLUMNS = /^(?:title|name|summary|description|subject|decision|topic)$/;\n\n/**\n * Column headers that declare a relation.\n *\n * Written the way a header is written - \"Depends on\", \"Superseded by\" - rather\n * than the way a front-matter key is, because that is what an author types at\n * the top of a column.\n */\nconst RELATION_COLUMNS: Readonly<Record<string, { kind: EdgeKind; inverted: boolean }>> = {\n 'depends on': { kind: 'depends-on', inverted: false },\n 'depends-on': { kind: 'depends-on', inverted: false },\n dependencies: { kind: 'depends-on', inverted: false },\n requires: { kind: 'depends-on', inverted: false },\n supersedes: { kind: 'supersedes', inverted: false },\n replaces: { kind: 'supersedes', inverted: false },\n 'superseded by': { kind: 'supersedes', inverted: true },\n 'replaced by': { kind: 'supersedes', inverted: true },\n 'blocked by': { kind: 'blocked-by', inverted: false },\n 'blocked on': { kind: 'blocked-by', inverted: false },\n blocks: { kind: 'blocked-by', inverted: true },\n amends: { kind: 'amends', inverted: false },\n extends: { kind: 'amends', inverted: false },\n assumes: { kind: 'assumes', inverted: false },\n 'delegates to': { kind: 'delegates-to', inverted: false },\n 'delegated to': { kind: 'delegates-to', inverted: false },\n 'tracked in': { kind: 'delegates-to', inverted: false },\n related: { kind: 'relates-to', inverted: false },\n 'related to': { kind: 'relates-to', inverted: false },\n 'see also': { kind: 'relates-to', inverted: false },\n references: { kind: 'references', inverted: false },\n};\n\n/** Cell values that mean \"nothing here\". */\nconst MARKDOWN_LINK = /!?\\[([^\\]]*)\\]\\(([^)]*)\\)/g;\nconst EMPTY_CELL = /^(?:-+|—|–|n\\/?a|none|nil|tbd|\\.|_+)$/i;\n\n/** `## ADR-0007: Sharding` - an identifier at the very start of a heading. */\nconst HEADING_ID = /^\\s*([A-Za-z]{1,15}[\\s._-]?\\d{1,6})\\b/;\n\n/** `**Status:** Accepted`, `Status: Accepted`, `*Status* : Accepted`. */\nconst INLINE_STATUS = /^[ \\t>]*[*_]{0,2}\\s*status\\s*[*_]{0,2}\\s*[::]\\s*(.+?)\\s*$/im;\n\n/**\n * Finds every specification in a file.\n *\n * The first entry is always the file itself, so a caller that ignores the rest\n * behaves exactly as it did before regions existed.\n */\nexport function findSpecificationRegions(\n scanned: ScannedDocument,\n directives: readonly Directive[],\n /** The file's own identifier, so its title heading is not read as a sub-region. */\n fileId: string,\n): SpecificationRegion[] {\n const whole: SpecificationRegion = {\n heading: null,\n row: null,\n start: scanned.bodyStart,\n end: scanned.text.length,\n declaredId: null,\n title: null,\n status: null,\n directive: null,\n relations: [],\n claimed: [],\n };\n\n const regions: SpecificationRegion[] = [];\n const folded = fold(fileId);\n const fileRef = parsePrefixedRef(fileId);\n\n for (let i = 0; i < scanned.headings.length; i += 1) {\n const heading = scanned.headings[i] as Heading;\n const declaredId = HEADING_ID.exec(heading.text)?.[1];\n if (declaredId === undefined) continue;\n // The file's own title heading names the file, not a region inside it.\n if (fold(declaredId) === folded) continue;\n // Padding is not part of an identity anywhere else - `ADR-40`, `ADR-040`\n // and `ADR-0040` all resolve to one document - so a heading that spells the\n // number differently from the file name is still that file's own title.\n // Comparing the text alone made `# ADR-040` inside `0040-enforce.md` a\n // region within the file it names: one decision, two nodes, and a citation\n // arriving at whichever spelling it happened to use.\n const ref = parsePrefixedRef(declaredId);\n if (ref !== null && fileRef !== null && ref.family === fileRef.family && ref.number === fileRef.number) continue;\n\n const end = regionEnd(scanned, i);\n const directive = directiveIn(directives, heading.end, end);\n const status = readRegionStatus(scanned, heading.end, end);\n\n // Two independent signals are required. An identifier alone matches\n // `## Q3 2026 Roadmap` and `## v1.2.0`; a status alone matches every\n // ordinary `## Status` section in a normal ADR.\n if (status === null && directive === null) continue;\n\n regions.push({\n heading,\n row: null,\n start: heading.start,\n end,\n declaredId: (directive ? attr(directive, 'id')?.value : null) ?? declaredId,\n title: heading.text,\n status,\n directive,\n relations: [],\n claimed: [],\n });\n }\n\n return [whole, ...regions, ...findTableRegions(scanned)];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Registers kept as tables */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Reads a table whose columns describe specifications.\n *\n * A table qualifies when it has an identifier column *and* either a status\n * column or at least one relation column. Two signals again, for the same\n * reason: a table of identifiers and prose is a citation list, and promoting\n * every row of it to a specification would invent a register nobody wrote.\n */\nexport function findTableRegions(scanned: ScannedDocument): SpecificationRegion[] {\n const out: SpecificationRegion[] = [];\n\n for (const table of scanned.tables) {\n const schema = readSchema(table);\n if (schema === null) continue;\n\n for (const row of table.rows) {\n const idCell = row.cells[schema.id];\n if (!idCell) continue;\n const id = flatten(idCell.text);\n if (id.length === 0 || EMPTY_CELL.test(id)) continue;\n\n const statusCell = schema.status === null ? undefined : row.cells[schema.status];\n const statusText = statusCell ? flatten(statusCell.text) : '';\n const status: RegionStatus | null =\n statusCell && statusText.length > 0 && !EMPTY_CELL.test(statusText)\n ? { text: statusText, start: statusCell.start, end: statusCell.end }\n : null;\n\n const titleCell = schema.title === null ? undefined : row.cells[schema.title];\n const title = titleCell ? flatten(titleCell.text) : null;\n\n const relations: TableRelation[] = [];\n const claimed: Range[] = [{ start: idCell.start, end: idCell.end }];\n if (statusCell) claimed.push({ start: statusCell.start, end: statusCell.end });\n\n for (const [column, relation] of schema.relations) {\n const cell = row.cells[column];\n if (!cell) continue;\n claimed.push({ start: cell.start, end: cell.end });\n for (const target of splitTargets(cell)) {\n relations.push({\n kind: relation.kind,\n inverted: relation.inverted,\n target: target.text,\n start: target.start,\n end: target.end,\n column: (table.headers[column] as TableCell).text,\n });\n }\n }\n\n out.push({\n heading: null,\n row,\n start: row.start,\n end: row.end,\n declaredId: id,\n title: title !== null && title.length > 0 ? title : null,\n status,\n directive: null,\n relations,\n claimed,\n });\n }\n }\n\n return out;\n}\n\ninterface TableSchema {\n readonly id: number;\n readonly status: number | null;\n readonly title: number | null;\n readonly relations: readonly (readonly [number, { kind: EdgeKind; inverted: boolean }])[];\n}\n\nfunction readSchema(table: Table): TableSchema | null {\n let id: number | null = null;\n let status: number | null = null;\n let title: number | null = null;\n const relations: [number, { kind: EdgeKind; inverted: boolean }][] = [];\n\n table.headers.forEach((header, column) => {\n const name = normaliseHeader(header.text);\n if (id === null && ID_COLUMNS.test(name)) {\n id = column;\n return;\n }\n if (status === null && STATUS_COLUMNS.test(name)) {\n status = column;\n return;\n }\n const relation = RELATION_COLUMNS[name];\n if (relation) {\n relations.push([column, relation]);\n return;\n }\n if (title === null && TITLE_COLUMNS.test(name)) title = column;\n });\n\n if (id === null) return null;\n if (status === null && relations.length === 0) return null;\n return { id, status, title, relations };\n}\n\nfunction normaliseHeader(text: string): string {\n return flatten(text)\n .toLowerCase()\n .replace(/[^a-z0-9/#\\s-]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Splits a cell into the identifiers it lists, keeping each one's offset. */\nfunction splitTargets(cell: TableCell): { text: string; start: number; end: number }[] {\n const out: { text: string; start: number; end: number }[] = [];\n // Every target is reported at the cell's span. A cell is short, and an offset\n // recovered back through a flattening is an offset that can drift.\n const push = (raw: string): void => {\n const target = raw.trim();\n if (target.length === 0 || EMPTY_CELL.test(target)) return;\n out.push({ text: target, start: cell.start, end: cell.end });\n };\n const prose = (segment: string): void => {\n for (const piece of flatten(segment).split(/\\s*(?:[,;]|\\band\\b)\\s*/i)) push(piece);\n };\n\n // Links are taken out whole rather than flattened with everything else: a\n // path would otherwise be cut in half by its own slash, and its underscores\n // stripped as emphasis.\n // A fresh matcher per cell. `prose` calls `flatten`, which drives the shared\n // pattern; one /g regex advanced from inside its own scan resets its cursor\n // and never terminates.\n const links = new RegExp(MARKDOWN_LINK.source, 'g');\n let last = 0;\n for (let match = links.exec(cell.text); match !== null; match = links.exec(cell.text)) {\n prose(cell.text.slice(last, match.index));\n const destination = (match[2] ?? '').trim();\n // A link states where its target lives; its label states only what the\n // target is called (ADR-0008). In a column the author has already typed,\n // the destination is the claim - `[see](adr/0050.md)` is a dependency on\n // that file, not on the word \"see\". An external or in-page destination\n // names no document here, so the label is what is left to try.\n const local = destination.length > 0 && !destination.startsWith('#') && !isExternal(destination);\n push(local ? destination : (match[1] ?? ''));\n last = match.index + match[0].length;\n }\n prose(cell.text.slice(last));\n return out;\n}\n\n/** Reduces a cell to its text: link labels rather than link syntax. */\nfunction flatten(text: string): string {\n return text\n .replace(MARKDOWN_LINK, '$1')\n .replace(/\\[\\[(?:[^\\]|]*\\|)?([^\\]]*)\\]\\]/g, '$1')\n .replace(/[`*_~]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Where a heading's section ends: the next heading at the same level or above. */\nfunction regionEnd(scanned: ScannedDocument, index: number): number {\n const heading = scanned.headings[index] as Heading;\n for (let i = index + 1; i < scanned.headings.length; i += 1) {\n const next = scanned.headings[i] as Heading;\n if (next.level <= heading.level) return next.start;\n }\n return scanned.text.length;\n}\n\n/**\n * Reads a status declared inside a region.\n *\n * Two forms, both common: a labelled line (`**Status:** Accepted`) and a\n * sub-heading (`### Status` with the value beneath it). Only the region is\n * searched, so one decision in a register cannot inherit its neighbour's.\n */\nexport function readRegionStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n const labelled = readLabelledStatus(scanned, start, end);\n if (labelled) return labelled;\n return readHeadedStatus(scanned, start, end);\n}\n\nfunction readLabelledStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n for (const line of scanned.lines) {\n if (line.contentStart < start) continue;\n if (line.contentStart >= end) break;\n // A template's commented-out `Status: proposed | accepted` is a hint to\n // whoever fills it in, not a status the region declares, and one in code or\n // a <pre> block is an example.\n if (!isMarkdownLine(line) || line.blank || line.comment) continue;\n const match = INLINE_STATUS.exec(line.content);\n if (!match) continue;\n // `**Status:** Accepted` closes its emphasis *after* the colon, so the\n // closing marker lands in the captured value. Strip it rather than let it\n // reach the report as part of the status a reader is shown.\n const value = (match[1] as string).replace(/^[*_\\s]+/, '').replace(/[*_\\s]+$/, '');\n if (value.length === 0) continue;\n const offset = line.contentStart + line.content.lastIndexOf(value);\n return { text: value, start: offset, end: offset + value.length };\n }\n return null;\n}\n\nfunction readHeadedStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n const heading = scanned.headings.find((h) => h.start >= start && h.start < end && isStatusHeading(h.text));\n if (!heading) return null;\n\n for (const line of scanned.lines) {\n if (line.line <= heading.line) continue;\n if (line.contentStart >= end) break;\n if (line.blank || isOnlyComment(scanned, line)) continue;\n if (!isMarkdownLine(line)) return null;\n const trimmed = line.content.trim();\n if (trimmed.startsWith('#')) return null;\n // A bullet list under Status is a status history; the first entry is current.\n const cleaned = trimmed.replace(/^[-*+]\\s+/, '');\n const offset = line.contentStart + line.content.indexOf(trimmed) + (trimmed.length - cleaned.length);\n return { text: cleaned, start: offset, end: offset + cleaned.length };\n }\n return null;\n}\n\n/** The last `@spec-node` directive inside a region. */\nfunction directiveIn(directives: readonly Directive[], start: number, end: number): Directive | null {\n let found: Directive | null = null;\n for (const directive of directives) {\n if (directive.name !== 'spec-node') continue;\n if (directive.start < start || directive.end > end) continue;\n if (found === null || directive.start > found.start) found = directive;\n }\n return found;\n}\n\n/** Case- and separator-insensitive comparison, matching reference folding. */\nfunction fold(value: string): string {\n return value.trim().toLowerCase().replace(/[\\s._-]+/g, '');\n}\n\n/** The region containing an offset, innermost first. `null` when only the file does. */\nexport function regionAt(regions: readonly SpecificationRegion[], offset: number): SpecificationRegion | null {\n let best: SpecificationRegion | null = null;\n for (const region of regions) {\n // The whole-file region owns nothing in particular; it is the fallback.\n if (region.heading === null && region.row === null) continue;\n if (offset < region.start || offset >= region.end) continue;\n if (best === null || region.start > best.start) best = region;\n }\n return best;\n}\n"]}
package/dist/select.d.ts CHANGED
@@ -19,9 +19,9 @@
19
19
  * March" instead of naming two documents and leaving the reader to reconstruct
20
20
  * the relationship.
21
21
  */
22
- import { type Matcher } from './regex.js';
23
22
  import type { SpecGraph } from './graph.js';
24
23
  import { type Edge, type EdgeKind, type NodeKind, type SpecNode } from './types.js';
24
+ import { type RegexMatcher } from './vendor/spec-core/pattern/index.js';
25
25
  export type Operator = '=' | '!=' | '^=' | '$=' | '*=' | '~=' | 'exists';
26
26
  export interface Predicate {
27
27
  readonly key: string;
@@ -83,7 +83,7 @@ export declare function attributesOf(node: SpecNode, key: string, graph?: SpecGr
83
83
  * Cached because a rule runs its predicate against every node in the corpus,
84
84
  * and because compiling is the expensive half now that matching is linear.
85
85
  */
86
- export declare function pattern(source: string): Matcher;
86
+ export declare function pattern(source: string): RegexMatcher;
87
87
  /** True when a node satisfies a matcher. */
88
88
  export declare function matches(node: SpecNode, matcher: NodeMatcher, graph?: SpecGraph): boolean;
89
89
  export interface ExecuteOptions {
package/dist/select.js CHANGED
@@ -20,9 +20,9 @@
20
20
  * the relationship.
21
21
  */
22
22
  import { receptivityOf } from './lifecycle.js';
23
- import { compilePattern, PatternError } from './regex.js';
24
23
  import { documentOf } from './resolve.js';
25
24
  import { EDGE_KINDS } from './types.js';
25
+ import { compileRegex, RegexError } from './vendor/spec-core/pattern/index.js';
26
26
  export class QueryError extends Error {
27
27
  /** Offset into the query string where the problem starts. */
28
28
  offset;
@@ -126,7 +126,7 @@ class Parser {
126
126
  pattern(value);
127
127
  }
128
128
  catch (error) {
129
- if (!(error instanceof PatternError))
129
+ if (!(error instanceof RegexError))
130
130
  throw error;
131
131
  throw new QueryError(error.message, valueStart + error.offset + (quoted(this.source[valueStart]) ? 1 : 0));
132
132
  }
@@ -347,7 +347,7 @@ export function pattern(source) {
347
347
  const cached = patterns.get(source);
348
348
  if (cached)
349
349
  return cached;
350
- const compiled = compilePattern(source);
350
+ const compiled = compileRegex(source);
351
351
  patterns.set(source, compiled);
352
352
  return compiled;
353
353
  }