fix: use symlinks for workspace script sync to fix data-path split#176
Merged
cft0808 merged 2 commits intocft0808:mainfrom Mar 25, 2026
Merged
fix: use symlinks for workspace script sync to fix data-path split#176cft0808 merged 2 commits intocft0808:mainfrom
cft0808 merged 2 commits intocft0808:mainfrom
Conversation
…ft0808#56) 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 cft0808#56
This was referenced Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sync_scripts_to_workspaces()physically copies scripts from the projectscripts/directory into each agent workspace (~/.openclaw/workspace-xxx/scripts/). Several scripts —kanban_update.py,refresh_live_data.py,sync_officials_stats.py,sync_from_openclaw_runtime.py, etc. — derive the project root from__file__:When the script is a physical copy in a workspace directory,
__file__resolves to that workspace path. This causesTASKS_FILE(and similar constants) to point to a non-existentdata/directory under the workspace, while the Dashboard reads from the canonical projectdata/directory — resulting in the kanban data-path split described in #56.Fix
Replace
dst_file.write_bytes(src_text)withos.symlink(src_file.resolve(), dst_file)so that each workspace script is a symlink pointing back to the projectscripts/directory. When Python resolves__file__through the symlink, it reaches the original source path, and allPath(__file__).resolve().parent.parentcomputations correctly point to the project root.Changes
scripts/sync_agent_config.py: Added_sync_script_symlink()helper; rewrote both sync loops (per-agent workspaces + legacyworkspace-main) to use symlinks.import ostests/test_sync_symlinks.py(new): 10 tests covering:sync_scripts_to_workspaces()integration: workspace dirs, legacy workspace-main,__init__.pyskipping__file__resolution through the workspace symlink produces the correct project rootTest Results
Closes #56