@williacj/rigger 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +370 -2
  3. package/package.json +56 -4
  4. package/scripts/doc-reference-check.mjs +59 -0
  5. package/scripts/gate-check.mjs +249 -0
  6. package/scripts/lib/pack-result.mjs +9 -0
  7. package/scripts/record-commit.mjs +67 -0
  8. package/src/cli/doctor.mjs +1021 -0
  9. package/src/cli/init.mjs +384 -0
  10. package/src/cli/once.mjs +489 -0
  11. package/src/cli/pause.mjs +56 -0
  12. package/src/cli/plan.mjs +106 -0
  13. package/src/cli/recording.mjs +52 -0
  14. package/src/cli/report.mjs +242 -0
  15. package/src/cli/resume.mjs +96 -0
  16. package/src/cli/rigger.mjs +12 -0
  17. package/src/cli/run.mjs +10 -0
  18. package/src/cli/setup-board.mjs +108 -0
  19. package/src/cli/verbs.mjs +82 -0
  20. package/src/cli/verdict.mjs +180 -0
  21. package/src/config/validate.mjs +960 -0
  22. package/src/execution/groups.mjs +185 -0
  23. package/src/execution/kept-output.mjs +21 -0
  24. package/src/execution/role.mjs +171 -0
  25. package/src/execution/run.mjs +490 -0
  26. package/src/execution/step.mjs +26 -0
  27. package/src/execution/workspace.mjs +866 -0
  28. package/src/observation/push.mjs +103 -0
  29. package/src/observation/report.mjs +415 -0
  30. package/src/observation/sink.mjs +271 -0
  31. package/src/package-commit.json +1 -0
  32. package/src/scheduling/admission.mjs +390 -0
  33. package/src/scheduling/clock.mjs +98 -0
  34. package/src/scheduling/lane.mjs +160 -0
  35. package/src/scheduling/loop.mjs +1738 -0
  36. package/src/scheduling/pull-order.mjs +46 -0
  37. package/src/substrate/data-ref.mjs +147 -0
  38. package/src/substrate/forge/assets.mjs +5 -0
  39. package/src/substrate/forge/graphql.mjs +258 -0
  40. package/src/substrate/forge/item-write.mjs +74 -0
  41. package/src/substrate/forge/read.mjs +998 -0
  42. package/src/substrate/forge/repository-write.mjs +152 -0
  43. package/src/substrate/forge/runners.mjs +510 -0
  44. package/src/substrate/forge/schema-write.mjs +70 -0
  45. package/src/substrate/forge/write-made.mjs +40 -0
  46. package/src/substrate/git-environment.mjs +54 -0
  47. package/src/substrate/host.mjs +23 -0
  48. package/src/substrate/launchd.mjs +23 -0
  49. package/src/substrate/process-table.sh +48 -0
  50. package/src/substrate/process.mjs +2474 -0
  51. package/src/substrate/providers/adapters.mjs +8 -0
  52. package/src/substrate/providers/claude.mjs +427 -0
  53. package/src/substrate/providers/codex.mjs +349 -0
  54. package/src/substrate/standard-error.mjs +134 -0
  55. package/src/substrate/worktrees.mjs +517 -0
  56. package/src/workflow/clock-mark.mjs +40 -0
  57. package/src/workflow/escalation.mjs +110 -0
  58. package/src/workflow/facts.mjs +92 -0
  59. package/src/workflow/first-above.mjs +17 -0
  60. package/src/workflow/form-check.mjs +88 -0
  61. package/src/workflow/gate.mjs +62 -0
  62. package/src/workflow/judges.mjs +695 -0
  63. package/src/workflow/marker.mjs +265 -0
  64. package/src/workflow/next-action.mjs +456 -0
  65. package/src/workflow/status-issue.mjs +268 -0
  66. package/src/workflow/transitions.mjs +588 -0
  67. package/templates/claude/agents/architect.md +116 -0
  68. package/templates/claude/agents/engineer.md +57 -0
  69. package/templates/claude/agents/pm.md +114 -0
  70. package/templates/claude/agents/reviewer.md +37 -0
  71. package/templates/claude/agents/spike-engineer.md +80 -0
  72. package/templates/claude/hooks/refuse-reserved-git-commands.mjs +909 -0
  73. package/templates/claude/settings.json +50 -0
  74. package/templates/claude/skills/acceptance/SKILL.md +275 -0
  75. package/templates/claude/skills/agent-style/SKILL.md +78 -0
  76. package/templates/claude/skills/code-review/SKILL.md +242 -0
  77. package/templates/claude/skills/proposal/SKILL.md +175 -0
  78. package/templates/claude/skills/spec-style/SKILL.md +112 -0
  79. package/templates/claude/skills/tdd/SKILL.md +230 -0
  80. package/templates/codex/config.toml +19 -0
  81. package/templates/doc-reference-check.md +25 -0
  82. package/templates/githooks/pre-push +24 -0
  83. package/templates/github/workflows/rigger-gate.yml +209 -0
  84. package/templates/launchd/com.williacj.rigger.plist +31 -0
  85. package/templates/rigger.config.mjs +78 -0
@@ -0,0 +1,54 @@
1
+ // ABOUTME: The environment a git child is given, so a git Rigger spawns acts on the repository
2
+ // the call names rather than one an inherited variable names.
3
+
4
+ /**
5
+ * The variables by which an inherited environment redirects git away from the repository a call
6
+ * names.
7
+ *
8
+ * Measured rather than read off a list: each candidate was set to a second repository's paths and
9
+ * six surfaces of `git -C <fixture>` compared against the same surfaces with nothing set, with
10
+ * git 2.55.0 on Windows 11. These five moved at least one surface — `GIT_DIR` moved the git dir,
11
+ * `HEAD`, the index and the object store; `GIT_COMMON_DIR` and `GIT_OBJECT_DIRECTORY` the object
12
+ * store; `GIT_WORK_TREE` the top level; `GIT_INDEX_FILE` the index.
13
+ * `GIT_ALTERNATE_OBJECT_DIRECTORIES`, `GIT_NAMESPACE`, `GIT_CEILING_DIRECTORIES` and `GIT_PREFIX`
14
+ * moved none of them, in either call shape this repository spawns git in, and so are left alone.
15
+ * The run is in `docs/journal/2026-09-24-0745-151-the-hook-exported-the-branch-it-was-committing.md`.
16
+ *
17
+ * Card #167 took `GIT_ALTERNATE_OBJECT_DIRECTORIES` and `GIT_CEILING_DIRECTORIES` further, on the
18
+ * ground that moving none of the six does not by itself settle whether a variable is safe to
19
+ * inherit. The first does move a surface outside them: set to a second repository's object store,
20
+ * that repository's objects become readable here, where with nothing set `git cat-file -e` on one
21
+ * exits 1. The second moves no surface at all in that shape; it bites only on an ancestor of the
22
+ * directory git runs in, and there it withholds the repository git would have found rather than
23
+ * naming a different one — measured across a repository nested inside another, so that a redirect
24
+ * had a second repository to reach. Neither reaches a write: with each set to a throwaway second
25
+ * repository, that repository is unchanged to the byte after fifteen write shapes. Card #151's
26
+ * fault was a write to a repository nobody named, so on that test neither is added, and a
27
+ * variable that widens a read is a divergence this list does not claim to cover. The run is in
28
+ * `docs/journal/2026-09-24-1720-167-a-read-is-not-a-write.md`.
29
+ */
30
+ export const REDIRECTING = [
31
+ 'GIT_DIR', 'GIT_COMMON_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_OBJECT_DIRECTORY',
32
+ ];
33
+
34
+ /** The same names, for the case-folded comparison below. */
35
+ const REMOVED = new Set(REDIRECTING);
36
+
37
+ /**
38
+ * `from` with every redirecting variable removed, for a git child to inherit. Everything else is
39
+ * handed on, because git reads its own configuration, credential helper and proxy out of the
40
+ * environment.
41
+ *
42
+ * The comparison folds case because the host may. Measured on the same host: `git_dir` and
43
+ * `Git_Dir` redirect git exactly as `GIT_DIR` does, Windows folding environment names, while
44
+ * `Object.keys(process.env)` reports each key in the case it was written — so deleting the
45
+ * upper-case spelling alone leaves the redirect standing. No variable git honours is spelled in
46
+ * lower case on a host that distinguishes them, so folding costs nothing there.
47
+ */
48
+ export function gitEnvironment(from = process.env) {
49
+ const env = {};
50
+ for (const [name, value] of Object.entries(from)) {
51
+ if (!REMOVED.has(name.toUpperCase())) env[name] = value;
52
+ }
53
+ return env;
54
+ }
@@ -0,0 +1,23 @@
1
+ // ABOUTME: L0's real operating-system host for process signals, starts, reads, paths, and time.
2
+
3
+ import * as childProcess from 'node:child_process';
4
+ import * as fs from 'node:fs';
5
+ import { setTimeout as pause } from 'node:timers/promises';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ export const realHost = {
9
+ ps: process.platform === 'linux' ? fileURLToPath(new URL('./process-table.sh', import.meta.url)) : '/bin/ps',
10
+ lsof: process.platform === 'linux' ? '/usr/bin/lsof' : '/usr/sbin/lsof',
11
+ get execFile() { return childProcess.execFile; },
12
+ get spawn() { return childProcess.spawn; },
13
+ get spawnSync() { return childProcess.spawnSync; },
14
+ killChild: (child, name) => child.kill(name),
15
+ get stat() { return fs.statSync; },
16
+ realpath: (path) => fs.realpathSync.native(path),
17
+ access: (path) => fs.accessSync(path, fs.constants.X_OK),
18
+ uid: () => process.getuid(),
19
+ pid: () => process.pid,
20
+ signal: (target, name) => process.kill(target, name),
21
+ // ARCHITECTURE.md defines the four-method L0 clock; these are Node's native timers.
22
+ clock: { get now() { return Date.now; }, pause, get schedule() { return setTimeout; }, get cancel() { return clearTimeout; } },
23
+ };
@@ -0,0 +1,23 @@
1
+ // ABOUTME: Reads a loaded launchd job's fields through the process adapter, without interpreting engine config.
2
+
3
+ import { isAbsolute } from 'node:path';
4
+
5
+ import { runCommand } from './process.mjs';
6
+ import { gitEnvironment } from './git-environment.mjs';
7
+ import { FORGE_TIMEOUT } from './forge/runners.mjs';
8
+
9
+ /** The program and exit timeout of the loaded label in this user's GUI domain. */
10
+ export async function loadedJob(label, { uid = process.getuid(), emitter, timeout = FORGE_TIMEOUT, run = runCommand } = {}) {
11
+ const result = await run({ command: 'launchctl', args: ['print', `gui/${uid}/${label}`],
12
+ cwd: process.cwd(), env: gitEnvironment(), emitter, timeout });
13
+ if (result.timedOut) throw new Error(`launchctl print reached its timeout of ${timeout} ms`);
14
+ if (result.exit === 113) return null;
15
+ if (result.exit !== 0) throw new Error(`launchctl print exited ${result.exit}`);
16
+ const output = result.stdout.toString('utf8');
17
+ const programs = [...output.matchAll(/^\tprogram = (.+)$/gm)];
18
+ const timeouts = [...output.matchAll(/^\texit timeout = (\d+)$/gm)];
19
+ if (programs.length !== 1 || timeouts.length !== 1 || !isAbsolute(programs[0][1]) || !Number.isSafeInteger(Number(timeouts[0][1]))) {
20
+ throw new Error('launchctl print cannot read one absolute program and one whole exit timeout');
21
+ }
22
+ return { program: programs[0][1], exitTimeout: Number(timeouts[0][1]) };
23
+ }
@@ -0,0 +1,48 @@
1
+ #!/bin/bash
2
+ # ABOUTME: Reads Linux process groups, raw command names and zombie wait statuses for L0.
3
+
4
+ # proc_pid_comm(5) exposes the kernel name without ps replacing control bytes.
5
+ if [[ $# == 4 && $1 == -p && $2 =~ ^[1-9][0-9]*$ && $3 == -o && $4 == ucomm= ]]; then
6
+ [[ -r /proc/$2/comm ]] || exit 1
7
+ exec /bin/cat /proc/"$2"/comm
8
+ fi
9
+
10
+ args=("$@")
11
+ wait_status=0
12
+ for argument in "$@"; do
13
+ if [[ $argument == pid=,stat=,xstat= ]]; then wait_status=1; fi
14
+ done
15
+ for ((index=0; index<${#args[@]}; index++)); do
16
+ if [[ ${args[index]} == -g && index+1 -lt ${#args[@]} ]]; then
17
+ group=${args[index+1]}
18
+ unset 'args[index]' 'args[index+1]'
19
+ /bin/ps -A -o pgid= "${args[@]}" |
20
+ /usr/bin/awk -v group="$group" -v wait_status="$wait_status" '
21
+ $1 == group {
22
+ sub(/^[[:space:]]*[0-9]+[[:space:]]+/, "")
23
+ if (wait_status) {
24
+ status = 0
25
+ if ($2 ~ /^Z/) {
26
+ path = "/proc/" $1 "/stat"
27
+ read = (getline record < path)
28
+ close(path)
29
+ # proc_pid_stat(5): field 52 is the decimal POSIX wait status.
30
+ # The comm field may contain spaces and closing parentheses.
31
+ sub(/^.*\) /, "", record)
32
+ count = split(record, fields, " ")
33
+ if (read != 1 || count < 50 || fields[1] != "Z") next
34
+ status = fields[50]
35
+ }
36
+ sub(/[^[:space:]]+[[:space:]]*$/, sprintf("%x", status))
37
+ }
38
+ print
39
+ found=1
40
+ }
41
+ END { exit !found }
42
+ '
43
+ status=("${PIPESTATUS[@]}")
44
+ if [[ ${status[0]} != 0 ]]; then exit "${status[0]}"; fi
45
+ exit "${status[1]}"
46
+ fi
47
+ done
48
+ exec /bin/ps "$@"