1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! The compaction landing (ARCH §2.6, §2.7, §5.5) — **rebase-forward**,
//! the zero-downtime successor to the retired compaction merge.
//!
//! A compactor forks off the **compaction point** `P` — the dispatching
//! branch's tip at dispatch, or `HEAD~keep_recent` when the workflow
//! retains a recent tail (§6) — and nominates deletions plus a summary of
//! everything at `P`. The live agent keeps stepping past `P` the whole
//! time. When the compactor returns on a `final-response` epitaph, its
//! product lands in two moves, both by the dispatching branch's own
//! executor at a step boundary (§2.3 branch advancement):
//!
//! 1. **The compaction base.** One commit whose tree is the tree at `P`
//! with the product applied — the nominated deletions removed, the new
//! `summary/<NNN>.md` added — parented on the **span's lower bound**:
//! the branch's own founding commit or its previous compaction base,
//! whichever is newer ([`super::checkpoint::origin`] read from `P`).
//! The **compaction span** — every commit between that bound and `P` —
//! is thereby squashed out of the branch's history: this is the squash
//! §5.4 prices, and what keeps a transcript-bearing repo's history from
//! bloating. The squashed commits stay reachable from the compactor's
//! own ref until it is retired (§9.2), so nothing is unrecoverable
//! while the provenance lives.
//! 2. **The replay.** The branch's commits after `P` — appended transcript
//! entries, deliveries, transfers — rebase onto the base
//! (`git rebase --onto <base> <P>`), and the branch moves to the
//! replayed tip. Transcript entries are one immutable file each with
//! monotonic names (§2.3), so the replay is conflict-free by
//! construction, with exactly three exception classes:
//!
//! - **A replayed commit rewrites a work product the compaction deleted**
//! — a modify/delete, resolved **live-branch-wins**: the live content is
//! staged, the compaction's deletion of that path is dropped. Lost
//! compaction, never lost work — the same worst case the deletion-only
//! toolset already guarantees (§2.7).
//! - **A conflict git writes markers for** (both sides carry content) —
//! the construction was violated, and staging would commit `<<<<<<<`
//! markup into context (§5.2). The whole landing is **declined loudly**:
//! the rebase aborts (the branch is restored bit-for-bit),
//! `refs/litany/conflicted/<compactor-id>` marks the compactor's tip,
//! and the branch continues uncompacted (§2.7).
//! - **Another compaction landed since `P`** — the point is no longer
//! reachable from the branch, or a base sits in the replay span.
//! Replaying a squash is not a landing this compactor can have; its
//! pass is [`LandOutcome::Superseded`]: nothing lands, nothing is
//! marked (an overtaken pass is not a defect), and the next checkpoint
//! trigger simply fires again.
//!
//! **Filtered by construction.** The retired merge filtered the
//! compactor's private dialog *out* of a staged tree; the base is built
//! the other way around — from the product *in*: only the deletions and
//! `summary/**` additions committed after the compactor's own dispatch
//! commit enter it ([`base`]). Its dispatch-commit prune of
//! `descriptions/**` to the empty compactor grant (§3.3), its `goal.md`/
//! `soul.md`, and its transcript never cross, structurally — the same
//! polarity as the work-product transfer's excludes (§2.6, bl-475a).
//!
//! **Cache honesty** (§5.4, §5.5). Any landing truncates the provider's
//! cached prefix at the compaction point — deletion is priced from the
//! earliest changed byte, and the base rewrites the tree at `P`.
//! Rebase-forward changes **availability**, not that price: the branch
//! never idles, and the entries after `P` survive verbatim in the tree —
//! but they sit after the truncation point and are re-sent like any
//! fresh tail.
use Error;
use crate;
use crateGitRunner;
use crateworkspace;
use Path;
/// Outcome of a compaction landing against the dispatching branch.
/// Land the returning compactor `compactor_id` into the dispatching
/// branch `parent_id`, checked out at `parent_worktree` (ARCH §2.6). The
/// checkout's `HEAD` *is* the dispatching branch (§2.3); the compaction
/// point, the span bound, and the product all derive from the two refs —
/// no sidecar state anywhere (`docs/PRINCIPLES.md` Single source of
/// truth).