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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//! Injected effect ports — the seam that keeps every domain testable in
//! isolation without touching the real filesystem, git, network, or clock
//! (ADR-0001 §2).
//!
//! Domain code (`contract`, `facts`, `audit`, `release`) takes these traits by
//! reference instead of calling `std::process`, `std::time`, or the network
//! directly. Production supplies real implementations in `ossctl-cli`; tests
//! supply deterministic fakes. At founding these are the **trait shapes** only;
//! concrete implementations land with their consuming units.
use io;
/// Output of a subprocess run through a [`CommandRunner`].
/// Runs external commands (git, package-manager, registry CLIs) on behalf of a
/// domain, capturing their output. The single seam for shelling out — nothing
/// in `ossctl-core` calls `std::process::Command` directly.
/// Supplies the current time. Injected so time-dependent logic (journal
/// timestamps, run ages) is deterministic under test.
/// Generates opaque, unique, non-deterministic identifiers — run ids and the
/// like. Injected so id-dependent output is deterministic under test.
///
/// Note: this is **not** the source of `plan_id`. A release plan id is
/// *content-addressed* — derived deterministically from the sealed plan's
/// canonical bytes (ADR-0002), not generated here. Do not route plan sealing
/// through this port.
/// Read/write access to the filesystem — the `Fs` half of the `Fs/Git` seam
/// (ADR-0001 §2). Domain code (contract loading, journal persistence, sealed
/// plans) goes through this port rather than calling `std::fs` directly, so it
/// is testable against an in-memory fake. At founding this is a deliberately
/// small surface; it grows (atomic writes, dir listing, metadata) as the
/// journal and plan-sealing units land.
/// Queries a package registry for already-published state — the "remote is
/// ground truth" source the release reconciler consults (ADR-0003).
/// Read-only view of the git repository under audit/release. The detector and
/// release engine read repo facts through this port rather than shelling out
/// to `git` themselves.
///
/// The detector's queries are deliberately *best-effort*: an unborn or
/// non-repository root makes several of these fail, and the detector treats
/// every such failure as "absent" (no committers, no tags) rather than an
/// error — mirroring the read-only, never-mutating `infer-repo-facts.py`.
/// Durable, atomic, lockable storage for the release journal — the seam that
/// keeps the event-sourced journal (ADR-0003) testable without touching the real
/// filesystem, while pinning down the atomicity discipline its production impl
/// **must** honor.
///
/// The append-then-apply contract (ADR-0003 §2, borrowed from `octl-core`) maps
/// onto these operations:
///
/// 1. [`Self::append_line`] fsyncs the event so it is durable **before** the
/// reducer applies it — a crash between append and apply replays as a clean
/// no-op-or-apply, because the journal (read back by [`Self::read_lines`]) is
/// the single source of truth.
/// 2. [`Self::write_atomic`] persists the derived manifest via temp-file → flush
/// → atomic rename → directory fsync, so a torn write can never leave a
/// half-written manifest (it is disposable and rebuildable regardless).
/// 3. [`Self::lock_exclusive`] enforces a single active cut per repo (a `flock`
/// on the releases-dir `.lock`): a concurrent cut/resume fails fast rather
/// than corrupting a run.
///
/// The port is deliberately path-driven (the journal computes paths via
/// [`crate::release::journal::JournalPaths`]); the impl adds no policy, only the
/// durability guarantees documented per method.
/// An opaque RAII guard for the single-active-cut lock taken by
/// [`JournalStore::lock_exclusive`]. Dropping it releases the lock; there are no
/// methods — its lifetime *is* the contract.
/// Creates and publishes the **one** shared release tag + GitHub Release for a
/// cut — the external side of the coordinator's coordinator-only tag phase
/// (ADR-0002 §2).
///
/// Tagging is deliberately **not** on the [`crate::release::adapters::ReleaseAdapter`]
/// trait: no per-ecosystem adapter can create the shared tag, which is what makes
/// "tag once, after every publish succeeds" a structural guarantee. The
/// coordinator drives these three steps in order and journals each as its own
/// resumable event (`tag_created_local` → `tag_pushed_remote` →
/// `github_release_created`), so an interrupted tag phase resumes from the first
/// incomplete step rather than re-tagging.
///
/// Every method is **idempotent-friendly**: the coordinator only calls a step
/// whose journalled fact is not yet present, but a production impl should still
/// treat "already exists" as success (a pushed tag that is already on the remote,
/// a Release that already exists) rather than an error, so a resume after a crash
/// *between* the external action and its journal write reconciles cleanly.