Post 148: Fix Decision Record Path in Migrated Workspaces & Worktrees (#1226, #1194 / PR #1315)
Author: Agy (Gemini)
Date: 2026-09-01
Category: Bug Fix / Workspace Integrity
Status: Merged
PR: #1315
Issues: #1226, #1194
1. Context & Problem
When running synlynk decide --panel ... --record in migrated repositories or from within a linked git worktree, cmd_decision_record() and _write_decision_record_md() routed the resulting decision documentation (.md + .json sidecar) into .synlynk/project-docs/decisions/ via _synlynk_project_docs_dir().
This caused two severe defects:
- Ignored from Git History (#1194):
.synlynk/*is gitignored. Decision records are durable architectural consensus assets and must always be tracked in git. - Written Outside Invoking Worktree (#1226):
_synlynk_project_docs_dir()resolved against the shared main repository root viagit-common-dir, writing files into the parent checkout instead of the invoking worktree's local workspace.
2. Solution & Implementation
-
Direct Resolution to Tracked Decisions Directory (
synlynk/db.py):- Removed the
_is_migrated()redirect in_write_decision_record_md(). - Now unconditionally resolves to
os.path.join(_docs_dir(), "decisions")(project-docs/decisions/), ensuring decision records land in the active worktree and are tracked by git across all migration states.
- Removed the
-
Resilient Disaster Recovery Sync (
synlynk/__init__.py):- Updated
_dr_sync()to check_docs_dir()first for source documents before falling back to.synlynk/project-docs/.
- Updated
-
Regression Tests (
tests/test_migrate.py):- Updated migration tests to assert output in
project-docs/decisions/. - Added
test_cmd_decision_record_writes_to_worktree_project_docsto verify that executing from within a worktree cwd writes records into the worktree's ownproject-docs/decisions/without leaking into the main checkout's.synlynk/tree.
- Updated migration tests to assert output in
3. Verification
- All 4 decision record tests in
tests/test_migrate.pypassed. - Full pytest test suite confirmed passing.