Skip to content

Commit 6981d5d

Browse files
committed
[fix.docs.sigma.D9+] keep runtime environments outside the architecture twin
Auto-discovery must absorb new first-party source without treating a 6.4 GB conda prefix as application architecture. Git now excludes classified external roots before capture, preventing 175k runtime paths from overflowing the watcher while preserving automatic discovery for new code roots.
1 parent 4474a16 commit 6981d5d

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎scripts/build_digital_twin.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ def layer_for(path: str) -> str:
9393

9494
def discovered_files() -> list[pathlib.Path]:
9595
"""Discover tracked and not-yet-tracked first-party files from one ownership policy."""
96-
ok, raw = run(['git', 'ls-files', '--cached', '--others', '--exclude-standard', '-z'])
96+
external_pathspecs = [pattern for root in SCOPE['external_roots']
97+
for pattern in (f':(exclude){root.rstrip("/")}',
98+
f':(exclude){root.rstrip("/")}/**')]
99+
# Reject external runtime trees during Git enumeration, not after capture.
100+
# Otherwise a large untracked environment can overflow the subprocess buffer
101+
# before the semantic ownership filter ever sees its paths.
102+
ok, raw = run(['git', 'ls-files', '--cached', '--others', '--exclude-standard',
103+
'-z', '--', *external_pathspecs], timeout=30)
97104
if not ok:
98105
ok, raw = run(['rg', '--files', '-0'])
99106
if not ok:

‎scripts/digital_twin_scope.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
],
4747
"external_roots": [
4848
".git", ".vscode", "_archive", "build", "data", "examples", "lib", "node_modules",
49+
"openfe-runtime-v2",
4950
"src/apps.reference.viewer-demos.vendored-readonly",
5051
"src/cli.tools.command-line.vendored-readonly",
5152
"src/examples.reference.mini-demos.vendored-readonly",

‎scripts/extract_ts_digital_twin.mjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ const ROOT = path.resolve(import.meta.dirname, '..');
99
const scope = JSON.parse(fs.readFileSync(path.join(ROOT, 'scripts/digital_twin_scope.json'), 'utf8'));
1010
const roots = scope.include_roots.map(x => x.replace(/\/$/, ''));
1111
const externalRoots = scope.external_roots.map(x => x.replace(/\/$/, ''));
12+
const externalPathspecs = externalRoots.flatMap(root => [
13+
`:(exclude)${root}`,
14+
`:(exclude)${root}/**`,
15+
]);
1216
const rootFiles = new Set(scope.include_root_files);
1317
const inScope = rel => (rootFiles.has(rel) || roots.some(root => rel === root || rel.startsWith(`${root}/`))
1418
|| (scope.auto_include_code_extensions.includes(path.extname(rel))
1519
&& !externalRoots.some(root => rel === root || rel.startsWith(`${root}/`))))
1620
&& !scope.exclude_fragments.some(fragment => `/${rel}`.includes(fragment))
1721
&& !scope.exclude_suffixes.some(suffix => rel.endsWith(suffix));
18-
const discovered = execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'],
22+
const discovered = execFileSync('git', [
23+
'ls-files', '--cached', '--others', '--exclude-standard', '-z', '--', ...externalPathspecs,
24+
],
1925
{ cwd: ROOT, encoding: 'utf8' }).split('\0').filter(Boolean);
2026
const files = discovered.filter(rel => inScope(rel) && /\.(?:tsx?|m?js)$/.test(rel) && !/\.d\.ts$/.test(rel))
2127
.map(rel => path.join(ROOT, rel)).filter(file => fs.existsSync(file));

‎scripts/watch_digital_twin.mjs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const scope = JSON.parse(fs.readFileSync(path.join(ROOT, 'scripts/digital_twin_s
1010
const rootFiles = new Set(scope.include_root_files);
1111
const roots = scope.include_roots.map(x => x.replace(/\/$/, ''));
1212
const externalRoots = scope.external_roots.map(x => x.replace(/\/$/, ''));
13+
const externalPathspecs = externalRoots.flatMap(root => [
14+
`:(exclude)${root}`,
15+
`:(exclude)${root}/**`,
16+
]);
1317
const outputs = new Set(scope.generated_outputs);
1418
let timer;
1519
let running = false;
@@ -60,7 +64,12 @@ function schedule(reason) {
6064
}
6165

6266
function sourceFiles() {
63-
const raw = execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'], {
67+
// Exclude classified external roots inside Git itself. Filtering only after
68+
// capture made a 6.4 GB conda runtime emit 175k paths and overflow maxBuffer
69+
// before inScope() had a chance to reject a single one.
70+
const raw = execFileSync('git', [
71+
'ls-files', '--cached', '--others', '--exclude-standard', '-z', '--', ...externalPathspecs,
72+
], {
6473
cwd: ROOT, encoding: 'buffer', maxBuffer: 32 * 1024 * 1024,
6574
});
6675
return raw.toString().split('\0').filter(Boolean).map(normalized).filter(inScope).sort();
@@ -88,9 +97,10 @@ function changedFiles(previous, current) {
8897

8998
if (process.argv.includes('--selftest')) {
9099
const probes = ['backend/new_module.py', 'src/app/new-view.ts', 'future-dir/new.py', 'bin/new-command',
91-
'src/mol-plugin/state.ts', 'docs/architecture/dirac-digital-twin.json'];
100+
'src/mol-plugin/state.ts', 'openfe-runtime-v2/pkgs/tool/run.py',
101+
'docs/architecture/dirac-digital-twin.json'];
92102
const verdicts = probes.map(file => ({ file, watched: inScope(file) }));
93-
const expected = [true, true, true, true, false, false];
103+
const expected = [true, true, true, true, false, false, false];
94104
if (verdicts.some((item, i) => item.watched !== expected[i])) {
95105
process.stderr.write(`${JSON.stringify(verdicts)}\n`);
96106
process.exit(1);

0 commit comments

Comments
 (0)