@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
package/dist/daemon.js ADDED
@@ -0,0 +1,394 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The Concord daemon — the top-level process, and the only one.
4
+ *
5
+ * It replaces `concord.timer` + `concord-run`. That pair existed to produce a
6
+ * working reconciler process every 15 minutes, which is why it carried
7
+ * build-before-swap and a last-known-good fallback. A long-running process
8
+ * needs none of that: it is already running, so a failed build is harmless —
9
+ * you simply do not restart it. Updating Concord is a deliberate, manual step
10
+ * (install the new version, restart the service), never something that
11
+ * happens to you.
12
+ *
13
+ * TWO RULES, both learned the hard way:
14
+ *
15
+ * 1. **Nothing here comes from the config repo.** Every setting is an
16
+ * environment variable, placed once at install time. The config repo is
17
+ * what Concord DEPLOYS; it must never decide how Concord RUNS. Putting a
18
+ * trigger in config once already made the mechanism that fixes a broken
19
+ * config depend on the config being right.
20
+ *
21
+ * 2. **Nothing short of SIGTERM may stop the loop.** A config that will not
22
+ * parse and a module that throws are both ordinary, expected events: log
23
+ * them and try again next tick. A daemon that exits on a bad config would
24
+ * hand the config repo the power to take Concord down — rule 1 again, by
25
+ * another route.
26
+ */
27
+ import { execFileSync } from 'node:child_process';
28
+ import { existsSync, mkdirSync, readFileSync } from 'node:fs';
29
+ import { homedir } from 'node:os';
30
+ import { join } from 'node:path';
31
+ import { loadConfig, RECONCILER_ROOT, syncConfigRepo } from './loader.js';
32
+ import { run } from './runner.js';
33
+ import { Scheduler } from './scheduler.js';
34
+ import { startHookListener } from './hook.js';
35
+ import { PlanService } from './plans.js';
36
+ import { appendCapped, newRecordId, RecordStore } from './records.js';
37
+ import { startUi } from './ui.js';
38
+ const HOME = process.env.CONCORD_HOME ?? join(homedir(), '.concord');
39
+ const STATE_DIR = join(HOME, 'state');
40
+ const CONFIG_DIR = process.env.CONCORD_CONFIG_DIR ?? join(HOME, 'config');
41
+ /** Compiled-in default. An env var can override it; the config repo cannot. */
42
+ const DEFAULT_INTERVAL_S = 900;
43
+ /** The reconcile in flight, if any. Its record collects every line logged. */
44
+ let currentRun = null;
45
+ function log(scope, message) {
46
+ const ts = new Date().toISOString().replace('T', ' ').slice(0, 19);
47
+ const line = `${ts} ${scope.padEnd(22)} ${message}`;
48
+ console.log(line);
49
+ if (currentRun)
50
+ appendCapped(currentRun.log, line);
51
+ }
52
+ function die(message) {
53
+ console.error(`concord: ${message}`);
54
+ process.exit(1);
55
+ }
56
+ function intervalSeconds() {
57
+ const raw = process.env.CONCORD_INTERVAL_SECONDS;
58
+ if (!raw)
59
+ return DEFAULT_INTERVAL_S;
60
+ const n = Number(raw);
61
+ if (!Number.isFinite(n) || n < 30) {
62
+ die(`CONCORD_INTERVAL_SECONDS=${raw} is not a number of seconds >= 30`);
63
+ }
64
+ return n;
65
+ }
66
+ // ------------------------------------------------------------- scheduling ---
67
+ const scheduler = new Scheduler();
68
+ /**
69
+ * Why the next cycle runs. The first request since the last cycle started
70
+ * names it; coalesced requests after that are the same run.
71
+ */
72
+ let pendingTrigger = 'startup';
73
+ /** Ask for a reconcile. The seam the webhook listener will attach to. */
74
+ export function requestRun(reason) {
75
+ pendingTrigger ??= reason;
76
+ const verdict = scheduler.request();
77
+ log('daemon', verdict === 'queued' ? `${reason} — run in flight, queued one more` : `${reason} — waking`);
78
+ return verdict;
79
+ }
80
+ // -------------------------------------------------------------- staleness ---
81
+ /**
82
+ * Say when the running code is out of date, and never act on it.
83
+ *
84
+ * Manual updates trade automatic upgrades for the certainty that nothing
85
+ * changes under you. The cost is a fix that is released and then forgotten,
86
+ * with the fleet quietly reconciling against old code. This refuses to let that
87
+ * be invisible without taking the decision back.
88
+ *
89
+ * Two install shapes, checked differently:
90
+ * - a git checkout (development, or a host deployed with `concord-deploy`):
91
+ * compare HEAD with the tip of its branch on the remote;
92
+ * - an npm install: compare the installed version with the registry's latest.
93
+ */
94
+ const reconcilerState = {};
95
+ /** Bounded, quiet child process. A nicety — never the thing that blocks a cycle. */
96
+ function quiet(command, args, cwd) {
97
+ return execFileSync(command, args, {
98
+ cwd,
99
+ encoding: 'utf8',
100
+ stdio: ['ignore', 'pipe', 'pipe'],
101
+ timeout: 60_000,
102
+ }).trim();
103
+ }
104
+ function reportStaleness() {
105
+ try {
106
+ if (existsSync(join(RECONCILER_ROOT, '.git')))
107
+ reportGitStaleness();
108
+ else
109
+ reportNpmStaleness();
110
+ }
111
+ catch {
112
+ // No network, no registry entry, or not a recognisable install. None of
113
+ // them is worth a line every cycle.
114
+ }
115
+ }
116
+ function reportGitStaleness() {
117
+ const git = (...args) => quiet('git', args, RECONCILER_ROOT);
118
+ const head = git('rev-parse', 'HEAD');
119
+ const branch = git('rev-parse', '--abbrev-ref', 'HEAD');
120
+ const remote = git('ls-remote', 'origin', branch).split(/\s+/)[0];
121
+ reconcilerState.sha = head;
122
+ if (!remote || remote === head) {
123
+ delete reconcilerState.behind;
124
+ log('daemon', `reconciler ${head.slice(0, 8)} (up to date)`);
125
+ return;
126
+ }
127
+ let behind = '';
128
+ try {
129
+ git('fetch', '--quiet', '--depth', '50', 'origin', branch);
130
+ behind = ` — ${git('rev-list', '--count', `HEAD..${remote}`)} commit(s) behind`;
131
+ }
132
+ catch {
133
+ /* counting is a nicety; the mismatch is the point */
134
+ }
135
+ reconcilerState.behind = `not the tip of ${branch}${behind}`;
136
+ log('daemon', `⚠ reconciler ${head.slice(0, 8)} is NOT the tip of ${branch}${behind}`);
137
+ log('daemon', ' update the reconciler on this host to pick it up');
138
+ }
139
+ function reportNpmStaleness() {
140
+ const pkg = JSON.parse(readFileSync(join(RECONCILER_ROOT, 'package.json'), 'utf8'));
141
+ reconcilerState.version = pkg.version;
142
+ const latest = quiet('npm', ['view', pkg.name, 'version'], RECONCILER_ROOT);
143
+ if (!latest || compareVersions(latest, pkg.version) <= 0) {
144
+ delete reconcilerState.behind;
145
+ log('daemon', `reconciler ${pkg.version} (up to date)`);
146
+ return;
147
+ }
148
+ reconcilerState.behind = `${latest} is available`;
149
+ log('daemon', `⚠ reconciler ${pkg.version} is out of date — ${latest} is published`);
150
+ log('daemon', ` update with \`npm install -g ${pkg.name}@${latest}\`, then restart the service`);
151
+ }
152
+ /** Compare `x.y.z` release versions numerically. Pre-release tags are ignored. */
153
+ function compareVersions(a, b) {
154
+ const parse = (v) => v.split('-')[0].split('.').map((n) => Number(n) || 0);
155
+ const [pa, pb] = [parse(a), parse(b)];
156
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
157
+ const d = (pa[i] ?? 0) - (pb[i] ?? 0);
158
+ if (d !== 0)
159
+ return Math.sign(d);
160
+ }
161
+ return 0;
162
+ }
163
+ // -------------------------------------------------------------- reconcile ---
164
+ async function reconcileOnce() {
165
+ // main() refuses to start the loop without these.
166
+ const repo = process.env.CONCORD_CONFIG_REPO;
167
+ const ageKey = process.env.CONCORD_AGE_KEY;
168
+ const sha = syncConfigRepo(repo, CONFIG_DIR);
169
+ if (currentRun)
170
+ currentRun.sha = sha;
171
+ log('concord', `config repo at ${sha.slice(0, 12)}`);
172
+ const { modules, hosts, settings } = await loadConfig(CONFIG_DIR);
173
+ const hostNames = Object.keys(hosts);
174
+ log('concord', `${modules.length} module(s), ${hostNames.length} host(s): ${hostNames.join(', ')}`);
175
+ const result = await run({
176
+ modules,
177
+ ageKey,
178
+ stateRoot: STATE_DIR,
179
+ configDir: CONFIG_DIR,
180
+ apply: true,
181
+ log,
182
+ hosts,
183
+ settings,
184
+ });
185
+ if (currentRun)
186
+ currentRun.totalOps = result.totalOps;
187
+ if (result.failed) {
188
+ const broken = result.modules.find((m) => m.error);
189
+ log('concord', `ABORTED at ${broken.kind}:${broken.id}. Convergence is UNKNOWN.`);
190
+ settle('aborted', `ABORTED at ${broken.kind}:${broken.id}: ${broken.error ?? ''}`);
191
+ if (result.skipped.length)
192
+ log('concord', ` not evaluated: ${result.skipped.join(', ')}`);
193
+ return;
194
+ }
195
+ const unknown = result.unreachable.length
196
+ ? ` — ${result.unreachable.length} module(s) NOT checked (host unreachable): ${result.unreachable.join(', ')}`
197
+ : '';
198
+ const warned = result.warnings.length ? ` — ${result.warnings.length} warning(s)` : '';
199
+ if (result.totalOps === 0) {
200
+ const line = unknown || warned ? `no changes where checked${unknown}${warned}` : 'converged — no changes';
201
+ log('concord', line);
202
+ settle('converged', line);
203
+ }
204
+ else {
205
+ const line = `${result.totalOps} change(s) across the fleet${unknown}${warned}`;
206
+ log('concord', line);
207
+ settle('changed', line);
208
+ }
209
+ for (const w of result.warnings)
210
+ log('concord', ` ! ${w.scope}: ${w.message}`);
211
+ }
212
+ /**
213
+ * One cycle. Never throws — see rule 2.
214
+ *
215
+ * An unparseable config and a module that blew up are both ordinary events
216
+ * here. The timer used to absorb them by virtue of the process exiting and
217
+ * being started again; a daemon has to absorb them itself.
218
+ */
219
+ async function cycle() {
220
+ await scheduler.cycle(async () => {
221
+ currentRun = {
222
+ id: newRecordId('run'),
223
+ trigger: pendingTrigger ?? 'interval',
224
+ status: 'running',
225
+ startedAt: new Date().toISOString(),
226
+ log: [],
227
+ };
228
+ pendingTrigger = null;
229
+ runs.save(currentRun);
230
+ try {
231
+ reportStaleness();
232
+ await reconcileOnce();
233
+ }
234
+ catch (err) {
235
+ const message = err instanceof Error ? err.message : String(err);
236
+ log('concord', `ERROR: ${err instanceof Error ? (err.stack ?? err.message) : String(err)}`);
237
+ log('concord', 'the daemon stays up and will try again next tick');
238
+ settle('error', `ERROR: ${message.split('\n')[0]}`);
239
+ }
240
+ finally {
241
+ const done = currentRun;
242
+ currentRun = null;
243
+ if (done.status === 'running')
244
+ done.status = 'error';
245
+ done.finishedAt = new Date().toISOString();
246
+ runs.save(done);
247
+ runs.prune();
248
+ }
249
+ });
250
+ }
251
+ /** Record how the reconcile in flight ended. The log already has the detail. */
252
+ function settle(status, summary) {
253
+ if (!currentRun)
254
+ return;
255
+ currentRun.status = status;
256
+ // One line, and a short one: errors can carry a whole HTML error page. The
257
+ // log keeps the full text.
258
+ const line = summary.replace(/\s+/g, ' ').trim();
259
+ currentRun.summary = line.length > 300 ? `${line.slice(0, 299)}…` : line;
260
+ }
261
+ // ------------------------------------------------------------ history, UI ---
262
+ const runs = new RecordStore(join(HOME, 'runs'), 200);
263
+ const startedAt = new Date().toISOString();
264
+ let nextRunAt;
265
+ /**
266
+ * Start the UI/API listener and the plan service behind it. Optional in the
267
+ * same way the webhook is: `CONCORD_UI_SOCKET=off` and neither exists, and the
268
+ * reconcile loop is exactly what it was.
269
+ */
270
+ function startUiAndPlans(interval) {
271
+ const socketPath = process.env.CONCORD_UI_SOCKET ?? '/run/concord/ui.sock';
272
+ if (socketPath === 'off') {
273
+ log('daemon', 'CONCORD_UI_SOCKET=off — no UI, no plans');
274
+ return;
275
+ }
276
+ const repoUrl = process.env.CONCORD_CONFIG_REPO;
277
+ const plans = new PlanService({
278
+ repoUrl,
279
+ root: join(HOME, 'plans'),
280
+ reconcileRunning: () => scheduler.running,
281
+ log,
282
+ command: ({ configDir, home, resultPath }) => ({
283
+ command: process.execPath,
284
+ args: [join(RECONCILER_ROOT, 'dist', 'cli', 'main.js'), 'plan', '--no-sync', '--result', resultPath],
285
+ // Its own CONCORD_HOME, so its state (docker's git mirrors) never races
286
+ // the daemon's; the age key and everything else come through as-is.
287
+ env: { ...process.env, CONCORD_HOME: home, CONCORD_CONFIG_DIR: configDir },
288
+ }),
289
+ });
290
+ startUi({
291
+ socketPath,
292
+ plans,
293
+ log,
294
+ status: () => ({
295
+ startedAt,
296
+ intervalSeconds: interval,
297
+ reconciler: { ...reconcilerState },
298
+ reconciling: scheduler.running,
299
+ ...(nextRunAt && !scheduler.running ? { nextRunAt } : {}),
300
+ configRepo: repoUrl,
301
+ }),
302
+ runs: {
303
+ list: (limit) => runs.list(limit).map((saved) => {
304
+ // The one in flight lives in memory; its file lags.
305
+ const { log: _log, ...summary } = currentRun?.id === saved.id ? currentRun : saved;
306
+ return summary;
307
+ }),
308
+ get: (id) => (currentRun?.id === id ? currentRun : runs.get(id)),
309
+ },
310
+ });
311
+ }
312
+ // ------------------------------------------------------------------- main ---
313
+ async function main() {
314
+ const interval = intervalSeconds();
315
+ mkdirSync(STATE_DIR, { recursive: true });
316
+ log('daemon', `starting — reconciling every ${interval}s`);
317
+ // Not configured yet — the normal state straight after install. Wait rather
318
+ // than exit: a unit that restarts on failure would turn an exit into a
319
+ // restart loop, and there is nothing to retry until someone edits the
320
+ // environment file and restarts the service.
321
+ const missing = ['CONCORD_CONFIG_REPO', 'CONCORD_AGE_KEY'].filter((k) => !process.env[k]);
322
+ if (missing.length) {
323
+ await waitUnconfigured(missing);
324
+ return;
325
+ }
326
+ log('daemon', `config repo ${process.env.CONCORD_CONFIG_REPO}`);
327
+ // A manual poke, and the same path the webhook uses.
328
+ process.on('SIGHUP', () => requestRun('SIGHUP'));
329
+ // The listener is OPTIONAL. Without a secret there is no webhook, and the
330
+ // daemon reconciles on its interval exactly as before — which is the whole
331
+ // reason a missing or broken route is survivable.
332
+ const secret = process.env.CONCORD_HOOK_SECRET;
333
+ if (secret) {
334
+ startHookListener({
335
+ socketPath: process.env.CONCORD_HOOK_SOCKET ?? '/run/concord/hook.sock',
336
+ secret,
337
+ onPush: requestRun,
338
+ log,
339
+ });
340
+ }
341
+ else {
342
+ log('daemon', 'no CONCORD_HOOK_SECRET — running on the interval only');
343
+ }
344
+ try {
345
+ startUiAndPlans(interval);
346
+ }
347
+ catch (err) {
348
+ // A UI that cannot start is a missing UI, never a missing reconcile.
349
+ log('daemon', `UI/plans not started: ${err instanceof Error ? err.message : String(err)}`);
350
+ }
351
+ for (const sig of ['SIGTERM', 'SIGINT']) {
352
+ process.on(sig, () => {
353
+ if (scheduler.stopping)
354
+ return;
355
+ log('daemon', `${sig} — finishing the current cycle, then exiting`);
356
+ scheduler.stop();
357
+ });
358
+ }
359
+ while (!scheduler.stopping) {
360
+ await cycle();
361
+ if (scheduler.stopping)
362
+ break;
363
+ if (scheduler.takeRerun()) {
364
+ log('daemon', 'a run was requested mid-cycle — going straight round again');
365
+ continue;
366
+ }
367
+ nextRunAt = new Date(Date.now() + interval * 1000).toISOString();
368
+ await scheduler.sleep(interval);
369
+ nextRunAt = undefined;
370
+ }
371
+ log('daemon', 'stopped');
372
+ process.exit(0);
373
+ }
374
+ /**
375
+ * Idle until stopped. No loop, no webhook, no UI: with no config repo there is
376
+ * nothing to reconcile, plan or show. Settings are read once at start, so the
377
+ * way out is a restart, never a reload.
378
+ */
379
+ async function waitUnconfigured(missing) {
380
+ log('daemon', `not configured — ${missing.join(' and ')} ${missing.length > 1 ? 'are' : 'is'} unset`);
381
+ log('daemon', ` set ${missing.length > 1 ? 'them' : 'it'} in the service's environment file, then restart the service`);
382
+ process.on('SIGHUP', () => log('daemon', 'SIGHUP ignored — not configured; restart the service after setting the environment'));
383
+ for (const sig of ['SIGTERM', 'SIGINT']) {
384
+ process.on(sig, () => {
385
+ log('daemon', `${sig} — exiting`);
386
+ process.exit(0);
387
+ });
388
+ }
389
+ // A pending promise alone does not keep Node alive; a timer does.
390
+ setInterval(() => { }, 2 ** 30);
391
+ return new Promise(() => { });
392
+ }
393
+ main().catch((err) => die(err instanceof Error ? (err.stack ?? err.message) : String(err)));
394
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.js","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AA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AAC,CAAC,CAAA;IAC/H,KAAK,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAU,EAAE,CAAC;QACjD,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE;YACnB,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,YAAY,CAAC,CAAA;YACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,kEAAkE;IAClE,WAAW,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9B,OAAO,IAAI,OAAO,CAAQ,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;AACrC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=eval-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-config.d.ts","sourceRoot":"","sources":["../src/eval-config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Evaluate a config repo's `concord.ts` and print its default export as JSON.
3
+ *
4
+ * node dist/eval-config.js <configDir>
5
+ *
6
+ * Runs as a SHORT-LIVED CHILD of the loader, never inside the daemon.
7
+ * tsx transpiles through esbuild's sync API: a worker thread plus a long-lived
8
+ * `esbuild` child process, created once per process and never recreated. When a
9
+ * signal killed that helper, every later config load in the daemon threw "The
10
+ * service is no longer running" until someone restarted it — while the daemon
11
+ * logged that it would try again next tick. A fresh process per evaluation has
12
+ * no helper to lose, and a config that hangs costs one cycle, not the daemon.
13
+ *
14
+ * Crossing the boundary as JSON is free because the config is already plain
15
+ * data.
16
+ */
17
+ import { join } from 'node:path';
18
+ import { pathToFileURL } from 'node:url';
19
+ import { tsImport } from 'tsx/esm/api';
20
+ // stdout is the result channel. A debugging console.log in the config must not
21
+ // corrupt it — in-process evaluation always tolerated one.
22
+ console.log = console.info = console.debug = console.error;
23
+ try {
24
+ const dir = process.argv[2];
25
+ if (!dir)
26
+ throw new Error('usage: node dist/eval-config.js <configDir>');
27
+ const mod = (await tsImport(pathToFileURL(join(dir, 'concord.ts')).href, import.meta.url));
28
+ // A config repo without `"type": "module"` in its package.json is transpiled
29
+ // as CommonJS, and the ESM interop then nests the export one level deeper
30
+ // (`mod.default.default`). Tolerate both shapes — otherwise the failure
31
+ // surfaces as a baffling "schemaVersion undefined" rather than anything
32
+ // pointing at module format.
33
+ const raw = mod.default && mod.default.default !== undefined && mod.default.schemaVersion === undefined
34
+ ? mod.default.default
35
+ : mod.default;
36
+ // `?? null`: JSON.stringify(undefined) is not a string. The loader names a
37
+ // missing default export. Exit explicitly after the flush — tsx's hooks
38
+ // thread keeps the process alive otherwise.
39
+ process.stdout.write(JSON.stringify(raw ?? null), () => process.exit(0));
40
+ }
41
+ catch (err) {
42
+ const text = err instanceof Error ? (err.stack ?? err.message) : String(err);
43
+ process.stderr.write(`${text}\n`, () => process.exit(1));
44
+ }
45
+ //# sourceMappingURL=eval-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-config.js","sourceRoot":"","sources":["../src/eval-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAA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 -0,0 +1,168 @@
1
+ /**
2
+ * Host execution — the seam a remote transport slots into.
3
+ *
4
+ * Every host operation in every module goes through this interface, which is
5
+ * why adding SSH required no module changes: `apt`, `file`, `systemd`, `script`
6
+ * and `container` touch nothing else. (`porkbun` drives a remote API and never
7
+ * touches it at all — that is the line between a host-scoped module and
8
+ * an API-driving one.)
9
+ *
10
+ * Two rules hold for every call shape below: **no child may run forever**, and
11
+ * **a child that did not exit normally is reported as what happened to it** —
12
+ * timed out, killed by a signal — never as "exit 1".
13
+ */
14
+ export interface ExecResult {
15
+ stdout: string;
16
+ status: number;
17
+ }
18
+ export interface ExecOptions {
19
+ timeoutMs?: number;
20
+ }
21
+ /** Ceiling on every host command unless the caller raises it. A stalled apt
22
+ * mirror or a hung ssh must fail the cycle, never hang the daemon. */
23
+ export declare const DEFAULT_TIMEOUT_MS = 600000;
24
+ export interface Exec {
25
+ /** Human-readable, for errors. */
26
+ readonly host: string;
27
+ /** Never throws on a non-zero exit — inspect `status`. */
28
+ run(cmd: string, args: string[], opts?: ExecOptions): ExecResult;
29
+ /** Throws with the command's own stderr on failure. */
30
+ sudo(args: string[], input?: string, opts?: ExecOptions): string;
31
+ /** stdout AND stderr merged — some tools report to stderr (docker compose). */
32
+ sudoCombined(args: string[], opts?: ExecOptions): {
33
+ output: string;
34
+ status: number;
35
+ };
36
+ /** Run a bash script. The body is passed via stdin, never spliced into a command. */
37
+ runScript(script: string, opts?: {
38
+ sudo?: boolean;
39
+ } & ExecOptions): {
40
+ output: string;
41
+ status: number;
42
+ };
43
+ readFileMaybe(path: string): string;
44
+ sudoReadFileMaybe(path: string): string;
45
+ statMaybe(path: string): {
46
+ uid: string;
47
+ gid: string;
48
+ mode: string;
49
+ mtime: number;
50
+ type: string;
51
+ } | null;
52
+ writeFileAsRoot(path: string, content: string, mode: string): void;
53
+ /** Cheap liveness probe. Lets an `optional` host be skipped rather than fail the run. */
54
+ reachable(): boolean;
55
+ }
56
+ export declare const sleep: (ms: number) => Promise<void>;
57
+ /**
58
+ * A script body, as `bash -s` receives it on stdin.
59
+ *
60
+ * `bash -s` reads its script from the same stdin that every command in it
61
+ * inherits, and it reads line by line as it goes. So a command that reads stdin
62
+ * (`ssh`, `docker exec -i`, `read`, `cat`) silently eats the rest of the script
63
+ * — and the script still exits 0, because the last command that DID run
64
+ * succeeded. A brace group is parsed in full before any of it runs, and
65
+ * `</dev/null` gives the commands inside it an empty stdin of their own. The
66
+ * closing brace sits on its own line so a body ending in a heredoc terminator
67
+ * or a comment still closes.
68
+ */
69
+ export declare const scriptInput: (body: string) => string;
70
+ /**
71
+ * Exit status + human note for a child that may not have exited on its own.
72
+ * Shell conventions, so the numbers read like `timeout(1)` and bash:
73
+ * 124 = timed out, 128+n = killed by signal n, 127 = could not be run.
74
+ *
75
+ * A signal-killed child has `status: null`. Mapping that to 1 with empty output
76
+ * is how an operator's `systemctl kill` read as a flaky upload.
77
+ */
78
+ export declare function settle(r: {
79
+ status: number | null;
80
+ signal: NodeJS.Signals | null;
81
+ error?: Error;
82
+ }, timeoutMs: number): {
83
+ status: number;
84
+ note: string;
85
+ };
86
+ /** `exit N`, or the note unbracketed — `timed out after 600s`, `killed by SIGHUP`. */
87
+ export declare function describeExit(status: number, note: string): string;
88
+ export declare class LocalExec implements Exec {
89
+ readonly host: string;
90
+ constructor(host: string);
91
+ /** Always. If local exec is broken there is nothing left to reconcile with. */
92
+ reachable(): boolean;
93
+ run(cmd: string, args: string[], opts?: ExecOptions): ExecResult;
94
+ sudo(args: string[], input?: string, opts?: ExecOptions): string;
95
+ sudoCombined(args: string[], opts?: ExecOptions): {
96
+ output: string;
97
+ status: number;
98
+ };
99
+ runScript(script: string, opts?: {
100
+ sudo?: boolean;
101
+ } & ExecOptions): {
102
+ output: string;
103
+ status: number;
104
+ };
105
+ readFileMaybe(path: string): string;
106
+ sudoReadFileMaybe(path: string): string;
107
+ statMaybe(path: string): {
108
+ uid: string;
109
+ gid: string;
110
+ mode: string;
111
+ mtime: number;
112
+ type: string;
113
+ } | null;
114
+ writeFileAsRoot(path: string, content: string, mode: string): void;
115
+ }
116
+ export interface SshTarget {
117
+ host: string;
118
+ ip: string;
119
+ user: string;
120
+ port?: number;
121
+ /** Private key material. Written to a 0600 temp file for the process lifetime. */
122
+ key?: string;
123
+ }
124
+ /**
125
+ * Remote execution over SSH.
126
+ *
127
+ * Connections are MULTIPLEXED (ControlMaster/ControlPersist): one TCP session
128
+ * per host, reused for every exec. Without it a module issuing dozens of execs
129
+ * pays a full handshake each time — roughly 100 ms versus 5 ms. This is the
130
+ * reason a worker process is unnecessary, since latency was its only real
131
+ * advantage.
132
+ *
133
+ * Commands are passed as ARGV to ssh, and script bodies over stdin, so nothing
134
+ * is spliced into a remote shell string. Shell quoting has been the single most
135
+ * common source of bugs in this project.
136
+ */
137
+ export declare class SshExec implements Exec {
138
+ #private;
139
+ private readonly target;
140
+ readonly host: string;
141
+ constructor(target: SshTarget);
142
+ /** Release the multiplexed connection and remove the key file. */
143
+ close(): void;
144
+ reachable(): boolean;
145
+ run(cmd: string, args: string[], opts?: ExecOptions): ExecResult;
146
+ sudo(args: string[], input?: string, opts?: ExecOptions): string;
147
+ sudoCombined(args: string[], opts?: ExecOptions): {
148
+ output: string;
149
+ status: number;
150
+ };
151
+ runScript(script: string, opts?: {
152
+ sudo?: boolean;
153
+ } & ExecOptions): {
154
+ output: string;
155
+ status: number;
156
+ };
157
+ readFileMaybe(path: string): string;
158
+ sudoReadFileMaybe(path: string): string;
159
+ statMaybe(path: string): {
160
+ uid: string;
161
+ gid: string;
162
+ mode: string;
163
+ mtime: number;
164
+ type: string;
165
+ } | null;
166
+ writeFileAsRoot(path: string, content: string, mode: string): void;
167
+ }
168
+ //# sourceMappingURL=exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MA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