Skip to content

chore(dx): add scoped-verify wrapper + enforce filtered verify on low-end HW#424

Merged
qnbs merged 2 commits into
mainfrom
chore/scoped-verify
Jul 14, 2026
Merged

chore(dx): add scoped-verify wrapper + enforce filtered verify on low-end HW#424
qnbs merged 2 commits into
mainfrom
chore/scoped-verify

Conversation

@qnbs

@qnbs qnbs commented Jul 14, 2026

Copy link
Copy Markdown
Owner

What

pnpm verify / pnpm verify:test / pnpm verify:lint — a wrapper that derives the affected workspaces from the git diff and runs one filtered turbo invocation with --concurrency=1.

The unfiltered typecheck / test scripts stay as they are, for CI.

Why

A bare turbo run typecheck runs all five tasks — ai-core build + typecheck, ui build + typecheck, web typecheck. Measured on the dual-core / ~4 GB machine this repo is developed on, that is 6–9 minutes cold. Scoped to the workspace a PR actually touches, most of that work disappears.

The gap is large enough that "remember to pass --filter" is not a workable rule. It gets forgotten, and forgetting it is what caused a tsc --noEmit to sit at 848 MB for 28 minutes and hard-freeze the editor earlier today. So the scoping is derived, not remembered.

How it scopes

Diff touches Filter
apps/web/** @cannaguide/web
apps/desktop/** @cannaguide/desktop
packages/ai-core/** @cannaguide/ai-core... (library → pull in its consumers)
packages/ui/** @cannaguide/ui...
nothing in a workspace exit 0, no workspace touched — skip verify

The diff is taken against the merge-base, not against origin/main's tip — otherwise every commit that lands on main while a branch is open would widen that branch's scope.

Verified

Both paths exercised:

# on this branch (only scripts/, package.json, CLAUDE.md)
$ pnpm verify
[verify] no workspace touched — skip verify

# on ci/phantom-dependency-guard (touches apps/web + packages/ai-core)
[verify] affected workspaces: @cannaguide/ai-core, @cannaguide/web
[verify] → pnpm exec turbo run typecheck --concurrency=1 \
             --filter=@cannaguide/ai-core... --filter=@cannaguide/web

One scoped command, not five tasks.

An honest caveat

This does not make a cold apps/web typecheck fast — that is 6–9 minutes on this hardware no matter how it is invoked, and no scoping changes it. What the wrapper removes is the other four tasks, which is most of the waste on a PR that only touches one workspace.

CLAUDE.md

Added, recording the rule and one more thing that mattered in practice: work each PR on a named branch, never a detached HEAD — every switch in detached HEAD invalidates the turbo hash, so the cache never hits and every run is cold.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added verification commands for type checking, tests, linting, and builds.
    • Verification now focuses on affected workspace packages and their dependents.
    • Added clear handling for unchanged workspaces and unsupported verification tasks.
  • Documentation

    • Added development workflow guidance, including verification practices, branch requirements, and repository language conventions.

…-end HW

A bare `turbo run typecheck` runs all five tasks -- ai-core build + typecheck,
ui build + typecheck, web typecheck -- and takes 6-9 minutes cold on the
dual-core / ~4 GB machine this repo is developed on. Scoped to the one workspace
a PR actually touches, the same check finishes in well under a minute. That gap
is large enough that "remember to pass --filter" is not a workable rule; it gets
forgotten, and the forgetting is expensive.

scripts/scoped-verify.mjs derives the affected workspaces from the diff against
the merge-base (not against origin/main's tip, which would widen the scope every
time something lands on main while a branch is open), maps them to package names,
and builds a single filtered turbo invocation with --concurrency=1. Changing
ai-core or ui pulls their consumers in via turbo's trailing `...`. A diff that
touches no workspace at all exits 0 without running anything.

Exposed as `pnpm verify`, `pnpm verify:test`, `pnpm verify:lint`. The unfiltered
`typecheck` / `test` scripts stay for CI, which runs on hardware that can afford
them.

CLAUDE.md records the rule, and that PRs are worked on named branches: a detached
HEAD invalidates the turbo hash on every switch, so the cache never hits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
canna-guide-2025-web Ready Ready Preview, Comment Jul 14, 2026 12:21pm

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@qnbs, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: af0c3c54-5916-4d44-a488-f249305f6a16

📥 Commits

Reviewing files that changed from the base of the PR and between 2a43cec and 49a2491.

📒 Files selected for processing (1)
  • scripts/scoped-verify.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/scoped-verify

Comment @coderabbitai help to get the list of available commands.

@deepsource-io

deepsource-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in bcbc97f...49a2491 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Docker Jul 14, 2026 12:21p.m. Review ↗
JavaScript Jul 14, 2026 12:21p.m. Review ↗
Python Jul 14, 2026 12:21p.m. Review ↗
Rust Jul 14, 2026 12:21p.m. Review ↗
Shell Jul 14, 2026 12:21p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@qnbs
qnbs marked this pull request as ready for review July 14, 2026 12:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/scoped-verify.mjs`:
- Line 75: Replace the non-ASCII characters in the console output strings within
the scoped verification script, including the messages near the no-workspace and
related output lines, with ASCII-only equivalents while preserving their
meaning.
- Around line 95-96: Update the launcher around spawnSync in the run flow to
invoke pnpm reliably on Windows, matching the platform-handling approach used by
the other launcher scripts; preserve the existing arguments, inherited stdio,
and exit-status propagation for non-Windows platforms.
- Around line 56-64: Update affectedWorkspaces to recognize shared
repository-root files such as package.json, pnpm-lock.yaml, tsconfig.json, and
turbo.json and mark every workspace as affected when any is present. Preserve
the existing prefix-based handling for workspace-specific files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ac97da31-d54b-4d4b-9b37-d83a2c165f21

📥 Commits

Reviewing files that changed from the base of the PR and between bcbc97f and 2a43cec.

📒 Files selected for processing (3)
  • CLAUDE.md
  • package.json
  • scripts/scoped-verify.mjs

Comment thread scripts/scoped-verify.mjs
Comment thread scripts/scoped-verify.mjs Outdated
Comment thread scripts/scoped-verify.mjs Outdated
- Shared root inputs were a hole, and a bad one: a change to package.json,
  pnpm-lock.yaml, pnpm-workspace.yaml, tsconfig*.json, turbo.json or .npmrc
  matches no workspace prefix, so `affected` came back empty and verify skipped
  entirely -- on exactly the changes that move the ground under every workspace
  at once. Those inputs now widen the scope to all of them. (This PR is its own
  test case: it touches package.json, and verify now fans out to all four.)

- pnpm is a .cmd shim on Windows, which spawnSync cannot execute without a shell
  since Node's CVE-2024-27980 fix. `shell: isWindows`, mirroring
  gitkraken-mcp-launcher and graphify-mcp-doctor. The argv is built entirely from
  literals in this file, never from the diff, so the shell has nothing to inject
  into -- noted in a comment so it stays that way.

- Replaced the em dash and arrow in the output with ASCII.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@qnbs

qnbs commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@qnbs
qnbs merged commit 7e203cf into main Jul 14, 2026
33 checks passed
@qnbs
qnbs deleted the chore/scoped-verify branch July 14, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant