Skip to content

Push check fails on a new $effect outside a reviewed allowlist #4382

Not planned

Description

@malibio

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 $effect rule 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 in AGENTS.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.ts fails, naming file and line, on an $effect, $effect.pre or $effect.root call 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 $effect are 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, and scripts/gate-scope.ts routes a frontend-only diff to it
  • scripts/check-effects.test.ts covers a new effect, a removed effect, a comment, and a test file; it is DOM-free and imports bun:test
  • ADR-049, code-quality.md and AGENTS.md describe the check
  • bun run test:scripts passes; bun run quality:fix is clean

Technical Specifications

Reference Files

  • scripts/check-node-type-literals.ts and scripts/check-lifecycle-reads.ts (with their .test.ts) - the pattern to follow for scanning, reporting and tests
  • scripts/test-gate.ts - where the push check's lint section lists its checks
  • scripts/gate-scope.ts - which tiers a diff reaches

Implementation Details

  • Tooling under scripts/ is TypeScript run with bun run; tests there use bun:test and 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

Related Issues

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

  1. malibio commented on Nov 28, 2026

    @malibio
    CollaboratorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions