Skip to content

fix(link): avoid writing an empty initial selection on disconnect - #8989

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:codex/link-initial-clear-1120
Nov 21, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:codex/link-initial-clear-1120

Conversation

@luvs01

@luvs01 luvs01 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A Link only records initial routing choices when the operator supplies an explicit client selection. Disconnect also clears this state for links without one. Previously that clear created an empty initial-<linkId>.json, including its state directory if missing.
  • Leave an absent selection absent. An existing record still goes through the same atomic no-follow write. Check the nearest existing entry so a broken directory link still surfaces an error. The disconnect journal and its phase transitions are unchanged.

Verification

  • Windows NTFS, Bun 1.4.4. The new regression failed on d61cca12 because the directory and file were created. bun test tests/clients/route-intent-connect-recovery.test.ts passed all 11 tests with the patch, including rollback after a recorded selection, older-Home provisioning, and an unreachable directory.
  • bun run typecheck, bun run structure:check, bun run privacy:scan, and git diff --check passed.
  • Seven alternating calls per revision after a warm-up, using distinct existing test directories with missing selection files. The base created 7 files and took a median of 226.97 ms per clear. The patch created 0 files and took 0.60 ms. This measures one operation on one host. The full Windows disconnect deadline in fix(link): restore guarded stop cleanup with native Windows owner proof #8933 remains open.
  • Local validation covered the changed contract and its rollback callers. The broader import-graph suite is left to PR CI to avoid duplicating the ongoing Windows recovery work.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Updated the client integration contract in structure/clients/integrations.md.
  • Reviewed existing write, link identity, and directory error handling. The change adds no credential access or logging.

Summary by CodeRabbit

  • Bug Fixes
    • Clearing an absent route selection no longer creates a state directory.
    • Attempts to clear a selection when its state path passes through a broken symlink now report an error and leave the symlink intact, preventing unintended filesystem changes.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

clearInitialRouteIntent now checks the target path and its ancestors before writing an empty selection. Tests cover clearing when the selection is absent and when the state path traverses a dangling symlink.

Changes: Route-intent recovery

Layer / File(s) Summary
Clear initial route intent
src/integrations/route-intent-initial.ts, tests/clients/route-intent-connect-recovery.test.ts, structure/clients/integrations.md
clearInitialRouteIntent checks the target path and its ancestors before writing an empty selection. Tests verify that clearing an absent selection does not create the state directory, preserves an unrelated file, and throws when the path traverses a dangling symlink. The responsibility description for src/integrations/state.ts is updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to 28694

Disconnecting a Link without an explicit client selection no longer creates an empty selection file or its state directory. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(link): avoid writing an empty initial selection on disconnect" matches the main change described in the PR objectives and raw summary. The PR stops clearInitialRouteIntent from creating…
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.
Full details: Title check

Explanation

The title "fix(link): avoid writing an empty initial selection on disconnect" matches the main change described in the PR objectives and raw summary. The PR stops clearInitialRouteIntent from creating an absent initial selection file and its state directory during disconnect, and it adds a dangling-symlink check. The title is specific and concise, and it follows a conventional commit style. It does not cover the symlink ancestor check, but that is a secondary detail.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d61cca1 and 2869409.

Files selected for processing: 3

  • src/integrations/route-intent-initial.ts
  • structure/clients/integrations.md
  • tests/clients/route-intent-connect-recovery.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 20, 2026
@luvs01
luvs01 marked this pull request as ready for review November 20, 2026 07:35
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (per MAINTAINERS.md; maintainer integration, not an independent approval)

  • Exact head: 2869409e7dccce5ecadeae336f7ea9af7c896a4d
  • Checks on this head: 17 passed, 14 skipped, none pending or failing (Ubuntu PR CI; Windows/macOS are covered by the next dev batch gate).
  • Review threads: none unresolved.
  • Review: gpt-6.1-terra, two rounds, final verdict PASS.
  • Regression: tests/clients/route-intent-connect-recovery.test.ts passes on this head (11 pass) and fails with src/integrations/route-intent-initial.ts restored from dev (1 fail).

@lidge-jun
lidge-jun merged commit 7f60c12 into lidge-jun:dev Nov 21, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants