Repository navigation
Add the Pro-boundary ratchet check and the Pro/sync placement rule - #3376
Conversation
99caa1d to
5f90318
Compare
|
Design deviation from issue #3299, requested by the coordinator: a one-way ratchet instead of an exact one. The issue specifies exact baselines that also fail when a count drops. With many Pro-removal PRs landing in parallel, that forces every other open PR to rebase just to edit
Trade-off: while Pro code remains, headroom between a count and its baseline can be spent by new Pro code until someone tightens. The notice makes tightening a copy-paste and removal PRs should tighten in the same diff when it is cheap. Also done in this update: rebased onto A fresh pragmatic review of the new head follows. |
Pragmatic code review: PR #3376 (initial review of head 5f90318)Review Type: Initial Review (medium effort) Summary: Net positive and close to mergeable. The checker is small, git-based, well commented, and the one-way ratchet is implemented consistently in the checker, its header comment, CLAUDE.md, the tests and the PR text. No blockers. I would do items 1 and 2 below before merging (both cheap); item 3 is the real hazard of the one-way design and is mostly a documentation fix plus a follow-up. Requirements Check (issue #3299)
Verification I ran: Code Review FindingsCritical / BlockerNone. Improvements1. [Improvement, fix before merge] The CLI usage test is the flakiest test in the file and the checker scans the whole repo before it validates its arguments.
2. [Improvement, fix before merge] The ratchet starts loose because the baselines are already stale against 3. [Improvement] Spending headroom is invisible to the gate and the CLI, and the CLAUDE.md wording overstates what the check catches.
Nits
Things I checked that are fine
Recommendation: APPROVE. No blockers. Please address items 1 and 2 in the address-review pass (both are small), and decide on item 3's CLAUDE.md wording now and the delta-warning as a follow-up. Merge stays gated on the ADR-081 / ADR-084 checks and the user's go-ahead. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment; GitHub blocks self-approval). Full findings in the review comment above.
5f90318 to
7e83205
Compare
Address-review summary (round 1)Responding to the review of head Addressed
Also done in this round (coordinator request, not from the review): exemptions are now allowed on the four installer recognition points via an explicit whole-path allowlist ( Skipped, with reasons
Verification: 225 tests pass in the checker's test file, Re-Review DecisionDecision: RE-REVIEW NEEDED (delta only). Rationale: the CLI entry block was restructured (argument parsing), and the exemption check gained new allowlist logic with its own tests. Both are logic changes rather than wording. A delta re-review of the commits since |
Pragmatic code review: PR #3376 (re-review, delta 6b3b96d..7e83205)Review Type: Re-Review (delta 6b3b96d..7e83205, medium effort) Previous Review Summary: 6 recommendations (3 improvements, 3 nits). 3 improvements addressed and verified, nits handled as stated (ADR-084 added to the pre-merge list; the other two consciously skipped with reasons I accept). New issues found in the delta: 1 improvement, 2 nits. No blockers. Previous feedback, verified by running it
Requirements check (delta)
Code review findingsCritical / BlockerNone. Improvements1. [Improvement] The allowlist names Nits
Things I checked that are fine
Recommendation: APPROVE. Improvement 1 is a wrong claim about what the ADRs allow (plus one unneeded allowlist slot on a file that #3349 strips), cheap to fix in the same pass; the nits are optional. Merge stays gated on the ADR-081 / ADR-084 checks and the user's go-ahead. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment; GitHub blocks self-approval). Full findings in the review comment above.
7e83205 to
0b4a055
Compare
Address-review summary (round 2)Responding to the re-review of the delta Addressed
Baselines were regenerated again from Verification: 225 tests pass in the checker's test file, Re-Review DecisionDecision: NO RE-REVIEW NEEDED. Rationale: this round changed comments, CLAUDE.md wording and PR text, and added test cases (two near-miss names, two arguments). No checker logic changed. The one logic-bearing area the re-review covered ( |
…loses #3299) scripts/check-pro-boundary.ts counts eleven Pro/sync line markers plus Pro-named files across packages/, scripts/ and README.md, and fails when any count moves off its checked-in baseline in either direction. Files come from git ls-files so gitignored build output stays out of the counts. Each baseline sits under its own comment line so the merge queue's cherry-pick replay only conflicts PRs that change the same marker. Test-file exemptions are per file and per marker, and fail once stale. CLAUDE.md gains the "Pro / Sync Boundary" section (placement rule, the three accepted baseline-raise classes, the absence-test convention) and a Finding Tasks paragraph routing Pro/sync issues to nodespace-sync; the issue management skill gets the same routing as Step 0. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…lternative Co-Authored-By: Claude Sonnet 5 <[email protected]>
A count above its baseline fails; a count below it prints a notice with the tightened BASELINES block instead of failing, so parallel Pro-removal changes do not each have to rebase just to edit BASELINES. The printed block only lowers ceilings and never raises one. A baseline of 0 fails on any hit, which is the strict end state. CLAUDE.md's Pro / Sync Boundary section says the same. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…eanup proEvents 87 -> 81, cloudWording 89 -> 88, proWording 314 -> 312; every other marker is unchanged. The block was pasted from the checker's own notice. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…nd the free-user wording cleanups proSyncModule 360 -> 370 and proNamedFiles 16 -> 18 come from the planned relocation of the Pro variant machine into its own files; editionBranching 122 -> 113, cloudBindState 322 -> 321, cloudWording 88 -> 87, tenantWording 507 -> 504 and proWording 312 -> 310 come from the removals that landed alongside it. Generated from the checker's own counts. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… ejecting PRs A usage error no longer pays for a full scan or needs a git checkout, proven by running the copied checker in a directory that is not a repository. The test file gets a 30s default timeout because many tests spawn git or bun and bun's 5s default is tight on the loaded machines the merge gate shares with builds. The header comment now says headroom below a ceiling is not permission to add Pro lines. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…headroom rule EXEMPTIBLE_NON_TEST_FILES names the four scripts (cask updater, pkg pre and postinstall, pkg builder) that must name other NodeSpace products to refuse installing over them. Matching is on the whole path; any other non-test file is still reported. CLAUDE.md now says headroom below a baseline is not permission to add Pro lines, and lists the recognition points. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…and app-lib split cloudBindState 321 -> 203, cloudWording 87 -> 82, tenantWording 504 -> 463 and proWording 310 -> 300; every other marker is unchanged. Generated from the checker's own counts. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… more edge cases ADR-084 lists three installer files; postinstall is allowlisted only until its old guard moves to the pre-install stage, and the header, the constant's comment and CLAUDE.md now say so. The rejection test gains extensionless near-miss names that begin with allowlisted paths, and the usage test gains empty-string arguments. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…oval cloudSyncHooks 15 -> 4, cloudWording 82 -> 74, proWording 300 -> 294; every other marker is unchanged. Generated from the checker's own counts. Co-Authored-By: Claude Sonnet 5 <[email protected]>
0b4a055 to
40efa54
Compare
Closes #3299
First step of the Pro/core boundary epic. Core will ship no Pro code (ADR-081, proposed in nodespace-docs); this freezes what is there and makes every later move lower a number. Measures only: no product code changes.
What it adds
scripts/check-pro-boundary.ts: a ratchet in the style ofcheck-code-references.ts. It counts 11 line markers plusproNamedFilesacrosspackages/,scripts/and the rootREADME.md. It fails only when a count rises above its baseline (new Pro code), listing the hits in files this branch changed first. A count below its baseline does not fail: it prints a non-failing notice with the exact tightenedBASELINESblock to paste. CLI: no arguments (table, failures, notices),--list <marker>,--changed.scripts/check-pro-boundary.test.ts(225 tests,bun:test, DOM-free): the enforcement point viabun run test:scriptsand the merge gate.CLAUDE.md: new## Pro / Sync Boundary (CRITICAL)section (placement rule, the three accepted baseline-raise classes, the absence-test convention) and a Finding Tasks paragraph routing Pro/sync issues to nodespace-sync..claude/skills/github-issue-management/SKILL.md:### Step 0: Confirm the issue belongs in nodespace-core.git diff --stat origin/mainlists only those four files.Deviation 1 (design, requested by the coordinator): a one-way ratchet, not an exact one
The issue specifies exact baselines that also fail when a count drops. Many Pro-removal PRs land in parallel, so that would force every other open PR to rebase just to edit
BASELINESevery time one merges, serializing the drain. This PR instead makes the check a one-way ratchet:set BASELINES.<marker> to N, with a justification in the PR description).BASELINESin its own diff and justifies it in its description (the relocation class). The check fails until the diff does; review polices the justification.Trade-off worth knowing: while Pro code remains, headroom between a count and its baseline can be spent by new Pro code until someone tightens. The notice makes tightening a copy-paste, and removal PRs are encouraged to do it in the same diff when cheap. CLAUDE.md is updated to say all of this. One exported function is new:
baselineNotices(counts, baselines?);baselineFailuresno longer reports decreases and no longer appends a paste block.Baselines: set from
mainatdac00a70(after the parallel PRs that had landed)Taken from the checker's own counts on this branch rebased onto
origin/main(1,400+ scanned files, no product code changed). At the issue's base commitaf8ddb61the counts reproduced the issue's table exactly (275, 360, 95, 87, 54, 122, 322, 15, 89, 507, 314, 16). The differences below are what merged since:proCommandsproSyncModuleproProtocolproEventsmembershipServiceeditionBranchingcloudBindStatecloudSyncHookscloudWordingtenantWordingproWordingproNamedFilesproSyncModule360 to 370 andproNamedFiles16 to 18 are the accepted relocation of the Pro variant machine into its own files (already on main); this PR adds no Pro code. If another PR merges first, the checker needs no rebase for a lower count, only a tightening if you want one.Other deviations from the issue, and things worth a look
decisions/081-pro-is-a-separate-app-core-ships-no-pro-code.md). Before merging, re-check that name against nodespace-docsorigin/mainand fix the link if the ADR merges under another name. The Finding Tasks paragraph and the skill cite "ADR-081" by number only. CLAUDE.md, the checker header and the exemption allowlist also cite ADR-084 (raise class 1, the installer recognition points) by number only; that ADR is also still a draft, so confirm it exists before merging.baselineFailurestakes an optional fourth argument,hits. The issue's signaturebaselineFailures(counts, baselines?, changedFiles?)has no way to list hits, yet the spec requires an above-baseline message to list hits in changed files first, then every hit. The real-repo test and the CLI passcountMarkers(...).hits; the three-argument call shape from the issue still works.exemptionProblemsreports one message per problem (Steps 4), so an entry with two problems yields two messages. The Exemptions section says "per bad entry"; each fixture in the tests has exactly one problem, so both readings pass.GIT_DIR,GIT_WORK_TREE,GIT_INDEX_FILE,GIT_COMMON_DIRandGIT_PREFIXfrom the environment of its git calls (and the tests do the same for their fixtures). I confirmed empirically that a pre-push hook run from a linked worktree, which is this repo's workflow, receivesGIT_DIR. Without stripping, the push-time run that the follow-up adds would scan the wrong repository, and a fixturegit initorgit addin the tests would hit the real one. Covered by a test that sets a bogusGIT_DIRand expects a correct scan.changedFilesSinceMainusesgit diff -z --name-only --no-renames <merge-base>(one diff against the working tree instead of committed plus uncommitted) and NUL-separated output for both git calls. It returns the same set aschangedFiles()ingate-scope.ts.proEventsfollows the issue's pattern exactly, which also matches an unquotedpro:tier-detected(only thesync:*alternatives require quotes), although the summary and the prose say "quoted". Kept as specified because the baseline reproduced on it. Worth deciding in the migration issue that removes those events.EXEMPTIBLE_NON_TEST_FILESadds an explicit allowlist of whole paths that may carry an entry too:scripts/update-homebrew-cask.ts,scripts/pkg-resources/preinstall,scripts/pkg-resources/postinstallandscripts/build-pkg.sh. It is documented in the checker header and CLAUDE.md. The match is on the whole path (no basename, suffix or prefix match), so a same-named file elsewhere is not covered, every other non-test file is still reported, and an allowlisted entry still needs a reason, a marker and a live hit. Two things to know against the ADR drafts, which I read:postinstallis not in ADR-084's list. ADR-084 section 5 lists exactly three installer files (build-pkg.sh, a newpreinstall,update-homebrew-cask.ts) and says the allowlist is "exactly these three"; the old guard inpostinstallmoves to the pre-install stage. The coordinator's list includedpostinstall, so it stays, but the header, the constant's comment and CLAUDE.md now say plainly that it is allowlisted only until that guard is gone and that the ADR does not list it. Recommendation: drop it from the list when the installer work removes the guard (one line plus one test entry).preinstalldoes not exist on main yet (the same work adds it); an entry for it reports "missing from the scan" until it does.changedFilesSinceMainin a fixture repo including a movedorigin/main, theGIT_DIRcase above, tests for the notices and the never-raising block, a control showing the comment-line layout is what prevents the cherry-pick conflict, and isolated cases for every pattern alternative that had none. Real-repo assertions do not pin today's counts, so they keep passing as baselines fall.Known behavior of the one-way design
BASELINES, and the passing test only logs the notice (the merge gate keeps full output in a log). CLAUDE.md now says headroom is not permission and asks the PR description to name the class either way. A useful follow-up, deliberately not built here: have the CLI and test warn when the branch's own diff adds hits for a marker that sits below its baseline, which would also allow an exact-by-diff check with no baseline rebasing.SCANNED_EXTENSIONSis the issue's allow-list, so a brand-new file type underpackages/orscripts/(for example.tsx,.yml) is not scanned until it is added. Today's tracked but unscanned text files hold no markers.Verification
bun run test:changed(scripts tier only): passed on the pushed head0b4a0551.bun run quality:scripts:check: clean.bun run scripts/check-code-references.ts: unchanged at 71 / 0.bun run scripts/check-pro-boundary.ts: exit 0, all 12 counts equal their baselines on the rebased branch.Mutation checks
The nine from the issue, run against the real repo or the source, each confirmed and reverted. Two results differ from the issue's text because of Deviation 1:
await invoke('pro_example');to a tracked non-Pro frontend file (packages/desktop-app/src/lib/utils/logger.ts): CLI exits 1 and the real-repo test fails.proCommandsis 276 vs 275 and the new line appears under "In files this branch changed".nodespaced-proparagraph (changed by Deviation 1): the check passes (exit 0, all 211 tests pass) and prints notices foreditionBranching(121),tenantWording(506) andproWording(311) plus a block. Pasting the block givesgit diffof exactly those three value lines, and the CLI then reports every count equal to its baseline.touch packages/desktop-app/src/lib/components/pro-upsell.svelte:proNamedFilesfails at 17 vs 16, with the file listed under the changed files.\bfromnodespace_pro\b: theproProtocol does not match "use nodespace_proto::socket;"test fails.EXEMPTIONSentry:tenantWordingis above its baseline (raw count is one higher) and fails.["proWording"]:exemptionProblemsreports it stale ("proWording has no hit left in the file"), andtenantWordingis above its baseline.["pro", "tier"].join("_")form and the Rustconcat!form): the "needles built from fragments count 0" test fails.formatBaselinesdrop the comment lines: the "source holdsformatBaselines(BASELINES)verbatim" test, the one-comment-per-value test and the adjacent-markers cherry-pick test all fail..mdwith markers under the gitignoredpackages/desktop-app/src-tauri/resources/skill/(confirmed ignored viagit check-ignore, rulesrc-tauri/.gitignore:15): no count changes and the CLI exits 0.On top of those, a mutation harness applied 128 mutations (one per behavior: each
git ls-filesflag, sorting, exclusions, extension rules, git-failure handling,GIT_*stripping, unreadable-file handling, exemption scoping, eachexemptionProblemscheck, eachTEST_PATHalternative, eachchangedFilesSinceMainstep, everybaselineFailuresandbaselineNoticesbranch and message part,formatBaselines, each marker's individual pattern alternatives,isProNamedFile, the CLI's modes, argument validation, exit codes and output streams, and the recognition-point allowlist). Each was killed by the test written for that behavior. Earlier passes found survivors (a sort test that git's ordering happened to satisfy, achangedFilesSinceMaintest whoseorigin/mainequalled the merge-base, an untested CLI failing path, and an un-isolated pattern alternative); all were closed with new tests.Not changed
scripts/check-code-references.tsand its baselines, anything underpackages/agent(scanned only), and any Pro code. Running the check at push time is the follow-up.🤖 Generated with Claude Code