chore(ratchets): count sync fs calls on Electron main and setInterval calls

Sync fs on main and fixed-cadence intervals that never settle were two of the
most common perf fix classes since September, and no gate counted them. Both
ratchets grandfather today's uses per file and fail when a file's count grows.
This commit is contained in:
Brennan Benson
2026-11-08 10:54:33 -08:00
parent fcd356ad88
commit bb5359f125
8 changed files with 835 additions and 0 deletions
+560
View File
@@ -0,0 +1,560 @@
# Synchronous node:fs calls in production src/main, per file: accessSync, appendFileSync, copyFileSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync.
# Startup-only or one-shot uses are fine to keep; per-RPC, per-spawn, per-focus or per-poll uses are the target.
# This is a RATCHET: counts may only go DOWN.
# Prune after removing calls: pnpm check:main-sync-fs-ratchet --prune
1 src/main/agent-hooks/first-work-rename-runtime.ts
2 src/main/agent-hooks/hook-config-write-path.ts
1 src/main/agent-hooks/hooks-json-read.ts
17 src/main/agent-hooks/installer-utils.ts
6 src/main/agent-hooks/locked-executable-rename.ts
1 src/main/agent-hooks/server/server-hydration.ts
1 src/main/agent-hooks/wsl-hook-relay-deps.ts
3 src/main/agent-hooks/wsl-hook-relay-launch.ts
1 src/main/agent-launch/trust/agent-trust-ownership-ledger.ts
14 src/main/agent-launch/trust/agent-trust-presets.ts
2 src/main/agent-launch/trust/antigravity-workspace-trust-ownership.ts
1 src/main/agent-launch/trust/execution-host-workspace-trust.ts
4 src/main/ai-vault/parse-cache/session-parse-cache-legacy-json.ts
2 src/main/ai-vault/scan-service/session-scanner-service-entry-path.ts
1 src/main/ai-vault/scan-service/session-scanner-service-spawn.ts
1 src/main/ai-vault/scanners/omp/omp-session-root.ts
1 src/main/ai-vault/scanners/opencode/reader-transport/opencode-wsl-runtime-preparation.ts
2 src/main/ai-vault/scanners/opencode/reader-transport/session-scanner-opencode-sqlite-worker-spawn.ts
8 src/main/amp/hook-service.ts
2 src/main/amp/managed-plugin-install-status.ts
1 src/main/antigravity/antigravity-host-acp.ts
1 src/main/antigravity/native-account-launch.ts
5 src/main/antigravity/native-account-store.ts
2 src/main/antigravity/native-credential-backend.ts
7 src/main/antigravity/native-file-credentials.ts
12 src/main/artifacts/artifact-create-intent-store.ts
2 src/main/artifacts/artifact-share-record-store.ts
1 src/main/automations/external-manager-discovery.ts
7 src/main/bitbucket/credential-store.ts
1 src/main/browser-passwords/browser-password-chromium-import.ts
2 src/main/browser-passwords/browser-password-vault-file.ts
2 src/main/browser/agent-browser/agent-browser-bridge-process.ts
1 src/main/browser/agent-browser/agent-browser-dependency-binary.ts
1 src/main/browser/agent-browser/agent-browser-process-environment.ts
1 src/main/browser/agent-browser/agent-browser-session-reset.ts
2 src/main/browser/client-hosts/file-transfers/browser-client-download-relay.ts
1 src/main/browser/client-hosts/file-transfers/browser-client-upload-staging.ts
2 src/main/browser/client-hosts/leases/browser-host-client-identity.ts
1 src/main/browser/cookies/browser-cookie-import-diagnostics.ts
2 src/main/browser/cookies/chromium/chromium-cookie-path.ts
3 src/main/browser/cookies/chromium/chromium-cookie-snapshot.ts
1 src/main/browser/cookies/chromium/import-cookies.ts
3 src/main/browser/cookies/client-route/client-route-cookie-import-source-store.ts
2 src/main/browser/cookies/sources/browser-cookie-detection.ts
7 src/main/browser/cookies/sources/browser-cookie-firefox-import.ts
2 src/main/browser/cookies/sources/browser-cookie-key.ts
1 src/main/browser/cookies/sources/browser-cookie-safari-import.ts
5 src/main/browser/cookies/sources/browser-cookie-source-profiles.ts
11 src/main/browser/cookies/staging/browser-session-cookie-staging.ts
1 src/main/browser/downloads/browser-download-destination.ts
2 src/main/browser/extensions/api-runtime/browser-extension-worker-shim-source.ts
8 src/main/browser/extensions/installation/browser-extension-install-store.ts
1 src/main/browser/extensions/installation/browser-extension-load-directory.ts
1 src/main/browser/extensions/profile-sessions/browser-extension-session-loader.ts
2 src/main/browser/extensions/profile-storage/browser-extension-data-removal.ts
4 src/main/browser/extensions/profile-storage/browser-extension-profile-state-store.ts
3 src/main/browser/extensions/profile-storage/browser-extension-retired-profile-storage.ts
8 src/main/browser/extensions/profile-storage/browser-extension-sync-storage-store.ts
1 src/main/browser/guest-lifecycle/popups/browser-popup-background-cdp-probe.ts
1 src/main/browser/guest-lifecycle/popups/popup-identity-electron-probe.ts
1 src/main/browser/identity/browser-identity-mode-record.ts
2 src/main/browser/identity/browser-identity-mode-store.ts
2 src/main/browser/network/egress/browser-route-egress-electron-launch.ts
4 src/main/browser/network/execution-routes/wsl-browser-network-relay-launch.ts
1 src/main/browser/routing/partitions/browser-route-partition-binding-file.ts
3 src/main/browser/routing/partitions/browser-route-partition-binding-store.ts
4 src/main/browser/routing/partitions/browser-route-partition-pending-deletes.ts
4 src/main/browser/sessions/browser-session-meta-store.ts
2 src/main/browser/site-settings/browser-profile-site-store.ts
6 src/main/claude-accounts/claude-account-folder.ts
1 src/main/claude-accounts/claude-observed-config-dirs.ts
11 src/main/claude-accounts/claude-profile-history.ts
2 src/main/claude-accounts/claude-profile-homes.ts
1 src/main/claude-accounts/claude-profile-launch-preparation.ts
7 src/main/claude-accounts/claude-profile-paths.ts
22 src/main/claude-accounts/claude-profile-prompt-history.ts
5 src/main/claude-accounts/claude-profile-provisioning.ts
5 src/main/claude-accounts/claude-profile-router.ts
1 src/main/claude-accounts/claude-profile-settings.ts
1 src/main/claude-accounts/claude-profile-setup-worker.ts
1 src/main/claude-accounts/claude-profile-setup.ts
10 src/main/claude-accounts/claude-profile-sharing.ts
1 src/main/claude-accounts/claude-profile-wsl-router.ts
2 src/main/claude-accounts/keychain.ts
1 src/main/claude-accounts/runtime-paths.ts
3 src/main/claude/agent-view/agent-view-install.ts
1 src/main/claude/claude-diff-panel-auto-open.ts
13 src/main/claude/claude-folder-trust-file.ts
2 src/main/claude/claude-profile-hook-target.ts
1 src/main/claude/claude-rejected-api-key.ts
1 src/main/claude/claude-rewind-transcript.ts
1 src/main/claude/hook-service.ts
3 src/main/claude/statusline-install.ts
6 src/main/claude/windows-hook-files.ts
1 src/main/cli/appimage-copy-pre-extraction.ts
1 src/main/cli/appimage-extracted-root.ts
1 src/main/cli/appimage-extraction-pruning.ts
2 src/main/cli/appimage-generation-lease.ts
3 src/main/cli/appimage-generation-residency.ts
10 src/main/cli/appimage-stable-launcher.ts
1 src/main/cli/cli-command-inspection.ts
1 src/main/cli/cli-dev-launcher.ts
3 src/main/cli/cli-install-location.ts
2 src/main/cli/linux-bare-orca-dispatcher.ts
6 src/main/cli/linux-terminal-orca-cli-shim.ts
2 src/main/cli/wsl-managed-cli.ts
2 src/main/codex-accounts/codex-account-identity.ts
3 src/main/codex-accounts/codex-account-registration.ts
4 src/main/codex-accounts/codex-config-mirror.ts
1 src/main/codex-accounts/codex-credential-absence-grace.ts
1 src/main/codex-accounts/codex-login-auth-snapshot.ts
5 src/main/codex-accounts/codex-managed-home-lifecycle.ts
6 src/main/codex-accounts/codex-managed-home-path.ts
15 src/main/codex-accounts/fs-utils.ts
1 src/main/codex-accounts/guest-codex-account-homes.ts
6 src/main/codex-accounts/host-codex-managed-home-ownership.ts
2 src/main/codex-accounts/legacy-shared-auth-migration.ts
18 src/main/codex-accounts/legacy-wsl-runtime-auth-drain-recovery-script-harness.ts
31 src/main/codex-accounts/legacy-wsl-runtime-auth-drain-script-harness.ts
3 src/main/codex-accounts/legacy-wsl-runtime-auth-drain-script-interference-shims.ts
1 src/main/codex-accounts/managed-codex-auth-readiness.ts
6 src/main/codex-accounts/runtime-home-service-auth-core.ts
5 src/main/codex-accounts/runtime-home-service-auth-provenance.ts
23 src/main/codex-accounts/runtime-home-service-auth-sync.ts
19 src/main/codex-accounts/runtime-home-service-legacy-migration.ts
1 src/main/codex-accounts/runtime-home-service-managed-home.ts
10 src/main/codex-accounts/runtime-home-service-paths.ts
1 src/main/codex-accounts/runtime-home-service-sync.ts
2 src/main/codex-accounts/runtime-home-service-wsl-core.ts
1 src/main/codex-usage/codex-session-file-discovery.ts
1 src/main/codex/configuration/codex-path-observation.ts
16 src/main/codex/configuration/homes/codex-home-paths.ts
6 src/main/codex/configuration/homes/codex-managed-home-resource-copy-marker.ts
8 src/main/codex/configuration/homes/codex-managed-home-rules.ts
5 src/main/codex/configuration/homes/codex-pane-account-registry.ts
5 src/main/codex/configuration/homes/codex-windows-sandbox-read-grant.ts
1 src/main/codex/configuration/settings/codex-config-path-reference-rewrite.ts
1 src/main/codex/configuration/settings/config-settings-baseline.ts
4 src/main/codex/configuration/settings/config-settings-promotion-write-target.ts
3 src/main/codex/configuration/settings/config-settings-promotion.ts
1 src/main/codex/configuration/shared-server/codex-daemon-socket-path-guard.ts
8 src/main/codex/configuration/toml/config-toml-atomic-write.ts
4 src/main/codex/history/backfill/codex-session-backfill-marker.ts
16 src/main/codex/history/bridges/codex-session-bridge.ts
5 src/main/codex/history/index/codex-session-index-heal-state.ts
2 src/main/codex/history/index/codex-state-db.ts
2 src/main/codex/history/resume/codex-session-resume-home.ts
2 src/main/codex/history/rollouts/codex-account-home-discovery.ts
1 src/main/codex/history/rollouts/codex-session-file-listing.ts
1 src/main/codex/hooks/installation/codex-hook-local-install.ts
2 src/main/codex/hooks/installation/codex-hook-local-maintenance.ts
4 src/main/codex/hooks/reconciliation/codex-hook-legacy-cleanup.ts
2 src/main/codex/hooks/reconciliation/codex-hook-status.ts
4 src/main/codex/hooks/reconciliation/codex-real-home-hooks-json.ts
3 src/main/codex/trust/grants/codex-trust-grant-ledger.ts
2 src/main/codex/trust/hooks/codex-hook-trust-derivation.ts
1 src/main/codex/trust/hooks/codex-hook-trust-memo.ts
2 src/main/codex/trust/hooks/codex-hook-user-mirroring.ts
4 src/main/codex/trust/hooks/hook-trust-promotion.ts
1 src/main/codex/trust/identity/codex-trust-identity.ts
1 src/main/codex/trust/toml/config-toml-project-trust.ts
7 src/main/codex/trust/toml/config-toml-trust.ts
2 src/main/computer/desktop-script-provider-paths.ts
1 src/main/computer/macos-native-provider-client.ts
3 src/main/computer/macos-native-provider-paths.ts
3 src/main/computer/macos-native-provider-transport.ts
1 src/main/computer/sidecar-client.ts
3 src/main/connector-cloud/connector-turn-events.ts
1 src/main/copilot/hook-service.ts
3 src/main/crash-reporting/appimage-crashpad-handler-exit.ts
2 src/main/credentials/credential-file-protection.ts
6 src/main/credentials/encrypted-api-key-file-store.ts
5 src/main/credentials/integration-credential-file.ts
1 src/main/credentials/integration-state-file-cache.ts
1 src/main/credentials/integration-token-file-cache.ts
2 src/main/credentials/saved-credential-readability.ts
2 src/main/daemon/admission/automatic-work-run-marker-store.ts
5 src/main/daemon/admission/host-terminal-ledger.ts
1 src/main/daemon/admission/legacy-restore-records.ts
1 src/main/daemon/daemon-entry.ts
1 src/main/daemon/endpoint/identity/daemon-endpoint-incarnation.ts
3 src/main/daemon/endpoint/identity/daemon-pid-identity.ts
2 src/main/daemon/endpoint/identity/daemon-pid-record-quarantine.ts
2 src/main/daemon/endpoint/identity/daemon-process-start-time.ts
2 src/main/daemon/endpoint/identity/daemon-ready-identity.ts
2 src/main/daemon/endpoint/publication/daemon-endpoint-lifecycle.ts
6 src/main/daemon/endpoint/publication/daemon-endpoint-ownership.ts
1 src/main/daemon/endpoint/publication/daemon-endpoint-probe.ts
2 src/main/daemon/endpoint/publication/daemon-private-file-modes.ts
2 src/main/daemon/endpoint/publication/daemon-socket-endpoint-path.ts
3 src/main/daemon/executable-host/linux/daemon-appimage-generation-launch.ts
1 src/main/daemon/executable-host/linux/daemon-appimage-launch.ts
2 src/main/daemon/executable-host/linux/daemon-host-image.ts
2 src/main/daemon/executable-host/macos/macos-daemon-bundle.ts
9 src/main/daemon/executable-host/windows/daemon-host-build-inventory.ts
2 src/main/daemon/executable-host/windows/daemon-host-file-hash-cache.ts
2 src/main/daemon/executable-host/windows/daemon-host-manifest.ts
2 src/main/daemon/executable-host/windows/daemon-host-reclaim.ts
12 src/main/daemon/executable-host/windows/daemon-host-relocation.ts
4 src/main/daemon/health/daemon-health.ts
3 src/main/daemon/history/restoration/history-reader.ts
1 src/main/daemon/history/restoration/terminal-history-checkpoint-reader.ts
1 src/main/daemon/history/restoration/terminal-history-legacy-scrollback-restore.ts
1 src/main/daemon/history/storage/history-manager.ts
3 src/main/daemon/history/storage/terminal-history-metadata.ts
2 src/main/daemon/history/storage/terminal-history-permission-repair.ts
8 src/main/daemon/history/storage/terminal-history-recovery-quarantine.ts
1 src/main/daemon/history/storage/terminal-history-session-files.ts
3 src/main/daemon/history/storage/terminal-history-session-tombstone.ts
3 src/main/daemon/history/storage/terminal-history-session-writer.ts
1 src/main/daemon/launch/daemon-bundle-staleness.ts
1 src/main/daemon/launch/daemon-endpoint-adoption.ts
3 src/main/daemon/launch/daemon-generation-liveness.ts
2 src/main/daemon/launch/daemon-launch-paths.ts
1 src/main/daemon/launch/daemon-legacy-process-liveness.ts
2 src/main/daemon/launch/daemon-protocol-cleanup.ts
11 src/main/daemon/launch/daemon-spawner.ts
1 src/main/daemon/launch/daemon-stale-kill.ts
1 src/main/daemon/observability/daemon-adoption-telemetry-event.ts
1 src/main/daemon/observability/daemon-file-log.ts
3 src/main/daemon/permissions/daemon-tcc-attribution.ts
5 src/main/daemon/process-scopes/daemon-cgroup-scope.ts
1 src/main/daemon/process-scopes/daemon-user-manager-lifetime.ts
1 src/main/daemon/process-scopes/terminal-scopes-runtime.ts
2 src/main/daemon/process-scopes/terminal-scopes.ts
1 src/main/daemon/providers/adapter/daemon-pty-daemon-recovery.ts
1 src/main/daemon/providers/adapter/daemon-pty-session-inventory.ts
1 src/main/daemon/providers/routing/daemon-legacy-adapters.ts
2 src/main/daemon/pty-subprocess/spawn-preflight.ts
1 src/main/daemon/shell-readiness/shell-ready.ts
1 src/main/daemon/transport/client/daemon-client-token.ts
2 src/main/daemon/transport/stream/daemon-stream-backlog-probe.ts
4 src/main/devin/hook-config-json.ts
3 src/main/dsh/dsh-hook-packages.ts
3 src/main/dsh/hook-service.ts
1 src/main/emulator/android/android-sdk-host-discovery.ts
7 src/main/emulator/android/scrcpy-server-download.ts
1 src/main/emulator/emulator-probe.ts
2 src/main/emulator/serve-sim-detached-session.ts
6 src/main/emulator/serve-sim-execution.ts
15 src/main/emulator/serve-sim-runtime-materializer.ts
12 src/main/external-editors/external-editor-launch.ts
5 src/main/filesystem/durable-file-write.ts
2 src/main/filesystem/rolling-file-backup.ts
2 src/main/foreign-sqlite-readers/foreign-sqlite-reader-entry-path.ts
1 src/main/foreign-sqlite-readers/foreign-sqlite-reader-spawn.ts
1 src/main/foreign-sqlite-readers/readers/cursor-profile.ts
1 src/main/foreign-sqlite-readers/readers/opencode-binder-sessions.ts
1 src/main/git/huge-folder-ignore.ts
5 src/main/git/repo-detection.ts
13 src/main/git/repo-git-marker-scan.ts
3 src/main/git/worktrees/catalog/worktree-git-path.ts
1 src/main/github/client/check/check-job-log-cache-retention-child.mjs
3 src/main/grok/grok-hook-backup-cleanup.ts
3 src/main/grok/grok-hook-owners.ts
4 src/main/grok/grok-hook-symlink-cleanup-marker.ts
4 src/main/grok/hook-service.ts
4 src/main/hang-watchdog/hang-detection-marker.ts
1 src/main/hang-watchdog/hang-watchdog-worker-path.ts
1 src/main/hang-watchdog/previous-hang-detection.ts
1 src/main/hermes/hermes-default-home.ts
10 src/main/hermes/hermes-home-filesystem.ts
2 src/main/hermes/hook-service.ts
2 src/main/host/secret-protection-report.ts
1 src/main/ipc/app.ts
1 src/main/ipc/command-path/command-path-directory-worker-client.ts
1 src/main/ipc/command-path/command-path-resolver.ts
4 src/main/ipc/diagnostics.ts
2 src/main/ipc/filesystem/access/filesystem-path-containment.ts
1 src/main/ipc/filesystem/watcher-process/parcel-watcher-canary-directory.ts
1 src/main/ipc/filesystem/watcher-process/parcel-watcher-child-launch.ts
3 src/main/ipc/filesystem/watcher-process/parcel-watcher-delivery-canary.ts
3 src/main/ipc/filesystem/watcher-process/parcel-watcher-entry-path.ts
1 src/main/ipc/filesystem/watcher-process/parcel-watcher-shallow-file-subscription.ts
1 src/main/ipc/filesystem/watcher-process/parcel-watcher-shallow-subscription.ts
1 src/main/ipc/filesystem/watcher-process/parcel-watcher-supervisor-subscribe.ts
1 src/main/ipc/filesystem/watcher-process/rebinding-file-watch.ts
1 src/main/ipc/filesystem/watcher-process/watcher-event-root-path-rewrite.ts
1 src/main/ipc/macos-keyboard-layout-snapshot.ts
1 src/main/ipc/notification-authorization-status.ts
1 src/main/ipc/pty/spawn-pane-env.ts
1 src/main/ipc/ssh/ssh-connect-flow.ts
2 src/main/ipc/worktree-remote.ts
2 src/main/ipc/wsl-guest-windows-drive-path.ts
7 src/main/jcode/hook-service.ts
8 src/main/jira/site-credential-store.ts
7 src/main/keybindings/keybinding-file-parser.ts
1 src/main/keybindings/keybinding-file.ts
12 src/main/kimi/hook-service.ts
3 src/main/kiro/hook-service.ts
1 src/main/kiro/standalone-hooks.ts
4 src/main/linear/linear-credential-paths.ts
3 src/main/linear/linear-legacy-viewer-store.ts
1 src/main/linear/linear-token-store.ts
3 src/main/linear/linear-workspace-registry.ts
1 src/main/macos-permissions/macos-tcc-prompt-notice.ts
3 src/main/managed-data-accounts/credential-capture.ts
18 src/main/managed-data-accounts/profile-removal.ts
10 src/main/managed-data-accounts/service.ts
2 src/main/managed-server/install/remote-versioned-install.ts
1 src/main/memory/darwin-process-footprint.ts
12 src/main/mimo/hook-service.ts
6 src/main/minimax/minimax-cookie-store.ts
1 src/main/muse/hook-config-json.ts
4 src/main/muse/hook-service.ts
2 src/main/native-chat/agent-session-attachments/agent-session-attachment-claims.ts
1 src/main/native-chat/agent-session-journal/database/journal-host-database.ts
1 src/main/native-chat/host-readable-transcript-path.ts
2 src/main/native-chat/wsl-transcript-fs-process-spawn.ts
1 src/main/node-runtime/appimage-bundled-node-runtime.ts
2 src/main/node-runtime/managed-runtime-release-install.ts
7 src/main/node-runtime/managed-runtime-release.ts
9 src/main/notebook/python-environments.ts
1 src/main/observability/bounded-log-file-writer.ts
2 src/main/observability/bundle.ts
5 src/main/observability/local-file-sink.ts
14 src/main/opencode/hook-service.ts
1 src/main/opencode/legacy-plugin-acl-retry.ts
2 src/main/opencode/opencode-overlay-manifest.ts
1 src/main/opencode/opencode-plugin-config-writer.ts
1 src/main/opencode/opencode-private-server.ts
1 src/main/opencode/opencode-wsl-text-task.ts
2 src/main/orca-profiles/new-profile-state.ts
3 src/main/orca-profiles/other-profile-workspace-catalog.ts
3 src/main/orca-profiles/profile-artifact-cloud-cleanup.ts
1 src/main/orca-profiles/profile-cloud-index.ts
4 src/main/orca-profiles/profile-cloud-session-store.ts
12 src/main/orca-profiles/profile-index-store.ts
5 src/main/orca-profiles/profile-legacy-state-import.ts
4 src/main/orca-profiles/profile-project-move-intent.ts
3 src/main/orca-profiles/profile-project-move-record.ts
4 src/main/orca-profiles/profile-project-state-file.ts
2 src/main/orcad/launcher.ts
6 src/main/orcad/node-pty-prebuilt-slot.ts
2 src/main/orcad/node-pty-precondition.ts
2 src/main/orcad/orcad-agent-browser-binary.ts
1 src/main/orcad/orcad-app-paths.ts
1 src/main/orcad/orcad-artifact-identity.ts
2 src/main/orcad/orcad-artifact-materializer.ts
12 src/main/orcad/orcad-bundled-runtime.ts
2 src/main/orcad/orcad-cli-launcher.ts
1 src/main/orcad/orcad-command-arguments.ts
1 src/main/orcad/orcad-completed-stop-receipt.ts
2 src/main/orcad/orcad-daemon-slot-pins.ts
2 src/main/orcad/orcad-data-root-privacy.ts
4 src/main/orcad/orcad-host-account-launch-env-store.ts
1 src/main/orcad/orcad-host-adapters.ts
2 src/main/orcad/orcad-idle-stop-record.ts
2 src/main/orcad/orcad-instance-lock-hold.ts
15 src/main/orcad/orcad-instance-lock-reclaim.ts
3 src/main/orcad/orcad-instance-lock.ts
5 src/main/orcad/orcad-local-serve-selection.ts
1 src/main/orcad/orcad-lock-clone-machine.ts
1 src/main/orcad/orcad-managed-stop-cancellation.ts
2 src/main/orcad/orcad-managed-stop-decision.ts
2 src/main/orcad/orcad-managed-stop-request.ts
4 src/main/orcad/orcad-plaintext-credential-migration.ts
5 src/main/orcad/orcad-process-start-time.ts
10 src/main/orcad/orcad-secret-key-record.ts
3 src/main/orcad/orcad-stale-lock-reclaim.ts
1 src/main/orcad/orcad-stop-request-listener.ts
1 src/main/orcad/orcad-wsl-holder-release.ts
2 src/main/orcad/orcad-wsl-host-claude-profile-refresh.ts
1 src/main/orcad/serve-profile-ssh-targets.ts
5 src/main/persistence/atomic-snapshot-writer.ts
6 src/main/persistence/loading-store/user-data-path.ts
3 src/main/persistence/loading-store/write-flush-barriers.ts
9 src/main/persistence/migrating-orcad-catalog/migration-journal-directory.ts
4 src/main/persistence/migrating-orcad-catalog/orcad-migration-blob-installers.ts
3 src/main/persistence/migrating-orcad-catalog/orcad-migration-blob-staging.ts
12 src/main/persistence/migrating-orcad-catalog/orcad-migration-staged-file.ts
1 src/main/persistence/migrating-orcad-catalog/orcad-scrollback-snapshot-transfer.ts
8 src/main/persistence/migrating-orcad-catalog/orcad-shell-history-installer.ts
7 src/main/persistence/migrating-orcad-catalog/orcad-terminal-history-installer.ts
1 src/main/persistence/migrating-orcad-catalog/orcad-terminal-restore-hint-store.ts
1 src/main/persistence/moving-wsl-projects/wsl-move-orchestration-history-rewrite.ts
1 src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-store.ts
4 src/main/persistence/moving-wsl-projects/wsl-move-slept-scrollback.ts
2 src/main/persistence/moving-wsl-projects/wsl-move-slept-spool-sweep.ts
5 src/main/persistence/preferences/active-view-preference.ts
4 src/main/persistence/profile-state/legacy-json/profile-state-authority-exports.ts
2 src/main/persistence/profile-state/legacy-json/profile-state-export-path.ts
1 src/main/persistence/profile-state/legacy-json/profile-state-legacy-backup-path.ts
2 src/main/persistence/profile-state/legacy-json/profile-state-legacy-import.ts
8 src/main/persistence/profile-state/legacy-json/profile-state-recovery.ts
6 src/main/persistence/profile-state/legacy-json/profile-state-versioned-export.ts
5 src/main/persistence/profile-state/profile-state-access-identity.ts
10 src/main/persistence/profile-state/profile-state-access-owner.ts
3 src/main/persistence/profile-state/profile-state-access.ts
2 src/main/persistence/profile-state/profile-state-active-location.ts
5 src/main/persistence/profile-state/profile-state-authority-bootstrap.ts
1 src/main/persistence/profile-state/profile-state-authority-marker.ts
2 src/main/persistence/profile-state/profile-state-backup-path.ts
2 src/main/persistence/profile-state/profile-state-backup-worker.ts
5 src/main/persistence/profile-state/profile-state-database-quarantine.ts
9 src/main/persistence/profile-state/profile-state-database-recovery.ts
2 src/main/persistence/profile-state/profile-state-database.ts
4 src/main/persistence/profile-state/profile-state-migration.ts
6 src/main/persistence/profile-state/profile-state-offline-settings.ts
6 src/main/persistence/profile-state/profile-state-recovery-command.ts
6 src/main/persistence/profile-state/profile-state-recovery-copy.ts
2 src/main/persistence/profile-state/profile-state-recovery-crash-process.ts
1 src/main/persistence/profile-state/profile-state-recovery-required.ts
2 src/main/persistence/profile-state/profile-state-section-repair.ts
2 src/main/persistence/profile-state/profile-state-sqlite-authority.ts
1 src/main/persistence/profile-state/profile-state-startup-recovery-dialog.ts
2 src/main/persistence/profile-state/profile-state-storage-classification.ts
1 src/main/persistence/profile-state/profile-state-writer-worker-path.ts
2 src/main/persistence/restoring-sessions/floating-workspace-normalization.ts
1 src/main/persistence/tracking-repos/worktree-metadata-normalization.ts
1 src/main/persistence/window-save-divergence.ts
7 src/main/pi/legacy-omp-overlay-migration.ts
5 src/main/pi/titlebar-extension-service.ts
3 src/main/plugins/appearance/plugin-appearance-service.ts
2 src/main/plugins/installation/plugin-install-staging.ts
1 src/main/plugins/installation/plugin-install.ts
1 src/main/plugins/panels/plugin-frame-guest-sessions.ts
1 src/main/plugins/panels/plugin-source-transpile-client.ts
2 src/main/plugins/plugin-dev-watcher.ts
3 src/main/plugins/plugin-secrets-store.ts
3 src/main/plugins/plugin-storage-store.ts
1 src/main/plugins/testing/plugin-editor-static-check.ts
1 src/main/plugins/workers/plugin-host-process.ts
3 src/main/plugins/workers/plugin-worker-source-hooks.ts
5 src/main/ports/darwin-port-scan-lock.ts
1 src/main/ports/port-scan-command-client.ts
2 src/main/provider-process/provider-executable-missing.ts
4 src/main/providers/local-pty/local-pty-executable-spawn.ts
1 src/main/providers/local-pty/local-pty-session-operations.ts
1 src/main/providers/local-pty/local-pty-shell-ready-wrapper-root.ts
1 src/main/providers/macos-login-session-pty-probe.ts
3 src/main/providers/macos-tcc-login-shell.ts
2 src/main/providers/windows-powershell-executable.ts
2 src/main/providers/working-directory-validation.ts
4 src/main/pty/history/fish-history-session.ts
4 src/main/pty/history/terminal-history-deletion.ts
2 src/main/pty/history/terminal-history-paths.ts
5 src/main/pty/history/terminal-history.ts
1 src/main/pty/process-retirement/posix-pty-process-table.ts
7 src/main/pty/scrollback/overlay-mirror.ts
1 src/main/pty/scrollback/terminal-scrollback-snapshot-nonblocking-reads.ts
9 src/main/pty/scrollback/terminal-scrollback-snapshots.ts
2 src/main/pty/shell-startup/codex-shell-launch-preflight.ts
7 src/main/pty/shell-startup/git-bash.ts
3 src/main/pty/shell-startup/legacy-terminal-posix-tombstone.ts
8 src/main/pty/shell-startup/legacy-terminal-shim-dir.ts
1 src/main/pty/shell-startup/managed-ssh-host-login-shell.ts
1 src/main/pty/shell-startup/powershell-profile-env.ts
3 src/main/pty/shell-startup/shell-startup-env.ts
4 src/main/pty/shell-startup/shell-wrapper-file-writer.ts
4 src/main/pty/shell-startup/zsh-startup-hook-pty-harness.ts
2 src/main/pty/shell-startup/zsh-wrapper-dir-ownership.ts
1 src/main/qoder/workspace-trust.ts
4 src/main/rate-limits/cursor-auth.ts
2 src/main/rate-limits/grok-auth.ts
3 src/main/rate-limits/hidden-probe-cwd.ts
2 src/main/rate-limits/opencode-go-api-key-source.ts
1 src/main/rate-limits/zcode-usage-credentials.ts
3 src/main/ripgrep/bundled-ripgrep-path.ts
7 src/main/runtime/agent-session/ownership/agent-session-claim-identity.ts
1 src/main/runtime/agent-session/records/agent-session-record-store-slot.ts
7 src/main/runtime/agent-session/records/agent-session-runtime-end-record.ts
1 src/main/runtime/agent-session/structured-agent-session-attachment-wiring.ts
1 src/main/runtime/client/navigation/desktop-chat-creation-history.ts
4 src/main/runtime/hosts/platform-probe/host-descriptor.ts
5 src/main/runtime/mobile-cloud-relay/relay-region-preference.ts
2 src/main/runtime/mobile-cloud-relay/relay-revoke-outbox.ts
1 src/main/runtime/orchestration/db/runtime-orchestration-database-access.ts
1 src/main/runtime/push/notifications/mobile-notification-dismissal-store.ts
2 src/main/runtime/push/push-unregister-outbox.ts
2 src/main/runtime/rpc/methods/mobile-delivery/bundled-mobile-web-bundle.ts
1 src/main/runtime/rpc/server/network-source-policy-store.ts
2 src/main/runtime/rpc/server/pairing/device-registry-corruption.ts
2 src/main/runtime/rpc/server/pairing/device-registry-disk-merge.ts
1 src/main/runtime/rpc/server/pairing/device-registry-file-read.ts
3 src/main/runtime/rpc/server/pairing/e2ee-keypair.ts
3 src/main/runtime/rpc/server/runtime-metadata.ts
2 src/main/runtime/rpc/server/runtime-rpc-socket-metadata.ts
4 src/main/runtime/rpc/unix-socket-transport.ts
3 src/main/runtime/rpc/ws-fallback-port-store.ts
2 src/main/runtime/terminal/launch/claude-agent-teams-shim-env.ts
1 src/main/runtime/workspaces/persisted-surfaces/crew-operations.ts
1 src/main/server/serve-pairing-output.ts
2 src/main/speech/model-cache-path.ts
9 src/main/speech/model-manager.ts
10 src/main/speech/openai-api-key-store.ts
2 src/main/speech/speech-model-download-cleanup.ts
1 src/main/speech/speech-model-download-transport.ts
2 src/main/speech/speech-model-http-download.ts
1 src/main/speech/stt-worker-model-config.ts
2 src/main/speech/stt-worker-paths.ts
1 src/main/sqlite/harden-database-files.ts
1 src/main/sqlite/sync-database.ts
1 src/main/sqlite/versioned-cache-database.ts
2 src/main/ssh/config/ssh-config-alias-claim.ts
4 src/main/ssh/config/ssh-config-include-expander.ts
1 src/main/ssh/config/ssh-config-parser.ts
1 src/main/ssh/config/ssh-g-config-resolution.ts
1 src/main/ssh/orcad-deployment-target.ts
1 src/main/ssh/orcad-held-fence-tokens.ts
1 src/main/ssh/ssh-auth-resolution.ts
3 src/main/ssh/ssh-control-socket.ts
1 src/main/ssh/ssh-windows-host-cells.ts
3 src/main/ssh/system-transport/system-ssh-binary.ts
3 src/main/ssh/system-transport/system-ssh-sftp-transfer.ts
3 src/main/startup/cli-launch-redirect.ts
2 src/main/startup/configure-process.ts
4 src/main/startup/gpu-fallback-marker.ts
2 src/main/startup/http1-compatibility-marker.ts
5 src/main/startup/http1-compatibility-profile-state.ts
4 src/main/startup/linux-realtime-scheduling-guard.ts
1 src/main/startup/linux-rttime-limit.ts
2 src/main/startup/profile-state-recovery-preflight.ts
1 src/main/startup/windows-app-data-path.ts
5 src/main/startup/windows-install-dir-acl-poison-marker.ts
1 src/main/startup/windows-install-dir-acl-probe.ts
1 src/main/startup/windows-install-dir-package-acl-grant.ts
4 src/main/startup/windows-install-dir-package-acl-repair.ts
1 src/main/startup/windows-renderer-runtime-files.ts
3 src/main/startup/windows-user-data-acl.ts
6 src/main/startup/x-display-artifacts.ts
2 src/main/stats/stats-file-loader.ts
1 src/main/text-generation/source-control-prompt-files.ts
1 src/main/updater/lifecycle/windows-update-install-directory.ts
6 src/main/updater/linux-package/appimage-runtime-identity.ts
1 src/main/updater/linux-package/linux-package-install-command.ts
1 src/main/updater/linux-package/linux-update-package-type.ts
6 src/main/updater/serve-update-handoff.ts
2 src/main/usage/usage-provider-store-lifecycle.ts
1 src/main/usage/usage-scan-worker-spawn.ts
1 src/main/warp-themes/discovery.ts
1 src/main/window/desktop-integration/custom-app-icon.ts
3 src/main/window/desktop-integration/macos-press-and-hold-default.ts
1 src/main/windows/windows-administrator-restart.ts
1 src/main/windows/windows-command-paths.ts
1 src/main/windows/windows-process-table.ts
1 src/main/worker-thread-child-process/worker-thread-child-process.ts
2 src/main/worker-threads/forked-child-entry-path.ts
4 src/main/workspace-hooks/hooks.ts
10 src/main/workspace-hooks/issue-command-file.ts
3 src/main/workspace-hooks/worktree-runner-script.ts
1 src/main/workspaces/catalog/folder-repo-git-conversion.ts
2 src/main/workspaces/catalog/folder-upgrade-worktree-path.ts
3 src/main/workspaces/execution-host/project-runtime-git-router.ts
1 src/main/workspaces/space-analysis/workspace-space-scan-worker-client.ts
1 src/main/wsl/execution/wsl-executable-path.ts
1 src/main/wsl/execution/wsl-interop-spawn-directory.ts
1 src/main/wsl/execution/wsl-node-runtime-prefetch.ts
3 src/main/wsl/filesystem/wsl-drive-project-new-default.ts
10 src/main/wsl/filesystem/wsl-drive-unc-conversion-stores.ts
2 src/main/wsl/host-lifecycle/wsl-host-automation-wake-store.ts
4 src/main/wsl/host-lifecycle/wsl-host-e2e-fake-connector.ts
1 src/main/wsl/host-lifecycle/wsl-host-early-wake.ts
1 src/main/wsl/host-lifecycle/wsl-orphan-holder-release.ts
1 src/main/zcode/hook-config-json.ts
12 src/main/zcode/zcode-plan-api-key-store.ts
+8
View File
@@ -54,3 +54,11 @@ identity, queue-admission or retained-memory oracle. Confirm it fails with the
old behavior. Use controlled, counterbalanced benchmark samples for timings;
avoid new machine-dependent millisecond gates in the normal unit suite. A green
source scan and these contracts cannot establish that the whole app is fast.
Two count ratchets (counts per file may only fall) cover classes the audit only warns about:
`pnpm check:main-sync-fs-ratchet` counts synchronous `node:fs` calls in production `src/main`
(`config/main-sync-fs-baseline.txt`), and `pnpm check:recurring-timer-ratchet` counts `setInterval`
calls in production `src/main`, `src/renderer`, `src/shared` and `src/cli`
(`config/recurring-timer-baseline.txt`). Both run in `check:ratchets` on every PR. A new use either
moves off the hot path (async fs or a stat-fingerprint cache; a push signal, a visibility-gated or
backing-off timer) or raises its file's count with reviewer sign-off.
+90
View File
@@ -0,0 +1,90 @@
# setInterval calls in production src/main, src/renderer, src/shared and src/cli, per file.
# This is a RATCHET: counts may only go DOWN.
# Prune after removing intervals: pnpm check:recurring-timer-ratchet --prune
1 src/cli/handlers/orchestration/check-keepalive.ts
1 src/cli/runtime/mac-app-update-bundle.ts
1 src/cli/runtime/serve-supervised-service.ts
1 src/main/agent-hooks/server/server-opencode-binder.ts
1 src/main/automations/retained-run-reconciliation.ts
1 src/main/automations/service.ts
1 src/main/browser/extensions/native-messaging/browser-extension-native-ports.ts
1 src/main/browser/extensions/web-store/browser-extension-webstore-updater.ts
1 src/main/claude/agent-view/agent-view-bridge.ts
1 src/main/cli/appimage-serve-preparation.ts
1 src/main/codex-accounts/codex-login-session.ts
1 src/main/codex/configuration/homes/codex-windows-sandbox-read-grant.ts
1 src/main/crash-reporting/pre-gone-host-memory.ts
1 src/main/crash-reporting/process-gone-diagnostics.ts
1 src/main/crash-reporting/renderer-heap-allocation-profile.ts
1 src/main/daemon/admission/host-terminal-ledger.ts
1 src/main/daemon/admission/host-terminal-policy.ts
1 src/main/daemon/endpoint/publication/daemon-endpoint-lifecycle.ts
1 src/main/daemon/transport/stream/daemon-stream-backlog-probe.ts
1 src/main/diagnostics/event-loop-delay-probe.ts
1 src/main/diagnostics/main-thread-churn-probe.ts
1 src/main/git/refs/maintenance/pack-refs-lock-ownership.ts
1 src/main/hang-watchdog/main-thread-hang-watchdog-entry.ts
1 src/main/hang-watchdog/main-thread-hang-watchdog.ts
2 src/main/ipc/filesystem/watcher-process/parcel-watcher-shallow-file-subscription.ts
1 src/main/ipc/filesystem/watcher-process/parcel-watcher-shallow-subscription.ts
1 src/main/ipc/runtime-environments/runtime-environment-preference.ts
1 src/main/ipc/worktrees/git/worktree-git-common-narrow-watch.ts
1 src/main/ipc/worktrees/git/worktree-git-common-native-upgrade-poll.ts
1 src/main/ipc/wsl/wsl-host-automation-wake-wiring.ts
1 src/main/native-chat/agent-session-attachments/agent-session-attachment-sweep.ts
1 src/main/native-chat/agent-session-wire/host/structured-agent-session-lease-renewer.ts
1 src/main/native-chat/agent-session-wire/recovery/structured-agent-session-usage-limit-continue.ts
1 src/main/native-chat/agent-session-wire/termination/structured-agent-session-idle-sweep.ts
1 src/main/notifications/desktop-presence-reporter.ts
1 src/main/orcad/orcad-browser-install-park.ts
1 src/main/orcad/orcad-lock-clone-machine.ts
1 src/main/orcad/orcad-stop-request-listener.ts
1 src/main/plugins/catalog/plugin-auto-updater.ts
1 src/main/plugins/catalog/plugin-kill-list-service.ts
1 src/main/plugins/installation/plugin-git-repository.ts
1 src/main/plugins/plugin-service-housekeeping.ts
1 src/main/rate-limits/service/service-polling.ts
1 src/main/runtime/agent-state-rules/agent-state-rules-live-update.ts
1 src/main/runtime/mobile-cloud-relay/desktop-relay-service.ts
2 src/main/runtime/mobile-cloud-relay/relay-control-liveness.ts
1 src/main/runtime/rpc/methods/orchestration/messaging/check-run.ts
1 src/main/runtime/rpc/mobile-socket-wiring.ts
1 src/main/runtime/rpc/remote-runtime-server-heartbeat.ts
1 src/main/runtime/rpc/server/runtime-metadata-ownership-watch.ts
1 src/main/runtime/rpc/unix-socket-transport.ts
1 src/main/runtime/sidebar-inputs/paired-server-rows-producer.ts
1 src/main/runtime/terminal/input/agent-prompt-permission-hold.ts
1 src/main/runtime/terminal/output/terminal-derived-agent-facts.ts
1 src/main/runtime/terminal/wait/terminal-idle-polls.ts
1 src/main/ssh/legacy-relay/legacy-relay-cli-call-limits.ts
1 src/main/ssh/legacy-relay/legacy-relay-daily-activity.ts
1 src/main/ssh/ssh-channel-multiplexer.ts
1 src/main/ssh/ssh-tcp-forwarding-probe.ts
1 src/main/startup/configure-process.ts
1 src/main/startup/event-loop-stall-probe.ts
1 src/main/startup/synthetic-title-runtime.ts
1 src/main/telemetry/wsl-usage-reporter.ts
1 src/main/wsl/host-lifecycle/wsl-hosts-policy-live-update.ts
1 src/main/wsl/orcad/wsl-orcad-connect-stop-fence.ts
1 src/renderer/src/app-shell/use-app-session-persistence.ts
1 src/renderer/src/components/browser-pane/browser-client-page-position-driver.ts
1 src/renderer/src/components/contextual-tours/use-contextual-tour.ts
1 src/renderer/src/components/editor/setup-contextual-copy.ts
1 src/renderer/src/components/right-sidebar/plugin-panels/health/plugin-panel-watchdog.ts
1 src/renderer/src/components/sidebar/SeveredTerminalDaemonBanner.tsx
1 src/renderer/src/components/sidebar/StalledTerminalDaemonBanner.tsx
1 src/renderer/src/components/sidebar/workspace-card/activity/prompt-cache-countdown-clock.ts
1 src/renderer/src/components/status-bar/use-resource-memory-snapshot.ts
1 src/renderer/src/components/status-bar/use-runtime-host-resources.ts
1 src/renderer/src/components/tab-bar/tab-strip-drag-scroll.ts
1 src/renderer/src/components/terminal-pane/pty-transport/delivery/terminal-delivery-watchdog.ts
1 src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/recovery/RemoteRuntimeRecoveryCard.tsx
1 src/renderer/src/components/terminal-pane/render-health/terminal-render-desync-sentinel.ts
1 src/renderer/src/hooks/use-now.ts
1 src/renderer/src/lib/agent-session/hibernation/agent-hibernation-coordinator.ts
1 src/renderer/src/lib/crash-diagnostics.ts
1 src/renderer/src/lib/window-visibility-interval.ts
1 src/renderer/src/lib/worker-auto-close.ts
1 src/renderer/src/runtime/hosts/wsl/wsl-refused-read-watch.ts
1 src/shared/remote-runtime/remote-runtime-socket-liveness.ts
1 src/shared/tmux-agent-hook-owner.ts
@@ -35,8 +35,15 @@ const RATCHET_INPUTS = {
'check-host-list-render-ratchet.mjs': ['src/renderer/src/'],
'check-id-only-store-write-ratchet.mjs': ['src/main/persistence/'],
'check-layout-writer-ratchets.mjs': ['src/main/', 'src/renderer/src/'],
'check-main-sync-fs-ratchet.mjs': ['src/main/'],
'check-main-sync-spawn-ratchet.mjs': ['src/main/'],
'check-react-compiler-compat-ratchet.mjs': ['src/renderer/src/'],
'check-recurring-timer-ratchet.mjs': [
'src/main/',
'src/renderer/src/',
'src/shared/',
'src/cli/'
],
'check-render-path-translate-ratchet.mjs': ['src/renderer/src/'],
'check-repo-host-read-ratchet.mjs': ['src/cli/', 'src/main/', 'src/shared/'],
'check-runtime-electron-ratchet.mjs': ['src/main/', 'src/cli/', 'src/shared/'],
@@ -258,6 +265,7 @@ export function selectTypecheckProjects(files) {
const RATCHET_SHARED_MODULES = {
'config/scripts/static-analysis/process-boundaries/gated-call-use-collector.mjs': [
'check-daemon-blocking-call-ratchet.mjs',
'check-main-sync-fs-ratchet.mjs',
'check-main-sync-spawn-ratchet.mjs'
],
'config/scripts/static-analysis/ratchets/react-compiler/react-compiler-hazards.mjs': [
@@ -41,6 +41,8 @@ export const LINT_STEPS = [
'check:workspace-record-read-ratchet',
'check:unproven-pty-retirement-ratchet',
'check:daemon-blocking-call-ratchet',
'check:main-sync-fs-ratchet',
'check:recurring-timer-ratchet',
'check:node-runtime-pin',
'check:path-literal-ratchet',
'check:host-list-render-ratchet',
@@ -0,0 +1,84 @@
import process from 'node:process'
import { pathToFileURL } from 'node:url'
import { createGatedCallCollector } from '../../process-boundaries/gated-call-use-collector.mjs'
import { readTrackedSources, runCountRatchet } from '../../ratchet-baseline/ratchet-baseline.mjs'
import { isTestOnlySourcePath } from '../../process-boundaries/test-only-source-path.mjs'
// Sync fs on Electron main stalls every window; per-spawn/RPC/focus stat and read sweeps were a recurring lag source (#39805, #35967, #38481).
const BASELINE_PATH = 'config/main-sync-fs-baseline.txt'
const SCAN_ROOTS = ['src/main']
const ADVICE =
'use node:fs/promises, or cache the result on a stat fingerprint outside the hot path'
const SYNC_FS = [
'accessSync',
'appendFileSync',
'copyFileSync',
'existsSync',
'lstatSync',
'mkdirSync',
'openSync',
'readFileSync',
'readdirSync',
'realpathSync',
'renameSync',
'rmSync',
'statSync',
'unlinkSync',
'writeFileSync'
]
const collector = createGatedCallCollector(
[
{
modules: ['fs', 'node:fs', 'original-fs', 'graceful-fs'],
advice: Object.fromEntries(SYNC_FS.map((name) => [name, ADVICE]))
}
],
'main sync-fs'
)
function isScannedPath(rel) {
return /\.[cm]?[jt]sx?$/.test(rel) && !rel.endsWith('.d.ts') && !isTestOnlySourcePath(rel)
}
export function countSyncFsCalls(rel, source) {
return collector.collectUses(rel, source).count
}
export function collectMainSyncFsCounts(root = process.cwd()) {
const counts = new Map()
for (const [rel, source] of readTrackedSources(root, SCAN_ROOTS, isScannedPath)) {
const count = countSyncFsCalls(rel, source)
if (count > 0) {
counts.set(rel, count)
}
}
return counts
}
export function main(root = process.cwd(), arg = undefined) {
return runCountRatchet(
{
name: 'main-sync-fs',
baselinePath: BASELINE_PATH,
header: [
`# Synchronous node:fs calls in production src/main, per file: ${SYNC_FS.join(', ')}.`,
'# Startup-only or one-shot uses are fine to keep; per-RPC, per-spawn, per-focus or per-poll uses are the target.',
'# This is a RATCHET: counts may only go DOWN.',
'# Prune after removing calls: pnpm check:main-sync-fs-ratchet --prune'
],
collect: collectMainSyncFsCounts,
unit: 'sync fs call(s)',
fix: [
`Sync fs blocks the Electron main thread and every window with it: ${ADVICE}.`,
`A one-shot startup or shutdown use may raise the file's count in ${BASELINE_PATH} with reviewer sign-off.`
]
},
root,
arg
)
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
process.exit(main(process.cwd(), process.argv[2]))
}
@@ -0,0 +1,81 @@
import process from 'node:process'
import { pathToFileURL } from 'node:url'
import ts from 'typescript-api'
import { readTrackedSources, runCountRatchet } from '../../ratchet-baseline/ratchet-baseline.mjs'
import { isTestOnlySourcePath } from '../../process-boundaries/test-only-source-path.mjs'
// Fixed-cadence polls that never back off, settle or pause while hidden were the most common perf fix class (#39734, #38902, #33829, #39650).
const BASELINE_PATH = 'config/recurring-timer-baseline.txt'
const SCAN_ROOTS = ['src/main', 'src/renderer/src', 'src/shared', 'src/cli']
const TIMER_HOSTS = new Set(['window', 'globalThis', 'self', 'global'])
function isScannedPath(rel) {
return /\.[cm]?[jt]sx?$/.test(rel) && !rel.endsWith('.d.ts') && !isTestOnlySourcePath(rel)
}
function isIntervalCallee(node) {
if (ts.isIdentifier(node)) {
return node.text === 'setInterval'
}
return (
ts.isPropertyAccessExpression(node) &&
node.name.text === 'setInterval' &&
ts.isIdentifier(node.expression) &&
TIMER_HOSTS.has(node.expression.text)
)
}
export function countRecurringTimers(rel, source) {
if (!source.includes('setInterval')) {
return 0
}
const file = ts.createSourceFile(rel, source, ts.ScriptTarget.Latest, true)
let count = 0
const visit = (node) => {
if (ts.isCallExpression(node) && isIntervalCallee(node.expression)) {
count += 1
}
ts.forEachChild(node, visit)
}
visit(file)
return count
}
export function collectRecurringTimerCounts(root = process.cwd()) {
const counts = new Map()
for (const [rel, source] of readTrackedSources(root, SCAN_ROOTS, isScannedPath)) {
const count = countRecurringTimers(rel, source)
if (count > 0) {
counts.set(rel, count)
}
}
return counts
}
export function main(root = process.cwd(), arg = undefined) {
return runCountRatchet(
{
name: 'recurring-timer',
baselinePath: BASELINE_PATH,
header: [
'# setInterval calls in production src/main, src/renderer, src/shared and src/cli, per file.',
'# This is a RATCHET: counts may only go DOWN.',
'# Prune after removing intervals: pnpm check:recurring-timer-ratchet --prune'
],
collect: collectRecurringTimerCounts,
unit: 'setInterval call(s)',
fix: [
'A fixed-cadence interval keeps working when nothing changes, the window is hidden or its dependency keeps failing.',
'Prefer a push signal; otherwise use installWindowVisibilityInterval (renderer) or a timer that backs off and stops when idle.',
`An interval whose cadence is the feature (a clock, a heartbeat with a stop) may raise the file's count in ${BASELINE_PATH} with reviewer sign-off.`
]
},
root,
arg
)
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
process.exit(main(process.cwd(), process.argv[2]))
}
+2
View File
@@ -226,6 +226,8 @@
"build:packages": "node config/scripts/workspace-package-build/build-workspace-packages.mjs",
"check:process-host-imports": "node config/scripts/static-analysis/process-boundaries/check-process-host-imports.mjs",
"check:main-sync-spawn-ratchet": "node config/scripts/static-analysis/process-boundaries/check-main-sync-spawn-ratchet.mjs",
"check:main-sync-fs-ratchet": "node config/scripts/static-analysis/ratchets/runtime-lifecycle/check-main-sync-fs-ratchet.mjs",
"check:recurring-timer-ratchet": "node config/scripts/static-analysis/ratchets/runtime-lifecycle/check-recurring-timer-ratchet.mjs",
"check:compat-boundary-imports": "node config/scripts/static-analysis/process-boundaries/check-compat-boundary-imports.mjs",
"check:import-boundaries": "bun config/scripts/static-analysis/process-boundaries/check-import-boundaries.mjs"
},