Skip to content

fix(dispatch): pre-validate worktree containment before git materialises (#1154) - #1185

Merged
sungjunlee merged 3 commits into
mainfrom
fix/1154-worktree-provisioning
Aug 8, 2026
Merged

fix(dispatch): pre-validate worktree containment before git materialises (#1154)#1185
sungjunlee merged 3 commits into
mainfrom
fix/1154-worktree-provisioning

Conversation

@sungjunlee

@sungjunlee sungjunlee commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

Pre-validate the retained-worktree destination BEFORE git worktree add so a pre-existing symlink (or non-directory component) in the run-id path can never make git materialise the worktree outside the trusted relay base (#1154 item 2).

  • dispatch.js: createRetainedWorktree walks the destination components from the canonical base and fails closed on a symlink / non-directory before git touches anything. The post-worktree add assertTrustedWorktree unwind remains as a second line of defense.
  • Test: instrumented git stub proves git worktree add never runs against a symlinked destination and nothing is materialised at the symlink target.

Scope split (direction: keep core, stay lightweight): the original draft also self-healed stranded worktrees inside dispatch (kill-window between worktree add and the immutable run record). That is deliberately not in this PR — dispatch must not run recovery (AGENTS.md invariant), and cross-run worktree scanning is machinery the relay runtime is trimming. Stranded-litter recovery is tracked separately for recover.js.

Verification

  • node tests/skills-lint/scripts/vnext-test-ledger.js check
  • node tests/skills-lint/scripts/vnext-runtime-inventory.js .
  • Full gate on CI (relay-dispatch covers the symlink pre-validation test)

Closes nothing yet: #1154 stays open for the recover.js-owned litter part.

Summary by CodeRabbit

  • 버그 수정

    • 작업 공간 경로에 심볼릭 링크가 포함된 경우 작업이 안전하게 중단됩니다.
    • 유효하지 않은 경로 구성 요소로 인해 파일이나 디렉터리가 잘못 생성되는 문제를 방지했습니다.
    • 검증 실패 시 Git 작업 공간과 브랜치가 불완전하게 등록되지 않습니다.
  • 테스트

    • 다양한 심볼릭 링크 경로에 대한 안전성 검증을 추가했습니다.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ead662ca-b424-4804-907f-4fa570b79a77

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8273a and ee43a21.

⛔ Files ignored due to path filters (2)
  • tests/ledger/vnext-baseline.generated.json is excluded by !**/*.generated.*
  • tests/ledger/vnext-test-sites.generated.json is excluded by !**/*.generated.*
📒 Files selected for processing (2)
  • skills/relay-dispatch/scripts/dispatch.js
  • tests/relay-dispatch/scripts/dispatch-vnext.test.js

Walkthrough

워크트리 생성 전에 기존 경로 구성요소를 검사합니다. 심볼릭 링크와 디렉터리가 아닌 구성요소를 거부합니다. run-id 및 repoSlug 심볼릭 링크 경로에 대한 dispatch 차단 테스트를 추가했습니다.

Changes

워크트리 경로 무결성

Layer / File(s) Summary
워크트리 경로 구성요소 검증
skills/relay-dispatch/scripts/dispatch.js
createRetainedWorktree가 기존 경로 구성요소를 lstat으로 검사합니다. 심볼릭 링크와 디렉터리가 아닌 구성요소를 거부합니다.
심볼릭 링크 차단 테스트
tests/relay-dispatch/scripts/dispatch-vnext.test.js
run-id 또는 repoSlug 경로가 심볼릭 링크이면 dispatch가 실패하는지 검증합니다. git worktree add, 대상 경로 변경, 브랜치 생성, worktree 등록이 발생하지 않는지 확인합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

  • sungjunlee/dev-relay#1151 — 동일한 dispatch.js와 vNext 테스트에서 worktree 및 run-directory 경로 처리를 변경합니다.

Poem

당근을 든 토끼가 경로를 살피네
링크가 보이면 멈춰 서네
lstat 검사가 문을 지키고
Git은 안전한 길에서만 달리네
새 테스트가 발자국을 확인하네 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 Git 실행 전에 worktree 경로를 검증하는 핵심 변경을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1154-worktree-provisioning

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.

@sungjunlee
sungjunlee force-pushed the fix/1154-worktree-provisioning branch 2 times, most recently from aef05d6 to 89b19c4 Compare August 8, 2026 09:15
@sungjunlee
sungjunlee force-pushed the fix/1154-worktree-provisioning branch from 89b19c4 to bde7b30 Compare August 8, 2026 10:03
@sungjunlee sungjunlee changed the title fix(dispatch): pre-validate worktree containment and self-heal stranded worktrees (#1154) fix(dispatch): pre-validate worktree containment before git materialises (#1154) Aug 8, 2026
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.

1 participant