refactor(contracts): declare the scroll reasons in one typed table with their owning command

Merged
TH
7d ago
+106-46

Summary

error.details.reason is published vocabulary, but most reasons are string literals at new AppError(...) sites with no owner. This PR sets the pattern on the scroll family.

  • packages/contracts/src/scroll-reasons.ts declares SCROLL_REASONS: one row per reason, { reason, command }, typed by CommandReasonRow. No prose.
  • All 12 scroll construction sites read SCROLL_REASONS.<member>.reason. An undeclared reason does not compile. Wire values are unchanged; the tests that pin the literals are untouched.
  • The table supersedes SCROLL_REFRESH_REFUSALS and SCROLL_KEYBOARD_OCCLUDES_SURFACE_REASON. The runner row for the keyboard refusal carries no reason, so the table is its only source.
  • test/repo-guards/command-reason-owners.test.ts checks every row: its command is a CLI command and no two rows share a reason. The command reference will read the table directly when it prints refusal reasons.
  • commands.md now names the seven scroll reasons it omitted.

Not device-facing: behavior and wire output are unchanged.

Value

basehead
R89 untyped reason sites388 in 194 files378 in 190 files
Scroll reasons with a declared owner012
Scroll reasons checked against commands.md012

Validation

At b844ca59d6, local: pnpm build; check:layering, check:fallow, check:production-exports, check:command-docs, check:daemon-wire-compat, check:quick all pass; 276 unit-core files (3373 tests) pass, including the eager-closure budget, repo guards, and the scroll tests in contracts, daemon, capture-kit, platform-apple and platform-android. CI owns the full suite.

Risk: the eager-closure budget admits a new table module only at flat statement weight. Here three superseded statements pay for it; later families need the same or a maintainer decision.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.