Files
Brennan Benson fb71c6ae4c ci(ratchets): fail PRs that add callers of sync helpers on Electron main (#43399)
* ci(ratchets): guard callers of sync helpers on main and skip worker-only modules

The main-thread ratchets counted blocking call syntax per file, so a new
caller of an existing sync helper in another file (env store reads, Codex
transcript cursor, durable secure writes) passed CI. A new ratchet counts
references to functions that make a synchronous fs, child_process or
SQLite call. Modules imported only by worker/utility entries are no longer
charged as main-thread work, and SQLite pragma()/transaction() now count.

* ci(ratchets): follow sync helpers two levels so timer and handler callers count

* ci(ratchets): guard event-loop entries, follow default exports and barrels, carry rows across renames

* test(ratchets): keep the shared import when checking a guarded entry

* ci(ratchets): shadow helpers only by parameters in scope, fail on unreadable entry lists, keep transaction results out of SQLite receivers

* ci(ratchets): match helper names file-wide (council ruling), harden entry discovery, count transaction modes

* Merge origin/main; baseline main's new WSL helper callers

* fix(ratchets): preserve helper exports and fail closed on missing roots

* Keep main's note on the worker large-send log baseline row
2026-11-17 14:49:39 -08:00

27 lines
862 B
JavaScript

import { existsSync, readFileSync } from 'node:fs'
import { isTestOnlySourcePath } from './test-only-source-path.mjs'
// Entry files are exempt here; main-blocking-import-graph.mjs also exempts modules only these entries import.
const entries = JSON.parse(
readFileSync(new URL('../../../main-blocking-worker-entries.json', import.meta.url), 'utf8')
)
export const MAIN_BLOCKING_WORKER_ENTRIES = entries
for (const [file, reason] of Object.entries(entries)) {
if (
!file.startsWith('src/main/') ||
!reason.trim() ||
!existsSync(new URL(`../../../../${file}`, import.meta.url))
) {
throw new Error(`Invalid worker entry: ${file}`)
}
}
export function isMainBlockingSource(file) {
return (
/\.[cm]?[jt]sx?$/.test(file) &&
!/\.d\.[cm]?ts$/.test(file) &&
!isTestOnlySourcePath(file) &&
!Object.hasOwn(entries, file)
)
}