@lensmcp/cluster 1.16.28 → 1.16.30
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.
- package/executors/gateway/runtime/lens-children.d.ts.map +1 -1
- package/executors/gateway/runtime/lens-children.js +5 -1
- package/executors/gateway/runtime/lifecycle.d.ts +3 -2
- package/executors/gateway/runtime/lifecycle.d.ts.map +1 -1
- package/executors/gateway/runtime/lifecycle.js +44 -5
- package/executors/gateway/runtime/pod-env.d.ts +24 -0
- package/executors/gateway/runtime/pod-env.d.ts.map +1 -0
- package/executors/gateway/runtime/pod-env.js +89 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lens-children.d.ts","sourceRoot":"","sources":["../../../../../../libs/cluster/src/executors/gateway/runtime/lens-children.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"lens-children.d.ts","sourceRoot":"","sources":["../../../../../../libs/cluster/src/executors/gateway/runtime/lens-children.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAuB,MAAM,SAAS,CAAC;AAQ1F,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAM7E;;;;8CAI8C;AAC9C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO5D;AAED,MAAM,WAAW,YAAY;IAC3B,iBAAiB,EAAE,UAAU,CAAC;IAC9B;;gFAE4E;IAC5E,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC;;6GAEyG;IACzG,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IACvF;;yGAEqG;IACrG,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;IACpE;gHAC4G;IAC5G,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,qBAAqB,EAE9B,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,GACzD,YAAY,CAmWd"}
|
|
@@ -13,6 +13,7 @@ const net = tslib_1.__importStar(require("node:net"));
|
|
|
13
13
|
const path = tslib_1.__importStar(require("node:path"));
|
|
14
14
|
const node_child_process_1 = require("node:child_process");
|
|
15
15
|
const lens_frontend_1 = require("@lensmcp/nx-plugin/lens-frontend");
|
|
16
|
+
const pod_env_1 = require("./pod-env");
|
|
16
17
|
const scope_1 = require("./scope");
|
|
17
18
|
const workspace_registry_1 = require("./workspace-registry");
|
|
18
19
|
const lifecycle_1 = require("./lifecycle");
|
|
@@ -91,7 +92,10 @@ deps) {
|
|
|
91
92
|
// their ports for the next gateway to route into.
|
|
92
93
|
const child = (0, node_child_process_1.spawn)(bin, args, {
|
|
93
94
|
cwd: cwd ?? rt.root,
|
|
94
|
-
|
|
95
|
+
// FOREIGN-POD ENV SCRUB (pod-env.ts): a registered workspace's vite/child runs in ITS root and must
|
|
96
|
+
// not inherit the daemon host's dotenv-loaded env (vite, like nx, keeps an already-set var over the
|
|
97
|
+
// workspace's own .env) — the caller's explicit `env` overlay still applies on top.
|
|
98
|
+
env: { ...(0, pod_env_1.podBaseEnv)(process.env, rt.root, cwd ?? rt.root), ...(env ?? {}), LENSMCP_PARENT_PID: String(process.pid) },
|
|
95
99
|
stdio: 'inherit',
|
|
96
100
|
});
|
|
97
101
|
lensChildren.push(child);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { GatewayRuntime, ServiceCtl, SockPool } from './types';
|
|
2
2
|
import type { Observability } from './observability';
|
|
3
3
|
/** Bounded, async, non-blocking walk of the workspace source tree → a signature of the file SET
|
|
4
|
-
* (`<count>:<xor-of-path-hashes>`). Skips node_modules/dist/build/dotdirs + `*-devserver` sock dirs
|
|
5
|
-
*
|
|
4
|
+
* (`<count>:<xor-of-path-hashes>`). Skips node_modules/dist/build/dotdirs + `*-devserver` sock dirs + every
|
|
5
|
+
* GITIGNORED path (runtime output is not source — see `SRC_EXCLUDE`), and only counts source-extension
|
|
6
|
+
* files. Order-independent (readdir order irrelevant) and null-safe. */
|
|
6
7
|
export declare function sourceSetSignature(root: string): Promise<string>;
|
|
7
8
|
export interface PodRecycleConfig {
|
|
8
9
|
maxAgeMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../../libs/cluster/src/executors/gateway/runtime/lifecycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../../libs/cluster/src/executors/gateway/runtime/lifecycle.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAapE,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,iBAAiB,CAAC;AAyE/D;;;yEAGyE;AACzE,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BtE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,oBAAoB,CAAC,EACpG,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,MAAM,EAC1B,GAAG,EAAE,gBAAgB,GACpB,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAQvC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,EAC1B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC7D,OAAO,CAMT;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAChC,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,2EAA2E;IAC3E,YAAY,IAAI,MAAM,CAAC,OAAO,CAAC;CAChC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA4XvF"}
|
|
@@ -14,7 +14,9 @@ const node_child_process_1 = require("node:child_process");
|
|
|
14
14
|
const fs = tslib_1.__importStar(require("node:fs"));
|
|
15
15
|
const http = tslib_1.__importStar(require("node:http"));
|
|
16
16
|
const path = tslib_1.__importStar(require("node:path"));
|
|
17
|
+
const node_util_1 = require("node:util");
|
|
17
18
|
const discovery_1 = require("./discovery");
|
|
19
|
+
const pod_env_1 = require("./pod-env");
|
|
18
20
|
const types_1 = require("./types");
|
|
19
21
|
/**
|
|
20
22
|
* The east-west env a pod needs to call ANOTHER service's `internal.<host>` route (memberships, settings,
|
|
@@ -47,6 +49,14 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
47
49
|
// degraded watcher missed it. We detect a set change — NOT a content change — by a cheap order-independent
|
|
48
50
|
// signature over source file PATHS (count + xor of per-path hashes): adding/removing a path flips the
|
|
49
51
|
// signature; editing a file's CONTENTS does not, so ordinary saves never trigger a recycle.
|
|
52
|
+
// RUNTIME OUTPUT IS NOT SOURCE. The hardcoded list below can only ever name the conventional output dirs;
|
|
53
|
+
// a workspace whose app WRITES into some other gitignored dir under the root would otherwise read every
|
|
54
|
+
// write as "a dev added a source file" and recycle every pod. Worked failure (foodguard, 2026-07-28): the
|
|
55
|
+
// engine's local artifact store defaults to `./artifacts` at the workspace root, so each run's
|
|
56
|
+
// `publish_pack` added pack-manifest + source-snapshot `.json` → the set flipped → the sweeper SIGTERMed all
|
|
57
|
+
// four vite pods → a ~12-18s `gateway.unavailable` 502 window per run (201 dashboard recycles in one
|
|
58
|
+
// session, and it crossed workspaces: the sweeper's viteChildren span every REGISTERED workspace while the
|
|
59
|
+
// scan only walks the daemon host's root). So the set is filtered by git's OWN ignore verdict too.
|
|
50
60
|
const SRC_EXCLUDE = new Set(['node_modules', 'dist', 'tmp', 'coverage', 'build', 'out', 'target']);
|
|
51
61
|
const SRC_EXT = new Set([
|
|
52
62
|
'.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.css', '.scss', '.sass', '.less',
|
|
@@ -61,12 +71,32 @@ function fnv1a(s) {
|
|
|
61
71
|
}
|
|
62
72
|
return h >>> 0;
|
|
63
73
|
}
|
|
74
|
+
const execFileP = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
75
|
+
/** The repo-relative paths git IGNORES — directories carry a trailing `/` (git's `--directory` collapses a
|
|
76
|
+
* wholly-ignored dir), files do not. ONE `git ls-files` per scan (~80ms on a 2.6k-file workspace, off the
|
|
77
|
+
* event loop) buys exact gitignore semantics — nested `.gitignore`, `.git/info/exclude`, global excludes —
|
|
78
|
+
* with no new dependency and no hand-rolled glob matcher. A partially-ignored dir isn't collapsed, so its
|
|
79
|
+
* individual ignored files are listed and filtered per-file instead. Fails OPEN to an empty set (git absent,
|
|
80
|
+
* not a repo, timeout) → the hardcoded `SRC_EXCLUDE` list alone still applies, exactly as before. */
|
|
81
|
+
async function gitIgnoredPaths(root) {
|
|
82
|
+
try {
|
|
83
|
+
const { stdout } = await execFileP('git', ['ls-files', '--others', '--directory', '--ignored', '--exclude-standard', '-z'], { cwd: root, maxBuffer: 32 * 1024 * 1024, timeout: 10_000, windowsHide: true });
|
|
84
|
+
return new Set(stdout.split('\0').filter(Boolean)); // -z → NUL-separated, never git's quoted-path form
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return new Set();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
64
90
|
/** Bounded, async, non-blocking walk of the workspace source tree → a signature of the file SET
|
|
65
|
-
* (`<count>:<xor-of-path-hashes>`). Skips node_modules/dist/build/dotdirs + `*-devserver` sock dirs
|
|
66
|
-
*
|
|
91
|
+
* (`<count>:<xor-of-path-hashes>`). Skips node_modules/dist/build/dotdirs + `*-devserver` sock dirs + every
|
|
92
|
+
* GITIGNORED path (runtime output is not source — see `SRC_EXCLUDE`), and only counts source-extension
|
|
93
|
+
* files. Order-independent (readdir order irrelevant) and null-safe. */
|
|
67
94
|
async function sourceSetSignature(root) {
|
|
68
95
|
let count = 0;
|
|
69
96
|
let xor = 0;
|
|
97
|
+
const ignored = await gitIgnoredPaths(root);
|
|
98
|
+
// git speaks posix-relative; `path.relative` yields `\` on win32 — normalize before every lookup.
|
|
99
|
+
const rel = (abs) => path.relative(root, abs).split(path.sep).join('/');
|
|
70
100
|
const walk = async (dir) => {
|
|
71
101
|
if (count > SCAN_FILE_CAP)
|
|
72
102
|
return;
|
|
@@ -81,17 +111,22 @@ async function sourceSetSignature(root) {
|
|
|
81
111
|
if (count > SCAN_FILE_CAP)
|
|
82
112
|
return;
|
|
83
113
|
const name = e.name;
|
|
114
|
+
const abs = path.join(dir, name);
|
|
84
115
|
if (e.isDirectory()) {
|
|
85
116
|
if (name.startsWith('.') || SRC_EXCLUDE.has(name) || name.endsWith('-devserver'))
|
|
86
117
|
continue;
|
|
87
|
-
|
|
118
|
+
if (ignored.has(`${rel(abs)}/`))
|
|
119
|
+
continue; // a gitignored output dir (foodguard's `artifacts/`)
|
|
120
|
+
await walk(abs);
|
|
88
121
|
}
|
|
89
122
|
else if (e.isFile()) {
|
|
90
123
|
const dot = name.lastIndexOf('.');
|
|
91
124
|
if (dot <= 0 || !SRC_EXT.has(name.slice(dot)))
|
|
92
125
|
continue;
|
|
126
|
+
if (ignored.has(rel(abs)))
|
|
127
|
+
continue; // a gitignored file in a tracked dir (generated reports)
|
|
93
128
|
count += 1;
|
|
94
|
-
xor ^= fnv1a(
|
|
129
|
+
xor ^= fnv1a(abs);
|
|
95
130
|
}
|
|
96
131
|
}
|
|
97
132
|
};
|
|
@@ -248,7 +283,11 @@ function createServiceLayer(rt, obs) {
|
|
|
248
283
|
// so its dashboard shows its live traces, not the daemon's. The daemon's own services keep rt.eventFile
|
|
249
284
|
// exactly (svc.root === rt.root), so single-workspace behavior is unchanged.
|
|
250
285
|
env: {
|
|
251
|
-
|
|
286
|
+
// FOREIGN-POD ENV SCRUB (pod-env.ts): a registered workspace's pod must NOT inherit the daemon
|
|
287
|
+
// host's dotenv-loaded env (nx never overrides an already-set var, so foodguard's PG_URL/REDIS_URL
|
|
288
|
+
// riding the daemon once pointed tetros's auth+iam at foodguard's stores). The daemon's own
|
|
289
|
+
// workspace keeps the full inherit — its pods reload the same files anyway.
|
|
290
|
+
...(0, pod_env_1.podBaseEnv)(process.env, rt.root, svc.root),
|
|
252
291
|
NX_DAEMON: 'false',
|
|
253
292
|
// NX_ISOLATE_PLUGINS=false: with the daemon off (above), EVERY serve client builds the
|
|
254
293
|
// project graph itself — and with plugin isolation on (nx's default) each client spawns
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The root-level dotenv files nx (and vite) auto-load for any invocation at a workspace root. */
|
|
2
|
+
export declare const WORKSPACE_DOTENV_FILES: readonly [".env", ".env.local", ".local.env"];
|
|
3
|
+
/**
|
|
4
|
+
* Data-store pointers that must never cross a workspace boundary, even when they arrived in the daemon's
|
|
5
|
+
* env some way other than the host's dotenv (an exported shell var at gateway start). Belt-and-suspenders
|
|
6
|
+
* under the dotenv-derived scrub — kept to the class that caused the incident.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FOREIGN_POD_ENV_DENYLIST: readonly ["PG_URL", "REDIS_URL", "DATABASE_URL", "POSTGRES_URL"];
|
|
9
|
+
/**
|
|
10
|
+
* The keys a dotenv file DECLARES — assignment lines only (`KEY=…`, optional `export ` prefix), comments
|
|
11
|
+
* and malformed lines ignored. We only need the key names (what to scrub), never the values.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseDotenvKeys(content: string): Set<string>;
|
|
14
|
+
/** Every key declared across a workspace root's dotenv files (missing/unreadable files contribute nothing). */
|
|
15
|
+
export declare function workspaceDotenvKeys(root: string): Set<string>;
|
|
16
|
+
/** PURE scrub: a copy of `base` without the given keys nor the store-pointer denylist. Never mutates `base`. */
|
|
17
|
+
export declare function scrubEnv(base: NodeJS.ProcessEnv, hostKeys: ReadonlySet<string>): NodeJS.ProcessEnv;
|
|
18
|
+
/**
|
|
19
|
+
* The spawn-base env for a child of `childRoot` under a daemon hosted at `hostRoot`: the daemon's own
|
|
20
|
+
* workspace inherits untouched; a foreign workspace gets the scrubbed copy (the child's own nx/vite dotenv
|
|
21
|
+
* load then supplies THAT workspace's values, which is the whole point).
|
|
22
|
+
*/
|
|
23
|
+
export declare function podBaseEnv(base: NodeJS.ProcessEnv, hostRoot: string, childRoot: string): NodeJS.ProcessEnv;
|
|
24
|
+
//# sourceMappingURL=pod-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pod-env.d.ts","sourceRoot":"","sources":["../../../../../../libs/cluster/src/executors/gateway/runtime/pod-env.ts"],"names":[],"mappings":"AAoBA,kGAAkG;AAClG,eAAO,MAAM,sBAAsB,+CAAgD,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,kEAAmE,CAAC;AAEzG;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAS5D;AAED,+GAA+G;AAC/G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAY7D;AAED,gHAAgH;AAChH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,UAAU,CAQlG;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAG1G"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FOREIGN_POD_ENV_DENYLIST = exports.WORKSPACE_DOTENV_FILES = void 0;
|
|
4
|
+
exports.parseDotenvKeys = parseDotenvKeys;
|
|
5
|
+
exports.workspaceDotenvKeys = workspaceDotenvKeys;
|
|
6
|
+
exports.scrubEnv = scrubEnv;
|
|
7
|
+
exports.podBaseEnv = podBaseEnv;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
/**
|
|
10
|
+
* FOREIGN-POD ENV SCRUB (the cross-workspace store bleed, foodguard↔tetros 2026-07-26).
|
|
11
|
+
*
|
|
12
|
+
* `nx run gateway:serve` auto-loads the DAEMON workspace's root dotenv (`.env`, `.env.local`) into the
|
|
13
|
+
* daemon's own process env, and the spawn sites' `...process.env` handed that to EVERY child — including a
|
|
14
|
+
* REGISTERED (foreign) workspace's pods. nx's dotenv load in the child never overrides an already-set var,
|
|
15
|
+
* so the daemon host's values beat the foreign workspace's own `.env.local`: with the daemon hosted from
|
|
16
|
+
* foodguard (whose root `.env.local` declares `PG_URL`/`REDIS_URL`), tetros's auth+iam pods booted onto
|
|
17
|
+
* foodguard's Postgres/Valkey — foodguard tenants rendered inside the tetros app, and tetros's boot seed
|
|
18
|
+
* wrote rows into foodguard's database.
|
|
19
|
+
*
|
|
20
|
+
* The rule: a FOREIGN workspace's pod gets the inherited env MINUS (every key the daemon workspace's root
|
|
21
|
+
* dotenv files declare ∪ a hard denylist of data-store pointers). The daemon's OWN workspace pods keep the
|
|
22
|
+
* full inherit — their nx/vite reload the exact same files at spawn (so the scrub would change nothing),
|
|
23
|
+
* and a deliberate shell override (`PG_URL=… lensmcp gateway start`) staying live for one's own pods is
|
|
24
|
+
* ordinary env semantics. Hosting order must never matter for anyone else's pods.
|
|
25
|
+
*/
|
|
26
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
27
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
28
|
+
/** The root-level dotenv files nx (and vite) auto-load for any invocation at a workspace root. */
|
|
29
|
+
exports.WORKSPACE_DOTENV_FILES = ['.env', '.env.local', '.local.env'];
|
|
30
|
+
/**
|
|
31
|
+
* Data-store pointers that must never cross a workspace boundary, even when they arrived in the daemon's
|
|
32
|
+
* env some way other than the host's dotenv (an exported shell var at gateway start). Belt-and-suspenders
|
|
33
|
+
* under the dotenv-derived scrub — kept to the class that caused the incident.
|
|
34
|
+
*/
|
|
35
|
+
exports.FOREIGN_POD_ENV_DENYLIST = ['PG_URL', 'REDIS_URL', 'DATABASE_URL', 'POSTGRES_URL'];
|
|
36
|
+
/**
|
|
37
|
+
* The keys a dotenv file DECLARES — assignment lines only (`KEY=…`, optional `export ` prefix), comments
|
|
38
|
+
* and malformed lines ignored. We only need the key names (what to scrub), never the values.
|
|
39
|
+
*/
|
|
40
|
+
function parseDotenvKeys(content) {
|
|
41
|
+
const keys = new Set();
|
|
42
|
+
for (const raw of content.split('\n')) {
|
|
43
|
+
const line = raw.trim();
|
|
44
|
+
if (!line || line.startsWith('#'))
|
|
45
|
+
continue;
|
|
46
|
+
const m = line.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/);
|
|
47
|
+
if (m)
|
|
48
|
+
keys.add(m[1]);
|
|
49
|
+
}
|
|
50
|
+
return keys;
|
|
51
|
+
}
|
|
52
|
+
/** Every key declared across a workspace root's dotenv files (missing/unreadable files contribute nothing). */
|
|
53
|
+
function workspaceDotenvKeys(root) {
|
|
54
|
+
const keys = new Set();
|
|
55
|
+
for (const file of exports.WORKSPACE_DOTENV_FILES) {
|
|
56
|
+
let content;
|
|
57
|
+
try {
|
|
58
|
+
content = fs.readFileSync(path.join(root, file), 'utf8');
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
for (const k of parseDotenvKeys(content))
|
|
64
|
+
keys.add(k);
|
|
65
|
+
}
|
|
66
|
+
return keys;
|
|
67
|
+
}
|
|
68
|
+
/** PURE scrub: a copy of `base` without the given keys nor the store-pointer denylist. Never mutates `base`. */
|
|
69
|
+
function scrubEnv(base, hostKeys) {
|
|
70
|
+
const out = {};
|
|
71
|
+
for (const [k, v] of Object.entries(base)) {
|
|
72
|
+
if (hostKeys.has(k))
|
|
73
|
+
continue;
|
|
74
|
+
if (exports.FOREIGN_POD_ENV_DENYLIST.includes(k))
|
|
75
|
+
continue;
|
|
76
|
+
out[k] = v;
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The spawn-base env for a child of `childRoot` under a daemon hosted at `hostRoot`: the daemon's own
|
|
82
|
+
* workspace inherits untouched; a foreign workspace gets the scrubbed copy (the child's own nx/vite dotenv
|
|
83
|
+
* load then supplies THAT workspace's values, which is the whole point).
|
|
84
|
+
*/
|
|
85
|
+
function podBaseEnv(base, hostRoot, childRoot) {
|
|
86
|
+
if (path.resolve(childRoot) === path.resolve(hostRoot))
|
|
87
|
+
return base;
|
|
88
|
+
return scrubEnv(base, workspaceDotenvKeys(hostRoot));
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/cluster",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.30",
|
|
4
4
|
"description": "Run your Nx workspace as a local production cluster: pods on unix sockets with true HMR, one https gateway with per-project domains, scale-from-zero, autoscale, idle-kill, local-CA TLS — observed by the LensMCP lens.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@lensmcp/node-instrumentation": "1.16.
|
|
69
|
-
"@lensmcp/nx-plugin": "1.16.
|
|
68
|
+
"@lensmcp/node-instrumentation": "1.16.30",
|
|
69
|
+
"@lensmcp/nx-plugin": "1.16.30",
|
|
70
70
|
"fork-ts-checker-webpack-plugin": "^9.0.0",
|
|
71
71
|
"glob": "^11.0.0",
|
|
72
72
|
"http-proxy": "^1.18.0",
|