@nervur.org/floor 0.37.15 → 0.37.17

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/index.js CHANGED
@@ -7,7 +7,7 @@ var FLOOR_FILES = [
7
7
  "design.json",
8
8
  `{
9
9
  "name": "floor",
10
- "version": "0.37.15",
10
+ "version": "0.37.17",
11
11
  "publisher": "nervur",
12
12
  "description": "The genome's one design: plain, clean and accessible, host-agnostic, given away with the packages. Its look is the describe look.",
13
13
  "languages": [
@@ -140,7 +140,7 @@ var FLOOR_FILES = [
140
140
 
141
141
  var FLOOR_LOOK_SOURCE = `import { Faculty } from 'nervur:faculty';
142
142
  export default class FloorLook extends Faculty {
143
- static #identity = {"design":"floor","name":"nervur.floor-look","version":"0.37.15","description":"The genome's one design: plain, clean and accessible, host-agnostic, given away with the packages. Its look is the describe look.","components":["lobe","organism","surround"],"tints":["blue"],"densities":["compact","regular","roomy"]};
143
+ static #identity = {"design":"floor","name":"nervur.floor-look","version":"0.37.17","description":"The genome's one design: plain, clean and accessible, host-agnostic, given away with the packages. Its look is the describe look.","components":["lobe","organism","surround"],"tints":["blue"],"densities":["compact","regular","roomy"]};
144
144
  static #components = (() => {
145
145
  const $m = {};
146
146
  $m["_tree.ts"] = (() => {
@@ -605,8 +605,8 @@ return { "lobe": $m["lobe.ts"].default, "organism": $m["organism.ts"].default, "
605
605
 
606
606
  static blueprint = {
607
607
  name: "nervur.floor-look",
608
- version: "0.37.15",
609
- assets: "881dde08796e0798c129da7aced906277824cab7d89d1b4e22ff0b5d7444ee97",
608
+ version: "0.37.17",
609
+ assets: "bbf9e84d0ed04d4c3dd0dbca18e154be9cf66cc76995bb2b19471c7289e17852",
610
610
  ...FloorLook.#rest(),
611
611
  };
612
612
 
@@ -1236,11 +1236,11 @@ var WINDOW = {
1236
1236
  given: { design: FLOOR_DESIGN }
1237
1237
  };
1238
1238
 
1239
- var REPOS_SOURCE = 'import { Faculty } from "nervur:faculty";\n\nvar BOX = 1048576;\nvar LETTER_LIVES = 864e5;\nvar LOBE_SHARE = 4;\nvar ITEM_SIZE = 1024;\nvar CELLS_RANGE = 1e3;\nvar LOGS = 20;\nvar ARG_LONGEST = 4096;\nvar ARGS_MOST = 64;\nvar SCOPE_MOST = 16;\n\nvar ReposSkin = class _ReposSkin extends Faculty {\n static #owner = "brain";\n static #lost = "the shell runs it no more: it was lost, as to a restart of the organ";\n static #box = BOX;\n static #lives = LETTER_LIVES;\n static #logs = LOGS;\n static #repos = "repos";\n static #transfers = "transfers";\n static #marker = "nervur-marker";\n static #env = ".env";\n static #folderName = /^[a-z](?:[a-z0-9-]|\\.(?=[a-z0-9-])){0,63}$/;\n static #name = /^(?!\\.{1,2}$)(?!\\.git$)[^/\\\\\\0]+$/i;\n static #script = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,63}$/;\n static #key = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;\n static #line = /^[^\\n\\r\\0]*$/;\n static #hash = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;\n static #sha = /^[0-9a-f]{64}$/;\n static #kept = "kept";\n static #organ = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n static #as = /^(?:push|pull|(?:out|in)-[A-Za-z0-9-]{1,64})$/;\n static #tag = /^v(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$/;\n static #segment = /^[A-Za-z0-9._-]+$/;\n static #design = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;\n static #marked = `IFS= read -r m; [ "$(cat nervur-marker)" = "$m" ] || { echo "the disk\'s folder is not $1" >&2; exit 1; }; rm nervur-marker`;\n static #exact(path, under, name) {\n return `{ [ -d "${path}" ] && [ ! -L "${path}" ] && ls -1A "${under}" | grep -qxF -- "${name}"; } || { echo "the folder ${name} stands not as named under repos" >&2; exit 1; }\n`;\n }\n static #ident = "export GIT_AUTHOR_NAME=Nervur GIT_AUTHOR_EMAIL=nervur@invalid GIT_COMMITTER_NAME=Nervur GIT_COMMITTER_EMAIL=nervur@invalid\\n";\n static #lend(dir) {\n return `if [ -n "\\${NERVUR_GENOME+x}" ]; then { [ -d "$NERVUR_GENOME" ] && [ -r "$NERVUR_GENOME" ] && [ -x "$NERVUR_GENOME" ]; } || { echo "NERVUR_GENOME $NERVUR_GENOME is no folder this account can read" >&2; exit 1; }; mkdir -p "${dir}/node_modules/@nervur.org" && ln -sfn "$NERVUR_GENOME" "${dir}/node_modules/@nervur.org/genome" || exit 1; fi\n`;\n }\n static #in = `${_ReposSkin.#exact("$1", "${1%/*}", "${1##*/}")}cd "$1" || exit 1\nexport GIT_CEILING_DIRECTORIES="\\${1%/*}"\n${_ReposSkin.#ident}`;\n static #keep = `k="$2"; c="$(printf \'\\\\t\')"\n[ -n "$k" ] || { echo "a scan names where it keeps" >&2; exit 1; }\nmkdir -p "$k/.t" "$k/.o" || exit 1\ngit tag --list \'v*\' | grep -E \'^v[0-9]+\\\\.[0-9]+\\\\.[0-9]+$\' | while IFS= read -r g; do [ -e "$k/.t/$g" ] && continue; git -c core.quotePath=false ls-tree -r "$g" -- designs faculties | while IFS="$c" read -r m p; do case "$p" in designs/*|faculties/*/assets/*) ;; *) continue ;; esac; o=\\${m##* }; [ "\\${m#* }" = "blob $o" ] || continue; [ -s "$k/.o/$o" ] && continue; git cat-file blob "$o" | perl -0777 -pe \'s/\\\\r\\\\n?/\\\\n/g unless /\\\\0/\' >"$k/.w" || exit 1; s=$({ sha256sum 2>/dev/null || shasum -a 256; } <"$k/.w" | cut -d " " -f 1); mv -f "$k/.w" "$k/$s" && echo "$s" >"$k/.o/$o" || exit 1; done || exit 1; : >"$k/.t/$g" || exit 1; done || exit 1\n`;\n static #untag = `git for-each-ref --format=\'delete %(refname)\' "$r-tags/" | git update-ref --stdin`;\n static #fetched = `${_ReposSkin.#in}trap \'rm -rf "$2"\' EXIT\nr="refs/nervur/$4"\ngit update-ref -d "$r" 2>/dev/null; git update-ref -d "$r-main" 2>/dev/null; ${_ReposSkin.#untag}\ncd "$2" || exit 1\ni=0; while [ "$i" -lt "$3" ]; do cat "q$i" || exit 1; i=$((i + 1)); done > b || exit 1\ncd "$1" || exit 1\ngit fetch --quiet --no-tags "$2/b" "+main:$r" || exit 1\n`;\n static #tagged = `git fetch --quiet --no-tags "$2/b" "+refs/tags/v*:$r-tags/v*" || exit 1\nw=$(git for-each-ref --format=\'%(objecttype) %(objectname) %(refname)\' "$r-tags/" | while read -r y o n; do n=\\${n#"$r-tags/"}; if [ "$y" != commit ] || ! git merge-base --is-ancestor "$o" "$r" 2>/dev/null; then echo "the tag $n names no commit it brings"; elif e=$(git rev-parse -q --verify "refs/tags/$n^{commit}") && [ "$e" != "$o" ]; then echo "this lobe holds the tag $n on another commit: a version names one commit for ever"; fi; done)\nif [ -n "$w" ]; then git update-ref -d "$r"; ${_ReposSkin.#untag}; echo "$w" >&2; exit 1; fi\n`;\n static #bring = `${_ReposSkin.#fetched}${_ReposSkin.#tagged}c=$(git rev-parse "$r") || exit 1\nif ! h=$(git rev-parse -q --verify HEAD); then m=new\nelif git merge-base --is-ancestor "$c" "$h"; then git update-ref -d "$r"; ${_ReposSkin.#untag}; echo "$h"; echo held; exit 0\nelif git merge-base --is-ancestor "$h" "$c"; then m=forward\nelse t=$(mktemp -d) || exit 1\ngit worktree add --quiet --detach "$t/w" "$h" >/dev/null 2>&1 || exit 1\nif git -C "$t/w" merge --quiet --no-edit "$c" >/dev/null 2>&1; then c=$(git -C "$t/w" rev-parse HEAD); m=merge; else m=; fi\ngit worktree remove --force "$t/w"; rm -rf "$t"\n[ -n "$m" ] || { git update-ref -d "$r"; ${_ReposSkin.#untag}; echo "it meets a conflict with main: merge it where it is authored, and send it again" >&2; exit 1; }\nfi\ngit update-ref "$r-main" "$c" && echo "$c" && echo "$m"`;\n static #cutting = [\n \'const { execFileSync } = require("node:child_process"); const fs = require("node:fs"); const os = require("node:os"); const path = require("node:path");\',\n \'const [as = "", ...scope] = process.argv.slice(1);\',\n \'const git = (args, input, env) => execFileSync("git", args, { input: input === undefined ? "" : input, env: env === undefined ? process.env : env, maxBuffer: 1073741824, stdio: ["pipe", "pipe", "pipe"] });\',\n \'const line = (args) => git(args).toString("utf8").trim();\',\n \'const maybe = (args) => { try { return line(args); } catch { return ""; } };\',\n "const holds = (args) => { try { git(args); return true; } catch { return false; } };",\n \'const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nervur-cut-")); process.on("exit", () => fs.rmSync(tmp, { recursive: true, force: true }));\',\n \'const index = path.join(tmp, "index");\',\n \'const within = (p) => scope.some((s) => p.startsWith(s + "/"));\',\n \'const entries = (args) => git(["ls-tree", "-r", "-z", ...args]).toString("latin1").split("\\\\0").filter((e) => e !== "");\',\n \'const named = (e) => e.slice(e.indexOf("\\\\t") + 1);\',\n \'const treeOf = (all) => { fs.rmSync(index, { force: true }); const env = { ...process.env, GIT_INDEX_FILE: index }; if (all.length > 0) git(["update-index", "-z", "--index-info"], Buffer.from(all.map((e) => e + "\\\\0").join(""), "latin1"), env); return git(["write-tree"], "", env).toString("utf8").trim(); };\',\n \'const who = (header, role) => { const m = new RegExp("^" + role + " (.*) <([^>\\\\\\\\n]*)> ([0-9]+) ([-+][0-9]{4})$", "m").exec(header); if (m === null) throw new Error("its " + role + " is not as git writes it"); return m; };\',\n \'const kept = (c, tree, parent) => { const raw = git(["cat-file", "commit", c]); const at = raw.indexOf("\\\\n\\\\n"); const header = raw.subarray(0, at < 0 ? raw.length : at).toString("utf8"); const message = at < 0 ? Buffer.alloc(0) : raw.subarray(at + 2); const a = who(header, "author"); const k = who(header, "committer"); const env = { ...process.env, GIT_AUTHOR_NAME: a[1], GIT_AUTHOR_EMAIL: a[2], GIT_AUTHOR_DATE: "@" + a[3] + " " + a[4], GIT_COMMITTER_NAME: k[1], GIT_COMMITTER_EMAIL: k[2], GIT_COMMITTER_DATE: "@" + k[3] + " " + k[4] }; return git(["commit-tree", "--no-gpg-sign", tree, ...(parent === "" ? [] : ["-p", parent])], message, env).toString("utf8").trim(); };\',\n \'const walk = (commits, from) => { const seen = commits.length === 0 ? [] : git(["cat-file", "--batch-check=%(objecttype) %(objectname)"], commits.flatMap((c) => scope.map((s) => c + ":" + s)).join("\\\\n") + "\\\\n").toString("utf8").split("\\\\n"); let { head, last } = from; commits.forEach((c, i) => { const oids = scope.map((s, j) => { const [type = "", oid = ""] = (seen[i * scope.length + j] ?? "").split(" "); return type === "tree" ? oid : "-"; }); const key = oids.join(" "); if (key === last) return; last = key; const trees = scope.filter((s, j) => oids[j] !== "-"); head = kept(c, treeOf(trees.length === 0 ? [] : entries([c, "--", ...trees])), head); }); return { head, last }; };\',\n \'const main = maybe(["rev-parse", "-q", "--verify", "refs/heads/main^{commit}"]);\',\n \'const tag = process.env.NERVUR_CUT_TAG === undefined ? "" : process.env.NERVUR_CUT_TAG;\',\n \'const tagged = tag === "" ? "" : maybe(["rev-parse", "-q", "--verify", "refs/tags/" + tag + "^{commit}"]);\',\n \'if (tag !== "" && tagged === "") { process.stderr.write("this lobe holds no tag " + tag + "\\\\n"); process.exit(1); }\',\n \'const upto = tagged === "" ? null : new Set(line(["rev-list", tagged]).split("\\\\n"));\',\n \'const firsts = (main === "" ? [] : line(["rev-list", "--first-parent", "--reverse", main]).split("\\\\n").filter((c) => c !== "")).filter((c) => upto === null || upto.has(c));\',\n \'const cut = walk(firsts, { head: "", last: scope.map(() => "-").join(" ") });\'\n ].join("\\n");\n static #cut = `${_ReposSkin.#in}a=$2; t=$3; shift 3\nNERVUR_CUT_TAG="$t" node -e \'${_ReposSkin.#cutting}\nif (cut.head === "") maybe(["update-ref", "-d", "refs/nervur/cut-" + as]); else git(["update-ref", "refs/nervur/cut-" + as, cut.head]);\nprocess.stdout.write(cut.head + "\\\\n");\' -- "$a" "$@"`;\n static #graft = `${_ReposSkin.#fetched}a=$4; shift 4\nNERVUR_CUT_TAG= node -e \'${[\n _ReposSkin.#cutting,\n \'const r = "refs/nervur/" + as; const refused = (why) => { maybe(["update-ref", "-d", r]); process.stderr.write(why + "\\\\n"); process.exit(1); };\',\n \'const tip = line(["rev-parse", r]);\',\n \'if (cut.head !== "" && tip === cut.head) { maybe(["update-ref", "-d", r]); process.stdout.write(tip + "\\\\nheld\\\\n"); process.exit(0); }\',\n \'if (cut.head !== "" && !holds(["merge-base", "--is-ancestor", cut.head, tip])) refused("behind the scope\\\\u0027s head; pull first");\',\n \'const pushed = line(["rev-list", "--reverse", "--parents", cut.head === "" ? tip : cut.head + ".." + tip]).split("\\\\n").filter((l) => l !== "").map((l) => l.split(" "));\',\n "let before = cut.head;",\n \'for (const [c = "", ...parents] of pushed) { if (parents.length > 1 || (parents[0] ?? "") !== before) refused("a push into a scope is linear on its head, and " + c + " is not"); const changed = git(["diff-tree", "-r", "-z", "--name-only", "--no-commit-id", ...(before === "" ? ["--root", c] : [before, c])]).toString("latin1").split("\\\\0").filter((p) => p !== ""); const outside = changed.find((p) => !within(p)); if (outside !== undefined) refused(c + " changes " + outside + ", outside the scope"); if (changed.length === 0) refused(c + " changes nothing within the scope"); before = c; }\',\n \'const outside = main === "" ? [] : entries([main]).filter((e) => !within(named(e)));\',\n \'let grafted = main; const graft = pushed.map(([c = ""]) => { grafted = kept(c, treeOf([...outside, ...entries([c]).filter((e) => within(named(e)))]), grafted); return grafted; });\',\n \'if (walk(graft, cut).head !== tip) refused("the scope cut again answers not the commits pushed: one carries what a cut drops, as a signature");\',\n \'git(["update-ref", r + "-main", grafted]); process.stdout.write(grafted + "\\\\ngraft\\\\n" + tip + "\\\\n");\'\n ].join("\\n")}\' -- "$a" "$@"`;\n static #mask = \'const { spawn } = require("node:child_process"); const fs = require("node:fs"); const env = { ...process.env }; const values = []; let held = ""; try { held = fs.readFileSync(process.argv[1], "utf8"); } catch {} for (const line of held.split("\\\\n")) { const at = line.indexOf("="); if (at < 1 || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(line.slice(0, at))) continue; env[line.slice(0, at)] = line.slice(at + 1); if (at + 1 < line.length) values.push(line.slice(at + 1)); } const shown = values.sort((a, b) => b.length - a.length || (a < b ? -1 : a > b ? 1 : 0)); const mask = (t) => shown.reduce((s, v) => s.split(v).join("[secret]"), t); const c = spawn(process.argv[2], process.argv.slice(3), { env, stdio: ["ignore", "pipe", "pipe"] }); const pass = (from, to) => { let kept = ""; from.setEncoding("utf8"); from.on("data", (d) => { kept += d; const i = kept.lastIndexOf("\\\\n") + 1; if (i > 0) { to.write(mask(kept.slice(0, i))); kept = kept.slice(i); } }); from.on("end", () => to.write(mask(kept))); }; pass(c.stdout, process.stdout); pass(c.stderr, process.stderr); for (const s of ["SIGTERM", "SIGINT", "SIGHUP"]) process.on(s, () => c.kill(s)); c.on("error", (e) => { process.stderr.write(e.message + "\\\\n"); process.exitCode = 127; }); c.on("close", (code) => { process.exitCode = code ?? 1; });\';\n static #masked = `node -e \'${_ReposSkin.#mask}\' -- "$1/${_ReposSkin.#env}"`;\n static #scripted = `node -e \'process.exit(require("./package.json").scripts?.[process.argv[1]] ? 0 : 3)\' "$2" 2>/dev/null || { echo "the repo holds no script $2" >&2; exit 3; }\n`;\n static #queued = `q="\\${1%/*}/.gates"; mkdir -p "$q" || exit 1\nlive() { find "$q" -type f -empty -mmin +1 -exec rm -f {} + 2>/dev/null; for gt in "$q"/*; do [ -e "$gt" ] || [ -L "$gt" ] || continue; [ -f "$gt" ] && [ ! -L "$gt" ] || { rm -f "$gt"; continue; }; [ -s "$gt" ] || continue; gp=$(sed -n 1p "$gt"); gs=$(sed -n 2p "$gt"); [ -n "$gp" ] && [ "$(ps -o lstart= -p "$gp" 2>/dev/null)" = "$gs" ] || rm -f "$gt"; done; }\nwhile :; do while :; do live; n=$(ls -1 "$q" | tail -1 | sed \'s/^0*//\'); me=$(printf \'%012d\' $(( \\${n:-0} + 1 ))); ( set -C; printf \'%s\\\\n%s\\\\n\' "$$" "$(ps -o lstart= -p $$)" > "$q/$me" ) 2>/dev/null && break; done; while [ -f "$q/$me" ]; do live; [ "$(ls -1 "$q" | head -1)" = "$me" ] && break 2; sleep 0.2; done; done\n`;\n static #unpack = [\n \'const fs = require("node:fs"); const { execFileSync } = require("node:child_process");\',\n \'const held = (args) => { try { return execFileSync("git", args, { stdio: ["ignore", "pipe", "ignore"], maxBuffer: 268435456 }).toString("utf8"); } catch { return null; } };\',\n \'const at = (file) => process.argv[1] + "/" + file;\',\n \'let s = ""; process.stdin.setEncoding("utf8"); process.stdin.on("data", (d) => { s += d; }); process.stdin.on("end", () => {\',\n "const given = JSON.parse(s);",\n \'for (const [name, file] of [["parts", "parts.mjs"], ["message", "message"], ["conform", "chosen"]]) if (typeof given[name] === "string") fs.writeFileSync(at(file), given[name]);\',\n \'if (Array.isArray(given.executable)) fs.writeFileSync(at("executable"), given.executable.map((path) => path + "\\\\0").join(""));\',\n \'if (Array.isArray(given.paths)) fs.writeFileSync(at("paths"), given.paths.map((path) => path + "\\\\0").join(""));\',\n \'if (given.scoped === true) fs.writeFileSync(at("scoped"), "");\',\n \'if (!fs.existsSync(at("parts.mjs"))) { process.stderr.write("no check of the parts was given\\\\n"); process.exit(1); }\',\n \'const tag = held(["describe", "--tags", "--abbrev=0", "--match", "v*", "HEAD"]);\',\n "if (tag === null) return;",\n "const told = {};",\n \'for (const path of (held(["ls-tree", "-r", "--name-only", tag.trim()]) ?? "").split("\\\\n")) {\',\n "if (!/^(faculties|designs)\\\\/[^/]+\\\\/versions\\\\.json$/.test(path)) continue;",\n \'const text = held(["show", tag.trim() + ":" + path]); if (text !== null) told[path] = text;\',\n "}",\n \'fs.writeFileSync(at("told.json"), JSON.stringify(told));\',\n "});"\n ].join("\\n");\n static #checks = `told=\n[ ! -f "$t/told.json" ] || told="$t/told.json"\nnode "$t/parts.mjs" "$w" \\${told:+"$told"} || exit 1\nif [ -f "$t/scoped" ]; then echo "conform: skipped: a lobe holding a scope is checked by the lobe it pushes to"\nelif [ ! -f "$t/chosen" ]; then echo "conform: skipped: no conform is chosen: the check of the parts alone"\nelse k=$(cat "$t/chosen")\ngit cat-file -e "$k^{commit}" 2>/dev/null || { echo "the commit whose conform is chosen, $k, the repo holds not"; exit 1; }\nif git show "$k:tools/conform.mjs" > "$t/conform.mjs" 2>/dev/null; then node "$t/conform.mjs" "$w" || exit 1; else echo "conform: skipped: the commit chosen, $k, holds no tools/conform.mjs"; fi\nfi\n`;\n static #versioning = [\n \'const fs = require("node:fs"); const { execFileSync } = require("node:child_process");\',\n \'const of = (text) => { try { const v = JSON.parse(text).version; return typeof v === "string" ? v : null; } catch { return null; } };\',\n \'const held = (args) => { try { return execFileSync("git", args, { stdio: ["ignore", "pipe", "ignore"] }).toString("utf8"); } catch { return null; } };\',\n \'let read = null; try { read = fs.readFileSync(process.argv[1], "utf8"); } catch {}\',\n \'const now = read === null ? null : of(read); const parent = held(["show", "HEAD:package.json"]); const was = parent === null ? null : of(parent);\',\n "if (now === was) process.exit(0);",\n \'const refused = (why) => { process.stderr.write(why +"\\\\n"); process.exit(1); };\',\n "const three = /^(0|[1-9][0-9]*)\\\\.(0|[1-9][0-9]*)\\\\.(0|[1-9][0-9]*)$/;",\n \'if (now === null || !three.test(now)) refused("the root version " + (now === null ? "none" : now) + " is not three whole numbers");\',\n \'const parts = (v) => v.split(".").map((n) => BigInt(n));\',\n \'if (was !== null && three.test(was)) { const [a, b] = [parts(now), parts(was)]; const at = a.findIndex((n, i) => n !== b[i]); if (at >= 0 && a[at] < b[at]) refused("the root version " + now + " is lower than " + was + ": a version is only raised"); }\',\n \'const tag = "v" + now;\',\n \'if (held(["rev-parse", "-q", "--verify", "refs/tags/" + tag]) !== null) refused("this lobe holds the tag " + tag + " already: a version names one commit for ever");\',\n \'process.stdout.write(tag + "\\\\n");\'\n ].join("\\n");\n static #versioned = `v=\nif [ ! -f "$t/scoped" ]; then v=$(node -e \'${_ReposSkin.#versioning}\' -- "$w/package.json") || exit 1; fi\n`;\n static #unsecret = `if [ -e ${_ReposSkin.#env} ] && ! git check-ignore -q -- ${_ReposSkin.#env}; then echo "${_ReposSkin.#env} is a secret file .gitignore keeps not out: no commit holds it"; exit 1; fi\n`;\n static #staged = `if [ -f "$t/paths" ]; then\nxargs -0 git --literal-pathspecs ls-files -z --cached --others --exclude-standard -- <"$t/paths" >"$t/present" || exit 1\ncp "$t/present" "$t/changed" || exit 1\nif git rev-parse -q --verify HEAD >/dev/null; then xargs -0 git --literal-pathspecs ls-tree -r -z --name-only HEAD -- <"$t/paths" >>"$t/changed" || exit 1; fi\nb=$(git rev-parse -q --verify HEAD || git hash-object -t tree /dev/null) || exit 1\nGIT_INDEX_FILE="$t/index" git read-tree "$b" || exit 1\n[ ! -s "$t/changed" ] || GIT_INDEX_FILE="$t/index" git --literal-pathspecs add --all --pathspec-from-file="$t/changed" --pathspec-file-nul || exit 1\nGIT_INDEX_FILE="$t/index" git diff-index --cached --quiet "$b" -- && { echo "none of the paths named holds a change"; exit 1; }\nelse\ncp -p "$(git rev-parse --git-path index)" "$t/index" 2>/dev/null\nGIT_INDEX_FILE="$t/index" git add --all || exit 1\nfi\nmkdir "$t/w" && GIT_INDEX_FILE="$t/index" git checkout-index --all --prefix="$t/w/" || exit 1\nw="$t/w"\n`;\n static #taken = `if [ -f "$t/paths" ]; then { [ ! -s "$t/present" ] || git --literal-pathspecs add --all --pathspec-from-file="$t/present" --pathspec-file-nul; } && git --literal-pathspecs commit --quiet --file="$t/message" --pathspec-from-file="$t/changed" --pathspec-file-nul || exit 1\nelse git add --all && { [ ! -s "$t/executable" ] || git update-index --chmod=+x -z --stdin <"$t/executable"; } && git commit --quiet --file="$t/message" || exit 1\nfi\n`;\n static #whole = \'const fs = require("node:fs"); let s = ""; process.stdin.setEncoding("utf8"); process.stdin.on("data", (d) => { s += d; }); process.stdin.on("end", () => { const { set = {} } = JSON.parse(s || "{}"); const f = process.argv[1]; const keys = Object.keys(set).sort(); if (keys.length === 0) { fs.rmSync(f, { force: true }); return; } fs.writeFileSync(f, keys.map((key) => key + "=" + set[key] + "\\\\n").join(""), { mode: 0o600 }); fs.chmodSync(f, 0o600); });\';\n static #scripts = {\n setup: `cd "$1/repos" || exit 1\n${_ReposSkin.#marked}`,\n init: `${_ReposSkin.#exact("$1/repos/$2", "$1/repos", "$2")}cd "$1/repos/$2" || exit 1\nexport GIT_CEILING_DIRECTORIES="$1/repos"\n${_ReposSkin.#ident}${_ReposSkin.#marked}\n[ -e .git ] && { echo "the folder holds a repo already" >&2; exit 1; }\n[ -z "$(ls -A)" ] || { echo "the folder holds files: a repo is born in an empty folder" >&2; exit 1; }\ngit init --quiet -b main`,\n stand: `${_ReposSkin.#in}[ -d .git ] && [ ! -L .git ] && [ "$(git rev-parse --show-toplevel 2>/dev/null)" = "$(pwd -P)" ] || { echo "the folder holds no repo to stand on" >&2; exit 1; }\n[ "$(git branch --show-current)" = main ] || { echo "the repo is not on main" >&2; exit 1; }\nc=$(git rev-parse -q --verify refs/heads/main) || { echo "main holds no commit: a repo with none is born by init alone" >&2; exit 1; }\nt=$(mktemp -d) || exit 1\ntrap \'git -C "$1" worktree remove --force "$t/w" 2>/dev/null; rm -rf "$t"; git -C "$1" worktree prune\' EXIT\nnode -e \'${_ReposSkin.#unpack}\' -- "$t" || exit 1\ngit worktree add --quiet --detach "$t/w" "$c" >/dev/null 2>&1 || exit 1\nw="$t/w"\nprintf %s "$c" > "$t/chosen"\n{\n${_ReposSkin.#lend("$t")}${_ReposSkin.#checks}} >&2\necho "conform $c"\necho "$c"`,\n head: `${_ReposSkin.#in}git rev-parse --git-dir >/dev/null 2>&1 || { echo "the folder holds no repo" >&2; exit 1; }\ngit rev-parse -q --verify HEAD || echo\n[ -n "$2" ] || exit 0\nif git merge-base --is-ancestor "$2" HEAD 2>/dev/null; then echo holds; else echo lacks; fi`,\n status: `${_ReposSkin.#in}exec git status --porcelain=v1 --branch`,\n commit: `${_ReposSkin.#in}[ "$(git branch --show-current)" = main ] || { echo "the repo is not on main" >&2; exit 1; }\nt=$(mktemp -d) || exit 1\ntrap \'rm -rf "$t"\' EXIT\nnode -e \'${_ReposSkin.#unpack}\' -- "$t" || exit 1\n{\n${_ReposSkin.#unsecret}${_ReposSkin.#staged}${_ReposSkin.#checks}${_ReposSkin.#versioned}} >&2\n${_ReposSkin.#taken}[ ! -s "$t/executable" ] || git checkout-index -f -z --stdin <"$t/executable" || exit 1\nif [ -n "$v" ]; then git tag "$v" || exit 1; echo "$v"; fi\nh=$(git rev-parse HEAD) || exit 1\n[ "$(git rev-parse -q --verify HEAD:tools/conform.mjs)" = "$(git rev-parse -q --verify HEAD~:tools/conform.mjs)" ] || echo "conform $h"\necho "$h"`,\n discard: `${_ReposSkin.#in}git restore --source=HEAD --staged --worktree -- . && exec git clean -fdq`,\n log: `${_ReposSkin.#in}exec git log --max-count="$2" --format=%H%x09%an%x09%aI%x09%s`,\n bundle: `${_ReposSkin.#in}rm -rf "$2" && mkdir -p "$2" || exit 1\nif [ -n "$5" ]; then u=$(git rev-parse -q --verify "refs/tags/$5^{commit}") || { echo "this lobe holds no tag $5" >&2; exit 1; }\nif [ -n "$3" ] && git merge-base --is-ancestor "$u" "$3" 2>/dev/null; then echo 0; echo "$u"; exit 0; fi\nt=$(mktemp -d) || exit 1\ntrap \'rm -rf "$t"\' EXIT\ngit init --quiet --bare --object-format="$(git rev-parse --show-object-format)" "$t/c" >/dev/null || exit 1\ngit rev-parse --path-format=absolute --git-path objects > "$t/c/objects/info/alternates" || exit 1\ngit --git-dir="$t/c" update-ref refs/heads/main "$u" || exit 1\nfor n in $(git tag --merged "$u" --list \'v*\'); do git --git-dir="$t/c" update-ref "refs/tags/$n" "$(git rev-parse "refs/tags/$n")" || exit 1; done\ncd "$t/c" && export GIT_DIR="$t/c" || exit 1\nelif [ -n "$4" ]; then if [ -n "$3" ] && u=$(git rev-parse -q --verify "$4") && git merge-base --is-ancestor "$u" "$3" 2>/dev/null; then git update-ref -d "$4"; echo 0; echo "$u"; exit 0; fi\nt=$(mktemp -d) || exit 1\ntrap \'rm -rf "$t"\' EXIT\ngit init --quiet --bare --object-format="$(git rev-parse --show-object-format)" "$t/c" >/dev/null || exit 1\nif git rev-parse -q --verify "$4" >/dev/null; then git --git-dir="$t/c" fetch --quiet --no-tags "$1" "+$4:refs/heads/main" || exit 1; fi\ngit update-ref -d "$4" 2>/dev/null; cd "$t/c" && export GIT_DIR="$t/c" || exit 1\nfi\nh=$(git rev-parse -q --verify main) || { echo 0; exit 0; }\n[ "$3" = "$h" ] && { echo 0; echo "$h"; exit 0; }\nif [ -n "$3" ] && git cat-file -e "$3^{commit}" 2>/dev/null; then x="^$3"; g=$(git for-each-ref --format=\'%(refname)\' --merged main --no-merged "$3" \'refs/tags/v*\'); else x=; g=$(git for-each-ref --format=\'%(refname)\' --merged main \'refs/tags/v*\'); fi\ngit bundle create --quiet "$2/b" main $g $x || exit 1\ncd "$2" || exit 1\np="\\${6:-${_ReposSkin.#box}}"\nn=$(( ($(wc -c < b) + p - 1) / p ))\ni=0; while [ "$i" -lt "$n" ]; do dd if=b of="q$i" bs="$p" skip="$i" count=1 2>/dev/null || exit 1; i=$((i + 1)); done\nrm b || exit 1\necho "$n"; echo "$h"`,\n bring: _ReposSkin.#bring,\n cut: _ReposSkin.#cut,\n graft: _ReposSkin.#graft,\n land: `${_ReposSkin.#in}r="refs/nervur/$2"\nc=$(git rev-parse -q --verify "$r-main") || { echo "nothing waits to land as $2" >&2; exit 1; }\ngit update-ref -d "$r"; git update-ref -d "$r-main"\nk=$(git for-each-ref --format=\'%(objectname) %(refname)\' "$r-tags/"); ${_ReposSkin.#untag}\nw=$(echo "$k" | while read -r o n; do [ -n "$n" ] || continue; n=\\${n#"$r-tags/"}; if e=$(git rev-parse -q --verify "refs/tags/$n^{commit}"); then [ "$e" = "$o" ] || echo "this lobe holds the tag $n on another commit: a version names one commit for ever"; fi; done)\n[ -z "$w" ] || { echo "$w" >&2; exit 1; }\nif git rev-parse -q --verify HEAD >/dev/null; then git merge --quiet --ff-only "$c" || { echo "main moved while what came was checked: send it again" >&2; exit 1; }; else git checkout --quiet -B main "$c" || exit 1; fi\necho "$k" | while read -r o n; do [ -n "$n" ] || continue; n=\\${n#"$r-tags/"}; git rev-parse -q --verify "refs/tags/$n" >/dev/null || echo "create refs/tags/$n $o"; done | git update-ref --stdin || exit 1\ngit rev-parse HEAD`,\n conform: `${_ReposSkin.#in}c=$(git rev-parse -q --verify "refs/nervur/$2-main") || { echo "nothing waits as $2" >&2; exit 1; }\n[ "$c" = "$3" ] || { echo "what waits as $2 is $c, not $3" >&2; exit 1; }\nt=$(mktemp -d) || exit 1\ntrap \'git -C "$1" worktree remove --force "$t/w" 2>/dev/null; rm -rf "$t"; git -C "$1" worktree prune\' EXIT\nnode -e \'${_ReposSkin.#unpack}\' -- "$t" || exit 1\ngit worktree add --quiet --detach "$t/w" "$c" >/dev/null 2>&1 || exit 1\nw="$t/w"\n${_ReposSkin.#lend("$t")}${_ReposSkin.#checks}[ -n "$4" ] || exit 0\ncd "$t/w" || exit 1\nnode -e \'process.exit(require("./package.json").scripts?.[process.argv[1]] ? 0 : 3)\' "$4" 2>/dev/null || { echo "gate: skipped: the repo holds no script $4"; exit 0; }\n${_ReposSkin.#queued}${_ReposSkin.#masked} sh -c \'if [ -f package-lock.json ]; then npm ci || exit 1; fi; exec npm run "$1"\' gate "$4"`,\n run: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}${_ReposSkin.#scripted}d="$1"; s="$2"; i="$3"; g="$4"\n[ -z "$g" ] || { ${_ReposSkin.#queued}}\nshift 4\nexec node -e \'${_ReposSkin.#mask}\' -- "$d/${_ReposSkin.#env}" sh -c \'if [ "$2" = install ] && [ -f package-lock.json ]; then npm ci || exit 1; fi; s="$1"; shift 2; exec npm run "$s" -- "$@"\' run "$s" "$i" "$@"`,\n secrets: `${_ReposSkin.#in}git rev-parse --git-dir >/dev/null 2>&1 || { echo "the folder holds no repo" >&2; exit 1; }\ngit check-ignore -q -- ${_ReposSkin.#env} || { echo "${_ReposSkin.#env} is not kept out by .gitignore: no secret file is written where git would take it" >&2; exit 1; }\numask 077\nexec node -e \'${_ReposSkin.#whole}\' -- "./${_ReposSkin.#env}"`,\n remove: `for n in "$2" "\\${3-x}"; do case "$n" in .*|*/*) echo "remove reaches one folder of repos/ alone" >&2; exit 1 ;; esac; done\n[ -n "$2" ] || { echo "remove names its folder" >&2; exit 1; }\ncd "$1/repos" || exit 1\nif [ -e "$2" ] || [ -L "$2" ]; then { [ -d "$2" ] && [ ! -L "$2" ] && ls -1A . | grep -qxF -- "$2"; } || { echo "the folder $2 stands not as named under repos" >&2; exit 1; }; rm -rf -- "$2" || exit 1; fi\n[ ! -e "$2" ] || { echo "the folder $2 stands still" >&2; exit 1; }\n[ -z "$3" ] || rm -rf -- "$1/transfers/$3"`,\n clear: `cd "$1/transfers" 2>/dev/null || exit 0\nfor n in "$2" "\\${3-x}"; do case "$n" in \'\'|.*|*/*) echo "clear reaches a lobe\'s pieces alone" >&2; exit 1 ;; esac; done\nexec rm -rf -- "$2\\${3:+/$3}"`,\n scan: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}h=$(git rev-parse -q --verify HEAD) || { echo; exit 0; }\necho "$h"\ngit tag --points-at HEAD --list \'v*\' | sed \'s/^/g /\'\ngit ls-files -- \':(glob)faculties/*/faculty.js\' \':(glob)faculties/*/versions.json\' \':(glob)organs/*/graph.json\' \':(glob)organs/*/host/build\' \':(glob)designs/*/design.json\' \':(glob)designs/*/versions.json\' | sed \'s/^/t /\'\n{ git diff --name-only HEAD -- faculties organs designs; git ls-files --others --exclude-standard -- faculties organs designs; } | sed \'s/^/c /\'\ngit -c core.quotePath=false ls-files -- designs \':(glob)faculties/*/assets/**\' | while IFS= read -r p; do { [ -f "$p" ] && [ ! -L "$p" ]; } || { echo "u $p"; continue; }; s=$(perl -0777 -pe \'s/\\\\r\\\\n?/\\\\n/g unless /\\\\0/\' -- "$p" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -d " " -f 1); echo "d $s $p"; done\n${_ReposSkin.#keep}t=$(git describe --tags --abbrev=0 --match \'v*\' HEAD 2>/dev/null) || exit 0\necho "@ $t"\ngit ls-tree -r --name-only "$t" -- faculties organs | grep -E \'^(faculties/[^/]+/(faculty\\\\.js|versions\\\\.json)|organs/[^/]+/(graph\\\\.json|host/build))$\' | while IFS= read -r p; do echo "T $p"; case "$p" in */host/build) continue ;; esac; git diff --quiet "$t" -- "$p" 2>/dev/null && continue; printf \'B %s \' "$p"; git show "$t:$p" | node -e \'let s="";process.stdin.setEncoding("utf8").on("data",(d)=>{s+=d}).on("end",()=>process.stdout.write(JSON.stringify(s)))\'; echo; done\ngit -c core.quotePath=false ls-tree -r "$t" -- faculties | while IFS="$c" read -r m p; do case "$p" in faculties/*/assets/*) ;; *) continue ;; esac; o=\\${m##* }; if [ -s "$k/.o/$o" ]; then echo "A $(cat "$k/.o/$o") $p"; else echo "U $p"; fi; done`,\n build: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}o="organs/$2/host"\n[ -x "$o/build" ] || { echo "organs/$2 holds no executable host/build" >&2; exit 1; }\n(cd "$o" && ./build) >&2 || exit 1\n[ -f "$o/half" ] || { echo "the build left no host/half" >&2; exit 1; }\nd=$({ sha256sum "$o/half" 2>/dev/null || shasum -a 256 "$o/half"; } | cut -d " " -f 1)\nr="\\${1%/*}"; h="\\${r%/*}/halves"\nmkdir -p "$h" && chmod 755 "$h" && cp "$o/half" "$h/$d.writing" && chmod 755 "$h/$d.writing" && mv -f "$h/$d.writing" "$h/$d" || { echo "the half is not laid in $h" >&2; exit 1; }\nprintf \'%s\\\\n\' "$d"`,\n look: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}d="designs/$2"\n{ [ -d "$d" ] && [ ! -L "$d" ] && ls -1A designs | grep -qxF -- "$2"; } || { echo "the repo holds no design $2" >&2; exit 1; }\nnode -e \'process.exit(require("./package.json").scripts?.design ? 0 : 3)\' 2>/dev/null || { echo "the repo holds no script design" >&2; exit 3; }\nt=$(mktemp) || exit 1\ntrap \'rm -f "$t"\' EXIT\nnpm run --silent design -- "$d" --look "$t" >&2 || exit 1\ncat "$t"`\n };\n static #sh(kind) {\n return ["sh", "-c", _ReposSkin.#scripts[kind], kind];\n }\n static programs = {\n setup: _ReposSkin.#sh("setup"),\n init: _ReposSkin.#sh("init"),\n stand: _ReposSkin.#sh("stand"),\n head: _ReposSkin.#sh("head"),\n status: _ReposSkin.#sh("status"),\n commit: _ReposSkin.#sh("commit"),\n discard: _ReposSkin.#sh("discard"),\n log: _ReposSkin.#sh("log"),\n bundle: _ReposSkin.#sh("bundle"),\n bring: _ReposSkin.#sh("bring"),\n cut: _ReposSkin.#sh("cut"),\n graft: _ReposSkin.#sh("graft"),\n land: _ReposSkin.#sh("land"),\n conform: _ReposSkin.#sh("conform"),\n run: _ReposSkin.#sh("run"),\n secrets: _ReposSkin.#sh("secrets"),\n clear: _ReposSkin.#sh("clear"),\n remove: _ReposSkin.#sh("remove"),\n scan: _ReposSkin.#sh("scan"),\n build: _ReposSkin.#sh("build"),\n look: _ReposSkin.#sh("look")\n };\n static #unready = { ready: false, doing: null, failed: null };\n static #plain = { type: "string" };\n static #some = { type: "string", minLength: 1 };\n static #maybe = { anyOf: [{ type: "string", minLength: 1 }, { type: "null" }] };\n static #place = { type: "integer", minimum: 0 };\n static #one = { type: "integer", minimum: 1 };\n static #named = { type: "string", pattern: "^[a-z][a-z0-9.-]{0,63}$" };\n static #jobSchema = {\n type: "object",\n properties: { job: _ReposSkin.#some },\n required: ["job"],\n additionalProperties: false\n };\n static #paging = {\n type: "object",\n properties: { cursor: _ReposSkin.#maybe },\n additionalProperties: false\n };\n static #scopeSchema = { type: "array", items: _ReposSkin.#some, minItems: 1, maxItems: SCOPE_MOST };\n static #many = { type: "array", items: _ReposSkin.#some, minItems: 1 };\n static #files = {\n type: "array",\n items: {\n type: "object",\n properties: { path: _ReposSkin.#some, text: _ReposSkin.#plain, absent: { type: "boolean" } },\n required: ["path"],\n additionalProperties: false\n }\n };\n static #object(properties, required = Object.keys(properties)) {\n return { type: "object", properties, required, additionalProperties: false };\n }\n static #says = {\n setup: "An owner, once: the disk\'s folder stands at `at` on the host, proven by a marker the disk writes and the shell reads back.",\n delegate: "An owner: the lobe `lobe` a delegate, which grants folders of its own as an owner does and removes those alone, as a keeper raising repo lobes as its children does; with `given` false, a delegate no more, the folders it granted standing.",\n grant: "An owner, or a delegate a folder it granted, a new one, or one no lobe holds, a lobe torn down having left it, which is the delegate’s from then on: the folder `folder`, `repos/<folder>`, is the repo lobe `lobe`’s, whatever lobe it names, its one folder and no other’s, so a wired lobe reaches it only through its repo lobe; its wire back is ordered as its first job starts; a name an entry of `repos/` holds in another case is refused; where `lobe` is null, it is granted to none; a lobe that loses it has its pieces cleared.",\n folders: "An owner, every folder; a delegate, those it granted and those no lobe holds, which it may take: each with the repo lobe it is granted to, whether a repo stands in it, the job going, and the secret files written in it, by their paths. A page, `{ folders, cursor }`, `cursor` null at the list’s end, else handed back to read on.",\n remove: "An owner, or a delegate the folder it granted: forgets the folder `folder` and its grant, its bytes left on disk, and its lobe’s pieces are cleared; with `erase` true, a job, answered `{ job }`, deletes them too: its grant forgotten at once, so its repo lobe reaches it no more, then the folder `repos/<folder>`, checked to stand under the disk’s `repos/` by that exact name and no link, deleted with every byte it holds, and the pieces of the lobe granted it, `transfers/<lobe>/`; the folder forgotten once the job ended, its bytes gone, read by `job`; one that failed stands, granted to none. One running a job is refused.",\n state: "An owner: the disk\'s folder as set up. A repo lobe: its folder on the host, whether a repo stands in it, read on the disk where one was made, and the job going.",\n read: "A repo lobe: a file\'s text, its first lines where `first` names how many, and how many lines it holds; or `paths` alone, `{ files }` in one answer, each `{ path, text }` or `{ path, absent: true }` in the order named, the whole refused where a path climbs or hides, a text is no UTF-8 or the texts weigh past what one answer carries.",\n bytes: "A repo lobe: the bytes of a file a tag of its repo holds in a design\'s folder or a faculty\'s `assets/`, as a design\'s font, which no text holds, by the SHA-256 `sha` its scan kept them under, a text\'s with LF line ends; `absent` where none is kept.",\n write: "A repo lobe: writes a file\'s text whole, as a commit\'s files.",\n erase: "A repo lobe: removes a file, or a folder that holds nothing, of its repo, as a refused commit\'s files are put back as they were; the one removal a repo lobe has this jailer make of a repo\'s bytes.",\n list: "A repo lobe: the names in a folder of its repo, its top where no path is named.",\n piece: "A repo lobe: the piece `at` of the bundle that waits as `as`",\n put: "A repo lobe: writes the piece `at` of `pieces` of a bundle that waits as `as`.",\n init: "A job: makes the repo on `main` in its folder, which holds nothing, empty, laying no file; never over a repo that stands.",\n stand: "A job: the repo its folder holds already, handed in place to the lobe granted it: refused where none stands there, or `main` holds no commit or is not checked out; else its `main` checked out apart and checked by the check of the parts `parts`, Nervur’s, and `tools/conform.mjs` as `main` holds it, on its errors, then `conform <head>`, the conform it chooses, and its head answered. Nothing is laid or moved. Its checks go on the input.",\n head: "A job: the HEAD, and whether it holds the commit `contains` where one is named.",\n status: "A job: `git status`.",\n commit: "A job: refused while `.env` stands where `.gitignore` keeps it not out; then the check of the parts `parts`, Nervur’s, and the repo’s `tools/conform.mjs` as the commit `conform` holds it, the one its owner chose, none where it names none, each over what it would commit, laid out apart as a clone would hold it, so a file `.gitignore` keeps out counts as absent; then its root `package.json` `version` read against `HEAD`’s: refused where it changed and is not three whole numbers, is lower by semver, or its tag `v<version>` stands already; then every change committed on `main`, or with `paths` the changes of those paths alone, each a file or a folder of the repo and the rest of the folder left as it stands, refused where they hold none, with `message`, each path `executable` names landing executable, and tagged `v<version>`, a git tag, where it raised the version, none in a lobe holding a scope; answering the tag where it made one, `conform <head>` where it changed `tools/conform.mjs`, the conform it chooses, then its HEAD. Its message and its checks go on the input.",\n discard: "A job: every change since the last commit undone.",\n log: "A job: the last commits, `most` of them, twenty where none is named.",\n run: "A job: the script `script` of the repo\'s `package.json`, by `npm run <script> -- <args…>`, each of `args` one argument, never read by a shell, its environment the repo\'s `.env`, each line as written, its values masked in its output; with `install`, `npm ci` first where a lockfile stands, in the same job; with `gate`, after the gates asked before it, one at a time across the organism; a script the repo lacks ends 3.",\n secrets: "A job: `.env` written whole, only where `.gitignore` keeps it out: each name of `set` a line `KEY=value`, readable by the owner of the files alone, and removed where it sets none. Its values go on the input, never kept nor read back.",\n clear: "A repo lobe\'s job beside its folder\'s, told to no one: the pieces of its bundle waiting as `as` removed; while they go, none is made, written or read under that name.",\n check: "A repo lobe: its job and its clears checked against the runs the shell names going; each it runs no more, lost to a restart, ended at once, failed, its lobe told. Answers the job going, those ended lost, and `last`, the end it last told that lobe, `{ job, kind, code, out, err }`, as its letter tells it, kept for that lobe alone until its next end, or null.",\n bundle: "A job: the commits on `main` after `since`, as a bundle in pieces waiting as `as`; answers how many and the HEAD. With `cut`, the commits of the cut of `as` after `since` instead, read from its own bare repo as `main`, so nothing of `main` leaves, not even a name; the cut’s ref then cleared, and no tag carried. The bundle carries every tag `v*` naming a commit after `since`; with `tag`, `v` and three whole numbers, `main` ends at the commit that tag names, refused where this lobe holds no such tag, and none where `since` holds that commit already; a cut is bundled by no tag, since its tag was named to the cut: with `cut`, none is made either where `since` holds the cut’s head already.",\n cut: "A job: `main` cut to the scope `scope`, folders none inside another: by first parent, each commit that changes a path within the scope rewritten to one whose tree holds those paths alone, its parent the last one cut, its author, committer, their times and its message kept exactly, signed by no one, so the same `main` is cut to the same commits every time; with `tag`, `v` and three whole numbers, only up to the commit that tag names, the beginning of the cut to the head, the very commits in the very order, refused where this lobe holds no such tag, and the tag’s name never in the cut; left at `refs/nervur/cut-<as>`, its head answered, or an empty line where the cut is empty.",\n bring: "A job: a pull\'s or a push\'s `pieces` waiting as `as` brought apart from `main`, and what `main` would become kept beside it, itself or a merge made apart; answers that head and `forward`, `merge` or `new`, or `main`\'s HEAD and `held` where `main` holds it already; a conflict refused. With `scope`, a scoped writer’s push, grafted: refused unless its commits are linear on the scope’s head as `main` is cut now, none where the cut is empty, else as behind, and where one changes a path outside the scope, naming it, or nothing within it; each commit then grafted on `main`’s tip, its tree `main`’s with every path within the scope taken from it, its author, committer, their times and its message kept, so the scope cut again answers the very commits pushed, else refused; answers that head, `graft` and the head pushed, or the head pushed and `held`. The tags `v*` the bundle carries, a scoped writer\'s none, fetched apart as `refs/nervur/<as>-tags/`, and the whole refused, nothing kept, where one names no commit it brings or this lobe holds a tag of that name on another commit.",\n land: "A job: what was brought as `as` brought into `main`, which it builds on; refused where `main` moved meanwhile. The tags brought with it laid once `main` moved, never before, one held on the same commit no change, and the whole refused, `main` unmoved, where one meets a tag of that name on another commit. Answers the HEAD.",\n conform: "A job: what was brought as `as`, at `head`, checked out apart and checked by the check of the parts `parts`, Nervur’s, then by `tools/conform.mjs` as the commit `conform` holds it, the one the lobe’s owner chose, never as what came holds it, said skipped where it names none or that commit holds none; with `script`, that gate then run there too, with the repo’s `.env`, masked in its output, after the gates asked before it, one at a time across the organism. Its checks go on the input.",\n scan: "A job: the HEAD, each tag `v*` it carries as `g <tag>`, each file of `faculties/` and `organs/` git tracks, each design\'s `design.json` and `versions.json`, each it shows changed, and each file of `designs/` and of each faculty\'s `assets/` with its SHA-256, a text\'s read with LF line ends; then the newest tag `v*` reachable from the HEAD as `@ <tag>`, each faculty\'s and organ\'s file its commit holds as `T <path>`, the text of each that differs from the folder as `B <path> <JSON string>`, and each file of each faculty\'s `assets/` there as `A <SHA-256> <path>`, or `U <path>` where none is kept. Between them, each file a tag `v*` holds in `designs/` or a faculty\'s `assets/` kept by its SHA-256, a text\'s with LF line ends, for `bytes` to read, each tag kept once.",\n build: "A job: the organ `organ`\'s `host/build` run, answering the SHA-256 of the `host/half` it leaves.",\n look: "A job: the design `design`\'s look built by the repo\'s own script `design`, given `designs/<design>` and `--look` with the file to write it to, answering that file alone, the look\'s source; it is built, never committed.",\n stop: "A repo lobe\'s own job, or an owner\'s of the folder `folder`, stopped through the shell; one the shell runs no more, lost to a restart of the organ, ends at once, failed.",\n ended: "The shell\'s alone: a job\'s program ended.",\n back: "The brain\'s alone: the shell\'s half connected, at its start or after it restarted, an update\'s among them: each job going that the shell names going no more ends, lost, its lobe told.",\n jobs: "The asker\'s jobs, an owner\'s every one, each with its code once ended; a job keeps no input and no output. Of each asker the jailer keeps every job that runs and its newest ended, as many as one read holds, a clear forgotten once ended. A page, `{ jobs, cursor }`, `cursor` null at the list\'s end, else handed back to read on.",\n job: "One of the asker\'s jobs, `job`, as the jailer keeps it; an owner reads any, and one not the asker\'s, or one gone past the newest kept, is absent."\n };\n static #reading(method, args, result) {\n const typed = { ...args === void 0 ? {} : { args }, ...result ? { result } : {} };\n const description = _ReposSkin.#says[method] ?? method;\n return { description, kind: "reading", ...typed, errors: ["refused", "absent"] };\n }\n static #writing(method, args, result) {\n return { ..._ReposSkin.#reading(method, args, result), kind: "writing" };\n }\n static #jobOf(method, args) {\n return _ReposSkin.#writing(method, args, _ReposSkin.#jobSchema);\n }\n static #none = _ReposSkin.#object({});\n static blueprint = {\n name: "nervur.repos",\n version: "0.1.121",\n description: "The jailer: keeps the bytes of the organism\'s repos at `repos/<name>` under the disk\'s folder, on `main`, a skin lobe of `shell` and `disk`. An owner sets the folder up and grants each repo\'s folder to one repo lobe, through which the lobes wired to it reach it; the repo lobe reaches its own and never names it: its files read and written as UTF-8 text through the disk, the pieces of its bundles beside them, and its jobs run through the shell, one at a time for each folder, each answered at once and asked back `done` by a letter. It holds no relation and no secret: `.env` is written whole from a job\'s input, only where `.gitignore` keeps it out, readable by the owner of the files alone, and read back by the names that stand alone; a commit is refused while one stands that git would take, and checked over what it would commit laid out apart; and every run of a repo\'s script loads `.env` into its environment, each line as written, masked in its output by its program; a job keeps neither its input nor its output, but the end last told each lobe, kept for that lobe alone until its next. It removes no repo\'s bytes but a refused commit\'s own files, which its repo lobe has it `erase`, and a folder an owner removes with `erase`: a plain `remove` forgets a folder and leaves its bytes.",\n methods: {\n setup: _ReposSkin.#jobOf("setup", _ReposSkin.#object({ at: _ReposSkin.#some })),\n delegate: _ReposSkin.#writing(\n "delegate",\n _ReposSkin.#object({ lobe: _ReposSkin.#some, given: { type: "boolean" } }, ["lobe"])\n ),\n grant: _ReposSkin.#writing("grant", _ReposSkin.#object({ folder: _ReposSkin.#named, lobe: _ReposSkin.#maybe })),\n folders: _ReposSkin.#reading("folders", _ReposSkin.#paging),\n remove: {\n ..._ReposSkin.#writing(\n "remove",\n _ReposSkin.#object({ folder: _ReposSkin.#named, erase: { type: "boolean" } }, ["folder"])\n ),\n irreversible: true\n },\n state: _ReposSkin.#reading("state", _ReposSkin.#none),\n read: _ReposSkin.#reading(\n "read",\n _ReposSkin.#object({ path: _ReposSkin.#some, first: _ReposSkin.#one, paths: _ReposSkin.#many }, []),\n _ReposSkin.#object({ text: _ReposSkin.#plain, lines: { type: "integer" }, files: _ReposSkin.#files }, [])\n ),\n bytes: _ReposSkin.#reading("bytes", _ReposSkin.#object({ sha: _ReposSkin.#some }), _ReposSkin.#object({ bytes: {} })),\n write: _ReposSkin.#writing("write", _ReposSkin.#object({ path: _ReposSkin.#some, text: _ReposSkin.#plain })),\n erase: { ..._ReposSkin.#writing("erase", _ReposSkin.#object({ path: _ReposSkin.#some })), irreversible: true },\n list: _ReposSkin.#reading(\n "list",\n _ReposSkin.#object({ path: _ReposSkin.#plain }, []),\n _ReposSkin.#object({ names: { type: "array", items: _ReposSkin.#plain } })\n ),\n piece: _ReposSkin.#reading(\n "piece",\n _ReposSkin.#object({ at: _ReposSkin.#place, as: _ReposSkin.#some }, ["at", "as"])\n ),\n put: _ReposSkin.#writing(\n "put",\n _ReposSkin.#object({\n at: _ReposSkin.#place,\n pieces: _ReposSkin.#one,\n bytes: {},\n as: _ReposSkin.#some\n })\n ),\n init: _ReposSkin.#jobOf("init", _ReposSkin.#none),\n stand: _ReposSkin.#jobOf(\n "stand",\n _ReposSkin.#object({ parts: _ReposSkin.#some, scoped: { type: "boolean" } }, ["parts"])\n ),\n head: _ReposSkin.#jobOf("head", _ReposSkin.#object({ contains: _ReposSkin.#some }, [])),\n status: _ReposSkin.#jobOf("status", _ReposSkin.#none),\n commit: _ReposSkin.#jobOf(\n "commit",\n _ReposSkin.#object(\n {\n message: _ReposSkin.#some,\n parts: _ReposSkin.#some,\n scoped: { type: "boolean" },\n executable: { type: "array", items: _ReposSkin.#some },\n paths: { type: "array", items: _ReposSkin.#some, minItems: 1 }\n },\n ["message", "parts"]\n )\n ),\n discard: { ..._ReposSkin.#jobOf("discard", _ReposSkin.#none), irreversible: true },\n log: _ReposSkin.#jobOf("log", _ReposSkin.#object({ most: { type: "integer", minimum: 1 } }, [])),\n run: _ReposSkin.#jobOf(\n "run",\n _ReposSkin.#object(\n {\n script: _ReposSkin.#some,\n args: { type: "array", items: _ReposSkin.#plain, maxItems: ARGS_MOST },\n install: { type: "boolean" },\n gate: { type: "boolean" }\n },\n ["script"]\n )\n ),\n secrets: _ReposSkin.#jobOf(\n "secrets",\n _ReposSkin.#object({ set: { type: "object", additionalProperties: _ReposSkin.#plain } })\n ),\n bundle: _ReposSkin.#jobOf(\n "bundle",\n _ReposSkin.#object(\n {\n since: _ReposSkin.#maybe,\n as: _ReposSkin.#some,\n cut: { type: "boolean" },\n tag: _ReposSkin.#some,\n piece: _ReposSkin.#one\n },\n ["since", "as"]\n )\n ),\n bring: _ReposSkin.#jobOf(\n "bring",\n _ReposSkin.#object({ as: _ReposSkin.#some, pieces: _ReposSkin.#one, scope: _ReposSkin.#scopeSchema }, [\n "as",\n "pieces"\n ])\n ),\n cut: _ReposSkin.#jobOf(\n "cut",\n _ReposSkin.#object({ as: _ReposSkin.#some, scope: _ReposSkin.#scopeSchema, tag: _ReposSkin.#some })\n ),\n land: _ReposSkin.#jobOf("land", _ReposSkin.#object({ as: _ReposSkin.#some })),\n conform: _ReposSkin.#jobOf(\n "conform",\n _ReposSkin.#object(\n {\n as: _ReposSkin.#some,\n head: _ReposSkin.#some,\n parts: _ReposSkin.#some,\n scoped: { type: "boolean" },\n script: _ReposSkin.#some\n },\n ["as", "head", "parts"]\n )\n ),\n clear: _ReposSkin.#jobOf("clear", _ReposSkin.#object({ as: _ReposSkin.#some })),\n check: _ReposSkin.#writing(\n "check",\n _ReposSkin.#none,\n _ReposSkin.#object({\n doing: _ReposSkin.#maybe,\n lost: { type: "array", items: _ReposSkin.#some }\n })\n ),\n scan: _ReposSkin.#jobOf("scan", _ReposSkin.#none),\n build: _ReposSkin.#jobOf("build", _ReposSkin.#object({ organ: _ReposSkin.#some })),\n look: _ReposSkin.#jobOf("look", _ReposSkin.#object({ design: _ReposSkin.#some })),\n stop: _ReposSkin.#writing("stop", _ReposSkin.#object({ folder: _ReposSkin.#named }, [])),\n ended: { ..._ReposSkin.#writing("ended"), askers: ["shell"] },\n back: { ..._ReposSkin.#writing("back"), askers: ["brain"] },\n jobs: _ReposSkin.#reading("jobs", _ReposSkin.#paging),\n job: _ReposSkin.#reading("job", _ReposSkin.#jobSchema)\n },\n placeholders: { shell: "nervur.shell", disk: "nervur.disk" }\n };\n static #fields(data) {\n return !!data && typeof data === "object" && !Array.isArray(data) && !ArrayBuffer.isView(data);\n }\n static #text(data) {\n return typeof data === "string" && data !== "";\n }\n static #count(data, most) {\n return typeof data === "number" && Number.isSafeInteger(data) && data >= 1 && data <= most;\n }\n static #arg(args, key) {\n return _ReposSkin.#fields(args) ? args[key] : void 0;\n }\n static #names(path) {\n if (path === void 0 || path === "") return [];\n if (typeof path !== "string") return null;\n const names = path.split("/");\n return names.every((name) => _ReposSkin.#name.test(name)) ? names : null;\n }\n static #paths(paths) {\n return Array.isArray(paths) && paths.length >= 1 && paths.every((path) => typeof path === "string" && path !== "" && _ReposSkin.#names(path) !== null);\n }\n static #scopeOf(scope) {\n if (!Array.isArray(scope) || scope.length < 1 || scope.length > SCOPE_MOST) return null;\n const folders = scope.flatMap((one) => typeof one === "string" ? [one] : []);\n const fit = (one) => one.split("/").every((name) => _ReposSkin.#segment.test(name) && ![".", "..", ".git"].includes(name));\n if (folders.length !== scope.length || !folders.every(fit)) return null;\n const sorted = folders.toSorted();\n const nested = sorted.some(\n (one, at) => sorted.some((other, by) => by !== at && (one === other || one.startsWith(`${other}/`)))\n );\n return nested ? null : sorted;\n }\n static #lone = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g;\n #bytes(text) {\n const encoded = this.codec.utf8(text.replace(_ReposSkin.#lone, "�"));\n return "bytes" in encoded ? encoded.bytes : null;\n }\n #textOf(bytes) {\n const decoded = this.codec.utf8Text(bytes);\n return "text" in decoded ? decoded.text : null;\n }\n #linesOf(set) {\n if (!_ReposSkin.#fields(set)) return null;\n const entries = Object.entries(set);\n if (entries.length > this.#most()) return null;\n for (const [key, value] of entries)\n if (!_ReposSkin.#key.test(key) || typeof value !== "string" || !_ReposSkin.#line.test(value)) return null;\n return set;\n }\n static #argsOf(args) {\n if (args === void 0) return [];\n if (!Array.isArray(args) || args.length > ARGS_MOST) return null;\n const all = args.flatMap(\n (one) => typeof one === "string" && one.length <= ARG_LONGEST && !one.includes("\\0") ? [one] : []\n );\n return all.length === args.length ? all : null;\n }\n #heard(answer) {\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : null;\n }\n #nonce() {\n return Array.from(this.stamp.seed.slice(0, 16), (byte) => byte.toString(16).padStart(2, "0")).join("");\n }\n #at() {\n const setup = this.cells.get(["setup"]);\n if (!_ReposSkin.#fields(setup) || setup["ready"] !== true) return null;\n return _ReposSkin.#text(setup["at"]) ? setup["at"] : null;\n }\n #most() {\n return Math.min(CELLS_RANGE, Math.floor(this.memory / LOBE_SHARE / ITEM_SIZE));\n }\n #all(prefix) {\n return this.cells.range({ prefix, limit: this.#most() }).cells;\n }\n #page(prefix, args) {\n const cursor = _ReposSkin.#arg(args, "cursor") ?? null;\n if (cursor !== null && !_ReposSkin.#text(cursor))\n return this.error("refused", "a cursor is the one a page answered");\n try {\n return this.cells.range({ prefix, limit: this.#most(), ...cursor === null ? {} : { cursor } });\n } catch {\n return this.error("refused", "a cursor is the one a page answered");\n }\n }\n async setup(args) {\n if (this.stamp.asker !== _ReposSkin.#owner) return this.error("refused", "setup is an owner\'s");\n const at = _ReposSkin.#arg(args, "at");\n if (!_ReposSkin.#text(at) || !at.startsWith("/"))\n return this.error("refused", "at is where the disk\'s folder stands, from the root");\n const held = await this.#unstuck(["setup"]);\n if (_ReposSkin.#fields(held) && _ReposSkin.#text(held["doing"]))\n return this.error("refused", "the setup runs already");\n const nonce = this.#nonce();\n const path = [_ReposSkin.#repos, _ReposSkin.#marker];\n const wrote = await this.ask("disk", "write", { path, bytes: this.#bytes(nonce) });\n if ("error" in wrote) return this.#heard(wrote);\n this.cells.set(["setup"], { at, ..._ReposSkin.#unready });\n return this.#begin("setup", null, [at], `${nonce}\n`);\n }\n async grant(args) {\n const delegate = this.#delegate();\n if (this.stamp.asker !== _ReposSkin.#owner && delegate === null)\n return this.error("refused", "grant is an owner\'s or a delegate\'s");\n const folder = _ReposSkin.#arg(args, "folder");\n const lobe = _ReposSkin.#arg(args, "lobe");\n if (!_ReposSkin.#text(folder) || !_ReposSkin.#folderName.test(folder))\n return this.error("refused", "a folder is a repo’s name, lowercase, a letter first");\n if (this.#at() === null) return this.error("refused", "the disk\'s folder is not set up");\n const held = this.cells.get(["folder", folder]);\n const free = _ReposSkin.#fields(held) && !_ReposSkin.#text(held["lobe"]);\n if (delegate !== null && _ReposSkin.#fields(held) && held["by"] !== delegate && (!free || lobe === null))\n return this.error("refused", `the folder ${folder} is none the delegate granted, and a lobe holds it`);\n const kept = _ReposSkin.#fields(held) ? { ...held, ...delegate === null ? {} : { by: delegate } } : { lobe: null, doing: null, made: false, ...delegate === null ? {} : { by: delegate } };\n if (lobe === null) {\n if (!_ReposSkin.#fields(held)) return this.error("absent", `no folder ${folder}`);\n this.cells.set(["folder", folder], { ...held, lobe: null });\n if (_ReposSkin.#text(held["lobe"])) await this.#release(held["lobe"], folder);\n return null;\n }\n if (!_ReposSkin.#text(lobe) || [_ReposSkin.#owner, "shell", "disk"].includes(lobe))\n return this.error("refused", "a grant names a repo lobe, or null for none");\n const holds = this.cells.get(["lobe", lobe]);\n if (typeof holds === "string" && holds !== folder)\n return this.error("refused", `the lobe ${lobe} holds the folder ${holds} already`);\n const met = _ReposSkin.#fields(held) ? null : await this.#folded(folder);\n if (met !== null) return met;\n const was = _ReposSkin.#fields(held) ? held["lobe"] : null;\n this.cells.set(["lobe", lobe], folder);\n this.cells.set(["folder", folder], { ...kept, lobe });\n if (_ReposSkin.#text(was) && was !== lobe) await this.#release(was, folder);\n return null;\n }\n async delegate(args) {\n if (this.stamp.asker !== _ReposSkin.#owner) return this.error("refused", "delegate is an owner\'s");\n const lobe = _ReposSkin.#arg(args, "lobe");\n if (!_ReposSkin.#text(lobe) || [_ReposSkin.#owner, "shell", "disk"].includes(lobe))\n return this.error("refused", "a delegate is a lobe");\n if (_ReposSkin.#arg(args, "given") === false) this.cells.delete(["delegate", lobe]);\n else this.cells.set(["delegate", lobe], true);\n return null;\n }\n #delegate() {\n const { asker } = this.stamp;\n return asker !== _ReposSkin.#owner && this.cells.get(["delegate", asker]) === true ? asker : null;\n }\n async #release(lobe, folder) {\n this.cells.delete(["lobe", lobe]);\n const at = this.#at();\n if (at === null) return;\n const program = [..._ReposSkin.programs.clear, at, lobe];\n const begun = await this.ask("shell", "run", { program, input: "" });\n const run = "result" in begun ? _ReposSkin.#arg(begun.result, "run") : void 0;\n if (!_ReposSkin.#text(run)) return;\n const { asker } = this.stamp;\n this.cells.set(["job", run], { job: run, kind: "clear", asker, folder, ended: null });\n this.cells.set(["by", asker, run], null);\n this.cells.set(["clearing", lobe, "*"], { run });\n }\n static #ends(read) {\n const all = _ReposSkin.#fields(read) && Array.isArray(read["result"]) ? read["result"] : [];\n return new Set(all.map((wire) => _ReposSkin.#arg(wire, "termination")));\n }\n async #torn(read) {\n const ends = _ReposSkin.#ends(read);\n for (const { key, value } of this.#all(["lobe"])) {\n const lobe = key[1];\n if (!_ReposSkin.#text(lobe) || ends.has(lobe) || !_ReposSkin.#text(value)) continue;\n if (this.cells.range({ prefix: ["by", lobe], limit: 1 }).cells.length === 0) continue;\n const held = this.cells.get(["folder", value]);\n if (_ReposSkin.#fields(held)) this.cells.set(["folder", value], { ...held, lobe: null });\n this.cells.delete(["last", lobe]);\n await this.#release(lobe, value);\n }\n }\n async #lostOf(jobs) {\n const asked = await this.ask("shell", "going", {});\n const named = "result" in asked ? _ReposSkin.#arg(asked.result, "runs") : void 0;\n if (!Array.isArray(named)) return null;\n const going = new Set(named);\n return jobs.filter((job) => !going.has(job));\n }\n async #unstuck(key) {\n const record = this.cells.get([...key]);\n const doing = _ReposSkin.#arg(record ?? null, "doing");\n if (!_ReposSkin.#text(doing)) return record;\n const lost = await this.#lostOf([doing]);\n if (lost === null || lost.length === 0) return record;\n await this.#end(doing, -1, "", _ReposSkin.#lost);\n return this.cells.get([...key]);\n }\n async check() {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const doing = own.held["doing"];\n const clears = this.#all(["clearing", this.stamp.asker]).flatMap(({ value }) => {\n const run = _ReposSkin.#arg(value, "run");\n return _ReposSkin.#text(run) ? [run] : [];\n });\n const runs = [..._ReposSkin.#text(doing) ? [doing] : [], ...clears];\n const lost = runs.length === 0 ? [] : await this.#lostOf(runs) ?? [];\n for (const run of lost) await this.#end(run, -1, "", _ReposSkin.#lost);\n const after = this.cells.get(["folder", own.folder]);\n const last = this.cells.get(["last", this.stamp.asker]) ?? null;\n return { doing: _ReposSkin.#arg(after ?? null, "doing") ?? null, lost: [...lost], last };\n }\n async #folded(folder) {\n const listed = await this.ask("disk", "list", { path: [_ReposSkin.#repos] });\n if ("error" in listed)\n return listed.error.code === "absent" ? null : this.error("refused", `repos/ is not listed: ${listed.error.message}`);\n const names = _ReposSkin.#arg(listed.result, "names");\n const lower = folder.toLowerCase();\n const met = Array.isArray(names) ? names.find((name) => typeof name === "string" && name !== folder && name.toLowerCase() === lower) : void 0;\n return typeof met === "string" ? this.error("refused", `the folder ${folder} meets ${met}, which repos/ holds in another case`) : null;\n }\n folders(args) {\n const delegate = this.#delegate();\n if (this.stamp.asker !== _ReposSkin.#owner && delegate === null)\n return this.error("refused", "folders is an owner\'s or a delegate\'s");\n const page = this.#page(["folder"], args);\n if (!("cells" in page)) return page;\n const seen = page.cells.filter(\n ({ value }) => delegate === null || _ReposSkin.#fields(value) && (value["by"] === delegate || !_ReposSkin.#text(value["lobe"]))\n );\n const folders = seen.map(({ key, value }) => ({\n folder: key[1] ?? null,\n ..._ReposSkin.#fields(value) ? value : {}\n }));\n return { folders, cursor: page.cursor };\n }\n async remove(args) {\n const delegate = this.#delegate();\n if (this.stamp.asker !== _ReposSkin.#owner && delegate === null)\n return this.error("refused", "remove is an owner\'s or a delegate\'s");\n const folder = _ReposSkin.#arg(args, "folder");\n const erase = _ReposSkin.#arg(args, "erase") ?? false;\n if (typeof erase !== "boolean") return this.error("refused", "erase is true or false");\n if (!_ReposSkin.#text(folder)) return this.error("absent", "no such folder");\n const held = await this.#unstuck(["folder", folder]);\n if (!_ReposSkin.#fields(held)) return this.error("absent", "no such folder");\n if (delegate !== null && held["by"] !== delegate)\n return this.error("refused", `the folder ${folder} is none the delegate granted`);\n const doing = held["doing"];\n if (_ReposSkin.#text(doing)) return this.error("refused", `the folder ${folder} runs ${doing}: wait for it to end`);\n if (erase) return this.#erasing(folder, held);\n this.cells.delete(["folder", folder]);\n if (_ReposSkin.#text(held["lobe"])) await this.#release(held["lobe"], folder);\n return null;\n }\n async #erasing(folder, held) {\n const at = this.#at();\n if (at === null) return this.error("refused", "the disk\'s folder is not set up");\n if (!_ReposSkin.#folderName.test(folder)) return this.error("refused", "a folder is a repo’s name");\n const lobe = _ReposSkin.#text(held["lobe"]) ? held["lobe"] : "";\n if (lobe !== "") this.cells.delete(["lobe", lobe]);\n this.cells.set(["folder", folder], { ...held, lobe: null });\n return this.#begin("remove", folder, [at, folder, lobe], "");\n }\n async state() {\n if (this.stamp.asker === _ReposSkin.#owner) return this.cells.get(["setup"]) ?? null;\n const own = this.#own();\n if (!("folder" in own)) return own;\n const at = this.#at();\n const listed = own.held["made"] === true ? await this.ask("disk", "list", { path: [_ReposSkin.#repos] }) : null;\n const names = listed !== null && "result" in listed ? _ReposSkin.#arg(listed.result, "names") : void 0;\n const made = Array.isArray(names) && names.includes(own.folder);\n return {\n folder: at === null ? null : `${at}/${_ReposSkin.#repos}/${own.folder}`,\n made,\n doing: own.held["doing"] ?? null\n };\n }\n #own() {\n const { asker } = this.stamp;\n const folder = this.cells.get(["lobe", asker]);\n const held = typeof folder === "string" ? this.cells.get(["folder", folder]) : void 0;\n if (typeof folder !== "string" || !_ReposSkin.#fields(held))\n return this.error("refused", `the lobe ${asker} is granted no folder`);\n return { folder, held };\n }\n async #readMany(args, paths) {\n if (_ReposSkin.#arg(args, "path") !== void 0 || _ReposSkin.#arg(args, "first") !== void 0)\n return this.error("refused", "paths come alone, without path or first");\n if (!Array.isArray(paths) || paths.length === 0) return this.error("refused", "paths are one file or more");\n const named = paths.flatMap((one) => _ReposSkin.#text(one) && _ReposSkin.#names(one) !== null ? [one] : []);\n if (named.length !== paths.length)\n return this.error("refused", "a path is names under the repo, none empty, climbing or reaching .git");\n const reads = await Promise.all(named.map((path) => this.#disk("read", path)));\n const files = [];\n let weight = 0;\n for (const [at, read] of reads.entries()) {\n const path = named[at] ?? "";\n if (!("result" in read)) {\n if ("code" in read && read.code === "absent") files.push({ path, absent: true });\n else return read;\n continue;\n }\n const bytes = _ReposSkin.#arg(read.result, "bytes");\n const text = bytes instanceof Uint8Array ? this.#textOf(bytes) : null;\n if (!(bytes instanceof Uint8Array) || text === null) return this.error("refused", `${path} is not UTF-8 text`);\n weight += bytes.length;\n if (weight > this.memory / LOBE_SHARE)\n return this.error(\n "refused",\n `the files weigh past ${Math.floor(this.memory / LOBE_SHARE)} bytes, what one answer of this lobe carries`\n );\n files.push({ path, text });\n }\n return { files };\n }\n async read(args) {\n const paths = _ReposSkin.#arg(args, "paths");\n if (paths !== void 0) return this.#readMany(args, paths);\n const first = _ReposSkin.#arg(args, "first");\n if (first !== void 0 && !_ReposSkin.#count(first, Number.MAX_SAFE_INTEGER))\n return this.error("refused", "first is how many lines, one or more");\n const read = await this.#disk("read", _ReposSkin.#arg(args, "path"));\n if (!("result" in read)) return read;\n const bytes = _ReposSkin.#arg(read.result, "bytes");\n const text = bytes instanceof Uint8Array ? this.#textOf(bytes) : null;\n if (text === null) return this.error("refused", "the file is not UTF-8 text");\n const lines = text.split("\\n");\n return {\n text: first === void 0 ? text : lines.slice(0, first).join("\\n"),\n lines: lines.length\n };\n }\n async bytes(args) {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const sha = _ReposSkin.#arg(args, "sha");\n if (!_ReposSkin.#text(sha) || !_ReposSkin.#sha.test(sha))\n return this.error("refused", "a kept file is named by its SHA-256, in lowercase hex");\n const read = await this.ask("disk", "read", {\n path: [_ReposSkin.#transfers, this.stamp.asker, _ReposSkin.#kept, sha]\n });\n if ("error" in read) return this.error(read.error.code, read.error.message);\n const bytes = _ReposSkin.#arg(read.result, "bytes");\n return bytes instanceof Uint8Array ? { bytes } : this.error("refused", "the disk answered no bytes");\n }\n async write(args) {\n const text = _ReposSkin.#arg(args, "text");\n if (typeof text !== "string") return this.error("refused", "a write holds its text");\n const bytes = this.#bytes(text);\n if (bytes === null) return this.error("refused", "the text has no UTF-8");\n const wrote = await this.#disk("write", _ReposSkin.#arg(args, "path"), bytes);\n return "result" in wrote ? wrote.result : wrote;\n }\n async erase(args) {\n const erased = await this.#disk("remove", _ReposSkin.#arg(args, "path"));\n return "result" in erased ? erased.result : erased;\n }\n async list(args) {\n const path = _ReposSkin.#arg(args, "path");\n const listed = await this.#disk("list", path);\n const root = _ReposSkin.#names(path)?.length === 0;\n if (root && "code" in listed && listed.code === "absent") return { names: [] };\n return "result" in listed ? listed.result : listed;\n }\n async #disk(method, path, bytes) {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const names = _ReposSkin.#names(path);\n if (names === null || names.length === 0 && method !== "list")\n return this.error("refused", "a path is names under the repo, none empty, climbing or reaching .git");\n if (method !== "list" && names.join("/").toLowerCase() === _ReposSkin.#env)\n return this.error("refused", `${names.join("/")} is a secret file, written by secrets alone and read by no one`);\n const at = [_ReposSkin.#repos, own.folder, ...names];\n const answer = await this.ask("disk", method, bytes === void 0 ? { path: at } : { path: at, bytes });\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : answer;\n }\n async piece(args) {\n const path = await this.#piecePath(args);\n if (!Array.isArray(path)) return path;\n const read = await this.ask("disk", "read", { path });\n if ("error" in read) return this.#heard(read);\n return { bytes: _ReposSkin.#arg(read.result, "bytes") ?? null };\n }\n async put(args) {\n const path = await this.#piecePath(args);\n if (!Array.isArray(path)) return path;\n const pieces = _ReposSkin.#arg(args, "pieces");\n const at = _ReposSkin.#arg(args, "at");\n const bytes = _ReposSkin.#arg(args, "bytes");\n if (typeof pieces !== "number" || typeof at !== "number" || at >= pieces)\n return this.error("refused", "a piece stands before the count of its pieces");\n if (!(bytes instanceof Uint8Array)) return this.error("refused", "a piece holds its bytes");\n const wrote = await this.ask("disk", "write", { path, bytes });\n return this.#heard(wrote);\n }\n async #piecePath(args) {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const at = _ReposSkin.#arg(args, "at");\n const as = _ReposSkin.#arg(args, "as");\n if (typeof at !== "number" || !Number.isSafeInteger(at) || at < 0)\n return this.error("refused", "a piece stands at a place, from 0");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return this.error("refused", "a bundle waits as push, pull, out-<far> or in-<far>");\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n return [_ReposSkin.#transfers, this.stamp.asker, as, `q${at}`];\n }\n async #clearing(as) {\n const runs = [as, "*"].flatMap((name) => {\n const run = _ReposSkin.#arg(this.cells.get(["clearing", this.stamp.asker, name]) ?? null, "run");\n return _ReposSkin.#text(run) ? [run] : [];\n });\n if (runs.length === 0) return null;\n const lost = await this.#lostOf(runs) ?? [];\n for (const run of lost) await this.#end(run, -1, "", _ReposSkin.#lost);\n return runs.every((run) => lost.includes(run)) ? null : this.error("refused", `the pieces of ${as} are being cleared`);\n }\n async clear(args) {\n const as = _ReposSkin.#arg(args, "as");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return this.error("refused", "a bundle waits as push, pull, out-<far> or in-<far>");\n const own = this.#own();\n if (!("folder" in own)) return own;\n const at = this.#at();\n if (at === null) return this.error("refused", "the disk\'s folder is not set up");\n const { asker } = this.stamp;\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n const program = [..._ReposSkin.programs.clear, at, asker, as];\n const begun = await this.ask("shell", "run", { program, input: "" });\n if ("error" in begun) return this.error(begun.error.code, begun.error.message);\n const run = _ReposSkin.#arg(begun.result, "run");\n if (!_ReposSkin.#text(run)) return this.error("refused", "the shell named no run");\n this.cells.set(["job", run], {\n job: run,\n kind: "clear",\n asker,\n folder: own.folder,\n ended: null\n });\n this.cells.set(["by", asker, run], null);\n this.cells.set(["clearing", asker, as], { run });\n return { job: run };\n }\n #transfer(as) {\n return `${this.#at() ?? ""}/${_ReposSkin.#transfers}/${this.stamp.asker}/${as}`;\n }\n async init(args) {\n const unchecked = this.checked("init", args);\n if (unchecked !== void 0) return unchecked;\n const own = this.#own();\n const at = this.#at();\n if (!("folder" in own)) return own;\n if (at === null) return this.error("refused", "the disk\'s folder is not set up");\n const held = await this.#unstuck(["folder", own.folder]);\n const doing = _ReposSkin.#arg(held ?? null, "doing");\n if (_ReposSkin.#text(doing)) return this.error("refused", `${own.folder} runs ${doing} already`);\n const nonce = this.#nonce();\n const path = [_ReposSkin.#repos, own.folder, _ReposSkin.#marker];\n const wrote = await this.ask("disk", "write", { path, bytes: this.#bytes(nonce) });\n if ("error" in wrote) return this.#heard(wrote);\n return this.#begin("init", own.folder, [at, own.folder], `${nonce}\n`);\n }\n stand(args) {\n const checks = _ReposSkin.#checksOf(args);\n if (checks === null) return Promise.resolve(this.error("refused", "a stand names the check of the parts"));\n return this.#job("stand", [], JSON.stringify(checks));\n }\n head(args) {\n const contains = _ReposSkin.#arg(args, "contains");\n if (contains !== void 0 && !(_ReposSkin.#text(contains) && _ReposSkin.#hash.test(contains)))\n return Promise.resolve(this.error("refused", "contains is a commit"));\n return this.#job("head", typeof contains === "string" ? [contains] : [], "");\n }\n status() {\n return this.#job("status", [], "");\n }\n commit(args) {\n const message = _ReposSkin.#arg(args, "message");\n if (!_ReposSkin.#text(message)) return Promise.resolve(this.error("refused", "a commit holds its message"));\n const checks = _ReposSkin.#checksOf(args);\n if (checks === null) return Promise.resolve(this.error("refused", "a commit names the check of the parts"));\n const own = this.#own();\n if (!("folder" in own)) return Promise.resolve(own);\n const executable = _ReposSkin.#arg(args, "executable");\n const paths = _ReposSkin.#arg(args, "paths");\n if (paths !== void 0 && !_ReposSkin.#paths(paths))\n return Promise.resolve(\n this.error("refused", "a commit takes paths of the repo, each a file or a folder under it")\n );\n const input = JSON.stringify({ ...checks, message, executable, paths });\n return this.#job("commit", [], input);\n }\n static #checksOf(args) {\n const { parts, conform, scoped } = _ReposSkin.#fields(args) ? args : {};\n if (!_ReposSkin.#text(parts)) return null;\n if (conform !== void 0 && !(_ReposSkin.#text(conform) && _ReposSkin.#hash.test(conform))) return null;\n if (scoped !== void 0 && typeof scoped !== "boolean") return null;\n return { parts, ...conform === void 0 ? {} : { conform }, ...scoped === true ? { scoped } : {} };\n }\n discard() {\n return this.#job("discard", [], "");\n }\n log(args) {\n const most = _ReposSkin.#arg(args, "most") ?? _ReposSkin.#logs;\n if (!_ReposSkin.#count(most, this.#most()))\n return Promise.resolve(this.error("refused", `most is how many commits, one to ${this.#most()}`));\n return this.#job("log", [String(most)], "");\n }\n run(args) {\n const script = _ReposSkin.#arg(args, "script");\n const install = _ReposSkin.#arg(args, "install") ?? false;\n const words = _ReposSkin.#argsOf(_ReposSkin.#arg(args, "args"));\n if (!_ReposSkin.#text(script) || !_ReposSkin.#script.test(script))\n return Promise.resolve(this.error("refused", "a run names a script of the repo\'s package"));\n if (typeof install !== "boolean") return Promise.resolve(this.error("refused", "install is true or false"));\n const gate = _ReposSkin.#arg(args, "gate") ?? false;\n if (typeof gate !== "boolean") return Promise.resolve(this.error("refused", "gate is true or false"));\n if (words === null)\n return Promise.resolve(this.error("refused", `a run\'s args are texts, at most ${ARGS_MOST}, none holding a NUL`));\n return this.#job("run", [script, install ? "install" : "", gate ? "gate" : "", ...words], "");\n }\n secrets(args) {\n const set = this.#linesOf(_ReposSkin.#arg(args, "set"));\n if (set === null)\n return Promise.resolve(\n this.error("refused", "a secret file\'s lines are each an environment variable\'s name and a value of one line")\n );\n const own = this.#own();\n if (!("folder" in own)) return Promise.resolve(own);\n return this.#job("secrets", [], JSON.stringify({ set }));\n }\n async bundle(args) {\n const since = _ReposSkin.#arg(args, "since") ?? null;\n const as = _ReposSkin.#arg(args, "as");\n if (since !== null && !(_ReposSkin.#text(since) && _ReposSkin.#hash.test(since)))\n return this.error("refused", "since is a commit, or null");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return this.error("refused", "a bundle waits as push, pull, out-<far> or in-<far>");\n const cut = _ReposSkin.#arg(args, "cut") ?? false;\n if (typeof cut !== "boolean") return this.error("refused", "cut is true or false");\n const tag = _ReposSkin.#arg(args, "tag");\n if (tag !== void 0 && !(_ReposSkin.#text(tag) && _ReposSkin.#tag.test(tag)))\n return this.error("refused", "a tag is v and three whole numbers");\n if (cut && tag !== void 0) return this.error("refused", "a cut is bundled by no tag");\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n const most = Math.floor(this.memory / LOBE_SHARE);\n const piece = _ReposSkin.#arg(args, "piece") ?? _ReposSkin.#box;\n if (!_ReposSkin.#count(piece, most))\n return this.error("refused", `a piece is a whole number of bytes, one to ${most}`);\n const words = [cut ? `refs/nervur/cut-${as}` : "", typeof tag === "string" ? tag : "", String(piece)];\n return this.#job("bundle", [this.#transfer(as), since ?? "", ...words], "");\n }\n cut(args) {\n const as = _ReposSkin.#arg(args, "as");\n const tag = _ReposSkin.#arg(args, "tag");\n if (tag !== void 0 && !(_ReposSkin.#text(tag) && _ReposSkin.#tag.test(tag)))\n return Promise.resolve(this.error("refused", "a tag is v and three whole numbers"));\n const scope = _ReposSkin.#scopeOf(_ReposSkin.#arg(args, "scope"));\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return Promise.resolve(this.error("refused", "a cut is named as push, pull, out-<far> or in-<far>"));\n if (scope === null)\n return Promise.resolve(\n this.error("refused", `a scope is 1 to ${SCOPE_MOST} folders of the repo, none inside another`)\n );\n return this.#job("cut", [as, typeof tag === "string" ? tag : "", ...scope], "");\n }\n async bring(args) {\n const as = _ReposSkin.#arg(args, "as");\n const pieces = _ReposSkin.#arg(args, "pieces");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as) || !_ReposSkin.#count(pieces, Number.MAX_SAFE_INTEGER))\n return this.error("refused", "a bundle names where it waits and its pieces");\n const scoped = _ReposSkin.#arg(args, "scope");\n const scope = scoped === void 0 ? [] : _ReposSkin.#scopeOf(scoped);\n if (scope === null)\n return this.error("refused", `a scope is 1 to ${SCOPE_MOST} folders of the repo, none inside another`);\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n return this.#job(scope.length === 0 ? "bring" : "graft", [this.#transfer(as), String(pieces), as, ...scope], "");\n }\n land(args) {\n const as = _ReposSkin.#arg(args, "as");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return Promise.resolve(this.error("refused", "a landing names what waits, as push, pull, out-<far> or in-<far>"));\n return this.#job("land", [as], "");\n }\n conform(args) {\n const { as, head, script } = _ReposSkin.#fields(args) ? args : {};\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as) || !_ReposSkin.#text(head) || !_ReposSkin.#hash.test(head))\n return Promise.resolve(\n this.error("refused", "a conform names what waits, as push, pull, out-<far> or in-<far>, and its head")\n );\n if (script !== void 0 && !(_ReposSkin.#text(script) && _ReposSkin.#script.test(script)))\n return Promise.resolve(this.error("refused", "a gate is a script of the repo\'s package"));\n const checks = _ReposSkin.#checksOf(args);\n if (checks === null) return Promise.resolve(this.error("refused", "a conform names the check of the parts"));\n const words = typeof script === "string" ? [as, head, script] : [as, head];\n return this.#job("conform", words, JSON.stringify(checks));\n }\n scan() {\n return this.#job("scan", [this.#transfer(_ReposSkin.#kept)], "");\n }\n build(args) {\n const organ = _ReposSkin.#arg(args, "organ");\n if (!_ReposSkin.#text(organ) || organ.length > 64 || !_ReposSkin.#organ.test(organ))\n return Promise.resolve(this.error("refused", "an organ is named by its fixed ID"));\n return this.#job("build", [organ], "");\n }\n look(args) {\n const design = _ReposSkin.#arg(args, "design");\n if (!_ReposSkin.#text(design) || design.length > 59 || !_ReposSkin.#design.test(design))\n return Promise.resolve(this.error("refused", "a design is named by its folder"));\n return this.#job("look", [design], "");\n }\n async stop(args) {\n const named = _ReposSkin.#arg(args, "folder");\n const owner = this.stamp.asker === _ReposSkin.#owner;\n if (!owner && named !== void 0) return this.error("refused", "a repo lobe reaches its own folder alone");\n const folder = owner ? named : this.cells.get(["lobe", this.stamp.asker]);\n const held = _ReposSkin.#text(folder) ? this.cells.get(["folder", folder]) : void 0;\n if (!_ReposSkin.#text(folder) || !_ReposSkin.#fields(held)) return this.error("refused", "no such folder");\n const doing = held["doing"];\n if (!_ReposSkin.#text(doing)) return this.error("refused", `the folder ${folder} runs nothing`);\n const asker = _ReposSkin.#arg(this.cells.get(["job", doing]) ?? null, "asker");\n if (!owner && asker !== this.stamp.asker)\n return this.error("refused", `the folder ${folder} runs another lobe\'s job`);\n const stopped = await this.ask("shell", "stop", { run: doing });\n if (!("error" in stopped)) return null;\n if (stopped.error.code !== "refused") return this.#heard(stopped);\n return this.#end(doing, -1, "", _ReposSkin.#lost);\n }\n async back(args) {\n if (this.stamp.asker !== _ReposSkin.#owner || _ReposSkin.#arg(args, "placeholder") !== "shell") return null;\n const going = [\n ...[this.cells.get(["setup"]), ...this.#all(["folder"]).map(({ value }) => value)].map(\n (held) => _ReposSkin.#arg(held ?? null, "doing")\n ),\n ...this.#all(["clearing"]).map(({ value }) => _ReposSkin.#arg(value, "run"))\n ].filter((run) => _ReposSkin.#text(run));\n const lost = going.length === 0 ? [] : await this.#lostOf(going) ?? [];\n for (const run of lost) await this.#end(run, -1, "", _ReposSkin.#lost);\n return null;\n }\n async ended(args) {\n const read = await this.nerves.read();\n await this.#torn(read);\n const { run, code, out, err } = _ReposSkin.#fields(args) ? args : {};\n const whole = typeof out === "string" && typeof err === "string" && typeof code === "number";\n if (!whole || !_ReposSkin.#text(run))\n return this.error("refused", "an end names its run, its exit code and its output");\n return this.#end(run, code, out, err, read);\n }\n async #end(job, code, out, err, read) {\n const run = job;\n const held = this.cells.get(["job", run]);\n if (!_ReposSkin.#fields(held) || held["ended"] !== null) return this.error("refused", "no such job going");\n const { asker, kind, folder } = held;\n if (kind === "clear") return this.#cleared(run, asker);\n this.cells.set(["job", run], { ...held, ended: { code } });\n if (_ReposSkin.#text(asker)) this.#endKept(asker, run);\n this.#settled(kind, folder, code);\n if (!_ReposSkin.#text(asker) || asker === _ReposSkin.#owner) return null;\n if (!_ReposSkin.#ends(read ?? await this.nerves.read()).has(asker)) return null;\n const told = { job: run, kind: kind ?? null, code, out, err };\n this.cells.set(["last", asker], told);\n const letter = { lives: _ReposSkin.#lives };\n return this.#heard(await this.ask(asker, "done", told, void 0, { letter }));\n }\n #cleared(run, asker) {\n for (const { key, value } of this.#all(["clearing"]))\n if (_ReposSkin.#arg(value, "run") === run) this.cells.delete(key);\n this.cells.delete(["job", run]);\n if (_ReposSkin.#text(asker)) this.cells.delete(["by", asker, run]);\n return null;\n }\n #endKept(asker, run) {\n const ends = this.cells.get(["ended", asker]);\n let first = Number(_ReposSkin.#arg(ends ?? null, "first") ?? 0);\n const next = Number(_ReposSkin.#arg(ends ?? null, "next") ?? 0);\n for (; next - first >= Math.max(1, this.#most()); first += 1) {\n const oldest = this.cells.get(["ended", asker, String(first)]);\n if (_ReposSkin.#text(oldest)) {\n this.cells.delete(["job", oldest]);\n this.cells.delete(["by", asker, oldest]);\n }\n this.cells.delete(["ended", asker, String(first)]);\n }\n this.cells.set(["ended", asker, String(next)], run);\n this.cells.set(["ended", asker], { first, next: next + 1 });\n }\n #settled(kind, folder, code) {\n if (kind === "setup") {\n const setup = this.cells.get(["setup"]);\n const failed = code === 0 ? null : "the marker was not read back";\n if (_ReposSkin.#fields(setup)) this.cells.set(["setup"], { ...setup, ready: code === 0, failed, doing: null });\n return;\n }\n const held = _ReposSkin.#text(folder) ? this.cells.get(["folder", folder]) : void 0;\n if (!_ReposSkin.#text(folder) || !_ReposSkin.#fields(held)) return;\n if (kind === "remove" && code === 0) {\n this.cells.delete(["folder", folder]);\n return;\n }\n const proven = (kind === "init" || kind === "stand" || kind === "head") && code === 0 ? { made: true } : {};\n this.cells.set(["folder", folder], { ...held, ...proven, doing: null });\n }\n jobs(args) {\n const { asker } = this.stamp;\n const page = this.#page(asker === _ReposSkin.#owner ? ["job"] : ["by", asker], args);\n if (!("cells" in page)) return page;\n const jobs = asker === _ReposSkin.#owner ? page.cells.map(({ value }) => value) : page.cells.map(({ key }) => this.cells.get(["job", key[2] ?? ""]) ?? null);\n return { jobs, cursor: page.cursor };\n }\n job(args) {\n const run = _ReposSkin.#arg(args, "job");\n if (!_ReposSkin.#text(run)) return this.error("refused", "a job is named by its id");\n const { asker } = this.stamp;\n const held = this.cells.get(["job", run]);\n const owns = asker === _ReposSkin.#owner || this.cells.get(["by", asker, run]) !== void 0;\n if (!owns || !_ReposSkin.#fields(held)) return this.error("absent", "no such job");\n return held;\n }\n async #back(folder) {\n const { asker } = this.stamp;\n if (this.cells.get(["lobe", asker]) !== folder || _ReposSkin.#ends(await this.nerves.read()).has(asker)) return null;\n const ordered = await this.nerves.order({ termination: asker });\n return "error" in ordered ? this.error("refused", `no wire back: ${ordered.error.message}`) : null;\n }\n #job(kind, more, input) {\n const own = this.#own();\n if (!("folder" in own)) return Promise.resolve(own);\n const at = this.#at();\n if (at === null) return Promise.resolve(this.error("refused", "the disk\'s folder is not set up"));\n const dir = `${at}/${_ReposSkin.#repos}/${own.folder}`;\n return this.#begin(kind, own.folder, [dir, ...more], input);\n }\n async #begin(kind, folder, words, input) {\n const record = await this.#unstuck(folder === null ? ["setup"] : ["folder", folder]);\n if (!_ReposSkin.#fields(record)) return this.error("refused", "no such folder");\n if (_ReposSkin.#text(record["doing"]))\n return this.error("refused", `${folder ?? "the setup"} runs ${record["doing"]} already`);\n const { asker } = this.stamp;\n const back = folder === null ? null : await this.#back(folder);\n if (back !== null) return back;\n const program = [..._ReposSkin.programs[kind], ...words];\n const begun = await this.ask("shell", "run", { program, input });\n if ("error" in begun) return this.error(begun.error.code, begun.error.message);\n const run = _ReposSkin.#arg(begun.result, "run");\n if (!_ReposSkin.#text(run)) return this.error("refused", "the shell named no run");\n this.cells.set(["job", run], { job: run, kind, asker, folder, ended: null });\n this.cells.set(["by", asker, run], null);\n this.cells.set(folder === null ? ["setup"] : ["folder", folder], { ...record, doing: run });\n return { job: run };\n }\n};\nexport {\n ReposSkin as default\n};\n';
1239
+ var REPOS_SOURCE = 'import { Faculty } from "nervur:faculty";\n\nvar BOX = 1048576;\nvar LETTER_LIVES = 864e5;\nvar LOBE_SHARE = 4;\nvar ITEM_SIZE = 1024;\nvar CELLS_RANGE = 1e3;\nvar LOGS = 20;\nvar ARG_LONGEST = 4096;\nvar ARGS_MOST = 64;\nvar SCOPE_MOST = 16;\n\nvar ReposSkin = class _ReposSkin extends Faculty {\n static #owner = "brain";\n static #lost = "the shell runs it no more: it was lost, as to a restart of the organ";\n static #box = BOX;\n static #lives = LETTER_LIVES;\n static #logs = LOGS;\n static #repos = "repos";\n static #transfers = "transfers";\n static #marker = "nervur-marker";\n static #env = ".env";\n static #folderName = /^[a-z](?:[a-z0-9-]|\\.(?=[a-z0-9-])){0,63}$/;\n static #name = /^(?!\\.{1,2}$)(?!\\.git$)[^/\\\\\\0]+$/i;\n static #script = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,63}$/;\n static #key = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;\n static #line = /^[^\\n\\r\\0]*$/;\n static #hash = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;\n static #sha = /^[0-9a-f]{64}$/;\n static #kept = "kept";\n static #organ = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n static #as = /^(?:push|pull|(?:out|in)-[A-Za-z0-9-]{1,64})$/;\n static #tag = /^v(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$/;\n static #segment = /^[A-Za-z0-9._-]+$/;\n static #design = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;\n static #marked = `IFS= read -r m; [ "$(cat nervur-marker)" = "$m" ] || { echo "the disk\'s folder is not $1" >&2; exit 1; }; rm nervur-marker`;\n static #exact(path, under, name) {\n return `{ [ -d "${path}" ] && [ ! -L "${path}" ] && ls -1A "${under}" | grep -qxF -- "${name}"; } || { echo "the folder ${name} stands not as named under repos" >&2; exit 1; }\n`;\n }\n static #ident = "export GIT_AUTHOR_NAME=Nervur GIT_AUTHOR_EMAIL=nervur@invalid GIT_COMMITTER_NAME=Nervur GIT_COMMITTER_EMAIL=nervur@invalid\\n";\n static #lend(dir) {\n return `if [ -n "\\${NERVUR_GENOME+x}" ]; then { [ -d "$NERVUR_GENOME" ] && [ -r "$NERVUR_GENOME" ] && [ -x "$NERVUR_GENOME" ]; } || { echo "NERVUR_GENOME $NERVUR_GENOME is no folder this account can read" >&2; exit 1; }; mkdir -p "${dir}/node_modules/@nervur.org" && ln -sfn "$NERVUR_GENOME" "${dir}/node_modules/@nervur.org/genome" || exit 1; fi\n`;\n }\n static #in = `${_ReposSkin.#exact("$1", "${1%/*}", "${1##*/}")}cd "$1" || exit 1\nexport GIT_CEILING_DIRECTORIES="\\${1%/*}"\n${_ReposSkin.#ident}`;\n static #keep = `k="$2"; c="$(printf \'\\\\t\')"\n[ -n "$k" ] || { echo "a scan names where it keeps" >&2; exit 1; }\nmkdir -p "$k/.t" "$k/.o" || exit 1\ngit tag --list \'v*\' | grep -E \'^v[0-9]+\\\\.[0-9]+\\\\.[0-9]+$\' | while IFS= read -r g; do [ -e "$k/.t/$g" ] && continue; git -c core.quotePath=false ls-tree -r "$g" -- designs faculties | while IFS="$c" read -r m p; do case "$p" in designs/*|faculties/*/assets/*) ;; *) continue ;; esac; o=\\${m##* }; [ "\\${m#* }" = "blob $o" ] || continue; [ -s "$k/.o/$o" ] && continue; git cat-file blob "$o" | perl -0777 -pe \'s/\\\\r\\\\n?/\\\\n/g unless /\\\\0/\' >"$k/.w" || exit 1; s=$({ sha256sum 2>/dev/null || shasum -a 256; } <"$k/.w" | cut -d " " -f 1); mv -f "$k/.w" "$k/$s" && echo "$s" >"$k/.o/$o" || exit 1; done || exit 1; : >"$k/.t/$g" || exit 1; done || exit 1\n`;\n static #untag = `git for-each-ref --format=\'delete %(refname)\' "$r-tags/" | git update-ref --stdin`;\n static #fetched = `${_ReposSkin.#in}trap \'rm -rf "$2"\' EXIT\nr="refs/nervur/$4"\ngit update-ref -d "$r" 2>/dev/null; git update-ref -d "$r-main" 2>/dev/null; ${_ReposSkin.#untag}\ncd "$2" || exit 1\ni=0; while [ "$i" -lt "$3" ]; do cat "q$i" || exit 1; i=$((i + 1)); done > b || exit 1\ncd "$1" || exit 1\ngit fetch --quiet --no-tags "$2/b" "+main:$r" || exit 1\n`;\n static #tagged = `git fetch --quiet --no-tags "$2/b" "+refs/tags/v*:$r-tags/v*" || exit 1\nw=$(git for-each-ref --format=\'%(objecttype) %(objectname) %(refname)\' "$r-tags/" | while read -r y o n; do n=\\${n#"$r-tags/"}; if [ "$y" != commit ] || ! git merge-base --is-ancestor "$o" "$r" 2>/dev/null; then echo "the tag $n names no commit it brings"; elif e=$(git rev-parse -q --verify "refs/tags/$n^{commit}") && [ "$e" != "$o" ]; then echo "this lobe holds the tag $n on another commit: a version names one commit for ever"; fi; done)\nif [ -n "$w" ]; then git update-ref -d "$r"; ${_ReposSkin.#untag}; echo "$w" >&2; exit 1; fi\n`;\n static #bring = `${_ReposSkin.#fetched}${_ReposSkin.#tagged}c=$(git rev-parse "$r") || exit 1\nif ! h=$(git rev-parse -q --verify HEAD); then m=new\nelif git merge-base --is-ancestor "$c" "$h"; then git update-ref -d "$r"; ${_ReposSkin.#untag}; echo "$h"; echo held; exit 0\nelif git merge-base --is-ancestor "$h" "$c"; then m=forward\nelse t=$(mktemp -d) || exit 1\ngit worktree add --quiet --detach "$t/w" "$h" >/dev/null 2>&1 || exit 1\nif git -C "$t/w" merge --quiet --no-edit "$c" >/dev/null 2>&1; then c=$(git -C "$t/w" rev-parse HEAD); m=merge; else m=; fi\ngit worktree remove --force "$t/w"; rm -rf "$t"\n[ -n "$m" ] || { git update-ref -d "$r"; ${_ReposSkin.#untag}; echo "it meets a conflict with main: merge it where it is authored, and send it again" >&2; exit 1; }\nfi\ngit update-ref "$r-main" "$c" && echo "$c" && echo "$m"`;\n static #cutting = [\n \'const { execFileSync } = require("node:child_process"); const fs = require("node:fs"); const os = require("node:os"); const path = require("node:path");\',\n \'const [as = "", ...scope] = process.argv.slice(1);\',\n \'const git = (args, input, env) => execFileSync("git", args, { input: input === undefined ? "" : input, env: env === undefined ? process.env : env, maxBuffer: 1073741824, stdio: ["pipe", "pipe", "pipe"] });\',\n \'const line = (args) => git(args).toString("utf8").trim();\',\n \'const maybe = (args) => { try { return line(args); } catch { return ""; } };\',\n "const holds = (args) => { try { git(args); return true; } catch { return false; } };",\n \'const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nervur-cut-")); process.on("exit", () => fs.rmSync(tmp, { recursive: true, force: true }));\',\n \'const index = path.join(tmp, "index");\',\n \'const within = (p) => scope.some((s) => p.startsWith(s + "/"));\',\n \'const entries = (args) => git(["ls-tree", "-r", "-z", ...args]).toString("latin1").split("\\\\0").filter((e) => e !== "");\',\n \'const named = (e) => e.slice(e.indexOf("\\\\t") + 1);\',\n \'const treeOf = (all) => { fs.rmSync(index, { force: true }); const env = { ...process.env, GIT_INDEX_FILE: index }; if (all.length > 0) git(["update-index", "-z", "--index-info"], Buffer.from(all.map((e) => e + "\\\\0").join(""), "latin1"), env); return git(["write-tree"], "", env).toString("utf8").trim(); };\',\n \'const who = (header, role) => { const m = new RegExp("^" + role + " (.*) <([^>\\\\\\\\n]*)> ([0-9]+) ([-+][0-9]{4})$", "m").exec(header); if (m === null) throw new Error("its " + role + " is not as git writes it"); return m; };\',\n \'const kept = (c, tree, parent) => { const raw = git(["cat-file", "commit", c]); const at = raw.indexOf("\\\\n\\\\n"); const header = raw.subarray(0, at < 0 ? raw.length : at).toString("utf8"); const message = at < 0 ? Buffer.alloc(0) : raw.subarray(at + 2); const a = who(header, "author"); const k = who(header, "committer"); const env = { ...process.env, GIT_AUTHOR_NAME: a[1], GIT_AUTHOR_EMAIL: a[2], GIT_AUTHOR_DATE: "@" + a[3] + " " + a[4], GIT_COMMITTER_NAME: k[1], GIT_COMMITTER_EMAIL: k[2], GIT_COMMITTER_DATE: "@" + k[3] + " " + k[4] }; return git(["commit-tree", "--no-gpg-sign", tree, ...(parent === "" ? [] : ["-p", parent])], message, env).toString("utf8").trim(); };\',\n \'const walk = (commits, from) => { const seen = commits.length === 0 ? [] : git(["cat-file", "--batch-check=%(objecttype) %(objectname)"], commits.flatMap((c) => scope.map((s) => c + ":" + s)).join("\\\\n") + "\\\\n").toString("utf8").split("\\\\n"); let { head, last } = from; commits.forEach((c, i) => { const oids = scope.map((s, j) => { const [type = "", oid = ""] = (seen[i * scope.length + j] ?? "").split(" "); return type === "tree" ? oid : "-"; }); const key = oids.join(" "); if (key === last) return; last = key; const trees = scope.filter((s, j) => oids[j] !== "-"); head = kept(c, treeOf(trees.length === 0 ? [] : entries([c, "--", ...trees])), head); }); return { head, last }; };\',\n \'const main = maybe(["rev-parse", "-q", "--verify", "refs/heads/main^{commit}"]);\',\n \'const tag = process.env.NERVUR_CUT_TAG === undefined ? "" : process.env.NERVUR_CUT_TAG;\',\n \'const tagged = tag === "" ? "" : maybe(["rev-parse", "-q", "--verify", "refs/tags/" + tag + "^{commit}"]);\',\n \'if (tag !== "" && tagged === "") { process.stderr.write("this lobe holds no tag " + tag + "\\\\n"); process.exit(1); }\',\n \'const upto = tagged === "" ? null : new Set(line(["rev-list", tagged]).split("\\\\n"));\',\n \'const firsts = (main === "" ? [] : line(["rev-list", "--first-parent", "--reverse", main]).split("\\\\n").filter((c) => c !== "")).filter((c) => upto === null || upto.has(c));\',\n \'const cut = walk(firsts, { head: "", last: scope.map(() => "-").join(" ") });\'\n ].join("\\n");\n static #cut = `${_ReposSkin.#in}a=$2; t=$3; shift 3\nNERVUR_CUT_TAG="$t" node -e \'${_ReposSkin.#cutting}\nif (cut.head === "") maybe(["update-ref", "-d", "refs/nervur/cut-" + as]); else git(["update-ref", "refs/nervur/cut-" + as, cut.head]);\nprocess.stdout.write(cut.head + "\\\\n");\' -- "$a" "$@"`;\n static #graft = `${_ReposSkin.#fetched}a=$4; shift 4\nNERVUR_CUT_TAG= node -e \'${[\n _ReposSkin.#cutting,\n \'const r = "refs/nervur/" + as; const refused = (why) => { maybe(["update-ref", "-d", r]); process.stderr.write(why + "\\\\n"); process.exit(1); };\',\n \'const tip = line(["rev-parse", r]);\',\n \'if (cut.head !== "" && tip === cut.head) { maybe(["update-ref", "-d", r]); process.stdout.write(tip + "\\\\nheld\\\\n"); process.exit(0); }\',\n \'if (cut.head !== "" && !holds(["merge-base", "--is-ancestor", cut.head, tip])) refused("behind the scope\\\\u0027s head; pull first");\',\n \'const pushed = line(["rev-list", "--reverse", "--parents", cut.head === "" ? tip : cut.head + ".." + tip]).split("\\\\n").filter((l) => l !== "").map((l) => l.split(" "));\',\n "let before = cut.head;",\n \'for (const [c = "", ...parents] of pushed) { if (parents.length > 1 || (parents[0] ?? "") !== before) refused("a push into a scope is linear on its head, and " + c + " is not"); const changed = git(["diff-tree", "-r", "-z", "--name-only", "--no-commit-id", ...(before === "" ? ["--root", c] : [before, c])]).toString("latin1").split("\\\\0").filter((p) => p !== ""); const outside = changed.find((p) => !within(p)); if (outside !== undefined) refused(c + " changes " + outside + ", outside the scope"); if (changed.length === 0) refused(c + " changes nothing within the scope"); before = c; }\',\n \'const outside = main === "" ? [] : entries([main]).filter((e) => !within(named(e)));\',\n \'let grafted = main; const graft = pushed.map(([c = ""]) => { grafted = kept(c, treeOf([...outside, ...entries([c]).filter((e) => within(named(e)))]), grafted); return grafted; });\',\n \'if (walk(graft, cut).head !== tip) refused("the scope cut again answers not the commits pushed: one carries what a cut drops, as a signature");\',\n \'git(["update-ref", r + "-main", grafted]); process.stdout.write(grafted + "\\\\ngraft\\\\n" + tip + "\\\\n");\'\n ].join("\\n")}\' -- "$a" "$@"`;\n static #mask = \'const { spawn } = require("node:child_process"); const fs = require("node:fs"); const env = { ...process.env }; const values = []; let held = ""; try { held = fs.readFileSync(process.argv[1], "utf8"); } catch {} for (const line of held.split("\\\\n")) { const at = line.indexOf("="); if (at < 1 || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(line.slice(0, at))) continue; env[line.slice(0, at)] = line.slice(at + 1); if (at + 1 < line.length) values.push(line.slice(at + 1)); } const shown = values.sort((a, b) => b.length - a.length || (a < b ? -1 : a > b ? 1 : 0)); const mask = (t) => shown.reduce((s, v) => s.split(v).join("[secret]"), t); const c = spawn(process.argv[2], process.argv.slice(3), { env, stdio: ["ignore", "pipe", "pipe"] }); const pass = (from, to) => { let kept = ""; from.setEncoding("utf8"); from.on("data", (d) => { kept += d; const i = kept.lastIndexOf("\\\\n") + 1; if (i > 0) { to.write(mask(kept.slice(0, i))); kept = kept.slice(i); } }); from.on("end", () => to.write(mask(kept))); }; pass(c.stdout, process.stdout); pass(c.stderr, process.stderr); for (const s of ["SIGTERM", "SIGINT", "SIGHUP"]) process.on(s, () => c.kill(s)); c.on("error", (e) => { process.stderr.write(e.message + "\\\\n"); process.exitCode = 127; }); c.on("close", (code) => { process.exitCode = code ?? 1; });\';\n static #masked = `node -e \'${_ReposSkin.#mask}\' -- "$1/${_ReposSkin.#env}"`;\n static #scripted = `node -e \'process.exit(require("./package.json").scripts?.[process.argv[1]] ? 0 : 3)\' "$2" 2>/dev/null || { echo "the repo holds no script $2" >&2; exit 3; }\n`;\n static #queued = `q="\\${1%/*}/.gates"; mkdir -p "$q" || exit 1\nlive() { find "$q" -type f -empty -mmin +1 -exec rm -f {} + 2>/dev/null; for gt in "$q"/*; do [ -e "$gt" ] || [ -L "$gt" ] || continue; [ -f "$gt" ] && [ ! -L "$gt" ] || { rm -f "$gt"; continue; }; [ -s "$gt" ] || continue; gp=$(sed -n 1p "$gt"); gs=$(sed -n 2p "$gt"); [ -n "$gp" ] && [ "$(ps -o lstart= -p "$gp" 2>/dev/null)" = "$gs" ] || rm -f "$gt"; done; }\nwhile :; do while :; do live; n=$(ls -1 "$q" | tail -1 | sed \'s/^0*//\'); me=$(printf \'%012d\' $(( \\${n:-0} + 1 ))); ( set -C; printf \'%s\\\\n%s\\\\n\' "$$" "$(ps -o lstart= -p $$)" > "$q/$me" ) 2>/dev/null && break; done; while [ -f "$q/$me" ]; do live; [ "$(ls -1 "$q" | head -1)" = "$me" ] && break 2; sleep 0.2; done; done\n`;\n static #unpack = [\n \'const fs = require("node:fs"); const { execFileSync } = require("node:child_process");\',\n \'const held = (args) => { try { return execFileSync("git", args, { stdio: ["ignore", "pipe", "ignore"], maxBuffer: 268435456 }).toString("utf8"); } catch { return null; } };\',\n \'const at = (file) => process.argv[1] + "/" + file;\',\n \'let s = ""; process.stdin.setEncoding("utf8"); process.stdin.on("data", (d) => { s += d; }); process.stdin.on("end", () => {\',\n "const given = JSON.parse(s);",\n \'for (const [name, file] of [["parts", "parts.mjs"], ["message", "message"], ["conform", "chosen"]]) if (typeof given[name] === "string") fs.writeFileSync(at(file), given[name]);\',\n \'if (Array.isArray(given.executable)) fs.writeFileSync(at("executable"), given.executable.map((path) => path + "\\\\0").join(""));\',\n \'if (Array.isArray(given.paths)) fs.writeFileSync(at("paths"), given.paths.map((path) => path + "\\\\0").join(""));\',\n \'if (given.scoped === true) fs.writeFileSync(at("scoped"), "");\',\n \'if (!fs.existsSync(at("parts.mjs"))) { process.stderr.write("no check of the parts was given\\\\n"); process.exit(1); }\',\n \'const tag = held(["describe", "--tags", "--abbrev=0", "--match", "v*", "HEAD"]);\',\n "if (tag === null) return;",\n "const told = {};",\n \'for (const path of (held(["ls-tree", "-r", "--name-only", tag.trim()]) ?? "").split("\\\\n")) {\',\n "if (!/^(faculties|designs)\\\\/[^/]+\\\\/versions\\\\.json$/.test(path)) continue;",\n \'const text = held(["show", tag.trim() + ":" + path]); if (text !== null) told[path] = text;\',\n "}",\n \'fs.writeFileSync(at("told.json"), JSON.stringify(told));\',\n "});"\n ].join("\\n");\n static #checks = `told=\n[ ! -f "$t/told.json" ] || told="$t/told.json"\nnode "$t/parts.mjs" "$w" \\${told:+"$told"} || exit 1\nif [ -f "$t/scoped" ]; then echo "conform: skipped: a lobe holding a scope is checked by the lobe it pushes to"\nelif [ ! -f "$t/chosen" ]; then echo "conform: skipped: no conform is chosen: the check of the parts alone"\nelse k=$(cat "$t/chosen")\ngit cat-file -e "$k^{commit}" 2>/dev/null || { echo "the commit whose conform is chosen, $k, the repo holds not"; exit 1; }\nif git show "$k:tools/conform.mjs" > "$t/conform.mjs" 2>/dev/null; then node "$t/conform.mjs" "$w" || exit 1; else echo "conform: skipped: the commit chosen, $k, holds no tools/conform.mjs"; fi\nfi\n`;\n static #versioning = [\n \'const fs = require("node:fs"); const { execFileSync } = require("node:child_process");\',\n \'const of = (text) => { try { const v = JSON.parse(text).version; return typeof v === "string" ? v : null; } catch { return null; } };\',\n \'const held = (args) => { try { return execFileSync("git", args, { stdio: ["ignore", "pipe", "ignore"] }).toString("utf8"); } catch { return null; } };\',\n \'let read = null; try { read = fs.readFileSync(process.argv[1], "utf8"); } catch {}\',\n \'const now = read === null ? null : of(read); const parent = held(["show", "HEAD:package.json"]); const was = parent === null ? null : of(parent);\',\n "if (now === was) process.exit(0);",\n \'const refused = (why) => { process.stderr.write(why +"\\\\n"); process.exit(1); };\',\n "const three = /^(0|[1-9][0-9]*)\\\\.(0|[1-9][0-9]*)\\\\.(0|[1-9][0-9]*)$/;",\n \'if (now === null || !three.test(now)) refused("the root version " + (now === null ? "none" : now) + " is not three whole numbers");\',\n \'const parts = (v) => v.split(".").map((n) => BigInt(n));\',\n \'if (was !== null && three.test(was)) { const [a, b] = [parts(now), parts(was)]; const at = a.findIndex((n, i) => n !== b[i]); if (at >= 0 && a[at] < b[at]) refused("the root version " + now + " is lower than " + was + ": a version is only raised"); }\',\n \'const tag = "v" + now;\',\n \'if (held(["rev-parse", "-q", "--verify", "refs/tags/" + tag]) !== null) refused("this lobe holds the tag " + tag + " already: a version names one commit for ever");\',\n \'process.stdout.write(tag + "\\\\n");\'\n ].join("\\n");\n static #versioned = `v=\nif [ ! -f "$t/scoped" ]; then v=$(node -e \'${_ReposSkin.#versioning}\' -- "$w/package.json") || exit 1; fi\n`;\n static #unsecret = `if [ -e ${_ReposSkin.#env} ] && ! git check-ignore -q -- ${_ReposSkin.#env}; then echo "${_ReposSkin.#env} is a secret file .gitignore keeps not out: no commit holds it"; exit 1; fi\n`;\n static #staged = `if [ -f "$t/paths" ]; then\nxargs -0 git --literal-pathspecs ls-files -z --cached --others --exclude-standard -- <"$t/paths" >"$t/present" || exit 1\ncp "$t/present" "$t/changed" || exit 1\nif git rev-parse -q --verify HEAD >/dev/null; then xargs -0 git --literal-pathspecs ls-tree -r -z --name-only HEAD -- <"$t/paths" >>"$t/changed" || exit 1; fi\nb=$(git rev-parse -q --verify HEAD || git hash-object -t tree /dev/null) || exit 1\nGIT_INDEX_FILE="$t/index" git read-tree "$b" || exit 1\n[ ! -s "$t/changed" ] || GIT_INDEX_FILE="$t/index" git --literal-pathspecs add --all --pathspec-from-file="$t/changed" --pathspec-file-nul || exit 1\nGIT_INDEX_FILE="$t/index" git diff-index --cached --quiet "$b" -- && { echo "none of the paths named holds a change"; exit 1; }\nelse\ncp -p "$(git rev-parse --git-path index)" "$t/index" 2>/dev/null\nGIT_INDEX_FILE="$t/index" git add --all || exit 1\nfi\nmkdir "$t/w" && GIT_INDEX_FILE="$t/index" git checkout-index --all --prefix="$t/w/" || exit 1\nw="$t/w"\n`;\n static #taken = `if [ -f "$t/paths" ]; then { [ ! -s "$t/present" ] || git --literal-pathspecs add --all --pathspec-from-file="$t/present" --pathspec-file-nul; } && git --literal-pathspecs commit --quiet --file="$t/message" --pathspec-from-file="$t/changed" --pathspec-file-nul || exit 1\nelse git add --all && { [ ! -s "$t/executable" ] || git update-index --chmod=+x -z --stdin <"$t/executable"; } && git commit --quiet --file="$t/message" || exit 1\nfi\n`;\n static #whole = \'const fs = require("node:fs"); let s = ""; process.stdin.setEncoding("utf8"); process.stdin.on("data", (d) => { s += d; }); process.stdin.on("end", () => { const { set = {} } = JSON.parse(s || "{}"); const f = process.argv[1]; const keys = Object.keys(set).sort(); if (keys.length === 0) { fs.rmSync(f, { force: true }); return; } fs.writeFileSync(f, keys.map((key) => key + "=" + set[key] + "\\\\n").join(""), { mode: 0o600 }); fs.chmodSync(f, 0o600); });\';\n static #scripts = {\n setup: `cd "$1/repos" || exit 1\n${_ReposSkin.#marked}`,\n init: `${_ReposSkin.#exact("$1/repos/$2", "$1/repos", "$2")}cd "$1/repos/$2" || exit 1\nexport GIT_CEILING_DIRECTORIES="$1/repos"\n${_ReposSkin.#ident}${_ReposSkin.#marked}\n[ -e .git ] && { echo "the folder holds a repo already" >&2; exit 1; }\n[ -z "$(ls -A)" ] || { echo "the folder holds files: a repo is born in an empty folder" >&2; exit 1; }\ngit init --quiet -b main`,\n stand: `${_ReposSkin.#in}[ -d .git ] && [ ! -L .git ] && [ "$(git rev-parse --show-toplevel 2>/dev/null)" = "$(pwd -P)" ] || { echo "the folder holds no repo to stand on" >&2; exit 1; }\n[ "$(git branch --show-current)" = main ] || { echo "the repo is not on main" >&2; exit 1; }\nc=$(git rev-parse -q --verify refs/heads/main) || { echo "main holds no commit: a repo with none is born by init alone" >&2; exit 1; }\nt=$(mktemp -d) || exit 1\ntrap \'git -C "$1" worktree remove --force "$t/w" 2>/dev/null; rm -rf "$t"; git -C "$1" worktree prune\' EXIT\nnode -e \'${_ReposSkin.#unpack}\' -- "$t" || exit 1\ngit worktree add --quiet --detach "$t/w" "$c" >/dev/null 2>&1 || exit 1\nw="$t/w"\nprintf %s "$c" > "$t/chosen"\n{\n${_ReposSkin.#lend("$t")}${_ReposSkin.#checks}} >&2\necho "conform $c"\necho "$c"`,\n head: `${_ReposSkin.#in}git rev-parse --git-dir >/dev/null 2>&1 || { echo "the folder holds no repo" >&2; exit 1; }\ngit rev-parse -q --verify HEAD || echo\n[ -n "$2" ] || exit 0\nif git merge-base --is-ancestor "$2" HEAD 2>/dev/null; then echo holds; else echo lacks; fi`,\n status: `${_ReposSkin.#in}exec git status --porcelain=v1 --branch`,\n commit: `${_ReposSkin.#in}[ "$(git branch --show-current)" = main ] || { echo "the repo is not on main" >&2; exit 1; }\nt=$(mktemp -d) || exit 1\ntrap \'rm -rf "$t"\' EXIT\nnode -e \'${_ReposSkin.#unpack}\' -- "$t" || exit 1\n{\n${_ReposSkin.#unsecret}${_ReposSkin.#staged}${_ReposSkin.#checks}${_ReposSkin.#versioned}} >&2\n${_ReposSkin.#taken}[ ! -s "$t/executable" ] || git checkout-index -f -z --stdin <"$t/executable" || exit 1\nif [ -n "$v" ]; then git tag "$v" || exit 1; echo "$v"; fi\nh=$(git rev-parse HEAD) || exit 1\n[ "$(git rev-parse -q --verify HEAD:tools/conform.mjs)" = "$(git rev-parse -q --verify HEAD~:tools/conform.mjs)" ] || echo "conform $h"\necho "$h"`,\n discard: `${_ReposSkin.#in}git restore --source=HEAD --staged --worktree -- . && exec git clean -fdq`,\n log: `${_ReposSkin.#in}exec git log --max-count="$2" --format=%H%x09%an%x09%aI%x09%s`,\n bundle: `${_ReposSkin.#in}rm -rf "$2" && mkdir -p "$2" || exit 1\nif [ -n "$5" ]; then u=$(git rev-parse -q --verify "refs/tags/$5^{commit}") || { echo "this lobe holds no tag $5" >&2; exit 1; }\nif [ -n "$3" ] && git merge-base --is-ancestor "$u" "$3" 2>/dev/null; then echo 0; echo "$u"; exit 0; fi\nt=$(mktemp -d) || exit 1\ntrap \'rm -rf "$t"\' EXIT\ngit init --quiet --bare --object-format="$(git rev-parse --show-object-format)" "$t/c" >/dev/null || exit 1\ngit rev-parse --path-format=absolute --git-path objects > "$t/c/objects/info/alternates" || exit 1\ngit --git-dir="$t/c" update-ref refs/heads/main "$u" || exit 1\nfor n in $(git tag --merged "$u" --list \'v*\'); do git --git-dir="$t/c" update-ref "refs/tags/$n" "$(git rev-parse "refs/tags/$n")" || exit 1; done\ncd "$t/c" && export GIT_DIR="$t/c" || exit 1\nelif [ -n "$4" ]; then if [ -n "$3" ] && u=$(git rev-parse -q --verify "$4") && git merge-base --is-ancestor "$u" "$3" 2>/dev/null; then git update-ref -d "$4"; echo 0; echo "$u"; exit 0; fi\nt=$(mktemp -d) || exit 1\ntrap \'rm -rf "$t"\' EXIT\ngit init --quiet --bare --object-format="$(git rev-parse --show-object-format)" "$t/c" >/dev/null || exit 1\nif git rev-parse -q --verify "$4" >/dev/null; then git --git-dir="$t/c" fetch --quiet --no-tags "$1" "+$4:refs/heads/main" || exit 1; fi\ngit update-ref -d "$4" 2>/dev/null; cd "$t/c" && export GIT_DIR="$t/c" || exit 1\nfi\nh=$(git rev-parse -q --verify main) || { echo 0; exit 0; }\n[ "$3" = "$h" ] && { echo 0; echo "$h"; exit 0; }\nif [ -n "$3" ] && git cat-file -e "$3^{commit}" 2>/dev/null; then x="^$3"; g=$(git for-each-ref --format=\'%(refname)\' --merged main --no-merged "$3" \'refs/tags/v*\'); else x=; g=$(git for-each-ref --format=\'%(refname)\' --merged main \'refs/tags/v*\'); fi\ngit bundle create --quiet "$2/b" main $g $x || exit 1\ncd "$2" || exit 1\np="\\${6:-${_ReposSkin.#box}}"\nn=$(( ($(wc -c < b) + p - 1) / p ))\ni=0; while [ "$i" -lt "$n" ]; do dd if=b of="q$i" bs="$p" skip="$i" count=1 2>/dev/null || exit 1; i=$((i + 1)); done\nrm b || exit 1\necho "$n"; echo "$h"`,\n bring: _ReposSkin.#bring,\n cut: _ReposSkin.#cut,\n graft: _ReposSkin.#graft,\n land: `${_ReposSkin.#in}r="refs/nervur/$2"\nc=$(git rev-parse -q --verify "$r-main") || { echo "nothing waits to land as $2" >&2; exit 1; }\ngit update-ref -d "$r"; git update-ref -d "$r-main"\nk=$(git for-each-ref --format=\'%(objectname) %(refname)\' "$r-tags/"); ${_ReposSkin.#untag}\nw=$(echo "$k" | while read -r o n; do [ -n "$n" ] || continue; n=\\${n#"$r-tags/"}; if e=$(git rev-parse -q --verify "refs/tags/$n^{commit}"); then [ "$e" = "$o" ] || echo "this lobe holds the tag $n on another commit: a version names one commit for ever"; fi; done)\n[ -z "$w" ] || { echo "$w" >&2; exit 1; }\nif git rev-parse -q --verify HEAD >/dev/null; then git merge --quiet --ff-only "$c" || { echo "main moved while what came was checked: send it again" >&2; exit 1; }; else git checkout --quiet -B main "$c" || exit 1; fi\necho "$k" | while read -r o n; do [ -n "$n" ] || continue; n=\\${n#"$r-tags/"}; git rev-parse -q --verify "refs/tags/$n" >/dev/null || echo "create refs/tags/$n $o"; done | git update-ref --stdin || exit 1\ngit rev-parse HEAD`,\n conform: `${_ReposSkin.#in}c=$(git rev-parse -q --verify "refs/nervur/$2-main") || { echo "nothing waits as $2" >&2; exit 1; }\n[ "$c" = "$3" ] || { echo "what waits as $2 is $c, not $3" >&2; exit 1; }\nt=$(mktemp -d) || exit 1\ntrap \'git -C "$1" worktree remove --force "$t/w" 2>/dev/null; rm -rf "$t"; git -C "$1" worktree prune\' EXIT\nnode -e \'${_ReposSkin.#unpack}\' -- "$t" || exit 1\ngit worktree add --quiet --detach "$t/w" "$c" >/dev/null 2>&1 || exit 1\nw="$t/w"\n${_ReposSkin.#lend("$t")}${_ReposSkin.#checks}[ -n "$4" ] || exit 0\ncd "$t/w" || exit 1\nnode -e \'process.exit(require("./package.json").scripts?.[process.argv[1]] ? 0 : 3)\' "$4" 2>/dev/null || { echo "gate: skipped: the repo holds no script $4"; exit 0; }\n${_ReposSkin.#queued}${_ReposSkin.#masked} sh -c \'if [ -f package-lock.json ]; then npm ci || exit 1; fi; exec npm run "$1"\' gate "$4"`,\n run: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}${_ReposSkin.#scripted}d="$1"; s="$2"; i="$3"; g="$4"\n[ -z "$g" ] || { ${_ReposSkin.#queued}}\nshift 4\nexec node -e \'${_ReposSkin.#mask}\' -- "$d/${_ReposSkin.#env}" sh -c \'if [ "$2" = install ] && [ -f package-lock.json ]; then npm ci || exit 1; fi; s="$1"; shift 2; exec npm run "$s" -- "$@"\' run "$s" "$i" "$@"`,\n secrets: `${_ReposSkin.#in}git rev-parse --git-dir >/dev/null 2>&1 || { echo "the folder holds no repo" >&2; exit 1; }\ngit check-ignore -q -- ${_ReposSkin.#env} || { echo "${_ReposSkin.#env} is not kept out by .gitignore: no secret file is written where git would take it" >&2; exit 1; }\numask 077\nexec node -e \'${_ReposSkin.#whole}\' -- "./${_ReposSkin.#env}"`,\n remove: `for n in "$2" "\\${3-x}"; do case "$n" in .*|*/*) echo "remove reaches one folder of repos/ alone" >&2; exit 1 ;; esac; done\n[ -n "$2" ] || { echo "remove names its folder" >&2; exit 1; }\ncd "$1/repos" || exit 1\nif [ -e "$2" ] || [ -L "$2" ]; then { [ -d "$2" ] && [ ! -L "$2" ] && ls -1A . | grep -qxF -- "$2"; } || { echo "the folder $2 stands not as named under repos" >&2; exit 1; }; rm -rf -- "$2" || exit 1; fi\n[ ! -e "$2" ] || { echo "the folder $2 stands still" >&2; exit 1; }\n[ -z "$3" ] || rm -rf -- "$1/transfers/$3"`,\n clear: `cd "$1/transfers" 2>/dev/null || exit 0\nfor n in "$2" "\\${3-x}"; do case "$n" in \'\'|.*|*/*) echo "clear reaches a lobe\'s pieces alone" >&2; exit 1 ;; esac; done\nexec rm -rf -- "$2\\${3:+/$3}"`,\n scan: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}h=$(git rev-parse -q --verify HEAD) || { echo; exit 0; }\necho "$h"\ngit tag --points-at HEAD --list \'v*\' | sed \'s/^/g /\'\ngit ls-files -- \':(glob)faculties/*/faculty.js\' \':(glob)faculties/*/versions.json\' \':(glob)organs/*/graph.json\' \':(glob)organs/*/host/build\' \':(glob)designs/*/design.json\' \':(glob)designs/*/versions.json\' | sed \'s/^/t /\'\n{ git diff --name-only HEAD -- faculties organs designs; git ls-files --others --exclude-standard -- faculties organs designs; } | sed \'s/^/c /\'\ngit -c core.quotePath=false ls-files -- designs \':(glob)faculties/*/assets/**\' | while IFS= read -r p; do { [ -f "$p" ] && [ ! -L "$p" ]; } || { echo "u $p"; continue; }; s=$(perl -0777 -pe \'s/\\\\r\\\\n?/\\\\n/g unless /\\\\0/\' -- "$p" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -d " " -f 1); echo "d $s $p"; done\n${_ReposSkin.#keep}t=$(git describe --tags --abbrev=0 --match \'v*\' HEAD 2>/dev/null) || exit 0\necho "@ $t"\ngit ls-tree -r --name-only "$t" -- faculties organs | grep -E \'^(faculties/[^/]+/(faculty\\\\.js|versions\\\\.json)|organs/[^/]+/(graph\\\\.json|host/build))$\' | while IFS= read -r p; do echo "T $p"; case "$p" in */host/build) continue ;; esac; git diff --quiet "$t" -- "$p" 2>/dev/null && continue; printf \'B %s \' "$p"; git show "$t:$p" | node -e \'let s="";process.stdin.setEncoding("utf8").on("data",(d)=>{s+=d}).on("end",()=>process.stdout.write(JSON.stringify(s)))\'; echo; done\ngit -c core.quotePath=false ls-tree -r "$t" -- faculties | while IFS="$c" read -r m p; do case "$p" in faculties/*/assets/*) ;; *) continue ;; esac; o=\\${m##* }; if [ -s "$k/.o/$o" ]; then echo "A $(cat "$k/.o/$o") $p"; else echo "U $p"; fi; done`,\n build: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}o="organs/$2/host"\n[ -x "$o/build" ] || { echo "organs/$2 holds no executable host/build" >&2; exit 1; }\n(cd "$o" && ./build) >&2 || exit 1\n[ -f "$o/half" ] || { echo "the build left no host/half" >&2; exit 1; }\nd=$({ sha256sum "$o/half" 2>/dev/null || shasum -a 256 "$o/half"; } | cut -d " " -f 1)\nr="\\${1%/*}"; h="\\${r%/*}/halves"\nmkdir -p "$h" && chmod 755 "$h" && cp "$o/half" "$h/$d.writing" && chmod 755 "$h/$d.writing" && mv -f "$h/$d.writing" "$h/$d" || { echo "the half is not laid in $h" >&2; exit 1; }\nprintf \'%s\\\\n\' "$d"`,\n look: `${_ReposSkin.#in}${_ReposSkin.#lend("${1%/*}")}d="designs/$2"\n{ [ -d "$d" ] && [ ! -L "$d" ] && ls -1A designs | grep -qxF -- "$2"; } || { echo "the repo holds no design $2" >&2; exit 1; }\nnode -e \'process.exit(require("./package.json").scripts?.design ? 0 : 3)\' 2>/dev/null || { echo "the repo holds no script design" >&2; exit 3; }\nt=$(mktemp) || exit 1\ntrap \'rm -f "$t"\' EXIT\nnpm run --silent design -- "$d" --look "$t" >&2 || exit 1\ncat "$t"`\n };\n static #sh(kind) {\n return ["sh", "-c", _ReposSkin.#scripts[kind], kind];\n }\n static programs = {\n setup: _ReposSkin.#sh("setup"),\n init: _ReposSkin.#sh("init"),\n stand: _ReposSkin.#sh("stand"),\n head: _ReposSkin.#sh("head"),\n status: _ReposSkin.#sh("status"),\n commit: _ReposSkin.#sh("commit"),\n discard: _ReposSkin.#sh("discard"),\n log: _ReposSkin.#sh("log"),\n bundle: _ReposSkin.#sh("bundle"),\n bring: _ReposSkin.#sh("bring"),\n cut: _ReposSkin.#sh("cut"),\n graft: _ReposSkin.#sh("graft"),\n land: _ReposSkin.#sh("land"),\n conform: _ReposSkin.#sh("conform"),\n run: _ReposSkin.#sh("run"),\n secrets: _ReposSkin.#sh("secrets"),\n clear: _ReposSkin.#sh("clear"),\n remove: _ReposSkin.#sh("remove"),\n scan: _ReposSkin.#sh("scan"),\n build: _ReposSkin.#sh("build"),\n look: _ReposSkin.#sh("look")\n };\n static #unready = { ready: false, doing: null, failed: null };\n static #plain = { type: "string" };\n static #some = { type: "string", minLength: 1 };\n static #maybe = { anyOf: [{ type: "string", minLength: 1 }, { type: "null" }] };\n static #place = { type: "integer", minimum: 0 };\n static #one = { type: "integer", minimum: 1 };\n static #named = { type: "string", pattern: "^[a-z][a-z0-9.-]{0,63}$" };\n static #jobSchema = {\n type: "object",\n properties: { job: _ReposSkin.#some },\n required: ["job"],\n additionalProperties: false\n };\n static #paging = {\n type: "object",\n properties: { cursor: _ReposSkin.#maybe },\n additionalProperties: false\n };\n static #scopeSchema = { type: "array", items: _ReposSkin.#some, minItems: 1, maxItems: SCOPE_MOST };\n static #many = { type: "array", items: _ReposSkin.#some, minItems: 1 };\n static #files = {\n type: "array",\n items: {\n type: "object",\n properties: { path: _ReposSkin.#some, text: _ReposSkin.#plain, absent: { type: "boolean" } },\n required: ["path"],\n additionalProperties: false\n }\n };\n static #object(properties, required = Object.keys(properties)) {\n return { type: "object", properties, required, additionalProperties: false };\n }\n static #says = {\n setup: "An owner, once: the disk\'s folder stands at `at` on the host, proven by a marker the disk writes and the shell reads back.",\n delegate: "An owner: the lobe `lobe` a delegate, which grants folders of its own as an owner does and removes those alone, as a keeper raising repo lobes as its children does; with `given` false, a delegate no more, the folders it granted standing.",\n grant: "An owner, or a delegate a folder it granted, a new one, or one no lobe holds, a lobe torn down having left it, which is the delegate’s from then on: the folder `folder`, `repos/<folder>`, is the repo lobe `lobe`’s, whatever lobe it names, its one folder and no other’s, so a wired lobe reaches it only through its repo lobe; its wire back is ordered as its first job starts; a name an entry of `repos/` holds in another case is refused; where `lobe` is null, it is granted to none; a lobe that loses it has its pieces cleared.",\n folders: "An owner, every folder; a delegate, those it granted and those no lobe holds, which it may take: each with the repo lobe it is granted to, whether a repo stands in it, the job going, and the secret files written in it, by their paths. A page, `{ folders, cursor }`, `cursor` null at the list’s end, else handed back to read on.",\n remove: "An owner, or a delegate the folder it granted: forgets the folder `folder` and its grant, its bytes left on disk, and its lobe’s pieces are cleared; with `erase` true, a job, answered `{ job }`, deletes them too: its grant forgotten at once, so its repo lobe reaches it no more, then the folder `repos/<folder>`, checked to stand under the disk’s `repos/` by that exact name and no link, deleted with every byte it holds, and the pieces of the lobe granted it, `transfers/<lobe>/`; the folder forgotten once the job ended, its bytes gone, read by `job`; one that failed stands, granted to none. One running a job is refused.",\n state: "An owner: the disk\'s folder as set up. A repo lobe: its folder on the host, whether a repo stands in it, read on the disk where one was made, and the job going.",\n read: "A repo lobe: a file\'s text, its first lines where `first` names how many, and how many lines it holds; or `paths` alone, `{ files }` in one answer, each `{ path, text }` or `{ path, absent: true }` in the order named, the whole refused where a path climbs or hides, a text is no UTF-8 or the texts weigh past what one answer carries.",\n bytes: "A repo lobe: the bytes of a file a tag of its repo holds in a design\'s folder or a faculty\'s `assets/`, as a design\'s font, which no text holds, by the SHA-256 `sha` its scan kept them under, a text\'s with LF line ends; `absent` where none is kept.",\n write: "A repo lobe: writes a file\'s text whole, as a commit\'s files.",\n erase: "A repo lobe: removes a file, or a folder that holds nothing, of its repo, as a refused commit\'s files are put back as they were; the one removal a repo lobe has this jailer make of a repo\'s bytes.",\n list: "A repo lobe: the names in a folder of its repo, its top where no path is named.",\n piece: "A repo lobe: the piece `at` of the bundle that waits as `as`",\n put: "A repo lobe: writes the piece `at` of `pieces` of a bundle that waits as `as`.",\n init: "A job: makes the repo on `main` in its folder, which holds nothing, empty, laying no file; never over a repo that stands.",\n stand: "A job: the repo its folder holds already, handed in place to the lobe granted it: refused where none stands there, or `main` holds no commit or is not checked out; else its `main` checked out apart and checked by the check of the parts `parts`, Nervur’s, and `tools/conform.mjs` as `main` holds it, on its errors, then `conform <head>`, the conform it chooses, and its head answered. Nothing is laid or moved. Its checks go on the input.",\n head: "A job: the HEAD, and whether it holds the commit `contains` where one is named.",\n status: "A job: `git status`.",\n commit: "A job: refused while `.env` stands where `.gitignore` keeps it not out; then the check of the parts `parts`, Nervur’s, and the repo’s `tools/conform.mjs` as the commit `conform` holds it, the one its owner chose, none where it names none, each over what it would commit, laid out apart as a clone would hold it, so a file `.gitignore` keeps out counts as absent; then its root `package.json` `version` read against `HEAD`’s: refused where it changed and is not three whole numbers, is lower by semver, or its tag `v<version>` stands already; then every change committed on `main`, or with `paths` the changes of those paths alone, each a file or a folder of the repo and the rest of the folder left as it stands, refused where they hold none, with `message`, each path `executable` names landing executable, and tagged `v<version>`, a git tag, where it raised the version, none in a lobe holding a scope; answering the tag where it made one, `conform <head>` where it changed `tools/conform.mjs`, the conform it chooses, then its HEAD. Its message and its checks go on the input.",\n discard: "A job: every change since the last commit undone.",\n log: "A job: the last commits, `most` of them, twenty where none is named.",\n run: "A job: the script `script` of the repo\'s `package.json`, by `npm run <script> -- <args…>`, each of `args` one argument, never read by a shell, its environment the repo\'s `.env`, each line as written, its values masked in its output; with `install`, `npm ci` first where a lockfile stands, in the same job; with `gate`, after the gates asked before it, one at a time across the organism; a script the repo lacks ends 3.",\n secrets: "A job: `.env` written whole, only where `.gitignore` keeps it out: each name of `set` a line `KEY=value`, readable by the owner of the files alone, and removed where it sets none. Its values go on the input, never kept nor read back.",\n clear: "A repo lobe\'s job beside its folder\'s, told to no one: the pieces of its bundle waiting as `as` removed; while they go, none is made, written or read under that name.",\n check: "A repo lobe: its job and its clears checked against the runs the shell names going; each it runs no more, lost to a restart, ended at once, failed, its lobe told. Answers the job going, those ended lost, and `last`, the end it last told that lobe, `{ job, kind, code, out, err }`, as its letter tells it, kept for that lobe alone until its next end, or null.",\n bundle: "A job: the commits on `main` after `since`, as a bundle in pieces waiting as `as`; answers how many and the HEAD. With `cut`, the commits of the cut of `as` after `since` instead, read from its own bare repo as `main`, so nothing of `main` leaves, not even a name; the cut’s ref then cleared, and no tag carried. The bundle carries every tag `v*` naming a commit after `since`; with `tag`, `v` and three whole numbers, `main` ends at the commit that tag names, refused where this lobe holds no such tag, and none where `since` holds that commit already; a cut is bundled by no tag, since its tag was named to the cut: with `cut`, none is made either where `since` holds the cut’s head already.",\n cut: "A job: `main` cut to the scope `scope`, folders none inside another: by first parent, each commit that changes a path within the scope rewritten to one whose tree holds those paths alone, its parent the last one cut, its author, committer, their times and its message kept exactly, signed by no one, so the same `main` is cut to the same commits every time; with `tag`, `v` and three whole numbers, only up to the commit that tag names, the beginning of the cut to the head, the very commits in the very order, refused where this lobe holds no such tag, and the tag’s name never in the cut; left at `refs/nervur/cut-<as>`, its head answered, or an empty line where the cut is empty.",\n bring: "A job: a pull\'s or a push\'s `pieces` waiting as `as` brought apart from `main`, and what `main` would become kept beside it, itself or a merge made apart; answers that head and `forward`, `merge` or `new`, or `main`\'s HEAD and `held` where `main` holds it already; a conflict refused. With `scope`, a scoped writer’s push, grafted: refused unless its commits are linear on the scope’s head as `main` is cut now, none where the cut is empty, else as behind, and where one changes a path outside the scope, naming it, or nothing within it; each commit then grafted on `main`’s tip, its tree `main`’s with every path within the scope taken from it, its author, committer, their times and its message kept, so the scope cut again answers the very commits pushed, else refused; answers that head, `graft` and the head pushed, or the head pushed and `held`. The tags `v*` the bundle carries, a scoped writer\'s none, fetched apart as `refs/nervur/<as>-tags/`, and the whole refused, nothing kept, where one names no commit it brings or this lobe holds a tag of that name on another commit.",\n land: "A job: what was brought as `as` brought into `main`, which it builds on; refused where `main` moved meanwhile. The tags brought with it laid once `main` moved, never before, one held on the same commit no change, and the whole refused, `main` unmoved, where one meets a tag of that name on another commit. Answers the HEAD.",\n conform: "A job: what was brought as `as`, at `head`, checked out apart and checked by the check of the parts `parts`, Nervur’s, then by `tools/conform.mjs` as the commit `conform` holds it, the one the lobe’s owner chose, never as what came holds it, said skipped where it names none or that commit holds none; with `script`, that gate then run there too, with the repo’s `.env`, masked in its output, after the gates asked before it, one at a time across the organism. Its checks go on the input.",\n scan: "A job: the HEAD, each tag `v*` it carries as `g <tag>`, each file of `faculties/` and `organs/` git tracks, each design\'s `design.json` and `versions.json`, each it shows changed, and each file of `designs/` and of each faculty\'s `assets/` with its SHA-256, a text\'s read with LF line ends; then the newest tag `v*` reachable from the HEAD as `@ <tag>`, each faculty\'s and organ\'s file its commit holds as `T <path>`, the text of each that differs from the folder as `B <path> <JSON string>`, and each file of each faculty\'s `assets/` there as `A <SHA-256> <path>`, or `U <path>` where none is kept. Between them, each file a tag `v*` holds in `designs/` or a faculty\'s `assets/` kept by its SHA-256, a text\'s with LF line ends, for `bytes` to read, each tag kept once.",\n build: "A job: the organ `organ`\'s `host/build` run, answering the SHA-256 of the `host/half` it leaves.",\n look: "A job: the design `design`\'s look built by the repo\'s own script `design`, given `designs/<design>` and `--look` with the file to write it to, answering that file alone, the look\'s source; it is built, never committed.",\n stop: "A repo lobe\'s own job, or an owner\'s of the folder `folder`, stopped through the shell, its program given `grace` milliseconds to end before it is killed, the shell\'s own five seconds where none is named; one the shell runs no more, lost to a restart of the organ, ends at once, failed.",\n ended: "The shell\'s alone: a job\'s program ended.",\n back: "The brain\'s alone: the shell\'s half connected, at its start or after it restarted, an update\'s among them: each job going that the shell names going no more ends, lost, its lobe told.",\n jobs: "The asker\'s jobs, an owner\'s every one, each with its code once ended; a job keeps no input and no output. Of each asker the jailer keeps every job that runs and its newest ended, as many as one read holds, a clear forgotten once ended. A page, `{ jobs, cursor }`, `cursor` null at the list\'s end, else handed back to read on.",\n job: "One of the asker\'s jobs, `job`, as the jailer keeps it; an owner reads any, and one not the asker\'s, or one gone past the newest kept, is absent."\n };\n static #reading(method, args, result) {\n const typed = { ...args === void 0 ? {} : { args }, ...result ? { result } : {} };\n const description = _ReposSkin.#says[method] ?? method;\n return { description, kind: "reading", ...typed, errors: ["refused", "absent"] };\n }\n static #writing(method, args, result) {\n return { ..._ReposSkin.#reading(method, args, result), kind: "writing" };\n }\n static #jobOf(method, args) {\n return _ReposSkin.#writing(method, args, _ReposSkin.#jobSchema);\n }\n static #none = _ReposSkin.#object({});\n static blueprint = {\n name: "nervur.repos",\n version: "0.1.122",\n description: "The jailer: keeps the bytes of the organism\'s repos at `repos/<name>` under the disk\'s folder, on `main`, a skin lobe of `shell` and `disk`. An owner sets the folder up and grants each repo\'s folder to one repo lobe, through which the lobes wired to it reach it; the repo lobe reaches its own and never names it: its files read and written as UTF-8 text through the disk, the pieces of its bundles beside them, and its jobs run through the shell, one at a time for each folder, each answered at once and asked back `done` by a letter. It holds no relation and no secret: `.env` is written whole from a job\'s input, only where `.gitignore` keeps it out, readable by the owner of the files alone, and read back by the names that stand alone; a commit is refused while one stands that git would take, and checked over what it would commit laid out apart; and every run of a repo\'s script loads `.env` into its environment, each line as written, masked in its output by its program; a job keeps neither its input nor its output, but the end last told each lobe, kept for that lobe alone until its next. It removes no repo\'s bytes but a refused commit\'s own files, which its repo lobe has it `erase`, and a folder an owner removes with `erase`: a plain `remove` forgets a folder and leaves its bytes.",\n methods: {\n setup: _ReposSkin.#jobOf("setup", _ReposSkin.#object({ at: _ReposSkin.#some })),\n delegate: _ReposSkin.#writing(\n "delegate",\n _ReposSkin.#object({ lobe: _ReposSkin.#some, given: { type: "boolean" } }, ["lobe"])\n ),\n grant: _ReposSkin.#writing("grant", _ReposSkin.#object({ folder: _ReposSkin.#named, lobe: _ReposSkin.#maybe })),\n folders: _ReposSkin.#reading("folders", _ReposSkin.#paging),\n remove: {\n ..._ReposSkin.#writing(\n "remove",\n _ReposSkin.#object({ folder: _ReposSkin.#named, erase: { type: "boolean" } }, ["folder"])\n ),\n irreversible: true\n },\n state: _ReposSkin.#reading("state", _ReposSkin.#none),\n read: _ReposSkin.#reading(\n "read",\n _ReposSkin.#object({ path: _ReposSkin.#some, first: _ReposSkin.#one, paths: _ReposSkin.#many }, []),\n _ReposSkin.#object({ text: _ReposSkin.#plain, lines: { type: "integer" }, files: _ReposSkin.#files }, [])\n ),\n bytes: _ReposSkin.#reading("bytes", _ReposSkin.#object({ sha: _ReposSkin.#some }), _ReposSkin.#object({ bytes: {} })),\n write: _ReposSkin.#writing("write", _ReposSkin.#object({ path: _ReposSkin.#some, text: _ReposSkin.#plain })),\n erase: { ..._ReposSkin.#writing("erase", _ReposSkin.#object({ path: _ReposSkin.#some })), irreversible: true },\n list: _ReposSkin.#reading(\n "list",\n _ReposSkin.#object({ path: _ReposSkin.#plain }, []),\n _ReposSkin.#object({ names: { type: "array", items: _ReposSkin.#plain } })\n ),\n piece: _ReposSkin.#reading(\n "piece",\n _ReposSkin.#object({ at: _ReposSkin.#place, as: _ReposSkin.#some }, ["at", "as"])\n ),\n put: _ReposSkin.#writing(\n "put",\n _ReposSkin.#object({\n at: _ReposSkin.#place,\n pieces: _ReposSkin.#one,\n bytes: {},\n as: _ReposSkin.#some\n })\n ),\n init: _ReposSkin.#jobOf("init", _ReposSkin.#none),\n stand: _ReposSkin.#jobOf(\n "stand",\n _ReposSkin.#object({ parts: _ReposSkin.#some, scoped: { type: "boolean" } }, ["parts"])\n ),\n head: _ReposSkin.#jobOf("head", _ReposSkin.#object({ contains: _ReposSkin.#some }, [])),\n status: _ReposSkin.#jobOf("status", _ReposSkin.#none),\n commit: _ReposSkin.#jobOf(\n "commit",\n _ReposSkin.#object(\n {\n message: _ReposSkin.#some,\n parts: _ReposSkin.#some,\n scoped: { type: "boolean" },\n executable: { type: "array", items: _ReposSkin.#some },\n paths: { type: "array", items: _ReposSkin.#some, minItems: 1 }\n },\n ["message", "parts"]\n )\n ),\n discard: { ..._ReposSkin.#jobOf("discard", _ReposSkin.#none), irreversible: true },\n log: _ReposSkin.#jobOf("log", _ReposSkin.#object({ most: { type: "integer", minimum: 1 } }, [])),\n run: _ReposSkin.#jobOf(\n "run",\n _ReposSkin.#object(\n {\n script: _ReposSkin.#some,\n args: { type: "array", items: _ReposSkin.#plain, maxItems: ARGS_MOST },\n install: { type: "boolean" },\n gate: { type: "boolean" }\n },\n ["script"]\n )\n ),\n secrets: _ReposSkin.#jobOf(\n "secrets",\n _ReposSkin.#object({ set: { type: "object", additionalProperties: _ReposSkin.#plain } })\n ),\n bundle: _ReposSkin.#jobOf(\n "bundle",\n _ReposSkin.#object(\n {\n since: _ReposSkin.#maybe,\n as: _ReposSkin.#some,\n cut: { type: "boolean" },\n tag: _ReposSkin.#some,\n piece: _ReposSkin.#one\n },\n ["since", "as"]\n )\n ),\n bring: _ReposSkin.#jobOf(\n "bring",\n _ReposSkin.#object({ as: _ReposSkin.#some, pieces: _ReposSkin.#one, scope: _ReposSkin.#scopeSchema }, [\n "as",\n "pieces"\n ])\n ),\n cut: _ReposSkin.#jobOf(\n "cut",\n _ReposSkin.#object({ as: _ReposSkin.#some, scope: _ReposSkin.#scopeSchema, tag: _ReposSkin.#some })\n ),\n land: _ReposSkin.#jobOf("land", _ReposSkin.#object({ as: _ReposSkin.#some })),\n conform: _ReposSkin.#jobOf(\n "conform",\n _ReposSkin.#object(\n {\n as: _ReposSkin.#some,\n head: _ReposSkin.#some,\n parts: _ReposSkin.#some,\n scoped: { type: "boolean" },\n script: _ReposSkin.#some\n },\n ["as", "head", "parts"]\n )\n ),\n clear: _ReposSkin.#jobOf("clear", _ReposSkin.#object({ as: _ReposSkin.#some })),\n check: _ReposSkin.#writing(\n "check",\n _ReposSkin.#none,\n _ReposSkin.#object({\n doing: _ReposSkin.#maybe,\n lost: { type: "array", items: _ReposSkin.#some }\n })\n ),\n scan: _ReposSkin.#jobOf("scan", _ReposSkin.#none),\n build: _ReposSkin.#jobOf("build", _ReposSkin.#object({ organ: _ReposSkin.#some })),\n look: _ReposSkin.#jobOf("look", _ReposSkin.#object({ design: _ReposSkin.#some })),\n stop: _ReposSkin.#writing(\n "stop",\n _ReposSkin.#object(\n { folder: _ReposSkin.#named, grace: { type: "integer", minimum: 0, maximum: 2147483647 } },\n []\n )\n ),\n ended: { ..._ReposSkin.#writing("ended"), askers: ["shell"] },\n back: { ..._ReposSkin.#writing("back"), askers: ["brain"] },\n jobs: _ReposSkin.#reading("jobs", _ReposSkin.#paging),\n job: _ReposSkin.#reading("job", _ReposSkin.#jobSchema)\n },\n placeholders: { shell: "nervur.shell", disk: "nervur.disk" }\n };\n static #fields(data) {\n return !!data && typeof data === "object" && !Array.isArray(data) && !ArrayBuffer.isView(data);\n }\n static #text(data) {\n return typeof data === "string" && data !== "";\n }\n static #count(data, most) {\n return typeof data === "number" && Number.isSafeInteger(data) && data >= 1 && data <= most;\n }\n static #arg(args, key) {\n return _ReposSkin.#fields(args) ? args[key] : void 0;\n }\n static #names(path) {\n if (path === void 0 || path === "") return [];\n if (typeof path !== "string") return null;\n const names = path.split("/");\n return names.every((name) => _ReposSkin.#name.test(name)) ? names : null;\n }\n static #paths(paths) {\n return Array.isArray(paths) && paths.length >= 1 && paths.every((path) => typeof path === "string" && path !== "" && _ReposSkin.#names(path) !== null);\n }\n static #scopeOf(scope) {\n if (!Array.isArray(scope) || scope.length < 1 || scope.length > SCOPE_MOST) return null;\n const folders = scope.flatMap((one) => typeof one === "string" ? [one] : []);\n const fit = (one) => one.split("/").every((name) => _ReposSkin.#segment.test(name) && ![".", "..", ".git"].includes(name));\n if (folders.length !== scope.length || !folders.every(fit)) return null;\n const sorted = folders.toSorted();\n const nested = sorted.some(\n (one, at) => sorted.some((other, by) => by !== at && (one === other || one.startsWith(`${other}/`)))\n );\n return nested ? null : sorted;\n }\n static #lone = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g;\n #bytes(text) {\n const encoded = this.codec.utf8(text.replace(_ReposSkin.#lone, "�"));\n return "bytes" in encoded ? encoded.bytes : null;\n }\n #textOf(bytes) {\n const decoded = this.codec.utf8Text(bytes);\n return "text" in decoded ? decoded.text : null;\n }\n #linesOf(set) {\n if (!_ReposSkin.#fields(set)) return null;\n const entries = Object.entries(set);\n if (entries.length > this.#most()) return null;\n for (const [key, value] of entries)\n if (!_ReposSkin.#key.test(key) || typeof value !== "string" || !_ReposSkin.#line.test(value)) return null;\n return set;\n }\n static #argsOf(args) {\n if (args === void 0) return [];\n if (!Array.isArray(args) || args.length > ARGS_MOST) return null;\n const all = args.flatMap(\n (one) => typeof one === "string" && one.length <= ARG_LONGEST && !one.includes("\\0") ? [one] : []\n );\n return all.length === args.length ? all : null;\n }\n #heard(answer) {\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : null;\n }\n #nonce() {\n return Array.from(this.stamp.seed.slice(0, 16), (byte) => byte.toString(16).padStart(2, "0")).join("");\n }\n #at() {\n const setup = this.cells.get(["setup"]);\n if (!_ReposSkin.#fields(setup) || setup["ready"] !== true) return null;\n return _ReposSkin.#text(setup["at"]) ? setup["at"] : null;\n }\n #most() {\n return Math.min(CELLS_RANGE, Math.floor(this.memory / LOBE_SHARE / ITEM_SIZE));\n }\n #all(prefix) {\n return this.cells.range({ prefix, limit: this.#most() }).cells;\n }\n #page(prefix, args) {\n const cursor = _ReposSkin.#arg(args, "cursor") ?? null;\n if (cursor !== null && !_ReposSkin.#text(cursor))\n return this.error("refused", "a cursor is the one a page answered");\n try {\n return this.cells.range({ prefix, limit: this.#most(), ...cursor === null ? {} : { cursor } });\n } catch {\n return this.error("refused", "a cursor is the one a page answered");\n }\n }\n async setup(args) {\n if (this.stamp.asker !== _ReposSkin.#owner) return this.error("refused", "setup is an owner\'s");\n const at = _ReposSkin.#arg(args, "at");\n if (!_ReposSkin.#text(at) || !at.startsWith("/"))\n return this.error("refused", "at is where the disk\'s folder stands, from the root");\n const held = await this.#unstuck(["setup"]);\n if (_ReposSkin.#fields(held) && _ReposSkin.#text(held["doing"]))\n return this.error("refused", "the setup runs already");\n const nonce = this.#nonce();\n const path = [_ReposSkin.#repos, _ReposSkin.#marker];\n const wrote = await this.ask("disk", "write", { path, bytes: this.#bytes(nonce) });\n if ("error" in wrote) return this.#heard(wrote);\n this.cells.set(["setup"], { at, ..._ReposSkin.#unready });\n return this.#begin("setup", null, [at], `${nonce}\n`);\n }\n async grant(args) {\n const delegate = this.#delegate();\n if (this.stamp.asker !== _ReposSkin.#owner && delegate === null)\n return this.error("refused", "grant is an owner\'s or a delegate\'s");\n const folder = _ReposSkin.#arg(args, "folder");\n const lobe = _ReposSkin.#arg(args, "lobe");\n if (!_ReposSkin.#text(folder) || !_ReposSkin.#folderName.test(folder))\n return this.error("refused", "a folder is a repo’s name, lowercase, a letter first");\n if (this.#at() === null) return this.error("refused", "the disk\'s folder is not set up");\n const held = this.cells.get(["folder", folder]);\n const free = _ReposSkin.#fields(held) && !_ReposSkin.#text(held["lobe"]);\n if (delegate !== null && _ReposSkin.#fields(held) && held["by"] !== delegate && (!free || lobe === null))\n return this.error("refused", `the folder ${folder} is none the delegate granted, and a lobe holds it`);\n const kept = _ReposSkin.#fields(held) ? { ...held, ...delegate === null ? {} : { by: delegate } } : { lobe: null, doing: null, made: false, ...delegate === null ? {} : { by: delegate } };\n if (lobe === null) {\n if (!_ReposSkin.#fields(held)) return this.error("absent", `no folder ${folder}`);\n this.cells.set(["folder", folder], { ...held, lobe: null });\n if (_ReposSkin.#text(held["lobe"])) await this.#release(held["lobe"], folder);\n return null;\n }\n if (!_ReposSkin.#text(lobe) || [_ReposSkin.#owner, "shell", "disk"].includes(lobe))\n return this.error("refused", "a grant names a repo lobe, or null for none");\n const holds = this.cells.get(["lobe", lobe]);\n if (typeof holds === "string" && holds !== folder)\n return this.error("refused", `the lobe ${lobe} holds the folder ${holds} already`);\n const met = _ReposSkin.#fields(held) ? null : await this.#folded(folder);\n if (met !== null) return met;\n const was = _ReposSkin.#fields(held) ? held["lobe"] : null;\n this.cells.set(["lobe", lobe], folder);\n this.cells.set(["folder", folder], { ...kept, lobe });\n if (_ReposSkin.#text(was) && was !== lobe) await this.#release(was, folder);\n return null;\n }\n async delegate(args) {\n if (this.stamp.asker !== _ReposSkin.#owner) return this.error("refused", "delegate is an owner\'s");\n const lobe = _ReposSkin.#arg(args, "lobe");\n if (!_ReposSkin.#text(lobe) || [_ReposSkin.#owner, "shell", "disk"].includes(lobe))\n return this.error("refused", "a delegate is a lobe");\n if (_ReposSkin.#arg(args, "given") === false) this.cells.delete(["delegate", lobe]);\n else this.cells.set(["delegate", lobe], true);\n return null;\n }\n #delegate() {\n const { asker } = this.stamp;\n return asker !== _ReposSkin.#owner && this.cells.get(["delegate", asker]) === true ? asker : null;\n }\n async #release(lobe, folder) {\n this.cells.delete(["lobe", lobe]);\n const at = this.#at();\n if (at === null) return;\n const program = [..._ReposSkin.programs.clear, at, lobe];\n const begun = await this.ask("shell", "run", { program, input: "" });\n const run = "result" in begun ? _ReposSkin.#arg(begun.result, "run") : void 0;\n if (!_ReposSkin.#text(run)) return;\n const { asker } = this.stamp;\n this.cells.set(["job", run], { job: run, kind: "clear", asker, folder, ended: null });\n this.cells.set(["by", asker, run], null);\n this.cells.set(["clearing", lobe, "*"], { run });\n }\n static #ends(read) {\n const all = _ReposSkin.#fields(read) && Array.isArray(read["result"]) ? read["result"] : [];\n return new Set(all.map((wire) => _ReposSkin.#arg(wire, "termination")));\n }\n async #torn(read) {\n const ends = _ReposSkin.#ends(read);\n for (const { key, value } of this.#all(["lobe"])) {\n const lobe = key[1];\n if (!_ReposSkin.#text(lobe) || ends.has(lobe) || !_ReposSkin.#text(value)) continue;\n if (this.cells.range({ prefix: ["by", lobe], limit: 1 }).cells.length === 0) continue;\n const held = this.cells.get(["folder", value]);\n if (_ReposSkin.#fields(held)) this.cells.set(["folder", value], { ...held, lobe: null });\n this.cells.delete(["last", lobe]);\n await this.#release(lobe, value);\n }\n }\n async #lostOf(jobs) {\n const asked = await this.ask("shell", "going", {});\n const named = "result" in asked ? _ReposSkin.#arg(asked.result, "runs") : void 0;\n if (!Array.isArray(named)) return null;\n const going = new Set(named);\n return jobs.filter((job) => !going.has(job));\n }\n async #unstuck(key) {\n const record = this.cells.get([...key]);\n const doing = _ReposSkin.#arg(record ?? null, "doing");\n if (!_ReposSkin.#text(doing)) return record;\n const lost = await this.#lostOf([doing]);\n if (lost === null || lost.length === 0) return record;\n await this.#end(doing, -1, "", _ReposSkin.#lost);\n return this.cells.get([...key]);\n }\n async check() {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const doing = own.held["doing"];\n const clears = this.#all(["clearing", this.stamp.asker]).flatMap(({ value }) => {\n const run = _ReposSkin.#arg(value, "run");\n return _ReposSkin.#text(run) ? [run] : [];\n });\n const runs = [..._ReposSkin.#text(doing) ? [doing] : [], ...clears];\n const lost = runs.length === 0 ? [] : await this.#lostOf(runs) ?? [];\n for (const run of lost) await this.#end(run, -1, "", _ReposSkin.#lost);\n const after = this.cells.get(["folder", own.folder]);\n const last = this.cells.get(["last", this.stamp.asker]) ?? null;\n return { doing: _ReposSkin.#arg(after ?? null, "doing") ?? null, lost: [...lost], last };\n }\n async #folded(folder) {\n const listed = await this.ask("disk", "list", { path: [_ReposSkin.#repos] });\n if ("error" in listed)\n return listed.error.code === "absent" ? null : this.error("refused", `repos/ is not listed: ${listed.error.message}`);\n const names = _ReposSkin.#arg(listed.result, "names");\n const lower = folder.toLowerCase();\n const met = Array.isArray(names) ? names.find((name) => typeof name === "string" && name !== folder && name.toLowerCase() === lower) : void 0;\n return typeof met === "string" ? this.error("refused", `the folder ${folder} meets ${met}, which repos/ holds in another case`) : null;\n }\n folders(args) {\n const delegate = this.#delegate();\n if (this.stamp.asker !== _ReposSkin.#owner && delegate === null)\n return this.error("refused", "folders is an owner\'s or a delegate\'s");\n const page = this.#page(["folder"], args);\n if (!("cells" in page)) return page;\n const seen = page.cells.filter(\n ({ value }) => delegate === null || _ReposSkin.#fields(value) && (value["by"] === delegate || !_ReposSkin.#text(value["lobe"]))\n );\n const folders = seen.map(({ key, value }) => ({\n folder: key[1] ?? null,\n ..._ReposSkin.#fields(value) ? value : {}\n }));\n return { folders, cursor: page.cursor };\n }\n async remove(args) {\n const delegate = this.#delegate();\n if (this.stamp.asker !== _ReposSkin.#owner && delegate === null)\n return this.error("refused", "remove is an owner\'s or a delegate\'s");\n const folder = _ReposSkin.#arg(args, "folder");\n const erase = _ReposSkin.#arg(args, "erase") ?? false;\n if (typeof erase !== "boolean") return this.error("refused", "erase is true or false");\n if (!_ReposSkin.#text(folder)) return this.error("absent", "no such folder");\n const held = await this.#unstuck(["folder", folder]);\n if (!_ReposSkin.#fields(held)) return this.error("absent", "no such folder");\n if (delegate !== null && held["by"] !== delegate)\n return this.error("refused", `the folder ${folder} is none the delegate granted`);\n const doing = held["doing"];\n if (_ReposSkin.#text(doing)) return this.error("refused", `the folder ${folder} runs ${doing}: wait for it to end`);\n if (erase) return this.#erasing(folder, held);\n this.cells.delete(["folder", folder]);\n if (_ReposSkin.#text(held["lobe"])) await this.#release(held["lobe"], folder);\n return null;\n }\n async #erasing(folder, held) {\n const at = this.#at();\n if (at === null) return this.error("refused", "the disk\'s folder is not set up");\n if (!_ReposSkin.#folderName.test(folder)) return this.error("refused", "a folder is a repo’s name");\n const lobe = _ReposSkin.#text(held["lobe"]) ? held["lobe"] : "";\n if (lobe !== "") this.cells.delete(["lobe", lobe]);\n this.cells.set(["folder", folder], { ...held, lobe: null });\n return this.#begin("remove", folder, [at, folder, lobe], "");\n }\n async state() {\n if (this.stamp.asker === _ReposSkin.#owner) return this.cells.get(["setup"]) ?? null;\n const own = this.#own();\n if (!("folder" in own)) return own;\n const at = this.#at();\n const listed = own.held["made"] === true ? await this.ask("disk", "list", { path: [_ReposSkin.#repos] }) : null;\n const names = listed !== null && "result" in listed ? _ReposSkin.#arg(listed.result, "names") : void 0;\n const made = Array.isArray(names) && names.includes(own.folder);\n return {\n folder: at === null ? null : `${at}/${_ReposSkin.#repos}/${own.folder}`,\n made,\n doing: own.held["doing"] ?? null\n };\n }\n #own() {\n const { asker } = this.stamp;\n const folder = this.cells.get(["lobe", asker]);\n const held = typeof folder === "string" ? this.cells.get(["folder", folder]) : void 0;\n if (typeof folder !== "string" || !_ReposSkin.#fields(held))\n return this.error("refused", `the lobe ${asker} is granted no folder`);\n return { folder, held };\n }\n async #readMany(args, paths) {\n if (_ReposSkin.#arg(args, "path") !== void 0 || _ReposSkin.#arg(args, "first") !== void 0)\n return this.error("refused", "paths come alone, without path or first");\n if (!Array.isArray(paths) || paths.length === 0) return this.error("refused", "paths are one file or more");\n const named = paths.flatMap((one) => _ReposSkin.#text(one) && _ReposSkin.#names(one) !== null ? [one] : []);\n if (named.length !== paths.length)\n return this.error("refused", "a path is names under the repo, none empty, climbing or reaching .git");\n const reads = await Promise.all(named.map((path) => this.#disk("read", path)));\n const files = [];\n let weight = 0;\n for (const [at, read] of reads.entries()) {\n const path = named[at] ?? "";\n if (!("result" in read)) {\n if ("code" in read && read.code === "absent") files.push({ path, absent: true });\n else return read;\n continue;\n }\n const bytes = _ReposSkin.#arg(read.result, "bytes");\n const text = bytes instanceof Uint8Array ? this.#textOf(bytes) : null;\n if (!(bytes instanceof Uint8Array) || text === null) return this.error("refused", `${path} is not UTF-8 text`);\n weight += bytes.length;\n if (weight > this.memory / LOBE_SHARE)\n return this.error(\n "refused",\n `the files weigh past ${Math.floor(this.memory / LOBE_SHARE)} bytes, what one answer of this lobe carries`\n );\n files.push({ path, text });\n }\n return { files };\n }\n async read(args) {\n const paths = _ReposSkin.#arg(args, "paths");\n if (paths !== void 0) return this.#readMany(args, paths);\n const first = _ReposSkin.#arg(args, "first");\n if (first !== void 0 && !_ReposSkin.#count(first, Number.MAX_SAFE_INTEGER))\n return this.error("refused", "first is how many lines, one or more");\n const read = await this.#disk("read", _ReposSkin.#arg(args, "path"));\n if (!("result" in read)) return read;\n const bytes = _ReposSkin.#arg(read.result, "bytes");\n const text = bytes instanceof Uint8Array ? this.#textOf(bytes) : null;\n if (text === null) return this.error("refused", "the file is not UTF-8 text");\n const lines = text.split("\\n");\n return {\n text: first === void 0 ? text : lines.slice(0, first).join("\\n"),\n lines: lines.length\n };\n }\n async bytes(args) {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const sha = _ReposSkin.#arg(args, "sha");\n if (!_ReposSkin.#text(sha) || !_ReposSkin.#sha.test(sha))\n return this.error("refused", "a kept file is named by its SHA-256, in lowercase hex");\n const read = await this.ask("disk", "read", {\n path: [_ReposSkin.#transfers, this.stamp.asker, _ReposSkin.#kept, sha]\n });\n if ("error" in read) return this.error(read.error.code, read.error.message);\n const bytes = _ReposSkin.#arg(read.result, "bytes");\n return bytes instanceof Uint8Array ? { bytes } : this.error("refused", "the disk answered no bytes");\n }\n async write(args) {\n const text = _ReposSkin.#arg(args, "text");\n if (typeof text !== "string") return this.error("refused", "a write holds its text");\n const bytes = this.#bytes(text);\n if (bytes === null) return this.error("refused", "the text has no UTF-8");\n const wrote = await this.#disk("write", _ReposSkin.#arg(args, "path"), bytes);\n return "result" in wrote ? wrote.result : wrote;\n }\n async erase(args) {\n const erased = await this.#disk("remove", _ReposSkin.#arg(args, "path"));\n return "result" in erased ? erased.result : erased;\n }\n async list(args) {\n const path = _ReposSkin.#arg(args, "path");\n const listed = await this.#disk("list", path);\n const root = _ReposSkin.#names(path)?.length === 0;\n if (root && "code" in listed && listed.code === "absent") return { names: [] };\n return "result" in listed ? listed.result : listed;\n }\n async #disk(method, path, bytes) {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const names = _ReposSkin.#names(path);\n if (names === null || names.length === 0 && method !== "list")\n return this.error("refused", "a path is names under the repo, none empty, climbing or reaching .git");\n if (method !== "list" && names.join("/").toLowerCase() === _ReposSkin.#env)\n return this.error("refused", `${names.join("/")} is a secret file, written by secrets alone and read by no one`);\n const at = [_ReposSkin.#repos, own.folder, ...names];\n const answer = await this.ask("disk", method, bytes === void 0 ? { path: at } : { path: at, bytes });\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : answer;\n }\n async piece(args) {\n const path = await this.#piecePath(args);\n if (!Array.isArray(path)) return path;\n const read = await this.ask("disk", "read", { path });\n if ("error" in read) return this.#heard(read);\n return { bytes: _ReposSkin.#arg(read.result, "bytes") ?? null };\n }\n async put(args) {\n const path = await this.#piecePath(args);\n if (!Array.isArray(path)) return path;\n const pieces = _ReposSkin.#arg(args, "pieces");\n const at = _ReposSkin.#arg(args, "at");\n const bytes = _ReposSkin.#arg(args, "bytes");\n if (typeof pieces !== "number" || typeof at !== "number" || at >= pieces)\n return this.error("refused", "a piece stands before the count of its pieces");\n if (!(bytes instanceof Uint8Array)) return this.error("refused", "a piece holds its bytes");\n const wrote = await this.ask("disk", "write", { path, bytes });\n return this.#heard(wrote);\n }\n async #piecePath(args) {\n const own = this.#own();\n if (!("folder" in own)) return own;\n const at = _ReposSkin.#arg(args, "at");\n const as = _ReposSkin.#arg(args, "as");\n if (typeof at !== "number" || !Number.isSafeInteger(at) || at < 0)\n return this.error("refused", "a piece stands at a place, from 0");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return this.error("refused", "a bundle waits as push, pull, out-<far> or in-<far>");\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n return [_ReposSkin.#transfers, this.stamp.asker, as, `q${at}`];\n }\n async #clearing(as) {\n const runs = [as, "*"].flatMap((name) => {\n const run = _ReposSkin.#arg(this.cells.get(["clearing", this.stamp.asker, name]) ?? null, "run");\n return _ReposSkin.#text(run) ? [run] : [];\n });\n if (runs.length === 0) return null;\n const lost = await this.#lostOf(runs) ?? [];\n for (const run of lost) await this.#end(run, -1, "", _ReposSkin.#lost);\n return runs.every((run) => lost.includes(run)) ? null : this.error("refused", `the pieces of ${as} are being cleared`);\n }\n async clear(args) {\n const as = _ReposSkin.#arg(args, "as");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return this.error("refused", "a bundle waits as push, pull, out-<far> or in-<far>");\n const own = this.#own();\n if (!("folder" in own)) return own;\n const at = this.#at();\n if (at === null) return this.error("refused", "the disk\'s folder is not set up");\n const { asker } = this.stamp;\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n const program = [..._ReposSkin.programs.clear, at, asker, as];\n const begun = await this.ask("shell", "run", { program, input: "" });\n if ("error" in begun) return this.error(begun.error.code, begun.error.message);\n const run = _ReposSkin.#arg(begun.result, "run");\n if (!_ReposSkin.#text(run)) return this.error("refused", "the shell named no run");\n this.cells.set(["job", run], {\n job: run,\n kind: "clear",\n asker,\n folder: own.folder,\n ended: null\n });\n this.cells.set(["by", asker, run], null);\n this.cells.set(["clearing", asker, as], { run });\n return { job: run };\n }\n #transfer(as) {\n return `${this.#at() ?? ""}/${_ReposSkin.#transfers}/${this.stamp.asker}/${as}`;\n }\n async init(args) {\n const unchecked = this.checked("init", args);\n if (unchecked !== void 0) return unchecked;\n const own = this.#own();\n const at = this.#at();\n if (!("folder" in own)) return own;\n if (at === null) return this.error("refused", "the disk\'s folder is not set up");\n const held = await this.#unstuck(["folder", own.folder]);\n const doing = _ReposSkin.#arg(held ?? null, "doing");\n if (_ReposSkin.#text(doing)) return this.error("refused", `${own.folder} runs ${doing} already`);\n const nonce = this.#nonce();\n const path = [_ReposSkin.#repos, own.folder, _ReposSkin.#marker];\n const wrote = await this.ask("disk", "write", { path, bytes: this.#bytes(nonce) });\n if ("error" in wrote) return this.#heard(wrote);\n return this.#begin("init", own.folder, [at, own.folder], `${nonce}\n`);\n }\n stand(args) {\n const checks = _ReposSkin.#checksOf(args);\n if (checks === null) return Promise.resolve(this.error("refused", "a stand names the check of the parts"));\n return this.#job("stand", [], JSON.stringify(checks));\n }\n head(args) {\n const contains = _ReposSkin.#arg(args, "contains");\n if (contains !== void 0 && !(_ReposSkin.#text(contains) && _ReposSkin.#hash.test(contains)))\n return Promise.resolve(this.error("refused", "contains is a commit"));\n return this.#job("head", typeof contains === "string" ? [contains] : [], "");\n }\n status() {\n return this.#job("status", [], "");\n }\n commit(args) {\n const message = _ReposSkin.#arg(args, "message");\n if (!_ReposSkin.#text(message)) return Promise.resolve(this.error("refused", "a commit holds its message"));\n const checks = _ReposSkin.#checksOf(args);\n if (checks === null) return Promise.resolve(this.error("refused", "a commit names the check of the parts"));\n const own = this.#own();\n if (!("folder" in own)) return Promise.resolve(own);\n const executable = _ReposSkin.#arg(args, "executable");\n const paths = _ReposSkin.#arg(args, "paths");\n if (paths !== void 0 && !_ReposSkin.#paths(paths))\n return Promise.resolve(\n this.error("refused", "a commit takes paths of the repo, each a file or a folder under it")\n );\n const input = JSON.stringify({ ...checks, message, executable, paths });\n return this.#job("commit", [], input);\n }\n static #checksOf(args) {\n const { parts, conform, scoped } = _ReposSkin.#fields(args) ? args : {};\n if (!_ReposSkin.#text(parts)) return null;\n if (conform !== void 0 && !(_ReposSkin.#text(conform) && _ReposSkin.#hash.test(conform))) return null;\n if (scoped !== void 0 && typeof scoped !== "boolean") return null;\n return { parts, ...conform === void 0 ? {} : { conform }, ...scoped === true ? { scoped } : {} };\n }\n discard() {\n return this.#job("discard", [], "");\n }\n log(args) {\n const most = _ReposSkin.#arg(args, "most") ?? _ReposSkin.#logs;\n if (!_ReposSkin.#count(most, this.#most()))\n return Promise.resolve(this.error("refused", `most is how many commits, one to ${this.#most()}`));\n return this.#job("log", [String(most)], "");\n }\n run(args) {\n const script = _ReposSkin.#arg(args, "script");\n const install = _ReposSkin.#arg(args, "install") ?? false;\n const words = _ReposSkin.#argsOf(_ReposSkin.#arg(args, "args"));\n if (!_ReposSkin.#text(script) || !_ReposSkin.#script.test(script))\n return Promise.resolve(this.error("refused", "a run names a script of the repo\'s package"));\n if (typeof install !== "boolean") return Promise.resolve(this.error("refused", "install is true or false"));\n const gate = _ReposSkin.#arg(args, "gate") ?? false;\n if (typeof gate !== "boolean") return Promise.resolve(this.error("refused", "gate is true or false"));\n if (words === null)\n return Promise.resolve(this.error("refused", `a run\'s args are texts, at most ${ARGS_MOST}, none holding a NUL`));\n return this.#job("run", [script, install ? "install" : "", gate ? "gate" : "", ...words], "");\n }\n secrets(args) {\n const set = this.#linesOf(_ReposSkin.#arg(args, "set"));\n if (set === null)\n return Promise.resolve(\n this.error("refused", "a secret file\'s lines are each an environment variable\'s name and a value of one line")\n );\n const own = this.#own();\n if (!("folder" in own)) return Promise.resolve(own);\n return this.#job("secrets", [], JSON.stringify({ set }));\n }\n async bundle(args) {\n const since = _ReposSkin.#arg(args, "since") ?? null;\n const as = _ReposSkin.#arg(args, "as");\n if (since !== null && !(_ReposSkin.#text(since) && _ReposSkin.#hash.test(since)))\n return this.error("refused", "since is a commit, or null");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return this.error("refused", "a bundle waits as push, pull, out-<far> or in-<far>");\n const cut = _ReposSkin.#arg(args, "cut") ?? false;\n if (typeof cut !== "boolean") return this.error("refused", "cut is true or false");\n const tag = _ReposSkin.#arg(args, "tag");\n if (tag !== void 0 && !(_ReposSkin.#text(tag) && _ReposSkin.#tag.test(tag)))\n return this.error("refused", "a tag is v and three whole numbers");\n if (cut && tag !== void 0) return this.error("refused", "a cut is bundled by no tag");\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n const most = Math.floor(this.memory / LOBE_SHARE);\n const piece = _ReposSkin.#arg(args, "piece") ?? _ReposSkin.#box;\n if (!_ReposSkin.#count(piece, most))\n return this.error("refused", `a piece is a whole number of bytes, one to ${most}`);\n const words = [cut ? `refs/nervur/cut-${as}` : "", typeof tag === "string" ? tag : "", String(piece)];\n return this.#job("bundle", [this.#transfer(as), since ?? "", ...words], "");\n }\n cut(args) {\n const as = _ReposSkin.#arg(args, "as");\n const tag = _ReposSkin.#arg(args, "tag");\n if (tag !== void 0 && !(_ReposSkin.#text(tag) && _ReposSkin.#tag.test(tag)))\n return Promise.resolve(this.error("refused", "a tag is v and three whole numbers"));\n const scope = _ReposSkin.#scopeOf(_ReposSkin.#arg(args, "scope"));\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return Promise.resolve(this.error("refused", "a cut is named as push, pull, out-<far> or in-<far>"));\n if (scope === null)\n return Promise.resolve(\n this.error("refused", `a scope is 1 to ${SCOPE_MOST} folders of the repo, none inside another`)\n );\n return this.#job("cut", [as, typeof tag === "string" ? tag : "", ...scope], "");\n }\n async bring(args) {\n const as = _ReposSkin.#arg(args, "as");\n const pieces = _ReposSkin.#arg(args, "pieces");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as) || !_ReposSkin.#count(pieces, Number.MAX_SAFE_INTEGER))\n return this.error("refused", "a bundle names where it waits and its pieces");\n const scoped = _ReposSkin.#arg(args, "scope");\n const scope = scoped === void 0 ? [] : _ReposSkin.#scopeOf(scoped);\n if (scope === null)\n return this.error("refused", `a scope is 1 to ${SCOPE_MOST} folders of the repo, none inside another`);\n const clearing = await this.#clearing(as);\n if (clearing !== null) return clearing;\n return this.#job(scope.length === 0 ? "bring" : "graft", [this.#transfer(as), String(pieces), as, ...scope], "");\n }\n land(args) {\n const as = _ReposSkin.#arg(args, "as");\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as))\n return Promise.resolve(this.error("refused", "a landing names what waits, as push, pull, out-<far> or in-<far>"));\n return this.#job("land", [as], "");\n }\n conform(args) {\n const { as, head, script } = _ReposSkin.#fields(args) ? args : {};\n if (!_ReposSkin.#text(as) || !_ReposSkin.#as.test(as) || !_ReposSkin.#text(head) || !_ReposSkin.#hash.test(head))\n return Promise.resolve(\n this.error("refused", "a conform names what waits, as push, pull, out-<far> or in-<far>, and its head")\n );\n if (script !== void 0 && !(_ReposSkin.#text(script) && _ReposSkin.#script.test(script)))\n return Promise.resolve(this.error("refused", "a gate is a script of the repo\'s package"));\n const checks = _ReposSkin.#checksOf(args);\n if (checks === null) return Promise.resolve(this.error("refused", "a conform names the check of the parts"));\n const words = typeof script === "string" ? [as, head, script] : [as, head];\n return this.#job("conform", words, JSON.stringify(checks));\n }\n scan() {\n return this.#job("scan", [this.#transfer(_ReposSkin.#kept)], "");\n }\n build(args) {\n const organ = _ReposSkin.#arg(args, "organ");\n if (!_ReposSkin.#text(organ) || organ.length > 64 || !_ReposSkin.#organ.test(organ))\n return Promise.resolve(this.error("refused", "an organ is named by its fixed ID"));\n return this.#job("build", [organ], "");\n }\n look(args) {\n const design = _ReposSkin.#arg(args, "design");\n if (!_ReposSkin.#text(design) || design.length > 59 || !_ReposSkin.#design.test(design))\n return Promise.resolve(this.error("refused", "a design is named by its folder"));\n return this.#job("look", [design], "");\n }\n async stop(args) {\n const named = _ReposSkin.#arg(args, "folder");\n const owner = this.stamp.asker === _ReposSkin.#owner;\n if (!owner && named !== void 0) return this.error("refused", "a repo lobe reaches its own folder alone");\n const folder = owner ? named : this.cells.get(["lobe", this.stamp.asker]);\n const held = _ReposSkin.#text(folder) ? this.cells.get(["folder", folder]) : void 0;\n if (!_ReposSkin.#text(folder) || !_ReposSkin.#fields(held)) return this.error("refused", "no such folder");\n const doing = held["doing"];\n if (!_ReposSkin.#text(doing)) return this.error("refused", `the folder ${folder} runs nothing`);\n const asker = _ReposSkin.#arg(this.cells.get(["job", doing]) ?? null, "asker");\n if (!owner && asker !== this.stamp.asker)\n return this.error("refused", `the folder ${folder} runs another lobe\'s job`);\n const grace = _ReposSkin.#arg(args, "grace");\n const stopped = await this.ask("shell", "stop", { run: doing, ...grace === void 0 ? {} : { grace } });\n if (!("error" in stopped)) return null;\n if (stopped.error.code !== "refused") return this.#heard(stopped);\n return this.#end(doing, -1, "", _ReposSkin.#lost);\n }\n async back(args) {\n if (this.stamp.asker !== _ReposSkin.#owner || _ReposSkin.#arg(args, "placeholder") !== "shell") return null;\n const going = [\n ...[this.cells.get(["setup"]), ...this.#all(["folder"]).map(({ value }) => value)].map(\n (held) => _ReposSkin.#arg(held ?? null, "doing")\n ),\n ...this.#all(["clearing"]).map(({ value }) => _ReposSkin.#arg(value, "run"))\n ].filter((run) => _ReposSkin.#text(run));\n const lost = going.length === 0 ? [] : await this.#lostOf(going) ?? [];\n for (const run of lost) await this.#end(run, -1, "", _ReposSkin.#lost);\n return null;\n }\n async ended(args) {\n const read = await this.nerves.read();\n await this.#torn(read);\n const { run, code, out, err } = _ReposSkin.#fields(args) ? args : {};\n const whole = typeof out === "string" && typeof err === "string" && typeof code === "number";\n if (!whole || !_ReposSkin.#text(run))\n return this.error("refused", "an end names its run, its exit code and its output");\n return this.#end(run, code, out, err, read);\n }\n async #end(job, code, out, err, read) {\n const run = job;\n const held = this.cells.get(["job", run]);\n if (!_ReposSkin.#fields(held) || held["ended"] !== null) return this.error("refused", "no such job going");\n const { asker, kind, folder } = held;\n if (kind === "clear") return this.#cleared(run, asker);\n this.cells.set(["job", run], { ...held, ended: { code } });\n if (_ReposSkin.#text(asker)) this.#endKept(asker, run);\n this.#settled(kind, folder, code);\n if (!_ReposSkin.#text(asker) || asker === _ReposSkin.#owner) return null;\n if (!_ReposSkin.#ends(read ?? await this.nerves.read()).has(asker)) return null;\n const told = { job: run, kind: kind ?? null, code, out, err };\n this.cells.set(["last", asker], told);\n const letter = { lives: _ReposSkin.#lives };\n return this.#heard(await this.ask(asker, "done", told, void 0, { letter }));\n }\n #cleared(run, asker) {\n for (const { key, value } of this.#all(["clearing"]))\n if (_ReposSkin.#arg(value, "run") === run) this.cells.delete(key);\n this.cells.delete(["job", run]);\n if (_ReposSkin.#text(asker)) this.cells.delete(["by", asker, run]);\n return null;\n }\n #endKept(asker, run) {\n const ends = this.cells.get(["ended", asker]);\n let first = Number(_ReposSkin.#arg(ends ?? null, "first") ?? 0);\n const next = Number(_ReposSkin.#arg(ends ?? null, "next") ?? 0);\n for (; next - first >= Math.max(1, this.#most()); first += 1) {\n const oldest = this.cells.get(["ended", asker, String(first)]);\n if (_ReposSkin.#text(oldest)) {\n this.cells.delete(["job", oldest]);\n this.cells.delete(["by", asker, oldest]);\n }\n this.cells.delete(["ended", asker, String(first)]);\n }\n this.cells.set(["ended", asker, String(next)], run);\n this.cells.set(["ended", asker], { first, next: next + 1 });\n }\n #settled(kind, folder, code) {\n if (kind === "setup") {\n const setup = this.cells.get(["setup"]);\n const failed = code === 0 ? null : "the marker was not read back";\n if (_ReposSkin.#fields(setup)) this.cells.set(["setup"], { ...setup, ready: code === 0, failed, doing: null });\n return;\n }\n const held = _ReposSkin.#text(folder) ? this.cells.get(["folder", folder]) : void 0;\n if (!_ReposSkin.#text(folder) || !_ReposSkin.#fields(held)) return;\n if (kind === "remove" && code === 0) {\n this.cells.delete(["folder", folder]);\n return;\n }\n const proven = (kind === "init" || kind === "stand" || kind === "head") && code === 0 ? { made: true } : {};\n this.cells.set(["folder", folder], { ...held, ...proven, doing: null });\n }\n jobs(args) {\n const { asker } = this.stamp;\n const page = this.#page(asker === _ReposSkin.#owner ? ["job"] : ["by", asker], args);\n if (!("cells" in page)) return page;\n const jobs = asker === _ReposSkin.#owner ? page.cells.map(({ value }) => value) : page.cells.map(({ key }) => this.cells.get(["job", key[2] ?? ""]) ?? null);\n return { jobs, cursor: page.cursor };\n }\n job(args) {\n const run = _ReposSkin.#arg(args, "job");\n if (!_ReposSkin.#text(run)) return this.error("refused", "a job is named by its id");\n const { asker } = this.stamp;\n const held = this.cells.get(["job", run]);\n const owns = asker === _ReposSkin.#owner || this.cells.get(["by", asker, run]) !== void 0;\n if (!owns || !_ReposSkin.#fields(held)) return this.error("absent", "no such job");\n return held;\n }\n async #back(folder) {\n const { asker } = this.stamp;\n if (this.cells.get(["lobe", asker]) !== folder || _ReposSkin.#ends(await this.nerves.read()).has(asker)) return null;\n const ordered = await this.nerves.order({ termination: asker });\n return "error" in ordered ? this.error("refused", `no wire back: ${ordered.error.message}`) : null;\n }\n #job(kind, more, input) {\n const own = this.#own();\n if (!("folder" in own)) return Promise.resolve(own);\n const at = this.#at();\n if (at === null) return Promise.resolve(this.error("refused", "the disk\'s folder is not set up"));\n const dir = `${at}/${_ReposSkin.#repos}/${own.folder}`;\n return this.#begin(kind, own.folder, [dir, ...more], input);\n }\n async #begin(kind, folder, words, input) {\n const record = await this.#unstuck(folder === null ? ["setup"] : ["folder", folder]);\n if (!_ReposSkin.#fields(record)) return this.error("refused", "no such folder");\n if (_ReposSkin.#text(record["doing"]))\n return this.error("refused", `${folder ?? "the setup"} runs ${record["doing"]} already`);\n const { asker } = this.stamp;\n const back = folder === null ? null : await this.#back(folder);\n if (back !== null) return back;\n const program = [..._ReposSkin.programs[kind], ...words];\n const begun = await this.ask("shell", "run", { program, input });\n if ("error" in begun) return this.error(begun.error.code, begun.error.message);\n const run = _ReposSkin.#arg(begun.result, "run");\n if (!_ReposSkin.#text(run)) return this.error("refused", "the shell named no run");\n this.cells.set(["job", run], { job: run, kind, asker, folder, ended: null });\n this.cells.set(["by", asker, run], null);\n this.cells.set(folder === null ? ["setup"] : ["folder", folder], { ...record, doing: run });\n return { job: run };\n }\n};\nexport {\n ReposSkin as default\n};\n';
1240
1240
 
1241
1241
  var REPOS = { faculty: REPOS_SOURCE, label: "repos" };
1242
1242
 
1243
- var REPO_SOURCE = 'import { Faculty } from "nervur:faculty";\n\nvar LETTER_LIVES = 864e5;\nvar LOBE_SHARE = 4;\nvar ITEM_SIZE = 1024;\nvar CELLS_RANGE = 1e3;\nvar ARG_LONGEST = 4096;\nvar ARGS_MOST = 64;\nvar RING_PAUSE = 1e3;\nvar TAIL = 4096;\nvar SCOPE_MOST = 16;\nvar STILL = 36e5;\nvar SPELL = 5e3;\nvar WITHIN = 36e5;\nvar MINUTE = 6e4;\n\nvar RepoLobe = class _RepoLobe extends Faculty {\n static #owner = "brain";\n static #library = "library";\n static #lives = LETTER_LIVES;\n static #every = RING_PAUSE;\n static #tail = TAIL;\n static #repoName = /^[a-z](?:[a-z0-9-]|\\.(?=[a-z0-9-])){0,63}$/;\n static #script = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,63}$/;\n static #key = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;\n static #issued = /^(?=.{1,40}$)[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;\n static #spell = SPELL;\n static #issuerWithin = WITHIN;\n static #minute = MINUTE;\n static #argsMost = ARGS_MOST;\n static #argLongest = ARG_LONGEST;\n static #hash = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;\n static #digest = /^[0-9a-f]{64}$/;\n static #version = /^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$/;\n static #label = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;\n static #id = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n static #tag = /^v(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$/;\n static #hashed = /^d ([0-9a-f]{64}) ((?:designs|faculties)\\/[^/]+)\\/(.+)$/;\n static #standings = ["reader", "writer", "library", "runner"];\n static #segment = /^[A-Za-z0-9._-]+$/;\n static #scopeMost = SCOPE_MOST;\n static #entry = /^(?!\\.{1,2}$)(?!\\.git$)[^/\\\\\\0]+$/i;\n static #lobe = "lobe";\n static #teller = "teller";\n static #tells = "tells";\n static #hears = "library";\n static #waits = ["timeout", "unavailable", "busy"];\n static #still = STILL;\n static #lifted = Math.floor(Number.MAX_SAFE_INTEGER / 2);\n static #onCommit = ["off", "on", "mandatory"];\n static #onPush = ["off", "on"];\n static #moves = ["init", "land", "commit"];\n static #writes = ["owner", "near"];\n static #offers = ["owner", "near", "library"];\n static #runs = ["owner", "near", "runner"];\n static #pulls = ["reader", "pusher"];\n static #who = {\n init: ["owner"],\n accept: ["owner"],\n relink: ["owner"],\n invite: ["owner"],\n drop: ["owner"],\n occupants: ["owner"],\n migrate: ["owner"],\n gate: ["owner"],\n gates: ["owner"],\n conform: ["owner"],\n author: ["owner"],\n remove: ["owner"],\n rebuild: ["owner"],\n state: ["owner", "near", "library"],\n jobs: _RepoLobe.#runs,\n job: _RepoLobe.#runs,\n pull: _RepoLobe.#writes,\n push: _RepoLobe.#writes,\n build: _RepoLobe.#writes,\n commit: _RepoLobe.#writes,\n status: _RepoLobe.#writes,\n log: _RepoLobe.#writes,\n discard: ["owner"],\n read: _RepoLobe.#writes,\n list: _RepoLobe.#writes,\n run: _RepoLobe.#runs,\n setToken: ["owner"],\n credential: ["owner"],\n stop: _RepoLobe.#writes,\n faculties: _RepoLobe.#offers,\n organs: _RepoLobe.#offers,\n designs: _RepoLobe.#offers,\n get: _RepoLobe.#offers,\n told: _RepoLobe.#offers,\n head: _RepoLobe.#pulls,\n give: _RepoLobe.#pulls,\n piece: _RepoLobe.#pulls,\n take: ["pusher"],\n taken: ["pusher"],\n done: ["jailer", "teller"]\n };\n static #some = { type: "string", minLength: 1 };\n static #maybe = { anyOf: [{ type: "string", minLength: 1 }, { type: "null" }] };\n static #place = { type: "integer", minimum: 0 };\n static #one = { type: "integer", minimum: 1 };\n static #span = { anyOf: [{ type: "integer", minimum: 0 }, { type: "null" }] };\n static #plain = { type: "string" };\n static #none = { type: "object", additionalProperties: false };\n static #named = { type: "string", pattern: "^[a-z][a-z0-9.-]{0,63}$" };\n static #fixed = { type: "string", maxLength: 64, pattern: "^[a-z][a-z0-9]*(-[a-z0-9]+)*$" };\n static #jobSchema = {\n type: "object",\n properties: { job: _RepoLobe.#some },\n required: ["job"],\n additionalProperties: false\n };\n static #object(properties, required = Object.keys(properties)) {\n return { type: "object", properties, required, additionalProperties: false };\n }\n static #over(properties, required = Object.keys(properties)) {\n return _RepoLobe.#object({ ...properties, name: _RepoLobe.#named }, required);\n }\n static #says = {\n init: "An owner: with `starter` true, the repo `name` born and its first commit the repo lobe\'s one small starter, a step of the same job; else the repo `name` born empty and ready in the folder the jailer grants, which holds nothing: it holds no commit, may give invitations, and what it begins with is laid by the first commit of its owner or the first push of the lobe that stands on it, whole, each checked as any. Never born again, since a folder holding a repo refuses it. With `standing` true: handed in place the repo the granted folder holds already, a lobe torn down having kept it, ready on its head and tags as they stand once its `main` passes the two checks, its `conform` as `main` holds it, which it chooses, nothing laid or moved, refused where no repo stands there. An init that failed may be asked again.",\n accept: "An owner: the repo `name` laid again from the lobe an invitation names, as a lost lobe is: made empty, standing on that lobe, and pulled whole from it, the pull a step of its one job, which ends on the pull’s code and check once it landed and was scanned. The mouth keeps `note` beside the standing the organism holds, the owner’s, else `{ repo, on }`, the repo and the placeholder it stands on by; it never travels. A lobe born of a scoped lobe notes the scope on that standing, and keeps that its bytes are cut beside its head.",\n relink: "An owner: stands on the lobe of the repo an invitation names, beside those it stands on, under a placeholder of its own, which it answers: `placeholder`, a name this lobe holds for nothing else; else, with `instead`, the name of the standing it replaces; else the next free `lobe-<n>`. With `instead`, the lobe it stood on under that placeholder is asked to `drop` this one\'s standing, and the relation ends: once the new one stands, or first where the new one takes its name, since a placeholder has one wire. The mouth keeps `note` beside the standing, the owner\'s, else `{ repo, on }`. Refused to a lobe born of a scope, which stands on no other.",\n setToken: "An owner: the key `name`, any environment variable\'s name, of this lobe, set to `value`, or removed where `value` is null; kept in this lobe\'s cells, never answered, masked in all it tells, and in `.env` from the next run.",\n credential: "An owner: takes the credential of an issuer\'s standing the organism holds, as the key `secret`. With `invitation`, the organism accepts it, the mouth keeping `note`, the owner\'s, beside the standing; with `placeholder`, a placeholder of this lobe an owner wired to a standing the organism holds already, refused where it reaches no standing or one this lobe keeps another key over. Either way this lobe writes its own note on the standing, `{ credential: secret }`, asks the issuer `credential`, again at the `ready` it answers while it makes it, and a few seconds on while it is silent, for as long as `within` names in milliseconds: the cap where it names none, and never more, an hour or an owner’s word over `within`, read in its nerves as it begins, a span past it refused; then failing, saying why, and keeps its `value`, masked and never answered; where it `expires`, it is asked again before then, by a tenth of its life, a renewal that fails keeping the value, asked again at half what is left and never within a minute, and told in `state`; answers `{ secret }`, with `pending` while the issuer makes it. Asked again with its `secret` alone it asks the issuer for a fresh one.",\n invite: "An owner: an invitation for one far organism, a `reader`, a `writer` or a `library`, kept by the ear for `waits` and its relation for `lives`, reached down a line to the address `through` where one is named. This lobe’s own note on the occupant, kept by the brain, is the owner’s `note`, if any, and `{ repo, standing }`, the repo and the kind of standing its far holds, and `scope` where one is named; this lobe reads the kind and the scope back from the stamp of each ask of that far, and keeps no cell of them; the note never travels with the invitation. A reader’s or a writer’s `scope`, 1 to 16 folders of the repo, each of names of letters, digits, `.`, `_` and `-`, none `.`, `..` nor `.git`, none inside another, kept sorted in that note and never in the invitation, so the standing reaches those folders alone; a library’s is refused, and a lobe born of a scope gives no occupant, for life.",\n drop: "An owner: ends the far organism `far`\'s relation and its standing, or this lobe\'s standing on the lobe it holds as `on`. A holder ends its own standing by its mouth\'s `drop`.",\n occupants: "An owner: each occupant of this lobe, its far organism and its role, a reader, a writer, a library or a runner, with its scope where it holds one, read from this lobe’s notes through its `nerves`.",\n left: "The brain\'s: an end this lobe gave or is granted ended, `far` with its `note`; whatever this lobe kept by that far, its pull and push pieces, forgotten; a pull or a push over a standing it was granted that ended ends. The repo\'s files and history stay as they stand.",\n migrate: "The brain, at a move to this version: each wired lobe whose wire back is gone, torn down, forgotten, its lines, where it held any, taken out at the next job’s end; a pull or a push standing is rung again: a fresh `chain` kept in it and its `tick` set by a letter, the old chain dying at its next ring; and a scan of the repo owed, so every tag’s files are kept before a version told is asked: begun where the repo has a head and runs nothing, no job and no pull or push, else at the first instant it does, found by a job’s end or a pull’s or a push’s or by an alarm of its own, and owed until a scan ends whole.",\n remove: "An owner: forgets the repo, once no far standing holds it and nothing runs; its bytes stay in the folder, for the jailer’s owner.",\n rebuild: "An owner, after a move or a restore: the repo made again empty, its head unanswered until it holds the head it kept, pulled whole from a lobe it stands on, a step of its one job, which ends once that pull ended, else pushed whole by one that stands on it, that push in once the head is proven.",\n state: "The repo: its name, head, whether it is ready, not where its folder holds no repo, `absent` then saying so and that `rebuild` fills it again, the job going, how its last pull or push ended, the lobes it stands on, how many far writers push to it, its folder on the host, its wired lobes, its gate and its settings, the commit whose `conform` its owner chose, and its author, the ends read from its `nerves`; `scopes`, each scoped occupant and its scope, and `scoped`, each lobe it stands on by a scope and that scope, where there are any; `cut`, each kind of part the last scan listed past one read’s most and how many it left unlisted, where it cut any; to the library, its name alone.",\n gate: "An owner: the script of the repo\'s package the gate runs, or null for none; `gate` where none was set.",\n gates: "An owner: the settings of the gate, `commit` and `push`, each only where named, answering both. On commit, `on` by default: a commit first runs the gate, with the repo’s `.env`, and is refused, with the gate’s tail, where it is red; `off` commits at once; `mandatory` is `on` and no commit skips it. On push, `off` by default: `on` runs the gate after the two checks on each push this lobe takes, and a red gate refuses it.",\n conform: "An owner: with `take` true, the repo’s `conform` as `main` holds it now chosen, the one that judges each commit, push and pull from then on, whoever changed it; with `take` false, none, what enters guarded by the check of the parts alone; answering the commit whose conform is chosen, or null. A commit of this lobe’s own that changes it chooses it too, and an `init` standing on a repo in place; nothing a writer pushes or a pull brings does.",\n author: "An owner: beside a lobe far writers push to, the one wired lobe whose commit it takes, as the spec’s wired lobe files a proposal, or null for none; no other commits there, an owner neither.",\n commit: "An owner\'s or a wired lobe\'s: `files`, each a path under the repo and its text, `executable` naming those of them that land executable, written first, then, where its setting on commit says so, the gate, with the repo\'s `.env`; then, in its own job, refused while a secret file stands that git would take, the check of the parts, handed what the latest tag told of each `versions.json` (a version told changed is refused), and the repo\'s `conform` as its owner chose it, none where it chose none, each over what it would commit laid out apart as a clone would hold it, so a file `.gitignore` keeps out counts as absent, and its root `package.json` `version` read against `HEAD`\'s, refused where it changed and is not three whole numbers, is lower by semver, or its tag stands already; then every change committed on `main` with `message`, tagged `v<version>` in the same job where it raised the version, a lobe holding a scope tagging none, its head taken and `main` scanned, the job\'s last step (`job`). `gate` false skips the gate, refused where the setting is `mandatory`; `gate` true asks it once where the setting is `off`. A red gate or a broken rule refuses it, saying why, and every file it wrote is put back as it was before the ask (removed where it stood not, its old text written where it did), in the same job, the refusal saying so; a commit without `files` is its owner\'s, of what the folder holds, and puts nothing back. With `paths`, each a file or a folder of the repo, no `files` beside them, it takes the changes of those paths alone, added, changed or removed, and leaves the rest of the folder as it stands; the gate still runs on the folder as it stands, the checks over `main` as the commit would leave it, and `paths` that hold no change refuse it, committing nothing. Beside a lobe far writers push to, its author\'s alone.",\n status: "A job: `git status` of the folder.",\n log: "A job: the last commits, `most` of them, twenty where none is named.",\n discard: "An owner: a job undoing every change since the last commit.",\n read: "A file\'s text, its first lines where `first` names how many, and how many lines it holds; or `paths` (one or more) alone, many files in one answer, as many as a quarter of what the jailer\'s lobe holds takes, `{ files }`, each `{ path, text }` or `{ path, absent: true }` in the order named, read in one ask of the jailer; the whole refused, saying why, where a path climbs or hides, a text is no UTF-8 or the texts weigh past what one answer carries.",\n list: "The names in a folder of the repo, its top where no path is named.",\n run: "A job, an owner\'s, a wired lobe\'s or a runner\'s, a runner\'s among the scripts its invitation names alone: the script `script` of the repo\'s `package.json` with `args`, each one argument after `--`, never read by a shell, with this lobe\'s keys, `.env` written whole first where it keeps any or wrote it before, its values masked in its output; a script without its key fails by its own words. With `install`, `npm ci` first where a lockfile stands, in the same job. Its end is told back by a letter to a wired lobe; an owner and a runner read it by `job`.",\n stop: "The asker\'s pull or push standing, an owner\'s any, ended failed, saying it was stopped, its job of the jailer\'s ending by itself unheeded, refused while it lands; else the asker\'s job going stopped through the jailer, an owner\'s any; one the shell runs no more ends at once, failed.",\n jobs: "The asker\'s jobs of this lobe\'s own, a build, an init, an owner\'s every one, each with `began`, the stamp time it began, and how it ended, `{ run, code, at }`, `at` the stamp time it ended, or null while it runs. Of each asker the lobe keeps every job that runs and its newest ended, as many as one read holds; a step of another\'s work is forgotten once it moved that work on. A page, `{ jobs, cursor }`, `cursor` null at the list\'s end, else handed back to read on.",\n job: "One of the asker\'s jobs, `job`, whole, with `began` and `ended.at`, the stamp times it began and ended; an owner reads any, and one not the asker\'s is absent. A job that moved `main` ends once its last step, the scan of `main`, ended, the repo then running nothing, `ended.scan` the scan\'s `code` and the tail of why it failed, `err`, which fails no work.",\n pull: "A job: the commits of the lobe it stands on as `on`, the one it stands on where it names none, after its own HEAD, as a bundle in pieces over the relation, each of the bytes `piece` names, Quo\'s box where it names none, brought apart, checked by this lobe\'s two checks, the check of the parts and `conform` as its owner chose it, never as what came holds it, then brought into `main`, merged where it must, with the tags `v*` of the commits it brings, laid once `main` moved; a conflict, a rule broken or a tag this lobe holds on another commit refuses it, saying which. With `tag`, `v` and three whole numbers, `main` is brought up to the commit that tag names and no further, refused where the lobe pulled from holds no such tag, and nothing brought where `main` holds that commit already; a lobe holding a scope pulls by a tag too, the lobe pulled from cutting `main` to the scope up to that commit, and the tag’s name never enters the scoped lobe. `still` names how long it may stand still, in milliseconds, nothing taken and no stage moved, before it ends failed: the cap where it names none, and never more, an hour or an owner’s word over `still`.",\n push: "A job: its commits after the HEAD of the lobe it stands on as `on`, the one it stands on where it names none, sent in pieces, which that lobe checks by its own rules and brings into its `main`, or refuses, saying why; it carries the tags `v*` of the commits it sends, which that lobe lays once its `main` moved, or refuses the whole where it holds one on another commit; once its last piece is in it asks that lobe its end, `taken`, each ring, and ends with what it heard. With `tells`, the asker’s word that this organism can be dialed, its first piece gives that lobe a standing back, drawn fresh, the one before ended, over which that lobe tells its end, `done`, so the push asks nothing once its last piece is in and ends with what it was told. `piece` names the bytes of each piece, Quo’s box where it names none, what one lobe holds bounding it on either side. `still` names how long it may stand still, in milliseconds, nothing taken and no stage moved, before it ends failed: the cap where it names none, and never more, an hour or an owner’s word over `still`.",\n faculties: "Each faculty `main` holds, its label, version and digest, and its assets where its `assets/` holds any, each `[path, SHA-256]`, or why it is not told; absent where `faculties/` is not.",\n organs: "Each organ `main` holds, its ID, version and digests, or why it is not told; absent where `organs/` is not.",\n designs: "Each design `main` holds, its name, version and the digests of its data and its look, or why it is not told, a design told as its look, the faculty `<name>.look` with its assets; absent where `designs/` is not.",\n get: "A faculty\'s `{ source, digest }`, with `assets` where its `assets/` holds any, each `[path, SHA-256]`, its evidence among them; an organ\'s `{ blueprint, half }`; or a design\'s look, the faculty `<name>.look` at the design\'s version, once built, `{ source, digest, assets }`, its assets the design\'s data; at a version told, its bytes checked, and served as told whatever `main` holds after, its assets read from what the jailer kept of every tag by SHA-256, `absent` where a scan keeps them not yet, saying whether it is being kept, a scan running, or waits, a scan owed that begins once the repo runs nothing; with `path`, an asset of a faculty or a look `{ path, digest, bytes }`, its canonical bytes whole, whose SHA-256 is `digest`; with `version` null, a faculty or an organ as the folder holds it, to an owner or a writer alone.",\n build: "A job building the organ `organ`\'s host half at a version told, keeping the built half\'s digest; or the design `design`\'s look, by the repo\'s script `design`, keeping its source where it is the look `versions.json` told; either refused while `main` holds not that version, as the last scan found it.",\n told: "The versions the repo told, each with its digests; a version is told once a commit tagged `v<version>` holds it, and a scan of a head no tag names tells none. A far library may name `tells`, the invitation to a standing back on it, taken under `library-<far>`, the one before ended, over which this lobe tells it each version it tells after, `changed`, by an ask; it ends with that library’s standing. A page, `{ told, cursor }`, of the versions from the first told, the newest last, `cursor` null at the list’s end, else handed back to read on.",\n head: "A far reader or writer: this lobe\'s HEAD, null while it rebuilds, and null to a scoped one, which pushes its scope whole.",\n give: "A far reader or writer: the commits after `since`, as a bundle in pieces once it is made, each of the bytes `piece` names, Quo’s box where it names none, with the tags `v*` naming commits among them; until then, not ready. With `tag`, `v` and three whole numbers, up to the commit that tag names and no further, refused where this lobe holds no such tag, and none where `since` holds that commit already; to a scoped one, `main` is cut to its scope up to the commit that tag names, which is the beginning of the cut to the head, and the bundle holds that cut’s commits after `since`, never a tag. A bundle that failed is refused once, then made again. To a scoped one, `main` is cut to its scope first, the same every time, and the bundle holds the cut’s commits after `since`, read against the cut, nothing of `main` outside the scope, no tag; its answer carries `scope`, which the lobe that pulls keeps, and from then gives no occupant.",\n piece: "A far reader or writer: the bundle\'s piece `at`.",\n take: "A far writer: the piece `at` of `pieces` of the push its writer names `push`, in order. The first may name `tells`, the invitation of the standing back its writer gives, which this lobe accepts under `tells-<far>`, the one it held of that writer before ended; once the push is in `main` or refused, a writer that gave one is told `done { job, kind, code, out, err, check }` over it by an ask, once. The same piece of the same push sent again, the same bytes, is answered as it was; a push named anew, from its first piece, is a new one, brought and checked anew by the rules as they stand, whatever came before; any other piece is refused as out of order. The last has this lobe bring it apart and check it by its two checks, and its gate where its setting on push is `on`; the tags it carries brought apart, the whole refused where one names no commit it brings or this lobe holds a tag of that name on another commit, and laid once `main` moved. A scoped writer\'s is grafted first, its tags not taken: refused unless it is linear on the scope\'s head as `main` is cut now, else as behind, and where a commit changes a path outside the scope; each commit grafted on `main`\'s tip, its tree `main`\'s with the scope\'s paths taken from it, its author, committer, times and message kept, and what `main` would become checked whole.",\n taken: "A far writer: the end of its last push, `{ job, kind, code, out, err, check }`, as `done` tells it, or `{ ready: false }` until it is in `main` or refused, with `waits`, what it waits on, where its last piece is in and the repo runs another job first: that job checked with the jailer, so one whose end was lost holds it not, and the push brought once the repo runs nothing. A scoped writer hears the head it pushed and its check\'s code alone.",\n renew: "The scheduler\'s alone: each credential waited on whose time came asked again, each due to be renewed renewed.",\n keep: "The scheduler\'s alone: a scan owed begins where the repo has a head and runs nothing, by the `chain` its alarm carries, the one the lobe keeps; where the repo runs a job, the jailer is asked of it first, so a job whose end was lost ends; answers `{ again }`, a minute on, while the scan is owed, begun or not, and null once it is no more owed; a ring of any other chain answers null and writes nothing.",\n tick: "The scheduler\'s alone: a pull or a push takes its next step, by the `chain` its alarm carries, the one the sync keeps; a tick of any other chain, or where no sync stands, answers null at once and writes nothing; each ring making one far ask at most, within the time the ring is given: a push\'s piece read through the jailer and taken, a pull\'s got and put through the jailer, one piece a ring; a ring that moved the work rings the next at once, as a job of the jailer ending does; one waiting on a job of the jailer is rung at once by that job\'s end or its loss, told at the shell\'s `back`, and meanwhile a minute on, each ring checking the job with the jailer, so one whose end was lost holds it not; one whose far answered not yet a second on; a push whose last piece is in asks its end, `taken`, a second on each ring, or, where it gave a standing back, asks nothing, since the lobe it went to tells its end, and rings again only to end it once it stood still for as long as it may; an ask timed out, unavailable or busy is asked again at the next ring, kept as `waits { why, since }`, any other far error ends it; one that moved not for as long as it may stand still, `still`, nothing taken and no stage changed, ends failed, naming what stood still, as data.",\n done: "The jailer\'s, a job ended; or, the lobe a push went to, over the standing back that push gave it: the push ended, `{ job, kind, code, out, err, check }`, landed with code 0 and the HEAD it left, or refused, saying why in `err`, and the push this lobe waits on ends with it. To a scoped writer, the head it pushed and its check’s code alone, a refusal telling that its check is red and no more."\n };\n static #reading(method, args) {\n const description = _RepoLobe.#says[method] ?? method;\n const typed = args === void 0 ? {} : { args };\n return { description, kind: "reading", ...typed, errors: ["refused", "absent"] };\n }\n static #writing(method, args) {\n return { ..._RepoLobe.#reading(method, args), kind: "writing" };\n }\n static #own = _RepoLobe.#over({}, []);\n static #which = _RepoLobe.#over(\n {\n kind: { enum: ["faculty", "organ"] },\n label: _RepoLobe.#some,\n version: _RepoLobe.#maybe,\n path: _RepoLobe.#some\n },\n ["kind", "label", "version"]\n );\n static #stillFor = { type: "integer", minimum: 1 };\n static #syncing = _RepoLobe.#over(\n { on: _RepoLobe.#some, piece: _RepoLobe.#one, still: _RepoLobe.#stillFor, tells: { const: true } },\n []\n );\n static #ringing = _RepoLobe.#over({ chain: _RepoLobe.#some }, ["chain"]);\n static #pulling = _RepoLobe.#over(\n { on: _RepoLobe.#some, tag: _RepoLobe.#some, piece: _RepoLobe.#one, still: _RepoLobe.#stillFor },\n []\n );\n static blueprint = {\n name: "nervur.repo",\n version: "0.2.70",\n description: "A repo lobe: one for each repo on each organism that holds it, its bytes kept by the jailer, `repos`, through which it reaches them alone. It keeps what the repo is there: its head; its gate and its settings; its wired lobes; and the versions of its faculties, organs and designs it told the library, `changed`, never told again with other bytes. A repo is born one of two ways: by its `init`, empty, filled by the first commit of its owner or a first push whole; or by its `accept` of an invitation, pulled whole. It commits, at an owner’s ask or a wired lobe’s, its gate first where its settings say; it guards its own `main` before anything enters it, a commit, a push, a pull, by Nervur’s check of the parts, which it holds, and the repo’s `conform` as its owner chose it, each over that tree checked out apart; it serves its wired lobes, each work a job, its end told back, and composes each secret file from their sets, keeping which names each holds by digest, never a value; it pulls and pushes, serves its readers, writers and libraries, and holds no secret. The lobes of the repo it stands on, any number, and its far standings, readers, writers and libraries, are the brain’s, each with this lobe’s own note: it keeps no record of them.",\n methods: {\n init: _RepoLobe.#writing(\n "init",\n _RepoLobe.#object({ name: _RepoLobe.#named, standing: { const: true }, starter: { const: true } }, ["name"])\n ),\n accept: _RepoLobe.#writing(\n "accept",\n _RepoLobe.#object({ name: _RepoLobe.#named, invitation: _RepoLobe.#some, note: {} }, ["name", "invitation"])\n ),\n relink: _RepoLobe.#writing(\n "relink",\n _RepoLobe.#object(\n { invitation: _RepoLobe.#some, instead: _RepoLobe.#some, placeholder: _RepoLobe.#fixed, note: {} },\n ["invitation"]\n )\n ),\n invite: _RepoLobe.#writing(\n "invite",\n _RepoLobe.#object(\n {\n standing: { enum: _RepoLobe.#standings },\n waits: _RepoLobe.#span,\n lives: _RepoLobe.#span,\n note: {},\n through: _RepoLobe.#some,\n scope: { type: "array", items: _RepoLobe.#some, minItems: 1, maxItems: SCOPE_MOST },\n scripts: { type: "array", items: _RepoLobe.#some, minItems: 1 }\n },\n ["standing"]\n )\n ),\n drop: {\n ..._RepoLobe.#writing("drop", _RepoLobe.#object({ far: _RepoLobe.#some, on: _RepoLobe.#some }, [])),\n irreversible: true\n },\n occupants: _RepoLobe.#reading("occupants"),\n left: _RepoLobe.#writing("left", _RepoLobe.#object({ far: _RepoLobe.#some, note: {} }, ["far"])),\n migrate: _RepoLobe.#writing("migrate"),\n remove: { ..._RepoLobe.#writing("remove", _RepoLobe.#own), irreversible: true },\n rebuild: _RepoLobe.#writing("rebuild", _RepoLobe.#own),\n state: _RepoLobe.#reading("state", _RepoLobe.#own),\n gate: _RepoLobe.#writing("gate", _RepoLobe.#object({ script: _RepoLobe.#maybe })),\n gates: _RepoLobe.#writing(\n "gates",\n _RepoLobe.#object({ commit: { enum: _RepoLobe.#onCommit }, push: { enum: _RepoLobe.#onPush } }, [])\n ),\n conform: _RepoLobe.#writing("conform", _RepoLobe.#object({ take: { type: "boolean" } })),\n author: _RepoLobe.#writing("author", _RepoLobe.#object({ lobe: _RepoLobe.#maybe })),\n commit: _RepoLobe.#writing(\n "commit",\n _RepoLobe.#object(\n {\n message: _RepoLobe.#some,\n files: { type: "object", additionalProperties: _RepoLobe.#plain },\n executable: { type: "array", items: _RepoLobe.#some },\n paths: { type: "array", items: _RepoLobe.#some, minItems: 1 },\n gate: { type: "boolean" }\n },\n ["message"]\n )\n ),\n status: _RepoLobe.#writing("status", _RepoLobe.#none),\n log: _RepoLobe.#writing("log", _RepoLobe.#object({ most: { type: "integer", minimum: 1 } }, [])),\n discard: { ..._RepoLobe.#writing("discard", _RepoLobe.#none), irreversible: true },\n read: _RepoLobe.#reading(\n "read",\n _RepoLobe.#object(\n {\n path: _RepoLobe.#some,\n first: _RepoLobe.#one,\n paths: { type: "array", items: _RepoLobe.#some, minItems: 1 }\n },\n []\n )\n ),\n list: _RepoLobe.#reading("list", _RepoLobe.#object({ path: _RepoLobe.#plain }, [])),\n run: _RepoLobe.#writing(\n "run",\n _RepoLobe.#object(\n {\n script: _RepoLobe.#some,\n args: { type: "array", items: _RepoLobe.#plain, maxItems: ARGS_MOST },\n install: { type: "boolean" }\n },\n ["script"]\n )\n ),\n setToken: _RepoLobe.#writing("setToken", _RepoLobe.#object({ name: _RepoLobe.#some, value: _RepoLobe.#maybe })),\n credential: _RepoLobe.#writing(\n "credential",\n _RepoLobe.#object(\n {\n invitation: _RepoLobe.#some,\n placeholder: _RepoLobe.#some,\n secret: _RepoLobe.#some,\n note: {},\n within: { type: "integer", minimum: 1 }\n },\n ["secret"]\n )\n ),\n stop: _RepoLobe.#writing("stop", _RepoLobe.#none),\n jobs: _RepoLobe.#reading("jobs", _RepoLobe.#object({ cursor: _RepoLobe.#maybe }, [])),\n job: _RepoLobe.#reading("job", _RepoLobe.#jobSchema),\n pull: _RepoLobe.#writing("pull", _RepoLobe.#pulling),\n push: _RepoLobe.#writing("push", _RepoLobe.#syncing),\n faculties: _RepoLobe.#reading("faculties"),\n organs: _RepoLobe.#reading("organs"),\n designs: _RepoLobe.#reading("designs"),\n get: _RepoLobe.#reading("get", _RepoLobe.#which),\n build: _RepoLobe.#writing(\n "build",\n _RepoLobe.#over({ organ: _RepoLobe.#some, design: _RepoLobe.#some, version: _RepoLobe.#some }, ["version"])\n ),\n told: _RepoLobe.#writing(\n "told",\n _RepoLobe.#object({ tells: { type: "string", minLength: 1 }, cursor: _RepoLobe.#maybe }, [])\n ),\n head: _RepoLobe.#reading("head"),\n give: _RepoLobe.#writing(\n "give",\n _RepoLobe.#object({ since: _RepoLobe.#maybe, tag: _RepoLobe.#some, piece: _RepoLobe.#one }, ["since"])\n ),\n piece: _RepoLobe.#reading("piece", _RepoLobe.#object({ at: _RepoLobe.#place })),\n take: _RepoLobe.#writing(\n "take",\n _RepoLobe.#object(\n { push: _RepoLobe.#some, at: _RepoLobe.#place, pieces: _RepoLobe.#one, bytes: {}, tells: _RepoLobe.#some },\n ["push", "at", "pieces", "bytes"]\n )\n ),\n taken: _RepoLobe.#writing("taken", _RepoLobe.#none),\n tick: { ..._RepoLobe.#writing("tick", _RepoLobe.#ringing), askers: ["scheduler"] },\n keep: { ..._RepoLobe.#writing("keep", _RepoLobe.#ringing), askers: ["scheduler"] },\n renew: { ..._RepoLobe.#writing("renew"), askers: ["scheduler"] },\n done: _RepoLobe.#writing("done")\n },\n placeholders: {\n repos: "nervur.repos",\n ear: "nervur.ear",\n mouth: "nervur.mouth",\n scheduler: "nervur.scheduler",\n library: "nervur.library"\n }\n };\n static parts = `// SPDX-License-Identifier: FSL-1.1-ALv2\nimport { createHash } from \'node:crypto\';\nimport { existsSync, lstatSync, readFileSync, readdirSync } from \'node:fs\';\nimport { join, resolve } from \'node:path\';\n\nconst root = resolve(process.argv[2] ?? \'.\');\nconst LABEL = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;\nconst ID = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\nconst VERSION = /^(?:0|[1-9][0-9]*)\\\\.(?:0|[1-9][0-9]*)\\\\.(?:0|[1-9][0-9]*)$/;\nconst broken = [];\nconst say = (why) => {\n broken.push(why);\n};\nconst isFolder = (path) => existsSync(path) && lstatSync(path).isDirectory();\nconst isFile = (path) => existsSync(path) && lstatSync(path).isFile();\nconst fieldsAt = (path) => {\n try {\n const read = JSON.parse(readFileSync(path, \'utf8\'));\n return read !== null && typeof read === \'object\' && !Array.isArray(read) ? read : null;\n } catch {\n return null;\n }\n};\n\nconst partsOf = (convention, pattern, what, by) => {\n const at = join(root, convention);\n if (!existsSync(at)) return [];\n if (!isFolder(at)) {\n say(convention + \' is no folder: it holds a folder for each \' + what);\n return [];\n }\n return readdirSync(at)\n .filter((name) => !name.startsWith(\'.\'))\n .toSorted()\n .flatMap((name) => {\n if (!isFolder(join(at, name))) {\n say(convention + \'/\' + name + \' is no folder: \' + convention + \'/ holds a folder for each \' + what);\n return [];\n }\n if (!pattern.test(name)) {\n say(convention + \'/\' + name + \' is no \' + what + "\'s name: a " + what + \' is named by \' + by);\n return [];\n }\n return [name];\n });\n};\n\nconst sha = (bytes) => createHash(\'sha256\').update(bytes).digest(\'hex\');\nconst canonical = (bytes) =>\n bytes.includes(0) ? bytes : Buffer.from(bytes.toString(\'latin1\').replace(/\\\\r\\\\n?/g, \'\\\\n\'), \'latin1\');\nconst assetsOf = (at, below = \'\') =>\n readdirSync(join(at, below), { withFileTypes: true })\n .filter((entry) => !entry.name.startsWith(\'.\'))\n .flatMap((entry) => {\n const path = below === \'\' ? entry.name : below + \'/\' + entry.name;\n if (entry.isDirectory()) return assetsOf(at, path);\n return entry.isFile() ? [[path, sha(canonical(readFileSync(join(at, path))))]] : [];\n })\n .toSorted((one, other) => (one[0] < other[0] ? -1 : 1));\n\nfor (const label of partsOf(\'faculties\', LABEL, \'faculty\', \'its label, in lowercase\')) {\n const at = \'faculties/\' + label;\n const path = join(root, at, \'faculty.js\');\n if (!isFile(path)) {\n say(at + \' holds no faculty.js: a faculty is one module of JavaScript\');\n continue;\n }\n const bytes = readFileSync(path);\n const text = bytes.toString(\'utf8\');\n const named =\n /\\\\b([A-Za-z_$][\\\\w$]*)\\\\s*=\\\\s*class(?:\\\\s+[A-Za-z_$][\\\\w$]*)?\\\\s+extends\\\\s+Faculty\\\\b/.exec(text) ??\n /\\\\bclass\\\\s+([A-Za-z_$][\\\\w$]*)\\\\s+extends\\\\s+Faculty\\\\b/.exec(text);\n const exported =\n /\\\\bexport\\\\s+default\\\\s+class\\\\b[^{]*\\\\bextends\\\\s+Faculty\\\\b/.test(text) ||\n (named !== null &&\n (new RegExp(\'\\\\\\\\bexport\\\\\\\\s+default\\\\\\\\s+\' + named[1] + \'\\\\\\\\b\').test(text) ||\n new RegExp(\'\\\\\\\\bexport\\\\\\\\s*\\\\\\\\{\\\\\\\\s*\' + named[1] + \'\\\\\\\\s+as\\\\\\\\s+default\\\\\\\\s*\\\\\\\\}\').test(text)));\n if (!/\\\\bimport\\\\s*\\\\{[^}]*\\\\bFaculty\\\\b[^}]*\\\\}\\\\s*from\\\\s*[\'"]nervur:faculty[\'"]/.test(text) || !exported)\n say(at + \'/faculty.js exports as its default no class extending Faculty from nervur:faculty\');\n const from = text.search(/\\\\bstatic\\\\s+blueprint\\\\s*=/);\n const blueprint = from < 0 ? \'\' : text.slice(from);\n const name = /\\\\bname\\\\s*:\\\\s*[\'"]([^\'"\\\\n]+)[\'"]/.exec(blueprint)?.[1];\n const version = /\\\\bversion\\\\s*:\\\\s*[\'"]([^\'"\\\\n]+)[\'"]/.exec(blueprint)?.[1];\n if (name === undefined || version === undefined || !VERSION.test(version)) {\n say(at + \'/faculty.js holds no blueprint naming its name and its version\');\n continue;\n }\n const versions = fieldsAt(join(root, at, \'versions.json\'));\n const digest = createHash(\'sha256\').update(bytes).digest(\'hex\');\n if (versions === null) say(at + \' holds no versions.json naming each version by its digest\');\n else if (versions[version] !== digest) say(at + \'/faculty.js is not the text its versions.json names at \' + version);\n const digested = /\\\\bassets\\\\s*:\\\\s*[\'"]([0-9a-f]{64})[\'"]/.exec(blueprint)?.[1];\n const held = isFolder(join(root, at, \'assets\')) ? assetsOf(join(root, at, \'assets\')) : [];\n if (digested === undefined && held.length > 0)\n say(at + \'/assets holds files its blueprint names no assets digest for\');\n else if (digested !== undefined && sha(JSON.stringify(held)) !== digested)\n say(at + \'/assets is not the digest its blueprint names as assets, \' + digested);\n}\n\nfor (const id of partsOf(\'organs\', ID, \'organ\', \'its fixed ID, in lowercase\')) {\n const at = \'organs/\' + id;\n const graph = fieldsAt(join(root, at, \'graph.json\'));\n const version = graph === null ? undefined : (graph.version ?? graph.blueprint?.version);\n if (graph === null || typeof version !== \'string\' || !VERSION.test(version))\n say(at + \' holds no graph.json, its blueprint with its version\');\n if (!isFile(join(root, at, \'host/build\'))) say(at + \' holds no host/build, which builds its host half\');\n}\n\nconst sheetsIn = (at, below = \'\') =>\n readdirSync(join(at, below), { withFileTypes: true }).flatMap((entry) => {\n const path = below === \'\' ? entry.name : below + \'/\' + entry.name;\n if (entry.isDirectory()) return sheetsIn(at, path);\n return path === \'layers.json\' ? [] : [path];\n });\n\nfor (const name of partsOf(\'designs\', LABEL, \'design\', \'its name, in lowercase\')) {\n const at = \'designs/\' + name;\n const design = fieldsAt(join(root, at, \'design.json\'));\n if (design === null || design.name !== name || typeof design.version !== \'string\' || !VERSION.test(design.version))\n say(at + \' holds no design.json naming it and its version\');\n const tokens = {};\n for (const file of [\'light\', \'dark\', \'tints\']) {\n tokens[file] = fieldsAt(join(root, at, \'tokens\', file + \'.json\'));\n if (tokens[file] === null) say(at + \' holds no tokens/\' + file + \'.json\');\n }\n if (design !== null) {\n const where = at + \'/design.json\';\n if (typeof design.publisher !== \'string\' || design.publisher === \'\') say(where + \' names no publisher\');\n const themes = Array.isArray(design.themes) ? design.themes : [];\n if (!themes.includes(\'light\') || !themes.includes(\'dark\')) say(where + \' names no themes light and dark\');\n if (!Array.isArray(design.tints)) say(where + \' names its tints as no list\');\n else if (tokens.tints !== null)\n for (const tint of design.tints)\n if (typeof tint !== \'string\' || !Object.hasOwn(tokens.tints, tint))\n say(where + \' names the tint \' + String(tint) + \', which tokens/tints.json holds not\');\n }\n const layers = fieldsAt(join(root, at, \'skin/layers.json\'));\n if (layers === null) say(at + \' holds no skin/layers.json\');\n else {\n const where = at + \'/skin/layers.json\';\n const named = [];\n for (const layer of [\'lobes\', \'home\']) {\n const sheets = Array.isArray(layers[layer]) ? layers[layer] : [];\n for (const sheet of sheets) {\n if (typeof sheet !== \'string\' || sheet === \'\') say(where + \' names a sheet that is no name in \' + layer);\n else if (named.includes(sheet)) say(where + \' names \' + sheet + \' more than once\');\n else if (!isFile(join(root, at, \'skin\', sheet))) say(where + \' names \' + sheet + \', which skin/ holds not\');\n named.push(sheet);\n }\n }\n for (const sheet of sheetsIn(join(root, at, \'skin\')).toSorted())\n if (!named.includes(sheet)) say(at + \'/skin/\' + sheet + \' is named by no layer of skin/layers.json\');\n }\n if (isFolder(join(root, at, \'fonts\'))) {\n const where = at + \'/fonts/fonts.json\';\n const manifest = fieldsAt(join(root, where));\n const faces = manifest !== null && Array.isArray(manifest.faces) ? manifest.faces : null;\n if (faces === null) say(at + \' holds no fonts/fonts.json naming its faces\');\n else\n for (const face of faces) {\n const file = face !== null && typeof face === \'object\' ? face.file : undefined;\n const licence = face !== null && typeof face === \'object\' ? face.licence : undefined;\n if (typeof file !== \'string\' || file === \'\') say(where + \' names a face with no file\');\n else {\n if (!isFile(join(root, at, \'fonts\', file))) say(where + \' names \' + file + \', which fonts/ holds not\');\n if (typeof licence !== \'string\' || licence === \'\')\n say(where + \' names the face \' + file + \' with no licence\');\n }\n if (typeof licence === \'string\' && licence !== \'\' && !isFile(join(root, at, \'fonts\', licence)))\n say(where + \' names the licence \' + licence + \', which fonts/ holds not\');\n }\n }\n if (fieldsAt(join(root, at, \'versions.json\')) === null) say(at + \' holds no versions.json\');\n}\n\nconst sorted = (value) =>\n value !== null && typeof value === \'object\' && !Array.isArray(value)\n ? Object.fromEntries(\n Object.keys(value)\n .toSorted()\n .map((key) => [key, sorted(value[key])]),\n )\n : value;\nconst same = (one, other) => JSON.stringify(sorted(one)) === JSON.stringify(sorted(other));\nconst told = process.argv[3] === undefined ? null : fieldsAt(resolve(process.argv[3]));\nif (told !== null)\n for (const path of Object.keys(told).toSorted()) {\n if (!/^(?:faculties|designs)\\\\/[^/]+\\\\/versions\\\\.json$/.test(path) || typeof told[path] !== \'string\') continue;\n let was = null;\n try {\n was = JSON.parse(told[path]);\n } catch {}\n if (was === null || typeof was !== \'object\' || Array.isArray(was)) continue;\n if (!isFolder(join(root, path, \'..\'))) continue;\n const now = fieldsAt(join(root, path));\n for (const version of Object.keys(was).toSorted())\n if (now === null || !Object.hasOwn(now, version) || !same(now[version], was[version]))\n say(path + \' no longer holds \' + version + \' as the tag told it\');\n }\n\nconst rootManifest = fieldsAt(join(root, \'package.json\'));\nfor (const field of [\'dependencies\', \'devDependencies\', \'peerDependencies\', \'optionalDependencies\']) {\n const held = rootManifest?.[field];\n if (held !== null && typeof held === \'object\' && \'@nervur.org/genome\' in held)\n say(\n \'package.json names @nervur.org/genome in \' +\n field +\n \': the organism lends the genome it runs, a repo names none\',\n );\n}\n\nif (existsSync(join(root, \'.env\')))\n say(\'.env would enter main: .gitignore keeps it not out, and a secret file is never committed\');\n\nif (broken.length > 0) {\n console.log(broken.join(\'\\\\n\'));\n process.exit(1);\n}\nconsole.log(\'parts: each part stands as its folder says\');\n`;\n static #order(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n }\n static #fields(data) {\n return !!data && typeof data === "object" && !Array.isArray(data) && !ArrayBuffer.isView(data);\n }\n static #text(data) {\n return typeof data === "string" && data !== "";\n }\n static #texts(data) {\n return Array.isArray(data) ? data.flatMap((one) => _RepoLobe.#text(one) ? [one] : []) : [];\n }\n static #arg(args, key) {\n return _RepoLobe.#fields(args) ? args[key] : void 0;\n }\n static #shown(data) {\n return typeof data === "string" ? data : "none";\n }\n static #lastLine(text) {\n return text.trim().split("\\n").pop() ?? "";\n }\n static #headOf(out) {\n const last = _RepoLobe.#lastLine(out);\n return _RepoLobe.#hash.test(last) ? last : null;\n }\n static #lone = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g;\n #bytes(text) {\n const encoded = this.codec.utf8(text.replace(_RepoLobe.#lone, "�"));\n return "bytes" in encoded ? encoded.bytes : null;\n }\n static #json(text) {\n try {\n const read = JSON.parse(text);\n return _RepoLobe.#fields(read) ? read : null;\n } catch {\n return null;\n }\n }\n static #holds(read, placeholder) {\n const all = "result" in read && Array.isArray(read.result) ? read.result : [];\n return all.some((one) => _RepoLobe.#fields(one) && one["placeholder"] === placeholder);\n }\n static #wiredTo(read, placeholder) {\n const all = "result" in read && Array.isArray(read.result) ? read.result : [];\n const wire = all.find((one) => _RepoLobe.#fields(one) && one["placeholder"] === placeholder);\n return _RepoLobe.#fields(wire) ? wire["termination"] ?? null : null;\n }\n #alarm(args) {\n return this.ask("scheduler", "set", args, void 0, { letter: { lives: _RepoLobe.#lives } });\n }\n #heard(answer) {\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : null;\n }\n #result(answer) {\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : answer.result;\n }\n #digestOf(text) {\n const bytes = this.#bytes(text);\n return bytes === null ? "" : this.#shaOf(bytes);\n }\n #shaOf(bytes) {\n const hash = this.crypto.sha256(bytes);\n return hash instanceof Uint8Array ? Array.from(hash, (byte) => byte.toString(16).padStart(2, "0")).join("") : "";\n }\n static #canonical(bytes) {\n if (bytes.includes(0)) return bytes;\n const out = new Uint8Array(bytes.length);\n let length = 0;\n for (let at = 0; at < bytes.length; at += 1) {\n const byte = bytes[at] ?? 0;\n out[length] = byte === 13 ? 10 : byte;\n length += 1;\n if (byte === 13 && bytes[at + 1] === 10) at += 1;\n }\n return out.subarray(0, length);\n }\n #nonce() {\n return Array.from(this.stamp.seed.slice(0, 6), (byte) => byte.toString(16).padStart(2, "0")).join("");\n }\n #most() {\n return Math.min(CELLS_RANGE, Math.floor(this.memory / LOBE_SHARE / ITEM_SIZE));\n }\n #all(prefix) {\n return this.cells.range({ prefix: [...prefix], limit: this.#most() }).cells;\n }\n static #relation(data) {\n if (!_RepoLobe.#fields(data)) return null;\n const { far, side, placeholder, note } = data;\n if (!_RepoLobe.#text(far) || side !== "occupant" && side !== "standing") return null;\n return { far, side, placeholder: _RepoLobe.#text(placeholder) ? placeholder : null, note: note ?? null };\n }\n async #relations() {\n const all = [];\n let cursor = null;\n for (const seen = new Set(); ; ) {\n const read = await this.ask("nerves", "relations", cursor === null ? {} : { cursor });\n const result = "result" in read ? read.result : null;\n const found = _RepoLobe.#arg(result, "relations");\n for (const one of Array.isArray(found) ? found : []) {\n const relation = _RepoLobe.#relation(one);\n if (relation !== null) all.push(relation);\n }\n const next = _RepoLobe.#arg(result, "cursor");\n if (!_RepoLobe.#text(next) || seen.has(next)) break;\n seen.add(next);\n cursor = next;\n }\n return all;\n }\n async #endOfFar(far) {\n const read = await this.ask("nerves", "relation", { far });\n return "result" in read ? _RepoLobe.#relation(read.result) : null;\n }\n async #held() {\n const all = await this.#relations();\n return all.filter((one) => one.side === "standing" && !_RepoLobe.#tellsOn(one)).toSorted((a, b) => _RepoLobe.#order(a.placeholder ?? "", b.placeholder ?? ""));\n }\n async #given() {\n return (await this.#relations()).filter(\n (one) => one.side === "occupant" && _RepoLobe.#kindOf(one.note) !== _RepoLobe.#teller\n );\n }\n static #backUnder(prefix, far) {\n return `${prefix}-${far.toLowerCase()}`;\n }\n static #tellsOn(one) {\n return _RepoLobe.#text(_RepoLobe.#arg(one.note, "credential")) || [_RepoLobe.#tells, _RepoLobe.#hears].some((prefix) => one.placeholder?.startsWith(`${prefix}-`) === true);\n }\n async #untell(on) {\n for (const one of await this.#relations())\n if (one.side === "occupant" && _RepoLobe.#kindOf(one.note) === _RepoLobe.#teller && _RepoLobe.#arg(one.note, "on") === on)\n await this.ask("ear", "drop", { far: one.far });\n }\n static #kindOf(note) {\n const kind = _RepoLobe.#arg(note, "standing");\n return typeof kind === "string" && (_RepoLobe.#standings.includes(kind) || kind === _RepoLobe.#teller) ? kind : null;\n }\n static #scopeIn(note) {\n const scope = _RepoLobe.#arg(note, "scope");\n return Array.isArray(scope) ? _RepoLobe.#texts(scope) : null;\n }\n async #noted(far, note) {\n const wrote = await this.ask("nerves", "note", { far, note });\n return "error" in wrote ? wrote.error.message : null;\n }\n #repo() {\n const repo = this.cells.get(["repo"]);\n return _RepoLobe.#fields(repo) ? repo : null;\n }\n #role() {\n const { asker } = this.stamp;\n if (asker === _RepoLobe.#owner) return "owner";\n if (asker === _RepoLobe.#library) return "library";\n const occupant = this.stamp.occupant;\n if (occupant !== null && occupant.far === asker) {\n const kind = _RepoLobe.#arg(occupant.note, "standing");\n if (kind === "writer") return "pusher";\n if (kind === _RepoLobe.#teller) return "teller";\n if (kind === "reader" || kind === "library" || kind === "runner") return kind;\n return "stood";\n }\n const repo = this.#repo();\n if (repo !== null && repo["jailer"] === asker) return "jailer";\n return "near";\n }\n #refusal(method, args) {\n if (!(_RepoLobe.#who[method] ?? []).includes(this.#role()))\n return this.error("refused", `${method} is not the asker\'s to ask`);\n const repo = this.#repo();\n const named = _RepoLobe.#arg(args, "name");\n if (repo !== null && named !== void 0 && !["init", "accept"].includes(method) && named !== repo["name"])\n return this.error(\n "refused",\n `this lobe keeps the repo ${_RepoLobe.#shown(repo["name"])}, not ${_RepoLobe.#shown(named)}`\n );\n return null;\n }\n #ready() {\n const repo = this.#repo();\n if (repo === null || repo["ready"] !== true || !_RepoLobe.#text(repo["name"]))\n return this.error("refused", "the repo is not ready");\n return { name: repo["name"], repo };\n }\n async #jailer() {\n const jailer = _RepoLobe.#wiredTo(await this.nerves.read(), "repos");\n return _RepoLobe.#text(jailer) ? jailer : this.error("refused", "the lobe is wired to no repos");\n }\n #unmade(name) {\n if (!_RepoLobe.#text(name) || !_RepoLobe.#repoName.test(name))\n return this.error("refused", "a repo is named in lowercase, a letter first");\n const repo = this.#repo();\n const failed = repo !== null && repo["ready"] !== true && repo["head"] === null && repo["rebuilds"] === null && !_RepoLobe.#text(repo["doing"]) && _RepoLobe.#text(repo["failed"]);\n if (repo !== null && !failed)\n return this.error("refused", `the lobe keeps the repo ${_RepoLobe.#shown(repo["name"])} already`);\n return name;\n }\n static #fresh(name, jailer) {\n return {\n name,\n head: null,\n ready: false,\n failed: null,\n doing: null,\n synced: null,\n jailer,\n rebuilds: null\n };\n }\n async init(args) {\n const refused = this.#refusal("init", args);\n if (refused !== null) return refused;\n const name = this.#unmade(_RepoLobe.#arg(args, "name"));\n if (typeof name !== "string") return name;\n const unchecked = this.checked("init", args);\n if (unchecked !== void 0) return unchecked;\n const standing = _RepoLobe.#arg(args, "standing") === true;\n const starter = _RepoLobe.#arg(args, "starter") === true;\n if (standing && starter)\n return this.error("refused", "a repo handed in place keeps what it holds, and takes no starter");\n const jailer = await this.#jailer();\n if (typeof jailer !== "string") return jailer;\n this.cells.set(["repo"], _RepoLobe.#fresh(name, jailer));\n if (standing) return this.#begin("init", this.#checks(), null, { method: "stand" });\n return this.#begin("init", {}, null, starter ? { more: { starter: true } } : {});\n }\n #starterOf(name) {\n const version = "0.1.0";\n const label = `com.example.${name}`;\n const source = `import { Faculty } from \'nervur:faculty\';\n\nexport default class extends Faculty {\n static blueprint = { name: \'${label}\', version: \'${version}\', placeholders: {}, methods: { hello: { kind: \'reading\' } } };\n hello() { return \'hello from ${name}\'; }\n}\n`;\n const conform = `// This repo\'s own rules, run over what would enter its main. A rule broken prints why and exits 1.\nconsole.log(\'conform: no rule of this repo is broken\');\n`;\n const scripts = { gate: "node tools/conform.mjs", conform: "node tools/conform.mjs" };\n return {\n ".gitignore": ".env\\nnode_modules/\\ndist/\\n",\n "package.json": `${JSON.stringify({ name, version, private: true, scripts }, null, 2)}\n`,\n "tools/conform.mjs": conform,\n [`faculties/${label}/faculty.js`]: source,\n [`faculties/${label}/versions.json`]: `${JSON.stringify({ [version]: this.#digestOf(source) }, null, 2)}\n`\n };\n }\n async #layStarter(run, asker) {\n const name = _RepoLobe.#shown(this.#repo()?.["name"]);\n for (const [path, text] of Object.entries(this.#starterOf(name))) {\n const wrote = await this.ask("repos", "write", { path, text });\n if ("error" in wrote) return `${path}: ${wrote.error.message}`;\n }\n const begun = await this.#begin(\n "commit",\n { message: "the starter", ...this.#checks() },\n { commit: run },\n { asker }\n );\n return "job" in begun ? null : begun.message;\n }\n async #link(invitation, placeholder, name, note) {\n if (!_RepoLobe.#text(invitation)) return this.error("refused", "an invitation is named");\n const held = note === void 0 ? { repo: name ?? null, on: placeholder } : note;\n const accepted = await this.ask("mouth", "accept", { invitation, placeholder, note: held });\n if ("error" in accepted) return this.error(accepted.error.code, accepted.error.message);\n const far = _RepoLobe.#arg(accepted.result, "far");\n if (!_RepoLobe.#text(far)) return this.error("refused", "the mouth named no far organism");\n return { placeholder, far };\n }\n async #free() {\n const held = new Set((await this.#held()).map((one) => one.placeholder));\n let at = 1;\n while (held.has(`${_RepoLobe.#lobe}-${at}`)) at += 1;\n return `${_RepoLobe.#lobe}-${at}`;\n }\n async #standingOn(on) {\n const all = await this.#held();\n if (on !== void 0) {\n const one = all.find((held) => held.placeholder === on);\n return one === void 0 || one.placeholder === null ? this.error("absent", `this lobe stands on no lobe as ${_RepoLobe.#shown(on)}`) : { placeholder: one.placeholder, far: one.far };\n }\n const [only] = all;\n if (only === void 0 || only.placeholder === null)\n return this.error("refused", "this lobe stands on no other: relink it");\n if (all.length > 1) return this.error("refused", "this lobe stands on several: name the one, `on`");\n return { placeholder: only.placeholder, far: only.far };\n }\n async accept(args) {\n const refused = this.#refusal("accept", args);\n if (refused !== null) return refused;\n const name = this.#unmade(_RepoLobe.#arg(args, "name"));\n if (typeof name !== "string") return name;\n const jailer = await this.#jailer();\n if (typeof jailer !== "string") return jailer;\n const placeholder = await this.#free();\n const linked = await this.#link(_RepoLobe.#arg(args, "invitation"), placeholder, name, _RepoLobe.#arg(args, "note"));\n if (!("far" in linked)) return linked;\n this.cells.set(["repo"], _RepoLobe.#fresh(name, jailer));\n return this.#begin("init", {}, null, { more: { pulls: placeholder } });\n }\n async relink(args) {\n const refused = this.#refusal("relink", args);\n if (refused !== null) return refused;\n if (this.#holdsScope()) return this.error("refused", "a lobe born of a scope stands on no other");\n if (this.cells.get(["sync"]) !== void 0)\n return this.error("refused", "the repo pulls or pushes: wait for it to end");\n const instead = _RepoLobe.#arg(args, "instead");\n const was = instead === void 0 ? null : await this.#standingOn(instead);\n if (was !== null && !("far" in was)) return was;\n const replaced = was === null ? null : was["placeholder"];\n const named = _RepoLobe.#arg(args, "placeholder");\n if (typeof named === "string" && named !== replaced && _RepoLobe.#holds(await this.nerves.read(), named))\n return this.error("refused", `this lobe holds ${named} already`);\n const placeholder = typeof named === "string" ? named : _RepoLobe.#text(replaced) ? replaced : await this.#free();\n const taken = was !== null && placeholder === replaced;\n if (taken) await this.#unlink(was);\n const name = this.#repo()?.["name"];\n const linked = await this.#link(_RepoLobe.#arg(args, "invitation"), placeholder, name, _RepoLobe.#arg(args, "note"));\n if (!("far" in linked)) return linked;\n if (was !== null && !taken) await this.#unlink(was);\n return { on: placeholder, far: linked["far"] ?? null };\n }\n async #unlink(was) {\n const placeholder = was["placeholder"];\n if (!_RepoLobe.#text(placeholder)) return;\n if (!placeholder.startsWith(`${_RepoLobe.#tells}-`)) await this.#untell(placeholder);\n if (_RepoLobe.#text(was["far"])) await this.ask("mouth", "drop", { far: was["far"] });\n await this.nerves.unwire(placeholder);\n }\n async invite(args) {\n const refused = this.#refusal("invite", args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n if (this.#holdsScope()) return this.error("refused", "a lobe holding a scope gives no occupant");\n const standing = _RepoLobe.#arg(args, "standing");\n if (typeof standing !== "string" || !_RepoLobe.#standings.includes(standing))\n return this.error("refused", "a standing is a reader, a writer, a library or a runner");\n const scripts = _RepoLobe.#arg(args, "scripts");\n const named = Array.isArray(scripts) ? scripts : [];\n if (standing === "runner" && (named.length === 0 || !named.every((one) => _RepoLobe.#text(one) && _RepoLobe.#script.test(one))))\n return this.error("refused", "a runner runs scripts of the repo\'s package, one or more");\n if (standing !== "runner" && scripts !== void 0)\n return this.error("refused", "scripts are a runner’s alone");\n const asked = _RepoLobe.#arg(args, "scope");\n const scope = asked === void 0 ? null : _RepoLobe.#scopeOf(asked);\n if (asked !== void 0 && (standing === "library" || standing === "runner"))\n return this.error("refused", `a ${standing}\'s standing is never scoped`);\n if (asked !== void 0 && scope === null)\n return this.error(\n "refused",\n `a scope is 1 to ${_RepoLobe.#scopeMost} folders of the repo, each of names of letters, digits, ., _ and -, none ., .. nor .git, none inside another`\n );\n const waits = _RepoLobe.#arg(args, "waits") ?? null;\n const lives = _RepoLobe.#arg(args, "lives") ?? null;\n const owned = _RepoLobe.#arg(args, "note");\n const base = owned === void 0 || owned === null ? {} : _RepoLobe.#fields(owned) ? owned : { note: owned };\n const note = {\n ...base,\n repo: ready.name,\n standing,\n ...scope === null ? {} : { scope },\n ...standing === "runner" ? { scripts: named } : {}\n };\n const through = _RepoLobe.#arg(args, "through");\n const line = through === void 0 ? {} : { through };\n const invited = await this.ask("ear", "invite", { waits, lives, note, ...line });\n if ("error" in invited) return this.#heard(invited);\n const far = _RepoLobe.#arg(invited.result, "far");\n if (!_RepoLobe.#text(far)) return this.error("refused", "the ear named no far organism");\n return invited.result;\n }\n static #scopeOf(scope) {\n if (!Array.isArray(scope) || scope.length < 1 || scope.length > _RepoLobe.#scopeMost) return null;\n const folders = scope.flatMap((one) => typeof one === "string" ? [one] : []);\n const fit = (one) => one.split("/").every((name) => _RepoLobe.#segment.test(name) && ![".", "..", ".git"].includes(name));\n if (folders.length !== scope.length || !folders.every(fit)) return null;\n const sorted = folders.toSorted();\n const nested = sorted.some(\n (one, at) => sorted.some((other, by) => by !== at && (one === other || one.startsWith(`${other}/`)))\n );\n return nested ? null : sorted;\n }\n #scopeOfAsker() {\n const occupant = this.stamp.occupant;\n return occupant === null ? null : _RepoLobe.#scopeIn(occupant.note);\n }\n async #scopeFor(far) {\n if (this.stamp.occupant?.far === far) return this.#scopeOfAsker();\n const found = await this.#endOfFar(far);\n return found === null ? null : _RepoLobe.#scopeIn(found.note);\n }\n #holdsScope() {\n return this.#repo()?.["cut"] === true;\n }\n async drop(args) {\n const refused = this.#refusal("drop", args);\n if (refused !== null) return refused;\n const [named, on] = [_RepoLobe.#arg(args, "far"), _RepoLobe.#arg(args, "on")];\n if (on !== void 0) {\n const held = await this.#standingOn(on);\n if (!("far" in held)) return held;\n if (_RepoLobe.#arg(this.cells.get(["sync"]), "on") === on)\n return this.error("refused", "the repo pulls or pushes over it: wait for it to end");\n await this.#unlink(held);\n return null;\n }\n const far = named;\n const given = _RepoLobe.#text(far) ? await this.#endOfFar(far) : null;\n if (!_RepoLobe.#text(far) || given === null || given.side !== "occupant")\n return this.error("absent", "no standing is held by that far organism");\n const dropped = await this.ask("ear", "drop", { far });\n if ("error" in dropped) return this.#heard(dropped);\n await this.#forgetFar(far, given.note);\n return null;\n }\n async left(args) {\n const far = _RepoLobe.#arg(args, "far");\n if (_RepoLobe.#text(far)) await this.#forgetFar(far, _RepoLobe.#arg(args, "note") ?? null);\n if (_RepoLobe.#text(far)) {\n this.cells.delete(["token", far]);\n this.cells.delete(["credential", far]);\n }\n const on = _RepoLobe.#arg(_RepoLobe.#arg(args, "note"), "on");\n if (_RepoLobe.#text(on) && !(await this.#held()).some((one) => one.placeholder === on)) await this.#untell(on);\n const sync = this.cells.get(["sync"]);\n if (_RepoLobe.#fields(sync) && !(await this.#held()).some((one) => one.placeholder === sync["on"]))\n await this.#finish(sync, 1, "the lobe stands on that lobe no more");\n return null;\n }\n async #forgetFar(far, note) {\n if (_RepoLobe.#kindOf(note) === "writer") await this.#untold(far);\n if (_RepoLobe.#kindOf(note) === "library") await this.#untold(far, _RepoLobe.#hears);\n for (const kept of ["out", "in"]) {\n if (this.cells.get([kept, far]) === void 0) continue;\n this.cells.delete([kept, far]);\n await this.#clear(`${kept}-${far}`);\n }\n }\n async occupants(args) {\n const refused = this.#refusal("occupants", args);\n if (refused !== null) return refused;\n return (await this.#given()).map(({ far, note }) => {\n const scope = _RepoLobe.#scopeIn(note);\n return { far, role: _RepoLobe.#kindOf(note), ...scope === null ? {} : { scope } };\n });\n }\n async migrate(args) {\n const refused = this.#refusal("migrate", args);\n if (refused !== null) return refused;\n const rearmed = await this.#rearm();\n if (this.#repo() !== null) {\n this.cells.set(["owed"], true);\n await this.#owing();\n await this.#awaiting();\n }\n return rearmed;\n }\n async #owing() {\n if (this.cells.get(["owed"]) !== true) return;\n const repo = this.#repo();\n const idle = !_RepoLobe.#text(repo?.["doing"]) && !_RepoLobe.#fields(this.cells.get(["sync"]));\n if (_RepoLobe.#text(repo?.["head"]) && idle && "name" in this.#ready())\n await this.#begin("scan", {}, { scan: null }, { asker: _RepoLobe.#owner });\n }\n async #awaiting() {\n if (this.cells.get(["owed"]) !== true || this.cells.get(["owes"]) !== void 0) return;\n const chain = this.#nonce();\n const set = await this.#alarm({ at: this.stamp.time + MINUTE, method: "keep", args: { chain } });\n if (!("error" in set)) this.cells.set(["owes"], chain);\n }\n async keep(args) {\n const owes = this.cells.get(["owes"]);\n if (typeof owes !== "string" || owes !== _RepoLobe.#arg(args, "chain")) return null;\n await this.#check();\n await this.#owing();\n if (this.cells.get(["owed"]) === true) return { again: this.stamp.time + MINUTE };\n this.cells.delete(["owes"]);\n return null;\n }\n #scanning() {\n const doing = this.#repo()?.["doing"];\n return _RepoLobe.#text(doing) && _RepoLobe.#arg(this.cells.get(["job", doing]), "kind") === "scan";\n }\n async #rearm() {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync)) return null;\n const chain = this.#nonce();\n this.cells.set(["sync"], { ...sync, chain });\n const set = await this.#alarm({ at: this.stamp.time + _RepoLobe.#every, method: "tick", args: { chain } });\n return "error" in set ? this.error(set.error.code, set.error.message) : null;\n }\n gate(args) {\n const refused = this.#refusal("gate", args);\n if (refused !== null) return refused;\n const script = _RepoLobe.#arg(args, "script");\n if (script !== null && !(_RepoLobe.#text(script) && _RepoLobe.#script.test(script)))\n return this.error("refused", "a gate is a script of the repo\'s package, or null");\n this.cells.set(["gate"], script ?? null);\n return null;\n }\n #gateScript() {\n const held = this.cells.get(["gate"]);\n return held === void 0 ? "gate" : held;\n }\n #gates() {\n const held = this.cells.get(["gates"]);\n const [commit, push] = [_RepoLobe.#arg(held, "commit"), _RepoLobe.#arg(held, "push")];\n return {\n commit: typeof commit === "string" && _RepoLobe.#onCommit.includes(commit) ? commit : "on",\n push: push === "on" ? "on" : "off"\n };\n }\n gates(args) {\n const refused = this.#refusal("gates", args);\n if (refused !== null) return refused;\n const [commit, push] = [_RepoLobe.#arg(args, "commit"), _RepoLobe.#arg(args, "push")];\n if (commit !== void 0 && !(typeof commit === "string" && _RepoLobe.#onCommit.includes(commit)))\n return this.error("refused", "on commit, the gate is off, on or mandatory");\n if (push !== void 0 && !(typeof push === "string" && _RepoLobe.#onPush.includes(push)))\n return this.error("refused", "on push, the gate is off or on");\n const now = this.#gates();\n const set = {\n commit: typeof commit === "string" ? commit : now.commit,\n push: typeof push === "string" ? push : now.push\n };\n this.cells.set(["gates"], set);\n return set;\n }\n conform(args) {\n const refused = this.#refusal("conform", args);\n if (refused !== null) return refused;\n const take = _RepoLobe.#arg(args, "take");\n if (typeof take !== "boolean") return this.error("refused", "take is true or false");\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n if (!take) {\n this.cells.delete(["conform"]);\n return null;\n }\n const head = ready.repo["head"];\n if (!_RepoLobe.#text(head)) return this.error("refused", "main holds no commit to take its conform from");\n this.cells.set(["conform"], head);\n return head;\n }\n author(args) {\n const refused = this.#refusal("author", args);\n if (refused !== null) return refused;\n const lobe = _RepoLobe.#arg(args, "lobe");\n if (lobe === null) {\n this.cells.delete(["author"]);\n return null;\n }\n if (!_RepoLobe.#text(lobe) || lobe === _RepoLobe.#owner)\n return this.error("refused", "an author is a wired lobe, named by its ID");\n this.cells.set(["author"], lobe);\n return null;\n }\n async remove(args) {\n const refused = this.#refusal("remove", args);\n if (refused !== null) return refused;\n const repo = this.#repo();\n if (repo === null) return this.error("absent", "the lobe keeps no repo");\n if ((await this.#given()).length > 0) return this.error("refused", "far standings hold the repo: drop them first");\n if (_RepoLobe.#text(repo["doing"]) || this.cells.get(["sync"]) !== void 0)\n return this.error("refused", "the repo runs a job: wait for it to end");\n for (const kept of [\n "told",\n "built",\n "look",\n "parts",\n "job",\n "by",\n "out",\n "in",\n "back",\n "secret",\n "token",\n "credential"\n ])\n for (const { key } of this.#all([kept])) this.cells.delete(key);\n for (const kept of ["repo", "gate", "gates", "conform", "author", "scanned", "owed", "owes", "env", "renews"])\n this.cells.delete([kept]);\n return null;\n }\n async rebuild(args) {\n const refused = this.#refusal("rebuild", args);\n if (refused !== null) return refused;\n const repo = this.#repo();\n if (repo === null) return this.error("refused", "the lobe keeps no repo");\n if (_RepoLobe.#text(repo["doing"]) || this.cells.get(["sync"]) !== void 0)\n return this.error("refused", "the repo runs a job: wait for it to end");\n const rebuilds = repo["rebuilds"] ?? repo["head"] ?? null;\n this.cells.set(["repo"], { ...repo, ready: false, head: null, rebuilds });\n return this.#begin("init", {}, { rebuild: true });\n }\n async state(args) {\n const refused = this.#refusal("state", args);\n if (refused !== null) return refused;\n const repo = this.#repo();\n if (repo === null) return null;\n if (this.#role() === "library") return { name: repo["name"] ?? null };\n const held = this.#result(await this.ask("repos", "state", {}));\n const folder = _RepoLobe.#arg(held, "folder") ?? null;\n const relations = await this.#relations();\n const stood = relations.filter((one) => one.side === "standing" && !_RepoLobe.#text(_RepoLobe.#arg(one.note, "credential"))).toSorted((a, b) => _RepoLobe.#order(a.placeholder ?? "", b.placeholder ?? ""));\n const given = relations.filter((one) => one.side === "occupant");\n const on = stood.map(({ placeholder, far }) => ({ placeholder, far }));\n const writers = given.filter(({ note }) => _RepoLobe.#kindOf(note) === "writer").length;\n const author = this.cells.get(["author"]);\n const conform = this.cells.get(["conform"]);\n const sync = this.cells.get(["sync"]) ?? null;\n const syncing = _RepoLobe.#fields(sync) ? Object.fromEntries(Object.entries(sync).filter(([key]) => key !== "tells")) : sync;\n const scopes = given.flatMap(({ far, note }) => {\n const scope = _RepoLobe.#scopeIn(note);\n return scope === null ? [] : [{ far, scope }];\n });\n const scoped = stood.flatMap(({ placeholder, note }) => {\n const scope = _RepoLobe.#scopeIn(note);\n return scope === null ? [] : [{ on: placeholder, scope }];\n });\n const { cut: _, ...whole } = repo;\n const lost = repo["ready"] === true && _RepoLobe.#arg(held, "made") === false;\n return {\n ...whole,\n ...lost ? {\n ready: false,\n absent: "its folder holds no repo: a backup carries no repo\'s bytes; rebuild fills it again, pulled whole from a lobe it stands on or pushed whole by one that stands on it"\n } : {},\n on,\n writers,\n folder,\n syncing,\n gate: this.#gateScript(),\n gates: this.#gates(),\n ..._RepoLobe.#text(conform) ? { conform } : {},\n ..._RepoLobe.#text(author) ? { author } : {},\n ...scopes.length > 0 ? { scopes } : {},\n ...scoped.length > 0 ? { scoped } : {},\n ..._RepoLobe.#fields(_RepoLobe.#arg(this.cells.get(["scanned"]), "cut")) ? { cut: _RepoLobe.#arg(this.cells.get(["scanned"]), "cut") ?? null } : {},\n ...this.#role() === "library" ? {} : await this.#keysShown()\n };\n }\n async #keysShown() {\n const issued = await this.#credentials();\n const credentials = issued.map(({ secret, far }) => {\n const cell = this.cells.get(["credential", far]);\n const url = _RepoLobe.#arg(cell, "url");\n const failed = _RepoLobe.#arg(cell, "failed");\n const expires = _RepoLobe.#arg(cell, "expires");\n const renews = _RepoLobe.#arg(cell, "renews");\n return {\n secret,\n far,\n pending: _RepoLobe.#arg(cell, "pending") === true,\n ..._RepoLobe.#text(url) ? { url } : {},\n ..._RepoLobe.#text(failed) ? { failed } : {},\n ...typeof expires === "number" && typeof renews === "number" ? { expires, renews } : {}\n };\n });\n const secrets = Object.keys(await this.#keys()).toSorted();\n return { ...secrets.length > 0 ? { secrets } : {}, ...credentials.length > 0 ? { credentials } : {} };\n }\n jobs(args) {\n const refused = this.#refusal("jobs", args);\n if (refused !== null) return refused;\n const { asker } = this.stamp;\n const page = this.#page(asker === _RepoLobe.#owner ? ["job"] : ["by", asker], args);\n if (!("cells" in page)) return page;\n const held = asker === _RepoLobe.#owner ? page.cells.map(({ value }) => value) : page.cells.map(({ key }) => this.cells.get(["job", key[2] ?? ""]) ?? null);\n return { jobs: held.map((one) => _RepoLobe.#brief(one)), cursor: page.cursor };\n }\n #page(prefix, args) {\n const cursor = _RepoLobe.#arg(args, "cursor") ?? null;\n if (cursor !== null && !_RepoLobe.#text(cursor)) return this.error("refused", "a cursor is the one a page answered");\n try {\n return this.cells.range({ prefix: [...prefix], limit: this.#most(), ...cursor === null ? {} : { cursor } });\n } catch {\n return this.error("refused", "a cursor is the one a page answered");\n }\n }\n static #brief(held) {\n if (!_RepoLobe.#fields(held) || !_RepoLobe.#fields(held["ended"])) return held;\n const { run, code, at } = held["ended"];\n return { ...held, ended: { run: run ?? null, code: code ?? null, at: at ?? null } };\n }\n job(args) {\n const refused = this.#refusal("job", args);\n if (refused !== null) return refused;\n const run = _RepoLobe.#arg(args, "job");\n if (!_RepoLobe.#text(run)) return this.error("refused", "a job is named by its id");\n const { asker } = this.stamp;\n const held = this.cells.get(["job", run]);\n const owns = asker === _RepoLobe.#owner || this.cells.get(["by", asker, run]) !== void 0;\n if (owns && _RepoLobe.#fields(held)) return held;\n const sync = this.cells.get(["sync"]);\n const last = this.#repo()?.["synced"];\n for (const one of [sync, last]) {\n if (!_RepoLobe.#fields(one) || one["job"] !== run) continue;\n if (asker !== _RepoLobe.#owner && one["asker"] !== asker) break;\n const ended = one === sync ? null : { code: one["code"] ?? null, err: one["err"] ?? null };\n return { job: run, kind: one["kind"] ?? null, stage: one === sync ? one["stage"] ?? null : null, ended };\n }\n return this.error("absent", "no such job");\n }\n async #begin(kind, given, step, { more = {}, asker = this.stamp.asker, method = kind } = {}) {\n const repo = this.#repo();\n if (repo === null) return this.error("refused", "the lobe keeps no repo");\n if (!_RepoLobe.#text(repo["doing"])) await this.#unclear();\n if (_RepoLobe.#text(repo["doing"])) {\n await this.#check();\n return this.error("refused", `the repo runs ${repo["doing"]} already`);\n }\n const back = step === null && this.#role() !== "runner" ? await this.#back(asker) : null;\n if (back !== null) return back;\n const begun = await this.ask("repos", method, given);\n if ("error" in begun) return this.error(begun.error.code, begun.error.message);\n const run = _RepoLobe.#arg(begun.result, "job");\n if (!_RepoLobe.#text(run)) return this.error("refused", "the jailer named no job");\n const owing = kind === "scan" && this.cells.get(["owed"]) === true;\n const of = step === null ? {} : { step: owing ? { ...step, owed: true } : step };\n this.cells.set(["job", run], {\n job: run,\n kind,\n asker,\n repo: repo["name"] ?? null,\n ...of,\n ...more,\n began: this.stamp.time,\n ended: null\n });\n if (step === null) this.cells.set(["by", asker, run], null);\n this.cells.set(["repo"], { ...repo, doing: run });\n return { job: run };\n }\n async #back(asker) {\n if (asker === _RepoLobe.#owner || this.cells.get(["back", asker]) !== void 0) return null;\n const ordered = await this.nerves.order({ termination: asker });\n if ("error" in ordered) return this.error("refused", `no wire back: ${ordered.error.message}`);\n this.cells.set(["back", asker], true);\n return null;\n }\n async done(args) {\n if (this.#role() === "teller") return this.#told(args);\n const read = await this.nerves.read();\n if (_RepoLobe.#wiredTo(read, "repos") !== this.stamp.asker)\n return this.error("refused", "only the jailer tells a job ended");\n const { job: run, code: ended, out: said, err: wrote } = _RepoLobe.#fields(args) ? args : {};\n const whole = typeof said === "string" && typeof wrote === "string" && typeof ended === "number";\n const held = _RepoLobe.#text(run) ? this.cells.get(["job", run]) : void 0;\n if (!whole || !_RepoLobe.#text(run) || !_RepoLobe.#fields(held) || held["ended"] !== null)\n return this.error("refused", "no such job going");\n return this.#jobEnded(read, run, held, ended, said, wrote);\n }\n async #jobEnded(read, run, held, ended, said, wrote) {\n this.#torn(read);\n const [out, err] = [this.#masked(said), this.#masked(wrote)];\n if (_RepoLobe.#text(held["gating"])) return this.#gated(held, run, ended, out, err);\n if (_RepoLobe.#fields(held["running"])) return this.#writtenThen(held, run, ended, err);\n const filed = held["kind"] !== "commit" ? err : ended === 0 ? err : await this.#undone(err);\n if (held["kind"] === "commit" && ended === 0) this.cells.delete(["undo"]);\n const [code, told] = this.#halfKept(held, ended, out, filed);\n this.#settled(held, code, out, told);\n const before = this.cells.get(["sync"]);\n const more = await this.#further(run, held, code, out, told);\n if (more !== null) await this.#closed(run, held, code, out, told, more);\n await this.#rung(before);\n await this.#tellEnds();\n await this.#receiveWaiting();\n const step = held["step"];\n const tried = _RepoLobe.#fields(step) && step["owed"] === true || more !== null && more["scan"] !== void 0;\n if (!tried) await this.#owing();\n return null;\n }\n async #further(run, held, code, out, err) {\n const asker = _RepoLobe.#text(held["asker"]) ? held["asker"] : _RepoLobe.#owner;\n const pulls = held["pulls"];\n if (held["kind"] === "init" && code === 0 && _RepoLobe.#text(pulls))\n return this.#pulled(run, held, out, pulls, asker);\n if (_RepoLobe.#fields(held["step"]) && held["step"]["rebuild"] === true) {\n const first = await this.#rebuilt(code === 0 ? null : _RepoLobe.#lastLine(err) || `the job ended ${code}`);\n return _RepoLobe.#text(first) ? this.#pulled(run, held, out, first, _RepoLobe.#owner) : {};\n }\n if (held["kind"] === "init" && code === 0 && held["starter"] === true) {\n const why = await this.#layStarter(run, asker);\n return why === null ? null : { starter: why };\n }\n const moved = code === 0 && typeof held["kind"] === "string" && _RepoLobe.#moves.includes(held["kind"]);\n if (!moved || !_RepoLobe.#text(this.#repo()?.["head"])) return {};\n const begun = await this.#begin("scan", {}, { scan: run, code, out, err }, { asker });\n if ("job" in begun) return null;\n this.cells.set(["owed"], true);\n await this.#awaiting();\n return { scan: { code: 1, err: `the scan did not begin: ${begun.message}` } };\n }\n async #pulled(run, held, out, on, asker) {\n const begun = await this.#start("pull", asker, on, { of: run });\n if (_RepoLobe.#text(_RepoLobe.#arg(begun, "job"))) return null;\n await this.#closed(\n run,\n held,\n 1,\n out,\n `the pull did not begin: ${_RepoLobe.#shown(_RepoLobe.#arg(begun, "message"))}`,\n {}\n );\n return null;\n }\n async #closed(run, held, code, out, err, more) {\n this.cells.set(["job", run], { ...held, ended: { run, code, out, err, ...more, at: this.stamp.time } });\n const step = held["step"];\n if (!_RepoLobe.#fields(step)) return this.#ended(held, code, out, err, more);\n await this.#stepped(step, held, code, out, err, more);\n if (step["rebuild"] === true) this.#endKept(_RepoLobe.#owner, run);\n else this.cells.delete(["job", run]);\n }\n async #scannedThen(step, code, err) {\n const run = step["scan"];\n const held = _RepoLobe.#text(run) ? this.cells.get(["job", run]) : void 0;\n if (!_RepoLobe.#text(run) || !_RepoLobe.#fields(held) || held["ended"] !== null) return;\n const scan = { code, err: code === 0 ? "" : _RepoLobe.#last(err) || `the scan ended ${code}` };\n const [out, said] = [step["out"], step["err"]].map((one) => typeof one === "string" ? one : "");\n await this.#closed(run, held, Number(step["code"]), out ?? "", said ?? "", { scan });\n }\n #halfKept(held, code, out, err) {\n const built = held["built"];\n if (code !== 0 || !_RepoLobe.#fields(built)) return [code, err];\n if (_RepoLobe.#text(built["design"])) return [code, err];\n const [organ, version] = [_RepoLobe.#shown(built["organ"]), _RepoLobe.#shown(built["version"])];\n const kept = this.cells.get(["built", organ, version]);\n const digest = out.trim();\n if (typeof kept !== "string" || kept === digest) return [code, err];\n return [\n 1,\n `the host half of ${organ} ${version} was built as ${kept}, and this build gives ${digest}: a version is never told with other bytes, so raise its version`\n ];\n }\n #settled(held, code, out, err) {\n const repo = this.#repo();\n if (repo === null) return;\n const { kind } = held;\n const failed = code === 0 ? null : _RepoLobe.#lastLine(err);\n const made = kind === "init" ? { ready: code === 0, failed } : {};\n const moved = code === 0 && typeof kind === "string" && _RepoLobe.#moves.includes(kind);\n const now = moved ? _RepoLobe.#headOf(out) : null;\n const head = moved ? { head: now } : {};\n this.cells.set(["repo"], { ...repo, ...made, ...head, doing: null });\n if (now !== null && kind !== "land" && out.split("\\n").includes(`conform ${now}`)) this.cells.set(["conform"], now);\n }\n async #ended(held, code, out, err, more = {}) {\n const { asker, kind, job: run } = held;\n if (_RepoLobe.#text(asker) && _RepoLobe.#text(run) && this.cells.get(["by", asker, run]) !== void 0)\n this.#endKept(asker, run);\n const built = held["built"];\n const digest = out.trim();\n if (code === 0 && _RepoLobe.#fields(built)) {\n if (_RepoLobe.#text(built["design"])) this.#looked(built, out);\n else if (_RepoLobe.#digest.test(digest))\n this.cells.set(["built", _RepoLobe.#shown(built["organ"]), _RepoLobe.#shown(built["version"])], digest);\n }\n if (!_RepoLobe.#text(asker) || this.cells.get(["back", asker]) === void 0) return;\n const told = { job: run ?? null, kind: kind ?? null, code, out, err, ...more };\n await this.ask(asker, "done", told, void 0, { letter: { lives: _RepoLobe.#lives } });\n }\n #endKept(asker, run) {\n const ends = this.cells.get(["ended", asker]);\n let first = Number(_RepoLobe.#arg(ends ?? null, "first") ?? 0);\n const next = Number(_RepoLobe.#arg(ends ?? null, "next") ?? 0);\n for (; next - first >= Math.max(1, this.#most()); first += 1) {\n const oldest = this.cells.get(["ended", asker, String(first)]);\n if (_RepoLobe.#text(oldest)) {\n this.cells.delete(["job", oldest]);\n this.cells.delete(["by", asker, oldest]);\n }\n this.cells.delete(["ended", asker, String(first)]);\n }\n this.cells.set(["ended", asker, String(next)], run);\n this.cells.set(["ended", asker], { first, next: next + 1 });\n }\n #looked(built, source) {\n const [name, version] = [_RepoLobe.#shown(built["design"]), _RepoLobe.#shown(built["version"])];\n const told = _RepoLobe.#arg(this.cells.get(["told", "faculty", `${name}.look`, version]), "digest");\n const digest = this.#digestOf(source);\n if (digest === told) {\n this.cells.set(["look", name, version], { source });\n return;\n }\n if (_RepoLobe.#text(_RepoLobe.#arg(this.cells.get(["look", name, version]), "source"))) return;\n const why = `the look built is ${digest}, not the ${_RepoLobe.#shown(told)} versions.json told`;\n this.cells.set(["look", name, version], { why });\n }\n async #stepped(step, held, code, out, err, more) {\n const why = code === 0 ? null : _RepoLobe.#lastLine(err) || `the job ended ${code}`;\n if (_RepoLobe.#text(step["commit"])) {\n await this.#commitEnded(step["commit"], code, out, err, more);\n return void 0;\n }\n if (_RepoLobe.#text(step["ran"])) {\n const kind = _RepoLobe.#text(held["kind"]) ? held["kind"] : "run";\n return this.#workEnded(step["ran"], kind, code, out, err);\n }\n if (_RepoLobe.#text(step["check"])) return this.#checked(step["check"], { code, out, err });\n if (step["scan"] !== void 0) {\n if (code === 0) await this.#scanned(out);\n if (code === 0 && step["owed"] === true) this.cells.delete(["owed"]);\n else if (step["owed"] === true) await this.#awaiting();\n return this.#scannedThen(step, code, err);\n }\n if (_RepoLobe.#text(step["for"])) return this.#served(step["for"], held["kind"], why, out);\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync)) return;\n if (held["kind"] === "bring") return this.#broughtPull(sync, why, out);\n if (held["kind"] === "land") return this.#landed(sync, why);\n if (sync["stage"] === "proving") return this.#proven(sync, code, why, out);\n if (why !== null) return this.#finish(sync, code, why);\n const pieces = Number(out.trim().split("\\n")[0]);\n if (pieces === 0) return this.#finish(sync, 0, "");\n this.cells.set(["sync"], { ...sync, stage: "sending", at: 0, pieces });\n return void 0;\n }\n async #broughtPull(sync, why, out) {\n if (why !== null) return this.#finish(sync, 1, why);\n const [head = "", how = ""] = out.trim().split("\\n");\n if (how === "held" || !_RepoLobe.#hash.test(head)) return this.#finish(sync, 0, "");\n const check = await this.#conform("pull", head, false, _RepoLobe.#askerOf(sync));\n const checking = { ...sync, stage: "checking", theirs: head, check };\n this.cells.set(["sync"], checking);\n if ("code" in check) await this.#checkedPull(checking, check);\n return void 0;\n }\n async #checkedPull(sync, check) {\n if (check["code"] !== 0) return this.#finish(sync, 1, _RepoLobe.#refusalOf(check), check);\n const begun = await this.#begin("land", { as: "pull" }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.cells.set(["sync"], { ...sync, stage: "landing" });\n else await this.#finish(sync, 1, begun.message, check);\n return void 0;\n }\n async #landed(sync, why) {\n const check = sync["check"] ?? null;\n if (why !== null) return this.#finish(sync, 1, why, check);\n const rebuilds = this.#repo()?.["rebuilds"];\n if (!_RepoLobe.#text(rebuilds)) return this.#finish(sync, 0, "", check);\n const begun = await this.#begin("head", { contains: rebuilds }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.cells.set(["sync"], { ...sync, stage: "proving" });\n else await this.#finish(sync, 1, begun.message, check);\n return void 0;\n }\n async #proven(sync, code, why, out) {\n const repo = this.#repo();\n const holds = code === 0 && out.trim().split("\\n")[1] === "holds";\n if (repo !== null && holds) this.cells.set(["repo"], { ...repo, rebuilds: null });\n const lacks = "the lobe pulled holds not the head this one kept: it waits for a whole push";\n return this.#finish(sync, holds ? 0 : 1, holds ? "" : why ?? lacks, sync["check"] ?? null);\n }\n async #rebuilt(why) {\n const repo = this.#repo();\n if (repo === null) return null;\n this.cells.set(["repo"], { ...repo, head: null, ready: why === null, failed: why });\n const first = why === null ? (await this.#held())[0]?.placeholder : null;\n return _RepoLobe.#text(first) ? first : null;\n }\n async #scanned(out) {\n const [shown = "", toldBlock = ""] = out.trim().split("\\n@ ");\n const [head = "", ...lines] = shown.split("\\n");\n const tracked = new Set(lines.filter((line) => line.startsWith("t ")).map((line) => line.slice(2)));\n const changed = new Set(lines.filter((line) => line.startsWith("c ")).map((line) => line.slice(2)));\n const tagged = lines.some((line) => line.startsWith("g "));\n const cut = {};\n const named = (kind, pattern) => {\n const all = [...tracked].flatMap((path) => pattern.exec(path)?.[1] ?? []).toSorted();\n if (all.length > this.#most()) cut[kind] = all.length - this.#most();\n return all.slice(0, this.#most());\n };\n const files = _RepoLobe.#hashedFiles(lines);\n const faculties = [];\n for (const label of named("faculties", /^faculties\\/([^/]+)\\/faculty\\.js$/))\n faculties.push(await this.#faculty(label, tracked, changed, files, tagged));\n const organs = [];\n for (const id of named("organs", /^organs\\/([^/]+)\\/graph\\.json$/))\n organs.push(await this.#organ(id, tracked, changed, tagged));\n const designs = [];\n for (const name of named("designs", /^designs\\/([^/]+)\\/design\\.json$/))\n designs.push(await this.#design(name, tracked, changed, files, tagged));\n this.cells.set(["scanned"], {\n head,\n faculties,\n organs,\n designs,\n ...Object.keys(cut).length > 0 ? { cut } : {}\n });\n const repo = this.#repo();\n if (repo !== null && _RepoLobe.#text(head) && repo["head"] !== head) this.cells.set(["repo"], { ...repo, head });\n if (!tagged) return this.#tell(await this.#toldAt(toldBlock));\n await this.#tell([\n ...faculties.flatMap((one) => _RepoLobe.#found("faculty", one)),\n ...organs.flatMap((one) => _RepoLobe.#found("organ", one)),\n ...designs.flatMap((one) => _RepoLobe.#lookFound(one))\n ]);\n }\n async #toldAt(block) {\n if (block === "") return [];\n const lines = block.split("\\n").slice(1);\n const files = _RepoLobe.#hashedFiles(\n lines.flatMap(\n (line) => line.startsWith("A ") ? [`d ${line.slice(2)}`] : line.startsWith("U ") ? [`u ${line.slice(2)}`] : []\n )\n );\n const tracked = new Set(lines.filter((line) => line.startsWith("T ")).map((line) => line.slice(2)));\n const carried = new Map(\n lines.flatMap((line) => {\n const [, path, text] = /^B (\\S+) (".*")$/u.exec(line) ?? [];\n return path === void 0 || text === void 0 ? [] : [[path, text]];\n })\n );\n const read = async (path) => {\n const text = carried.get(path);\n if (text === void 0) return this.#file(path);\n try {\n const one = JSON.parse(text);\n return typeof one === "string" ? one : null;\n } catch {\n return null;\n }\n };\n const named = (pattern) => [...tracked].flatMap((path) => pattern.exec(path)?.[1] ?? []).toSorted().slice(0, this.#most());\n const none = new Set();\n const found = [];\n for (const label of named(/^faculties\\/([^/]+)\\/faculty\\.js$/))\n found.push(..._RepoLobe.#found("faculty", await this.#faculty(label, tracked, none, files, true, read)));\n for (const id of named(/^organs\\/([^/]+)\\/graph\\.json$/))\n found.push(..._RepoLobe.#found("organ", await this.#organ(id, tracked, none, true, read)));\n return found;\n }\n static #hashedFiles(lines) {\n const files = new Map();\n for (const line of lines) {\n if (!line.startsWith("d ") && !line.startsWith("u ")) continue;\n const hashed = _RepoLobe.#hashed.exec(line);\n const folder = hashed?.[2] ?? /^. (?:\\S* )?((?:designs|faculties)\\/[^/]+)\\//.exec(line)?.[1];\n if (folder === void 0) continue;\n const held = files.get(folder) ?? { parts: [], unread: false };\n const [sha, path] = [hashed?.[1], hashed?.[3]];\n const part = path === void 0 ? void 0 : _RepoLobe.#partOf(folder, path);\n if (sha === void 0 || path === void 0) held.unread = true;\n else if (part !== void 0) held.parts.push([part, sha]);\n files.set(folder, held);\n }\n return files;\n }\n static #partOf(folder, path) {\n if (folder.startsWith("designs/")) return _RepoLobe.#isData(path) ? path : void 0;\n const asset = path.startsWith("assets/") ? path.slice("assets/".length) : "";\n return asset !== "" && !asset.split("/").some((name) => name.startsWith(".")) ? asset : void 0;\n }\n static #isData(path) {\n if (path === "DESIGN.md" || path === "versions.json") return false;\n if (path.startsWith("components/") || path.startsWith("words/")) return false;\n return !path.split("/").some((name) => name.startsWith("."));\n }\n #dataOf(parts) {\n return this.#digestOf(JSON.stringify(_RepoLobe.#byPath(parts)));\n }\n static #byPath(parts) {\n return parts.map((part) => [...part]).toSorted((one, other) => (one[0] ?? "") < (other[0] ?? "") ? -1 : 1);\n }\n async #design(name, tracked, changed, files, tagged) {\n const root = `designs/${name}/`;\n if (!_RepoLobe.#label.test(name)) return { name, why: "its folder is no name" };\n if (!tracked.has(`${root}versions.json`)) return { name, why: "it holds no versions.json committed" };\n if ([...changed].some((path) => path.startsWith(root)))\n return { name, why: "its files hold changes not committed" };\n const held = files.get(`designs/${name}`) ?? { parts: [], unread: true };\n const design = await this.#file(`${root}design.json`);\n const kept = await this.#file(`${root}versions.json`);\n if (held.unread || design === null || kept === null) return { name, why: "its files are not all read" };\n const read = _RepoLobe.#json(design);\n const version = _RepoLobe.#arg(read, "version");\n if (_RepoLobe.#arg(read, "name") !== name) return { name, why: "its design.json names another name" };\n if (!_RepoLobe.#text(version) || !_RepoLobe.#version.test(version))\n return { name, why: "its design.json names no version" };\n const data = this.#dataOf(held.parts);\n const named = _RepoLobe.#arg(_RepoLobe.#json(kept), version);\n const look = _RepoLobe.#arg(named, "look");\n if (_RepoLobe.#arg(named, "data") !== data)\n return {\n name,\n version,\n data,\n why: "versions.json names another data digest for its version"\n };\n if (!_RepoLobe.#text(look) || !_RepoLobe.#digest.test(look))\n return { name, version, data, why: "versions.json names no look for its version" };\n const told = this.#record(\n "faculty",\n `${name}.look`,\n version,\n { digest: look, assets: _RepoLobe.#byPath(held.parts) },\n tagged\n );\n const why = _RepoLobe.#arg(told, "why");\n return { name, version, data, look, ...why === void 0 ? {} : { why } };\n }\n static #lookFound(one) {\n const [name, version] = [_RepoLobe.#arg(one, "name"), _RepoLobe.#arg(one, "version")];\n if (!_RepoLobe.#text(name) || !_RepoLobe.#text(version) || _RepoLobe.#arg(one, "why") !== void 0) return [];\n return [{ kind: "faculty", label: `${name}.look`, version }];\n }\n static #found(kind, one) {\n const label = _RepoLobe.#arg(one, _RepoLobe.#keyOf(kind));\n const version = _RepoLobe.#arg(one, "version");\n if (!_RepoLobe.#text(label) || !_RepoLobe.#text(version) || _RepoLobe.#arg(one, "why") !== void 0) return [];\n return [{ kind, label, version }];\n }\n async #faculty(label, tracked, changed, files, tagged, reader = (path) => this.#file(path)) {\n const [code, versions] = [`faculties/${label}/faculty.js`, `faculties/${label}/versions.json`];\n if (!_RepoLobe.#label.test(label)) return { label, why: "its folder is no label" };\n if (!tracked.has(versions)) return { label, why: "it holds no versions.json committed" };\n if (changed.has(code) || changed.has(versions))\n return { label, why: "its faculty.js or versions.json holds changes not committed" };\n const assets = `faculties/${label}/assets/`;\n if ([...changed].some((path) => path.startsWith(assets)))\n return { label, why: "its assets hold changes not committed" };\n const hashed = files.get(`faculties/${label}`) ?? {\n parts: [],\n unread: false\n };\n if (hashed.unread) return { label, why: "its assets are not all read" };\n const [source, kept] = [await reader(code), await reader(versions)];\n if (source === null || kept === null) return { label, why: "its files are not read" };\n const digest = this.#digestOf(source);\n const held = _RepoLobe.#json(kept);\n const version = _RepoLobe.#fields(held) ? Object.keys(held).find((one) => held[one] === digest) : void 0;\n if (version === void 0 || !_RepoLobe.#version.test(version))\n return { label, digest, why: "versions.json names no version for its digest" };\n const carried = hashed.parts.length === 0 ? {} : { assets: _RepoLobe.#byPath(hashed.parts) };\n return this.#record("faculty", label, version, { digest, ...carried }, tagged, source);\n }\n async #organ(id, tracked, changed, tagged, reader = (path) => this.#file(path)) {\n const [graph, build] = [`organs/${id}/graph.json`, `organs/${id}/host/build`];\n if (!_RepoLobe.#id.test(id)) return { id, why: "its folder is no fixed ID" };\n if (!tracked.has(build)) return { id, why: "it holds no host/build" };\n if ([graph, build].some((file) => changed.has(file))) return { id, why: "its files hold changes not committed" };\n const blueprint = tracked.has(graph) ? await reader(graph) : null;\n const read = blueprint === null ? null : _RepoLobe.#json(blueprint);\n const inner = _RepoLobe.#arg(read, "blueprint");\n const version = _RepoLobe.#arg(read, "version") ?? _RepoLobe.#arg(inner, "version");\n if (blueprint === null || typeof version !== "string" || !_RepoLobe.#version.test(version))\n return { id, why: "its graph.json names no version" };\n return this.#record("organ", id, version, { digest: this.#digestOf(blueprint) }, tagged, blueprint);\n }\n static #keyOf(kind) {\n return kind === "faculty" ? "label" : "id";\n }\n #record(kind, label, version, bytes, tagged, text = null) {\n const named = { [_RepoLobe.#keyOf(kind)]: label };\n const held = this.cells.get(["told", kind, label, version]);\n if (!_RepoLobe.#fields(held)) {\n if (tagged) {\n this.cells.set(["told", kind, label, version], {\n ...bytes,\n heard: false,\n at: this.stamp.time\n });\n this.#toldInOrder([kind, label, version]);\n if (text !== null) this.cells.set(["text", kind, label, version], text);\n }\n return { ...named, version, ...bytes };\n }\n const same = Object.keys(bytes).every((key) => JSON.stringify(held[key]) === JSON.stringify(bytes[key]));\n if (same) return { ...named, version, ...bytes };\n return {\n ...named,\n version,\n ...bytes,\n why: `version ${version} was told with other bytes: raise its version`\n };\n }\n #toldInOrder(named) {\n const next = Number(this.cells.get(["toldNext"]) ?? 0);\n this.cells.set(["toldAt", next], [...named]);\n this.cells.set(["toldNext"], next + 1);\n }\n async #file(path) {\n const read = await this.ask("repos", "read", { path });\n const text = "result" in read ? _RepoLobe.#arg(read.result, "text") : void 0;\n return typeof text === "string" ? text : null;\n }\n async #tell(found) {\n await this.#tellFar(found);\n const unheard = found.flatMap(({ kind, label, version }) => {\n const held = this.cells.get(["told", kind, label, version]);\n return _RepoLobe.#fields(held) && held["heard"] !== true ? [{ kind, label, version, held }] : [];\n });\n if (unheard.length === 0) return;\n const described = await this.ask("library", null, null);\n const methods = "result" in described ? _RepoLobe.#arg(described.result, "methods") : void 0;\n const offered = _RepoLobe.#kinds(_RepoLobe.#arg(methods, "changed"));\n for (const { kind, label, version, held } of unheard) {\n if (!offered.includes(kind)) continue;\n const changed = { kind, label, version, digest: held["digest"] ?? null };\n const letter = { lives: _RepoLobe.#lives };\n const sent = await this.ask("library", "changed", changed, void 0, { letter });\n if (!("error" in sent)) this.cells.set(["told", kind, label, version], { ...held, heard: true });\n }\n }\n async #tellFar(found) {\n const fresh = found.flatMap(({ kind, label, version }) => {\n const held = this.cells.get(["told", kind, label, version]);\n return _RepoLobe.#fields(held) && held["far"] !== true && (kind === "faculty" || kind === "organ") ? [{ kind, label, version, held }] : [];\n });\n if (fresh.length === 0) return;\n const backs = (await this.#relations()).filter(\n (one) => one.side === "standing" && one.placeholder?.startsWith(`${_RepoLobe.#hears}-`) === true\n );\n if (backs.length === 0) return;\n for (const { kind, label, version, held } of fresh) {\n const changed = { kind, label, version, digest: held["digest"] ?? null };\n const before = held["farHeard"];\n const heard = new Set(Array.isArray(before) ? before.filter((one) => _RepoLobe.#text(one)) : []);\n for (const { placeholder } of backs) {\n if (!_RepoLobe.#text(placeholder) || heard.has(placeholder)) continue;\n if (!("error" in await this.ask(placeholder, "changed", changed))) heard.add(placeholder);\n }\n const { farHeard: _, ...rest } = held;\n const all = backs.every(({ placeholder }) => !_RepoLobe.#text(placeholder) || heard.has(placeholder));\n this.cells.set(["told", kind, label, version], all ? { ...rest, far: true } : { ...rest, farHeard: [...heard] });\n }\n }\n static #kinds(changed) {\n const kind = _RepoLobe.#arg(_RepoLobe.#arg(_RepoLobe.#arg(changed, "args"), "properties"), "kind");\n const named = _RepoLobe.#arg(kind, "enum");\n return Array.isArray(named) ? named : [];\n }\n faculties(args) {\n return this.#offered("faculties", args);\n }\n organs(args) {\n return this.#offered("organs", args);\n }\n designs(args) {\n return this.#offered("designs", args);\n }\n #offered(method, args) {\n const refused = this.#refusal(method, args);\n if (refused !== null) return refused;\n const found = _RepoLobe.#arg(this.cells.get(["scanned"]), method);\n if (!Array.isArray(found) || found.length === 0) return this.error("absent", `the repo holds no ${method}/`);\n return found;\n }\n async get(args) {\n const refused = this.#refusal("get", args);\n if (refused !== null) return refused;\n const { kind, label, version, path } = _RepoLobe.#fields(args) ? args : {};\n if (kind !== "faculty" && kind !== "organ" || !_RepoLobe.#text(label) || !_RepoLobe.#label.test(label))\n return this.error("refused", "a get names a faculty or an organ by its label");\n if (path !== void 0 && (kind !== "faculty" || !_RepoLobe.#text(path)))\n return this.error("refused", "a path names a faculty\'s asset");\n const near = ["owner", "near"].includes(this.#role());\n if (version === null && !near) return this.error("refused", "a version told is read from afar");\n const told = _RepoLobe.#text(version) ? this.cells.get(["told", kind, label, version]) : null;\n const at = _RepoLobe.#shown(version);\n if (told !== null && !_RepoLobe.#fields(told)) return this.error("absent", `no version ${at} of ${label} was told`);\n if (kind === "faculty" && told !== null && told["assets"] !== void 0 && this.#isLook(label))\n return this.#getLook(label, at, told, path);\n if (path !== void 0 && (told === null || told["assets"] === void 0))\n return this.error("refused", `${label} ${at} carries no assets`);\n if (path !== void 0 && told !== null) return this.#getAsset(label, told, path);\n const kept = _RepoLobe.#text(version) ? this.cells.get(["text", kind, label, version]) : void 0;\n if (told !== null && typeof kept === "string") {\n if (kind === "faculty")\n return {\n source: kept,\n digest: told["digest"] ?? null,\n ..._RepoLobe.#carried(told)\n };\n return { blueprint: kept, half: this.cells.get(["built", label, at]) ?? null };\n }\n if (kind === "faculty") return this.#getFaculty(label, told);\n return this.#getOrgan(label, at, told);\n }\n #isLook(label) {\n const designs = _RepoLobe.#arg(this.cells.get(["scanned"]), "designs");\n const name = label.endsWith(".look") ? label.slice(0, -".look".length) : null;\n return Array.isArray(designs) && designs.some((one) => _RepoLobe.#arg(one, "name") === name);\n }\n static #carried(told) {\n const parts = _RepoLobe.#partsOf(told["assets"]);\n return parts === null ? {} : { assets: parts };\n }\n async #getAsset(label, told, path) {\n const part = _RepoLobe.#partsOf(told["assets"])?.find((one) => one[0] === path);\n if (part === void 0) return this.error("absent", `${label} holds no asset ${_RepoLobe.#shown(path)}`);\n return this.#asset(part);\n }\n async #asset(part) {\n const read = await this.ask("repos", "bytes", { sha: part[1] ?? null });\n if ("error" in read)\n return read.error.code === "absent" ? this.error("absent", this.#unkept(_RepoLobe.#shown(part[0]))) : this.#result(read);\n const bytes = _RepoLobe.#arg(read.result, "bytes");\n const whole = bytes instanceof Uint8Array ? _RepoLobe.#canonical(bytes) : null;\n if (whole === null || this.#shaOf(whole) !== part[1])\n return this.error("refused", "the asset kept is not the version told");\n return { path: part[0] ?? null, digest: part[1] ?? null, bytes: whole };\n }\n #unkept(shown) {\n if (this.#scanning()) return `${shown} is being kept: a scan of the repo is running, ask again once it ends`;\n if (this.cells.get(["owed"]) === true)\n return `${shown} is not kept yet: a scan of the repo is owed and begins once the repo runs nothing, ask again then`;\n return `${shown} is not kept yet: a scan of the repo keeps it`;\n }\n static #partsOf(data) {\n if (!Array.isArray(data)) return null;\n const parts = [];\n for (const one of data) {\n const [path, sha] = Array.isArray(one) && one.length === 2 ? one : [];\n if (!_RepoLobe.#text(path) || !_RepoLobe.#text(sha) || !_RepoLobe.#digest.test(sha)) return null;\n parts.push([path, sha]);\n }\n return parts;\n }\n async #getLook(label, version, told, path) {\n const name = label.slice(0, -".look".length);\n const parts = _RepoLobe.#partsOf(told["assets"]);\n if (parts === null) return this.error("refused", `the look ${label} ${version} names no assets whole`);\n if (path === void 0) {\n const built = this.cells.get(["look", name, version]);\n const source = _RepoLobe.#arg(built, "source");\n if (typeof source === "string" && this.#digestOf(source) === told["digest"])\n return { source, digest: told["digest"], assets: parts };\n const why = _RepoLobe.#arg(built, "why");\n return this.error("refused", _RepoLobe.#text(why) ? why : `the look of ${name} ${version} is not built: build it`);\n }\n const part = parts.find((one) => one[0] === path);\n if (part === void 0) return this.error("absent", `the look ${label} holds no asset ${_RepoLobe.#shown(path)}`);\n return this.#asset(part);\n }\n async #getFaculty(label, told) {\n const source = await this.#file(`faculties/${label}/faculty.js`);\n if (source === null) return this.error("absent", `the repo holds no faculties/${label}/faculty.js`);\n const digest = this.#digestOf(source);\n if (told !== null && told["digest"] !== digest)\n return this.error("refused", "the faculty.js the repo holds is not the version told");\n return {\n source,\n digest,\n ...told === null ? {} : _RepoLobe.#carried(told)\n };\n }\n async #getOrgan(id, version, told) {\n const blueprint = await this.#file(`organs/${id}/graph.json`);\n if (blueprint === null) return this.error("absent", `the repo holds no organ ${id} whole`);\n if (told !== null && told["digest"] !== this.#digestOf(blueprint))\n return this.error("refused", "the organ the repo holds is not the version told");\n const half = told === null ? null : this.cells.get(["built", id, version]) ?? null;\n return { blueprint, half };\n }\n build(args) {\n const refused = this.#refusal("build", args);\n if (refused !== null) return Promise.resolve(refused);\n const [organ, design] = [_RepoLobe.#arg(args, "organ"), _RepoLobe.#arg(args, "design")];\n const version = _RepoLobe.#arg(args, "version");\n if (organ === void 0 === (design === void 0))\n return Promise.resolve(this.error("refused", "a build names an organ or a design"));\n const [kind, named] = organ === void 0 ? ["design", design] : ["organ", organ];\n const told = _RepoLobe.#text(named) && _RepoLobe.#text(version) ? this.cells.get(\n kind === "design" ? ["told", "faculty", `${named}.look`, version] : ["told", "organ", named, version]\n ) : void 0;\n if (!_RepoLobe.#fields(told))\n return Promise.resolve(this.error("absent", `no such ${kind} was told at that version`));\n if (!("name" in this.#ready())) return Promise.resolve(this.error("refused", "the repo is not ready"));\n if (!this.#mainHolds(kind, _RepoLobe.#shown(named), _RepoLobe.#shown(version), told["digest"]))\n return Promise.resolve(\n this.error(\n "refused",\n `main holds not ${_RepoLobe.#shown(named)} ${_RepoLobe.#shown(version)}: a version is built while main holds it`\n )\n );\n const built = { [kind]: named ?? null, version: version ?? null };\n const method = kind === "design" ? "look" : "build";\n return this.#begin("build", { [kind]: named ?? null }, null, { more: { built }, method });\n }\n #mainHolds(kind, named, version, digest) {\n const [list, key, by] = kind === "design" ? ["designs", "name", "look"] : ["organs", "id", "digest"];\n const found = _RepoLobe.#arg(this.cells.get(["scanned"]), list);\n const now = Array.isArray(found) ? found.find((one) => _RepoLobe.#arg(one, key) === named) : void 0;\n return _RepoLobe.#arg(now, "version") === version && _RepoLobe.#arg(now, by) === digest && _RepoLobe.#arg(now, "why") === void 0;\n }\n async told(args) {\n const refused = this.#refusal("told", args);\n if (refused !== null) return refused;\n const tells = _RepoLobe.#arg(args, "tells");\n if (this.#role() === "library" && this.stamp.occupant !== null) {\n if (_RepoLobe.#text(tells)) {\n const far = this.stamp.asker;\n await this.#untold(far, _RepoLobe.#hears);\n const note = { repo: this.#repo()?.["name"] ?? null, library: far };\n const accepted = await this.ask("mouth", "accept", {\n invitation: tells,\n placeholder: _RepoLobe.#backUnder(_RepoLobe.#hears, far),\n note\n });\n if ("error" in accepted)\n return this.error(accepted.error.code, `the standing back was not taken: ${accepted.error.message}`);\n }\n } else if (tells !== void 0) return this.error("refused", "tells is a far library’s alone");\n const page = this.#page(["toldAt"], args);\n if (!("cells" in page)) return page;\n const told = page.cells.flatMap(({ value }) => {\n if (!Array.isArray(value)) return [];\n const [kind, label, version] = value.map((part) => typeof part === "string" ? part : "");\n const held = this.cells.get(["told", kind ?? "", label ?? "", version ?? ""]);\n if (!_RepoLobe.#fields(held)) return [];\n return [{ kind: kind ?? null, label: label ?? null, version: version ?? null, ...held }];\n });\n return { told, cursor: page.cursor };\n }\n head(args) {\n const refused = this.#serving("head", args);\n if (refused !== null) return refused;\n const repo = this.#repo() ?? {};\n if (this.#scopeOfAsker() !== null) return { head: null };\n return { head: _RepoLobe.#text(repo["rebuilds"]) ? null : repo["head"] ?? null };\n }\n async give(args) {\n const refused = this.#serving("give", args);\n if (refused !== null) return refused;\n const repo = this.#repo() ?? {};\n const since = _RepoLobe.#arg(args, "since") ?? null;\n const tag = _RepoLobe.#arg(args, "tag") ?? null;\n const far = this.stamp.asker;\n const scope = this.#scopeOfAsker();\n if (tag !== null && !(_RepoLobe.#text(tag) && _RepoLobe.#tag.test(tag)))\n return this.error("refused", "a tag is v and three whole numbers");\n const out = this.cells.get(["out", far]);\n const current = _RepoLobe.#fields(out) && (out["of"] ?? null) === (repo["head"] ?? null);\n const piece = _RepoLobe.#arg(args, "piece") ?? null;\n const same = _RepoLobe.#fields(out) && out["since"] === since && (out["tag"] ?? null) === tag && (out["piece"] ?? null) === piece;\n if (_RepoLobe.#fields(out) && current && same && _RepoLobe.#text(out["run"])) {\n if (_RepoLobe.#text(out["failed"])) {\n this.cells.delete(["out", far]);\n return this.error("refused", out["failed"]);\n }\n if (typeof out["pieces"] !== "number") return { ready: false };\n const ready = { pieces: out["pieces"], head: out["head"] ?? null };\n return scope === null ? ready : { ...ready, scope };\n }\n if (_RepoLobe.#text(repo["doing"])) {\n await this.#check();\n return { ready: false };\n }\n const as = `out-${far}`;\n const named = { ...typeof tag === "string" ? { tag } : {}, ...typeof piece === "number" ? { piece } : {} };\n const tagged = typeof tag === "string" ? { tag } : {};\n const begun = scope === null ? await this.#begin("bundle", { since, as, ...named }, { for: far }) : await this.#begin("cut", { as, scope, ...tagged }, { for: far });\n if (!("job" in begun)) return begun;\n const of = repo["head"] ?? null;\n this.cells.set(["out", far], { since, ...named, of, run: begun.job, pieces: null, head: null, failed: null });\n return { ready: false };\n }\n #serving(method, args) {\n const refused = this.#refusal(method, args);\n if (refused !== null) return refused;\n if (!("name" in this.#ready())) return this.error("refused", "the repo is not ready");\n if (method === "give" && _RepoLobe.#text(this.#repo()?.["rebuilds"]))\n return this.error("refused", "the lobe rebuilds: it is pushed whole first");\n return null;\n }\n async piece(args) {\n const refused = this.#serving("piece", args);\n if (refused !== null) return refused;\n const at = _RepoLobe.#arg(args, "at");\n const out = this.cells.get(["out", this.stamp.asker]);\n const pieces = _RepoLobe.#arg(out, "pieces");\n if (typeof pieces !== "number" || typeof at !== "number" || !Number.isInteger(at) || at < 0 || at >= pieces)\n return this.error("refused", "no such piece is ready");\n return this.#result(await this.ask("repos", "piece", { at, as: `out-${this.stamp.asker}` }));\n }\n async take(args) {\n const refused = this.#serving("take", args);\n if (refused !== null) return refused;\n const { push, at, pieces, bytes } = _RepoLobe.#fields(args) ? args : {};\n if (!_RepoLobe.#text(push) || typeof at !== "number" || typeof pieces !== "number" || !(bytes instanceof Uint8Array))\n return this.error("refused", "a piece names its push, where it stands, of how many, and its bytes");\n const far = this.stamp.asker;\n const last = this.#shaOf(bytes);\n const held = this.cells.get(["in", far]);\n const same = _RepoLobe.#fields(held) && held["push"] === push && held["pieces"] === pieces ? held : null;\n if (same !== null && same["got"] === at + 1 && same["last"] === last) return this.#receive(far);\n const named = _RepoLobe.#fields(held) && held["push"] === push;\n const fresh = {\n push,\n pieces,\n got: 0,\n run: null,\n head: null,\n failed: null,\n check: null,\n landing: null,\n landed: false\n };\n const begins = !named && at === 0;\n const given = _RepoLobe.#arg(args, "tells");\n const kept = begins ? { ...fresh, ...given === void 0 ? { told: true } : {} } : same !== null && same["got"] === at ? same : null;\n if (kept === null) return this.error("refused", "the pieces of a push come in order");\n const back = begins ? await this.#tellsBy(far, given) : null;\n if (back !== null && typeof back !== "string") return back;\n const put = await this.ask("repos", "put", { at, pieces, bytes, as: `in-${far}` });\n if ("error" in put) return this.#heard(put);\n this.cells.set(["in", far], { ...kept, got: at + 1, last });\n return this.#receive(far);\n }\n async taken(args) {\n const refused = this.#serving("taken", args);\n if (refused !== null) return refused;\n const far = this.stamp.asker;\n const kept = this.cells.get(["in", far]);\n if (!_RepoLobe.#fields(kept)) return this.error("refused", "no push is coming");\n const ended = await this.#endOf(far, kept);\n if (ended !== null) return ended;\n await this.#check();\n await this.#receive(far);\n const now = this.cells.get(["in", far]);\n const doing = this.#repo()?.["doing"];\n const job = _RepoLobe.#text(doing) ? this.cells.get(["job", doing]) : void 0;\n const waiting = _RepoLobe.#fields(now) && now["run"] === null && now["got"] === now["pieces"];\n const waits = waiting && _RepoLobe.#fields(job) ? { waits: `the repo runs a ${_RepoLobe.#shown(job["kind"])} first` } : {};\n return { ready: false, ...waits };\n }\n async #receiveWaiting() {\n for (const { key } of this.#all(["in"])) {\n const far = key[1];\n if (_RepoLobe.#text(far)) await this.#receive(far);\n }\n }\n async #clear(as) {\n const asked = await this.ask("repos", "clear", { as });\n if ("error" in asked && asked.error.code === "busy") this.cells.set(["uncleared", as], null);\n else if (this.cells.get(["uncleared", as]) !== void 0) this.cells.delete(["uncleared", as]);\n }\n async #unclear() {\n for (const { key } of this.#all(["uncleared"])) {\n const as = key[1];\n if (_RepoLobe.#text(as)) await this.#clear(as);\n }\n }\n async #check() {\n await this.#unclear();\n const doing = this.#repo()?.["doing"];\n if (!_RepoLobe.#text(doing)) return;\n const checked = await this.ask("repos", "check", {});\n if ("error" in checked || !_RepoLobe.#fields(checked.result)) return;\n const { doing: running, lost, last } = checked.result;\n const held = this.cells.get(["job", doing]);\n if (running === doing || !_RepoLobe.#fields(held)) return;\n if (_RepoLobe.#fields(last) && last["job"] === doing) {\n const { code, out, err } = last;\n if (typeof code === "number" && typeof out === "string" && typeof err === "string") {\n await this.#jobEnded(await this.nerves.read(), doing, held, code, out, err);\n return;\n }\n }\n if (Array.isArray(lost) && lost.includes(doing)) return;\n const kept = await this.ask("repos", "job", { job: doing });\n const ended = "result" in kept ? _RepoLobe.#arg(_RepoLobe.#arg(kept.result, "ended") ?? null, "code") : void 0;\n if ("result" in kept && typeof ended !== "number") return;\n const whole = ended === 0;\n if (whole) {\n this.cells.delete(["undo"]);\n this.cells.set(["owed"], true);\n }\n const why = whole ? "the jailer ended this job whole, and its word of the end never came: its output is lost" : "the jailer runs this job no more, and its word of the end never came";\n await this.#jobEnded(await this.nerves.read(), doing, held, -1, "", why);\n await this.#awaiting();\n }\n async #tellsBy(far, invitation) {\n await this.#untold(far);\n if (!_RepoLobe.#text(invitation)) return null;\n const placeholder = _RepoLobe.#backUnder(_RepoLobe.#tells, far);\n const note = { repo: this.#repo()?.["name"] ?? null, tells: far };\n const accepted = await this.ask("mouth", "accept", { invitation, placeholder, note });\n if ("error" in accepted)\n return this.error(accepted.error.code, `the standing back was not taken: ${accepted.error.message}`);\n return placeholder;\n }\n async #untold(far, prefix = _RepoLobe.#tells) {\n const placeholder = _RepoLobe.#backUnder(prefix, far);\n const held = (await this.#relations()).find((one) => one.side === "standing" && one.placeholder === placeholder);\n if (held !== void 0) await this.#unlink({ placeholder, far: held.far });\n }\n async #tellEnds() {\n for (const { key, value } of this.#all(["in"])) {\n const far = key[1];\n if (typeof far !== "string" || !_RepoLobe.#fields(value) || value["told"] === true) continue;\n const told = await this.#endOf(far, value);\n if (told === null) continue;\n this.cells.set(key, { ...value, told: true });\n await this.ask(_RepoLobe.#backUnder(_RepoLobe.#tells, far), "done", told);\n }\n }\n async #endOf(far, kept) {\n const landed = kept["landed"] === true;\n const failed = kept["failed"];\n if (!landed && !_RepoLobe.#text(failed)) return null;\n const checked = kept["check"] ?? null;\n const scoped = checked !== null && await this.#scopeFor(far) !== null;\n const check = scoped ? { code: _RepoLobe.#arg(checked, "code") ?? null } : checked;\n const head = kept["head"];\n const ended = landed ? { code: 0, out: _RepoLobe.#text(head) ? `${head}\n` : "", err: "" } : { code: 1, out: "", err: _RepoLobe.#shown(failed) };\n return { job: kept["push"] ?? null, kind: "push", ...ended, check };\n }\n async #receive(far) {\n const kept = this.cells.get(["in", far]);\n const repo = this.#repo();\n if (!_RepoLobe.#fields(kept) || kept["got"] !== kept["pieces"] || kept["run"] !== null) return null;\n if (repo === null || _RepoLobe.#text(repo["doing"])) return null;\n const scope = await this.#scopeFor(far);\n const given = { as: `in-${far}`, pieces: kept["pieces"] ?? 1, ...scope === null ? {} : { scope } };\n const begun = await this.#begin("bring", given, { for: far }, { asker: far });\n if ("job" in begun) this.cells.set(["in", far], { ...kept, run: begun.job });\n return null;\n }\n async #served(far, kind, why, out) {\n const key = kind === "bundle" || kind === "cut" ? ["out", far] : ["in", far];\n const kept = this.cells.get(key);\n if (!_RepoLobe.#fields(kept)) return;\n const [first = "", second = "", third = ""] = out.trim().split("\\n");\n if (kind === "cut") return this.#cutGiven(far, kept, why);\n if (kind === "bundle") {\n this.cells.set(key, {\n ...kept,\n pieces: why === null ? Number(first) : null,\n head: second || null,\n failed: why\n });\n return;\n }\n if (kind === "bring") return this.#pushBrought(far, kept, why, first, second, third);\n if (kind === "land") return this.#pushLanded(far, kept, why, out);\n const repo = this.#repo();\n if (kind !== "head") return void 0;\n if (why === null && second === "holds" && repo !== null) this.cells.set(["repo"], { ...repo, rebuilds: null });\n this.cells.set(key, { ...kept, landed: true });\n return void 0;\n }\n async #cutGiven(far, kept, why) {\n if (why !== null) {\n this.cells.set(["out", far], { ...kept, failed: why });\n return;\n }\n const piece = typeof kept["piece"] === "number" ? { piece: kept["piece"] } : {};\n const given = { since: kept["since"] ?? null, as: `out-${far}`, cut: true, ...piece };\n const begun = await this.#begin("bundle", given, { for: far }, { asker: far });\n this.cells.set(["out", far], "job" in begun ? { ...kept, run: begun.job } : { ...kept, failed: begun.message });\n }\n async #pushBrought(far, kept, why, head, how, tip) {\n const key = ["in", far];\n if (why !== null) {\n this.cells.set(key, { ...kept, failed: why });\n return;\n }\n if (how === "held") {\n this.cells.set(key, { ...kept, head, landed: true });\n return;\n }\n const check = await this.#conform(`in-${far}`, head, true, far);\n this.cells.set(key, { ...kept, head, check, ...how === "graft" && _RepoLobe.#text(tip) ? { tip } : {} });\n if ("code" in check) await this.#verdict(far);\n }\n async #pushLanded(far, kept, why, out) {\n const tip = kept["tip"];\n const head = _RepoLobe.#text(tip) ? tip : _RepoLobe.#headOf(out);\n const rebuilds = this.#repo()?.["rebuilds"];\n const proving = why === null && _RepoLobe.#text(rebuilds) && "job" in await this.#begin("head", { contains: rebuilds }, { for: far }, { asker: far });\n const landed = why !== null ? { failed: why } : proving ? { head } : { head, landed: true };\n this.cells.set(["in", far], { ...kept, ...landed });\n }\n async #conform(as, head, push, asker) {\n const script = this.#gateScript();\n const gated = push && this.#gates().push === "on" && _RepoLobe.#text(script);\n const given = {\n as,\n head,\n ...this.#checks(),\n ...gated ? { script } : {}\n };\n const begun = await this.#begin("check", given, { check: as }, { asker, method: "conform" });\n if ("job" in begun) return { job: begun.job };\n return { code: 1, out: "", err: `the check did not begin: ${begun.message}` };\n }\n #checks() {\n if (this.#holdsScope()) return { parts: _RepoLobe.parts, scoped: true };\n const conform = this.cells.get(["conform"]);\n return { parts: _RepoLobe.parts, ..._RepoLobe.#text(conform) ? { conform } : {} };\n }\n async #checked(as, check) {\n const tail = {\n ...check,\n out: _RepoLobe.#last(_RepoLobe.#shown(check["out"])),\n err: _RepoLobe.#last(_RepoLobe.#shown(check["err"]))\n };\n if (as === "pull") {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync) || sync["stage"] !== "checking") return;\n const checked = { ...sync, check: tail };\n this.cells.set(["sync"], checked);\n return this.#checkedPull(checked, tail);\n }\n const far = as.startsWith("in-") ? as.slice(3) : "";\n const kept = this.cells.get(["in", far]);\n if (!_RepoLobe.#fields(kept)) return;\n this.cells.set(["in", far], { ...kept, check: tail });\n return this.#verdict(far);\n }\n static #last(text) {\n const last = text.slice(-_RepoLobe.#tail);\n return /^[\\uDC00-\\uDFFF]/.test(last) ? last.slice(1) : last;\n }\n async #verdict(far) {\n const kept = this.cells.get(["in", far]);\n const check = _RepoLobe.#arg(kept, "check");\n if (!_RepoLobe.#fields(kept) || !_RepoLobe.#fields(check) || !("code" in check)) return;\n if (check["code"] !== 0) {\n this.cells.set(["in", far], {\n ...kept,\n failed: _RepoLobe.#refusalOf(check, await this.#scopeFor(far) !== null)\n });\n return;\n }\n if (_RepoLobe.#text(kept["landing"]) || _RepoLobe.#text(this.#repo()?.["doing"])) return;\n const as = `in-${far}`;\n const begun = await this.#begin("land", { as }, { for: far }, { asker: far });\n if ("job" in begun) this.cells.set(["in", far], { ...kept, landing: begun.job });\n }\n static #refusalOf(check, bare = false) {\n if (bare) return "its check is red";\n const said = `${_RepoLobe.#shown(check["out"])}\n${_RepoLobe.#shown(check["err"])}`.trim();\n const tail = said.slice(-_RepoLobe.#tail);\n return `its check is red:\n${tail || `it ended ${typeof check["code"] === "number" ? check["code"] : "unread"}`}`;\n }\n async #authoring(repo) {\n const writers = (await this.#given()).some(({ note }) => _RepoLobe.#kindOf(note) === "writer");\n if (!writers) return null;\n if (this.cells.get(["author"]) !== this.stamp.asker)\n return this.error("refused", "far writers push to this lobe: only its author commits beside it");\n if (_RepoLobe.#text(repo["rebuilds"])) return this.error("refused", "the lobe rebuilds: it is pushed whole first");\n return null;\n }\n #filesOf(files) {\n if (files === void 0) return {};\n if (!_RepoLobe.#fields(files)) return null;\n const all = Object.entries(files);\n if (all.length > this.#most() || all.some(([path, text]) => path === "" || typeof text !== "string")) return null;\n return files;\n }\n #pathsOf(paths) {\n if (paths === void 0) return [];\n if (!Array.isArray(paths) || paths.length < 1 || paths.length > this.#most()) return null;\n const named = paths.flatMap((one) => typeof one === "string" ? [one] : []);\n const fit = (one) => one.split("/").every((name) => _RepoLobe.#entry.test(name));\n return named.length === paths.length && named.every(fit) ? named : null;\n }\n async commit(args) {\n const refused = this.#refusal("commit", args);\n if (refused !== null) return refused;\n const message = _RepoLobe.#arg(args, "message");\n const files = this.#filesOf(_RepoLobe.#arg(args, "files"));\n if (!_RepoLobe.#text(message)) return this.error("refused", "a commit holds its message");\n if (files === null)\n return this.error("refused", `a commit\'s files are each a path and its text, ${this.#most()} at most`);\n const paths = this.#pathsOf(_RepoLobe.#arg(args, "paths"));\n if (paths === null)\n return this.error("refused", `a commit\'s paths are each a file or a folder of the repo, ${this.#most()} at most`);\n if (paths.length > 0 && Object.keys(files).length > 0)\n return this.error("refused", "a commit writes files or takes paths, not both");\n const executable = _RepoLobe.#arg(args, "executable") ?? [];\n if (!Array.isArray(executable) || executable.some((path) => typeof path !== "string" || !Object.hasOwn(files, path)))\n return this.error("refused", "what a commit makes executable are paths among its files");\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n const unauthored = await this.#authoring(ready.repo);\n if (unauthored !== null) return unauthored;\n const gating = this.#commitGate(args);\n if (typeof gating !== "boolean") return gating;\n if (_RepoLobe.#text(ready.repo["doing"])) {\n await this.#check();\n return this.error("refused", `the repo runs ${ready.repo["doing"]} already`);\n }\n const written = Object.keys(files);\n const before = written.length === 0 ? null : await this.#before(written);\n if (before !== null && "code" in before) return before;\n if (before !== null) this.cells.set(["undo"], executable.length === 0 ? before : { ...before, executable });\n else if (paths.length > 0) this.cells.set(["undo"], { files: [], dirs: [], paths });\n for (const [path, text] of Object.entries(files)) {\n const wrote = await this.ask("repos", "write", { path, text: text ?? "" });\n if ("error" in wrote) return this.error(wrote.error.code, await this.#undone(`${path}: ${wrote.error.message}`));\n }\n const script = this.#gateScript();\n const begun = !gating || !_RepoLobe.#text(script) ? await this.#begin("commit", this.#committing(message), null) : (\n await this.#gating(message, { script, install: true, gate: true })\n );\n if ("job" in begun) return begun;\n return this.error(begun.code, await this.#undone(begun.message));\n }\n #committing(message) {\n const kept = this.cells.get(["undo"]) ?? null;\n const [executable, paths] = [_RepoLobe.#arg(kept, "executable"), _RepoLobe.#arg(kept, "paths")];\n return {\n message,\n ...executable === void 0 ? {} : { executable },\n ...paths === void 0 ? {} : { paths },\n ...this.#checks()\n };\n }\n async #gating(message, gate) {\n if (!this.#keyed()) return this.#begin("commit", gate, null, { method: "run", more: { gating: message } });\n const more = { running: gate, commits: message };\n return this.#begin("commit", { set: await this.#keys() }, null, { method: "secrets", more });\n }\n async #before(paths) {\n const files = [];\n const stands = new Map();\n const dirs = [];\n for (const path of paths) {\n const read = await this.ask("repos", "read", { path });\n if ("error" in read) {\n if (read.error.code !== "absent") return this.error(read.error.code, `${path}: ${read.error.message}`);\n files.push({ path, was: null });\n } else {\n const was = _RepoLobe.#arg(read.result, "text");\n if (typeof was !== "string") return this.error("refused", `${path}: it holds no text`);\n files.push({ path, was });\n }\n const names = path.split("/");\n for (let at = 1; at < names.length; at += 1) {\n const dir = names.slice(0, at).join("/");\n if (!stands.has(dir)) {\n const parent = at === 1 ? true : stands.get(names.slice(0, at - 1).join("/"));\n const listed = parent ? await this.ask("repos", "list", { path: dir }) : null;\n stands.set(dir, listed !== null && !("error" in listed));\n }\n if (stands.get(dir) === false && !dirs.includes(dir)) dirs.push(dir);\n }\n }\n return { files, dirs };\n }\n async #undone(why) {\n const undo = this.cells.get(["undo"]);\n if (!_RepoLobe.#fields(undo)) return why;\n const [files, dirs] = [undo["files"], undo["dirs"]];\n const lost = [];\n for (const one of Array.isArray(files) ? files : []) {\n const path = _RepoLobe.#arg(one, "path");\n const was = _RepoLobe.#arg(one, "was");\n if (typeof path !== "string") continue;\n const put = typeof was === "string" ? await this.ask("repos", "write", { path, text: was }) : await this.ask("repos", "erase", { path });\n if ("error" in put && !(was === null && put.error.code === "absent")) lost.push(path);\n }\n const made = Array.isArray(dirs) ? dirs.filter((dir) => typeof dir === "string") : [];\n for (const path of made.toReversed()) await this.ask("repos", "erase", { path });\n this.cells.delete(["undo"]);\n if (!Array.isArray(files) || files.length === 0) return why;\n return lost.length === 0 ? `${why.trimEnd()}\nthe files it wrote are put back as they were before the ask` : `${why.trimEnd()}\nthe files it wrote could not all be put back: ${lost.join(", ")}`;\n }\n #commitGate(args) {\n const asked = _RepoLobe.#arg(args, "gate");\n const { commit } = this.#gates();\n if (asked === false && commit === "mandatory")\n return this.error("refused", "the setting on commit is mandatory: no commit skips the gate");\n return asked === true || commit !== "off" && asked !== false;\n }\n async #gated(held, run, code, out, err) {\n const repo = this.#repo();\n if (repo !== null) this.cells.set(["repo"], { ...repo, doing: null });\n const message = _RepoLobe.#shown(held["gating"]);\n const asker = _RepoLobe.#text(held["asker"]) ? held["asker"] : _RepoLobe.#owner;\n const first = _RepoLobe.#arg(held["step"] ?? null, "ran");\n const holds = _RepoLobe.#text(first) ? first : run;\n if (holds !== run) this.cells.delete(["job", run]);\n if (code === 0 || code === 3 && err.includes("holds no script")) {\n const begun = await this.#begin("commit", this.#committing(message), { commit: holds }, { asker });\n if ("job" in begun) return null;\n return this.#commitEnded(holds, 1, "", await this.#undone(`the commit is refused: ${begun.message}`));\n }\n const why = await this.#undone(`the commit is refused: the gate is red\n${_RepoLobe.#last(err)}`);\n await this.#commitEnded(holds, code, _RepoLobe.#last(out), why);\n return null;\n }\n async #commitEnded(run, code, out, err, more = {}) {\n const first = this.cells.get(["job", run]);\n if (!_RepoLobe.#fields(first)) return null;\n const { gating: _, running: __, commits: ___, ...kept } = first;\n this.cells.set(["job", run], { ...kept, ended: { run, code, out, err, ...more, at: this.stamp.time } });\n await this.#ended(kept, code, out, err, more);\n return null;\n }\n status(args) {\n return this.#work("status", args, {});\n }\n log(args) {\n const most = _RepoLobe.#arg(args, "most");\n return this.#work("log", args, most === void 0 ? {} : { most });\n }\n discard(args) {\n return this.#work("discard", args, {});\n }\n async run(args) {\n const script = _RepoLobe.#arg(args, "script");\n const install = _RepoLobe.#arg(args, "install") ?? false;\n const words = _RepoLobe.#argsOf(_RepoLobe.#arg(args, "args"));\n if (!_RepoLobe.#text(script) || !_RepoLobe.#script.test(script))\n return this.error("refused", "a run names a script of the repo\'s package");\n if (typeof install !== "boolean") return this.error("refused", "install is true or false");\n if (words === null)\n return this.error("refused", `a run\'s args are texts, at most ${_RepoLobe.#argsMost}, none holding a NUL`);\n const gate = script === this.#gateScript() ? { gate: true } : {};\n const given = { script, ...words.length === 0 ? {} : { args: words }, install, ...gate };\n const scripts = _RepoLobe.#arg(this.stamp.occupant?.note, "scripts");\n if (this.#role() === "runner" && !(Array.isArray(scripts) && scripts.includes(script)))\n return this.error("refused", `the runner runs ${script} not`);\n return this.#keyed() ? this.#keysFirst("run", args, given) : this.#work("run", args, given);\n }\n static #argsOf(args) {\n if (args === void 0) return [];\n if (!Array.isArray(args) || args.length > _RepoLobe.#argsMost) return null;\n const all = args.flatMap(\n (one) => typeof one === "string" && one.length <= _RepoLobe.#argLongest && !one.includes("\\0") ? [one] : []\n );\n return all.length === args.length ? all : null;\n }\n async #writtenThen(held, run, code, err) {\n const repo = this.#repo();\n if (repo !== null) this.cells.set(["repo"], { ...repo, doing: null });\n const asker = _RepoLobe.#text(held["asker"]) ? held["asker"] : _RepoLobe.#owner;\n const kind = "run";\n const commits = held["kind"] === "commit";\n if (code !== 0) {\n const why = `its secret file was not written: ${err}`;\n if (commits) await this.#commitEnded(run, code, "", await this.#undone(`the commit is refused: ${why}`));\n else await this.#workEnded(run, kind, code, "", why);\n return null;\n }\n if (Object.keys(await this.#keys()).length > 0) this.cells.set(["env"], true);\n else this.cells.delete(["env"]);\n const running = _RepoLobe.#fields(held["running"]) ? held["running"] : {};\n if (commits) {\n const more = { gating: _RepoLobe.#shown(held["commits"]) };\n const gate = await this.#begin("commit", running, { ran: run }, { asker, method: "run", more });\n if ("job" in gate) return null;\n await this.#commitEnded(run, 1, "", await this.#undone(`the commit is refused: ${gate.message}`));\n return null;\n }\n const begun = await this.#begin(kind, running, { ran: run }, { asker });\n if ("job" in begun) return null;\n await this.#workEnded(run, kind, 1, "", `the ${kind} did not begin: ${begun.message}`);\n return null;\n }\n async #workEnded(run, kind, code, out, err, more = {}) {\n const first = this.cells.get(["job", run]);\n if (!_RepoLobe.#fields(first)) return;\n const { running: _, ...kept } = first;\n this.cells.set(["job", run], { ...kept, ended: { run, code, out, err, ...more, at: this.stamp.time } });\n await this.#ended({ ...kept, kind }, code, out, err, more);\n }\n #torn(read) {\n const all = "result" in read && Array.isArray(read.result) ? read.result : [];\n const ends = new Set(all.map((wire) => _RepoLobe.#arg(wire, "termination")));\n for (const { key } of this.#all(["back"])) if (!ends.has(key[1])) this.cells.delete(key);\n }\n async #credentials() {\n if (this.#all(["credential"]).length === 0 && this.#all(["token"]).length === 0) return [];\n const kept = (await this.#relations()).flatMap((one) => {\n const secret = _RepoLobe.#arg(one.note, "credential");\n return one.side === "standing" && _RepoLobe.#text(secret) ? [{ secret, far: one.far, placeholder: one.placeholder }] : [];\n });\n return kept.toSorted((a, b) => _RepoLobe.#order(a.secret, b.secret));\n }\n async setToken(args) {\n const refused = this.#refusal("setToken", {});\n if (refused !== null) return refused;\n const name = _RepoLobe.#arg(args, "name");\n const value = _RepoLobe.#arg(args, "value");\n if (!_RepoLobe.#text(name) || !_RepoLobe.#key.test(name))\n return this.error("refused", "a token\'s name is an environment variable\'s name");\n if (value !== null && (typeof value !== "string" || /[\\n\\r\\0]/.test(value)))\n return this.error("refused", "a token is one line of text, or null to remove it");\n if ((await this.#credentials()).some((one) => one.secret === name))\n return this.error("refused", "a credential keeps that name: drop it");\n if (value !== null && this.cells.get(["secret", name]) === void 0 && this.#all(["secret"]).length >= this.#most())\n return this.error("refused", `a copy keeps ${this.#most()} keys at most`);\n if (value === null) this.cells.delete(["secret", name]);\n else this.cells.set(["secret", name], value);\n return null;\n }\n async #giveUp(held) {\n await this.ask("mouth", "drop", { far: held.far });\n if (_RepoLobe.#text(held.placeholder)) await this.nerves.unwire(held.placeholder);\n }\n async credential(args) {\n const refused = this.#refusal("credential", args);\n if (refused !== null) return refused;\n const secret = _RepoLobe.#arg(args, "secret");\n const invitation = _RepoLobe.#arg(args, "invitation");\n const wired = _RepoLobe.#arg(args, "placeholder");\n if (!_RepoLobe.#text(secret) || !_RepoLobe.#issued.test(secret))\n return this.error(\n "refused",\n "a credential\'s secret is an environment variable\'s name in capitals, its words joined by single underscores"\n );\n const cap = await this.#cap("within", _RepoLobe.#issuerWithin);\n if (typeof cap !== "number") return cap;\n const named = _RepoLobe.#arg(args, "within");\n if (typeof named === "number" && named > cap)\n return this.error(\n "refused",\n `an issuer may keep a credential waiting ${cap} ms at most, a cap an owner\'s word moves`\n );\n const within = typeof named === "number" ? named : cap;\n const held = (await this.#credentials()).find((one) => one.secret === secret);\n if (held !== void 0) {\n if (invitation !== void 0 || wired !== void 0)\n return this.error(\n "refused",\n "a standing keeps that secret already: drop it, or ask again with no invitation and no placeholder"\n );\n return this.#askIssuer(secret, held.far, held.placeholder, "kept", within);\n }\n if (invitation !== void 0 && wired !== void 0)\n return this.error("refused", "a credential is taken by an invitation or by a placeholder, not both");\n if (this.cells.get(["secret", secret]) !== void 0)\n return this.error("refused", "a token keeps that name: remove it by setToken");\n if (_RepoLobe.#text(wired)) return this.#takenOver(secret, wired, within);\n if (!_RepoLobe.#text(invitation)) return this.error("refused", "an invitation or a placeholder is named");\n const placeholder = `credential-${secret.toLowerCase().replaceAll("_", "-")}`;\n const given = _RepoLobe.#arg(args, "note");\n const note = given ?? { repo: this.#repo()?.["name"] ?? null, credential: secret };\n const accepted = await this.ask("mouth", "accept", { invitation, placeholder, note });\n if ("error" in accepted) return this.#result(accepted);\n const far = _RepoLobe.#arg(accepted.result, "far");\n if (!_RepoLobe.#text(far)) return this.error("refused", "the mouth named no far organism");\n const noted = await this.#noted(far, { credential: secret });\n if (noted !== null) {\n await this.#giveUp({ far, placeholder });\n return this.error("refused", noted);\n }\n return this.#askIssuer(secret, far, placeholder, "accepted", within);\n }\n async #takenOver(secret, placeholder, within) {\n const standing = (await this.#relations()).find(\n (one) => one.side === "standing" && one.placeholder === placeholder\n );\n if (standing === void 0) return this.error("refused", `the placeholder ${placeholder} is wired to no standing`);\n if (_RepoLobe.#text(_RepoLobe.#arg(standing.note, "credential")))\n return this.error("refused", "that standing keeps another secret already");\n const noted = await this.#noted(standing.far, { credential: secret });\n if (noted !== null) return this.error("refused", noted);\n return this.#askIssuer(secret, standing.far, placeholder, "wired", within);\n }\n #askAgain(asked, since, within, silent = false) {\n const ready = "result" in asked ? _RepoLobe.#arg(asked.result, "ready") : void 0;\n silent &&= "error" in asked && _RepoLobe.#waits.includes(asked.error.code);\n if (!silent && !(typeof ready === "number" && Number.isSafeInteger(ready))) return null;\n const soonest = this.stamp.time + _RepoLobe.#spell;\n const next = typeof ready === "number" ? Math.max(ready, soonest) : soonest;\n return next <= since + within ? next : null;\n }\n #keptToken(far, cell, result) {\n const value = _RepoLobe.#arg(result, "value");\n const url = _RepoLobe.#arg(result, "url");\n if (!_RepoLobe.#text(value) || /[\\n\\r\\0]/.test(value)) return false;\n this.cells.set(["token", far], value);\n const { failed: _, next: __, expires: ___, renews: ____, since: _____, within: ______, ...rest } = cell;\n const where = _RepoLobe.#text(url) ? { url } : {};\n const expires = _RepoLobe.#arg(result, "expires");\n const life = typeof expires === "number" && Number.isInteger(expires) ? expires - this.stamp.time : 0;\n const ends = life > 0 ? { expires: Number(expires), renews: Number(expires) - Math.floor(life / 10) } : {};\n this.cells.set(["credential", far], { ...rest, pending: false, ...where, ...ends });\n return true;\n }\n #renewedAgain(expires) {\n const left = typeof expires === "number" ? Math.floor((expires - this.stamp.time) / 2) : 0;\n return this.stamp.time + Math.max(_RepoLobe.#minute, left);\n }\n async #renewAt(at, ringing) {\n const set = this.cells.get(["renews"]);\n if (typeof set === "number" && set > this.stamp.time && set <= at) return false;\n this.cells.set(["renews"], at);\n const when = Math.max(at, this.stamp.time + _RepoLobe.#spell);\n if (!ringing) await this.#alarm({ at: when, method: "renew", args: {} });\n return true;\n }\n #nextRenewal() {\n let next = null;\n for (const { value } of this.#all(["credential"])) {\n const renews = _RepoLobe.#arg(value, "renews");\n if (typeof renews !== "number" || _RepoLobe.#arg(value, "pending") === true) continue;\n if (next === null || renews < next) next = renews;\n }\n return next;\n }\n async #askIssuer(secret, far, placeholder, how, within) {\n if (!_RepoLobe.#text(placeholder)) return this.error("refused", "the standing has no relation");\n const cell = this.cells.get(["credential", far]);\n const before = _RepoLobe.#fields(cell) ? cell : {};\n const asked = await this.ask(placeholder, "credential", {});\n const next = this.#askAgain(asked, this.stamp.time, within);\n if (next !== null) {\n this.cells.set(["credential", far], { ...before, pending: true, since: this.stamp.time, within, next });\n const set = await this.#alarm({ at: next, method: "renew", args: {} });\n return "error" in set ? this.#result(set) : { secret, pending: true };\n }\n if (!("error" in asked) && this.#keptToken(far, before, asked.result)) {\n const renews = this.#nextRenewal();\n if (renews !== null) await this.#renewAt(renews, false);\n return { secret };\n }\n if (how === "accepted") await this.#giveUp({ far, placeholder });\n if (how === "wired") await this.#noted(far, null);\n return "error" in asked ? this.error(asked.error.code, asked.error.message) : this.error("refused", "the issuer gave no secret of one line");\n }\n async #renewOne(far, value) {\n const placeholder = (await this.#endOfFar(far))?.placeholder;\n const asked = _RepoLobe.#text(placeholder) ? await this.ask(placeholder, "credential", {}) : { error: { code: "refused", message: "the standing has no relation" } };\n if ("result" in asked && this.#keptToken(far, value, asked.result)) return "given";\n const ready = "result" in asked ? _RepoLobe.#arg(asked.result, "ready") : void 0;\n const cap = typeof ready === "number" ? await this.#cap("within", _RepoLobe.#issuerWithin) : _RepoLobe.#issuerWithin;\n const within = typeof cap === "number" ? cap : _RepoLobe.#issuerWithin;\n const next = this.#askAgain(asked, this.stamp.time, within);\n if (next !== null) {\n this.cells.set(["credential", far], { ...value, pending: true, since: this.stamp.time, within, next });\n return "pending";\n }\n const why = "error" in asked ? asked.error.message : "it gave no secret of one line";\n const failed = `the issuer renewed no secret: ${why}`;\n this.cells.set(["credential", far], { ...value, failed, renews: this.#renewedAgain(value["expires"]) });\n return "failed";\n }\n async #issuedAgain(far, value) {\n const since = typeof value["since"] === "number" ? value["since"] : this.stamp.time;\n const within = typeof value["within"] === "number" ? value["within"] : _RepoLobe.#issuerWithin;\n const placeholder = (await this.#endOfFar(far))?.placeholder;\n const asked = _RepoLobe.#text(placeholder) ? await this.ask(placeholder, "credential", {}) : { error: { code: "refused", message: "the standing has no relation" } };\n const { next: _, ...rest } = value;\n if ("result" in asked && this.#keptToken(far, rest, asked.result)) return "given";\n const next = this.#askAgain(asked, since, within, true);\n if (next !== null) {\n this.cells.set(["credential", far], { ...rest, next });\n return "pending";\n }\n const ready = "result" in asked ? _RepoLobe.#arg(asked.result, "ready") : void 0;\n const why = "error" in asked ? asked.error.message : typeof ready === "number" ? "it is made only after then" : "it gave no secret of one line";\n const failed = `the issuer gave no secret in ${within} ms: ${why}`;\n const again = typeof rest["expires"] === "number" ? { renews: this.#renewedAgain(rest["expires"]) } : {};\n const { since: ___, within: ____, ...left } = rest;\n this.cells.set(["credential", far], { ...left, pending: false, failed, ...again });\n return "failed";\n }\n async renew() {\n let soonest = null;\n const waiting = (far) => {\n const next = _RepoLobe.#arg(this.cells.get(["credential", far]) ?? null, "next");\n if (typeof next === "number" && (soonest === null || next < soonest)) soonest = next;\n };\n for (const { key, value } of this.#all(["credential"])) {\n const far = key[1];\n if (typeof far !== "string" || !_RepoLobe.#fields(value)) continue;\n if (value["pending"] !== true) {\n const renews2 = value["renews"];\n if (typeof renews2 !== "number" || this.stamp.time < renews2) continue;\n if (await this.#renewOne(far, value) === "pending") waiting(far);\n continue;\n }\n if (typeof value["next"] === "number" && this.stamp.time < value["next"]) {\n waiting(far);\n continue;\n }\n if (await this.#issuedAgain(far, value) === "pending") waiting(far);\n }\n if (soonest !== null) return { again: soonest };\n const renews = this.#nextRenewal();\n if (renews === null || !await this.#renewAt(renews, true)) return null;\n return { again: Math.max(renews, this.stamp.time + _RepoLobe.#spell) };\n }\n async #keys() {\n const values = {};\n for (const { key, value } of this.#all(["secret"]))\n if (typeof key[1] === "string" && typeof value === "string") values[key[1]] = value;\n for (const { secret, far } of await this.#credentials()) {\n const token = this.cells.get(["token", far]);\n if (typeof token === "string") values[secret] = token;\n }\n return values;\n }\n #keyed() {\n return this.cells.get(["env"]) !== void 0 || this.#all(["secret"]).length > 0 || this.#all(["token"]).length > 0;\n }\n #masked(text) {\n let shown = text;\n for (const { value } of [...this.#all(["secret"]), ...this.#all(["token"])])\n if (typeof value === "string" && value.length > 0) shown = shown.split(value).join("[secret]");\n return shown;\n }\n async #keysFirst(kind, args, given) {\n const refused = this.#refusal(kind, args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n return this.#begin(kind, { set: await this.#keys() }, null, { method: "secrets", more: { running: given } });\n }\n async #work(kind, args, given, begun = {}) {\n const refused = this.#refusal(kind, args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n return this.#begin(kind, given, null, begun);\n }\n async read(args) {\n const refused = this.#refusal("read", args);\n if (refused !== null) return refused;\n const paths = _RepoLobe.#arg(args, "paths");\n if (paths !== void 0) {\n const lone = _RepoLobe.#arg(args, "path") === void 0 && _RepoLobe.#arg(args, "first") === void 0;\n if (!lone || !Array.isArray(paths) || paths.length < 1)\n return this.error("refused", "paths are one file or more, without path or first");\n return this.#result(await this.ask("repos", "read", { paths }));\n }\n const first = _RepoLobe.#arg(args, "first");\n const path = _RepoLobe.#arg(args, "path") ?? null;\n return this.#result(await this.ask("repos", "read", first === void 0 ? { path } : { path, first }));\n }\n async list(args) {\n const refused = this.#refusal("list", args);\n if (refused !== null) return refused;\n const path = _RepoLobe.#arg(args, "path");\n return this.#result(await this.ask("repos", "list", path === void 0 ? {} : { path }));\n }\n async stop(args) {\n const refused = this.#refusal("stop", args);\n if (refused !== null) return refused;\n const doing = this.#repo()?.["doing"];\n const held = _RepoLobe.#text(doing) ? this.cells.get(["job", doing]) : void 0;\n const sync = this.cells.get(["sync"]);\n if (_RepoLobe.#fields(sync)) {\n const kind = _RepoLobe.#shown(sync["kind"]);\n if (this.stamp.asker !== _RepoLobe.#owner && sync["asker"] !== this.stamp.asker)\n return this.error("refused", `the repo runs another\'s ${kind}`);\n const step = _RepoLobe.#arg(held ?? null, "step");\n const own = _RepoLobe.#arg(step ?? null, "sync") === true;\n if (own && _RepoLobe.#arg(held ?? null, "kind") === "land")\n return this.error("refused", `the ${kind} lands already: it ends once landed`);\n if (own && _RepoLobe.#text(doing) && _RepoLobe.#fields(held))\n this.cells.set(["job", doing], { ...held, step: { stopped: true } });\n await this.#finish(sync, 1, `the ${kind} was stopped`);\n return null;\n }\n if (!_RepoLobe.#text(doing)) return this.error("refused", "the repo runs nothing");\n const asker = _RepoLobe.#arg(held, "asker");\n if (this.stamp.asker !== _RepoLobe.#owner && asker !== this.stamp.asker)\n return this.error("refused", "the repo runs another\'s job");\n return this.#heard(await this.ask("repos", "stop", {}));\n }\n pull(args) {\n return this.#sync("pull", args);\n }\n push(args) {\n return this.#sync("push", args);\n }\n async #sync(kind, args) {\n const refused = this.#refusal(kind, args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n const tag = _RepoLobe.#arg(args, "tag");\n if (tag !== void 0 && !(kind === "pull" && _RepoLobe.#text(tag) && _RepoLobe.#tag.test(tag)))\n return this.error("refused", "a pull names a tag, v and three whole numbers; a push names none");\n if (this.cells.get(["sync"]) !== void 0 && !await this.#stalled())\n return this.error("refused", "the repo pulls or pushes already");\n const on = await this.#standingOn(_RepoLobe.#arg(args, "on"));\n if (!("far" in on)) return on;\n const piece = _RepoLobe.#arg(args, "piece");\n const still = _RepoLobe.#arg(args, "still");\n return this.#start(kind, this.stamp.asker, _RepoLobe.#shown(on["placeholder"]), {\n ...typeof tag === "string" ? { tag } : {},\n ...typeof piece === "number" ? { piece } : {},\n ...typeof still === "number" ? { still } : {},\n ..._RepoLobe.#arg(args, "tells") === true ? { tells: true } : {}\n });\n }\n async #stalled() {\n const sync = this.cells.get(["sync"]);\n return _RepoLobe.#fields(sync) && [..._RepoLobe.#syncFar, "headed"].includes(_RepoLobe.#shown(sync["stage"])) && await this.#stood(sync);\n }\n async #start(kind, asker, on, named = {}) {\n const cap = await this.#cap("still", _RepoLobe.#still);\n if (typeof cap !== "number") return cap;\n const still = named["still"];\n if (typeof still === "number" && still > cap)\n return this.error("refused", `a ${kind} may stand still ${cap} ms at most, a cap an owner\'s word moves`);\n const capped = still === void 0 && cap !== _RepoLobe.#still ? { still: cap } : {};\n const back = await this.#back(asker);\n if (back !== null) return back;\n const job = `${kind}-${this.#nonce()}`;\n const stage = kind === "pull" ? "asking" : "heading";\n const chain = this.#nonce();\n const sync = { job, kind, chain, asker, on, stage, at: 0, pieces: null, moved: this.stamp.time };\n this.cells.set(["sync"], { ...sync, ...named, ...capped });\n const set = await this.#alarm({ at: this.stamp.time, method: "tick", args: { chain } });\n return "error" in set ? this.error(set.error.code, set.error.message) : { job };\n }\n async #cap(name, otherwise) {\n const word = await this.ask("nerves", "limit", { name });\n if ("error" in word) return this.error(word.error.code, word.error.message);\n return typeof word.result === "number" ? Math.min(word.result, _RepoLobe.#lifted) : otherwise;\n }\n async #rung(before) {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync) || !_RepoLobe.#fields(before) || !_RepoLobe.#moved(before, sync)) return;\n const chain = this.#nonce();\n const set = await this.#alarm({ at: this.stamp.time, method: "tick", args: { chain } });\n this.cells.set(["sync"], { ...sync, moved: this.stamp.time, ..."error" in set ? {} : { chain } });\n }\n static #moved(before, after) {\n return after["stage"] !== before["stage"] || after["at"] !== before["at"];\n }\n static #askerOf(sync) {\n return _RepoLobe.#text(sync["asker"]) ? sync["asker"] : _RepoLobe.#owner;\n }\n static #of(sync) {\n return { asker: _RepoLobe.#askerOf(sync) };\n }\n async tick(args) {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync) || sync["chain"] !== _RepoLobe.#arg(args, "chain")) return null;\n const over = sync["on"];\n if (!_RepoLobe.#text(over)) {\n await this.#finish(sync, 1, "the lobe stands on that lobe no more");\n return null;\n }\n const far = _RepoLobe.#syncFar.includes(_RepoLobe.#shown(sync["stage"]));\n if (far && await this.#stood(sync)) return null;\n if (sync["stage"] === "waiting" && _RepoLobe.#text(sync["tells"])) return { again: _RepoLobe.#stillEnds(sync) };\n if (far) await this.#step(sync, over);\n else if (sync["stage"] === "headed") await this.#bundling(sync);\n else await this.#check();\n const kept = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(kept)) return null;\n if (_RepoLobe.#moved(sync, kept)) return { again: this.stamp.time };\n return { again: this.stamp.time + (far || kept["stage"] === "headed" ? _RepoLobe.#every : MINUTE) };\n }\n static #syncFar = ["asking", "getting", "heading", "sending", "waiting"];\n async #step(sync, over) {\n const { stage } = sync;\n if (stage === "asking") await this.#asking(sync, over);\n else if (stage === "getting") await this.#getting(sync, over);\n else if (stage === "heading") await this.#heading(sync, over);\n else if (stage === "sending") await this.#sending(sync, over);\n else if (stage === "waiting") await this.#waiting(sync, over);\n }\n #synced(next) {\n const { waits: _, ...rest } = next;\n this.cells.set(["sync"], { ...rest, moved: this.stamp.time });\n }\n async #asking(sync, over) {\n const repo = this.#repo() ?? {};\n const tag = _RepoLobe.#text(sync["tag"]) ? { tag: sync["tag"] } : {};\n const piece = typeof sync["piece"] === "number" ? { piece: sync["piece"] } : {};\n const asked = await this.ask(over, "give", { since: repo["head"] ?? null, ...tag, ...piece });\n if ("error" in asked) return this.#failedOr(sync, "give", asked.error);\n const { pieces, head, scope } = _RepoLobe.#fields(asked.result) ? asked.result : {};\n if (typeof pieces !== "number") return this.#heardOf(sync);\n if (Array.isArray(scope) && !this.#holdsScope()) {\n if (!_RepoLobe.#text(repo["head"]) && !_RepoLobe.#text(repo["rebuilds"])) {\n const standing = (await this.#held()).find((one) => one.placeholder === sync["on"]);\n const noted = standing === void 0 ? null : await this.#noted(standing.far, { scope: _RepoLobe.#texts(scope) });\n if (noted !== null) return this.#finish(sync, 1, `the scope was not noted: ${noted}`);\n this.cells.set(["repo"], { ...repo, cut: true });\n } else\n return this.#finish(sync, 1, "a scope is held from a lobe’s birth alone, and this lobe holds the repo whole");\n }\n if (pieces === 0) return this.#finish(sync, 0, "");\n this.#synced({ ...sync, stage: "getting", at: 0, pieces, theirs: head ?? null });\n return void 0;\n }\n async #getting(sync, over) {\n const { at, pieces } = sync;\n if (typeof at !== "number" || typeof pieces !== "number") return;\n const asked = await this.ask(over, "piece", { at });\n if ("error" in asked) return this.#failedOr(sync, "piece", asked.error);\n const bytes = _RepoLobe.#arg(asked.result, "bytes");\n if (!(bytes instanceof Uint8Array)) return;\n const put = await this.ask("repos", "put", { at, pieces, bytes, as: "pull" });\n if ("error" in put) return;\n if (at + 1 < pieces) return this.#synced({ ...sync, at: at + 1 });\n const begun = await this.#begin("bring", { as: "pull", pieces }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.#synced({ ...sync, at: pieces, stage: "bringing" });\n else if (!_RepoLobe.#transient(begun.message)) await this.#finish(sync, 1, begun.message);\n }\n async #heading(sync, over) {\n const asked = await this.ask(over, "head", {});\n if ("error" in asked) return this.#failedOr(sync, "head", asked.error);\n const theirs = _RepoLobe.#arg(asked.result, "head") ?? null;\n this.#synced({ ...sync, stage: "headed", theirs: typeof theirs === "string" ? theirs : null });\n }\n async #bundling(sync) {\n const theirs = sync["theirs"];\n const since = typeof theirs === "string" ? theirs : null;\n const piece = typeof sync["piece"] === "number" ? { piece: sync["piece"] } : {};\n const begun = await this.#begin("bundle", { since, as: "push", ...piece }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.#synced({ ...sync, stage: "bundling", theirs: since });\n else if (_RepoLobe.#transient(begun.message) || begun.code === "timeout") this.#heardOf(sync);\n else\n await this.#finish(\n sync,\n 1,\n since === null ? begun.message : `the lobe pushed to holds commits this one does not (${since}): pull first; the jailer said: ${begun.message}`\n );\n }\n async #backOf(sync) {\n const on = _RepoLobe.#shown(sync["on"]);\n await this.#untell(on);\n const waits = typeof sync["still"] === "number" ? sync["still"] : _RepoLobe.#still;\n const note = { repo: this.#repo()?.["name"] ?? null, standing: _RepoLobe.#teller, on };\n const invited = await this.ask("ear", "invite", { waits, lives: null, note });\n if ("error" in invited)\n return this.error(invited.error.code, `no standing back was drawn: ${invited.error.message}`);\n const invitation = _RepoLobe.#arg(invited.result, "invitation");\n return _RepoLobe.#text(invitation) ? invitation : this.error("refused", "the ear drew no invitation back");\n }\n static #transient(message) {\n return message.endsWith(" being cleared") || /^the repo runs .* already$/.test(message) || message === "the lobe keeps no repo";\n }\n async #sending(sync, over) {\n const { job, at, pieces } = sync;\n if (!_RepoLobe.#text(job) || typeof at !== "number" || typeof pieces !== "number") return;\n const sending = at === 0 && sync["tells"] === true ? await this.#drawn(sync) : sync;\n if (sending === null) return;\n const read = await this.ask("repos", "piece", { at, as: "push" });\n const bytes = "result" in read ? _RepoLobe.#arg(read.result, "bytes") : void 0;\n if (!(bytes instanceof Uint8Array)) return;\n const tells = at === 0 && _RepoLobe.#text(sending["tells"]) ? { tells: sending["tells"] } : {};\n const asked = await this.ask(over, "take", { push: job, at, pieces, bytes, ...tells });\n if ("error" in asked) return this.#failedOr(sending, "take", asked.error);\n this.#synced({ ...sending, at: at + 1, ...at + 1 === pieces ? { stage: "waiting" } : {} });\n }\n async #drawn(sync) {\n const tells = await this.#backOf(sync);\n if (typeof tells !== "string") {\n await this.#finish(sync, 1, tells.message);\n return null;\n }\n const drawn = { ...sync, tells };\n this.cells.set(["sync"], drawn);\n return drawn;\n }\n async #told(args) {\n const sync = this.cells.get(["sync"]);\n const on = _RepoLobe.#arg(this.stamp.occupant?.note ?? null, "on");\n const { job, code, err } = _RepoLobe.#fields(args) ? args : {};\n if (!_RepoLobe.#fields(sync) || sync["kind"] !== "push" || sync["stage"] !== "waiting" || sync["on"] !== on || sync["job"] !== job || typeof code !== "number" || typeof err !== "string")\n return this.error("refused", "no such push waits on its end");\n await this.#endHeard(sync, code, err, _RepoLobe.#arg(args, "check") ?? null);\n return null;\n }\n async #endHeard(sync, code, err, check) {\n await this.#finish(sync, code === 0 ? 0 : 1, code === 0 ? "" : err, check === null ? void 0 : check);\n }\n async #waiting(sync, over) {\n const asked = await this.ask(over, "taken", {});\n if ("error" in asked) return this.#failedOr(sync, "taken", asked.error);\n const { code, err, check } = _RepoLobe.#fields(asked.result) ? asked.result : {};\n if (typeof code !== "number" || typeof err !== "string") return this.#heardOf(sync);\n return this.#endHeard(sync, code, err, check ?? null);\n }\n #heardOf(sync) {\n if (sync["waits"] === void 0) return;\n const { waits: _, ...rest } = sync;\n this.cells.set(["sync"], rest);\n }\n async #failedOr(sync, method, error) {\n if (_RepoLobe.#waits.includes(error.code)) return this.#waited(method, error, sync);\n await this.#finish(sync, 1, error.message);\n }\n static #left(kind, stage) {\n if (kind === "push") return stage === "heading" || stage === "headed" ? null : "push";\n return kind === "pull" && stage === "getting" ? "pull" : null;\n }\n async #finish(sync, code, err, check) {\n await this.#finished(sync, code, err, check);\n await this.#owing();\n }\n async #finished(sync, code, err, check) {\n this.cells.delete(["sync"]);\n const { asker, job, kind } = sync;\n const left = _RepoLobe.#left(kind, sync["stage"]);\n if (left !== null) await this.#clear(left);\n const repo = this.#repo();\n const checked = check === void 0 ? {} : { check };\n const synced = { job: job ?? null, kind: kind ?? null, asker: asker ?? null, code, err, ...checked };\n if (repo !== null) this.cells.set(["repo"], { ...repo, synced });\n const out = repo !== null && _RepoLobe.#text(repo["head"]) ? `${repo["head"]}\n` : "";\n const of = sync["of"];\n const init = _RepoLobe.#text(of) ? this.cells.get(["job", of]) : void 0;\n if (_RepoLobe.#text(of) && _RepoLobe.#fields(init) && init["ended"] === null)\n return this.#closed(of, init, code, out, err, checked);\n if (!_RepoLobe.#text(asker) || asker === _RepoLobe.#owner) return;\n const told = { job: job ?? null, kind: kind ?? null, code, out, err, ...checked };\n await this.ask(asker, "done", told, void 0, { letter: { lives: _RepoLobe.#lives } });\n }\n #waited(method, error, next) {\n const kept = this.cells.get(["sync"]);\n const why = `${method}: ${error.code}: ${error.message}`;\n const since = _RepoLobe.#arg(_RepoLobe.#arg(kept, "waits"), "since");\n const waits = { why, since: typeof since === "number" ? since : this.stamp.time };\n this.cells.set(["sync"], { ...next, waits });\n }\n static #stillOn(held) {\n return `its stage ${_RepoLobe.#shown(held["stage"])}, piece ${JSON.stringify(held["at"] ?? null)} of ${JSON.stringify(held["pieces"] ?? null)}`;\n }\n static #stillEnds(held) {\n const moved = typeof held["moved"] === "number" ? held["moved"] : 0;\n return moved + (typeof held["still"] === "number" ? held["still"] : _RepoLobe.#still) + 1;\n }\n async #stood(held) {\n const moved = held["moved"];\n const span = typeof held["still"] === "number" ? held["still"] : _RepoLobe.#still;\n if (typeof moved !== "number" || this.stamp.time - moved <= span) return false;\n if (held["stage"] === "waiting" && _RepoLobe.#text(held["tells"]) && _RepoLobe.#text(held["on"])) {\n await this.#waiting(held, held["on"]);\n if (this.cells.get(["sync"]) === void 0) return true;\n }\n const why = _RepoLobe.#arg(held["waits"], "why");\n const last = _RepoLobe.#text(why) ? `; its last ask ${why}` : "";\n const still = `moved not for ${span} ms: ${_RepoLobe.#stillOn(held)}${last}`;\n await this.#finish(held, 1, `the ${_RepoLobe.#shown(held["kind"])} ${still}`);\n return true;\n }\n};\nexport {\n RepoLobe as default\n};\n';
1243
+ var REPO_SOURCE = 'import { Faculty } from "nervur:faculty";\n\nvar LETTER_LIVES = 864e5;\nvar LOBE_SHARE = 4;\nvar ITEM_SIZE = 1024;\nvar CELLS_RANGE = 1e3;\nvar ARG_LONGEST = 4096;\nvar ARGS_MOST = 64;\nvar RING_PAUSE = 1e3;\nvar TAIL = 4096;\nvar SCOPE_MOST = 16;\nvar STILL = 36e5;\nvar SPELL = 5e3;\nvar WITHIN = 36e5;\nvar MINUTE = 6e4;\n\nvar RepoLobe = class _RepoLobe extends Faculty {\n static #owner = "brain";\n static #library = "library";\n static #lives = LETTER_LIVES;\n static #every = RING_PAUSE;\n static #tail = TAIL;\n static #repoName = /^[a-z](?:[a-z0-9-]|\\.(?=[a-z0-9-])){0,63}$/;\n static #script = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,63}$/;\n static #key = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;\n static #issued = /^(?=.{1,40}$)[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;\n static #spell = SPELL;\n static #issuerWithin = WITHIN;\n static #minute = MINUTE;\n static #argsMost = ARGS_MOST;\n static #argLongest = ARG_LONGEST;\n static #hash = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;\n static #digest = /^[0-9a-f]{64}$/;\n static #version = /^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$/;\n static #label = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;\n static #id = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n static #tag = /^v(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)$/;\n static #hashed = /^d ([0-9a-f]{64}) ((?:designs|faculties)\\/[^/]+)\\/(.+)$/;\n static #standings = ["reader", "writer", "library", "runner"];\n static #segment = /^[A-Za-z0-9._-]+$/;\n static #scopeMost = SCOPE_MOST;\n static #entry = /^(?!\\.{1,2}$)(?!\\.git$)[^/\\\\\\0]+$/i;\n static #lobe = "lobe";\n static #teller = "teller";\n static #tells = "tells";\n static #hears = "library";\n static #waits = ["timeout", "unavailable", "busy"];\n static #still = STILL;\n static #lifted = Math.floor(Number.MAX_SAFE_INTEGER / 2);\n static #onCommit = ["off", "on", "mandatory"];\n static #onPush = ["off", "on"];\n static #moves = ["init", "land", "commit"];\n static #writes = ["owner", "near"];\n static #offers = ["owner", "near", "library"];\n static #runs = ["owner", "near", "runner"];\n static #pulls = ["reader", "pusher"];\n static #who = {\n init: ["owner"],\n accept: ["owner"],\n relink: ["owner"],\n invite: ["owner"],\n drop: ["owner"],\n occupants: ["owner"],\n migrate: ["owner"],\n gate: ["owner"],\n gates: ["owner"],\n conform: ["owner"],\n author: ["owner"],\n remove: ["owner"],\n rebuild: ["owner"],\n state: ["owner", "near", "library"],\n jobs: _RepoLobe.#runs,\n job: _RepoLobe.#runs,\n pull: _RepoLobe.#writes,\n push: _RepoLobe.#writes,\n build: _RepoLobe.#writes,\n commit: _RepoLobe.#writes,\n status: _RepoLobe.#writes,\n log: _RepoLobe.#writes,\n discard: ["owner"],\n read: _RepoLobe.#writes,\n list: _RepoLobe.#writes,\n run: _RepoLobe.#runs,\n setToken: ["owner"],\n credential: ["owner"],\n stop: _RepoLobe.#writes,\n faculties: _RepoLobe.#offers,\n organs: _RepoLobe.#offers,\n designs: _RepoLobe.#offers,\n get: _RepoLobe.#offers,\n told: _RepoLobe.#offers,\n head: _RepoLobe.#pulls,\n give: _RepoLobe.#pulls,\n piece: _RepoLobe.#pulls,\n take: ["pusher"],\n taken: ["pusher"],\n done: ["jailer", "teller"]\n };\n static #some = { type: "string", minLength: 1 };\n static #maybe = { anyOf: [{ type: "string", minLength: 1 }, { type: "null" }] };\n static #place = { type: "integer", minimum: 0 };\n static #one = { type: "integer", minimum: 1 };\n static #span = { anyOf: [{ type: "integer", minimum: 0 }, { type: "null" }] };\n static #plain = { type: "string" };\n static #none = { type: "object", additionalProperties: false };\n static #named = { type: "string", pattern: "^[a-z][a-z0-9.-]{0,63}$" };\n static #fixed = { type: "string", maxLength: 64, pattern: "^[a-z][a-z0-9]*(-[a-z0-9]+)*$" };\n static #jobSchema = {\n type: "object",\n properties: { job: _RepoLobe.#some },\n required: ["job"],\n additionalProperties: false\n };\n static #object(properties, required = Object.keys(properties)) {\n return { type: "object", properties, required, additionalProperties: false };\n }\n static #over(properties, required = Object.keys(properties)) {\n return _RepoLobe.#object({ ...properties, name: _RepoLobe.#named }, required);\n }\n static #says = {\n init: "An owner: with `starter` true, the repo `name` born and its first commit the repo lobe\'s one small starter, a step of the same job; else the repo `name` born empty and ready in the folder the jailer grants, which holds nothing: it holds no commit, may give invitations, and what it begins with is laid by the first commit of its owner or the first push of the lobe that stands on it, whole, each checked as any. Never born again, since a folder holding a repo refuses it. With `standing` true: handed in place the repo the granted folder holds already, a lobe torn down having kept it, ready on its head and tags as they stand once its `main` passes the two checks, its `conform` as `main` holds it, which it chooses, nothing laid or moved, refused where no repo stands there. An init that failed may be asked again.",\n accept: "An owner: the repo `name` laid again from the lobe an invitation names, as a lost lobe is: made empty, standing on that lobe, and pulled whole from it, the pull a step of its one job, which ends on the pull’s code and check once it landed and was scanned. The mouth keeps `note` beside the standing the organism holds, the owner’s, else `{ repo, on }`, the repo and the placeholder it stands on by; it never travels. A lobe born of a scoped lobe notes the scope on that standing, and keeps that its bytes are cut beside its head.",\n relink: "An owner: stands on the lobe of the repo an invitation names, beside those it stands on, under a placeholder of its own, which it answers: `placeholder`, a name this lobe holds for nothing else; else, with `instead`, the name of the standing it replaces; else the next free `lobe-<n>`. With `instead`, the lobe it stood on under that placeholder is asked to `drop` this one\'s standing, and the relation ends: once the new one stands, or first where the new one takes its name, since a placeholder has one wire. The mouth keeps `note` beside the standing, the owner\'s, else `{ repo, on }`. Refused to a lobe born of a scope, which stands on no other.",\n setToken: "An owner: the key `name`, any environment variable\'s name, of this lobe, set to `value`, or removed where `value` is null; kept in this lobe\'s cells, never answered, masked in all it tells, and in `.env` from the next run.",\n credential: "An owner: takes the credential of an issuer\'s standing the organism holds, as the key `secret`. With `invitation`, the organism accepts it, the mouth keeping `note`, the owner\'s, beside the standing; with `placeholder`, a placeholder of this lobe an owner wired to a standing the organism holds already, refused where it reaches no standing or one this lobe keeps another key over. Either way this lobe writes its own note on the standing, `{ credential: secret }`, asks the issuer `credential`, again at the `ready` it answers while it makes it, and a few seconds on while it is silent, for as long as `within` names in milliseconds: the cap where it names none, and never more, an hour or an owner’s word over `within`, read in its nerves as it begins, a span past it refused; then failing, saying why, and keeps its `value`, masked and never answered; where it `expires`, it is asked again before then, by a tenth of its life, a renewal that fails keeping the value, asked again at half what is left and never within a minute, and told in `state`; answers `{ secret }`, with `pending` while the issuer makes it. Asked again with its `secret` alone it asks the issuer for a fresh one.",\n invite: "An owner: an invitation for one far organism, a `reader`, a `writer`, a `library` or a `runner`, kept by the ear for `waits` and its relation for `lives`, reached down a line to the address `through` where one is named. This lobe’s own note on the occupant, kept by the brain, is the owner’s `note`, if any, and `{ repo, standing }`, the repo and the kind of standing its far holds, `scope` where one is named and a runner’s `scripts`; this lobe reads them back from the stamp of each ask of that far, and keeps no cell of them; the note never travels with the invitation. A runner names `scripts`, one or more scripts of the repo’s `package.json`, the only ones it may `run`, and no other standing names any. A reader’s or a writer’s `scope`, 1 to 16 folders of the repo, each of names of letters, digits, `.`, `_` and `-`, none `.`, `..` nor `.git`, none inside another, kept sorted in that note and never in the invitation, so the standing reaches those folders alone; a library’s or a runner’s is refused, and a lobe born of a scope gives no occupant, for life.",\n drop: "An owner: ends the far organism `far`\'s relation and its standing, or this lobe\'s standing on the lobe it holds as `on`. A holder ends its own standing by its mouth\'s `drop`.",\n occupants: "An owner: each occupant of this lobe, its far organism and its role, a reader, a writer, a library or a runner, with its scope where it holds one, read from this lobe’s notes through its `nerves`.",\n left: "The brain\'s: an end this lobe gave or is granted ended, `far` with its `note`; whatever this lobe kept by that far, its pull and push pieces, forgotten; a pull or a push over a standing it was granted that ended ends. The repo\'s files and history stay as they stand.",\n migrate: "The brain, at a move to this version: each wired lobe whose wire back is gone, torn down, forgotten, its lines, where it held any, taken out at the next job’s end; a pull or a push standing is rung again: a fresh `chain` kept in it and its `tick` set by a letter, the old chain dying at its next ring; and a scan of the repo owed, so every tag’s files are kept before a version told is asked: begun where the repo has a head and runs nothing, no job and no pull or push, else at the first instant it does, found by a job’s end or a pull’s or a push’s or by an alarm of its own, and owed until a scan ends whole.",\n remove: "An owner: forgets the repo, once no far standing holds it and nothing runs; its bytes stay in the folder, for the jailer’s owner.",\n rebuild: "An owner, after a move or a restore: the repo made again empty, its head unanswered until it holds the head it kept, pulled whole from a lobe it stands on, a step of its one job, which ends once that pull ended, else pushed whole by one that stands on it, that push in once the head is proven.",\n state: "The repo: its name, head, whether it is ready, not where its folder holds no repo, `absent` then saying so and that `rebuild` fills it again, the job going, how its last pull or push ended, the lobes it stands on, how many far writers push to it, its folder on the host, its wired lobes, its gate and its settings, the commit whose `conform` its owner chose, and its author, the ends read from its `nerves`; `scopes`, each scoped occupant and its scope, and `scoped`, each lobe it stands on by a scope and that scope, where there are any; `cut`, each kind of part the last scan listed past one read’s most and how many it left unlisted, where it cut any; to the library, its name alone.",\n gate: "An owner: the script of the repo\'s package the gate runs, or null for none; `gate` where none was set.",\n gates: "An owner: the settings of the gate, `commit` and `push`, each only where named, answering both. On commit, `on` by default: a commit first runs the gate, with the repo’s `.env`, and is refused, with the gate’s tail, where it is red; `off` commits at once; `mandatory` is `on` and no commit skips it. On push, `off` by default: `on` runs the gate after the two checks on each push this lobe takes, and a red gate refuses it.",\n conform: "An owner: with `take` true, the repo’s `conform` as `main` holds it now chosen, the one that judges each commit, push and pull from then on, whoever changed it; with `take` false, none, what enters guarded by the check of the parts alone; answering the commit whose conform is chosen, or null. A commit of this lobe’s own that changes it chooses it too, and an `init` standing on a repo in place; nothing a writer pushes or a pull brings does.",\n author: "An owner: beside a lobe far writers push to, the one wired lobe whose commit it takes, as the spec’s wired lobe files a proposal, or null for none; no other commits there, an owner neither.",\n commit: "An owner\'s or a wired lobe\'s: `files`, each a path under the repo and its text, `executable` naming those of them that land executable, written first, then, where its setting on commit says so, the gate, with the repo\'s `.env`; then, in its own job, refused while a secret file stands that git would take, the check of the parts, handed what the latest tag told of each `versions.json` (a version told changed is refused), and the repo\'s `conform` as its owner chose it, none where it chose none, each over what it would commit laid out apart as a clone would hold it, so a file `.gitignore` keeps out counts as absent, and its root `package.json` `version` read against `HEAD`\'s, refused where it changed and is not three whole numbers, is lower by semver, or its tag stands already; then every change committed on `main` with `message`, tagged `v<version>` in the same job where it raised the version, a lobe holding a scope tagging none, its head taken and `main` scanned, the job\'s last step (`job`). `gate` false skips the gate, refused where the setting is `mandatory`; `gate` true asks it once where the setting is `off`. A red gate or a broken rule refuses it, saying why, and every file it wrote is put back as it was before the ask (removed where it stood not, its old text written where it did), in the same job, the refusal saying so; a commit without `files` is its owner\'s, of what the folder holds, and puts nothing back. With `paths`, each a file or a folder of the repo, no `files` beside them, it takes the changes of those paths alone, added, changed or removed, and leaves the rest of the folder as it stands; the gate still runs on the folder as it stands, the checks over `main` as the commit would leave it, and `paths` that hold no change refuse it, committing nothing. Beside a lobe far writers push to, its author\'s alone.",\n status: "A job: `git status` of the folder.",\n log: "A job: the last commits, `most` of them, twenty where none is named.",\n discard: "An owner: a job undoing every change since the last commit.",\n read: "A file\'s text, its first lines where `first` names how many, and how many lines it holds; or `paths` (one or more) alone, many files in one answer, as many as a quarter of what the jailer\'s lobe holds takes, `{ files }`, each `{ path, text }` or `{ path, absent: true }` in the order named, read in one ask of the jailer; the whole refused, saying why, where a path climbs or hides, a text is no UTF-8 or the texts weigh past what one answer carries.",\n list: "The names in a folder of the repo, its top where no path is named.",\n run: "A job, an owner\'s, a wired lobe\'s or a runner\'s, a runner\'s among the scripts its invitation names alone: the script `script` of the repo\'s `package.json` with `args`, each one argument after `--`, never read by a shell, with this lobe\'s keys, `.env` written whole first where it keeps any or wrote it before, its values masked in its output; a script without its key fails by its own words. With `install`, `npm ci` first where a lockfile stands, in the same job. Its end is told back by a letter to a wired lobe; an owner and a runner read it by `job`.",\n stop: "The asker\'s pull or push standing, an owner\'s any, ended failed, saying it was stopped, its job of the jailer\'s ending by itself unheeded, refused while it lands; else the asker\'s job going stopped through the jailer, an owner\'s any, its program given `grace` milliseconds to end before it is killed, the shell\'s own five seconds where none is named; one the shell runs no more ends at once, failed.",\n jobs: "The asker\'s jobs of this lobe\'s own, a build, an init, an owner\'s every one, each with `began`, the stamp time it began, and how it ended, `{ run, code, at }`, `at` the stamp time it ended, or null while it runs. Of each asker the lobe keeps every job that runs and its newest ended, as many as one read holds; a step of another\'s work is forgotten once it moved that work on. A page, `{ jobs, cursor }`, `cursor` null at the list\'s end, else handed back to read on.",\n job: "One of the asker\'s jobs, `job`, whole, with `began` and `ended.at`, the stamp times it began and ended; an owner reads any, and one not the asker\'s is absent. A job that moved `main` ends once its last step, the scan of `main`, ended, the repo then running nothing, `ended.scan` the scan\'s `code` and the tail of why it failed, `err`, which fails no work.",\n pull: "A job: the commits of the lobe it stands on as `on`, the one it stands on where it names none, after its own HEAD, as a bundle in pieces over the relation, each of the bytes `piece` names, Quo\'s box where it names none, brought apart, checked by this lobe\'s two checks, the check of the parts and `conform` as its owner chose it, never as what came holds it, then brought into `main`, merged where it must, with the tags `v*` of the commits it brings, laid once `main` moved; a conflict, a rule broken or a tag this lobe holds on another commit refuses it, saying which. With `tag`, `v` and three whole numbers, `main` is brought up to the commit that tag names and no further, refused where the lobe pulled from holds no such tag, and nothing brought where `main` holds that commit already; a lobe holding a scope pulls by a tag too, the lobe pulled from cutting `main` to the scope up to that commit, and the tag’s name never enters the scoped lobe. `still` names how long it may stand still, in milliseconds, nothing taken and no stage moved, before it ends failed: the cap where it names none, and never more, an hour or an owner’s word over `still`.",\n push: "A job: its commits after the HEAD of the lobe it stands on as `on`, the one it stands on where it names none, sent in pieces, which that lobe checks by its own rules and brings into its `main`, or refuses, saying why; it carries the tags `v*` of the commits it sends, which that lobe lays once its `main` moved, or refuses the whole where it holds one on another commit; once its last piece is in it asks that lobe its end, `taken`, each ring, and ends with what it heard. With `tells`, the asker’s word that this organism can be dialed, its first piece gives that lobe a standing back, drawn fresh, the one before ended, over which that lobe tells its end, `done`, so the push asks nothing once its last piece is in and ends with what it was told. `piece` names the bytes of each piece, Quo’s box where it names none, what one lobe holds bounding it on either side. `still` names how long it may stand still, in milliseconds, nothing taken and no stage moved, before it ends failed: the cap where it names none, and never more, an hour or an owner’s word over `still`.",\n faculties: "Each faculty `main` holds, its label, version and digest, and its assets where its `assets/` holds any, each `[path, SHA-256]`, or why it is not told; absent where `faculties/` is not.",\n organs: "Each organ `main` holds, its ID, version and digests, or why it is not told; absent where `organs/` is not.",\n designs: "Each design `main` holds, its name, version and the digests of its data and its look, or why it is not told, a design told as its look, the faculty `<name>.look` with its assets; absent where `designs/` is not.",\n get: "A faculty\'s `{ source, digest }`, with `assets` where its `assets/` holds any, each `[path, SHA-256]`, its evidence among them; an organ\'s `{ blueprint, half }`; or a design\'s look, the faculty `<name>.look` at the design\'s version, once built, `{ source, digest, assets }`, its assets the design\'s data; at a version told, its bytes checked, and served as told whatever `main` holds after, its assets read from what the jailer kept of every tag by SHA-256, `absent` where a scan keeps them not yet, saying whether it is being kept, a scan running, or waits, a scan owed that begins once the repo runs nothing; with `path`, an asset of a faculty or a look `{ path, digest, bytes }`, its canonical bytes whole, whose SHA-256 is `digest`; with `version` null, a faculty or an organ as the folder holds it, to an owner or a writer alone.",\n build: "A job building the organ `organ`\'s host half at a version told, keeping the built half\'s digest; or the design `design`\'s look, by the repo\'s script `design`, keeping its source where it is the look `versions.json` told; either refused while `main` holds not that version, as the last scan found it.",\n told: "The versions the repo told, each with its digests; a version is told once a commit tagged `v<version>` holds it, and a scan of a head no tag names tells none. A far library may name `tells`, the invitation to a standing back on it, taken under `library-<far>`, the one before ended, over which this lobe tells it each version it tells after, `changed`, by an ask; it ends with that library’s standing. A page, `{ told, cursor }`, of the versions from the first told, the newest last, `cursor` null at the list’s end, else handed back to read on.",\n head: "A far reader or writer: this lobe\'s HEAD, null while it rebuilds, and null to a scoped one, which pushes its scope whole.",\n give: "A far reader or writer: the commits after `since`, as a bundle in pieces once it is made, each of the bytes `piece` names, Quo’s box where it names none, with the tags `v*` naming commits among them; until then, not ready. With `tag`, `v` and three whole numbers, up to the commit that tag names and no further, refused where this lobe holds no such tag, and none where `since` holds that commit already; to a scoped one, `main` is cut to its scope up to the commit that tag names, which is the beginning of the cut to the head, and the bundle holds that cut’s commits after `since`, never a tag. A bundle that failed is refused once, then made again. To a scoped one, `main` is cut to its scope first, the same every time, and the bundle holds the cut’s commits after `since`, read against the cut, nothing of `main` outside the scope, no tag; its answer carries `scope`, which the lobe that pulls keeps, and from then gives no occupant.",\n piece: "A far reader or writer: the bundle\'s piece `at`.",\n take: "A far writer: the piece `at` of `pieces` of the push its writer names `push`, in order. The first may name `tells`, the invitation of the standing back its writer gives, which this lobe accepts under `tells-<far>`, the one it held of that writer before ended; once the push is in `main` or refused, a writer that gave one is told `done { job, kind, code, out, err, check }` over it by an ask, once. The same piece of the same push sent again, the same bytes, is answered as it was; a push named anew, from its first piece, is a new one, brought and checked anew by the rules as they stand, whatever came before; any other piece is refused as out of order. The last has this lobe bring it apart and check it by its two checks, and its gate where its setting on push is `on`; the tags it carries brought apart, the whole refused where one names no commit it brings or this lobe holds a tag of that name on another commit, and laid once `main` moved. A scoped writer\'s is grafted first, its tags not taken: refused unless it is linear on the scope\'s head as `main` is cut now, else as behind, and where a commit changes a path outside the scope; each commit grafted on `main`\'s tip, its tree `main`\'s with the scope\'s paths taken from it, its author, committer, times and message kept, and what `main` would become checked whole.",\n taken: "A far writer: the end of its last push, `{ job, kind, code, out, err, check }`, as `done` tells it, or `{ ready: false }` until it is in `main` or refused, with `waits`, what it waits on, where its last piece is in and the repo runs another job first: that job checked with the jailer, so one whose end was lost holds it not, and the push brought once the repo runs nothing. A scoped writer hears the head it pushed and its check\'s code alone.",\n renew: "The scheduler\'s alone: each credential waited on whose time came asked again, each due to be renewed renewed.",\n keep: "The scheduler\'s alone: a scan owed begins where the repo has a head and runs nothing, by the `chain` its alarm carries, the one the lobe keeps; where the repo runs a job, the jailer is asked of it first, so a job whose end was lost ends; answers `{ again }`, a minute on, while the scan is owed, begun or not, and null once it is no more owed; a ring of any other chain answers null and writes nothing.",\n tick: "The scheduler\'s alone: a pull or a push takes its next step, by the `chain` its alarm carries, the one the sync keeps; a tick of any other chain, or where no sync stands, answers null at once and writes nothing; each ring making one far ask at most, within the time the ring is given: a push\'s piece read through the jailer and taken, a pull\'s got and put through the jailer, one piece a ring; a ring that moved the work rings the next at once, as a job of the jailer ending does; one waiting on a job of the jailer is rung at once by that job\'s end or its loss, told at the shell\'s `back`, and meanwhile a minute on, each ring checking the job with the jailer, so one whose end was lost holds it not; one whose far answered not yet a second on; a push whose last piece is in asks its end, `taken`, a second on each ring, or, where it gave a standing back, asks nothing, since the lobe it went to tells its end, and rings again only to end it once it stood still for as long as it may; an ask timed out, unavailable or busy is asked again at the next ring, kept as `waits { why, since }`, any other far error ends it; one that moved not for as long as it may stand still, `still`, nothing taken and no stage changed, ends failed, naming what stood still, as data.",\n done: "The jailer\'s, a job ended; or, the lobe a push went to, over the standing back that push gave it: the push ended, `{ job, kind, code, out, err, check }`, landed with code 0 and the HEAD it left, or refused, saying why in `err`, and the push this lobe waits on ends with it. To a scoped writer, the head it pushed and its check’s code alone, a refusal telling that its check is red and no more."\n };\n static #reading(method, args) {\n const description = _RepoLobe.#says[method] ?? method;\n const typed = args === void 0 ? {} : { args };\n return { description, kind: "reading", ...typed, errors: ["refused", "absent"] };\n }\n static #writing(method, args) {\n return { ..._RepoLobe.#reading(method, args), kind: "writing" };\n }\n static #own = _RepoLobe.#over({}, []);\n static #which = _RepoLobe.#over(\n {\n kind: { enum: ["faculty", "organ"] },\n label: _RepoLobe.#some,\n version: _RepoLobe.#maybe,\n path: _RepoLobe.#some\n },\n ["kind", "label", "version"]\n );\n static #stillFor = { type: "integer", minimum: 1 };\n static #syncing = _RepoLobe.#over(\n { on: _RepoLobe.#some, piece: _RepoLobe.#one, still: _RepoLobe.#stillFor, tells: { const: true } },\n []\n );\n static #ringing = _RepoLobe.#over({ chain: _RepoLobe.#some }, ["chain"]);\n static #pulling = _RepoLobe.#over(\n { on: _RepoLobe.#some, tag: _RepoLobe.#some, piece: _RepoLobe.#one, still: _RepoLobe.#stillFor },\n []\n );\n static blueprint = {\n name: "nervur.repo",\n version: "0.2.71",\n description: "A repo lobe: one for each repo on each organism that holds it, its bytes kept by the jailer, `repos`, through which it reaches them alone. It keeps what the repo is there: its head; its gate and its settings; its wired lobes; and the versions of its faculties, organs and designs it told the library, `changed`, never told again with other bytes. A repo is born one of two ways: by its `init`, empty, filled by the first commit of its owner or a first push whole; or by its `accept` of an invitation, pulled whole. It commits, at an owner’s ask or a wired lobe’s, its gate first where its settings say; it guards its own `main` before anything enters it, a commit, a push, a pull, by Nervur’s check of the parts, which it holds, and the repo’s `conform` as its owner chose it, each over that tree checked out apart; it serves its wired lobes, each work a job, its end told back, and composes each secret file from their sets, keeping which names each holds by digest, never a value; it pulls and pushes, serves its readers, writers and libraries, and holds no secret. The lobes of the repo it stands on, any number, and its far standings, readers, writers and libraries, are the brain’s, each with this lobe’s own note: it keeps no record of them.",\n methods: {\n init: _RepoLobe.#writing(\n "init",\n _RepoLobe.#object({ name: _RepoLobe.#named, standing: { const: true }, starter: { const: true } }, ["name"])\n ),\n accept: _RepoLobe.#writing(\n "accept",\n _RepoLobe.#object({ name: _RepoLobe.#named, invitation: _RepoLobe.#some, note: {} }, ["name", "invitation"])\n ),\n relink: _RepoLobe.#writing(\n "relink",\n _RepoLobe.#object(\n { invitation: _RepoLobe.#some, instead: _RepoLobe.#some, placeholder: _RepoLobe.#fixed, note: {} },\n ["invitation"]\n )\n ),\n invite: _RepoLobe.#writing(\n "invite",\n _RepoLobe.#object(\n {\n standing: { enum: _RepoLobe.#standings },\n waits: _RepoLobe.#span,\n lives: _RepoLobe.#span,\n note: {},\n through: _RepoLobe.#some,\n scope: { type: "array", items: _RepoLobe.#some, minItems: 1, maxItems: SCOPE_MOST },\n scripts: { type: "array", items: _RepoLobe.#some, minItems: 1 }\n },\n ["standing"]\n )\n ),\n drop: {\n ..._RepoLobe.#writing("drop", _RepoLobe.#object({ far: _RepoLobe.#some, on: _RepoLobe.#some }, [])),\n irreversible: true\n },\n occupants: _RepoLobe.#reading("occupants"),\n left: _RepoLobe.#writing("left", _RepoLobe.#object({ far: _RepoLobe.#some, note: {} }, ["far"])),\n migrate: _RepoLobe.#writing("migrate"),\n remove: { ..._RepoLobe.#writing("remove", _RepoLobe.#own), irreversible: true },\n rebuild: _RepoLobe.#writing("rebuild", _RepoLobe.#own),\n state: _RepoLobe.#reading("state", _RepoLobe.#own),\n gate: _RepoLobe.#writing("gate", _RepoLobe.#object({ script: _RepoLobe.#maybe })),\n gates: _RepoLobe.#writing(\n "gates",\n _RepoLobe.#object({ commit: { enum: _RepoLobe.#onCommit }, push: { enum: _RepoLobe.#onPush } }, [])\n ),\n conform: _RepoLobe.#writing("conform", _RepoLobe.#object({ take: { type: "boolean" } })),\n author: _RepoLobe.#writing("author", _RepoLobe.#object({ lobe: _RepoLobe.#maybe })),\n commit: _RepoLobe.#writing(\n "commit",\n _RepoLobe.#object(\n {\n message: _RepoLobe.#some,\n files: { type: "object", additionalProperties: _RepoLobe.#plain },\n executable: { type: "array", items: _RepoLobe.#some },\n paths: { type: "array", items: _RepoLobe.#some, minItems: 1 },\n gate: { type: "boolean" }\n },\n ["message"]\n )\n ),\n status: _RepoLobe.#writing("status", _RepoLobe.#none),\n log: _RepoLobe.#writing("log", _RepoLobe.#object({ most: { type: "integer", minimum: 1 } }, [])),\n discard: { ..._RepoLobe.#writing("discard", _RepoLobe.#none), irreversible: true },\n read: _RepoLobe.#reading(\n "read",\n _RepoLobe.#object(\n {\n path: _RepoLobe.#some,\n first: _RepoLobe.#one,\n paths: { type: "array", items: _RepoLobe.#some, minItems: 1 }\n },\n []\n )\n ),\n list: _RepoLobe.#reading("list", _RepoLobe.#object({ path: _RepoLobe.#plain }, [])),\n run: _RepoLobe.#writing(\n "run",\n _RepoLobe.#object(\n {\n script: _RepoLobe.#some,\n args: { type: "array", items: _RepoLobe.#plain, maxItems: ARGS_MOST },\n install: { type: "boolean" }\n },\n ["script"]\n )\n ),\n setToken: _RepoLobe.#writing("setToken", _RepoLobe.#object({ name: _RepoLobe.#some, value: _RepoLobe.#maybe })),\n credential: _RepoLobe.#writing(\n "credential",\n _RepoLobe.#object(\n {\n invitation: _RepoLobe.#some,\n placeholder: _RepoLobe.#some,\n secret: _RepoLobe.#some,\n note: {},\n within: { type: "integer", minimum: 1 }\n },\n ["secret"]\n )\n ),\n stop: _RepoLobe.#writing(\n "stop",\n _RepoLobe.#object({ grace: { type: "integer", minimum: 0, maximum: 2147483647 } }, [])\n ),\n jobs: _RepoLobe.#reading("jobs", _RepoLobe.#object({ cursor: _RepoLobe.#maybe }, [])),\n job: _RepoLobe.#reading("job", _RepoLobe.#jobSchema),\n pull: _RepoLobe.#writing("pull", _RepoLobe.#pulling),\n push: _RepoLobe.#writing("push", _RepoLobe.#syncing),\n faculties: _RepoLobe.#reading("faculties"),\n organs: _RepoLobe.#reading("organs"),\n designs: _RepoLobe.#reading("designs"),\n get: _RepoLobe.#reading("get", _RepoLobe.#which),\n build: _RepoLobe.#writing(\n "build",\n _RepoLobe.#over({ organ: _RepoLobe.#some, design: _RepoLobe.#some, version: _RepoLobe.#some }, ["version"])\n ),\n told: _RepoLobe.#writing(\n "told",\n _RepoLobe.#object({ tells: { type: "string", minLength: 1 }, cursor: _RepoLobe.#maybe }, [])\n ),\n head: _RepoLobe.#reading("head"),\n give: _RepoLobe.#writing(\n "give",\n _RepoLobe.#object({ since: _RepoLobe.#maybe, tag: _RepoLobe.#some, piece: _RepoLobe.#one }, ["since"])\n ),\n piece: _RepoLobe.#reading("piece", _RepoLobe.#object({ at: _RepoLobe.#place })),\n take: _RepoLobe.#writing(\n "take",\n _RepoLobe.#object(\n { push: _RepoLobe.#some, at: _RepoLobe.#place, pieces: _RepoLobe.#one, bytes: {}, tells: _RepoLobe.#some },\n ["push", "at", "pieces", "bytes"]\n )\n ),\n taken: _RepoLobe.#writing("taken", _RepoLobe.#none),\n tick: { ..._RepoLobe.#writing("tick", _RepoLobe.#ringing), askers: ["scheduler"] },\n keep: { ..._RepoLobe.#writing("keep", _RepoLobe.#ringing), askers: ["scheduler"] },\n renew: { ..._RepoLobe.#writing("renew"), askers: ["scheduler"] },\n done: _RepoLobe.#writing("done")\n },\n placeholders: {\n repos: "nervur.repos",\n ear: "nervur.ear",\n mouth: "nervur.mouth",\n scheduler: "nervur.scheduler",\n library: "nervur.library"\n }\n };\n static parts = `// SPDX-License-Identifier: FSL-1.1-ALv2\nimport { createHash } from \'node:crypto\';\nimport { existsSync, lstatSync, readFileSync, readdirSync } from \'node:fs\';\nimport { join, resolve } from \'node:path\';\n\nconst root = resolve(process.argv[2] ?? \'.\');\nconst LABEL = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;\nconst ID = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\nconst VERSION = /^(?:0|[1-9][0-9]*)\\\\.(?:0|[1-9][0-9]*)\\\\.(?:0|[1-9][0-9]*)$/;\nconst broken = [];\nconst say = (why) => {\n broken.push(why);\n};\nconst isFolder = (path) => existsSync(path) && lstatSync(path).isDirectory();\nconst isFile = (path) => existsSync(path) && lstatSync(path).isFile();\nconst fieldsAt = (path) => {\n try {\n const read = JSON.parse(readFileSync(path, \'utf8\'));\n return read !== null && typeof read === \'object\' && !Array.isArray(read) ? read : null;\n } catch {\n return null;\n }\n};\n\nconst partsOf = (convention, pattern, what, by) => {\n const at = join(root, convention);\n if (!existsSync(at)) return [];\n if (!isFolder(at)) {\n say(convention + \' is no folder: it holds a folder for each \' + what);\n return [];\n }\n return readdirSync(at)\n .filter((name) => !name.startsWith(\'.\'))\n .toSorted()\n .flatMap((name) => {\n if (!isFolder(join(at, name))) {\n say(convention + \'/\' + name + \' is no folder: \' + convention + \'/ holds a folder for each \' + what);\n return [];\n }\n if (!pattern.test(name)) {\n say(convention + \'/\' + name + \' is no \' + what + "\'s name: a " + what + \' is named by \' + by);\n return [];\n }\n return [name];\n });\n};\n\nconst sha = (bytes) => createHash(\'sha256\').update(bytes).digest(\'hex\');\nconst canonical = (bytes) =>\n bytes.includes(0) ? bytes : Buffer.from(bytes.toString(\'latin1\').replace(/\\\\r\\\\n?/g, \'\\\\n\'), \'latin1\');\nconst assetsOf = (at, below = \'\') =>\n readdirSync(join(at, below), { withFileTypes: true })\n .filter((entry) => !entry.name.startsWith(\'.\'))\n .flatMap((entry) => {\n const path = below === \'\' ? entry.name : below + \'/\' + entry.name;\n if (entry.isDirectory()) return assetsOf(at, path);\n return entry.isFile() ? [[path, sha(canonical(readFileSync(join(at, path))))]] : [];\n })\n .toSorted((one, other) => (one[0] < other[0] ? -1 : 1));\n\nfor (const label of partsOf(\'faculties\', LABEL, \'faculty\', \'its label, in lowercase\')) {\n const at = \'faculties/\' + label;\n const path = join(root, at, \'faculty.js\');\n if (!isFile(path)) {\n say(at + \' holds no faculty.js: a faculty is one module of JavaScript\');\n continue;\n }\n const bytes = readFileSync(path);\n const text = bytes.toString(\'utf8\');\n const named =\n /\\\\b([A-Za-z_$][\\\\w$]*)\\\\s*=\\\\s*class(?:\\\\s+[A-Za-z_$][\\\\w$]*)?\\\\s+extends\\\\s+Faculty\\\\b/.exec(text) ??\n /\\\\bclass\\\\s+([A-Za-z_$][\\\\w$]*)\\\\s+extends\\\\s+Faculty\\\\b/.exec(text);\n const exported =\n /\\\\bexport\\\\s+default\\\\s+class\\\\b[^{]*\\\\bextends\\\\s+Faculty\\\\b/.test(text) ||\n (named !== null &&\n (new RegExp(\'\\\\\\\\bexport\\\\\\\\s+default\\\\\\\\s+\' + named[1] + \'\\\\\\\\b\').test(text) ||\n new RegExp(\'\\\\\\\\bexport\\\\\\\\s*\\\\\\\\{\\\\\\\\s*\' + named[1] + \'\\\\\\\\s+as\\\\\\\\s+default\\\\\\\\s*\\\\\\\\}\').test(text)));\n if (!/\\\\bimport\\\\s*\\\\{[^}]*\\\\bFaculty\\\\b[^}]*\\\\}\\\\s*from\\\\s*[\'"]nervur:faculty[\'"]/.test(text) || !exported)\n say(at + \'/faculty.js exports as its default no class extending Faculty from nervur:faculty\');\n const from = text.search(/\\\\bstatic\\\\s+blueprint\\\\s*=/);\n const blueprint = from < 0 ? \'\' : text.slice(from);\n const name = /\\\\bname\\\\s*:\\\\s*[\'"]([^\'"\\\\n]+)[\'"]/.exec(blueprint)?.[1];\n const version = /\\\\bversion\\\\s*:\\\\s*[\'"]([^\'"\\\\n]+)[\'"]/.exec(blueprint)?.[1];\n if (name === undefined || version === undefined || !VERSION.test(version)) {\n say(at + \'/faculty.js holds no blueprint naming its name and its version\');\n continue;\n }\n const versions = fieldsAt(join(root, at, \'versions.json\'));\n const digest = createHash(\'sha256\').update(bytes).digest(\'hex\');\n if (versions === null) say(at + \' holds no versions.json naming each version by its digest\');\n else if (versions[version] !== digest) say(at + \'/faculty.js is not the text its versions.json names at \' + version);\n const digested = /\\\\bassets\\\\s*:\\\\s*[\'"]([0-9a-f]{64})[\'"]/.exec(blueprint)?.[1];\n const held = isFolder(join(root, at, \'assets\')) ? assetsOf(join(root, at, \'assets\')) : [];\n if (digested === undefined && held.length > 0)\n say(at + \'/assets holds files its blueprint names no assets digest for\');\n else if (digested !== undefined && sha(JSON.stringify(held)) !== digested)\n say(at + \'/assets is not the digest its blueprint names as assets, \' + digested);\n}\n\nfor (const id of partsOf(\'organs\', ID, \'organ\', \'its fixed ID, in lowercase\')) {\n const at = \'organs/\' + id;\n const graph = fieldsAt(join(root, at, \'graph.json\'));\n const version = graph === null ? undefined : (graph.version ?? graph.blueprint?.version);\n if (graph === null || typeof version !== \'string\' || !VERSION.test(version))\n say(at + \' holds no graph.json, its blueprint with its version\');\n if (!isFile(join(root, at, \'host/build\'))) say(at + \' holds no host/build, which builds its host half\');\n}\n\nconst sheetsIn = (at, below = \'\') =>\n readdirSync(join(at, below), { withFileTypes: true }).flatMap((entry) => {\n const path = below === \'\' ? entry.name : below + \'/\' + entry.name;\n if (entry.isDirectory()) return sheetsIn(at, path);\n return path === \'layers.json\' ? [] : [path];\n });\n\nfor (const name of partsOf(\'designs\', LABEL, \'design\', \'its name, in lowercase\')) {\n const at = \'designs/\' + name;\n const design = fieldsAt(join(root, at, \'design.json\'));\n if (design === null || design.name !== name || typeof design.version !== \'string\' || !VERSION.test(design.version))\n say(at + \' holds no design.json naming it and its version\');\n const tokens = {};\n for (const file of [\'light\', \'dark\', \'tints\']) {\n tokens[file] = fieldsAt(join(root, at, \'tokens\', file + \'.json\'));\n if (tokens[file] === null) say(at + \' holds no tokens/\' + file + \'.json\');\n }\n if (design !== null) {\n const where = at + \'/design.json\';\n if (typeof design.publisher !== \'string\' || design.publisher === \'\') say(where + \' names no publisher\');\n const themes = Array.isArray(design.themes) ? design.themes : [];\n if (!themes.includes(\'light\') || !themes.includes(\'dark\')) say(where + \' names no themes light and dark\');\n if (!Array.isArray(design.tints)) say(where + \' names its tints as no list\');\n else if (tokens.tints !== null)\n for (const tint of design.tints)\n if (typeof tint !== \'string\' || !Object.hasOwn(tokens.tints, tint))\n say(where + \' names the tint \' + String(tint) + \', which tokens/tints.json holds not\');\n }\n const layers = fieldsAt(join(root, at, \'skin/layers.json\'));\n if (layers === null) say(at + \' holds no skin/layers.json\');\n else {\n const where = at + \'/skin/layers.json\';\n const named = [];\n for (const layer of [\'lobes\', \'home\']) {\n const sheets = Array.isArray(layers[layer]) ? layers[layer] : [];\n for (const sheet of sheets) {\n if (typeof sheet !== \'string\' || sheet === \'\') say(where + \' names a sheet that is no name in \' + layer);\n else if (named.includes(sheet)) say(where + \' names \' + sheet + \' more than once\');\n else if (!isFile(join(root, at, \'skin\', sheet))) say(where + \' names \' + sheet + \', which skin/ holds not\');\n named.push(sheet);\n }\n }\n for (const sheet of sheetsIn(join(root, at, \'skin\')).toSorted())\n if (!named.includes(sheet)) say(at + \'/skin/\' + sheet + \' is named by no layer of skin/layers.json\');\n }\n if (isFolder(join(root, at, \'fonts\'))) {\n const where = at + \'/fonts/fonts.json\';\n const manifest = fieldsAt(join(root, where));\n const faces = manifest !== null && Array.isArray(manifest.faces) ? manifest.faces : null;\n if (faces === null) say(at + \' holds no fonts/fonts.json naming its faces\');\n else\n for (const face of faces) {\n const file = face !== null && typeof face === \'object\' ? face.file : undefined;\n const licence = face !== null && typeof face === \'object\' ? face.licence : undefined;\n if (typeof file !== \'string\' || file === \'\') say(where + \' names a face with no file\');\n else {\n if (!isFile(join(root, at, \'fonts\', file))) say(where + \' names \' + file + \', which fonts/ holds not\');\n if (typeof licence !== \'string\' || licence === \'\')\n say(where + \' names the face \' + file + \' with no licence\');\n }\n if (typeof licence === \'string\' && licence !== \'\' && !isFile(join(root, at, \'fonts\', licence)))\n say(where + \' names the licence \' + licence + \', which fonts/ holds not\');\n }\n }\n if (fieldsAt(join(root, at, \'versions.json\')) === null) say(at + \' holds no versions.json\');\n}\n\nconst sorted = (value) =>\n value !== null && typeof value === \'object\' && !Array.isArray(value)\n ? Object.fromEntries(\n Object.keys(value)\n .toSorted()\n .map((key) => [key, sorted(value[key])]),\n )\n : value;\nconst same = (one, other) => JSON.stringify(sorted(one)) === JSON.stringify(sorted(other));\nconst told = process.argv[3] === undefined ? null : fieldsAt(resolve(process.argv[3]));\nif (told !== null)\n for (const path of Object.keys(told).toSorted()) {\n if (!/^(?:faculties|designs)\\\\/[^/]+\\\\/versions\\\\.json$/.test(path) || typeof told[path] !== \'string\') continue;\n let was = null;\n try {\n was = JSON.parse(told[path]);\n } catch {}\n if (was === null || typeof was !== \'object\' || Array.isArray(was)) continue;\n if (!isFolder(join(root, path, \'..\'))) continue;\n const now = fieldsAt(join(root, path));\n for (const version of Object.keys(was).toSorted())\n if (now === null || !Object.hasOwn(now, version) || !same(now[version], was[version]))\n say(path + \' no longer holds \' + version + \' as the tag told it\');\n }\n\nconst rootManifest = fieldsAt(join(root, \'package.json\'));\nfor (const field of [\'dependencies\', \'devDependencies\', \'peerDependencies\', \'optionalDependencies\']) {\n const held = rootManifest?.[field];\n if (held !== null && typeof held === \'object\' && \'@nervur.org/genome\' in held)\n say(\n \'package.json names @nervur.org/genome in \' +\n field +\n \': the organism lends the genome it runs, a repo names none\',\n );\n}\n\nif (existsSync(join(root, \'.env\')))\n say(\'.env would enter main: .gitignore keeps it not out, and a secret file is never committed\');\n\nif (broken.length > 0) {\n console.log(broken.join(\'\\\\n\'));\n process.exit(1);\n}\nconsole.log(\'parts: each part stands as its folder says\');\n`;\n static #order(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n }\n static #fields(data) {\n return !!data && typeof data === "object" && !Array.isArray(data) && !ArrayBuffer.isView(data);\n }\n static #text(data) {\n return typeof data === "string" && data !== "";\n }\n static #texts(data) {\n return Array.isArray(data) ? data.flatMap((one) => _RepoLobe.#text(one) ? [one] : []) : [];\n }\n static #arg(args, key) {\n return _RepoLobe.#fields(args) ? args[key] : void 0;\n }\n static #shown(data) {\n return typeof data === "string" ? data : "none";\n }\n static #lastLine(text) {\n return text.trim().split("\\n").pop() ?? "";\n }\n static #headOf(out) {\n const last = _RepoLobe.#lastLine(out);\n return _RepoLobe.#hash.test(last) ? last : null;\n }\n static #lone = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/g;\n #bytes(text) {\n const encoded = this.codec.utf8(text.replace(_RepoLobe.#lone, "�"));\n return "bytes" in encoded ? encoded.bytes : null;\n }\n static #json(text) {\n try {\n const read = JSON.parse(text);\n return _RepoLobe.#fields(read) ? read : null;\n } catch {\n return null;\n }\n }\n static #holds(read, placeholder) {\n const all = "result" in read && Array.isArray(read.result) ? read.result : [];\n return all.some((one) => _RepoLobe.#fields(one) && one["placeholder"] === placeholder);\n }\n static #wiredTo(read, placeholder) {\n const all = "result" in read && Array.isArray(read.result) ? read.result : [];\n const wire = all.find((one) => _RepoLobe.#fields(one) && one["placeholder"] === placeholder);\n return _RepoLobe.#fields(wire) ? wire["termination"] ?? null : null;\n }\n #alarm(args) {\n return this.ask("scheduler", "set", args, void 0, { letter: { lives: _RepoLobe.#lives } });\n }\n #heard(answer) {\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : null;\n }\n #result(answer) {\n return "error" in answer ? this.error(answer.error.code, answer.error.message) : answer.result;\n }\n #digestOf(text) {\n const bytes = this.#bytes(text);\n return bytes === null ? "" : this.#shaOf(bytes);\n }\n #shaOf(bytes) {\n const hash = this.crypto.sha256(bytes);\n return hash instanceof Uint8Array ? Array.from(hash, (byte) => byte.toString(16).padStart(2, "0")).join("") : "";\n }\n static #canonical(bytes) {\n if (bytes.includes(0)) return bytes;\n const out = new Uint8Array(bytes.length);\n let length = 0;\n for (let at = 0; at < bytes.length; at += 1) {\n const byte = bytes[at] ?? 0;\n out[length] = byte === 13 ? 10 : byte;\n length += 1;\n if (byte === 13 && bytes[at + 1] === 10) at += 1;\n }\n return out.subarray(0, length);\n }\n #nonce() {\n return Array.from(this.stamp.seed.slice(0, 6), (byte) => byte.toString(16).padStart(2, "0")).join("");\n }\n #most() {\n return Math.min(CELLS_RANGE, Math.floor(this.memory / LOBE_SHARE / ITEM_SIZE));\n }\n #all(prefix) {\n return this.cells.range({ prefix: [...prefix], limit: this.#most() }).cells;\n }\n static #relation(data) {\n if (!_RepoLobe.#fields(data)) return null;\n const { far, side, placeholder, note } = data;\n if (!_RepoLobe.#text(far) || side !== "occupant" && side !== "standing") return null;\n return { far, side, placeholder: _RepoLobe.#text(placeholder) ? placeholder : null, note: note ?? null };\n }\n async #relations() {\n const all = [];\n let cursor = null;\n for (const seen = new Set(); ; ) {\n const read = await this.ask("nerves", "relations", cursor === null ? {} : { cursor });\n const result = "result" in read ? read.result : null;\n const found = _RepoLobe.#arg(result, "relations");\n for (const one of Array.isArray(found) ? found : []) {\n const relation = _RepoLobe.#relation(one);\n if (relation !== null) all.push(relation);\n }\n const next = _RepoLobe.#arg(result, "cursor");\n if (!_RepoLobe.#text(next) || seen.has(next)) break;\n seen.add(next);\n cursor = next;\n }\n return all;\n }\n async #endOfFar(far) {\n const read = await this.ask("nerves", "relation", { far });\n return "result" in read ? _RepoLobe.#relation(read.result) : null;\n }\n async #held() {\n const all = await this.#relations();\n return all.filter((one) => one.side === "standing" && !_RepoLobe.#tellsOn(one)).toSorted((a, b) => _RepoLobe.#order(a.placeholder ?? "", b.placeholder ?? ""));\n }\n async #given() {\n return (await this.#relations()).filter(\n (one) => one.side === "occupant" && _RepoLobe.#kindOf(one.note) !== _RepoLobe.#teller\n );\n }\n static #backUnder(prefix, far) {\n return `${prefix}-${far.toLowerCase()}`;\n }\n static #tellsOn(one) {\n return _RepoLobe.#text(_RepoLobe.#arg(one.note, "credential")) || [_RepoLobe.#tells, _RepoLobe.#hears].some((prefix) => one.placeholder?.startsWith(`${prefix}-`) === true);\n }\n async #untell(on) {\n for (const one of await this.#relations())\n if (one.side === "occupant" && _RepoLobe.#kindOf(one.note) === _RepoLobe.#teller && _RepoLobe.#arg(one.note, "on") === on)\n await this.ask("ear", "drop", { far: one.far });\n }\n static #kindOf(note) {\n const kind = _RepoLobe.#arg(note, "standing");\n return typeof kind === "string" && (_RepoLobe.#standings.includes(kind) || kind === _RepoLobe.#teller) ? kind : null;\n }\n static #scopeIn(note) {\n const scope = _RepoLobe.#arg(note, "scope");\n return Array.isArray(scope) ? _RepoLobe.#texts(scope) : null;\n }\n async #noted(far, note) {\n const wrote = await this.ask("nerves", "note", { far, note });\n return "error" in wrote ? wrote.error.message : null;\n }\n #repo() {\n const repo = this.cells.get(["repo"]);\n return _RepoLobe.#fields(repo) ? repo : null;\n }\n #role() {\n const { asker } = this.stamp;\n if (asker === _RepoLobe.#owner) return "owner";\n if (asker === _RepoLobe.#library) return "library";\n const occupant = this.stamp.occupant;\n if (occupant !== null && occupant.far === asker) {\n const kind = _RepoLobe.#arg(occupant.note, "standing");\n if (kind === "writer") return "pusher";\n if (kind === _RepoLobe.#teller) return "teller";\n if (kind === "reader" || kind === "library" || kind === "runner") return kind;\n return "stood";\n }\n const repo = this.#repo();\n if (repo !== null && repo["jailer"] === asker) return "jailer";\n return "near";\n }\n #refusal(method, args) {\n if (!(_RepoLobe.#who[method] ?? []).includes(this.#role()))\n return this.error("refused", `${method} is not the asker\'s to ask`);\n const repo = this.#repo();\n const named = _RepoLobe.#arg(args, "name");\n if (repo !== null && named !== void 0 && !["init", "accept"].includes(method) && named !== repo["name"])\n return this.error(\n "refused",\n `this lobe keeps the repo ${_RepoLobe.#shown(repo["name"])}, not ${_RepoLobe.#shown(named)}`\n );\n return null;\n }\n #ready() {\n const repo = this.#repo();\n if (repo === null || repo["ready"] !== true || !_RepoLobe.#text(repo["name"]))\n return this.error("refused", "the repo is not ready");\n return { name: repo["name"], repo };\n }\n async #jailer() {\n const jailer = _RepoLobe.#wiredTo(await this.nerves.read(), "repos");\n return _RepoLobe.#text(jailer) ? jailer : this.error("refused", "the lobe is wired to no repos");\n }\n #unmade(name) {\n if (!_RepoLobe.#text(name) || !_RepoLobe.#repoName.test(name))\n return this.error("refused", "a repo is named in lowercase, a letter first");\n const repo = this.#repo();\n const failed = repo !== null && repo["ready"] !== true && repo["head"] === null && repo["rebuilds"] === null && !_RepoLobe.#text(repo["doing"]) && _RepoLobe.#text(repo["failed"]);\n if (repo !== null && !failed)\n return this.error("refused", `the lobe keeps the repo ${_RepoLobe.#shown(repo["name"])} already`);\n return name;\n }\n static #fresh(name, jailer) {\n return {\n name,\n head: null,\n ready: false,\n failed: null,\n doing: null,\n synced: null,\n jailer,\n rebuilds: null\n };\n }\n async init(args) {\n const refused = this.#refusal("init", args);\n if (refused !== null) return refused;\n const name = this.#unmade(_RepoLobe.#arg(args, "name"));\n if (typeof name !== "string") return name;\n const unchecked = this.checked("init", args);\n if (unchecked !== void 0) return unchecked;\n const standing = _RepoLobe.#arg(args, "standing") === true;\n const starter = _RepoLobe.#arg(args, "starter") === true;\n if (standing && starter)\n return this.error("refused", "a repo handed in place keeps what it holds, and takes no starter");\n const jailer = await this.#jailer();\n if (typeof jailer !== "string") return jailer;\n this.cells.set(["repo"], _RepoLobe.#fresh(name, jailer));\n if (standing) return this.#begin("init", this.#checks(), null, { method: "stand" });\n return this.#begin("init", {}, null, starter ? { more: { starter: true } } : {});\n }\n #starterOf(name) {\n const version = "0.1.0";\n const label = `com.example.${name}`;\n const source = `import { Faculty } from \'nervur:faculty\';\n\nexport default class extends Faculty {\n static blueprint = { name: \'${label}\', version: \'${version}\', placeholders: {}, methods: { hello: { kind: \'reading\' } } };\n hello() { return \'hello from ${name}\'; }\n}\n`;\n const conform = `// This repo\'s own rules, run over what would enter its main. A rule broken prints why and exits 1.\nconsole.log(\'conform: no rule of this repo is broken\');\n`;\n const scripts = { gate: "node tools/conform.mjs", conform: "node tools/conform.mjs" };\n return {\n ".gitignore": ".env\\nnode_modules/\\ndist/\\n",\n "package.json": `${JSON.stringify({ name, version, private: true, scripts }, null, 2)}\n`,\n "tools/conform.mjs": conform,\n [`faculties/${label}/faculty.js`]: source,\n [`faculties/${label}/versions.json`]: `${JSON.stringify({ [version]: this.#digestOf(source) }, null, 2)}\n`\n };\n }\n async #layStarter(run, asker) {\n const name = _RepoLobe.#shown(this.#repo()?.["name"]);\n for (const [path, text] of Object.entries(this.#starterOf(name))) {\n const wrote = await this.ask("repos", "write", { path, text });\n if ("error" in wrote) return `${path}: ${wrote.error.message}`;\n }\n const begun = await this.#begin(\n "commit",\n { message: "the starter", ...this.#checks() },\n { commit: run },\n { asker }\n );\n return "job" in begun ? null : begun.message;\n }\n async #link(invitation, placeholder, name, note) {\n if (!_RepoLobe.#text(invitation)) return this.error("refused", "an invitation is named");\n const held = note === void 0 ? { repo: name ?? null, on: placeholder } : note;\n const accepted = await this.ask("mouth", "accept", { invitation, placeholder, note: held });\n if ("error" in accepted) return this.error(accepted.error.code, accepted.error.message);\n const far = _RepoLobe.#arg(accepted.result, "far");\n if (!_RepoLobe.#text(far)) return this.error("refused", "the mouth named no far organism");\n return { placeholder, far };\n }\n async #free() {\n const held = new Set((await this.#held()).map((one) => one.placeholder));\n let at = 1;\n while (held.has(`${_RepoLobe.#lobe}-${at}`)) at += 1;\n return `${_RepoLobe.#lobe}-${at}`;\n }\n async #standingOn(on) {\n const all = await this.#held();\n if (on !== void 0) {\n const one = all.find((held) => held.placeholder === on);\n return one === void 0 || one.placeholder === null ? this.error("absent", `this lobe stands on no lobe as ${_RepoLobe.#shown(on)}`) : { placeholder: one.placeholder, far: one.far };\n }\n const [only] = all;\n if (only === void 0 || only.placeholder === null)\n return this.error("refused", "this lobe stands on no other: relink it");\n if (all.length > 1) return this.error("refused", "this lobe stands on several: name the one, `on`");\n return { placeholder: only.placeholder, far: only.far };\n }\n async accept(args) {\n const refused = this.#refusal("accept", args);\n if (refused !== null) return refused;\n const name = this.#unmade(_RepoLobe.#arg(args, "name"));\n if (typeof name !== "string") return name;\n const jailer = await this.#jailer();\n if (typeof jailer !== "string") return jailer;\n const placeholder = await this.#free();\n const linked = await this.#link(_RepoLobe.#arg(args, "invitation"), placeholder, name, _RepoLobe.#arg(args, "note"));\n if (!("far" in linked)) return linked;\n this.cells.set(["repo"], _RepoLobe.#fresh(name, jailer));\n return this.#begin("init", {}, null, { more: { pulls: placeholder } });\n }\n async relink(args) {\n const refused = this.#refusal("relink", args);\n if (refused !== null) return refused;\n if (this.#holdsScope()) return this.error("refused", "a lobe born of a scope stands on no other");\n if (this.cells.get(["sync"]) !== void 0)\n return this.error("refused", "the repo pulls or pushes: wait for it to end");\n const instead = _RepoLobe.#arg(args, "instead");\n const was = instead === void 0 ? null : await this.#standingOn(instead);\n if (was !== null && !("far" in was)) return was;\n const replaced = was === null ? null : was["placeholder"];\n const named = _RepoLobe.#arg(args, "placeholder");\n if (typeof named === "string" && named !== replaced && _RepoLobe.#holds(await this.nerves.read(), named))\n return this.error("refused", `this lobe holds ${named} already`);\n const placeholder = typeof named === "string" ? named : _RepoLobe.#text(replaced) ? replaced : await this.#free();\n const taken = was !== null && placeholder === replaced;\n if (taken) await this.#unlink(was);\n const name = this.#repo()?.["name"];\n const linked = await this.#link(_RepoLobe.#arg(args, "invitation"), placeholder, name, _RepoLobe.#arg(args, "note"));\n if (!("far" in linked)) return linked;\n if (was !== null && !taken) await this.#unlink(was);\n return { on: placeholder, far: linked["far"] ?? null };\n }\n async #unlink(was) {\n const placeholder = was["placeholder"];\n if (!_RepoLobe.#text(placeholder)) return;\n if (!placeholder.startsWith(`${_RepoLobe.#tells}-`)) await this.#untell(placeholder);\n if (_RepoLobe.#text(was["far"])) await this.ask("mouth", "drop", { far: was["far"] });\n await this.nerves.unwire(placeholder);\n }\n async invite(args) {\n const refused = this.#refusal("invite", args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n if (this.#holdsScope()) return this.error("refused", "a lobe holding a scope gives no occupant");\n const standing = _RepoLobe.#arg(args, "standing");\n if (typeof standing !== "string" || !_RepoLobe.#standings.includes(standing))\n return this.error("refused", "a standing is a reader, a writer, a library or a runner");\n const scripts = _RepoLobe.#arg(args, "scripts");\n const named = Array.isArray(scripts) ? scripts : [];\n if (standing === "runner" && (named.length === 0 || !named.every((one) => _RepoLobe.#text(one) && _RepoLobe.#script.test(one))))\n return this.error("refused", "a runner runs scripts of the repo\'s package, one or more");\n if (standing !== "runner" && scripts !== void 0)\n return this.error("refused", "scripts are a runner’s alone");\n const asked = _RepoLobe.#arg(args, "scope");\n const scope = asked === void 0 ? null : _RepoLobe.#scopeOf(asked);\n if (asked !== void 0 && (standing === "library" || standing === "runner"))\n return this.error("refused", `a ${standing}\'s standing is never scoped`);\n if (asked !== void 0 && scope === null)\n return this.error(\n "refused",\n `a scope is 1 to ${_RepoLobe.#scopeMost} folders of the repo, each of names of letters, digits, ., _ and -, none ., .. nor .git, none inside another`\n );\n const waits = _RepoLobe.#arg(args, "waits") ?? null;\n const lives = _RepoLobe.#arg(args, "lives") ?? null;\n const owned = _RepoLobe.#arg(args, "note");\n const base = owned === void 0 || owned === null ? {} : _RepoLobe.#fields(owned) ? owned : { note: owned };\n const note = {\n ...base,\n repo: ready.name,\n standing,\n ...scope === null ? {} : { scope },\n ...standing === "runner" ? { scripts: named } : {}\n };\n const through = _RepoLobe.#arg(args, "through");\n const line = through === void 0 ? {} : { through };\n const invited = await this.ask("ear", "invite", { waits, lives, note, ...line });\n if ("error" in invited) return this.#heard(invited);\n const far = _RepoLobe.#arg(invited.result, "far");\n if (!_RepoLobe.#text(far)) return this.error("refused", "the ear named no far organism");\n return invited.result;\n }\n static #scopeOf(scope) {\n if (!Array.isArray(scope) || scope.length < 1 || scope.length > _RepoLobe.#scopeMost) return null;\n const folders = scope.flatMap((one) => typeof one === "string" ? [one] : []);\n const fit = (one) => one.split("/").every((name) => _RepoLobe.#segment.test(name) && ![".", "..", ".git"].includes(name));\n if (folders.length !== scope.length || !folders.every(fit)) return null;\n const sorted = folders.toSorted();\n const nested = sorted.some(\n (one, at) => sorted.some((other, by) => by !== at && (one === other || one.startsWith(`${other}/`)))\n );\n return nested ? null : sorted;\n }\n #scopeOfAsker() {\n const occupant = this.stamp.occupant;\n return occupant === null ? null : _RepoLobe.#scopeIn(occupant.note);\n }\n async #scopeFor(far) {\n if (this.stamp.occupant?.far === far) return this.#scopeOfAsker();\n const found = await this.#endOfFar(far);\n return found === null ? null : _RepoLobe.#scopeIn(found.note);\n }\n #holdsScope() {\n return this.#repo()?.["cut"] === true;\n }\n async drop(args) {\n const refused = this.#refusal("drop", args);\n if (refused !== null) return refused;\n const [named, on] = [_RepoLobe.#arg(args, "far"), _RepoLobe.#arg(args, "on")];\n if (on !== void 0) {\n const held = await this.#standingOn(on);\n if (!("far" in held)) return held;\n if (_RepoLobe.#arg(this.cells.get(["sync"]), "on") === on)\n return this.error("refused", "the repo pulls or pushes over it: wait for it to end");\n await this.#unlink(held);\n return null;\n }\n const far = named;\n const given = _RepoLobe.#text(far) ? await this.#endOfFar(far) : null;\n if (!_RepoLobe.#text(far) || given === null || given.side !== "occupant")\n return this.error("absent", "no standing is held by that far organism");\n const dropped = await this.ask("ear", "drop", { far });\n if ("error" in dropped) return this.#heard(dropped);\n await this.#forgetFar(far, given.note);\n return null;\n }\n async left(args) {\n const far = _RepoLobe.#arg(args, "far");\n if (_RepoLobe.#text(far)) await this.#forgetFar(far, _RepoLobe.#arg(args, "note") ?? null);\n if (_RepoLobe.#text(far)) {\n this.cells.delete(["token", far]);\n this.cells.delete(["credential", far]);\n }\n const on = _RepoLobe.#arg(_RepoLobe.#arg(args, "note"), "on");\n if (_RepoLobe.#text(on) && !(await this.#held()).some((one) => one.placeholder === on)) await this.#untell(on);\n const sync = this.cells.get(["sync"]);\n if (_RepoLobe.#fields(sync) && !(await this.#held()).some((one) => one.placeholder === sync["on"]))\n await this.#finish(sync, 1, "the lobe stands on that lobe no more");\n return null;\n }\n async #forgetFar(far, note) {\n if (_RepoLobe.#kindOf(note) === "writer") await this.#untold(far);\n if (_RepoLobe.#kindOf(note) === "library") await this.#untold(far, _RepoLobe.#hears);\n for (const kept of ["out", "in"]) {\n if (this.cells.get([kept, far]) === void 0) continue;\n this.cells.delete([kept, far]);\n await this.#clear(`${kept}-${far}`);\n }\n }\n async occupants(args) {\n const refused = this.#refusal("occupants", args);\n if (refused !== null) return refused;\n return (await this.#given()).map(({ far, note }) => {\n const scope = _RepoLobe.#scopeIn(note);\n return { far, role: _RepoLobe.#kindOf(note), ...scope === null ? {} : { scope } };\n });\n }\n async migrate(args) {\n const refused = this.#refusal("migrate", args);\n if (refused !== null) return refused;\n const rearmed = await this.#rearm();\n if (this.#repo() !== null) {\n this.cells.set(["owed"], true);\n await this.#owing();\n await this.#awaiting();\n }\n return rearmed;\n }\n async #owing() {\n if (this.cells.get(["owed"]) !== true) return;\n const repo = this.#repo();\n const idle = !_RepoLobe.#text(repo?.["doing"]) && !_RepoLobe.#fields(this.cells.get(["sync"]));\n if (_RepoLobe.#text(repo?.["head"]) && idle && "name" in this.#ready())\n await this.#begin("scan", {}, { scan: null }, { asker: _RepoLobe.#owner });\n }\n async #awaiting() {\n if (this.cells.get(["owed"]) !== true || this.cells.get(["owes"]) !== void 0) return;\n const chain = this.#nonce();\n const set = await this.#alarm({ at: this.stamp.time + MINUTE, method: "keep", args: { chain } });\n if (!("error" in set)) this.cells.set(["owes"], chain);\n }\n async keep(args) {\n const owes = this.cells.get(["owes"]);\n if (typeof owes !== "string" || owes !== _RepoLobe.#arg(args, "chain")) return null;\n await this.#check();\n await this.#owing();\n if (this.cells.get(["owed"]) === true) return { again: this.stamp.time + MINUTE };\n this.cells.delete(["owes"]);\n return null;\n }\n #scanning() {\n const doing = this.#repo()?.["doing"];\n return _RepoLobe.#text(doing) && _RepoLobe.#arg(this.cells.get(["job", doing]), "kind") === "scan";\n }\n async #rearm() {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync)) return null;\n const chain = this.#nonce();\n this.cells.set(["sync"], { ...sync, chain });\n const set = await this.#alarm({ at: this.stamp.time + _RepoLobe.#every, method: "tick", args: { chain } });\n return "error" in set ? this.error(set.error.code, set.error.message) : null;\n }\n gate(args) {\n const refused = this.#refusal("gate", args);\n if (refused !== null) return refused;\n const script = _RepoLobe.#arg(args, "script");\n if (script !== null && !(_RepoLobe.#text(script) && _RepoLobe.#script.test(script)))\n return this.error("refused", "a gate is a script of the repo\'s package, or null");\n this.cells.set(["gate"], script ?? null);\n return null;\n }\n #gateScript() {\n const held = this.cells.get(["gate"]);\n return held === void 0 ? "gate" : held;\n }\n #gates() {\n const held = this.cells.get(["gates"]);\n const [commit, push] = [_RepoLobe.#arg(held, "commit"), _RepoLobe.#arg(held, "push")];\n return {\n commit: typeof commit === "string" && _RepoLobe.#onCommit.includes(commit) ? commit : "on",\n push: push === "on" ? "on" : "off"\n };\n }\n gates(args) {\n const refused = this.#refusal("gates", args);\n if (refused !== null) return refused;\n const [commit, push] = [_RepoLobe.#arg(args, "commit"), _RepoLobe.#arg(args, "push")];\n if (commit !== void 0 && !(typeof commit === "string" && _RepoLobe.#onCommit.includes(commit)))\n return this.error("refused", "on commit, the gate is off, on or mandatory");\n if (push !== void 0 && !(typeof push === "string" && _RepoLobe.#onPush.includes(push)))\n return this.error("refused", "on push, the gate is off or on");\n const now = this.#gates();\n const set = {\n commit: typeof commit === "string" ? commit : now.commit,\n push: typeof push === "string" ? push : now.push\n };\n this.cells.set(["gates"], set);\n return set;\n }\n conform(args) {\n const refused = this.#refusal("conform", args);\n if (refused !== null) return refused;\n const take = _RepoLobe.#arg(args, "take");\n if (typeof take !== "boolean") return this.error("refused", "take is true or false");\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n if (!take) {\n this.cells.delete(["conform"]);\n return null;\n }\n const head = ready.repo["head"];\n if (!_RepoLobe.#text(head)) return this.error("refused", "main holds no commit to take its conform from");\n this.cells.set(["conform"], head);\n return head;\n }\n author(args) {\n const refused = this.#refusal("author", args);\n if (refused !== null) return refused;\n const lobe = _RepoLobe.#arg(args, "lobe");\n if (lobe === null) {\n this.cells.delete(["author"]);\n return null;\n }\n if (!_RepoLobe.#text(lobe) || lobe === _RepoLobe.#owner)\n return this.error("refused", "an author is a wired lobe, named by its ID");\n this.cells.set(["author"], lobe);\n return null;\n }\n async remove(args) {\n const refused = this.#refusal("remove", args);\n if (refused !== null) return refused;\n const repo = this.#repo();\n if (repo === null) return this.error("absent", "the lobe keeps no repo");\n if ((await this.#given()).length > 0) return this.error("refused", "far standings hold the repo: drop them first");\n if (_RepoLobe.#text(repo["doing"]) || this.cells.get(["sync"]) !== void 0)\n return this.error("refused", "the repo runs a job: wait for it to end");\n for (const kept of [\n "told",\n "built",\n "look",\n "parts",\n "job",\n "by",\n "out",\n "in",\n "back",\n "secret",\n "token",\n "credential"\n ])\n for (const { key } of this.#all([kept])) this.cells.delete(key);\n for (const kept of ["repo", "gate", "gates", "conform", "author", "scanned", "owed", "owes", "env", "renews"])\n this.cells.delete([kept]);\n return null;\n }\n async rebuild(args) {\n const refused = this.#refusal("rebuild", args);\n if (refused !== null) return refused;\n const repo = this.#repo();\n if (repo === null) return this.error("refused", "the lobe keeps no repo");\n if (_RepoLobe.#text(repo["doing"]) || this.cells.get(["sync"]) !== void 0)\n return this.error("refused", "the repo runs a job: wait for it to end");\n const rebuilds = repo["rebuilds"] ?? repo["head"] ?? null;\n this.cells.set(["repo"], { ...repo, ready: false, head: null, rebuilds });\n return this.#begin("init", {}, { rebuild: true });\n }\n async state(args) {\n const refused = this.#refusal("state", args);\n if (refused !== null) return refused;\n const repo = this.#repo();\n if (repo === null) return null;\n if (this.#role() === "library") return { name: repo["name"] ?? null };\n const held = this.#result(await this.ask("repos", "state", {}));\n const folder = _RepoLobe.#arg(held, "folder") ?? null;\n const relations = await this.#relations();\n const stood = relations.filter((one) => one.side === "standing" && !_RepoLobe.#text(_RepoLobe.#arg(one.note, "credential"))).toSorted((a, b) => _RepoLobe.#order(a.placeholder ?? "", b.placeholder ?? ""));\n const given = relations.filter((one) => one.side === "occupant");\n const on = stood.map(({ placeholder, far }) => ({ placeholder, far }));\n const writers = given.filter(({ note }) => _RepoLobe.#kindOf(note) === "writer").length;\n const author = this.cells.get(["author"]);\n const conform = this.cells.get(["conform"]);\n const sync = this.cells.get(["sync"]) ?? null;\n const syncing = _RepoLobe.#fields(sync) ? Object.fromEntries(Object.entries(sync).filter(([key]) => key !== "tells")) : sync;\n const scopes = given.flatMap(({ far, note }) => {\n const scope = _RepoLobe.#scopeIn(note);\n return scope === null ? [] : [{ far, scope }];\n });\n const scoped = stood.flatMap(({ placeholder, note }) => {\n const scope = _RepoLobe.#scopeIn(note);\n return scope === null ? [] : [{ on: placeholder, scope }];\n });\n const { cut: _, ...whole } = repo;\n const lost = repo["ready"] === true && _RepoLobe.#arg(held, "made") === false;\n return {\n ...whole,\n ...lost ? {\n ready: false,\n absent: "its folder holds no repo: a backup carries no repo\'s bytes; rebuild fills it again, pulled whole from a lobe it stands on or pushed whole by one that stands on it"\n } : {},\n on,\n writers,\n folder,\n syncing,\n gate: this.#gateScript(),\n gates: this.#gates(),\n ..._RepoLobe.#text(conform) ? { conform } : {},\n ..._RepoLobe.#text(author) ? { author } : {},\n ...scopes.length > 0 ? { scopes } : {},\n ...scoped.length > 0 ? { scoped } : {},\n ..._RepoLobe.#fields(_RepoLobe.#arg(this.cells.get(["scanned"]), "cut")) ? { cut: _RepoLobe.#arg(this.cells.get(["scanned"]), "cut") ?? null } : {},\n ...this.#role() === "library" ? {} : await this.#keysShown()\n };\n }\n async #keysShown() {\n const issued = await this.#credentials();\n const credentials = issued.map(({ secret, far }) => {\n const cell = this.cells.get(["credential", far]);\n const url = _RepoLobe.#arg(cell, "url");\n const failed = _RepoLobe.#arg(cell, "failed");\n const expires = _RepoLobe.#arg(cell, "expires");\n const renews = _RepoLobe.#arg(cell, "renews");\n return {\n secret,\n far,\n pending: _RepoLobe.#arg(cell, "pending") === true,\n ..._RepoLobe.#text(url) ? { url } : {},\n ..._RepoLobe.#text(failed) ? { failed } : {},\n ...typeof expires === "number" && typeof renews === "number" ? { expires, renews } : {}\n };\n });\n const secrets = Object.keys(await this.#keys()).toSorted();\n return { ...secrets.length > 0 ? { secrets } : {}, ...credentials.length > 0 ? { credentials } : {} };\n }\n jobs(args) {\n const refused = this.#refusal("jobs", args);\n if (refused !== null) return refused;\n const { asker } = this.stamp;\n const page = this.#page(asker === _RepoLobe.#owner ? ["job"] : ["by", asker], args);\n if (!("cells" in page)) return page;\n const held = asker === _RepoLobe.#owner ? page.cells.map(({ value }) => value) : page.cells.map(({ key }) => this.cells.get(["job", key[2] ?? ""]) ?? null);\n return { jobs: held.map((one) => _RepoLobe.#brief(one)), cursor: page.cursor };\n }\n #page(prefix, args) {\n const cursor = _RepoLobe.#arg(args, "cursor") ?? null;\n if (cursor !== null && !_RepoLobe.#text(cursor)) return this.error("refused", "a cursor is the one a page answered");\n try {\n return this.cells.range({ prefix: [...prefix], limit: this.#most(), ...cursor === null ? {} : { cursor } });\n } catch {\n return this.error("refused", "a cursor is the one a page answered");\n }\n }\n static #brief(held) {\n if (!_RepoLobe.#fields(held) || !_RepoLobe.#fields(held["ended"])) return held;\n const { run, code, at } = held["ended"];\n return { ...held, ended: { run: run ?? null, code: code ?? null, at: at ?? null } };\n }\n job(args) {\n const refused = this.#refusal("job", args);\n if (refused !== null) return refused;\n const run = _RepoLobe.#arg(args, "job");\n if (!_RepoLobe.#text(run)) return this.error("refused", "a job is named by its id");\n const { asker } = this.stamp;\n const held = this.cells.get(["job", run]);\n const owns = asker === _RepoLobe.#owner || this.cells.get(["by", asker, run]) !== void 0;\n if (owns && _RepoLobe.#fields(held)) return held;\n const sync = this.cells.get(["sync"]);\n const last = this.#repo()?.["synced"];\n for (const one of [sync, last]) {\n if (!_RepoLobe.#fields(one) || one["job"] !== run) continue;\n if (asker !== _RepoLobe.#owner && one["asker"] !== asker) break;\n const ended = one === sync ? null : { code: one["code"] ?? null, err: one["err"] ?? null };\n return { job: run, kind: one["kind"] ?? null, stage: one === sync ? one["stage"] ?? null : null, ended };\n }\n return this.error("absent", "no such job");\n }\n async #begin(kind, given, step, { more = {}, asker = this.stamp.asker, method = kind } = {}) {\n const repo = this.#repo();\n if (repo === null) return this.error("refused", "the lobe keeps no repo");\n if (!_RepoLobe.#text(repo["doing"])) await this.#unclear();\n if (_RepoLobe.#text(repo["doing"])) {\n await this.#check();\n return this.error("refused", `the repo runs ${repo["doing"]} already`);\n }\n const back = step === null && this.#role() !== "runner" ? await this.#back(asker) : null;\n if (back !== null) return back;\n const begun = await this.ask("repos", method, given);\n if ("error" in begun) return this.error(begun.error.code, begun.error.message);\n const run = _RepoLobe.#arg(begun.result, "job");\n if (!_RepoLobe.#text(run)) return this.error("refused", "the jailer named no job");\n const owing = kind === "scan" && this.cells.get(["owed"]) === true;\n const of = step === null ? {} : { step: owing ? { ...step, owed: true } : step };\n this.cells.set(["job", run], {\n job: run,\n kind,\n asker,\n repo: repo["name"] ?? null,\n ...of,\n ...more,\n began: this.stamp.time,\n ended: null\n });\n if (step === null) this.cells.set(["by", asker, run], null);\n this.cells.set(["repo"], { ...repo, doing: run });\n return { job: run };\n }\n async #back(asker) {\n if (asker === _RepoLobe.#owner || this.cells.get(["back", asker]) !== void 0) return null;\n const ordered = await this.nerves.order({ termination: asker });\n if ("error" in ordered) return this.error("refused", `no wire back: ${ordered.error.message}`);\n this.cells.set(["back", asker], true);\n return null;\n }\n async done(args) {\n if (this.#role() === "teller") return this.#told(args);\n const read = await this.nerves.read();\n if (_RepoLobe.#wiredTo(read, "repos") !== this.stamp.asker)\n return this.error("refused", "only the jailer tells a job ended");\n const { job: run, code: ended, out: said, err: wrote } = _RepoLobe.#fields(args) ? args : {};\n const whole = typeof said === "string" && typeof wrote === "string" && typeof ended === "number";\n const held = _RepoLobe.#text(run) ? this.cells.get(["job", run]) : void 0;\n if (!whole || !_RepoLobe.#text(run) || !_RepoLobe.#fields(held) || held["ended"] !== null)\n return this.error("refused", "no such job going");\n return this.#jobEnded(read, run, held, ended, said, wrote);\n }\n async #jobEnded(read, run, held, ended, said, wrote) {\n this.#torn(read);\n const [out, err] = [this.#masked(said), this.#masked(wrote)];\n if (_RepoLobe.#text(held["gating"])) return this.#gated(held, run, ended, out, err);\n if (_RepoLobe.#fields(held["running"])) return this.#writtenThen(held, run, ended, err);\n const filed = held["kind"] !== "commit" ? err : ended === 0 ? err : await this.#undone(err);\n if (held["kind"] === "commit" && ended === 0) this.cells.delete(["undo"]);\n const [code, told] = this.#halfKept(held, ended, out, filed);\n this.#settled(held, code, out, told);\n const before = this.cells.get(["sync"]);\n const more = await this.#further(run, held, code, out, told);\n if (more !== null) await this.#closed(run, held, code, out, told, more);\n await this.#rung(before);\n await this.#tellEnds();\n await this.#receiveWaiting();\n const step = held["step"];\n const tried = _RepoLobe.#fields(step) && step["owed"] === true || more !== null && more["scan"] !== void 0;\n if (!tried) await this.#owing();\n return null;\n }\n async #further(run, held, code, out, err) {\n const asker = _RepoLobe.#text(held["asker"]) ? held["asker"] : _RepoLobe.#owner;\n const pulls = held["pulls"];\n if (held["kind"] === "init" && code === 0 && _RepoLobe.#text(pulls))\n return this.#pulled(run, held, out, pulls, asker);\n if (_RepoLobe.#fields(held["step"]) && held["step"]["rebuild"] === true) {\n const first = await this.#rebuilt(code === 0 ? null : _RepoLobe.#lastLine(err) || `the job ended ${code}`);\n return _RepoLobe.#text(first) ? this.#pulled(run, held, out, first, _RepoLobe.#owner) : {};\n }\n if (held["kind"] === "init" && code === 0 && held["starter"] === true) {\n const why = await this.#layStarter(run, asker);\n return why === null ? null : { starter: why };\n }\n const moved = code === 0 && typeof held["kind"] === "string" && _RepoLobe.#moves.includes(held["kind"]);\n if (!moved || !_RepoLobe.#text(this.#repo()?.["head"])) return {};\n const begun = await this.#begin("scan", {}, { scan: run, code, out, err }, { asker });\n if ("job" in begun) return null;\n this.cells.set(["owed"], true);\n await this.#awaiting();\n return { scan: { code: 1, err: `the scan did not begin: ${begun.message}` } };\n }\n async #pulled(run, held, out, on, asker) {\n const begun = await this.#start("pull", asker, on, { of: run });\n if (_RepoLobe.#text(_RepoLobe.#arg(begun, "job"))) return null;\n await this.#closed(\n run,\n held,\n 1,\n out,\n `the pull did not begin: ${_RepoLobe.#shown(_RepoLobe.#arg(begun, "message"))}`,\n {}\n );\n return null;\n }\n async #closed(run, held, code, out, err, more) {\n this.cells.set(["job", run], { ...held, ended: { run, code, out, err, ...more, at: this.stamp.time } });\n const step = held["step"];\n if (!_RepoLobe.#fields(step)) return this.#ended(held, code, out, err, more);\n await this.#stepped(step, held, code, out, err, more);\n if (step["rebuild"] === true) this.#endKept(_RepoLobe.#owner, run);\n else this.cells.delete(["job", run]);\n }\n async #scannedThen(step, code, err) {\n const run = step["scan"];\n const held = _RepoLobe.#text(run) ? this.cells.get(["job", run]) : void 0;\n if (!_RepoLobe.#text(run) || !_RepoLobe.#fields(held) || held["ended"] !== null) return;\n const scan = { code, err: code === 0 ? "" : _RepoLobe.#last(err) || `the scan ended ${code}` };\n const [out, said] = [step["out"], step["err"]].map((one) => typeof one === "string" ? one : "");\n await this.#closed(run, held, Number(step["code"]), out ?? "", said ?? "", { scan });\n }\n #halfKept(held, code, out, err) {\n const built = held["built"];\n if (code !== 0 || !_RepoLobe.#fields(built)) return [code, err];\n if (_RepoLobe.#text(built["design"])) return [code, err];\n const [organ, version] = [_RepoLobe.#shown(built["organ"]), _RepoLobe.#shown(built["version"])];\n const kept = this.cells.get(["built", organ, version]);\n const digest = out.trim();\n if (typeof kept !== "string" || kept === digest) return [code, err];\n return [\n 1,\n `the host half of ${organ} ${version} was built as ${kept}, and this build gives ${digest}: a version is never told with other bytes, so raise its version`\n ];\n }\n #settled(held, code, out, err) {\n const repo = this.#repo();\n if (repo === null) return;\n const { kind } = held;\n const failed = code === 0 ? null : _RepoLobe.#lastLine(err);\n const made = kind === "init" ? { ready: code === 0, failed } : {};\n const moved = code === 0 && typeof kind === "string" && _RepoLobe.#moves.includes(kind);\n const now = moved ? _RepoLobe.#headOf(out) : null;\n const head = moved ? { head: now } : {};\n this.cells.set(["repo"], { ...repo, ...made, ...head, doing: null });\n if (now !== null && kind !== "land" && out.split("\\n").includes(`conform ${now}`)) this.cells.set(["conform"], now);\n }\n async #ended(held, code, out, err, more = {}) {\n const { asker, kind, job: run } = held;\n if (_RepoLobe.#text(asker) && _RepoLobe.#text(run) && this.cells.get(["by", asker, run]) !== void 0)\n this.#endKept(asker, run);\n const built = held["built"];\n const digest = out.trim();\n if (code === 0 && _RepoLobe.#fields(built)) {\n if (_RepoLobe.#text(built["design"])) this.#looked(built, out);\n else if (_RepoLobe.#digest.test(digest))\n this.cells.set(["built", _RepoLobe.#shown(built["organ"]), _RepoLobe.#shown(built["version"])], digest);\n }\n if (!_RepoLobe.#text(asker) || this.cells.get(["back", asker]) === void 0) return;\n const told = { job: run ?? null, kind: kind ?? null, code, out, err, ...more };\n await this.ask(asker, "done", told, void 0, { letter: { lives: _RepoLobe.#lives } });\n }\n #endKept(asker, run) {\n const ends = this.cells.get(["ended", asker]);\n let first = Number(_RepoLobe.#arg(ends ?? null, "first") ?? 0);\n const next = Number(_RepoLobe.#arg(ends ?? null, "next") ?? 0);\n for (; next - first >= Math.max(1, this.#most()); first += 1) {\n const oldest = this.cells.get(["ended", asker, String(first)]);\n if (_RepoLobe.#text(oldest)) {\n this.cells.delete(["job", oldest]);\n this.cells.delete(["by", asker, oldest]);\n }\n this.cells.delete(["ended", asker, String(first)]);\n }\n this.cells.set(["ended", asker, String(next)], run);\n this.cells.set(["ended", asker], { first, next: next + 1 });\n }\n #looked(built, source) {\n const [name, version] = [_RepoLobe.#shown(built["design"]), _RepoLobe.#shown(built["version"])];\n const told = _RepoLobe.#arg(this.cells.get(["told", "faculty", `${name}.look`, version]), "digest");\n const digest = this.#digestOf(source);\n if (digest === told) {\n this.cells.set(["look", name, version], { source });\n return;\n }\n if (_RepoLobe.#text(_RepoLobe.#arg(this.cells.get(["look", name, version]), "source"))) return;\n const why = `the look built is ${digest}, not the ${_RepoLobe.#shown(told)} versions.json told`;\n this.cells.set(["look", name, version], { why });\n }\n async #stepped(step, held, code, out, err, more) {\n const why = code === 0 ? null : _RepoLobe.#lastLine(err) || `the job ended ${code}`;\n if (_RepoLobe.#text(step["commit"])) {\n await this.#commitEnded(step["commit"], code, out, err, more);\n return void 0;\n }\n if (_RepoLobe.#text(step["ran"])) {\n const kind = _RepoLobe.#text(held["kind"]) ? held["kind"] : "run";\n return this.#workEnded(step["ran"], kind, code, out, err);\n }\n if (_RepoLobe.#text(step["check"])) return this.#checked(step["check"], { code, out, err });\n if (step["scan"] !== void 0) {\n if (code === 0) await this.#scanned(out);\n if (code === 0 && step["owed"] === true) this.cells.delete(["owed"]);\n else if (step["owed"] === true) await this.#awaiting();\n return this.#scannedThen(step, code, err);\n }\n if (_RepoLobe.#text(step["for"])) return this.#served(step["for"], held["kind"], why, out);\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync)) return;\n if (held["kind"] === "bring") return this.#broughtPull(sync, why, out);\n if (held["kind"] === "land") return this.#landed(sync, why);\n if (sync["stage"] === "proving") return this.#proven(sync, code, why, out);\n if (why !== null) return this.#finish(sync, code, why);\n const pieces = Number(out.trim().split("\\n")[0]);\n if (pieces === 0) return this.#finish(sync, 0, "");\n this.cells.set(["sync"], { ...sync, stage: "sending", at: 0, pieces });\n return void 0;\n }\n async #broughtPull(sync, why, out) {\n if (why !== null) return this.#finish(sync, 1, why);\n const [head = "", how = ""] = out.trim().split("\\n");\n if (how === "held" || !_RepoLobe.#hash.test(head)) return this.#finish(sync, 0, "");\n const check = await this.#conform("pull", head, false, _RepoLobe.#askerOf(sync));\n const checking = { ...sync, stage: "checking", theirs: head, check };\n this.cells.set(["sync"], checking);\n if ("code" in check) await this.#checkedPull(checking, check);\n return void 0;\n }\n async #checkedPull(sync, check) {\n if (check["code"] !== 0) return this.#finish(sync, 1, _RepoLobe.#refusalOf(check), check);\n const begun = await this.#begin("land", { as: "pull" }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.cells.set(["sync"], { ...sync, stage: "landing" });\n else await this.#finish(sync, 1, begun.message, check);\n return void 0;\n }\n async #landed(sync, why) {\n const check = sync["check"] ?? null;\n if (why !== null) return this.#finish(sync, 1, why, check);\n const rebuilds = this.#repo()?.["rebuilds"];\n if (!_RepoLobe.#text(rebuilds)) return this.#finish(sync, 0, "", check);\n const begun = await this.#begin("head", { contains: rebuilds }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.cells.set(["sync"], { ...sync, stage: "proving" });\n else await this.#finish(sync, 1, begun.message, check);\n return void 0;\n }\n async #proven(sync, code, why, out) {\n const repo = this.#repo();\n const holds = code === 0 && out.trim().split("\\n")[1] === "holds";\n if (repo !== null && holds) this.cells.set(["repo"], { ...repo, rebuilds: null });\n const lacks = "the lobe pulled holds not the head this one kept: it waits for a whole push";\n return this.#finish(sync, holds ? 0 : 1, holds ? "" : why ?? lacks, sync["check"] ?? null);\n }\n async #rebuilt(why) {\n const repo = this.#repo();\n if (repo === null) return null;\n this.cells.set(["repo"], { ...repo, head: null, ready: why === null, failed: why });\n const first = why === null ? (await this.#held())[0]?.placeholder : null;\n return _RepoLobe.#text(first) ? first : null;\n }\n async #scanned(out) {\n const [shown = "", toldBlock = ""] = out.trim().split("\\n@ ");\n const [head = "", ...lines] = shown.split("\\n");\n const tracked = new Set(lines.filter((line) => line.startsWith("t ")).map((line) => line.slice(2)));\n const changed = new Set(lines.filter((line) => line.startsWith("c ")).map((line) => line.slice(2)));\n const tagged = lines.some((line) => line.startsWith("g "));\n const cut = {};\n const named = (kind, pattern) => {\n const all = [...tracked].flatMap((path) => pattern.exec(path)?.[1] ?? []).toSorted();\n if (all.length > this.#most()) cut[kind] = all.length - this.#most();\n return all.slice(0, this.#most());\n };\n const files = _RepoLobe.#hashedFiles(lines);\n const faculties = [];\n for (const label of named("faculties", /^faculties\\/([^/]+)\\/faculty\\.js$/))\n faculties.push(await this.#faculty(label, tracked, changed, files, tagged));\n const organs = [];\n for (const id of named("organs", /^organs\\/([^/]+)\\/graph\\.json$/))\n organs.push(await this.#organ(id, tracked, changed, tagged));\n const designs = [];\n for (const name of named("designs", /^designs\\/([^/]+)\\/design\\.json$/))\n designs.push(await this.#design(name, tracked, changed, files, tagged));\n this.cells.set(["scanned"], {\n head,\n faculties,\n organs,\n designs,\n ...Object.keys(cut).length > 0 ? { cut } : {}\n });\n const repo = this.#repo();\n if (repo !== null && _RepoLobe.#text(head) && repo["head"] !== head) this.cells.set(["repo"], { ...repo, head });\n if (!tagged) return this.#tell(await this.#toldAt(toldBlock));\n await this.#tell([\n ...faculties.flatMap((one) => _RepoLobe.#found("faculty", one)),\n ...organs.flatMap((one) => _RepoLobe.#found("organ", one)),\n ...designs.flatMap((one) => _RepoLobe.#lookFound(one))\n ]);\n }\n async #toldAt(block) {\n if (block === "") return [];\n const lines = block.split("\\n").slice(1);\n const files = _RepoLobe.#hashedFiles(\n lines.flatMap(\n (line) => line.startsWith("A ") ? [`d ${line.slice(2)}`] : line.startsWith("U ") ? [`u ${line.slice(2)}`] : []\n )\n );\n const tracked = new Set(lines.filter((line) => line.startsWith("T ")).map((line) => line.slice(2)));\n const carried = new Map(\n lines.flatMap((line) => {\n const [, path, text] = /^B (\\S+) (".*")$/u.exec(line) ?? [];\n return path === void 0 || text === void 0 ? [] : [[path, text]];\n })\n );\n const read = async (path) => {\n const text = carried.get(path);\n if (text === void 0) return this.#file(path);\n try {\n const one = JSON.parse(text);\n return typeof one === "string" ? one : null;\n } catch {\n return null;\n }\n };\n const named = (pattern) => [...tracked].flatMap((path) => pattern.exec(path)?.[1] ?? []).toSorted().slice(0, this.#most());\n const none = new Set();\n const found = [];\n for (const label of named(/^faculties\\/([^/]+)\\/faculty\\.js$/))\n found.push(..._RepoLobe.#found("faculty", await this.#faculty(label, tracked, none, files, true, read)));\n for (const id of named(/^organs\\/([^/]+)\\/graph\\.json$/))\n found.push(..._RepoLobe.#found("organ", await this.#organ(id, tracked, none, true, read)));\n return found;\n }\n static #hashedFiles(lines) {\n const files = new Map();\n for (const line of lines) {\n if (!line.startsWith("d ") && !line.startsWith("u ")) continue;\n const hashed = _RepoLobe.#hashed.exec(line);\n const folder = hashed?.[2] ?? /^. (?:\\S* )?((?:designs|faculties)\\/[^/]+)\\//.exec(line)?.[1];\n if (folder === void 0) continue;\n const held = files.get(folder) ?? { parts: [], unread: false };\n const [sha, path] = [hashed?.[1], hashed?.[3]];\n const part = path === void 0 ? void 0 : _RepoLobe.#partOf(folder, path);\n if (sha === void 0 || path === void 0) held.unread = true;\n else if (part !== void 0) held.parts.push([part, sha]);\n files.set(folder, held);\n }\n return files;\n }\n static #partOf(folder, path) {\n if (folder.startsWith("designs/")) return _RepoLobe.#isData(path) ? path : void 0;\n const asset = path.startsWith("assets/") ? path.slice("assets/".length) : "";\n return asset !== "" && !asset.split("/").some((name) => name.startsWith(".")) ? asset : void 0;\n }\n static #isData(path) {\n if (path === "DESIGN.md" || path === "versions.json") return false;\n if (path.startsWith("components/") || path.startsWith("words/")) return false;\n return !path.split("/").some((name) => name.startsWith("."));\n }\n #dataOf(parts) {\n return this.#digestOf(JSON.stringify(_RepoLobe.#byPath(parts)));\n }\n static #byPath(parts) {\n return parts.map((part) => [...part]).toSorted((one, other) => (one[0] ?? "") < (other[0] ?? "") ? -1 : 1);\n }\n async #design(name, tracked, changed, files, tagged) {\n const root = `designs/${name}/`;\n if (!_RepoLobe.#label.test(name)) return { name, why: "its folder is no name" };\n if (!tracked.has(`${root}versions.json`)) return { name, why: "it holds no versions.json committed" };\n if ([...changed].some((path) => path.startsWith(root)))\n return { name, why: "its files hold changes not committed" };\n const held = files.get(`designs/${name}`) ?? { parts: [], unread: true };\n const design = await this.#file(`${root}design.json`);\n const kept = await this.#file(`${root}versions.json`);\n if (held.unread || design === null || kept === null) return { name, why: "its files are not all read" };\n const read = _RepoLobe.#json(design);\n const version = _RepoLobe.#arg(read, "version");\n if (_RepoLobe.#arg(read, "name") !== name) return { name, why: "its design.json names another name" };\n if (!_RepoLobe.#text(version) || !_RepoLobe.#version.test(version))\n return { name, why: "its design.json names no version" };\n const data = this.#dataOf(held.parts);\n const named = _RepoLobe.#arg(_RepoLobe.#json(kept), version);\n const look = _RepoLobe.#arg(named, "look");\n if (_RepoLobe.#arg(named, "data") !== data)\n return {\n name,\n version,\n data,\n why: "versions.json names another data digest for its version"\n };\n if (!_RepoLobe.#text(look) || !_RepoLobe.#digest.test(look))\n return { name, version, data, why: "versions.json names no look for its version" };\n const told = this.#record(\n "faculty",\n `${name}.look`,\n version,\n { digest: look, assets: _RepoLobe.#byPath(held.parts) },\n tagged\n );\n const why = _RepoLobe.#arg(told, "why");\n return { name, version, data, look, ...why === void 0 ? {} : { why } };\n }\n static #lookFound(one) {\n const [name, version] = [_RepoLobe.#arg(one, "name"), _RepoLobe.#arg(one, "version")];\n if (!_RepoLobe.#text(name) || !_RepoLobe.#text(version) || _RepoLobe.#arg(one, "why") !== void 0) return [];\n return [{ kind: "faculty", label: `${name}.look`, version }];\n }\n static #found(kind, one) {\n const label = _RepoLobe.#arg(one, _RepoLobe.#keyOf(kind));\n const version = _RepoLobe.#arg(one, "version");\n if (!_RepoLobe.#text(label) || !_RepoLobe.#text(version) || _RepoLobe.#arg(one, "why") !== void 0) return [];\n return [{ kind, label, version }];\n }\n async #faculty(label, tracked, changed, files, tagged, reader = (path) => this.#file(path)) {\n const [code, versions] = [`faculties/${label}/faculty.js`, `faculties/${label}/versions.json`];\n if (!_RepoLobe.#label.test(label)) return { label, why: "its folder is no label" };\n if (!tracked.has(versions)) return { label, why: "it holds no versions.json committed" };\n if (changed.has(code) || changed.has(versions))\n return { label, why: "its faculty.js or versions.json holds changes not committed" };\n const assets = `faculties/${label}/assets/`;\n if ([...changed].some((path) => path.startsWith(assets)))\n return { label, why: "its assets hold changes not committed" };\n const hashed = files.get(`faculties/${label}`) ?? {\n parts: [],\n unread: false\n };\n if (hashed.unread) return { label, why: "its assets are not all read" };\n const [source, kept] = [await reader(code), await reader(versions)];\n if (source === null || kept === null) return { label, why: "its files are not read" };\n const digest = this.#digestOf(source);\n const held = _RepoLobe.#json(kept);\n const version = _RepoLobe.#fields(held) ? Object.keys(held).find((one) => held[one] === digest) : void 0;\n if (version === void 0 || !_RepoLobe.#version.test(version))\n return { label, digest, why: "versions.json names no version for its digest" };\n const carried = hashed.parts.length === 0 ? {} : { assets: _RepoLobe.#byPath(hashed.parts) };\n return this.#record("faculty", label, version, { digest, ...carried }, tagged, source);\n }\n async #organ(id, tracked, changed, tagged, reader = (path) => this.#file(path)) {\n const [graph, build] = [`organs/${id}/graph.json`, `organs/${id}/host/build`];\n if (!_RepoLobe.#id.test(id)) return { id, why: "its folder is no fixed ID" };\n if (!tracked.has(build)) return { id, why: "it holds no host/build" };\n if ([graph, build].some((file) => changed.has(file))) return { id, why: "its files hold changes not committed" };\n const blueprint = tracked.has(graph) ? await reader(graph) : null;\n const read = blueprint === null ? null : _RepoLobe.#json(blueprint);\n const inner = _RepoLobe.#arg(read, "blueprint");\n const version = _RepoLobe.#arg(read, "version") ?? _RepoLobe.#arg(inner, "version");\n if (blueprint === null || typeof version !== "string" || !_RepoLobe.#version.test(version))\n return { id, why: "its graph.json names no version" };\n return this.#record("organ", id, version, { digest: this.#digestOf(blueprint) }, tagged, blueprint);\n }\n static #keyOf(kind) {\n return kind === "faculty" ? "label" : "id";\n }\n #record(kind, label, version, bytes, tagged, text = null) {\n const named = { [_RepoLobe.#keyOf(kind)]: label };\n const held = this.cells.get(["told", kind, label, version]);\n if (!_RepoLobe.#fields(held)) {\n if (tagged) {\n this.cells.set(["told", kind, label, version], {\n ...bytes,\n heard: false,\n at: this.stamp.time\n });\n this.#toldInOrder([kind, label, version]);\n if (text !== null) this.cells.set(["text", kind, label, version], text);\n }\n return { ...named, version, ...bytes };\n }\n const same = Object.keys(bytes).every((key) => JSON.stringify(held[key]) === JSON.stringify(bytes[key]));\n if (same) return { ...named, version, ...bytes };\n return {\n ...named,\n version,\n ...bytes,\n why: `version ${version} was told with other bytes: raise its version`\n };\n }\n #toldInOrder(named) {\n const next = Number(this.cells.get(["toldNext"]) ?? 0);\n this.cells.set(["toldAt", next], [...named]);\n this.cells.set(["toldNext"], next + 1);\n }\n async #file(path) {\n const read = await this.ask("repos", "read", { path });\n const text = "result" in read ? _RepoLobe.#arg(read.result, "text") : void 0;\n return typeof text === "string" ? text : null;\n }\n async #tell(found) {\n await this.#tellFar(found);\n const unheard = found.flatMap(({ kind, label, version }) => {\n const held = this.cells.get(["told", kind, label, version]);\n return _RepoLobe.#fields(held) && held["heard"] !== true ? [{ kind, label, version, held }] : [];\n });\n if (unheard.length === 0) return;\n const described = await this.ask("library", null, null);\n const methods = "result" in described ? _RepoLobe.#arg(described.result, "methods") : void 0;\n const offered = _RepoLobe.#kinds(_RepoLobe.#arg(methods, "changed"));\n for (const { kind, label, version, held } of unheard) {\n if (!offered.includes(kind)) continue;\n const changed = { kind, label, version, digest: held["digest"] ?? null };\n const letter = { lives: _RepoLobe.#lives };\n const sent = await this.ask("library", "changed", changed, void 0, { letter });\n if (!("error" in sent)) this.cells.set(["told", kind, label, version], { ...held, heard: true });\n }\n }\n async #tellFar(found) {\n const fresh = found.flatMap(({ kind, label, version }) => {\n const held = this.cells.get(["told", kind, label, version]);\n return _RepoLobe.#fields(held) && held["far"] !== true && (kind === "faculty" || kind === "organ") ? [{ kind, label, version, held }] : [];\n });\n if (fresh.length === 0) return;\n const backs = (await this.#relations()).filter(\n (one) => one.side === "standing" && one.placeholder?.startsWith(`${_RepoLobe.#hears}-`) === true\n );\n if (backs.length === 0) return;\n for (const { kind, label, version, held } of fresh) {\n const changed = { kind, label, version, digest: held["digest"] ?? null };\n const before = held["farHeard"];\n const heard = new Set(Array.isArray(before) ? before.filter((one) => _RepoLobe.#text(one)) : []);\n for (const { placeholder } of backs) {\n if (!_RepoLobe.#text(placeholder) || heard.has(placeholder)) continue;\n if (!("error" in await this.ask(placeholder, "changed", changed))) heard.add(placeholder);\n }\n const { farHeard: _, ...rest } = held;\n const all = backs.every(({ placeholder }) => !_RepoLobe.#text(placeholder) || heard.has(placeholder));\n this.cells.set(["told", kind, label, version], all ? { ...rest, far: true } : { ...rest, farHeard: [...heard] });\n }\n }\n static #kinds(changed) {\n const kind = _RepoLobe.#arg(_RepoLobe.#arg(_RepoLobe.#arg(changed, "args"), "properties"), "kind");\n const named = _RepoLobe.#arg(kind, "enum");\n return Array.isArray(named) ? named : [];\n }\n faculties(args) {\n return this.#offered("faculties", args);\n }\n organs(args) {\n return this.#offered("organs", args);\n }\n designs(args) {\n return this.#offered("designs", args);\n }\n #offered(method, args) {\n const refused = this.#refusal(method, args);\n if (refused !== null) return refused;\n const found = _RepoLobe.#arg(this.cells.get(["scanned"]), method);\n if (!Array.isArray(found) || found.length === 0) return this.error("absent", `the repo holds no ${method}/`);\n return found;\n }\n async get(args) {\n const refused = this.#refusal("get", args);\n if (refused !== null) return refused;\n const { kind, label, version, path } = _RepoLobe.#fields(args) ? args : {};\n if (kind !== "faculty" && kind !== "organ" || !_RepoLobe.#text(label) || !_RepoLobe.#label.test(label))\n return this.error("refused", "a get names a faculty or an organ by its label");\n if (path !== void 0 && (kind !== "faculty" || !_RepoLobe.#text(path)))\n return this.error("refused", "a path names a faculty\'s asset");\n const near = ["owner", "near"].includes(this.#role());\n if (version === null && !near) return this.error("refused", "a version told is read from afar");\n const told = _RepoLobe.#text(version) ? this.cells.get(["told", kind, label, version]) : null;\n const at = _RepoLobe.#shown(version);\n if (told !== null && !_RepoLobe.#fields(told)) return this.error("absent", `no version ${at} of ${label} was told`);\n if (kind === "faculty" && told !== null && told["assets"] !== void 0 && this.#isLook(label))\n return this.#getLook(label, at, told, path);\n if (path !== void 0 && (told === null || told["assets"] === void 0))\n return this.error("refused", `${label} ${at} carries no assets`);\n if (path !== void 0 && told !== null) return this.#getAsset(label, told, path);\n const kept = _RepoLobe.#text(version) ? this.cells.get(["text", kind, label, version]) : void 0;\n if (told !== null && typeof kept === "string") {\n if (kind === "faculty")\n return {\n source: kept,\n digest: told["digest"] ?? null,\n ..._RepoLobe.#carried(told)\n };\n return { blueprint: kept, half: this.cells.get(["built", label, at]) ?? null };\n }\n if (kind === "faculty") return this.#getFaculty(label, told);\n return this.#getOrgan(label, at, told);\n }\n #isLook(label) {\n const designs = _RepoLobe.#arg(this.cells.get(["scanned"]), "designs");\n const name = label.endsWith(".look") ? label.slice(0, -".look".length) : null;\n return Array.isArray(designs) && designs.some((one) => _RepoLobe.#arg(one, "name") === name);\n }\n static #carried(told) {\n const parts = _RepoLobe.#partsOf(told["assets"]);\n return parts === null ? {} : { assets: parts };\n }\n async #getAsset(label, told, path) {\n const part = _RepoLobe.#partsOf(told["assets"])?.find((one) => one[0] === path);\n if (part === void 0) return this.error("absent", `${label} holds no asset ${_RepoLobe.#shown(path)}`);\n return this.#asset(part);\n }\n async #asset(part) {\n const read = await this.ask("repos", "bytes", { sha: part[1] ?? null });\n if ("error" in read)\n return read.error.code === "absent" ? this.error("absent", this.#unkept(_RepoLobe.#shown(part[0]))) : this.#result(read);\n const bytes = _RepoLobe.#arg(read.result, "bytes");\n const whole = bytes instanceof Uint8Array ? _RepoLobe.#canonical(bytes) : null;\n if (whole === null || this.#shaOf(whole) !== part[1])\n return this.error("refused", "the asset kept is not the version told");\n return { path: part[0] ?? null, digest: part[1] ?? null, bytes: whole };\n }\n #unkept(shown) {\n if (this.#scanning()) return `${shown} is being kept: a scan of the repo is running, ask again once it ends`;\n if (this.cells.get(["owed"]) === true)\n return `${shown} is not kept yet: a scan of the repo is owed and begins once the repo runs nothing, ask again then`;\n return `${shown} is not kept yet: a scan of the repo keeps it`;\n }\n static #partsOf(data) {\n if (!Array.isArray(data)) return null;\n const parts = [];\n for (const one of data) {\n const [path, sha] = Array.isArray(one) && one.length === 2 ? one : [];\n if (!_RepoLobe.#text(path) || !_RepoLobe.#text(sha) || !_RepoLobe.#digest.test(sha)) return null;\n parts.push([path, sha]);\n }\n return parts;\n }\n async #getLook(label, version, told, path) {\n const name = label.slice(0, -".look".length);\n const parts = _RepoLobe.#partsOf(told["assets"]);\n if (parts === null) return this.error("refused", `the look ${label} ${version} names no assets whole`);\n if (path === void 0) {\n const built = this.cells.get(["look", name, version]);\n const source = _RepoLobe.#arg(built, "source");\n if (typeof source === "string" && this.#digestOf(source) === told["digest"])\n return { source, digest: told["digest"], assets: parts };\n const why = _RepoLobe.#arg(built, "why");\n return this.error("refused", _RepoLobe.#text(why) ? why : `the look of ${name} ${version} is not built: build it`);\n }\n const part = parts.find((one) => one[0] === path);\n if (part === void 0) return this.error("absent", `the look ${label} holds no asset ${_RepoLobe.#shown(path)}`);\n return this.#asset(part);\n }\n async #getFaculty(label, told) {\n const source = await this.#file(`faculties/${label}/faculty.js`);\n if (source === null) return this.error("absent", `the repo holds no faculties/${label}/faculty.js`);\n const digest = this.#digestOf(source);\n if (told !== null && told["digest"] !== digest)\n return this.error("refused", "the faculty.js the repo holds is not the version told");\n return {\n source,\n digest,\n ...told === null ? {} : _RepoLobe.#carried(told)\n };\n }\n async #getOrgan(id, version, told) {\n const blueprint = await this.#file(`organs/${id}/graph.json`);\n if (blueprint === null) return this.error("absent", `the repo holds no organ ${id} whole`);\n if (told !== null && told["digest"] !== this.#digestOf(blueprint))\n return this.error("refused", "the organ the repo holds is not the version told");\n const half = told === null ? null : this.cells.get(["built", id, version]) ?? null;\n return { blueprint, half };\n }\n build(args) {\n const refused = this.#refusal("build", args);\n if (refused !== null) return Promise.resolve(refused);\n const [organ, design] = [_RepoLobe.#arg(args, "organ"), _RepoLobe.#arg(args, "design")];\n const version = _RepoLobe.#arg(args, "version");\n if (organ === void 0 === (design === void 0))\n return Promise.resolve(this.error("refused", "a build names an organ or a design"));\n const [kind, named] = organ === void 0 ? ["design", design] : ["organ", organ];\n const told = _RepoLobe.#text(named) && _RepoLobe.#text(version) ? this.cells.get(\n kind === "design" ? ["told", "faculty", `${named}.look`, version] : ["told", "organ", named, version]\n ) : void 0;\n if (!_RepoLobe.#fields(told))\n return Promise.resolve(this.error("absent", `no such ${kind} was told at that version`));\n if (!("name" in this.#ready())) return Promise.resolve(this.error("refused", "the repo is not ready"));\n if (!this.#mainHolds(kind, _RepoLobe.#shown(named), _RepoLobe.#shown(version), told["digest"]))\n return Promise.resolve(\n this.error(\n "refused",\n `main holds not ${_RepoLobe.#shown(named)} ${_RepoLobe.#shown(version)}: a version is built while main holds it`\n )\n );\n const built = { [kind]: named ?? null, version: version ?? null };\n const method = kind === "design" ? "look" : "build";\n return this.#begin("build", { [kind]: named ?? null }, null, { more: { built }, method });\n }\n #mainHolds(kind, named, version, digest) {\n const [list, key, by] = kind === "design" ? ["designs", "name", "look"] : ["organs", "id", "digest"];\n const found = _RepoLobe.#arg(this.cells.get(["scanned"]), list);\n const now = Array.isArray(found) ? found.find((one) => _RepoLobe.#arg(one, key) === named) : void 0;\n return _RepoLobe.#arg(now, "version") === version && _RepoLobe.#arg(now, by) === digest && _RepoLobe.#arg(now, "why") === void 0;\n }\n async told(args) {\n const refused = this.#refusal("told", args);\n if (refused !== null) return refused;\n const tells = _RepoLobe.#arg(args, "tells");\n if (this.#role() === "library" && this.stamp.occupant !== null) {\n if (_RepoLobe.#text(tells)) {\n const far = this.stamp.asker;\n await this.#untold(far, _RepoLobe.#hears);\n const note = { repo: this.#repo()?.["name"] ?? null, library: far };\n const accepted = await this.ask("mouth", "accept", {\n invitation: tells,\n placeholder: _RepoLobe.#backUnder(_RepoLobe.#hears, far),\n note\n });\n if ("error" in accepted)\n return this.error(accepted.error.code, `the standing back was not taken: ${accepted.error.message}`);\n }\n } else if (tells !== void 0) return this.error("refused", "tells is a far library’s alone");\n const page = this.#page(["toldAt"], args);\n if (!("cells" in page)) return page;\n const told = page.cells.flatMap(({ value }) => {\n if (!Array.isArray(value)) return [];\n const [kind, label, version] = value.map((part) => typeof part === "string" ? part : "");\n const held = this.cells.get(["told", kind ?? "", label ?? "", version ?? ""]);\n if (!_RepoLobe.#fields(held)) return [];\n return [{ kind: kind ?? null, label: label ?? null, version: version ?? null, ...held }];\n });\n return { told, cursor: page.cursor };\n }\n head(args) {\n const refused = this.#serving("head", args);\n if (refused !== null) return refused;\n const repo = this.#repo() ?? {};\n if (this.#scopeOfAsker() !== null) return { head: null };\n return { head: _RepoLobe.#text(repo["rebuilds"]) ? null : repo["head"] ?? null };\n }\n async give(args) {\n const refused = this.#serving("give", args);\n if (refused !== null) return refused;\n const repo = this.#repo() ?? {};\n const since = _RepoLobe.#arg(args, "since") ?? null;\n const tag = _RepoLobe.#arg(args, "tag") ?? null;\n const far = this.stamp.asker;\n const scope = this.#scopeOfAsker();\n if (tag !== null && !(_RepoLobe.#text(tag) && _RepoLobe.#tag.test(tag)))\n return this.error("refused", "a tag is v and three whole numbers");\n const out = this.cells.get(["out", far]);\n const current = _RepoLobe.#fields(out) && (out["of"] ?? null) === (repo["head"] ?? null);\n const piece = _RepoLobe.#arg(args, "piece") ?? null;\n const same = _RepoLobe.#fields(out) && out["since"] === since && (out["tag"] ?? null) === tag && (out["piece"] ?? null) === piece;\n if (_RepoLobe.#fields(out) && current && same && _RepoLobe.#text(out["run"])) {\n if (_RepoLobe.#text(out["failed"])) {\n this.cells.delete(["out", far]);\n return this.error("refused", out["failed"]);\n }\n if (typeof out["pieces"] !== "number") return { ready: false };\n const ready = { pieces: out["pieces"], head: out["head"] ?? null };\n return scope === null ? ready : { ...ready, scope };\n }\n if (_RepoLobe.#text(repo["doing"])) {\n await this.#check();\n return { ready: false };\n }\n const as = `out-${far}`;\n const named = { ...typeof tag === "string" ? { tag } : {}, ...typeof piece === "number" ? { piece } : {} };\n const tagged = typeof tag === "string" ? { tag } : {};\n const begun = scope === null ? await this.#begin("bundle", { since, as, ...named }, { for: far }) : await this.#begin("cut", { as, scope, ...tagged }, { for: far });\n if (!("job" in begun)) return begun;\n const of = repo["head"] ?? null;\n this.cells.set(["out", far], { since, ...named, of, run: begun.job, pieces: null, head: null, failed: null });\n return { ready: false };\n }\n #serving(method, args) {\n const refused = this.#refusal(method, args);\n if (refused !== null) return refused;\n if (!("name" in this.#ready())) return this.error("refused", "the repo is not ready");\n if (method === "give" && _RepoLobe.#text(this.#repo()?.["rebuilds"]))\n return this.error("refused", "the lobe rebuilds: it is pushed whole first");\n return null;\n }\n async piece(args) {\n const refused = this.#serving("piece", args);\n if (refused !== null) return refused;\n const at = _RepoLobe.#arg(args, "at");\n const out = this.cells.get(["out", this.stamp.asker]);\n const pieces = _RepoLobe.#arg(out, "pieces");\n if (typeof pieces !== "number" || typeof at !== "number" || !Number.isInteger(at) || at < 0 || at >= pieces)\n return this.error("refused", "no such piece is ready");\n return this.#result(await this.ask("repos", "piece", { at, as: `out-${this.stamp.asker}` }));\n }\n async take(args) {\n const refused = this.#serving("take", args);\n if (refused !== null) return refused;\n const { push, at, pieces, bytes } = _RepoLobe.#fields(args) ? args : {};\n if (!_RepoLobe.#text(push) || typeof at !== "number" || typeof pieces !== "number" || !(bytes instanceof Uint8Array))\n return this.error("refused", "a piece names its push, where it stands, of how many, and its bytes");\n const far = this.stamp.asker;\n const last = this.#shaOf(bytes);\n const held = this.cells.get(["in", far]);\n const same = _RepoLobe.#fields(held) && held["push"] === push && held["pieces"] === pieces ? held : null;\n if (same !== null && same["got"] === at + 1 && same["last"] === last) return this.#receive(far);\n const named = _RepoLobe.#fields(held) && held["push"] === push;\n const fresh = {\n push,\n pieces,\n got: 0,\n run: null,\n head: null,\n failed: null,\n check: null,\n landing: null,\n landed: false\n };\n const begins = !named && at === 0;\n const given = _RepoLobe.#arg(args, "tells");\n const kept = begins ? { ...fresh, ...given === void 0 ? { told: true } : {} } : same !== null && same["got"] === at ? same : null;\n if (kept === null) return this.error("refused", "the pieces of a push come in order");\n const back = begins ? await this.#tellsBy(far, given) : null;\n if (back !== null && typeof back !== "string") return back;\n const put = await this.ask("repos", "put", { at, pieces, bytes, as: `in-${far}` });\n if ("error" in put) return this.#heard(put);\n this.cells.set(["in", far], { ...kept, got: at + 1, last });\n return this.#receive(far);\n }\n async taken(args) {\n const refused = this.#serving("taken", args);\n if (refused !== null) return refused;\n const far = this.stamp.asker;\n const kept = this.cells.get(["in", far]);\n if (!_RepoLobe.#fields(kept)) return this.error("refused", "no push is coming");\n const ended = await this.#endOf(far, kept);\n if (ended !== null) return ended;\n await this.#check();\n await this.#receive(far);\n const now = this.cells.get(["in", far]);\n const doing = this.#repo()?.["doing"];\n const job = _RepoLobe.#text(doing) ? this.cells.get(["job", doing]) : void 0;\n const waiting = _RepoLobe.#fields(now) && now["run"] === null && now["got"] === now["pieces"];\n const waits = waiting && _RepoLobe.#fields(job) ? { waits: `the repo runs a ${_RepoLobe.#shown(job["kind"])} first` } : {};\n return { ready: false, ...waits };\n }\n async #receiveWaiting() {\n for (const { key } of this.#all(["in"])) {\n const far = key[1];\n if (_RepoLobe.#text(far)) await this.#receive(far);\n }\n }\n async #clear(as) {\n const asked = await this.ask("repos", "clear", { as });\n if ("error" in asked && asked.error.code === "busy") this.cells.set(["uncleared", as], null);\n else if (this.cells.get(["uncleared", as]) !== void 0) this.cells.delete(["uncleared", as]);\n }\n async #unclear() {\n for (const { key } of this.#all(["uncleared"])) {\n const as = key[1];\n if (_RepoLobe.#text(as)) await this.#clear(as);\n }\n }\n async #check() {\n await this.#unclear();\n const doing = this.#repo()?.["doing"];\n if (!_RepoLobe.#text(doing)) return;\n const checked = await this.ask("repos", "check", {});\n if ("error" in checked || !_RepoLobe.#fields(checked.result)) return;\n const { doing: running, lost, last } = checked.result;\n const held = this.cells.get(["job", doing]);\n if (running === doing || !_RepoLobe.#fields(held)) return;\n if (_RepoLobe.#fields(last) && last["job"] === doing) {\n const { code, out, err } = last;\n if (typeof code === "number" && typeof out === "string" && typeof err === "string") {\n await this.#jobEnded(await this.nerves.read(), doing, held, code, out, err);\n return;\n }\n }\n if (Array.isArray(lost) && lost.includes(doing)) return;\n const kept = await this.ask("repos", "job", { job: doing });\n const ended = "result" in kept ? _RepoLobe.#arg(_RepoLobe.#arg(kept.result, "ended") ?? null, "code") : void 0;\n if ("result" in kept && typeof ended !== "number") return;\n const whole = ended === 0;\n if (whole) {\n this.cells.delete(["undo"]);\n this.cells.set(["owed"], true);\n }\n const why = whole ? "the jailer ended this job whole, and its word of the end never came: its output is lost" : "the jailer runs this job no more, and its word of the end never came";\n await this.#jobEnded(await this.nerves.read(), doing, held, -1, "", why);\n await this.#awaiting();\n }\n async #tellsBy(far, invitation) {\n await this.#untold(far);\n if (!_RepoLobe.#text(invitation)) return null;\n const placeholder = _RepoLobe.#backUnder(_RepoLobe.#tells, far);\n const note = { repo: this.#repo()?.["name"] ?? null, tells: far };\n const accepted = await this.ask("mouth", "accept", { invitation, placeholder, note });\n if ("error" in accepted)\n return this.error(accepted.error.code, `the standing back was not taken: ${accepted.error.message}`);\n return placeholder;\n }\n async #untold(far, prefix = _RepoLobe.#tells) {\n const placeholder = _RepoLobe.#backUnder(prefix, far);\n const held = (await this.#relations()).find((one) => one.side === "standing" && one.placeholder === placeholder);\n if (held !== void 0) await this.#unlink({ placeholder, far: held.far });\n }\n async #tellEnds() {\n for (const { key, value } of this.#all(["in"])) {\n const far = key[1];\n if (typeof far !== "string" || !_RepoLobe.#fields(value) || value["told"] === true) continue;\n const told = await this.#endOf(far, value);\n if (told === null) continue;\n this.cells.set(key, { ...value, told: true });\n await this.ask(_RepoLobe.#backUnder(_RepoLobe.#tells, far), "done", told);\n }\n }\n async #endOf(far, kept) {\n const landed = kept["landed"] === true;\n const failed = kept["failed"];\n if (!landed && !_RepoLobe.#text(failed)) return null;\n const checked = kept["check"] ?? null;\n const scoped = checked !== null && await this.#scopeFor(far) !== null;\n const check = scoped ? { code: _RepoLobe.#arg(checked, "code") ?? null } : checked;\n const head = kept["head"];\n const ended = landed ? { code: 0, out: _RepoLobe.#text(head) ? `${head}\n` : "", err: "" } : { code: 1, out: "", err: _RepoLobe.#shown(failed) };\n return { job: kept["push"] ?? null, kind: "push", ...ended, check };\n }\n async #receive(far) {\n const kept = this.cells.get(["in", far]);\n const repo = this.#repo();\n if (!_RepoLobe.#fields(kept) || kept["got"] !== kept["pieces"] || kept["run"] !== null) return null;\n if (repo === null || _RepoLobe.#text(repo["doing"])) return null;\n const scope = await this.#scopeFor(far);\n const given = { as: `in-${far}`, pieces: kept["pieces"] ?? 1, ...scope === null ? {} : { scope } };\n const begun = await this.#begin("bring", given, { for: far }, { asker: far });\n if ("job" in begun) this.cells.set(["in", far], { ...kept, run: begun.job });\n return null;\n }\n async #served(far, kind, why, out) {\n const key = kind === "bundle" || kind === "cut" ? ["out", far] : ["in", far];\n const kept = this.cells.get(key);\n if (!_RepoLobe.#fields(kept)) return;\n const [first = "", second = "", third = ""] = out.trim().split("\\n");\n if (kind === "cut") return this.#cutGiven(far, kept, why);\n if (kind === "bundle") {\n this.cells.set(key, {\n ...kept,\n pieces: why === null ? Number(first) : null,\n head: second || null,\n failed: why\n });\n return;\n }\n if (kind === "bring") return this.#pushBrought(far, kept, why, first, second, third);\n if (kind === "land") return this.#pushLanded(far, kept, why, out);\n const repo = this.#repo();\n if (kind !== "head") return void 0;\n if (why === null && second === "holds" && repo !== null) this.cells.set(["repo"], { ...repo, rebuilds: null });\n this.cells.set(key, { ...kept, landed: true });\n return void 0;\n }\n async #cutGiven(far, kept, why) {\n if (why !== null) {\n this.cells.set(["out", far], { ...kept, failed: why });\n return;\n }\n const piece = typeof kept["piece"] === "number" ? { piece: kept["piece"] } : {};\n const given = { since: kept["since"] ?? null, as: `out-${far}`, cut: true, ...piece };\n const begun = await this.#begin("bundle", given, { for: far }, { asker: far });\n this.cells.set(["out", far], "job" in begun ? { ...kept, run: begun.job } : { ...kept, failed: begun.message });\n }\n async #pushBrought(far, kept, why, head, how, tip) {\n const key = ["in", far];\n if (why !== null) {\n this.cells.set(key, { ...kept, failed: why });\n return;\n }\n if (how === "held") {\n this.cells.set(key, { ...kept, head, landed: true });\n return;\n }\n const check = await this.#conform(`in-${far}`, head, true, far);\n this.cells.set(key, { ...kept, head, check, ...how === "graft" && _RepoLobe.#text(tip) ? { tip } : {} });\n if ("code" in check) await this.#verdict(far);\n }\n async #pushLanded(far, kept, why, out) {\n const tip = kept["tip"];\n const head = _RepoLobe.#text(tip) ? tip : _RepoLobe.#headOf(out);\n const rebuilds = this.#repo()?.["rebuilds"];\n const proving = why === null && _RepoLobe.#text(rebuilds) && "job" in await this.#begin("head", { contains: rebuilds }, { for: far }, { asker: far });\n const landed = why !== null ? { failed: why } : proving ? { head } : { head, landed: true };\n this.cells.set(["in", far], { ...kept, ...landed });\n }\n async #conform(as, head, push, asker) {\n const script = this.#gateScript();\n const gated = push && this.#gates().push === "on" && _RepoLobe.#text(script);\n const given = {\n as,\n head,\n ...this.#checks(),\n ...gated ? { script } : {}\n };\n const begun = await this.#begin("check", given, { check: as }, { asker, method: "conform" });\n if ("job" in begun) return { job: begun.job };\n return { code: 1, out: "", err: `the check did not begin: ${begun.message}` };\n }\n #checks() {\n if (this.#holdsScope()) return { parts: _RepoLobe.parts, scoped: true };\n const conform = this.cells.get(["conform"]);\n return { parts: _RepoLobe.parts, ..._RepoLobe.#text(conform) ? { conform } : {} };\n }\n async #checked(as, check) {\n const tail = {\n ...check,\n out: _RepoLobe.#last(_RepoLobe.#shown(check["out"])),\n err: _RepoLobe.#last(_RepoLobe.#shown(check["err"]))\n };\n if (as === "pull") {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync) || sync["stage"] !== "checking") return;\n const checked = { ...sync, check: tail };\n this.cells.set(["sync"], checked);\n return this.#checkedPull(checked, tail);\n }\n const far = as.startsWith("in-") ? as.slice(3) : "";\n const kept = this.cells.get(["in", far]);\n if (!_RepoLobe.#fields(kept)) return;\n this.cells.set(["in", far], { ...kept, check: tail });\n return this.#verdict(far);\n }\n static #last(text) {\n const last = text.slice(-_RepoLobe.#tail);\n return /^[\\uDC00-\\uDFFF]/.test(last) ? last.slice(1) : last;\n }\n async #verdict(far) {\n const kept = this.cells.get(["in", far]);\n const check = _RepoLobe.#arg(kept, "check");\n if (!_RepoLobe.#fields(kept) || !_RepoLobe.#fields(check) || !("code" in check)) return;\n if (check["code"] !== 0) {\n this.cells.set(["in", far], {\n ...kept,\n failed: _RepoLobe.#refusalOf(check, await this.#scopeFor(far) !== null)\n });\n return;\n }\n if (_RepoLobe.#text(kept["landing"]) || _RepoLobe.#text(this.#repo()?.["doing"])) return;\n const as = `in-${far}`;\n const begun = await this.#begin("land", { as }, { for: far }, { asker: far });\n if ("job" in begun) this.cells.set(["in", far], { ...kept, landing: begun.job });\n }\n static #refusalOf(check, bare = false) {\n if (bare) return "its check is red";\n const said = `${_RepoLobe.#shown(check["out"])}\n${_RepoLobe.#shown(check["err"])}`.trim();\n const tail = said.slice(-_RepoLobe.#tail);\n return `its check is red:\n${tail || `it ended ${typeof check["code"] === "number" ? check["code"] : "unread"}`}`;\n }\n async #authoring(repo) {\n const writers = (await this.#given()).some(({ note }) => _RepoLobe.#kindOf(note) === "writer");\n if (!writers) return null;\n if (this.cells.get(["author"]) !== this.stamp.asker)\n return this.error("refused", "far writers push to this lobe: only its author commits beside it");\n if (_RepoLobe.#text(repo["rebuilds"])) return this.error("refused", "the lobe rebuilds: it is pushed whole first");\n return null;\n }\n #filesOf(files) {\n if (files === void 0) return {};\n if (!_RepoLobe.#fields(files)) return null;\n const all = Object.entries(files);\n if (all.length > this.#most() || all.some(([path, text]) => path === "" || typeof text !== "string")) return null;\n return files;\n }\n #pathsOf(paths) {\n if (paths === void 0) return [];\n if (!Array.isArray(paths) || paths.length < 1 || paths.length > this.#most()) return null;\n const named = paths.flatMap((one) => typeof one === "string" ? [one] : []);\n const fit = (one) => one.split("/").every((name) => _RepoLobe.#entry.test(name));\n return named.length === paths.length && named.every(fit) ? named : null;\n }\n async commit(args) {\n const refused = this.#refusal("commit", args);\n if (refused !== null) return refused;\n const message = _RepoLobe.#arg(args, "message");\n const files = this.#filesOf(_RepoLobe.#arg(args, "files"));\n if (!_RepoLobe.#text(message)) return this.error("refused", "a commit holds its message");\n if (files === null)\n return this.error("refused", `a commit\'s files are each a path and its text, ${this.#most()} at most`);\n const paths = this.#pathsOf(_RepoLobe.#arg(args, "paths"));\n if (paths === null)\n return this.error("refused", `a commit\'s paths are each a file or a folder of the repo, ${this.#most()} at most`);\n if (paths.length > 0 && Object.keys(files).length > 0)\n return this.error("refused", "a commit writes files or takes paths, not both");\n const executable = _RepoLobe.#arg(args, "executable") ?? [];\n if (!Array.isArray(executable) || executable.some((path) => typeof path !== "string" || !Object.hasOwn(files, path)))\n return this.error("refused", "what a commit makes executable are paths among its files");\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n const unauthored = await this.#authoring(ready.repo);\n if (unauthored !== null) return unauthored;\n const gating = this.#commitGate(args);\n if (typeof gating !== "boolean") return gating;\n if (_RepoLobe.#text(ready.repo["doing"])) {\n await this.#check();\n return this.error("refused", `the repo runs ${ready.repo["doing"]} already`);\n }\n const written = Object.keys(files);\n const before = written.length === 0 ? null : await this.#before(written);\n if (before !== null && "code" in before) return before;\n if (before !== null) this.cells.set(["undo"], executable.length === 0 ? before : { ...before, executable });\n else if (paths.length > 0) this.cells.set(["undo"], { files: [], dirs: [], paths });\n for (const [path, text] of Object.entries(files)) {\n const wrote = await this.ask("repos", "write", { path, text: text ?? "" });\n if ("error" in wrote) return this.error(wrote.error.code, await this.#undone(`${path}: ${wrote.error.message}`));\n }\n const script = this.#gateScript();\n const begun = !gating || !_RepoLobe.#text(script) ? await this.#begin("commit", this.#committing(message), null) : (\n await this.#gating(message, { script, install: true, gate: true })\n );\n if ("job" in begun) return begun;\n return this.error(begun.code, await this.#undone(begun.message));\n }\n #committing(message) {\n const kept = this.cells.get(["undo"]) ?? null;\n const [executable, paths] = [_RepoLobe.#arg(kept, "executable"), _RepoLobe.#arg(kept, "paths")];\n return {\n message,\n ...executable === void 0 ? {} : { executable },\n ...paths === void 0 ? {} : { paths },\n ...this.#checks()\n };\n }\n async #gating(message, gate) {\n if (!this.#keyed()) return this.#begin("commit", gate, null, { method: "run", more: { gating: message } });\n const more = { running: gate, commits: message };\n return this.#begin("commit", { set: await this.#keys() }, null, { method: "secrets", more });\n }\n async #before(paths) {\n const files = [];\n const stands = new Map();\n const dirs = [];\n for (const path of paths) {\n const read = await this.ask("repos", "read", { path });\n if ("error" in read) {\n if (read.error.code !== "absent") return this.error(read.error.code, `${path}: ${read.error.message}`);\n files.push({ path, was: null });\n } else {\n const was = _RepoLobe.#arg(read.result, "text");\n if (typeof was !== "string") return this.error("refused", `${path}: it holds no text`);\n files.push({ path, was });\n }\n const names = path.split("/");\n for (let at = 1; at < names.length; at += 1) {\n const dir = names.slice(0, at).join("/");\n if (!stands.has(dir)) {\n const parent = at === 1 ? true : stands.get(names.slice(0, at - 1).join("/"));\n const listed = parent ? await this.ask("repos", "list", { path: dir }) : null;\n stands.set(dir, listed !== null && !("error" in listed));\n }\n if (stands.get(dir) === false && !dirs.includes(dir)) dirs.push(dir);\n }\n }\n return { files, dirs };\n }\n async #undone(why) {\n const undo = this.cells.get(["undo"]);\n if (!_RepoLobe.#fields(undo)) return why;\n const [files, dirs] = [undo["files"], undo["dirs"]];\n const lost = [];\n for (const one of Array.isArray(files) ? files : []) {\n const path = _RepoLobe.#arg(one, "path");\n const was = _RepoLobe.#arg(one, "was");\n if (typeof path !== "string") continue;\n const put = typeof was === "string" ? await this.ask("repos", "write", { path, text: was }) : await this.ask("repos", "erase", { path });\n if ("error" in put && !(was === null && put.error.code === "absent")) lost.push(path);\n }\n const made = Array.isArray(dirs) ? dirs.filter((dir) => typeof dir === "string") : [];\n for (const path of made.toReversed()) await this.ask("repos", "erase", { path });\n this.cells.delete(["undo"]);\n if (!Array.isArray(files) || files.length === 0) return why;\n return lost.length === 0 ? `${why.trimEnd()}\nthe files it wrote are put back as they were before the ask` : `${why.trimEnd()}\nthe files it wrote could not all be put back: ${lost.join(", ")}`;\n }\n #commitGate(args) {\n const asked = _RepoLobe.#arg(args, "gate");\n const { commit } = this.#gates();\n if (asked === false && commit === "mandatory")\n return this.error("refused", "the setting on commit is mandatory: no commit skips the gate");\n return asked === true || commit !== "off" && asked !== false;\n }\n async #gated(held, run, code, out, err) {\n const repo = this.#repo();\n if (repo !== null) this.cells.set(["repo"], { ...repo, doing: null });\n const message = _RepoLobe.#shown(held["gating"]);\n const asker = _RepoLobe.#text(held["asker"]) ? held["asker"] : _RepoLobe.#owner;\n const first = _RepoLobe.#arg(held["step"] ?? null, "ran");\n const holds = _RepoLobe.#text(first) ? first : run;\n if (holds !== run) this.cells.delete(["job", run]);\n if (code === 0 || code === 3 && err.includes("holds no script")) {\n const begun = await this.#begin("commit", this.#committing(message), { commit: holds }, { asker });\n if ("job" in begun) return null;\n return this.#commitEnded(holds, 1, "", await this.#undone(`the commit is refused: ${begun.message}`));\n }\n const why = await this.#undone(`the commit is refused: the gate is red\n${_RepoLobe.#last(err)}`);\n await this.#commitEnded(holds, code, _RepoLobe.#last(out), why);\n return null;\n }\n async #commitEnded(run, code, out, err, more = {}) {\n const first = this.cells.get(["job", run]);\n if (!_RepoLobe.#fields(first)) return null;\n const { gating: _, running: __, commits: ___, ...kept } = first;\n this.cells.set(["job", run], { ...kept, ended: { run, code, out, err, ...more, at: this.stamp.time } });\n await this.#ended(kept, code, out, err, more);\n return null;\n }\n status(args) {\n return this.#work("status", args, {});\n }\n log(args) {\n const most = _RepoLobe.#arg(args, "most");\n return this.#work("log", args, most === void 0 ? {} : { most });\n }\n discard(args) {\n return this.#work("discard", args, {});\n }\n async run(args) {\n const script = _RepoLobe.#arg(args, "script");\n const install = _RepoLobe.#arg(args, "install") ?? false;\n const words = _RepoLobe.#argsOf(_RepoLobe.#arg(args, "args"));\n if (!_RepoLobe.#text(script) || !_RepoLobe.#script.test(script))\n return this.error("refused", "a run names a script of the repo\'s package");\n if (typeof install !== "boolean") return this.error("refused", "install is true or false");\n if (words === null)\n return this.error("refused", `a run\'s args are texts, at most ${_RepoLobe.#argsMost}, none holding a NUL`);\n const gate = script === this.#gateScript() ? { gate: true } : {};\n const given = { script, ...words.length === 0 ? {} : { args: words }, install, ...gate };\n const scripts = _RepoLobe.#arg(this.stamp.occupant?.note, "scripts");\n if (this.#role() === "runner" && !(Array.isArray(scripts) && scripts.includes(script)))\n return this.error("refused", `the runner runs ${script} not`);\n return this.#keyed() ? this.#keysFirst("run", args, given) : this.#work("run", args, given);\n }\n static #argsOf(args) {\n if (args === void 0) return [];\n if (!Array.isArray(args) || args.length > _RepoLobe.#argsMost) return null;\n const all = args.flatMap(\n (one) => typeof one === "string" && one.length <= _RepoLobe.#argLongest && !one.includes("\\0") ? [one] : []\n );\n return all.length === args.length ? all : null;\n }\n async #writtenThen(held, run, code, err) {\n const repo = this.#repo();\n if (repo !== null) this.cells.set(["repo"], { ...repo, doing: null });\n const asker = _RepoLobe.#text(held["asker"]) ? held["asker"] : _RepoLobe.#owner;\n const kind = "run";\n const commits = held["kind"] === "commit";\n if (code !== 0) {\n const why = `its secret file was not written: ${err}`;\n if (commits) await this.#commitEnded(run, code, "", await this.#undone(`the commit is refused: ${why}`));\n else await this.#workEnded(run, kind, code, "", why);\n return null;\n }\n if (Object.keys(await this.#keys()).length > 0) this.cells.set(["env"], true);\n else this.cells.delete(["env"]);\n const running = _RepoLobe.#fields(held["running"]) ? held["running"] : {};\n if (commits) {\n const more = { gating: _RepoLobe.#shown(held["commits"]) };\n const gate = await this.#begin("commit", running, { ran: run }, { asker, method: "run", more });\n if ("job" in gate) return null;\n await this.#commitEnded(run, 1, "", await this.#undone(`the commit is refused: ${gate.message}`));\n return null;\n }\n const begun = await this.#begin(kind, running, { ran: run }, { asker });\n if ("job" in begun) return null;\n await this.#workEnded(run, kind, 1, "", `the ${kind} did not begin: ${begun.message}`);\n return null;\n }\n async #workEnded(run, kind, code, out, err, more = {}) {\n const first = this.cells.get(["job", run]);\n if (!_RepoLobe.#fields(first)) return;\n const { running: _, ...kept } = first;\n this.cells.set(["job", run], { ...kept, ended: { run, code, out, err, ...more, at: this.stamp.time } });\n await this.#ended({ ...kept, kind }, code, out, err, more);\n }\n #torn(read) {\n const all = "result" in read && Array.isArray(read.result) ? read.result : [];\n const ends = new Set(all.map((wire) => _RepoLobe.#arg(wire, "termination")));\n for (const { key } of this.#all(["back"])) if (!ends.has(key[1])) this.cells.delete(key);\n }\n async #credentials() {\n if (this.#all(["credential"]).length === 0 && this.#all(["token"]).length === 0) return [];\n const kept = (await this.#relations()).flatMap((one) => {\n const secret = _RepoLobe.#arg(one.note, "credential");\n return one.side === "standing" && _RepoLobe.#text(secret) ? [{ secret, far: one.far, placeholder: one.placeholder }] : [];\n });\n return kept.toSorted((a, b) => _RepoLobe.#order(a.secret, b.secret));\n }\n async setToken(args) {\n const refused = this.#refusal("setToken", {});\n if (refused !== null) return refused;\n const name = _RepoLobe.#arg(args, "name");\n const value = _RepoLobe.#arg(args, "value");\n if (!_RepoLobe.#text(name) || !_RepoLobe.#key.test(name))\n return this.error("refused", "a token\'s name is an environment variable\'s name");\n if (value !== null && (typeof value !== "string" || /[\\n\\r\\0]/.test(value)))\n return this.error("refused", "a token is one line of text, or null to remove it");\n if ((await this.#credentials()).some((one) => one.secret === name))\n return this.error("refused", "a credential keeps that name: drop it");\n if (value !== null && this.cells.get(["secret", name]) === void 0 && this.#all(["secret"]).length >= this.#most())\n return this.error("refused", `a copy keeps ${this.#most()} keys at most`);\n if (value === null) this.cells.delete(["secret", name]);\n else this.cells.set(["secret", name], value);\n return null;\n }\n async #giveUp(held) {\n await this.ask("mouth", "drop", { far: held.far });\n if (_RepoLobe.#text(held.placeholder)) await this.nerves.unwire(held.placeholder);\n }\n async credential(args) {\n const refused = this.#refusal("credential", args);\n if (refused !== null) return refused;\n const secret = _RepoLobe.#arg(args, "secret");\n const invitation = _RepoLobe.#arg(args, "invitation");\n const wired = _RepoLobe.#arg(args, "placeholder");\n if (!_RepoLobe.#text(secret) || !_RepoLobe.#issued.test(secret))\n return this.error(\n "refused",\n "a credential\'s secret is an environment variable\'s name in capitals, its words joined by single underscores"\n );\n const cap = await this.#cap("within", _RepoLobe.#issuerWithin);\n if (typeof cap !== "number") return cap;\n const named = _RepoLobe.#arg(args, "within");\n if (typeof named === "number" && named > cap)\n return this.error(\n "refused",\n `an issuer may keep a credential waiting ${cap} ms at most, a cap an owner\'s word moves`\n );\n const within = typeof named === "number" ? named : cap;\n const held = (await this.#credentials()).find((one) => one.secret === secret);\n if (held !== void 0) {\n if (invitation !== void 0 || wired !== void 0)\n return this.error(\n "refused",\n "a standing keeps that secret already: drop it, or ask again with no invitation and no placeholder"\n );\n return this.#askIssuer(secret, held.far, held.placeholder, "kept", within);\n }\n if (invitation !== void 0 && wired !== void 0)\n return this.error("refused", "a credential is taken by an invitation or by a placeholder, not both");\n if (this.cells.get(["secret", secret]) !== void 0)\n return this.error("refused", "a token keeps that name: remove it by setToken");\n if (_RepoLobe.#text(wired)) return this.#takenOver(secret, wired, within);\n if (!_RepoLobe.#text(invitation)) return this.error("refused", "an invitation or a placeholder is named");\n const placeholder = `credential-${secret.toLowerCase().replaceAll("_", "-")}`;\n const given = _RepoLobe.#arg(args, "note");\n const note = given ?? { repo: this.#repo()?.["name"] ?? null, credential: secret };\n const accepted = await this.ask("mouth", "accept", { invitation, placeholder, note });\n if ("error" in accepted) return this.#result(accepted);\n const far = _RepoLobe.#arg(accepted.result, "far");\n if (!_RepoLobe.#text(far)) return this.error("refused", "the mouth named no far organism");\n const noted = await this.#noted(far, { credential: secret });\n if (noted !== null) {\n await this.#giveUp({ far, placeholder });\n return this.error("refused", noted);\n }\n return this.#askIssuer(secret, far, placeholder, "accepted", within);\n }\n async #takenOver(secret, placeholder, within) {\n const standing = (await this.#relations()).find(\n (one) => one.side === "standing" && one.placeholder === placeholder\n );\n if (standing === void 0) return this.error("refused", `the placeholder ${placeholder} is wired to no standing`);\n if (_RepoLobe.#text(_RepoLobe.#arg(standing.note, "credential")))\n return this.error("refused", "that standing keeps another secret already");\n const noted = await this.#noted(standing.far, { credential: secret });\n if (noted !== null) return this.error("refused", noted);\n return this.#askIssuer(secret, standing.far, placeholder, "wired", within);\n }\n #askAgain(asked, since, within, silent = false) {\n const ready = "result" in asked ? _RepoLobe.#arg(asked.result, "ready") : void 0;\n silent &&= "error" in asked && _RepoLobe.#waits.includes(asked.error.code);\n if (!silent && !(typeof ready === "number" && Number.isSafeInteger(ready))) return null;\n const soonest = this.stamp.time + _RepoLobe.#spell;\n const next = typeof ready === "number" ? Math.max(ready, soonest) : soonest;\n return next <= since + within ? next : null;\n }\n #keptToken(far, cell, result) {\n const value = _RepoLobe.#arg(result, "value");\n const url = _RepoLobe.#arg(result, "url");\n if (!_RepoLobe.#text(value) || /[\\n\\r\\0]/.test(value)) return false;\n this.cells.set(["token", far], value);\n const { failed: _, next: __, expires: ___, renews: ____, since: _____, within: ______, ...rest } = cell;\n const where = _RepoLobe.#text(url) ? { url } : {};\n const expires = _RepoLobe.#arg(result, "expires");\n const life = typeof expires === "number" && Number.isInteger(expires) ? expires - this.stamp.time : 0;\n const ends = life > 0 ? { expires: Number(expires), renews: Number(expires) - Math.floor(life / 10) } : {};\n this.cells.set(["credential", far], { ...rest, pending: false, ...where, ...ends });\n return true;\n }\n #renewedAgain(expires) {\n const left = typeof expires === "number" ? Math.floor((expires - this.stamp.time) / 2) : 0;\n return this.stamp.time + Math.max(_RepoLobe.#minute, left);\n }\n async #renewAt(at, ringing) {\n const set = this.cells.get(["renews"]);\n if (typeof set === "number" && set > this.stamp.time && set <= at) return false;\n this.cells.set(["renews"], at);\n const when = Math.max(at, this.stamp.time + _RepoLobe.#spell);\n if (!ringing) await this.#alarm({ at: when, method: "renew", args: {} });\n return true;\n }\n #nextRenewal() {\n let next = null;\n for (const { value } of this.#all(["credential"])) {\n const renews = _RepoLobe.#arg(value, "renews");\n if (typeof renews !== "number" || _RepoLobe.#arg(value, "pending") === true) continue;\n if (next === null || renews < next) next = renews;\n }\n return next;\n }\n async #askIssuer(secret, far, placeholder, how, within) {\n if (!_RepoLobe.#text(placeholder)) return this.error("refused", "the standing has no relation");\n const cell = this.cells.get(["credential", far]);\n const before = _RepoLobe.#fields(cell) ? cell : {};\n const asked = await this.ask(placeholder, "credential", {});\n const next = this.#askAgain(asked, this.stamp.time, within);\n if (next !== null) {\n this.cells.set(["credential", far], { ...before, pending: true, since: this.stamp.time, within, next });\n const set = await this.#alarm({ at: next, method: "renew", args: {} });\n return "error" in set ? this.#result(set) : { secret, pending: true };\n }\n if (!("error" in asked) && this.#keptToken(far, before, asked.result)) {\n const renews = this.#nextRenewal();\n if (renews !== null) await this.#renewAt(renews, false);\n return { secret };\n }\n if (how === "accepted") await this.#giveUp({ far, placeholder });\n if (how === "wired") await this.#noted(far, null);\n return "error" in asked ? this.error(asked.error.code, asked.error.message) : this.error("refused", "the issuer gave no secret of one line");\n }\n async #renewOne(far, value) {\n const placeholder = (await this.#endOfFar(far))?.placeholder;\n const asked = _RepoLobe.#text(placeholder) ? await this.ask(placeholder, "credential", {}) : { error: { code: "refused", message: "the standing has no relation" } };\n if ("result" in asked && this.#keptToken(far, value, asked.result)) return "given";\n const ready = "result" in asked ? _RepoLobe.#arg(asked.result, "ready") : void 0;\n const cap = typeof ready === "number" ? await this.#cap("within", _RepoLobe.#issuerWithin) : _RepoLobe.#issuerWithin;\n const within = typeof cap === "number" ? cap : _RepoLobe.#issuerWithin;\n const next = this.#askAgain(asked, this.stamp.time, within);\n if (next !== null) {\n this.cells.set(["credential", far], { ...value, pending: true, since: this.stamp.time, within, next });\n return "pending";\n }\n const why = "error" in asked ? asked.error.message : "it gave no secret of one line";\n const failed = `the issuer renewed no secret: ${why}`;\n this.cells.set(["credential", far], { ...value, failed, renews: this.#renewedAgain(value["expires"]) });\n return "failed";\n }\n async #issuedAgain(far, value) {\n const since = typeof value["since"] === "number" ? value["since"] : this.stamp.time;\n const within = typeof value["within"] === "number" ? value["within"] : _RepoLobe.#issuerWithin;\n const placeholder = (await this.#endOfFar(far))?.placeholder;\n const asked = _RepoLobe.#text(placeholder) ? await this.ask(placeholder, "credential", {}) : { error: { code: "refused", message: "the standing has no relation" } };\n const { next: _, ...rest } = value;\n if ("result" in asked && this.#keptToken(far, rest, asked.result)) return "given";\n const next = this.#askAgain(asked, since, within, true);\n if (next !== null) {\n this.cells.set(["credential", far], { ...rest, next });\n return "pending";\n }\n const ready = "result" in asked ? _RepoLobe.#arg(asked.result, "ready") : void 0;\n const why = "error" in asked ? asked.error.message : typeof ready === "number" ? "it is made only after then" : "it gave no secret of one line";\n const failed = `the issuer gave no secret in ${within} ms: ${why}`;\n const again = typeof rest["expires"] === "number" ? { renews: this.#renewedAgain(rest["expires"]) } : {};\n const { since: ___, within: ____, ...left } = rest;\n this.cells.set(["credential", far], { ...left, pending: false, failed, ...again });\n return "failed";\n }\n async renew() {\n let soonest = null;\n const waiting = (far) => {\n const next = _RepoLobe.#arg(this.cells.get(["credential", far]) ?? null, "next");\n if (typeof next === "number" && (soonest === null || next < soonest)) soonest = next;\n };\n for (const { key, value } of this.#all(["credential"])) {\n const far = key[1];\n if (typeof far !== "string" || !_RepoLobe.#fields(value)) continue;\n if (value["pending"] !== true) {\n const renews2 = value["renews"];\n if (typeof renews2 !== "number" || this.stamp.time < renews2) continue;\n if (await this.#renewOne(far, value) === "pending") waiting(far);\n continue;\n }\n if (typeof value["next"] === "number" && this.stamp.time < value["next"]) {\n waiting(far);\n continue;\n }\n if (await this.#issuedAgain(far, value) === "pending") waiting(far);\n }\n if (soonest !== null) return { again: soonest };\n const renews = this.#nextRenewal();\n if (renews === null || !await this.#renewAt(renews, true)) return null;\n return { again: Math.max(renews, this.stamp.time + _RepoLobe.#spell) };\n }\n async #keys() {\n const values = {};\n for (const { key, value } of this.#all(["secret"]))\n if (typeof key[1] === "string" && typeof value === "string") values[key[1]] = value;\n for (const { secret, far } of await this.#credentials()) {\n const token = this.cells.get(["token", far]);\n if (typeof token === "string") values[secret] = token;\n }\n return values;\n }\n #keyed() {\n return this.cells.get(["env"]) !== void 0 || this.#all(["secret"]).length > 0 || this.#all(["token"]).length > 0;\n }\n #masked(text) {\n let shown = text;\n for (const { value } of [...this.#all(["secret"]), ...this.#all(["token"])])\n if (typeof value === "string" && value.length > 0) shown = shown.split(value).join("[secret]");\n return shown;\n }\n async #keysFirst(kind, args, given) {\n const refused = this.#refusal(kind, args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n return this.#begin(kind, { set: await this.#keys() }, null, { method: "secrets", more: { running: given } });\n }\n async #work(kind, args, given, begun = {}) {\n const refused = this.#refusal(kind, args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n return this.#begin(kind, given, null, begun);\n }\n async read(args) {\n const refused = this.#refusal("read", args);\n if (refused !== null) return refused;\n const paths = _RepoLobe.#arg(args, "paths");\n if (paths !== void 0) {\n const lone = _RepoLobe.#arg(args, "path") === void 0 && _RepoLobe.#arg(args, "first") === void 0;\n if (!lone || !Array.isArray(paths) || paths.length < 1)\n return this.error("refused", "paths are one file or more, without path or first");\n return this.#result(await this.ask("repos", "read", { paths }));\n }\n const first = _RepoLobe.#arg(args, "first");\n const path = _RepoLobe.#arg(args, "path") ?? null;\n return this.#result(await this.ask("repos", "read", first === void 0 ? { path } : { path, first }));\n }\n async list(args) {\n const refused = this.#refusal("list", args);\n if (refused !== null) return refused;\n const path = _RepoLobe.#arg(args, "path");\n return this.#result(await this.ask("repos", "list", path === void 0 ? {} : { path }));\n }\n async stop(args) {\n const refused = this.#refusal("stop", args);\n if (refused !== null) return refused;\n const doing = this.#repo()?.["doing"];\n const held = _RepoLobe.#text(doing) ? this.cells.get(["job", doing]) : void 0;\n const sync = this.cells.get(["sync"]);\n if (_RepoLobe.#fields(sync)) {\n const kind = _RepoLobe.#shown(sync["kind"]);\n if (this.stamp.asker !== _RepoLobe.#owner && sync["asker"] !== this.stamp.asker)\n return this.error("refused", `the repo runs another\'s ${kind}`);\n const step = _RepoLobe.#arg(held ?? null, "step");\n const own = _RepoLobe.#arg(step ?? null, "sync") === true;\n if (own && _RepoLobe.#arg(held ?? null, "kind") === "land")\n return this.error("refused", `the ${kind} lands already: it ends once landed`);\n if (own && _RepoLobe.#text(doing) && _RepoLobe.#fields(held))\n this.cells.set(["job", doing], { ...held, step: { stopped: true } });\n await this.#finish(sync, 1, `the ${kind} was stopped`);\n return null;\n }\n if (!_RepoLobe.#text(doing)) return this.error("refused", "the repo runs nothing");\n const asker = _RepoLobe.#arg(held, "asker");\n if (this.stamp.asker !== _RepoLobe.#owner && asker !== this.stamp.asker)\n return this.error("refused", "the repo runs another\'s job");\n const grace = _RepoLobe.#arg(args, "grace");\n return this.#heard(await this.ask("repos", "stop", grace === void 0 ? {} : { grace }));\n }\n pull(args) {\n return this.#sync("pull", args);\n }\n push(args) {\n return this.#sync("push", args);\n }\n async #sync(kind, args) {\n const refused = this.#refusal(kind, args);\n if (refused !== null) return refused;\n const ready = this.#ready();\n if (!("name" in ready)) return ready;\n const tag = _RepoLobe.#arg(args, "tag");\n if (tag !== void 0 && !(kind === "pull" && _RepoLobe.#text(tag) && _RepoLobe.#tag.test(tag)))\n return this.error("refused", "a pull names a tag, v and three whole numbers; a push names none");\n if (this.cells.get(["sync"]) !== void 0 && !await this.#stalled())\n return this.error("refused", "the repo pulls or pushes already");\n const on = await this.#standingOn(_RepoLobe.#arg(args, "on"));\n if (!("far" in on)) return on;\n const piece = _RepoLobe.#arg(args, "piece");\n const still = _RepoLobe.#arg(args, "still");\n return this.#start(kind, this.stamp.asker, _RepoLobe.#shown(on["placeholder"]), {\n ...typeof tag === "string" ? { tag } : {},\n ...typeof piece === "number" ? { piece } : {},\n ...typeof still === "number" ? { still } : {},\n ..._RepoLobe.#arg(args, "tells") === true ? { tells: true } : {}\n });\n }\n async #stalled() {\n const sync = this.cells.get(["sync"]);\n return _RepoLobe.#fields(sync) && [..._RepoLobe.#syncFar, "headed"].includes(_RepoLobe.#shown(sync["stage"])) && await this.#stood(sync);\n }\n async #start(kind, asker, on, named = {}) {\n const cap = await this.#cap("still", _RepoLobe.#still);\n if (typeof cap !== "number") return cap;\n const still = named["still"];\n if (typeof still === "number" && still > cap)\n return this.error("refused", `a ${kind} may stand still ${cap} ms at most, a cap an owner\'s word moves`);\n const capped = still === void 0 && cap !== _RepoLobe.#still ? { still: cap } : {};\n const back = await this.#back(asker);\n if (back !== null) return back;\n const job = `${kind}-${this.#nonce()}`;\n const stage = kind === "pull" ? "asking" : "heading";\n const chain = this.#nonce();\n const sync = { job, kind, chain, asker, on, stage, at: 0, pieces: null, moved: this.stamp.time };\n this.cells.set(["sync"], { ...sync, ...named, ...capped });\n const set = await this.#alarm({ at: this.stamp.time, method: "tick", args: { chain } });\n return "error" in set ? this.error(set.error.code, set.error.message) : { job };\n }\n async #cap(name, otherwise) {\n const word = await this.ask("nerves", "limit", { name });\n if ("error" in word) return this.error(word.error.code, word.error.message);\n return typeof word.result === "number" ? Math.min(word.result, _RepoLobe.#lifted) : otherwise;\n }\n async #rung(before) {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync) || !_RepoLobe.#fields(before) || !_RepoLobe.#moved(before, sync)) return;\n const chain = this.#nonce();\n const set = await this.#alarm({ at: this.stamp.time, method: "tick", args: { chain } });\n this.cells.set(["sync"], { ...sync, moved: this.stamp.time, ..."error" in set ? {} : { chain } });\n }\n static #moved(before, after) {\n return after["stage"] !== before["stage"] || after["at"] !== before["at"];\n }\n static #askerOf(sync) {\n return _RepoLobe.#text(sync["asker"]) ? sync["asker"] : _RepoLobe.#owner;\n }\n static #of(sync) {\n return { asker: _RepoLobe.#askerOf(sync) };\n }\n async tick(args) {\n const sync = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(sync) || sync["chain"] !== _RepoLobe.#arg(args, "chain")) return null;\n const over = sync["on"];\n if (!_RepoLobe.#text(over)) {\n await this.#finish(sync, 1, "the lobe stands on that lobe no more");\n return null;\n }\n const far = _RepoLobe.#syncFar.includes(_RepoLobe.#shown(sync["stage"]));\n if (far && await this.#stood(sync)) return null;\n if (sync["stage"] === "waiting" && _RepoLobe.#text(sync["tells"])) return { again: _RepoLobe.#stillEnds(sync) };\n if (far) await this.#step(sync, over);\n else if (sync["stage"] === "headed") await this.#bundling(sync);\n else await this.#check();\n const kept = this.cells.get(["sync"]);\n if (!_RepoLobe.#fields(kept)) return null;\n if (_RepoLobe.#moved(sync, kept)) return { again: this.stamp.time };\n return { again: this.stamp.time + (far || kept["stage"] === "headed" ? _RepoLobe.#every : MINUTE) };\n }\n static #syncFar = ["asking", "getting", "heading", "sending", "waiting"];\n async #step(sync, over) {\n const { stage } = sync;\n if (stage === "asking") await this.#asking(sync, over);\n else if (stage === "getting") await this.#getting(sync, over);\n else if (stage === "heading") await this.#heading(sync, over);\n else if (stage === "sending") await this.#sending(sync, over);\n else if (stage === "waiting") await this.#waiting(sync, over);\n }\n #synced(next) {\n const { waits: _, ...rest } = next;\n this.cells.set(["sync"], { ...rest, moved: this.stamp.time });\n }\n async #asking(sync, over) {\n const repo = this.#repo() ?? {};\n const tag = _RepoLobe.#text(sync["tag"]) ? { tag: sync["tag"] } : {};\n const piece = typeof sync["piece"] === "number" ? { piece: sync["piece"] } : {};\n const asked = await this.ask(over, "give", { since: repo["head"] ?? null, ...tag, ...piece });\n if ("error" in asked) return this.#failedOr(sync, "give", asked.error);\n const { pieces, head, scope } = _RepoLobe.#fields(asked.result) ? asked.result : {};\n if (typeof pieces !== "number") return this.#heardOf(sync);\n if (Array.isArray(scope) && !this.#holdsScope()) {\n if (!_RepoLobe.#text(repo["head"]) && !_RepoLobe.#text(repo["rebuilds"])) {\n const standing = (await this.#held()).find((one) => one.placeholder === sync["on"]);\n const noted = standing === void 0 ? null : await this.#noted(standing.far, { scope: _RepoLobe.#texts(scope) });\n if (noted !== null) return this.#finish(sync, 1, `the scope was not noted: ${noted}`);\n this.cells.set(["repo"], { ...repo, cut: true });\n } else\n return this.#finish(sync, 1, "a scope is held from a lobe’s birth alone, and this lobe holds the repo whole");\n }\n if (pieces === 0) return this.#finish(sync, 0, "");\n this.#synced({ ...sync, stage: "getting", at: 0, pieces, theirs: head ?? null });\n return void 0;\n }\n async #getting(sync, over) {\n const { at, pieces } = sync;\n if (typeof at !== "number" || typeof pieces !== "number") return;\n const asked = await this.ask(over, "piece", { at });\n if ("error" in asked) return this.#failedOr(sync, "piece", asked.error);\n const bytes = _RepoLobe.#arg(asked.result, "bytes");\n if (!(bytes instanceof Uint8Array)) return;\n const put = await this.ask("repos", "put", { at, pieces, bytes, as: "pull" });\n if ("error" in put) return;\n if (at + 1 < pieces) return this.#synced({ ...sync, at: at + 1 });\n const begun = await this.#begin("bring", { as: "pull", pieces }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.#synced({ ...sync, at: pieces, stage: "bringing" });\n else if (!_RepoLobe.#transient(begun.message)) await this.#finish(sync, 1, begun.message);\n }\n async #heading(sync, over) {\n const asked = await this.ask(over, "head", {});\n if ("error" in asked) return this.#failedOr(sync, "head", asked.error);\n const theirs = _RepoLobe.#arg(asked.result, "head") ?? null;\n this.#synced({ ...sync, stage: "headed", theirs: typeof theirs === "string" ? theirs : null });\n }\n async #bundling(sync) {\n const theirs = sync["theirs"];\n const since = typeof theirs === "string" ? theirs : null;\n const piece = typeof sync["piece"] === "number" ? { piece: sync["piece"] } : {};\n const begun = await this.#begin("bundle", { since, as: "push", ...piece }, { sync: true }, _RepoLobe.#of(sync));\n if ("job" in begun) this.#synced({ ...sync, stage: "bundling", theirs: since });\n else if (_RepoLobe.#transient(begun.message) || begun.code === "timeout") this.#heardOf(sync);\n else\n await this.#finish(\n sync,\n 1,\n since === null ? begun.message : `the lobe pushed to holds commits this one does not (${since}): pull first; the jailer said: ${begun.message}`\n );\n }\n async #backOf(sync) {\n const on = _RepoLobe.#shown(sync["on"]);\n await this.#untell(on);\n const waits = typeof sync["still"] === "number" ? sync["still"] : _RepoLobe.#still;\n const note = { repo: this.#repo()?.["name"] ?? null, standing: _RepoLobe.#teller, on };\n const invited = await this.ask("ear", "invite", { waits, lives: null, note });\n if ("error" in invited)\n return this.error(invited.error.code, `no standing back was drawn: ${invited.error.message}`);\n const invitation = _RepoLobe.#arg(invited.result, "invitation");\n return _RepoLobe.#text(invitation) ? invitation : this.error("refused", "the ear drew no invitation back");\n }\n static #transient(message) {\n return message.endsWith(" being cleared") || /^the repo runs .* already$/.test(message) || message === "the lobe keeps no repo";\n }\n async #sending(sync, over) {\n const { job, at, pieces } = sync;\n if (!_RepoLobe.#text(job) || typeof at !== "number" || typeof pieces !== "number") return;\n const sending = at === 0 && sync["tells"] === true ? await this.#drawn(sync) : sync;\n if (sending === null) return;\n const read = await this.ask("repos", "piece", { at, as: "push" });\n const bytes = "result" in read ? _RepoLobe.#arg(read.result, "bytes") : void 0;\n if (!(bytes instanceof Uint8Array)) return;\n const tells = at === 0 && _RepoLobe.#text(sending["tells"]) ? { tells: sending["tells"] } : {};\n const asked = await this.ask(over, "take", { push: job, at, pieces, bytes, ...tells });\n if ("error" in asked) return this.#failedOr(sending, "take", asked.error);\n this.#synced({ ...sending, at: at + 1, ...at + 1 === pieces ? { stage: "waiting" } : {} });\n }\n async #drawn(sync) {\n const tells = await this.#backOf(sync);\n if (typeof tells !== "string") {\n await this.#finish(sync, 1, tells.message);\n return null;\n }\n const drawn = { ...sync, tells };\n this.cells.set(["sync"], drawn);\n return drawn;\n }\n async #told(args) {\n const sync = this.cells.get(["sync"]);\n const on = _RepoLobe.#arg(this.stamp.occupant?.note ?? null, "on");\n const { job, code, err } = _RepoLobe.#fields(args) ? args : {};\n if (!_RepoLobe.#fields(sync) || sync["kind"] !== "push" || sync["stage"] !== "waiting" || sync["on"] !== on || sync["job"] !== job || typeof code !== "number" || typeof err !== "string")\n return this.error("refused", "no such push waits on its end");\n await this.#endHeard(sync, code, err, _RepoLobe.#arg(args, "check") ?? null);\n return null;\n }\n async #endHeard(sync, code, err, check) {\n await this.#finish(sync, code === 0 ? 0 : 1, code === 0 ? "" : err, check === null ? void 0 : check);\n }\n async #waiting(sync, over) {\n const asked = await this.ask(over, "taken", {});\n if ("error" in asked) return this.#failedOr(sync, "taken", asked.error);\n const { code, err, check } = _RepoLobe.#fields(asked.result) ? asked.result : {};\n if (typeof code !== "number" || typeof err !== "string") return this.#heardOf(sync);\n return this.#endHeard(sync, code, err, check ?? null);\n }\n #heardOf(sync) {\n if (sync["waits"] === void 0) return;\n const { waits: _, ...rest } = sync;\n this.cells.set(["sync"], rest);\n }\n async #failedOr(sync, method, error) {\n if (_RepoLobe.#waits.includes(error.code)) return this.#waited(method, error, sync);\n await this.#finish(sync, 1, error.message);\n }\n static #left(kind, stage) {\n if (kind === "push") return stage === "heading" || stage === "headed" ? null : "push";\n return kind === "pull" && stage === "getting" ? "pull" : null;\n }\n async #finish(sync, code, err, check) {\n await this.#finished(sync, code, err, check);\n await this.#owing();\n }\n async #finished(sync, code, err, check) {\n this.cells.delete(["sync"]);\n const { asker, job, kind } = sync;\n const left = _RepoLobe.#left(kind, sync["stage"]);\n if (left !== null) await this.#clear(left);\n const repo = this.#repo();\n const checked = check === void 0 ? {} : { check };\n const synced = { job: job ?? null, kind: kind ?? null, asker: asker ?? null, code, err, ...checked };\n if (repo !== null) this.cells.set(["repo"], { ...repo, synced });\n const out = repo !== null && _RepoLobe.#text(repo["head"]) ? `${repo["head"]}\n` : "";\n const of = sync["of"];\n const init = _RepoLobe.#text(of) ? this.cells.get(["job", of]) : void 0;\n if (_RepoLobe.#text(of) && _RepoLobe.#fields(init) && init["ended"] === null)\n return this.#closed(of, init, code, out, err, checked);\n if (!_RepoLobe.#text(asker) || asker === _RepoLobe.#owner) return;\n const told = { job: job ?? null, kind: kind ?? null, code, out, err, ...checked };\n await this.ask(asker, "done", told, void 0, { letter: { lives: _RepoLobe.#lives } });\n }\n #waited(method, error, next) {\n const kept = this.cells.get(["sync"]);\n const why = `${method}: ${error.code}: ${error.message}`;\n const since = _RepoLobe.#arg(_RepoLobe.#arg(kept, "waits"), "since");\n const waits = { why, since: typeof since === "number" ? since : this.stamp.time };\n this.cells.set(["sync"], { ...next, waits });\n }\n static #stillOn(held) {\n return `its stage ${_RepoLobe.#shown(held["stage"])}, piece ${JSON.stringify(held["at"] ?? null)} of ${JSON.stringify(held["pieces"] ?? null)}`;\n }\n static #stillEnds(held) {\n const moved = typeof held["moved"] === "number" ? held["moved"] : 0;\n return moved + (typeof held["still"] === "number" ? held["still"] : _RepoLobe.#still) + 1;\n }\n async #stood(held) {\n const moved = held["moved"];\n const span = typeof held["still"] === "number" ? held["still"] : _RepoLobe.#still;\n if (typeof moved !== "number" || this.stamp.time - moved <= span) return false;\n if (held["stage"] === "waiting" && _RepoLobe.#text(held["tells"]) && _RepoLobe.#text(held["on"])) {\n await this.#waiting(held, held["on"]);\n if (this.cells.get(["sync"]) === void 0) return true;\n }\n const why = _RepoLobe.#arg(held["waits"], "why");\n const last = _RepoLobe.#text(why) ? `; its last ask ${why}` : "";\n const still = `moved not for ${span} ms: ${_RepoLobe.#stillOn(held)}${last}`;\n await this.#finish(held, 1, `the ${_RepoLobe.#shown(held["kind"])} ${still}`);\n return true;\n }\n};\nexport {\n RepoLobe as default\n};\n';
1244
1244
 
1245
1245
  var REPO = { faculty: REPO_SOURCE, label: "repo" };
1246
1246
  export {