Skip to content

[obvious-fleet] Anchor sync_breadth.sh mirrors inside backend/ - #265

Merged
SamGu-NRX merged 1 commit into
alphafrom
obv/burst6-bs-sync-breadth
Oct 16, 2026
Merged

SamGu-NRX merged 1 commit into
alphafrom
obv/burst6-bs-sync-breadth

Conversation

@obvious-autobuild

Copy link
Copy Markdown

fleet-packet: burst6-bs-sync-breadth

Closes the unaddressed half of the path-safety finding on #247 (Greptile, comment 4281254460): "sync_breadth.sh also writes outside backend/. Keep Git operations at the repository root, but anchor copied files under backend/." #249 fixed sync_from_store.sh and explicitly left sync_breadth.sh untouched; this PR gives the breadth script the same treatment.

What changed and why

Confirmed on the base commit (57f57ff): git -C backend/scripts rev-parse --show-toplevel returns the BaseScanning root, not backend/, and every worktree mirror anchored there — mkdir -p "$wt/$dst" with dst one of recon/a1-classical, scene/b1-detection, criteria/c1-rules-3d, … So a real run would have copied store folders into the monorepo's top-level recon/ (which the app already owns), scene/ and criteria/ — all outside backend/ — with rsync --delete pointed at them.

The fix anchors copies at the package root derived from the script's own location, the same pattern #249 used for sync_from_store.sh (following #248's ssr_overlap_check.py):

  • PACKAGE="$(cd "$(dirname "$0")/.." && pwd -P)" — pwd -P keeps PACKAGE comparable to the toplevel across symlinked parents.
  • REPO stays git rev-parse --show-toplevel: fetch, worktree add, commit and push are untouched.
  • PACKAGE_REL is PACKAGE relative to REPO (backend in the monorepo; empty when the package still sits at the repo root, i.e. the pre-port layout), with a hard error if the package is not inside the repository.
  • The three copy sites (mkdir -p, the rsync destination, the README.md / RESULTS.md copies) now target $wt/$PACKAGE_REL/$dst.

Git-root vs script-location anchoring. Git-root anchoring is correct for git operations but wrong for copies after the port: the toplevel moved one level above the package, so copies anchored there land beside the app, and rsync --delete makes those app-adjacent folders deletion targets. Script-location anchoring moves with the file, and the port was exactly a relocation — the anchor survives it — while worktrees, branches and pushes stay repo-global at the git root.

Everything else is preserved: the worktree-per-branch flow, base selection (origin/breadth/<id> else origin/main), --no-push, and the safety scan (meter numbers, SSR prompt text, keys, >5 MB files) — the scan now sees backend/-prefixed paths, and its checks are basename/path based, so they are unaffected.

Exact deletion boundary tested: for path id a1-classical, rsync --delete is confined to backend/recon/a1-classical/ inside the throwaway worktree. Pre-fix that destination was <monorepo-root>/recon/a1-classical/.

How I verified it

From backend/ in a fresh clone (~/work/burst6-bs-sync-breadth) on the existing BaseScanning repo sandbox (computers-list route; the sandbox's pre-existing checkout untouched):

  • bash -n scripts/sync_breadth.sh — clean.
  • New backend/tests/test_sync_breadth.py (2 tests): a temporary monorepo with a bare origin and a fake store, driving the script through a recording rsync stand-in on PATH.
    • python3 -m pytest tests/test_sync_breadth.py -q → 2 failed against the pre-fix script (checked out from 57f57ff), 2 passed with the fix.
    • test_mirrors_land_inside_backend: the only rsync call targets …/backend/recon/a1-classical/; every path added to breadth/a1-classical vs origin/main is under backend/; a top-level recon/a1-classical is absent; the sentinel blob at the app's top-level recon/APP-SENTINEL.txt is unchanged; with --no-push nothing reaches origin.
    • test_delete_boundary_stays_inside_the_mirrored_folder: second sync with origin/breadth/a1-classical as base — a stale file inside the mirror folder and a store-deleted code.py are pruned, while backend/recon/a0-stray.txt (in the package, outside the mirrored folder), top-level recon/cruft.txt and the sentinel all survive; --no-push keeps the second sync commit local.
  • make lint (uv run --frozen): ruff check ✓, ruff format --check ✓, lint-imports ✓ (5 contracts kept, 0 broken).

What is not verified

Assumptions

  • The script never deleted files outside its worktree mirrors even before the port, so the fix is anchoring only — no other behavior changes.
  • The pre-port layout (package root == repo root) keeps working via the empty PACKAGE_REL branch.
  • Draft PR; nothing merged; nothing pushed to feat/port-house-scanning-server; no .github/, deploy, or Swift files touched.

After the port into the BaseScanning monorepo, git rev-parse --show-toplevel
returns the monorepo root, so sync_breadth.sh's worktree mirrors anchored at
the toplevel and rsync --delete pointed at the app's own top-level recon/,
scene/ and criteria/ folders -- the half of Greptile's path-safety finding on
PR #247 (comment 4281254460) that #249 left untouched.

Copies now anchor at the package root derived from the script's location
(PACKAGE, pwd -P, relative to the git toplevel), matching sync_from_store.sh;
git operations (fetch, worktrees, push) stay at the repository root, and
--no-push, the worktree flow, base selection and the safety scan are
unchanged. backend/tests/test_sync_breadth.py builds a temporary monorepo
with a fake store and a recording rsync stand-in: both tests fail against the
pre-fix script and pass with this change.
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67b62036-3a3b-43be-a0e1-b7e24b158b44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • 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

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

@obvious-autobuild

Copy link
Copy Markdown
Author

Independent review (Obvious, Autobuild + Max)

Verdict: ready. Correct, minimal fix for the unaddressed half of the #247 path-safety finding, matching the #249 precedent. All findings below are non-blocking; no regression found.

What I verified

Fresh clone at head 1470c697 on base 57f57ff8; followed AGENTS.md/CLAUDE.md/CONTRIBUTING.md/backend/CONTRIBUTING.md (breadth conventions, draft, one writer). Read the full body, the complete diff (2 files: backend/scripts/sync_breadth.sh +22/−6, backend/tests/test_sync_breadth.py +292) and all comments — only a CodeRabbit skip notice, no human reviews yet.

  • bash -n backend/scripts/sync_breadth.sh — clean.
  • New tests: uv run --frozen python -m pytest tests/test_sync_breadth.py -q → 2 passed. They drive the real script end-to-end in a temporary monorepo with a bare origin, a fake store and a recording rsync shim on PATH, and assert on the real path: the exact added-file set on breadth/a1-classical (only under backend/), the recorded rsync destination ending in backend/recon/a1-classical, an unchanged sentinel blob at top-level recon/APP-SENTINEL.txt, deletion confined to the mirrored folder, and both --no-push invariants. This exercises the actual script, not a reimplementation of it.
  • Bites-check: checked out the base script (git show 57f57ff8:... | grep PACKAGE → 0 matches), re-ran the new tests → 2 failed; restored the head script → 2 passed. The tests genuinely pin this fix.
  • make lint (uv run --frozen ruff check . / ruff format --check . / lint-imports): all green, 460 files formatted, 5 import contracts kept.
  • Full backend suite at head: 5 failed / 1205 passed / 17 skipped; identical control run on base 57f57ff8: 5 failed / 1203 passed / 17 skipped. The failures are the documented baseline (1 SSR-hygiene + 4 eval gates), identical on both sides; head adds exactly the 2 new passing tests. (First head run showed 254 failures — my sandbox disk hit 100% mid-run; after cleanup the clean head/base pair above is the evidence.)
  • Script read in full: only the three copy sites (mkdir -p, rsync destination, README/RESULTS copies) gain the PACKAGE_REL prefix. Worktree-per-branch flow, base selection (origin/breadth/<id> else origin/main), --no-push, commit and push are untouched. The safety scan's checks are name/substring based (/raw/meter/, meter-number CSVs, SSR prompt names, key regexes), so the backend/ prefix on scanned paths doesn't weaken them. The anchoring math is sound: PACKAGE uses pwd -P and git rev-parse --show-toplevel returns a physical path, so the prefix comparison is meaningful across symlinked parents; the not-inside-repo hard error fires before any copy; and the empty-PACKAGE_REL branch preserves pre-port (package-root == toplevel) behavior exactly.

Findings (ranked, all low/informational)

  1. [low] Minor idiom drift with PR fix(backend): reviewer-page form and point cloud, store-sync paths #249. fix(backend): reviewer-page form and point cloud, store-sync paths #249's sync_from_store.sh derives PACKAGE="$(cd "$(dirname "$0")/.." && pwd)" (logical pwd); this PR uses pwd -P. The pwd -P variant here is the better one — it's what makes PACKAGE comparable to the toplevel under symlinked parents, and the in-script comment says so. When both merge, consider converging fix(backend): reviewer-page form and point cloud, store-sync paths #249 onto pwd -P. No change needed in this PR.
  2. [low] Symlinked-invocation edge. If the script were ever invoked through a symlink to the script itself (e.g. PATH-installed), dirname "$0" resolves to the link's directory, so PACKAGE would be wrong. In-repo invocation (the only documented usage, and what the tests do) is unaffected, the wrong-PACKAGE case fails loudly via the hard error rather than mis-copying, and fix(backend): reviewer-page form and point cloud, store-sync paths #249 shares the trait. Smallest fix if ever wanted: derive the path from realpath "${BASH_SOURCE[0]}".
  3. [info] "fix(backend): reviewer-page form and point cloud, store-sync paths #249 fixed sync_from_store.sh" refers to PR fix(backend): reviewer-page form and point cloud, store-sync paths #249, which is still open against this same base branch. Accurate as written (it's linked), and the two PRs touch different scripts, so there's no conflict — but neither fix has landed yet, so backend/scripts/sync_from_store.sh at the base commit still mirrors to the monorepo root. Worth keeping in mind when sequencing the merges.

Couldn't verify

  • No run against a real Cursor Project store and no real rsync binary available here: the deletion-boundary proof rests on the recorded rsync destinations plus the git-tree assertions, exactly as the body discloses. The store-detection, safety-scan and push code paths are unchanged by this diff.
  • CI: no backend/ CI workflow runs on this branch (label bot only) — a pre-existing repo-wide gap, nothing for this PR to pass.

@SamGu-NRX
SamGu-NRX changed the base branch from feat/port-house-scanning-server to alpha October 16, 2026 04:30
@SamGu-NRX
SamGu-NRX marked this pull request as ready for review October 16, 2026 04:30
@SamGu-NRX
SamGu-NRX merged commit 473f9e1 into alpha Oct 16, 2026
6 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T04:33:01.240295Z 1470c69 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codemetrics-ai

Copy link
Copy Markdown

Note

Review skipped

Codemetrics is installed on this repository, but it hasn't been added to your team yet.

To enable AI code reviews for this repo, go to your dashboard and add BaseScanning to your team's repositories.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Anchors breadth copies under backend/ while keeping Git operations at the repository root.

  • Breadth sync copies its files under the backend package.

Reviews (1) · Last reviewed commit: "fix(backend): anchor breadth sync mirror..." · Reviewed by Greptile

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

Labels

size:S 10-29 effective changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant