rtl-analyzer 0.3.0 → 0.4.0

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.
@@ -61,8 +61,18 @@ export async function initializeOriginalPreview(root, application) {
61
61
  throw Error('ORIGINAL_PREVIEW_STARTUP_FAILED');
62
62
  }
63
63
  }
64
+ /** Signals every owned original runtime and waits for exit (SIGKILL after 2 s). Synchronous callers may ignore the promise. */
64
65
  export function stopOwnedOriginalPreviews() {
66
+ return Promise.all([...children.values()].map(child => new Promise(resolve => {
67
+ if (child.exitCode !== null || child.signalCode !== null)
68
+ return resolve();
69
+ const timer = setTimeout(() => { signalOwnedRuntime(child, 'SIGKILL'); resolve(); }, 2000);
70
+ child.once('exit', () => { clearTimeout(timer); resolve(); });
71
+ signalOwnedRuntime(child);
72
+ }))).then(() => undefined);
73
+ }
74
+ /** Synchronous last resort for process exit. */
75
+ export function signalOwnedOriginalPreviews(signal = 'SIGKILL') {
65
76
  for (const child of children.values())
66
- if (child.exitCode === null)
67
- signalOwnedRuntime(child);
77
+ signalOwnedRuntime(child, signal);
68
78
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A cold Vite dev server may reload once shortly after the first load ("optimized dependencies changed"),
3
+ * destroying the page's execution context mid-evaluation. Re-run page work that raced such a reload.
4
+ * Only that specific failure is retried; every other error, and the final attempt, propagates unchanged.
5
+ */
6
+ export async function retryAcrossNavigation(operation, attempts = 3) {
7
+ for (let attempt = 1;; attempt++) {
8
+ try {
9
+ return await operation();
10
+ }
11
+ catch (error) {
12
+ if (attempt >= attempts || !/Execution context was destroyed/.test(error instanceof Error ? error.message : String(error)))
13
+ throw error;
14
+ await new Promise(resolve => setTimeout(resolve, 250));
15
+ }
16
+ }
17
+ }
@@ -74,7 +74,7 @@ export function validatePolicy(input, text) {
74
74
  fail(p, 'expected lowercase SHA-256 digest'); };
75
75
  const rule = (v, p) => { if (!ruleIds.has(str(v, p)))
76
76
  fail(p, 'rule is not supported by this scanner', 'POLICY_UNSUPPORTED'); };
77
- const top = object(input, '', ['schemaVersion', 'generatedStyleOwner', 'ownership', 'approvals', 'exceptions', 'issueBindings', 'dynamicExceptions', 'roles'], ['ownerOverrides']);
77
+ const top = object(input, '', ['schemaVersion', 'generatedStyleOwner', 'ownership', 'approvals', 'exceptions', 'issueBindings', 'dynamicExceptions', 'roles'], ['ownerOverrides', 'cssProposals']);
78
78
  if (top.schemaVersion !== 1)
79
79
  fail('/schemaVersion', 'only schemaVersion 1 is supported', 'POLICY_UNSUPPORTED');
80
80
  enumValue(top.generatedStyleOwner, '/generatedStyleOwner', ['mui-generated', 'unknown']);
@@ -90,15 +90,16 @@ export function validatePolicy(input, text) {
90
90
  issueBindings: [['ruleId', 'path', 'contextIncludes', 'issueId'], ['originalIncludes']],
91
91
  dynamicExceptions: [['path', 'property', 'valueDigest', 'sourceDigest', 'reason'], []],
92
92
  roles: [['kind', 'path', 'className'], []],
93
+ cssProposals: [['path', 'context', 'property', 'value', 'kind', 'sourceDigest'], []],
93
94
  ownerOverrides: [['path', 'context', 'owner', 'reason'], []],
94
95
  };
95
96
  const identities = {
96
97
  approvals: ['path', 'context', 'property', 'value'], exceptions: ['ruleId', 'path', 'context', 'originalDigest'],
97
98
  issueBindings: ['ruleId', 'path', 'contextIncludes', 'originalIncludes', 'issueId'],
98
- dynamicExceptions: ['path', 'property', 'valueDigest'], roles: ['kind', 'path', 'className'], ownerOverrides: ['path', 'context'],
99
+ dynamicExceptions: ['path', 'property', 'valueDigest'], roles: ['kind', 'path', 'className'], ownerOverrides: ['path', 'context'], cssProposals: ['path', 'context', 'property', 'value'],
99
100
  };
100
101
  for (const [name, [required, optional]] of Object.entries(shapes)) {
101
- if (name === 'ownerOverrides' && !Object.hasOwn(top, name))
102
+ if ((name === 'ownerOverrides' || name === 'cssProposals') && !Object.hasOwn(top, name))
102
103
  continue;
103
104
  const records = top[name];
104
105
  if (!Array.isArray(records) || records.length > 10000)
@@ -118,6 +119,8 @@ export function validatePolicy(input, text) {
118
119
  enumValue(entry.owner, `${p}/owner`, owners);
119
120
  if ('category' in entry)
120
121
  enumValue(entry.category, `${p}/category`, ['INTENTIONAL_LTR', 'INFORMATIONAL']);
122
+ if (name === 'cssProposals')
123
+ enumValue(entry.kind, `${p}/kind`, ['inline-edge', 'logical-corners', 'dom-order', 'mirror-offset']);
121
124
  if (name === 'roles')
122
125
  enumValue(entry.kind, `${p}/kind`, ['brand']);
123
126
  if (name === 'dynamicExceptions')
@@ -1,8 +1,9 @@
1
- import { initializeOriginalPreview, stopOwnedOriginalPreviews } from './original-preview-runtime.js';
1
+ import { initializeOriginalPreview, signalOwnedOriginalPreviews, stopOwnedOriginalPreviews } from './original-preview-runtime.js';
2
2
  import { loadPreviewConfiguration } from './preview-configuration.js';
3
3
  import { contextualPreview } from './contextual-preview.js';
4
4
  import { verifiedSourceTransition, reconcileSourceRuntimes, reconcileSelectedFinding } from './source-context.js';
5
5
  import { scan } from './scan.js';
6
+ import { directionRequirement, proposeTransformation, sameSupportedPatch } from './transformations.js';
6
7
  import { toSchemaV2Presentation } from './presentation-adapter.js';
7
8
  import { toDashboardData } from './dashboard-data.js';
8
9
  import { extractSourceSnippets } from './source-snippets.js';
@@ -13,7 +14,7 @@ import { join, relative, resolve, sep } from 'node:path';
13
14
  import { createHash } from 'node:crypto';
14
15
  import { lstat, readFile } from 'node:fs/promises';
15
16
  import { PREVIEW_COMPANION_ORIGIN, previewManifest, validatedPreviewRoute } from './preview-manifest.js';
16
- import { applyReviewPatch, createReviewSession, disposeReviewSession, reviewSessionComparison, reviewSessionDiff, startCandidateRuntime, stopCandidateRuntime, validateProjectSourcePath, validateReviewIdentity, REVIEW_SOURCE } from './review-session.js';
17
+ import { applyReviewPatch, createReviewSession, disposeReviewSession, signalAllCandidateRuntimes, stopAllCandidateRuntimes, reviewSessionComparison, reviewSessionDiff, startCandidateRuntime, stopCandidateRuntime, validateProjectSourcePath, validateReviewIdentity, REVIEW_SOURCE } from './review-session.js';
17
18
  import { DEFAULT_REVIEW_STORE_PATH, ReviewRecordStore } from './review-store.js';
18
19
  import { DEFAULT_EVIDENCE_STORE_PATH, EvidenceSnapshotStore } from './evidence-store.js';
19
20
  import { ApplyAuditStore, ControlledApplyService } from './controlled-apply.js';
@@ -254,7 +255,7 @@ const server = createServer(async (request, response) => {
254
255
  try {
255
256
  if (request.method === 'GET' && url.pathname === '/review/workflows' && url.searchParams.get('history') === '1')
256
257
  return send(response, 200, { workflows: await workflowStore.exclusive(async () => workflowStore.list().map(w => workflowStore.view(w))), projectRoot });
257
- const match = url.pathname.match(/^\/review\/workflows(?:\/([^/]+)(?:\/(change|runtime|validate|apply|rollback|preview|resume|prepare-preview))?)?$/);
258
+ const match = url.pathname.match(/^\/review\/workflows(?:\/([^/]+)(?:\/(change|runtime|validate|apply|rollback|preview|resume|remaining|prepare-preview|prepare-batch|approve-batch))?)?$/);
258
259
  if (!match)
259
260
  throw new Error('WORKFLOW_ROUTE_NOT_FOUND');
260
261
  const id = match[1], action = match[2];
@@ -270,17 +271,23 @@ const server = createServer(async (request, response) => {
270
271
  return workflowStore.begin(input);
271
272
  if (action === 'change')
272
273
  return workflowStore.change(id, input.findingId, input);
274
+ if (action === 'prepare-batch')
275
+ return workflowStore.prepareBatch(id);
276
+ if (action === 'approve-batch')
277
+ return workflowStore.approveBatch(id, input.findingIds);
273
278
  if (action === 'prepare-preview')
274
279
  return workflowStore.preparePreview(id, input);
275
280
  if (action === 'runtime') {
276
281
  return workflowStore.runtime(id, input.application);
277
282
  }
278
283
  if (action === 'validate')
279
- return workflowStore.validate(id);
284
+ return input.operationId ? workflowStore.runOperation(id, 'validate', input.operationId, () => workflowStore.validate(id)) : workflowStore.validate(id);
280
285
  if (action === 'apply')
281
- return workflowStore.apply(id, input.confirmation);
286
+ return input.operationId ? workflowStore.runOperation(id, 'apply', input.operationId, () => workflowStore.apply(id, input.confirmation)) : workflowStore.apply(id, input.confirmation);
282
287
  if (action === 'rollback')
283
288
  return workflowStore.rollback(id, input.confirmation);
289
+ if (action === 'remaining')
290
+ return workflowStore.reviewRemaining(id);
284
291
  if (action === 'resume')
285
292
  return workflowStore.resumeAfterRollback(id);
286
293
  throw new Error('WORKFLOW_ACTION_REQUIRED');
@@ -508,7 +515,15 @@ const server = createServer(async (request, response) => {
508
515
  }
509
516
  if (url.pathname === '/review/apply' && request.method === 'POST') {
510
517
  try {
518
+ const report = await scan(cwd());
511
519
  const input = await body(request);
520
+ if (!report.complete)
521
+ throw new Error('INCOMPLETE_SCAN_REQUIRES_MANUAL_RESOLUTION');
522
+ if (report.inputDigest !== input.identity.inputDigest || report.policyDigest !== input.identity.policyDigest)
523
+ throw new Error('STALE_PROJECT_IDENTITY');
524
+ const currentFinding = report.findings.find(f => f.id === input.identity.findingId && f.path === input.identity.sourcePath);
525
+ if (!currentFinding || directionRequirement(currentFinding) !== 'independent')
526
+ throw new Error('LEGACY_DIRECTION_DEPENDENT_APPLY_UNSUPPORTED');
512
527
  const record = reviewStore.get(input.identity);
513
528
  if (!record)
514
529
  return send(response, 400, { error: 'APPROVED_REVIEW_REQUIRED' });
@@ -516,6 +531,9 @@ const server = createServer(async (request, response) => {
516
531
  const approved = evidence.find(x => (x.decision === 'Approved' || x.decision === 'Ready for Review') && x.patch);
517
532
  if (!approved?.patch)
518
533
  return send(response, 400, { error: 'PATCH_METADATA_REQUIRED' });
534
+ const proposal = proposeTransformation(currentFinding, await readFile(await validateProjectSourcePath(cwd(), currentFinding.path), 'utf8'));
535
+ if (!sameSupportedPatch(proposal.patch, approved.patch))
536
+ throw new Error('UNSUPPORTED_CANDIDATE_PATCH');
519
537
  const receipt = await applyService.apply({ identity: input.identity, confirmation: input.confirmation, reviewRecord: record, evidence, patch: approved.patch });
520
538
  return send(response, 200, { receipt, state: 'APPLIED' });
521
539
  }
@@ -614,8 +632,18 @@ const server = createServer(async (request, response) => {
614
632
  return send(response, 404, { error: 'NOT_FOUND' });
615
633
  });
616
634
  let shuttingDown = false;
617
- const shutdown = async () => { if (shuttingDown)
618
- return; shuttingDown = true; stopOwnedOriginalPreviews(); await workflowStore.shutdown(); await Promise.all([...sessions.values()].map(session => disposeReviewSession(session).catch(() => undefined))); server.close(() => process.exit(0)); setTimeout(() => process.exit(1), 5000).unref(); };
619
- process.once('SIGTERM', shutdown);
620
- process.once('SIGINT', shutdown);
635
+ // Idempotent: npm/npx forward the terminal's SIGINT, so the companion routinely receives it twice. A second signal must not abort the first shutdown.
636
+ const shutdown = async () => {
637
+ if (shuttingDown)
638
+ return;
639
+ shuttingDown = true;
640
+ setTimeout(() => process.exit(1), 8000).unref();
641
+ await Promise.allSettled([stopOwnedOriginalPreviews(), workflowStore.shutdown(), stopAllCandidateRuntimes(), ...[...sessions.values()].map(session => disposeReviewSession(session))]);
642
+ server.close(() => process.exit(0));
643
+ setTimeout(() => process.exit(1), 3000).unref();
644
+ };
645
+ for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP'])
646
+ process.on(signal, shutdown);
647
+ // Last resort for any exit path: never leave an owned runtime process group behind.
648
+ process.on('exit', () => { signalOwnedOriginalPreviews(); signalAllCandidateRuntimes(); });
621
649
  server.listen(port, host, () => console.log(`RTL preview companion listening on ${host}:${port}`));
@@ -3,6 +3,7 @@ import { resolve, relative, isAbsolute, join } from 'node:path';
3
3
  import { hash } from './model.js';
4
4
  import { exampleContextMapping } from './example-preview-mappings.js';
5
5
  import postcss from 'postcss';
6
+ import ts from 'typescript';
6
7
  export const PREVIEW_CONFIGURATION = 'rtl-preview.config.json';
7
8
  const fail = (message) => { throw Error('PREVIEW_CONFIGURATION_INVALID: ' + message); };
8
9
  const object = (x) => !!x && typeof x === 'object' && !Array.isArray(x);
@@ -43,8 +44,17 @@ catch (e) {
43
44
  export async function previewConfigurationDigest(root) { const raw = await configurationText(root); return raw === undefined ? hash('') : hash('preview-config\0' + raw); }
44
45
  export async function loadPreviewConfiguration(root) {
45
46
  const raw = await configurationText(root);
46
- if (raw === undefined)
47
- return { schemaVersion: 1, applications: {}, mappings: [], digest: hash('') };
47
+ if (raw === undefined) {
48
+ let builtinAtlas = false;
49
+ try {
50
+ const pkg = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
51
+ await previewFile(root, 'apps/invoicing/src/components/InvoiceTable.tsx');
52
+ await previewFile(root, 'apps/procurement/vite.config.ts');
53
+ builtinAtlas = pkg.name === 'atlas-invoice';
54
+ }
55
+ catch { }
56
+ return { schemaVersion: 1, applications: {}, mappings: [], digest: hash(''), builtinAtlas };
57
+ }
48
58
  let x;
49
59
  try {
50
60
  x = JSON.parse(raw);
@@ -116,19 +126,36 @@ export async function loadPreviewConfiguration(root) {
116
126
  fail('unknown/duplicate route reference');
117
127
  refs.add(ref.application + ':' + ref.route);
118
128
  }
119
- mappings.push(m);
129
+ const binding = m;
130
+ if (m.sourceSelector && !m.source.endsWith('.css')) {
131
+ if (!/^[.#][a-zA-Z_][\w-]*$/.test(String(m.sourceSelector)) || !/[.]tsx$/.test(String(m.source)))
132
+ fail('JSX sourceSelector requires a simple class or id selector and a TSX source');
133
+ const source = await readFile(await previewFile(root, String(m.source)), 'utf8'), sf = ts.createSourceFile(String(m.source), source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX), expressions = [];
134
+ const selector = String(m.sourceSelector), attribute = selector[0] === '.' ? 'className' : 'id', value = selector.slice(1);
135
+ const matches = (node) => node.attributes.properties.some(a => ts.isJsxAttribute(a) && a.name.getText(sf) === attribute && a.initializer && ts.isStringLiteral(a.initializer) && (attribute === 'className' ? a.initializer.text.split(/\s+/).includes(value) : a.initializer.text === value));
136
+ const visit = (node, owned = false) => { const next = ts.isJsxElement(node) ? matches(node.openingElement) || owned : owned; if (next && ts.isJsxExpression(node) && node.expression)
137
+ expressions.push({ text: node.getText(sf), start: node.getStart(sf), end: node.getEnd() }); ts.forEachChild(node, child => visit(child, next)); };
138
+ visit(sf);
139
+ binding.sourceExpressions = expressions;
140
+ }
141
+ mappings.push(binding);
120
142
  }
121
143
  return { schemaVersion: 1, applications, mappings, digest: hash('preview-config\0' + raw) };
122
144
  }
123
145
  export function configuredMapping(f, config) {
124
- const candidates = config.mappings.filter(m => m.source === f.path && (!m.context || m.context === f.context) && (!m.sourceSelector || f.sourceMechanism === 'css' && f.context === 'stylesheet/' + m.sourceSelector));
146
+ const candidates = config.mappings.filter(m => m.source === f.path && (!m.context || m.context === f.context) && (!m.sourceSelector || (f.sourceMechanism === 'css' ? (m.context ? f.context === m.context : f.context === 'stylesheet/' + m.sourceSelector) : m.sourceExpressions?.some(e => e.text === f.original && e.start === f.range.start.offset && e.end === f.range.end.offset))));
125
147
  if (candidates.length > 1)
126
148
  return { kind: 'unresolved', label: 'Ambiguous configured mapping', selector: '', routes: [], evidence: [], limitation: 'More than one configured locator matches this source context; choose one explicit source binding.' };
127
- if (!candidates.length)
128
- return exampleContextMapping(f);
149
+ if (!candidates.length) {
150
+ if (config.digest === hash('') && config.builtinAtlas)
151
+ return exampleContextMapping(f);
152
+ if (Object.keys(config.applications).length)
153
+ return { kind: 'unresolved', label: 'No configured source binding', selector: '', routes: [], evidence: [], limitation: 'This finding has no exact source-to-element binding in rtl-preview.config.json. Add a binding for its source context and rendered target. No built-in application mapping was used.' };
154
+ return { kind: 'unresolved', label: 'No mapped preview for this finding.', selector: '', routes: [], evidence: [], limitation: 'No mapped preview for this finding.' };
155
+ }
129
156
  const m = candidates[0], routes = m.routes.map(ref => { const app = config.applications[ref.application], r = app.routes.find(r => r.id === ref.route); return { id: ref.application + ':' + r.id, application: ref.application, path: r.path, label: ref.application + ' · ' + r.path, urls: { ltr: r.ltr, rtl: r.rtl } }; });
130
- const mapping = { kind: 'targets', label: 'Configured source binding · runtime verification required', selector: m.targetSelector, routes, evidence: [PREVIEW_CONFIGURATION + ' · ' + m.source + ' · ' + (m.sourceSelector || m.context || 'file locator')], configured: true, sourceSelector: m.sourceSelector, limitation: 'Configuration declares this relationship; the real route, loaded source rule and rendered target must be checked before Verified.' };
131
- if (m.sourceSelector) {
157
+ const mapping = { kind: 'targets', label: 'Configured source binding · runtime verification required', selector: m.targetSelector, routes, evidence: [PREVIEW_CONFIGURATION + ' · ' + m.source + ' · ' + (m.sourceSelector || m.context || 'file locator')], configured: true, sourceSelector: f.sourceMechanism === 'css' ? m.sourceSelector : undefined, limitation: 'Configuration declares this relationship; the real route, loaded source rule and rendered target must be checked before Verified.' };
158
+ if (m.sourceSelector && f.sourceMechanism === 'css') {
132
159
  try {
133
160
  const root = postcss.parse('.probe{' + f.original + '}');
134
161
  const decl = root.first?.type === 'rule' ? root.first.nodes.find(n => n.type === 'decl') : undefined;
@@ -31,7 +31,8 @@ export async function writePreviewRuntimeConfig(root, identity, options = {}) {
31
31
  runtimeIdentity.policyDigest = report.policyDigest;
32
32
  for (const path of report.files)
33
33
  sourceHashes[path] = createHash('sha256').update(await readFile(join(root, path))).digest('hex');
34
- bindings = report.findings.map(f => ({ finding: { id: f.id, path: f.path }, mapping: configuredMapping(f, configuration) })).filter(b => b.mapping.routes.some(r => r.application === application));
34
+ const bindingConfiguration = options.contextRoot ? await loadPreviewConfiguration(options.contextRoot) : configuration;
35
+ bindings = report.findings.map(f => ({ finding: { id: f.id, path: f.path }, mapping: configuredMapping(f, bindingConfiguration) })).filter(b => b.mapping.routes.some(r => r.application === application));
35
36
  // Candidate CSS inspection reuses the shared proposal; no second transformation inventory.
36
37
  if (options.contextRoot && options.contextRoot !== root) {
37
38
  const { proposeTransformation } = await import('./transformations.js');
@@ -39,17 +40,20 @@ export async function writePreviewRuntimeConfig(root, identity, options = {}) {
39
40
  const f = report.findings.find(f => f.id === binding.finding.id);
40
41
  if (!binding.mapping.configured || !binding.mapping.css)
41
42
  continue;
42
- const actual = postcss.parse(await readFile(join(root, f.path), 'utf8'));
43
- let present = false;
44
- actual.walkRules(r => { if (r.selector === binding.mapping.sourceSelector && r.nodes.some(d => d.type === 'decl' && d.prop === binding.mapping.css.property))
45
- present = true; });
46
- if (present)
47
- continue;
48
43
  try {
49
44
  const proposal = proposeTransformation(f, await readFile(join(options.contextRoot, f.path), 'utf8'));
50
45
  const replacement = postcss.parse('.probe{' + proposal.patch.replacement + '}').first;
51
- const declaration = replacement?.type === 'rule' ? replacement.nodes.find(d => d.type === 'decl') : undefined;
52
- if (declaration?.type === 'decl')
46
+ const declarations = replacement?.type === 'rule' ? replacement.nodes.filter(d => d.type === 'decl') : [];
47
+ const declaration = declarations[0];
48
+ if (!declaration)
49
+ continue;
50
+ const actual = postcss.parse(await readFile(join(root, f.path), 'utf8'));
51
+ let present = false;
52
+ actual.walkRules(r => {
53
+ if (r.selector === binding.mapping.sourceSelector && declarations.every(expected => r.nodes.some(d => d.type === 'decl' && d.prop === expected.prop && d.value === expected.value && d.important === expected.important)))
54
+ present = true;
55
+ });
56
+ if (present)
53
57
  binding.mapping.css = { ...binding.mapping.css, property: declaration.prop, value: declaration.value };
54
58
  }
55
59
  catch { /* Target binding remains independent of transformation eligibility. */ }
@@ -293,6 +293,16 @@ export async function stopCandidateRuntime(session) {
293
293
  await Promise.all([...new Set([session.id, ...runtimes.keys(), ...runtimeStates.keys()])].filter(key => key === session.id || key.startsWith(session.id + ':')).map(key => stopRuntimeKey(session, key)));
294
294
  return { ...session, runtime: session.runtime ? { ...session.runtime, status: 'stopped' } : undefined };
295
295
  }
296
+ /** Stops every runtime this process owns, whatever session it belongs to. Waits for starts in flight so none escapes. */
297
+ export async function stopAllCandidateRuntimes() {
298
+ await Promise.allSettled([...runtimeStarts.values()]);
299
+ await Promise.allSettled([...new Set([...runtimes.keys(), ...runtimeStates.keys()])].map(key => stopRuntimeKey({}, key)));
300
+ }
301
+ /** Synchronous last resort for process exit: signal every owned runtime's process group. Never touches adopted or port-owning processes. */
302
+ export function signalAllCandidateRuntimes(signal = 'SIGKILL') {
303
+ for (const child of runtimes.values())
304
+ signalOwnedRuntime(child, signal);
305
+ }
296
306
  export async function disposeReviewSession(session) { if (!inside(await realpath(tmpdir()), await realpath(session.candidateRoot)))
297
307
  throw new Error('INVALID_REVIEW_SESSION_ROOT'); await Promise.all([...runtimeStarts].filter(([key]) => key === session.id || key.startsWith(session.id + ':')).map(([, start]) => start.catch(() => undefined))); await stopCandidateRuntime(session); await rm(session.candidateRoot, { recursive: true, force: true }); }
298
308
  export const reviewSourceDirectory = (root) => dirname(validateReviewPath(root, REVIEW_SOURCE));