Skip to content

docs(proposals): opt-in .skillfollow for declared source links (#274) - #369

Merged
runkids merged 18 commits into
mainfrom
runkids/proposal-274-skillfollow
Oct 4, 2026
Merged

runkids merged 18 commits into
mainfrom
runkids/proposal-274-skillfollow

Conversation

@runkids

@runkids runkids commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Summary

Adds proposals/274-skillfollow.md: an opt-in .skillfollow file that lets discovery follow declared first-level links (symlinks or Windows junctions) in the skills source, so a repo can live in the user's projects directory and still be a tracked repo. Without a .skillfollow, behavior does not change.

The design and the call-site list are @hhdebb's from #274. The Windows junction analysis and the provenance suggestion come from @star-nebula. The proposal answers the three requirements the maintainer set in #274:

  • (a) Future-proofing: one internal/sourcewalk package owns source traversal. A go/parser ratchet test in make test fails on any unclassified raw walk, and an integration fixture holds a per-command behavior matrix. Repo-root consumers (the update audit gates) move in the same step, because today they would scan zero files under a followed root and pass.
  • (b) Link ownership: three separate contracts. Sync identity uses an exact sameSkillLink. Prune requires manifest.Managed and a link inside the source or a currently followed root, which keeps merge-mode prune deletes live links into the source that skillshare never created #314's and fix(sync): prune only links skillshare created #315's guarantees. Status counts external links only with both. While any declared entry is unavailable (missing or rejected), prune is paused on every target, even with --force, and copy mode never replaces a copy whose origin it cannot prove.
  • (c) Git: an anchored /_name ignore line (the existing _name/ pattern does not match a symlink). A staging guard based on Git reachability runs at every staging point, including init --remote. Followed repos update with a dedicated --ff-only pull, and --force is refused. Source-repo pulls and resets fetch first and refuse when a declared link is indexed or when incoming paths cross any link in the working tree.

The write boundary is a filesystem handle, not a checklist. All writes to the skills source go through a small module that wraps an os.Root opened at the source root. It refuses any path that crosses a link, and it refuses removing or replacing a link. Only Unlink(entry) removes a link, and only unfollow calls it. A second ratchet counts raw os write calls in every package. Git subprocess seams keep explicit checks. An earlier per-seam design kept missing write paths in review, so the proposal replaced it.

Windows, verified on a real machine. Two Go probes ran on Windows 11 ARM64 with Developer Mode off, using both the full and the basic-user token:

  • Target junctions read back their logical path, so the ownership rules hold.
  • filepath.EvalSymlinks does not resolve junctions, so the proposal requires a junction-aware canonicalizer, including for relative-link parents.
  • os.Root refuses writes through escaping junctions and symlinks, removes only the link itself, and opens a source root that is a link. The same results hold on Linux.

The Developer Mode relative-symlink case is not tested yet.

Rollout is in four steps. Step 1 is a doctor notice for undeclared links, with no behavior change. Step 2 moves walks and writes onto the new modules. .skillfollow is enabled in step 3. Five former open questions are recorded as decisions that review can reopen. One open question remains: a suspected pre-existing bug where a junction used as the skills source root is discovered as empty on Windows.

No code changes. Implementation waits for approval of the proposal.

Review notes

Codex review ran nine rounds. Every finding was fixed in a follow-up commit, and each thread has a reply naming the commit. Two threads were answered in the final commit (ec86f32): the install --update audit rollback is now listed as the third hard-reset path, and the dashboard branch switch joins the pull/reset git seam, with discard documented as safe because git clean -fd runs without -x. No threads were resolved. Re-review was stopped after round 9 because the remaining findings were at the level of implementation detail.

Linked Issue

Refs #274 (a proposal does not close the feature issue).

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — not applicable: documentation only. python3 scripts/ai-context.py check passed; make check was not run.
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Issue #274 asks for a way to keep a tracked repo outside the skills
source and link it in. The maintainer asked the proposal to cover
future-proofing of source walks, link ownership for prune/status, and
git operations. This records the design grounded in current source,
credits hhdebb's design and star-nebula's Windows/provenance analysis,
and lists the open questions before any implementation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 449fbe357b

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Resolved
Comment thread proposals/274-skillfollow.md Resolved
Comment thread proposals/274-skillfollow.md Resolved
Comment thread proposals/274-skillfollow.md Resolved
Comment thread proposals/274-skillfollow.md Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T20:20:10.027636Z d4b74b4 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

An adversarial review against current source found gaps: followed
groups would let uninstall trash external content, overlap checks were
one-directional, relative links still churned with a symlinked source
root, and plain pull can create merge commits in the user's repo.

This records the agreed fixes: an external mutation boundary shared by
CLI and server, symmetric overlap rules, exact link identity, a
conservative prune policy while an entry is missing, staging-tree-only
git guards with indexed-link detection, ff-only pulls with documented
audit rollback, a call-level ratchet plus a behavior fixture, and
phase 1 limited to followed groups and tracked repos.
The second review found that the update audit walks a followed repo
root through its link and would scan nothing, and that a missing
followed entry could let standard-naming copy sync overwrite the only
remaining copy of its content. It also found that followed-repo pulls
could still create merge commits or hide errors, and that the staging
guard judged by path containment instead of Git reachability.

This records the agreed fixes: repo-root consumers resolve their root in
step 3 with a zero-file fail-closed check, a prune pause and copy
preservation while any entry is missing (even with --force), separate
identity/ownership/status contracts, one shared ff-only followed-update
policy with per-item errors, a reachability-based staging guard, and
rejection of followed targets inside the git staging tree.
The proposal left open whether Go reads back a target junction whose
stored path crosses a followed junction. A probe on Windows 11 ARM64
(Go 1.25.5, full and basic-user tokens) shows os.Readlink returns the
logical path, so ownership and identity hold without the EvalSymlinks
fallback. It also shows filepath.EvalSymlinks leaves junctions
unresolved, so the design now resolves followed entries with
ResolveLinkTarget and requires a junction-aware canonicalizer instead
of ResolveSymlink/evalOrClean on Windows.
The maintainer review needs a clear position instead of five open
questions. Record the recommended defaults as decisions that review
can still reopen, and keep the pre-existing junction source-root issue
as the only open question, since it needs an ss.exe reproduction first.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8e76fdc08

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Resolved
single-skill was checked before cycle, target-overlap, inside-git-root,
and entry-overlap, so a link into an active target such as
a -> <target>/a would be accepted as a skill once step 4 enables them.
sync --force could then remove the real directory as a local copy.
Run every safety check first and keep single-skill ahead of tracked-repo
detection only.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6855e0466e

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Resolved
Comment thread proposals/274-skillfollow.md Resolved
Comment thread proposals/274-skillfollow.md Resolved
The section 4 boundary missed writes that would change a followed
tree: dashboard content edits, dashboard remote changes, dashboard
create with an into path, and config installs that create the group
directory before the install guard runs. List each seam and require the
check before the first write, including directory creation.

Treating not-link entries as followed also blocked ordinary work in a
real source directory that happens to be named in a shared declaration.
Keep not-link under today's source ownership rules.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cb8863784

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated
| CLI uninstall of a descendant | `performUninstallQuiet`, `performUninstall` (`cmd/skillshare/uninstall_handlers.go:107`, `:128`) |
| Server uninstall of a descendant | `handleBatchUninstallSkills` (`internal/server/handler_uninstall.go:147`, trash at `:204`, `:251`) |
| Collect into or over a followed entry | `PullSkill` (`internal/sync/pull.go:127`, `RemoveAll` at `:136`) |
| Install overwrite or `--into` a followed tree | `installImpl` (`internal/install/install_apply.go:177`, `RemoveAll` at `:202`); `installFromDiscoveryInternal` (`:348`, replace at `:449-452`) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard all --into directory creation before writing

When a CLI install uses --into _f/new-group, or either dashboard install endpoint submits the same path, these callers create the directory before reaching the proposed guards in installImpl or installFromDiscoveryInternal: ensureIntoDirExists calls os.MkdirAll (cmd/skillshare/install.go:245-249), and handleInstallBatch/handleInstall do so directly (internal/server/handler_install.go:172-178, :487-490). If _f is followed, this already creates new-group in the external repository even though the later install is refused. The new config-install row covers only install_config.go; apply the ownership check before these non-config creation paths too.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 12a7262. §4 no longer relies on a per-seam check. Every write to the skills source now goes through an *os.Root opened at the source root, which refuses any path that leaves the root through a link. A probe on Linux and on Windows 11 ARM64 (full and basic-user tokens) confirmed that WriteFile, MkdirAll, Remove, RemoveAll, and Rename through an escaping symlink or junction are refused with the external tree unchanged (table in §4). The --into paths in ensureIntoDirExists and both server install endpoints create directories through the same handle, so they are refused before anything is created. The Test Plan lists them as regression cases.

Comment thread proposals/274-skillfollow.md Outdated
| Tracked install over a followed repo | `installTrackedRepoImpl` (`internal/install/install_tracked.go:10`, overwrite at `:72`). `install --update` on a followed repo goes through §5's followed-update policy instead. |
| Standalone or local update inside a followed tree | `handleUpdate` (`internal/install/install_update.go:11`, replace at `:146-150`, `:260-263`) |
| Config install into a followed group | both config-install paths create the group directory before the install guard runs (`internal/install/install_config.go:273`, `:406`), so the check runs before each `os.MkdirAll` |
| Dashboard edit of a followed skill's files | `handlePutSkillContent` (`internal/server/handler_skill_content.go:34`, write at `:70`) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refuse frontmatter edits inside followed entries

Once followed group skills become discoverable, two mutation paths remain outside this table: the dashboard target endpoints write metadata.targets directly to each discovered SKILL.md (internal/server/handler_skills_batch.go:115-116 and :229-233), and pressing M in the list TUI writes disable-model-invocation through ToggleFrontmatterFlag (cmd/skillshare/list_tui.go:642-650). For a skill below a followed group these writes modify the user's external tree, contradicting the stated rule that only unfollowing and controlled pulls may do so; both paths need the shared followed-entry refusal before editing.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 12a7262. §4 no longer relies on a per-seam check. Every write to the skills source now goes through an *os.Root opened at the source root, which refuses any path that leaves the root through a link. A probe on Linux and on Windows 11 ARM64 (full and basic-user tokens) confirmed that WriteFile, MkdirAll, Remove, RemoveAll, and Rename through an escaping symlink or junction are refused with the external tree unchanged (table in §4). Frontmatter edits from the server batch endpoints and the list TUI M toggle write through the handle, so a skill below a followed group is refused. Both are regression cases in the Test Plan.

Comment thread proposals/274-skillfollow.md Outdated

**1. Identity: does this link already point at this skill?** This is used only by sync to decide whether to keep a link or recreate it.

- *Creation.* Relative skill links are computed from `evalOrClean(linkDir)` to `evalOrClean(sourceRoot) + "/" + relPath`. Only the source root and the link's parent are canonicalized. The followed entry stays in the link text, and the OS resolves it when the link is opened. `createLink` gets an explicit skills-only root/tail input. Its agents and extras callers keep their current behavior (`agent_sync.go:153-184`, `:317-349`, `extras.go`, `extras_file.go`). `reformatLink` (`relative.go:90`) and `CreateSymlink` (`sync.go:236`) take the skills path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve junction parents before computing relative links

On Windows Developer Mode, a project target whose parent is a junction will still be mislinked by this algorithm because evalOrClean(linkDir) does not resolve junctions, as §6 itself establishes. For example, if C:\proj\target is a junction to C:\elsewhere\target, the relative path is calculated from the logical parent under C:\proj but Windows interprets it from the real parent under C:\elsewhere, so the link points at the wrong tree. Use the proposed junction-aware canonicalizer for the link parent and the relative-link decision rather than retaining evalOrClean here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 12a7262. §3 Creation now computes relative links from canon(linkDir) to canon(sourceRoot), using the junction-aware canonicalizer from §1 instead of evalOrClean, and Comparison resolves the real parent with canon too. §6 notes the switch. The Developer Mode case is still listed as untested in the runbook.

Comment thread proposals/274-skillfollow.md Outdated
- `handleBatchUninstallSkills` (`internal/server/handler_uninstall.go:239-251`) refuses only tracked-repo members, so it would move a group child into trash.
- `resolveGroupSkills` (`uninstall.go:221-255`) feeds children to `MoveToTrash` (`uninstall_handlers.go:113`, `:129`).

The boundary below therefore lives in shared domain code that the CLI and the server both call, not in each handler. Every refused seam runs the check before its first write, including directory creation. A declared name in any state except `not-link` (missing, rejected, and so on) is treated as followed for these checks, so they fail closed before any write. A `not-link` entry is a real directory inside the source, so it keeps today's source ownership rules: naming it in a shared `.skillfollow` never blocks ordinary uninstall, install, or update below it on a machine where it is not a link.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop init fallback from writing through followed entries

When an existing source declares a followed group named skillshare without a root SKILL.md, init calls installBuiltinSkill; even if the proposed install.Install guard refuses the destination, that function treats every install error as a download failure and immediately falls back to os.MkdirAll(dir) plus os.WriteFile(dir/SKILL.md) (cmd/skillshare/init_apply.go:185-198). Because dir is the followed link, the fallback writes into the external group and bypasses the fail-closed boundary. Guard this fallback before its first write, or propagate ownership refusals instead of invoking the fallback.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 12a7262. §4 no longer relies on a per-seam check. Every write to the skills source now goes through an *os.Root opened at the source root, which refuses any path that leaves the root through a link. A probe on Linux and on Windows 11 ARM64 (full and basic-user tokens) confirmed that WriteFile, MkdirAll, Remove, RemoveAll, and Rename through an escaping symlink or junction are refused with the external tree unchanged (table in §4). installBuiltinSkill's fallback writes through the same handle, so a refused install cannot fall through to a raw MkdirAll/WriteFile into the followed group. It is a regression case in the Test Plan.

Four review rounds kept finding write paths that the per-seam
followed-entry check missed, each of which wrote into the user's
external tree before any check ran. A predicate that every caller must
remember is the wrong shape for this boundary.

Route source writes through an os.Root opened at the source root, which
refuses any path that leaves the root through a link. A probe on Linux
and on Windows 11 ARM64 (full and basic tokens) confirmed that writes,
removals, and renames through escaping symlinks and junctions are
refused, that removing the link itself works, and that a linked source
root still opens. Only git subprocess seams keep an explicit check, and
a ratchet counts raw os write calls.

Also canonicalize relative-link parents with the junction-aware
canonicalizer, since evalOrClean does not resolve junctions.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12a7262e4a

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated

*What callers do:*

- Domain functions that write the source take the root handle instead of building paths from the source string. That covers install, update, uninstall, collect, `new`, `init`, reconcile, sidecar migration, frontmatter edits, and the server handlers that call them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard final link components before overwriting them

When an overwrite targets the followed entry itself—for example, install --track --force selecting an existing _repo—moving the current os.RemoveAll(destPath) (internal/install/install_tracked.go:72) onto the root handle will still remove the link and let the subsequent clone replace it with a real directory, silently disconnecting the external repo and changing the declaration to not-link. The same issue affects atomic Root.Rename over a symlinked SKILL.md: rename replaces the link rather than traversing it. Fresh evidence against the prior os.Root resolution is the proposal's own table at line 243, which confirms that removing _f itself is allowed; final components therefore need an explicit link/follow-state guard before generic overwrite or replacement operations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 46697a7. Callers no longer get the raw *os.Root. §4 adds a thin source-write module that wraps it and checks the last component with Lstat through the root before Remove, RemoveAll, an overwriting write, or a Rename onto an existing path, and refuses when it is a link. A declared entry gets "use unfollow", and any other link gets "edit its target directly". Link removal is exposed only as Unlink(entry), which unfollow alone calls. So install --track --force onto a followed _repo is refused at install_tracked.go:72, and an atomic write cannot replace a linked SKILL.md. Both are in the Test Plan. The check-then-act gap is documented alongside §5's concurrency note.

os.Root refuses paths that pass through a link but still removes or
replaces a link that is the last component. install --track --force on
a followed _repo would then delete the link and clone a real directory
in its place, and an atomic write would replace a linked SKILL.md.

Wrap the root in a source-write module that refuses remove, overwrite,
and rename-over when the last component is a link, and expose link
removal only through Unlink for unfollow.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46697a7b57

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated
Comment on lines +58 to +59
2. `not-link`: the entry is a real directory. This is a no-op; the directory is discovered anyway.
3. `invalid-target`: the link resolves to a file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Classify declared non-link files before followed

When a declaration names an existing regular file, FIFO, or socket, it matches neither missing, not-link (limited to real directories), nor invalid-target (limited to links resolving to files), so the ordered rules fall through to followed despite the claim that every entry has exactly one meaningful state. Define a rejected state for existing non-link, non-directory entries, or broaden invalid-target, so the walker never treats them as followable roots.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2aef578. invalid-target (state 3) now covers a link that resolves to anything other than a directory, and an entry that is itself neither a link nor a directory (regular file, FIFO, socket, or device). So no existing entry can fall through to followed.

Comment on lines +273 to +280
**Outside the handle.** Git runs as a subprocess, so the root cannot see its writes. These seams keep an explicit followed-entry check:

| Operation | Seam |
|---|---|
| Pull, audit rollback, and `--force` on a followed repo | §5's followed-update policy |
| Dashboard source change on a followed repo | `handlePatchSkillSource` (`internal/server/handler_skill_content.go:98`), which calls `git.SetRemoteURL` at `:162` |
| Staging | §5's staging guard |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard source-repository pulls that can replace followed links

When a declared link is already indexed—the recovery state explicitly handled by the staging guard—a clean skillshare pull, dashboard source pull, or init remote reset can update, remove, or repoint that link from a remote commit because Git writes outside the os.Root wrapper. This bypasses the preceding guarantee that only Unlink(entry) may remove or replace a final link component; include source-repository pull/reset seams in this table or refuse them until indexed followed links are untracked.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2aef578. §4's Outside the handle table now lists the source-repo seams: pullFromRemote (ss pull), the dashboard handlePull via PullWithResolution, and the init resets (resetToRemoteBranch, init.go:775). Each one fetches first, then refuses while a declared entry in the staging tree is indexed, or while the incoming revision touches a declared entry path. The second check covers the ignored-only case too, since Git treats ignored files as expendable. The Test Plan covers both cases.

Comment thread proposals/274-skillfollow.md Outdated
Comment on lines +339 to +342
**Audit rollback is kept and documented.** When the audit fails after a pull, two paths run `git reset --hard <beforeHash>`, even without `--force`:

- `auditGateAfterPull` (`update_handlers.go:56`, `:96`, `:107`)
- the server's `auditGateTrackedRepo` (`handler_update.go:375`, `:392`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include install updates in the rollback contract

The proposal has just included install --update in the shared followed-update policy, but this section says only two paths hard-reset after an audit failure. auditTrackedRepoUpdate in internal/install/install_audit.go also calls git reset --hard <beforeHash>, so leaving it out can make the required user documentation falsely imply that install updates never reset a followed working copy. Preserve and document this third rollback path as well.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ec86f32. The rollback section now lists auditTrackedRepoUpdate (internal/install/install_audit.go:277) as the third hard-reset path, so the documentation requirement covers install --update too.

A declared name that is a regular file, FIFO, or socket matched no
state and fell through to followed. Broaden invalid-target to cover any
entry that is neither a link nor a directory.

Source-repo pulls and init resets run git outside the os.Root module
and could replace a declared link from a remote commit, even when the
link is only ignored, since Git treats ignored files as expendable.
Fetch first and refuse while a declared link is indexed or the incoming
revision touches a declared entry path.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2aef578acc

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated
| Pull, audit rollback, and `--force` on a followed repo | §5's followed-update policy |
| Dashboard source change on a followed repo | `handlePatchSkillSource` (`internal/server/handler_skill_content.go:98`), which calls `git.SetRemoteURL` at `:162` |
| Staging | §5's staging guard |
| Source-repo pull and reset: `ss pull` (`pullFromRemote`, `cmd/skillshare/pull.go:54`), the dashboard pull (`handlePull`, `internal/server/handler_git.go:677`, via `PullWithResolution` at `:745`), and the `init` resets to a remote branch (`resetToRemoteBranch`, `cmd/skillshare/init_remote.go:126`; `cmd/skillshare/init.go:775`) | Fetch first. Then refuse while any declared entry in the staging tree is indexed, or while the incoming revision touches a declared entry path (`git diff --name-only HEAD <incoming> -- <entries>`). Ignoring the link is not enough: Git treats ignored files as expendable, so a remote commit that adds that path would replace the link. The message names the path and the commit, and says to run `git rm --cached` or to fix the remote. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard undeclared links during source-repository updates

When an ignored but undeclared link exists in the source and the incoming revision adds the same path, this guard checks only declared entry names, so pullFromRemote, dashboard pull, or an init reset can replace the link because Git treats ignored paths as expendable. Fresh evidence beyond the earlier declared-link guard is §4's final-component contract at lines 248–250, which explicitly protects undeclared links too; inspect incoming paths for existing link components rather than limiting this Git-side guard to the FollowSet declarations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b16a2aa. The source-repo pull/reset guard now checks every path from git diff --name-only HEAD <incoming> with Lstat on its existing ancestors, and refuses when any of them is a link, declared or not. That matches the final-component rule in the write module, and it also closes the same exposure that undeclared links have today. The Test Plan covers an ignored undeclared link.

Comment thread proposals/274-skillfollow.md Outdated
- **Reconcile keeps metadata only under the missing entry's logical prefix**, including the entry itself. Keys are already logical paths (`reconcile_core.go:46`). `pruneStaleEntries` (`:132-138`) still prunes everything else normally.
- **Output.** `sync` prints `prune paused`, and reports copies kept from replacement. `status` and `doctor` name the blocking entry and say "restore `<path>` or remove `<name>` from `.skillfollow[.local]` to resume cleanup". An abandoned declaration keeps the pause in place indefinitely. This is by design: a visible, recoverable safety state is better than silent data loss. It needs no new override and no schema change.

These rules apply only when at least one entry is `missing`. Prune with no `.skillfollow`, or with every entry valid, is unchanged.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pause pruning for rejected unavailable entries

When a previously followed entry becomes invalid-target, cycle, target-overlap, or another rejected state, discovery omits its skills just as it does for missing, but this restriction leaves pruning enabled. A normal copy-mode sync can therefore delete the managed target copies from that entry—for example after its link is accidentally replaced by a regular file—even when those copies are the only remaining skill content. Extend the conservative pause to every declared state whose prior skills cannot be attributed, or define an equally safe recovery policy for rejected entries.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b16a2aa. §3 point 4 now applies to unavailable entries: any declared entry in a state other than followed or not-link, which means missing or any rejected state (including single-skill before step 4). Prune pauses, copies are not replaced, and reconcile keeps metadata under the entry's prefix, the same as for missing. The recovery message now says "restore or fix". New case 8b covers a link replaced by a regular file in copy mode.

A previously followed entry that turns into a rejected state, such as a
link replaced by a regular file, drops its skills from discovery just
like a missing one, and copy-mode prune could then delete the only
remaining copies. Pause prune for every declared entry that is not
followed or not-link.

The source-pull guard checked only declared entries, while the write
module also protects undeclared links. Check every incoming path for an
existing link component so Git cannot replace any ignored link.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b16a2aae11

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated
- A move across the root's edge cannot use `Root.Rename`, so the in-source side is checked through the root first. For example, trash moves out of the source, and staged installs and updates rename a temp directory in (`install_apply.go:452`, `install_update.go:150`, `:263`). `Root.Stat` of the in-source parent fails on any crossing link, as the table shows.
- Fallbacks write through the same handle, so a refused install cannot fall through to a raw write (for example `installBuiltinSkill`, `cmd/skillshare/init_apply.go:185-198`).
- An escape error under a declared entry is reported as "inside followed entry `<name>`; hide it with the root `.skillignore`". Any other escape is reported as "path crosses a link in the skills source". Sidecar migration (`metadata_migrate.go:135`) skips instead of failing, and `doctor` reports the unmigrated sidecars.
- The step 2 ratchet also counts raw `os` write calls (`Create`, `OpenFile`, `WriteFile`, `Mkdir`, `MkdirAll`, `Remove`, `RemoveAll`, `Rename`, `Symlink`) in `cmd/skillshare`, `internal/install`, `internal/sync`, and `internal/server`. Each remaining call carries a reason that says it does not write the skills source, such as `target`, `backup`, `trash`, `config`, `agents`, or `extras`. A new unclassified call fails the test. This has the same syntactic limitation as the walk ratchet.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include CreateTemp in the source-write boundary

When the dashboard edits content inside a followed skill, writeFileAtomic currently begins with os.CreateTemp(dir, ...) in internal/server/handler_skill_content.go:347; because this ratchet omits os.CreateTemp, that call can survive the migration and create/write a temporary file in the external repository before the guarded rename refuses the escape. Fresh evidence beyond the earlier dashboard-mutation finding is this unclassified raw creator, which is not covered by the proposed module API or call list. Add CreateTemp to the ratchet and provide a root-scoped atomic-write operation so the first filesystem mutation is also constrained.

AGENTS.md reference: AGENTS.md:L13-L17

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2f7e951. The ratchet now also counts CreateTemp, MkdirTemp, Link, Truncate, and Chmod. The write module provides WriteFileAtomic, which creates the temp file and renames it inside the root, following the existing rootAtomicWrite (internal/plugin/pi_extensions_project.go:593). So the first filesystem change is constrained too, and the dashboard edit path no longer starts with a raw os.CreateTemp in the target directory.

writeFileAtomic starts with os.CreateTemp in the target directory, and
the ratchet did not count CreateTemp, so a temp file could be created
in the external tree before the guarded rename refused the escape.
Count CreateTemp and the other raw file-creating calls, and give the
write module a root-scoped WriteFileAtomic.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f7e951440

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated
Comment on lines +249 to +251
*The final component.* `os.Root` refuses paths that pass *through* a link, but it still acts on a link that is the *last* component. `Remove("_f")` deletes the link, and `Rename` over a link replaces it. Without a guard, `install --track --force` on an existing followed `_repo` would remove the link at `os.RemoveAll(destPath)` (`internal/install/install_tracked.go:72`) and clone a real directory in its place, so the external repo is silently disconnected. An atomic write (temp file plus rename) would also replace a `SKILL.md` that is a link with a plain file.

So callers do not get the raw `*os.Root`. They get a thin source-write module that wraps it and owns this rule. Before `Remove`, `RemoveAll`, an overwriting `WriteFile` or `OpenFile`, or a `Rename` onto an existing path, it runs `Lstat` on the last component through the root. If that component is a link, it refuses: "`<name>` is a followed entry; use `unfollow`" for a declared entry, and "`<path>` is a link; edit its target directly" otherwise. The only way to remove a link is `Unlink(entry)`, which unfollow alone calls. Removing a directory that *contains* links is unchanged, because removal never follows them. The check and the operation are not atomic. This is the same limitation as §5's concurrency note.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check intermediate links before source writes

When an explicit destination crosses an undeclared relative symlink that resolves back inside the source, os.Root permits the operation (as the table at line 245 acknowledges), while this wrapper checks only the final component. Thus install --into alias/new can still write through alias, contradicting both the refusal promised at line 264 and the integration case requiring undeclared --into links to be rejected. Inspect every path component in the wrapper, or narrow the documented contract and tests to escaping links.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d4b74b4. The write module now runs Lstat through the root on every path component, not only the last, and applies the check to every write. That refuses install --into alias/new through an undeclared relative in-source link, which os.Root alone allows, so the contract and the integration case are consistent.

Comment thread proposals/274-skillfollow.md Outdated
- Atomic writes use the module's `WriteFileAtomic`, which creates the temp file and renames it inside the root, following `rootAtomicWrite` (`internal/plugin/pi_extensions_project.go:593`). So the first filesystem change is already constrained. Today's `writeFileAtomic` starts with `os.CreateTemp` in the target directory (`internal/server/handler_skill_content.go:347`), which would otherwise create a temp file in the external tree before the rename is refused.
- Fallbacks write through the same handle, so a refused install cannot fall through to a raw write (for example `installBuiltinSkill`, `cmd/skillshare/init_apply.go:185-198`).
- An escape error under a declared entry is reported as "inside followed entry `<name>`; hide it with the root `.skillignore`". Any other escape is reported as "path crosses a link in the skills source". Sidecar migration (`metadata_migrate.go:135`) skips instead of failing, and `doctor` reports the unmigrated sidecars.
- The step 2 ratchet also counts raw `os` write calls (`Create`, `CreateTemp`, `MkdirTemp`, `OpenFile`, `WriteFile`, `Mkdir`, `MkdirAll`, `Remove`, `RemoveAll`, `Rename`, `Symlink`, `Link`, `Truncate`, `Chmod`) in `cmd/skillshare`, `internal/install`, `internal/sync`, and `internal/server`. Each remaining call carries a reason that says it does not write the skills source, such as `target`, `backup`, `trash`, `config`, `agents`, or `extras`. A new unclassified call fails the test. This has the same syntactic limitation as the walk ratchet.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scan every package that can write the skills source

Restricting the write ratchet to these four directories omits existing helpers that directly mutate skills-source paths, including internal/utils/frontmatter_write.go, internal/skillignore/write.go, and internal/trash/trash.go (MoveToTrash renames and removes its source argument). Those are precisely the frontmatter, ignore-file, and uninstall paths this section claims to constrain, so a retained or newly introduced raw write in those packages passes the proposed ratchet and can bypass the os.Root boundary. Include all source-writing packages or ratchet the shared helper APIs themselves.

AGENTS.md reference: AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d4b74b4. The write ratchet now scans every non-test package under cmd/ and internal/, and names the shared helpers that write source paths today: internal/utils/frontmatter_write.go, internal/skillignore/write.go, and MoveToTrash in internal/trash/trash.go.

Comment thread proposals/274-skillfollow.md Outdated
| Pull, audit rollback, and `--force` on a followed repo | §5's followed-update policy |
| Dashboard source change on a followed repo | `handlePatchSkillSource` (`internal/server/handler_skill_content.go:98`), which calls `git.SetRemoteURL` at `:162` |
| Staging | §5's staging guard |
| Source-repo pull and reset: `ss pull` (`pullFromRemote`, `cmd/skillshare/pull.go:54`), the dashboard pull (`handlePull`, `internal/server/handler_git.go:677`, via `PullWithResolution` at `:745`), and the `init` resets to a remote branch (`resetToRemoteBranch`, `cmd/skillshare/init_remote.go:126`; `cmd/skillshare/init.go:775`) | Fetch first. Then refuse while any declared entry in the staging tree is indexed, or while the incoming revision touches a path that has a link component in the working tree, declared or not. Each path from `git diff --name-only HEAD <incoming>` is checked with `Lstat` on its existing ancestors. Ignoring the link is not enough: Git treats ignored files as expendable, so a remote commit that adds that path would replace the link. Checking undeclared links too keeps this seam consistent with the final-component rule above, and it closes the same exposure that undeclared links have today. The message names the path and the commit, and says to run `git rm --cached` or to fix the remote. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse changed Git paths with NUL delimiters

When an incoming revision contains a pathname requiring Git quoting—such as a newline, tab, quote, or backslash beneath an existing undeclared link—plain git diff --name-only does not yield an unambiguous path stream, so the ancestor Lstat check can inspect a quoted or split name instead of the actual link and allow the subsequent pull/reset to replace it. git diff -h documents -z as producing NUL-terminated output; require git diff --name-only -z and NUL parsing so every legal Git pathname is checked.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d4b74b4. The guard now uses git diff --name-only -z HEAD <incoming> and parses on NUL, so names that Git would quote are checked exactly.

os.Root permits a relative link that stays inside the root, so checking
only the last component let install --into write through an undeclared
in-source link. Check every component. Widen the write ratchet to all
packages, since frontmatter, skillignore, and trash helpers write source
paths outside the four listed ones. Parse git diff output with -z so
names that Git quotes are checked exactly.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4b74b4f55

ℹ️ 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".

Comment thread proposals/274-skillfollow.md Outdated
| Pull, audit rollback, and `--force` on a followed repo | §5's followed-update policy |
| Dashboard source change on a followed repo | `handlePatchSkillSource` (`internal/server/handler_skill_content.go:98`), which calls `git.SetRemoteURL` at `:162` |
| Staging | §5's staging guard |
| Source-repo pull and reset: `ss pull` (`pullFromRemote`, `cmd/skillshare/pull.go:54`), the dashboard pull (`handlePull`, `internal/server/handler_git.go:677`, via `PullWithResolution` at `:745`), and the `init` resets to a remote branch (`resetToRemoteBranch`, `cmd/skillshare/init_remote.go:126`; `cmd/skillshare/init.go:775`) | Fetch first. Then refuse while any declared entry in the staging tree is indexed, or while the incoming revision touches a path that has a link component in the working tree, declared or not. Each path from `git diff --name-only -z HEAD <incoming>`, parsed on NUL so that quoted names are read exactly, is checked with `Lstat` on its existing ancestors. Ignoring the link is not enough: Git treats ignored files as expendable, so a remote commit that adds that path would replace the link. Checking undeclared links too keeps this seam consistent with the final-component rule above, and it closes the same exposure that undeclared links have today. The message names the path and the commit, and says to run `git rm --cached` or to fix the remote. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard checkout and discard from replacing followed links

When dashboard Git Sync operates on a source repository containing followed entries, this table protects pull/reset but omits POST /api/git/checkout and POST /api/git/discard. I checked handleGitCheckout and handleGitDiscard: they invoke git.Checkout and git.DiscardChanges, whose checkout and git clean -fd/restore mutations run outside the source-write wrapper. git checkout -h explicitly documents --overwrite-ignore as the default, so switching to a branch that tracks a declared link path can replace even a correctly ignored link; discard can likewise delete an unignored declared link or restore an indexed one. Apply the incoming-path/link guard to both operations, or refuse them while affected links exist, to preserve the contract that only Unlink may remove or replace a link component.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ec86f32. The dashboard branch switch (handleGitCheckout, via git.Checkout) joins the pull/reset seam, with the branch being checked out as the incoming revision. Discard is documented as needing no new seam: git clean -fd runs without -x, so an ignored link stays, and git restore --source=HEAD only rewrites indexed paths, which the staging guard keeps the link out of. The Test Plan pins both.

The audit rollback section listed two hard-reset paths while the shared
followed-update policy already covered install --update, whose
auditTrackedRepoUpdate is a third. The git seam table protected pull and
reset but not the dashboard branch switch, which replaces an ignored link
the same way an incoming pull does. Discard is documented as safe because
git clean runs without -x.
@runkids
runkids merged commit 61c366b into main Oct 4, 2026
8 checks passed
@runkids
runkids deleted the runkids/proposal-274-skillfollow branch October 4, 2026 20:27
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