Skip to content

refactor(lib): harden shared-file-writer derivation against drift - #2204

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2110-shared-file-derive-hardening
Jul 10, 2026
Merged

refactor(lib): harden shared-file-writer derivation against drift#2204
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2110-shared-file-derive-hardening

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Addresses the two mid follow-ups from the PR #2109 review captured in #2110, hardening src/lib/shared-file-derive.ts against future drift. Refs #2081.

Changes

mid #1 — exhaustiveness for the shared-write feature classification

SHARED_WRITE_FEATURE_ORDER is hand-maintained. If commands/subagents/skills later start writing shared config files and someone forgets to account for them, the drift this derivation is meant to prevent could silently re-appear.

  • Added an explicit NON_SHARED_WRITE_FEATURES exclusion list (commands, skills), each documented with why it is excluded (both write their own dedicated per-item artifacts — command files / skill directories — never a file another feature also writes).
  • Added a test asserting SHARED_WRITE_FEATURE_ORDER ∪ NON_SHARED_WRITE_FEATURES partitions ALL_FEATURES exactly. Adding a new Feature now fails the test until it is consciously classified as a shared writer or an excluded one. (A duplicate makes the classified list longer than ALL_FEATURES, so the single partition assertion also rejects overlap — no redundant case.)

mid #2getExtraSharedWritePaths no longer swallowed by a throwing getSettablePaths

settablePathsForScope early-returned from the getSettablePaths catch, which skipped the subsequent getExtraSharedWritePaths collection. Currently harmless with existing tools, but a tool whose global getSettablePaths throws while it also has a global-only extra shared path would silently drop that path.

  • The two hooks are now collected independently: a throwing getSettablePaths leaves settable undefined and falls through to the extra-path collection instead of returning early. Both hooks remain fail-open individually (the derivation runs at module load, so a throwing tool must not take down every generate).
  • Exported settablePathsForScope and added a test that a throwing getSettablePaths still yields the tool's getExtraSharedWritePaths entries.

Notes

Full pnpm cicheck is green (typecheck, lint, 6926 tests, content checks).

Closes #2110

cm-dyoshikawa and others added 2 commits July 10, 2026 01:29
Address the two `mid` follow-ups from PR #2109 review (#2110):

mid#1: SHARED_WRITE_FEATURE_ORDER is hand-maintained, so a feature that later
starts writing a shared config file could be silently forgotten. Add an
explicit NON_SHARED_WRITE_FEATURES exclusion list (commands, skills — each
writes its own dedicated per-item artifact) plus a test asserting the two
lists partition ALL_FEATURES exactly. Adding a new Feature now fails the test
until it is consciously classified as a shared writer or an excluded one.

mid#2: settablePathsForScope early-returned from the getSettablePaths catch,
which skipped the subsequent getExtraSharedWritePaths collection. A tool whose
global getSettablePaths throws while it also has a global-only extra shared
path would silently drop that path. Collect extra paths independently of
getSettablePaths success (still fail-open per hook), and cover it with a test.

Closes #2110

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address a review low: settablePathsForScope became public in this PR, so
switch its positional (cls, global) args to a single object argument per the
project coding guideline for multi-arg functions.
@dyoshikawa
dyoshikawa merged commit 15a48c7 into main Jul 10, 2026
8 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-2110-shared-file-derive-hardening branch July 10, 2026 08:44
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

@dyoshikawa dyoshikawa mentioned this pull request Jul 10, 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.

Follow-ups from PR #2109: harden shared-file-writer derivation against drift

2 participants