@inixiative/config 0.5.255 → 0.5.257

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/README.md CHANGED
@@ -64,7 +64,7 @@ One version of `@inixiative/config` names one coherent state of the inixiative p
64
64
  }
65
65
  ```
66
66
 
67
- A lane is a release cascade with its own blessed set. `primitives` (field-map, json-rules, permissions, transitions, rules-builder, prisma-map, atlas, gloss) ships first; `agentic` (signet → archive, signet → kcp, signet → integrations, agent-session → foundry-core → foundry → foundry-acp) builds on the primitives' blessed set and never the reverse. `check` holds every repo to the union of all lanes, so a repo that mixes both answers to both.
67
+ A lane is a release cascade with its own blessed set. `primitives` (field-map, json-rules, permissions, transitions, rules-builder, prisma-map, atlas, gloss) ships first; `agentic` (signet → archive, signet → kcp, signet → integrations, infra, agent-session → foundry-core → foundry → foundry-acp) builds on the primitives' blessed set and never the reverse. `check` holds every repo to the union of all lanes, so a repo that mixes both answers to both.
68
68
 
69
69
  TypeScript 6.0 notes, discovered by this repo's fixture suite:
70
70
 
@@ -216,6 +216,6 @@ One agent runs every train: the release conductor, a Foundry schedule on this re
216
216
  Two lanes, each publishing in dependency order, with config last:
217
217
 
218
218
  - **primitives:** for example field-map → json-rules → permissions → transitions → rules-builder, plus prisma-map (retiring into field-map), atlas and gloss. Consumers: template, kingdom.
219
- - **agentic:** signet, kcp (the Kingdom CLI proxy, on signet), integrations (the public provider catalog, on signet), archive and agent-session, then foundry-core → foundry → foundry-acp (foundry depends on archive), built on the primitives' blessed set. foundry-core, foundry and foundry-acp publish from the foundry monorepo's `packages/core`, `packages/foundry` and `packages/acp`. Consumers: oracle (a private leaf), kingdom, template (for integrations).
219
+ - **agentic:** signet, kcp (the Kingdom CLI proxy, on signet), integrations (the public provider catalog, on signet), infra (stateless hosting drivers, no inixiative dependencies), archive and agent-session, then foundry-core → foundry → foundry-acp (foundry depends on archive), built on the primitives' blessed set. foundry-core, foundry and foundry-acp publish from the foundry monorepo's `packages/core`, `packages/foundry` and `packages/acp`. Consumers: oracle (a private leaf), kingdom, template (for integrations; its `init` moves onto infra in INFRA-050).
220
220
 
221
221
  A release is `train` (or `train --lane=agentic` to leave the primitives alone): bump the package's version on its default branch, then run the train. `train` automates the whole walk, this package and the consumer bumps included. Downstream repos pick up toolchain changes via `sync`.
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  writeFileSync as writeFileSync3
13
13
  } from "fs";
14
14
  import { hostname as hostname2, tmpdir } from "os";
15
- import { basename, dirname as dirname4, join as join4, resolve as resolve2 } from "path";
15
+ import { basename as basename2, dirname as dirname4, join as join4, resolve as resolve2 } from "path";
16
16
 
17
17
  // src/args.ts
18
18
  import { parseArgs } from "util";
@@ -1126,8 +1126,8 @@ var parseCommandLine = (argv) => {
1126
1126
  // src/bounded.ts
1127
1127
  import { spawn, spawnSync as spawnSync2 } from "child_process";
1128
1128
  import { mkdirSync as mkdirSync2 } from "fs";
1129
- import { constants, homedir as homedir2 } from "os";
1130
- import { dirname as dirname2, join as join2 } from "path";
1129
+ import { constants, cpus, homedir as homedir2, totalmem } from "os";
1130
+ import { basename, dirname as dirname2, join as join2 } from "path";
1131
1131
  var DEFAULT_BOUNDS = {
1132
1132
  seconds: 40 * 60,
1133
1133
  memoryBytes: 12 * 2 ** 30,
@@ -1137,7 +1137,27 @@ var INSIDE_BOUNDED = "INIXIATIVE_BOUNDED";
1137
1137
  var TIME_LIMIT_EXIT_CODE = 124;
1138
1138
  var checkLockPath = () => join2(homedir2(), ".foundry", "check.lock");
1139
1139
  var LOCK_WAIT_EXIT_CODE = 75;
1140
- var underLock = (path, seconds, command2) => process.platform === "linux" ? ["flock", "-o", "-E", String(LOCK_WAIT_EXIT_CODE), "-w", String(seconds), path, ...command2] : ["lockf", "-k", "-s", "-t", String(seconds), path, ...command2];
1140
+ var MAX_CHECK_SLOTS = 8;
1141
+ var defaultCheckSlots = (cpuCount = cpus().length, totalMemoryBytes = totalmem(), envValue = process.env.INIXIATIVE_CHECK_SLOTS) => {
1142
+ if (envValue !== void 0 && envValue.trim() !== "") {
1143
+ const parsed = Number(envValue.trim());
1144
+ if (Number.isInteger(parsed) && parsed >= 1) return Math.min(parsed, MAX_CHECK_SLOTS);
1145
+ }
1146
+ if (cpuCount >= 8 && totalMemoryBytes >= 32 * 2 ** 30) return 3;
1147
+ if (cpuCount >= 4 && totalMemoryBytes >= 16 * 2 ** 30) return 2;
1148
+ return 1;
1149
+ };
1150
+ var checkSlotPaths = (basePath = checkLockPath(), slots = defaultCheckSlots()) => {
1151
+ const count = Math.max(1, Math.min(Math.floor(slots), MAX_CHECK_SLOTS));
1152
+ const dir2 = dirname2(basePath);
1153
+ const name = basename(basePath);
1154
+ const paths = [basePath];
1155
+ for (let i = 1; i < count; i++) {
1156
+ paths.push(name === "check.lock" ? join2(dir2, `check-slot-${i}.lock`) : `${basePath}.${i}`);
1157
+ }
1158
+ return paths;
1159
+ };
1160
+ var underLock = (path, seconds, command2) => process.platform === "linux" ? seconds <= 0 ? ["flock", "-n", "-o", "-E", String(LOCK_WAIT_EXIT_CODE), path, ...command2] : ["flock", "-o", "-E", String(LOCK_WAIT_EXIT_CODE), "-w", String(seconds), path, ...command2] : ["lockf", "-k", "-s", "-t", String(seconds), path, ...command2];
1141
1161
  var lockWrapperAbove = (path, from = process.ppid) => {
1142
1162
  let pid = from;
1143
1163
  for (let depth = 0; depth < 40 && pid > 1; depth++) {
@@ -1202,39 +1222,36 @@ var stopGroup = async (pgid) => {
1202
1222
  };
1203
1223
  var WITH_WATCHER = '(exec 4>&-; read _ <&3; kill -KILL 0) >/dev/null 2>&1 & exec "$@"';
1204
1224
  var HOLDING_THE_LOCK = 'echo held >&4; exec 4>&- 3<&-; "$@"; exit $?';
1225
+ var spawnBoundedAttempt = (args, cwd) => {
1226
+ const child = spawn("sh", ["-c", WITH_WATCHER, "sh", ...args], {
1227
+ cwd,
1228
+ stdio: ["inherit", "inherit", "inherit", "pipe", "pipe"],
1229
+ detached: true,
1230
+ env: { ...process.env, [INSIDE_BOUNDED]: String(process.pid) }
1231
+ });
1232
+ const exited = new Promise((done) => {
1233
+ child.on("error", (error) => done({ code: 127, reason: error.message }));
1234
+ child.on("exit", (code, signal) => done({ code: exitCodeOf(code, signal) }));
1235
+ });
1236
+ const held = new Promise((done) => child.stdio[4]?.once("data", () => done(true)));
1237
+ return { child, exited, held };
1238
+ };
1205
1239
  var runBounded = async (command2, options = {}) => {
1206
1240
  if (command2.length === 0) throw new Error("bounded: no command given");
1207
1241
  const bounds = { ...DEFAULT_BOUNDS, ...options.bounds };
1208
1242
  const say = options.say ?? ((line) => console.error(line));
1209
- const path = options.lockPath ?? checkLockPath();
1243
+ const basePath = options.lockPath ?? checkLockPath();
1244
+ const slots = options.slots ?? (options.lockPath ? 1 : defaultCheckSlots());
1245
+ const slotPaths = checkSlotPaths(basePath, slots);
1246
+ const cwd = options.cwd ?? process.cwd();
1210
1247
  const sampleMs = options.sampleMs ?? 1e4;
1211
- mkdirSync2(dirname2(path), { recursive: true });
1248
+ mkdirSync2(dirname2(basePath), { recursive: true });
1212
1249
  const holding = ["sh", "-c", HOLDING_THE_LOCK, "sh", ...command2];
1213
- const child = spawn(
1214
- "sh",
1215
- [
1216
- "-c",
1217
- WITH_WATCHER,
1218
- "sh",
1219
- ...options.lock === false ? holding : underLock(path, Math.ceil(bounds.waitSeconds), holding)
1220
- ],
1221
- {
1222
- cwd: options.cwd ?? process.cwd(),
1223
- stdio: ["inherit", "inherit", "inherit", "pipe", "pipe"],
1224
- detached: true,
1225
- env: { ...process.env, [INSIDE_BOUNDED]: String(process.pid) }
1226
- }
1227
- );
1228
- const pgid = child.pid;
1229
- const exited = new Promise((done) => {
1230
- child.on("error", (error) => done({ code: 127, reason: error.message }));
1231
- child.on("exit", (code, signal) => done({ code: exitCodeOf(code, signal) }));
1232
- });
1233
- const held = new Promise((done) => child.stdio[4]?.once("data", () => done(true)));
1250
+ let activePgid;
1251
+ let signalled = null;
1234
1252
  const stop = async () => {
1235
- if (pgid) await stopGroup(pgid);
1253
+ if (activePgid) await stopGroup(activePgid);
1236
1254
  };
1237
- let signalled = null;
1238
1255
  const stopOnSignal = [
1239
1256
  ["SIGINT", 130],
1240
1257
  ["SIGTERM", 143],
@@ -1250,25 +1267,72 @@ var runBounded = async (command2, options = {}) => {
1250
1267
  let peakBytes = 0;
1251
1268
  let heaviest = "";
1252
1269
  try {
1253
- const waiting = setTimeout(
1254
- () => say(`bounded: waiting for the machine's check lock (${path})`),
1255
- Math.min(5e3, sampleMs)
1256
- );
1257
- const first2 = await Promise.race([held, exited]);
1258
- clearTimeout(waiting);
1259
- if (first2 !== true) {
1260
- if (first2.reason !== void 0)
1261
- return { ended: "not started", code: 127, reason: first2.reason };
1262
- const ran = await Promise.race([held, sleep(200).then(() => false)]);
1263
- return !ran && first2.code === LOCK_WAIT_EXIT_CODE ? { ended: "lock wait", code: LOCK_WAIT_EXIT_CODE, path } : { ended: "exited", code: first2.code };
1270
+ let attempt = null;
1271
+ if (options.lock === false || slotPaths.length === 1) {
1272
+ const args = options.lock === false ? holding : underLock(basePath, Math.ceil(bounds.waitSeconds), holding);
1273
+ attempt = spawnBoundedAttempt(args, cwd);
1274
+ activePgid = attempt.child.pid;
1275
+ const waiting = setTimeout(
1276
+ () => say(`bounded: waiting for the machine's check lock (${basePath})`),
1277
+ Math.min(5e3, sampleMs)
1278
+ );
1279
+ const first2 = await Promise.race([attempt.held, attempt.exited]);
1280
+ clearTimeout(waiting);
1281
+ if (first2 !== true) {
1282
+ if (first2.reason !== void 0)
1283
+ return { ended: "not started", code: 127, reason: first2.reason };
1284
+ const ran = await Promise.race([attempt.held, sleep(200).then(() => false)]);
1285
+ return !ran && first2.code === LOCK_WAIT_EXIT_CODE ? { ended: "lock wait", code: LOCK_WAIT_EXIT_CODE, path: basePath } : { ended: "exited", code: first2.code };
1286
+ }
1287
+ } else {
1288
+ const waitStart = Date.now();
1289
+ const waitDeadline = waitStart + bounds.waitSeconds * 1e3;
1290
+ const announceMs = Math.min(5e3, sampleMs);
1291
+ let announced = false;
1292
+ for (; ; ) {
1293
+ let acquired = null;
1294
+ for (const slotPath of slotPaths) {
1295
+ if (signalled !== null) return { ended: "exited", code: signalled };
1296
+ const candidate = spawnBoundedAttempt(underLock(slotPath, 0, holding), cwd);
1297
+ activePgid = candidate.child.pid;
1298
+ const first2 = await Promise.race([candidate.held, candidate.exited]);
1299
+ if (first2 === true) {
1300
+ acquired = candidate;
1301
+ break;
1302
+ }
1303
+ if (first2.reason !== void 0)
1304
+ return { ended: "not started", code: 127, reason: first2.reason };
1305
+ const ran = await Promise.race([candidate.held, sleep(50).then(() => false)]);
1306
+ if (ran || first2.code !== LOCK_WAIT_EXIT_CODE) {
1307
+ return { ended: "exited", code: first2.code };
1308
+ }
1309
+ await stop();
1310
+ activePgid = void 0;
1311
+ }
1312
+ if (acquired) {
1313
+ attempt = acquired;
1314
+ break;
1315
+ }
1316
+ const remainingMs = waitDeadline - Date.now();
1317
+ if (remainingMs <= 0) {
1318
+ return { ended: "lock wait", code: LOCK_WAIT_EXIT_CODE, path: basePath };
1319
+ }
1320
+ if (!announced && Date.now() - waitStart >= announceMs) {
1321
+ announced = true;
1322
+ say(
1323
+ `bounded: waiting for a free check slot (${slotPaths.length} busy under ${dirname2(basePath)})`
1324
+ );
1325
+ }
1326
+ await sleep(Math.min(250, remainingMs));
1327
+ }
1264
1328
  }
1265
1329
  const deadline = Date.now() + bounds.seconds * 1e3;
1266
1330
  for (; ; ) {
1267
- const end = await Promise.race([exited, sleep(sampleMs).then(() => null)]);
1331
+ const end = await Promise.race([attempt.exited, sleep(sampleMs).then(() => null)]);
1268
1332
  if (end?.reason !== void 0) return { ended: "not started", code: 127, reason: end.reason };
1269
1333
  if (end) return { ended: "exited", code: end.code };
1270
- if (!pgid) continue;
1271
- const group = (options.memoryOf ?? fetchGroupMemory)(pgid);
1334
+ if (!activePgid) continue;
1335
+ const group = (options.memoryOf ?? fetchGroupMemory)(activePgid);
1272
1336
  const bytes = group.reduce((sum, entry) => sum + entry.bytes, 0);
1273
1337
  if (bytes > peakBytes) {
1274
1338
  peakBytes = bytes;
@@ -1278,7 +1342,7 @@ var runBounded = async (command2, options = {}) => {
1278
1342
  const over = bytes > bounds.memoryBytes ? "memory ceiling" : Date.now() > deadline ? "time limit" : null;
1279
1343
  if (!over) continue;
1280
1344
  await stop();
1281
- await exited;
1345
+ await attempt.exited;
1282
1346
  return {
1283
1347
  ended: over,
1284
1348
  code: over === "time limit" ? TIME_LIMIT_EXIT_CODE : 137,
@@ -1293,27 +1357,58 @@ var runBounded = async (command2, options = {}) => {
1293
1357
  }
1294
1358
  };
1295
1359
  var HOLDING_UNTIL_CLOSED = "echo held >&4; exec 4>&-; read _ <&3";
1296
- var holdCheckLock = async (options = {}) => {
1297
- const path = options.lockPath ?? checkLockPath();
1298
- const say = options.say ?? ((line) => console.error(line));
1299
- mkdirSync2(dirname2(path), { recursive: true });
1300
- const [file = "", ...args] = underLock(
1301
- path,
1302
- Math.ceil(options.waitSeconds ?? DEFAULT_BOUNDS.waitSeconds),
1303
- ["sh", "-c", HOLDING_UNTIL_CLOSED]
1304
- );
1360
+ var tryHoldOneSlot = async (slotPath, waitSeconds, say) => {
1361
+ const [file = "", ...args] = underLock(slotPath, waitSeconds, ["sh", "-c", HOLDING_UNTIL_CLOSED]);
1305
1362
  const holder = spawn(file, args, { stdio: ["ignore", "inherit", "inherit", "pipe", "pipe"] });
1306
- const waiting = setTimeout(
1307
- () => say(`train: waiting for the machine's check lock (${path})`),
1308
- 5e3
1309
- );
1363
+ const waiting = say ? setTimeout(say, 5e3) : null;
1310
1364
  const held = await new Promise((done) => {
1311
1365
  holder.stdio[4]?.once("data", () => done(true));
1312
1366
  holder.on("error", () => done(false));
1313
1367
  holder.on("exit", () => done(false));
1314
1368
  });
1315
- clearTimeout(waiting);
1316
- if (!held) return false;
1369
+ if (waiting) clearTimeout(waiting);
1370
+ if (!held) {
1371
+ holder.kill();
1372
+ return null;
1373
+ }
1374
+ return holder;
1375
+ };
1376
+ var holdCheckLock = async (options = {}) => {
1377
+ const basePath = options.lockPath ?? checkLockPath();
1378
+ const slots = options.slots ?? (options.lockPath ? 1 : defaultCheckSlots());
1379
+ const slotPaths = checkSlotPaths(basePath, slots);
1380
+ const waitSeconds = options.waitSeconds ?? DEFAULT_BOUNDS.waitSeconds;
1381
+ const say = options.say ?? ((line) => console.error(line));
1382
+ mkdirSync2(dirname2(basePath), { recursive: true });
1383
+ let holder = null;
1384
+ if (slotPaths.length === 1) {
1385
+ holder = await tryHoldOneSlot(
1386
+ basePath,
1387
+ Math.ceil(waitSeconds),
1388
+ () => say(`train: waiting for the machine's check lock (${basePath})`)
1389
+ );
1390
+ } else {
1391
+ const waitStart = Date.now();
1392
+ const waitDeadline = waitStart + waitSeconds * 1e3;
1393
+ let announced = false;
1394
+ for (; ; ) {
1395
+ for (const slotPath of slotPaths) {
1396
+ holder = await tryHoldOneSlot(slotPath, 0);
1397
+ if (holder) break;
1398
+ }
1399
+ if (holder) break;
1400
+ const remainingMs = waitDeadline - Date.now();
1401
+ if (remainingMs <= 0) return false;
1402
+ if (!announced && Date.now() - waitStart >= 5e3) {
1403
+ announced = true;
1404
+ say(
1405
+ `train: waiting for a free check slot (${slotPaths.length} busy under ${dirname2(basePath)})`
1406
+ );
1407
+ }
1408
+ await sleep(Math.min(250, remainingMs));
1409
+ }
1410
+ }
1411
+ if (!holder) return false;
1317
1412
  process.on("exit", () => holder.kill());
1318
1413
  holder.unref();
1319
1414
  for (const pipe of [holder.stdio[3], holder.stdio[4]])
@@ -1850,7 +1945,7 @@ if (command === "train") {
1850
1945
  const worktrees = [];
1851
1946
  const removeWorktree = ({ repo, path, tooling }) => {
1852
1947
  if (tooling) {
1853
- spawnSync4("bun", ["run", "worktree:destroy", basename(path), "--force"], {
1948
+ spawnSync4("bun", ["run", "worktree:destroy", basename2(path), "--force"], {
1854
1949
  cwd: repo,
1855
1950
  stdio: "inherit"
1856
1951
  });
@@ -2028,7 +2123,7 @@ if (command === "train") {
2028
2123
  };
2029
2124
  const worktree = (checkout, branch) => {
2030
2125
  const tooling = !!checkout.pkg.scripts?.["worktree:create"];
2031
- const path = tooling ? join4(checkout.dir, ".worktrees", branch.replaceAll("/", "-")) : join4(mkdtempSync(join4(tmpdir(), "inixiative-train-")), basename(checkout.dir));
2126
+ const path = tooling ? join4(checkout.dir, ".worktrees", branch.replaceAll("/", "-")) : join4(mkdtempSync(join4(tmpdir(), "inixiative-train-")), basename2(checkout.dir));
2032
2127
  const created = tooling ? spawnSync4("bun", ["run", "worktree:create", defaultBranch(checkout.dir), branch], {
2033
2128
  cwd: checkout.dir,
2034
2129
  stdio: "inherit"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inixiative/config",
3
- "version": "0.5.255",
3
+ "version": "0.5.257",
4
4
  "description": "Shared toolchain and theme for the inixiative packages: tsconfig/biome/tsup presets, theme CSS, a version manifest (BOM), and a sync/check/train CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/versions.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "@types/bun"
14
14
  ],
15
15
  "ecosystem": {
16
- "@inixiative/config": "0.5.255",
16
+ "@inixiative/config": "0.5.257",
17
17
  "@inixiative/field-map": "0.1.1",
18
18
  "@inixiative/json-rules": "3.16.0",
19
19
  "@inixiative/permissions": "0.25.0",
@@ -24,10 +24,11 @@
24
24
  "@inixiative/gloss": "0.1.1"
25
25
  },
26
26
  "agentic": {
27
- "@inixiative/signet": "0.25.0",
27
+ "@inixiative/signet": "0.29.0",
28
28
  "@inixiative/integrations": "0.2.1",
29
+ "@inixiative/infra": "0.1.1",
29
30
  "@inixiative/kcp": "0.2.3",
30
- "@inixiative/archive": "0.34.0",
31
+ "@inixiative/archive": "0.35.2",
31
32
  "@inixiative/agent-session": "0.12.0",
32
33
  "@inixiative/foundry-core": "0.5.13",
33
34
  "@inixiative/foundry": "0.5.12",
@@ -53,14 +54,20 @@
53
54
  ]
54
55
  }
55
56
  },
57
+ "holds": {
58
+ "@inixiative/integrations": {
59
+ "below": "0.3.0",
60
+ "reason": "0.3.0 removes the google and github provider keys; Kingdom's family integrations and template's Provider enum still use them",
61
+ "until": "the FEAT-034 build in template and Kingdom (after template #338)",
62
+ "owner": "inixiative-fb"
63
+ }
64
+ },
56
65
  "candidates": {
57
66
  "@inixiative/atlas": "0.5.1",
58
67
  "@inixiative/json-rules": "4.7.0",
59
68
  "@inixiative/agent-session": "0.23.0",
60
69
  "@inixiative/field-map": "0.1.2",
61
- "@inixiative/archive": "0.35.2",
62
70
  "@inixiative/permissions": "0.30.0",
63
- "@inixiative/signet": "0.29.0",
64
- "@inixiative/integrations": "0.3.0"
71
+ "@inixiative/infra": "0.1.2"
65
72
  }
66
73
  }