@rcpooley/concord 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +318 -0
  3. package/bin/concord.service +69 -0
  4. package/dist/age.d.ts +20 -0
  5. package/dist/age.d.ts.map +1 -0
  6. package/dist/age.js +58 -0
  7. package/dist/age.js.map +1 -0
  8. package/dist/cli/main.d.ts +3 -0
  9. package/dist/cli/main.d.ts.map +1 -0
  10. package/dist/cli/main.js +301 -0
  11. package/dist/cli/main.js.map +1 -0
  12. package/dist/daemon.d.ts +4 -0
  13. package/dist/daemon.d.ts.map +1 -0
  14. package/dist/daemon.js +394 -0
  15. package/dist/daemon.js.map +1 -0
  16. package/dist/eval-config.d.ts +2 -0
  17. package/dist/eval-config.d.ts.map +1 -0
  18. package/dist/eval-config.js +45 -0
  19. package/dist/eval-config.js.map +1 -0
  20. package/dist/exec.d.ts +168 -0
  21. package/dist/exec.d.ts.map +1 -0
  22. package/dist/exec.js +313 -0
  23. package/dist/exec.js.map +1 -0
  24. package/dist/git.d.ts +59 -0
  25. package/dist/git.d.ts.map +1 -0
  26. package/dist/git.js +265 -0
  27. package/dist/git.js.map +1 -0
  28. package/dist/hook.d.ts +37 -0
  29. package/dist/hook.d.ts.map +1 -0
  30. package/dist/hook.js +89 -0
  31. package/dist/hook.js.map +1 -0
  32. package/dist/index.d.ts +18 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +15 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/init.d.ts +76 -0
  37. package/dist/init.d.ts.map +1 -0
  38. package/dist/init.js +236 -0
  39. package/dist/init.js.map +1 -0
  40. package/dist/loader.d.ts +35 -0
  41. package/dist/loader.d.ts.map +1 -0
  42. package/dist/loader.js +230 -0
  43. package/dist/loader.js.map +1 -0
  44. package/dist/module.d.ts +116 -0
  45. package/dist/module.d.ts.map +1 -0
  46. package/dist/module.js +100 -0
  47. package/dist/module.js.map +1 -0
  48. package/dist/modules/apt/index.d.ts +45 -0
  49. package/dist/modules/apt/index.d.ts.map +1 -0
  50. package/dist/modules/apt/index.js +249 -0
  51. package/dist/modules/apt/index.js.map +1 -0
  52. package/dist/modules/apt/schema.d.ts +63 -0
  53. package/dist/modules/apt/schema.d.ts.map +1 -0
  54. package/dist/modules/apt/schema.js +75 -0
  55. package/dist/modules/apt/schema.js.map +1 -0
  56. package/dist/modules/checkout/index.d.ts +88 -0
  57. package/dist/modules/checkout/index.d.ts.map +1 -0
  58. package/dist/modules/checkout/index.js +382 -0
  59. package/dist/modules/checkout/index.js.map +1 -0
  60. package/dist/modules/checkout/schema.d.ts +52 -0
  61. package/dist/modules/checkout/schema.d.ts.map +1 -0
  62. package/dist/modules/checkout/schema.js +132 -0
  63. package/dist/modules/checkout/schema.js.map +1 -0
  64. package/dist/modules/cloudflare/api.d.ts +64 -0
  65. package/dist/modules/cloudflare/api.d.ts.map +1 -0
  66. package/dist/modules/cloudflare/api.js +98 -0
  67. package/dist/modules/cloudflare/api.js.map +1 -0
  68. package/dist/modules/cloudflare/index.d.ts +74 -0
  69. package/dist/modules/cloudflare/index.d.ts.map +1 -0
  70. package/dist/modules/cloudflare/index.js +374 -0
  71. package/dist/modules/cloudflare/index.js.map +1 -0
  72. package/dist/modules/cloudflare/schema.d.ts +62 -0
  73. package/dist/modules/cloudflare/schema.d.ts.map +1 -0
  74. package/dist/modules/cloudflare/schema.js +85 -0
  75. package/dist/modules/cloudflare/schema.js.map +1 -0
  76. package/dist/modules/docker/index.d.ts +83 -0
  77. package/dist/modules/docker/index.d.ts.map +1 -0
  78. package/dist/modules/docker/index.js +470 -0
  79. package/dist/modules/docker/index.js.map +1 -0
  80. package/dist/modules/docker/registry.d.ts +35 -0
  81. package/dist/modules/docker/registry.d.ts.map +1 -0
  82. package/dist/modules/docker/registry.js +95 -0
  83. package/dist/modules/docker/registry.js.map +1 -0
  84. package/dist/modules/docker/render.d.ts +45 -0
  85. package/dist/modules/docker/render.d.ts.map +1 -0
  86. package/dist/modules/docker/render.js +162 -0
  87. package/dist/modules/docker/render.js.map +1 -0
  88. package/dist/modules/docker/schema.d.ts +231 -0
  89. package/dist/modules/docker/schema.d.ts.map +1 -0
  90. package/dist/modules/docker/schema.js +335 -0
  91. package/dist/modules/docker/schema.js.map +1 -0
  92. package/dist/modules/docker/sweeper.d.ts +64 -0
  93. package/dist/modules/docker/sweeper.d.ts.map +1 -0
  94. package/dist/modules/docker/sweeper.js +94 -0
  95. package/dist/modules/docker/sweeper.js.map +1 -0
  96. package/dist/modules/file/index.d.ts +79 -0
  97. package/dist/modules/file/index.d.ts.map +1 -0
  98. package/dist/modules/file/index.js +305 -0
  99. package/dist/modules/file/index.js.map +1 -0
  100. package/dist/modules/file/schema.d.ts +45 -0
  101. package/dist/modules/file/schema.d.ts.map +1 -0
  102. package/dist/modules/file/schema.js +114 -0
  103. package/dist/modules/file/schema.js.map +1 -0
  104. package/dist/modules/index.d.ts +20 -0
  105. package/dist/modules/index.d.ts.map +1 -0
  106. package/dist/modules/index.js +11 -0
  107. package/dist/modules/index.js.map +1 -0
  108. package/dist/modules/porkbun/api.d.ts +36 -0
  109. package/dist/modules/porkbun/api.d.ts.map +1 -0
  110. package/dist/modules/porkbun/api.js +62 -0
  111. package/dist/modules/porkbun/api.js.map +1 -0
  112. package/dist/modules/porkbun/index.d.ts +50 -0
  113. package/dist/modules/porkbun/index.d.ts.map +1 -0
  114. package/dist/modules/porkbun/index.js +236 -0
  115. package/dist/modules/porkbun/index.js.map +1 -0
  116. package/dist/modules/porkbun/schema.d.ts +38 -0
  117. package/dist/modules/porkbun/schema.d.ts.map +1 -0
  118. package/dist/modules/porkbun/schema.js +39 -0
  119. package/dist/modules/porkbun/schema.js.map +1 -0
  120. package/dist/modules/script/index.d.ts +43 -0
  121. package/dist/modules/script/index.d.ts.map +1 -0
  122. package/dist/modules/script/index.js +116 -0
  123. package/dist/modules/script/index.js.map +1 -0
  124. package/dist/modules/script/schema.d.ts +25 -0
  125. package/dist/modules/script/schema.d.ts.map +1 -0
  126. package/dist/modules/script/schema.js +63 -0
  127. package/dist/modules/script/schema.js.map +1 -0
  128. package/dist/modules/systemd/index.d.ts +93 -0
  129. package/dist/modules/systemd/index.d.ts.map +1 -0
  130. package/dist/modules/systemd/index.js +394 -0
  131. package/dist/modules/systemd/index.js.map +1 -0
  132. package/dist/modules/systemd/render.d.ts +41 -0
  133. package/dist/modules/systemd/render.d.ts.map +1 -0
  134. package/dist/modules/systemd/render.js +252 -0
  135. package/dist/modules/systemd/render.js.map +1 -0
  136. package/dist/modules/systemd/schema.d.ts +293 -0
  137. package/dist/modules/systemd/schema.d.ts.map +1 -0
  138. package/dist/modules/systemd/schema.js +302 -0
  139. package/dist/modules/systemd/schema.js.map +1 -0
  140. package/dist/modules/systemd/sweeper.d.ts +31 -0
  141. package/dist/modules/systemd/sweeper.d.ts.map +1 -0
  142. package/dist/modules/systemd/sweeper.js +77 -0
  143. package/dist/modules/systemd/sweeper.js.map +1 -0
  144. package/dist/plans.d.ts +132 -0
  145. package/dist/plans.d.ts.map +1 -0
  146. package/dist/plans.js +315 -0
  147. package/dist/plans.js.map +1 -0
  148. package/dist/records.d.ts +37 -0
  149. package/dist/records.d.ts.map +1 -0
  150. package/dist/records.js +100 -0
  151. package/dist/records.js.map +1 -0
  152. package/dist/registry.d.ts +38 -0
  153. package/dist/registry.d.ts.map +1 -0
  154. package/dist/registry.js +31 -0
  155. package/dist/registry.js.map +1 -0
  156. package/dist/runner.d.ts +48 -0
  157. package/dist/runner.d.ts.map +1 -0
  158. package/dist/runner.js +150 -0
  159. package/dist/runner.js.map +1 -0
  160. package/dist/scheduler.d.ts +36 -0
  161. package/dist/scheduler.d.ts.map +1 -0
  162. package/dist/scheduler.js +77 -0
  163. package/dist/scheduler.js.map +1 -0
  164. package/dist/schema.d.ts +762 -0
  165. package/dist/schema.d.ts.map +1 -0
  166. package/dist/schema.js +185 -0
  167. package/dist/schema.js.map +1 -0
  168. package/dist/secret.d.ts +24 -0
  169. package/dist/secret.d.ts.map +1 -0
  170. package/dist/secret.js +3 -0
  171. package/dist/secret.js.map +1 -0
  172. package/dist/ui.d.ts +62 -0
  173. package/dist/ui.d.ts.map +1 -0
  174. package/dist/ui.js +288 -0
  175. package/dist/ui.js.map +1 -0
  176. package/package.json +57 -0
@@ -0,0 +1,382 @@
1
+ import { Module } from '../../module.js';
2
+ import { cloneUrl, resolveRefs } from '../../git.js';
3
+ /** Single-quote for a POSIX shell. Scripts are built here and run over stdin. */
4
+ const sq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
5
+ const short = (c) => c.slice(0, 7);
6
+ const parent = (p) => p.replace(/\/+$/, '').replace(/\/[^/]+$/, '') || '/';
7
+ /** Output may contain anything git printed — keep it short. */
8
+ const tail = (s, n = 20) => s.trim().split('\n').slice(-n).join('\n');
9
+ /**
10
+ * Exit codes the inner (unprivileged) half of an apply uses to tell the outer
11
+ * half what happened. Anything else is a real failure and propagates.
12
+ */
13
+ const BLOCKED_DIRTY = 10;
14
+ const BLOCKED_UNPUSHED = 11;
15
+ const BLOCKED_BRANCH = 12;
16
+ /** `scheme://user:secret@host/…` — the shape the old `set-url` idiom left behind. */
17
+ const hasCredential = (url) => /^[a-z][a-z0-9+.-]*:\/\/[^/@]+@/i.test(url ?? '');
18
+ // --------------------------------------------------------------- module ----
19
+ /**
20
+ * Git working trees on a host.
21
+ *
22
+ * ADDITIVE, like `apt`, `file` and `systemd`: `owned()` stays empty and no
23
+ * sweeper exists, so an undeclared checkout is never touched. That is the right
24
+ * default here because the host has legitimate unmanaged state of this kind,
25
+ * often a great deal of it: a development machine can carry dozens of
26
+ * hand-made checkouts. "Remove the directory on undeclare"
27
+ * pointed at one of those is a data-loss bug, not host-truth.
28
+ */
29
+ export class CheckoutModule extends Module {
30
+ config;
31
+ kind = 'checkout';
32
+ /** Resolved in desired(), read by apply(). Never on an op — ops are logged. */
33
+ #token;
34
+ /** Paths that exist but are not readable repos, and why. Set by read(). */
35
+ #unreadable = new Map();
36
+ constructor(config) {
37
+ super(config.id, config.host);
38
+ this.config = config;
39
+ }
40
+ get checkouts() {
41
+ return this.config.checkouts ?? [];
42
+ }
43
+ entry(name) {
44
+ return this.checkouts.find((c) => c.name === name);
45
+ }
46
+ stampPath(name) {
47
+ return `${this.config.stampDir.replace(/\/+$/, '')}/${name}.sha`;
48
+ }
49
+ // ------------------------------------------------------------ desired ----
50
+ async desired() {
51
+ const seen = new Set();
52
+ for (const c of this.checkouts) {
53
+ if (seen.has(c.name))
54
+ throw new Error(`${this.scope}: checkout "${c.name}" declared twice`);
55
+ seen.add(c.name);
56
+ }
57
+ // Two checkouts writing one directory would fight every cycle, each undoing
58
+ // the other — and the plan would look like ordinary drift forever.
59
+ const paths = new Map();
60
+ for (const c of this.checkouts) {
61
+ const prior = paths.get(c.path);
62
+ if (prior) {
63
+ throw new Error(`${this.scope}: "${prior}" and "${c.name}" both declare the path ${c.path}`);
64
+ }
65
+ paths.set(c.path, c.name);
66
+ }
67
+ const declared = this.settings.git?.token;
68
+ this.#token = declared ? await this.secret(declared) : undefined;
69
+ // One batched request for every tracked checkout; pinned ones cost no
70
+ // network at all. Whole-repo tips, so no local mirror is needed — a
71
+ // checkout has no build context to scope the watch to.
72
+ const tracked = this.checkouts
73
+ .filter((c) => c.track)
74
+ .map((c) => ({ app: c.name, repo: c.repo, branch: c.track.branch }));
75
+ const tips = tracked.length ? await resolveRefs(tracked, this.#token) : new Map();
76
+ const checkouts = [];
77
+ const unresolved = [];
78
+ for (const c of this.checkouts) {
79
+ const want = { name: c.name, present: true, dirty: false, branch: null, remote: cloneUrl(c.repo) };
80
+ if (c.pin) {
81
+ checkouts.push({ ...want, commit: c.pin.commit });
82
+ continue;
83
+ }
84
+ const got = tips.get(c.name);
85
+ if (!got || 'error' in got) {
86
+ unresolved.push(`"${c.name}" (${got?.error ?? `could not resolve ${c.track.branch}`})`);
87
+ continue;
88
+ }
89
+ checkouts.push({ ...want, commit: got.commit });
90
+ }
91
+ // A checkout whose ref will not resolve is NOT converged, and we do not
92
+ // know what should be on disk — so nothing about it may be claimed. It
93
+ // fails rather than being silently omitted.
94
+ if (unresolved.length) {
95
+ throw new Error(`${this.scope}: could not determine desired state for ${unresolved.join(', ')}`);
96
+ }
97
+ return { checkouts };
98
+ }
99
+ // --------------------------------------------------------------- read ----
100
+ /**
101
+ * One script for every checkout on the host, because this runs on every
102
+ * reconcile including plans and each `runScript` is an SSH round trip.
103
+ *
104
+ * Local git only — no fetch, no `ls-remote`, no credential. The scripts this
105
+ * module replaces hit the network from the host on every single guard; tips
106
+ * are resolved once on the primary now.
107
+ */
108
+ async read() {
109
+ this.#unreadable.clear();
110
+ if (!this.checkouts.length)
111
+ return { checkouts: [] };
112
+ const lines = ['set -uo pipefail'];
113
+ for (const c of this.checkouts) {
114
+ const as = `sudo -n -u ${sq(c.owner)} git -C ${sq(c.path)}`;
115
+ lines.push(
116
+ // An EMPTY directory reads as absent on purpose: `git clone` is happy to
117
+ // populate one, and the `file` module legitimately pre-creates parents
118
+ // with an owner. Only a non-empty path that will not answer counts as a
119
+ // problem.
120
+ `if [ ! -e ${sq(c.path)} ] || { [ -d ${sq(c.path)} ] && [ -z "$(ls -A ${sq(c.path)} 2>/dev/null)" ]; }; then`, ` printf 'absent\\t%s\\t\\t\\n' ${sq(c.name)}`, `else`, ` H=$(${as} rev-parse HEAD 2>&1) || true`, ` if printf '%s' "$H" | grep -qE '^[0-9a-f]{40}$'; then`, ` D=$(${as} status --porcelain --untracked-files=no 2>&1) || D='unreadable'`, ` B=$(${as} symbolic-ref --short -q HEAD 2>/dev/null) || B=''`, ` R=$(${as} remote get-url origin 2>/dev/null) || R=''`, ` printf 'ok\\t%s\\t%s\\t%s\\t%s\\t%s\\n' ${sq(c.name)} "$H" "$([ -n "$D" ] && echo dirty || echo clean)" "$B" "$R"`, ` else`,
121
+ // A path that exists but will not answer `rev-parse` must never read as
122
+ // "nothing here". The scripts this replaces got exactly this wrong: as
123
+ // root, rev-parse fails on a user-owned tree with "dubious ownership"
124
+ // and ls-remote fails without a credential, so the guard compared "" to
125
+ // "" and reported CONVERGED. Two errors cancelling into a false answer.
126
+ ` printf 'error\\t%s\\t\\t%s\\n' ${sq(c.name)} "$(printf '%s' "$H" | head -1 | tr -d '\\t')"`, ` fi`, `fi`);
127
+ }
128
+ const r = this.exec.runScript(lines.join('\n'), { sudo: true, timeoutMs: 60_000 });
129
+ if (r.status !== 0 && !r.output.trim()) {
130
+ throw new Error(`${this.scope}: could not read checkouts (exit ${r.status}):\n${tail(r.output)}`);
131
+ }
132
+ return { checkouts: this.parse(r.output) };
133
+ }
134
+ parse(out) {
135
+ const byName = new Map();
136
+ for (const line of out.split('\n')) {
137
+ if (!line.includes('\t'))
138
+ continue;
139
+ // Field 4 is `clean`/`dirty` on an ok line and git's complaint on an
140
+ // error one — the two never coexist. Fields 5 and 6 exist only on ok.
141
+ const [status, name, commit, detail, branch, remote] = line.split('\t');
142
+ if (!name)
143
+ continue;
144
+ const gone = { name, present: false, commit: null, branch: null, remote: null };
145
+ if (status === 'error') {
146
+ this.#unreadable.set(name, detail?.trim() || 'git could not read it');
147
+ byName.set(name, { ...gone, dirty: true });
148
+ }
149
+ else if (status === 'ok') {
150
+ byName.set(name, {
151
+ name,
152
+ present: true,
153
+ commit: commit || null,
154
+ // Fail closed: an unreadable status is treated as work at risk, so
155
+ // the safety gate holds rather than falls open.
156
+ dirty: detail !== 'clean',
157
+ branch: branch || null,
158
+ remote: remote || null,
159
+ });
160
+ }
161
+ else {
162
+ byName.set(name, { ...gone, dirty: false });
163
+ }
164
+ }
165
+ // A checkout the script said nothing about is not evidence of absence.
166
+ return this.checkouts.map((c) => byName.get(c.name) ?? {
167
+ name: c.name, present: false, commit: null, dirty: true, branch: null, remote: null,
168
+ });
169
+ }
170
+ // --------------------------------------------------------------- diff ----
171
+ diff(actual, desired) {
172
+ const byName = new Map(actual.checkouts.map((c) => [c.name, c]));
173
+ const ops = [];
174
+ for (const want of desired.checkouts) {
175
+ const have = byName.get(want.name);
176
+ const c = this.entry(want.name);
177
+ if (!have?.present) {
178
+ ops.push({
179
+ kind: 'create',
180
+ entity: 'checkout',
181
+ id: `checkout/${want.name}`,
182
+ name: want.name,
183
+ commit: want.commit,
184
+ summary: `clone ${c.repo} into ${c.path} at ${short(want.commit)}`,
185
+ });
186
+ continue;
187
+ }
188
+ if (have.commit === want.commit) {
189
+ // The tree is where it should be. Its remote may not be: a hand-rolled
190
+ // `remote set-url` with an embedded token leaves it in origin's URL, and a tree that
191
+ // never moves would otherwise carry it forever. The script rewrites the
192
+ // URL before it touches anything else, and stops there when HEAD
193
+ // already matches — so this never trips the gates on a dirty tree.
194
+ if (have.remote !== want.remote) {
195
+ ops.push({
196
+ kind: 'update',
197
+ entity: 'checkout',
198
+ id: `checkout/${want.name}`,
199
+ name: want.name,
200
+ commit: want.commit,
201
+ // Only the TARGET is printed. The URL on disk is what may hold the
202
+ // secret, and a plan line is a log line.
203
+ summary: `${c.path}: origin URL ${hasCredential(have.remote) ? 'carries a credential' : 'differs'}` +
204
+ ` → ${want.remote}`,
205
+ });
206
+ }
207
+ continue;
208
+ }
209
+ // The op is emitted even when local work will block it, and apply() warns
210
+ // instead of resetting. The alternative — planning nothing and warning —
211
+ // hides real outstanding work from the plan. A recurring identical plan
212
+ // is not a module failing to converge what it claims to: it is Concord correctly reporting, every cycle, that a
213
+ // declared checkout is stuck behind something only a human can clear.
214
+ const held = c.discardLocalChanges
215
+ ? null
216
+ : have.dirty
217
+ ? 'local changes present, will not be reset'
218
+ : c.track && have.branch !== c.track.branch
219
+ ? `checked out on ${have.branch ?? 'a detached HEAD'}, not ${c.track.branch}`
220
+ : null;
221
+ ops.push({
222
+ kind: 'update',
223
+ entity: 'checkout',
224
+ id: `checkout/${want.name}`,
225
+ name: want.name,
226
+ commit: want.commit,
227
+ summary: `${c.path}: ${short(have.commit ?? '???????')} → ${short(want.commit)}` +
228
+ (held ? ` — HELD: ${held}` : ''),
229
+ });
230
+ }
231
+ return ops;
232
+ }
233
+ // -------------------------------------------------------------- apply ----
234
+ async apply(ops) {
235
+ for (const op of ops) {
236
+ const c = this.entry(op.name);
237
+ if (op.kind === 'create') {
238
+ const why = this.#unreadable.get(c.name);
239
+ if (why) {
240
+ throw new Error(`${this.scope}: ${c.path} exists but is not a readable git repository (${why}). ` +
241
+ `Refusing to clone over it — fix the ownership or move it aside.`);
242
+ }
243
+ }
244
+ const r = this.exec.runScript(this.script(c, op.commit, op.kind === 'create'), {
245
+ sudo: true,
246
+ timeoutMs: c.timeout * 1000,
247
+ });
248
+ const blocked = {
249
+ [BLOCKED_DIRTY]: ['uncommitted changes to tracked files', 'Commit, stash or discard them'],
250
+ [BLOCKED_UNPUSHED]: ['commits that exist on no origin branch — unpushed work', 'Push them'],
251
+ [BLOCKED_BRANCH]: [
252
+ `checked out on a branch other than ${c.track?.branch} (or a detached HEAD) — someone is working there`,
253
+ `Switch it back to ${c.track?.branch}`,
254
+ ],
255
+ };
256
+ const hit = blocked[r.status];
257
+ if (hit) {
258
+ const [what, fix] = hit;
259
+ // A warning, not a failure: one tree someone left mid-edit must
260
+ // not halt every other module on that host. The run carries the warning
261
+ // and therefore never claims convergence.
262
+ this.warn(`${c.name}: HELD at ${c.path} — ${what}. Not resetting to ${short(op.commit)}. ` +
263
+ `${fix}, or set discardLocalChanges on this checkout.`);
264
+ continue;
265
+ }
266
+ if (r.status !== 0) {
267
+ throw new Error(`${this.scope}: checkout "${c.name}" failed (exit ${r.status}):\n${tail(r.output)}`);
268
+ }
269
+ this.log(` ✓ ${c.name} at ${short(op.commit)}`);
270
+ }
271
+ }
272
+ /**
273
+ * The outer half runs as root: it can write the stamp, and it is the only
274
+ * thing that may `sudo -u`. Every git command runs in the INNER half, as the
275
+ * tree's owner.
276
+ *
277
+ * The token is interpolated into the script BODY, which travels over stdin —
278
+ * never argv, which is world-readable in /proc. It is exported to the inner
279
+ * shell and referenced only by NAME inside the credential helper, so it does
280
+ * not reach argv there either, and — unlike the `remote set-url` idiom this
281
+ * replaces — it is never written into `.git/config` on disk.
282
+ */
283
+ script(c, commit, fresh = false) {
284
+ const url = cloneUrl(c.repo);
285
+ const inner = [
286
+ 'set -euo pipefail',
287
+ 'export GIT_TERMINAL_PROMPT=0',
288
+ // Ignore the invoking user's git config and the system one, for the
289
+ // reason src/git.ts documents: without it a private repo with no declared
290
+ // token still clones, silently borrowing whatever credential helper the
291
+ // user happens to have. An absent credential must fail, not be supplied
292
+ // from somewhere undeclared.
293
+ 'export GIT_CONFIG_GLOBAL=/dev/null',
294
+ 'export GIT_CONFIG_SYSTEM=/dev/null',
295
+ ...(this.#token
296
+ ? [
297
+ `export CONCORD_GIT_TOKEN=${sq(this.#token)}`,
298
+ `G() { git -c credential.helper='!f() { echo username=x-access-token; echo "password=$CONCORD_GIT_TOKEN"; }; f' "$@"; }`,
299
+ ]
300
+ : ['G() { git "$@"; }']),
301
+ `if [ ! -d ${sq(`${c.path}/.git`)} ]; then`,
302
+ ` mkdir -p ${sq(parent(c.path))}`,
303
+ ` G clone --quiet ${sq(url)} ${sq(c.path)}`,
304
+ `fi`,
305
+ // Rewritten every run so the URL on disk never goes stale — and, for a
306
+ // tree migrated off the old script, so a token baked into it is dropped.
307
+ `G -C ${sq(c.path)} remote set-url origin ${sq(url)} 2>/dev/null || G -C ${sq(c.path)} remote add origin ${sq(url)}`,
308
+ // Already at the target? Then the URL above was the whole job — a repair
309
+ // op — and it must not reach the gates: a dirty tree is no reason to keep
310
+ // a credential on disk.
311
+ `if [ "$(git -C ${sq(c.path)} rev-parse HEAD)" = ${sq(commit)} ]; then exit 0; fi`,
312
+ `G -C ${sq(c.path)} fetch --quiet --prune origin '+refs/heads/*:refs/remotes/origin/*'`,
313
+ `git -C ${sq(c.path)} cat-file -e ${sq(`${commit}^{commit}`)}`,
314
+ // The gate protects work that was already on the machine. A tree this
315
+ // run just cloned has none by construction, so it is skipped there —
316
+ // otherwise the very first deploy of a pinned checkout blocks itself,
317
+ // having cloned the branch tip and then been asked to rewind to the pin.
318
+ ...(c.discardLocalChanges || fresh
319
+ ? []
320
+ : [
321
+ // Checked HERE rather than from read()'s data, because only after
322
+ // the fetch are the objects present to answer the second question.
323
+ `if [ -n "$(git -C ${sq(c.path)} status --porcelain --untracked-files=no)" ]; then`,
324
+ ` exit ${BLOCKED_DIRTY}`,
325
+ `fi`,
326
+ // The question is NOT "is HEAD behind the target" — a pin may
327
+ // legitimately rewind to an ancestor, and that destroys nothing
328
+ // because the commits remain on the remote. What must never be
329
+ // reset away is a commit that exists ONLY here, which is exactly a
330
+ // HEAD no remote-tracking branch contains (the fetch above just
331
+ // made those current).
332
+ `if [ -z "$(git -C ${sq(c.path)} branch -r --contains HEAD 2>/dev/null)" ]; then`,
333
+ ` exit ${BLOCKED_UNPUSHED}`,
334
+ `fi`,
335
+ // A tree on some OTHER branch is someone's work in progress, even
336
+ // when clean and pushed. Resetting it would repoint their branch at
337
+ // the tracked tip, and their next push would bounce as a
338
+ // non-fast-forward. A pin has no branch to protect: it detaches
339
+ // below and moves nothing but HEAD.
340
+ ...(c.track
341
+ ? [
342
+ `if [ "$(git -C ${sq(c.path)} symbolic-ref --short -q HEAD)" != ${sq(c.track.branch)} ]; then`,
343
+ ` exit ${BLOCKED_BRANCH}`,
344
+ `fi`,
345
+ ]
346
+ : []),
347
+ ]),
348
+ // Never `git clean`: it would delete node_modules/, .env and data/, none
349
+ // of which git put there and none of which a redeploy would restore.
350
+ //
351
+ // Clear the index and worktree IN PLACE first (a half-finished merge would
352
+ // make the detach refuse; on a tree the gates passed this is a no-op),
353
+ // then step off the branch, so the reset that follows moves no branch
354
+ // pointer — every branch the tree has stays exactly where it was.
355
+ `git -C ${sq(c.path)} reset --hard --quiet`,
356
+ `git -C ${sq(c.path)} checkout --quiet --detach`,
357
+ `git -C ${sq(c.path)} reset --hard --quiet ${sq(commit)}`,
358
+ // A tracking checkout ends on the branch it tracks, at the tip it tracks —
359
+ // the state `git pull` would have produced. A pin stays detached: it is a
360
+ // commit, not a branch.
361
+ ...(c.track ? [`git -C ${sq(c.path)} checkout --quiet -B ${sq(c.track.branch)}`] : []),
362
+ // The script module's discipline: verify the goal, not the exit code. A
363
+ // reset that "succeeded" without landing on the sha would otherwise be
364
+ // planned and applied on every run forever.
365
+ `test "$(git -C ${sq(c.path)} rev-parse HEAD)" = ${sq(commit)}`,
366
+ ].join('\n');
367
+ const stamp = this.stampPath(c.name);
368
+ return [
369
+ 'set -uo pipefail',
370
+ `sudo -n -u ${sq(c.owner)} -- bash -s <<'CONCORD_CHECKOUT_EOF'`,
371
+ inner,
372
+ 'CONCORD_CHECKOUT_EOF',
373
+ 'RC=$?',
374
+ 'if [ "$RC" != 0 ]; then exit "$RC"; fi',
375
+ 'set -e',
376
+ `mkdir -p ${sq(parent(stamp))}`,
377
+ `printf '%s\\n' ${sq(commit)} > ${sq(stamp)}`,
378
+ `chmod 0644 ${sq(stamp)}`,
379
+ ].join('\n');
380
+ }
381
+ }
382
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/checkout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAA;AAKrE,iFAAiF;AACjF,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAA;AAEzD,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAE1C,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE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7C,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE;SAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ export declare const CheckoutSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ repo: z.ZodString;
5
+ path: z.ZodString;
6
+ owner: z.ZodString;
7
+ track: z.ZodOptional<z.ZodObject<{
8
+ branch: z.ZodString;
9
+ }, z.core.$strict>>;
10
+ pin: z.ZodOptional<z.ZodObject<{
11
+ commit: z.ZodString;
12
+ }, z.core.$strict>>;
13
+ discardLocalChanges: z.ZodDefault<z.ZodBoolean>;
14
+ timeout: z.ZodDefault<z.ZodNumber>;
15
+ }, z.core.$strict>;
16
+ /**
17
+ * Where the module records the sha it last converged each checkout to.
18
+ *
19
+ * NOT a state file: `read()` still enumerates the truth with
20
+ * `git rev-parse HEAD`, and nothing here is ever read back as desired state.
21
+ * It is an OUTPUT, for the two mechanisms that already exist and want to know
22
+ * "did this move":
23
+ *
24
+ * systemd `watches: [{ paths: ['<dir>/<name>.sha'], onChange: 'restart' }]`
25
+ * a script guard `test "$(cat <dir>/<name>.sha)" = "$(cat DIR/.built-sha)"`
26
+ *
27
+ * which is how a build step stays OUT of this module.
28
+ */
29
+ export declare const DEFAULT_STAMP_DIR = "/var/lib/concord/checkouts";
30
+ export declare const CheckoutConfigSchema: z.ZodObject<{
31
+ type: z.ZodLiteral<"checkout">;
32
+ id: z.ZodString;
33
+ host: z.ZodString;
34
+ stampDir: z.ZodDefault<z.ZodString>;
35
+ checkouts: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
+ name: z.ZodString;
37
+ repo: z.ZodString;
38
+ path: z.ZodString;
39
+ owner: z.ZodString;
40
+ track: z.ZodOptional<z.ZodObject<{
41
+ branch: z.ZodString;
42
+ }, z.core.$strict>>;
43
+ pin: z.ZodOptional<z.ZodObject<{
44
+ commit: z.ZodString;
45
+ }, z.core.$strict>>;
46
+ discardLocalChanges: z.ZodDefault<z.ZodBoolean>;
47
+ timeout: z.ZodDefault<z.ZodNumber>;
48
+ }, z.core.$strict>>>;
49
+ }, z.core.$strict>;
50
+ export type CheckoutEntry = z.output<typeof CheckoutSchema>;
51
+ export type CheckoutConfig = z.output<typeof CheckoutConfigSchema>;
52
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/checkout/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAqDvB,eAAO,MAAM,cAAc;;;;;;;;;;;;;kBAiEvB,CAAA;AAEJ;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,+BAA+B,CAAA;AAE7D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;kBAiBtB,CAAA;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAA;AAC3D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * A git working tree on a host, at a declared ref.
4
+ *
5
+ * The module that drives `git`, and nothing else. It gets source onto a machine;
6
+ * what happens to that source afterwards — a build, a unit restart — belongs to
7
+ * `script` and `systemd`, which already do those jobs (a module is named for the
8
+ * interface it DRIVES).
9
+ *
10
+ * Unlike `docker`, git runs ON THE TARGET here, because the deliverable IS a
11
+ * working tree: a notes repo may push from one, and a dev checkout is
12
+ * something you `git log` in. It also matters operationally — docker's
13
+ * `uploadContext()` does `rm -rf` and extracts a tar, which on an npm project
14
+ * would delete `node_modules/`, `.env` and `data/` on every deploy. A
15
+ * `reset --hard` leaves gitignored siblings alone, which is what makes
16
+ * re-converging a checkout nearly free.
17
+ *
18
+ * Branch tips are still resolved on the PRIMARY, in one batched request per
19
+ * host (see src/git.ts).
20
+ */
21
+ const Name = z.string().regex(/^[a-z0-9][a-z0-9-]*$/, 'must be kebab-case, starting alphanumeric');
22
+ /**
23
+ * `owner/name` (implies github.com) or any git URL.
24
+ *
25
+ * `file://` is accepted where the docker schema does not accept it: it is a
26
+ * real git transport, and it is how the test harness exercises this module
27
+ * against actual repositories rather than a mocked git. Real configs are not
28
+ * expected to declare one.
29
+ */
30
+ const Repo = z
31
+ .string()
32
+ .min(1)
33
+ .refine((r) => /^[\w.-]+\/[\w.-]+$/.test(r) ||
34
+ /^(https?|ssh|git|file):\/\//.test(r) ||
35
+ /^[\w.-]+@/.test(r), 'must be "owner/name" or a git URL');
36
+ const Commit = z.string().regex(/^[0-9a-f]{40}$/, 'must be a full 40-character commit sha');
37
+ /**
38
+ * POSIX-ish user name, checked rather than passed through.
39
+ *
40
+ * The config repo is trusted, but a name that reaches a shell is not a place to
41
+ * accept arbitrary text — the same rule the file module applies to owner/group.
42
+ */
43
+ const UnixName = z.string().regex(/^[a-z_][a-z0-9_-]*\$?$/i, 'must be a unix user name');
44
+ export const CheckoutSchema = z
45
+ .object({
46
+ name: Name,
47
+ repo: Repo,
48
+ /** Absolute path of the working tree on the target. */
49
+ path: z.string().startsWith('/', 'must be an absolute path'),
50
+ /**
51
+ * The user that owns the tree, and that git runs as.
52
+ *
53
+ * REQUIRED, with no default. Running git as root against a user-owned
54
+ * checkout fails with "dubious ownership", and the shape of bug that
55
+ * produces (an error on both sides comparing equal, reported as converged)
56
+ * is exactly what a hand-written guard script tends to get wrong.
57
+ */
58
+ owner: UnixName,
59
+ /**
60
+ * Follow a branch: every reconcile resolves its tip and converges to it.
61
+ *
62
+ * Same semantics as the docker module's, deliberately — a branch tip is an
63
+ * EXTERNAL authority the host has no say in, so tracking one is a
64
+ * declaration of policy and drift against it is real.
65
+ */
66
+ track: z.object({ branch: z.string().min(1) }).strict().optional(),
67
+ /** Exactly this commit. Nothing moves until the config changes. */
68
+ pin: z.object({ commit: Commit }).strict().optional(),
69
+ /**
70
+ * Reset over local work instead of preserving it.
71
+ *
72
+ * The default REFUSES to move a tree that holds work — uncommitted changes
73
+ * to tracked files, commits no origin branch contains, or (for `track`) a
74
+ * HEAD checked out on some other branch — and warns instead. That is the
75
+ * same call `syncConfigRepo` made after an unguarded `reset --hard`
76
+ * destroyed a whole refactor in the config checkout.
77
+ *
78
+ * Set it true only where the tree is a pure deploy target that nobody
79
+ * develops in. A checkout someone (or an agent) also authors code in
80
+ * will have local commits, and must keep the default.
81
+ *
82
+ * Note this never removes UNTRACKED files: `reset --hard` leaves them, and
83
+ * the module never runs `git clean` (that would delete `node_modules/`,
84
+ * `.env` and `data/`). So untracked files are not "local work at risk" and
85
+ * do not block an update.
86
+ */
87
+ discardLocalChanges: z.boolean().default(false),
88
+ /** Seconds before a clone/fetch is killed. */
89
+ timeout: z.number().int().positive().max(3600).default(300),
90
+ })
91
+ .strict()
92
+ .superRefine((c, ctx) => {
93
+ const n = [c.track !== undefined, c.pin !== undefined].filter(Boolean).length;
94
+ if (n !== 1) {
95
+ ctx.addIssue({
96
+ code: 'custom',
97
+ message: n === 0
98
+ ? 'needs exactly one of `track` (follow a branch) or `pin` (an exact commit)'
99
+ : 'track and pin are mutually exclusive — pick one',
100
+ });
101
+ }
102
+ });
103
+ /**
104
+ * Where the module records the sha it last converged each checkout to.
105
+ *
106
+ * NOT a state file: `read()` still enumerates the truth with
107
+ * `git rev-parse HEAD`, and nothing here is ever read back as desired state.
108
+ * It is an OUTPUT, for the two mechanisms that already exist and want to know
109
+ * "did this move":
110
+ *
111
+ * systemd `watches: [{ paths: ['<dir>/<name>.sha'], onChange: 'restart' }]`
112
+ * a script guard `test "$(cat <dir>/<name>.sha)" = "$(cat DIR/.built-sha)"`
113
+ *
114
+ * which is how a build step stays OUT of this module.
115
+ */
116
+ export const DEFAULT_STAMP_DIR = '/var/lib/concord/checkouts';
117
+ export const CheckoutConfigSchema = z
118
+ .object({
119
+ type: z.literal('checkout'),
120
+ id: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, 'must be kebab-case, starting alphanumeric'),
121
+ /**
122
+ * Which host this runs on — a key of the config's `hosts` registry.
123
+ *
124
+ * REQUIRED, with no default, like every other host-scoped module: a
125
+ * silently-defaulting host is a way to check code out on the wrong machine.
126
+ */
127
+ host: z.string().min(1),
128
+ stampDir: z.string().startsWith('/', 'must be an absolute path').default(DEFAULT_STAMP_DIR),
129
+ checkouts: z.array(CheckoutSchema).optional(),
130
+ })
131
+ .strict();
132
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/checkout/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,sBAAsB,EAAE,2CAA2C,CAAC,CAAA;AAElG;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG,CAAC;KACX,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CACJ,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5B,6BAA6B,CAAC,IAAI,CAAC,CAAC,CAAC;IACrC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EACrB,mCAAmC,CACpC,CAAA;AAEH,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,wCAAwC,CAAC,CAAA;AAE3F;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yBAAyB,EAAE,0BAA0B,CAAC,CAAA;AAExF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAA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