@muloka/figma-console-mcp 0.6.3 → 0.6.4

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 (43) hide show
  1. package/README.md +7 -0
  2. package/dist/core/cache-invalidation.d.ts +14 -0
  3. package/dist/core/cache-invalidation.d.ts.map +1 -0
  4. package/dist/core/cache-invalidation.js +39 -0
  5. package/dist/core/cache-invalidation.js.map +1 -0
  6. package/dist/core/design-system-manifest.d.ts +30 -14
  7. package/dist/core/design-system-manifest.d.ts.map +1 -1
  8. package/dist/core/design-system-manifest.js +61 -19
  9. package/dist/core/design-system-manifest.js.map +1 -1
  10. package/dist/core/design-system-tools.js +1 -1
  11. package/dist/core/design-system-tools.js.map +1 -1
  12. package/dist/core/figma-tools.d.ts.map +1 -1
  13. package/dist/core/figma-tools.js +10 -11
  14. package/dist/core/figma-tools.js.map +1 -1
  15. package/dist/core/file-generations.d.ts +18 -0
  16. package/dist/core/file-generations.d.ts.map +1 -0
  17. package/dist/core/file-generations.js +44 -0
  18. package/dist/core/file-generations.js.map +1 -0
  19. package/dist/core/manifest-build.d.ts +41 -0
  20. package/dist/core/manifest-build.d.ts.map +1 -0
  21. package/dist/core/manifest-build.js +135 -0
  22. package/dist/core/manifest-build.js.map +1 -0
  23. package/dist/core/tool-annotations.js +2 -2
  24. package/dist/core/tool-annotations.js.map +1 -1
  25. package/dist/core/variables-cache.d.ts +28 -24
  26. package/dist/core/variables-cache.d.ts.map +1 -1
  27. package/dist/core/variables-cache.js +63 -35
  28. package/dist/core/variables-cache.js.map +1 -1
  29. package/dist/core/websocket-connector.d.ts.map +1 -1
  30. package/dist/core/websocket-connector.js +7 -1
  31. package/dist/core/websocket-connector.js.map +1 -1
  32. package/dist/core/websocket-server.d.ts +9 -4
  33. package/dist/core/websocket-server.d.ts.map +1 -1
  34. package/dist/core/websocket-server.js +18 -5
  35. package/dist/core/websocket-server.js.map +1 -1
  36. package/dist/core/write-tools.d.ts.map +1 -1
  37. package/dist/core/write-tools.js +152 -39
  38. package/dist/core/write-tools.js.map +1 -1
  39. package/dist/local.d.ts +1 -0
  40. package/dist/local.d.ts.map +1 -1
  41. package/dist/local.js +46 -255
  42. package/dist/local.js.map +1 -1
  43. package/package.json +1 -1
package/dist/local.js CHANGED
@@ -24,6 +24,7 @@ import { realpathSync, existsSync, readFileSync, mkdirSync, copyFileSync, writeF
24
24
  import { homedir } from "os";
25
25
  import { getConfig } from "./core/config.js";
26
26
  import { createChildLogger } from "./core/logger.js";
27
+ import { attachCacheInvalidation } from "./core/cache-invalidation.js";
27
28
  import { onStdinClosed } from "./core/stdin-lifecycle.js";
28
29
  import { FigmaAPI, extractFileKey, extractFigmaUrlInfo, formatVariables, } from "./core/figma-api.js";
29
30
  import { registerFigmaAPITools } from "./core/figma-tools.js";
@@ -42,7 +43,8 @@ import { MAX_TOOL_RESPONSE_BYTES, withToolIdentity } from "./core/identity.js";
42
43
  import { PACKAGE_ROOT } from "./core/resolve-package-root.js";
43
44
  import { FigmaWebSocketServer, getBundledPluginVersion, getBundledForkPluginRevision, heldPinStatusWarning, } from "./core/websocket-server.js";
44
45
  import { WebSocketConnector } from "./core/websocket-connector.js";
45
- import { invalidateAfterVariableWrite } from "./core/design-system-manifest.js";
46
+ import { DesignSystemManifestCache, invalidateAfterVariableWrite } from "./core/design-system-manifest.js";
47
+ import { ensureManifest } from "./core/manifest-build.js";
46
48
  import { VariablesCache, cacheGeneration, setCacheIfCurrent } from "./core/variables-cache.js";
47
49
  import { DEFAULT_WS_PORT, getPortRange, advertisePort, unadvertisePort, registerPortCleanup, startPeriodicReaper, discoverActiveInstances, cleanupStalePortFiles, cleanupOrphanedProcesses, evictOldestInstance, refreshPortAdvertisement, setAdvertisedMcpHttpPort, HEARTBEAT_INTERVAL_MS, } from "./core/port-discovery.js";
48
50
  import { registerTokenBrowserApp } from "./apps/token-browser/server.js";
@@ -226,7 +228,7 @@ class LocalFigmaConsoleMCP {
226
228
  // touches no node fires no documentChange, so nothing else would, and the
227
229
  // summary / token-value tools would serve pre-write tokens (#14).
228
230
  const hadVariables = this.variablesCache.size > 0;
229
- invalidateAfterVariableWrite(this.variablesCache);
231
+ invalidateAfterVariableWrite(this.variablesCache, this.manifestCache);
230
232
  if (hadVariables)
231
233
  logger.info('Variables cache invalidated after write operation');
232
234
  }
@@ -253,11 +255,15 @@ class LocalFigmaConsoleMCP {
253
255
  // In-memory cache for variables data to avoid MCP token limits
254
256
  // Maps fileKey -> {data, timestamp}
255
257
  //
256
- // Every invalidation (a write's clear(), the documentChange and
257
- // fileDisconnected deletes) also ends in-flight read sharing: a read that
258
- // starts after the invalidation must not join a read that started before
259
- // it, or it would store pre-change data under the new generation.
260
- this.variablesCache = new VariablesCache(() => this.wsServer?.forgetSharedReads());
258
+ // Every invalidation also ends in-flight read sharing, for the files it
259
+ // invalidates: a read that starts after the invalidation must not join a
260
+ // read that started before it, or it would store pre-change data under the
261
+ // new generation. A write's clear() ends every file's shared reads. Document
262
+ // changes and disconnects invalidate per file, through attachCacheInvalidation
263
+ // (src/core/cache-invalidation.ts), and end only that file's shared reads.
264
+ this.variablesCache = new VariablesCache((fileKey) => this.wsServer?.forgetSharedReads(fileKey));
265
+ // Design-system manifests, one per file; its invalidations end shared reads the same way.
266
+ this.manifestCache = new DesignSystemManifestCache((fileKey) => this.wsServer?.forgetSharedReads(fileKey));
261
267
  /** Stable plugin directory path (set during startup) */
262
268
  this.stablePluginPath = null;
263
269
  this.server = new StdioMcpServer({
@@ -1630,122 +1636,24 @@ class LocalFigmaConsoleMCP {
1630
1636
  // These tools provide progressive disclosure of design system data
1631
1637
  // to minimize context window usage. Start with summary, then search,
1632
1638
  // then get details for specific components.
1633
- // Helper function to ensure design system cache is loaded (auto-loads if needed)
1634
- const ensureDesignSystemCache = async () => {
1635
- const { DesignSystemManifestCache, createEmptyManifest, loadManifestVariables, } = await import("./core/design-system-manifest.js");
1636
- const cache = DesignSystemManifestCache.getInstance();
1637
- const currentUrl = this.getCurrentFileUrl();
1638
- // extractFileKey is branch-aware: on /design/KEY/branch/BRANCH_KEY/…
1639
- // URLs the branch key is the effective file key — an ad-hoc regex
1640
- // here returned the main key and cached the wrong manifest for
1641
- // branch files.
1642
- const fileKey = (currentUrl ? extractFileKey(currentUrl) : null) ?? "unknown";
1643
- // Check cache first
1644
- let cacheEntry = cache.get(fileKey);
1645
- if (cacheEntry) {
1646
- return { cacheEntry, fileKey, wasLoaded: false };
1647
- }
1648
- // Need to extract fresh data - do this silently without returning an error
1649
- logger.info({ fileKey }, "Auto-loading design system cache");
1650
- const connector = await this.getDesktopConnector();
1651
- const manifest = createEmptyManifest(fileKey);
1652
- manifest.fileUrl = currentUrl || undefined;
1653
- // Get variables (tokens). A failed read is reported, and the manifest
1654
- // is not cached, so a transient plugin error can't serve "0 tokens"
1655
- // for the full TTL.
1656
- const variablesFetchError = await loadManifestVariables(manifest, () => connector.readVariables(fileKey));
1657
- if (variablesFetchError) {
1658
- logger.warn({ error: variablesFetchError }, "Could not fetch variables during auto-load");
1659
- }
1660
- // Get components
1661
- // Maps are keyed by component key (unique) rather than name — same-named
1662
- // components on different pages would silently overwrite each other.
1663
- let rawComponents;
1664
- let componentsFetchError = null;
1665
- try {
1666
- const componentsResult = await connector.getLocalComponents();
1667
- if (componentsResult.success && componentsResult.data) {
1668
- rawComponents = {
1669
- components: componentsResult.data.components || [],
1670
- componentSets: componentsResult.data.componentSets || [],
1671
- };
1672
- for (const comp of rawComponents.components) {
1673
- manifest.components[comp.key || comp.nodeId] = {
1674
- key: comp.key,
1675
- nodeId: comp.nodeId,
1676
- name: comp.name,
1677
- description: comp.description || undefined,
1678
- defaultSize: { width: comp.width, height: comp.height },
1679
- };
1680
- }
1681
- for (const compSet of rawComponents.componentSets) {
1682
- manifest.componentSets[compSet.key || compSet.nodeId] = {
1683
- key: compSet.key,
1684
- nodeId: compSet.nodeId,
1685
- name: compSet.name,
1686
- description: compSet.description || undefined,
1687
- variants: compSet.variants?.map((v) => ({
1688
- key: v.key,
1689
- nodeId: v.nodeId,
1690
- name: v.name,
1691
- })) || [],
1692
- variantAxes: compSet.variantAxes?.map((a) => ({
1693
- name: a.name,
1694
- values: a.values,
1695
- })) || [],
1696
- };
1697
- }
1698
- }
1699
- else {
1700
- componentsFetchError =
1701
- componentsResult?.error || "getLocalComponents returned no data";
1702
- }
1703
- }
1704
- catch (error) {
1705
- componentsFetchError =
1706
- error instanceof Error ? error.message : String(error);
1707
- logger.warn({ error }, "Could not fetch components during auto-load");
1708
- }
1709
- // Update summary
1710
- manifest.summary = {
1711
- totalTokens: Object.keys(manifest.tokens.colors).length +
1712
- Object.keys(manifest.tokens.spacing).length,
1713
- totalComponents: Object.keys(manifest.components).length,
1714
- totalComponentSets: Object.keys(manifest.componentSets).length,
1715
- colorPalette: Object.keys(manifest.tokens.colors).slice(0, 10),
1716
- spacingScale: Object.values(manifest.tokens.spacing)
1717
- .map((s) => s.value)
1718
- .filter((v) => typeof v === "number")
1719
- .sort((a, b) => a - b)
1720
- .slice(0, 10),
1721
- typographyScale: [],
1722
- componentCategories: [],
1723
- };
1724
- // Cache the result — but never cache a manifest built from a FAILED
1725
- // components fetch: serving an empty manifest as "cached" for the full
1726
- // TTL is exactly the "search returns 0 components" poisoning bug.
1727
- if (!componentsFetchError && !variablesFetchError) {
1728
- cache.set(fileKey, manifest, rawComponents);
1729
- cacheEntry = cache.get(fileKey);
1730
- }
1731
- else {
1732
- cacheEntry = {
1733
- manifest,
1734
- timestamp: Date.now(),
1735
- fileKey,
1736
- rawComponents,
1737
- };
1738
- }
1639
+ // Helper function to ensure design system cache is loaded (auto-loads if needed).
1640
+ // The build itself, shared by the four manifest tools, is ensureManifest
1641
+ // (core/manifest-build.ts); this joins its fetch errors into one warning.
1642
+ const ensureDesignSystemCache = async (opts) => {
1643
+ const result = await ensureManifest({
1644
+ manifestCache: this.manifestCache,
1645
+ getConnector: (fileKey) => this.getDesktopConnector(fileKey),
1646
+ getCurrentFileUrl: () => this.getCurrentFileUrl(),
1647
+ }, opts);
1648
+ const { componentsError, variablesError } = result;
1739
1649
  return {
1740
- cacheEntry,
1741
- fileKey,
1742
- wasLoaded: true,
1650
+ ...result,
1743
1651
  warning: [
1744
- componentsFetchError
1745
- ? `Components fetch failed (${componentsFetchError}) — results may be incomplete and were NOT cached; retry after checking the Desktop Bridge plugin.`
1652
+ componentsError
1653
+ ? `Components fetch failed (${componentsError}) — results may be incomplete and were NOT cached; retry after checking the Desktop Bridge plugin.`
1746
1654
  : null,
1747
- variablesFetchError
1748
- ? `Variables fetch failed (${variablesFetchError}) — tokens are missing and the result was NOT cached; retry after checking the Desktop Bridge plugin.`
1655
+ variablesError
1656
+ ? `Variables fetch failed (${variablesError}) — tokens are missing and the result was NOT cached; retry after checking the Desktop Bridge plugin.`
1749
1657
  : null,
1750
1658
  ]
1751
1659
  .filter(Boolean)
@@ -1768,16 +1676,11 @@ class LocalFigmaConsoleMCP {
1768
1676
  }),
1769
1677
  }, async ({ forceRefresh }) => {
1770
1678
  try {
1771
- const { DesignSystemManifestCache, createEmptyManifest, loadManifestVariables, getCategories, getTokenSummary, } = await import("./core/design-system-manifest.js");
1772
- const cache = DesignSystemManifestCache.getInstance();
1773
- const currentUrl = this.getCurrentFileUrl();
1774
- const fileKeyMatch = currentUrl?.match(/\/(file|design|board|slides)\/([a-zA-Z0-9]+)/);
1775
- const fileKey = fileKeyMatch ? fileKeyMatch[2] : "unknown";
1776
- // Check cache first
1777
- let cacheEntry = cache.get(fileKey);
1778
- if (cacheEntry && !forceRefresh) {
1779
- const categories = getCategories(cacheEntry.manifest);
1780
- const tokenSummary = getTokenSummary(cacheEntry.manifest);
1679
+ const { getCategories, getTokenSummary } = await import("./core/design-system-manifest.js");
1680
+ const { cacheEntry, fileKey, wasLoaded, componentsError, variablesError } = await ensureDesignSystemCache({ forceRefresh });
1681
+ const categories = getCategories(cacheEntry.manifest);
1682
+ const tokenSummary = getTokenSummary(cacheEntry.manifest);
1683
+ if (!wasLoaded) {
1781
1684
  return {
1782
1685
  content: [
1783
1686
  {
@@ -1800,83 +1703,7 @@ class LocalFigmaConsoleMCP {
1800
1703
  ],
1801
1704
  };
1802
1705
  }
1803
- // Need to extract fresh data
1804
- const connector = await this.getDesktopConnector();
1805
- const manifest = createEmptyManifest(fileKey);
1806
- manifest.fileUrl = currentUrl || undefined;
1807
- // Get variables (tokens); see ensureDesignSystemCache for the failure guard.
1808
- const variablesFetchError = await loadManifestVariables(manifest, () => connector.readVariables(fileKey));
1809
- // Get components (can be slow for large files)
1810
- // Keyed by component key (unique) — name keys drop same-named
1811
- // components on other pages.
1812
- let rawComponents;
1813
- let componentsFetchError = null;
1814
- try {
1815
- const componentsResult = await connector.getLocalComponents();
1816
- if (componentsResult.success && componentsResult.data) {
1817
- rawComponents = {
1818
- components: componentsResult.data.components || [],
1819
- componentSets: componentsResult.data.componentSets || [],
1820
- };
1821
- for (const comp of rawComponents.components) {
1822
- manifest.components[comp.key || comp.nodeId] = {
1823
- key: comp.key,
1824
- nodeId: comp.nodeId,
1825
- name: comp.name,
1826
- description: comp.description || undefined,
1827
- defaultSize: { width: comp.width, height: comp.height },
1828
- };
1829
- }
1830
- for (const compSet of rawComponents.componentSets) {
1831
- manifest.componentSets[compSet.key || compSet.nodeId] = {
1832
- key: compSet.key,
1833
- nodeId: compSet.nodeId,
1834
- name: compSet.name,
1835
- description: compSet.description || undefined,
1836
- variants: compSet.variants?.map((v) => ({
1837
- key: v.key,
1838
- nodeId: v.nodeId,
1839
- name: v.name,
1840
- })) || [],
1841
- variantAxes: compSet.variantAxes?.map((a) => ({
1842
- name: a.name,
1843
- values: a.values,
1844
- })) || [],
1845
- };
1846
- }
1847
- }
1848
- else {
1849
- componentsFetchError =
1850
- componentsResult?.error || "getLocalComponents returned no data";
1851
- }
1852
- }
1853
- catch (error) {
1854
- componentsFetchError =
1855
- error instanceof Error ? error.message : String(error);
1856
- logger.warn({ error }, "Could not fetch components");
1857
- }
1858
- // Update summary
1859
- manifest.summary = {
1860
- totalTokens: Object.keys(manifest.tokens.colors).length +
1861
- Object.keys(manifest.tokens.spacing).length,
1862
- totalComponents: Object.keys(manifest.components).length,
1863
- totalComponentSets: Object.keys(manifest.componentSets).length,
1864
- colorPalette: Object.keys(manifest.tokens.colors).slice(0, 10),
1865
- spacingScale: Object.values(manifest.tokens.spacing)
1866
- .map((s) => s.value)
1867
- .filter((v) => typeof v === "number")
1868
- .sort((a, b) => a - b)
1869
- .slice(0, 10),
1870
- typographyScale: [],
1871
- componentCategories: [],
1872
- };
1873
- // Cache the result — never cache a manifest built from a failed
1874
- // components fetch (would serve empty results for the full TTL).
1875
- if (!componentsFetchError && !variablesFetchError) {
1876
- cache.set(fileKey, manifest, rawComponents);
1877
- }
1878
- const categories = getCategories(manifest);
1879
- const tokenSummary = getTokenSummary(manifest);
1706
+ const { manifest } = cacheEntry;
1880
1707
  return {
1881
1708
  content: [
1882
1709
  {
@@ -1892,13 +1719,13 @@ class LocalFigmaConsoleMCP {
1892
1719
  componentSets: manifest.summary.totalComponentSets,
1893
1720
  tokens: manifest.summary.totalTokens,
1894
1721
  },
1895
- warnings: componentsFetchError || variablesFetchError
1722
+ warnings: componentsError || variablesError
1896
1723
  ? [
1897
- componentsFetchError
1898
- ? `Components fetch failed (${componentsFetchError}) — component data is incomplete and was NOT cached. Check the Desktop Bridge plugin and retry.`
1724
+ componentsError
1725
+ ? `Components fetch failed (${componentsError}) — component data is incomplete and was NOT cached. Check the Desktop Bridge plugin and retry.`
1899
1726
  : null,
1900
- variablesFetchError
1901
- ? `Variables fetch failed (${variablesFetchError}) — tokens are missing and the result was NOT cached. Check the Desktop Bridge plugin and retry.`
1727
+ variablesError
1728
+ ? `Variables fetch failed (${variablesError}) — tokens are missing and the result was NOT cached. Check the Desktop Bridge plugin and retry.`
1902
1729
  : null,
1903
1730
  ].filter(Boolean)
1904
1731
  : undefined,
@@ -2789,7 +2616,7 @@ Without libraryFileKey/libraryFileUrl, searches the currently open file (local c
2789
2616
  }
2790
2617
  // Priority 1: Try Desktop Bridge via transport-agnostic connector
2791
2618
  try {
2792
- const startedAt = cacheGeneration(this.variablesCache);
2619
+ const startedAt = cacheGeneration(this.variablesCache, fileKey);
2793
2620
  const connector = await this.getDesktopConnector();
2794
2621
  const desktopResult = await connector.readVariables(fileKey);
2795
2622
  if (desktopResult.success && desktopResult.variables) {
@@ -2817,7 +2644,7 @@ Without libraryFileKey/libraryFileUrl, searches the currently open file (local c
2817
2644
  }, "Desktop Bridge failed for token browser, trying REST API");
2818
2645
  }
2819
2646
  // Priority 2: Fall back to REST API (requires Enterprise plan)
2820
- const restStartedAt = cacheGeneration(this.variablesCache);
2647
+ const restStartedAt = cacheGeneration(this.variablesCache, fileKey);
2821
2648
  const api = await this.getFigmaAPI();
2822
2649
  const { local, localError } = await api.getAllVariables(fileKey);
2823
2650
  if (localError) {
@@ -2875,7 +2702,7 @@ Without libraryFileKey/libraryFileUrl, searches the currently open file (local c
2875
2702
  if (variables.length === 0) {
2876
2703
  desktopBridgeAttempted = true;
2877
2704
  try {
2878
- const startedAt = cacheGeneration(this.variablesCache);
2705
+ const startedAt = cacheGeneration(this.variablesCache, fileKey);
2879
2706
  const connector = await this.getDesktopConnector();
2880
2707
  const desktopResult = await connector.readVariables(fileKey);
2881
2708
  if (desktopResult.success && desktopResult.variables) {
@@ -2907,7 +2734,7 @@ Without libraryFileKey/libraryFileUrl, searches the currently open file (local c
2907
2734
  if (variables.length === 0) {
2908
2735
  restApiAttempted = true;
2909
2736
  try {
2910
- const startedAt = cacheGeneration(this.variablesCache);
2737
+ const startedAt = cacheGeneration(this.variablesCache, fileKey);
2911
2738
  const api = await this.getFigmaAPI();
2912
2739
  const { local, localError } = await api.getAllVariables(fileKey);
2913
2740
  if (!localError && local) {
@@ -3284,47 +3111,11 @@ Without libraryFileKey/libraryFileUrl, searches the currently open file (local c
3284
3111
  this.wsServer.on("fileConnected", (data) => {
3285
3112
  logger.info({ fileKey: data.fileKey, fileName: data.fileName }, "Desktop Bridge plugin connected via WebSocket");
3286
3113
  });
3287
- // Plugin disconnect leaves cached variables stale — when the plugin reconnects
3288
- // after a sleep/wake or network blip, the file may have edits we missed
3289
- // (no DOCUMENT_CHANGE event was delivered while we were disconnected).
3290
- // Invalidate the cache for the disconnected file so the next read is fresh.
3114
+ // Cache invalidation on disconnect and document changes lives in
3115
+ // core/cache-invalidation.ts so it can be tested by behaviour.
3116
+ attachCacheInvalidation(this.wsServer, { variablesCache: this.variablesCache, manifestCache: this.manifestCache });
3291
3117
  this.wsServer.on("fileDisconnected", (data) => {
3292
3118
  logger.info({ fileKey: data.fileKey, fileName: data.fileName }, "Desktop Bridge plugin disconnected from WebSocket");
3293
- if (data.fileKey) {
3294
- this.variablesCache.delete(data.fileKey);
3295
- // design-system-tools.ts stores token data under a prefixed key
3296
- this.variablesCache.delete(`vars:${data.fileKey}`);
3297
- void import("./core/design-system-manifest.js").then(({ DesignSystemManifestCache }) => {
3298
- DesignSystemManifestCache.getInstance().invalidate(data.fileKey);
3299
- }).catch(() => { });
3300
- }
3301
- });
3302
- // Invalidate variable cache when document changes are reported.
3303
- // Figma's documentchange API doesn't expose a specific variable change type —
3304
- // variable operations manifest as node PROPERTY_CHANGE events, so we invalidate
3305
- // on any style or node change to be safe.
3306
- this.wsServer.on("documentChange", (data) => {
3307
- if (data.hasStyleChanges || data.hasNodeChanges) {
3308
- if (data.fileKey) {
3309
- // Per-file cache invalidation — only clear the affected file's cache.
3310
- // Also clear the design-system-tools token entry (prefixed key)
3311
- // and the component manifest, so searches see new components
3312
- // and the design-system kit sees edited variables.
3313
- this.variablesCache.delete(data.fileKey);
3314
- this.variablesCache.delete(`vars:${data.fileKey}`);
3315
- void import("./core/design-system-manifest.js").then(({ DesignSystemManifestCache }) => {
3316
- DesignSystemManifestCache.getInstance().invalidate(data.fileKey);
3317
- }).catch(() => { });
3318
- logger.debug({ fileKey: data.fileKey, changeCount: data.changeCount, hasStyleChanges: data.hasStyleChanges, hasNodeChanges: data.hasNodeChanges }, "Variable cache invalidated due to document changes");
3319
- }
3320
- else {
3321
- // Unidentified file (event arrived before FILE_INFO handshake completed).
3322
- // We don't know which cache entry to invalidate; do nothing rather than
3323
- // blanket-clear other files' caches. FILE_INFO will arrive shortly and
3324
- // any subsequent document changes will route correctly.
3325
- logger.debug({ changeCount: data.changeCount }, "Document change received before file identification — cache untouched");
3326
- }
3327
- }
3328
3119
  });
3329
3120
  }
3330
3121
  // Periodically reap orphaned/zombie servers for the whole run, not just