@hydranium/core 1.0.0-next.198 → 1.0.0-next.200

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 (90) hide show
  1. package/README.md +8 -7
  2. package/lib/documents/ast-document-manager.d.ts +2 -52
  3. package/lib/documents/ast-document-manager.d.ts.map +1 -1
  4. package/lib/documents/ast-document-manager.js.map +1 -1
  5. package/lib/documents/index.d.ts +0 -1
  6. package/lib/documents/index.d.ts.map +1 -1
  7. package/lib/documents/index.js +0 -1
  8. package/lib/documents/index.js.map +1 -1
  9. package/lib/langium/integrity/integrity-service.d.ts +1 -1
  10. package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
  11. package/lib/langium/language-module.d.ts +2 -2
  12. package/lib/langium/language-module.d.ts.map +1 -1
  13. package/lib/langium/language-module.js +2 -2
  14. package/lib/langium/language-module.js.map +1 -1
  15. package/lib/langium/module.d.ts +3 -3
  16. package/lib/langium/module.d.ts.map +1 -1
  17. package/lib/langium/module.js +1 -1
  18. package/lib/langium/module.js.map +1 -1
  19. package/lib/langium/shared-services.d.ts +2 -2
  20. package/lib/langium/shared-services.d.ts.map +1 -1
  21. package/lib/langium/validation/validation-contribution-collector.d.ts +9 -1
  22. package/lib/langium/validation/validation-contribution-collector.d.ts.map +1 -1
  23. package/lib/langium/validation/validation-contribution-collector.js +1 -1
  24. package/lib/langium/validation/validation-contribution-collector.js.map +1 -1
  25. package/lib/langium/workspace/file-system-provider.d.ts +52 -2
  26. package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
  27. package/lib/langium/workspace/file-system-provider.js.map +1 -1
  28. package/lib/langium/workspace/hydranium-workspace-manager.d.ts +1 -1
  29. package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
  30. package/lib/langium/workspace/in-memory-file-system-provider.d.ts +1 -1
  31. package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
  32. package/lib/langium/workspace/index.d.ts +1 -0
  33. package/lib/langium/workspace/index.d.ts.map +1 -1
  34. package/lib/langium/workspace/index.js +1 -0
  35. package/lib/langium/workspace/index.js.map +1 -1
  36. package/lib/langium/workspace/persistent-file-system-provider.d.ts +1 -1
  37. package/lib/langium/workspace/persistent-file-system-provider.d.ts.map +1 -1
  38. package/lib/{documents → langium/workspace}/self-save-registry.d.ts +1 -1
  39. package/lib/langium/workspace/self-save-registry.d.ts.map +1 -0
  40. package/lib/{documents → langium/workspace}/self-save-registry.js +1 -1
  41. package/lib/langium/workspace/self-save-registry.js.map +1 -0
  42. package/lib/langium/workspace/virtual-document.d.ts +1 -1
  43. package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
  44. package/lib/lsp/hydranium-document-update-handler.d.ts +2 -2
  45. package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
  46. package/lib/node/index.d.ts +0 -1
  47. package/lib/node/index.d.ts.map +1 -1
  48. package/lib/node/index.js +0 -1
  49. package/lib/node/index.js.map +1 -1
  50. package/lib/node/node-file-system-provider.d.ts +2 -2
  51. package/lib/node/node-file-system-provider.d.ts.map +1 -1
  52. package/lib/node/profile-capture.js +1 -1
  53. package/lib/node/profile-capture.js.map +1 -1
  54. package/lib/testing/stub-ast-document-manager.d.ts +2 -1
  55. package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
  56. package/lib/testing/stub-ast-document-manager.js.map +1 -1
  57. package/lib/testing/stub-self-save-registry.d.ts +1 -1
  58. package/lib/testing/stub-self-save-registry.d.ts.map +1 -1
  59. package/lib/testing/stub-writable-file-system.d.ts +1 -1
  60. package/lib/testing/stub-writable-file-system.d.ts.map +1 -1
  61. package/package.json +5 -5
  62. package/src/documents/ast-document-manager.ts +2 -61
  63. package/src/documents/index.ts +0 -1
  64. package/src/langium/integrity/integrity-service.ts +1 -1
  65. package/src/langium/language-module.ts +6 -3
  66. package/src/langium/module.ts +4 -3
  67. package/src/langium/shared-services.ts +2 -2
  68. package/src/langium/validation/validation-contribution-collector.ts +10 -1
  69. package/src/langium/workspace/file-system-provider.ts +53 -2
  70. package/src/langium/workspace/hydranium-workspace-manager.ts +1 -1
  71. package/src/langium/workspace/in-memory-file-system-provider.ts +1 -1
  72. package/src/langium/workspace/index.ts +1 -0
  73. package/src/langium/workspace/persistent-file-system-provider.ts +1 -1
  74. package/src/{documents → langium/workspace}/self-save-registry.ts +2 -2
  75. package/src/langium/workspace/virtual-document.ts +1 -1
  76. package/src/lsp/hydranium-document-update-handler.ts +2 -2
  77. package/src/node/index.ts +0 -1
  78. package/src/node/node-file-system-provider.ts +2 -2
  79. package/src/node/profile-capture.ts +1 -1
  80. package/src/testing/parse-semantic-root.ts +1 -1
  81. package/src/testing/stub-ast-document-manager.ts +2 -2
  82. package/src/testing/stub-self-save-registry.ts +1 -1
  83. package/src/testing/stub-writable-file-system.ts +1 -1
  84. package/lib/documents/self-save-registry.d.ts.map +0 -1
  85. package/lib/documents/self-save-registry.js.map +0 -1
  86. package/lib/node/process-memory.d.ts +0 -66
  87. package/lib/node/process-memory.d.ts.map +0 -1
  88. package/lib/node/process-memory.js +0 -252
  89. package/lib/node/process-memory.js.map +0 -1
  90. package/src/node/process-memory.ts +0 -299
@@ -15,6 +15,15 @@ import { type ValidationCheckRegistry } from './validation-contribution.js';
15
15
 
16
16
  export type ValidationContributionCollectorOptions = LogNameOptions;
17
17
 
18
+ /**
19
+ * The validation-collector slot. Empty because the service registers checks in
20
+ * its constructor and nothing calls it; typing the slot by the class would stop
21
+ * an adopter's subclass from a second package copy satisfying it. The cost: any
22
+ * non-null value satisfies it, so a mis-bound slot compiles and registers no check.
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- the slot has no public member to name
25
+ export interface ValidationContributionCollector {}
26
+
18
27
  /**
19
28
  * Per-language eager collector that wires `ValidationCheckContribution`s
20
29
  * declared under `services.validation.checks` into Langium's native
@@ -32,7 +41,7 @@ export type ValidationContributionCollectorOptions = LogNameOptions;
32
41
  * DI proxy. That is what gets the checks into the registry before Langium
33
42
  * reaches the `Validated` phase — nothing else constructs this service.
34
43
  */
35
- export class ValidationContributionCollector {
44
+ export class DefaultValidationContributionCollector implements ValidationContributionCollector {
36
45
  protected readonly tracer: Tracer;
37
46
 
38
47
  constructor(services: ServerLanguageServices, options: ValidationContributionCollectorOptions = {}) {
@@ -9,11 +9,62 @@
9
9
 
10
10
  import { type Tracer } from '@hydranium/protocol';
11
11
  import { EmptyFileSystemProvider } from '@hydranium/langium';
12
- import type { FileSystemNode, URI } from '@hydranium/langium';
13
- import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
12
+ import type { FileSystemNode, FileSystemProvider, URI } from '@hydranium/langium';
13
+ import { type SelfSaveRegistry } from './self-save-registry.js';
14
14
  import { type LogNameOptions } from '../diagnostics/logger.js';
15
15
  import { type ServerSharedServicesMinimal } from '../shared-services.js';
16
16
 
17
+ /**
18
+ * File-system provider extension that supports writes. Langium's standard
19
+ * {@link FileSystemProvider} is read-only; `AstDocumentManager` needs to persist
20
+ * saves, so consumers wire in a provider that implements this superset.
21
+ *
22
+ * Implementations may optionally hold a reference to a
23
+ * {@link SelfSaveRegistry} so they can record their own write mtimes and
24
+ * help downstream file-watchers suppress echo events for those writes.
25
+ * The framework's `DefaultFileSystemProvider` reads it from
26
+ * `services.workspace.SelfSaveRegistry`; alternative implementations can do
27
+ * the same or leave the field unset.
28
+ */
29
+ export interface WritableFileSystemProvider extends FileSystemProvider {
30
+ writeFile(uri: URI, content: string): Promise<void>;
31
+ /**
32
+ * Last-modified time (ms) of the file at `uri`, or `undefined` if it can't
33
+ * be determined (missing file, or a provider with no disk — in-memory /
34
+ * browser). Optional: the only consumer is self-save echo suppression
35
+ * (`didChangeWatchedFiles`), which simply lets a change through when the
36
+ * mtime is unavailable. Distinct from Langium's `stat` (whose
37
+ * `FileSystemNode` carries no mtime). Keeping disk access on the provider
38
+ * seam is what lets the LSP update handler avoid a direct `node:fs` import.
39
+ */
40
+ mtimeMs?(uri: URI): Promise<number | undefined>;
41
+ /**
42
+ * Resolve `uri` to its real on-disk identity (symlinks collapsed, `..`/`.`
43
+ * walked, case-folded on case-insensitive filesystems), or `undefined` *iff
44
+ * the filesystem knows the path is absent*. The single source of the
45
+ * "nothing loadable here" signal `RealpathDocumentUriPolicy` turns into
46
+ * the synthetic-placeholder branch of `getOrCreateDocument`.
47
+ *
48
+ * Contract for implementers:
49
+ * - A `file:`-backed provider returns the resolved URI when the file exists,
50
+ * and `undefined` when it cannot resolve the path (missing / unreadable).
51
+ * - A non-`file:` URI (or any URI the provider cannot stat) passes through
52
+ * **unchanged** — it is treated as present, never reported absent.
53
+ * - A provider with no disk to check (in-memory / browser / empty) simply
54
+ * omits this method; the framework's `FileSystemProviderRegistry` then
55
+ * returns the URI unchanged, and `RealpathDocumentUriPolicy` answers as
56
+ * the syntactic `DefaultDocumentUriPolicy` does.
57
+ *
58
+ * Synchronous (a `realpath` is a kernel-cached syscall) and optional — the
59
+ * only consumers are the document-identity policy's `canonicalUri`/`loadUri`.
60
+ * Keeping the syscall on the provider seam is what lets the policy stay
61
+ * browser-neutral (no `node:fs` import).
62
+ */
63
+ realpath?(uri: URI): URI | undefined;
64
+ /** Registry the provider records its own writes against. Optional — providers without watcher integration may omit. */
65
+ readonly selfSaveRegistry?: SelfSaveRegistry;
66
+ }
67
+
17
68
  /**
18
69
  * Empty-filesystem {@link WritableFileSystemProvider}. For browser / test / CLI
19
70
  * hosts that don't have a real filesystem. All writes are no-ops. On the
@@ -24,7 +24,7 @@ import type { ServerLocale } from '../../locale/server-locale.js';
24
24
  import type { ProjectChangeEvent } from '../project/project-change-event.js';
25
25
  import type { ProjectManager } from '../project/project-manager.js';
26
26
  import type { ServerSharedServicesMinimal } from '../shared-services.js';
27
- import type { WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
27
+ import type { WritableFileSystemProvider } from './file-system-provider.js';
28
28
  import { type DocumentUriPolicy, findRealpathDivergence } from './document-uri-policy.js';
29
29
  import { type AdditionalDocumentContribution, collectAdditionalDocuments } from './additional-document-contribution.js';
30
30
  import { onProcessEvent } from '../../util/environment.js';
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { type FileSystemNode, URI } from '@hydranium/langium';
11
11
  import { defineMessage, type Tracer } from '@hydranium/protocol';
12
- import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
12
+ import { type WritableFileSystemProvider } from './file-system-provider.js';
13
13
  import { type LogNameOptions } from '../diagnostics/logger.js';
14
14
  import { serverSharedFactory, type ServerSharedServicesMinimal } from '../shared-services.js';
15
15
  import { notFound } from './file-not-found.js';
@@ -11,6 +11,7 @@ export * from './document-uri-policy.js';
11
11
  export * from './file-system-provider.js';
12
12
  export * from './in-memory-file-system-provider.js';
13
13
  export * from './persistent-file-system-provider.js';
14
+ export * from './self-save-registry.js';
14
15
  export * from './index-manager.js';
15
16
  export * from './initialize-workspace.js';
16
17
  export * from './langium-documents.js';
@@ -8,7 +8,7 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import { URI } from '@hydranium/langium';
11
- import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
11
+ import { type WritableFileSystemProvider } from './file-system-provider.js';
12
12
  import { serverSharedFactory, type ServerSharedServicesMinimal } from '../shared-services.js';
13
13
  import { type FileSystemSeed, InMemoryFileSystemProvider, type InMemoryFileSystemOptions } from './in-memory-file-system-provider.js';
14
14
 
@@ -8,8 +8,8 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import { type Clock } from '@hydranium/protocol';
11
- import { isCaseInsensitiveFileSystem } from '../util/environment.js';
12
- import { type ServerSharedServicesMinimal } from '../langium/shared-services.js';
11
+ import { isCaseInsensitiveFileSystem } from '../../util/environment.js';
12
+ import { type ServerSharedServicesMinimal } from '../shared-services.js';
13
13
 
14
14
  /** Default eligibility window for a self-save entry. */
15
15
  const DEFAULT_TTL_MS = 30_000;
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { type FileSystemNode, URI } from '@hydranium/langium';
11
11
  import { type Tracer } from '@hydranium/protocol';
12
- import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
12
+ import { type WritableFileSystemProvider } from './file-system-provider.js';
13
13
  import { type LogNameOptions } from '../diagnostics/logger.js';
14
14
  import { type ServerSharedServicesMinimal } from '../shared-services.js';
15
15
  import { NO_SUCH_FILE, NO_SUCH_PATH, UNSUPPORTED_WRITE } from './in-memory-file-system-provider.js';
@@ -13,8 +13,8 @@ import { DefaultDocumentUpdateHandler } from '@hydranium/langium/lsp';
13
13
  import { HYDRANIUM_BUILD_REASONS, type HydraniumDocumentBuilder } from '../langium/document-builder/document-builder.js';
14
14
  import { type ServerSharedServices } from '../langium/module.js';
15
15
  import { LANGUAGE_CLIENT_ID } from '../documents/client-ids.js';
16
- import { type SelfSaveRegistry } from '../documents/self-save-registry.js';
17
- import { type WritableFileSystemProvider } from '../documents/ast-document-manager.js';
16
+ import { type SelfSaveRegistry } from '../langium/workspace/self-save-registry.js';
17
+ import { type WritableFileSystemProvider } from '../langium/workspace/file-system-provider.js';
18
18
  import { type HydraniumTextDocuments } from '../documents/hydranium-text-documents.js';
19
19
  import { isConnectionGoneError } from '../util/connection-liveness.js';
20
20
  import {
package/src/node/index.ts CHANGED
@@ -40,7 +40,6 @@ export * from './latency-from-env.js';
40
40
  export * from './measure-memory.js';
41
41
  export * from './memory-monitor.js';
42
42
  export * from './lint-grammar.js';
43
- export * from './process-memory.js';
44
43
  export * from './profile-capture.js';
45
44
  export * from './profile-digest.js';
46
45
  export * from './profiling-run.js';
@@ -13,8 +13,8 @@ import { NodeFileSystemProvider } from '@hydranium/langium/node';
13
13
  import { randomUUID } from 'node:crypto';
14
14
  import { realpathSync } from 'node:fs';
15
15
  import * as fsp from 'node:fs/promises';
16
- import { type WritableFileSystemProvider } from '../documents/ast-document-manager.js';
17
- import { type SelfSaveRegistry } from '../documents/self-save-registry.js';
16
+ import { type WritableFileSystemProvider } from '../langium/workspace/file-system-provider.js';
17
+ import { type SelfSaveRegistry } from '../langium/workspace/self-save-registry.js';
18
18
  import { renameOverOpenReaders } from './rename-over-open-readers.js';
19
19
  import { type LogNameOptions } from '../langium/diagnostics/logger.js';
20
20
  import { serverSharedFactory, type ServerSharedServicesMinimal } from '../langium/shared-services.js';
@@ -28,7 +28,7 @@ import {
28
28
  type IntervalHistogram,
29
29
  type PerformanceEntry
30
30
  } from 'node:perf_hooks';
31
- import { snapshotFilePath, writeHeapSnapshotToDir } from './process-memory.js';
31
+ import { snapshotFilePath, writeHeapSnapshotToDir } from '@hydranium/protocol/node';
32
32
 
33
33
  export const DEFAULT_CPU_INTERVAL_MICROS = 1000;
34
34
  export const DEFAULT_ALLOCATION_INTERVAL_BYTES = 32768;
@@ -55,7 +55,7 @@
55
55
 
56
56
  import { type AstNode, AstUtils, type LangiumCoreServices, URI } from '@hydranium/langium';
57
57
  import { type ParseHelperOptions, parseHelper } from '@hydranium/langium/test';
58
- import type { WritableFileSystemProvider } from '../documents/ast-document-manager.js';
58
+ import type { WritableFileSystemProvider } from '../langium/workspace/file-system-provider.js';
59
59
 
60
60
  /** The one field this module reads off a lexer or parser error. */
61
61
  interface ParseErrorMessage {
@@ -14,9 +14,9 @@ import {
14
14
  AstDocument,
15
15
  type AstDocumentManager,
16
16
  type AstDocumentUpdatedEvent,
17
- type UpdateAttribution,
18
- type WritableFileSystemProvider
17
+ type UpdateAttribution
19
18
  } from '../documents/ast-document-manager.js';
19
+ import { type WritableFileSystemProvider } from '../langium/workspace/file-system-provider.js';
20
20
  import { UNKNOWN_CLIENT_ID } from '../documents/client-ids.js';
21
21
  import { DefaultModelLedger, type ModelLedger } from '../documents/model-ledger.js';
22
22
  import { type CloseModelArgs, type OpenModelArgs } from '@hydranium/protocol';
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
 
10
- import type { SelfSaveRegistry } from '../documents/self-save-registry.js';
10
+ import type { SelfSaveRegistry } from '../langium/workspace/self-save-registry.js';
11
11
 
12
12
  /**
13
13
  * Stub for the framework's {@link SelfSaveRegistry}. Records `register` calls
@@ -8,7 +8,7 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import type { URI } from '@hydranium/langium';
11
- import type { WritableFileSystemProvider } from '../documents/ast-document-manager.js';
11
+ import type { WritableFileSystemProvider } from '../langium/workspace/file-system-provider.js';
12
12
  import type { StubSelfSaveRegistry } from './stub-self-save-registry.js';
13
13
 
14
14
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"self-save-registry.d.ts","sourceRoot":"","sources":["../../src/documents/self-save-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAKjF,MAAM,WAAW,uBAAuB;IACrC,0GAA0G;IAC1G,KAAK,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhD;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACzD;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAC7D,SAAS,CAAC,QAAQ,CAAC,OAAO;iBAA8B,MAAM;sBAAgB,MAAM;OAAM;IAC1F;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAChC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEjC,YAAY,QAAQ,EAAE,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC,EAAE,OAAO,GAAE,uBAA4B,EAGtG;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,M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AG,EAAE,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,OAAe;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;YAChD,OAAO,KAAK,CAAC;QAChB,CAAC;QACD,oEAAoE;QACpE,OAAO,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC;IACpC,CAAC;IAED;;;;;;;;;OASG;IACO,YAAY;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;QACJ,CAAC;IACJ,CAAC;IAED,+EAA+E;IACrE,SAAS,CAAC,YAAoB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC;IACvD,CAAC;CACH"}
@@ -1,66 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the MIT License which is available in the project root.
6
- *
7
- * SPDX-License-Identifier: MIT
8
- ********************************************************************************/
9
- /**
10
- * Format a one-shot memory snapshot of the CURRENT process (heap, rss, external, V8 limit).
11
- * Suited to a process that hosts no Langium documents (e.g. a host backend); for the
12
- * language-server process with document counts, see `formatServerState`.
13
- */
14
- export declare function formatProcessMemory(label: string): string;
15
- /**
16
- * Compose an absolute artifact file path of the form `<prefix>[-<label>].<ext>` inside
17
- * {@link directory} (e.g. the workspace folder, so it lands on the persistent volume in cloud and
18
- * is visible in the file explorer), falling back to the OS temp dir when the directory is missing
19
- * or does not exist. The {@link prefix} carries the origin-first stem (e.g. `server-cpu`) and, when
20
- * a non-empty {@link label} is given (a named capture window), it is sanitised (non-word characters
21
- * → `_`, truncated to 40 chars) and appended as `-<label>`; an empty label yields the bare
22
- * `<prefix>.<ext>` so the manifest `kind` equals the filename stem. No timestamp — a fresh session
23
- * directory per run keeps names stable and collision-free. Shared by the heap-snapshot writer and
24
- * the sampled-profile capture so heap / CPU / allocation artefacts land identically, differing only
25
- * by extension.
26
- */
27
- export declare function snapshotFilePath(directory: string | undefined, label: string, prefix: string, ext: string): string;
28
- /**
29
- * Write a V8 heap snapshot of the CURRENT process to {@link directory}, falling back to the OS temp
30
- * dir when it is missing (see {@link snapshotFilePath}). `v8.writeHeapSnapshot` runs a full GC first and
31
- * briefly pauses the process; it also transiently inflates RSS while serialising. Returns the
32
- * absolute file path. The {@link prefix} (default `server-heap`, the origin-first stem) and
33
- * {@link label} are folded into the name.
34
- */
35
- export declare function writeHeapSnapshotToDir(directory: string | undefined, label: string, prefix?: string): string;
36
- /** A readable role for a process, whether it belongs to the app, and whether exactly one is expected. */
37
- export interface ProcessRole {
38
- /** Human-readable role shown in the snapshot. */
39
- role: string;
40
- /** Whether this process is part of the application (vs. tooling/debugger), counted in the app total. */
41
- isApp: boolean;
42
- /**
43
- * Set when at most one instance of this role should exist; `formatPodMemory` warns when more than
44
- * one is found (e.g. a duplicated/ghost language server).
45
- */
46
- singletonExpected?: boolean;
47
- }
48
- /** Map a raw command line to a {@link ProcessRole}. A head supplies this to label its own processes. */
49
- export type ProcessClassifier = (cmdline: string) => ProcessRole;
50
- /** Options for {@link formatPodMemory}. */
51
- export interface PodMemoryOptions {
52
- /** Map a process command line to a readable role; lets a head label its own processes. */
53
- classify?: ProcessClassifier;
54
- /** Heading for the in-app process group (default `Application`). */
55
- appLabel?: string;
56
- }
57
- /**
58
- * Format a pod/container-level memory snapshot read from the cgroup this process belongs to
59
- * (cgroup v2 `memory.current`/`peak`/`max`/`stat`, falling back to cgroup v1). This is the figure
60
- * the Kubernetes OOM-killer watches — it covers every process in the pod plus page cache and kernel
61
- * memory, so it is higher than any single `process.memoryUsage().rss`. Also sums per-process RSS so
62
- * the per-process split is visible. Explains itself when no cgroup memory controller is present
63
- * (e.g. local dev outside a container).
64
- */
65
- export declare function formatPodMemory(options?: PodMemoryOptions): string;
66
- //# sourceMappingURL=process-memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-memory.d.ts","sourceRoot":"","sources":["../../src/node/process-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAelF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKlH;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAgB,GAAG,MAAM,CAInH;AA8CD,yGAAyG;AACzG,MAAM,WAAW,WAAW;IACzB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wGAAwG;AACxG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC;AA2EjE,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC9B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM,CA6EtE"}
@@ -1,252 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2026 CrossBreeze, EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the MIT License which is available in the project root.
6
- *
7
- * SPDX-License-Identifier: MIT
8
- ********************************************************************************/
9
- /*
10
- * Node-only process- and pod-level memory introspection plus heap-snapshot
11
- * writing. Everything here is generic OS-level code (V8 stats, cgroup v2/v1,
12
- * `/proc`); the only host-specific part is naming the processes, which a head
13
- * supplies through a `ProcessClassifier`.
14
- */
15
- import { Format } from '@hydranium/protocol';
16
- import * as fs from 'node:fs';
17
- import * as os from 'node:os';
18
- import * as path from 'node:path';
19
- import * as v8 from 'node:v8';
20
- /**
21
- * Format a one-shot memory snapshot of the CURRENT process (heap, rss, external, V8 limit).
22
- * Suited to a process that hosts no Langium documents (e.g. a host backend); for the
23
- * language-server process with document counts, see `formatServerState`.
24
- */
25
- export function formatProcessMemory(label) {
26
- const mem = process.memoryUsage();
27
- const heap = v8.getHeapStatistics();
28
- const heapPercent = Math.round((mem.heapUsed / heap.heap_size_limit) * 100);
29
- return [
30
- `${label}:`,
31
- ` heap ${Format.bytes(mem.heapUsed)} used / ${Format.bytes(mem.heapTotal)} total / ` +
32
- `${Format.bytes(heap.heap_size_limit)} limit (${heapPercent}% of limit)`,
33
- ` rss ${Format.bytes(mem.rss)}, external ${Format.bytes(mem.external)}, arrayBuffers ${Format.bytes(mem.arrayBuffers)}`,
34
- ` uptime ${Math.round(process.uptime())}s, pid ${process.pid}`
35
- ].join('\n');
36
- }
37
- /**
38
- * Compose an absolute artifact file path of the form `<prefix>[-<label>].<ext>` inside
39
- * {@link directory} (e.g. the workspace folder, so it lands on the persistent volume in cloud and
40
- * is visible in the file explorer), falling back to the OS temp dir when the directory is missing
41
- * or does not exist. The {@link prefix} carries the origin-first stem (e.g. `server-cpu`) and, when
42
- * a non-empty {@link label} is given (a named capture window), it is sanitised (non-word characters
43
- * → `_`, truncated to 40 chars) and appended as `-<label>`; an empty label yields the bare
44
- * `<prefix>.<ext>` so the manifest `kind` equals the filename stem. No timestamp — a fresh session
45
- * directory per run keeps names stable and collision-free. Shared by the heap-snapshot writer and
46
- * the sampled-profile capture so heap / CPU / allocation artefacts land identically, differing only
47
- * by extension.
48
- */
49
- export function snapshotFilePath(directory, label, prefix, ext) {
50
- const safeLabel = label ? label.replace(/[^\w.-]+/g, '_').slice(0, 40) : '';
51
- const dir = directory && fs.existsSync(directory) ? directory : os.tmpdir();
52
- const stem = safeLabel ? `${prefix}-${safeLabel}` : prefix;
53
- return path.join(dir, `${stem}.${ext}`);
54
- }
55
- /**
56
- * Write a V8 heap snapshot of the CURRENT process to {@link directory}, falling back to the OS temp
57
- * dir when it is missing (see {@link snapshotFilePath}). `v8.writeHeapSnapshot` runs a full GC first and
58
- * briefly pauses the process; it also transiently inflates RSS while serialising. Returns the
59
- * absolute file path. The {@link prefix} (default `server-heap`, the origin-first stem) and
60
- * {@link label} are folded into the name.
61
- */
62
- export function writeHeapSnapshotToDir(directory, label, prefix = 'server-heap') {
63
- const filePath = snapshotFilePath(directory, label, prefix, 'heapsnapshot');
64
- v8.writeHeapSnapshot(filePath);
65
- return filePath;
66
- }
67
- const CGROUP_ROOT = '/sys/fs/cgroup';
68
- function readNumber(file) {
69
- try {
70
- const text = fs.readFileSync(file, 'utf8').trim();
71
- if (text === 'max') {
72
- return Number.POSITIVE_INFINITY;
73
- }
74
- const value = Number(text);
75
- return Number.isFinite(value) ? value : undefined;
76
- }
77
- catch {
78
- return undefined;
79
- }
80
- }
81
- /** Parse a `key value` per-line file (cgroup memory.stat) into a map. */
82
- function readKeyedBytes(file) {
83
- const out = {};
84
- try {
85
- for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
86
- const [key, value] = line.trim().split(/\s+/);
87
- if (key && value !== undefined) {
88
- const num = Number(value);
89
- if (Number.isFinite(num)) {
90
- out[key] = num;
91
- }
92
- }
93
- }
94
- }
95
- catch {
96
- // file absent or unreadable; caller handles the empty map.
97
- }
98
- return out;
99
- }
100
- /** Generic fallback: every process is shown under the app heading, labelled by its (truncated) command line. */
101
- const defaultProcessClassifier = cmdline => ({ role: cmdline ? cmdline.slice(0, 60) : 'process', isApp: true });
102
- /** Read /proc for every visible process: pid, ppid, RSS, and a command label. */
103
- function readAllProcs() {
104
- const procs = [];
105
- let entries = [];
106
- try {
107
- entries = fs.readdirSync('/proc');
108
- }
109
- catch {
110
- return procs;
111
- }
112
- for (const entry of entries) {
113
- if (!/^\d+$/.test(entry)) {
114
- continue;
115
- }
116
- let status = '';
117
- try {
118
- status = fs.readFileSync(`/proc/${entry}/status`, 'utf8');
119
- }
120
- catch {
121
- continue;
122
- }
123
- const rssMatch = status.match(/^VmRSS:\s+(\d+)\s+kB/m);
124
- if (!rssMatch) {
125
- continue;
126
- }
127
- const ppid = Number(status.match(/^PPid:\s+(\d+)/m)?.[1] ?? 0);
128
- let label = '';
129
- try {
130
- label = fs.readFileSync(`/proc/${entry}/cmdline`, 'utf8').replace(/\0/g, ' ').trim();
131
- }
132
- catch {
133
- // fall back to the process name from status below.
134
- }
135
- if (!label) {
136
- label = status.match(/^Name:\s+(.+)$/m)?.[1] ?? `pid ${entry}`;
137
- }
138
- procs.push({ pid: Number(entry), ppid, rssBytes: Number(rssMatch[1]) * 1024, label });
139
- }
140
- return procs;
141
- }
142
- /**
143
- * Sum and list per-process RSS. When {@link rootPid} is given, restrict to that process and its
144
- * descendants (the app's own process tree), which keeps the figure meaningful in local dev where
145
- * /proc otherwise shows the whole machine. In a container's PID namespace the tree is effectively
146
- * all the pod's processes anyway.
147
- */
148
- function collectProcessRss(rootPid) {
149
- const all = readAllProcs();
150
- let selected = all;
151
- let scoped = false;
152
- if (rootPid !== undefined) {
153
- const childrenByPpid = new Map();
154
- for (const proc of all) {
155
- (childrenByPpid.get(proc.ppid) ?? childrenByPpid.set(proc.ppid, []).get(proc.ppid)).push(proc);
156
- }
157
- const tree = [];
158
- const queue = all.filter(proc => proc.pid === rootPid);
159
- while (queue.length > 0) {
160
- const proc = queue.shift();
161
- tree.push(proc);
162
- queue.push(...(childrenByPpid.get(proc.pid) ?? []));
163
- }
164
- if (tree.length > 0) {
165
- selected = tree;
166
- scoped = true;
167
- }
168
- }
169
- const total = selected.reduce((sum, proc) => sum + proc.rssBytes, 0);
170
- selected.sort((a, b) => b.rssBytes - a.rssBytes);
171
- return { total, processes: selected, scoped };
172
- }
173
- /**
174
- * Format a pod/container-level memory snapshot read from the cgroup this process belongs to
175
- * (cgroup v2 `memory.current`/`peak`/`max`/`stat`, falling back to cgroup v1). This is the figure
176
- * the Kubernetes OOM-killer watches — it covers every process in the pod plus page cache and kernel
177
- * memory, so it is higher than any single `process.memoryUsage().rss`. Also sums per-process RSS so
178
- * the per-process split is visible. Explains itself when no cgroup memory controller is present
179
- * (e.g. local dev outside a container).
180
- */
181
- export function formatPodMemory(options = {}) {
182
- const classify = options.classify ?? defaultProcessClassifier;
183
- const appLabel = options.appLabel ?? 'Application';
184
- const lines = ['Pod memory snapshot:'];
185
- const v2Current = path.join(CGROUP_ROOT, 'memory.current');
186
- const v1Usage = path.join(CGROUP_ROOT, 'memory', 'memory.usage_in_bytes');
187
- if (fs.existsSync(v2Current)) {
188
- const current = readNumber(v2Current);
189
- const peak = readNumber(path.join(CGROUP_ROOT, 'memory.peak'));
190
- const max = readNumber(path.join(CGROUP_ROOT, 'memory.max'));
191
- const stat = readKeyedBytes(path.join(CGROUP_ROOT, 'memory.stat'));
192
- lines.push(' cgroup v2');
193
- lines.push(` current ${current !== undefined ? Format.bytes(current) : 'n/a'}`);
194
- lines.push(` peak ${peak !== undefined ? Format.bytes(peak) : 'n/a (kernel too old for memory.peak)'}`);
195
- lines.push(` limit ${max === Number.POSITIVE_INFINITY ? 'unlimited' : max !== undefined ? Format.bytes(max) : 'n/a'}`);
196
- if (Object.keys(stat).length > 0) {
197
- lines.push(` breakdown anon ${Format.bytes(stat.anon ?? 0)} (heaps/stacks), file ${Format.bytes(stat.file ?? 0)} (page cache), ` +
198
- `kernel ${Format.bytes(stat.kernel ?? stat.slab ?? 0)}, sock ${Format.bytes(stat.sock ?? 0)}`);
199
- }
200
- }
201
- else if (fs.existsSync(v1Usage)) {
202
- const v1 = path.join(CGROUP_ROOT, 'memory');
203
- const current = readNumber(v1Usage);
204
- const peak = readNumber(path.join(v1, 'memory.max_usage_in_bytes'));
205
- const limit = readNumber(path.join(v1, 'memory.limit_in_bytes'));
206
- const stat = readKeyedBytes(path.join(v1, 'memory.stat'));
207
- lines.push(' cgroup v1');
208
- lines.push(` current ${current !== undefined ? Format.bytes(current) : 'n/a'}`);
209
- lines.push(` peak ${peak !== undefined ? Format.bytes(peak) : 'n/a'}`);
210
- // v1 reports a huge sentinel for "unlimited"; treat anything >= 2^60 as unlimited.
211
- lines.push(` limit ${limit !== undefined && limit < 2 ** 60 ? Format.bytes(limit) : 'unlimited'}`);
212
- if (Object.keys(stat).length > 0) {
213
- lines.push(` breakdown rss ${Format.bytes(stat.rss ?? 0)}, cache ${Format.bytes(stat.cache ?? 0)} (page cache), ` +
214
- `kernel ${Format.bytes(stat.kernel ?? 0)}`);
215
- }
216
- }
217
- else {
218
- lines.push(' cgroup no memory controller under /sys/fs/cgroup (not running in a container?)');
219
- }
220
- // Root at this process so local dev reports only the app's tree, not the whole machine.
221
- const { processes } = collectProcessRss(process.pid);
222
- if (processes.length > 0) {
223
- const classified = processes.map(proc => ({ ...proc, ...classify(proc.label) }));
224
- const appProcs = classified.filter(proc => proc.isApp);
225
- const otherProcs = classified.filter(proc => !proc.isApp);
226
- const appTotal = appProcs.reduce((sum, proc) => sum + proc.rssBytes, 0);
227
- lines.push('');
228
- lines.push(` ${appLabel}: ${Format.bytes(appTotal)} across ${appProcs.length} process(es)`);
229
- for (const proc of appProcs) {
230
- lines.push(` ${Format.bytes(proc.rssBytes).padStart(10)} ${proc.role} (pid ${proc.pid})`);
231
- }
232
- const singletonCounts = new Map();
233
- for (const proc of appProcs) {
234
- if (proc.singletonExpected) {
235
- singletonCounts.set(proc.role, (singletonCounts.get(proc.role) ?? 0) + 1);
236
- }
237
- }
238
- for (const [role, count] of singletonCounts) {
239
- if (count > 1) {
240
- lines.push(` WARNING: ${count} instances of "${role}" running - likely ghost process(es); expected 1`);
241
- }
242
- }
243
- if (otherProcs.length > 0) {
244
- const otherTotal = otherProcs.reduce((sum, proc) => sum + proc.rssBytes, 0);
245
- lines.push(` Other (tooling/debugger, not counted above): ${Format.bytes(otherTotal)} across ${otherProcs.length} process(es)`);
246
- }
247
- lines.push(' Note: in a real pod the cgroup figure above is the OOM ceiling; this per-process');
248
- lines.push(' split is for attribution. Local dev may include debugger processes (excluded here).');
249
- }
250
- return lines.join('\n');
251
- }
252
- //# sourceMappingURL=process-memory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-memory.js","sourceRoot":"","sources":["../../src/node/process-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC;IACpC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC,CAAC;IAC5E,OAAO;QACJ,GAAG,KAAK,GAAG;QACX,eA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