Documentation
¶
Overview ¶
Package merge is the deterministic, record-aware three-way merge for tasks JSONL files — the Go port of lib/tasks/jsonl_merge.rb.
The merge is field-level; ordering stays ours-first while the final DFS walk guarantees parent-before-child structural validity. Nothing here touches a file: Merge builds and VALIDATES entirely in memory, and only a result that passed carries text. That ordering is the whole safety property — a write-then-validate driver would leave a rejected merge's output in the working file looking clean, and returning nonzero afterwards could not take it back.
Index ¶
Constants ¶
const ( DecisionDeleted = "deleted" DecisionDeletedByOurs = "deleted_by_ours" DecisionDeletedByTheirs = "deleted_by_theirs" DecisionKeptTheirsEditOverOursDelete = "kept_theirs_edit_over_ours_delete" DecisionKeptOursEditOverTheirsDelete = "kept_ours_edit_over_theirs_delete" DecisionAddedOurs = "added_ours" DecisionAddedTheirs = "added_theirs" DecisionMergedConcurrentAdd = "merged_concurrent_add" DecisionMergedFields = "merged_fields" DecisionRestoredAncestor = "restored_ancestor_for_edited_descendant" DecisionOursOrderingConflict = "ours_ordering_conflict" )
The decisions a merge can record. They are the audit log's vocabulary: a merge that silently loses or duplicates a task is the failure nobody notices until the data is already wrong, so every record the merge touched says what happened to it and why.
const ( ReasonRemovalWins = "removal_wins" ReasonClaimHolds = "claim_holds" ReasonEarlierClaim = "earlier_claim" ReasonLaterIntent = "later_intent" ClearedOnNonTask = "cleared_on_non_task" ClearedOnProposal = "cleared_on_proposal" ClearedOnClose = "cleared_on_close" )
Why one delegation marker outranked the other, and why a resolved marker was then cleared.
const Version = check.Version
Version is the schema version this binary merges. Both SIDES must declare it.
Variables ¶
This section is empty.
Functions ¶
func FormatEvent ¶
FormatEvent renders one decision the way the log carries it.
func RunDriver ¶
RunDriver is `tasks merge-driver <base> <ours> <theirs> <pathname> [marker-size] [ours-label] [theirs-label]` — the Git merge driver.
Git's contract is what shapes the failure path. Git hands the driver three TEMP files and copies whatever %A holds back over the working file when the driver returns, on failure exactly as on success. Git seeds %A with the ours blob and has already checked that same blob into the working file before the driver runs. So leaving %A untouched does NOT mean "wrote nothing": it means the working file is left as ours' full content, valid JSONL, no markers anywhere — a file `tasks check` passes and the reflex `git add tasks.jsonl` stages, silently discarding all of theirs. That is the failure this refusal path exists to prevent.
So a refusal writes what Git's own text driver would: ours verbatim, theirs verbatim, both fenced. The path stays UU with a nonzero exit, `tasks check` fails on the marker lines, and neither side has been summarized or dropped.
The rule for anyone changing this: never write a MERGED result to %A before it is known valid. Merge builds and validates entirely in memory and only a result that passed carries text, so the merged write below is reached only by a merge that is already known good.
Types ¶
type DelegationEvent ¶
DelegationEvent is the delegation half of one record's decision: which rule decided the marker, who holds it afterwards, and whether the resolved record then dropped it.
type Event ¶
type Event struct {
ID string
Decision string
Conflicts []string
LowConfidence []string
Delegation *DelegationEvent
}
Event is one record's decision.
type Result ¶
Result is one merge attempt. A failed merge carries no text at all: there is no partial result a caller could be tempted to write.