Skip to content

feat(sync): restore-time cwd projection and symlink diagnostics (#28, #30) - #32

Merged
PerryLink merged 3 commits into
mainfrom
feat/restore-cwd-projection
Nov 13, 2026
Merged

PerryLink merged 3 commits into
mainfrom
feat/restore-cwd-projection

Conversation

@PerryLink

Copy link
Copy Markdown
Owner

What

Release 0.3.0: restore-time cwd projection for cross-OS sessions (#28) and symlink diagnostics plus an opt-in follow mode (#30).

#28 — cwdMap

A session synced from another platform carries a header.cwd that is not natively absolute on the receiving host: @deepseek-ai/dsh-workspace never indexes it, and session-persistence-jsonl cannot even parse a header whose cwd is foreign (so the session is invisible, not just ungrouped).

  • cwdMap: [{ from, to }] — longest matching prefix wins, prefixes end on a path-segment boundary, Windows prefixes compare case-insensitively (C:\Users\me2 does not match C:\Users\me).
  • Restore rewrites only the local copy's first zstd frame, lands the file at <projectKey(mapped cwd)>/<sessionId>/<file> (the formula the host validates), and creates the mapped directory.
  • The mirror keeps the origin device's bytes. On push the original header frame is reattached and only locally appended frames are added, so the other device still sees a byte-identical append-only history (no fork churn).
  • Unmatched cross-platform cwds go read-only to <sessionRoot>/--unmapped--; sync_status reports cwdUnmapped.
  • The projection state is local-only (.git/dsh-session-sync-projection.json); a pull rebuilds it.

#30 — symlink diagnostics + opt-in

  • sync_status now reports skippedSymlinks, skippedSymlinkPaths, followedSymlinks, plus the cwd projection counters; push results carry the same warning.
  • followSessionSymlinks: true (default false) follows only links whose realpath stays inside sessionRoot; links that escape are always skipped and counted.
  • Auto-push listener registration is logged once at mount, so a host that never delivers session/event can be told apart from the plugin not registering.

Tests

  • New test/cwdmap.test.mjs — 11 tests. The key ones are host-validated: a synthetic Windows session log is restored, then the real @deepseek-ai/dsh-session-persistence-jsonl backend (now a devDependency) stat()/list()s it. The host asserts <root>/<projectKey(header.cwd)>/<sessionId>/<file>, which pins our projectKey copy, the directory layout and the header rewrite.
  • Also: prefix-boundary matching, longest-prefix, placeholder read-only + never pushed, byte-identical append round-trip, prune mapping, inside/outside symlink following, status diagnostics, config validation.
  • Local gate: typecheck, typecheck:ci, test (117), lint (0 errors), verify:self-contained, verify:artifacts, check:readmes, pnpm pack — all green.

Docs

READMEs in five languages (config tables + cross-OS/symlink sections), ARCHITECTURE module map/data flow/safety boundaries, CHANGELOG, and cordis.patch.yml document both new keys.

Closes #28. Refs #30 (the app-level auto-push bug is not fixable from the plugin; diagnostics shipped instead).

…30)

- cwdMap projects a cross-OS header.cwd onto a local path at restore time (longest prefix, segment boundary, Windows case-insensitive). Only the local copy's first zstd frame changes; the mirror keeps the origin device's bytes and a push reattaches the original header frame, so appends stay byte-identical across devices.
- Unmatched cross-platform cwds land read-only under <sessionRoot>/--unmapped-- and are counted in sync_status.
- sync_status reports skipped/followed symlinks and the new cwd projection counters; push results carry the same warning.
- followSessionSymlinks (default false) follows only links whose realpath stays inside sessionRoot.
- Auto-push listener registration is logged once at mount so hosts that never deliver session/event are diagnosable.
- New lib modules: cwdmap (matching + host-compatible projectKey), sessionlog (zstd header-frame read/rewrite), projection (local projection state).
- Tests drive the real @deepseek-ai/dsh-session-persistence-jsonl backend to prove the projected layout passes the host's stored-identity check.
Windows CI failed because the unit tests hard-coded POSIX mapping targets and
treated a Windows cwd as foreign on Windows (it is native there). Use a native
temp target for every mapping and pick the foreign cwd per platform: the reverse
direction (POSIX cwd on Windows) exercises the same projection path. Also clear
a read-only placeholder bit before unlinking it so remote deletions prune on
Windows too.
@PerryLink
PerryLink merged commit 6a18dec into main Nov 13, 2026
9 checks passed
@PerryLink
PerryLink deleted the feat/restore-cwd-projection branch November 13, 2026 04:57
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.

[Feature] Restore-time cwd remapping so cross-OS sessions appear in the host workspace list

1 participant