fix(sync-workspace): allow pre-wsId flat branch past init guard (closes #1961 more)#1997
fix(sync-workspace): allow pre-wsId flat branch past init guard (closes #1961 more)#1997john-the-dev wants to merge 3 commits into
Conversation
sonichi#1961 more) _assert_sync_initialized rejected workspaces that had a flat `host/<host>` branch (no wsId segment) because they lacked both init sentinels (.git/info/exclude marker and .sutando-vault/ws-id). This caused the existing Test 27 to abort before _migrate_flat_branch could fire — the function designed to upgrade exactly this state. Add a third sentinel: if HEAD is on `host/<hostname>` with no wsId segment, the workspace was initialized under the pre-sonichi#1459 scheme. Allow the sync to proceed; _host_ws_segment writes .sutando-vault/ws-id later in the same run, before push-only sees the guard again. sync-workspace.test.sh: 88/88 pass (Test 27 was the pre-existing failure). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QB3qZQrwponfum2JFNvHeh
Coverage Gate✅ No Python changes — nothing to gate (bar: 95% on changed lines). |
|
Automated review [blocker] |
| # will write .sutando-vault/ws-id before push-only runs — so this is safe to allow. | ||
| local _cur_branch | ||
| _cur_branch="$(git -C "$WORKSPACE_DIR" symbolic-ref --short HEAD 2>/dev/null || true)" | ||
| if [ "$_cur_branch" = "host/$(_host)" ]; then |
There was a problem hiding this comment.
Automated review: this new branch-name fast path weakens the init guard enough to reintroduce the "commit the whole workspace" failure mode it was added to prevent. An unrelated git repo (or any half-initialized workspace) can already have HEAD on host/<hostname> without ever having the generated .git/info/exclude or a ws-id; in that case _push_only_impl now proceeds to git add -A with no carrier-set filter. I think this should only bypass the guard if the flat branch is accompanied by some sync-owned marker, or after _migrate_flat_branch has proved it is a real pre-wsId vault repo.
|
Automated review: scripts/sync-workspace.sh:662 makes |
|
Automated mergeability review (2026-07-09) Signal: NOT MERGEABLE Current blocker(s):
This is a conservative backlog triage signal. After the blockers are cleared, please rerun checks and request a focused review. |
…fast path Review fix (qingyun-wu, PR sonichi#1997): the branch-name fast path in _assert_sync_initialized returned 0 whenever HEAD was on host/<hostname>, without checking any init marker. A half-initialized repo — HEAD parked on host/<hostname> but lacking both .git/info/exclude and .sutando-vault/ws-id — could slip past the guard into `git add -A`, the "commit the whole workspace" failure mode the guard exists to prevent. Tighten the fast path: still require a real whitelist to exist first — either the .git/info/exclude generator marker OR the pre-sonichi#1459 in-tree .gitignore `*` deny-all (that era's whitelist, which a genuine pre-wsId workspace carries — exactly what _migrate_flat_branch upgrades). If no whitelist is present, fall through to die(). This preserves the legitimate pre-wsId migration (Test 27, still 88/88) while closing the half-init hole. Updated the uninit-guard inline mirror to match and added T12 (flat branch + whitelist passes) / T13 (flat branch, no whitelist, blocked — the reviewer's exact case). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFp2p6XUSAQ1eAKKZeiZPt
|
@cla-assistant check |
qingyun-wu
left a comment
There was a problem hiding this comment.
Delta review (commit b5b0870 since my 2026-07-08 pass): LGTM — the fail-open concern is closed.
Prior point addressed: the branch-name fast path no longer lets a half-initialized repo (HEAD parked on host/<hostname>, no carrier-set filter) ride into git add -A. The fast path now additionally requires whitelist evidence — the generated .git/info/exclude marker or the pre-#1459 in-tree .gitignore deny-all (scripts/sync-workspace.sh:671-685). That is exactly the fail-closed shape I asked for, and it still admits the genuine pre-wsId layout (which always carries the * deny-all .gitignore that _migrate_flat_branch expects). Test T13 locks the half-init rejection in and T12 covers the legitimate flat-branch pass (tests/sync-workspace-uninit-guard.test.sh:135-167).
CI: all checks green (tsc + tests, diff coverage, all three refuse-lints, CLA, recheck).
Non-blocking: _has_exclude_marker is dead code — it is only set to 1 on the path that immediately return 0s (scripts/sync-workspace.sh:660-663), so the [ "$_has_exclude_marker" = "1" ] arm of the flat-branch condition can never be true. Harmless, but it reads as if the exclude marker could reach that branch. Dropping the variable (leaving just the legacy-.gitignore check) would say what the code actually does. Same dead arm exists in the test's inline mirror.
|
LGTM from code review. Verified on the current head (
No actionable findings on this revision. Merge once required checks pass. Qingyun's Personal Codex Agent |
|
Closing as duplicate (covered elsewhere) — already fixed (change already on main).
|
What
_assert_sync_initializedinscripts/sync-workspace.shrecognized only two proof-of-init sentinels (.git/info/excludemarker +.sutando-vault/ws-id). A workspace initialized under the pre-#1459 scheme sits on a flathost/<hostname>branch with neither sentinel, causing the guard to abort — before_migrate_flat_branchcan run to upgrade that state.Add a third sentinel: if
HEADis on the flathost/<hostname>branch (no wsId segment), allow the sync to proceed._migrate_flat_branchcarries history into the wsId branch and_host_ws_segmentwrites.sutando-vault/ws-idduring that same run — so the guard passes cleanly on the follow-up invocation.Test
sync-workspace.test.sh: 88/88 pass. Test 27 (pre-wsId flat branch upgrade) was the failing case.Why split from #1970
This is a behavior change to
sync-workspace.sh, not a shell test portability fix. Split at reviewer request (qingyun-wu 2026-07-07T05:41Z) so the sync-workspace change can be reviewed on its own merits.