Repository navigation
Description
Overview
ADR-049 reserves $effect for pushing state out to non-reactive systems (DOM, timers, platform listeners). Its own rationale says a crisp rule is enforceable where "use effects sparingly" is not, but nothing enforces it: a code-reading review found 46 production $effect call sites, 11 of which write reactive state. This issue adds a checker so every new effect is a reviewed decision.
Problem Statement
The rule lives only in an ADR and in review. Other rules of the same kind already have a script in the push check: scripts/check-node-type-literals.ts for literal node-type comparisons and scripts/check-lifecycle-reads.ts for lifecycle_status reads. Effects have none, so a state-syncing effect can be added without anyone deciding it should exist.
Proposed Solution
A scripts/check-effects.ts that scans packages/desktop-app/src for $effect(, $effect.pre( and $effect.root( in .svelte and .svelte.ts/.ts files outside tests, and fails on any call site not in an allowlist. Each allowlist entry names the file, the count of effects allowed in it, and what external system each one drives. The checker runs in the push check and in bun run test:scripts.
Documentation
- ADR-049 Decision item 4 and the Rationale point "A crisp
$effectrule is enforceable" - the rule this enforces. - ADR-047 - what the push check and the merge gate run.
- Code Quality - where the frontend rules are listed.
- Updates: an amendment to ADR-049 saying the rule is enforced by the checker and how an effect is added to the allowlist;
code-quality.md; the gate description and the Development Standards section inAGENTS.md.
Architecture Impact
Extends ADR-049 with enforcement; reverses nothing. The companion nodespace-docs change is an amendment to ADR-049, made in the same change as the code. Unlike the sync-boundary ban, this checker has an allowlist by design: effects that drive the DOM are legitimate.
Acceptance Criteria
-
scripts/check-effects.tsfails, naming file and line, on an$effect,$effect.preor$effect.rootcall that the allowlist does not cover - It fails on an allowlist entry whose file no longer has that many effects, so the list cannot go stale
- Doc comments and strings containing
$effectare not counted (the review's first grep counted two doc-comment lines) - Test files are exempt
- Every effect in the allowlist at the time of merge has a stated external system; an effect that writes reactive state is either removed first or listed with the reason it stays
- The checker runs in the push check and in
bun run test:scripts, andscripts/gate-scope.tsroutes a frontend-only diff to it -
scripts/check-effects.test.tscovers a new effect, a removed effect, a comment, and a test file; it is DOM-free and importsbun:test - ADR-049,
code-quality.mdandAGENTS.mddescribe the check -
bun run test:scriptspasses;bun run quality:fixis clean
Technical Specifications
Reference Files
scripts/check-node-type-literals.tsandscripts/check-lifecycle-reads.ts(with their.test.ts) - the pattern to follow for scanning, reporting and testsscripts/test-gate.ts- where the push check's lint section lists its checksscripts/gate-scope.ts- which tiers a diff reaches
Implementation Details
- Tooling under
scripts/is TypeScript run withbun run; tests there usebun:testand must stay DOM-free. - Count per file rather than pinning line numbers, so unrelated edits to a file do not break the check.
- Keep the allowlist in the checker or beside it as data, one entry per file, each with a short reason.
Dependencies
- Remove dead editor workarounds and state-writing effects that ADR-049 forbids #4378 (removes effects that should not be allowlisted)
Related Issues
- Outline rows read their node from the store by id, with callback props instead of dispatched events #4379
- An explicit edit session owns a focused node's draft and caret, replacing the timer-arbitrated editor bridge #4380
- Separate confirmed and pending node state in SharedNodeStore so remote updates always apply #4381
Non-Goals
- Judging what an effect's body does. The checker makes each new effect visible in a diff; review decides whether it is legitimate.
Activity
malibio commentedon Nov 28, 2026
Moved to NodeSpace: the issue "A new effect outside a reviewed allowlist fails the push check" (
e4d933d6-86f9-4dd1-aac5-d4024d1aee6e) in the NodeSpace workspace. The team's work is tracked there, so this GitHub copy is closed to keep its status in one place.