@moldea.ai/core 9.1.1 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { n as CoreOperationException, t as CoreConfigurationException } from "./exceptions-AT654xUL.js";
2
2
  import { compareCodePoints, deepFreeze, isObjectValid } from "jg-utilities";
3
+ import { Parser, isAlias, isMap, isScalar, isSeq, parseAllDocuments } from "yaml";
3
4
  //#region src/constants/index.ts
4
5
  var ACCEPTABLE_WARNING_CODES = Object.freeze([
5
6
  "MOLDEA_IMPACT_PATTERN_UNMATCHED",
@@ -71,6 +72,269 @@ var createNullPrototypeRecord = (entries) => {
71
72
  return record;
72
73
  };
73
74
  //#endregion
75
+ //#region src/yaml/index.ts
76
+ var mappingEntries = /* @__PURE__ */ new WeakMap();
77
+ var YAML_NODE_RETAINED_BYTES = 512;
78
+ /** Resolves a pointer to its authored member span or nearest existing ancestor. */
79
+ var locateYamlPointer = (root, pointer) => {
80
+ if (pointer === "") return root.range;
81
+ if (!pointer.startsWith("/")) return null;
82
+ const segments = pointer.slice(1).split("/");
83
+ if (segments.some((segment) => /~(?:[^01]|$)/u.test(segment))) return null;
84
+ let node = root;
85
+ let range = root.range;
86
+ for (const encodedSegment of segments) {
87
+ const segment = encodedSegment.replaceAll("~1", "/").replaceAll("~0", "~");
88
+ if (node.kind === "mapping") {
89
+ let entries = mappingEntries.get(node);
90
+ if (entries === void 0) {
91
+ const indexed = /* @__PURE__ */ new Map();
92
+ for (const entry of node.entries) if (entry.key.kind === "scalar" && typeof entry.key.value === "string") indexed.set(entry.key.value, entry);
93
+ entries = indexed;
94
+ mappingEntries.set(node, entries);
95
+ }
96
+ const entry = entries.get(segment);
97
+ if (entry === void 0) break;
98
+ range = {
99
+ start: entry.key.range.start,
100
+ end: entry.value.range.end
101
+ };
102
+ node = entry.value;
103
+ continue;
104
+ }
105
+ if (node.kind !== "sequence" || !/^(?:0|[1-9][0-9]*)$/u.test(segment)) break;
106
+ const index = Number(segment);
107
+ if (!Number.isSafeInteger(index) || index >= node.items.length) break;
108
+ const item = node.items[index];
109
+ if (item === void 0) break;
110
+ node = item;
111
+ range = item.range;
112
+ }
113
+ return range;
114
+ };
115
+ /** Measures logical retained tree/index coverage using the existing conservative object allowance. */
116
+ var measureYamlRetainedBytes = (root) => {
117
+ const pending = [root];
118
+ let bytes = 0;
119
+ while (pending.length > 0) {
120
+ const node = pending.pop();
121
+ bytes += YAML_NODE_RETAINED_BYTES;
122
+ if (node.kind === "mapping") for (const entry of node.entries) pending.push(entry.key, entry.value);
123
+ else if (node.kind === "sequence") for (const item of node.items) pending.push(item);
124
+ else {
125
+ bytes += node.source.length * 2;
126
+ if (typeof node.value === "string") bytes += node.value.length * 2;
127
+ }
128
+ }
129
+ return bytes;
130
+ };
131
+ var CORE_TAGS = /* @__PURE__ */ new Set([
132
+ "tag:yaml.org,2002:bool",
133
+ "tag:yaml.org,2002:float",
134
+ "tag:yaml.org,2002:int",
135
+ "tag:yaml.org,2002:map",
136
+ "tag:yaml.org,2002:null",
137
+ "tag:yaml.org,2002:seq",
138
+ "tag:yaml.org,2002:str"
139
+ ]);
140
+ var toRange = (range, locator) => {
141
+ return locator.locateRange(range?.[0] ?? 0, range?.[1] ?? range?.[0] ?? 0);
142
+ };
143
+ var addUnsupportedFeature = (diagnostics, path, range, reason) => {
144
+ diagnostics.add({
145
+ code: "MOLDEA_YAML_FEATURE_UNSUPPORTED",
146
+ details: { reason },
147
+ path,
148
+ range
149
+ });
150
+ };
151
+ var isCoreTagCompatible = (node) => {
152
+ switch (node.tag) {
153
+ case "tag:yaml.org,2002:bool": return isScalar(node) && typeof node.value === "boolean";
154
+ case "tag:yaml.org,2002:float": return isScalar(node) && typeof node.value === "number";
155
+ case "tag:yaml.org,2002:int": return isScalar(node) && typeof node.value === "bigint";
156
+ case "tag:yaml.org,2002:map": return isMap(node);
157
+ case "tag:yaml.org,2002:null": return isScalar(node) && node.value === null;
158
+ case "tag:yaml.org,2002:seq": return isSeq(node);
159
+ case "tag:yaml.org,2002:str": return isScalar(node) && typeof node.value === "string";
160
+ default: return false;
161
+ }
162
+ };
163
+ var convertNode = (node, path, locator, diagnostics) => {
164
+ const range = toRange(node.range, locator);
165
+ if (isAlias(node)) {
166
+ addUnsupportedFeature(diagnostics, path, range, "alias");
167
+ return null;
168
+ }
169
+ if ("anchor" in node && typeof node.anchor === "string") addUnsupportedFeature(diagnostics, path, range, "anchor");
170
+ if (node.tag !== void 0) {
171
+ if (!CORE_TAGS.has(node.tag)) {
172
+ addUnsupportedFeature(diagnostics, path, range, "custom-tag");
173
+ return null;
174
+ }
175
+ if (!isCoreTagCompatible(node)) {
176
+ diagnostics.add({
177
+ code: "MOLDEA_YAML_MALFORMED",
178
+ details: { reason: "tag-value" },
179
+ path,
180
+ range
181
+ });
182
+ return null;
183
+ }
184
+ }
185
+ if (isScalar(node)) {
186
+ const value = node.value;
187
+ if (value !== null && typeof value !== "string" && typeof value !== "number" && typeof value !== "bigint" && typeof value !== "boolean") {
188
+ diagnostics.add({
189
+ code: "MOLDEA_YAML_MALFORMED",
190
+ details: { reason: "scalar-type" },
191
+ path,
192
+ range
193
+ });
194
+ return null;
195
+ }
196
+ if (typeof value === "string" && !value.isWellFormed()) {
197
+ diagnostics.add({
198
+ code: "MOLDEA_YAML_MALFORMED",
199
+ details: { reason: "invalid-unicode" },
200
+ path,
201
+ range
202
+ });
203
+ return null;
204
+ }
205
+ return {
206
+ kind: "scalar",
207
+ range,
208
+ source: node.source,
209
+ style: node.type ?? null,
210
+ value
211
+ };
212
+ }
213
+ if (isSeq(node)) {
214
+ const items = [];
215
+ for (const item of node.items) {
216
+ if (item === null) {
217
+ items.push({
218
+ kind: "scalar",
219
+ range,
220
+ source: "",
221
+ style: null,
222
+ value: null
223
+ });
224
+ continue;
225
+ }
226
+ const converted = convertNode(item, path, locator, diagnostics);
227
+ if (converted !== null) items.push(converted);
228
+ }
229
+ return {
230
+ items,
231
+ kind: "sequence",
232
+ range
233
+ };
234
+ }
235
+ if (isMap(node)) {
236
+ const entries = [];
237
+ for (const pair of node.items) {
238
+ const key = convertNode(pair.key, path, locator, diagnostics);
239
+ const value = pair.value === null ? {
240
+ kind: "scalar",
241
+ range: key?.range ?? range,
242
+ source: "",
243
+ style: null,
244
+ value: null
245
+ } : convertNode(pair.value, path, locator, diagnostics);
246
+ if (key?.kind === "scalar" && key.value === "<<" && key.style === "PLAIN") addUnsupportedFeature(diagnostics, path, key.range, "merge-key");
247
+ if (key !== null && value !== null) entries.push({
248
+ key,
249
+ value
250
+ });
251
+ }
252
+ return {
253
+ entries,
254
+ kind: "mapping",
255
+ range
256
+ };
257
+ }
258
+ diagnostics.add({
259
+ code: "MOLDEA_YAML_MALFORMED",
260
+ details: { reason: "node-type" },
261
+ path,
262
+ range
263
+ });
264
+ return null;
265
+ };
266
+ var addParserDiagnostic = (code, start, end, path, locator, diagnostics) => {
267
+ if (code === "BAD_DIRECTIVE") return;
268
+ if (code === "DUPLICATE_KEY") {
269
+ diagnostics.add({
270
+ code: "MOLDEA_YAML_DUPLICATE_KEY",
271
+ path,
272
+ range: locator.locateRange(start, end)
273
+ });
274
+ return;
275
+ }
276
+ if (code === "TAG_RESOLVE_FAILED") return;
277
+ diagnostics.add({
278
+ code: "MOLDEA_YAML_MALFORMED",
279
+ details: { reason: code === "RESOURCE_EXHAUSTION" ? "resource-exhaustion" : "syntax" },
280
+ path,
281
+ range: locator.locateRange(start, end)
282
+ });
283
+ };
284
+ /**
285
+ * Parses one normalized YAML 1.2 Core Schema document into parser-neutral nodes.
286
+ * @param value The normalized manifest text.
287
+ * @param path The logical source path used by diagnostics.
288
+ * @param locator The scalar-aware source locator for the normalized text.
289
+ * @param diagnostics The operation diagnostic collector.
290
+ * @returns The private parsed tree only when the YAML substrate is trustworthy.
291
+ */
292
+ var parseStrictYaml = (value, path, locator, diagnostics) => {
293
+ const initialDiagnosticCount = diagnostics.size;
294
+ 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");
295
+ const documents = parseAllDocuments(value, {
296
+ intAsBigInt: true,
297
+ keepSourceTokens: true,
298
+ logLevel: "silent",
299
+ merge: false,
300
+ prettyErrors: false,
301
+ resolveKnownTags: false,
302
+ schema: "core",
303
+ strict: true,
304
+ uniqueKeys: true,
305
+ version: "1.2"
306
+ });
307
+ if (documents.length > 1) {
308
+ const range = documents[1]?.range;
309
+ diagnostics.add({
310
+ code: "MOLDEA_YAML_MULTIPLE_DOCUMENTS",
311
+ path,
312
+ range: locator.locateRange(range?.[0] ?? 0, range?.[0] ?? 0)
313
+ });
314
+ }
315
+ 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);
316
+ if (documents.length > 1 || diagnostics.size > initialDiagnosticCount) return {
317
+ valid: false,
318
+ value: null
319
+ };
320
+ const document = documents[0];
321
+ if (document === void 0 || document.contents === null) return {
322
+ valid: true,
323
+ value: {
324
+ kind: "scalar",
325
+ range: locator.locateRange(0, 0),
326
+ source: "",
327
+ style: null,
328
+ value: null
329
+ }
330
+ };
331
+ const parsedValue = convertNode(document.contents, path, locator, diagnostics);
332
+ return {
333
+ valid: parsedValue !== null && diagnostics.size === initialDiagnosticCount,
334
+ value: diagnostics.size === initialDiagnosticCount ? parsedValue : null
335
+ };
336
+ };
337
+ //#endregion
74
338
  //#region src/diagnostic-utilities/index.ts
75
339
  var CORE_DIAGNOSTIC_MESSAGES = {
76
340
  MOLDEA_AGENT_DESCRIPTION_INVALID: "The agent description is invalid.",
@@ -335,6 +599,19 @@ var normalizeDiagnostics = (candidates) => {
335
599
  }
336
600
  return deepFreeze([...diagnostics.values()].sort(compareDiagnostics));
337
601
  };
602
+ /** Adds available YAML locations while preserving existing ranges and warning acceptance fields. */
603
+ var locateDiagnosticRanges = (diagnostics, roots) => {
604
+ return normalizeDiagnostics(diagnostics.map((diagnostic) => {
605
+ if (diagnostic.range !== null || diagnostic.path === null || diagnostic.pointer === null) return diagnostic;
606
+ const root = roots.get(diagnostic.path);
607
+ if (root === void 0) return diagnostic;
608
+ const range = locateYamlPointer(root, diagnostic.pointer);
609
+ return range === null ? diagnostic : {
610
+ ...diagnostic,
611
+ range
612
+ };
613
+ }));
614
+ };
338
615
  /** Counts the complete normalized diagnostic result by severity once. */
339
616
  var countDiagnosticsBySeverity = (diagnostics) => {
340
617
  let errorCount = 0;
@@ -446,6 +723,6 @@ var normalizeCoreOptions = (options) => {
446
723
  return deepFreeze({ limits: normalizeLimits(options?.["limits"]) });
447
724
  };
448
725
  //#endregion
449
- export { escapeJsonPointerSegment as a, ACCEPTABLE_WARNING_CODES as c, SUPPORTED_REPOSITORY_FORMAT_VERSIONS as d, createCoreDiagnosticCollector as i, DEFAULT_CORE_RESOURCE_LIMITS as l, normalizeCoreOptions as n, normalizeDiagnostics as o, countDiagnosticsBySeverity as r, createNullPrototypeRecord as s, createCoreOperationOptionsSnapshot as t, RECOGNIZED_RUNTIME_IDS as u };
726
+ export { escapeJsonPointerSegment as a, measureYamlRetainedBytes as c, ACCEPTABLE_WARNING_CODES as d, DEFAULT_CORE_RESOURCE_LIMITS as f, createCoreDiagnosticCollector as i, parseStrictYaml as l, SUPPORTED_REPOSITORY_FORMAT_VERSIONS as m, normalizeCoreOptions as n, locateDiagnosticRanges as o, RECOGNIZED_RUNTIME_IDS as p, countDiagnosticsBySeverity as r, normalizeDiagnostics as s, createCoreOperationOptionsSnapshot as t, createNullPrototypeRecord as u };
450
727
 
451
- //# sourceMappingURL=options-C5360E_N.js.map
728
+ //# sourceMappingURL=options-BXKLnSDR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options-BXKLnSDR.js","names":[],"sources":["../../src/constants/index.ts","../../src/immutable/index.ts","../../src/yaml/index.ts","../../src/diagnostic-utilities/index.ts","../../src/options/index.ts"],"sourcesContent":["import type { ICoreResourceLimits } from '../contracts/index.js';\nimport type { IRepositoryFormatVersion } from '../format/index.js';\n\n// warning codes whose findings may be explicitly accepted in the manifest\nexport const ACCEPTABLE_WARNING_CODES = Object.freeze([\n 'MOLDEA_IMPACT_PATTERN_UNMATCHED',\n 'MOLDEA_INTEGRATION_BLOCK_MISSING',\n 'MOLDEA_INTEGRATION_SKILL_MISSING',\n 'MOLDEA_INTEGRATION_BLOCK_STALE',\n 'MOLDEA_INTEGRATION_LINK_UNRESOLVED',\n 'MOLDEA_INTEGRATION_CLAUDE_IMPORT_MISSING',\n] as const);\n\n// runtime labels selecting guidance without asserting SDK compatibility\nexport const RECOGNIZED_RUNTIME_IDS = Object.freeze([\n 'amazon-bedrock',\n 'anthropic',\n 'cerebras',\n 'claude-agent-sdk',\n 'cloudflare-agents',\n 'cohere',\n 'convex-agent',\n 'cursor-sdk',\n 'custom',\n 'deep-agents',\n 'eve',\n 'genkit',\n 'github-copilot-sdk',\n 'google-adk',\n 'google-genai',\n 'groq',\n 'hugging-face',\n 'ibm-watsonx-ai',\n 'langchain',\n 'langgraph',\n 'livekit-agents',\n 'mastra',\n 'microsoft-foundry',\n 'mistral',\n 'node-llama-cpp',\n 'ollama',\n 'openai',\n 'openai-agents-sdk',\n 'openai-codex',\n 'opencode-sdk',\n 'openrouter',\n 'pi-agent',\n 'strands-agents',\n 'tanstack-ai',\n 'vercel-ai-sdk',\n 'voltagent',\n] as const);\n\n// repository-format major versions interpreted by this Core release\nexport const SUPPORTED_REPOSITORY_FORMAT_VERSIONS: readonly IRepositoryFormatVersion[] =\n Object.freeze([1]);\n\n// default safety budgets applied independently to each Core operation\nexport const DEFAULT_CORE_RESOURCE_LIMITS: ICoreResourceLimits = Object.freeze({\n maxDiagnostics: 10_000,\n maxEntries: 100_000,\n maxCoverage: 10_000,\n maxAcceptedWarnings: 256,\n maxFileBytes: 8_388_608,\n maxManifestBytes: 2_097_152,\n maxRetainedBytes: 536_870_912,\n maxTotalBytesRead: 134_217_728,\n});\n","/**\n * Creates a record that cannot collide with prototype-chain properties.\n * @param entries The own string-keyed entries to assign.\n * @returns A mutable null-prototype record for later normalization and freezing.\n */\nexport const createNullPrototypeRecord = <Value>(\n entries: Iterable<readonly [string, Value]>,\n): Record<string, Value> => {\n const record = Object.create(null) as Record<string, Value>;\n\n for (const [key, value] of entries) {\n record[key] = value;\n }\n\n return record;\n};\n","import { Parser, isAlias, isMap, isScalar, isSeq, parseAllDocuments, type ParsedNode } from 'yaml';\n\nimport type { IRepositoryPath } from '@moldea.ai/repository';\n\nimport type { ICoreDiagnosticCollector } from '../diagnostic-utilities/index.js';\nimport type { ISourceRange } from '../diagnostics/index.js';\nimport type { ISourceLocator } from '../source-location/index.js';\n\n// parser-neutral YAML nodes retained only inside Core\nexport type IYamlNode = IYamlMappingNode | IYamlSequenceNode | IYamlScalarNode;\n\nexport interface IYamlMappingEntry {\n readonly key: IYamlNode;\n readonly value: IYamlNode;\n}\n\nexport interface IYamlMappingNode {\n readonly kind: 'mapping';\n readonly entries: readonly IYamlMappingEntry[];\n readonly range: ISourceRange;\n}\n\nexport interface IYamlSequenceNode {\n readonly kind: 'sequence';\n readonly items: readonly IYamlNode[];\n readonly range: ISourceRange;\n}\n\nexport interface IYamlScalarNode {\n readonly kind: 'scalar';\n readonly range: ISourceRange;\n readonly source: string;\n readonly style: string | null;\n readonly value: string | number | bigint | boolean | null;\n}\n\nexport interface IStrictYamlParseResult {\n readonly valid: boolean;\n readonly value: IYamlNode | null;\n}\n\n// lazy mapping lookups share the parsed tree's lifetime without retaining it globally\nconst mappingEntries = new WeakMap<IYamlMappingNode, ReadonlyMap<string, IYamlMappingEntry>>();\n// logical allowance for each node, coordinates and mapping-lookup metadata\nconst YAML_NODE_RETAINED_BYTES = 512;\n\n/** Resolves a pointer to its authored member span or nearest existing ancestor. */\nexport const locateYamlPointer = (root: IYamlNode, pointer: string): ISourceRange | null => {\n if (pointer === '') return root.range;\n if (!pointer.startsWith('/')) return null;\n const segments = pointer.slice(1).split('/');\n if (segments.some((segment) => /~(?:[^01]|$)/u.test(segment))) return null;\n let node = root;\n let range = root.range;\n\n for (const encodedSegment of segments) {\n const segment = encodedSegment.replaceAll('~1', '/').replaceAll('~0', '~');\n if (node.kind === 'mapping') {\n let entries = mappingEntries.get(node);\n if (entries === undefined) {\n const indexed = new Map<string, IYamlMappingEntry>();\n for (const entry of node.entries) {\n if (entry.key.kind === 'scalar' && typeof entry.key.value === 'string') {\n indexed.set(entry.key.value, entry);\n }\n }\n entries = indexed;\n mappingEntries.set(node, entries);\n }\n const entry = entries.get(segment);\n if (entry === undefined) break;\n range = { start: entry.key.range.start, end: entry.value.range.end };\n node = entry.value;\n continue;\n }\n if (node.kind !== 'sequence' || !/^(?:0|[1-9][0-9]*)$/u.test(segment)) break;\n const index = Number(segment);\n if (!Number.isSafeInteger(index) || index >= node.items.length) break;\n const item = node.items[index];\n if (item === undefined) break;\n node = item;\n range = item.range;\n }\n\n return range;\n};\n\n/** Measures logical retained tree/index coverage using the existing conservative object allowance. */\nexport const measureYamlRetainedBytes = (root: IYamlNode): number => {\n const pending = [root];\n let bytes = 0;\n while (pending.length > 0) {\n const node = pending.pop()!;\n bytes += YAML_NODE_RETAINED_BYTES;\n if (node.kind === 'mapping') {\n for (const entry of node.entries) pending.push(entry.key, entry.value);\n } else if (node.kind === 'sequence') {\n for (const item of node.items) pending.push(item);\n } else {\n bytes += node.source.length * 2;\n if (typeof node.value === 'string') bytes += node.value.length * 2;\n }\n }\n return bytes;\n};\n\nconst CORE_TAGS = new Set([\n 'tag:yaml.org,2002:bool',\n 'tag:yaml.org,2002:float',\n 'tag:yaml.org,2002:int',\n 'tag:yaml.org,2002:map',\n 'tag:yaml.org,2002:null',\n 'tag:yaml.org,2002:seq',\n 'tag:yaml.org,2002:str',\n]);\n\nconst toRange = (\n range: readonly [number, number, number] | null | undefined,\n locator: ISourceLocator,\n): ISourceRange => {\n return locator.locateRange(range?.[0] ?? 0, range?.[1] ?? range?.[0] ?? 0);\n};\n\nconst addUnsupportedFeature = (\n diagnostics: ICoreDiagnosticCollector,\n path: IRepositoryPath,\n range: ISourceRange,\n reason: string,\n): void => {\n diagnostics.add({\n code: 'MOLDEA_YAML_FEATURE_UNSUPPORTED',\n details: { reason },\n path,\n range,\n });\n};\n\nconst isCoreTagCompatible = (node: ParsedNode): boolean => {\n switch (node.tag) {\n case 'tag:yaml.org,2002:bool':\n return isScalar(node) && typeof node.value === 'boolean';\n case 'tag:yaml.org,2002:float':\n return isScalar(node) && typeof node.value === 'number';\n case 'tag:yaml.org,2002:int':\n return isScalar(node) && typeof node.value === 'bigint';\n case 'tag:yaml.org,2002:map':\n return isMap(node);\n case 'tag:yaml.org,2002:null':\n return isScalar(node) && node.value === null;\n case 'tag:yaml.org,2002:seq':\n return isSeq(node);\n case 'tag:yaml.org,2002:str':\n return isScalar(node) && typeof node.value === 'string';\n default:\n return false;\n }\n};\n\nconst convertNode = (\n node: ParsedNode,\n path: IRepositoryPath,\n locator: ISourceLocator,\n diagnostics: ICoreDiagnosticCollector,\n): IYamlNode | null => {\n const range = toRange(node.range, locator);\n\n if (isAlias(node)) {\n addUnsupportedFeature(diagnostics, path, range, 'alias');\n return null;\n }\n\n if ('anchor' in node && typeof node.anchor === 'string') {\n addUnsupportedFeature(diagnostics, path, range, 'anchor');\n }\n\n if (node.tag !== undefined) {\n if (!CORE_TAGS.has(node.tag)) {\n addUnsupportedFeature(diagnostics, path, range, 'custom-tag');\n return null;\n }\n\n if (!isCoreTagCompatible(node)) {\n diagnostics.add({\n code: 'MOLDEA_YAML_MALFORMED',\n details: { reason: 'tag-value' },\n path,\n range,\n });\n return null;\n }\n }\n\n if (isScalar(node)) {\n const value = node.value;\n\n if (\n value !== null &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'bigint' &&\n typeof value !== 'boolean'\n ) {\n diagnostics.add({\n code: 'MOLDEA_YAML_MALFORMED',\n details: { reason: 'scalar-type' },\n path,\n range,\n });\n return null;\n }\n\n if (typeof value === 'string' && !value.isWellFormed()) {\n diagnostics.add({\n code: 'MOLDEA_YAML_MALFORMED',\n details: { reason: 'invalid-unicode' },\n path,\n range,\n });\n return null;\n }\n\n return {\n kind: 'scalar',\n range,\n source: node.source,\n style: node.type ?? null,\n value,\n };\n }\n\n if (isSeq(node)) {\n const items: IYamlNode[] = [];\n\n for (const item of node.items) {\n if (item === null) {\n items.push({ kind: 'scalar', range, source: '', style: null, value: null });\n continue;\n }\n\n const converted = convertNode(item, path, locator, diagnostics);\n\n if (converted !== null) {\n items.push(converted);\n }\n }\n\n return { items, kind: 'sequence', range };\n }\n\n if (isMap(node)) {\n const entries: IYamlMappingEntry[] = [];\n\n for (const pair of node.items) {\n const key = convertNode(pair.key, path, locator, diagnostics);\n const value =\n pair.value === null\n ? ({\n kind: 'scalar',\n range: key?.range ?? range,\n source: '',\n style: null,\n value: null,\n } satisfies IYamlScalarNode)\n : convertNode(pair.value, path, locator, diagnostics);\n\n if (key?.kind === 'scalar' && key.value === '<<' && key.style === 'PLAIN') {\n addUnsupportedFeature(diagnostics, path, key.range, 'merge-key');\n }\n\n if (key !== null && value !== null) {\n entries.push({ key, value });\n }\n }\n\n return { entries, kind: 'mapping', range };\n }\n\n diagnostics.add({\n code: 'MOLDEA_YAML_MALFORMED',\n details: { reason: 'node-type' },\n path,\n range,\n });\n return null;\n};\n\nconst addParserDiagnostic = (\n code: string,\n start: number,\n end: number,\n path: IRepositoryPath,\n locator: ISourceLocator,\n diagnostics: ICoreDiagnosticCollector,\n): void => {\n if (code === 'BAD_DIRECTIVE') {\n return;\n }\n\n if (code === 'DUPLICATE_KEY') {\n diagnostics.add({\n code: 'MOLDEA_YAML_DUPLICATE_KEY',\n path,\n range: locator.locateRange(start, end),\n });\n return;\n }\n\n if (code === 'TAG_RESOLVE_FAILED') {\n return;\n }\n\n diagnostics.add({\n code: 'MOLDEA_YAML_MALFORMED',\n details: { reason: code === 'RESOURCE_EXHAUSTION' ? 'resource-exhaustion' : 'syntax' },\n path,\n range: locator.locateRange(start, end),\n });\n};\n\n/**\n * Parses one normalized YAML 1.2 Core Schema document into parser-neutral nodes.\n * @param value The normalized manifest text.\n * @param path The logical source path used by diagnostics.\n * @param locator The scalar-aware source locator for the normalized text.\n * @param diagnostics The operation diagnostic collector.\n * @returns The private parsed tree only when the YAML substrate is trustworthy.\n */\nexport const parseStrictYaml = (\n value: string,\n path: IRepositoryPath,\n locator: ISourceLocator,\n diagnostics: ICoreDiagnosticCollector,\n): IStrictYamlParseResult => {\n const initialDiagnosticCount = diagnostics.size;\n\n for (const token of new Parser().parse(value)) {\n if (token.type === 'directive') {\n addUnsupportedFeature(\n diagnostics,\n path,\n locator.locateRange(token.offset, token.offset + token.source.length),\n 'directive',\n );\n }\n }\n\n const documents = parseAllDocuments(value, {\n intAsBigInt: true,\n keepSourceTokens: true,\n logLevel: 'silent',\n merge: false,\n prettyErrors: false,\n resolveKnownTags: false,\n schema: 'core',\n strict: true,\n uniqueKeys: true,\n version: '1.2',\n });\n\n if (documents.length > 1) {\n const secondDocument = documents[1];\n const range = secondDocument?.range;\n\n diagnostics.add({\n code: 'MOLDEA_YAML_MULTIPLE_DOCUMENTS',\n path,\n range: locator.locateRange(range?.[0] ?? 0, range?.[0] ?? 0),\n });\n }\n\n for (const document of documents) {\n for (const error of [...document.errors, ...document.warnings]) {\n addParserDiagnostic(error.code, error.pos[0], error.pos[1], path, locator, diagnostics);\n }\n }\n\n if (documents.length > 1 || diagnostics.size > initialDiagnosticCount) {\n return { valid: false, value: null };\n }\n\n const document = documents[0];\n\n if (document === undefined || document.contents === null) {\n return {\n valid: true,\n value: {\n kind: 'scalar',\n range: locator.locateRange(0, 0),\n source: '',\n style: null,\n value: null,\n },\n };\n }\n\n const parsedValue = convertNode(document.contents, path, locator, diagnostics);\n\n return {\n valid: parsedValue !== null && diagnostics.size === initialDiagnosticCount,\n value: diagnostics.size === initialDiagnosticCount ? parsedValue : null,\n };\n};\n","import { compareCodePoints, deepFreeze } from 'jg-utilities';\n\nimport type { IRepositoryPath } from '@moldea.ai/repository';\n\nimport { ACCEPTABLE_WARNING_CODES } from '../constants/index.js';\nimport type { ICoreResourceLimits } from '../contracts/index.js';\nimport type {\n ICoreDiagnostic,\n ICoreDiagnosticCode,\n IDiagnostic,\n IDiagnosticDetails,\n IDiagnosticEntity,\n ISourceRange,\n} from '../diagnostics/index.js';\nimport { CoreOperationException, type ICoreOperation } from '../exceptions/index.js';\nimport { createNullPrototypeRecord } from '../immutable/index.js';\nimport { locateYamlPointer, type IYamlNode } from '../yaml/index.js';\n\nconst CORE_DIAGNOSTIC_MESSAGES: Record<ICoreDiagnosticCode, string> = {\n MOLDEA_AGENT_DESCRIPTION_INVALID: 'The agent description is invalid.',\n MOLDEA_AGENT_DESCRIPTION_MISSING: 'The agent description is missing.',\n MOLDEA_AGENT_DIRECTORY_MISSING: 'The registered agent directory is missing.',\n MOLDEA_AGENT_DIRECTORY_UNREGISTERED: 'The agent directory is not registered.',\n MOLDEA_AGENT_HANDOFF_DESCRIPTION_INVALID: 'The agent handoff description is invalid.',\n MOLDEA_AGENT_IDENTITY_INVALID: 'The agent instruction identity is invalid.',\n MOLDEA_AGENT_INSTRUCTION_EMPTY: 'The agent instruction is empty.',\n MOLDEA_AGENT_INSTRUCTION_MISSING: 'The agent instruction is missing.',\n MOLDEA_CANONICAL_ASSET_SYMLINK: 'The canonical asset is a symlink.',\n MOLDEA_CANONICAL_PATH_UNRECOGNIZED: 'The canonical path is unrecognized.',\n MOLDEA_CAPABILITY_DESCRIPTION_INVALID: 'The capability description is invalid.',\n MOLDEA_CAPABILITY_DESCRIPTION_MISSING: 'The capability description is missing.',\n MOLDEA_CONTEXT_FILE_EMPTY: 'The focused context file is empty.',\n MOLDEA_CONTEXT_PATH_INVALID: 'The context relationship path is invalid.',\n MOLDEA_CONTEXT_RELATIONSHIP_EMPTY: 'The declared relationship has no bindings or impact paths.',\n MOLDEA_DECISION_BODY_EMPTY: 'The decision Markdown body is empty.',\n MOLDEA_DECISION_CREATED_AT_INVALID: 'The decision createdAt value is invalid.',\n MOLDEA_DECISION_FILENAME_INVALID: 'The decision path or filename is invalid.',\n MOLDEA_DECISION_FRONTMATTER_INVALID: 'The decision frontmatter is invalid.',\n MOLDEA_DECISION_FRONTMATTER_MISSING: 'The decision frontmatter or its delimiters are missing.',\n MOLDEA_DECISION_ID_DUPLICATE: 'The decision ID is duplicated.',\n MOLDEA_DECISION_PROPERTY_UNKNOWN: 'The decision frontmatter contains an unknown property.',\n MOLDEA_DECISION_REFERENCE_MISSING: 'The referenced decision does not exist.',\n MOLDEA_DECISION_RELATIONSHIP_INACTIVE: 'The referenced decision is not accepted.',\n MOLDEA_DECISION_SELF_SUPERSESSION: 'The decision supersedes itself.',\n MOLDEA_DECISION_STATUS_INVALID: 'The decision status is invalid.',\n MOLDEA_DECISION_SUPERSEDED_ORPHAN:\n 'The superseded decision has no active supersession relationship.',\n MOLDEA_DECISION_SUPERSESSION_CYCLE: 'The decision supersession graph contains a cycle.',\n MOLDEA_DECISION_SUPERSESSION_STATUS_INVALID:\n 'The decision supersession relationship has inconsistent statuses.',\n MOLDEA_DECISION_TIMESTAMP_MISMATCH:\n 'The decision filename timestamp and createdAt value do not match.',\n MOLDEA_ENTRY_TYPE_INVALID: 'The repository entry type is invalid.',\n MOLDEA_RUNTIME_ID_INVALID: 'The runtime ID is invalid.',\n MOLDEA_GLOB_INVALID: 'The impact pattern is invalid.',\n MOLDEA_ID_DUPLICATE: 'An ID is duplicated within its required scope.',\n MOLDEA_ID_INVALID: 'The ID is invalid.',\n MOLDEA_ID_RESERVED: 'The ID uses a reserved filesystem name.',\n MOLDEA_IMPACT_PATH_MISSING: 'The exact impact path does not exist.',\n MOLDEA_IMPACT_PATH_NOT_FILE: 'The exact impact path is not a regular file.',\n MOLDEA_MANIFEST_MISSING: 'The project manifest is missing.',\n MOLDEA_MANIFEST_PATH_INVALID: 'The manifest path is not the canonical manifest path.',\n MOLDEA_MANIFEST_PROPERTY_UNKNOWN: 'The manifest contains an unknown property.',\n MOLDEA_MANIFEST_ROOT_INVALID: 'The manifest root is not a mapping.',\n MOLDEA_MANIFEST_VALUE_INVALID: 'The manifest value is invalid.',\n MOLDEA_MANIFEST_VERSION_INVALID: 'The manifest version is not a valid integer major version.',\n MOLDEA_MANIFEST_VERSION_MISSING: 'The manifest version is missing.',\n MOLDEA_MANIFEST_VERSION_UNSUPPORTED: 'The manifest version is unsupported.',\n MOLDEA_MIRROR_PATH_DUPLICATE: 'The mirror path is assigned more than once.',\n MOLDEA_MIRROR_PATH_INSIDE_MOLDEA: 'The mirror path is inside /moldea.',\n MOLDEA_MIRROR_PATH_INVALID: 'The mirror path is invalid.',\n MOLDEA_MIRROR_MISSING: 'The declared mirror does not exist.',\n MOLDEA_MIRROR_NOT_FILE: 'The declared mirror is not a regular file.',\n MOLDEA_MIRROR_STALE: 'The declared mirror differs from its canonical instruction.',\n MOLDEA_MIRROR_SYMLINK: 'The declared mirror is a symlink.',\n MOLDEA_PATH_DUPLICATE: 'The path is duplicated.',\n MOLDEA_PATH_INVALID: 'The manifest logical path is invalid.',\n MOLDEA_PATTERN_DUPLICATE: 'The impact pattern is duplicated.',\n MOLDEA_PROJECT_FILE_EMPTY: 'The project file is empty.',\n MOLDEA_PROJECT_FILE_MISSING: 'The project file is missing.',\n MOLDEA_INTEGRATION_BLOCK_MISSING: 'The AGENTS.md moldea block is missing.',\n MOLDEA_INTEGRATION_SKILL_MISSING:\n 'The skill installation referenced by the AGENTS.md moldea block was not found.',\n MOLDEA_INTEGRATION_BLOCK_STALE: 'The AGENTS.md moldea block differs from its skill installation.',\n MOLDEA_INTEGRATION_LINK_UNRESOLVED:\n \"This instruction file's link doesn't lead to a file in the repository.\",\n MOLDEA_INTEGRATION_CLAUDE_IMPORT_MISSING: 'Claude Code instructions do not load AGENTS.md.',\n MOLDEA_IMPACT_PATTERN_UNMATCHED: 'The impact pattern matches no files.',\n MOLDEA_ACCEPTANCE_UNMATCHED: 'The warning acceptance matches no reported warning.',\n MOLDEA_REFERENCE_EXPORT_MISSING: 'The referenced export is missing.',\n MOLDEA_REFERENCE_MISSING: 'The referenced repository path does not exist.',\n MOLDEA_REFERENCE_NOT_FILE: 'The referenced repository path is not a regular file.',\n MOLDEA_REFERENCE_SYMLINK: 'The referenced repository path is a symlink.',\n MOLDEA_RUNTIME_GUIDANCE_EMPTY: 'The runtime guidance is empty.',\n MOLDEA_RUNTIME_GUIDANCE_MISSING: 'The referenced runtime guidance does not exist.',\n MOLDEA_SKILL_IMPLEMENTATION_MISSING: 'The registered skill implementation is missing.',\n MOLDEA_SYMBOL_FORBIDDEN: 'A canonical moldea reference must not include a symbol.',\n MOLDEA_SYMBOL_INVALID: 'The repository-reference symbol is invalid.',\n MOLDEA_TEXT_EMPTY: 'The required text document is empty.',\n MOLDEA_TEXT_INVALID_UNICODE:\n 'The text document contains an invalid Unicode scalar representation.',\n MOLDEA_TEXT_INVALID_UTF8: 'The text document is not valid UTF-8.',\n MOLDEA_TEXT_NUL_FORBIDDEN: 'The text document contains a forbidden NUL character.',\n MOLDEA_TOOL_IMPLEMENTATION_MISSING: 'The registered tool implementation is missing.',\n MOLDEA_VARIABLE_ID_INVALID: 'The runtime-variable ID is invalid.',\n MOLDEA_VARIABLE_PLACEHOLDER_MALFORMED:\n 'The agent instruction contains a malformed runtime-variable placeholder.',\n MOLDEA_VARIABLE_PROVIDER_UNDECLARED:\n 'A variable-provider binding exists for an undeclared variable.',\n MOLDEA_VARIABLE_UNDECLARED: 'The agent instruction references an undeclared runtime variable.',\n MOLDEA_VARIABLE_UNUSED: 'The declared runtime variable is unused by the agent instruction.',\n MOLDEA_YAML_DUPLICATE_KEY: 'The YAML document contains a duplicate mapping key.',\n MOLDEA_YAML_FEATURE_UNSUPPORTED: 'The YAML document uses an unsupported feature.',\n MOLDEA_YAML_MALFORMED: 'The YAML document is malformed.',\n MOLDEA_YAML_MULTIPLE_DOCUMENTS: 'The YAML stream contains more than one document.',\n};\n\nconst ENTITY_KEYS = [\n 'agentId',\n 'capabilityKind',\n 'capabilityId',\n 'decisionId',\n 'variableId',\n 'contextPath',\n 'integrationPath',\n] as const satisfies readonly (keyof IDiagnosticEntity)[];\n\n// private normalized diagnostic construction contracts\nexport interface ICoreDiagnosticInput {\n readonly code: ICoreDiagnosticCode;\n readonly details?: Readonly<Record<string, string | number | boolean | null>>;\n readonly entity?: IDiagnosticEntity | null;\n readonly path: IRepositoryPath | null;\n readonly pointer?: string | null;\n readonly range?: ISourceRange | null;\n readonly subject?: IRepositoryPath;\n readonly qualifier?: string | null;\n}\n\nexport interface ICoreDiagnosticCollector {\n add(input: ICoreDiagnosticInput): void;\n merge(input: ICoreDiagnosticInput): void;\n finalize(): readonly ICoreDiagnostic[];\n readonly size: number;\n}\n\ninterface ICoreDiagnosticBudget {\n count: number;\n}\n\nconst CORE_DIAGNOSTIC_BUDGET = Symbol('core-diagnostic-budget');\n\ntype ICoreOperationResourceLimits = ICoreResourceLimits & {\n readonly [CORE_DIAGNOSTIC_BUDGET]?: ICoreDiagnosticBudget;\n};\n\n/** Creates a detached limits view with one diagnostic budget for a complete Core operation. */\nexport const createCoreOperationResourceLimits = (\n limits: ICoreResourceLimits,\n): ICoreResourceLimits => {\n const operationLimits = limits as ICoreOperationResourceLimits;\n\n if (operationLimits[CORE_DIAGNOSTIC_BUDGET] !== undefined) {\n return limits;\n }\n\n return Object.freeze({\n ...limits,\n [CORE_DIAGNOSTIC_BUDGET]: { count: 0 },\n });\n};\n\n/** Registers raw diagnostics against the shared operation budget before normalization. */\nexport const registerCoreDiagnosticCandidates = (\n limits: ICoreResourceLimits,\n amount: number,\n operation: ICoreOperation,\n fallbackCount = 0,\n): number => {\n const budget = (limits as ICoreOperationResourceLimits)[CORE_DIAGNOSTIC_BUDGET];\n const currentCount = budget?.count ?? fallbackCount;\n\n if (amount > limits.maxDiagnostics - currentCount) {\n throw new CoreOperationException({\n code: 'RESOURCE_LIMIT_EXCEEDED',\n limit: 'maxDiagnostics',\n limitMaximum: limits.maxDiagnostics,\n nextAction: 'reduce-input-or-increase-limit',\n observedUsage: currentCount + amount,\n operation,\n });\n }\n\n if (budget !== undefined) {\n budget.count += amount;\n }\n\n return fallbackCount + amount;\n};\n\nconst compareNullableStrings = (left: string | null, right: string | null): number => {\n if (left === null) {\n return right === null ? 0 : -1;\n }\n\n return right === null ? 1 : compareCodePoints(left, right);\n};\n\n/**\n * Normalizes trusted JSON-scalar diagnostic metadata.\n * @param details The optional detached metadata record.\n * @returns A frozen null-prototype record with canonical key order.\n */\nexport const normalizeDiagnosticDetails = (\n details: Readonly<Record<string, string | number | boolean | null>> | undefined,\n): IDiagnosticDetails => {\n const entries = Object.entries(details ?? {})\n .sort(([left], [right]) => compareCodePoints(left, right))\n .map(\n ([key, value]) =>\n [key, typeof value === 'number' && Object.is(value, -0) ? 0 : value] as const,\n );\n\n return deepFreeze(createNullPrototypeRecord(entries));\n};\n\n/**\n * Normalizes a trusted diagnostic entity into canonical key order.\n * @param entity The optional diagnostic entity.\n * @returns The frozen normalized entity or `null`.\n */\nexport const normalizeDiagnosticEntity = (\n entity: IDiagnosticEntity | null | undefined,\n): IDiagnosticEntity | null => {\n if (entity === undefined || entity === null) {\n return null;\n }\n\n const entries = ENTITY_KEYS.flatMap((key) => {\n const value = entity[key];\n return value === undefined ? [] : ([[key, value]] as const);\n });\n\n return deepFreeze(createNullPrototypeRecord(entries) as IDiagnosticEntity);\n};\n\n/** Serializes unordered diagnostic details with explicit exact-code-point key ordering. */\nexport const serializeDiagnosticDetails = (details: IDiagnosticDetails): string => {\n const entries = Object.entries(details).sort(([left], [right]) => compareCodePoints(left, right));\n\n return JSON.stringify(entries);\n};\n\nconst serializeDiagnostic = (diagnostic: IDiagnostic): string => {\n const entity =\n diagnostic.entity === null\n ? null\n : ENTITY_KEYS.map((key) => [key, diagnostic.entity?.[key] ?? null]);\n const range =\n diagnostic.range === null\n ? null\n : [\n diagnostic.range.start.line,\n diagnostic.range.start.column,\n diagnostic.range.start.offset,\n diagnostic.range.end.line,\n diagnostic.range.end.column,\n diagnostic.range.end.offset,\n ];\n\n return JSON.stringify([\n diagnostic.code,\n diagnostic.severity,\n diagnostic.severity === 'warning'\n ? [\n diagnostic.subject,\n diagnostic.qualifier,\n diagnostic.accepted ?? false,\n diagnostic.reason ?? null,\n ]\n : null,\n serializeDiagnosticDetails(diagnostic.details),\n entity,\n diagnostic.message,\n diagnostic.path,\n diagnostic.pointer,\n range,\n diagnostic.source,\n ]);\n};\n\nconst compareRanges = (left: ISourceRange | null, right: ISourceRange | null): number => {\n if (left === null) {\n return right === null ? 0 : -1;\n }\n\n if (right === null) {\n return 1;\n }\n\n return (\n left.start.line - right.start.line ||\n left.start.column - right.start.column ||\n left.start.offset - right.start.offset ||\n left.end.line - right.end.line ||\n left.end.column - right.end.column ||\n left.end.offset - right.end.offset\n );\n};\n\nconst readEntityValue = (\n entity: IDiagnosticEntity | null,\n key: keyof IDiagnosticEntity,\n): string => {\n return entity?.[key] ?? '';\n};\n\nconst compareDiagnostics = (left: IDiagnostic, right: IDiagnostic): number => {\n return (\n compareNullableStrings(left.path, right.path) ||\n compareRanges(left.range, right.range) ||\n compareNullableStrings(left.pointer, right.pointer) ||\n compareCodePoints(left.source, right.source) ||\n compareCodePoints(left.code, right.code) ||\n compareCodePoints(left.severity, right.severity) ||\n compareCodePoints(\n left.severity === 'warning'\n ? JSON.stringify([\n left.subject,\n left.qualifier,\n left.accepted ?? false,\n left.reason ?? null,\n ])\n : '',\n right.severity === 'warning'\n ? JSON.stringify([\n right.subject,\n right.qualifier,\n right.accepted ?? false,\n right.reason ?? null,\n ])\n : '',\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'agentId'),\n readEntityValue(right.entity, 'agentId'),\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'capabilityKind'),\n readEntityValue(right.entity, 'capabilityKind'),\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'capabilityId'),\n readEntityValue(right.entity, 'capabilityId'),\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'decisionId'),\n readEntityValue(right.entity, 'decisionId'),\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'variableId'),\n readEntityValue(right.entity, 'variableId'),\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'contextPath'),\n readEntityValue(right.entity, 'contextPath'),\n ) ||\n compareCodePoints(\n readEntityValue(left.entity, 'integrationPath'),\n readEntityValue(right.entity, 'integrationPath'),\n ) ||\n compareCodePoints(\n serializeDiagnosticDetails(left.details),\n serializeDiagnosticDetails(right.details),\n ) ||\n compareCodePoints(left.message, right.message)\n );\n};\n\n/** Classifies every catalog code by its documented validation responsibility. */\nconst getDiagnosticGroup = (code: ICoreDiagnosticCode): ICoreDiagnostic['group'] => {\n if (code.startsWith('MOLDEA_INTEGRATION_')) return 'integration';\n if (code.startsWith('MOLDEA_MIRROR_')) return 'mirrors';\n if (/^MOLDEA_(REFERENCE|IMPACT|SYMBOL|CONTEXT|DECISION|RUNTIME_GUIDANCE)_/.test(code))\n return 'references';\n if (code === 'MOLDEA_VARIABLE_ID_INVALID') return 'manifest';\n if (/^MOLDEA_(AGENT|VARIABLE|CAPABILITY|TOOL|SKILL|RUNTIME)_/.test(code)) return 'agents';\n if (/^MOLDEA_(MANIFEST_MISSING|PROJECT_FILE|ENTRY_TYPE|CANONICAL|TEXT)_/.test(code))\n return 'discovery';\n return 'manifest';\n};\n\n/**\n * Creates one normalized, immutable Core diagnostic.\n * @param input The trusted Core-owned diagnostic fields to normalize.\n * @returns A deeply immutable public diagnostic value.\n */\nexport const createCoreDiagnostic = (input: ICoreDiagnosticInput): ICoreDiagnostic => {\n const message = CORE_DIAGNOSTIC_MESSAGES[input.code];\n\n if (message === undefined) {\n throw new TypeError('The requested Core diagnostic is not implemented.');\n }\n\n const base = {\n code: input.code,\n details: normalizeDiagnosticDetails(input.details),\n entity: normalizeDiagnosticEntity(input.entity),\n message,\n path: input.path,\n pointer: input.pointer ?? null,\n range: input.range ?? null,\n group: getDiagnosticGroup(input.code),\n source: 'core' as const,\n };\n if (\n input.code === 'MOLDEA_IMPACT_PATTERN_UNMATCHED' ||\n input.code === 'MOLDEA_ACCEPTANCE_UNMATCHED' ||\n input.code === 'MOLDEA_INTEGRATION_BLOCK_MISSING' ||\n input.code === 'MOLDEA_INTEGRATION_SKILL_MISSING' ||\n input.code === 'MOLDEA_INTEGRATION_BLOCK_STALE' ||\n input.code === 'MOLDEA_INTEGRATION_LINK_UNRESOLVED' ||\n input.code === 'MOLDEA_INTEGRATION_CLAUDE_IMPORT_MISSING'\n ) {\n if (input.subject === undefined) throw new TypeError('A warning subject is required.');\n return deepFreeze({\n ...base,\n code: input.code,\n severity: 'warning' as const,\n subject: input.subject,\n qualifier: input.qualifier ?? null,\n acceptable: ACCEPTABLE_WARNING_CODES.some((code) => code === input.code),\n });\n }\n return deepFreeze({ ...base, code: input.code, severity: 'error' as const });\n};\n\n/**\n * Deduplicates and sorts already-normalized Core diagnostics.\n * @param candidates The immutable diagnostics to combine.\n * @returns A frozen deterministic diagnostic collection.\n */\nexport const normalizeDiagnostics = (\n candidates: readonly IDiagnostic[],\n): readonly IDiagnostic[] => {\n const diagnostics = new Map<string, IDiagnostic>();\n\n for (const diagnostic of candidates) {\n const key = serializeDiagnostic(diagnostic);\n\n if (diagnostics.has(key)) {\n continue;\n }\n\n diagnostics.set(key, diagnostic);\n }\n\n return deepFreeze([...diagnostics.values()].sort(compareDiagnostics));\n};\n\n/** Adds available YAML locations while preserving existing ranges and warning acceptance fields. */\nexport const locateDiagnosticRanges = (\n diagnostics: readonly ICoreDiagnostic[],\n roots: ReadonlyMap<IRepositoryPath, IYamlNode>,\n): readonly ICoreDiagnostic[] => {\n return normalizeDiagnostics(\n diagnostics.map((diagnostic) => {\n if (diagnostic.range !== null || diagnostic.path === null || diagnostic.pointer === null) {\n return diagnostic;\n }\n const root = roots.get(diagnostic.path);\n if (root === undefined) return diagnostic;\n const range = locateYamlPointer(root, diagnostic.pointer);\n return range === null ? diagnostic : { ...diagnostic, range };\n }),\n );\n};\n\n/** Counts the complete normalized diagnostic result by severity once. */\nexport const countDiagnosticsBySeverity = (\n diagnostics: readonly IDiagnostic[],\n): {\n readonly errorCount: number;\n readonly warningCount: number;\n readonly acceptedWarningCount: number;\n readonly diagnosticCount: number;\n} => {\n let errorCount = 0;\n let warningCount = 0;\n let acceptedWarningCount = 0;\n\n for (const diagnostic of diagnostics) {\n if (diagnostic.severity === 'error') {\n errorCount += 1;\n } else if (diagnostic.accepted === true) {\n acceptedWarningCount += 1;\n } else {\n warningCount += 1;\n }\n }\n\n return { errorCount, warningCount, acceptedWarningCount, diagnosticCount: diagnostics.length };\n};\n\n/**\n * Creates a deterministic, deduplicating diagnostic collector for one operation.\n * @param limits The Core resource limits governing diagnostic output.\n * @param operation The operation reported by resource failures.\n * @returns A collector that freezes and sorts its final diagnostic array.\n */\nexport const createCoreDiagnosticCollector = (\n limits: ICoreResourceLimits,\n operation: ICoreOperation,\n): ICoreDiagnosticCollector => {\n const diagnostics = new Map<string, ICoreDiagnostic>();\n let proposalCount = 0;\n let fallbackRawCount = 0;\n\n const retain = (input: ICoreDiagnosticInput): void => {\n const diagnostic = createCoreDiagnostic(input);\n const key = serializeDiagnostic(diagnostic);\n\n proposalCount += 1;\n\n if (!diagnostics.has(key)) {\n diagnostics.set(key, diagnostic);\n }\n };\n\n return {\n add: (input): void => {\n fallbackRawCount = registerCoreDiagnosticCandidates(limits, 1, operation, fallbackRawCount);\n retain(input);\n },\n merge: retain,\n finalize: (): readonly ICoreDiagnostic[] => normalizeDiagnostics([...diagnostics.values()]),\n get size(): number {\n return proposalCount;\n },\n };\n};\n\n/**\n * Escapes one JSON Pointer reference token.\n * @param value The decoded mapping key or array index token.\n * @returns The RFC 6901 escaped token.\n */\nexport const escapeJsonPointerSegment = (value: string): string => {\n return value.replaceAll('~', '~0').replaceAll('/', '~1');\n};\n","import { deepFreeze, isObjectValid } from 'jg-utilities';\n\nimport { DEFAULT_CORE_RESOURCE_LIMITS } from '../constants/index.js';\nimport type { ICoreOptions, ICoreResourceLimits } from '../contracts/index.js';\nimport { createCoreOperationResourceLimits } from '../diagnostic-utilities/index.js';\nimport { CoreConfigurationException } from '../exceptions/index.js';\n\n// complete immutable Core configuration\nexport interface ICoreOptionsSnapshot {\n readonly limits: ICoreResourceLimits;\n}\n\n/** Creates an operation-local options view with one shared raw-diagnostic budget. */\nexport const createCoreOperationOptionsSnapshot = (\n options: ICoreOptionsSnapshot,\n): ICoreOptionsSnapshot => {\n return Object.freeze({\n limits: createCoreOperationResourceLimits(options.limits),\n });\n};\n\nconst RESOURCE_LIMIT_KEYS = [\n 'maxEntries',\n 'maxTotalBytesRead',\n 'maxFileBytes',\n 'maxManifestBytes',\n 'maxRetainedBytes',\n 'maxDiagnostics',\n 'maxCoverage',\n 'maxAcceptedWarnings',\n] as const satisfies readonly (keyof ICoreResourceLimits)[];\n\n/**\n * Validates, copies, fills, and freezes all configured resource limits.\n * @param candidate The untrusted optional limit overrides.\n * @returns The complete frozen resource limits.\n * @throws\n * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.\n */\nconst normalizeLimits = (candidate: unknown): ICoreResourceLimits => {\n if (candidate === undefined) {\n return DEFAULT_CORE_RESOURCE_LIMITS;\n }\n\n if (!isObjectValid(candidate, true)) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n\n const knownKeys = new Set<string>(RESOURCE_LIMIT_KEYS);\n\n if (Object.keys(candidate).some((key) => !knownKeys.has(key))) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n\n const normalized: ICoreResourceLimits = {\n ...DEFAULT_CORE_RESOURCE_LIMITS,\n };\n\n for (const key of RESOURCE_LIMIT_KEYS) {\n const value: unknown = candidate[key];\n\n if (value === undefined) {\n continue;\n }\n\n if (!Number.isSafeInteger(value) || (value as number) <= 0) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n\n (normalized as Record<keyof ICoreResourceLimits, number>)[key] = value as number;\n }\n\n return deepFreeze(normalized);\n};\n\n/**\n * Validates and snapshots caller-owned Core resource limits.\n * @returns A deeply frozen configuration snapshot.\n * @throws\n * - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.\n */\nexport const normalizeCoreOptions = (options: ICoreOptions | undefined): ICoreOptionsSnapshot => {\n if (\n options !== undefined &&\n (!isObjectValid(options, true) || Reflect.ownKeys(options).some((key) => key !== 'limits'))\n ) {\n throw new CoreConfigurationException({\n code: 'INVALID_RESOURCE_LIMIT',\n operation: 'create-core',\n });\n }\n return deepFreeze({ limits: normalizeLimits(options?.['limits']) });\n};\n"],"mappings":";;;;AAIA,IAAa,2BAA2B,OAAO,OAAO;CACpD;CACA;CACA;CACA;CACA;CACA;AACF,CAAU;AAGV,IAAa,yBAAyB,OAAO,OAAO;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAU;AAGV,IAAa,uCACX,OAAO,OAAO,CAAC,CAAC,CAAC;AAGnB,IAAa,+BAAoD,OAAO,OAAO;CAC7E,gBAAgB;CAChB,YAAY;CACZ,aAAa;CACb,qBAAqB;CACrB,cAAc;CACd,kBAAkB;CAClB,kBAAkB;CAClB,mBAAmB;AACrB,CAAC;;;;;;;;AC9DD,IAAa,6BACX,YAC0B;CAC1B,MAAM,SAAS,OAAO,OAAO,IAAI;CAEjC,KAAK,MAAM,CAAC,KAAK,UAAU,SACzB,OAAO,OAAO;CAGhB,OAAO;AACT;;;AC2BA,IAAM,iCAAiB,IAAI,QAAkE;AAE7F,IAAM,2BAA2B;;AAGjC,IAAa,qBAAqB,MAAiB,YAAyC;CAC1F,IAAI,YAAY,IAAI,OAAO,KAA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