docs: add git worktree mandatory workflow to agents and lessons

This commit is contained in:
dasemu committed 2026-03-13 06:55:45 +01:00
1 parent c486c585d0
commit 00efa356c3
2 files changed
+44

No files matched your search

+33
View File
@@ -10,6 +10,8 @@
**Files affected:** `bot/telegram_bot.py`, `scripts/collect_daily_data.py`
---
## Migration Scope - 2026-03-13
**What went wrong:** I started a database migration while preserving compatibility fallbacks to the previous CSV/JSON storage flow.
@@ -21,3 +23,34 @@
**Example:** The SQLite migration must make the bot, the daily pipeline, and model training read from the database directly instead of keeping fallbacks to `data/processed/predictions_latest.json` or `data/processed/dataset_featured.csv`.
**Files affected:** `bot/telegram_bot.py`, `scripts/collect_daily_data.py`, `ml/train_model.py`
---
## Git - 2026-03-13
**What went wrong:** Worktree creation and cleanup were mismanaged, leading to confusion between the main directory and the worktree. Changes were applied to the main directory instead of the newly created worktree, and branch deletion failed because the worktree was still active.
**Root cause:** Lack of a strict "switch directory" step and incorrect order in the cleanup process (trying to delete the branch before removing the worktree).
**Prevention rule:** Before using a worktree:
1. **Always** `cd` into the new worktree directory immediately after creation.
2. Perform all edits and commits **inside** the worktree.
3. To clean up:
* Return to the main directory: `cd -`
* Remove the worktree: `git worktree remove <path>`
* Then, and only then, delete the branch: `git branch -d <branch>`
**Example:**
```bash
# Correct flow:
git worktree add ../new-feature -b feature-branch
cd ../new-feature
# ... do work, add, commit ...
cd -
git merge feature-branch
git worktree remove ../new-feature
git branch -d feature-branch
```
**Files affected:**
- [LESSONS.md](LESSONS.md)