@equationalapplications/core-okf 9.20.1 → 9.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/frontmatter.ts","../src/concept.ts","../src/index-md.ts","../src/entity-index-md.ts","../src/log-md.ts","../src/sha256.ts","../src/event-id.ts","../src/related-section.ts","../src/path-allowlist.ts","../src/markdown-links.ts","../src/footnotes.ts","../src/v02-helpers.ts"],"names":["i"],"mappings":";AAEA,IAAM,iBAAA,mBAAoB,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAA,EAAO,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAA,EAAK,EAAE,CAAC,CAAA;AAE9F,SAAS,gBAAgB,KAAA,EAAwB;AAC/C,EAAA,OAAO,yCAAA,CAA0C,KAAK,KAAK,CAAA;AAC7D;AAEA,SAAS,mBAAmB,KAAA,EAAwB;AAClD,EAAA,OAAO,sFAAA,CAAuF,KAAK,KAAK,CAAA;AAC1G;AAEA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,IAAI,KAAA,KAAU,KAAA,CAAM,IAAA,EAAK,EAAG,OAAO,IAAA;AACnC,EAAA,IAAI,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAAG,OAAO,IAAA;AACnC,EAAA,IAAI,kBAAA,CAAmB,KAAK,CAAA,EAAG,OAAO,KAAA;AAGtC,EAAA,IAAI,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAAG,OAAO,IAAA;AACnC,EAAA,IAAI,sBAAA,CAAuB,IAAA,CAAK,KAAK,CAAA,EAAG,OAAO,IAAA;AAE/C,EAAA,IAAI,KAAA,CAAM,SAAS,GAAG,CAAA,IAAK,MAAM,QAAA,CAAS,GAAG,GAAG,OAAO,IAAA;AACvD,EAAA,IAAI,kBAAkB,GAAA,CAAI,KAAA,CAAM,WAAA,EAAa,GAAG,O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EAAA,IAAI,QAAA,KAAa,EAAA,EAAI,OAAO,EAAC;AAC7B,EAAA,MAAM,MAAgB,EAAC;AACvB,EAAA,KAAA,IAAS,IAAI,QAAA,GAAW,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,QAAQ,CAAA,EAAA,EAAK;AAChD,IAAA,MAAM,IAAA,GAAO,MAAM,CAAC,CAAA;AAEpB,IAAA,MAAM,KAAA,GAAQ,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AACzC,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,MAAM,MAAA,GAAS,MAAM,CAAC,CAAA;AACtB,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,OAAA,GAAU,IAAA;AACV,QAAA,WAAA,GAAc,OAAO,CAAC,CAAA;AACtB,QAAA,WAAA,GAAc,MAAA,CAAO,MAAA;AACrB,QAAA;AAAA,MACF;AACA,MAAA,IAAI,aAAa,MAAA,EAAQ,KAAA,CAAM,CAAC,CAAA,EAAG,IAAI,CAAA,EAAG;AACxC,QAAA,OAAA,GAAU,KAAA;AACV,QAAA,WAAA,GAAc,EAAA;AACd,QAAA,WAAA,GAAc,CAAA;AAAA,MAChB;AACA,MAAA;AAAA,IACF;AACA,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,EAAG;AAG5C,IAAA,IAAI,OAAA,EAAS;AACb,IAAA,MAAM,CAAA,GAAI,QAAA,CAAS,IAAA,CAAK,IAAI,CAAA;AAC5B,IAAA,IAAI,CAAA,EAAG,GAAA,CAAI,IAAA,CAAK,CAAA,CAAE,CAAC,CAAC,CAAA;AAAA,EACtB;AACA,EAAA,OAAO,GAAA;AACT","file":"index.mjs","sourcesContent":["import type { OkfFrontmatter, OkfFrontmatterScalar, OkfFrontmatterValue } from './types';\n\nconst RESERVED_LITERALS = new Set(['true', 'false', 'yes', 'no', 'on', 'off', 'null', '~', '']);\n\nfunction looksLikeNumber(value: string): boolean {\n return /^[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/.test(value);\n}\n\nfunction isIso8601Timestamp(value: string): boolean {\n return /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2}|[+-]\\d{4}|[+-]\\d{2})$/.test(value);\n}\n\nfunction needsQuoting(value: string): boolean {\n if (value !== value.trim()) return true;\n if (/[\\n\\r\\t]/.test(value)) return true;\n if (isIso8601Timestamp(value)) return false;\n\n // Quote strings that YAML could otherwise parse as collections/indicators.\n if (/^[-?:]\\s/.test(value)) return true;\n if (/^[\\[\\]{}&,*%!|>'\"@`]/.test(value)) return true;\n\n if (value.includes(':') || value.includes('#')) return true;\n if (RESERVED_LITERALS.has(value.toLowerCase())) return true;\n if (looksLikeNumber(value)) return true;\n return false;\n}\n\nfunction quoteString(value: string): string {\n const escaped = value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\t/g, '\\\\t');\n return `\"${escaped}\"`;\n}\n\nexport function serializeScalarString(value: string): string {\n return needsQuoting(value) ? quoteString(value) : value;\n}\n\nexport function serializeActorString(value: string): string {\n // Actor strings in OKF v0.2 §7 contain `/` (agent/version), `:` (human:/process:),\n // or both — any of these would otherwise parse ambiguously as YAML scalars.\n if (/[/:]/.test(value)) return quoteString(value);\n return value;\n}\n\nfunction serializeKey(key: string): string {\n // needsQuoting() intentionally exempts ISO 8601 timestamps for *values*.\n // For keys, quote timestamp-like scalars to avoid YAML timestamp coercion in some parsers.\n if (/\\s/.test(key) || needsQuoting(key) || isIso8601Timestamp(key)) {\n return quoteString(key);\n }\n return key;\n}\n\nfunction serializeValue(value: unknown): string {\n if (value === null) return 'null';\n if (typeof value === 'boolean') return String(value);\n if (typeof value === 'number') return String(value);\n if (typeof value === 'string') return serializeScalarString(value);\n if (Array.isArray(value)) return serializeFlowSequenceValue(value);\n if (typeof value === 'object') return serializeFlowMappingValue(value as Record<string, OkfFrontmatterValue>);\n throw new Error(`Unsupported frontmatter value type: ${typeof value}`);\n}\n\n/**\n * Quote a flow-mapping/-sequence scalar string more strictly than a top-level\n * scalar. Flow syntax additionally treats `,`, `{`, `}`, `[`, `]` as\n * structural (so a `title` like `\"Foo, Bar\"` MUST be quoted even though\n * `needsQuoting` alone wouldn't require it for a top-level, non-flow value),\n * and `/`/`:` are quoted too — this is what makes it safe to use uniformly\n * for actor strings (`reference_agent/gemini-2.5-pro`, `human:ahormati`) as\n * well as ordinary string values inside the same flow mapping. This\n * subsumes what a narrower \"only quote actor-shaped values\" helper would\n * need to do, so every string inside a flow mapping/sequence goes through\n * this one function rather than two different quoting rules depending on\n * which key it's under.\n */\nfunction needsFlowQuoting(value: string): boolean {\n return needsQuoting(value) || /[,{}[\\]/:]/.test(value);\n}\n\nfunction serializeFlowScalarString(value: string): string {\n return needsFlowQuoting(value) ? quoteString(value) : value;\n}\n\n/** Emit a plain object as an inline flow mapping `{ k: v, k: v }`. At most one\n * level of nested flow collection (mapping or sequence) as a value, per\n * spec §2.6 — matches what the parser accepts. */\nfunction serializeFlowMappingValue(obj: Record<string, OkfFrontmatterValue>, depth = 0): string {\n const entries = Object.entries(obj).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return '{}';\n const parts = entries.map(([k, v]) => {\n let rendered: string;\n if (typeof v === 'string') rendered = serializeFlowScalarString(v);\n else if (v === null || typeof v === 'boolean' || typeof v === 'number') rendered = serializeValue(v);\n else if (Array.isArray(v)) {\n if (depth >= 1) throw new Error(`serializeFlowMappingValue: nesting deeper than one level is not supported (key \"${k}\")`);\n rendered = serializeFlowSequenceValue(v, depth + 1);\n } else if (typeof v === 'object') {\n if (depth >= 1) throw new Error(`serializeFlowMappingValue: nesting deeper than one level is not supported (key \"${k}\")`);\n rendered = serializeFlowMappingValue(v as Record<string, OkfFrontmatterValue>, depth + 1);\n } else {\n throw new Error(`serializeFlowMappingValue: unsupported value type for key \"${k}\"`);\n }\n return `${serializeKey(k)}: ${rendered}`;\n });\n return `{ ${parts.join(', ')} }`;\n}\n\n/** Emit an array as an inline flow sequence `[ a, b, c ]`. Object items\n * serialize as nested inline flow mappings (the base \"array of objects\"\n * shape — see the design note above Step 5.1 — does not consume the\n * one-level nesting budget). A nested ARRAY does consume the budget: the\n * `parameters` field in v0.2 §10 is a sequence of values, not a sequence\n * of mappings, and recursing with the same depth would let a hostile\n * `[[[[...]]]]` exhaust the JS stack. */\nfunction serializeFlowSequenceValue(arr: unknown[], depth = 0): string {\n if (arr.length === 0) return '[]';\n const parts = arr.map((item) => {\n if (typeof item === 'string') return serializeFlowScalarString(item);\n if (item === null || typeof item === 'boolean' || typeof item === 'number') return serializeValue(item);\n if (item !== null && typeof item === 'object' && !Array.isArray(item)) {\n // Sequence item that is itself a mapping: same depth (base shape, not nesting).\n return serializeFlowMappingValue(item as Record<string, OkfFrontmatterValue>, depth);\n }\n if (Array.isArray(item)) {\n if (depth >= 1) throw new Error(`serializeFlowSequenceValue: nested array deeper than one level is not supported`);\n return serializeFlowSequenceValue(item, depth + 1);\n }\n throw new Error('serializeFlowSequenceValue: unsupported item type');\n });\n return `[ ${parts.join(', ')} ]`;\n}\n\nexport function serializeFrontmatter(fm: OkfFrontmatter): string {\n const lines: string[] = ['---'];\n for (const [key, value] of Object.entries(fm)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n if (value.length === 0) {\n lines.push(`${serializeKey(key)}: []`);\n } else if ((value as unknown[]).some((item) => item !== null && typeof item === 'object')) {\n // Array of objects (sources, verified-list, parameters, ...): always a\n // single-line flow sequence, never a block-list of flow-mapping items\n // (see the Step 5 design note — the latter cannot round-trip).\n lines.push(`${serializeKey(key)}: ${serializeFlowSequenceValue(value as unknown[])}`);\n } else {\n // Plain scalar array: existing v0.1 block-sequence form, unchanged.\n lines.push(`${serializeKey(key)}:`);\n for (const item of value as unknown[]) {\n lines.push(` - ${typeof item === 'string' ? serializeScalarString(item) : serializeValue(item)}`);\n }\n }\n } else if (value !== null && typeof value === 'object') {\n lines.push(`${serializeKey(key)}: ${serializeFlowMappingValue(value as Record<string, OkfFrontmatterValue>)}`);\n } else {\n lines.push(`${serializeKey(key)}: ${serializeValue(value)}`);\n }\n }\n lines.push('---');\n return lines.join('\\n') + '\\n';\n}\n\nfunction unescapeFrontmatterString(escaped: string): string {\n let result = '';\n for (let i = 0; i < escaped.length; i++) {\n const ch = escaped[i];\n if (ch === '\\\\' && i + 1 < escaped.length) {\n const next = escaped[i + 1];\n if (next === 'n') { result += '\\n'; i++; continue; }\n if (next === 'r') { result += '\\r'; i++; continue; }\n if (next === 't') { result += '\\t'; i++; continue; }\n if (next === '\"') { result += '\"'; i++; continue; }\n if (next === '\\\\') { result += '\\\\'; i++; continue; }\n // CT #231: decode the escape forms the Rust write path\n // (curated-thoughts okf::quote_for_note) emits beyond the classics.\n // YAML 1.1 double-quoted line-break escapes:\n if (next === 'N') { result += '\\u0085'; i++; continue; }\n if (next === 'L') { result += '\\u2028'; i++; continue; }\n if (next === 'P') { result += '\\u2029'; i++; continue; }\n // \\xNN — C0 controls + DEL as written by the Rust writer (2 hex digits).\n if (next === 'x') {\n const hex = escaped.slice(i + 2, i + 4);\n if (/^[0-9a-fA-F]{2}$/.test(hex)) {\n result += String.fromCharCode(parseInt(hex, 16));\n i += 3;\n continue;\n }\n }\n // \\uXXXX — remaining C1 and U+FFFE/U+FFFF (4 hex digits, lowercase from\n // the writer; uppercase accepted too).\n if (next === 'u') {\n const hex = escaped.slice(i + 2, i + 6);\n if (/^[0-9a-fA-F]{4}$/.test(hex)) {\n result += String.fromCharCode(parseInt(hex, 16));\n i += 5;\n continue;\n }\n }\n }\n result += ch;\n }\n return result;\n}\n\nfunction unescapeSingleQuotedString(escaped: string): string {\n return escaped.replace(/''/g, \"'\");\n}\n\nfunction parseQuotedScalar(raw: string): string | null {\n const trimmed = raw.trim();\n if (trimmed.length < 2) return null;\n if (trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n return unescapeFrontmatterString(trimmed.slice(1, -1));\n }\n if (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\")) {\n return unescapeSingleQuotedString(trimmed.slice(1, -1));\n }\n return null;\n}\n\nfunction parseKey(raw: string): string {\n return parseQuotedScalar(raw) ?? raw.trim();\n}\n\nfunction parseScalarValue(raw: string): OkfFrontmatterScalar {\n const quoted = parseQuotedScalar(raw);\n if (quoted !== null) return quoted;\n const trimmed = raw.trim();\n if (trimmed === 'null') return null;\n if (trimmed === 'true') return true;\n if (trimmed === 'false') return false;\n // linear: `\\d+(?:\\.\\d*)?` accepts the same language as `\\d+\\.?\\d*` with one parse per digit run (closes CodeQL #7)\n if (/^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?$/.test(trimmed)) return Number(trimmed);\n return trimmed;\n}\n\nfunction matchFrontmatterKeyValue(\n line: string,\n): { key: string; value: string; hasValue: boolean } | null {\n const keyMatch = /^(?:\"(?:\\\\.|[^\"\\\\])*\"|'(?:''|[^'])*'|[^:]+)/.exec(line);\n if (!keyMatch) return null;\n const key = keyMatch[0];\n if (line[key.length] !== ':') return null;\n const tail = line.slice(key.length + 1);\n return { key, value: tail.trimStart(), hasValue: tail.trim().length > 0 };\n}\n\n/**\n * True if `text` contains an unquoted `&` or `*` — the anchor/alias indicators we\n * refuse to recognize (billion-laughs safety, profile-1 §8). Quoted spans are\n * excluded from the scan so an ordinary value like a URL query string\n * (`\"https://x/a?p=1&q=2\"`) is never misdetected as an anchor.\n */\nfunction hasUnquotedAnchorOrAlias(text: string): boolean {\n let quote: '\"' | \"'\" | null = null;\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n if (quote) {\n if (ch === '\\\\' && i + 1 < text.length) { i++; continue; }\n if (ch === quote) quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\") { quote = ch; continue; }\n if (ch === '&' || ch === '*') return true;\n }\n return false;\n}\n\n/**\n * Split a comma-separated list of inner flow entries, respecting quoted strings\n * and nested `{...}` / `[...]` spans (so a nested flow collection's internal\n * commas don't split the outer entry list). Returns null on unbalanced\n * quotes/brackets.\n */\nfunction splitFlowEntries(inner: string): string[] | null {\n const entries: string[] = [];\n let buf = '';\n let i = 0;\n let quote: '\"' | \"'\" | null = null;\n let depthBrace = 0;\n let depthBracket = 0;\n while (i < inner.length) {\n const ch = inner[i];\n if (quote) {\n buf += ch;\n if (ch === '\\\\' && i + 1 < inner.length) { buf += inner[i + 1]; i += 2; continue; }\n if (ch === quote) quote = null;\n i++; continue;\n }\n if (ch === '\"' || ch === \"'\") { quote = ch; buf += ch; i++; continue; }\n if (ch === '{') depthBrace++;\n else if (ch === '}') depthBrace--;\n else if (ch === '[') depthBracket++;\n else if (ch === ']') depthBracket--;\n if (ch === ',' && depthBrace === 0 && depthBracket === 0) {\n entries.push(buf.trim()); buf = ''; i++; continue;\n }\n buf += ch;\n i++;\n }\n if (buf.trim().length > 0) entries.push(buf.trim());\n if (depthBrace !== 0 || depthBracket !== 0 || quote !== null) return null;\n return entries;\n}\n\n/**\n * `depth` counts levels of **mapping-value nesting** only: it increments when a\n * flow MAPPING's key has a value that is itself a flow collection, and is\n * rejected once it would exceed 1 (spec §2.6's \"at most one level of nesting\").\n * It does NOT increment when a flow SEQUENCE's item is itself a mapping or\n * sequence — `sources: [ {...}, {...} ]` (a flat array of objects) is the base\n * shape v0.2 uses everywhere and is not \"nesting\" in the spec's sense. This is\n * what lets `sources: [ { usage_window: { from, to } } ]` parse (sequence item\n * is a mapping at depth 0; that mapping's `usage_window` value is a mapping at\n * depth 1 — one level, allowed) while `{ a: { b: { c: 1 } } }` is rejected\n * (`a`'s value nests at depth 1; `b`'s value would need depth 2 — rejected).\n */\nexport function parseFlowMapping(text: string, depth = 0): Record<string, OkfFrontmatterValue> | null {\n const trimmed = text.trim();\n if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) return null;\n // Anchor / alias hard ban, quoted spans excluded from the scan.\n if (hasUnquotedAnchorOrAlias(trimmed)) return null;\n const inner = trimmed.slice(1, -1).trim();\n if (inner.length === 0) return {};\n const entries = splitFlowEntries(inner);\n if (!entries) return null;\n const out: Record<string, OkfFrontmatterValue> = {};\n for (const entry of entries) {\n const kv = matchFrontmatterKeyValue(entry);\n if (!kv || !kv.hasValue) return null;\n const v = kv.value.trim();\n if (v.startsWith('{') || v.startsWith('[')) {\n // This IS a mapping-value nesting step: consumes one level of budget.\n if (depth >= 1) return null; // would be a 2nd level of mapping-value nesting — reject\n const nested = v.startsWith('{') ? parseFlowMapping(v, depth + 1) : parseFlowSequence(v, depth + 1);\n if (nested === null) return null;\n out[parseKey(kv.key)] = nested as unknown as OkfFrontmatterValue;\n continue;\n }\n out[parseKey(kv.key)] = parseScalarValue(v);\n }\n return out;\n}\n\nexport function parseFlowSequence(text: string, depth = 0): OkfFrontmatterValue[] | null {\n const trimmed = text.trim();\n if (!trimmed.startsWith('[') || !trimmed.endsWith(']')) return null;\n if (hasUnquotedAnchorOrAlias(trimmed)) return null;\n const inner = trimmed.slice(1, -1).trim();\n if (inner.length === 0) return [];\n const entries = splitFlowEntries(inner);\n if (!entries) return null;\n const out: OkfFrontmatterValue[] = [];\n for (const entry of entries) {\n const v = entry.trim();\n if (v.startsWith('{')) {\n // Sequence item is a mapping: same depth (base array-of-objects shape).\n const nested = parseFlowMapping(v, depth);\n if (nested === null) return null;\n out.push(nested as unknown as OkfFrontmatterValue);\n continue;\n }\n if (v.startsWith('[')) {\n // Nested array consumes one level of depth budget.\n if (depth >= 1) return null;\n const nested = parseFlowSequence(v, depth + 1);\n if (nested === null) return null;\n out.push(nested as unknown as OkfFrontmatterValue);\n continue;\n }\n out.push(parseScalarValue(v));\n }\n return out;\n}\n\n/**\n * Parses the subset of YAML frontmatter that {@link serializeFrontmatter} produces:\n * scalar string/number/boolean/null values, quoted strings, and block string-lists.\n * NOT a general YAML parser — flow collections (`[...]`/`{...}`), multi-line block\n * scalars (`|`/`>`), anchors, and aliases are not recognized. Lines that don't match\n * a recognized shape are silently skipped rather than throwing, so a foreign bundle\n * never crashes\n * the import — it just loses fidelity on the unrecognized line.\n */\nexport function parseFrontmatter(content: string): { frontmatter: OkfFrontmatter; rest: string } {\n const lines = content.split(/\\r?\\n/);\n const fallback = { frontmatter: { type: '' } as OkfFrontmatter, rest: content };\n\n if (lines[0]?.trim() !== '---') return fallback;\n\n let closingIndex = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i].trim() === '---') {\n closingIndex = i;\n break;\n }\n }\n if (closingIndex === -1) return fallback;\n\n const frontmatter: Record<string, OkfFrontmatterValue> = {};\n let i = 1;\n while (i < closingIndex) {\n const line = lines[i];\n const kv = matchFrontmatterKeyValue(line);\n if (!kv) {\n i++;\n continue;\n }\n if (kv.value.trim() === '[]') {\n frontmatter[parseKey(kv.key)] = [];\n i++;\n continue;\n }\n if (!kv.hasValue) {\n const key = parseKey(kv.key);\n const items: OkfFrontmatterScalar[] = [];\n i++;\n while (i < closingIndex && /^\\s*-\\s/.test(lines[i])) {\n items.push(parseScalarValue(lines[i].replace(/^\\s*-\\s/, '')));\n i++;\n }\n frontmatter[key] = items;\n continue;\n }\n const valueRaw = kv.value.trim();\n // OKF v0.2 flow collections: { k: v, k: v } and [ a, b, c ], at most one level\n // of nesting (spec §2.6). Anchor/alias-opaque (handled inside the flow parsers).\n if (valueRaw.startsWith('{')) {\n const flowObj = parseFlowMapping(valueRaw);\n if (flowObj !== null) { frontmatter[parseKey(kv.key)] = flowObj as unknown as OkfFrontmatterValue; i++; continue; }\n // Rejected (anchor/alias, or nested more than one level deep): preserve the key\n // with a null value rather than misreading `{ a: { b: 1 } }` as a scalar string.\n frontmatter[parseKey(kv.key)] = null;\n i++;\n continue;\n }\n if (valueRaw.startsWith('[')) {\n // Empty flow sequence falls through to existing `[]` handling above.\n if (valueRaw === '[]') {\n frontmatter[parseKey(kv.key)] = [];\n i++;\n continue;\n }\n const flowSeq = parseFlowSequence(valueRaw);\n if (flowSeq !== null) { frontmatter[parseKey(kv.key)] = flowSeq as unknown as OkfFrontmatterValue; i++; continue; }\n frontmatter[parseKey(kv.key)] = null;\n i++;\n continue;\n }\n frontmatter[parseKey(kv.key)] = parseScalarValue(kv.value);\n i++;\n }\n\n if (typeof frontmatter['type'] !== 'string') {\n frontmatter['type'] = '';\n }\n\n const restLines = lines.slice(closingIndex + 1);\n const rest = restLines.length > 0 ? restLines.join('\\n') : '';\n\n return { frontmatter: frontmatter as OkfFrontmatter, rest };\n}\n","import type { OkfFrontmatter } from './types';\nimport { serializeFrontmatter, parseFrontmatter } from './frontmatter';\n\nexport function buildConceptDocument(fm: OkfFrontmatter, body: string): string {\n return `${serializeFrontmatter(fm)}\\n${body}`;\n}\n\n/** Reverse of {@link buildConceptDocument}: strips the single leading blank-line separator. */\nexport function parseConcept(content: string): { frontmatter: OkfFrontmatter; body: string } {\n const { frontmatter, rest } = parseFrontmatter(content);\n const body = rest.startsWith('\\n') ? rest.slice(1) : rest;\n return { frontmatter, body };\n}\n","import { parseFrontmatter, serializeScalarString } from './frontmatter';\nimport type { OkfIndexEntry, OkfIndexSection } from './types';\n\nfunction renderEntry(entry: OkfIndexEntry): string {\n const esc = (s: string) =>\n s\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\\[/g, '\\\\[')\n .replace(/\\]/g, '\\\\]')\n .replace(/\\r?\\n/g, ' ');\n\n const title = esc(entry.title);\n const description = entry.description ? esc(entry.description) : undefined;\n\n return description\n ? `* [${title}](${entry.path}) - ${description}`\n : `* [${title}](${entry.path})`;\n}\n\nfunction renderSections(sections: OkfIndexSection[]): string {\n const lines: string[] = [];\n for (const section of sections) {\n lines.push(`## ${section.heading}`);\n lines.push('');\n for (const entry of section.entries) {\n lines.push(renderEntry(entry));\n }\n lines.push('');\n }\n if (lines.length === 0) return '';\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\nexport function buildIndexMd(sections: OkfIndexSection[]): string {\n return renderSections(sections);\n}\n\nexport function buildRootIndexMd(\n okfVersion: string,\n sections: OkfIndexSection[],\n options?: { profile?: string },\n): string {\n const lines = ['---', `okf_version: ${serializeScalarString(okfVersion)}`];\n if (options?.profile) {\n lines.push(`profile: ${serializeScalarString(options.profile)}`);\n }\n lines.push('---', '');\n return `${lines.join('\\n')}\\n${renderSections(sections)}`;\n}\n\nexport function parseRootIndexMd(content: string): { okf_version?: string; profile?: string } {\n const { frontmatter } = parseFrontmatter(content);\n const okf = frontmatter.okf_version;\n return {\n okf_version:\n typeof okf === 'string' ? okf : typeof okf === 'number' && Number.isFinite(okf) ? String(okf) : undefined,\n profile: typeof frontmatter.profile === 'string' ? frontmatter.profile : undefined,\n };\n}\n","import type { OkfIndexSection } from './types';\nimport { buildIndexMd } from './index-md';\n\nconst EVENT_LOG_LINK = /^\\[Event log\\]\\(\\.\\/log\\.md\\)\\s*$/;\n// Only ever tested against trimmed lines; `\\S` replaces `.+\\s*$`.\nconst TOP_LEVEL_H1 = /^#\\s+\\S/;\n// linear: capture starts on \\S so it cannot trade characters with \\s+ (closes CodeQL #2, #3)\nconst SECTION_HEADING = /^##\\s+(\\S.*)$/;\n// linear: `\\` and `[` cannot start a plain label char (closes CodeQL #9); disjoint tail (closes CodeQL #4)\nconst INDEX_ENTRY = /^\\*\\s+\\[((?:\\\\.|[^\\[\\]\\\\])*)\\]\\(([^)]+)\\)(?:\\s+-(\\s.*)?)?$/;\n\nfunction unescapeIndexTitle(title: string): string {\n return title.replace(/\\\\\\]/g, ']').replace(/\\\\\\[/g, '[').replace(/\\\\\\\\/g, '\\\\');\n}\n\nexport function buildEntityIndexMd(options: {\n summary?: string;\n sections: OkfIndexSection[];\n}): string {\n const parts: string[] = [];\n if (options.summary?.trim()) {\n parts.push(options.summary.trimEnd(), '');\n }\n const sectionsMd = buildIndexMd(options.sections).trimEnd();\n if (sectionsMd) {\n parts.push(sectionsMd);\n parts.push('');\n }\n parts.push('[Event log](./log.md)');\n return `${parts.join('\\n')}\\n`;\n}\n\nexport function parseEntityIndexMd(content: string): {\n summary: string;\n sections: OkfIndexSection[];\n} {\n const lines = content.split(/\\r?\\n/);\n\n // Optional frontmatter block (--- ... ---) per profile.\n let start = 0;\n if (lines[0]?.trim() === '---') {\n const closing = lines.findIndex((line, idx) => idx > 0 && line.trim() === '---');\n if (closing !== -1) start = closing + 1;\n }\n\n const firstSectionIdx = lines.findIndex((line, idx) => idx >= start && SECTION_HEADING.test(line));\n const summaryEnd = firstSectionIdx === -1 ? lines.length : firstSectionIdx;\n const summaryLines = lines\n .slice(start, summaryEnd)\n .filter(line => !EVENT_LOG_LINK.test(line.trim()));\n let summaryStart = 0;\n while (summaryStart < summaryLines.length && summaryLines[summaryStart].trim() === '') {\n summaryStart += 1;\n }\n if (summaryStart < summaryLines.length && TOP_LEVEL_H1.test(summaryLines[summaryStart].trim())) {\n summaryStart += 1;\n }\n const summary = summaryLines.slice(summaryStart).join('\\n').trim();\n\n const sections: OkfIndexSection[] = [];\n if (firstSectionIdx === -1) return { summary, sections };\n\n let current: OkfIndexSection | null = null;\n for (let i = Math.max(firstSectionIdx, start); i < lines.length; i += 1) {\n const line = lines[i];\n if (EVENT_LOG_LINK.test(line.trim())) continue;\n\n const headingMatch = SECTION_HEADING.exec(line);\n if (headingMatch) {\n current = { heading: headingMatch[1], entries: [] };\n sections.push(current);\n continue;\n }\n\n if (!current) continue;\n const entryMatch = INDEX_ENTRY.exec(line);\n if (!entryMatch) continue;\n\n const description = entryMatch[3]?.trimStart();\n current.entries.push({\n title: unescapeIndexTitle(entryMatch[1]),\n path: entryMatch[2],\n description: description ? unescapeIndexTitle(description) : undefined,\n });\n }\n return { summary, sections };\n}\n","import type { OkfLogEntry } from './types';\n\nexport function buildLogMd(entries: OkfLogEntry[]): string {\n const groups = new Map<string, OkfLogEntry[]>();\n for (const entry of entries) {\n const group = groups.get(entry.date) ?? [];\n group.push(entry);\n groups.set(entry.date, group);\n }\n\n const dates = Array.from(groups.keys()).sort((a, b) => (a < b ? 1 : a > b ? -1 : 0));\n\n const lines: string[] = [];\n for (const date of dates) {\n lines.push(`## ${date}`);\n lines.push('');\n for (const entry of groups.get(date)!) {\n lines.push(`- ${entry.text}`);\n }\n lines.push('');\n }\n\n if (lines.length === 0) return '';\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\nexport function appendEventIdComment(text: string, eventId: string): string {\n if (!/^[A-Za-z0-9._-]+$/.test(eventId)) return text;\n return `${text} <!-- id: ${eventId} -->`;\n}\n\n// Hand-rolled instead of an unanchored regex (closes CodeQL #5). `lastIndexOf` matches the\n// old leftmost-regex result: `\\S+` could never span the whitespace before a later `<!--`.\nexport function parseEventIdComment(text: string): { text: string; eventId?: string } {\n const trimmed = text.trimEnd();\n if (!trimmed.endsWith('-->')) return { text };\n const open = trimmed.lastIndexOf('<!--');\n if (open === -1) return { text };\n const inner = trimmed.slice(open + 4, -3).trim();\n if (!inner.startsWith('id:')) return { text };\n const eventId = inner.slice(3).trim();\n if (eventId === '' || /\\s/.test(eventId)) return { text };\n const stripped = trimmed.slice(0, open).trimEnd();\n if (!/^[A-Za-z0-9._-]+$/.test(eventId)) return { text: stripped };\n return { text: stripped, eventId };\n}\n\nconst DATE_HEADING = /^##\\s+(\\d{4}-\\d{2}-\\d{2})\\s*$/;\n// linear: capture starts on \\S so it cannot trade characters with \\s+ (closes CodeQL #6)\nconst BULLET = /^-\\s+(\\S.*)?$/;\n\n/**\n * Reverse of {@link buildLogMd}. Best-effort: lines that don't match the exact\n * `## YYYY-MM-DD` heading or `- text` bullet shape buildLogMd emits are skipped,\n * not thrown — a foreign log.md in a different format degrades to fewer entries\n * rather than failing the import.\n */\nexport function parseLogMd(content: string): OkfLogEntry[] {\n const entries: OkfLogEntry[] = [];\n let currentDate: string | null = null;\n\n for (const line of content.split(/\\r?\\n/)) {\n const headingMatch = DATE_HEADING.exec(line);\n if (headingMatch) {\n currentDate = headingMatch[1];\n continue;\n }\n const bulletMatch = BULLET.exec(line);\n if (bulletMatch && currentDate) {\n entries.push({ date: currentDate, text: bulletMatch[1] ?? '' });\n }\n }\n\n return entries;\n}\n","// SHA-256 (FIPS 180-4) and a UTF-8 encoder, written out so core-okf keeps zero runtime\n// dependencies and runs where neither `TextEncoder` nor a synchronous `crypto` is\n// guaranteed (Hermes, browsers). Internal: used by deriveEventId and\n// createEventIdDeriver, not exported from the package.\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nconst rotr = (x: number, n: number) => (x >>> n) | (x << (32 - n));\n\nconst IV = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n\n/** One 64-byte block at `off` of `view` into state `H` (in place). */\nfunction compress(H: Uint32Array, W: Uint32Array, view: DataView, off: number): void {\n for (let t = 0; t < 16; t++) W[t] = view.getUint32(off + t * 4);\n for (let t = 16; t < 64; t++) {\n const s0 = rotr(W[t - 15], 7) ^ rotr(W[t - 15], 18) ^ (W[t - 15] >>> 3);\n const s1 = rotr(W[t - 2], 17) ^ rotr(W[t - 2], 19) ^ (W[t - 2] >>> 10);\n W[t] = (W[t - 16] + s0 + W[t - 7] + s1) >>> 0;\n }\n let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];\n for (let t = 0; t < 64; t++) {\n const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (h + S1 + ch + K[t] + W[t]) >>> 0;\n const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (S0 + maj) >>> 0;\n h = g; g = f; f = e; e = (d + t1) >>> 0;\n d = c; c = b; b = a; a = (t1 + t2) >>> 0;\n }\n H[0] = (H[0] + a) >>> 0; H[1] = (H[1] + b) >>> 0; H[2] = (H[2] + c) >>> 0; H[3] = (H[3] + d) >>> 0;\n H[4] = (H[4] + e) >>> 0; H[5] = (H[5] + f) >>> 0; H[6] = (H[6] + g) >>> 0; H[7] = (H[7] + h) >>> 0;\n}\n\n/**\n * SHA-256 of `prefix` followed by a suffix given later, many times: the\n * prefix's whole blocks are hashed once here, and each call of the returned\n * function hashes only the rest (`remainder of prefix + suffix`). Same digest\n * as `sha256(concat(prefix, suffix))`.\n */\nexport function sha256WithPrefix(prefix: Uint8Array): (suffix: Uint8Array) => Uint8Array {\n const whole = prefix.length - (prefix.length % 64);\n const H = new Uint32Array(IV);\n const W = new Uint32Array(64);\n const view = new DataView(prefix.buffer, prefix.byteOffset, prefix.byteLength);\n for (let off = 0; off < whole; off += 64) compress(H, W, view, off);\n const rest = prefix.subarray(whole);\n return (suffix) => {\n const tailLen = rest.length + suffix.length;\n const bitLen = (prefix.length + suffix.length) * 8;\n const padded = new Uint8Array((((tailLen + 9 + 63) >> 6) << 6));\n padded.set(rest);\n padded.set(suffix, rest.length);\n padded[tailLen] = 0x80;\n const pv = new DataView(padded.buffer);\n // 64-bit big-endian length; messages here are far below 2^32 bytes.\n pv.setUint32(padded.length - 8, Math.floor(bitLen / 0x100000000));\n pv.setUint32(padded.length - 4, bitLen >>> 0);\n const state = new Uint32Array(H);\n for (let off = 0; off < padded.length; off += 64) compress(state, W, pv, off);\n const out = new Uint8Array(32);\n const outView = new DataView(out.buffer);\n for (let i = 0; i < 8; i++) outView.setUint32(i * 4, state[i]);\n return out;\n };\n}\n\nexport function sha256(bytes: Uint8Array): Uint8Array {\n return sha256WithPrefix(bytes)(new Uint8Array(0));\n}\n\n/** UTF-8 bytes of `s`; a lone UTF-16 surrogate encodes as U+FFFD, as TextEncoder does. */\nexport function utf8Encode(s: string): Uint8Array {\n const out: number[] = [];\n for (let i = 0; i < s.length; i++) {\n let cp = s.charCodeAt(i);\n if (cp >= 0xd800 && cp <= 0xdbff) {\n const next = i + 1 < s.length ? s.charCodeAt(i + 1) : 0;\n if (next >= 0xdc00 && next <= 0xdfff) {\n cp = 0x10000 + ((cp - 0xd800) << 10) + (next - 0xdc00);\n i++;\n } else {\n cp = 0xfffd;\n }\n } else if (cp >= 0xdc00 && cp <= 0xdfff) {\n cp = 0xfffd;\n }\n if (cp < 0x80) out.push(cp);\n else if (cp < 0x800) out.push(0xc0 | (cp >> 6), 0x80 | (cp & 0x3f));\n else if (cp < 0x10000) out.push(0xe0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));\n else out.push(0xf0 | (cp >> 18), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));\n }\n return Uint8Array.from(out);\n}\n","import { sha256WithPrefix, utf8Encode } from './sha256';\n\nexport interface DeriveEventIdInput {\n /** The entity the log is imported into (not a directory name in the bundle). */\n entityId: string;\n /** The log heading's date text, `YYYY-MM-DD`, as written. */\n date: string;\n /** The event type the event is stored with. */\n eventType: string;\n /** The summary the event is stored with (after unescaping). */\n summary: string;\n /** How many earlier id-less lines in the same log share date, type and summary; 0 for the first. */\n occurrence: number;\n}\n\nconst TAG = 'llm-wiki/event-id/1';\nconst PREFIX = 'evt_okf1_';\n\nfunction encodeFields(fields: readonly string[]): Uint8Array {\n const parts: Uint8Array[] = [];\n let total = 0;\n for (const field of fields) {\n const bytes = utf8Encode(field);\n const part = utf8Encode(`${bytes.length}:`);\n const chunk = new Uint8Array(part.length + bytes.length + 1);\n chunk.set(part);\n chunk.set(bytes, part.length);\n chunk[chunk.length - 1] = 0x2c; // ','\n parts.push(chunk);\n total += chunk.length;\n }\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of parts) {\n out.set(p, off);\n off += p.length;\n }\n return out;\n}\n\nconst prefixFields = (input: Omit<DeriveEventIdInput, 'occurrence'>) =>\n [TAG, input.entityId, input.date, input.eventType, input.summary];\n\n/** Length-prefixed field encoding hashed by {@link deriveEventId}. Internal; exported for tests. */\nexport function encodeEventIdInput(input: DeriveEventIdInput): Uint8Array {\n return encodeFields([...prefixFields(input), String(input.occurrence)]);\n}\n\n/**\n * {@link deriveEventId} for one (entity, date, type, summary) at many\n * occurrences: the shared fields are encoded and hashed once, so each call\n * costs the same however long the summary is. Returns the same ids as\n * `deriveEventId({ ...input, occurrence })`.\n */\nexport function createEventIdDeriver(input: Omit<DeriveEventIdInput, 'occurrence'>): (occurrence: number) => string {\n const finish = sha256WithPrefix(encodeFields(prefixFields(input)));\n return (occurrence) => {\n if (!Number.isInteger(occurrence) || occurrence < 0) {\n throw new TypeError(`deriveEventId: occurrence must be an integer >= 0, got ${String(occurrence)}`);\n }\n const digest = finish(encodeFields([String(occurrence)]));\n let hex = '';\n for (let i = 0; i < 16; i++) hex += digest[i].toString(16).padStart(2, '0');\n return PREFIX + hex;\n };\n}\n\n/**\n * Deterministic id for an OKF log line that carries no id comment\n * (`docs/okf-profile.md` §7): `evt_okf1_` + the first 32 hex characters of\n * SHA-256 over the length-prefixed fields. The same line in the same entity\n * always gets the same id, so importing it again is a no-op while the earlier\n * copy is stored.\n */\nexport function deriveEventId(input: DeriveEventIdInput): string {\n return createEventIdDeriver(input)(input.occurrence);\n}\n","import type { OkfMarkdownLink } from './types';\n\nfunction escapeLinkLabel(label: string): string {\n return label\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\\[/g, '\\\\[')\n .replace(/\\]/g, '\\\\]')\n .replace(/\\r?\\n/g, ' ');\n}\n\nexport function appendRelatedSection(\n body: string,\n links: Array<{ edge_type: string; path: string }>,\n): string {\n if (links.length === 0) return body;\n const prefix =\n body.length === 0\n ? ''\n : body.endsWith('\\n\\n')\n ? body\n : body.endsWith('\\n')\n ? `${body}\\n`\n : `${body}\\n\\n`;\n const lines = ['## Related', ''];\n for (const link of links) {\n lines.push(`- [${escapeLinkLabel(link.edge_type)}](${link.path})`);\n }\n return `${prefix}${lines.join('\\n')}\\n`;\n}\n\nexport function splitRelatedSection(body: string): { body: string; relatedLinks: OkfMarkdownLink[] } {\n const lines = body.split(/\\r?\\n/);\n let end = lines.length;\n while (end > 0 && lines[end - 1].trim() === '') end -= 1;\n\n let scan = end - 1;\n while (scan >= 0 && /^-\\s+/.test(lines[scan])) scan -= 1;\n while (scan >= 0 && lines[scan].trim() === '') scan -= 1;\n\n if (scan < 0 || lines[scan].trim() !== '## Related') {\n return { body, relatedLinks: [] };\n }\n\n const relatedStart = scan;\n const contentBody = lines.slice(0, relatedStart).join('\\n');\n const relatedBlock = lines.slice(relatedStart, end).join('\\n');\n const relatedLinks: OkfMarkdownLink[] = [];\n for (const line of relatedBlock.split(/\\r?\\n/)) {\n const bullet = /^-\\s+(\\S.*)?$/.exec(line);\n if (!bullet) continue;\n\n // linear: `\\` and `[` cannot start a plain label char, so each attempt stops at the next `[` (closes CodeQL #10)\n const linkPattern = /\\[((?:\\\\.|[^\\[\\]\\\\])*)\\]\\(([^)\\s]+)\\)/g;\n let match: RegExpExecArray | null;\n while ((match = linkPattern.exec(bullet[1] ?? '')) !== null) {\n const linkPath = match[2];\n if (/^(https?:|mailto:)/i.test(linkPath)) continue;\n relatedLinks.push({\n text: match[1].replace(/\\\\\\]/g, ']').replace(/\\\\\\[/g, '[').replace(/\\\\\\\\/g, '\\\\'),\n path: linkPath,\n });\n }\n }\n const normalizedBody =\n contentBody.length === 0 ? '' : contentBody.endsWith('\\n') ? contentBody : `${contentBody}\\n`;\n return { body: normalizedBody, relatedLinks };\n}\n","const ALLOWED =\n /^(index\\.md|entities\\/[^/]+\\/(index\\.md|log\\.md|(facts|tasks)\\/[^/]+\\.md))$/;\n\nexport function isAllowedOkfPath(filePath: string): boolean {\n const normalized = filePath.replace(/^\\.\\//, '').replace(/\\\\/g, '/');\n if (normalized.split('/').some(segment => segment === '.' || segment === '..')) {\n return false;\n }\n return ALLOWED.test(normalized);\n}\n","import type { OkfMarkdownLink } from './types';\n\nconst EXCLUDED_SCHEME = /^(https?:|mailto:)/i;\nconst FENCED_CODE_BLOCK_PATTERN = /```[\\s\\S]*?```/g;\n\n/**\n * Extracts inline markdown links (`[text](path)`) from a concept body.\n * Single-line regex, not a CommonMark parser — reference-style links, links\n * split across lines, and links inside code fences are not recognized.\n * `http(s):` and `mailto:` targets are excluded; only relative/local paths\n * are candidates for graph edges.\n */\nexport function extractMarkdownLinks(body: string): OkfMarkdownLink[] {\n const searchableBody = body.replace(FENCED_CODE_BLOCK_PATTERN, '');\n const linkPattern = /\\[([^\\]]*)\\]\\(([^)\\s]+)\\)/g;\n const links: OkfMarkdownLink[] = [];\n let match: RegExpExecArray | null;\n while ((match = linkPattern.exec(searchableBody)) !== null) {\n const [, text, path] = match;\n if (EXCLUDED_SCHEME.test(path)) continue;\n links.push({ text, path });\n }\n return links;\n}\n","import type { OkfFootnote } from './types';\n\nconst FOOTNOTE_DEFINITION = /^\\[\\^([^\\]]+)\\]:\\s?(.*)$/;\n\n/**\n * Extracts footnote definitions from a body. OKF v0.2 footnote attribution uses\n * `[^id]` markers whose label joins to `sources[].id`. This helper parses the\n * `[^id]: text` definition lines at the body tail and returns them as opaque\n * text — we deliberately do NOT try to interpret which body span uses which\n * footnote; the body is the source of truth and is preserved verbatim on\n * round-trip.\n */\nexport function extractFootnotes(body: string): OkfFootnote[] {\n const out: OkfFootnote[] = [];\n const lines = body.split(/\\r?\\n/);\n let i = 0;\n while (i < lines.length) {\n const m = FOOTNOTE_DEFINITION.exec(lines[i]);\n if (!m) { i++; continue; }\n const id = m[1];\n const firstLine = m[2] ?? '';\n const collected: string[] = [firstLine];\n i++;\n while (i < lines.length) {\n const next = lines[i];\n if (FOOTNOTE_DEFINITION.test(next)) break;\n // Continuation lines are indented (>= 2 spaces) per CommonMark.\n if (/^\\s{2,}\\S/.test(next) || /^\\s{2,}/.test(next)) {\n collected.push(next.replace(/^\\s{2}/, ''));\n i++;\n continue;\n }\n break;\n }\n out.push({ id, body: collected.join('\\n').trimEnd() });\n }\n return out;\n}\n\n/** Joins footnote definitions back into a body block. Continuation lines are\n * indented (two spaces) so that {@link extractFootnotes} — which only\n * recognizes continuation lines that are indented per CommonMark — round-trips\n * multi-line bodies. */\nexport function serializeFootnotes(footnotes: OkfFootnote[]): string {\n return footnotes\n .map((f) => {\n const lines = f.body.split('\\n');\n const [firstLine, ...continuation] = lines;\n const tail = continuation.map((line) => `\\n ${line}`).join('');\n return `[^${f.id}]: ${firstLine ?? ''}${tail}`;\n })\n .join('\\n');\n}","import type {\n OkfVerified,\n OkfVerifiedEntry,\n OkfSource,\n OkfSourceUsageWindow,\n} from './types';\n\nexport type TrustTier = 'unverified' | 'machine-confirmed' | 'human-reviewed';\n\nexport function deriveTrustTier(verified: OkfVerified | undefined): TrustTier {\n if (!verified || verified.length === 0) return 'unverified';\n for (const v of verified) {\n if (typeof v?.by === 'string' && v.by.startsWith('human:')) return 'human-reviewed';\n }\n return 'machine-confirmed';\n}\n\nfunction parseStaleAfter(staleAfter: string | number | null): number | null {\n if (staleAfter == null) return null;\n if (typeof staleAfter === 'number') return Number.isFinite(staleAfter) ? staleAfter : null;\n // YYYY-MM-DD — compare at day granularity: stale_after is the first day that IS stale.\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(staleAfter);\n if (!match) return null;\n const year = Number(match[1]);\n const month = Number(match[2]);\n const day = Number(match[3]);\n const ts = Date.UTC(year, month - 1, day);\n if (!Number.isFinite(ts)) return null;\n // Date.UTC silently normalizes calendar-invalid dates (2025-02-29 → 2025-03-01);\n // round-trip back through Date and reject any component that doesn't match.\n const d = new Date(ts);\n if (\n d.getUTCFullYear() !== year ||\n d.getUTCMonth() + 1 !== month ||\n d.getUTCDate() !== day\n ) {\n return null;\n }\n return ts;\n}\n\nexport function isStaleAfter(staleAfter: string | number | null, now: number): boolean {\n const cutoff = parseStaleAfter(staleAfter);\n if (cutoff == null) return false;\n return now >= cutoff;\n}\n\nexport function parseVerifiedFlexible(value: unknown): OkfVerified {\n if (value == null) return [];\n if (Array.isArray(value)) {\n return value.filter(\n (v): v is OkfVerifiedEntry =>\n !!v && typeof v === 'object' && typeof (v as any).by === 'string' && typeof (v as any).at === 'string',\n );\n }\n if (typeof value === 'object' && typeof (value as any).by === 'string' && typeof (value as any).at === 'string') {\n return [value as OkfVerifiedEntry];\n }\n return [];\n}\n\nexport function formatVerifiedJson(entries: OkfVerified): string {\n // Sort by Date.parse() instant so different ISO 8601 offsets don't re-order\n // (lexical sort put `2026-01-01T00:00:00-08:00` before `2026-01-01T05:00:00Z`,\n // even though the latter is later in real time). Falls back to a deterministic\n // lexical tiebreak only when one or both values fail to parse.\n const sorted = [...entries].sort((a, b) => {\n const ta = Date.parse(a.at);\n const tb = Date.parse(b.at);\n const fa = Number.isFinite(ta);\n const fb = Number.isFinite(tb);\n if (fa && fb) return ta - tb;\n if (fa && !fb) return -1;\n if (!fa && fb) return 1;\n return a.at < b.at ? -1 : a.at > b.at ? 1 : 0;\n });\n return JSON.stringify(sorted);\n}\n\nexport function formatSourcesJson(sources: OkfSource[], sharedWindow?: OkfSourceUsageWindow | null): string {\n const folded = sources.map((s) =>\n s.usage_window ? s : sharedWindow ? { ...s, usage_window: sharedWindow } : s,\n );\n return JSON.stringify(folded);\n}\n\nexport function latestVerified(\n entries: OkfVerified | undefined,\n _now: number,\n): { by: string; at: number } | null {\n if (!entries || entries.length === 0) return null;\n let best: OkfVerifiedEntry | null = null;\n let bestAt = -Infinity;\n for (const e of entries) {\n const ts = Date.parse(e.at);\n if (Number.isFinite(ts) && ts > bestAt) {\n best = e;\n bestAt = ts;\n }\n }\n if (!best) return null;\n return { by: best.by, at: bestAt };\n}\n\nconst URL_LINE = /^\\s*-\\s+(https?:\\/\\/\\S+)\\s*$/;\n\nexport function parseCitationsList(body: string): string[] {\n // Find a '# Citations' (case-insensitive) heading; collect URL list lines\n // until the next heading or EOF. Headings inside fenced code blocks\n // (``` and ~~~) are ignored so a Markdown example containing\n // `# Citations` and URL bullets is not imported as real provenance.\n //\n // Fence tracking retains the full opening fence length: a 4-backtick\n // opener is only closed by a 4+ backtick line of the same character\n // followed by whitespace (CommonMark §4.5). Tracking only the marker\n // char let ``` close ```` blocks, which then exposed the next line as\n // a URL bullet and imported it as synthetic provenance (see #90 review).\n const lines = body.split(/\\r?\\n/);\n let inFence = false;\n let fenceMarker = '';\n let fenceLength = 0;\n let startIdx = -1;\n const isFenceClose = (marker: string, fullMatch: string, line: string): boolean => {\n if (marker[0] !== fenceMarker) return false;\n if (marker.length < fenceLength) return false;\n return /^\\s*$/.test(line.slice(fullMatch.length));\n };\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const fence = /^\\s*(```+|~~~+)/.exec(line);\n if (fence) {\n const marker = fence[1]!;\n if (!inFence) {\n inFence = true;\n fenceMarker = marker[0]!;\n fenceLength = marker.length;\n } else if (isFenceClose(marker, fence[0], line)) {\n inFence = false;\n fenceMarker = '';\n fenceLength = 0;\n }\n continue;\n }\n if (!inFence && /^\\s*#{1,2}\\s*citations\\s*$/i.test(line)) {\n startIdx = i;\n break;\n }\n }\n if (startIdx === -1) return [];\n const out: string[] = [];\n for (let i = startIdx + 1; i < lines.length; i++) {\n const line = lines[i];\n // Closing fence or a new heading exits the citations section.\n const fence = /^\\s*(```+|~~~+)/.exec(line);\n if (fence) {\n const marker = fence[1]!;\n if (!inFence) {\n inFence = true;\n fenceMarker = marker[0]!;\n fenceLength = marker.length;\n continue;\n }\n if (isFenceClose(marker, fence[0], line)) {\n inFence = false;\n fenceMarker = '';\n fenceLength = 0;\n }\n continue;\n }\n if (!inFence && /^\\s*#{1,2}\\s+/.test(line)) break; // next heading\n // Skip URL line matching inside open fences — body's narrative code\n // examples must not contaminate provenance.\n if (inFence) continue;\n const m = URL_LINE.exec(line);\n if (m) out.push(m[1]);\n }\n return out;\n}"]}
1
+ {"version":3,"sources":["../src/frontmatter.ts","../src/concept.ts","../src/index-md.ts","../src/entity-index-md.ts","../src/log-md.ts","../src/sha256.ts","../src/event-id.ts","../src/related-section.ts","../src/path-allowlist.ts","../src/markdown-links.ts","../src/footnotes.ts","../src/v03-helpers.ts","../src/v02-helpers.ts"],"names":["i","region","year","month","day"],"mappings":";AAEA,IAAM,iBAAA,mBAAoB,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAA,EAAO,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,GAAA,EAAK,EAAE,CAAC,CAAA;AAE9F,SAAS,gBAAgB,KAAA,EAAwB;AAK/C,EAAA,OAAO,iDAAA,CAAkD,KAAK,KAAK,CAAA;AACrE;AAEA,SAAS,mBAAmB,KAAA,EAAwB;AAClD,EAAA,OAAO,sFAAA,CAAuF,KAAK,KAAK,CAAA;AAC1G;AAEA,SAAS,aAAa,KAAA,EAAwB;AAC5C,EAAA,IAAI,KAAA,KAAU,KAAA,CAAM,IAAA,EAAK,EAAG,OAAO,IAAA;AACnC,EAAA,IAAI,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAA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AAAA,EACF;AACA,EAAA,IAAI,QAAA,KAAa,EAAA,EAAI,OAAO,EAAC;AAC7B,EAAA,MAAM,MAAgB,EAAC;AACvB,EAAA,KAAA,IAAS,IAAI,QAAA,GAAW,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,QAAQ,CAAA,EAAA,EAAK;AAChD,IAAA,MAAM,IAAA,GAAO,MAAM,CAAC,CAAA;AAEpB,IAAA,MAAM,KAAA,GAAQ,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AACzC,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,MAAM,MAAA,GAAS,MAAM,CAAC,CAAA;AACtB,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,OAAA,GAAU,IAAA;AACV,QAAA,WAAA,GAAc,OAAO,CAAC,CAAA;AACtB,QAAA,WAAA,GAAc,MAAA,CAAO,MAAA;AACrB,QAAA;AAAA,MACF;AACA,MAAA,IAAI,aAAa,MAAA,EAAQ,KAAA,CAAM,CAAC,CAAA,EAAG,IAAI,CAAA,EAAG;AACxC,QAAA,OAAA,GAAU,KAAA;AACV,QAAA,WAAA,GAAc,EAAA;AACd,QAAA,WAAA,GAAc,CAAA;AAAA,MAChB;AACA,MAAA;AAAA,IACF;AACA,IAAA,IAAI,CAAC,OAAA,IAAW,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA,EAAG;AAG5C,IAAA,IAAI,OAAA,EAAS;AACb,IAAA,MAAM,CAAA,GAAI,QAAA,CAAS,IAAA,CAAK,IAAI,CAAA;AAC5B,IAAA,IAAI,CAAA,EAAG,GAAA,CAAI,IAAA,CAAK,CAAA,CAAE,CAAC,CAAC,CAAA;AAAA,EACtB;AACA,EAAA,OAAO,GAAA;AACT","file":"index.mjs","sourcesContent":["import type { OkfFrontmatter, OkfFrontmatterScalar, OkfFrontmatterValue } from './types';\n\nconst RESERVED_LITERALS = new Set(['true', 'false', 'yes', 'no', 'on', 'off', 'null', '~', '']);\n\nfunction looksLikeNumber(value: string): boolean {\n // linear: `\\d+(?:\\.\\d*)?` accepts the same language as `\\d+\\.?\\d*` with one\n // parse per digit run (same fix as parseScalarValue, CodeQL #7 — the §A3f\n // exactness check reaches this from the parse path, where a 100k-digit run\n // must not go quadratic).\n return /^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?$/.test(value);\n}\n\nfunction isIso8601Timestamp(value: string): boolean {\n return /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2}|[+-]\\d{4}|[+-]\\d{2})$/.test(value);\n}\n\nfunction needsQuoting(value: string): boolean {\n if (value !== value.trim()) return true;\n if (/[\\n\\r\\t]/.test(value)) return true;\n if (isIso8601Timestamp(value)) return false;\n\n // Quote strings that YAML could otherwise parse as collections/indicators.\n if (/^[-?:]\\s/.test(value)) return true;\n if (/^[\\[\\]{}&,*%!|>'\"@`]/.test(value)) return true;\n\n if (value.includes(':') || value.includes('#')) return true;\n if (RESERVED_LITERALS.has(value.toLowerCase())) return true;\n if (looksLikeNumber(value)) return true;\n return false;\n}\n\nfunction quoteString(value: string): string {\n const escaped = value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\t/g, '\\\\t');\n return `\"${escaped}\"`;\n}\n\nexport function serializeScalarString(value: string): string {\n return needsQuoting(value) ? quoteString(value) : value;\n}\n\nexport function serializeActorString(value: string): string {\n // Actor strings in OKF v0.2 §7 contain `/` (agent/version), `:` (human:/process:),\n // or both — any of these would otherwise parse ambiguously as YAML scalars.\n if (/[/:]/.test(value)) return quoteString(value);\n return value;\n}\n\nfunction serializeKey(key: string): string {\n // needsQuoting() intentionally exempts ISO 8601 timestamps for *values*.\n // For keys, quote timestamp-like scalars to avoid YAML timestamp coercion in some parsers.\n if (/\\s/.test(key) || needsQuoting(key) || isIso8601Timestamp(key)) {\n return quoteString(key);\n }\n return key;\n}\n\nfunction serializeValue(value: unknown): string {\n if (value === null) return 'null';\n if (typeof value === 'boolean') return String(value);\n if (typeof value === 'number') return String(value);\n if (typeof value === 'string') return serializeScalarString(value);\n if (Array.isArray(value)) return serializeFlowSequenceValue(value);\n if (typeof value === 'object') return serializeFlowMappingValue(value as Record<string, OkfFrontmatterValue>);\n throw new Error(`Unsupported frontmatter value type: ${typeof value}`);\n}\n\n/**\n * Quote a flow-mapping/-sequence scalar string more strictly than a top-level\n * scalar. Flow syntax additionally treats `,`, `{`, `}`, `[`, `]` as\n * structural (so a `title` like `\"Foo, Bar\"` MUST be quoted even though\n * `needsQuoting` alone wouldn't require it for a top-level, non-flow value),\n * and `/`/`:` are quoted too — this is what makes it safe to use uniformly\n * for actor strings (`reference_agent/gemini-2.5-pro`, `human:ahormati`) as\n * well as ordinary string values inside the same flow mapping. This\n * subsumes what a narrower \"only quote actor-shaped values\" helper would\n * need to do, so every string inside a flow mapping/sequence goes through\n * this one function rather than two different quoting rules depending on\n * which key it's under.\n */\nfunction needsFlowQuoting(value: string): boolean {\n return needsQuoting(value) || /[,{}[\\]/:]/.test(value);\n}\n\nfunction serializeFlowScalarString(value: string): string {\n return needsFlowQuoting(value) ? quoteString(value) : value;\n}\n\n/** Emit a plain object as an inline flow mapping `{ k: v, k: v }`. At most one\n * level of nested flow collection (mapping or sequence) as a value, per\n * spec §2.6 — matches what the parser accepts. */\nfunction serializeFlowMappingValue(obj: Record<string, OkfFrontmatterValue>, depth = 0): string {\n const entries = Object.entries(obj).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return '{}';\n const parts = entries.map(([k, v]) => {\n let rendered: string;\n if (typeof v === 'string') rendered = serializeFlowScalarString(v);\n else if (v === null || typeof v === 'boolean' || typeof v === 'number') rendered = serializeValue(v);\n else if (Array.isArray(v)) {\n if (depth >= 1) throw new Error(`serializeFlowMappingValue: nesting deeper than one level is not supported (key \"${k}\")`);\n rendered = serializeFlowSequenceValue(v, depth + 1);\n } else if (typeof v === 'object') {\n if (depth >= 1) throw new Error(`serializeFlowMappingValue: nesting deeper than one level is not supported (key \"${k}\")`);\n rendered = serializeFlowMappingValue(v as Record<string, OkfFrontmatterValue>, depth + 1);\n } else {\n throw new Error(`serializeFlowMappingValue: unsupported value type for key \"${k}\"`);\n }\n return `${serializeKey(k)}: ${rendered}`;\n });\n return `{ ${parts.join(', ')} }`;\n}\n\n/** Emit an array as an inline flow sequence `[ a, b, c ]`. Object items\n * serialize as nested inline flow mappings (the base \"array of objects\"\n * shape — see the design note above Step 5.1 — does not consume the\n * one-level nesting budget). A nested ARRAY does consume the budget: the\n * `parameters` field in v0.2 §10 is a sequence of values, not a sequence\n * of mappings, and recursing with the same depth would let a hostile\n * `[[[[...]]]]` exhaust the JS stack. */\nfunction serializeFlowSequenceValue(arr: unknown[], depth = 0): string {\n if (arr.length === 0) return '[]';\n const parts = arr.map((item) => {\n if (typeof item === 'string') return serializeFlowScalarString(item);\n if (item === null || typeof item === 'boolean' || typeof item === 'number') return serializeValue(item);\n if (item !== null && typeof item === 'object' && !Array.isArray(item)) {\n // Sequence item that is itself a mapping: same depth (base shape, not nesting).\n return serializeFlowMappingValue(item as Record<string, OkfFrontmatterValue>, depth);\n }\n if (Array.isArray(item)) {\n if (depth >= 1) throw new Error(`serializeFlowSequenceValue: nested array deeper than one level is not supported`);\n return serializeFlowSequenceValue(item, depth + 1);\n }\n throw new Error('serializeFlowSequenceValue: unsupported item type');\n });\n return `[ ${parts.join(', ')} ]`;\n}\n\n/** Options for {@link serializeFrontmatter} (§A7). */\nexport interface SerializeFrontmatterOptions {\n /**\n * Verbatim lines §A3(d) handed back for one key each, written after the\n * serialized keys and before the closing `---`, unchanged. The serializer\n * does not parse or validate them; callers pass only blocks they stored\n * from a parse. Without the option the output is byte-identical to the\n * pre-v0.3 serializer's.\n */\n rawBlocks?: string[];\n}\n\nexport function serializeFrontmatter(fm: OkfFrontmatter, options?: SerializeFrontmatterOptions): string {\n const lines: string[] = ['---'];\n for (const [key, value] of Object.entries(fm)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n if (value.length === 0) {\n lines.push(`${serializeKey(key)}: []`);\n } else if ((value as unknown[]).some((item) => item !== null && typeof item === 'object')) {\n // Array of objects (sources, verified-list, parameters, ...): a\n // single-line flow sequence, never a block-list of flow-mapping\n // items — the §A3 parser reads that form now, but the serializer\n // still emits the one-line flow form (T26 note; the old\n // \"cannot round-trip\" sentence is obsolete).\n lines.push(`${serializeKey(key)}: ${serializeFlowSequenceValue(value as unknown[])}`);\n } else {\n // Plain scalar array: existing v0.1 block-sequence form, unchanged.\n lines.push(`${serializeKey(key)}:`);\n for (const item of value as unknown[]) {\n lines.push(` - ${typeof item === 'string' ? serializeScalarString(item) : serializeValue(item)}`);\n }\n }\n } else if (value !== null && typeof value === 'object') {\n lines.push(`${serializeKey(key)}: ${serializeFlowMappingValue(value as Record<string, OkfFrontmatterValue>)}`);\n } else {\n lines.push(`${serializeKey(key)}: ${serializeValue(value)}`);\n }\n }\n // §A7: raw blocks go out verbatim (lines.join preserves their newlines),\n // after the serialized keys and before the closing delimiter.\n for (const block of options?.rawBlocks ?? []) {\n lines.push(block);\n }\n lines.push('---');\n return lines.join('\\n') + '\\n';\n}\n\nfunction unescapeFrontmatterString(escaped: string): string {\n let result = '';\n for (let i = 0; i < escaped.length; i++) {\n const ch = escaped[i];\n if (ch === '\\\\' && i + 1 < escaped.length) {\n const next = escaped[i + 1];\n if (next === 'n') { result += '\\n'; i++; continue; }\n if (next === 'r') { result += '\\r'; i++; continue; }\n if (next === 't') { result += '\\t'; i++; continue; }\n if (next === '\"') { result += '\"'; i++; continue; }\n if (next === '\\\\') { result += '\\\\'; i++; continue; }\n // CT #231: decode the escape forms the Rust write path\n // (curated-thoughts okf::quote_for_note) emits beyond the classics.\n // YAML 1.1 double-quoted line-break escapes:\n if (next === 'N') { result += '\\u0085'; i++; continue; }\n if (next === 'L') { result += '\\u2028'; i++; continue; }\n if (next === 'P') { result += '\\u2029'; i++; continue; }\n // \\xNN — C0 controls + DEL as written by the Rust writer (2 hex digits).\n if (next === 'x') {\n const hex = escaped.slice(i + 2, i + 4);\n if (/^[0-9a-fA-F]{2}$/.test(hex)) {\n result += String.fromCharCode(parseInt(hex, 16));\n i += 3;\n continue;\n }\n }\n // \\uXXXX — remaining C1 and U+FFFE/U+FFFF (4 hex digits, lowercase from\n // the writer; uppercase accepted too).\n if (next === 'u') {\n const hex = escaped.slice(i + 2, i + 6);\n if (/^[0-9a-fA-F]{4}$/.test(hex)) {\n result += String.fromCharCode(parseInt(hex, 16));\n i += 5;\n continue;\n }\n }\n }\n result += ch;\n }\n return result;\n}\n\nfunction unescapeSingleQuotedString(escaped: string): string {\n return escaped.replace(/''/g, \"'\");\n}\n\nfunction parseQuotedScalar(raw: string): string | null {\n const trimmed = raw.trim();\n if (trimmed.length < 2) return null;\n if (trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n return unescapeFrontmatterString(trimmed.slice(1, -1));\n }\n if (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\")) {\n return unescapeSingleQuotedString(trimmed.slice(1, -1));\n }\n return null;\n}\n\nexport function parseKey(raw: string): string {\n return parseQuotedScalar(raw) ?? raw.trim();\n}\n\nfunction parseScalarValue(raw: string): OkfFrontmatterScalar {\n const quoted = parseQuotedScalar(raw);\n if (quoted !== null) return quoted;\n const trimmed = raw.trim();\n if (trimmed === 'null') return null;\n if (trimmed === 'true') return true;\n if (trimmed === 'false') return false;\n // linear: `\\d+(?:\\.\\d*)?` accepts the same language as `\\d+\\.?\\d*` with one parse per digit run (closes CodeQL #7)\n if (/^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?$/.test(trimmed)) return Number(trimmed);\n return trimmed;\n}\n\nfunction matchFrontmatterKeyValue(\n line: string,\n): { key: string; value: string; hasValue: boolean } | null {\n const keyMatch = /^(?:\"(?:\\\\.|[^\"\\\\])*\"|'(?:''|[^'])*'|[^:]+)/.exec(line);\n if (!keyMatch) return null;\n const key = keyMatch[0];\n if (line[key.length] !== ':') return null;\n const tail = line.slice(key.length + 1);\n return { key, value: tail.trimStart(), hasValue: tail.trim().length > 0 };\n}\n\n/**\n * Match a BLOCK mapping line (`k: v` at one indentation, §A3c). Like\n * {@link matchFrontmatterKeyValue} — quoted keys with colons still split —\n * but the separator must be a colon followed by a space or the end of the\n * line (refinement 48), so `http://x/y` is not a mapping line. Top-level key\n * matching is unchanged; only block content uses this rule.\n */\nfunction matchBlockKeyValue(\n line: string,\n): { key: string; value: string; hasValue: boolean } | null {\n const kv = matchFrontmatterKeyValue(line);\n if (!kv) return null;\n const tail = line.slice(kv.key.length + 1);\n if (tail.length > 0 && tail[0] !== ' ' && tail[0] !== '\\t') return null;\n return kv;\n}\n\n/** Width of a line's leading whitespace (§A3c's \"one indentation\"). */\nfunction indentWidth(line: string): number {\n let n = 0;\n while (n < line.length && (line[n] === ' ' || line[n] === '\\t')) n++;\n return n;\n}\n\n/**\n * §A3e node-start predicate for quote spans (review T4-R3 F1) — the\n * stripInlineComment rule: a quote opens an exempt span at the start of the\n * text, or after `{`, `[`, `,`, `:` or `-` with at most one space. A quote\n * anywhere else is data (a mid-word apostrophe in a plain scalar), so a scan\n * that honored it would let a later `&`/`*` escape detection.\n */\nfunction quoteOpensAtNodeStart(text: string, i: number): boolean {\n if (i === 0) return true;\n // Scan the WHOLE whitespace run back to the boundary character (review\n // CodeRabbit round 2): a quoted scalar after two spaces inside a flow\n // collection is still a node start — `[ \"alpha # beta\"]` — and capping\n // the run at one space let mid-value `#` strips mangle such values.\n let j = i - 1;\n while (j >= 0 && (text[j] === ' ' || text[j] === '\\t')) j--;\n if (j < 0) return true;\n const c = text[j];\n if (c === '{' || c === '[' || c === ',' || c === ':') return true;\n // A dash opens a node only at a node boundary itself (review CodeRabbit\n // round 3 — `x- \"y # note`: the dash sits inside a plain scalar, so the\n // quote after it is mid-scalar data and must not shield the comment).\n if (c === '-') {\n if (j === 0) return true;\n const d = text[j - 1];\n return d === ' ' || d === '\\t' || d === '{' || d === '[' || d === ',' || d === ':';\n }\n return false;\n}\n\n/**\n * True if `text` contains `&` or `*` at the start of a node — after the start\n * of the text, or after `{`, `[`, `,`, `:`, or a `- ` dash that is itself at a\n * node boundary, with any amount of whitespace between — outside quotes. That\n * is where YAML anchors/aliases actually live; the same characters\n * mid-scalar (`FP&A`, `R&D notes`, `a*b`, `user@*`, `a-*b`) are data (spec\n * §A3e, refinement 35). Quoted spans are excluded from the scan so an\n * ordinary value like a URL query string (`\"https://x/a?p=1&q=2\"`) is never\n * misdetected as an anchor. A dash glued to preceding text (`a-*b`) is not a\n * node boundary, so `*b` there is plain data too (T3-review carry-over).\n */\nfunction hasNodeStartAnchorOrAlias(text: string): boolean {\n let quote: '\"' | \"'\" | null = null;\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n if (quote) {\n // YAML single quotes have no backslash escape (review T4-R1 m4) — a\n // backslash is data there, mirroring stripInlineComment/quoteCloses.\n if (quote === '\"' && ch === '\\\\' && i + 1 < text.length) { i++; continue; }\n if (ch === quote) quote = null;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n // §A3e (review T4-R3 F1): a quote opens a comment-exempt span only at a\n // node start (the stripInlineComment predicate — text start, or after\n // `{`/`[`/`,`/`:`/`-` with at most one space). A mid-word apostrophe\n // (`it's`) is data: opening a span there swallowed the rest of the line\n // and hid a later anchor/alias from this scan.\n if (quoteOpensAtNodeStart(text, i)) quote = ch;\n continue;\n }\n if (ch !== '&' && ch !== '*') continue;\n // Scan back over the whitespace run to the nearest non-space character\n // (any amount of whitespace separates a node start from its opener).\n let j = i - 1;\n while (j >= 0 && (text[j] === ' ' || text[j] === '\\t')) j--;\n if (j < 0) return true;\n const c = text[j];\n if (c === '{' || c === '[' || c === ',' || c === ':') return true;\n if (c === '-') {\n // A dash opens a node only at the start of the text or after a node\n // boundary itself; inside a scalar (`a-*b`, `a- *b`) it is data.\n if (j === 0) return true;\n const d = text[j - 1];\n if (d === ' ' || d === '\\t' || d === '{' || d === '[' || d === ',' || d === ':') return true;\n }\n }\n return false;\n}\n\n/** A line whose first non-blank character is `#` (§A3a). */\nfunction isFullLineComment(line: string): boolean {\n return /^[ \\t]*#/.test(line);\n}\n\n/**\n * Remove a trailing `# comment` from a raw key tail (everything after the\n * `key:` separator), per §A3a: a `#` that follows whitespace and sits outside\n * quotes starts a comment running to end of line; a `#` with no whitespace\n * before it (`https://x/y#frag`, `a#b`, `key:#tag`) and a `#` inside quotes\n * are data. A quote opens a comment-exempt region only at a node start — the\n * start of the scalar itself, or (inside a flow collection, where each quoted\n * string is a scalar of its own) after `{`, `[`, `,` or `:`/`-` with at most\n * one space, the §A3e node-start positions. A quote appearing mid-scalar\n * (`R&D \"notes\" #2`) does not shield a following comment. An unterminated\n * quote keeps the whole tail (no comment strip is possible). Returns the\n * value text with the comment and surrounding whitespace removed; an empty\n * string means the key has no inline value.\n */\nfunction stripInlineComment(tail: string): string {\n let start = 0;\n while (start < tail.length && (tail[start] === ' ' || tail[start] === '\\t')) start++;\n if (start >= tail.length) return '';\n let quote: '\"' | \"'\" | null = null;\n for (let i = start; i < tail.length; i++) {\n const ch = tail[i];\n if (quote) {\n if (ch === '\\\\' && quote === '\"' && i + 1 < tail.length) { i++; continue; }\n if (ch === quote) {\n if (quote === \"'\" && tail[i + 1] === \"'\") { i++; continue; }\n quote = null;\n }\n continue;\n }\n if (ch === '#' && i > 0 && (tail[i - 1] === ' ' || tail[i - 1] === '\\t')) {\n return tail.slice(0, i).trim();\n }\n if (ch === '\"' || ch === \"'\") {\n // Node start across any whitespace run (review CodeRabbit round 2 —\n // `[ \"alpha # beta\"]`): scan back over the whole run, not one space.\n let k = i - 1;\n while (k >= start && (tail[k] === ' ' || tail[k] === '\\t')) k--;\n const nodeStart = i === start\n || k < start\n || (tail[k] === '{' || tail[k] === '[' || tail[k] === ',' || tail[k] === ':' || tail[k] === '-');\n if (nodeStart) quote = ch;\n }\n }\n return tail.trim();\n}\n\n/**\n * True when the quote opening `text` is closed on the same line — §A3b's\n * \"quoted string left open\" check. Double-quoted strings honor backslash\n * escapes; single-quoted honor the doubled-quote escape.\n */\nfunction quoteCloses(text: string): boolean {\n const q = text[0];\n for (let i = 1; i < text.length; i++) {\n if (q === '\"' && text[i] === '\\\\') { i++; continue; }\n if (text[i] === q) {\n if (q === \"'\" && text[i + 1] === \"'\") { i++; continue; }\n return true;\n }\n }\n return false;\n}\n\n/**\n * True when a flow collection's quotes or brackets do not balance within\n * `text` — i.e. it was left open at end of line (§A3d's multi-line flow).\n */\nfunction flowIsOpen(text: string): boolean {\n let quote: '\"' | \"'\" | null = null;\n let brace = 0;\n let bracket = 0;\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n if (quote) {\n // Single quotes: no backslash escape (review T4-R1 m4).\n if (quote === '\"' && ch === '\\\\' && i + 1 < text.length) { i++; continue; }\n if (ch === quote) quote = null;\n continue;\n }\n // §A3e node-start predicate (review T4-R3 F1) — same rule as the anchor\n // scan; a mid-scalar apostrophe must not swallow the tail.\n if ((ch === '\"' || ch === \"'\") && quoteOpensAtNodeStart(text, i)) { quote = ch; continue; }\n if (ch === '{') brace++;\n else if (ch === '}') brace--;\n else if (ch === '[') bracket++;\n else if (ch === ']') bracket--;\n }\n return brace !== 0 || bracket !== 0 || quote !== null;\n}\n\n/**\n * The lines following a key line that belong to it (§A3d's capture): every\n * following line that is blank or starts with whitespace, plus — when\n * `includeColumn0Items` (a block-opening key) — `- ` item lines at column 0\n * (a block list's items may sit at the key's own indentation, §A3c). Stops at\n * the first other line that starts in column 0 or at the closing `---`;\n * trailing blank lines are excluded.\n */\nfunction captureRawLines(\n lines: string[],\n start: number,\n closingIndex: number,\n includeColumn0Items: boolean,\n): { captured: string[]; next: number } {\n const captured: string[] = [];\n let j = start;\n while (j < closingIndex) {\n const l = lines[j];\n // §A3a (review 2026-12-04): a standalone full-line comment is transparent\n // to a block-opening key's capture — block items may sit at column 0, so\n // a comment BETWEEN items must not end the collection (the parse path\n // filters full-line comments before block parsing; a raw handback keeps\n // them verbatim). The next top-level key still ends the capture.\n if (l.trim() === '' || /^[ \\t]/.test(l) || (includeColumn0Items && (/^-\\s/.test(l) || isFullLineComment(l)))) {\n captured.push(l);\n j++;\n continue;\n }\n break;\n }\n while (captured.length > 0 && captured[captured.length - 1].trim() === '') captured.pop();\n return { captured, next: j };\n}\n\n/**\n * Split a comma-separated list of inner flow entries, respecting quoted strings\n * and nested `{...}` / `[...]` spans (so a nested flow collection's internal\n * commas don't split the outer entry list). Returns null on unbalanced\n * quotes/brackets.\n */\nfunction splitFlowEntries(inner: string): string[] | null {\n const entries: string[] = [];\n let buf = '';\n let i = 0;\n let quote: '\"' | \"'\" | null = null;\n let depthBrace = 0;\n let depthBracket = 0;\n while (i < inner.length) {\n const ch = inner[i];\n if (quote) {\n buf += ch;\n // Single quotes: no backslash escape (review T4-R1 m4).\n if (quote === '\"' && ch === '\\\\' && i + 1 < inner.length) { buf += inner[i + 1]; i += 2; continue; }\n if (ch === quote) quote = null;\n i++; continue;\n }\n if (ch === '\"' || ch === \"'\") { quote = ch; buf += ch; i++; continue; }\n if (ch === '{') depthBrace++;\n else if (ch === '}') depthBrace--;\n else if (ch === '[') depthBracket++;\n else if (ch === ']') depthBracket--;\n if (ch === ',' && depthBrace === 0 && depthBracket === 0) {\n entries.push(buf.trim()); buf = ''; i++; continue;\n }\n buf += ch;\n i++;\n }\n if (buf.trim().length > 0) entries.push(buf.trim());\n if (depthBrace !== 0 || depthBracket !== 0 || quote !== null) return null;\n return entries;\n}\n\n/**\n * Result of the E-variant flow parsers: either a parsed value, or a rejection\n * with the reason the §A3d issue entry carries — `anchor_or_alias` when a\n * node-start `&`/`*` was rejected, `malformed` for a flow syntax error, and\n * `too_deep` for a collection nested past the one-level bound. Callers map\n * the reason onto the §A3d slug: at the top level `too_deep` reports as\n * `malformed` (the value is one flow collection the parser refuses); inside\n * a block (§A3c) it reports as `nested_too_deep` — the block's denoted value\n * is then deeper than anything `serializeFrontmatter` can write (refinement\n * 36).\n */\ntype FlowParseResult =\n | { ok: true; value: OkfFrontmatterValue }\n | { ok: false; reason: 'anchor_or_alias' | 'malformed' | 'too_deep' };\n\n/** Map a flow-parser rejection onto the §A3d slug a block issue carries. */\nfunction blockIssueReason(reason: 'anchor_or_alias' | 'malformed' | 'too_deep'): BlockIssueReason {\n return reason === 'too_deep' ? 'nested_too_deep' : reason;\n}\n\n/**\n * `depth` counts levels of **mapping-value nesting** only: it increments when a\n * flow MAPPING's key has a value that is itself a flow collection, and is\n * rejected once it would exceed 1 (spec §2.6's \"at most one level of nesting\").\n * It does NOT increment when a flow SEQUENCE's item is itself a mapping or\n * sequence — `sources: [ {...}, {...} ]` (a flat array of objects) is the base\n * shape v0.2 uses everywhere and is not \"nesting\" in the spec's sense. This is\n * what lets `sources: [ { usage_window: { from, to } } ]` parse (sequence item\n * is a mapping at depth 0; that mapping's `usage_window` value is a mapping at\n * depth 1 — one level, allowed) while `{ a: { b: { c: 1 } } }` is rejected\n * (`a`'s value nests at depth 1; `b`'s value would need depth 2 — rejected).\n */\nfunction parseFlowMappingE(text: string, depth = 0): FlowParseResult {\n const trimmed = text.trim();\n if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) return { ok: false, reason: 'malformed' };\n // Anchor / alias hard ban, node-start only, quoted spans excluded from the scan.\n if (hasNodeStartAnchorOrAlias(trimmed)) return { ok: false, reason: 'anchor_or_alias' };\n const inner = trimmed.slice(1, -1).trim();\n if (inner.length === 0) return { ok: true, value: {} };\n const entries = splitFlowEntries(inner);\n if (!entries) return { ok: false, reason: 'malformed' };\n const out: Record<string, OkfFrontmatterValue> = {};\n for (const entry of entries) {\n const kv = matchFrontmatterKeyValue(entry);\n if (!kv || !kv.hasValue) return { ok: false, reason: 'malformed' };\n const v = kv.value.trim();\n if (v.startsWith('{') || v.startsWith('[')) {\n // This IS a mapping-value nesting step: consumes one level of budget.\n if (depth >= 1) return { ok: false, reason: 'too_deep' }; // would be a 2nd level of mapping-value nesting — reject\n const nested = v.startsWith('{') ? parseFlowMappingE(v, depth + 1) : parseFlowSequenceE(v, depth + 1);\n if (!nested.ok) return nested;\n // `__proto__` (T4-R3 F5): a mapping-value assignment under it mutates\n // the container's prototype — skipped; the key is never representable.\n const fk = parseKey(kv.key);\n if (fk !== '__proto__') out[fk] = nested.value;\n continue;\n }\n out[parseKey(kv.key)] = parseScalarValue(v);\n }\n return { ok: true, value: out };\n}\n\nfunction parseFlowSequenceE(text: string, depth = 0): FlowParseResult {\n const trimmed = text.trim();\n if (!trimmed.startsWith('[') || !trimmed.endsWith(']')) return { ok: false, reason: 'malformed' };\n if (hasNodeStartAnchorOrAlias(trimmed)) return { ok: false, reason: 'anchor_or_alias' };\n const inner = trimmed.slice(1, -1).trim();\n if (inner.length === 0) return { ok: true, value: [] };\n const entries = splitFlowEntries(inner);\n if (!entries) return { ok: false, reason: 'malformed' };\n const out: OkfFrontmatterValue[] = [];\n for (const entry of entries) {\n const v = entry.trim();\n if (v.startsWith('{')) {\n // Sequence item is a mapping: same depth (base array-of-objects shape).\n const nested = parseFlowMappingE(v, depth);\n if (!nested.ok) return nested;\n out.push(nested.value);\n continue;\n }\n if (v.startsWith('[')) {\n // Nested array consumes one level of depth budget.\n if (depth >= 1) return { ok: false, reason: 'too_deep' };\n const nested = parseFlowSequenceE(v, depth + 1);\n if (!nested.ok) return nested;\n out.push(nested.value);\n continue;\n }\n out.push(parseScalarValue(v));\n }\n return { ok: true, value: out };\n}\n\nexport function parseFlowMapping(text: string, depth = 0): Record<string, OkfFrontmatterValue> | null {\n const res = parseFlowMappingE(text, depth);\n return res.ok ? res.value as Record<string, OkfFrontmatterValue> : null;\n}\n\nexport function parseFlowSequence(text: string, depth = 0): OkfFrontmatterValue[] | null {\n const res = parseFlowSequenceE(text, depth);\n return res.ok ? res.value as OkfFrontmatterValue[] : null;\n}\n\n/**\n * Result of parsing a captured block (§A3c). `ok` carries the value the\n * block denotes; a rejection carries the §A3d slug for the whole\n * block-opening key — `anchor_or_alias` means the key goes to `issues` ONLY\n * (never to `raw`), every other reason hands the key's lines back unparsed.\n */\ntype BlockIssueReason = 'nested_too_deep' | 'block_scalar' | 'multiline_scalar' | 'malformed' | 'anchor_or_alias';\n\ntype BlockParseResult =\n | { ok: true; value: OkfFrontmatterValue }\n | { ok: false; reason: BlockIssueReason };\n\n/** Result of storing one entry: an entry has no single value of its own. */\ntype BlockEntryResult = { ok: true } | { ok: false; reason: BlockIssueReason };\n\n/**\n * Parse the non-blank, non-comment lines of a block that a top-level key with\n * no inline value opened (§A3c): a block mapping (indented `k: v` at one\n * indentation), a block list (`- ` items: scalars, single-line flow\n * collections, or `- k: v` with aligned continuations), or — first line a\n * `|`/`>` indicator — a block scalar, which is unrepresentable. Anything\n * else (mixed forms, misaligned lines, a second indentation level) is not\n * guessed at and comes back as `nested_too_deep`.\n */\nfunction parseBlockLines(blockLines: string[]): BlockParseResult {\n if (/^[|>][-+0-9]*$/.test(blockLines[0].trim())) {\n return { ok: false, reason: 'block_scalar' };\n }\n return /^-\\s/.test(blockLines[0].trimStart())\n ? parseBlockList(blockLines)\n : parseBlockMapping(blockLines);\n}\n\n/**\n * Store one `k: v` entry of a block mapping or block-list item mapping. The\n * value is a scalar, an empty list (key with no value, §11.2 rule 1), or a\n * single-line flow collection parsed at depth 1 — the block's denoted value\n * already sits at the serializer's depth 0, so a line-level flow collection\n * has the one remaining nesting level (refinement 36: a block line\n * `x: { a: { b: 1 } }` is therefore past the bound).\n */\nfunction setBlockMappingEntry(\n out: Record<string, OkfFrontmatterValue>,\n kv: { key: string; value: string; hasValue: boolean },\n content: string,\n): BlockEntryResult {\n const key = parseKey(kv.key);\n const valueText = stripInlineComment(content.slice(kv.key.length + 1));\n if (valueText.length === 0) {\n out[key] = [];\n return { ok: true };\n }\n if (/^[|>][-+0-9]*$/.test(valueText)) return { ok: false, reason: 'block_scalar' };\n if ((valueText[0] === '\"' || valueText[0] === \"'\") && !quoteCloses(valueText)) {\n return { ok: false, reason: 'multiline_scalar' };\n }\n if (hasNodeStartAnchorOrAlias(valueText)) return { ok: false, reason: 'anchor_or_alias' };\n if (valueText.startsWith('{') || valueText.startsWith('[')) {\n const flow = valueText.startsWith('{')\n ? parseFlowMappingE(valueText, 1)\n : parseFlowSequenceE(valueText, 1);\n if (!flow.ok) return { ok: false, reason: blockIssueReason(flow.reason) };\n // `__proto__` (T4-R3 F5): skipped — a mapping under it would mutate the\n // container's prototype. Nothing downstream reads it back as a key.\n if (key !== '__proto__') out[key] = flow.value;\n return { ok: true };\n }\n out[key] = parseScalarValue(valueText);\n return { ok: true };\n}\n\n/** A block mapping: every line an indented `k: v` at one indentation. */\nfunction parseBlockMapping(blockLines: string[]): BlockParseResult {\n const indent = indentWidth(blockLines[0]);\n const out: Record<string, OkfFrontmatterValue> = {};\n for (const line of blockLines) {\n const content = line.trimStart();\n if (indentWidth(line) !== indent || /^-\\s/.test(content)) {\n return { ok: false, reason: 'nested_too_deep' };\n }\n // A line whose unquoted key would start with a flow indicator is not a\n // `k: v` mapping line of the §A3c grammar (a flow node cannot be a key\n // here); leaving it to the key matcher would split at its first colon.\n if (content[0] === '{' || content[0] === '[') return { ok: false, reason: 'nested_too_deep' };\n if (hasNodeStartAnchorOrAlias(content)) return { ok: false, reason: 'anchor_or_alias' };\n const kv = matchBlockKeyValue(content);\n if (!kv) return { ok: false, reason: 'nested_too_deep' };\n const stored = setBlockMappingEntry(out, kv, content);\n if (!stored.ok) return stored;\n }\n return { ok: true, value: out };\n}\n\n/**\n * A block list: `- ` items at one indentation, each a scalar (today's form),\n * a single-line flow collection, or the start of a mapping whose remaining\n * `k: v` lines sit aligned with the item's first key (§A3c, v0.3 §5.2's\n * form). Flow-collection items parse at depth 0 — as a sequence's items they\n * sit AT the denoted array's one nesting level, not below it.\n */\nfunction parseBlockList(blockLines: string[]): BlockParseResult {\n const dashIndent = indentWidth(blockLines[0]);\n const out: OkfFrontmatterValue[] = [];\n let idx = 0;\n while (idx < blockLines.length) {\n const line = blockLines[idx];\n const content = line.trimStart();\n if (indentWidth(line) !== dashIndent || !/^-\\s/.test(content)) {\n return { ok: false, reason: 'nested_too_deep' };\n }\n const afterDash = line.slice(dashIndent + 1);\n const itemWs = afterDash.length - afterDash.trimStart().length;\n // The prepended space keeps a leading `#` counting as \"following\n // whitespace\" for the §A3a comment rule, as in the v0.2 scalar path. An\n // empty item text (`- ` — what the serializer writes for an empty-string\n // list item) stays a scalar, as today.\n const itemText = stripInlineComment(` ${afterDash.trimStart()}`).trim();\n if (hasNodeStartAnchorOrAlias(itemText)) return { ok: false, reason: 'anchor_or_alias' };\n // §A3b symmetry (review T4-R1 m8): an unterminated quoted item is a\n // multiline scalar — refused like a mapping value, never read as a\n // plain string.\n if ((itemText[0] === '\"' || itemText[0] === \"'\") && !quoteCloses(itemText)) {\n return { ok: false, reason: 'multiline_scalar' };\n }\n if (itemText.startsWith('{') || itemText.startsWith('[')) {\n // A single-line flow collection is the item itself (§A3c), not a\n // mapping whose key happens to start with `{`.\n // Array-valued items parse at the serializer's depth (review\n // 2026-12-04): block-list items are emitted one level deep, so a\n // nested array in an item exceeds the bound and the block is handed\n // back raw — parsing it at depth 0 would accept a value the\n // serializer then throws on. Mapping-valued items keep depth 0, as\n // the serializer emits them.\n const flow = itemText.startsWith('{')\n ? parseFlowMappingE(itemText, 0)\n : parseFlowSequenceE(itemText, 1);\n if (!flow.ok) return { ok: false, reason: blockIssueReason(flow.reason) };\n out.push(flow.value);\n idx++;\n continue;\n }\n const kv = matchBlockKeyValue(itemText);\n if (!kv) {\n out.push(parseScalarValue(itemText));\n idx++;\n continue;\n }\n // A mapping item: `- k: v` followed by `k: v` lines aligned with the\n // first key — i.e. at dashIndent + 1 + itemWs.\n const item: Record<string, OkfFrontmatterValue> = {};\n const contIndent = dashIndent + 1 + itemWs;\n const started = setBlockMappingEntry(item, kv, itemText);\n if (!started.ok) return started;\n idx++;\n while (idx < blockLines.length) {\n const cont = blockLines[idx];\n const ci = indentWidth(cont);\n if (ci === dashIndent && /^-\\s/.test(cont.trimStart())) break; // next item\n if (ci !== contIndent) return { ok: false, reason: 'nested_too_deep' };\n const cc = cont.trimStart();\n if (/^-\\s/.test(cc)) return { ok: false, reason: 'nested_too_deep' };\n if (cc[0] === '{' || cc[0] === '[') return { ok: false, reason: 'nested_too_deep' };\n if (hasNodeStartAnchorOrAlias(cc)) return { ok: false, reason: 'anchor_or_alias' };\n const ckv = matchBlockKeyValue(cc);\n if (!ckv) return { ok: false, reason: 'nested_too_deep' };\n const stored = setBlockMappingEntry(item, ckv, cc);\n if (!stored.ok) return stored;\n idx++;\n }\n out.push(item);\n }\n return { ok: true, value: out };\n}\n\n/**\n * A key the parser could not represent, reported by key and reason slug —\n * never by content (spec §A3d). The reason is one of: `nested_too_deep`\n * (block structure beyond the representable level), `block_scalar` (a value\n * introduced by `|` or `>`), `multiline_scalar` (an inline scalar continued\n * on indented lines), `malformed` (a flow collection left open or rejected\n * for depth or syntax), or `anchor_or_alias` (a `&`/`*` at a node start).\n */\nexport interface FrontmatterIssue {\n key: string;\n reason: string;\n}\n\n/**\n * Parses the subset of YAML frontmatter that {@link serializeFrontmatter} produces:\n * scalar string/number/boolean/null values, quoted strings, block string-lists,\n * and one bounded level of block structure (§A3c): a top-level key with no inline\n * value opens a block mapping (indented `k: v` at one indentation) or a block\n * list (`- ` items that are scalars, single-line flow collections, or `- k: v`\n * with aligned continuations). NOT a general YAML parser. The grammar is the\n * §A3 subset: full-line comments are skipped; a `#` after whitespace outside\n * quotes starts a comment (a URL fragment and a `#` inside quotes are data); a\n * line starting with whitespace is never a top-level key; inside a block a key\n * is separated from its value by a colon + space or the end of the line;\n * anchors/aliases (`&`/`*` at a node start) are rejected.\n *\n * Lines whose value the parser cannot represent are handed back unparsed in\n * `raw` (the key's lines verbatim, key line included, trailing blanks excluded)\n * with an entry in `issues`, and the key is absent from `frontmatter` — no key\n * is ever stored as `null`. An anchor/alias key goes to `issues` only, never to\n * `raw` (we must not become an emitter of anchors). An inexact top-level plain\n * scalar (`1.10`, `1234567890123456789`, `True`, `~` — its serialized form\n * differs from its source text) is parsed as today AND its line is placed in\n * `raw` with no issue (§A3f; the check is a top-level one by rule). Block\n * content the grammar cannot represent — a block scalar, a second indentation\n * level, a block line whose flow value nests past the serializer's bound, a\n * multi-line flow — comes back in `raw` with the §A3d reason slug\n * (`block_scalar`, `nested_too_deep`, `malformed`, `multiline_scalar`).\n * Unrecognized lines that match no key at all are still skipped rather than\n * throwing, so a foreign bundle never crashes the import.\n */\nexport function parseFrontmatter(content: string): {\n frontmatter: OkfFrontmatter;\n rest: string;\n raw: Record<string, string>;\n issues: FrontmatterIssue[];\n} {\n const lines = content.split(/\\r?\\n/);\n const fallback = {\n frontmatter: { type: '' } as OkfFrontmatter,\n rest: content,\n raw: {} as Record<string, string>,\n issues: [] as FrontmatterIssue[],\n };\n\n if (lines[0]?.trim() !== '---') return fallback;\n\n let closingIndex = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i].trim() === '---') {\n closingIndex = i;\n break;\n }\n }\n if (closingIndex === -1) return fallback;\n\n const frontmatter: Record<string, OkfFrontmatterValue> = {};\n const raw: Record<string, string> = {};\n const issues: FrontmatterIssue[] = [];\n // §A3e (review T4-R1 M1): a value rejected for an anchor or alias is never\n // kept as raw lines — re-emitting them would make us an emitter of anchors.\n // The scan covers every captured line's node start (a key line's value\n // tail, or a bare node line), so an anchor sitting on a nested or\n // continuation line — past a structural reject the per-line checks never\n // reached — routes the key to `issues` only. Block scalars are excepted\n // (their content is literal text, spec §A3e). Returns false when the\n // handback was refused for an anchor.\n const capturedLinesHaveAnchorOrAlias = (allLines: string[]): boolean => {\n for (const l of allLines) {\n if (l.trim() === '' || isFullLineComment(l)) continue;\n // Key-tail extraction without a backtracking regex (CodeQL\n // js/polynomial-redos, review T3-tail6): the line text is attacker-\n // controlled bundle content, and the previous pattern's\n // leading-whitespace + alternation form backtracked quadratically on\n // repeated tabs. Walk the whitespace, then the quoted-or-bare key run,\n // then require the colon — same language, linear time.\n let i = 0;\n while (i < l.length && (l[i] === ' ' || l[i] === '\\t')) i++;\n let colon = -1;\n if (l[i] === '\"' || l[i] === \"'\") {\n // Escape-aware close (review CodeRabbit round 3): a double-quoted key\n // may contain `\\\"` — the first raw quote is not the closer, and\n // stopping there misreads the value tail as an alias-bearing key.\n let close = -1;\n for (let s = i + 1; s < l.length; s++) {\n if (l[i] === '\"' && l[s] === '\\\\') { s++; continue; }\n if (l[s] === l[i]) { close = s; break; }\n }\n if (close !== -1 && l[close + 1] === ':') {\n colon = close + 1;\n // A key-node anchor (`&x key: v`) rides the KEY, not the tail — the\n // value-only scan missed it (review CodeRabbit round 2).\n if (hasNodeStartAnchorOrAlias(l.slice(i, close))) return true;\n }\n } else {\n let j = i;\n while (j < l.length && l[j] !== ':' && l[j] !== '#') j++;\n if (j < l.length && l[j] === ':' && j > i) {\n colon = j;\n if (hasNodeStartAnchorOrAlias(l.slice(i, j))) return true;\n }\n }\n const tail = colon !== -1 ? l.slice(colon + 1) : l.trimStart();\n if (hasNodeStartAnchorOrAlias(tail)) return true;\n }\n return false;\n };\n const handBack = (key: string, line: string, captured: string[], opts?: { allowAnchors?: boolean }): boolean => {\n if (!opts?.allowAnchors && capturedLinesHaveAnchorOrAlias([line, ...captured])) {\n issues.push({ key, reason: 'anchor_or_alias' });\n return false;\n }\n raw[key] = [line, ...captured].join('\\n');\n return true;\n };\n\n let i = 1;\n while (i < closingIndex) {\n const line = lines[i];\n // §A3a: a line whose first non-blank character is `#` is skipped; blank\n // lines carry no key. §A3b: a line starting with whitespace is never a\n // top-level key — before any key it is ignored (after a key it was\n // already consumed by that key's capture).\n if (line.trim() === '' || isFullLineComment(line) || /^[ \\t]/.test(line)) {\n i++;\n continue;\n }\n\n // §A3e: `&`/`*` at the key node's start. The whole line is rejected to\n // issues only — never kept as raw lines, never mapped.\n if (line[0] === '&' || line[0] === '*') {\n const guess = matchFrontmatterKeyValue(line);\n issues.push({ key: guess ? parseKey(guess.key) : line.trim(), reason: 'anchor_or_alias' });\n i++;\n continue;\n }\n\n const kv = matchFrontmatterKeyValue(line);\n if (!kv) {\n i++;\n continue;\n }\n const key = parseKey(kv.key);\n const valueText = stripInlineComment(line.slice(kv.key.length + 1));\n\n if (valueText.length === 0) {\n // A key with no inline value opens a block (§A3c): a block mapping, a\n // block list (scalars, single-line flow collections, or `- k: v` with\n // aligned continuations), or — first line a `|`/`>` indicator — a\n // block scalar. Anything the one-level grammar cannot represent is\n // handed back unparsed (§A3d); an anchor anywhere in the block sends\n // the key to issues only, never to raw (§A3e).\n const region = captureRawLines(lines, i + 1, closingIndex, true);\n const blockLines = region.captured.filter((l) => l.trim() !== '' && !isFullLineComment(l));\n if (blockLines.length === 0) {\n // No inline value and no block: an empty list, as today.\n frontmatter[key] = [];\n } else {\n const block = parseBlockLines(blockLines);\n if (block.ok) {\n // `__proto__` (T4-R3 F5): a block under that key would mutate the\n // container's prototype — skipped, never representable.\n if (key !== '__proto__') frontmatter[key] = block.value;\n } else if (block.reason === 'anchor_or_alias') {\n issues.push({ key, reason: 'anchor_or_alias' });\n } else {\n // handBack refuses the handback when the captured lines carry an\n // anchor (§A3e), pushing `anchor_or_alias` itself.\n if (handBack(key, line, region.captured)) issues.push({ key, reason: block.reason });\n }\n }\n i = region.next;\n continue;\n }\n\n // §A3e: an anchor/alias at the value node's start is rejected to issues\n // only — never raw, never mapped.\n if (hasNodeStartAnchorOrAlias(valueText)) {\n issues.push({ key, reason: 'anchor_or_alias' });\n i++;\n continue;\n }\n\n // §A3d: a value that starts with a block-scalar indicator (`|` or `>`,\n // indicators included) is a block scalar — its indented lines are literal\n // text the parser does not read.\n if (/^[|>][-+0-9]*$/.test(valueText)) {\n const region = captureRawLines(lines, i + 1, closingIndex, false);\n // Block scalar: content is literal text — the §A3e exception applies.\n handBack(key, line, region.captured, { allowAnchors: true });\n issues.push({ key, reason: 'block_scalar' });\n i = region.next;\n continue;\n }\n\n // Lines after the key line that belong to it (§A3d capture; column-0\n // lines stop it). A non-blank, non-comment one is a continuation of the\n // inline value (§A3b) and makes the key unrepresentable.\n const region = captureRawLines(lines, i + 1, closingIndex, false);\n const hasContinuation = region.captured.some((l) => l.trim() !== '' && !isFullLineComment(l));\n\n // OKF v0.2 flow collections: { k: v, k: v } and [ a, b, c ], at most one\n // level of nesting (spec §2.6). Rejections come back with the reason the\n // issue entry carries (§A3d).\n if (valueText.startsWith('{') || valueText.startsWith('[')) {\n const flow = valueText.startsWith('{')\n ? parseFlowMappingE(valueText)\n : parseFlowSequenceE(valueText);\n if (flow.ok) {\n if (hasContinuation) {\n if (handBack(key, line, region.captured)) issues.push({ key, reason: 'multiline_scalar' });\n } else {\n // `__proto__` (T4-R3 F5): skipped, as at the block site above.\n if (key !== '__proto__') frontmatter[key] = flow.value;\n }\n i = region.next;\n continue;\n }\n if (flow.reason === 'anchor_or_alias') {\n issues.push({ key, reason: 'anchor_or_alias' });\n i++;\n continue;\n }\n // Malformed. A flow collection left open with its continuation in\n // column 0 has no capturable lines: the key is dropped and listed in\n // issues only.\n if (flowIsOpen(valueText) && region.captured.length === 0) {\n issues.push({ key, reason: 'malformed' });\n i++;\n continue;\n }\n if (handBack(key, line, region.captured)) issues.push({ key, reason: 'malformed' });\n i = region.next;\n continue;\n }\n\n // §A3b: a quoted string left open continues on the indented lines below.\n const quoteOpen = (valueText[0] === '\"' || valueText[0] === \"'\") && !quoteCloses(valueText);\n const value = parseScalarValue(valueText);\n if (quoteOpen || hasContinuation) {\n if (handBack(key, line, region.captured)) issues.push({ key, reason: 'multiline_scalar' });\n i = region.next;\n continue;\n }\n frontmatter[key] = value;\n // §A3f: an inexact plain scalar keeps its parsed value AND its line —\n // re-serializing it would differ from the source text — with no issue.\n if (valueText[0] !== '\"' && valueText[0] !== \"'\" && serializeValue(value) !== valueText) {\n raw[key] = line;\n }\n i = region.next;\n }\n\n if (typeof frontmatter['type'] !== 'string') {\n frontmatter['type'] = '';\n }\n\n const restLines = lines.slice(closingIndex + 1);\n const rest = restLines.length > 0 ? restLines.join('\\n') : '';\n\n return { frontmatter: frontmatter as OkfFrontmatter, rest, raw, issues };\n}\n","import type { OkfFrontmatter } from './types';\nimport { serializeFrontmatter, parseFrontmatter, type SerializeFrontmatterOptions } from './frontmatter';\n\nexport function buildConceptDocument(\n fm: OkfFrontmatter,\n body: string,\n options?: SerializeFrontmatterOptions,\n): string {\n return `${serializeFrontmatter(fm, options)}\\n${body}`;\n}\n\n/**\n * Reverse of {@link buildConceptDocument}: strips the single leading blank-line\n * separator. The raw lines (`raw`) and issue entries (`issues`) the §A3 parser\n * handed back are passed through beside `frontmatter` — core decides what to\n * do with each (keep the raw lines of an unmapped key, drop and report a\n * mapped one, spec §A3d/§B8).\n */\nexport function parseConcept(content: string): {\n frontmatter: OkfFrontmatter;\n body: string;\n raw: Record<string, string>;\n issues: ReturnType<typeof parseFrontmatter>['issues'];\n} {\n const { frontmatter, rest, raw, issues } = parseFrontmatter(content);\n const body = rest.startsWith('\\n') ? rest.slice(1) : rest;\n return { frontmatter, body, raw, issues };\n}\n","import { parseFrontmatter, parseKey, serializeFrontmatter } from './frontmatter';\nimport type { FrontmatterIssue } from './frontmatter';\nimport type { OkfFrontmatter, OkfFrontmatterValue, OkfIndexEntry, OkfIndexSection } from './types';\n\nfunction renderEntry(entry: OkfIndexEntry): string {\n const esc = (s: string) =>\n s\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\\[/g, '\\\\[')\n .replace(/\\]/g, '\\\\]')\n .replace(/\\r?\\n/g, ' ');\n\n const title = esc(entry.title);\n const description = entry.description ? esc(entry.description) : undefined;\n\n return description\n ? `* [${title}](${entry.path}) - ${description}`\n : `* [${title}](${entry.path})`;\n}\n\nfunction renderSections(sections: OkfIndexSection[]): string {\n const lines: string[] = [];\n for (const section of sections) {\n lines.push(`## ${section.heading}`);\n lines.push('');\n for (const entry of section.entries) {\n lines.push(renderEntry(entry));\n }\n lines.push('');\n }\n if (lines.length === 0) return '';\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\nexport function buildIndexMd(sections: OkfIndexSection[]): string {\n return renderSections(sections);\n}\n\n/**\n * Reserved raw-line slot of the root-index metadata record (§A5): maps the\n * key of a root key handed back unparsed to its verbatim lines, key line\n * included. `x-llm-wiki-*` is this producer's namespace under profile §4.1.\n */\nconst RAW_SLOT_KEY = 'x-llm-wiki-raw';\n\n/** Options for {@link buildRootIndexMd} (§A5). */\nexport interface BuildRootIndexMdOptions {\n profile?: string;\n /**\n * Root-index metadata, emitted verbatim after `okf_version` and `profile`.\n * Both of those keys are builder-owned and never taken from this record.\n * The reserved `x-llm-wiki-raw` slot (a `Record<key, lines>`) is written\n * only when `profile` is `llm-wiki/3` — its string entries go out verbatim\n * after the metadata keys — and is stripped on `llm-wiki/1` and `/2`, so it\n * can never serialize as a literal YAML key on older profiles (owner note 1).\n */\n bundleMetadata?: Record<string, OkfFrontmatterValue>;\n /**\n * Verbatim lines handed back by a parse (§A7), written after the metadata\n * keys and before the closing `---`. Callers pass only blocks they stored\n * from a parse.\n */\n rawBlocks?: string[];\n}\n\nexport function buildRootIndexMd(\n okfVersion: string,\n sections: OkfIndexSection[],\n options?: BuildRootIndexMdOptions,\n): string {\n const metadata: Record<string, OkfFrontmatterValue> = {};\n // Builder-owned keys never ride a raw block (review 2026-12-04): a verbatim\n // `okf_version: 0.20` line in a caller-supplied raw block would emit beside\n // the owned `okf_version` we write below, and a re-read takes the later\n // line. Genuine raw metadata (a folded `description`, …) is untouched.\n // The grammar binds `key:` with no space too (`okf_version:\"9\"`) and a\n // bare `okf_version:` at end of line (review T4-R1 m6), so the key match\n // accepts both. Applied to caller `rawBlocks` as well as slot entries.\n const OWNED_RAW_KEYS = new Set(['okf_version', 'profile', RAW_SLOT_KEY]);\n // Decode the key with the parser's own normalizer (review CodeRabbit\n // round 3 — `\"x\\u002dcount\"` decodes to `x-count`): the raw block's key\n // claim must match the parsed metadata key, or a verbatim line and its\n // structured copy both emit.\n const rawBlockKeyOf = (lines: string): string | undefined => {\n const first = lines.slice(0, lines.indexOf('\\n') === -1 ? lines.length : lines.indexOf('\\n'));\n const m = first.match(/^[ \\t]*(?:\"([^\"]*)\"|'([^']*)'|([^:#\\s][^:]*)):/);\n if (!m) return undefined;\n return parseKey(m[1] ?? m[2] ?? m[3] ?? '');\n };\n const isOwnedRawBlock = (lines: string): boolean => {\n const key = rawBlockKeyOf(lines);\n return key !== undefined && OWNED_RAW_KEYS.has(key);\n };\n const rawBlocks: string[] = (options?.rawBlocks ?? []).filter((b) => !isOwnedRawBlock(b));\n for (const [key, value] of Object.entries(options?.bundleMetadata ?? {})) {\n // The builder owns okf_version and profile; bundleMetadata never supplies them.\n if (key === 'okf_version' || key === 'profile') continue;\n if (key === RAW_SLOT_KEY) {\n // Owner note 1: the reserved slot is never serialized as a literal key.\n // On llm-wiki/3 its string entries go out verbatim; on every other\n // profile it is stripped entirely.\n if (options?.profile === 'llm-wiki/3' && value !== null && typeof value === 'object' && !Array.isArray(value)) {\n for (const lines of Object.values(value)) {\n if (typeof lines === 'string' && lines.length > 0 && !isOwnedRawBlock(lines)) rawBlocks.push(lines);\n }\n }\n continue;\n }\n metadata[key] = value;\n }\n // A key claimed by a raw block is emitted ONCE — verbatim (review\n // CodeRabbit round 2): `x-count: 0.20` in a raw handback beside the parsed\n // `x-count: 0.2` in metadata would emit the key twice, and last-key-wins\n // would flip the value on re-import. The verbatim raw form is the carrier.\n const claimedByRaw = new Set<string>();\n for (const b of rawBlocks) {\n const k = rawBlockKeyOf(b);\n if (k !== undefined) claimedByRaw.add(k);\n }\n for (const k of claimedByRaw) delete metadata[k];\n const fm: Record<string, OkfFrontmatterValue> = {\n okf_version: okfVersion,\n ...(options?.profile ? { profile: options.profile } : {}),\n ...metadata,\n };\n // One raw block per key (review CodeRabbit round 3): a caller can pass a\n // folded `description` block in rawBlocks AND the same block inside the\n // derived slot — both copies would serialize. First claim wins; later\n // same-key blocks are dropped.\n const seenRawKeys = new Set<string>();\n const uniqueRawBlocks: string[] = [];\n for (const b of rawBlocks) {\n const k = rawBlockKeyOf(b);\n if (k !== undefined && seenRawKeys.has(k)) continue;\n if (k !== undefined) seenRawKeys.add(k);\n uniqueRawBlocks.push(b);\n }\n return `${serializeFrontmatter(fm as OkfFrontmatter, { rawBlocks: uniqueRawBlocks })}\\n${renderSections(sections)}`;\n}\n\n/** Result of {@link parseRootIndexMd} (§A5, refinement 44). */\nexport interface ParsedRootIndexMd {\n okf_version?: string;\n profile?: string;\n /** Every frontmatter key except `okf_version`/`profile` and the\n * parser-synthesized empty `type`. A root key handed back unparsed keeps\n * its verbatim lines under the reserved `x-llm-wiki-raw` slot; an anchor\n * is dropped and reported in `issues` only. */\n metadata: Record<string, OkfFrontmatterValue>;\n /** The parse's raw handback record (§A3d/§A3f), key line included. */\n raw: Record<string, string>;\n /** What the parse dropped or could not read, by key and reason slug. */\n issues: FrontmatterIssue[];\n}\n\nexport function parseRootIndexMd(content: string): ParsedRootIndexMd {\n const { frontmatter, raw, issues } = parseFrontmatter(content);\n const metadata: Record<string, OkfFrontmatterValue> = {};\n // A literal wire `x-llm-wiki-raw` key is reserved (§A5, review T4-R1 m1):\n // it is dropped here — its value would be clobbered by the derived slot —\n // and reported via `issues` so the §B13 parse report can carry\n // `reserved_key` for the root index without mistaking the DERIVED slot\n // (below) for a wire key.\n let literalReservedRaw = false;\n for (const [key, value] of Object.entries(frontmatter)) {\n if (value === undefined) continue;\n if (key === 'okf_version' || key === 'profile') continue;\n if (key === RAW_SLOT_KEY) { literalReservedRaw = true; continue; }\n if (key === 'type' && value === '') continue; // the parser's synthesized empty type (refinement 44)\n metadata[key] = value;\n }\n if (literalReservedRaw) issues.push({ key: RAW_SLOT_KEY, reason: 'reserved_key' });\n // A root key handed back unparsed follows the concept rule (§A5): its\n // verbatim lines are kept under the reserved slot for llm-wiki/3 re-emission.\n // Builder-owned keys are excluded from the slot (review 2026-12-04): a\n // fidelity handback of `okf_version: 0.20` rides the slot otherwise, and a\n // rebuild then emits the owned key twice — the later line wins on re-read.\n // The parsed values are returned as the okf_version/profile fields above,\n // so nothing is lost.\n const builderOwnedRaw = Object.fromEntries(\n Object.entries(raw).filter(\n ([key]) => key !== 'okf_version' && key !== 'profile' && key !== RAW_SLOT_KEY,\n ),\n );\n if (Object.keys(builderOwnedRaw).length > 0) {\n metadata[RAW_SLOT_KEY] = { ...builderOwnedRaw };\n }\n const okf = frontmatter.okf_version;\n // §B1 (review T4-R1 m2): prefer the verbatim source text for `okf_version`.\n // A numeric scalar is read through a float — `1.0` becomes `\"1\"`, which the\n // `<major>.<minor>` integer comparison rejects, so the bundle would count\n // as \"no version\" instead of v0.3-or-above. The §A3f raw handback carries\n // the exact source line; strip an inline comment before matching (review\n // CodeRabbit round 2 — `okf_version: 1.0 # note` is still v0.3-or-above).\n let okfVersion: string | undefined;\n if (typeof okf === 'string') okfVersion = okf;\n else {\n const rawLine = raw['okf_version'];\n let rawText = rawLine != null ? rawLine.slice(rawLine.indexOf(':') + 1).trim() : undefined;\n if (rawText != null) {\n const hash = rawText.indexOf(' #');\n if (hash !== -1) rawText = rawText.slice(0, hash).trim();\n }\n if (rawText != null && /^\\d+\\.\\d+$/.test(rawText)) okfVersion = rawText;\n else if (typeof okf === 'number' && Number.isFinite(okf)) okfVersion = String(okf);\n }\n return {\n okf_version: okfVersion,\n profile: typeof frontmatter.profile === 'string' ? frontmatter.profile : undefined,\n metadata,\n raw,\n issues,\n };\n}\n","import type { OkfIndexSection } from './types';\nimport { buildIndexMd } from './index-md';\n\nconst EVENT_LOG_LINK = /^\\[Event log\\]\\(\\.\\/log\\.md\\)\\s*$/;\n// Only ever tested against trimmed lines; `\\S` replaces `.+\\s*$`.\nconst TOP_LEVEL_H1 = /^#\\s+\\S/;\n// linear: capture starts on \\S so it cannot trade characters with \\s+ (closes CodeQL #2, #3)\nconst SECTION_HEADING = /^##\\s+(\\S.*)$/;\n// linear: `\\` and `[` cannot start a plain label char (closes CodeQL #9); disjoint tail (closes CodeQL #4)\nconst INDEX_ENTRY = /^\\*\\s+\\[((?:\\\\.|[^\\[\\]\\\\])*)\\]\\(([^)]+)\\)(?:\\s+-(\\s.*)?)?$/;\n\nfunction unescapeIndexTitle(title: string): string {\n return title.replace(/\\\\\\]/g, ']').replace(/\\\\\\[/g, '[').replace(/\\\\\\\\/g, '\\\\');\n}\n\nexport function buildEntityIndexMd(options: {\n summary?: string;\n sections: OkfIndexSection[];\n}): string {\n const parts: string[] = [];\n if (options.summary?.trim()) {\n parts.push(options.summary.trimEnd(), '');\n }\n const sectionsMd = buildIndexMd(options.sections).trimEnd();\n if (sectionsMd) {\n parts.push(sectionsMd);\n parts.push('');\n }\n parts.push('[Event log](./log.md)');\n return `${parts.join('\\n')}\\n`;\n}\n\nexport function parseEntityIndexMd(content: string): {\n summary: string;\n sections: OkfIndexSection[];\n} {\n const lines = content.split(/\\r?\\n/);\n\n // Optional frontmatter block (--- ... ---) per profile.\n let start = 0;\n if (lines[0]?.trim() === '---') {\n const closing = lines.findIndex((line, idx) => idx > 0 && line.trim() === '---');\n if (closing !== -1) start = closing + 1;\n }\n\n const firstSectionIdx = lines.findIndex((line, idx) => idx >= start && SECTION_HEADING.test(line));\n const summaryEnd = firstSectionIdx === -1 ? lines.length : firstSectionIdx;\n const summaryLines = lines\n .slice(start, summaryEnd)\n .filter(line => !EVENT_LOG_LINK.test(line.trim()));\n let summaryStart = 0;\n while (summaryStart < summaryLines.length && summaryLines[summaryStart].trim() === '') {\n summaryStart += 1;\n }\n if (summaryStart < summaryLines.length && TOP_LEVEL_H1.test(summaryLines[summaryStart].trim())) {\n summaryStart += 1;\n }\n const summary = summaryLines.slice(summaryStart).join('\\n').trim();\n\n const sections: OkfIndexSection[] = [];\n if (firstSectionIdx === -1) return { summary, sections };\n\n let current: OkfIndexSection | null = null;\n for (let i = Math.max(firstSectionIdx, start); i < lines.length; i += 1) {\n const line = lines[i];\n if (EVENT_LOG_LINK.test(line.trim())) continue;\n\n const headingMatch = SECTION_HEADING.exec(line);\n if (headingMatch) {\n current = { heading: headingMatch[1], entries: [] };\n sections.push(current);\n continue;\n }\n\n if (!current) continue;\n const entryMatch = INDEX_ENTRY.exec(line);\n if (!entryMatch) continue;\n\n const description = entryMatch[3]?.trimStart();\n current.entries.push({\n title: unescapeIndexTitle(entryMatch[1]),\n path: entryMatch[2],\n description: description ? unescapeIndexTitle(description) : undefined,\n });\n }\n return { summary, sections };\n}\n","import type { OkfLogEntry } from './types';\n\nexport function buildLogMd(entries: OkfLogEntry[]): string {\n const groups = new Map<string, OkfLogEntry[]>();\n for (const entry of entries) {\n const group = groups.get(entry.date) ?? [];\n group.push(entry);\n groups.set(entry.date, group);\n }\n\n const dates = Array.from(groups.keys()).sort((a, b) => (a < b ? 1 : a > b ? -1 : 0));\n\n const lines: string[] = [];\n for (const date of dates) {\n lines.push(`## ${date}`);\n lines.push('');\n for (const entry of groups.get(date)!) {\n lines.push(`- ${entry.text}`);\n }\n lines.push('');\n }\n\n if (lines.length === 0) return '';\n return lines.join('\\n').trimEnd() + '\\n';\n}\n\nexport function appendEventIdComment(text: string, eventId: string): string {\n if (!/^[A-Za-z0-9._-]+$/.test(eventId)) return text;\n return `${text} <!-- id: ${eventId} -->`;\n}\n\n// Hand-rolled instead of an unanchored regex (closes CodeQL #5). `lastIndexOf` matches the\n// old leftmost-regex result: `\\S+` could never span the whitespace before a later `<!--`.\nexport function parseEventIdComment(text: string): { text: string; eventId?: string } {\n const trimmed = text.trimEnd();\n if (!trimmed.endsWith('-->')) return { text };\n const open = trimmed.lastIndexOf('<!--');\n if (open === -1) return { text };\n const inner = trimmed.slice(open + 4, -3).trim();\n if (!inner.startsWith('id:')) return { text };\n const eventId = inner.slice(3).trim();\n if (eventId === '' || /\\s/.test(eventId)) return { text };\n const stripped = trimmed.slice(0, open).trimEnd();\n if (!/^[A-Za-z0-9._-]+$/.test(eventId)) return { text: stripped };\n return { text: stripped, eventId };\n}\n\nconst DATE_HEADING = /^##\\s+(\\d{4}-\\d{2}-\\d{2})\\s*$/;\n// linear: capture starts on \\S so it cannot trade characters with \\s+ (closes CodeQL #6)\nconst BULLET = /^-\\s+(\\S.*)?$/;\n\n/**\n * Reverse of {@link buildLogMd}. Best-effort: lines that don't match the exact\n * `## YYYY-MM-DD` heading or `- text` bullet shape buildLogMd emits are skipped,\n * not thrown — a foreign log.md in a different format degrades to fewer entries\n * rather than failing the import.\n */\nexport function parseLogMd(content: string): OkfLogEntry[] {\n const entries: OkfLogEntry[] = [];\n let currentDate: string | null = null;\n\n for (const line of content.split(/\\r?\\n/)) {\n const headingMatch = DATE_HEADING.exec(line);\n if (headingMatch) {\n currentDate = headingMatch[1];\n continue;\n }\n const bulletMatch = BULLET.exec(line);\n if (bulletMatch && currentDate) {\n entries.push({ date: currentDate, text: bulletMatch[1] ?? '' });\n }\n }\n\n return entries;\n}\n","// SHA-256 (FIPS 180-4) and a UTF-8 encoder, written out so core-okf keeps zero runtime\n// dependencies and runs where neither `TextEncoder` nor a synchronous `crypto` is\n// guaranteed (Hermes, browsers). Internal: used by deriveEventId and\n// createEventIdDeriver, not exported from the package.\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nconst rotr = (x: number, n: number) => (x >>> n) | (x << (32 - n));\n\nconst IV = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n\n/** One 64-byte block at `off` of `view` into state `H` (in place). */\nfunction compress(H: Uint32Array, W: Uint32Array, view: DataView, off: number): void {\n for (let t = 0; t < 16; t++) W[t] = view.getUint32(off + t * 4);\n for (let t = 16; t < 64; t++) {\n const s0 = rotr(W[t - 15], 7) ^ rotr(W[t - 15], 18) ^ (W[t - 15] >>> 3);\n const s1 = rotr(W[t - 2], 17) ^ rotr(W[t - 2], 19) ^ (W[t - 2] >>> 10);\n W[t] = (W[t - 16] + s0 + W[t - 7] + s1) >>> 0;\n }\n let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];\n for (let t = 0; t < 64; t++) {\n const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const t1 = (h + S1 + ch + K[t] + W[t]) >>> 0;\n const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const t2 = (S0 + maj) >>> 0;\n h = g; g = f; f = e; e = (d + t1) >>> 0;\n d = c; c = b; b = a; a = (t1 + t2) >>> 0;\n }\n H[0] = (H[0] + a) >>> 0; H[1] = (H[1] + b) >>> 0; H[2] = (H[2] + c) >>> 0; H[3] = (H[3] + d) >>> 0;\n H[4] = (H[4] + e) >>> 0; H[5] = (H[5] + f) >>> 0; H[6] = (H[6] + g) >>> 0; H[7] = (H[7] + h) >>> 0;\n}\n\n/**\n * SHA-256 of `prefix` followed by a suffix given later, many times: the\n * prefix's whole blocks are hashed once here, and each call of the returned\n * function hashes only the rest (`remainder of prefix + suffix`). Same digest\n * as `sha256(concat(prefix, suffix))`.\n */\nexport function sha256WithPrefix(prefix: Uint8Array): (suffix: Uint8Array) => Uint8Array {\n const whole = prefix.length - (prefix.length % 64);\n const H = new Uint32Array(IV);\n const W = new Uint32Array(64);\n const view = new DataView(prefix.buffer, prefix.byteOffset, prefix.byteLength);\n for (let off = 0; off < whole; off += 64) compress(H, W, view, off);\n const rest = prefix.subarray(whole);\n return (suffix) => {\n const tailLen = rest.length + suffix.length;\n const bitLen = (prefix.length + suffix.length) * 8;\n const padded = new Uint8Array((((tailLen + 9 + 63) >> 6) << 6));\n padded.set(rest);\n padded.set(suffix, rest.length);\n padded[tailLen] = 0x80;\n const pv = new DataView(padded.buffer);\n // 64-bit big-endian length; messages here are far below 2^32 bytes.\n pv.setUint32(padded.length - 8, Math.floor(bitLen / 0x100000000));\n pv.setUint32(padded.length - 4, bitLen >>> 0);\n const state = new Uint32Array(H);\n for (let off = 0; off < padded.length; off += 64) compress(state, W, pv, off);\n const out = new Uint8Array(32);\n const outView = new DataView(out.buffer);\n for (let i = 0; i < 8; i++) outView.setUint32(i * 4, state[i]);\n return out;\n };\n}\n\nexport function sha256(bytes: Uint8Array): Uint8Array {\n return sha256WithPrefix(bytes)(new Uint8Array(0));\n}\n\n/** UTF-8 bytes of `s`; a lone UTF-16 surrogate encodes as U+FFFD, as TextEncoder does. */\nexport function utf8Encode(s: string): Uint8Array {\n const out: number[] = [];\n for (let i = 0; i < s.length; i++) {\n let cp = s.charCodeAt(i);\n if (cp >= 0xd800 && cp <= 0xdbff) {\n const next = i + 1 < s.length ? s.charCodeAt(i + 1) : 0;\n if (next >= 0xdc00 && next <= 0xdfff) {\n cp = 0x10000 + ((cp - 0xd800) << 10) + (next - 0xdc00);\n i++;\n } else {\n cp = 0xfffd;\n }\n } else if (cp >= 0xdc00 && cp <= 0xdfff) {\n cp = 0xfffd;\n }\n if (cp < 0x80) out.push(cp);\n else if (cp < 0x800) out.push(0xc0 | (cp >> 6), 0x80 | (cp & 0x3f));\n else if (cp < 0x10000) out.push(0xe0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));\n else out.push(0xf0 | (cp >> 18), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));\n }\n return Uint8Array.from(out);\n}\n","import { sha256WithPrefix, utf8Encode } from './sha256';\n\nexport interface DeriveEventIdInput {\n /** The entity the log is imported into (not a directory name in the bundle). */\n entityId: string;\n /** The log heading's date text, `YYYY-MM-DD`, as written. */\n date: string;\n /** The event type the event is stored with. */\n eventType: string;\n /** The summary the event is stored with (after unescaping). */\n summary: string;\n /** How many earlier id-less lines in the same log share date, type and summary; 0 for the first. */\n occurrence: number;\n}\n\nconst TAG = 'llm-wiki/event-id/1';\nconst PREFIX = 'evt_okf1_';\n\nfunction encodeFields(fields: readonly string[]): Uint8Array {\n const parts: Uint8Array[] = [];\n let total = 0;\n for (const field of fields) {\n const bytes = utf8Encode(field);\n const part = utf8Encode(`${bytes.length}:`);\n const chunk = new Uint8Array(part.length + bytes.length + 1);\n chunk.set(part);\n chunk.set(bytes, part.length);\n chunk[chunk.length - 1] = 0x2c; // ','\n parts.push(chunk);\n total += chunk.length;\n }\n const out = new Uint8Array(total);\n let off = 0;\n for (const p of parts) {\n out.set(p, off);\n off += p.length;\n }\n return out;\n}\n\nconst prefixFields = (input: Omit<DeriveEventIdInput, 'occurrence'>) =>\n [TAG, input.entityId, input.date, input.eventType, input.summary];\n\n/** Length-prefixed field encoding hashed by {@link deriveEventId}. Internal; exported for tests. */\nexport function encodeEventIdInput(input: DeriveEventIdInput): Uint8Array {\n return encodeFields([...prefixFields(input), String(input.occurrence)]);\n}\n\n/**\n * {@link deriveEventId} for one (entity, date, type, summary) at many\n * occurrences: the shared fields are encoded and hashed once, so each call\n * costs the same however long the summary is. Returns the same ids as\n * `deriveEventId({ ...input, occurrence })`.\n */\nexport function createEventIdDeriver(input: Omit<DeriveEventIdInput, 'occurrence'>): (occurrence: number) => string {\n const finish = sha256WithPrefix(encodeFields(prefixFields(input)));\n return (occurrence) => {\n if (!Number.isInteger(occurrence) || occurrence < 0) {\n throw new TypeError(`deriveEventId: occurrence must be an integer >= 0, got ${String(occurrence)}`);\n }\n const digest = finish(encodeFields([String(occurrence)]));\n let hex = '';\n for (let i = 0; i < 16; i++) hex += digest[i].toString(16).padStart(2, '0');\n return PREFIX + hex;\n };\n}\n\n/**\n * Deterministic id for an OKF log line that carries no id comment\n * (`docs/okf-profile.md` §7): `evt_okf1_` + the first 32 hex characters of\n * SHA-256 over the length-prefixed fields. The same line in the same entity\n * always gets the same id, so importing it again is a no-op while the earlier\n * copy is stored.\n */\nexport function deriveEventId(input: DeriveEventIdInput): string {\n return createEventIdDeriver(input)(input.occurrence);\n}\n","import type { OkfMarkdownLink } from './types';\n\nfunction escapeLinkLabel(label: string): string {\n return label\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\\[/g, '\\\\[')\n .replace(/\\]/g, '\\\\]')\n .replace(/\\r?\\n/g, ' ');\n}\n\nexport function appendRelatedSection(\n body: string,\n links: Array<{ edge_type: string; path: string }>,\n): string {\n if (links.length === 0) return body;\n const prefix =\n body.length === 0\n ? ''\n : body.endsWith('\\n\\n')\n ? body\n : body.endsWith('\\n')\n ? `${body}\\n`\n : `${body}\\n\\n`;\n const lines = ['## Related', ''];\n for (const link of links) {\n lines.push(`- [${escapeLinkLabel(link.edge_type)}](${link.path})`);\n }\n return `${prefix}${lines.join('\\n')}\\n`;\n}\n\nexport function splitRelatedSection(body: string): { body: string; relatedLinks: OkfMarkdownLink[] } {\n const lines = body.split(/\\r?\\n/);\n let end = lines.length;\n while (end > 0 && lines[end - 1].trim() === '') end -= 1;\n\n let scan = end - 1;\n while (scan >= 0 && /^-\\s+/.test(lines[scan])) scan -= 1;\n while (scan >= 0 && lines[scan].trim() === '') scan -= 1;\n\n if (scan < 0 || lines[scan].trim() !== '## Related') {\n return { body, relatedLinks: [] };\n }\n\n const relatedStart = scan;\n const contentBody = lines.slice(0, relatedStart).join('\\n');\n const relatedBlock = lines.slice(relatedStart, end).join('\\n');\n const relatedLinks: OkfMarkdownLink[] = [];\n for (const line of relatedBlock.split(/\\r?\\n/)) {\n const bullet = /^-\\s+(\\S.*)?$/.exec(line);\n if (!bullet) continue;\n\n // linear: `\\` and `[` cannot start a plain label char, so each attempt stops at the next `[` (closes CodeQL #10)\n const linkPattern = /\\[((?:\\\\.|[^\\[\\]\\\\])*)\\]\\(([^)\\s]+)\\)/g;\n let match: RegExpExecArray | null;\n while ((match = linkPattern.exec(bullet[1] ?? '')) !== null) {\n const linkPath = match[2];\n if (/^(https?:|mailto:)/i.test(linkPath)) continue;\n relatedLinks.push({\n text: match[1].replace(/\\\\\\]/g, ']').replace(/\\\\\\[/g, '[').replace(/\\\\\\\\/g, '\\\\'),\n path: linkPath,\n });\n }\n }\n const normalizedBody =\n contentBody.length === 0 ? '' : contentBody.endsWith('\\n') ? contentBody : `${contentBody}\\n`;\n return { body: normalizedBody, relatedLinks };\n}\n","const ALLOWED =\n /^(index\\.md|entities\\/[^/]+\\/(index\\.md|log\\.md|(facts|tasks)\\/[^/]+\\.md))$/;\n\nexport function isAllowedOkfPath(filePath: string): boolean {\n const normalized = filePath.replace(/^\\.\\//, '').replace(/\\\\/g, '/');\n if (normalized.split('/').some(segment => segment === '.' || segment === '..')) {\n return false;\n }\n return ALLOWED.test(normalized);\n}\n","import type { OkfMarkdownLink } from './types';\n\nconst EXCLUDED_SCHEME = /^(https?:|mailto:)/i;\nconst FENCED_CODE_BLOCK_PATTERN = /```[\\s\\S]*?```/g;\n\n/**\n * Extracts inline markdown links (`[text](path)`) from a concept body.\n * Single-line regex, not a CommonMark parser — reference-style links, links\n * split across lines, and links inside code fences are not recognized.\n * `http(s):` and `mailto:` targets are excluded; only relative/local paths\n * are candidates for graph edges.\n */\nexport function extractMarkdownLinks(body: string): OkfMarkdownLink[] {\n const searchableBody = body.replace(FENCED_CODE_BLOCK_PATTERN, '');\n const linkPattern = /\\[([^\\]]*)\\]\\(([^)\\s]+)\\)/g;\n const links: OkfMarkdownLink[] = [];\n let match: RegExpExecArray | null;\n while ((match = linkPattern.exec(searchableBody)) !== null) {\n const [, text, path] = match;\n if (EXCLUDED_SCHEME.test(path)) continue;\n links.push({ text, path });\n }\n return links;\n}\n","import type { OkfFootnote } from './types';\n\nconst FOOTNOTE_DEFINITION = /^\\[\\^([^\\]]+)\\]:\\s?(.*)$/;\n\n/**\n * Extracts footnote definitions from a body. OKF v0.2 footnote attribution uses\n * `[^id]` markers whose label joins to `sources[].id`. This helper parses the\n * `[^id]: text` definition lines at the body tail and returns them as opaque\n * text — we deliberately do NOT try to interpret which body span uses which\n * footnote; the body is the source of truth and is preserved verbatim on\n * round-trip.\n */\nexport function extractFootnotes(body: string): OkfFootnote[] {\n const out: OkfFootnote[] = [];\n const lines = body.split(/\\r?\\n/);\n let i = 0;\n while (i < lines.length) {\n const m = FOOTNOTE_DEFINITION.exec(lines[i]);\n if (!m) { i++; continue; }\n const id = m[1];\n const firstLine = m[2] ?? '';\n const collected: string[] = [firstLine];\n i++;\n while (i < lines.length) {\n const next = lines[i];\n if (FOOTNOTE_DEFINITION.test(next)) break;\n // Continuation lines are indented (>= 2 spaces) per CommonMark.\n if (/^\\s{2,}\\S/.test(next) || /^\\s{2,}/.test(next)) {\n collected.push(next.replace(/^\\s{2}/, ''));\n i++;\n continue;\n }\n break;\n }\n out.push({ id, body: collected.join('\\n').trimEnd() });\n }\n return out;\n}\n\n/** Joins footnote definitions back into a body block. Continuation lines are\n * indented (two spaces) so that {@link extractFootnotes} — which only\n * recognizes continuation lines that are indented per CommonMark — round-trips\n * multi-line bodies. */\nexport function serializeFootnotes(footnotes: OkfFootnote[]): string {\n return footnotes\n .map((f) => {\n const lines = f.body.split('\\n');\n const [firstLine, ...continuation] = lines;\n const tail = continuation.map((line) => `\\n ${line}`).join('');\n return `[^${f.id}]: ${firstLine ?? ''}${tail}`;\n })\n .join('\\n');\n}","/**\n * OKF v0.3 timestamp helpers (spec okf-v03 §A1; upstream §5, §13.2).\n *\n * v0.3 §5 accepts exactly two forms: an RFC 3339 date-time WITH an explicit\n * offset, or a date-only `YYYY-MM-DD` (meaning start of that day, UTC). An\n * offset-less date-time (`2026-01-01T00:00:00`) stays invalid — §13.2. Our\n * YAML layer is 1.2 core schema, so quoted and native scalars both arrive\n * here as strings; finite numbers (epoch ms, the stored column form) pass\n * through. Returns epoch ms, or null when unparseable.\n */\n\nconst DATE_ONLY = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst DATE_TIME =\n /^(\\d{4})-(\\d{2})-(\\d{2})[Tt](\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?([Zz]|[+-]\\d{2}:\\d{2})$/;\n\n/** Review T4-R1 m5: compute the epoch from the already-captured components\n * instead of the host's `Date.parse`, which differs across engines on\n * lowercase `t`/`z` and fraction digits beyond six — the doc comment\n * promises host independence. Second 60 (RFC 3339 leap second) rolls over\n * deterministically in Date.UTC. Fraction digits past milliseconds\n * truncate. */\nfunction epochFromDateTime(dt: RegExpExecArray): number {\n const year = Number(dt[1]);\n const month = Number(dt[2]);\n const day = Number(dt[3]);\n const hour = Number(dt[4]);\n const minute = Number(dt[5]);\n const second = Number(dt[6]);\n const frac = dt[7];\n const fracMs = frac ? Number(frac.slice(1, 4).padEnd(3, '0')) : 0;\n let ms = Date.UTC(year, month - 1, day, hour, minute, second, fracMs);\n const offset = dt[8];\n if (offset[0] === '+' || offset[0] === '-') {\n const sign = offset[0] === '-' ? -1 : 1;\n const oh = Number(offset.slice(1, 3));\n const om = Number(offset.slice(4, 6));\n ms -= sign * (oh * 60 + om) * 60_000;\n }\n return ms;\n}\n\n/** Date.UTC silently normalizes calendar-invalid dates (2025-02-29 → 2025-03-01);\n * round-trip back through Date and reject any component that doesn't match. */\nfunction utcDayValid(year: number, month: number, day: number): boolean {\n const ts = Date.UTC(year, month - 1, day);\n const d = new Date(ts);\n return (\n d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day\n );\n}\n\nexport function parseOkfTimestamp(value: unknown): number | null {\n if (typeof value === 'number') return Number.isFinite(value) ? value : null;\n if (typeof value !== 'string') return null;\n const s = value.trim();\n if (s.length === 0) return null;\n\n const dateOnly = DATE_ONLY.exec(s);\n if (dateOnly) {\n const year = Number(dateOnly[1]);\n const month = Number(dateOnly[2]);\n const day = Number(dateOnly[3]);\n if (!utcDayValid(year, month, day)) return null;\n return Date.UTC(year, month - 1, day);\n }\n\n const dt = DATE_TIME.exec(s);\n if (!dt) return null;\n const year = Number(dt[1]);\n const month = Number(dt[2]);\n const day = Number(dt[3]);\n const hour = Number(dt[4]);\n const minute = Number(dt[5]);\n const second = Number(dt[6]);\n if (!utcDayValid(year, month, day)) return null;\n if (hour > 23 || minute > 59 || second > 60) return null; // RFC 3339 allows leap second 60\n // Offset component bounds (review T3-tail7 #2): the regex admits `+99:99`,\n // which RFC 3339 does not — an invalid offset must read unparseable (raw /\n // stale), not become a \"valid\" cutoff.\n const offset = dt[8];\n if (offset[0] !== 'Z' && offset[0] !== 'z') {\n const oh = Number(offset.slice(1, 3));\n const om = Number(offset.slice(4, 6));\n if (oh > 23 || om > 59) return null;\n }\n return epochFromDateTime(dt);\n}\n","import type {\n OkfVerified,\n OkfVerifiedEntry,\n OkfSource,\n OkfSourceUsageWindow,\n} from './types';\nimport { parseOkfTimestamp } from './v03-helpers';\n\nexport type TrustTier = 'unverified' | 'machine-confirmed' | 'human-reviewed';\n\n/**\n * OKF v0.3 §5.3 trust currency (spec okf-v03 §A2, ruling R2). Optional second\n * parameter `generatedAt`: epoch ms or a parseable timestamp string. When\n * provided, only events whose parsed `at >= generatedAt` are current (an\n * event whose `at` does not parse is ignored for tiering, kept as history);\n * a `generatedAt` that is present but unreadable means NO event is current.\n * When no event is current the tier is 'unverified' — it can only go down.\n * When `generatedAt` is absent, all events are current, which\n * reproduces the v0.2 sticky rule exactly (R2). §11.2 rule 2: `verified` may\n * be a bare mapping.\n */\nexport function deriveTrustTier(\n verified: OkfVerified | OkfVerifiedEntry | undefined,\n generatedAt?: number | string | null,\n): TrustTier {\n const events: OkfVerifiedEntry[] = !verified\n ? []\n : Array.isArray(verified)\n ? verified\n : [verified as OkfVerifiedEntry];\n if (events.length === 0) return 'unverified';\n\n const restricted = generatedAt !== undefined && generatedAt !== null;\n const cutoff = restricted ? parseOkfTimestamp(generatedAt) : null;\n\n const isCurrent = (v: OkfVerifiedEntry): boolean => {\n if (!restricted) return true;\n const at = parseOkfTimestamp(v.at);\n if (at == null) return false;\n return cutoff != null && at >= cutoff;\n };\n\n // Owner amendment 2026-12-03: tier from CURRENT events only — when no\n // event is current (all `at`s stale or unparseable, or `generatedAt`\n // itself unreadable) the tier is 'unverified', not 'machine-confirmed'.\n const current = events.filter(isCurrent);\n if (current.length === 0) return 'unverified';\n\n for (const v of current) {\n if (typeof v?.by === 'string' && v.by.startsWith('human:')) {\n return 'human-reviewed';\n }\n }\n return 'machine-confirmed';\n}\n\n/**\n * OKF v0.3 §5.5: a consumer MUST NOT treat a `stale_after` value that it\n * cannot parse as fresh. `null`/`undefined`, an empty or whitespace-only\n * string are absent — not stale (§11.2 rule 1). A finite number, or a string\n * `parseOkfTimestamp` accepts, compares as `now >= cutoff`. Anything else —\n * a string that does not parse, a non-finite number — is STALE.\n */\nexport function isStaleAfter(staleAfter: string | number | null, now: number): boolean {\n if (staleAfter == null) return false;\n if (typeof staleAfter === 'number') {\n return Number.isFinite(staleAfter) ? now >= staleAfter : true;\n }\n if (typeof staleAfter !== 'string') return true;\n if (staleAfter.trim().length === 0) return false;\n const cutoff = parseOkfTimestamp(staleAfter);\n if (cutoff != null) return now >= cutoff;\n return true;\n}\n\nexport function parseVerifiedFlexible(value: unknown): OkfVerified {\n if (value == null) return [];\n if (Array.isArray(value)) {\n return value.filter(\n (v): v is OkfVerifiedEntry =>\n !!v && typeof v === 'object' && typeof (v as any).by === 'string' && typeof (v as any).at === 'string',\n );\n }\n if (typeof value === 'object' && typeof (value as any).by === 'string' && typeof (value as any).at === 'string') {\n return [value as OkfVerifiedEntry];\n }\n return [];\n}\n\n/**\n * OKF v0.3 §A4 (spec okf-v03, refinement 26): mirror of\n * `parseVerifiedFlexible`. §11.2 rule 2: `sources` may be a bare mapping —\n * one item ⇒ a list with one item. An entry is kept only when it is a\n * mapping whose REQUIRED `resource` is a non-empty string (§5.1, §11.2\n * rule 3); every other entry is ignored and counted in `ignored` so a\n * consumer can report the count (§B13 `sources_entry_invalid`). `null`,\n * `undefined` and unrecognizable shapes are absent — nothing to keep,\n * nothing to count. The kept entries are the caller's own objects,\n * unmodified (extras ride along; refinement 47).\n */\nexport function parseSourcesFlexible(value: unknown): { sources: OkfSource[]; ignored: number } {\n const isValidSource = (v: unknown): v is OkfSource =>\n !!v &&\n typeof v === 'object' &&\n !Array.isArray(v) &&\n typeof (v as any).resource === 'string' &&\n (v as any).resource !== '';\n if (value == null) return { sources: [], ignored: 0 };\n if (Array.isArray(value)) {\n const sources: OkfSource[] = [];\n let ignored = 0;\n for (const entry of value) {\n if (isValidSource(entry)) sources.push(entry);\n else ignored += 1;\n }\n return { sources, ignored };\n }\n // A bare mapping is the one item of §11.2 rule 2: the same per-entry\n // rule decides keep vs ignore-and-count. Anything else (a scalar) is\n // not an entry — absent, like parseVerifiedFlexible.\n if (isValidSource(value)) return { sources: [value], ignored: 0 };\n if (typeof value === 'object') return { sources: [], ignored: 1 };\n return { sources: [], ignored: 0 };\n}\n\nexport function formatVerifiedJson(entries: OkfVerified): string {\n // Sort by Date.parse() instant so different ISO 8601 offsets don't re-order\n // (lexical sort put `2026-01-01T00:00:00-08:00` before `2026-01-01T05:00:00Z`,\n // even though the latter is later in real time). Falls back to a deterministic\n // lexical tiebreak only when one or both values fail to parse.\n const sorted = [...entries].sort((a, b) => {\n // §5 timestamps parse through parseOkfTimestamp: an offset-less date-time\n // is invalid (§13.2) and must not sort by the importing machine's zone.\n const ta = parseOkfTimestamp(a.at);\n const tb = parseOkfTimestamp(b.at);\n const fa = ta != null;\n const fb = tb != null;\n if (fa && fb) return ta - tb;\n if (fa && !fb) return -1;\n if (!fa && fb) return 1;\n return a.at < b.at ? -1 : a.at > b.at ? 1 : 0;\n });\n return JSON.stringify(sorted);\n}\n\nexport function formatSourcesJson(sources: OkfSource[], sharedWindow?: OkfSourceUsageWindow | null): string {\n const folded = sources.map((s) =>\n s.usage_window ? s : sharedWindow ? { ...s, usage_window: sharedWindow } : s,\n );\n return JSON.stringify(folded);\n}\n\nexport function latestVerified(\n entries: OkfVerified | undefined,\n _now: number,\n): { by: string; at: number } | null {\n if (!entries || entries.length === 0) return null;\n let best: OkfVerifiedEntry | null = null;\n let bestAt = -Infinity;\n for (const e of entries) {\n const ts = parseOkfTimestamp(e.at);\n if (ts != null && ts > bestAt) {\n best = e;\n bestAt = ts;\n }\n }\n if (!best) return null;\n return { by: best.by, at: bestAt };\n}\n\nconst URL_LINE = /^\\s*-\\s+(https?:\\/\\/\\S+)\\s*$/;\n\nexport function parseCitationsList(body: string): string[] {\n // Find a '# Citations' (case-insensitive) heading; collect URL list lines\n // until the next heading or EOF. Headings inside fenced code blocks\n // (``` and ~~~) are ignored so a Markdown example containing\n // `# Citations` and URL bullets is not imported as real provenance.\n //\n // Fence tracking retains the full opening fence length: a 4-backtick\n // opener is only closed by a 4+ backtick line of the same character\n // followed by whitespace (CommonMark §4.5). Tracking only the marker\n // char let ``` close ```` blocks, which then exposed the next line as\n // a URL bullet and imported it as synthetic provenance (see #90 review).\n const lines = body.split(/\\r?\\n/);\n let inFence = false;\n let fenceMarker = '';\n let fenceLength = 0;\n let startIdx = -1;\n const isFenceClose = (marker: string, fullMatch: string, line: string): boolean => {\n if (marker[0] !== fenceMarker) return false;\n if (marker.length < fenceLength) return false;\n return /^\\s*$/.test(line.slice(fullMatch.length));\n };\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const fence = /^\\s*(```+|~~~+)/.exec(line);\n if (fence) {\n const marker = fence[1]!;\n if (!inFence) {\n inFence = true;\n fenceMarker = marker[0]!;\n fenceLength = marker.length;\n } else if (isFenceClose(marker, fence[0], line)) {\n inFence = false;\n fenceMarker = '';\n fenceLength = 0;\n }\n continue;\n }\n if (!inFence && /^\\s*#{1,2}\\s*citations\\s*$/i.test(line)) {\n startIdx = i;\n break;\n }\n }\n if (startIdx === -1) return [];\n const out: string[] = [];\n for (let i = startIdx + 1; i < lines.length; i++) {\n const line = lines[i];\n // Closing fence or a new heading exits the citations section.\n const fence = /^\\s*(```+|~~~+)/.exec(line);\n if (fence) {\n const marker = fence[1]!;\n if (!inFence) {\n inFence = true;\n fenceMarker = marker[0]!;\n fenceLength = marker.length;\n continue;\n }\n if (isFenceClose(marker, fence[0], line)) {\n inFence = false;\n fenceMarker = '';\n fenceLength = 0;\n }\n continue;\n }\n if (!inFence && /^\\s*#{1,2}\\s+/.test(line)) break; // next heading\n // Skip URL line matching inside open fences — body's narrative code\n // examples must not contaminate provenance.\n if (inFence) continue;\n const m = URL_LINE.exec(line);\n if (m) out.push(m[1]);\n }\n return out;\n}"]}