-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] Harden git-backed task sync #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BumpyClock
wants to merge
4
commits into
main
Choose a base branch
from
fix/git-sync-bugfix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
63850ad
fix(sync): repair git-backed task sync
BumpyClock 834d04a
Remove sequential child ID counters and simplify task ID generation
BumpyClock 68d6b12
fix(sync): harden sync conflict handling
BumpyClock 2a73bcd
test(tui): use generated task ids in contract test
BumpyClock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Task sync across machines | ||
|
|
||
| Tasque is local-first. `tsq sync` is the only path that touches the network, | ||
| and only when a remote is configured. It turns the local `.tasque/` data into a | ||
| git branch you can share between machines and collaborators. | ||
|
|
||
| ## Where task data lives | ||
|
|
||
| In a git repo, `tsq init` moves task data off your code branch into a dedicated | ||
| **sync worktree** on a separate branch (default `tsq-sync`, configurable via | ||
| `--sync-branch` / `--worktree-name`). Your code branch keeps only | ||
| `.tasque/config.json` so Tasque can find the sync branch. | ||
|
|
||
| Main worktree: | ||
|
|
||
| - `.tasque/config.json` — sync-branch pointer/locator only. | ||
|
|
||
| Sync worktree: | ||
|
|
||
| - `.tasque/events.jsonl` — append-only event log (canonical source of truth). | ||
| - `.tasque/specs/<task-id>/spec.md` — task specs. | ||
| - `.tasque/config.json` — task-data config committed with the sync branch. | ||
| - `.tasque/state.json`, `.tasque/.lock`, `.tasque/snapshots/` — local-only, | ||
| gitignored, always rebuildable. | ||
|
|
||
| ## What `tsq sync` does | ||
|
|
||
| `tsq sync` runs a local-first two-way sync in this order: | ||
|
|
||
| 1. **Commit** local changes to the sync branch (events, specs, config). | ||
| 2. **Fetch** the `origin` branch, if it exists. | ||
| 3. **Merge** fetched changes. `events.jsonl` is merged by the | ||
| `tasque-events` driver (see below); other files use git's default merge. | ||
| 4. **Push** the result back to the remote, setting upstream on first push. | ||
|
|
||
| `tsq sync --no-push` stops after step 1: local commit only, no network. The | ||
| bundled pre-push hook runs exactly this so a manual `git push` from the sync | ||
| worktree still commits pending task updates first. | ||
|
|
||
| When no remote/remote branch exists, `tsq sync` commits locally and reports that | ||
| push was skipped. | ||
|
|
||
| ## How conflicts resolve | ||
|
|
||
| Different files merge differently by design: | ||
|
|
||
| - `events.jsonl`: the `tasque-events` driver unions events by event id, | ||
| deduplicates identical events, and replay-validates the result. Independent | ||
| edits auto-merge. Same event id with divergent payloads, or an invalid merged | ||
| history, surfaces a structured `MERGE_*` error. | ||
| - `specs/<id>/spec.md`: git default 3-way text merge. Conflicting spec edits | ||
| leave conflict markers and require manual resolution. | ||
| - `config.json`: git default 3-way text merge. If both sides edit config, | ||
| resolve it manually. | ||
|
|
||
| The event merge is commutative for independent task creates: pulling A then B | ||
| yields the same `events.jsonl` as B then A, because events are deduplicated by | ||
| id (ULID `id`, legacy `event_id` accepted on read). | ||
|
|
||
| ### Conflict UX | ||
|
|
||
| If a git merge conflict cannot be auto-resolved, `tsq sync` leaves the merge in | ||
| progress and returns a structured error with the conflicted paths and the sync | ||
| worktree path (`SYNC_MERGE_CONFLICT`). Resolve the conflicts in that worktree, | ||
| then re-run `tsq sync`: with no unmerged paths remaining it completes the merge | ||
| and pushes; if unmerged paths still exist it re-emits the conflict. | ||
|
|
||
| Spec conflicts in particular must be resolved by a human: open the marked | ||
| `spec.md`, pick the intended content, remove the `<<<<<<<` / `=======` / `>>>>>>>` | ||
| markers, save, then re-run `tsq sync`. | ||
|
|
||
| ## Task IDs | ||
|
|
||
| New tasks get a flat random canonical id of the form `tsq-<8 lowercase crockford | ||
| chars>` (for example `tsq-7k3q9x2a`). Random ids avoid collisions when two | ||
| machines create tasks independently and later sync. | ||
|
|
||
| Existing ids keep working unchanged: | ||
|
|
||
| - Sequential root ids `tsq-<number>` (for example `tsq-42`) — still valid. | ||
| - Child ids `<parent>.<n>` (for example `tsq-42.3`) — still valid. | ||
| - Legacy 8-char ids `tsq-<8 crockford>` — still valid. | ||
|
|
||
| `--id <id>` on `tsq create` accepts any of these shapes. Commands that take a | ||
| task id accept the id, exact alias, or a unique alias prefix. An exact alias that | ||
| matches more than one task returns `TASK_ID_AMBIGUOUS` rather than guessing. | ||
|
|
||
| ## Commit policy | ||
|
|
||
| For the **sync worktree** (task data), commit: | ||
|
|
||
| - `.tasque/events.jsonl` | ||
| - `.tasque/specs/` (specs are meant to sync) | ||
| - `.tasque/config.json` | ||
|
|
||
| Do not commit `.tasque/state.json`, `.tasque/.lock`, or `.tasque/snapshots/` — | ||
| they are gitignored and rebuildable. `tsq sync` handles this set automatically; | ||
| you should not stage task data manually. | ||
|
|
||
| For the **main code worktree**, commit: | ||
|
|
||
| - `.tasque/config.json` (the pointer to the sync branch) | ||
| - `.gitattributes` (it registers `.tasque/events.jsonl merge=tasque-events`) | ||
|
|
||
| `.gitattributes` matters: without the `tasque-events` driver entry, event merges | ||
| fall back to git's text merge and can corrupt the log. `tsq init` / | ||
| `tsq migrate` ensure the entry exists; keep it committed. | ||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Doc inaccuracy: "no remote branch" does not result in a skipped push.
Per
src/app/sync.rs::sync_worktree_locked, whenoriginexists but doesn't yet have the sync branch,tsq syncactively publishes it viapush -u(and only falls back to the fetch/merge/retry loop if that publish push is rejected) — it does not skip the push. Only the "nooriginremote at all" case skips push. Suggest splitting this sentence to avoid implying the sync branch is left unpublished when a remote exists.📝 Proposed doc fix
📝 Committable suggestion
🤖 Prompt for AI Agents