Skip to content

refactor(shared): one errorMessage helper in a new shared module - #1849

Merged
V3RON merged 9 commits into
mainfrom
task/1442
Nov 25, 2026
Merged

V3RON merged 9 commits into
mainfrom
task/1442

Conversation

@V3RON

@V3RON V3RON commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1442

Status

Implement: done (build 4/4, audit 3/3, fix 4/4) Review: r1 + fix-check + r2 (spec) passed, 0 open Hardware: n/a Gate: running
Next: gate on #1849 (the whole stack)

Done when

  • src/shared/ exists with an index.ts exporting errorMessage, an AGENTS.md holding the admission rule of Modules touched, and a CLAUDE.md holding @AGENTS.md; docs/internal/ARCHITECTURE.md's module table has a shared row linking that manual, and its dependency table has a shared-imports-nothing row — src/shared/index.test.ts and src/docs-manuals.repo.test.ts pass; rows read in review.
  • .dependency-cruiser.mjs has shared-imports-nothing and shared-imports-nothing-unresolved, and cli-router-imports-no-component-values, updater-imports-little and modules-imports-little allow src/shared/, and they and host-load-imports-ports-only say so in their comments — src/lint-rules.test.ts B2/B3 pathCases; comments read in review.
  • Architecture rule 18 states the exception for a module that imports nothing and that no host wires, and always-in-scope item 9 agrees with it — read in review (claims lens, 0 findings).
  • git grep -nE 'instanceof Error \? [A-Za-z_.]+\.message : String\(' -- 'src/*.ts' ':!*.test.ts' prints exactly one line, in src/shared/, and git grep -n 'function errorMessage' -- 'src/*.ts' prints exactly one line, in src/shared/. The two test-file unwraps of F3 remain — both greps run in the audit; code lens re-derived all 98 converted files.
  • src/mcp/connect.ts calls the shared helper and has no isSimlockError fast path of its own — read in the audit and review; B1's SimlockError case.
  • X7's and X10's manual lines, map rows and rule comments are true of the new imports — fixed in review round 1 (R1), fix-check passed at 4c0c079.
  • src/lint-rules.test.ts holds the cases and the copy check of Tests, and src/cli/lazy-loading.test.ts passes unchanged — both files run in the audit; lazy-loading test not in the diff.
  • pnpm check passes — CI at the head commit (checked before the gate).

Assumptions

none

Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 1 blocking, 1 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 2. Tokens: 2.1M.
Runs: 9. Cost USD: 3.1936. Agent seconds: 1477.

Assessment: complete

Completion conditions

  • src/shared/ exists, exports errorMessage, and its manual says what may go in it — src/shared/index.ts, src/shared/AGENTS.md; Done when line 1.
  • The unwrap grep of Existing code prints one line, in src/shared/, and so does git grep -n 'function errorMessage' -- 'src/*.ts' — Done when line 4.
  • A file in src/shared/ importing anything but a sibling fails pnpm lint — src/lint-rules.test.ts B2 pathCases.
  • A hand-written unwrap added outside src/shared/ fails pnpm check — the copy check in src/lint-rules.test.ts (B4), probed in the audit.
  • src/cli/lazy-loading.test.ts passes unchanged, and pnpm check passes — Done when lines 7 and 8.

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds and exports errorMessage from src/shared/, then replaces repeated error-message conversions across source modules with calls to that helper. It adds dependency rules that constrain imports from shared and allow specified modules to import it. Tests cover the helper, import rules, and duplicate-formatting checks. Documentation updates describe the shared module and its import boundaries.

Suggested reviewers: leonardoxr

Merge Risk: Minimal · up to 4c0c0

This refactor centralizes error-message formatting without changing behavior. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a new shared module (src/shared/) that holds one errorMessage helper, replacing the duplicated local error-unwrap helpers and inline Error/String conversions across sr…
Description check Passed The description ties to the changeset. It references issue #1442, the new src/shared/ module with its index.ts, AGENTS.md and CLAUDE.md, the dependency-cruiser rules, the architecture documentation, t…
Linked Issues check Passed [#1442] Coding requirements checked against the whole-PR summary and the reviewed head:

- Shared module: src/shared/index.ts re-exports errorMessage from src/shared/error-message.ts. `src/share…
Out of Scope Changes check Passed Changes outside the listed site modules are supporting work for #1442:

- .dependency-cruiser.mjs, src/lint-rules.test.ts: rules and tests for shared.
- docs/internal/ARCHITECTURE.md, `docs/in…
Full details: Title check

Explanation

The title names the main change: a new shared module (src/shared/) that holds one errorMessage helper, replacing the duplicated local error-unwrap helpers and inline Error/String conversions across src/. The refactor(shared) prefix matches the changeset, and the title is concise and specific.

Full details: Description check

Explanation

The description ties to the changeset. It references issue #1442, the new src/shared/ module with its index.ts, AGENTS.md and CLAUDE.md, the dependency-cruiser rules, the architecture documentation, the errorMessage greps, and the src/mcp/connect.ts change. It is somewhat process-heavy, but it describes the actual changes.

Full details: Linked Issues check

Explanation

[#1442] Coding requirements checked against the whole-PR summary and the reviewed head:

  • Shared module: src/shared/index.ts re-exports errorMessage from src/shared/error-message.ts. src/shared/AGENTS.md and CLAUDE.md state the admission rule and @AGENTS.md. Head src/shared/error-message.ts returns error instanceof Error ? error.message : String(error).
  • Hand-written copies: the summary lists removal of local errorMessage definitions in src/cli/errors.ts, src/core/doctor-types.ts, src/daemon/composition-support.ts, src/daemon/server-connection.ts, src/drivers/ios/command-run.ts, src/gateway/worker-link.ts, src/http/app-helpers.ts, src/mcp/connect.ts, and src/drivers/android/*. Inline unwraps in the listed site modules are converted to the helper.
  • src/mcp/connect.ts: base had a local errorMessage with an isSimlockError branch. Head imports the shared helper and has no fast path. Base and head behavior match only when SimlockError is an Error subclass with the same message. The shared helper test covers an Error subclass, which supports this. This is the one point that depends on code not read in this review.
  • Dependency rules: .dependency-cruiser.mjs adds shared-imports-nothing and shared-imports-nothing-unresolved, and allows src/shared/ in cli-router-imports-no-component-values, updater-imports-little, and modules-imports-little. src/lint-rules.test.ts adds pathCases for these rules and a source-wide copy check.
  • Docs: docs/internal/ARCHITECTURE.md, docs/internal/agent-rules/architecture.md (rule 18), and always-in-scope.md (item 9) are updated for shared, as the issue requires.
  • Tests: src/shared/index.test.ts covers helper behavior. The summary reports the audit results and the 0-open review ledger, which were not re-run here.

The issue's exclusions (ui/, e2e/, packages/, test files) are kept, as the summary states. Non-coding items (manual checks, release steps) do not affect this verdict.

Full details: Out of Scope Changes check

Explanation

Changes outside the listed site modules are supporting work for #1442:

  • .dependency-cruiser.mjs, src/lint-rules.test.ts: rules and tests for shared.
  • docs/internal/ARCHITECTURE.md, docs/internal/agent-rules/*, and per-module AGENTS.md files: manual and map updates that the issue requires (X7, X9, X10).
  • Import-split edits, such as src/cli/commands/config.ts, src/daemon/server-requests.ts, src/daemon/worker-composition.ts, and src/drivers/ios/*.ts: these move the errorMessage import to shared or split an existing import in the same file. They do not change runtime logic.
  • src/shared/*: the new leaf module.

No change was found that is unrelated to the errorMessage conversion, the dependency rules, or the required docs. The summary does not show changes to ui/, e2e/, packages/, or test-file unwraps, which the issue excludes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 4fa01fdf-4a34-4500-9891-01e51e7edb17
Commits

Reviewing files that changed from the base of the PR and between 200afe5 and 4c0c079.

Files selected for processing: 113

  • .dependency-cruiser.mjs
  • docs/internal/ARCHITECTURE.md
  • docs/internal/agent-rules/always-in-scope.md
  • docs/internal/agent-rules/architecture.md
  • src/agent-device/front/context.ts
  • src/agent-device/front/front.ts
  • src/agent-device/front/orientation.ts
  • src/agent-device/front/renewals.ts
  • src/agent-device/host/agent-device-supervisor.ts
  • src/agent-device/host/host.ts
  • src/agent-identity/AGENTS.md
  • src/cli/AGENTS.md
  • src/cli/args.ts
  • src/cli/commands/config.ts
  • src/cli/commands/lease.ts
  • src/cli/commands/setup.ts
  • src/cli/environment.ts
  • src/cli/errors.ts
  • src/core/baselines.ts
  • src/core/create-core.ts
  • src/core/device-root.ts
  • src/core/doctor-types.ts
  • src/core/doctor.ts
  • src/core/instance-identity.ts
  • src/core/physical-auto-enrollment.ts
  • src/core/physical-enrollment.ts
  • src/core/reclaim-coordinator.ts
  • src/core/registry-rows.ts
  • src/core/usage/read-thread.ts
  • src/daemon/AGENTS.md
  • src/daemon/composition-support.ts
  • src/daemon/dispatch.ts
  • src/daemon/dispatcher-devices.ts
  • src/daemon/gateway-uplink.ts
  • src/daemon/main.ts
  • src/daemon/relay.ts
  • src/daemon/server-connection.ts
  • src/daemon/server-hello.ts
  • src/daemon/server-requests.ts
  • src/daemon/server.ts
  • src/daemon/service-main.ts
  • src/daemon/test-relay-support.ts
  • src/daemon/update-coordinator.ts
  • src/daemon/version-check.ts
  • src/daemon/worker-composition.ts
  • src/drivers/AGENTS.md
  • src/drivers/android/adb-server.ts
  • src/drivers/android/device-profile-source.ts
  • src/drivers/android/device-tcp.ts
  • src/drivers/android/input/device-input.ts
  • src/drivers/android/screen/scrcpy-link.ts
  • src/drivers/android/screen/session.ts
  • src/drivers/android/seeds.ts
  • src/drivers/android/system-images.ts
  • src/drivers/ios/boot-courtesies.ts
  • src/drivers/ios/command-run.ts
  • src/drivers/ios/components.ts
  • src/drivers/ios/device-set-leftovers.ts
  • src/drivers/ios/device-tcp.ts
  • src/drivers/ios/index.ts
  • src/drivers/ios/input/device-input.ts
  • src/drivers/ios/lineage-files.ts
  • src/drivers/ios/physical.ts
  • src/drivers/ios/seeds.ts
  • src/drivers/ios/simctl.ts
  • src/drivers/ios/slim-boot.ts
  • src/fseventsd/worker.ts
  • src/gateway/component-relay.ts
  • src/gateway/drain-store.ts
  • src/gateway/ended-lease-ids.ts
  • src/gateway/fleet-dispatch.ts
  • src/gateway/fleet-forwarding.ts
  • src/gateway/fleet-grant.ts
  • src/gateway/test-dispatcher.ts
  • src/gateway/test-fleet.ts
  • src/gateway/test-relay.ts
  • src/gateway/worker-link.ts
  • src/gateway/worker-registry.ts
  • src/history/index.ts
  • src/history/versions.ts
  • src/host-load/sampler.ts
  • src/http/app-helpers.ts
  • src/http/app.ts
  • src/lease-files/store.ts
  • src/leasing/acquisition-errors.ts
  • src/leasing/create-leasing.ts
  • src/leasing/lease-release-coordinator.ts
  • src/leasing/test-lease-acquisition.ts
  • src/leasing/testing.ts
  • src/lint-rules.test.ts
  • src/mcp/connect.ts
  • src/mcp/session.ts
  • src/modules/host.ts
  • src/ports/ipc.ts
  • src/ports/logging-process-runner.ts
  • src/ports/service-manager.ts
  • src/ports/sqlite.ts
  • src/ports/uplink-websocket.ts
  • src/ports/worker-lock.ts
  • src/shared/AGENTS.md
  • src/shared/CLAUDE.md
  • src/shared/error-message.ts
  • src/shared/index.test.ts
  • src/shared/index.ts
  • src/simlock-client/client-errors.ts
  • src/simlock-client/remote-connector.ts
  • src/simlock-client/wire.ts
  • src/state/AGENTS.md
  • src/state/open.ts
  • src/stream/gateway-link.ts
  • src/stream/service.ts
  • src/tunnel/sessions.ts
  • src/updater/main.ts
Files with no reviewable changes: 3

  • src/core/doctor-types.ts
  • src/daemon/server-connection.ts
  • src/http/app-helpers.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Finishing Touches
Fix failing CI checks

  • Commit to this branch
  • Create a new PR

@V3RON

V3RON commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: 22aa318
Round fix-check: 4c0c079
Round 2: 4c0c079

Runs: 9. Cost USD: 3.1936. Agent seconds: 1477.
Tokens input 210, output 60127, cache read 6682655, cache write 517667.
- build implementer: claude-sonnet-5-5 373 s $0.7413
- audit implementer: claude-sonnet-5-5 322 s $0.1873
- review 1 reviewer: claude-sonnet-5-5 322 s $0.2314
- review 1 code behaviour: claude-opus-5-5 256 s $1.2591
- review 1 claims: claude-sonnet-5-5 23 s $0.1489
- fix 1 implementer: claude-sonnet-5-5 28 s $0.1175
- review fix-check reviewer: claude-sonnet-5-5 36 s $0.1272
- review 2 reviewer spec: claude-sonnet-5-5 72 s $0.0995
- review 2 spec spec: claude-sonnet-5-5 45 s $0.2814
Finding outcomes: {"fixed":1}. Classes: {"architecture 13 manual made false":1}.
{"findings":[{"id":"R1","role":"code","class":"architecture 13 manual made false","outcome":"fixed","path":"src/drivers/AGENTS.md","round":"1","fix":"4c0c079e8a5756741ea9efed9d2a052d33a252ea"}]}

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review November 25, 2026 09:00
@V3RON
V3RON merged commit cc79ffe into main Nov 25, 2026
80 of 82 checks passed
@V3RON
V3RON deleted the task/1442 branch November 25, 2026 09:35
V3RON added a commit that referenced this pull request Nov 25, 2026
Agents now search code shapes with ast-grep instead of grep, so a
helper's body written out again is easy to find. This follows the
[ast-grep guide for AI
agents](https://ast-grep.github.io/advanced/prompting.html): a standing
`AGENTS.md` instruction plus its agent skills.

- `@ast-grep/cli` 0.51.3 is a dev dependency (`pnpm exec ast-grep`),
allowed to build its binary, and ignored by Fallow because nothing
imports it.
- `AGENTS.md` gains a Code search section; `EXPLORATION.md` points to
it.
- `toolchain.md` lists the commands and six traps, each measured on this
repo.
- `.claude/settings.json` loads ast-grep's plugin (two skills) from an
inline marketplace pinned to `0613dc7f`, because a plugin can add hooks.
A new machine runs `claude plugin install ast-grep@simlock-pinned
--scope project` once.

ast-grep is for search only; lint rules stay in oxlint and
`src/lint-rules.test.ts`.

How I checked it:
- On the pre-#1849 tree, one shape search found 107 copies of the
error-message fallback, against 12 named helpers.
- grep finds 0 of the 2 multi-line `<div onClick>` in `ui/src`; ast-grep
finds both.
- A/B: 6 Opus agents, 3 with the skill, all scored 100%. The skill ships
because the guide recommends it.
- A headless session in a fresh worktree lists both skills.

## Review

Spec review: skipped. Code review: skipped. Claims review: 1 blocking, 1
fixed, 0 notes.
Rounds: 2. Tokens: 0.8M.
Runs: 3. Cost USD: 0.4263. Agent seconds: 152.

Assessment: complete

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared helper: errorMessage for the error-message unwrap

1 participant