@moldea.ai/core 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +4 -6
  2. package/dist/analysis-worker.js +5 -5
  3. package/dist/chunks/{core-Cdeiu6xG.js → core-DC9KYL1H.js} +30 -28
  4. package/dist/chunks/core-DC9KYL1H.js.map +1 -0
  5. package/dist/chunks/{errors-BE4DS3Ak.js → errors-Dw1ahMS1.js} +4 -9
  6. package/dist/chunks/errors-Dw1ahMS1.js.map +1 -0
  7. package/dist/chunks/{exceptions-IXsorE8t.js → exceptions-CYf1pCKf.js} +1 -3
  8. package/dist/chunks/exceptions-CYf1pCKf.js.map +1 -0
  9. package/dist/chunks/{lifecycle-D_RvxhDC.js → lifecycle-h3DWn5vl.js} +2 -2
  10. package/dist/chunks/{lifecycle-D_RvxhDC.js.map → lifecycle-h3DWn5vl.js.map} +1 -1
  11. package/dist/chunks/{options-5x9gu2Qb.js → options-AMqX7rx_.js} +3 -9
  12. package/dist/chunks/options-AMqX7rx_.js.map +1 -0
  13. package/dist/chunks/{repository-rpc-B_y0Kspf.js → repository-rpc-ClAIx3-c.js} +2 -2
  14. package/dist/chunks/{repository-rpc-B_y0Kspf.js.map → repository-rpc-ClAIx3-c.js.map} +1 -1
  15. package/dist/chunks/{scope-AGMcHUE_.js → scope-DxhC1hq2.js} +7 -7
  16. package/dist/chunks/scope-DxhC1hq2.js.map +1 -0
  17. package/dist/chunks/{syntax-CVvExx4R.js → syntax-MNWJxC7y.js} +5 -3
  18. package/dist/chunks/syntax-MNWJxC7y.js.map +1 -0
  19. package/dist/exceptions/index.d.ts +0 -2
  20. package/dist/exceptions/index.d.ts.map +1 -1
  21. package/dist/export-inventory/inventory.d.ts +3 -3
  22. package/dist/export-inventory/inventory.d.ts.map +1 -1
  23. package/dist/export-inventory/syntax.d.ts.map +1 -1
  24. package/dist/format-validation/index.d.ts +0 -3
  25. package/dist/format-validation/index.d.ts.map +1 -1
  26. package/dist/impact-pattern-validation/inspection.d.ts.map +1 -1
  27. package/dist/index.js +3 -3
  28. package/dist/manifest-validation/index.d.ts.map +1 -1
  29. package/dist/node-inspection/errors.d.ts.map +1 -1
  30. package/dist/node-runner.js +3 -3
  31. package/dist/node.js +5 -5
  32. package/dist/repository-reference-validation/index.d.ts.map +1 -1
  33. package/dist/scope.js +2 -2
  34. package/package.json +1 -1
  35. package/dist/chunks/core-Cdeiu6xG.js.map +0 -1
  36. package/dist/chunks/errors-BE4DS3Ak.js.map +0 -1
  37. package/dist/chunks/exceptions-IXsorE8t.js.map +0 -1
  38. package/dist/chunks/options-5x9gu2Qb.js.map +0 -1
  39. package/dist/chunks/scope-AGMcHUE_.js.map +0 -1
  40. package/dist/chunks/syntax-CVvExx4R.js.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # `@moldea.ai/core`
4
4
 
5
- Source-neutral, deterministic, content-safe interpretation of the `moldea` repository format.
5
+ Source-neutral, deterministic, content-safe interpretation of the moldea repository format.
6
6
 
7
7
  Version 7 accepts caller-supplied text and `@moldea.ai/repository` version 2 readers. The main, format, and scope entry points remain environment-neutral. Repository access belongs to the caller-supplied reader. Project validation returns content-free summaries, diagnostics, binding coverage, agent assignments, and metadata. Canonical document bodies are available only through an explicit path-scoped byte-range operation.
8
8
 
@@ -74,7 +74,7 @@ The prepared inspection retains only its content-free records, summary, source i
74
74
 
75
75
  ## Binding coverage
76
76
 
77
- Core checks each declared binding's file and, when a symbol is named, its syntax-only runtime export inventory. TypeScript and JavaScript ESM are recognized conservatively. A proven missing export is an error and a `failed` coverage record. CommonJS, declaration files, wildcard exports, malformed source, and insufficient parsing capacity remain `not-checked`, with a reason. Coverage names the checks performed; it does not establish runtime wiring, behavior, provider compatibility, or business correctness.
77
+ Core checks each declared binding's file and, when a symbol is named, its syntax-only runtime export inventory. TypeScript and JavaScript ESM are recognized conservatively. A proven missing export is an error and a `failed` coverage record. CommonJS, declaration files, wildcard exports, malformed or oversized source, and insufficient parsing capacity remain `not-checked`, with a reason. Coverage names the checks performed; it does not establish runtime wiring, behavior, provider compatibility, or business correctness.
78
78
 
79
79
  `RECOGNIZED_RUNTIME_IDS` contains 35 runtime labels plus `custom`. Labels select agent guidance. Core applies the same universal checks to every label and does not interpret SDK calls. Use the installed SDK's type definitions and real application tests to establish runtime behavior. Handoffs remain runtime-native behavior.
80
80
 
@@ -82,11 +82,9 @@ Every diagnostic has `severity`, `group`, and stable `source: 'core'`. The group
82
82
 
83
83
  ## Resource and trust boundaries
84
84
 
85
- Core uses independent limits for distinct entries, total bytes read, per-file bytes, manifest bytes, logical retained bytes, diagnostics, and coverage records. The default logical retained-memory ceiling is 512 MiB. Before parsing a supported source, Core reserves `65536 + sourceBytes * (8 + 512)` bytes for text and syntax nodes. A reservation miss records `resource-limit` without parsing; a source read, cancellation, or operation budget failure rejects the whole operation. Each distinct source is parsed at most once per operation. Source buffers and syntax reservations are released after analysis; only export names remain in the inventory cache. Core executes no repository code, follows no symlink, receives no host path or source credential, and returns logical paths only.
85
+ Core uses independent limits for distinct entries, total bytes read, per-file bytes, manifest bytes, logical retained bytes, diagnostics, and coverage records. The default logical retained-memory ceiling is 512 MiB. Before reading a supported source for export analysis, Core checks `maxFileBytes`, confirms read-buffer headroom, and reserves `65536 + sourceBytes * (8 + 512)` bytes for text and syntax nodes. An oversized source or reservation miss records `resource-limit` without a source read; a subsequent failed read, cancellation, or operation budget failure rejects the whole operation. Each distinct source is parsed at most once per operation. Source buffers and syntax reservations are released after analysis; only export names remain in the inventory cache. Core executes no repository code, follows no symlink, receives no host path or source credential, and returns logical paths only.
86
86
 
87
- Every `RESOURCE_LIMIT_EXCEEDED` exception identifies the exceeded limit, its configured maximum, the observed or projected usage, and the stable `reduce-input-or-increase-limit` next action. Core refuses the operation before allocating retained state beyond the applicable ceiling.
88
-
89
- The release-5 calibration corpus drives these limits through the real CLI and PR Assurance across ordinary, 1,024-path, broad-relationship, Unicode, binary, diagnostic-heavy, and incomplete-provider cases. Repeated measurements establish ordinary cumulative headroom, while adversarial tests prove explicit bounded failure without treating a page, file, or operation limit as total repository capacity.
87
+ Logical `RESOURCE_LIMIT_EXCEEDED` exceptions identify the exceeded limit, its configured maximum, the observed or projected usage, and `reduce-input-or-increase-limit`. Verified isolated-worker heap exhaustion uses `review-inspection-capacity` with unknown observed usage. Fixed transport limits have no next action. Core refuses an operation before allocating retained state beyond the applicable ceiling.
90
88
 
91
89
  ## Development
92
90
 
@@ -1,7 +1,7 @@
1
- import { n as normalizeCoreOptions } from "./chunks/options-5x9gu2Qb.js";
2
- import { n as CoreOperationException } from "./chunks/exceptions-IXsorE8t.js";
3
- import { a as encodeInspectionMessage, d as NODE_INSPECTION_TRANSPORT_BYTES, i as decodeInspectionMessage, n as serializeInspectionFailure, o as NODE_INSPECTION_FILE_PAGE_BYTES, r as createInspectionProcessFailure, t as deserializeInspectionFailure } from "./chunks/errors-BE4DS3Ak.js";
4
- import { i as parseRpcFilePage, n as parseRpcEntry, r as parseRpcEntryPage } from "./chunks/repository-rpc-B_y0Kspf.js";
1
+ import { n as normalizeCoreOptions } from "./chunks/options-AMqX7rx_.js";
2
+ import { n as CoreOperationException } from "./chunks/exceptions-CYf1pCKf.js";
3
+ import { a as encodeInspectionMessage, d as NODE_INSPECTION_TRANSPORT_BYTES, i as decodeInspectionMessage, n as serializeInspectionFailure, o as NODE_INSPECTION_FILE_PAGE_BYTES, r as createInspectionProcessFailure, t as deserializeInspectionFailure } from "./chunks/errors-Dw1ahMS1.js";
4
+ import { i as parseRpcFilePage, n as parseRpcEntry, r as parseRpcEntryPage } from "./chunks/repository-rpc-ClAIx3-c.js";
5
5
  import { RepositorySourceException } from "@moldea.ai/repository";
6
6
  import { parentPort, workerData } from "node:worker_threads";
7
7
  import { getHeapStatistics } from "node:v8";
@@ -76,7 +76,7 @@ var repository = {
76
76
  };
77
77
  /** Prepares the fixed Core implementation after the parent acknowledges the heap. */
78
78
  var prepare = async () => {
79
- const { createCore } = await import("./chunks/core-Cdeiu6xG.js").then((n) => n.t);
79
+ const { createCore } = await import("./chunks/core-DC9KYL1H.js").then((n) => n.t);
80
80
  inspection = await createCore(normalizeCoreOptions({ limits: {
81
81
  ...start.limits,
82
82
  maxRetainedBytes: start.limits.maxRetainedBytes - NODE_INSPECTION_TRANSPORT_BYTES
@@ -1,6 +1,6 @@
1
- import { E as parseDecisionIdFromPath, S as isRuntimeGuidancePath, T as isVariableId, a as escapeJsonPointerSegment, c as freezeRecursively, d as hasNonWhitespace, g as isContextPath, i as createCoreDiagnosticCollector, k as trimRepositoryFormatWhitespace, l as compareExactStrings, n as normalizeCoreOptions, o as normalizeDiagnostics, r as countDiagnosticsBySeverity, s as createNullPrototypeRecord, t as createCoreOperationOptionsSnapshot, u as countUnicodeScalars } from "./options-5x9gu2Qb.js";
2
- import { n as CoreOperationException } from "./exceptions-IXsorE8t.js";
3
- import { a as createSourceLocator, c as calculateContentDigest, i as parseStrictYaml, l as calculateNormalizedTextDigest, n as inspectManifestDocument, o as collectManifestScopeDeclarations, r as parseManifestDocument, s as matchesRepositoryGlob, t as matchManifestScope, u as normalizeTextDocument } from "./scope-AGMcHUE_.js";
1
+ import { E as parseDecisionIdFromPath, O as trimRepositoryFormatWhitespace, S as isRuntimeGuidancePath, T as isVariableId, a as escapeJsonPointerSegment, c as freezeRecursively, d as hasNonWhitespace, g as isContextPath, i as createCoreDiagnosticCollector, l as compareExactStrings, n as normalizeCoreOptions, o as normalizeDiagnostics, r as countDiagnosticsBySeverity, s as createNullPrototypeRecord, t as createCoreOperationOptionsSnapshot, u as countUnicodeScalars } from "./options-AMqX7rx_.js";
2
+ import { n as CoreOperationException } from "./exceptions-CYf1pCKf.js";
3
+ import { a as createSourceLocator, c as calculateContentDigest, i as parseStrictYaml, l as calculateNormalizedTextDigest, n as inspectManifestDocument, o as collectManifestScopeDeclarations, r as parseManifestDocument, s as matchesRepositoryGlob, t as matchManifestScope, u as normalizeTextDocument } from "./scope-DxhC1hq2.js";
4
4
  import { REPOSITORY_ROOT, RepositorySourceException, compareRepositoryPaths, createRepositoryIdentity, isRepositoryPath, parseRepositoryPath } from "@moldea.ai/repository";
5
5
  //#region \0rolldown/runtime.js
6
6
  var __defProp = Object.defineProperty;
@@ -2093,7 +2093,7 @@ var inspectImpactPatterns = async (reader, manifest, limits, signal) => {
2093
2093
  unmatched.push(...pending);
2094
2094
  }
2095
2095
  } catch (error) {
2096
- if (error instanceof CoreOperationException && error.code === "RESOURCE_LIMIT_EXCEEDED" && error.limit === "maxEntries" || error instanceof RepositorySourceException && error.code === "RESOURCE_LIMIT_EXCEEDED") return {
2096
+ if (error instanceof CoreOperationException && error.code === "RESOURCE_LIMIT_EXCEEDED" || error instanceof RepositorySourceException && error.code === "RESOURCE_LIMIT_EXCEEDED") return {
2097
2097
  completed: false,
2098
2098
  diagnostics: []
2099
2099
  };
@@ -2409,7 +2409,7 @@ var createProjectIndex = (input) => {
2409
2409
  /** Identifies syntax-only source formats with explicit runtime export semantics. */
2410
2410
  var isSupportedExportSource = (path) => !/\.d\.(?:ts|tsx|mts|cts)$/.test(path) && /\.(?:ts|tsx|mts|cts|js|mjs|jsx)$/.test(path);
2411
2411
  /**
2412
- * Reads and parses a declared source once, retaining only its export-name set.
2412
+ * Checks a declared source when budgets allow, retaining only its export-name set.
2413
2413
  * @returns A conclusive inventory or the precise reason analysis could not run.
2414
2414
  * @throws
2415
2415
  * - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.
@@ -2423,21 +2423,29 @@ var isSupportedExportSource = (path) => !/\.d\.(?:ts|tsx|mts|cts)$/.test(path) &
2423
2423
  * - ENTRY_NOT_FOUND: The requested repository entry was not found.
2424
2424
  * - ENTRY_NOT_FILE: The requested repository entry is not a file.
2425
2425
  */
2426
- var readExportInventory = async (reader, path) => {
2426
+ var readExportInventory = async (reader, path, byteLength, maxFileBytes) => {
2427
2427
  if (!isSupportedExportSource(path)) return {
2428
2428
  kind: "not-checked",
2429
2429
  reason: "unsupported-file-type"
2430
2430
  };
2431
2431
  const ledger = getRetainedMemory(reader);
2432
- const source = await ledger.readSourceFile(path);
2433
- const reservation = 65536 + source.bytes.byteLength * 520;
2432
+ const reservation = 65536 + byteLength * 520;
2433
+ const readHeadroom = Math.max(1, byteLength + Math.min(65536, byteLength));
2434
+ if (byteLength > maxFileBytes || !ledger.tryReserve(reservation + readHeadroom)) return {
2435
+ kind: "not-checked",
2436
+ reason: "resource-limit"
2437
+ };
2438
+ ledger.release(readHeadroom);
2434
2439
  try {
2435
- if (!ledger.tryReserve(reservation)) return {
2436
- kind: "not-checked",
2437
- reason: "resource-limit"
2438
- };
2440
+ const source = await ledger.readSourceFile(path);
2439
2441
  try {
2440
- const { inventoryExports } = await import("./syntax-CVvExx4R.js");
2442
+ if (source.bytes.byteLength !== byteLength) throw new RepositorySourceException({
2443
+ code: "INVALID_SOURCE_DATA",
2444
+ operation: "read-file-page",
2445
+ path,
2446
+ retryable: false
2447
+ });
2448
+ const { inventoryExports } = await import("./syntax-MNWJxC7y.js");
2441
2449
  const result = inventoryExports(path, source.bytes);
2442
2450
  if (result.kind === "parsed") {
2443
2451
  let bytes = 64;
@@ -2446,10 +2454,10 @@ var readExportInventory = async (reader, path) => {
2446
2454
  }
2447
2455
  return result;
2448
2456
  } finally {
2449
- ledger.release(reservation);
2457
+ source.release();
2450
2458
  }
2451
2459
  } finally {
2452
- source.release();
2460
+ ledger.release(reservation);
2453
2461
  }
2454
2462
  };
2455
2463
  //#endregion
@@ -2457,16 +2465,9 @@ var readExportInventory = async (reader, path) => {
2457
2465
  var childPointer = (pointer, segment) => {
2458
2466
  return `${pointer}/${escapeJsonPointerSegment(segment)}`;
2459
2467
  };
2460
- var compareNullableStrings = (left, right) => {
2461
- if (left === void 0) return right === void 0 ? 0 : -1;
2462
- return right === void 0 ? 1 : compareExactStrings(left, right);
2463
- };
2464
- var compareReferences = (left, right) => {
2465
- return compareExactStrings(left.path, right.path) || compareNullableStrings(left.symbol, right.symbol);
2466
- };
2467
- /** Adds sorted repository-reference array entries with their normalized indexes. */
2468
+ /** Adds repository-reference array entries with their authored indexes. */
2468
2469
  var addReferenceCandidates = (candidates, references, pointer, entity, relationship) => {
2469
- for (const [index, reference] of [...references ?? []].sort(compareReferences).entries()) candidates.push({
2470
+ for (const [index, reference] of (references ?? []).entries()) candidates.push({
2470
2471
  entity,
2471
2472
  kind: "reference",
2472
2473
  path: reference.path,
@@ -2475,9 +2476,9 @@ var addReferenceCandidates = (candidates, references, pointer, entity, relations
2475
2476
  ...reference.symbol === void 0 ? {} : { symbol: reference.symbol }
2476
2477
  });
2477
2478
  };
2478
- /** Adds sorted exact impact paths while retaining skipped glob indexes. */
2479
+ /** Adds exact impact paths while retaining authored indexes for skipped globs. */
2479
2480
  var addImpactCandidates = (candidates, affectedBy, pointer, entity) => {
2480
- for (const [index, pattern] of [...affectedBy ?? []].sort(compareExactStrings).entries()) {
2481
+ for (const [index, pattern] of (affectedBy ?? []).entries()) {
2481
2482
  if (pattern.includes("*")) continue;
2482
2483
  candidates.push({
2483
2484
  entity,
@@ -2678,6 +2679,7 @@ var validateRepositoryReferences = async (repository, manifestPath, manifest, di
2678
2679
  const entry = await entryPromise;
2679
2680
  validateCandidate(candidate, entry, manifestPath, collector);
2680
2681
  if (entry?.type !== "file" || candidate.relationship === void 0) continue;
2682
+ if (entry.byteLength === null) throw new TypeError("A repository file entry must declare its byte length.");
2681
2683
  if (coverage.length >= limits.maxCoverage) throw new CoreOperationException({
2682
2684
  code: "RESOURCE_LIMIT_EXCEEDED",
2683
2685
  operation: "validate-project",
@@ -2702,7 +2704,7 @@ var validateRepositoryReferences = async (repository, manifestPath, manifest, di
2702
2704
  else {
2703
2705
  let inventory = inventories.get(candidate.path);
2704
2706
  if (inventory === void 0) {
2705
- inventory = await readExportInventory(repository, candidate.path);
2707
+ inventory = await readExportInventory(repository, candidate.path, entry.byteLength, limits.maxFileBytes);
2706
2708
  inventories.set(candidate.path, inventory);
2707
2709
  }
2708
2710
  if (inventory.kind === "not-checked") record = {
@@ -3361,4 +3363,4 @@ var createCore = (options) => {
3361
3363
  //#endregion
3362
3364
  export { createCore as n, parseIntegrationBlock as r, core_exports as t };
3363
3365
 
3364
- //# sourceMappingURL=core-Cdeiu6xG.js.map
3366
+ //# sourceMappingURL=core-DC9KYL1H.js.map