Commit Graph

2 Commits

Author SHA1 Message Date
YueKang
260d5c9f9c test: add regression tests for self-referential symlink bug (#217)
Two new test cases in test_sync_symlinks.py:

1. TestSyncScriptSymlink.test_skips_self_referential_via_directory_symlink
   Unit test: verifies _sync_script_symlink() returns False and leaves
   the real source file intact when dst_file is accessed through a
   directory-level symlink that points back to the project scripts/ dir.

2. TestSyncScriptsToWorkspaces.test_no_self_referential_symlinks_when_workspace_scripts_is_dir_symlink
   Integration test: simulates the install.sh scenario where
   workspace-main/scripts -> project/scripts, then confirms that
   sync_scripts_to_workspaces() does not convert any real source file
   into a self-referential symlink."
2026-03-28 17:10:16 +08:00
Sliverp
c8d9b9d7c4 fix: use symlinks for workspace script sync to fix data-path split (#56) (#176)
sync_scripts_to_workspaces() previously used physical file copies.  Scripts
that derive project root from __file__ (e.g. kanban_update.py) therefore
resolved to the workspace directory when run as a copied file, causing
tasks_source.json writes to land in the wrong location while the Dashboard
reads from the canonical data/ directory.

Replace write_bytes() with os.symlink() so __file__ always resolves back to
the project scripts/ directory.  This ensures that all path-derived constants
(TASKS_FILE, DATA, etc.) point to the single canonical data/ folder regardless
of which agent workspace runs the script.

Added _sync_script_symlink() helper with:
- Idempotent re-runs (skip if link already correct)
- Automatic cleanup of stale physical copies and broken symlinks
- Full test suite (10 tests) covering creation, idempotency, replacement
  of physical copies, broken symlinks, __file__ resolution, etc.

Closes #56

Co-authored-by: cft0808 <41196455+cft0808@users.noreply.github.com>
2026-03-25 22:20:21 +08:00