Commit c76ff33
taosu
fix(uninstall): prevent over-hashing of user files in manifest
trellis init walked managed dirs (.codex/, .claude/, .opencode/) and hashed
every file into .template-hashes.json — including pre-existing user data
(.codex/sessions/, .claude/projects/, user-owned AGENTS.md). trellis uninstall
then unlinked every manifest entry, deleting that user data. Two real reports:
GitHub Issue #221 (.codex/sessions/ wiped) and PR #271 (pre-existing AGENTS.md
wiped via skip-existing path).
Manifest is now derived from "what trellis actually wrote this run", not from
walking the disk:
- writeFile() instruments recordWrite() on actual disk writes only. byte-
identical, skip-existing, and append paths do NOT record. initializeHashes
consumes the recorded set instead of fs.readdirSync walks.
- Root-level AGENTS.md only enters manifest when trellis writes it.
- pruneOrphanManifestKeys() self-heals already-poisoned manifests at the top
of both trellis update and trellis uninstall. Preserves .trellis/* (still
walk-managed), every configured-platform collectTemplates() path, every
path referenced by any migration manifest from/to, and AGENTS.md only when
it still carries trellis managed-block markers.
- Homedir guard: trellis init / uninstall refuse to run when cwd is exactly
the user's home directory (realpathSync.native + Windows lowercase). Bypass
via TRELLIS_ALLOW_HOMEDIR=1; --force does not bypass.
.trellis/ files keep their existing walk-based hashing — trellis uninstall
rm -rf's that subtree wholesale regardless of manifest content, so over-
hashing there does not affect uninstall safety.
Internal:
- New utils/cwd-guard.ts and utils/manifest-prune.ts.
- claude configurator excludes dev-only .ts from its template walk.
- 27 new tests across recorder boundaries, prune semantics, homedir cases,
and full init+uninstall reproductions for both reported scenarios.
Spec:
- .trellis/spec/cli/backend/migrations.md adds "Manifest ownership contract"
with the recorder rules, prune preserve-set, homedir guard, wrong-vs-
correct, and tests required for any future change in this area.1 parent e000208 commit c76ff33
13 files changed
Lines changed: 1296 additions & 99 deletions
File tree
- .trellis/spec/cli/backend
- packages/cli
- src
- commands
- configurators
- utils
- test
- commands
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
196 | 274 | | |
197 | 275 | | |
198 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
826 | 833 | | |
827 | 834 | | |
828 | 835 | | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
843 | 853 | | |
844 | 854 | | |
| 855 | + | |
| 856 | + | |
845 | 857 | | |
846 | 858 | | |
847 | | - | |
848 | | - | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
849 | 865 | | |
850 | 866 | | |
851 | 867 | | |
| |||
997 | 1013 | | |
998 | 1014 | | |
999 | 1015 | | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1000 | 1024 | | |
1001 | 1025 | | |
1002 | 1026 | | |
| |||
1727 | 1751 | | |
1728 | 1752 | | |
1729 | 1753 | | |
1730 | | - | |
1731 | | - | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
1738 | 1769 | | |
1739 | | - | |
1740 | | - | |
1741 | | - | |
1742 | | - | |
1743 | | - | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
1744 | 1775 | | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
1748 | 1779 | | |
1749 | | - | |
1750 | | - | |
1751 | | - | |
1752 | | - | |
1753 | | - | |
1754 | | - | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
1755 | 1789 | | |
1756 | | - | |
1757 | 1790 | | |
1758 | | - | |
1759 | | - | |
1760 | | - | |
1761 | | - | |
1762 | | - | |
1763 | | - | |
1764 | | - | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
1765 | 1798 | | |
1766 | | - | |
1767 | | - | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
1768 | 1804 | | |
1769 | 1805 | | |
1770 | | - | |
| 1806 | + | |
1771 | 1807 | | |
1772 | 1808 | | |
1773 | 1809 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| |||
362 | 371 | | |
363 | 372 | | |
364 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
365 | 382 | | |
366 | 383 | | |
367 | 384 | | |
| |||
388 | 405 | | |
389 | 406 | | |
390 | 407 | | |
391 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
392 | 436 | | |
393 | 437 | | |
394 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
1754 | 1755 | | |
1755 | 1756 | | |
1756 | 1757 | | |
1757 | | - | |
| 1758 | + | |
1758 | 1759 | | |
1759 | 1760 | | |
1760 | 1761 | | |
| |||
1772 | 1773 | | |
1773 | 1774 | | |
1774 | 1775 | | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
1775 | 1780 | | |
1776 | 1781 | | |
1777 | 1782 | | |
| |||
1781 | 1786 | | |
1782 | 1787 | | |
1783 | 1788 | | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
1784 | 1812 | | |
1785 | 1813 | | |
1786 | 1814 | | |
| |||
0 commit comments