Repository navigation
fix(sync): never delete or re-point entries skillshare did not create - #914
Conversation
On Windows, a plain `init` followed by `sync` deleted things in ~/.claude/skills that skillshare never created, with no backup and no prompt. It also re-pointed another tool's junction. Seen in a sandbox run of v0.30.7: - prune removed real folders whose names only look like skillshare's flat naming (team__shared, _drafts), via the name heuristic - prune removed a broken link that another tool or the user made - merge sync deleted and re-created a same-name link that pointed into another manager's store - init's import deleted original folders that matched the source byte for byte The manifest already records what skillshare made, so use it: - prune keeps a look-alike folder that is not in the manifest and warns once per sync; --force still removes it - prune removes a broken external link only if the manifest records it (e.g. after the source moved); otherwise it keeps the link and warns - merge sync re-points a link only if the manifest records it or it already points into the source; otherwise it reports the entry as kept local, as it already does for a real folder; --force replaces it - init's import moves identical copies to the trash under replaced-by-init/<target>/ instead of deleting them Tests: ownership_test.go adds regression tests that use createLink, so they run on Windows without Developer Mode (junctions). The 4 keep tests fail without this change. TestSyncTargetMerge_FixesBrokenLink now records the link in the manifest first, since a same-name link that skillshare did not make is no longer re-pointed. Existing tests in internal/sync, internal/trash and cmd/skillshare show the same failures on a Windows host with and without the change (symlink privilege). The devcontainer suite has not been run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit makes sync and init leave alone entries skillshare did not create. Update the pages that describe that behaviour: - sync-modes: merge mode keeps a same-name link from another tool and reports it as local; orphan cleanup keeps folders that only look like skillshare's flat names, and broken links outside the source that the manifest does not record. sync --force still removes them. - init: identical folders replaced with links during the first sync go to the trash first (replaced-by-init/<tool>/, cleaned after 7 days). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o longer needs replaceIdenticalCopies now moves an identical copy to the trash instead of calling os.RemoveAll, so TestRawWriteRatchet reports its allowance as stale. Co-Authored-By: Claude Opus 5.5 <[email protected]>
runkids
left a comment
There was a problem hiding this comment.
Thanks for this, and for the careful sandbox evidence. The direction is right: deleting a user's own team__x folder because of its name, or re-pointing another tool's link, is data loss, and the manifest is the right source of truth.
I ran the change in the Linux devcontainer image: go vet and go test ./internal/... ./cmd/... -count=1 both pass. tests/integration and Windows were not run on my side.
The skills merge path is fixed, but a few consumers still describe or do the old behaviour. Here is what I found, most important first.
Consumers that now disagree with sync
- Dashboard diff predicts the old behaviour.
internal/server/handler_diff_stream.go:239-241still predictsprune/ "orphan managed directory" for an unmanagedteam__xor_repofolder, which sync now keeps. Lines 196-200 still predictupdate/ "symlink points elsewhere" for another tool's same-name link, which sync now reports as kept local. doctorrecommends a fix that no longer works.cmd/skillshare/doctor.go(checkBrokenSymlinks, around line 1195) reports every broken link as an error and suggestsskillshare syncto prune it. A broken link skillshare did not create is now kept, so doctor keeps failing and its suggestion never clears it.website/docs/reference/commands/doctor.md:303-307says the same.TestSync_Pruning_RemovesBrokenExternalSymlinksno longer tests anything.tests/integration/sync_test.go:407expects sync to remove a broken external link that is not in the manifest. The link is now kept, but the test still passes becausesb.FileExistsusesos.Stat, which returns false for a broken link. It should assert the link is kept (viaLstat), plus a manifest-recorded variant that asserts removal.- Two paths still re-point links skillshare did not create. Copy mode (
internal/sync/copy.go:154-160) removes any same-name link and writes a copy. Agent merge (internal/sync/agent_sync.go:140-156) re-points any same-name link to the source. Either cover them here, ideally through one shared "is this link ours?" helper used by skills merge, agents merge and copy mode (agents prune already hasprunableLink), or list them under "Not covered" so the title's "never re-point" stays accurate.
replaceIdenticalCopies and the trash
- Restoring from the trash lands in the source.
trash listshows the entry asreplaced-by-init/claude/alpha.trash restore(CLIcmd/skillshare/trash.go:203, dashboardinternal/server/handler_trash.go:166) restores into the skills source, so the folder ends up at<source>/replaced-by-init/claude/alphaand the next sync picks it up as a new nested skill. No data is lost, since the content is identical to the source, but the docs promise the folder "can be recovered". Please either say the trash copy is for manual recovery only, or keep it out of the restorable skills trash. - A failed move is reported as "differs from the source". When
MoveToTrashfails (init_apply.go:313-315), the folder goes intokept, andinit.go:421prints "Kept local copies that differ from the source". The folder is identical; the real error is dropped.MoveToTrashcan also return a path together with an error ("copied to trash but failed to remove original"). Only the success path is tested.
Smaller points
ManagedOnlybehaviour changed without a note. Dropping!opts.ManagedOnlyfrom the broken-external-link branch (sync.go:901) means the legacy project cleanup (legacy_project.go:104) now removes manifest-recorded broken external links. That seems reasonable, but thePruneOptions.ManagedOnlycomment (sync.go:773-776) still says broken-external-link cleanup is skipped, and nothing tests it.- Translations.
reference/commands/init.mdandunderstand/sync-modes.mdhave copies underwebsite/i18n/{ja,ko,zh-Hans,zh-Hant}/docusaurus-plugin-content-docs/current/, and none were updated with the trash sentence or the new sync-modes bullets. - PR body. It says
init --copy-from: replaceIdenticalCopies, butreplaceIdenticalCopiesruns on every init's first sync (firstSync), not only with--copy-from. The docs ("During the first sync") are correct. - Untested states: project mode with relative links, installs whose links predate the manifest (source moved),
ManagedOnly,target_naming: standard, and dry-run output for the new prune branches.
A small cleanup, optional: prune looks up manifest.Managed[name] three times for the same entry; computing owned := inManifest || force once would simplify the branches.
Happy to help with any of these. Feel free to ask if a point is unclear or you disagree with it.
Review of the first commit found places that still did, or predicted, the old behaviour. One rule now decides whether a link is skillshare's: Manifest.OwnsLink (the manifest records a link there, or it points into the source). It compares canonical paths, so a source reached through an alias and a relative project link still count as skillshare's. - copy mode kept re-pointing: it removed any same-name link and wrote a copy. It now keeps a link it does not own, like merge mode. - the dashboard diff predicted a prune for a folder that is only named like skillshare's, and an update for another tool's link. It now reports them as local and kept. The orphan-link prediction uses the same rule as prune. - `diff` reported a target as in sync while sync printed "kept local" for another tool's link. It lists the link as a local override. - doctor reported a broken link skillshare did not create as an error and suggested `skillshare sync`, which now keeps it. It is a warning with its own row, and `broken_symlinks` is `warning` in --json. - `trash restore` put a folder init had replaced into the source as a new nested skill. Restore refuses entries under replaced-by-init/ and names the trash folder to copy from. - init reported a folder it could not move to the trash as one that differs from the source, and dropped the error. It is reported separately, with the error. - the PruneOptions.ManagedOnly comment still said broken external links are skipped; manifest-recorded ones are removed. Tests cover the states the review listed: a source behind an alias, a relative project link, ManagedOnly, standard naming, dry run with --force, and a recorded copy the user replaced with a link. TestSync_Pruning_RemovesBrokenExternalSymlinks passed without testing anything, because FileExists follows links; it is now two tests that use Lstat, one per owner. Agent merge is unchanged: agents have no link manifest.
Copy mode now keeps a same-name link skillshare did not create, but both diffs read the entry with os.Stat. A broken link showed as a skill to add on every run, and a live one as a plain local copy, while sync kept both and said "kept local". `diff` and the dashboard diff check the link first and report it the way merge mode does: a local override, kept until --force.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
TestSyncMergeRepointsUnrecordedLinkIntoAliasedSource failed on Windows: it linked straight to a missing folder, and a junction cannot be made to one. It now links first and removes the folder after, like the other broken-link tests in this file.
|
@codex review |
linksIntoSource resolved both paths with EvalSymlinks, which gives up on a path that does not exist. A broken link is exactly that, so a link into a source reached through an alias (a symlinked config folder, or a short 8.3 path on Windows) compared an unresolved path with a resolved one and was taken for another tool's link. Sync then kept it instead of repairing or pruning it. It now uses sourcewalk.Canonical, which resolves the nearest folder that exists and keeps the missing tail. The test covers both spellings: the alias in the link, and the alias in the configured source.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6adb75f71d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return 0, nil, nil, err | ||
| } | ||
| kept = replaceIdenticalCopies(cfg, discovered) | ||
| kept, notTrashed = replaceIdenticalCopies(cfg, discovered) |
There was a problem hiding this comment.
Surface first-sync warnings for preserved foreign links
When initializing against an existing repository while a tool has a same-name link into another manager’s store, merge and copy sync now preserve that link. However, firstSync discards the results from runParallelSyncQuiet, and kept/notTrashed only describe real folders inspected by replaceIdenticalCopies. Consequently, performFreshInit prints “Synced …” without warning that the repository’s version was not activated or explaining how to replace the existing link. Propagate the actual sync results’ kept-link and prune warnings through the initialization output as well.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b60bf1c. firstSync now returns the warnings a plain sync prints, and init shows them, so a kept link, a look-alike folder and a broken link from another tool are all listed.
| _, inManifest := manifest.Managed[eName] | ||
| if manifest.OwnsLink(eName, entryPath, source) && (os.IsNotExist(statErr) || inManifest) { | ||
| dt.Items = append(dt.Items, diffItem{Skill: eName, Action: "prune", Reason: "orphan symlink", Kind: kindSkill}) |
There was a problem hiding this comment.
Match orphan previews to the live-external-link pruning rule
When a user changes the skills source through the dashboard configuration editor but retains the old checkout, an old skill absent from the new source can still have a manifest symlink record and a live external destination. Both OwnsLink and inManifest are then true, so this condition advertises a prune, but PruneOrphanLinksWithSkills explicitly keeps live external links unless forced (internal/sync/sync.go:910-916). The Sync page therefore counts a removal that ordinary sync never performs, and subsequent previews retain the same pending removal. Mirror the actual pruning predicate instead of treating the manifest record alone as sufficient for a live external link.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b60bf1c. The orphan preview now uses prune's rule: a link into the source goes when broken or recorded; any other link only when broken and recorded.
Two previews said less, or more, than sync does. init ran its first sync quietly and printed only "Synced". Sync now keeps a link another tool put on a skill's name, a folder that is only named like skillshare's, and a broken link it did not create, so the skill was reported as synced while the tool still loaded the other copy. firstSync returns the warnings a plain sync prints, and init shows them. They already name the folders that differ from the source, so the separate list of those is gone. The dashboard diff counted an orphan link as a removal whenever the manifest recorded it. Prune keeps a recorded link that still resolves outside the source (the source moved and the old checkout stayed), so the Sync page showed a removal that never happened. The diff now uses prune's own rule: a link into the source goes when broken or recorded; any other link only when broken and recorded.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add the four marketplace commits to the fork README's table. Record that runkids#914 was squash-merged upstream as 1419b62 after v0.30.9, so the replay will not drop the three runkids#914 commits by itself; they have to be dropped by hand once an upstream release contains it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the four marketplace commits to the fork README's table. Record that runkids#914 was squash-merged upstream as 1419b62 after v0.30.9, so the replay will not drop the three runkids#914 commits by itself; they have to be dropped by hand once an upstream release contains it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for this, @endgame302. The sandbox evidence made the problem easy to confirm, and the manifest-based rule is the right one. I pushed follow-up commits to your branch for the review points rather than send them back to you, and merged it. The main additions: the same rule now applies in diff, doctor and the dashboard, copy mode keeps another tool's link too, and a broken link into an aliased source is still repaired on Windows. It will be in the next release. If anything behaves differently from what you saw, please tell me. |
…board (#937) The Sync page predicted which orphan links sync would remove with its own copy of prune's rule. The copy had already drifted once (#914), and it still disagreed in two cases: prune treats a link it cannot follow, such as a loop, as broken, while the page only counted a missing destination; and prune keeps a link whose target it cannot read. The decision now lives in sync.OrphanLink. Prune and the dashboard diff both call it, so a later change to the rule reaches both. Prune's results, warnings and dry-run text are unchanged. LinksIntoSource, added for the dashboard's copy, is no longer needed and is removed.
The Latest callout still named 0.30.9. Point it at the Codex hook trust that 0.30.10 ships, in every translated README, and add the author of #914 to the contributors.
Type
proposals/only — see CONTRIBUTING.md)approvedlabel)Linked Issue
No issue yet. I found this testing 0.30.7 / 0.30.8 on Windows 10 against a copy of a real
~/.claude/skills. I'm happy to open an issue first if you'd rather discuss the approach there.Summary
On a plain
initfollowed bysync, skillshare deleted or re-pointed entries in~/.claude/skillsthat it never created (Windows, junctions)..skillshare-manifest.jsonalready records what skillshare made, so these paths now check it:Docs:
understand/sync-modes.mdalready said unknown directories are preserved, and the code now matches it. The page also gets notes on broken links and other tools' same-name links.reference/commands/init.mdmentions the trash.Evidence
Sandbox setup: a throwaway HOME on D: holding copies of a real
~/.claude/skills, plus four canaries:team__sharedwith an extra file_draftsnotes folderxlsxjunction into another manager's storeThe same script ran with 0.30.7 and with this branch: init → install pdf → sync → disable/enable → install xlsx + docx → uninstall.
team__sharedand its 2 files,_draftsand its file,broken-link), andxlsxre-pointed from the other store to skillshare's copy.Regression tests:
internal/sync/ownership_test.goandcmd/skillshare/init_apply_trash_test.gomake links withcreateLink, so they also run on Windows without Developer Mode (junctions).TestSyncTargetMerge_FixesBrokenLinknow records the link in the manifest first, because a same-name link that skillshare did not make is no longer re-pointed.Merge Danger
Door: two-way. There's no data migration, and reverting restores the old behaviour.
Blast Radius: narrow
Two groups see a change:
sync --forceis needed to remove or replace them.--force.Checks
Run on a Windows 10 host, not in the devcontainer:
go vetandgo buildfor./internal/sync ./internal/trash ./cmd/skillsharego teston the same packages: the same set of failures with and without this change, 90 ininternal/sync+internal/trashand 21 incmd/skillshare. Almost all areos.Symlinkneeding Developer Mode; the rest are Windows-environment tests. The 7 tests above pass.python3 scripts/ai-context.py checkNot run:
make checkin the devcontainer (no Docker on this machine),tests/integration, and the UI tests.Not covered:
.mdlinks.PruneOrphanAgentLinksstill removes broken links it did not make, because agents have no link manifest.replaced-by-initrows and shows the refusal.Checklist
make check) — tests are included;make checkwas not run, see ChecksWritten with AI assistance (Claude Code). It stays a draft until the author has reviewed it.
🤖 Generated with Claude Code