@moldea.ai/core 9.1.1 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
- import { a as escapeJsonPointerSegment, c as ACCEPTABLE_WARNING_CODES, i as createCoreDiagnosticCollector, s as createNullPrototypeRecord, t as createCoreOperationOptionsSnapshot, u as RECOGNIZED_RUNTIME_IDS } from "./options-C5360E_N.js";
1
+ import { a as escapeJsonPointerSegment, d as ACCEPTABLE_WARNING_CODES, i as createCoreDiagnosticCollector, l as parseStrictYaml, o as locateDiagnosticRanges, p as RECOGNIZED_RUNTIME_IDS, t as createCoreOperationOptionsSnapshot, u as createNullPrototypeRecord } from "./options-BXKLnSDR.js";
2
2
  import { n as CoreOperationException } from "./exceptions-AT654xUL.js";
3
3
  import { compareCodePoints, countUtf8Bytes, deepFreeze, isObjectValid } from "jg-utilities";
4
4
  import { isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
5
- import { Parser, isAlias, isMap, isScalar, isSeq, parseAllDocuments } from "yaml";
6
5
  //#region src/format-validation/index.ts
7
6
  var STABLE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
8
7
  var VARIABLE_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
@@ -1509,214 +1508,6 @@ var createSourceLocator = (value) => {
1509
1508
  }) });
1510
1509
  };
1511
1510
  //#endregion
1512
- //#region src/yaml/index.ts
1513
- var CORE_TAGS = /* @__PURE__ */ new Set([
1514
- "tag:yaml.org,2002:bool",
1515
- "tag:yaml.org,2002:float",
1516
- "tag:yaml.org,2002:int",
1517
- "tag:yaml.org,2002:map",
1518
- "tag:yaml.org,2002:null",
1519
- "tag:yaml.org,2002:seq",
1520
- "tag:yaml.org,2002:str"
1521
- ]);
1522
- var toRange = (range, locator) => {
1523
- return locator.locateRange(range?.[0] ?? 0, range?.[1] ?? range?.[0] ?? 0);
1524
- };
1525
- var addUnsupportedFeature = (diagnostics, path, range, reason) => {
1526
- diagnostics.add({
1527
- code: "MOLDEA_YAML_FEATURE_UNSUPPORTED",
1528
- details: { reason },
1529
- path,
1530
- range
1531
- });
1532
- };
1533
- var isCoreTagCompatible = (node) => {
1534
- switch (node.tag) {
1535
- case "tag:yaml.org,2002:bool": return isScalar(node) && typeof node.value === "boolean";
1536
- case "tag:yaml.org,2002:float": return isScalar(node) && typeof node.value === "number";
1537
- case "tag:yaml.org,2002:int": return isScalar(node) && typeof node.value === "bigint";
1538
- case "tag:yaml.org,2002:map": return isMap(node);
1539
- case "tag:yaml.org,2002:null": return isScalar(node) && node.value === null;
1540
- case "tag:yaml.org,2002:seq": return isSeq(node);
1541
- case "tag:yaml.org,2002:str": return isScalar(node) && typeof node.value === "string";
1542
- default: return false;
1543
- }
1544
- };
1545
- var convertNode = (node, path, locator, diagnostics) => {
1546
- const range = toRange(node.range, locator);
1547
- if (isAlias(node)) {
1548
- addUnsupportedFeature(diagnostics, path, range, "alias");
1549
- return null;
1550
- }
1551
- if ("anchor" in node && typeof node.anchor === "string") addUnsupportedFeature(diagnostics, path, range, "anchor");
1552
- if (node.tag !== void 0) {
1553
- if (!CORE_TAGS.has(node.tag)) {
1554
- addUnsupportedFeature(diagnostics, path, range, "custom-tag");
1555
- return null;
1556
- }
1557
- if (!isCoreTagCompatible(node)) {
1558
- diagnostics.add({
1559
- code: "MOLDEA_YAML_MALFORMED",
1560
- details: { reason: "tag-value" },
1561
- path,
1562
- range
1563
- });
1564
- return null;
1565
- }
1566
- }
1567
- if (isScalar(node)) {
1568
- const value = node.value;
1569
- if (value !== null && typeof value !== "string" && typeof value !== "number" && typeof value !== "bigint" && typeof value !== "boolean") {
1570
- diagnostics.add({
1571
- code: "MOLDEA_YAML_MALFORMED",
1572
- details: { reason: "scalar-type" },
1573
- path,
1574
- range
1575
- });
1576
- return null;
1577
- }
1578
- if (typeof value === "string" && !value.isWellFormed()) {
1579
- diagnostics.add({
1580
- code: "MOLDEA_YAML_MALFORMED",
1581
- details: { reason: "invalid-unicode" },
1582
- path,
1583
- range
1584
- });
1585
- return null;
1586
- }
1587
- return {
1588
- kind: "scalar",
1589
- range,
1590
- source: node.source,
1591
- style: node.type ?? null,
1592
- value
1593
- };
1594
- }
1595
- if (isSeq(node)) {
1596
- const items = [];
1597
- for (const item of node.items) {
1598
- if (item === null) {
1599
- items.push({
1600
- kind: "scalar",
1601
- range,
1602
- source: "",
1603
- style: null,
1604
- value: null
1605
- });
1606
- continue;
1607
- }
1608
- const converted = convertNode(item, path, locator, diagnostics);
1609
- if (converted !== null) items.push(converted);
1610
- }
1611
- return {
1612
- items,
1613
- kind: "sequence",
1614
- range
1615
- };
1616
- }
1617
- if (isMap(node)) {
1618
- const entries = [];
1619
- for (const pair of node.items) {
1620
- const key = convertNode(pair.key, path, locator, diagnostics);
1621
- const value = pair.value === null ? {
1622
- kind: "scalar",
1623
- range: key?.range ?? range,
1624
- source: "",
1625
- style: null,
1626
- value: null
1627
- } : convertNode(pair.value, path, locator, diagnostics);
1628
- if (key?.kind === "scalar" && key.value === "<<" && key.style === "PLAIN") addUnsupportedFeature(diagnostics, path, key.range, "merge-key");
1629
- if (key !== null && value !== null) entries.push({
1630
- key,
1631
- value
1632
- });
1633
- }
1634
- return {
1635
- entries,
1636
- kind: "mapping",
1637
- range
1638
- };
1639
- }
1640
- diagnostics.add({
1641
- code: "MOLDEA_YAML_MALFORMED",
1642
- details: { reason: "node-type" },
1643
- path,
1644
- range
1645
- });
1646
- return null;
1647
- };
1648
- var addParserDiagnostic = (code, start, end, path, locator, diagnostics) => {
1649
- if (code === "BAD_DIRECTIVE") return;
1650
- if (code === "DUPLICATE_KEY") {
1651
- diagnostics.add({
1652
- code: "MOLDEA_YAML_DUPLICATE_KEY",
1653
- path,
1654
- range: locator.locateRange(start, end)
1655
- });
1656
- return;
1657
- }
1658
- if (code === "TAG_RESOLVE_FAILED") return;
1659
- diagnostics.add({
1660
- code: "MOLDEA_YAML_MALFORMED",
1661
- details: { reason: code === "RESOURCE_EXHAUSTION" ? "resource-exhaustion" : "syntax" },
1662
- path,
1663
- range: locator.locateRange(start, end)
1664
- });
1665
- };
1666
- /**
1667
- * Parses one normalized YAML 1.2 Core Schema document into parser-neutral nodes.
1668
- * @param value The normalized manifest text.
1669
- * @param path The logical source path used by diagnostics.
1670
- * @param locator The scalar-aware source locator for the normalized text.
1671
- * @param diagnostics The operation diagnostic collector.
1672
- * @returns The private parsed tree only when the YAML substrate is trustworthy.
1673
- */
1674
- var parseStrictYaml = (value, path, locator, diagnostics) => {
1675
- const initialDiagnosticCount = diagnostics.size;
1676
- for (const token of new Parser().parse(value)) if (token.type === "directive") addUnsupportedFeature(diagnostics, path, locator.locateRange(token.offset, token.offset + token.source.length), "directive");
1677
- const documents = parseAllDocuments(value, {
1678
- intAsBigInt: true,
1679
- keepSourceTokens: true,
1680
- logLevel: "silent",
1681
- merge: false,
1682
- prettyErrors: false,
1683
- resolveKnownTags: false,
1684
- schema: "core",
1685
- strict: true,
1686
- uniqueKeys: true,
1687
- version: "1.2"
1688
- });
1689
- if (documents.length > 1) {
1690
- const range = documents[1]?.range;
1691
- diagnostics.add({
1692
- code: "MOLDEA_YAML_MULTIPLE_DOCUMENTS",
1693
- path,
1694
- range: locator.locateRange(range?.[0] ?? 0, range?.[0] ?? 0)
1695
- });
1696
- }
1697
- for (const document of documents) for (const error of [...document.errors, ...document.warnings]) addParserDiagnostic(error.code, error.pos[0], error.pos[1], path, locator, diagnostics);
1698
- if (documents.length > 1 || diagnostics.size > initialDiagnosticCount) return {
1699
- valid: false,
1700
- value: null
1701
- };
1702
- const document = documents[0];
1703
- if (document === void 0 || document.contents === null) return {
1704
- valid: true,
1705
- value: {
1706
- kind: "scalar",
1707
- range: locator.locateRange(0, 0),
1708
- source: "",
1709
- style: null,
1710
- value: null
1711
- }
1712
- };
1713
- const parsedValue = convertNode(document.contents, path, locator, diagnostics);
1714
- return {
1715
- valid: parsedValue !== null && diagnostics.size === initialDiagnosticCount,
1716
- value: diagnostics.size === initialDiagnosticCount ? parsedValue : null
1717
- };
1718
- };
1719
- //#endregion
1720
1511
  //#region src/manifest/index.ts
1721
1512
  /**
1722
1513
  * Inspects one complete manifest while retaining an independently trustworthy supported version.
@@ -1744,18 +1535,21 @@ var inspectManifestDocument = async (input, options, operation = "parse-manifest
1744
1535
  diagnostics: diagnostics.finalize(),
1745
1536
  formatVersion: null,
1746
1537
  manifest: null,
1747
- valid: false
1538
+ valid: false,
1539
+ yamlRoot: null
1748
1540
  });
1749
1541
  const locator = createSourceLocator(normalized.text.value);
1750
1542
  const parsed = parseStrictYaml(normalized.text.value, path, locator, diagnostics);
1751
1543
  const formatVersion = parsed.value === null ? null : detectSupportedManifestVersion(parsed.value);
1752
1544
  const manifest = parsed.valid && parsed.value !== null ? validateManifest(parsed.value, path, diagnostics, options.limits, operation) : null;
1545
+ const locatedDiagnostics = locateDiagnosticRanges(diagnostics.finalize(), new Map(parsed.value === null ? [] : [[path, parsed.value]]));
1753
1546
  if (manifest === null || diagnostics.size > 0) return deepFreeze({
1754
1547
  asset: null,
1755
- diagnostics: diagnostics.finalize(),
1548
+ diagnostics: locatedDiagnostics,
1756
1549
  formatVersion,
1757
1550
  manifest: null,
1758
- valid: false
1551
+ valid: false,
1552
+ yamlRoot: parsed.value
1759
1553
  });
1760
1554
  const digest = await calculateNormalizedTextDigest(normalized.text);
1761
1555
  const asset = {
@@ -1767,10 +1561,11 @@ var inspectManifestDocument = async (input, options, operation = "parse-manifest
1767
1561
  };
1768
1562
  return deepFreeze({
1769
1563
  asset,
1770
- diagnostics: diagnostics.finalize(),
1564
+ diagnostics: locatedDiagnostics,
1771
1565
  formatVersion,
1772
1566
  manifest,
1773
- valid: true
1567
+ valid: true,
1568
+ yamlRoot: parsed.value
1774
1569
  });
1775
1570
  };
1776
1571
  /**
@@ -1885,6 +1680,6 @@ var matchManifestScope = async (input, options) => {
1885
1680
  });
1886
1681
  };
1887
1682
  //#endregion
1888
- export { trimRepositoryFormatWhitespace as _, createSourceLocator as a, calculateContentDigest as c, countUnicodeScalars as d, hasNonWhitespace as f, parseDecisionIdFromPath as g, isVariableId as h, parseStrictYaml as i, calculateNormalizedTextDigest as l, isRuntimeGuidancePath as m, inspectManifestDocument as n, collectManifestScopeDeclarations as o, isContextPath as p, parseManifestDocument as r, matchesRepositoryGlob as s, matchManifestScope as t, normalizeTextDocument as u };
1683
+ export { collectManifestScopeDeclarations as a, calculateNormalizedTextDigest as c, hasNonWhitespace as d, isContextPath as f, trimRepositoryFormatWhitespace as g, parseDecisionIdFromPath as h, createSourceLocator as i, normalizeTextDocument as l, isVariableId as m, inspectManifestDocument as n, matchesRepositoryGlob as o, isRuntimeGuidancePath as p, parseManifestDocument as r, calculateContentDigest as s, matchManifestScope as t, countUnicodeScalars as u };
1889
1684
 
1890
- //# sourceMappingURL=scope-CNg6Gnpi.js.map
1685
+ //# sourceMappingURL=scope-COlv6gct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-COlv6gct.js","names":[],"sources":["../../src/format-validation/index.ts","../../src/text/index.ts","../../src/scope-matching/patterns.ts","../../src/scope-matching/matching.ts","../../src/manifest-validation/index.ts","../../src/source-location/index.ts","../../src/manifest/index.ts","../../src/scope-matching/validations.ts","../../src/scope-matching/scope.ts"],"sourcesContent":["import { isRepositoryPath, parseRepositoryPath, type IRepositoryPath } from '@moldea.ai/repository';\n\nconst STABLE_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;\nconst VARIABLE_ID_PATTERN = /^[A-Z][A-Z0-9_]*$/u;\nconst WINDOWS_RESERVED_ID_PATTERN = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u;\nconst LINE_BREAK_CHARACTERS = ['\\n', '\\r', '\\u0085', '\\u2028', '\\u2029'] as const;\nconst UNSUPPORTED_GLOB_PATTERN = /[!?[\\]{}]/u;\n\nconst hasLineBreak = (value: string): boolean => {\n return LINE_BREAK_CHARACTERS.some((lineBreak) => value.includes(lineBreak));\n};\n\n/** Determines whether a code point belongs to the Repository Format version 1 whitespace set. */\nexport const isRepositoryFormatWhitespace = (codePoint: number): boolean => {\n return (\n (codePoint >= 0x0009 && codePoint <= 0x000d) ||\n codePoint === 0x0020 ||\n codePoint === 0x0085 ||\n codePoint === 0x00a0 ||\n codePoint === 0x1680 ||\n (codePoint >= 0x2000 && codePoint <= 0x200a) ||\n codePoint === 0x2028 ||\n codePoint === 0x2029 ||\n codePoint === 0x202f ||\n codePoint === 0x205f ||\n codePoint === 0x3000\n );\n};\n\n/** Counts Unicode scalar values in valid JavaScript text. */\nexport const countUnicodeScalars = (value: string): number => {\n const scalars = value[Symbol.iterator]();\n let count = 0;\n\n while (scalars.next().done !== true) {\n count += 1;\n }\n\n return count;\n};\n\n/** Determines whether a value contains at least one non-whitespace scalar. */\nexport const hasNonWhitespace = (value: string): boolean => {\n for (const scalar of value) {\n if (!isRepositoryFormatWhitespace(scalar.codePointAt(0) ?? 0)) {\n return true;\n }\n }\n\n return false;\n};\n\n/** Determines whether a value begins or ends with version 1 whitespace. */\nexport const hasSurroundingWhitespace = (value: string): boolean => {\n const firstCodePoint = value.codePointAt(0);\n const lastCodePoint = value.codePointAt(value.length - 1);\n\n return (\n (firstCodePoint !== undefined && isRepositoryFormatWhitespace(firstCodePoint)) ||\n (lastCodePoint !== undefined && isRepositoryFormatWhitespace(lastCodePoint))\n );\n};\n\n/** Removes only Repository Format version 1 whitespace from both edges. */\nexport const trimRepositoryFormatWhitespace = (value: string): string => {\n let start = 0;\n let end = value.length;\n\n while (start < end) {\n const codePoint = value.codePointAt(start);\n\n if (codePoint === undefined || !isRepositoryFormatWhitespace(codePoint)) {\n break;\n }\n\n start += codePoint > 0xffff ? 2 : 1;\n }\n\n while (end > start) {\n const codePoint = value.codePointAt(end - 1);\n\n if (codePoint === undefined || !isRepositoryFormatWhitespace(codePoint)) {\n break;\n }\n\n end -= 1;\n }\n\n return value.slice(start, end);\n};\n\n/** Determines whether a string is non-empty and contains no line break. */\nexport const isNonEmptySingleLine = (value: string): boolean => {\n return value.length > 0 && !hasLineBreak(value);\n};\n\n/** Determines whether a value satisfies stable moldea ID syntax. */\nexport const isStableId = (value: string): boolean => {\n return value.length <= 64 && STABLE_ID_PATTERN.test(value);\n};\n\n/** Determines whether an otherwise valid stable ID is filesystem-reserved. */\nexport const isReservedId = (value: string): boolean => WINDOWS_RESERVED_ID_PATTERN.test(value);\n\n/** Determines whether a value satisfies runtime-variable ID syntax. */\nexport const isVariableId = (value: string): boolean => {\n return value.length <= 64 && VARIABLE_ID_PATTERN.test(value);\n};\n\n/** Determines whether a parsed capability description satisfies version 1 limits. */\nexport const isCapabilityDescription = (value: string): boolean => {\n const scalarLength = countUnicodeScalars(value);\n\n return (\n scalarLength >= 1 &&\n scalarLength <= 1_000 &&\n !hasSurroundingWhitespace(value) &&\n !hasLineBreak(value) &&\n !value.includes('\\0') &&\n !value.includes('{{') &&\n !value.includes('}}')\n );\n};\n\n/** Parses a non-root repository-format logical path without throwing. */\nexport const parseManifestPath = (value: string): IRepositoryPath | null => {\n return value !== '/' && isRepositoryPath(value) ? parseRepositoryPath(value) : null;\n};\n\n/** Determines whether a path is the canonical manifest path. */\nexport const isCanonicalManifestPath = (path: IRepositoryPath): boolean => {\n return path === '/moldea/moldea.yaml';\n};\n\n/** Extracts the stable millisecond ID from one canonical immediate decision path. */\nexport const parseDecisionIdFromPath = (path: IRepositoryPath): string | null => {\n const match = /^\\/moldea\\/decisions\\/(\\d{13})-([a-z0-9]+(?:-[a-z0-9]+)*)\\.md$/u.exec(path);\n const id = match?.[1];\n const slug = match?.[2];\n\n return id !== undefined && slug !== undefined && isStableId(slug) ? id : null;\n};\n\n/** Determines whether a path is an allowed focused-context relationship key. */\nexport const isContextPath = (path: IRepositoryPath, allowProject: boolean): boolean => {\n if (allowProject && path === '/moldea/project.md') {\n return true;\n }\n\n return path.startsWith('/moldea/context/') && path.endsWith('.md');\n};\n\n/** Determines whether a path has the canonical immediate decision filename shape. */\nexport const isDecisionPath = (path: IRepositoryPath): boolean => {\n return parseDecisionIdFromPath(path) !== null;\n};\n\n/** Determines whether a path is canonical runtime guidance. */\nexport const isRuntimeGuidancePath = (path: IRepositoryPath): boolean => {\n return path.startsWith('/moldea/runtimes/') && path.endsWith('.md');\n};\n\n/** Determines whether a mirror path is outside canonical moldea content. */\nexport const isMirrorPath = (path: IRepositoryPath): boolean => {\n return path !== '/moldea' && !path.startsWith('/moldea/');\n};\n\n/** Determines whether an impact path contains prohibited glob metacharacters. */\nexport const hasUnsupportedGlobMetacharacter = (value: string): boolean => {\n return UNSUPPORTED_GLOB_PATTERN.test(value);\n};\n\n/** Determines whether a string satisfies the version 1 simple-glob grammar. */\nexport const isSimpleGlob = (value: string): boolean => {\n if (hasUnsupportedGlobMetacharacter(value) || value.includes('***')) {\n return false;\n }\n\n const segments = value.slice(1).split('/');\n\n if (segments.some((segment) => segment.includes('**') && segment !== '**')) {\n return false;\n }\n\n return value.includes('*') && isRepositoryPath(value.replaceAll('*', 'x'));\n};\n\n/** Determines whether a repository-reference symbol has the common safe shape. */\nexport const isRepositorySymbol = (value: string): boolean => {\n return isNonEmptySingleLine(value) && !value.includes('\\0');\n};\n\n/** Determines whether a canonical moldea reference incorrectly carries a symbol. */\nexport const isCanonicalMoldeaPath = (path: IRepositoryPath): boolean => {\n return path === '/moldea' || path.startsWith('/moldea/');\n};\n","import { countUtf8Bytes, deepFreeze, isObjectValid } from 'jg-utilities';\n\nimport { parseRepositoryPath, type IRepositoryPath } from '@moldea.ai/repository';\n\nimport type {\n IContentDigest,\n IContentDigestResult,\n ICoreResourceLimits,\n INormalizedText,\n ITextDocumentInput,\n ITextNormalizationResult,\n} from '../contracts/index.js';\nimport {\n createCoreDiagnosticCollector,\n type ICoreDiagnosticCollector,\n} from '../diagnostic-utilities/index.js';\nimport type { ICoreDiagnostic } from '../diagnostics/index.js';\nimport { CoreOperationException, type ICoreOperation } from '../exceptions/index.js';\nimport { countUnicodeScalars } from '../format-validation/index.js';\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });\n\n/**\n * Collects every normalized NUL location or rejects when the diagnostic budget is exhausted.\n * @param value The normalized scalar text to inspect.\n * @param path The logical document path attached to each diagnostic.\n * @param diagnostics The operation collector receiving every NUL diagnostic.\n * @throws\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nconst collectNulDiagnostics = (\n value: string,\n path: IRepositoryPath,\n diagnostics: ICoreDiagnosticCollector,\n): void => {\n let column = 1;\n let line = 1;\n let offset = 0;\n\n for (const scalar of value) {\n if (scalar === '\\0') {\n diagnostics.add({\n code: 'MOLDEA_TEXT_NUL_FORBIDDEN',\n path,\n range: {\n end: { column: column + 1, line, offset: offset + 1 },\n start: { column, line, offset },\n },\n });\n }\n\n if (scalar === '\\n') {\n column = 1;\n line += 1;\n } else {\n column += 1;\n }\n\n offset += 1;\n }\n};\n\nconst invalidArgument = (operation: ICoreOperation): never => {\n throw new CoreOperationException({\n code: 'INVALID_ARGUMENT',\n operation,\n });\n};\n\nconst enforceFileLimit = (\n byteLength: number,\n limits: ICoreResourceLimits,\n operation: ICoreOperation,\n limit: 'maxFileBytes' | 'maxManifestBytes',\n): void => {\n if (byteLength <= limits[limit]) {\n return;\n }\n\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit,\n limitMaximum: limits[limit],\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage: byteLength,\n operation,\n });\n};\n\nconst invalidResult = (diagnostics: readonly ICoreDiagnostic[]): ITextNormalizationResult => {\n return deepFreeze({\n diagnostics: [...diagnostics],\n text: null,\n valid: false,\n });\n};\n\n/**\n * Validates one public text input, enforces its source-byte budget, and decodes strict UTF-8.\n * @param input The untrusted public text-document input.\n * @param limits The immutable Core resource limits.\n * @param operation The public operation requesting the input.\n * @param limit The source-byte limit applied by the operation.\n * @param diagnostics The operation collector receiving text diagnostics.\n * @returns Decoded text or a frozen structural failure result.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - INVALID_ARGUMENT: The Core operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nconst readInput = (\n input: ITextDocumentInput,\n limits: ICoreResourceLimits,\n operation: ICoreOperation,\n limit: 'maxFileBytes' | 'maxManifestBytes',\n diagnostics: ICoreDiagnosticCollector,\n): { readonly path: IRepositoryPath; readonly value: string } | ITextNormalizationResult => {\n if (!isObjectValid(input, true)) {\n return invalidArgument(operation);\n }\n\n const pathCandidate = input['path'];\n const content = input['content'];\n\n if (\n typeof pathCandidate !== 'string' ||\n (typeof content !== 'string' && !(content instanceof Uint8Array))\n ) {\n return invalidArgument(operation);\n }\n\n const path = parseRepositoryPath(pathCandidate);\n\n if (typeof content === 'string') {\n enforceFileLimit(countUtf8Bytes(content, limits[limit]), limits, operation, limit);\n\n if (!content.isWellFormed()) {\n diagnostics.add({ code: 'MOLDEA_TEXT_INVALID_UNICODE', path });\n return invalidResult(diagnostics.finalize());\n }\n\n return { path, value: content };\n }\n\n enforceFileLimit(content.byteLength, limits, operation, limit);\n const bytes = new Uint8Array(content);\n\n try {\n return { path, value: decoder.decode(bytes) };\n } catch {\n diagnostics.add({ code: 'MOLDEA_TEXT_INVALID_UTF8', path });\n return invalidResult(diagnostics.finalize());\n }\n};\n\n/**\n * Validates and normalizes one text document under an operation-specific resource budget.\n * @param input The logical path and decoded string or exact source bytes.\n * @param limits The immutable Core resource limits.\n * @param operation The public Core operation requesting normalization.\n * @param limit The source-byte limit applied by the operation.\n * @returns A frozen normalized result or structural text diagnostics.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - INVALID_ARGUMENT: The Core operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const normalizeTextDocument = (\n input: ITextDocumentInput,\n limits: ICoreResourceLimits,\n operation: ICoreOperation,\n limit: 'maxFileBytes' | 'maxManifestBytes' = 'maxFileBytes',\n): ITextNormalizationResult => {\n const diagnostics = createCoreDiagnosticCollector(limits, operation);\n const decoded = readInput(input, limits, operation, limit, diagnostics);\n\n if ('valid' in decoded) {\n return decoded;\n }\n\n const withoutLeadingBom = decoded.value.startsWith('\\ufeff')\n ? decoded.value.slice(1)\n : decoded.value;\n const value = withoutLeadingBom.replace(/\\r\\n?/gu, '\\n');\n collectNulDiagnostics(value, decoded.path, diagnostics);\n\n if (diagnostics.size > 0) {\n return invalidResult(diagnostics.finalize());\n }\n\n const text: INormalizedText = deepFreeze({\n scalarLength: countUnicodeScalars(value),\n utf8ByteLength: countUtf8Bytes(value),\n value,\n });\n\n return deepFreeze({\n diagnostics: [],\n text,\n valid: true,\n });\n};\n\nconst toLowercaseHex = (bytes: Uint8Array): string => {\n let value = '';\n\n for (const byte of bytes) {\n value += byte.toString(16).padStart(2, '0');\n }\n\n return value;\n};\n\n/**\n * Calculates the canonical digest for already-normalized text.\n * @param text The validated normalized text to encode and hash.\n * @returns A promise resolving to the canonical lowercase SHA-256 digest.\n */\nexport const calculateNormalizedTextDigest = async (\n text: INormalizedText,\n): Promise<IContentDigest> => {\n const bytes = encoder.encode(text.value);\n const hash = new Uint8Array(await globalThis.crypto.subtle.digest('SHA-256', bytes));\n\n return `sha256:${toLowercaseHex(hash)}` as IContentDigest;\n};\n\n/**\n * Calculates the normalized SHA-256 digest for one text document.\n * @param input The logical path and decoded string or exact source bytes.\n * @param limits The immutable Core resource limits.\n * @returns A promise resolving to a frozen digest result or structural text diagnostics.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - INVALID_ARGUMENT: The Core operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const calculateContentDigest = async (\n input: ITextDocumentInput,\n limits: ICoreResourceLimits,\n): Promise<IContentDigestResult> => {\n const normalized = normalizeTextDocument(input, limits, 'calculate-content-digest');\n\n if (!normalized.valid || normalized.text === null) {\n return deepFreeze({\n diagnostics: normalized.diagnostics,\n digest: null,\n text: null,\n valid: false,\n });\n }\n\n const digest = await calculateNormalizedTextDigest(normalized.text);\n\n return deepFreeze({\n diagnostics: [],\n digest,\n text: normalized.text,\n valid: true,\n });\n};\n","import type { IRepositoryPath } from '@moldea.ai/repository';\n\n/** Tests a single-segment wildcard without regular-expression interpretation. */\nconst matchesSegment = (pattern: string, value: string): boolean => {\n let patternIndex = 0;\n let valueIndex = 0;\n let starIndex = -1;\n let starValueIndex = -1;\n\n while (valueIndex < value.length) {\n if (pattern[patternIndex] === value[valueIndex]) {\n patternIndex += 1;\n valueIndex += 1;\n continue;\n }\n\n if (pattern[patternIndex] === '*') {\n starIndex = patternIndex;\n starValueIndex = valueIndex;\n patternIndex += 1;\n continue;\n }\n\n if (starIndex === -1) {\n return false;\n }\n\n patternIndex = starIndex + 1;\n starValueIndex += 1;\n valueIndex = starValueIndex;\n }\n\n while (pattern[patternIndex] === '*') {\n patternIndex += 1;\n }\n\n return patternIndex === pattern.length;\n};\n\n/** Matches validated simple-glob segments with zero-or-more-segment globstars. */\nexport const matchesRepositoryGlob = (\n patternSegments: readonly string[],\n path: IRepositoryPath,\n): boolean => {\n const pathSegments = path.slice(1).split('/');\n let reachable = new Uint8Array(pathSegments.length + 1);\n reachable[0] = 1;\n\n for (const patternSegment of patternSegments) {\n const next = new Uint8Array(pathSegments.length + 1);\n\n if (patternSegment === '**') {\n let canReach = false;\n\n for (let index = 0; index < reachable.length; index += 1) {\n canReach ||= reachable[index] === 1;\n next[index] = canReach ? 1 : 0;\n }\n } else {\n for (let index = 0; index < pathSegments.length; index += 1) {\n if (reachable[index] === 1 && matchesSegment(patternSegment, pathSegments[index] ?? '')) {\n next[index + 1] = 1;\n }\n }\n }\n\n reachable = next;\n }\n\n return reachable[pathSegments.length] === 1;\n};\n","import { compareCodePoints, countUtf8Bytes, deepFreeze } from 'jg-utilities';\n\nimport type { IRepositoryPath } from '@moldea.ai/repository';\n\nimport type { IContentDigest, ICoreResourceLimits } from '../contracts/index.js';\nimport { escapeJsonPointerSegment } from '../diagnostic-utilities/index.js';\nimport { CoreOperationException } from '../exceptions/index.js';\nimport { countUnicodeScalars } from '../format-validation/index.js';\nimport type {\n IAgentManifestEntry,\n IMoldeaManifestV1,\n IRepositoryReference,\n ISkillManifestEntry,\n IToolManifestEntry,\n IUnresolvedRequirementManifestEntry,\n} from '../format/index.js';\nimport { calculateNormalizedTextDigest } from '../text/index.js';\n\nimport type {\n IManifestScopeCounts,\n IManifestScopeDeclaration,\n IManifestScopeMatch,\n IManifestScopeOwner,\n IManifestScopeRelationshipField,\n} from './types.js';\nimport { matchesRepositoryGlob } from './patterns.js';\n\ninterface IManifestScopeRelationshipDeclaration {\n readonly owner: IManifestScopeOwner;\n readonly field: IManifestScopeRelationshipField;\n readonly pointer: string;\n readonly declaration: IManifestScopeDeclaration;\n}\n\ninterface ICompiledGlobDeclaration {\n readonly declaration: IManifestScopeRelationshipDeclaration;\n readonly segments: readonly string[];\n}\n\ninterface ICompiledManifestScope {\n readonly declarations: readonly IManifestScopeRelationshipDeclaration[];\n readonly exact: ReadonlyMap<IRepositoryPath, readonly IManifestScopeRelationshipDeclaration[]>;\n readonly globalGlobs: readonly ICompiledGlobDeclaration[];\n readonly globsByFirstSegment: ReadonlyMap<string, readonly ICompiledGlobDeclaration[]>;\n}\n\ntype IManifestCapability =\n | { readonly kind: 'skill'; readonly value: ISkillManifestEntry }\n | { readonly kind: 'tool'; readonly value: IToolManifestEntry };\n\nconst childPointer = (pointer: string, segment: string): string => {\n return `${pointer}/${escapeJsonPointerSegment(segment)}`;\n};\n\nconst createOwner = (\n kind: IManifestScopeOwner['kind'],\n id: string,\n agentId: string | null = null,\n): IManifestScopeOwner => ({ agentId, id, kind });\n\nconst compareOwners = (left: IManifestScopeOwner, right: IManifestScopeOwner): number => {\n return (\n compareCodePoints(left.kind, right.kind) ||\n compareCodePoints(left.agentId ?? '', right.agentId ?? '') ||\n compareCodePoints(left.id, right.id)\n );\n};\n\nconst getDeclarationValue = (declaration: IManifestScopeDeclaration): string => {\n return declaration.kind === 'exact' ? declaration.path : declaration.pattern;\n};\n\nconst compareDeclarations = (\n left: IManifestScopeRelationshipDeclaration,\n right: IManifestScopeRelationshipDeclaration,\n): number => {\n return (\n compareOwners(left.owner, right.owner) ||\n compareCodePoints(left.field, right.field) ||\n compareCodePoints(\n getDeclarationValue(left.declaration),\n getDeclarationValue(right.declaration),\n ) ||\n compareCodePoints(left.pointer, right.pointer)\n );\n};\n\n/** Adds one exact repository relationship to the normalized declaration collection. */\nconst addExactDeclaration = (\n declarations: IManifestScopeRelationshipDeclaration[],\n owner: IManifestScopeOwner,\n field: IManifestScopeRelationshipField,\n pointer: string,\n reference: IRepositoryReference | IRepositoryPath,\n): void => {\n declarations.push({\n declaration:\n typeof reference === 'string'\n ? { kind: 'exact', path: reference, symbol: null }\n : { kind: 'exact', path: reference.path, symbol: reference.symbol ?? null },\n field,\n owner,\n pointer,\n });\n};\n\n/** Adds repository references with their authored declaration pointers. */\nconst addReferenceDeclarations = (\n declarations: IManifestScopeRelationshipDeclaration[],\n references: readonly IRepositoryReference[] | undefined,\n owner: IManifestScopeOwner,\n field: IManifestScopeRelationshipField,\n pointer: string,\n): void => {\n for (const [index, reference] of (references ?? []).entries()) {\n addExactDeclaration(\n declarations,\n owner,\n field,\n childPointer(pointer, String(index)),\n reference,\n );\n }\n};\n\n/** Adds exact and simple-glob impact relationships in authored array order. */\nconst addAffectedByDeclarations = (\n declarations: IManifestScopeRelationshipDeclaration[],\n affectedBy: readonly string[] | undefined,\n owner: IManifestScopeOwner,\n pointer: string,\n): void => {\n for (const [index, pattern] of (affectedBy ?? []).entries()) {\n declarations.push({\n declaration: pattern.includes('*')\n ? { kind: 'glob', pattern }\n : { kind: 'exact', path: pattern as IRepositoryPath, symbol: null },\n field: 'affectedBy',\n owner,\n pointer: childPointer(pointer, String(index)),\n });\n }\n};\n\n/** Adds project-level or agent-level unresolved requirement references. */\nconst addUnresolvedDeclarations = (\n declarations: IManifestScopeRelationshipDeclaration[],\n requirements: Readonly<Record<string, IUnresolvedRequirementManifestEntry>> | undefined,\n pointer: string,\n agentId: string | null,\n): void => {\n for (const requirementId of Object.keys(requirements ?? {}).sort(compareCodePoints)) {\n const requirement = requirements?.[requirementId];\n\n if (requirement === undefined) {\n continue;\n }\n\n const owner = createOwner('unresolved', requirementId, agentId);\n addReferenceDeclarations(\n declarations,\n requirement.related,\n owner,\n 'related',\n childPointer(childPointer(pointer, requirementId), 'related'),\n );\n }\n};\n\n/** Adds exact and impact declarations owned by one tool or skill capability. */\nconst addCapabilityDeclarations = (\n declarations: IManifestScopeRelationshipDeclaration[],\n capabilityId: string,\n capability: IManifestCapability,\n agentId: string,\n pointer: string,\n): void => {\n const owner = createOwner(capability.kind, capabilityId, agentId);\n addExactDeclaration(\n declarations,\n owner,\n 'implementation',\n childPointer(pointer, 'implementation'),\n capability.value.implementation,\n );\n\n if (capability.value.registration !== undefined) {\n addExactDeclaration(\n declarations,\n owner,\n 'registration',\n childPointer(pointer, 'registration'),\n capability.value.registration,\n );\n }\n\n if (capability.kind === 'tool') {\n for (const field of ['inputSchema', 'outputSchema'] as const) {\n const reference = capability.value[field];\n\n if (reference !== undefined) {\n addExactDeclaration(declarations, owner, field, childPointer(pointer, field), reference);\n }\n }\n }\n\n addAffectedByDeclarations(\n declarations,\n capability.value.affectedBy,\n owner,\n childPointer(pointer, 'affectedBy'),\n );\n};\n\n/** Adds all exact and impact relationships owned by one registered agent. */\nconst addAgentDeclarations = (\n declarations: IManifestScopeRelationshipDeclaration[],\n agentId: string,\n agent: IAgentManifestEntry,\n): void => {\n const pointer = childPointer('/agents', agentId);\n const owner = createOwner('agent', agentId, agentId);\n const bindingsPointer = childPointer(pointer, 'bindings');\n\n for (const field of [\n 'runtimeAgent',\n 'inputSchema',\n 'outputSchema',\n 'instructionLoader',\n ] as const) {\n const reference = agent.bindings?.[field];\n\n if (reference !== undefined) {\n addExactDeclaration(\n declarations,\n owner,\n field,\n childPointer(bindingsPointer, field),\n reference,\n );\n }\n }\n\n for (const variableId of Object.keys(agent.bindings?.variableProviders ?? {}).sort(\n compareCodePoints,\n )) {\n const reference = agent.bindings?.variableProviders?.[variableId];\n\n if (reference !== undefined) {\n addExactDeclaration(\n declarations,\n owner,\n 'variableProvider',\n childPointer(childPointer(bindingsPointer, 'variableProviders'), variableId),\n reference,\n );\n }\n }\n\n addAffectedByDeclarations(\n declarations,\n agent.affectedBy,\n owner,\n childPointer(pointer, 'affectedBy'),\n );\n\n for (const capabilityId of Object.keys(agent.tools ?? {}).sort(compareCodePoints)) {\n const tool = agent.tools?.[capabilityId];\n\n if (tool !== undefined) {\n addCapabilityDeclarations(\n declarations,\n capabilityId,\n { kind: 'tool', value: tool },\n agentId,\n childPointer(childPointer(pointer, 'tools'), capabilityId),\n );\n }\n }\n\n for (const capabilityId of Object.keys(agent.skills ?? {}).sort(compareCodePoints)) {\n const skill = agent.skills?.[capabilityId];\n\n if (skill !== undefined) {\n addCapabilityDeclarations(\n declarations,\n capabilityId,\n { kind: 'skill', value: skill },\n agentId,\n childPointer(childPointer(pointer, 'skills'), capabilityId),\n );\n }\n }\n\n for (const [index, mirror] of (agent.mirrors ?? []).entries()) {\n addExactDeclaration(\n declarations,\n owner,\n 'mirrors',\n childPointer(childPointer(pointer, 'mirrors'), String(index)),\n mirror,\n );\n }\n\n addUnresolvedDeclarations(\n declarations,\n agent.unresolved,\n childPointer(pointer, 'unresolved'),\n agentId,\n );\n};\n\n/** Collects every version 1 declaration that can establish changed-path relevance. */\nexport const collectManifestScopeDeclarations = (\n manifest: IMoldeaManifestV1,\n): readonly IManifestScopeRelationshipDeclaration[] => {\n const declarations: IManifestScopeRelationshipDeclaration[] = [];\n\n for (const kind of ['context', 'decision'] as const) {\n const relationships = kind === 'context' ? manifest.context : manifest.decisions;\n\n for (const ownerId of Object.keys(relationships ?? {}).sort(compareCodePoints)) {\n const relationship = relationships?.[ownerId];\n\n if (relationship === undefined) {\n continue;\n }\n\n const owner = createOwner(kind, ownerId);\n const pointer = childPointer(kind === 'context' ? '/context' : '/decisions', ownerId);\n addReferenceDeclarations(\n declarations,\n relationship.bindings,\n owner,\n 'bindings',\n childPointer(pointer, 'bindings'),\n );\n addAffectedByDeclarations(\n declarations,\n relationship.affectedBy,\n owner,\n childPointer(pointer, 'affectedBy'),\n );\n }\n }\n\n addUnresolvedDeclarations(declarations, manifest.unresolved, '/unresolved', null);\n\n for (const agentId of Object.keys(manifest.agents ?? {}).sort(compareCodePoints)) {\n const agent = manifest.agents?.[agentId];\n\n if (agent !== undefined) {\n addAgentDeclarations(declarations, agentId, agent);\n }\n }\n\n return declarations.sort(compareDeclarations);\n};\n\n/** Builds exact and first-segment glob indexes once for one parsed manifest. */\nconst compileManifestScope = (\n manifest: IMoldeaManifestV1,\n limits: ICoreResourceLimits,\n): ICompiledManifestScope => {\n const declarations = collectManifestScopeDeclarations(manifest);\n\n if (declarations.length > limits.maxEntries) {\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: 'maxEntries',\n limitMaximum: limits.maxEntries,\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage: declarations.length,\n operation: 'match-manifest-scope',\n });\n }\n\n const exact = new Map<IRepositoryPath, IManifestScopeRelationshipDeclaration[]>();\n const globalGlobs: ICompiledGlobDeclaration[] = [];\n const globsByFirstSegment = new Map<string, ICompiledGlobDeclaration[]>();\n\n for (const declaration of declarations) {\n if (declaration.declaration.kind === 'exact') {\n const existing = exact.get(declaration.declaration.path) ?? [];\n existing.push(declaration);\n exact.set(declaration.declaration.path, existing);\n continue;\n }\n\n const segments = declaration.declaration.pattern.slice(1).split('/');\n const compiled = { declaration, segments };\n const firstSegment = segments[0] ?? '';\n\n if (firstSegment === '**' || firstSegment.includes('*')) {\n globalGlobs.push(compiled);\n } else {\n const existing = globsByFirstSegment.get(firstSegment) ?? [];\n existing.push(compiled);\n globsByFirstSegment.set(firstSegment, existing);\n }\n }\n\n return { declarations, exact, globalGlobs, globsByFirstSegment };\n};\n\nconst compareMatches = (left: IManifestScopeMatch, right: IManifestScopeMatch): number => {\n return (\n compareOwners(left.owner, right.owner) ||\n compareCodePoints(left.field, right.field) ||\n compareCodePoints(\n getDeclarationValue(left.declaration),\n getDeclarationValue(right.declaration),\n ) ||\n compareCodePoints(left.inputPath, right.inputPath) ||\n compareCodePoints(left.pointer, right.pointer)\n );\n};\n\nconst createMatch = (\n inputPath: IRepositoryPath,\n relationship: IManifestScopeRelationshipDeclaration,\n): IManifestScopeMatch => ({\n declaration: relationship.declaration,\n field: relationship.field,\n inputPath,\n owner: relationship.owner,\n pointer: relationship.pointer,\n});\n\n/** Adds one match without ever allocating beyond the operation entry budget. */\nconst addMatch = (\n matches: IManifestScopeMatch[],\n inputPath: IRepositoryPath,\n relationship: IManifestScopeRelationshipDeclaration,\n limits: ICoreResourceLimits,\n): void => {\n if (matches.length >= limits.maxEntries) {\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: 'maxEntries',\n limitMaximum: limits.maxEntries,\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage: matches.length + 1,\n operation: 'match-manifest-scope',\n });\n }\n\n matches.push(createMatch(inputPath, relationship));\n};\n\n/** Appends matches from one precompiled glob bucket without copying the bucket. */\nconst addGlobMatches = (\n matches: IManifestScopeMatch[],\n inputPath: IRepositoryPath,\n declarations: readonly ICompiledGlobDeclaration[],\n limits: ICoreResourceLimits,\n): void => {\n for (const compiled of declarations) {\n if (matchesRepositoryGlob(compiled.segments, inputPath)) {\n addMatch(matches, inputPath, compiled.declaration, limits);\n }\n }\n};\n\n/** Creates the canonical digest of the sorted unique changed-path set. */\nexport const calculateManifestScopeInputDigest = async (\n paths: readonly IRepositoryPath[],\n): Promise<IContentDigest> => {\n const value = paths.join('\\0');\n\n return calculateNormalizedTextDigest({\n scalarLength: countUnicodeScalars(value),\n utf8ByteLength: countUtf8Bytes(value),\n value,\n });\n};\n\n/**\n * Matches normalized changed paths against one valid version 1 manifest.\n * @param manifest The parsed and validated manifest value.\n * @param paths Sorted unique repository-logical changed paths.\n * @param limits The immutable Core operation limits.\n * @returns Frozen content-free matches and stable aggregate counts.\n * @throws\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const matchParsedManifestScope = (\n manifest: IMoldeaManifestV1,\n paths: readonly IRepositoryPath[],\n limits: ICoreResourceLimits,\n): { readonly counts: IManifestScopeCounts; readonly matches: readonly IManifestScopeMatch[] } => {\n const compiled = compileManifestScope(manifest, limits);\n const matches: IManifestScopeMatch[] = [];\n const matchedOwners = new Set<string>();\n const matchedPaths = new Set<IRepositoryPath>();\n\n for (const path of paths) {\n const firstSegment = path.slice(1).split('/', 1)[0] ?? '';\n const exactDeclarations = compiled.exact.get(path) ?? [];\n\n for (const relationship of exactDeclarations) {\n addMatch(matches, path, relationship, limits);\n }\n\n addGlobMatches(matches, path, compiled.globalGlobs, limits);\n addGlobMatches(matches, path, compiled.globsByFirstSegment.get(firstSegment) ?? [], limits);\n }\n\n matches.sort(compareMatches);\n\n for (const match of matches) {\n matchedOwners.add(`${match.owner.kind}\\0${match.owner.agentId ?? ''}\\0${match.owner.id}`);\n matchedPaths.add(match.inputPath);\n }\n\n return deepFreeze({\n counts: {\n declarations: compiled.declarations.length,\n inputPaths: paths.length,\n matchedOwners: matchedOwners.size,\n matchedPaths: matchedPaths.size,\n matches: matches.length,\n },\n matches,\n });\n};\n","import { compareCodePoints } from 'jg-utilities';\n\nimport type { IRepositoryPath } from '@moldea.ai/repository';\n\nimport type { ICoreResourceLimits } from '../contracts/index.js';\nimport { CoreOperationException, type ICoreOperation } from '../exceptions/index.js';\nimport { ACCEPTABLE_WARNING_CODES, RECOGNIZED_RUNTIME_IDS } from '../constants/index.js';\nimport {\n escapeJsonPointerSegment,\n type ICoreDiagnosticCollector,\n} from '../diagnostic-utilities/index.js';\nimport type { IDiagnosticEntity, ISourceRange } from '../diagnostics/index.js';\nimport {\n countUnicodeScalars,\n hasNonWhitespace,\n hasUnsupportedGlobMetacharacter,\n isCanonicalMoldeaPath,\n isCapabilityDescription,\n isContextPath,\n isDecisionPath,\n isMirrorPath,\n isNonEmptySingleLine,\n isRepositorySymbol,\n isReservedId,\n isRuntimeGuidancePath,\n isSimpleGlob,\n isStableId,\n isVariableId,\n parseManifestPath,\n} from '../format-validation/index.js';\nimport type {\n IAcceptedWarningManifestEntry,\n IAgentBindingsManifestEntry,\n IAgentManifestEntry,\n IRuntimeManifestEntry,\n IMoldeaManifestV1,\n IRelationshipManifestEntry,\n IRepositoryFormatVersion,\n IRepositoryReference,\n IRuntimeVariableManifestEntry,\n ISkillManifestEntry,\n IToolManifestEntry,\n IUnresolvedRequirementEffect,\n IUnresolvedRequirementManifestEntry,\n} from '../format/index.js';\nimport { createNullPrototypeRecord } from '../immutable/index.js';\nimport type { IYamlNode, IYamlScalarNode } from '../yaml/index.js';\n\ninterface IManifestValidationContext {\n readonly diagnostics: ICoreDiagnosticCollector;\n readonly mirrorPaths: Set<string>;\n readonly path: IRepositoryPath;\n readonly limits: ICoreResourceLimits;\n readonly operation: ICoreOperation;\n}\n\ninterface IMappingEntry {\n readonly key: IYamlScalarNode;\n readonly value: IYamlNode;\n}\n\nconst childPointer = (pointer: string, key: string): string => {\n return `${pointer}/${escapeJsonPointerSegment(key)}`;\n};\n\nconst addInvalidValue = (\n context: IManifestValidationContext,\n pointer: string,\n range: ISourceRange | null,\n reason: string,\n entity: IDiagnosticEntity | null = null,\n): void => {\n context.diagnostics.add({\n code: 'MOLDEA_MANIFEST_VALUE_INVALID',\n details: { reason },\n entity,\n path: context.path,\n pointer,\n range,\n });\n};\n\nconst readMapping = (\n node: IYamlNode,\n pointer: string,\n allowedProperties: ReadonlySet<string> | null,\n context: IManifestValidationContext,\n entity: IDiagnosticEntity | null = null,\n): ReadonlyMap<string, IMappingEntry> | null => {\n if (node.kind !== 'mapping') {\n addInvalidValue(context, pointer, node.range, 'mapping-required', entity);\n return null;\n }\n\n const entries = new Map<string, IMappingEntry>();\n\n for (const entry of node.entries) {\n if (entry.key.kind !== 'scalar' || typeof entry.key.value !== 'string') {\n addInvalidValue(context, pointer, entry.key.range, 'string-key-required', entity);\n continue;\n }\n\n const key = entry.key.value;\n\n if (allowedProperties !== null && !allowedProperties.has(key)) {\n context.diagnostics.add({\n code: 'MOLDEA_MANIFEST_PROPERTY_UNKNOWN',\n entity,\n path: context.path,\n pointer: childPointer(pointer, key),\n range: entry.key.range,\n });\n continue;\n }\n\n entries.set(key, { key: entry.key, value: entry.value });\n }\n\n return entries;\n};\n\nconst readString = (\n entry: IMappingEntry | undefined,\n pointer: string,\n context: IManifestValidationContext,\n options: {\n readonly entity?: IDiagnosticEntity;\n readonly required?: boolean;\n readonly singleLine?: boolean;\n } = {},\n): string | null => {\n if (entry === undefined) {\n if (options.required === true) {\n addInvalidValue(context, pointer, null, 'required', options.entity ?? null);\n }\n\n return null;\n }\n\n if (entry.value.kind !== 'scalar' || typeof entry.value.value !== 'string') {\n addInvalidValue(context, pointer, entry.value.range, 'string-required', options.entity ?? null);\n return null;\n }\n\n const value = entry.value.value;\n\n if (!hasNonWhitespace(value) || (options.singleLine === true && !isNonEmptySingleLine(value))) {\n addInvalidValue(context, pointer, entry.value.range, 'string-invalid', options.entity ?? null);\n return null;\n }\n\n return value;\n};\n\nconst validateStableId = (\n value: string,\n range: ISourceRange,\n pointer: string,\n context: IManifestValidationContext,\n entity: IDiagnosticEntity | null = null,\n): boolean => {\n if (!isStableId(value)) {\n context.diagnostics.add({\n code: 'MOLDEA_ID_INVALID',\n entity,\n path: context.path,\n pointer,\n range,\n });\n return false;\n }\n\n if (isReservedId(value)) {\n context.diagnostics.add({\n code: 'MOLDEA_ID_RESERVED',\n entity,\n path: context.path,\n pointer,\n range,\n });\n return false;\n }\n\n return true;\n};\n\nconst readReference = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n entity: IDiagnosticEntity | null = null,\n): IRepositoryReference | null => {\n const entries = readMapping(node, pointer, new Set(['path', 'symbol']), context, entity);\n\n if (entries === null) {\n return null;\n }\n\n const pathEntry = entries.get('path');\n\n if (pathEntry?.value.kind !== 'scalar' || typeof pathEntry.value.value !== 'string') {\n context.diagnostics.add({\n code: 'MOLDEA_PATH_INVALID',\n details: { reason: pathEntry === undefined ? 'missing' : 'type' },\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'path'),\n range: pathEntry?.value.range ?? null,\n });\n return null;\n }\n\n const path = parseManifestPath(pathEntry.value.value);\n\n if (path === null) {\n context.diagnostics.add({\n code: 'MOLDEA_PATH_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'path'),\n range: pathEntry.value.range,\n });\n return null;\n }\n\n const symbolEntry = entries.get('symbol');\n\n if (symbolEntry === undefined) {\n return { path };\n }\n\n if (\n symbolEntry.value.kind !== 'scalar' ||\n typeof symbolEntry.value.value !== 'string' ||\n !isRepositorySymbol(symbolEntry.value.value)\n ) {\n context.diagnostics.add({\n code: 'MOLDEA_SYMBOL_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'symbol'),\n range: symbolEntry.value.range,\n });\n return null;\n }\n\n if (isCanonicalMoldeaPath(path)) {\n context.diagnostics.add({\n code: 'MOLDEA_SYMBOL_FORBIDDEN',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'symbol'),\n range: symbolEntry.value.range,\n });\n return null;\n }\n\n return { path, symbol: symbolEntry.value.value };\n};\n\nconst readReferenceList = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n entity: IDiagnosticEntity | null = null,\n): readonly IRepositoryReference[] => {\n if (node.kind !== 'sequence' || node.items.length === 0) {\n addInvalidValue(context, pointer, node.range, 'non-empty-sequence-required', entity);\n return [];\n }\n\n const references: IRepositoryReference[] = [];\n const seen = new Set<string>();\n\n node.items.forEach((item, index) => {\n const reference = readReference(item, childPointer(pointer, String(index)), context, entity);\n\n if (reference === null) {\n return;\n }\n\n const key = `${reference.path}\\0${reference.symbol ?? ''}`;\n\n if (seen.has(key)) {\n context.diagnostics.add({\n code: 'MOLDEA_PATH_DUPLICATE',\n entity,\n path: context.path,\n pointer: childPointer(pointer, String(index)),\n range: item.range,\n });\n return;\n }\n\n seen.add(key);\n references.push(reference);\n });\n\n return references;\n};\n\nconst readAffectedBy = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n entity: IDiagnosticEntity | null = null,\n): readonly string[] => {\n if (node.kind !== 'sequence' || node.items.length === 0) {\n addInvalidValue(context, pointer, node.range, 'non-empty-sequence-required', entity);\n return [];\n }\n\n const values: string[] = [];\n const seen = new Set<string>();\n\n node.items.forEach((item, index) => {\n const itemPointer = childPointer(pointer, String(index));\n\n if (item.kind !== 'scalar' || typeof item.value !== 'string') {\n addInvalidValue(context, itemPointer, item.range, 'string-required', entity);\n return;\n }\n\n const isGlob = item.value.includes('*') || hasUnsupportedGlobMetacharacter(item.value);\n const isValid = isGlob ? isSimpleGlob(item.value) : parseManifestPath(item.value) !== null;\n\n if (!isValid) {\n context.diagnostics.add({\n code: isGlob ? 'MOLDEA_GLOB_INVALID' : 'MOLDEA_PATH_INVALID',\n entity,\n path: context.path,\n pointer: itemPointer,\n range: item.range,\n });\n return;\n }\n\n if (seen.has(item.value)) {\n context.diagnostics.add({\n code: isGlob ? 'MOLDEA_PATTERN_DUPLICATE' : 'MOLDEA_PATH_DUPLICATE',\n entity,\n path: context.path,\n pointer: itemPointer,\n range: item.range,\n });\n return;\n }\n\n seen.add(item.value);\n values.push(item.value);\n });\n\n return values;\n};\n\nconst readRelationship = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n): IRelationshipManifestEntry | null => {\n const entries = readMapping(node, pointer, new Set(['affectedBy', 'bindings']), context);\n\n if (entries === null) {\n return null;\n }\n\n const bindingsEntry = entries.get('bindings');\n const affectedByEntry = entries.get('affectedBy');\n\n if (bindingsEntry === undefined && affectedByEntry === undefined) {\n context.diagnostics.add({\n code: 'MOLDEA_CONTEXT_RELATIONSHIP_EMPTY',\n path: context.path,\n pointer,\n range: node.range,\n });\n }\n\n return {\n ...(bindingsEntry === undefined\n ? {}\n : {\n bindings: readReferenceList(\n bindingsEntry.value,\n childPointer(pointer, 'bindings'),\n context,\n ),\n }),\n ...(affectedByEntry === undefined\n ? {}\n : {\n affectedBy: readAffectedBy(\n affectedByEntry.value,\n childPointer(pointer, 'affectedBy'),\n context,\n ),\n }),\n };\n};\n\nconst readRelationshipRecord = (\n node: IYamlNode,\n pointer: string,\n kind: 'context' | 'decision',\n context: IManifestValidationContext,\n): Readonly<Record<string, IRelationshipManifestEntry>> | null => {\n const entries = readMapping(node, pointer, null, context);\n\n if (entries === null) {\n return null;\n }\n\n const normalized: Array<readonly [string, IRelationshipManifestEntry]> = [];\n\n for (const [key, entry] of [...entries].sort(([left], [right]) =>\n compareCodePoints(left, right),\n )) {\n const path = parseManifestPath(key);\n const validPath =\n path !== null && (kind === 'context' ? isContextPath(path, true) : isDecisionPath(path));\n\n if (!validPath) {\n context.diagnostics.add({\n code:\n kind === 'context' ? 'MOLDEA_CONTEXT_PATH_INVALID' : 'MOLDEA_DECISION_FILENAME_INVALID',\n path: context.path,\n pointer: childPointer(pointer, key),\n range: entry.key.range,\n });\n continue;\n }\n\n const relationship = readRelationship(entry.value, childPointer(pointer, key), context);\n\n if (relationship !== null) {\n normalized.push([key, relationship]);\n }\n }\n\n return createNullPrototypeRecord(normalized);\n};\n\nconst readPathList = (\n node: IYamlNode,\n pointer: string,\n kind: 'context' | 'decision' | 'mirror',\n context: IManifestValidationContext,\n entity: IDiagnosticEntity,\n): readonly IRepositoryPath[] => {\n if (node.kind !== 'sequence') {\n addInvalidValue(context, pointer, node.range, 'sequence-required', entity);\n return [];\n }\n\n const paths: IRepositoryPath[] = [];\n const seen = new Set<string>();\n\n node.items.forEach((item, index) => {\n const itemPointer = childPointer(pointer, String(index));\n\n if (item.kind !== 'scalar' || typeof item.value !== 'string') {\n addInvalidValue(context, itemPointer, item.range, 'string-required', entity);\n return;\n }\n\n const path = parseManifestPath(item.value);\n const valid =\n path !== null &&\n (kind === 'context'\n ? isContextPath(path, false)\n : kind === 'decision'\n ? isDecisionPath(path)\n : isMirrorPath(path));\n\n if (!valid || path === null) {\n const code =\n kind === 'context'\n ? 'MOLDEA_CONTEXT_PATH_INVALID'\n : kind === 'decision'\n ? 'MOLDEA_DECISION_FILENAME_INVALID'\n : path !== null && !isMirrorPath(path)\n ? 'MOLDEA_MIRROR_PATH_INSIDE_MOLDEA'\n : 'MOLDEA_MIRROR_PATH_INVALID';\n context.diagnostics.add({\n code,\n entity,\n path: context.path,\n pointer: itemPointer,\n range: item.range,\n });\n return;\n }\n\n if (seen.has(path)) {\n context.diagnostics.add({\n code: kind === 'mirror' ? 'MOLDEA_MIRROR_PATH_DUPLICATE' : 'MOLDEA_PATH_DUPLICATE',\n entity,\n path: context.path,\n pointer: itemPointer,\n range: item.range,\n });\n return;\n }\n\n if (kind === 'mirror' && context.mirrorPaths.has(path)) {\n context.diagnostics.add({\n code: 'MOLDEA_MIRROR_PATH_DUPLICATE',\n entity,\n path: context.path,\n pointer: itemPointer,\n range: item.range,\n });\n return;\n }\n\n seen.add(path);\n if (kind === 'mirror') {\n context.mirrorPaths.add(path);\n }\n paths.push(path);\n });\n\n return paths;\n};\n\nconst readRuntime = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n): IRuntimeManifestEntry | null => {\n const entity = { agentId };\n const entries = readMapping(node, pointer, new Set(['guidance', 'id']), context, entity);\n\n if (entries === null) {\n return null;\n }\n\n const idEntry = entries.get('id');\n\n if (idEntry?.value.kind !== 'scalar' || typeof idEntry.value.value !== 'string') {\n context.diagnostics.add({\n code: 'MOLDEA_RUNTIME_ID_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'id'),\n range: idEntry?.value.range ?? null,\n });\n return null;\n }\n\n const id = idEntry.value.value;\n\n if (\n !isStableId(id) ||\n isReservedId(id) ||\n !(RECOGNIZED_RUNTIME_IDS as readonly string[]).includes(id)\n ) {\n context.diagnostics.add({\n code: 'MOLDEA_RUNTIME_ID_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'id'),\n range: idEntry.value.range,\n });\n }\n\n const guidanceEntry = entries.get('guidance');\n let guidance: IRepositoryPath | null = null;\n\n if (guidanceEntry !== undefined) {\n if (guidanceEntry.value.kind === 'scalar' && typeof guidanceEntry.value.value === 'string') {\n const candidate = parseManifestPath(guidanceEntry.value.value);\n\n if (candidate !== null && isRuntimeGuidancePath(candidate)) {\n guidance = candidate;\n } else {\n context.diagnostics.add({\n code: 'MOLDEA_PATH_INVALID',\n details: { reason: 'runtime-guidance' },\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'guidance'),\n range: guidanceEntry.value.range,\n });\n }\n } else {\n context.diagnostics.add({\n code: 'MOLDEA_PATH_INVALID',\n details: { reason: 'runtime-guidance' },\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'guidance'),\n range: guidanceEntry.value.range,\n });\n }\n }\n\n return { id, ...(guidance === null ? {} : { guidance }) };\n};\n\nconst readVariables = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n): Readonly<Record<string, IRuntimeVariableManifestEntry>> | null => {\n const entries = readMapping(node, pointer, null, context, { agentId });\n\n if (entries === null) {\n return null;\n }\n\n const normalized: Array<readonly [string, IRuntimeVariableManifestEntry]> = [];\n\n for (const [variableId, entry] of [...entries].sort(([left], [right]) =>\n compareCodePoints(left, right),\n )) {\n const entity = { agentId, variableId };\n\n if (!isVariableId(variableId)) {\n context.diagnostics.add({\n code: 'MOLDEA_VARIABLE_ID_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(pointer, variableId),\n range: entry.key.range,\n });\n }\n\n const variablePointer = childPointer(pointer, variableId);\n const variableEntries = readMapping(\n entry.value,\n variablePointer,\n new Set(['description']),\n context,\n entity,\n );\n\n if (variableEntries === null) {\n continue;\n }\n\n const description = readString(\n variableEntries.get('description'),\n childPointer(variablePointer, 'description'),\n context,\n { entity, required: true },\n );\n\n if (description !== null) {\n normalized.push([variableId, { description }]);\n }\n }\n\n return createNullPrototypeRecord(normalized);\n};\n\nconst readBindings = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n declaredVariables: ReadonlySet<string>,\n): IAgentBindingsManifestEntry | null => {\n const entity = { agentId };\n const entries = readMapping(\n node,\n pointer,\n new Set([\n 'inputSchema',\n 'instructionLoader',\n 'outputSchema',\n 'runtimeAgent',\n 'variableProviders',\n ]),\n context,\n entity,\n );\n\n if (entries === null) {\n return null;\n }\n\n const referenceProperty = (\n key: 'inputSchema' | 'instructionLoader' | 'outputSchema' | 'runtimeAgent',\n ) => {\n const entry = entries.get(key);\n return entry === undefined\n ? null\n : readReference(entry.value, childPointer(pointer, key), context, entity);\n };\n const inputSchema = referenceProperty('inputSchema');\n const instructionLoader = referenceProperty('instructionLoader');\n const outputSchema = referenceProperty('outputSchema');\n const runtimeAgent = referenceProperty('runtimeAgent');\n const providersEntry = entries.get('variableProviders');\n let variableProviders: Readonly<Record<string, IRepositoryReference>> | null = null;\n\n if (providersEntry !== undefined) {\n const providers = readMapping(\n providersEntry.value,\n childPointer(pointer, 'variableProviders'),\n null,\n context,\n entity,\n );\n\n if (providers !== null) {\n const normalized: Array<readonly [string, IRepositoryReference]> = [];\n\n for (const [variableId, providerEntry] of [...providers].sort(([left], [right]) =>\n compareCodePoints(left, right),\n )) {\n const variableEntity = { agentId, variableId };\n const providerPointer = childPointer(\n childPointer(pointer, 'variableProviders'),\n variableId,\n );\n\n if (!isVariableId(variableId)) {\n context.diagnostics.add({\n code: 'MOLDEA_VARIABLE_ID_INVALID',\n entity: variableEntity,\n path: context.path,\n pointer: providerPointer,\n range: providerEntry.key.range,\n });\n } else if (!declaredVariables.has(variableId)) {\n context.diagnostics.add({\n code: 'MOLDEA_VARIABLE_PROVIDER_UNDECLARED',\n entity: variableEntity,\n path: context.path,\n pointer: providerPointer,\n range: providerEntry.key.range,\n });\n }\n\n const reference = readReference(\n providerEntry.value,\n providerPointer,\n context,\n variableEntity,\n );\n\n if (reference !== null) {\n normalized.push([variableId, reference]);\n }\n }\n\n variableProviders = createNullPrototypeRecord(normalized);\n }\n }\n\n return {\n ...(runtimeAgent === null ? {} : { runtimeAgent }),\n ...(inputSchema === null ? {} : { inputSchema }),\n ...(outputSchema === null ? {} : { outputSchema }),\n ...(instructionLoader === null ? {} : { instructionLoader }),\n ...(variableProviders === null ? {} : { variableProviders }),\n };\n};\n\nconst readCapability = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n capabilityId: string,\n kind: 'tool' | 'skill',\n): IToolManifestEntry | ISkillManifestEntry | null => {\n const entity = { agentId, capabilityId, capabilityKind: kind } as const;\n const allowed =\n kind === 'tool'\n ? new Set([\n 'affectedBy',\n 'description',\n 'implementation',\n 'inputSchema',\n 'name',\n 'outputSchema',\n 'registration',\n ])\n : new Set(['affectedBy', 'description', 'implementation', 'name', 'registration']);\n const entries = readMapping(node, pointer, allowed, context, entity);\n\n if (entries === null) {\n return null;\n }\n\n const name = readString(entries.get('name'), childPointer(pointer, 'name'), context, {\n entity,\n required: true,\n singleLine: true,\n });\n const descriptionEntry = entries.get('description');\n let description: string | null = null;\n\n if (descriptionEntry === undefined) {\n context.diagnostics.add({\n code: 'MOLDEA_CAPABILITY_DESCRIPTION_MISSING',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'description'),\n });\n } else if (\n descriptionEntry.value.kind !== 'scalar' ||\n typeof descriptionEntry.value.value !== 'string' ||\n !isCapabilityDescription(descriptionEntry.value.value)\n ) {\n context.diagnostics.add({\n code: 'MOLDEA_CAPABILITY_DESCRIPTION_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'description'),\n range: descriptionEntry.value.range,\n });\n } else {\n description = descriptionEntry.value.value;\n }\n\n const implementationEntry = entries.get('implementation');\n let implementation: IRepositoryReference | null = null;\n\n if (implementationEntry === undefined) {\n context.diagnostics.add({\n code:\n kind === 'tool'\n ? 'MOLDEA_TOOL_IMPLEMENTATION_MISSING'\n : 'MOLDEA_SKILL_IMPLEMENTATION_MISSING',\n entity,\n path: context.path,\n pointer: childPointer(pointer, 'implementation'),\n });\n } else {\n implementation = readReference(\n implementationEntry.value,\n childPointer(pointer, 'implementation'),\n context,\n entity,\n );\n }\n\n const optionalReference = (key: 'inputSchema' | 'outputSchema' | 'registration') => {\n const entry = entries.get(key);\n return entry === undefined\n ? null\n : readReference(entry.value, childPointer(pointer, key), context, entity);\n };\n const registration = optionalReference('registration');\n const inputSchema = kind === 'tool' ? optionalReference('inputSchema') : null;\n const outputSchema = kind === 'tool' ? optionalReference('outputSchema') : null;\n const affectedByEntry = entries.get('affectedBy');\n const affectedBy =\n affectedByEntry === undefined\n ? null\n : readAffectedBy(affectedByEntry.value, childPointer(pointer, 'affectedBy'), context, entity);\n\n if (name === null || description === null || implementation === null) {\n return null;\n }\n\n return {\n name,\n description,\n implementation,\n ...(registration === null ? {} : { registration }),\n ...(inputSchema === null ? {} : { inputSchema }),\n ...(outputSchema === null ? {} : { outputSchema }),\n ...(affectedBy === null ? {} : { affectedBy }),\n };\n};\n\nconst readCapabilities = <Value extends IToolManifestEntry | ISkillManifestEntry>(\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n kind: 'tool' | 'skill',\n): Readonly<Record<string, Value>> | null => {\n const entries = readMapping(node, pointer, null, context, { agentId });\n\n if (entries === null) {\n return null;\n }\n\n const normalized: Array<readonly [string, Value]> = [];\n\n for (const [capabilityId, entry] of [...entries].sort(([left], [right]) =>\n compareCodePoints(left, right),\n )) {\n const entity = { agentId, capabilityId, capabilityKind: kind } as const;\n const capabilityPointer = childPointer(pointer, capabilityId);\n validateStableId(capabilityId, entry.key.range, capabilityPointer, context, entity);\n const capability = readCapability(\n entry.value,\n capabilityPointer,\n context,\n agentId,\n capabilityId,\n kind,\n );\n\n if (capability !== null) {\n normalized.push([capabilityId, capability as Value]);\n }\n }\n\n return createNullPrototypeRecord(normalized);\n};\n\nconst readUnresolved = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId?: string,\n): Readonly<Record<string, IUnresolvedRequirementManifestEntry>> | null => {\n const entries = readMapping(\n node,\n pointer,\n null,\n context,\n agentId === undefined ? null : { agentId },\n );\n\n if (entries === null) {\n return null;\n }\n\n const normalized: Array<readonly [string, IUnresolvedRequirementManifestEntry]> = [];\n\n for (const [requirementId, entry] of [...entries].sort(([left], [right]) =>\n compareCodePoints(left, right),\n )) {\n const entity = agentId === undefined ? null : { agentId };\n const requirementPointer = childPointer(pointer, requirementId);\n validateStableId(requirementId, entry.key.range, requirementPointer, context, entity);\n const requirementEntries = readMapping(\n entry.value,\n requirementPointer,\n new Set(['category', 'description', 'effect', 'reference', 'related', 'resolution']),\n context,\n entity,\n );\n\n if (requirementEntries === null) {\n continue;\n }\n\n const category = readString(\n requirementEntries.get('category'),\n childPointer(requirementPointer, 'category'),\n context,\n { ...(entity === null ? {} : { entity }), required: true },\n );\n\n if (category !== null && !isStableId(category)) {\n context.diagnostics.add({\n code: 'MOLDEA_ID_INVALID',\n entity,\n path: context.path,\n pointer: childPointer(requirementPointer, 'category'),\n range: requirementEntries.get('category')?.value.range ?? null,\n });\n }\n\n const effectEntry = requirementEntries.get('effect');\n let effect: IUnresolvedRequirementEffect | null = null;\n\n if (\n effectEntry?.value.kind === 'scalar' &&\n (effectEntry.value.value === 'blocking' ||\n effectEntry.value.value === 'warning' ||\n effectEntry.value.value === 'informational')\n ) {\n effect = effectEntry.value.value;\n } else {\n addInvalidValue(\n context,\n childPointer(requirementPointer, 'effect'),\n effectEntry?.value.range ?? null,\n effectEntry === undefined ? 'required' : 'enum',\n entity,\n );\n }\n\n const description = readString(\n requirementEntries.get('description'),\n childPointer(requirementPointer, 'description'),\n context,\n { ...(entity === null ? {} : { entity }), required: true },\n );\n const resolution = readString(\n requirementEntries.get('resolution'),\n childPointer(requirementPointer, 'resolution'),\n context,\n { ...(entity === null ? {} : { entity }), required: true },\n );\n const relatedEntry = requirementEntries.get('related');\n const related =\n relatedEntry === undefined\n ? null\n : readReferenceList(\n relatedEntry.value,\n childPointer(requirementPointer, 'related'),\n context,\n entity,\n );\n const reference = readString(\n requirementEntries.get('reference'),\n childPointer(requirementPointer, 'reference'),\n context,\n { ...(entity === null ? {} : { entity }), singleLine: true },\n );\n\n if (category !== null && effect !== null && description !== null && resolution !== null) {\n normalized.push([\n requirementId,\n {\n category,\n effect,\n description,\n resolution,\n ...(related === null ? {} : { related }),\n ...(reference === null ? {} : { reference }),\n },\n ]);\n }\n }\n\n return createNullPrototypeRecord(normalized);\n};\n\nconst findMappingProperty = (node: IYamlNode, property: string): IYamlNode | null => {\n if (node.kind !== 'mapping') {\n return null;\n }\n\n for (const entry of node.entries) {\n if (entry.key.kind === 'scalar' && entry.key.value === property) {\n return entry.value;\n }\n }\n\n return null;\n};\n\n/**\n * Detects a supported repository-format version without treating the remaining manifest as valid.\n * @param node The trustworthy strict-YAML manifest root.\n * @returns The supported parsed version when its declaration is independently unambiguous.\n */\nexport const detectSupportedManifestVersion = (\n node: IYamlNode,\n): IRepositoryFormatVersion | null => {\n if (node.kind !== 'mapping') {\n return null;\n }\n\n const versionNode = findMappingProperty(node, 'version');\n\n return versionNode?.kind === 'scalar' && versionNode.value === 1n ? 1 : null;\n};\n\nconst validateAgentOwnedIdUniqueness = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n): void => {\n const seen = new Set<string>();\n\n for (const property of ['tools', 'skills', 'unresolved']) {\n const record = findMappingProperty(node, property);\n\n if (record?.kind !== 'mapping') {\n continue;\n }\n\n for (const entry of record.entries) {\n if (entry.key.kind !== 'scalar' || typeof entry.key.value !== 'string') {\n continue;\n }\n\n if (seen.has(entry.key.value)) {\n context.diagnostics.add({\n code: 'MOLDEA_ID_DUPLICATE',\n entity: { agentId },\n path: context.path,\n pointer: childPointer(childPointer(pointer, property), entry.key.value),\n range: entry.key.range,\n });\n }\n\n seen.add(entry.key.value);\n }\n }\n};\n\nconst readAgent = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n agentId: string,\n): IAgentManifestEntry | null => {\n const entity = { agentId };\n const entries = readMapping(\n node,\n pointer,\n new Set([\n 'affectedBy',\n 'bindings',\n 'context',\n 'decisions',\n 'runtime',\n 'mirrors',\n 'skills',\n 'tools',\n 'unresolved',\n 'variables',\n ]),\n context,\n entity,\n );\n\n if (entries === null) {\n return null;\n }\n\n validateAgentOwnedIdUniqueness(node, pointer, context, agentId);\n const runtimeEntry = entries.get('runtime');\n let runtime: IRuntimeManifestEntry | null = null;\n\n if (runtimeEntry === undefined) {\n addInvalidValue(context, childPointer(pointer, 'runtime'), null, 'required', entity);\n } else {\n runtime = readRuntime(runtimeEntry.value, childPointer(pointer, 'runtime'), context, agentId);\n }\n\n const variablesEntry = entries.get('variables');\n const variables =\n variablesEntry === undefined\n ? null\n : readVariables(variablesEntry.value, childPointer(pointer, 'variables'), context, agentId);\n const declaredVariables = new Set(Object.keys(variables ?? {}));\n const bindingsEntry = entries.get('bindings');\n const bindings =\n bindingsEntry === undefined\n ? null\n : readBindings(\n bindingsEntry.value,\n childPointer(pointer, 'bindings'),\n context,\n agentId,\n declaredVariables,\n );\n const contextEntry = entries.get('context');\n const contextPaths =\n contextEntry === undefined\n ? null\n : readPathList(\n contextEntry.value,\n childPointer(pointer, 'context'),\n 'context',\n context,\n entity,\n );\n const decisionsEntry = entries.get('decisions');\n const decisions =\n decisionsEntry === undefined\n ? null\n : readPathList(\n decisionsEntry.value,\n childPointer(pointer, 'decisions'),\n 'decision',\n context,\n entity,\n );\n const toolsEntry = entries.get('tools');\n const tools =\n toolsEntry === undefined\n ? null\n : readCapabilities<IToolManifestEntry>(\n toolsEntry.value,\n childPointer(pointer, 'tools'),\n context,\n agentId,\n 'tool',\n );\n const skillsEntry = entries.get('skills');\n const skills =\n skillsEntry === undefined\n ? null\n : readCapabilities<ISkillManifestEntry>(\n skillsEntry.value,\n childPointer(pointer, 'skills'),\n context,\n agentId,\n 'skill',\n );\n const affectedByEntry = entries.get('affectedBy');\n const affectedBy =\n affectedByEntry === undefined\n ? null\n : readAffectedBy(affectedByEntry.value, childPointer(pointer, 'affectedBy'), context, entity);\n const mirrorsEntry = entries.get('mirrors');\n const mirrors =\n mirrorsEntry === undefined\n ? null\n : readPathList(\n mirrorsEntry.value,\n childPointer(pointer, 'mirrors'),\n 'mirror',\n context,\n entity,\n );\n const unresolvedEntry = entries.get('unresolved');\n const unresolved =\n unresolvedEntry === undefined\n ? null\n : readUnresolved(\n unresolvedEntry.value,\n childPointer(pointer, 'unresolved'),\n context,\n agentId,\n );\n\n if (runtime === null) {\n return null;\n }\n\n return {\n runtime,\n ...(contextPaths === null ? {} : { context: contextPaths }),\n ...(decisions === null ? {} : { decisions }),\n ...(variables === null ? {} : { variables }),\n ...(bindings === null ? {} : { bindings }),\n ...(tools === null ? {} : { tools }),\n ...(skills === null ? {} : { skills }),\n ...(affectedBy === null ? {} : { affectedBy }),\n ...(mirrors === null ? {} : { mirrors }),\n ...(unresolved === null ? {} : { unresolved }),\n };\n};\n\nconst readAgents = (\n node: IYamlNode,\n pointer: string,\n context: IManifestValidationContext,\n): Readonly<Record<string, IAgentManifestEntry>> | null => {\n const entries = readMapping(node, pointer, null, context);\n\n if (entries === null) {\n return null;\n }\n\n const normalized: Array<readonly [string, IAgentManifestEntry]> = [];\n\n for (const [agentId, entry] of [...entries].sort(([left], [right]) =>\n compareCodePoints(left, right),\n )) {\n const agentPointer = childPointer(pointer, agentId);\n validateStableId(agentId, entry.key.range, agentPointer, context, { agentId });\n const agent = readAgent(entry.value, agentPointer, context, agentId);\n\n if (agent !== null) {\n normalized.push([agentId, agent]);\n }\n }\n\n return createNullPrototypeRecord(normalized);\n};\n\n/**\n * Validates the closed warning-acceptance contract with field-specific diagnostics.\n * @returns Valid acceptance entries; diagnostics invalidate the complete manifest on any bad entry.\n * @throws\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nconst readAcceptedWarnings = (\n node: IYamlNode,\n context: IManifestValidationContext,\n): IAcceptedWarningManifestEntry[] | null => {\n const report = (\n entry: number | null,\n field: string,\n range: ISourceRange,\n reason: string,\n ): void => {\n context.diagnostics.add({\n code: 'MOLDEA_MANIFEST_VALUE_INVALID',\n path: context.path,\n pointer:\n entry === null\n ? '/acceptedWarnings'\n : `/acceptedWarnings/${entry}/${escapeJsonPointerSegment(field)}`,\n range,\n details: { entry, field, reason },\n });\n };\n if (node.kind !== 'sequence') {\n report(null, 'acceptedWarnings', node.range, 'sequence-required');\n return null;\n }\n if (node.items.length > context.limits.maxAcceptedWarnings)\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n operation: context.operation,\n limit: 'maxAcceptedWarnings',\n limitMaximum: context.limits.maxAcceptedWarnings,\n observedUsage: node.items.length,\n nextAction: 'reduce-input-or-increase-limit',\n });\n const accepted: IAcceptedWarningManifestEntry[] = [];\n const identities = new Set<string>();\n for (const [index, item] of node.items.entries()) {\n if (item.kind !== 'mapping') {\n report(index, 'entry', item.range, 'mapping-required');\n continue;\n }\n const fields = new Map<string, IYamlNode>();\n let isValid = true;\n for (const entry of item.entries) {\n if (\n entry.key.kind !== 'scalar' ||\n typeof entry.key.value !== 'string' ||\n !['code', 'subject', 'qualifier', 'reason'].includes(entry.key.value)\n ) {\n report(\n index,\n entry.key.kind === 'scalar' && typeof entry.key.value === 'string'\n ? entry.key.value\n : 'key',\n entry.key.range,\n 'unknown-field',\n );\n isValid = false;\n } else fields.set(entry.key.value, entry.value);\n }\n const scalar = (field: string): string | null => {\n const value = fields.get(field);\n if (\n value?.kind !== 'scalar' ||\n typeof value.value !== 'string' ||\n !hasNonWhitespace(value.value)\n ) {\n report(\n index,\n field,\n value?.range ?? item.range,\n value === undefined ? 'required' : 'non-empty-string-required',\n );\n isValid = false;\n return null;\n }\n return value.value;\n };\n const code = scalar('code');\n const subjectText = scalar('subject');\n const reason = scalar('reason');\n const subject = subjectText === null ? null : parseManifestPath(subjectText);\n const qualifierNode = fields.get('qualifier');\n let qualifier: string | null = null;\n if (\n qualifierNode !== undefined &&\n !(qualifierNode.kind === 'scalar' && qualifierNode.value === null)\n ) {\n qualifier = scalar('qualifier');\n if (qualifier !== null && !isNonEmptySingleLine(qualifier)) {\n report(index, 'qualifier', qualifierNode.range, 'single-line-required');\n isValid = false;\n }\n }\n const acceptedCode = ACCEPTABLE_WARNING_CODES.find((candidate) => candidate === code);\n if (code !== null && acceptedCode === undefined) {\n report(index, 'code', fields.get('code')!.range, 'code-not-acceptable');\n isValid = false;\n }\n if (subjectText !== null && subject === null) {\n report(index, 'subject', fields.get('subject')!.range, 'repository-path-required');\n isValid = false;\n }\n if (reason !== null && countUnicodeScalars(reason) > 256) {\n report(index, 'reason', fields.get('reason')!.range, 'maximum-256-characters');\n isValid = false;\n }\n if (!isValid || acceptedCode === undefined || subject === null || reason === null) continue;\n const identity = JSON.stringify([acceptedCode, subject, qualifier]);\n if (identities.has(identity)) {\n report(index, 'code', fields.get('code')!.range, 'duplicate-identity');\n continue;\n }\n identities.add(identity);\n accepted.push({\n code: acceptedCode,\n subject,\n ...(qualifierNode === undefined ? {} : { qualifier }),\n reason,\n });\n }\n return accepted;\n};\n\n/**\n * Validates and normalizes a strict YAML document as a version 1 moldea manifest.\n * @param node The parser-neutral YAML root node.\n * @param path The canonical or caller-supplied logical manifest path.\n * @param diagnostics The operation diagnostic collector.\n * @param limits The immutable operation limits, including the acceptance-list bound.\n * @param operation The public operation receiving resource failures.\n * @returns The normalized manifest when its supported version can be interpreted.\n * @throws\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const validateManifest = (\n node: IYamlNode,\n path: IRepositoryPath,\n diagnostics: ICoreDiagnosticCollector,\n limits: ICoreResourceLimits,\n operation: ICoreOperation,\n): IMoldeaManifestV1 | null => {\n const context: IManifestValidationContext = {\n diagnostics,\n operation,\n limits,\n mirrorPaths: new Set(),\n path,\n };\n\n if (node.kind !== 'mapping') {\n diagnostics.add({ code: 'MOLDEA_MANIFEST_ROOT_INVALID', path, range: node.range });\n return null;\n }\n\n const versionNode = findMappingProperty(node, 'version');\n\n if (versionNode === null) {\n diagnostics.add({ code: 'MOLDEA_MANIFEST_VERSION_MISSING', path, pointer: '/version' });\n return null;\n }\n\n const isIntegerSyntax = versionNode.kind === 'scalar' && typeof versionNode.value === 'bigint';\n\n if (!isIntegerSyntax || versionNode.kind !== 'scalar' || versionNode.value <= 0n) {\n diagnostics.add({\n code: 'MOLDEA_MANIFEST_VERSION_INVALID',\n path,\n pointer: '/version',\n range: versionNode.range,\n });\n return null;\n }\n\n if (versionNode.value !== 1n) {\n diagnostics.add({\n code: 'MOLDEA_MANIFEST_VERSION_UNSUPPORTED',\n path,\n pointer: '/version',\n range: versionNode.range,\n });\n return null;\n }\n\n const entries = readMapping(\n node,\n '',\n new Set(['acceptedWarnings', 'agents', 'context', 'decisions', 'unresolved', 'version']),\n context,\n );\n\n if (entries === null) {\n return null;\n }\n\n const acceptedWarningsEntry = entries.get('acceptedWarnings');\n const acceptedWarnings =\n acceptedWarningsEntry === undefined\n ? null\n : readAcceptedWarnings(acceptedWarningsEntry.value, context);\n const contextEntry = entries.get('context');\n const contextRelationships =\n contextEntry === undefined\n ? null\n : readRelationshipRecord(contextEntry.value, '/context', 'context', context);\n const decisionsEntry = entries.get('decisions');\n const decisionRelationships =\n decisionsEntry === undefined\n ? null\n : readRelationshipRecord(decisionsEntry.value, '/decisions', 'decision', context);\n const unresolvedEntry = entries.get('unresolved');\n const unresolved =\n unresolvedEntry === undefined\n ? null\n : readUnresolved(unresolvedEntry.value, '/unresolved', context);\n const agentsEntry = entries.get('agents');\n const agents =\n agentsEntry === undefined ? null : readAgents(agentsEntry.value, '/agents', context);\n\n return {\n version: 1,\n ...(acceptedWarnings === null ? {} : { acceptedWarnings }),\n ...(contextRelationships === null ? {} : { context: contextRelationships }),\n ...(decisionRelationships === null ? {} : { decisions: decisionRelationships }),\n ...(unresolved === null ? {} : { unresolved }),\n ...(agents === null ? {} : { agents }),\n };\n};\n","import type { ISourcePosition, ISourceRange } from '../diagnostics/index.js';\n\n// scalar-aware normalized source lookup used by parsers and diagnostics\nexport interface ISourceLocator {\n locateRange(startOffset: number, endOffset: number): ISourceRange;\n}\n\nconst findLineIndex = (lineStarts: readonly number[], offset: number): number => {\n let lower = 0;\n let upper = lineStarts.length - 1;\n\n while (lower < upper) {\n const middle = Math.ceil((lower + upper) / 2);\n\n if ((lineStarts[middle] ?? 0) <= offset) {\n lower = middle;\n } else {\n upper = middle - 1;\n }\n }\n\n return lower;\n};\n\n/**\n * Creates an efficient UTF-16-offset to Unicode-scalar source locator.\n * @param value The already-normalized valid Unicode scalar text.\n * @returns A locator producing one-based lines and columns with zero-based scalar offsets.\n */\nexport const createSourceLocator = (value: string): ISourceLocator => {\n const scalarOffsets = new Uint32Array(value.length + 1);\n const lineStarts = [0];\n let scalarOffset = 0;\n\n for (let codeUnitOffset = 0; codeUnitOffset < value.length;) {\n const codePoint = value.codePointAt(codeUnitOffset);\n const width = codePoint !== undefined && codePoint > 0xffff ? 2 : 1;\n\n scalarOffsets[codeUnitOffset] = scalarOffset;\n\n for (let interiorOffset = 1; interiorOffset < width; interiorOffset += 1) {\n scalarOffsets[codeUnitOffset + interiorOffset] = scalarOffset;\n }\n\n codeUnitOffset += width;\n scalarOffset += 1;\n scalarOffsets[codeUnitOffset] = scalarOffset;\n\n if (codePoint === 0x0a) {\n lineStarts.push(codeUnitOffset);\n }\n }\n\n const locatePosition = (candidateOffset: number): ISourcePosition => {\n const codeUnitOffset = Math.max(0, Math.min(value.length, candidateOffset));\n const lineIndex = findLineIndex(lineStarts, codeUnitOffset);\n const lineStart = lineStarts[lineIndex] ?? 0;\n const positionScalarOffset = scalarOffsets[codeUnitOffset] ?? 0;\n const lineStartScalarOffset = scalarOffsets[lineStart] ?? 0;\n\n return {\n column: positionScalarOffset - lineStartScalarOffset + 1,\n line: lineIndex + 1,\n offset: positionScalarOffset,\n };\n };\n\n return Object.freeze({\n locateRange: (startOffset: number, endOffset: number): ISourceRange => ({\n end: locatePosition(endOffset),\n start: locatePosition(startOffset),\n }),\n });\n};\n","import { deepFreeze } from 'jg-utilities';\n\nimport { parseRepositoryPath } from '@moldea.ai/repository';\n\nimport { createCoreOperationOptionsSnapshot, type ICoreOptionsSnapshot } from '../options/index.js';\nimport type {\n IIndexedTextAsset,\n IManifestParseResult,\n ITextDocumentInput,\n} from '../contracts/index.js';\nimport {\n createCoreDiagnosticCollector,\n locateDiagnosticRanges,\n} from '../diagnostic-utilities/index.js';\nimport type { ICoreOperation } from '../exceptions/index.js';\nimport { isCanonicalManifestPath } from '../format-validation/index.js';\nimport { detectSupportedManifestVersion, validateManifest } from '../manifest-validation/index.js';\nimport { createSourceLocator } from '../source-location/index.js';\nimport { calculateNormalizedTextDigest, normalizeTextDocument } from '../text/index.js';\nimport { parseStrictYaml, type IYamlNode } from '../yaml/index.js';\n\n// richer manifest parse state retained only by repository inspection\nexport interface IManifestDocumentInspectionResult extends IManifestParseResult {\n readonly formatVersion: 1 | null;\n readonly yamlRoot: IYamlNode | null;\n}\n\n/**\n * Inspects one complete manifest while retaining an independently trustworthy supported version.\n * @param input The canonical logical path and exact manifest text or bytes.\n * @param options The immutable Core limit snapshot.\n * @param operation The owning public or repository-level operation for typed failures.\n * @returns Frozen inspection state with all-or-nothing manifest assets and values.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - INVALID_ARGUMENT: The Core operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const inspectManifestDocument = async (\n input: ITextDocumentInput,\n options: ICoreOptionsSnapshot,\n operation: Extract<\n ICoreOperation,\n 'parse-manifest' | 'match-manifest-scope' | 'validate-project'\n > = 'parse-manifest',\n): Promise<IManifestDocumentInspectionResult> => {\n options = createCoreOperationOptionsSnapshot(options);\n const normalized = normalizeTextDocument(input, options.limits, operation, 'maxManifestBytes');\n const path = parseRepositoryPath(input.path);\n const diagnostics = createCoreDiagnosticCollector(options.limits, operation);\n\n if (!isCanonicalManifestPath(path)) {\n diagnostics.add({ code: 'MOLDEA_MANIFEST_PATH_INVALID', path });\n }\n\n for (const diagnostic of normalized.diagnostics) {\n diagnostics.merge(diagnostic);\n }\n\n if (!normalized.valid || normalized.text === null) {\n return deepFreeze({\n asset: null,\n diagnostics: diagnostics.finalize(),\n formatVersion: null,\n manifest: null,\n valid: false,\n yamlRoot: null,\n });\n }\n\n const locator = createSourceLocator(normalized.text.value);\n const parsed = parseStrictYaml(normalized.text.value, path, locator, diagnostics);\n const formatVersion = parsed.value === null ? null : detectSupportedManifestVersion(parsed.value);\n const manifest =\n parsed.valid && parsed.value !== null\n ? validateManifest(parsed.value, path, diagnostics, options.limits, operation)\n : null;\n const locatedDiagnostics = locateDiagnosticRanges(\n diagnostics.finalize(),\n new Map(parsed.value === null ? [] : [[path, parsed.value]]),\n );\n\n if (manifest === null || diagnostics.size > 0) {\n return deepFreeze({\n asset: null,\n diagnostics: locatedDiagnostics,\n formatVersion,\n manifest: null,\n valid: false,\n yamlRoot: parsed.value,\n });\n }\n\n const digest = await calculateNormalizedTextDigest(normalized.text);\n const asset: IIndexedTextAsset = {\n content: normalized.text.value,\n digest,\n path,\n scalarLength: normalized.text.scalarLength,\n utf8ByteLength: normalized.text.utf8ByteLength,\n };\n\n return deepFreeze({\n asset,\n diagnostics: locatedDiagnostics,\n formatVersion,\n manifest,\n valid: true,\n yamlRoot: parsed.value,\n });\n};\n\n/**\n * Parses and validates one complete version 1 manifest document.\n * @param input The canonical logical path and exact manifest text or bytes.\n * @param options The immutable Core limit snapshot.\n * @returns A frozen all-or-nothing manifest parse result.\n * @throws\n * - INVALID_REPOSITORY_PATH: The repository path is invalid.\n * - INVALID_ARGUMENT: The Core operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const parseManifestDocument = async (\n input: ITextDocumentInput,\n options: ICoreOptionsSnapshot,\n operation: Extract<ICoreOperation, 'parse-manifest' | 'match-manifest-scope'> = 'parse-manifest',\n): Promise<IManifestParseResult> => {\n const inspection = await inspectManifestDocument(input, options, operation);\n\n return deepFreeze({\n asset: inspection.asset,\n diagnostics: inspection.diagnostics,\n manifest: inspection.manifest,\n valid: inspection.valid,\n });\n};\n","import { compareCodePoints, countUtf8Bytes, isObjectValid } from 'jg-utilities';\n\nimport { parseRepositoryPath, type IRepositoryPath } from '@moldea.ai/repository';\n\nimport type { ICoreResourceLimits, ITextDocumentInput } from '../contracts/index.js';\nimport { CoreOperationException } from '../exceptions/index.js';\n\nimport type { IManifestScopeInput } from './types.js';\n\n/** Throws the stable invalid-argument failure for malformed scope input. */\nconst invalidArgument = (): never => {\n throw new CoreOperationException({\n code: 'INVALID_ARGUMENT',\n operation: 'match-manifest-scope',\n });\n};\n\n/** Throws the stable resource failure for an exhausted scope-input budget. */\nconst resourceLimitExceeded = (\n limit: 'maxEntries' | 'maxTotalBytesRead',\n limitMaximum: number,\n observedUsage: number,\n): never => {\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit,\n limitMaximum,\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage,\n operation: 'match-manifest-scope',\n });\n};\n\nexport interface INormalizedManifestScopeInput {\n readonly manifest: ITextDocumentInput;\n readonly paths: readonly IRepositoryPath[];\n}\n\n/**\n * Validates and snapshots one public manifest-scope input.\n * @param input The untrusted manifest document and changed logical paths.\n * @param limits The immutable Core resource limits.\n * @returns The detached manifest input and sorted unique repository paths.\n * @throws\n * - INVALID_REPOSITORY_PATH: A changed repository path is invalid.\n * - INVALID_ARGUMENT: The scope operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: The changed-path count or byte budget was exceeded.\n */\nexport const normalizeManifestScopeInput = (\n input: IManifestScopeInput,\n limits: ICoreResourceLimits,\n): INormalizedManifestScopeInput => {\n if (!isObjectValid(input, true)) {\n return invalidArgument();\n }\n\n const manifest = input['manifest'];\n const pathCandidates = input['paths'];\n\n if (!isObjectValid(manifest, true) || !Array.isArray(pathCandidates)) {\n return invalidArgument();\n }\n\n if (pathCandidates.length > limits.maxEntries) {\n return resourceLimitExceeded('maxEntries', limits.maxEntries, pathCandidates.length);\n }\n\n const uniquePaths = new Set<IRepositoryPath>();\n let totalBytes = 0;\n\n for (const [index, candidate] of pathCandidates.entries()) {\n if (typeof candidate !== 'string') {\n return invalidArgument();\n }\n\n const path = parseRepositoryPath(candidate);\n totalBytes += countUtf8Bytes(path) + (index === 0 ? 0 : 1);\n\n if (totalBytes > limits.maxTotalBytesRead) {\n return resourceLimitExceeded('maxTotalBytesRead', limits.maxTotalBytesRead, totalBytes);\n }\n\n uniquePaths.add(path);\n }\n\n return {\n manifest,\n paths: [...uniquePaths].sort(compareCodePoints),\n };\n};\n","import { deepFreeze } from 'jg-utilities';\n\nimport type { ICoreOptionsSnapshot } from '../options/index.js';\nimport { parseManifestDocument } from '../manifest/index.js';\n\nimport { calculateManifestScopeInputDigest, matchParsedManifestScope } from './matching.js';\nimport type { IManifestScopeInput, IManifestScopeResult } from './types.js';\nimport { normalizeManifestScopeInput } from './validations.js';\n\n/**\n * Parses a manifest and matches its repository relationships against changed logical paths.\n * @param input The canonical manifest document and untrusted changed-path collection.\n * @param options The immutable Core operation options.\n * @returns A promise resolving to frozen content-free scope metadata and matches.\n * @throws\n * - INVALID_REPOSITORY_PATH: The manifest path or a changed repository path is invalid.\n * - INVALID_ARGUMENT: The scope operation received an invalid argument.\n * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.\n */\nexport const matchManifestScope = async (\n input: IManifestScopeInput,\n options: ICoreOptionsSnapshot,\n): Promise<IManifestScopeResult> => {\n const normalized = normalizeManifestScopeInput(input, options.limits);\n const inputDigest = await calculateManifestScopeInputDigest(normalized.paths);\n const parsed = await parseManifestDocument(normalized.manifest, options, 'match-manifest-scope');\n\n if (!parsed.valid || parsed.asset === null || parsed.manifest === null) {\n return deepFreeze({\n counts: {\n declarations: 0,\n inputPaths: normalized.paths.length,\n matchedOwners: 0,\n matchedPaths: 0,\n matches: 0,\n },\n diagnostics: parsed.diagnostics,\n inputDigest,\n manifestDigest: null,\n matches: [],\n relevant: false,\n valid: false,\n });\n }\n\n const matched = matchParsedManifestScope(parsed.manifest, normalized.paths, options.limits);\n\n return deepFreeze({\n counts: matched.counts,\n diagnostics: [],\n inputDigest,\n manifestDigest: parsed.asset.digest,\n matches: matched.matches,\n relevant: matched.matches.length > 0,\n valid: true,\n });\n};\n"],"mappings":";;;;;AAEA,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAC5B,IAAM,8BAA8B;AACpC,IAAM,wBAAwB;CAAC;CAAM;CAAM;CAAU;CAAU;AAAQ;AACvE,IAAM,2BAA2B;AAEjC,IAAM,gBAAgB,UAA2B;CAC/C,OAAO,sBAAsB,MAAM,cAAc,MAAM,SAAS,SAAS,CAAC;AAC5E;;AAGA,IAAa,gCAAgC,cAA+B;CAC1E,OACG,aAAa,KAAU,aAAa,MACrC,cAAc,MACd,cAAc,OACd,cAAc,OACd,cAAc,QACb,aAAa,QAAU,aAAa,QACrC,cAAc,QACd,cAAc,QACd,cAAc,QACd,cAAc,QACd,cAAc;AAElB;;AAGA,IAAa,uBAAuB,UAA0B;CAC5D,MAAM,UAAU,MAAM,OAAO,SAAS,CAAC;CACvC,IAAI,QAAQ;CAEZ,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,MAC7B,SAAS;CAGX,OAAO;AACT;;AAGA,IAAa,oBAAoB,UAA2B;CAC1D,KAAK,MAAM,UAAU,OACnB,IAAI,CAAC,6BAA6B,OAAO,YAAY,CAAC,KAAK,CAAC,GAC1D,OAAO;CAIX,OAAO;AACT;;AAGA,IAAa,4BAA4B,UAA2B;CAClE,MAAM,iBAAi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B,OAAO,MAAM;EAC7B,SAAS,QAAQ;EACjB,UAAU,QAAQ,QAAQ,SAAS;EACnC,OAAO;CACT,CAAC;AACH"}
@@ -1,6 +1,10 @@
1
1
  import type { IDecisionParseResult, ITextDocumentInput } from '../contracts/index.js';
2
2
  import type { ICoreOperation } from '../exceptions/index.js';
3
3
  import { type ICoreOptionsSnapshot } from '../options/index.js';
4
+ import { type IYamlNode } from '../yaml/index.js';
5
+ export interface IDecisionDocumentInspectionResult extends IDecisionParseResult {
6
+ readonly yamlRoot: IYamlNode | null;
7
+ }
4
8
  /**
5
9
  * Parses and validates one complete decision document without resolving cross-file relationships.
6
10
  * @param input The canonical logical path and exact decision text or bytes.
@@ -12,5 +16,14 @@ import { type ICoreOptionsSnapshot } from '../options/index.js';
12
16
  * - INVALID_ARGUMENT: The Core operation received an invalid argument.
13
17
  * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.
14
18
  */
19
+ export declare const inspectDecisionDocument: (input: ITextDocumentInput, options: ICoreOptionsSnapshot, operation?: Extract<ICoreOperation, "parse-decision" | "validate-project">) => Promise<IDecisionDocumentInspectionResult>;
20
+ /**
21
+ * Parses a decision without exposing private YAML nodes to public callers.
22
+ * @returns The immutable decision parse result.
23
+ * @throws
24
+ * - INVALID_REPOSITORY_PATH: The repository path is invalid.
25
+ * - INVALID_ARGUMENT: The Core operation received an invalid argument.
26
+ * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.
27
+ */
15
28
  export declare const parseDecisionDocument: (input: ITextDocumentInput, options: ICoreOptionsSnapshot, operation?: Extract<ICoreOperation, "parse-decision" | "validate-project">) => Promise<IDecisionParseResult>;
16
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decision/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KA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