@descent-vtt/spec-graph 0.2.0 → 0.2.1
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.
- package/dist/extract.js +48 -0
- package/dist/extract.js.map +1 -1
- package/package.json +1 -1
package/dist/extract.js
CHANGED
|
@@ -843,8 +843,56 @@ function extractReferences(context) {
|
|
|
843
843
|
opportunistic: true,
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
|
+
return withoutOverlaps(out);
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Collapses candidates that describe the same written citation.
|
|
850
|
+
*
|
|
851
|
+
* `Superseded by ADR-0009` in a status section is read twice: the status
|
|
852
|
+
* reader reports the whole line, and prose scanning reports the identifier
|
|
853
|
+
* inside it. One written citation is one reference - so when the target
|
|
854
|
+
* resolves it must not become two edges, and when it does not it must not
|
|
855
|
+
* become two findings on one line a reader can only fix once.
|
|
856
|
+
*
|
|
857
|
+
* The narrower span wins, because it points at the text that has to change.
|
|
858
|
+
*
|
|
859
|
+
* Only overlapping spans collapse. Two sentences citing the same missing
|
|
860
|
+
* document are two citations, and silently reporting one of them would leave
|
|
861
|
+
* the other to be discovered on the next run.
|
|
862
|
+
*/
|
|
863
|
+
function withoutOverlaps(candidates) {
|
|
864
|
+
const out = [];
|
|
865
|
+
for (const candidate of candidates) {
|
|
866
|
+
const index = out.findIndex((other) => other.kind === candidate.kind &&
|
|
867
|
+
other.from === candidate.from &&
|
|
868
|
+
other.inverted === candidate.inverted &&
|
|
869
|
+
normaliseRef(other.target) === normaliseRef(candidate.target) &&
|
|
870
|
+
overlapping(other.declaredAt, candidate.declaredAt));
|
|
871
|
+
if (index === -1) {
|
|
872
|
+
out.push(candidate);
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
const held = out[index];
|
|
876
|
+
// The status reader runs before prose scanning, so today the wider span is
|
|
877
|
+
// always the one already held and this comparison always replaces it. It is
|
|
878
|
+
// written as a comparison rather than an unconditional swap because which
|
|
879
|
+
// reader runs first is not a property worth depending on, and a mutant that
|
|
880
|
+
// makes it unconditional is equivalent only by that accident.
|
|
881
|
+
if (width(candidate.declaredAt) < width(held.declaredAt))
|
|
882
|
+
out[index] = candidate;
|
|
883
|
+
}
|
|
846
884
|
return out;
|
|
847
885
|
}
|
|
886
|
+
const width = (ref) => ref.span.end.offset - ref.span.start.offset;
|
|
887
|
+
/**
|
|
888
|
+
* Whether two spans cover any of the same text.
|
|
889
|
+
*
|
|
890
|
+
* Offsets alone, with no file comparison: every candidate here was built from
|
|
891
|
+
* one scan of one file, so there is no second file for them to be offsets into.
|
|
892
|
+
*/
|
|
893
|
+
function overlapping(a, b) {
|
|
894
|
+
return a.span.start.offset < b.span.end.offset && b.span.start.offset < a.span.end.offset;
|
|
895
|
+
}
|
|
848
896
|
/** The item whose block contains an offset, if any. */
|
|
849
897
|
function ownerOf(items, offset) {
|
|
850
898
|
let best = null;
|
package/dist/extract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAyB,OAAO,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,OAAO,EAAkD,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAA4B,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAkB,MAAM,aAAa,CAAC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AAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACtG,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC;AAED,gEAAgE;AAChE,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK;SACT,IAAI,EAAE;SACN,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;SAC1B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;SAC1B,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC;QAC9B,KAAK,UAAU;YACb,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAC5B,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;QAC1C;YACE,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;IAC5C,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC","sourcesContent":["/**\n * Document extraction: Markdown in, graph fragments out.\n *\n * This module is where domain-agnosticism is won or lost. It never requires a\n * repository to adopt a syntax. It reads what teams already write - front\n * matter, a `## Status` section, a checklist under `## Open Questions`, a link\n * that says \"deferred to ADR-0011\" - and turns each into a typed relation with a\n * source position.\n *\n * The one rule it holds to everywhere: **an inference that cannot be justified\n * is not made.** An unrecognised status becomes `unknown`, not a guess. A link\n * with no governing verb becomes a neutral `references`, not a dependency. Bare\n * identifiers found in prose are opportunistic and are dropped silently when\n * they do not resolve, because the alternative is reporting `SHA-256` as a\n * broken reference to specification 256.\n */\n\nimport { attr, attrList, directiveFor, parseDirectives, type Directive } from './directives.js';\nimport { identify, isExternal, normaliseRef, type DocumentIdentity, ID_KEYS } from './identity.js';\nimport { isStatusHeading, phaseFromPath, phaseOf, STATUS_KEYS, supersessionTargetsIn } from './lifecycle.js';\nimport { scanMarkdown, slugify, type Link, type ListItem, type ScannedDocument } from './markdown.js';\nimport { findSpecificationRegions, regionAt, type SpecificationRegion } from './sections.js';\nimport { resolveItemState } from './state.js';\nimport { refOf, type LineIndex } from './source.js';\nimport type {\n DocumentNode,\n EdgeKind,\n EdgeOrigin,\n ItemNode,\n ParseProblem,\n Phase,\n SourceRef,\n} from './types.js';\nimport { parseFrontMatter, toRecord, valuesOf, type YamlEntry } from './yaml.js';\n\n/* -------------------------------------------------------------------------- */\n/* Output */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A relation that has been read but not yet resolved to a target node.\n *\n * Resolution needs the whole corpus, so extraction stops at the raw target text.\n */\nexport interface ReferenceCandidate {\n readonly kind: EdgeKind;\n /** Id of the node the relation was written on. */\n readonly from: string;\n /** The target exactly as written: a path, an identifier, or a URL. */\n readonly target: string;\n readonly origin: EdgeOrigin;\n readonly declaredAt: SourceRef;\n readonly raw: string;\n /**\n * When true the relation runs `target -> from`.\n *\n * `superseded-by: ADR-0009` written in ADR-0003 declares that *ADR-0009*\n * supersedes ADR-0003. The edge belongs to ADR-0009; the line a human must go\n * and fix is in ADR-0003, which is why `declaredAt` is tracked separately.\n */\n readonly inverted: boolean;\n /**\n * Opportunistic references are dropped in silence when they do not resolve.\n * Only deliberate ones - links, front matter, directives - are reported.\n */\n readonly opportunistic: boolean;\n}\n\nexport interface ExtractedDocument {\n readonly document: DocumentNode;\n readonly items: readonly ItemNode[];\n readonly references: readonly ReferenceCandidate[];\n readonly problems: readonly ParseProblem[];\n /** Heading slugs, for resolving `#anchor` references into this document. */\n readonly anchors: ReadonlySet<string>;\n readonly identity: DocumentIdentity;\n readonly scanned: ScannedDocument;\n /**\n * Specifications declared inside this file, each a document in its own right.\n *\n * Empty for the ordinary one-file-per-decision layout, which is why nothing\n * downstream had to change to support registers.\n */\n readonly subSpecifications: readonly ExtractedDocument[];\n /**\n * The file-level specification this one is a region of, if any.\n *\n * Recorded so the register's structure is a relation in the graph rather than\n * an accident of which offsets fall inside which: \"what decisions does this\n * register hold\" is a question worth being able to ask.\n */\n readonly containerId: string | null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Vocabulary */\n/* -------------------------------------------------------------------------- */\n\n/** Front-matter keys that declare a relation, and what they mean. */\nconst RELATION_KEYS: Readonly<Record<string, { kind: EdgeKind; inverted: boolean }>> = {\n supersedes: { kind: 'supersedes', inverted: false },\n supercedes: { kind: 'supersedes', inverted: false },\n replaces: { kind: 'supersedes', inverted: false },\n obsoletes: { kind: 'supersedes', inverted: false },\n 'superseded-by': { kind: 'supersedes', inverted: true },\n 'superceded-by': { kind: 'supersedes', inverted: true },\n 'replaced-by': { kind: 'supersedes', inverted: true },\n 'obsoleted-by': { kind: 'supersedes', inverted: true },\n amends: { kind: 'amends', inverted: false },\n extends: { kind: 'amends', inverted: false },\n 'amended-by': { kind: 'amends', inverted: true },\n 'depends-on': { kind: 'depends-on', inverted: false },\n dependencies: { kind: 'depends-on', inverted: false },\n requires: { kind: 'depends-on', inverted: false },\n assumes: { kind: 'assumes', inverted: false },\n 'blocked-by': { kind: 'blocked-by', inverted: false },\n blocks: { kind: 'blocked-by', inverted: true },\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 'relates-to': { kind: 'relates-to', inverted: false },\n 'see-also': { kind: 'relates-to', inverted: false },\n references: { kind: 'references', inverted: false },\n refs: { kind: 'references', inverted: false },\n};\n\n/**\n * Phrases that give a link its meaning, longest-matching-nearest wins.\n *\n * Only phrases that genuinely commit the citing document are here. Vague ones\n * (\"see\", \"covered by\") stay out: a `references` edge is harmless, whereas a\n * wrongly inferred `assumes` edge produces a confident stale-premise finding\n * about a document that never depended on anything.\n */\nconst VERB_RULES: readonly { kind: EdgeKind; inverted: boolean; phrases: readonly string[] }[] = [\n {\n kind: 'supersedes',\n inverted: true,\n phrases: ['superseded by', 'superceded by', 'replaced by', 'obsoleted by', 'deprecated by', 'rolled into'],\n },\n { kind: 'supersedes', inverted: false, phrases: ['supersedes', 'supercedes', 'replaces', 'obsoletes', 'deprecates'] },\n { kind: 'amends', inverted: true, phrases: ['amended by', 'refined by', 'clarified by', 'revised by'] },\n { kind: 'amends', inverted: false, phrases: ['amends', 'refines', 'clarifies', 'revises'] },\n {\n kind: 'delegates-to',\n inverted: false,\n phrases: [\n 'delegated to',\n 'delegate to',\n 'deferred to',\n 'defer to',\n 'moved to',\n 'move to',\n 'tracked in',\n 'tracked by',\n 'handed off to',\n 'handed to',\n 'hand off to',\n 'follow up in',\n 'follow-up in',\n 'followup in',\n 'continued in',\n 'continues in',\n 'punted to',\n 'left to',\n 'belongs in',\n 'owned by',\n 'will be decided in',\n 'will be resolved in',\n 'will be handled in',\n 'will be handled by',\n 'will be answered in',\n 'to be decided in',\n 'to be resolved in',\n 'to be handled in',\n 'to be answered in',\n ],\n },\n {\n kind: 'blocked-by',\n inverted: false,\n phrases: ['blocked by', 'blocked on', 'waiting on', 'waiting for', 'gated on', 'gated by', 'unblocked by'],\n },\n { kind: 'blocked-by', inverted: true, phrases: ['blocks', 'blocking'] },\n {\n kind: 'depends-on',\n inverted: false,\n phrases: ['depends on', 'depend on', 'dependent on', 'requires', 'builds on', 'built on', 'relies on'],\n },\n { kind: 'depends-on', inverted: true, phrases: ['depended on by'] },\n {\n kind: 'assumes',\n inverted: false,\n phrases: [\n 'assumes',\n 'assuming',\n 'on the assumption of',\n 'as decided in',\n 'as established in',\n 'as established by',\n 'as stated in',\n 'as specified in',\n 'as required by',\n 'as mandated by',\n 'in accordance with',\n 'constrained by',\n 'mandated by',\n 'governed by',\n 'predicated on',\n 'rests on',\n 'follows from',\n 'justified by',\n // A constraint the citing document designs around. \"the row limit imposed\n // by ADR-0002\" is the archetypal stale premise: when ADR-0002 is retired,\n // this document is still working around a cap that no longer exists.\n 'imposed by',\n 'required by',\n 'dictated by',\n 'determined by',\n 'limited by',\n 'capped by',\n 'bounded by',\n 'defined by',\n 'defined in',\n 'specified by',\n 'set by',\n 'per',\n 'because',\n 'since',\n ],\n },\n];\n\n/**\n * Words that cancel a governing phrase standing before them.\n *\n * The window allows a short noun phrase between a verb and the reference it\n * governs - \"deferred to the sharding decision in [ADR-7]\" is one statement.\n * It cannot allow a negation. A table entry reading \"Owned by nobody today and\n * disclaimed by [138]\" was being read as a delegation *to* 138, which is the\n * opposite of what the sentence says, and an inference that inverts its source\n * is worse than no inference at all.\n */\nconst NEGATION = /(?:^|\\s)(?:no|not|nobody|none|never|neither|nor|nothing|without)(?:\\s|$)/;\n\n/** How close a governing phrase must sit to the reference it governs. */\nconst VERB_WINDOW = 40;\n\n/**\n * Every governing phrase compiled into one alternation, plus a lookup table.\n *\n * Classification runs on every reference in the corpus, and testing a hundred\n * phrases one at a time made it the most expensive thing extraction did. The\n * alternation is sorted longest-first so that at any given position the regex\n * prefers `partially resolved` over `resolved`, matching the precedence the\n * per-phrase search had. Lookarounds rather than `\\b`, because phrases contain\n * hyphens and `\\b` does the wrong thing around them.\n */\nconst VERB_LOOKUP: ReadonlyMap<string, Classification> = new Map(\n VERB_RULES.flatMap((rule) =>\n rule.phrases.map((phrase) => [phrase, { kind: rule.kind, inverted: rule.inverted }] as const),\n ),\n);\n\nconst VERB_PATTERN = new RegExp(\n `(?<![\\\\p{L}\\\\p{N}])(?:${[...VERB_LOOKUP.keys()]\n .sort((a, b) => b.length - a.length)\n .map((phrase) => phrase.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('|')})(?![\\\\p{L}\\\\p{N}])`,\n 'gu',\n);\n\n/** Headings under which a link is bookkeeping rather than a commitment. */\nconst WEAK_SECTIONS: ReadonlySet<string> = new Set([\n 'see also',\n 'references',\n 'reference',\n 'related',\n 'related work',\n 'related decisions',\n 'related documents',\n 'links',\n 'further reading',\n 'prior art',\n 'history',\n 'changelog',\n 'change log',\n 'revision history',\n 'bibliography',\n 'sources',\n 'appendix',\n 'more information',\n 'resources',\n 'index',\n]);\n\n/** Headings whose bullets are obligations even without a checkbox. */\nconst OBLIGATION_SECTIONS: ReadonlySet<string> = new Set([\n 'open questions',\n 'open question',\n 'unresolved questions',\n 'unanswered questions',\n 'questions',\n 'open issues',\n 'action items',\n 'actions',\n 'todo',\n 'to do',\n 'to-do',\n 'todos',\n 'next steps',\n 'follow ups',\n 'follow-ups',\n 'followups',\n 'follow up',\n 'follow-up',\n 'unresolved',\n 'outstanding',\n 'outstanding questions',\n 'tasks',\n 'task list',\n 'work items',\n 'remaining work',\n 'decisions needed',\n 'blockers',\n 'parking lot',\n 'future work',\n 'deferred',\n]);\n\n/**\n * Prefixes that look like specification identifiers but never are.\n *\n * The corpus filter in `resolve.ts` is the real defence; this list only keeps\n * the obvious noise out of the candidate set.\n */\nconst NOT_A_FAMILY: ReadonlySet<string> = new Set([\n 'v',\n 'ver',\n 'version',\n 'p',\n 'pp',\n 'fig',\n 'figure',\n 'table',\n 'tbl',\n 'section',\n 'sect',\n 'sec',\n 'step',\n 'item',\n 'no',\n 'num',\n 'line',\n 'ln',\n 'col',\n 'port',\n 'pr',\n 'issue',\n 'gh',\n 'utf',\n 'ascii',\n 'sha',\n 'md',\n 'http',\n 'https',\n 'ipv',\n 'tls',\n 'ssl',\n 'es',\n 'ecma',\n 'x',\n 'h',\n 'p99',\n 'base',\n 'sql',\n 'ipv4',\n 'ipv6',\n 'arm',\n 'x86',\n 'win',\n 'node',\n 'python',\n 'java',\n 'go',\n 'c',\n 'cpp',\n]);\n\nconst BARE_REF = /\\b([A-Za-z][A-Za-z0-9]{0,14})[\\s._-]?(\\d{1,6})\\b/g;\n\n/* -------------------------------------------------------------------------- */\n/* Extraction */\n/* -------------------------------------------------------------------------- */\n\nexport interface ExtractInput {\n /** Repository-relative POSIX path. */\n readonly path: string;\n readonly text: string;\n /**\n * This file is a historical record: a log of what was decided, not a\n * decision. Matched against the caller's history patterns, because deciding\n * which files those are is a repository's business and not a guess this\n * layer could justify making. See ADR-0011.\n */\n readonly record?: boolean | undefined;\n}\n\n/**\n * Reads one file into graph fragments, one entry per specification in it.\n *\n * A file yields at least itself. It yields more when it is a register: a\n * heading that carries an identifier *and* declares a status is a specification\n * in its own right, with its own lifecycle, its own obligations and its own\n * relations. See ADR-0009.\n */\nexport function extractSpecifications(input: ExtractInput): ExtractedDocument[] {\n const first = extractDocument(input);\n return first === null ? [] : [first, ...(first.subSpecifications as ExtractedDocument[])];\n}\n\n/** Reads a file's own specification. Returns `null` when it opts out. */\nexport function extractDocument(input: ExtractInput): ExtractedDocument | null {\n const scanned = scanMarkdown(input.text);\n const directives = parseDirectives(scanned.comments);\n if (directives.some((d) => d.name === 'spec-ignore')) return null;\n\n const index = scanned.index;\n const file = input.path;\n const problems: ParseProblem[] = [];\n const at = (start: number, end: number): SourceRef => refOf(file, index, start, end);\n\n for (const directive of directives) {\n for (const unknown of directive.unknownAttributes) {\n problems.push({\n message: `unknown attribute \"${unknown}\" on @${directive.name}`,\n at: at(directive.start, directive.end),\n });\n }\n }\n\n const entries = scanned.frontMatter ? parseFrontMatter(scanned.frontMatter.raw, scanned.frontMatter.start) : [];\n const byKey = new Map<string, YamlEntry>();\n for (const entry of entries) byKey.set(entry.key, entry);\n\n const h1 = scanned.headings.find((h) => h.level === 1) ?? null;\n const frontMatterId = firstValue(byKey, ID_KEYS) ?? null;\n\n const identityOf = (declaredId: string | null, directive: Directive | null): DocumentIdentity =>\n identify({\n path: input.path,\n declaredId,\n declaredAliases: [\n ...(directive ? attrList(directive, 'aliases') : []),\n ...valuesOf(byKey.get('aliases')),\n ...valuesOf(byKey.get('alias')),\n ],\n heading: h1?.text ?? null,\n });\n\n // A `@spec-node` written inside a register's section belongs to that section,\n // not to the file. Finding the file's own therefore needs the regions, and\n // finding the regions needs the file's identity - so the identity is settled\n // provisionally first, then again once the file's own directive is known.\n const provisional = identityOf(frontMatterId, null);\n const provisionalRegions = findSpecificationRegions(scanned, directives, provisional.id);\n const nodeDirective =\n directives.find(\n (directive) =>\n directive.name === 'spec-node' &&\n !provisionalRegions.some(\n (region) =>\n (region.heading !== null || region.row !== null) &&\n directive.start >= region.start &&\n directive.end <= region.end,\n ),\n ) ?? null;\n\n const declaredId = (nodeDirective ? attr(nodeDirective, 'id')?.value : null) ?? frontMatterId;\n const identity = declaredId === frontMatterId && nodeDirective === null\n ? provisional\n : identityOf(declaredId, nodeDirective);\n\n const status = readStatus(scanned, byKey, nodeDirective, index, file);\n const pathPhase = phaseFromPath(input.path);\n // A record is a categorical statement about what the file *is*, made by\n // configuration or by an explicit directive, so it outranks a status word\n // that happened to be written inside it.\n const record = input.record === true || directives.some((directive) => directive.name === 'spec-history');\n const phase: Phase = record ? 'record' : status.phase !== 'unknown' ? status.phase : pathPhase;\n\n const title =\n (nodeDirective ? attr(nodeDirective, 'title')?.value : null) ??\n asString(byKey.get('title')) ??\n h1?.text ??\n identity.id;\n\n const document: DocumentNode = {\n id: identity.id,\n kind: 'document',\n title,\n at: at(0, Math.min(scanned.text.length, index.lineEnd(1))),\n path: input.path,\n aliases: identity.aliases,\n phase,\n rawStatus: status.raw,\n statusAt: status.at,\n frontMatter: toRecord(entries),\n };\n\n // A register's sections are specifications too. The file is always the first\n // region, so a one-decision file behaves exactly as it did before.\n const regions =\n identity.id === provisional.id ? provisionalRegions : findSpecificationRegions(scanned, directives, identity.id);\n // Every region but the first: a heading section, or a row of a register kept\n // as a table.\n const subSpecifications = regions\n .filter((region) => region.heading !== null || region.row !== null)\n .map((region) =>\n buildRegion({\n region,\n containerId: identity.id,\n input,\n scanned,\n directives,\n index,\n file,\n pathPhase,\n record,\n }),\n );\n\n const ownerAt = (offset: number): string => {\n const region = regionAt(regions, offset);\n if (region === null) return identity.id;\n const owner = subSpecifications.find((spec) => spec.region === region);\n return owner?.document.id ?? identity.id;\n };\n\n const allItems = extractItems({ scanned, directives, ownerAt, file, index });\n const documentAt = (offset: number): DocumentNode => {\n const id = ownerAt(offset);\n if (id === identity.id) return document;\n return subSpecifications.find((spec) => spec.document.id === id)?.document ?? document;\n };\n\n const allReferences = extractReferences({\n scanned,\n directives,\n document,\n documentAt,\n items: allItems,\n byKey,\n status,\n claimed: regions.flatMap((region) => [...region.claimed]),\n file,\n index,\n });\n\n // Hand each region the items and references that fall inside it.\n const ownItems = allItems.filter((item) => item.document === identity.id);\n const ownReferences = allReferences.filter((reference) => belongsTo(reference, identity.id, allItems));\n const anchors = new Set<string>(scanned.headings.map((h) => h.slug));\n\n const filled = subSpecifications.map((spec) => ({\n ...spec.extracted,\n items: allItems.filter((item) => item.document === spec.document.id),\n references: [\n // Column-declared relations first: they are typed by the header rather\n // than guessed from prose.\n ...spec.extracted.references,\n ...allReferences.filter((reference) => belongsTo(reference, spec.document.id, allItems)),\n ],\n }));\n\n return {\n document,\n items: ownItems,\n references: ownReferences,\n problems,\n anchors,\n identity,\n scanned,\n subSpecifications: filled,\n containerId: null,\n };\n}\n\n/** True when a reference was written on a document or on one of its items. */\nfunction belongsTo(reference: ReferenceCandidate, documentId: string, items: readonly ItemNode[]): boolean {\n if (reference.from === documentId) return true;\n const owner = items.find((item) => item.id === reference.from);\n return owner?.document === documentId;\n}\n\ninterface RegionInput {\n readonly region: SpecificationRegion;\n readonly containerId: string;\n readonly input: ExtractInput;\n readonly scanned: ScannedDocument;\n readonly directives: readonly Directive[];\n readonly index: LineIndex;\n readonly file: string;\n readonly pathPhase: Phase;\n /** The whole file is a historical record, so every part of it is one too. */\n readonly record: boolean;\n}\n\ninterface BuiltRegion {\n readonly region: SpecificationRegion;\n readonly document: DocumentNode;\n readonly extracted: ExtractedDocument;\n}\n\n/**\n * Turns one region into a specification.\n *\n * It produces exactly the `DocumentNode` a whole file produces, which is the\n * reason every rule, query and reporter works on registers without knowing they\n * exist. The only deliberate differences: the node is anchored at its heading\n * rather than at line one, it carries no front matter of its own, and it does\n * not claim the file's path as an alias - the file already does, and two nodes\n * answering to one path would make every link to that file ambiguous.\n */\nfunction buildRegion(context: RegionInput): BuiltRegion {\n const { region, input, scanned, index, file, pathPhase, record } = context;\n const at = (start: number, end: number): SourceRef => refOf(file, index, start, end);\n\n const identity = identify({\n path: input.path,\n declaredId: region.declaredId,\n declaredAliases: region.directive ? attrList(region.directive, 'aliases') : [],\n heading: region.title,\n includePathAliases: false,\n });\n\n const declaredStatus = region.directive ? attr(region.directive, 'status') : null;\n const rawStatus = declaredStatus?.value ?? region.status?.text ?? null;\n const statusAt = declaredStatus\n ? at(declaredStatus.start, declaredStatus.end)\n : region.status\n ? at(region.status.start, region.status.end)\n : null;\n const declaredPhase = phaseOf(rawStatus);\n\n const document: DocumentNode = {\n id: identity.id,\n kind: 'document',\n title: (region.directive ? attr(region.directive, 'title')?.value : null) ?? region.title ?? identity.id,\n // Anchored at its heading, or at the row when the register is a table.\n at: at(region.start, Math.min(region.end, region.heading?.end ?? region.row?.end ?? region.end)),\n path: input.path,\n aliases: identity.aliases,\n // A section of a journal is part of the journal, whatever status word it\n // wrote for itself. Being a record is a statement about the file made from\n // outside it, and it does not stop at a heading.\n phase: record ? 'record' : declaredPhase !== 'unknown' ? declaredPhase : pathPhase,\n rawStatus,\n statusAt,\n frontMatter: {},\n };\n\n const anchors = new Set<string>(\n scanned.headings.filter((h) => h.start >= region.start && h.start < region.end).map((h) => h.slug),\n );\n\n // Relations a table declares by column, typed by the header the author wrote.\n const references: ReferenceCandidate[] = region.relations.map((relation) => ({\n kind: relation.kind,\n from: document.id,\n target: relation.target,\n origin: 'front-matter' as const,\n declaredAt: at(relation.start, relation.end),\n raw: `${relation.column}: ${relation.target}`,\n inverted: relation.inverted,\n opportunistic: false,\n }));\n\n return {\n region,\n document,\n extracted: {\n document,\n items: [],\n references,\n problems: [],\n anchors,\n identity,\n scanned,\n subSpecifications: [],\n containerId: context.containerId,\n },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Status */\n/* -------------------------------------------------------------------------- */\n\ninterface StatusReading {\n readonly raw: string | null;\n readonly at: SourceRef | null;\n readonly phase: Phase;\n}\n\n/**\n * Finds the document status.\n *\n * Looks in the three places teams actually put it, in descending order of how\n * deliberate each is: a directive, a front-matter field, then the body of a\n * `## Status` section. A repository using none of them still gets a phase from\n * its directory layout, which is handled by the caller.\n */\nfunction readStatus(\n scanned: ScannedDocument,\n byKey: ReadonlyMap<string, YamlEntry>,\n nodeDirective: Directive | null,\n index: LineIndex,\n file: string,\n): StatusReading {\n if (nodeDirective) {\n const declared = attr(nodeDirective, 'status');\n if (declared) {\n return {\n raw: declared.value,\n at: refOf(file, index, declared.start, declared.end),\n phase: phaseOf(declared.value),\n };\n }\n }\n\n for (const key of STATUS_KEYS) {\n const entry = byKey.get(key);\n if (!entry) continue;\n const raw = typeof entry.value === 'string' ? entry.value : entry.value.join(', ');\n if (raw.trim().length === 0) continue;\n return {\n raw,\n at: refOf(file, index, entry.valueStart, entry.end),\n phase: phaseOf(raw),\n };\n }\n\n const heading = scanned.headings.find((h) => isStatusHeading(h.text));\n if (heading) {\n const body = statusSectionBody(scanned, heading.line);\n if (body) {\n return {\n raw: body.text,\n at: refOf(file, index, body.start, body.end),\n phase: phaseOf(body.text),\n };\n }\n }\n\n return { raw: null, at: null, phase: 'unknown' };\n}\n\n/** The first non-blank line under a `## Status` heading. */\nfunction statusSectionBody(\n scanned: ScannedDocument,\n headingLine: number,\n): { text: string; start: number; end: number } | null {\n for (const line of scanned.lines) {\n if (line.line <= headingLine) continue;\n if (line.blank) continue;\n if (line.code) return null;\n const trimmed = line.content.trim();\n // A heading immediately after means the section is empty.\n if (trimmed.startsWith('#')) return null;\n const offset = line.contentStart + line.content.indexOf(trimmed);\n // Bullet lists under Status are a status history; take the first entry.\n const cleaned = trimmed.replace(/^[-*+]\\s+/, '');\n const start = offset + (trimmed.length - cleaned.length);\n return { text: cleaned, start, end: start + cleaned.length };\n }\n return null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Items */\n/* -------------------------------------------------------------------------- */\n\ninterface ItemContext {\n readonly scanned: ScannedDocument;\n readonly directives: readonly Directive[];\n /** The specification that owns an offset, which in a register is a section. */\n readonly ownerAt: (offset: number) => string;\n readonly file: string;\n readonly index: LineIndex;\n}\n\nfunction extractItems(context: ItemContext): ItemNode[] {\n const { scanned, directives, ownerAt, file, index } = context;\n const out: ItemNode[] = [];\n const ordinals = new Map<string, number>();\n\n for (const item of scanned.listItems) {\n const section = sectionPathAt(scanned, item.start);\n const inObligationSection = section.some((heading) => OBLIGATION_SECTIONS.has(normaliseHeading(heading)));\n const directive = directiveFor(directives, 'spec-item', { start: item.start, end: item.end }, 200);\n\n if (!isObligation(item, inObligationSection, directive)) continue;\n\n const documentId = ownerAt(item.start);\n const slug = section.length > 0 ? slugify(section[section.length - 1] as string) : 'item';\n // Ordinals count within a specification, so two decisions in one register\n // each get their own `#open-questions.1` rather than sharing a sequence.\n const key = `${documentId}#${slug}`;\n const ordinal = (ordinals.get(key) ?? 0) + 1;\n ordinals.set(key, ordinal);\n\n const declaredId = directive ? attr(directive, 'id')?.value : null;\n const id = `${documentId}#${declaredId ?? `${slug}.${ordinal}`}`;\n\n const state = resolveItemState({\n file,\n index,\n item,\n section,\n directive,\n inObligationSection,\n });\n\n out.push({\n id,\n kind: 'item',\n title: (directive ? attr(directive, 'title')?.value : null) ?? summarise(item.firstLine),\n at: refOf(file, index, item.start, item.end),\n document: documentId,\n section,\n text: summarise(item.firstLine),\n body: item.body,\n disposition: state.disposition,\n openness: state.openness,\n evidence: state.evidence,\n conflicts: state.conflicts,\n });\n }\n\n return out;\n}\n\n/**\n * Decides whether a bullet is an obligation.\n *\n * A checkbox or an explicit directive always makes one. Otherwise only\n * top-level bullets under a heading like \"Open Questions\" count: promoting\n * every bullet in a specification would bury the real obligations under the\n * document's own prose.\n */\nfunction isObligation(item: ListItem, inObligationSection: boolean, directive: Directive | null): boolean {\n if (directive !== null) return true;\n if (item.checkbox !== null) return true;\n return inObligationSection && item.depth === 0;\n}\n\n/** The heading path enclosing an offset, outermost first. */\nfunction sectionPathAt(scanned: ScannedDocument, offset: number): string[] {\n const path: { level: number; text: string }[] = [];\n for (const heading of scanned.headings) {\n if (heading.start > offset) break;\n while (path.length > 0 && (path[path.length - 1] as { level: number }).level >= heading.level) path.pop();\n path.push({ level: heading.level, text: heading.text });\n }\n return path.map((entry) => entry.text);\n}\n\n/**\n * Memoised because it is called for every heading above every reference and\n * every item, and a corpus has only a handful of distinct headings - `Context`,\n * `Decision`, `Open Questions`, `See also` - repeated thousands of times.\n */\nconst headingCache = new Map<string, string>();\n\nfunction normaliseHeading(text: string): string {\n const cached = headingCache.get(text);\n if (cached !== undefined) return cached;\n const normalised = text\n .toLowerCase()\n .replace(/[`*_~]/g, '')\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n .replace(/\\s+/g, ' ')\n .trim();\n // Bounded so a pathological corpus of unique headings cannot grow it forever.\n if (headingCache.size < 4096) headingCache.set(text, normalised);\n return normalised;\n}\n\n/**\n * One-line form of an item for reports.\n *\n * Link syntax is flattened to its label. A finding that quotes the obligation\n * back at the reader should read like the sentence they wrote, not like the\n * Markdown source of it.\n */\nfunction summarise(text: string): string {\n const flat = text\n .replace(/!?\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n // `[[target|display]]` keeps the display half: that is the text a reader\n // of the rendered document actually sees.\n .replace(/\\[\\[(?:[^\\]|]*\\|)?([^\\]]*)\\]\\]/g, '$1')\n .replace(/\\s+/g, ' ')\n .trim();\n return flat.length <= 120 ? flat : `${flat.slice(0, 117)}...`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* References */\n/* -------------------------------------------------------------------------- */\n\ninterface ReferenceContext {\n readonly scanned: ScannedDocument;\n readonly directives: readonly Directive[];\n readonly document: DocumentNode;\n /** The specification that owns an offset, for a reference outside any item. */\n readonly documentAt: (offset: number) => DocumentNode;\n readonly items: readonly ItemNode[];\n readonly byKey: ReadonlyMap<string, YamlEntry>;\n readonly status: StatusReading;\n /** Cell ranges already typed by a table column header. */\n readonly claimed: readonly { start: number; end: number }[];\n readonly file: string;\n readonly index: LineIndex;\n}\n\n/** True when an offset falls in a cell a column header already accounted for. */\nfunction isClaimed(claimed: readonly { start: number; end: number }[], offset: number): boolean {\n return claimed.some((range) => offset >= range.start && offset < range.end);\n}\n\nfunction extractReferences(context: ReferenceContext): ReferenceCandidate[] {\n const { scanned, directives, document, documentAt, items, byKey, status, claimed, file, index } = context;\n const out: ReferenceCandidate[] = [];\n const at = (start: number, end: number): SourceRef => refOf(file, index, start, end);\n\n // Front matter.\n for (const [key, relation] of Object.entries(RELATION_KEYS)) {\n const entry = byKey.get(key) ?? byKey.get(key.replace(/-/g, '_'));\n if (!entry) continue;\n for (const value of valuesOf(entry)) {\n const target = cleanTarget(value);\n if (target.length === 0) continue;\n out.push({\n kind: relation.kind,\n from: document.id,\n target,\n origin: 'front-matter',\n declaredAt: at(entry.valueStart, entry.end),\n raw: `${key}: ${value}`,\n inverted: relation.inverted,\n opportunistic: false,\n });\n }\n }\n\n // `status: Superseded by ADR-0009` is the most common supersession record of\n // all, and it never appears as a field of its own.\n if (status.raw && status.at) {\n for (const target of supersessionTargetsIn(status.raw)) {\n const cleaned = cleanTarget(target);\n if (cleaned.length === 0) continue;\n out.push({\n kind: 'supersedes',\n from: document.id,\n target: cleaned,\n origin: 'front-matter',\n declaredAt: status.at,\n raw: status.raw,\n inverted: true,\n opportunistic: true,\n });\n }\n }\n\n // Explicit edge directives.\n for (const directive of directives) {\n if (directive.name !== 'spec-edge') continue;\n const kind = attr(directive, 'kind')?.value as EdgeKind | undefined;\n const to = attr(directive, 'to');\n const from = attr(directive, 'from');\n if (!kind) continue;\n const owner = ownerOf(items, directive.start) ?? documentAt(directive.start).id;\n if (to) {\n out.push({\n kind,\n from: owner,\n target: to.value,\n origin: 'directive',\n declaredAt: at(to.start, to.end),\n raw: `@spec-edge kind=\"${kind}\" to=\"${to.value}\"`,\n inverted: false,\n opportunistic: false,\n });\n }\n if (from) {\n out.push({\n kind,\n from: owner,\n target: from.value,\n origin: 'directive',\n declaredAt: at(from.start, from.end),\n raw: `@spec-edge kind=\"${kind}\" from=\"${from.value}\"`,\n inverted: true,\n opportunistic: false,\n });\n }\n }\n\n // Prose links. A cell whose meaning a column header already gave is skipped,\n // so `| ADR-0002 | ... | [ADR-0001](0001.md) |` yields one typed edge rather\n // than a typed edge and a neutral citation beside it.\n const linked = new Set<string>();\n for (const link of scanned.links) {\n if (link.form === 'definition') continue;\n if (isClaimed(claimed, link.start)) continue;\n const target = cleanTarget(link.target);\n if (target.length === 0) continue;\n if (isExternal(target)) continue;\n\n const owner = ownerOf(items, link.start) ?? documentAt(link.start).id;\n const section = sectionPathAt(scanned, link.start);\n const classified = classifyReference(scanned.masked, link.start, link.end, section);\n\n linked.add(normaliseRef(stripAnchor(target)));\n out.push({\n kind: classified.kind,\n from: owner,\n target,\n origin: 'link',\n declaredAt: at(link.targetStart, link.targetStart + link.target.length),\n raw: renderLink(link),\n inverted: classified.inverted,\n opportunistic: false,\n });\n }\n\n // Bare identifiers in prose. Everything already covered by a link is skipped\n // so a citation written as `[ADR-7](0007.md)` is not counted twice.\n for (const bare of findBareReferences(scanned)) {\n const key = normaliseRef(bare.text);\n if (linked.has(key)) continue;\n if (isClaimed(claimed, bare.start)) continue;\n const owner = ownerOf(items, bare.start) ?? documentAt(bare.start).id;\n const section = sectionPathAt(scanned, bare.start);\n const classified = classifyReference(scanned.masked, bare.start, bare.end, section);\n out.push({\n kind: classified.kind,\n from: owner,\n target: bare.text,\n origin: 'text',\n declaredAt: at(bare.start, bare.end),\n raw: bare.text,\n inverted: classified.inverted,\n opportunistic: true,\n });\n }\n\n return out;\n}\n\n/** The item whose block contains an offset, if any. */\nfunction ownerOf(items: readonly ItemNode[], offset: number): string | null {\n let best: ItemNode | null = null;\n for (const item of items) {\n const span = item.at.span;\n if (offset < span.start.offset || offset >= span.end.offset) continue;\n // Innermost wins when items nest.\n if (best === null || span.start.offset > best.at.span.start.offset) best = item;\n }\n return best?.id ?? null;\n}\n\nexport interface Classification {\n readonly kind: EdgeKind;\n readonly inverted: boolean;\n}\n\n/**\n * Decides what a reference means from the words around it.\n *\n * The nearest governing phrase within {@link VERB_WINDOW} characters wins, and\n * the search never crosses a sentence boundary. With nothing to go on, a\n * reference under a \"See also\" heading is bookkeeping and everything else is a\n * neutral citation.\n */\nexport function classifyReference(\n text: string,\n start: number,\n end: number,\n section: readonly string[],\n): Classification {\n const before = sentenceBefore(text, start);\n\n // Left to right, so the last match within the window is the nearest one - and\n // the nearest governing phrase is the one that governs.\n let best: Classification | null = null;\n VERB_PATTERN.lastIndex = 0;\n for (let m = VERB_PATTERN.exec(before); m !== null; m = VERB_PATTERN.exec(before)) {\n const phrase = m[0] as string;\n const end = (m.index ?? 0) + phrase.length;\n const distance = before.length - end;\n if (distance > VERB_WINDOW) continue;\n // What sits between the phrase and the reference has to be connective. A\n // negation in there reverses the claim the phrase would otherwise make.\n if (NEGATION.test(before.slice(end))) continue;\n const rule = VERB_LOOKUP.get(phrase);\n if (rule) best = rule;\n }\n\n if (best) return best;\n\n // \"[ADR-0009] supersedes this decision\": the reference is the subject, so the\n // relation runs the other way.\n const after = sentenceAfter(text, end);\n for (const rule of VERB_RULES) {\n if (rule.inverted) continue;\n for (const phrase of rule.phrases) {\n if (!after.startsWith(phrase)) continue;\n if (rule.kind === 'assumes' || rule.kind === 'depends-on') continue;\n return { kind: rule.kind, inverted: true };\n }\n }\n\n const innermost = section.length > 0 ? normaliseHeading(section[section.length - 1] as string) : '';\n if (WEAK_SECTIONS.has(innermost)) return { kind: 'relates-to', inverted: false };\n for (const heading of section) {\n if (WEAK_SECTIONS.has(normaliseHeading(heading))) return { kind: 'relates-to', inverted: false };\n }\n\n return { kind: 'references', inverted: false };\n}\n\n/** A sentence end, a blank line, or the start of a new block-level item. */\n/**\n * A table cell edge ends a statement too.\n *\n * The pipe matters more than it looks. A table row is a list of independent\n * fields, and without it the look-behind window reaches back across the row\n * boundary into the previous row's prose. An index of archived documents whose\n * last column ended \"...before assuming the drift was fixed\" turned every\n * following row's link into an `assumes` edge, and so turned every archived\n * document it listed into a stale premise.\n */\nconst STATEMENT_BREAK = /[.?!;]\\s|\\n\\s*\\n|\\n\\s*[-*+>#]|\\|/g;\n\n/**\n * Lower-cased, whitespace-collapsed text back to the start of the statement.\n *\n * The search stops at the last boundary: a governing phrase in the *previous*\n * sentence does not govern this reference. \"We deferred that to ADR-3. See also\n * [ADR-9].\" must not read as a delegation to ADR-9.\n */\nfunction sentenceBefore(text: string, start: number): string {\n const window = text.slice(Math.max(0, start - 160), start);\n let cut = 0;\n STATEMENT_BREAK.lastIndex = 0;\n for (let m = STATEMENT_BREAK.exec(window); m !== null; m = STATEMENT_BREAK.exec(window)) {\n cut = (m.index ?? 0) + (m[0] as string).length;\n }\n return window\n .slice(cut)\n .toLowerCase()\n .replace(/[`*_~\"'()\\[\\],]/g, ' ')\n .replace(/\\s+/g, ' ');\n}\n\nfunction sentenceAfter(text: string, end: number): string {\n const window = text.slice(end, Math.min(text.length, end + 80));\n const stop = /[.?!;\\n|]/.exec(window);\n const cut = stop ? window.slice(0, stop.index) : window;\n return cut.toLowerCase().replace(/[`*_~\"'()\\[\\],]/g, ' ').replace(/\\s+/g, ' ').trim();\n}\n\ninterface BareReference {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\n/**\n * Finds identifiers written as plain prose, such as \"as decided in ADR-0007\".\n *\n * Link constructs are blanked first. Without that, `[ADR-7](https://x/adr-7)`\n * would yield three references to the same thing - one real and two harvested\n * out of a URL - which is precisely the mis-match that makes hand-rolled regex\n * checks untrustworthy.\n */\nfunction findBareReferences(scanned: ScannedDocument): BareReference[] {\n // Slice-based for the same reason as the scanner's masking: this runs over\n // every document, and a per-character array is the wrong shape for the job.\n const source = scanned.masked;\n let text = '';\n let cursor = 0;\n for (const link of scanned.links) {\n const start = Math.max(link.start, cursor);\n const end = Math.min(link.end, source.length);\n if (end <= start) continue;\n text += source.slice(cursor, start);\n text += source.slice(start, end).replace(/[^\\n\\r]/g, ' ');\n cursor = end;\n }\n text += source.slice(cursor);\n\n const out: BareReference[] = [];\n BARE_REF.lastIndex = 0;\n for (let m = BARE_REF.exec(text); m !== null; m = BARE_REF.exec(text)) {\n const prefix = (m[1] as string).toLowerCase();\n if (NOT_A_FAMILY.has(prefix)) continue;\n if (prefix.length < 2) continue;\n const start = m.index ?? 0;\n // A token glued to a path separator or an extension is not a citation.\n const before = text[start - 1] ?? ' ';\n const after = text[start + (m[0] as string).length] ?? ' ';\n if (before === '/' || before === '.' || after === '/') continue;\n out.push({ text: m[0] as string, start, end: start + (m[0] as string).length });\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------------- */\n\nfunction firstValue(byKey: ReadonlyMap<string, YamlEntry>, keys: readonly string[]): string | null {\n for (const key of keys) {\n const entry = byKey.get(key);\n if (!entry) continue;\n const value = asString(entry);\n if (value !== null && value.length > 0) return value;\n }\n return null;\n}\n\nfunction asString(entry: YamlEntry | undefined): string | null {\n if (!entry) return null;\n if (typeof entry.value === 'string') return entry.value.trim().length > 0 ? entry.value.trim() : null;\n return entry.value.length > 0 ? (entry.value[0] as string) : null;\n}\n\n/** Strips Markdown decoration a target may still be wearing. */\nfunction cleanTarget(value: string): string {\n return value\n .trim()\n .replace(/^[`'\"<(\\[]+/, '')\n .replace(/[`'\">)\\]]+$/, '')\n .replace(/[.,;]+$/, '')\n .trim();\n}\n\nfunction stripAnchor(target: string): string {\n const hash = target.indexOf('#');\n return hash <= 0 ? target : target.slice(0, hash);\n}\n\nfunction renderLink(link: Link): string {\n switch (link.form) {\n case 'wiki':\n return `[[${link.target}]]`;\n case 'autolink':\n return `<${link.target}>`;\n case 'reference':\n case 'shortcut':\n return `[${link.text}][${link.target}]`;\n default:\n return `[${link.text}](${link.target})`;\n }\n}\n\n/** Exposed for tests and for callers that classify their own sections. */\nexport { OBLIGATION_SECTIONS, sectionPathAt, WEAK_SECTIONS };\n"]}
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAyB,OAAO,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,OAAO,EAAkD,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAA4B,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAkB,MAAM,aAAa,CAAC;AAUpD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAkB,MAAM,WAAW,CAAC;AA6DjF,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,qEAAqE;AACrE,MAAM,aAAa,GAAoE;IACrF,UAAU,EAAE,EAAE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AC,CAAC,CAAC,IAAI,CAAC;IACtG,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AACpE,CAAC;AAED,gEAAgE;AAChE,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK;SACT,IAAI,EAAE;SACN,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;SAC1B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;SAC1B,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC;QAC9B,KAAK,UAAU;YACb,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAC5B,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;QAC1C;YACE,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;IAC5C,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC","sourcesContent":["/**\n * Document extraction: Markdown in, graph fragments out.\n *\n * This module is where domain-agnosticism is won or lost. It never requires a\n * repository to adopt a syntax. It reads what teams already write - front\n * matter, a `## Status` section, a checklist under `## Open Questions`, a link\n * that says \"deferred to ADR-0011\" - and turns each into a typed relation with a\n * source position.\n *\n * The one rule it holds to everywhere: **an inference that cannot be justified\n * is not made.** An unrecognised status becomes `unknown`, not a guess. A link\n * with no governing verb becomes a neutral `references`, not a dependency. Bare\n * identifiers found in prose are opportunistic and are dropped silently when\n * they do not resolve, because the alternative is reporting `SHA-256` as a\n * broken reference to specification 256.\n */\n\nimport { attr, attrList, directiveFor, parseDirectives, type Directive } from './directives.js';\nimport { identify, isExternal, normaliseRef, type DocumentIdentity, ID_KEYS } from './identity.js';\nimport { isStatusHeading, phaseFromPath, phaseOf, STATUS_KEYS, supersessionTargetsIn } from './lifecycle.js';\nimport { scanMarkdown, slugify, type Link, type ListItem, type ScannedDocument } from './markdown.js';\nimport { findSpecificationRegions, regionAt, type SpecificationRegion } from './sections.js';\nimport { resolveItemState } from './state.js';\nimport { refOf, type LineIndex } from './source.js';\nimport type {\n DocumentNode,\n EdgeKind,\n EdgeOrigin,\n ItemNode,\n ParseProblem,\n Phase,\n SourceRef,\n} from './types.js';\nimport { parseFrontMatter, toRecord, valuesOf, type YamlEntry } from './yaml.js';\n\n/* -------------------------------------------------------------------------- */\n/* Output */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A relation that has been read but not yet resolved to a target node.\n *\n * Resolution needs the whole corpus, so extraction stops at the raw target text.\n */\nexport interface ReferenceCandidate {\n readonly kind: EdgeKind;\n /** Id of the node the relation was written on. */\n readonly from: string;\n /** The target exactly as written: a path, an identifier, or a URL. */\n readonly target: string;\n readonly origin: EdgeOrigin;\n readonly declaredAt: SourceRef;\n readonly raw: string;\n /**\n * When true the relation runs `target -> from`.\n *\n * `superseded-by: ADR-0009` written in ADR-0003 declares that *ADR-0009*\n * supersedes ADR-0003. The edge belongs to ADR-0009; the line a human must go\n * and fix is in ADR-0003, which is why `declaredAt` is tracked separately.\n */\n readonly inverted: boolean;\n /**\n * Opportunistic references are dropped in silence when they do not resolve.\n * Only deliberate ones - links, front matter, directives - are reported.\n */\n readonly opportunistic: boolean;\n}\n\nexport interface ExtractedDocument {\n readonly document: DocumentNode;\n readonly items: readonly ItemNode[];\n readonly references: readonly ReferenceCandidate[];\n readonly problems: readonly ParseProblem[];\n /** Heading slugs, for resolving `#anchor` references into this document. */\n readonly anchors: ReadonlySet<string>;\n readonly identity: DocumentIdentity;\n readonly scanned: ScannedDocument;\n /**\n * Specifications declared inside this file, each a document in its own right.\n *\n * Empty for the ordinary one-file-per-decision layout, which is why nothing\n * downstream had to change to support registers.\n */\n readonly subSpecifications: readonly ExtractedDocument[];\n /**\n * The file-level specification this one is a region of, if any.\n *\n * Recorded so the register's structure is a relation in the graph rather than\n * an accident of which offsets fall inside which: \"what decisions does this\n * register hold\" is a question worth being able to ask.\n */\n readonly containerId: string | null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Vocabulary */\n/* -------------------------------------------------------------------------- */\n\n/** Front-matter keys that declare a relation, and what they mean. */\nconst RELATION_KEYS: Readonly<Record<string, { kind: EdgeKind; inverted: boolean }>> = {\n supersedes: { kind: 'supersedes', inverted: false },\n supercedes: { kind: 'supersedes', inverted: false },\n replaces: { kind: 'supersedes', inverted: false },\n obsoletes: { kind: 'supersedes', inverted: false },\n 'superseded-by': { kind: 'supersedes', inverted: true },\n 'superceded-by': { kind: 'supersedes', inverted: true },\n 'replaced-by': { kind: 'supersedes', inverted: true },\n 'obsoleted-by': { kind: 'supersedes', inverted: true },\n amends: { kind: 'amends', inverted: false },\n extends: { kind: 'amends', inverted: false },\n 'amended-by': { kind: 'amends', inverted: true },\n 'depends-on': { kind: 'depends-on', inverted: false },\n dependencies: { kind: 'depends-on', inverted: false },\n requires: { kind: 'depends-on', inverted: false },\n assumes: { kind: 'assumes', inverted: false },\n 'blocked-by': { kind: 'blocked-by', inverted: false },\n blocks: { kind: 'blocked-by', inverted: true },\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 'relates-to': { kind: 'relates-to', inverted: false },\n 'see-also': { kind: 'relates-to', inverted: false },\n references: { kind: 'references', inverted: false },\n refs: { kind: 'references', inverted: false },\n};\n\n/**\n * Phrases that give a link its meaning, longest-matching-nearest wins.\n *\n * Only phrases that genuinely commit the citing document are here. Vague ones\n * (\"see\", \"covered by\") stay out: a `references` edge is harmless, whereas a\n * wrongly inferred `assumes` edge produces a confident stale-premise finding\n * about a document that never depended on anything.\n */\nconst VERB_RULES: readonly { kind: EdgeKind; inverted: boolean; phrases: readonly string[] }[] = [\n {\n kind: 'supersedes',\n inverted: true,\n phrases: ['superseded by', 'superceded by', 'replaced by', 'obsoleted by', 'deprecated by', 'rolled into'],\n },\n { kind: 'supersedes', inverted: false, phrases: ['supersedes', 'supercedes', 'replaces', 'obsoletes', 'deprecates'] },\n { kind: 'amends', inverted: true, phrases: ['amended by', 'refined by', 'clarified by', 'revised by'] },\n { kind: 'amends', inverted: false, phrases: ['amends', 'refines', 'clarifies', 'revises'] },\n {\n kind: 'delegates-to',\n inverted: false,\n phrases: [\n 'delegated to',\n 'delegate to',\n 'deferred to',\n 'defer to',\n 'moved to',\n 'move to',\n 'tracked in',\n 'tracked by',\n 'handed off to',\n 'handed to',\n 'hand off to',\n 'follow up in',\n 'follow-up in',\n 'followup in',\n 'continued in',\n 'continues in',\n 'punted to',\n 'left to',\n 'belongs in',\n 'owned by',\n 'will be decided in',\n 'will be resolved in',\n 'will be handled in',\n 'will be handled by',\n 'will be answered in',\n 'to be decided in',\n 'to be resolved in',\n 'to be handled in',\n 'to be answered in',\n ],\n },\n {\n kind: 'blocked-by',\n inverted: false,\n phrases: ['blocked by', 'blocked on', 'waiting on', 'waiting for', 'gated on', 'gated by', 'unblocked by'],\n },\n { kind: 'blocked-by', inverted: true, phrases: ['blocks', 'blocking'] },\n {\n kind: 'depends-on',\n inverted: false,\n phrases: ['depends on', 'depend on', 'dependent on', 'requires', 'builds on', 'built on', 'relies on'],\n },\n { kind: 'depends-on', inverted: true, phrases: ['depended on by'] },\n {\n kind: 'assumes',\n inverted: false,\n phrases: [\n 'assumes',\n 'assuming',\n 'on the assumption of',\n 'as decided in',\n 'as established in',\n 'as established by',\n 'as stated in',\n 'as specified in',\n 'as required by',\n 'as mandated by',\n 'in accordance with',\n 'constrained by',\n 'mandated by',\n 'governed by',\n 'predicated on',\n 'rests on',\n 'follows from',\n 'justified by',\n // A constraint the citing document designs around. \"the row limit imposed\n // by ADR-0002\" is the archetypal stale premise: when ADR-0002 is retired,\n // this document is still working around a cap that no longer exists.\n 'imposed by',\n 'required by',\n 'dictated by',\n 'determined by',\n 'limited by',\n 'capped by',\n 'bounded by',\n 'defined by',\n 'defined in',\n 'specified by',\n 'set by',\n 'per',\n 'because',\n 'since',\n ],\n },\n];\n\n/**\n * Words that cancel a governing phrase standing before them.\n *\n * The window allows a short noun phrase between a verb and the reference it\n * governs - \"deferred to the sharding decision in [ADR-7]\" is one statement.\n * It cannot allow a negation. A table entry reading \"Owned by nobody today and\n * disclaimed by [138]\" was being read as a delegation *to* 138, which is the\n * opposite of what the sentence says, and an inference that inverts its source\n * is worse than no inference at all.\n */\nconst NEGATION = /(?:^|\\s)(?:no|not|nobody|none|never|neither|nor|nothing|without)(?:\\s|$)/;\n\n/** How close a governing phrase must sit to the reference it governs. */\nconst VERB_WINDOW = 40;\n\n/**\n * Every governing phrase compiled into one alternation, plus a lookup table.\n *\n * Classification runs on every reference in the corpus, and testing a hundred\n * phrases one at a time made it the most expensive thing extraction did. The\n * alternation is sorted longest-first so that at any given position the regex\n * prefers `partially resolved` over `resolved`, matching the precedence the\n * per-phrase search had. Lookarounds rather than `\\b`, because phrases contain\n * hyphens and `\\b` does the wrong thing around them.\n */\nconst VERB_LOOKUP: ReadonlyMap<string, Classification> = new Map(\n VERB_RULES.flatMap((rule) =>\n rule.phrases.map((phrase) => [phrase, { kind: rule.kind, inverted: rule.inverted }] as const),\n ),\n);\n\nconst VERB_PATTERN = new RegExp(\n `(?<![\\\\p{L}\\\\p{N}])(?:${[...VERB_LOOKUP.keys()]\n .sort((a, b) => b.length - a.length)\n .map((phrase) => phrase.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('|')})(?![\\\\p{L}\\\\p{N}])`,\n 'gu',\n);\n\n/** Headings under which a link is bookkeeping rather than a commitment. */\nconst WEAK_SECTIONS: ReadonlySet<string> = new Set([\n 'see also',\n 'references',\n 'reference',\n 'related',\n 'related work',\n 'related decisions',\n 'related documents',\n 'links',\n 'further reading',\n 'prior art',\n 'history',\n 'changelog',\n 'change log',\n 'revision history',\n 'bibliography',\n 'sources',\n 'appendix',\n 'more information',\n 'resources',\n 'index',\n]);\n\n/** Headings whose bullets are obligations even without a checkbox. */\nconst OBLIGATION_SECTIONS: ReadonlySet<string> = new Set([\n 'open questions',\n 'open question',\n 'unresolved questions',\n 'unanswered questions',\n 'questions',\n 'open issues',\n 'action items',\n 'actions',\n 'todo',\n 'to do',\n 'to-do',\n 'todos',\n 'next steps',\n 'follow ups',\n 'follow-ups',\n 'followups',\n 'follow up',\n 'follow-up',\n 'unresolved',\n 'outstanding',\n 'outstanding questions',\n 'tasks',\n 'task list',\n 'work items',\n 'remaining work',\n 'decisions needed',\n 'blockers',\n 'parking lot',\n 'future work',\n 'deferred',\n]);\n\n/**\n * Prefixes that look like specification identifiers but never are.\n *\n * The corpus filter in `resolve.ts` is the real defence; this list only keeps\n * the obvious noise out of the candidate set.\n */\nconst NOT_A_FAMILY: ReadonlySet<string> = new Set([\n 'v',\n 'ver',\n 'version',\n 'p',\n 'pp',\n 'fig',\n 'figure',\n 'table',\n 'tbl',\n 'section',\n 'sect',\n 'sec',\n 'step',\n 'item',\n 'no',\n 'num',\n 'line',\n 'ln',\n 'col',\n 'port',\n 'pr',\n 'issue',\n 'gh',\n 'utf',\n 'ascii',\n 'sha',\n 'md',\n 'http',\n 'https',\n 'ipv',\n 'tls',\n 'ssl',\n 'es',\n 'ecma',\n 'x',\n 'h',\n 'p99',\n 'base',\n 'sql',\n 'ipv4',\n 'ipv6',\n 'arm',\n 'x86',\n 'win',\n 'node',\n 'python',\n 'java',\n 'go',\n 'c',\n 'cpp',\n]);\n\nconst BARE_REF = /\\b([A-Za-z][A-Za-z0-9]{0,14})[\\s._-]?(\\d{1,6})\\b/g;\n\n/* -------------------------------------------------------------------------- */\n/* Extraction */\n/* -------------------------------------------------------------------------- */\n\nexport interface ExtractInput {\n /** Repository-relative POSIX path. */\n readonly path: string;\n readonly text: string;\n /**\n * This file is a historical record: a log of what was decided, not a\n * decision. Matched against the caller's history patterns, because deciding\n * which files those are is a repository's business and not a guess this\n * layer could justify making. See ADR-0011.\n */\n readonly record?: boolean | undefined;\n}\n\n/**\n * Reads one file into graph fragments, one entry per specification in it.\n *\n * A file yields at least itself. It yields more when it is a register: a\n * heading that carries an identifier *and* declares a status is a specification\n * in its own right, with its own lifecycle, its own obligations and its own\n * relations. See ADR-0009.\n */\nexport function extractSpecifications(input: ExtractInput): ExtractedDocument[] {\n const first = extractDocument(input);\n return first === null ? [] : [first, ...(first.subSpecifications as ExtractedDocument[])];\n}\n\n/** Reads a file's own specification. Returns `null` when it opts out. */\nexport function extractDocument(input: ExtractInput): ExtractedDocument | null {\n const scanned = scanMarkdown(input.text);\n const directives = parseDirectives(scanned.comments);\n if (directives.some((d) => d.name === 'spec-ignore')) return null;\n\n const index = scanned.index;\n const file = input.path;\n const problems: ParseProblem[] = [];\n const at = (start: number, end: number): SourceRef => refOf(file, index, start, end);\n\n for (const directive of directives) {\n for (const unknown of directive.unknownAttributes) {\n problems.push({\n message: `unknown attribute \"${unknown}\" on @${directive.name}`,\n at: at(directive.start, directive.end),\n });\n }\n }\n\n const entries = scanned.frontMatter ? parseFrontMatter(scanned.frontMatter.raw, scanned.frontMatter.start) : [];\n const byKey = new Map<string, YamlEntry>();\n for (const entry of entries) byKey.set(entry.key, entry);\n\n const h1 = scanned.headings.find((h) => h.level === 1) ?? null;\n const frontMatterId = firstValue(byKey, ID_KEYS) ?? null;\n\n const identityOf = (declaredId: string | null, directive: Directive | null): DocumentIdentity =>\n identify({\n path: input.path,\n declaredId,\n declaredAliases: [\n ...(directive ? attrList(directive, 'aliases') : []),\n ...valuesOf(byKey.get('aliases')),\n ...valuesOf(byKey.get('alias')),\n ],\n heading: h1?.text ?? null,\n });\n\n // A `@spec-node` written inside a register's section belongs to that section,\n // not to the file. Finding the file's own therefore needs the regions, and\n // finding the regions needs the file's identity - so the identity is settled\n // provisionally first, then again once the file's own directive is known.\n const provisional = identityOf(frontMatterId, null);\n const provisionalRegions = findSpecificationRegions(scanned, directives, provisional.id);\n const nodeDirective =\n directives.find(\n (directive) =>\n directive.name === 'spec-node' &&\n !provisionalRegions.some(\n (region) =>\n (region.heading !== null || region.row !== null) &&\n directive.start >= region.start &&\n directive.end <= region.end,\n ),\n ) ?? null;\n\n const declaredId = (nodeDirective ? attr(nodeDirective, 'id')?.value : null) ?? frontMatterId;\n const identity = declaredId === frontMatterId && nodeDirective === null\n ? provisional\n : identityOf(declaredId, nodeDirective);\n\n const status = readStatus(scanned, byKey, nodeDirective, index, file);\n const pathPhase = phaseFromPath(input.path);\n // A record is a categorical statement about what the file *is*, made by\n // configuration or by an explicit directive, so it outranks a status word\n // that happened to be written inside it.\n const record = input.record === true || directives.some((directive) => directive.name === 'spec-history');\n const phase: Phase = record ? 'record' : status.phase !== 'unknown' ? status.phase : pathPhase;\n\n const title =\n (nodeDirective ? attr(nodeDirective, 'title')?.value : null) ??\n asString(byKey.get('title')) ??\n h1?.text ??\n identity.id;\n\n const document: DocumentNode = {\n id: identity.id,\n kind: 'document',\n title,\n at: at(0, Math.min(scanned.text.length, index.lineEnd(1))),\n path: input.path,\n aliases: identity.aliases,\n phase,\n rawStatus: status.raw,\n statusAt: status.at,\n frontMatter: toRecord(entries),\n };\n\n // A register's sections are specifications too. The file is always the first\n // region, so a one-decision file behaves exactly as it did before.\n const regions =\n identity.id === provisional.id ? provisionalRegions : findSpecificationRegions(scanned, directives, identity.id);\n // Every region but the first: a heading section, or a row of a register kept\n // as a table.\n const subSpecifications = regions\n .filter((region) => region.heading !== null || region.row !== null)\n .map((region) =>\n buildRegion({\n region,\n containerId: identity.id,\n input,\n scanned,\n directives,\n index,\n file,\n pathPhase,\n record,\n }),\n );\n\n const ownerAt = (offset: number): string => {\n const region = regionAt(regions, offset);\n if (region === null) return identity.id;\n const owner = subSpecifications.find((spec) => spec.region === region);\n return owner?.document.id ?? identity.id;\n };\n\n const allItems = extractItems({ scanned, directives, ownerAt, file, index });\n const documentAt = (offset: number): DocumentNode => {\n const id = ownerAt(offset);\n if (id === identity.id) return document;\n return subSpecifications.find((spec) => spec.document.id === id)?.document ?? document;\n };\n\n const allReferences = extractReferences({\n scanned,\n directives,\n document,\n documentAt,\n items: allItems,\n byKey,\n status,\n claimed: regions.flatMap((region) => [...region.claimed]),\n file,\n index,\n });\n\n // Hand each region the items and references that fall inside it.\n const ownItems = allItems.filter((item) => item.document === identity.id);\n const ownReferences = allReferences.filter((reference) => belongsTo(reference, identity.id, allItems));\n const anchors = new Set<string>(scanned.headings.map((h) => h.slug));\n\n const filled = subSpecifications.map((spec) => ({\n ...spec.extracted,\n items: allItems.filter((item) => item.document === spec.document.id),\n references: [\n // Column-declared relations first: they are typed by the header rather\n // than guessed from prose.\n ...spec.extracted.references,\n ...allReferences.filter((reference) => belongsTo(reference, spec.document.id, allItems)),\n ],\n }));\n\n return {\n document,\n items: ownItems,\n references: ownReferences,\n problems,\n anchors,\n identity,\n scanned,\n subSpecifications: filled,\n containerId: null,\n };\n}\n\n/** True when a reference was written on a document or on one of its items. */\nfunction belongsTo(reference: ReferenceCandidate, documentId: string, items: readonly ItemNode[]): boolean {\n if (reference.from === documentId) return true;\n const owner = items.find((item) => item.id === reference.from);\n return owner?.document === documentId;\n}\n\ninterface RegionInput {\n readonly region: SpecificationRegion;\n readonly containerId: string;\n readonly input: ExtractInput;\n readonly scanned: ScannedDocument;\n readonly directives: readonly Directive[];\n readonly index: LineIndex;\n readonly file: string;\n readonly pathPhase: Phase;\n /** The whole file is a historical record, so every part of it is one too. */\n readonly record: boolean;\n}\n\ninterface BuiltRegion {\n readonly region: SpecificationRegion;\n readonly document: DocumentNode;\n readonly extracted: ExtractedDocument;\n}\n\n/**\n * Turns one region into a specification.\n *\n * It produces exactly the `DocumentNode` a whole file produces, which is the\n * reason every rule, query and reporter works on registers without knowing they\n * exist. The only deliberate differences: the node is anchored at its heading\n * rather than at line one, it carries no front matter of its own, and it does\n * not claim the file's path as an alias - the file already does, and two nodes\n * answering to one path would make every link to that file ambiguous.\n */\nfunction buildRegion(context: RegionInput): BuiltRegion {\n const { region, input, scanned, index, file, pathPhase, record } = context;\n const at = (start: number, end: number): SourceRef => refOf(file, index, start, end);\n\n const identity = identify({\n path: input.path,\n declaredId: region.declaredId,\n declaredAliases: region.directive ? attrList(region.directive, 'aliases') : [],\n heading: region.title,\n includePathAliases: false,\n });\n\n const declaredStatus = region.directive ? attr(region.directive, 'status') : null;\n const rawStatus = declaredStatus?.value ?? region.status?.text ?? null;\n const statusAt = declaredStatus\n ? at(declaredStatus.start, declaredStatus.end)\n : region.status\n ? at(region.status.start, region.status.end)\n : null;\n const declaredPhase = phaseOf(rawStatus);\n\n const document: DocumentNode = {\n id: identity.id,\n kind: 'document',\n title: (region.directive ? attr(region.directive, 'title')?.value : null) ?? region.title ?? identity.id,\n // Anchored at its heading, or at the row when the register is a table.\n at: at(region.start, Math.min(region.end, region.heading?.end ?? region.row?.end ?? region.end)),\n path: input.path,\n aliases: identity.aliases,\n // A section of a journal is part of the journal, whatever status word it\n // wrote for itself. Being a record is a statement about the file made from\n // outside it, and it does not stop at a heading.\n phase: record ? 'record' : declaredPhase !== 'unknown' ? declaredPhase : pathPhase,\n rawStatus,\n statusAt,\n frontMatter: {},\n };\n\n const anchors = new Set<string>(\n scanned.headings.filter((h) => h.start >= region.start && h.start < region.end).map((h) => h.slug),\n );\n\n // Relations a table declares by column, typed by the header the author wrote.\n const references: ReferenceCandidate[] = region.relations.map((relation) => ({\n kind: relation.kind,\n from: document.id,\n target: relation.target,\n origin: 'front-matter' as const,\n declaredAt: at(relation.start, relation.end),\n raw: `${relation.column}: ${relation.target}`,\n inverted: relation.inverted,\n opportunistic: false,\n }));\n\n return {\n region,\n document,\n extracted: {\n document,\n items: [],\n references,\n problems: [],\n anchors,\n identity,\n scanned,\n subSpecifications: [],\n containerId: context.containerId,\n },\n };\n}\n\n/* -------------------------------------------------------------------------- */\n/* Status */\n/* -------------------------------------------------------------------------- */\n\ninterface StatusReading {\n readonly raw: string | null;\n readonly at: SourceRef | null;\n readonly phase: Phase;\n}\n\n/**\n * Finds the document status.\n *\n * Looks in the three places teams actually put it, in descending order of how\n * deliberate each is: a directive, a front-matter field, then the body of a\n * `## Status` section. A repository using none of them still gets a phase from\n * its directory layout, which is handled by the caller.\n */\nfunction readStatus(\n scanned: ScannedDocument,\n byKey: ReadonlyMap<string, YamlEntry>,\n nodeDirective: Directive | null,\n index: LineIndex,\n file: string,\n): StatusReading {\n if (nodeDirective) {\n const declared = attr(nodeDirective, 'status');\n if (declared) {\n return {\n raw: declared.value,\n at: refOf(file, index, declared.start, declared.end),\n phase: phaseOf(declared.value),\n };\n }\n }\n\n for (const key of STATUS_KEYS) {\n const entry = byKey.get(key);\n if (!entry) continue;\n const raw = typeof entry.value === 'string' ? entry.value : entry.value.join(', ');\n if (raw.trim().length === 0) continue;\n return {\n raw,\n at: refOf(file, index, entry.valueStart, entry.end),\n phase: phaseOf(raw),\n };\n }\n\n const heading = scanned.headings.find((h) => isStatusHeading(h.text));\n if (heading) {\n const body = statusSectionBody(scanned, heading.line);\n if (body) {\n return {\n raw: body.text,\n at: refOf(file, index, body.start, body.end),\n phase: phaseOf(body.text),\n };\n }\n }\n\n return { raw: null, at: null, phase: 'unknown' };\n}\n\n/** The first non-blank line under a `## Status` heading. */\nfunction statusSectionBody(\n scanned: ScannedDocument,\n headingLine: number,\n): { text: string; start: number; end: number } | null {\n for (const line of scanned.lines) {\n if (line.line <= headingLine) continue;\n if (line.blank) continue;\n if (line.code) return null;\n const trimmed = line.content.trim();\n // A heading immediately after means the section is empty.\n if (trimmed.startsWith('#')) return null;\n const offset = line.contentStart + line.content.indexOf(trimmed);\n // Bullet lists under Status are a status history; take the first entry.\n const cleaned = trimmed.replace(/^[-*+]\\s+/, '');\n const start = offset + (trimmed.length - cleaned.length);\n return { text: cleaned, start, end: start + cleaned.length };\n }\n return null;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Items */\n/* -------------------------------------------------------------------------- */\n\ninterface ItemContext {\n readonly scanned: ScannedDocument;\n readonly directives: readonly Directive[];\n /** The specification that owns an offset, which in a register is a section. */\n readonly ownerAt: (offset: number) => string;\n readonly file: string;\n readonly index: LineIndex;\n}\n\nfunction extractItems(context: ItemContext): ItemNode[] {\n const { scanned, directives, ownerAt, file, index } = context;\n const out: ItemNode[] = [];\n const ordinals = new Map<string, number>();\n\n for (const item of scanned.listItems) {\n const section = sectionPathAt(scanned, item.start);\n const inObligationSection = section.some((heading) => OBLIGATION_SECTIONS.has(normaliseHeading(heading)));\n const directive = directiveFor(directives, 'spec-item', { start: item.start, end: item.end }, 200);\n\n if (!isObligation(item, inObligationSection, directive)) continue;\n\n const documentId = ownerAt(item.start);\n const slug = section.length > 0 ? slugify(section[section.length - 1] as string) : 'item';\n // Ordinals count within a specification, so two decisions in one register\n // each get their own `#open-questions.1` rather than sharing a sequence.\n const key = `${documentId}#${slug}`;\n const ordinal = (ordinals.get(key) ?? 0) + 1;\n ordinals.set(key, ordinal);\n\n const declaredId = directive ? attr(directive, 'id')?.value : null;\n const id = `${documentId}#${declaredId ?? `${slug}.${ordinal}`}`;\n\n const state = resolveItemState({\n file,\n index,\n item,\n section,\n directive,\n inObligationSection,\n });\n\n out.push({\n id,\n kind: 'item',\n title: (directive ? attr(directive, 'title')?.value : null) ?? summarise(item.firstLine),\n at: refOf(file, index, item.start, item.end),\n document: documentId,\n section,\n text: summarise(item.firstLine),\n body: item.body,\n disposition: state.disposition,\n openness: state.openness,\n evidence: state.evidence,\n conflicts: state.conflicts,\n });\n }\n\n return out;\n}\n\n/**\n * Decides whether a bullet is an obligation.\n *\n * A checkbox or an explicit directive always makes one. Otherwise only\n * top-level bullets under a heading like \"Open Questions\" count: promoting\n * every bullet in a specification would bury the real obligations under the\n * document's own prose.\n */\nfunction isObligation(item: ListItem, inObligationSection: boolean, directive: Directive | null): boolean {\n if (directive !== null) return true;\n if (item.checkbox !== null) return true;\n return inObligationSection && item.depth === 0;\n}\n\n/** The heading path enclosing an offset, outermost first. */\nfunction sectionPathAt(scanned: ScannedDocument, offset: number): string[] {\n const path: { level: number; text: string }[] = [];\n for (const heading of scanned.headings) {\n if (heading.start > offset) break;\n while (path.length > 0 && (path[path.length - 1] as { level: number }).level >= heading.level) path.pop();\n path.push({ level: heading.level, text: heading.text });\n }\n return path.map((entry) => entry.text);\n}\n\n/**\n * Memoised because it is called for every heading above every reference and\n * every item, and a corpus has only a handful of distinct headings - `Context`,\n * `Decision`, `Open Questions`, `See also` - repeated thousands of times.\n */\nconst headingCache = new Map<string, string>();\n\nfunction normaliseHeading(text: string): string {\n const cached = headingCache.get(text);\n if (cached !== undefined) return cached;\n const normalised = text\n .toLowerCase()\n .replace(/[`*_~]/g, '')\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n .replace(/\\s+/g, ' ')\n .trim();\n // Bounded so a pathological corpus of unique headings cannot grow it forever.\n if (headingCache.size < 4096) headingCache.set(text, normalised);\n return normalised;\n}\n\n/**\n * One-line form of an item for reports.\n *\n * Link syntax is flattened to its label. A finding that quotes the obligation\n * back at the reader should read like the sentence they wrote, not like the\n * Markdown source of it.\n */\nfunction summarise(text: string): string {\n const flat = text\n .replace(/!?\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n // `[[target|display]]` keeps the display half: that is the text a reader\n // of the rendered document actually sees.\n .replace(/\\[\\[(?:[^\\]|]*\\|)?([^\\]]*)\\]\\]/g, '$1')\n .replace(/\\s+/g, ' ')\n .trim();\n return flat.length <= 120 ? flat : `${flat.slice(0, 117)}...`;\n}\n\n/* -------------------------------------------------------------------------- */\n/* References */\n/* -------------------------------------------------------------------------- */\n\ninterface ReferenceContext {\n readonly scanned: ScannedDocument;\n readonly directives: readonly Directive[];\n readonly document: DocumentNode;\n /** The specification that owns an offset, for a reference outside any item. */\n readonly documentAt: (offset: number) => DocumentNode;\n readonly items: readonly ItemNode[];\n readonly byKey: ReadonlyMap<string, YamlEntry>;\n readonly status: StatusReading;\n /** Cell ranges already typed by a table column header. */\n readonly claimed: readonly { start: number; end: number }[];\n readonly file: string;\n readonly index: LineIndex;\n}\n\n/** True when an offset falls in a cell a column header already accounted for. */\nfunction isClaimed(claimed: readonly { start: number; end: number }[], offset: number): boolean {\n return claimed.some((range) => offset >= range.start && offset < range.end);\n}\n\nfunction extractReferences(context: ReferenceContext): ReferenceCandidate[] {\n const { scanned, directives, document, documentAt, items, byKey, status, claimed, file, index } = context;\n const out: ReferenceCandidate[] = [];\n const at = (start: number, end: number): SourceRef => refOf(file, index, start, end);\n\n // Front matter.\n for (const [key, relation] of Object.entries(RELATION_KEYS)) {\n const entry = byKey.get(key) ?? byKey.get(key.replace(/-/g, '_'));\n if (!entry) continue;\n for (const value of valuesOf(entry)) {\n const target = cleanTarget(value);\n if (target.length === 0) continue;\n out.push({\n kind: relation.kind,\n from: document.id,\n target,\n origin: 'front-matter',\n declaredAt: at(entry.valueStart, entry.end),\n raw: `${key}: ${value}`,\n inverted: relation.inverted,\n opportunistic: false,\n });\n }\n }\n\n // `status: Superseded by ADR-0009` is the most common supersession record of\n // all, and it never appears as a field of its own.\n if (status.raw && status.at) {\n for (const target of supersessionTargetsIn(status.raw)) {\n const cleaned = cleanTarget(target);\n if (cleaned.length === 0) continue;\n out.push({\n kind: 'supersedes',\n from: document.id,\n target: cleaned,\n origin: 'front-matter',\n declaredAt: status.at,\n raw: status.raw,\n inverted: true,\n opportunistic: true,\n });\n }\n }\n\n // Explicit edge directives.\n for (const directive of directives) {\n if (directive.name !== 'spec-edge') continue;\n const kind = attr(directive, 'kind')?.value as EdgeKind | undefined;\n const to = attr(directive, 'to');\n const from = attr(directive, 'from');\n if (!kind) continue;\n const owner = ownerOf(items, directive.start) ?? documentAt(directive.start).id;\n if (to) {\n out.push({\n kind,\n from: owner,\n target: to.value,\n origin: 'directive',\n declaredAt: at(to.start, to.end),\n raw: `@spec-edge kind=\"${kind}\" to=\"${to.value}\"`,\n inverted: false,\n opportunistic: false,\n });\n }\n if (from) {\n out.push({\n kind,\n from: owner,\n target: from.value,\n origin: 'directive',\n declaredAt: at(from.start, from.end),\n raw: `@spec-edge kind=\"${kind}\" from=\"${from.value}\"`,\n inverted: true,\n opportunistic: false,\n });\n }\n }\n\n // Prose links. A cell whose meaning a column header already gave is skipped,\n // so `| ADR-0002 | ... | [ADR-0001](0001.md) |` yields one typed edge rather\n // than a typed edge and a neutral citation beside it.\n const linked = new Set<string>();\n for (const link of scanned.links) {\n if (link.form === 'definition') continue;\n if (isClaimed(claimed, link.start)) continue;\n const target = cleanTarget(link.target);\n if (target.length === 0) continue;\n if (isExternal(target)) continue;\n\n const owner = ownerOf(items, link.start) ?? documentAt(link.start).id;\n const section = sectionPathAt(scanned, link.start);\n const classified = classifyReference(scanned.masked, link.start, link.end, section);\n\n linked.add(normaliseRef(stripAnchor(target)));\n out.push({\n kind: classified.kind,\n from: owner,\n target,\n origin: 'link',\n declaredAt: at(link.targetStart, link.targetStart + link.target.length),\n raw: renderLink(link),\n inverted: classified.inverted,\n opportunistic: false,\n });\n }\n\n // Bare identifiers in prose. Everything already covered by a link is skipped\n // so a citation written as `[ADR-7](0007.md)` is not counted twice.\n for (const bare of findBareReferences(scanned)) {\n const key = normaliseRef(bare.text);\n if (linked.has(key)) continue;\n if (isClaimed(claimed, bare.start)) continue;\n const owner = ownerOf(items, bare.start) ?? documentAt(bare.start).id;\n const section = sectionPathAt(scanned, bare.start);\n const classified = classifyReference(scanned.masked, bare.start, bare.end, section);\n out.push({\n kind: classified.kind,\n from: owner,\n target: bare.text,\n origin: 'text',\n declaredAt: at(bare.start, bare.end),\n raw: bare.text,\n inverted: classified.inverted,\n opportunistic: true,\n });\n }\n\n return withoutOverlaps(out);\n}\n\n/**\n * Collapses candidates that describe the same written citation.\n *\n * `Superseded by ADR-0009` in a status section is read twice: the status\n * reader reports the whole line, and prose scanning reports the identifier\n * inside it. One written citation is one reference - so when the target\n * resolves it must not become two edges, and when it does not it must not\n * become two findings on one line a reader can only fix once.\n *\n * The narrower span wins, because it points at the text that has to change.\n *\n * Only overlapping spans collapse. Two sentences citing the same missing\n * document are two citations, and silently reporting one of them would leave\n * the other to be discovered on the next run.\n */\nfunction withoutOverlaps(candidates: readonly ReferenceCandidate[]): ReferenceCandidate[] {\n const out: ReferenceCandidate[] = [];\n for (const candidate of candidates) {\n const index = out.findIndex(\n (other) =>\n other.kind === candidate.kind &&\n other.from === candidate.from &&\n other.inverted === candidate.inverted &&\n normaliseRef(other.target) === normaliseRef(candidate.target) &&\n overlapping(other.declaredAt, candidate.declaredAt),\n );\n if (index === -1) {\n out.push(candidate);\n continue;\n }\n const held = out[index] as ReferenceCandidate;\n // The status reader runs before prose scanning, so today the wider span is\n // always the one already held and this comparison always replaces it. It is\n // written as a comparison rather than an unconditional swap because which\n // reader runs first is not a property worth depending on, and a mutant that\n // makes it unconditional is equivalent only by that accident.\n if (width(candidate.declaredAt) < width(held.declaredAt)) out[index] = candidate;\n }\n return out;\n}\n\nconst width = (ref: SourceRef): number => ref.span.end.offset - ref.span.start.offset;\n\n/**\n * Whether two spans cover any of the same text.\n *\n * Offsets alone, with no file comparison: every candidate here was built from\n * one scan of one file, so there is no second file for them to be offsets into.\n */\nfunction overlapping(a: SourceRef, b: SourceRef): boolean {\n return a.span.start.offset < b.span.end.offset && b.span.start.offset < a.span.end.offset;\n}\n\n/** The item whose block contains an offset, if any. */\nfunction ownerOf(items: readonly ItemNode[], offset: number): string | null {\n let best: ItemNode | null = null;\n for (const item of items) {\n const span = item.at.span;\n if (offset < span.start.offset || offset >= span.end.offset) continue;\n // Innermost wins when items nest.\n if (best === null || span.start.offset > best.at.span.start.offset) best = item;\n }\n return best?.id ?? null;\n}\n\nexport interface Classification {\n readonly kind: EdgeKind;\n readonly inverted: boolean;\n}\n\n/**\n * Decides what a reference means from the words around it.\n *\n * The nearest governing phrase within {@link VERB_WINDOW} characters wins, and\n * the search never crosses a sentence boundary. With nothing to go on, a\n * reference under a \"See also\" heading is bookkeeping and everything else is a\n * neutral citation.\n */\nexport function classifyReference(\n text: string,\n start: number,\n end: number,\n section: readonly string[],\n): Classification {\n const before = sentenceBefore(text, start);\n\n // Left to right, so the last match within the window is the nearest one - and\n // the nearest governing phrase is the one that governs.\n let best: Classification | null = null;\n VERB_PATTERN.lastIndex = 0;\n for (let m = VERB_PATTERN.exec(before); m !== null; m = VERB_PATTERN.exec(before)) {\n const phrase = m[0] as string;\n const end = (m.index ?? 0) + phrase.length;\n const distance = before.length - end;\n if (distance > VERB_WINDOW) continue;\n // What sits between the phrase and the reference has to be connective. A\n // negation in there reverses the claim the phrase would otherwise make.\n if (NEGATION.test(before.slice(end))) continue;\n const rule = VERB_LOOKUP.get(phrase);\n if (rule) best = rule;\n }\n\n if (best) return best;\n\n // \"[ADR-0009] supersedes this decision\": the reference is the subject, so the\n // relation runs the other way.\n const after = sentenceAfter(text, end);\n for (const rule of VERB_RULES) {\n if (rule.inverted) continue;\n for (const phrase of rule.phrases) {\n if (!after.startsWith(phrase)) continue;\n if (rule.kind === 'assumes' || rule.kind === 'depends-on') continue;\n return { kind: rule.kind, inverted: true };\n }\n }\n\n const innermost = section.length > 0 ? normaliseHeading(section[section.length - 1] as string) : '';\n if (WEAK_SECTIONS.has(innermost)) return { kind: 'relates-to', inverted: false };\n for (const heading of section) {\n if (WEAK_SECTIONS.has(normaliseHeading(heading))) return { kind: 'relates-to', inverted: false };\n }\n\n return { kind: 'references', inverted: false };\n}\n\n/** A sentence end, a blank line, or the start of a new block-level item. */\n/**\n * A table cell edge ends a statement too.\n *\n * The pipe matters more than it looks. A table row is a list of independent\n * fields, and without it the look-behind window reaches back across the row\n * boundary into the previous row's prose. An index of archived documents whose\n * last column ended \"...before assuming the drift was fixed\" turned every\n * following row's link into an `assumes` edge, and so turned every archived\n * document it listed into a stale premise.\n */\nconst STATEMENT_BREAK = /[.?!;]\\s|\\n\\s*\\n|\\n\\s*[-*+>#]|\\|/g;\n\n/**\n * Lower-cased, whitespace-collapsed text back to the start of the statement.\n *\n * The search stops at the last boundary: a governing phrase in the *previous*\n * sentence does not govern this reference. \"We deferred that to ADR-3. See also\n * [ADR-9].\" must not read as a delegation to ADR-9.\n */\nfunction sentenceBefore(text: string, start: number): string {\n const window = text.slice(Math.max(0, start - 160), start);\n let cut = 0;\n STATEMENT_BREAK.lastIndex = 0;\n for (let m = STATEMENT_BREAK.exec(window); m !== null; m = STATEMENT_BREAK.exec(window)) {\n cut = (m.index ?? 0) + (m[0] as string).length;\n }\n return window\n .slice(cut)\n .toLowerCase()\n .replace(/[`*_~\"'()\\[\\],]/g, ' ')\n .replace(/\\s+/g, ' ');\n}\n\nfunction sentenceAfter(text: string, end: number): string {\n const window = text.slice(end, Math.min(text.length, end + 80));\n const stop = /[.?!;\\n|]/.exec(window);\n const cut = stop ? window.slice(0, stop.index) : window;\n return cut.toLowerCase().replace(/[`*_~\"'()\\[\\],]/g, ' ').replace(/\\s+/g, ' ').trim();\n}\n\ninterface BareReference {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\n/**\n * Finds identifiers written as plain prose, such as \"as decided in ADR-0007\".\n *\n * Link constructs are blanked first. Without that, `[ADR-7](https://x/adr-7)`\n * would yield three references to the same thing - one real and two harvested\n * out of a URL - which is precisely the mis-match that makes hand-rolled regex\n * checks untrustworthy.\n */\nfunction findBareReferences(scanned: ScannedDocument): BareReference[] {\n // Slice-based for the same reason as the scanner's masking: this runs over\n // every document, and a per-character array is the wrong shape for the job.\n const source = scanned.masked;\n let text = '';\n let cursor = 0;\n for (const link of scanned.links) {\n const start = Math.max(link.start, cursor);\n const end = Math.min(link.end, source.length);\n if (end <= start) continue;\n text += source.slice(cursor, start);\n text += source.slice(start, end).replace(/[^\\n\\r]/g, ' ');\n cursor = end;\n }\n text += source.slice(cursor);\n\n const out: BareReference[] = [];\n BARE_REF.lastIndex = 0;\n for (let m = BARE_REF.exec(text); m !== null; m = BARE_REF.exec(text)) {\n const prefix = (m[1] as string).toLowerCase();\n if (NOT_A_FAMILY.has(prefix)) continue;\n if (prefix.length < 2) continue;\n const start = m.index ?? 0;\n // A token glued to a path separator or an extension is not a citation.\n const before = text[start - 1] ?? ' ';\n const after = text[start + (m[0] as string).length] ?? ' ';\n if (before === '/' || before === '.' || after === '/') continue;\n out.push({ text: m[0] as string, start, end: start + (m[0] as string).length });\n }\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Helpers */\n/* -------------------------------------------------------------------------- */\n\nfunction firstValue(byKey: ReadonlyMap<string, YamlEntry>, keys: readonly string[]): string | null {\n for (const key of keys) {\n const entry = byKey.get(key);\n if (!entry) continue;\n const value = asString(entry);\n if (value !== null && value.length > 0) return value;\n }\n return null;\n}\n\nfunction asString(entry: YamlEntry | undefined): string | null {\n if (!entry) return null;\n if (typeof entry.value === 'string') return entry.value.trim().length > 0 ? entry.value.trim() : null;\n return entry.value.length > 0 ? (entry.value[0] as string) : null;\n}\n\n/** Strips Markdown decoration a target may still be wearing. */\nfunction cleanTarget(value: string): string {\n return value\n .trim()\n .replace(/^[`'\"<(\\[]+/, '')\n .replace(/[`'\">)\\]]+$/, '')\n .replace(/[.,;]+$/, '')\n .trim();\n}\n\nfunction stripAnchor(target: string): string {\n const hash = target.indexOf('#');\n return hash <= 0 ? target : target.slice(0, hash);\n}\n\nfunction renderLink(link: Link): string {\n switch (link.form) {\n case 'wiki':\n return `[[${link.target}]]`;\n case 'autolink':\n return `<${link.target}>`;\n case 'reference':\n case 'shortcut':\n return `[${link.text}][${link.target}]`;\n default:\n return `[${link.text}](${link.target})`;\n }\n}\n\n/** Exposed for tests and for callers that classify their own sections. */\nexport { OBLIGATION_SECTIONS, sectionPathAt, WEAK_SECTIONS };\n"]}
|
package/package.json
CHANGED