pi-straw-boss 0.77.1 → 0.77.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.
@@ -17191,6 +17191,13 @@ var noticeName = (name2) => name2.replace(/\.json$/, ".notice.json");
17191
17191
  var PAST = "#";
17192
17192
  var changedAt = (held) => held.file.states.at(-1)?.at ?? "";
17193
17193
  var firstLine = (error) => String(error.stderr || error.message).trim().split("\n")[0].slice(0, 200);
17194
+ function reachClass(line3) {
17195
+ if (/could not read (?:Username|Password)|terminal prompts disabled|Authentication failed|Access denied|Permission denied \(publickey|returned error: 40[13]|Host key verification failed/i.test(line3)) return "auth";
17196
+ if (/Repository not found|does not appear to be a git repository|returned error: 404|not found/i.test(line3)) return "repository-not-found";
17197
+ if (/Could not resolve host|Connection refused|Connection timed out|timed out|Failed to connect|Network is unreachable|Could not read from remote repository|unable to access|Connection reset|Connection closed/i.test(line3)) return "connection";
17198
+ return void 0;
17199
+ }
17200
+ var unreached = (text11, line3) => Object.assign(refusal3(text11), { reach: reachClass(line3) });
17194
17201
  var same3 = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
17195
17202
  var MIRROR_FLAGS = ["-c", "core.commitGraph=false", "-c", "fetch.writeCommitGraph=false", "-c", "gc.auto=0", "-c", "maintenance.auto=false", "-c", "core.multiPackIndex=false"];
17196
17203
  var FETCH_FLAGS = ["-c", "transfer.fsckObjects=true", "-c", "fetch.fsckObjects=true", "-c", "fetch.unpackLimit=1", "-c", "transfer.unpackLimit=1"];
@@ -17633,12 +17640,13 @@ var CarBook = class {
17633
17640
  * A car lands once (#15): `received` is refused for a head that git, run here, finds on the base's branch of the project's remote already. Nothing the book remembers is asked, so it holds after a restart, when the book no longer knows that the car landed, and
17634
17641
  * for a head somebody pushed to the base by hand. The remote and the base are read now: the remote of the checkout of the integrator's workspace (where an open reads it) and the app's `integration.base` in that checkout's apps.json. The fetch is the one of
17635
17642
  * `landed`, into a mirror of its own. When the checkout's remote cannot be read nothing is checked (`cars-received-unchecked` is logged, and the integrator's tool says so): an open reads the remote from the same checkout, so a train of such a project has no remote and
17636
- * cannot set `landed` either. When the remote is read but the app names no usable `integration.base`, `received` is refused (car-forward-F003; the boss's rule that a car is never landed twice wins), and so it is when git fails. A head that is not in the base's history is the usual car. A car merged by squash or rebase has no head on the base and is not found here.
17643
+ * cannot set `landed` either. When the remote is read but the app names no usable `integration.base`, `received` is refused (car-forward-F003; the boss's rule that a car is never landed twice wins), and so it is when git fails for any reason but reaching the remote. When
17644
+ * `ls-remote` or the fetch fails because the remote cannot be reached or authenticated (the server's git has no credential helper, RR3-F002; repository not found counts), the car is received unchecked with that class as the reason (0.77.2). A head that is not in the base's history is the usual car. A car merged by squash or rebase has no head on the base and is not found here.
17637
17645
  */
17638
17646
  async unlanded(project, app, head, label, look3) {
17639
17647
  const where = await this.baseOf(look3, app);
17640
17648
  if ("unread" in where) {
17641
- this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40) });
17649
+ this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40), reason: "unread" });
17642
17650
  return { unchecked: `the remote of the integrator's workspace checkout could not be read, so whether head ${head.slice(0, 12)} is on the base already was not checked` };
17643
17651
  }
17644
17652
  if ("refused" in where) {
@@ -17665,6 +17673,11 @@ var CarBook = class {
17665
17673
  }
17666
17674
  });
17667
17675
  } catch (error) {
17676
+ const reach = error.reach;
17677
+ if (reach) {
17678
+ this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40), reason: reach });
17679
+ return { unchecked: `the server could not reach the project's remote (${reach}: ${error.message.replace(/^sb: /, "").slice(0, 200)}), so whether head ${head.slice(0, 12)} is on ${base} already was not checked` };
17680
+ }
17668
17681
  const word = `sb: car ${label} is not received: whether its head ${head.slice(0, 12)} is on ${base} of the project's remote already could not be checked (${error.message.replace(/^sb: /, "").slice(0, 300)}). A car that is on the base is never received again, so the check has to run: try again`;
17669
17682
  this.d.log?.("cars-received-refused", { project, car: label.slice(0, 40), reason: word.slice(0, 200) });
17670
17683
  throw refusal3(word);
@@ -17716,7 +17729,8 @@ var CarBook = class {
17716
17729
  try {
17717
17730
  listed2 = await this.d.git(parse3(this.d.dir).root, [...REMOTE_FLAGS, "ls-remote", "--exit-code", "--", url, ref], env);
17718
17731
  } catch (error) {
17719
- throw refusal3(`sb: git ls-remote of ${base} from the project's remote failed: ${firstLine(error)}`);
17732
+ const line3 = firstLine(error);
17733
+ throw unreached(`sb: git ls-remote of ${base} from the project's remote failed: ${line3}`, line3);
17720
17734
  }
17721
17735
  const tip = listed2.split("\n").map((l) => l.split(" ")).find(([, name2]) => name2 === ref)?.[0];
17722
17736
  if (!tip || !/^[0-9a-f]{40,64}$/.test(tip)) throw refusal3(`sb: the project's remote lists no branch ${base}`);
@@ -17731,7 +17745,8 @@ var CarBook = class {
17731
17745
  try {
17732
17746
  await inMirror(...REMOTE_FLAGS, ...FETCH_FLAGS, "fetch", "--no-tags", "--no-recurse-submodules", "--", url, `+${ref}:${mine}`);
17733
17747
  } catch (error) {
17734
- throw refusal3(`sb: git fetch of ${base} from the project's remote failed: ${firstLine(error)}`);
17748
+ const line3 = firstLine(error);
17749
+ throw unreached(`sb: git fetch of ${base} from the project's remote failed: ${line3}`, line3);
17735
17750
  }
17736
17751
  const fetched = inspectMirror(mirror, code, "fetch", fresh.look);
17737
17752
  if (fetched.problems.length) throw tampered(fetched.problems);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-straw-boss",
3
- "version": "0.77.1",
3
+ "version": "0.77.2",
4
4
  "description": "Straw Boss coordination for pi in Herdr: sessions join a tab's net by choice, the first joiner is its main agent, a workspace tower opens on demand with a live monitoring dashboard, and boss_broadcast reaches the rest",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -115,6 +115,15 @@ const noticeName = (name: string) => name.replace(/\.json$/, ".notice.json");
115
115
  const PAST = "#";
116
116
  const changedAt = (held: Held) => held.file.states.at(-1)?.at ?? "";
117
117
  const firstLine = (error: unknown) => String((error as { stderr?: unknown }).stderr || (error as Error).message).trim().split("\n")[0]!.slice(0, 200);
118
+ /** Why git could not reach a remote, read from its first line of stderr; undefined for any other failure. Only `received` acts on it (0.77.2). */
119
+ export function reachClass(line: string): "auth" | "connection" | "repository-not-found" | undefined {
120
+ if (/could not read (?:Username|Password)|terminal prompts disabled|Authentication failed|Access denied|Permission denied \(publickey|returned error: 40[13]|Host key verification failed/i.test(line)) return "auth";
121
+ if (/Repository not found|does not appear to be a git repository|returned error: 404|not found/i.test(line)) return "repository-not-found";
122
+ if (/Could not resolve host|Connection refused|Connection timed out|timed out|Failed to connect|Network is unreachable|Could not read from remote repository|unable to access|Connection reset|Connection closed/i.test(line)) return "connection";
123
+ return undefined;
124
+ }
125
+ /** A refusal of a remote git could not reach: `reach` names the class. */
126
+ const unreached = (text: string, line: string) => Object.assign(refusal(text), { reach: reachClass(line) });
118
127
  const same = (a: readonly string[], b: readonly string[]) => a.length === b.length && a.every((x, i) => x === b[i]);
119
128
  /** git's settings for the mirror: no commit-graph, multi-pack-index, or automatic gc is read or written, so nothing but the objects the fetch hashed itself decides the answer. */
120
129
  const MIRROR_FLAGS = ["-c", "core.commitGraph=false", "-c", "fetch.writeCommitGraph=false", "-c", "gc.auto=0", "-c", "maintenance.auto=false", "-c", "core.multiPackIndex=false"];
@@ -540,12 +549,13 @@ export class CarBook {
540
549
  * A car lands once (#15): `received` is refused for a head that git, run here, finds on the base's branch of the project's remote already. Nothing the book remembers is asked, so it holds after a restart, when the book no longer knows that the car landed, and
541
550
  * for a head somebody pushed to the base by hand. The remote and the base are read now: the remote of the checkout of the integrator's workspace (where an open reads it) and the app's `integration.base` in that checkout's apps.json. The fetch is the one of
542
551
  * `landed`, into a mirror of its own. When the checkout's remote cannot be read nothing is checked (`cars-received-unchecked` is logged, and the integrator's tool says so): an open reads the remote from the same checkout, so a train of such a project has no remote and
543
- * cannot set `landed` either. When the remote is read but the app names no usable `integration.base`, `received` is refused (car-forward-F003; the boss's rule that a car is never landed twice wins), and so it is when git fails. A head that is not in the base's history is the usual car. A car merged by squash or rebase has no head on the base and is not found here.
552
+ * cannot set `landed` either. When the remote is read but the app names no usable `integration.base`, `received` is refused (car-forward-F003; the boss's rule that a car is never landed twice wins), and so it is when git fails for any reason but reaching the remote. When
553
+ * `ls-remote` or the fetch fails because the remote cannot be reached or authenticated (the server's git has no credential helper, RR3-F002; repository not found counts), the car is received unchecked with that class as the reason (0.77.2). A head that is not in the base's history is the usual car. A car merged by squash or rebase has no head on the base and is not found here.
544
554
  */
545
555
  private async unlanded(project: string, app: string, head: string, label: string, look: Look): Promise<{ unchecked?: string }> {
546
556
  const where = await this.baseOf(look, app);
547
557
  if ("unread" in where) {
548
- this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40) });
558
+ this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40), reason: "unread" });
549
559
  return { unchecked: `the remote of the integrator's workspace checkout could not be read, so whether head ${head.slice(0, 12)} is on the base already was not checked` };
550
560
  }
551
561
  if ("refused" in where) {
@@ -565,6 +575,12 @@ export class CarBook {
565
575
  }
566
576
  });
567
577
  } catch (error) {
578
+ // The remote could not be reached or would not let the server in (its git has no credential helper, RR3-F002): the boss's 0.77.2 rule receives the car unchecked and says why.
579
+ const reach = (error as { reach?: string }).reach;
580
+ if (reach) {
581
+ this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40), reason: reach });
582
+ return { unchecked: `the server could not reach the project's remote (${reach}: ${(error as Error).message.replace(/^sb: /, "").slice(0, 200)}), so whether head ${head.slice(0, 12)} is on ${base} already was not checked` };
583
+ }
568
584
  const word = `sb: car ${label} is not received: whether its head ${head.slice(0, 12)} is on ${base} of the project's remote already could not be checked (${(error as Error).message.replace(/^sb: /, "").slice(0, 300)}). A car that is on the base is never received again, so the check has to run: try again`;
569
585
  this.d.log?.("cars-received-refused", { project, car: label.slice(0, 40), reason: word.slice(0, 200) });
570
586
  throw refusal(word);
@@ -610,14 +626,14 @@ export class CarBook {
610
626
  try {
611
627
  // The tip, from no repository: git reads no repository configuration there.
612
628
  let listed: string;
613
- try { listed = await this.d.git(parse(this.d.dir).root, [...REMOTE_FLAGS, "ls-remote", "--exit-code", "--", url, ref], env); } catch (error) { throw refusal(`sb: git ls-remote of ${base} from the project's remote failed: ${firstLine(error)}`); }
629
+ try { listed = await this.d.git(parse(this.d.dir).root, [...REMOTE_FLAGS, "ls-remote", "--exit-code", "--", url, ref], env); } catch (error) { const line = firstLine(error); throw unreached(`sb: git ls-remote of ${base} from the project's remote failed: ${line}`, line); }
614
630
  const tip = listed.split("\n").map((l) => l.split("\t")).find(([, name]) => name === ref)?.[0];
615
631
  if (!tip || !/^[0-9a-f]{40,64}$/.test(tip)) throw refusal(`sb: the project's remote lists no branch ${base}`);
616
632
  try { await this.d.git(mirror, ["init", "--bare", "-q", "--template=", "."]); } catch (error) { throw refusal(`sb: the server's mirror for project ${project} cannot be made: ${firstLine(error)}`); }
617
633
  const inMirror = (...args: string[]) => this.d.git(mirror, ["--git-dir", mirror, ...MIRROR_FLAGS, ...args], env);
618
634
  const fresh = inspectMirror(mirror, code, "init");
619
635
  if (fresh.problems.length) throw tampered(fresh.problems);
620
- try { await inMirror(...REMOTE_FLAGS, ...FETCH_FLAGS, "fetch", "--no-tags", "--no-recurse-submodules", "--", url, `+${ref}:${mine}`); } catch (error) { throw refusal(`sb: git fetch of ${base} from the project's remote failed: ${firstLine(error)}`); }
636
+ try { await inMirror(...REMOTE_FLAGS, ...FETCH_FLAGS, "fetch", "--no-tags", "--no-recurse-submodules", "--", url, `+${ref}:${mine}`); } catch (error) { const line = firstLine(error); throw unreached(`sb: git fetch of ${base} from the project's remote failed: ${line}`, line); }
621
637
  const fetched = inspectMirror(mirror, code, "fetch", fresh.look);
622
638
  if (fetched.problems.length) throw tampered(fetched.problems);
623
639
  const got = (await inMirror("rev-parse", "--verify", "-q", mine)).trim();