spur-board 0.40.1 → 0.40.2
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.
- package/dist/cli.mjs +14 -3
- package/dist/{client-xhD478pB.mjs → client-Cfs2Qhd9.mjs} +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{config-C2WS3sNi.mjs → config-B2CqZZh_.mjs} +2 -2
- package/dist/daemon.mjs +73 -18
- package/dist/mcp.mjs +3 -3
- package/dist/{src-BI3t7Lzd.mjs → src-C-HpKSEK.mjs} +4 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as ERRORS, J as requiredSecretKeys, K as configSchema, Y as SLACK_BOT_SCOPES, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-
|
|
2
|
-
import { a as CliError, c as escapeTerminalControls, i as requestTokenEnrollment, n as fetchTokenStatus, o as errorExitCode, r as requestOperation, s as renderCliError } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-
|
|
1
|
+
import { F as ERRORS, J as requiredSecretKeys, K as configSchema, Y as SLACK_BOT_SCOPES, l as roleCanUseOperation, r as SYSTEMD_SERVICE_SETTINGS, u as OPERATIONS } from "./src-C-HpKSEK.mjs";
|
|
2
|
+
import { a as CliError, c as escapeTerminalControls, i as requestTokenEnrollment, n as fetchTokenStatus, o as errorExitCode, r as requestOperation, s as renderCliError } from "./client-Cfs2Qhd9.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./config-B2CqZZh_.mjs";
|
|
4
4
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -231,6 +231,16 @@ function unitFile(env, home) {
|
|
|
231
231
|
const xdg = env["XDG_CONFIG_HOME"];
|
|
232
232
|
return join(xdg && isAbsolute(xdg) ? xdg : join(home, ".config"), "systemd", "user", "spur-board.service");
|
|
233
233
|
}
|
|
234
|
+
/** Fails when group or others can access `board.sqlite`; a missing database passes. */
|
|
235
|
+
function databasePrivate(path, ports) {
|
|
236
|
+
let mode;
|
|
237
|
+
try {
|
|
238
|
+
mode = ports.secretFile(path).mode;
|
|
239
|
+
} catch {
|
|
240
|
+
return result("database.private", true, "");
|
|
241
|
+
}
|
|
242
|
+
return result("database.private", (mode & 63) === 0, "Set board.sqlite mode to 0600 with chmod 600; the daemon also sets it when it starts.");
|
|
243
|
+
}
|
|
234
244
|
function localSecrets(config, path, ports) {
|
|
235
245
|
let file;
|
|
236
246
|
try {
|
|
@@ -494,6 +504,7 @@ async function runDoctor(options = {}) {
|
|
|
494
504
|
run: (command, args) => Promise.resolve(ports.run(command, args))
|
|
495
505
|
});
|
|
496
506
|
checks.push(result("http.port", portFix === null, portFix ?? ""));
|
|
507
|
+
checks.push(databasePrivate(join(dataDirectory(env, home), "board.sqlite"), ports));
|
|
497
508
|
let remote = null;
|
|
498
509
|
try {
|
|
499
510
|
const address = resolveDaemonAddress(env, home, config.http.port);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as successEnvelopeSchema, F as ERRORS, L as errorContextSchema, R as errorEnvelopeSchema, p as renderJsonError } from "./src-
|
|
1
|
+
import { B as successEnvelopeSchema, F as ERRORS, L as errorContextSchema, R as errorEnvelopeSchema, p as renderJsonError } from "./src-C-HpKSEK.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { i as requestTokenEnrollment, n as fetchTokenStatus, r as requestOperation, t as fetchCatalogVersion } from "./client-Cfs2Qhd9.mjs";
|
|
2
2
|
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestTokenEnrollment };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as configSchema, c as buildCatalogSnapshot, q as plainHttpAllowed, u as OPERATIONS } from "./src-
|
|
2
|
-
import { a as CliError, t as fetchCatalogVersion } from "./client-
|
|
1
|
+
import { K as configSchema, c as buildCatalogSnapshot, q as plainHttpAllowed, u as OPERATIONS } from "./src-C-HpKSEK.mjs";
|
|
2
|
+
import { a as CliError, t as fetchCatalogVersion } from "./client-Cfs2Qhd9.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
package/dist/daemon.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as encodeActorId, B as successEnvelopeSchema, C as SESSION_HEALTH_STATES, D as sessionFactsSchema, E as prRefSchema, F as ERRORS, G as RESERVED_PROJECT, H as DEFAULT_LINK, I as err, J as requiredSecretKeys, K as configSchema, M as parseActorId, N as parseRef$1, O as ticketFactsSchema, P as taskKeySchema, S as eventPayloadSchemas, T as prFactsSchema, W as DEFAULT_SLACK_COMMAND, Y as SLACK_BOT_SCOPES, _ as inboundEventSchema, a as batchSchema, b as userIdSchema, c as buildCatalogSnapshot, d as turnHandedSchema, f as renderHttpProblem, g as conversationRefSchema, h as SPACE_IDS, i as AdapterError, j as errorCodeOf, k as actorIdSchema, l as roleCanUseOperation, n as BOARD_TICK_MS, o as entityRefSchema, q as plainHttpAllowed, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as interactionRefSchema, w as SESSION_STATUSES, x as EVENT_KINDS, y as messageRefSchema, z as ok } from "./src-
|
|
1
|
+
import { A as encodeActorId, B as successEnvelopeSchema, C as SESSION_HEALTH_STATES, D as sessionFactsSchema, E as prRefSchema, F as ERRORS, G as RESERVED_PROJECT, H as DEFAULT_LINK, I as err, J as requiredSecretKeys, K as configSchema, M as parseActorId, N as parseRef$1, O as ticketFactsSchema, P as taskKeySchema, S as eventPayloadSchemas, T as prFactsSchema, W as DEFAULT_SLACK_COMMAND, Y as SLACK_BOT_SCOPES, _ as inboundEventSchema, a as batchSchema, b as userIdSchema, c as buildCatalogSnapshot, d as turnHandedSchema, f as renderHttpProblem, g as conversationRefSchema, h as SPACE_IDS, i as AdapterError, j as errorCodeOf, k as actorIdSchema, l as roleCanUseOperation, n as BOARD_TICK_MS, o as entityRefSchema, q as plainHttpAllowed, s as sourceCursorSchema, t as assertNever, u as OPERATIONS, v as interactionRefSchema, w as SESSION_STATUSES, x as EVENT_KINDS, y as messageRefSchema, z as ok } from "./src-C-HpKSEK.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
-
import { closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
|
|
4
|
+
import { chmodSync, closeSync, existsSync, fchmodSync, fstatSync, fsyncSync, ftruncateSync, linkSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
|
-
import path, { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6
|
+
import path, { basename, dirname, isAbsolute, join, normalize, resolve } from "node:path";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import YAML from "yaml";
|
|
9
9
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -82,15 +82,15 @@ function checkpoint(file) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* Copies a database into one self-contained file at `target`, with the source's rows, schema
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* then checkpointed, so its main file holds every committed row. The target is
|
|
89
|
-
* `<target>.replaced-<uuid>`, its empty `-wal` and `-shm` are removed, the partial
|
|
90
|
-
* over `target`, and only then is the link removed. A kill at any point leaves a
|
|
91
|
-
* database at `target`, the old one or the new one. A failure before the rename leaves the
|
|
92
|
-
* target as it is, with no `.partial` and no link. `step` is called after each step; tests use
|
|
93
|
-
*
|
|
85
|
+
* Copies a database into one self-contained file at `target`, with the source's rows, schema and
|
|
86
|
+
* `user_version`. `source` is a path or an open connection. The copy is written with `VACUUM INTO`
|
|
87
|
+
* to `<target>.partial`, created at mode 0600, and synced. An existing target with a non-empty
|
|
88
|
+
* `-wal` is then checkpointed, so its main file holds every committed row. The target is
|
|
89
|
+
* hard-linked to `<target>.replaced-<uuid>`, its empty `-wal` and `-shm` are removed, the partial
|
|
90
|
+
* is renamed over `target`, and only then is the link removed. A kill at any point leaves a
|
|
91
|
+
* complete database at `target`, the old one or the new one. A failure before the rename leaves the
|
|
92
|
+
* target as it is, with no `.partial` and no link. `step` is called after each step; tests use it
|
|
93
|
+
* to stand in for a kill.
|
|
94
94
|
*
|
|
95
95
|
* Opens `target` only to checkpoint a non-empty `-wal`. Creates no directory, takes no lock and
|
|
96
96
|
* checks no version: the caller creates the directory and holds the board lock or owns the
|
|
@@ -105,6 +105,7 @@ function copyDatabase(source, target, step = () => void 0) {
|
|
|
105
105
|
let linked = false;
|
|
106
106
|
try {
|
|
107
107
|
rmSync(partial, { force: true });
|
|
108
|
+
closeSync(openSync(partial, "wx", 384));
|
|
108
109
|
db.prepare("VACUUM INTO ?").run(partial);
|
|
109
110
|
fsyncFile(partial);
|
|
110
111
|
step("partial");
|
|
@@ -160,6 +161,38 @@ function backupPath(file, from) {
|
|
|
160
161
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "");
|
|
161
162
|
return `${file}.v${String(from)}.${stamp}.bak`;
|
|
162
163
|
}
|
|
164
|
+
const BACKUP_SUFFIX = /^(\d+)\.(\d{8}T\d{9}Z)\.bak$/;
|
|
165
|
+
/**
|
|
166
|
+
* Keeps the newest `KEEP_BACKUPS` migration backups of `file` (`<name>.v<n>.<stamp>.bak` beside
|
|
167
|
+
* it, by stamp, then version) at mode 0600 and removes the rest. `protect`, when it is one of
|
|
168
|
+
* them, is always kept and counts toward the limit: the clock can step back, so the backup just
|
|
169
|
+
* written may not carry the newest stamp. Anything else is left alone: other names, and
|
|
170
|
+
* directories or symlinks with a backup name. Every backup is set to 0600 first, and a failed
|
|
171
|
+
* chmod throws. Removing an old backup is best effort: one that cannot be deleted stays,
|
|
172
|
+
* owner-only, until a later prune.
|
|
173
|
+
*/
|
|
174
|
+
function pruneBackups(file, protect) {
|
|
175
|
+
const dir = dirname(file);
|
|
176
|
+
const prefix = `${basename(file)}.v`;
|
|
177
|
+
const shielded = protect === void 0 ? void 0 : normalize(protect);
|
|
178
|
+
const candidates = readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.startsWith(prefix)).flatMap(({ name }) => {
|
|
179
|
+
const match = BACKUP_SUFFIX.exec(name.slice(prefix.length));
|
|
180
|
+
if (match?.[1] === void 0 || match[2] === void 0) return [];
|
|
181
|
+
return [{
|
|
182
|
+
path: join(dir, name),
|
|
183
|
+
version: Number(match[1]),
|
|
184
|
+
stamp: match[2]
|
|
185
|
+
}];
|
|
186
|
+
}).sort((a, b) => a.stamp === b.stamp ? b.version - a.version : a.stamp < b.stamp ? 1 : -1);
|
|
187
|
+
const ordered = [...candidates.filter((backup) => backup.path === shielded), ...candidates.filter((backup) => backup.path !== shielded)];
|
|
188
|
+
for (const backup of ordered) chmodSync(backup.path, 384);
|
|
189
|
+
for (const backup of ordered.slice(5)) removeQuietly(backup.path);
|
|
190
|
+
}
|
|
191
|
+
function removeQuietly(path) {
|
|
192
|
+
try {
|
|
193
|
+
rmSync(path, { force: true });
|
|
194
|
+
} catch {}
|
|
195
|
+
}
|
|
163
196
|
/**
|
|
164
197
|
* Reads `user_version` and throws if it is above `target`. Only reads, so it is safe to call
|
|
165
198
|
* before any PRAGMA that could rewrite the file.
|
|
@@ -192,6 +225,7 @@ function migrate(db, migrations) {
|
|
|
192
225
|
if (!(db.prepare("SELECT count(*) FROM sqlite_schema").pluck().get() === 0)) {
|
|
193
226
|
backup = backupPath(db.name, from);
|
|
194
227
|
copyDatabase(db, backup);
|
|
228
|
+
pruneBackups(db.name, backup);
|
|
195
229
|
}
|
|
196
230
|
const kept = `database kept at v${String(from)}${backup === null ? "" : `, backup at ${backup}`}`;
|
|
197
231
|
db.pragma("foreign_keys = OFF");
|
|
@@ -228,6 +262,24 @@ function migrate(db, migrations) {
|
|
|
228
262
|
function connect(file) {
|
|
229
263
|
return new Database(file, { timeout: 5e3 });
|
|
230
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Creates `file` if it is missing and sets it and any existing `-wal` and `-shm` to 0600,
|
|
267
|
+
* whatever the umask. Changes no bytes, so it is safe before `assertNotNewer`. Throws if a mode
|
|
268
|
+
* cannot be set, e.g. a file owned by another user.
|
|
269
|
+
*/
|
|
270
|
+
function makePrivate(file) {
|
|
271
|
+
const fd = openSync(file, "a", 384);
|
|
272
|
+
try {
|
|
273
|
+
fchmodSync(fd, 384);
|
|
274
|
+
} finally {
|
|
275
|
+
closeSync(fd);
|
|
276
|
+
}
|
|
277
|
+
for (const sidecar of [`${file}-wal`, `${file}-shm`]) try {
|
|
278
|
+
chmodSync(sidecar, 384);
|
|
279
|
+
} catch (error) {
|
|
280
|
+
if (error.code !== "ENOENT") throw error;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
231
283
|
/** WAL, NORMAL sync and foreign keys on. Switching to WAL rewrites the file header. */
|
|
232
284
|
function configure(database) {
|
|
233
285
|
database.pragma("journal_mode = WAL");
|
|
@@ -235,17 +287,20 @@ function configure(database) {
|
|
|
235
287
|
database.pragma("foreign_keys = ON");
|
|
236
288
|
}
|
|
237
289
|
/**
|
|
238
|
-
* Opens `file` and applies pending migrations.
|
|
239
|
-
*
|
|
240
|
-
*
|
|
290
|
+
* Opens `file` and applies pending migrations. The file, its `-wal` and `-shm` and its migration
|
|
291
|
+
* backups are kept at mode 0600, and only the newest `KEEP_BACKUPS` backups are kept. A database
|
|
292
|
+
* newer than the code is refused before the WAL switch, so its file is left byte for byte as it
|
|
293
|
+
* was; only its mode may change. Throws, with the file closed, if anything fails.
|
|
241
294
|
*/
|
|
242
295
|
function openStore(file) {
|
|
243
296
|
const migrations = readMigrations(migrationsDir);
|
|
297
|
+
makePrivate(file);
|
|
244
298
|
const database = connect(file);
|
|
245
299
|
let migration;
|
|
246
300
|
try {
|
|
247
301
|
assertNotNewer(database, migrations.length);
|
|
248
302
|
configure(database);
|
|
303
|
+
pruneBackups(file);
|
|
249
304
|
migration = migrate(database, migrations);
|
|
250
305
|
} catch (error) {
|
|
251
306
|
database.close();
|
|
@@ -15940,7 +15995,7 @@ function issueNumber(ref, repo) {
|
|
|
15940
15995
|
if (!Number.isSafeInteger(value) || value <= 0) throw new AdapterError("transient", MALFORMED$1);
|
|
15941
15996
|
return value;
|
|
15942
15997
|
}
|
|
15943
|
-
function normalize(issue, trackerId, repo, inFilter) {
|
|
15998
|
+
function normalize$1(issue, trackerId, repo, inFilter) {
|
|
15944
15999
|
if (issue.pull_request !== void 0) throw new AdapterError("transient", "A pull request cannot be a tracker ticket");
|
|
15945
16000
|
return {
|
|
15946
16001
|
trackerId,
|
|
@@ -16121,7 +16176,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
16121
16176
|
for (const value of listed) {
|
|
16122
16177
|
const issue = parseWire(issueWire$1, value, MALFORMED$1);
|
|
16123
16178
|
if (issue.pull_request !== void 0) continue;
|
|
16124
|
-
facts.set(issue.number, normalize(issue, options.id, options.tracker.repo, true));
|
|
16179
|
+
facts.set(issue.number, normalize$1(issue, options.id, options.tracker.repo, true));
|
|
16125
16180
|
}
|
|
16126
16181
|
const entities = [];
|
|
16127
16182
|
for (const ref of ctx.observe.tickets) {
|
|
@@ -16137,7 +16192,7 @@ function createGithubIssuesAdapter(options) {
|
|
|
16137
16192
|
});
|
|
16138
16193
|
continue;
|
|
16139
16194
|
}
|
|
16140
|
-
fact = normalize(detail, options.id, options.tracker.repo, matchesFilter(detail, options.tracker));
|
|
16195
|
+
fact = normalize$1(detail, options.id, options.tracker.repo, matchesFilter(detail, options.tracker));
|
|
16141
16196
|
facts.set(issueNo, fact);
|
|
16142
16197
|
} catch (error) {
|
|
16143
16198
|
if (error instanceof GithubIssuesHttpError && (error.status === 404 || error.status === 410)) {
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as ERRORS, m as renderMcpError, u as OPERATIONS } from "./src-
|
|
2
|
-
import { a as CliError, r as requestOperation } from "./client-
|
|
3
|
-
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-
|
|
1
|
+
import { F as ERRORS, m as renderMcpError, u as OPERATIONS } from "./src-C-HpKSEK.mjs";
|
|
2
|
+
import { a as CliError, r as requestOperation } from "./client-Cfs2Qhd9.mjs";
|
|
3
|
+
import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./config-B2CqZZh_.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -3199,7 +3199,8 @@ var AdapterError = class extends Error {
|
|
|
3199
3199
|
*
|
|
3200
3200
|
* The daemon notifies systemd by spawning `systemd-notify`, so the notifying process is a child
|
|
3201
3201
|
* of the main PID: the unit needs `NotifyAccess=all`. `WATCHDOG_MS` is three board ticks, so a
|
|
3202
|
-
* single slow or failed tick does not restart the daemon.
|
|
3202
|
+
* single slow or failed tick does not restart the daemon. `UMask=0077` makes every file the daemon
|
|
3203
|
+
* creates owner-only.
|
|
3203
3204
|
*/
|
|
3204
3205
|
const BOARD_TICK_MS = 6e4;
|
|
3205
3206
|
const SYSTEMD_SERVICE_SETTINGS = [
|
|
@@ -3208,7 +3209,8 @@ const SYSTEMD_SERVICE_SETTINGS = [
|
|
|
3208
3209
|
`WatchdogSec=${String(3 * BOARD_TICK_MS)}ms`,
|
|
3209
3210
|
"Restart=on-failure",
|
|
3210
3211
|
"RestartSec=5s",
|
|
3211
|
-
"TimeoutStopSec=15s"
|
|
3212
|
+
"TimeoutStopSec=15s",
|
|
3213
|
+
"UMask=0077"
|
|
3212
3214
|
];
|
|
3213
3215
|
//#endregion
|
|
3214
3216
|
//#region ../contracts/src/index.ts
|