@krysoworks/kryso 0.0.2 → 2.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +146 -6
- package/bin/kryso +31 -0
- package/bin/ship-it-status +14 -0
- package/bin/ship-ledger +14 -0
- package/bin/ship-loop +14 -0
- package/bin/ship-pass +14 -0
- package/bin/warden +14 -0
- package/dist/answer.d.ts +38 -0
- package/dist/answer.js +48 -0
- package/dist/bytes.d.ts +5 -0
- package/dist/bytes.js +35 -0
- package/dist/cleanup.d.ts +1 -0
- package/dist/cleanup.js +629 -0
- package/dist/commands.d.ts +48 -0
- package/dist/commands.js +293 -0
- package/dist/completions.d.ts +24 -0
- package/dist/completions.js +239 -0
- package/dist/daemon.d.ts +15 -0
- package/dist/daemon.js +23 -0
- package/dist/diagnose.d.ts +47 -0
- package/dist/diagnose.js +314 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +241 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.js +17 -0
- package/dist/evidence.d.ts +39 -0
- package/dist/evidence.js +327 -0
- package/dist/home.d.ts +3 -0
- package/dist/home.js +27 -0
- package/dist/install.d.ts +59 -0
- package/dist/install.js +137 -0
- package/dist/isolate.d.ts +28 -0
- package/dist/isolate.js +402 -0
- package/dist/leftovers.d.ts +5 -0
- package/dist/leftovers.js +156 -0
- package/dist/machine.d.ts +6 -0
- package/dist/machine.js +185 -0
- package/dist/palette.d.ts +147 -0
- package/dist/palette.js +167 -0
- package/dist/plan.d.ts +1 -0
- package/dist/plan.js +133 -0
- package/dist/proc.d.ts +23 -0
- package/dist/proc.js +23 -0
- package/dist/read.d.ts +1 -0
- package/dist/read.js +297 -0
- package/dist/readiness.d.ts +5 -0
- package/dist/readiness.js +64 -0
- package/dist/remote.d.ts +6 -0
- package/dist/remote.js +85 -0
- package/dist/self-update.d.ts +1 -0
- package/dist/self-update.js +224 -0
- package/dist/semver.d.ts +7 -0
- package/dist/semver.js +42 -0
- package/dist/style.d.ts +71 -0
- package/dist/style.js +187 -0
- package/dist/update.d.ts +47 -0
- package/dist/update.js +190 -0
- package/dist/work.d.ts +25 -0
- package/dist/work.js +449 -0
- package/dist/workflows.d.ts +4 -0
- package/dist/workflows.js +73 -0
- package/docker/entrypoint.sh +44 -0
- package/docker/runner.Dockerfile +39 -0
- package/package.json +55 -22
- package/scripts/install-skills.sh +607 -0
- package/skills/code-review/SKILL.md +231 -0
- package/skills/kryso/SKILL.md +107 -0
- package/skills/kryso/golden/help.rounded.ansi +23 -0
- package/skills/kryso/golden/help.square.ansi +23 -0
- package/skills/kryso/golden/help.txt +23 -0
- package/skills/kryso/golden/table-narrow.json +11 -0
- package/skills/kryso/golden/table-narrow.rounded.ansi +4 -0
- package/skills/kryso/golden/table-narrow.square.ansi +4 -0
- package/skills/kryso/golden/table.ansi +5 -0
- package/skills/kryso/golden/table.json +11 -0
- package/skills/kryso/ledger.sh +2146 -0
- package/skills/kryso/palette.json +57 -0
- package/skills/kryso/reference/resuming.md +30 -0
- package/skills/kryso/reference/routing.md +23 -0
- package/skills/kryso/reference/stage-1-claim.md +79 -0
- package/skills/kryso/reference/stage-2-build.md +133 -0
- package/skills/kryso/reference/stage-3-prove.md +51 -0
- package/skills/kryso/reference/stage-4-pr.md +76 -0
- package/skills/kryso/reference/stage-5-reconcile.md +81 -0
- package/skills/kryso/reference/stage-6-merge-or-park.md +73 -0
- package/skills/kryso/reference/stage-7-close-out.md +62 -0
- package/skills/kryso/reference/terminal.md +7 -0
- package/skills/kryso/ship-it-status.sh +1503 -0
- package/skills/kryso/ui.py +274 -0
- package/skills/kryso/ui.sh +609 -0
- package/skills/kryso-build/SKILL.md +168 -0
- package/skills/kryso-shift/SKILL.md +167 -0
- package/skills/kryso-shift/archive.py +2784 -0
- package/skills/kryso-shift/archive_checker.py +462 -0
- package/skills/kryso-shift/archive_checker_lambda.py +155 -0
- package/skills/kryso-shift/archive_health.py +364 -0
- package/skills/kryso-shift/archive_launchd.py +140 -0
- package/skills/kryso-shift/archive_remote.py +990 -0
- package/skills/kryso-shift/archiving-checker.md +140 -0
- package/skills/kryso-shift/archiving-keep.md +115 -0
- package/skills/kryso-shift/archiving-recovery.md +112 -0
- package/skills/kryso-shift/archiving-remote.md +166 -0
- package/skills/kryso-shift/archiving.md +146 -0
- package/skills/kryso-shift/coverage.schema.json +225 -0
- package/skills/kryso-shift/deadline.sh +254 -0
- package/skills/kryso-shift/feedback.schema.json +35 -0
- package/skills/kryso-shift/feedback.sh +228 -0
- package/skills/kryso-shift/history-manifest.schema.json +331 -0
- package/skills/kryso-shift/keep-after.sh +55 -0
- package/skills/kryso-shift/measure.sh +611 -0
- package/skills/kryso-shift/merge-ready.sh +207 -0
- package/skills/kryso-shift/outcome.schema.json +16 -0
- package/skills/kryso-shift/pass-rules.md +8 -0
- package/skills/kryso-shift/profile.schema.json +42 -0
- package/skills/kryso-shift/reader.sh +692 -0
- package/skills/kryso-shift/reads.sh +151 -0
- package/skills/kryso-shift/reference/allowance.md +21 -0
- package/skills/kryso-shift/reference/driver.md +95 -0
- package/skills/kryso-shift/reference/measuring.md +67 -0
- package/skills/kryso-shift/reference/outputs.md +21 -0
- package/skills/kryso-shift/reference/pass-script.md +115 -0
- package/skills/kryso-shift/reference/reconcile-and-merge.md +55 -0
- package/skills/kryso-shift/reference/second-reader.md +9 -0
- package/skills/kryso-shift/reference/sweeps.md +83 -0
- package/skills/kryso-shift/repair.schema.json +14 -0
- package/skills/kryso-shift/report-template.html +679 -0
- package/skills/kryso-shift/report.py +389 -0
- package/skills/kryso-shift/report_fixture.py +65 -0
- package/skills/kryso-shift/reporting.md +58 -0
- package/skills/kryso-shift/result.sh +91 -0
- package/skills/kryso-shift/runner.sh +1178 -0
- package/skills/kryso-shift/ship-loop.sh +3977 -0
- package/skills/kryso-shift/ship-pass.sh +4987 -0
- package/skills/kryso-shift/steps.jq +19 -0
- package/skills/kryso-shift/workflow.mjs +830 -0
- package/skills/kryso-shift/workflows/default.json +22 -0
- package/skills/kryso-shift/workflows/ralph.json +13 -0
- package/skills/kryso-watch/SKILL.md +100 -0
- package/skills/kryso-watch/answer.schema.json +23 -0
- package/skills/kryso-watch/base-refs.sh +44 -0
- package/skills/kryso-watch/board.sh +58 -0
- package/skills/kryso-watch/reference/config.md +23 -0
- package/skills/kryso-watch/reference/outputs.md +30 -0
- package/skills/kryso-watch/reference/report.md +29 -0
- package/skills/kryso-watch/reference/scheduler.md +32 -0
- package/skills/kryso-watch/reference/settlement.md +29 -0
- package/skills/kryso-watch/reference/shift.md +44 -0
- package/skills/kryso-watch/reference/shim-limits.md +22 -0
- package/skills/kryso-watch/reference/triage.md +26 -0
- package/skills/kryso-watch/schema.jq +40 -0
- package/skills/kryso-watch/settle.schema.json +36 -0
- package/skills/kryso-watch/stage-common.sh +187 -0
- package/skills/kryso-watch/stages/report.sh +525 -0
- package/skills/kryso-watch/stages/settle.sh +722 -0
- package/skills/kryso-watch/stages/shift.sh +466 -0
- package/skills/kryso-watch/stages/triage.sh +379 -0
- package/skills/kryso-watch/tracker.sh +27 -0
- package/skills/kryso-watch/triage.schema.json +77 -0
- package/skills/kryso-watch/warden.launchd.plist +50 -0
- package/skills/kryso-watch/warden.schema.json +98 -0
- package/skills/kryso-watch/warden.sh +1004 -0
- package/bin/kryso.js +0 -11
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# reads.sh: what a build fork is handed so that it need not read whole files (#681). Wave 3's
|
|
3
|
+
# forks read 135k tokens of files a pass, and each whole read is paid again on every later turn.
|
|
4
|
+
# Two sections for the build prompt: the parts of a spec the brief cites, quoted, and a line
|
|
5
|
+
# index of every large file the brief names or the branch changes. ship-pass.sh sources it.
|
|
6
|
+
# Run as `bash reads.sh <worktree> <base> <brief>`, it prints both, for /kryso's stage 2.
|
|
7
|
+
|
|
8
|
+
# A file longer than this gets an index, and the build skill tells a fork to read an indexed
|
|
9
|
+
# file by ranges no longer than the second.
|
|
10
|
+
READS_INDEX_LINES=1000
|
|
11
|
+
READS_RANGE_LINES=120
|
|
12
|
+
|
|
13
|
+
# _reads_named <worktree> <brief>: each file of the worktree the brief names, once: a path with a
|
|
14
|
+
# folder in it, or a file at the root in backticks. A path that climbs out with `..` is left
|
|
15
|
+
# alone, because the brief's text comes from the tracker.
|
|
16
|
+
_reads_named() {
|
|
17
|
+
local path
|
|
18
|
+
{ grep -oE '[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)+' "$2"; grep -oE '`[A-Za-z0-9_.-]+\.[A-Za-z0-9]+`' "$2" | tr -d '`'; } |
|
|
19
|
+
sed -e 's/^\.\///' -e 's/\.*$//' | sort -u |
|
|
20
|
+
while IFS= read -r path; do [[ "/$path/" == */../* || ! -f "$1/$path" ]] || printf '%s\n' "$path"; done
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# _reads_stories <brief>: the user stories the brief cites by number, one a line, in order.
|
|
24
|
+
# It reads `story 5`, `stories 2 to 3`, `stories 2-3`, `stories 2 through 3` and
|
|
25
|
+
# `stories 1, 2 and 4`.
|
|
26
|
+
_reads_stories() {
|
|
27
|
+
local -a words
|
|
28
|
+
local i from
|
|
29
|
+
grep -oiE 'stor(y|ies)[[:space:]]+[0-9]+([[:space:]]*(,|and|to|through|-|–)[[:space:]]*[0-9]+)*' "$1" |
|
|
30
|
+
sed -E 's/^[A-Za-z]+[[:space:]]+//; s/(to|through|–)/-/g; s/(,|and)/ /g; s/-/ - /g' |
|
|
31
|
+
while read -r -a words; do
|
|
32
|
+
for ((i = 0; i < ${#words[@]}; i++)); do
|
|
33
|
+
if [[ "${words[i]}" == - && -n "${from:-}" && "${words[i + 1]:-}" =~ ^[0-9]+$ ]]; then
|
|
34
|
+
# BSD seq counts down where GNU seq prints nothing, so a backward range reads as none.
|
|
35
|
+
[[ "${words[i + 1]}" -le "$from" ]] || seq "$((from + 1))" "${words[i + 1]}"
|
|
36
|
+
from=""; i=$((i + 1))
|
|
37
|
+
elif [[ "${words[i]}" =~ ^[0-9]+$ ]]; then
|
|
38
|
+
echo "${words[i]}"; from="${words[i]}"
|
|
39
|
+
fi
|
|
40
|
+
done
|
|
41
|
+
done | sort -un
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# _reads_cited <spec> <brief>: the spec's cited parts, each line quoted: the numbered items of
|
|
45
|
+
# its user stories section that the brief cites, then each section the brief cites as
|
|
46
|
+
# `§ <heading>`, `section <heading>` or `the <heading> section`, to the next heading of its level
|
|
47
|
+
# or above.
|
|
48
|
+
_reads_cited() {
|
|
49
|
+
local spec="$1" brief="$2" stories headings="" heading
|
|
50
|
+
stories="$(_reads_stories "$brief" | tr '\n' ' ')"
|
|
51
|
+
while IFS= read -r heading; do
|
|
52
|
+
[[ -n "$heading" ]] || continue
|
|
53
|
+
heading="${heading#* }"
|
|
54
|
+
# Whole words, and `the <heading> section` rather than `<heading> section`, so a heading
|
|
55
|
+
# such as Scope is not cited by `the Out of scope section`.
|
|
56
|
+
if grep -qiwF -e "§ $heading" -e "§$heading" -e "section $heading" -e "the $heading section" "$brief"; then
|
|
57
|
+
headings+="$heading"$'\n'
|
|
58
|
+
fi
|
|
59
|
+
done < <(grep -E '^#{1,6} ' "$spec")
|
|
60
|
+
READS_HEADINGS="$headings" awk -v stories=" $stories" '
|
|
61
|
+
BEGIN { n = split(ENVIRON["READS_HEADINGS"], h, "\n"); for (i = 1; i <= n; i++) if (h[i] != "") want[tolower(h[i])] = 1 }
|
|
62
|
+
/^#{1,6} / {
|
|
63
|
+
level = index($0, " ") - 1; text = substr($0, level + 2)
|
|
64
|
+
if (in_section && level <= section_level) in_section = 0
|
|
65
|
+
in_stories = (tolower(text) ~ /stories/)
|
|
66
|
+
item = 0
|
|
67
|
+
if (!in_section && (tolower(text) in want)) { in_section = 1; section_level = level; print "" }
|
|
68
|
+
}
|
|
69
|
+
in_section { print "> " $0; next }
|
|
70
|
+
in_stories && /^[0-9]+\. / { item = (index(stories, " " ($0 + 0) " ") > 0) }
|
|
71
|
+
in_stories && item && /^[^ \t]/ && !/^[0-9]+\. / { item = 0 }
|
|
72
|
+
in_stories && item && /^$/ { item = 0 }
|
|
73
|
+
in_stories && item { print "> " $0 }' "$spec"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# reads_spec <worktree> <brief>: the From the spec section, or nothing when the brief cites no
|
|
77
|
+
# part of a file it names.
|
|
78
|
+
reads_spec() {
|
|
79
|
+
local wt="$1" brief="$2" path cited lines out=""
|
|
80
|
+
while IFS= read -r path; do
|
|
81
|
+
[[ "$path" == *.md ]] || continue
|
|
82
|
+
cited="$(_reads_cited "$wt/$path" "$brief")"
|
|
83
|
+
[[ -n "${cited//[[:space:]]/}" ]] || continue
|
|
84
|
+
lines="$(wc -l < "$wt/$path" | tr -d ' ')"
|
|
85
|
+
out+="The brief cites these parts of \`$path\`, which is $lines lines. Read the rest of it only where they leave a question open, and by line range."$'\n\n'"${cited#$'\n'}"$'\n\n'
|
|
86
|
+
done < <(_reads_named "$wt" "$brief")
|
|
87
|
+
[[ -n "$out" ]] || return 0
|
|
88
|
+
printf '## From the spec\n\n%s' "$out"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# _reads_outline <file>: one line per landmark, `<start>-<end> <name>` or `<line> <text>`: a
|
|
92
|
+
# shell file's top-level functions, its `# ---- <title>` banners and, in a suite, the start of each
|
|
93
|
+
# case's banner, cut short because a suite has hundreds; a
|
|
94
|
+
# Markdown file's headings and a TypeScript, JavaScript or Python file's top-level definitions,
|
|
95
|
+
# each with the lines up to the next.
|
|
96
|
+
_reads_outline() {
|
|
97
|
+
case "$1" in
|
|
98
|
+
*.sh|*.bash)
|
|
99
|
+
awk '
|
|
100
|
+
/^(function[ \t]+)?[A-Za-z_][A-Za-z0-9_:.-]*[ \t]*\(\)[ \t]*\{?/ {
|
|
101
|
+
name = $0; sub(/^function[ \t]+/, "", name); sub(/[ \t]*\(\).*/, "", name)
|
|
102
|
+
if ($0 ~ /\}[ \t]*$/ && $0 ~ /\{/) print NR " " name; else { start = NR; open = 1 }
|
|
103
|
+
next
|
|
104
|
+
}
|
|
105
|
+
open && /^\}/ { print start "-" NR " " name; open = 0; next }
|
|
106
|
+
/^# (----|====) *[^ =-]/ { text = $0; sub(/[ =-]+$/, "", text); print NR " " text; next }
|
|
107
|
+
/^echo "/ { text = substr($0, 7); sub(/"$/, "", text); if (length(text) > 48) text = substr(text, 1, 48) "..."; print NR " case: " text }' "$1" ;;
|
|
108
|
+
*.md)
|
|
109
|
+
_reads_spans '^#{1,6} ' "$1" ;;
|
|
110
|
+
*.ts|*.tsx|*.js|*.mjs|*.py)
|
|
111
|
+
_reads_spans '^(export[ \t]+)?(default[ \t]+)?(async[ \t]+)?(function|class|const|interface|type|def)[ \t]' "$1" ;;
|
|
112
|
+
esac
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# _reads_spans <regex> <file>: `<start>-<end> <line>` for each line the regex matches, each
|
|
116
|
+
# span running to the line before the next match, and the last to the end of the file.
|
|
117
|
+
_reads_spans() {
|
|
118
|
+
awk -v re="$1" '
|
|
119
|
+
$0 ~ re { if (start) print start "-" (NR - 1) " " text; start = NR; text = substr($0, 1, 100) }
|
|
120
|
+
END { if (start) print start "-" NR " " text }' "$2"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# reads_index <worktree> <base> <brief>: the Line index section, or nothing when no file the
|
|
124
|
+
# brief names or the branch changes is over the limit.
|
|
125
|
+
reads_index() {
|
|
126
|
+
local wt="$1" base="$2" brief="$3" path lines out=""
|
|
127
|
+
while IFS= read -r path; do
|
|
128
|
+
[[ -n "$path" && -f "$wt/$path" ]] || continue
|
|
129
|
+
lines="$(wc -l < "$wt/$path" | tr -d ' ')"
|
|
130
|
+
[[ "$lines" -gt "$READS_INDEX_LINES" ]] || continue
|
|
131
|
+
out+="### \`$path\` ($lines lines)"$'\n\n'"$(_reads_outline "$wt/$path" | sed 's/^/- /')"$'\n\n'
|
|
132
|
+
done < <({ _reads_named "$wt" "$brief"; git -C "$wt" diff --name-only "$base" -- 2>/dev/null; } | sort -u)
|
|
133
|
+
[[ -n "$out" ]] || return 0
|
|
134
|
+
printf '## Line index\n\nThese files are over %s lines, and the brief names them or the branch changes them. Read them by range, %s lines or fewer a call, from the lines below, and read a whole file only when it is shorter than that. The lines are the worktree'"'"'s as this prompt was written, so after an edit find a name again with `grep -n`.\n\n%s' \
|
|
135
|
+
"$READS_INDEX_LINES" "$READS_RANGE_LINES" "$out"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# reads_sections <worktree> <base> <brief>: both sections, a blank line between them.
|
|
139
|
+
reads_sections() {
|
|
140
|
+
local spec index
|
|
141
|
+
spec="$(reads_spec "$1" "$3")"
|
|
142
|
+
index="$(reads_index "$1" "$2" "$3")"
|
|
143
|
+
[[ -z "$spec" ]] || printf '%s\n' "$spec"
|
|
144
|
+
[[ -z "$spec" || -z "$index" ]] || printf '\n'
|
|
145
|
+
[[ -z "$index" ]] || printf '%s\n' "$index"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
149
|
+
[[ $# -eq 3 ]] || { echo "usage: reads.sh <worktree> <base> <brief>" >&2; exit 2; }
|
|
150
|
+
reads_sections "$@"
|
|
151
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# The allowance
|
|
2
|
+
|
|
3
|
+
Every pass runs under an allowance of active execution, `--timeout` seconds, and a grace of `--grace` seconds for its processes to exit once the allowance runs out. `ship-loop.sh --help` gives the defaults. The shell keeps it, never the model. The claim's tracker calls, the fork and its reviewers, a receipt waiting for the gate lock or running, the PR, the CI wait and every reconciliation context with its proof and its second CI wait all count against it, and neither a fork rerun nor a reconciliation context inside the pass renews it. A rate-limit wait is the driver's own sleep, bounded by `--wait` and the reset, so it is not counted, and the retry runs under what the attempt before it left. A later sweep's pass on the same issue gets a new allowance and nothing else: the fork count, a spent rerun and the reconciliation count stay on the checkpoint. The dry run prints the allowance under both engines and both profiles, and the script engine's pass command carries it.
|
|
4
|
+
|
|
5
|
+
Under the `ship-it` engine the driver stops the host. Under the script engine the pass script stops itself: it runs the pass as a second process and stops that process with everything it started, and the driver's own stop is a backstop at the allowance plus two graces and thirty seconds. Either way the stop is TERM to the pass's process tree, and to its process group when it has one of its own, then KILL to whatever is left when the grace is up. Nothing outside that tree is signalled. The pass's own receipts are inside it: the pass script calls `receipt` without `--wait`, which keeps the command in the pass's process tree and group, and only a model host's `--wait` detaches one ([playbook ADR 0050](../../../docs/adr/0050-a-receipt-detaches-only-when-a-model-host-bounds-its-wait.md)). A receipt another worktree holds the gate lock with is not the pass's descendant, so a pass that runs out while it queues behind that receipt leaves it running, and leaves no receipt of its own, because a queued receipt has not reserved one yet.
|
|
6
|
+
|
|
7
|
+
The pass holds its issue's authority while it runs: a kernel lock `ledger.sh hold` takes on `<git-common-dir>/ship-it-pass-<issue>.lock` and hands down to every process the pass starts. The kernel frees it when the last of them exits, which is how a stop is confirmed, and `ledger.sh active <repo> <issue>` reads it. A pass started while it is held, by a continuation, a second shift or a person at a terminal, ends `locked` having touched nothing, which the driver counts the way it counts any locked issue rather than as a failure, so a continuation cannot start while the pass before it still runs.
|
|
8
|
+
|
|
9
|
+
When the allowance runs out, the ledger module records it in the worktree. The checkpoint is rewritten at the stage the pass reached with status `interrupted` and disposition `resumable`, the fork count and the PR kept, and one line follows it: `<stage> interrupted deadline consumed=<n>s allowance=<n>s stopped=<confirmed|unconfirmed> signal=<TERM|KILL>`, which `ledger.sh read` returns as `interruption`. The pass script's block says `interrupted`, exit 4, with a `deadline` field. Under the `ship-it` engine the host wrote nothing, so the driver writes `pass-<n>.json` itself, the block in `structured_output` beside the same `deadline` field. The shift line's outcome is `interrupted`, it counts toward the two-in-a-row stop, and the summary lists it under `interrupted` and `exceptions` until a later attempt supersedes it. A confirmed stop is resumable at its stage in a later sweep, or from the claim when the pass stopped before its cut. An unconfirmed one is never continued in the shift, and nothing may resume it while its authority is held.
|
|
10
|
+
|
|
11
|
+
An INT or a TERM to a driver while a pass runs, which is a ctrl+c at its terminal or `kryso attach`'s stop, ends the allowance at once. The pass is stopped the same way, its ledger line adds `interrupt=<signal>`, and `--resume` continues it. A shift that gets one stops after that pass, or before the next when none runs: it writes its summary with the stop reason `interrupted by SIG<signal>` and exits 130.
|
|
12
|
+
|
|
13
|
+
A session can also exit with one of its receipts still open, because a model host's `--wait` receipt runs detached and outlives the session that started it: a budget stop, a crash or a host kill all leave one. So the driver judges a pass only once the receipts in its worktree have closed, as `ledger.sh read` calls them, waiting at most `--receipt-wait` seconds after the session exits. The wait is outside the allowance, because the session it bounds has already ended. Unattended it is one `pass <n>: #<issue>'s session exited with <log> open` line, and on a terminal a spinner naming the receipt and the clock it waits until, the way the CI wait shows. Once the receipts close, the pass is judged from the evidence as any other is, and a continuation reuses those receipts under ADR 0009's rule. Past the bound the shift line's outcome is `interrupted`, its reason names the open receipt, and the issue stays resumable at its stage, unless the allowance stopped the pass and its stop was unconfirmed. A rate-limited session past the bound is interrupted too, rather than retried, because the retry would resume beside the live writer. Every sweep's plan holds a resumable issue while a receipt is open in its worktree, with `<log> is open in its worktree` as the reason, so no continuation starts beside a live writer. A worktree that was there before the pass and is not the shift's is another pass's, and its receipts are not waited on.
|
|
14
|
+
|
|
15
|
+
The driver reads the same evidence before it continues any interrupted or resumable issue in a later sweep, under either engine: a checkpoint that does not parse, a disposition the ledger was never taught, a worktree on another branch or a HEAD that lost the checkpoint's head makes the issue `unsafe`, named in the shift's output and the summary, with no pass spent on it.
|
|
16
|
+
|
|
17
|
+
What makes an interruption resumable is on disk. The resume re-enters the stage the checkpoint names and nothing earlier, and it refuses, with a `resume refused` line and nothing spent, a checkpoint that names another issue or branch, a disposition this engine was never taught, an issue since assigned to someone else, a worktree on another branch, and a HEAD that no longer contains the checkpoint's head. A pass killed with no chance to record anything, by a crash or a `kill -9`, leaves its checkpoint `running`. The resume names that stage and every receipt with no exit on one `resume reconciled` line, re-enters the stage, and runs again, to a new receipt, each gate that never closed: a receipt with no exit line proves nothing, and `read` calls it `abandoned` once no live process can still write it. An effect whose answer was lost is found rather than made twice. The claim is an assignment, made again. A cut whose ledger never came is reused when it is exactly the worktree this pass would cut, on its branch at the base with nothing in it, and anything else there stays a lock. A PR create is the open PR on the branch. Dirty work in a worktree is left where it is, except the tracked changes a resume finds as it enters the prove.
|
|
18
|
+
|
|
19
|
+
A resume that enters the prove reuses a gate's receipt under [ADR 0009](../../../docs/adr/0009-receipts-run-detached-and-a-pass-waits-on-them-in-the-foreground.md)'s rule rather than run the gate again, and the gate's ledger line says so: `prove <name> exit=<n> (logs/<log>), reused: closed over <head>`. A red receipt the pass recorded counts as the run it was, so the retries go on from there and are not renewed. This engine adds two conditions to the ADR's. The receipt ran the gate's own command, and it started after the last `build checked` line of the current build attempt, so neither a fork's own receipt nor one from before a rerun stands in for the pass's. Tracked files changed since that check are put back to HEAD first, because a stopped gate may have left its writes behind, and a `resume restored` line names them and the log that keeps their diff. A proof inside reconcile never reuses a receipt.
|
|
20
|
+
|
|
21
|
+
The driver's own tracker calls are outside every allowance: the preflight's, each sweep's snapshot, and the reads it makes between passes for the fingerprint, the continuation brief and the stack's evidence. Each runs under a limit of its own, 60 seconds and a five-second grace, and `SHIP_LOOP_TRACKER_SECONDS` sets another for a slow connection. A call that runs out is stopped with everything it started and then reads as a call that failed, so every reader's rule for a failed read holds: a merge-ready read rejects the issue, a brief leaves the PR's state out, and a fingerprint takes the PR or its checks as empty and the feedback as unreadable, so it differs from one whose read came back. The shift log gets one `tracker=timeout` line per call stopped. The preflight's login, remote, label and CI checks, the default branch and the first snapshot stop the shift there with a reason that says gh did not answer within the limit. The candidate count and the ruleset check do not, as they never did. A later sweep's snapshot that cannot be read, for that reason or another, closes the shift as `failed` with its summary, because the passes before it have evidence to leave. `ship-loop.sh integration` is a person's command and runs without the limit.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Driver reference
|
|
2
|
+
|
|
3
|
+
The detail behind the driver's options in [SKILL.md](../SKILL.md): what a reported pass posts, how each profile runs and which MCP servers it loads, what the preflight and its CI check read, how options travel to a pass, what a queued pass is told, how the output is styled on a terminal, how a stacked queue merges, and what an integration branch is.
|
|
4
|
+
|
|
5
|
+
## Reporting each pass
|
|
6
|
+
|
|
7
|
+
`KRYSO_REPORT_URL` and `KRYSO_REPORT_TOKEN` are set the way [Running it](../SKILL.md#running-it) says. Every setting the driver reads from the environment has a `KRYSO_` name, except `SHIP_LOOP_TRACKER_SECONDS`, which [The allowance](allowance.md) describes. Until 3.0.0 the old `SHIP_LOOP_` name of each of the others still works when the new one is unset, and the driver prints one warning line naming each old name it read.
|
|
8
|
+
|
|
9
|
+
Right after it writes a pass's shift-log line, the driver posts one JSON body for that pass to the URL, under either engine, so a shift killed at three in the morning has still reported its first passes. The body carries the line's fields (`pass`, `ended_at`, `outcome`, `issue`, `branch`, `base`, `pr`, `profile`, `host`, `billing`, `effort`, `cost_usd`, `usage`, `session`) plus the outcome block's `reason`, the `repo` as `owner/name`, the one the shift's tracker queries address (gh's answer, or the origin remote's URL where there is no gh or gh cannot place the repo), and the `shift` id, so passes from several repos and shifts on one night are told apart and a retried push lands on the same row. A rate-limited attempt and its retry are the same pass, so both post to that pass's row, and the disk keeps each attempt's body under its own name, as [What it leaves behind](outputs.md) lists. Identifiers the line records as `none` are `null`, and so is a cost the host does not supply. The push is best effort: a non-2xx or a transport error is retried once after five seconds, and a second failure is one line in the shift log and never a failed pass. URL unset means nothing is sent and nothing is said. URL set without the token is a preflight stop, because every push would be a 401. The dry run prints `the shift reports to <url>` or `the shift reports nothing`, never the token. What is behind the URL is not the playbook's concern.
|
|
10
|
+
|
|
11
|
+
## Profiles and models
|
|
12
|
+
|
|
13
|
+
The default dollar cap of 20 has room in it: two ordinary passes on a Swift repo with an `xcodebuild test` gate ran $11 and $13, about thirty minutes each, of which twenty was API time and the rest the gate and the CI wait.
|
|
14
|
+
|
|
15
|
+
### MCP servers
|
|
16
|
+
|
|
17
|
+
A Claude pass loads the MCP servers your settings name, and every context in it, the orchestrator, the build fork and each reviewer, starts with a note that lists each of their tools. On the 2026-11 archive of 498 passes that note was 16,700 to 18,500 tokens a context, re-read on every turn. `mcp` in the repository's `.kryso/config.json` takes three forms, the list as a JSON list or comma-separated. `on`, the default, keeps every server. `off` starts each pass with `--strict-mcp-config` and no servers, for a repository whose passes call no MCP tool. A list keeps those servers and no others: `"mcp": ["claude.ai Figma", "neon"]`.
|
|
18
|
+
|
|
19
|
+
Choose the list from what the repository's passes call, not from what its tickets might touch. Run `claude mcp list` in the repository and copy each name as it prints it, `claude.ai` prefix included. A server the archive shows no pass calling belongs off the list, because it costs its whole share of the note in every context and gives nothing back. When a new kind of ticket needs a server, add it to the list before the shift, since a pass cannot load one mid-run.
|
|
20
|
+
|
|
21
|
+
For one shift, `--mcp` takes any of the three forms and wins over the config: `kryso shift --mcp "claude.ai Figma, neon"`. The driver exports it as `KRYSO_PASS_MCP`, which a pass script reads the same way, and under the script engine the pass command carries the flag as well. `KRYSO_PASS_MCP` set in the environment does the same for every shift that shell starts, and the flag wins over it.
|
|
22
|
+
|
|
23
|
+
The preflight checks every name against `claude mcp list` before any claim, so a misspelt name stops the shift and the line names it. The list reaches the host as an `allowedMcpServers` entry in `--settings`, not through `--strict-mcp-config`, which drops every claude.ai connector. The host matches a connector by its URL alone, so a plugin's server at the same URL is kept with it, and matches every other server by its name. The shift's opening says what is off or kept and where the value came from, and `shift.json` records it in `mcp` and `mcp_kept`.
|
|
24
|
+
|
|
25
|
+
Every setting in git config is `kryso.<name>`: `passMcp`, `passSkills`, `secondReader`, `secondReaderModel` and `jevKeychain`. Before the rename they were `playbook.<name>`. The old key is read where the new one is absent, until 3.0.0, and the preflight prints one warning for each old key with the command that moves it. `passMcp` and `passSkills` have since moved to `mcp` and `skills` in `.kryso/config.json`: the git config key is read where the file does not set it, until 3.0.0, with one warning that names the move. Where the file sets one, the git config key is ignored, and the warning says so.
|
|
26
|
+
|
|
27
|
+
### The Codex profile
|
|
28
|
+
|
|
29
|
+
The Codex profile unsets `OPENAI_API_KEY` and `CODEX_API_KEY` for its auth check and every invocation, so an exported key cannot silently change the billing path. It uses `--approve-for-me`, whose unattended policy includes workspace writes, without the mutually exclusive `--sandbox workspace-write`. That sandbox writes the workspace alone, and a worktree's commits, the gate lock and the pass lock live in the main checkout's git common dir, so a fresh `exec` adds that directory with `--add-dir`. Without it every commit and receipt fails once, the receipt with exit 75, and is retried escalated. A resume keeps the sandbox its session started with. It never uses the sandbox-bypass flag and feature-probes the flags its `exec` and `exec resume` commands require. If Codex exits before producing JSONL or a final response, the result keeps the first stderr diagnostic, capped at 300 characters, and the driver records a failed pass. On a full-engine rate limit, the retry uses `codex exec resume <session>` inside the same pass. A later sweep's continuation of that issue is a new `codex exec`, never a resume. The script engine keeps its worktree-and-ledger resume and starts a fresh model context.
|
|
30
|
+
|
|
31
|
+
Built-ins live in [runner.sh](../runner.sh). `KRYSO_PROFILE_FILE` may point at JSON that follows [profile.schema.json](../profile.schema.json) and gives a registered host a named default model:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{"profiles":{"codex-fast":{"host":"codex","model":"gpt-5.6-luna","effort":"medium"}}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
That format keeps future names such as Muse Spark, DeepSeek or Kimi out of the CLI grammar. A new provider still needs one host adapter in `runner.sh` for its authentication, permissions and result shape. Credentials stay in that provider's normal credential store, never in this file.
|
|
38
|
+
|
|
39
|
+
### The process limit
|
|
40
|
+
|
|
41
|
+
Every context a pass starts runs under a process limit. `KRYSO_PROCESSES` sets it, and `runner_process_limit` in [runner.sh](../runner.sh) holds the default and the rules. `processesOf` in `packages/cli/src/isolate.ts` gives a container started with `--isolate docker` the same number as `--pids-limit`. A profile cannot name it yet, because [profile.schema.json](../profile.schema.json) is frozen and a new field needs a new version of the schema.
|
|
42
|
+
|
|
43
|
+
The limit exists because of #451. On 2026-11-26 a build fork's probe put a logging `sleep` first on PATH, a suite's slow `ps` called `sleep`, and the probe called `ps`. The two called each other until the user reached `kern.maxprocperuid`, and every shell on the machine failed to fork.
|
|
44
|
+
|
|
45
|
+
### The skills a pass lists
|
|
46
|
+
|
|
47
|
+
Every Claude context also starts with a listing of the skills it can call. A pass lists only the pass skills: `kryso`, `kryso-build`, `kryso-shift`, `kryso-watch`, `code-review`, `tdd`, `implement` and `diagnosing-bugs`. In the #547 probes the listing fell from 78 skills to 6, and a context's first request from 32,332 tokens to 29,425 (`docs/qa/pass-skills-547/RESULTS.md`). `skills` in `.kryso/config.json` adds skills to the set, as a list named the way a session lists them: `"skills": ["grilling", "design:ux-copy"]`. A plugin's skill keeps its whole plugin on. `all` lists every skill, as before.
|
|
48
|
+
|
|
49
|
+
Claude Code has no skill allowlist, so the runner writes the deny side into the start's `--settings`: a `skillOverrides` entry of `off` for every other folder in the repository's `.claude/skills`, the user's skills and synced claude.ai skills, and every command file. It adds `disableBundledSkills` for the skills Claude Code ships, so a bundled skill cannot be added. `skillOverrides` does not reach a plugin's skills, so a plugin that carries none of the set is set to false in `enabledPlugins`. A plugin with hooks stays on, since turning it off would drop its hooks too. So does a plugin whose server `mcp` keeps. The orchestrator, the build fork and each reviewer run in the process that read those settings, and the user's own sessions never see them. The host reads only the last `--settings`, so this JSON and `mcp`'s allowlist travel as one, and a passthrough `--settings` is refused while `mcp` names servers to keep or `skills` is not `all`. A name no folder, command or plugin carries stops the preflight with that name. A Codex pass lists every skill, and the opening says so.
|
|
50
|
+
|
|
51
|
+
## What the preflight checks
|
|
52
|
+
|
|
53
|
+
Each check is a stop with a `preflight:` line and exit 1, except the warnings named below. A `--base` origin lacks is a stop, a local copy notwithstanding, and an integration base with no ruleset blocking its deletion is a warning: see [Integration branches](#integration-branches).
|
|
54
|
+
|
|
55
|
+
Every skill the workflow pins, `tdd` and `implement` in the built-in default, has to be in kryso's store, `~/.kryso/skills/<owner>/<repo>@<commit>/`. The shift, a pass and a resumed pass fetch a pin the store lacks from its source (`KRYSO_PIN_SOURCES` names another host or a directory in place of GitHub), and stop with a line that names the pin when the fetch fails. An entry is written once and never fetched again. A pass hands the build its pins and no other copy: on Claude a plugin, `kryso-pins`, under the ledger that links each one and that every start loads with `--plugin-dir`, while the user's own copy of the same name is turned off; on Codex a link per pin in the worktree's `.agents/skills`, named `kryso-pin-<skill>@<commit>` and kept out of git by one exclude line, whose path the prompt names. A ship-it shift loads the same plugin from its shift directory. An installed copy of a skill kryso carries that differs from the copy beside the driver, test files aside, is a warning that names `kryso skills install`.
|
|
56
|
+
|
|
57
|
+
The `gh` allow rules are a warning, not a stop. Under `--permission-prompts none` a `gh` read that no allow rule covers is denied, and the model reads the denial as an empty column or a failure. The user-level `~/.claude/settings.json` is the reliable place for the rules, because a project's own `.claude/settings.json` allow rules are ignored in print mode until the workspace has been trusted once, interactively. The preflight checks both and warns. It cannot fail on either, since managed settings can grant them in ways it cannot see.
|
|
58
|
+
|
|
59
|
+
### The CI health check
|
|
60
|
+
|
|
61
|
+
CI is checked once per shift, because it is the piece of infrastructure a whole build can be lost to: a PR that gets no check parks at reconcile after the fork has run. Where any file under `.github/workflows/` names `self-hosted`, `gh api repos/{owner}/{repo}/actions/runners` must list at least one runner with status `online`. Busy is fine, and labels are not matched: a busy runner plus the queue rule covers overload, and label drift is a repo misconfiguration the preflight does not diagnose. A repo on GitHub-hosted runners skips that rule, since the endpoint lists self-hosted runners alone. On every repo with a GitHub remote, `gh run list --status queued` must report at most three runs, or the number `--ci-max-queued` or `KRYSO_CI_MAX_QUEUED` sets, the flag winning. The limit is inclusive: N lets N queued runs through and stops at N+1, and 0 asks for an empty queue. A run in progress is the runner doing its job, not a queue. A runner process takes one job at a time, so a box that runs several runner instances drains a deeper queue in the time one instance drained three, and about three per instance keeps the wait the same. A very large N, such as 999, turns the queue rule off and keeps the runner rule, which is the narrower way past a deep queue than `--no-ci-check`. Listing runners needs admin on the repository, which a write collaborator does not have however many runners they registered or host themselves, and GitHub answers a private repo with 404 rather than 403 so as not to confirm it exists. Being refused the list is not evidence that a runner is down, so on either code the check asks a question write can answer instead: it walks the last ten runs, newest first, and reads their jobs for the freshest one that carries a `runner_name` and a `self-hosted` label. A job that reached a runner within a day is a runner that was alive and taking work, and the queue rule is what catches one that has died since. A skipped job carries the labels but no `runner_name`, so it proves nothing and is passed over. No recent self-hosted job, none at all, or no run to read stops the shift, as does any runners error that is not one of those two codes, because a health the driver cannot read for another reason is not one it can vouch for. The header prints one `CI:` line either way, the runner count or the runner that last took a job, and the queue depth, so a park read back later can be set against what CI looked like when the shift started. `--no-ci-check` skips both rules for a shift whose passes should park at reconcile instead.
|
|
62
|
+
|
|
63
|
+
## Options
|
|
64
|
+
|
|
65
|
+
`--second-reader off|on|jev|llm` sets the second reader for every pass the shift runs. The driver exports it as `PLAYBOOK_SECOND_READER`, so a `/kryso` session or a pass script it starts reads the same value, and under the script engine the pass command carries the flag as well. The flag wins over a `PLAYBOOK_SECOND_READER` already in the environment, which wins over `kryso.secondReader` in git config, which wins over the default, `off`. The preflight resolves the three in that order through `reader.sh mode`, which owns the values and their order, so the driver needs `reader.sh` beside it, and stops on a value outside the set, whichever source it came from, with one `preflight:` line naming `kryso.secondReader`, the value it got and the allowed values, before anything is claimed or spent. When any source set a value, the dry run and the header of a shift print it and where it came from on one `second reader:` line, `on` read as `jev`, the way `reader.sh mode` reads it. Unset, nothing prints, nothing is exported, and a pass resolves the environment and the config as it always did.
|
|
66
|
+
|
|
67
|
+
## A queue instead of the label
|
|
68
|
+
|
|
69
|
+
Which flags need a queue is in [A queue instead of the label](../SKILL.md#a-queue-instead-of-the-label). Every cap is reported before anything runs: `--max` as the distinct issues admitted to the shift, `--sweeps` as the traversals, and from the two the worst case in driver passes and model starts that [Sweeps](sweeps.md#sweeps) gives. Each rate-limit retry is one more start, up to three a shift.
|
|
70
|
+
|
|
71
|
+
With a queue, each pass runs with the issue, the base and the note after the skill name:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
claude -p "/kryso Work issue #36. Base branch: main. Caller note: keep the diff small" ...
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
That is the whole change to a pass. The prompt is where a caller names the issue and the base for `/kryso`, as a person would in a session, and how `/kryso` reads them is its own contract, which this driver does not change. Without a queue the prompt is the bare `/kryso`, and the driver behaves as it always did. A `--dry-run` with a queue prints the queue, the resolved base and one command per queued pass, so the prompt text can be read before anything is spent. Under `--epic` it also prints the scope, the epic's open children in GitHub's order, and the children it dropped for an open blocker, each with its blockers' numbers, so a queue shorter than the epic can be read against the tracker. The filter is the one `/kryso`'s stage 1 applies and the frontier query in `docs/agents/issue-tracker.md` describes, read once per sweep. The driver applies it because a blocked or locked child queued anyway costs a pass that ends `nothing-to-take`, or ends a stacked shift. Each pass still runs stage 1's [gates](../../kryso/reference/stage-1-claim.md#gates) itself. An `--epic` child came off a sweep, so its prompt ends `The issue came off a sweep of epic #N.`, the script engine's pass gets `--swept`, and a gate that refuses it writes nothing on the issue. An `--issues` child was named, so a refusal labels it `agent:blocked` and says why on the issue.
|
|
78
|
+
|
|
79
|
+
## On a terminal
|
|
80
|
+
|
|
81
|
+
The driver styles its output only on an attended run: stdout a terminal, or CLICOLOR_FORCE set, with NO_COLOR unset. The first line is the brand pill with the queue and the cap at the right edge. A pill opens each section after it: the preflight, the plan, and on a dry run a `DONE` pill after one arrow line per planned pass. Each pass opens under a pill that names its place in the shift and its issue, such as `PASS 2 OF 5 #37`, with a static bar of the passes when the count is exact and the spend so far under `--budget`. Its ledger events print under it as they land, its mark from the outcome word and its evidence dim, while a spinner waits on the next one. The pass ends on one line where its logfmt line was, and the shift closes under a `DONE` pill on a planned stop or a `STOPPED` pill on any other, with a table of the passes. A failure before any work starts, a bad flag among them, is an `ERROR` pill with the way out under a `HINT` pill.
|
|
82
|
+
|
|
83
|
+
NO_COLOR set to anything non-empty turns the styling off, whatever else is set. Otherwise CLICOLOR_FORCE set to anything but 0 sends the run down the styled path with no terminal, and FORCE_COLOR does nothing. The pills and lines draw from the palette in `ui.sh` beside `ledger.sh` and need no gum. gum, 0.12 or newer, draws only the spinner and the pager, and a terminal without it gets one line on stderr, once per run: `the spinner and the pager need gum 0.12 or newer (brew install gum)`. Playbook ADRs 0006 and 0042 record why.
|
|
84
|
+
|
|
85
|
+
`shift.log` and `summary.json` are written the same either way. In plain mode the last line and its stop word stay exactly as playbook ADR 0003 fixes them, and plain mode is what a background run sees, because its stdout is a file.
|
|
86
|
+
|
|
87
|
+
## A stacked queue
|
|
88
|
+
|
|
89
|
+
With `--stack`, a pass that parked with its PR open leaves its branch for the next pass to build on, and a pass that shipped merged its branch into the base it was given, so the base stays where it was. Under the default engine that merge is the stack's shape: `/kryso`'s no-merge rule guards the default branch alone, so a pass whose base is an earlier pass's branch merges into it and reports `shipped`. The first pass's PR then carries every later pass's commits, and the shift ends with one PR to review and merge rather than one per issue, and the earlier worktrees behind their own branches until a resume fetches them. A pass that parked before it reached a PR, or failed, left nothing to stack on, and the shift ends there with exit 1 rather than base the next pass on a guess. Without `--stack` every pass bases on the shift base. A queued shift-log line carries a `base=` field, so the chain can be read back afterwards.
|
|
90
|
+
|
|
91
|
+
## Integration branches
|
|
92
|
+
|
|
93
|
+
`ship-loop.sh integration <epic> <slug>` cuts `integration/<epic>-<slug>` from origin's default branch with an empty commit of its own, so `git branch --merged` never lists it as merged, pushes it, and leaves a local copy tracking origin when it cut the branch. It also adds a repository ruleset with no bypass that blocks deleting `integration/*` on origin, and leaves one that already does alone. Where the plan has no rulesets it warns and carries on. A second run changes nothing: a branch already on origin is not cut again, and a local branch origin lacks is refused, because whether it holds the epic's work is a person's call. [Playbook ADR 0010](../../../docs/adr/0010-integration-branches-carry-a-commit-of-their-own-and-cannot-be-deleted-on-origin.md) says why.
|
|
94
|
+
|
|
95
|
+
A pass resumed on a base that is gone locally restores it from origin, or parks as `base-missing` when origin lacks it too: the pass script's rule is in [the pass script reference](pass-script.md#the-checkpoint), and `/kryso`'s in its [resuming reference](../../kryso/reference/resuming.md).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Measuring passes
|
|
2
|
+
|
|
3
|
+
For a per-run table of added and deleted lines, cost, wall and API time, model, effort and layer shares, use [the reporting procedure](../reporting.md). It covers both historical evidence and the committed change counts new script-engine records retain.
|
|
4
|
+
|
|
5
|
+
To keep one completed pass's evidence after its worktree goes, and to restore it somewhere else and report on it there, use [the archive command](../archiving.md).
|
|
6
|
+
|
|
7
|
+
A pass's outcome, timing and usage are measured from what it saved, never from a transcript read back or a model asked. The evidence is the pass record, and the analysis is [measure.sh](../measure.sh), which reads files and nothing else: it starts no model session and changes no tracker state.
|
|
8
|
+
|
|
9
|
+
## The pass record
|
|
10
|
+
|
|
11
|
+
Every script-engine attempt that got as far as a ledger writes a pass record, at the path [What it prints and leaves](pass-script.md#what-it-prints-and-leaves) gives, and names it in the outcome block. Its schema is `ship-pass-record/4`, and the schema of record is [packages/core/schemas/pass-record/4.schema.json](../../../packages/core/schemas/pass-record/4.schema.json), which names every field, its type and which ones can be null. Version 2 added `test_volume`, version 3 `workflow`: the workflow the pass resolved from its base, its hash, what chose it and each stage's source. Version 4 added each context's `transcript` figures, the five `rereads` and the brief's `criteria`. Records written before them say `ship-pass-record/1`, `/2` or `/3`, and every reader still takes them. Core's tests run `write_record` from `ship-pass.sh` and check both records it writes against that file, so the writer cannot drift from it unnoticed.
|
|
12
|
+
|
|
13
|
+
The schema cannot say why a few fields read the way they do. The `code-review` skill gets a hash in `revisions` only when every copy a host could load agrees, because the host does not say which copy it loaded, and `review_skill_copies` lists each copy with its own hash. `reviewers` records the restriction the fork was told about, not what it dispatched: the host does not report a sub-agent's type, and only a live trial shows the fork used it. A context's `role` is `build`, `standards`, `spec`, `repair`, `feedback`, `second-reader` or `seam-reader`. Usage, cost, peak context and compaction are `null` where the host did not report them, never zero.
|
|
14
|
+
|
|
15
|
+
The transcript figures exist so that a cost review reads the record instead of parsing every turn again, as the review of 2026-12-03 had to. The record reads them at the close of the pass from the host's own transcripts, which a pass cannot keep: `${CLAUDE_CONFIG_DIR:-~/.claude}/projects/<worktree>/<session>.jsonl` for a context the pass started, and `<session>/subagents/agent-<id>.jsonl` beside it for a reviewer. They follow that review's `docs/qa/plan-2026-12-02/cost-review/analyse.py` on `main`, so a record compares like for like with its `turns.csv` and `data.csv`, and the schema's descriptions give each definition. A context on another host, or whose transcript is gone, keeps `transcript: null`. Records already in the archive stay as they were written.
|
|
16
|
+
|
|
17
|
+
The record reads no env file, so nothing in one can reach it. Under the default engine the driver's `pass-<n>.json` is the host's own result, which has the usage, cost, duration and model the host reports and none of the rest. The analysis reads both.
|
|
18
|
+
|
|
19
|
+
## Test volume
|
|
20
|
+
|
|
21
|
+
`test_volume` in the record is what `bash measure.sh volume <repo> <merge base> <head>` prints for the change: the added lines of test and of source, their ratio, whether that is over the policy's threshold, and the rule that counted them. A path on the test paths is test code. Of the rest, JSON, Markdown, SQL and lockfiles are neither. The test paths and the threshold come from the repository's `.kryso/testing-policy.md` as the base holds it (`docs/agents/testing-policy.md` where that is absent), or from the default rule when it has none, and the record names the policy's blob hash so a change in volume can be traced to a change in policy. The record adds the seams the fork named, from its `build seam` events, and the tests each kept, from its `build seam-tests seam=<k> tests=<n>` events.
|
|
22
|
+
|
|
23
|
+
`bash measure.sh volume --list changes.jsonl` counts many changes at once, one `{repo, from, to, label, seam, policy}` per line, and adds a summary: the median ratio and the over-threshold count over the seam passes, and the aggregate ratio over all of them. `analyze` adds the same summary to each cohort from the records that carry a volume, and leaves out the ones from before it. [docs/qa/test-volume-baseline/](../../../docs/qa/test-volume-baseline/REPORT.md) holds the baseline it was first run on.
|
|
24
|
+
|
|
25
|
+
## Lasting
|
|
26
|
+
|
|
27
|
+
A lean pass that ships fewer tests is only cheaper if its change holds. `bash measure.sh lasting --list changes.jsonl [--days 30]` reads the same lines as `volume --list` and asks git what happened to each change after it merged: whether it was reverted, and how many `fix` commits followed it into its files. The rules for each are in the comment above `lasting_json`.
|
|
28
|
+
|
|
29
|
+
The numbers lean on git's dates and merges, and three things bend them. Committer dates set the window, so a fix rebased later than it was written counts by the later date. A change merged too recently to have had its whole window is still counted, and `window_complete` marks it, because a crop of them makes the second half look better than it is. A squash merge leaves `to` off the branch, so the change reads as not merged.
|
|
30
|
+
|
|
31
|
+
The halves split each repository's merged changes at the midpoint between its first merge and its last, which is the trend a lean-pass change should move.
|
|
32
|
+
|
|
33
|
+
## The procedure
|
|
34
|
+
|
|
35
|
+
1. Copy the evidence you want to measure out of the worktrees and shift directories into one directory, because a worktree goes when its PR merges. A pass kept with [the archive command](../archiving.md) restores into such a directory. Take each attempt's `record*.json`, and each `pass-<n>.json` and `ratelimit-<n>-<k>.json` from the shift directories.
|
|
36
|
+
2. Write `sources.json` beside them: the observation period, then one entry per file with its cohort, and what only a person knows about it, which `measure.sh` cannot read off disk:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{"period": {"from": "2026-09-01T00:00:00Z", "to": "2026-10-01T00:00:00Z"},
|
|
40
|
+
"workload": {"repository": "o/r", "task": "ship-loop tickets", "gate": "test"},
|
|
41
|
+
"observed": {"assisted": false, "interventions": 0, "defects": 0},
|
|
42
|
+
"sources": [
|
|
43
|
+
{"path": "baseline/pass-1.json", "cohort": "baseline", "time": "2026-09-10T01:00:00Z", "observed": {"eventual": "merged"}},
|
|
44
|
+
{"path": "trial/record.json", "cohort": "trial", "observed": {"assisted": true, "interventions": 1}}]}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The top-level `workload` and `observed` are defaults each entry overrides. A record fills in its own `repository` and `gate`, the gate as its names joined by spaces, so write the gate the same way for a host result or the report lists a confounder that is only spelling. `assisted` says a person helped the issue to its outcome, `interventions` and `defects` count what a person did and found, and `eventual` is the PR's state later: `merged`, `closed` or `open`. Leave a value out or `null` when nobody knows it, and the report counts it as unknown. A host result has no time of its own, so give it one, or its file time is used and the manifest says so.
|
|
48
|
+
3. Freeze: `bash measure.sh freeze sources.json > manifest.json`. Every source is pinned by its sha256 with its kind, cohort, time, revisions, workload and observations, and marked in or out with the reason: missing, empty, not JSON, not a record or result, no time, outside the period, a byte-identical duplicate of an earlier source, or an outcome block or fork result that an included record already covers.
|
|
49
|
+
4. Analyse: `bash measure.sh analyze manifest.json`, with `--prices prices.json` for an API-equivalent figure. A source that changed since the freeze stops it with exit 1, so a report always matches its manifest, and the same manifest, read with the same price table or none, always prints the same bytes. `--root DIR` reads the sources from where the archive was moved to.
|
|
50
|
+
|
|
51
|
+
## The report
|
|
52
|
+
|
|
53
|
+
One JSON document, one entry per cohort, and the confounders between them.
|
|
54
|
+
|
|
55
|
+
- An issue is keyed by its repository and its number, because a number belongs to one repository. A cohort can hold several repositories, and #254 in one and #254 in another are two issues in it. The repository is the source's `workload.repository`, from step 2. A source whose workload names no repository is keyed by its number alone within its cohort, so two such sources with the same number count as one issue, and `sample.issues_without_repository` counts the issues keyed that way.
|
|
56
|
+
- A source that names no issue at all is an issue of its own, and that count leaves it out, because it has no number to share.
|
|
57
|
+
- Give every source of one issue the same repository: a record names its own, so a host-result retry of it with no repository in `sources.json` counts as a second issue. A top-level `workload.repository` gives every source one.
|
|
58
|
+
- Outcomes are per issue, from its last attempt: `shipped`, `review-ready` (parked at the merge gate with the PR open), `parked`, `failed`, `interrupted` (a rate limit, a budget stop, a host that died or an allowance that ran out), `not-taken` and `unknown`. Attempt outcomes, retries and repairs are counted apart.
|
|
59
|
+
- `unattended` counts the issues nobody assisted, and their shipped and review-ready outcomes per hour of the passes' own elapsed time. Issues whose elapsed time is unknown are counted and left out of the rate. `assisted` holds the rest, and `eventual` holds later merges apart, because a merge a person finished is not an unattended success.
|
|
60
|
+
- `time` splits elapsed time into waiting, the CI wait and the gate-lock queue, and active, the rest, where the record has both.
|
|
61
|
+
- `contexts` counts each context once by host and id: a Codex session resumed across two passes is one context with two invocations. Peak context and compaction are reported with how many are unknown.
|
|
62
|
+
- `usage` sums input, output, cache reads, and cache writes split into five-minute and one-hour, with any write the host did not split kept apart as `cache_write_unsplit`. A context whose usage is unknown is counted in `invocations_unknown`, and `complete` says whether the sums cover every invocation.
|
|
63
|
+
- `reported_cost_usd` is what the hosts reported, with the unknown counted. Claude's figure is an API-equivalent one, not an invoice.
|
|
64
|
+
- `api_equivalent` appears only with a price table: `{"source": <url>, "date": <when read>, "models": {<model>: {"input", "output", "cache_read", "cache_write_5m", "cache_write_1h"}}}`, in dollars per million tokens. An invocation is priced only when its model is known and its cache writes are split by lifetime, so the rest is counted unknown rather than guessed, and the figure is labelled as a reconstruction, not subscription spend and not invoice savings.
|
|
65
|
+
- `confounders` names every field whose values differ between cohorts: engine, host, profile, model, effort, repository, task, gate and revisions. A difference there is a reason a comparison may not be like for like, and the report states it rather than adjusting for it.
|
|
66
|
+
|
|
67
|
+
The rollout comparison between engines is a person's reading of this report over a baseline and a trial cohort with their sample sizes. Playbook ADR 0008's single full-suite stage, bounded red-path retries and receipt serialization are unchanged by any of this, and none of it switches the default engine.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# What it leaves behind
|
|
2
|
+
|
|
3
|
+
Everything lands under `.claude/kryso/<shift>/`, excluded through the common git directory's `info/exclude` so nothing is committed:
|
|
4
|
+
|
|
5
|
+
- `shift.log`, one line per run, and one per rate-limited attempt that was waited out: time, pass, outcome, issue, branch, PR, profile, host, billing, effort, `cost` and the nullable `cost_usd`, token usage and its output tokens, session id, subtype, the sweep, the base on a queued run, and the test-volume numbers of a pass over its test budget. When a report URL is set and a pass's report could not be delivered after its retry, one more line, `<time> pass=<n> report=failed <status or curl error>`, so the morning post is known to be short. A tracker call of the driver's own that was stopped at [its limit](allowance.md) leaves one too, `<time> pass=<n> tracker=timeout after=<n>s gh <words>`, numbered for the pass just ended, or for the one about to start when the read is its continuation's.
|
|
6
|
+
- `report-<n>.json`, when a report URL is set: the body posted for each pass, the shift line's fields plus the reason, the repo and the shift id. A rate-limited attempt's body moves to `report-<n>-<k>.json`, beside its `ratelimit-<n>-<k>.json`, so its retry cannot overwrite it. A pass that gave up on the rate limit has these and no `report-<n>.json`.
|
|
7
|
+
- `sweep-<n>.json`, one manifest per sweep: what the sweep was over, for an epic the scope (`scope.open`) and every child the first read discovered (`scope.discovered`), when the snapshot was taken, the candidates in GitHub or caller order, every in-scope issue left out with its reason and its open blockers, the order the sweep runs with why each issue sits where it does and the base it is told, the issues it holds with the reason, the issues it continues with their recorded stage and fingerprint, the issues admitted, and under a stacked sweep the `stack` record: every satisfied issue with how (`merge-ready` or `shipped`), its branch, PR, head and the evidence read, and every rejected one with the reason. Written before the sweep's first pass, so the snapshot on disk is the one that ran. A sweep that found nothing to run leaves its manifest too, with the reason, so the early stop can be read against the tracker.
|
|
8
|
+
- `continue-<issue>-<pass>.md`, the brief a continuation pass was started from.
|
|
9
|
+
- `shift.json`, the selection the shift ran, its engine, its start and the shift it adopted, if any, and `driver.lock`, which the driver holds for as long as it or anything it started runs. A later `--adopt` reads both.
|
|
10
|
+
- `pass-<n>.json`, the full result of each run, for opening a bad one by its session id. Under the script engine it is the pass script's outcome block, and the fork's result is in the worktree. Each carries a `ship_loop` object beside the host's fields: the pass number, the sweep, the issue it was for, which attempt at that issue it is, the path of the saved attempt before it, the typed state the supervisor read off the evidence, the recorded stage, the fingerprint after the pass, the worktree and the base the pass was told. The host's own fields are untouched, so a reader that ignores `ship_loop` reads what it always read.
|
|
11
|
+
- `ratelimit-<n>-<k>.json`, any attempt that was waited out and retried, with the same metadata.
|
|
12
|
+
- `deadline-<n>.json`, the allowance's report on each pass: whether it ran out, the allowance and the grace it ran under, the seconds it ran, the signal that ended it and whether the stop was confirmed.
|
|
13
|
+
- `summary.json`, the bounded record the launcher reports from: the stop state and reason, the exit code, the sweep cap and count, one final row per distinct issue with its outcome, PR, branch, base, attempt count, typed state, stage, worktree, fingerprints before and after the last pass and saved result, the aggregate counts, one entry per row the shift ran under `pass_rows`, in order, with the pass, the issue, the outcome, the PR, `took_seconds`, `cost_usd`, the `commits` the attempt added to its branch, `ci_wait_seconds` and `rounds`, the last two from the attempt's pass record, which only the script engine writes, and each `null` where it is unknown, never 0, the PRs waiting for review, every shipped pass whose closeout is incomplete under `closeout_incomplete`, with its issue, the step it stopped at, its PR, the worktree it kept (null once that is gone) and the saved result that holds the reason, the issues that stalled, the issues whose last attempt the allowance stopped under `interrupted`, with their state and stage, the issues whose park spent the pass's own rerun or its reconciliation contexts under `exhausted`, the attempts that need a person, and the paths to the shift log, every manifest, every continuation brief, every saved result and any worktree a pass left. A shift started with `--adopt` adds `adopted`: the shift it adopted, how that shift's stop was confirmed, each worktree taken over with its handoff, and each one left behind with the reason. Under a stacked sweep it adds `merge_ready`, the PRs whose evidence satisfied a dependency, `blocked`, the in-scope issues the last snapshot left blocked with their blockers and the reason, and `stack`, the satisfied and rejected records as last read. Merged work is the `shipped` count, whatever its closeout reached, merge-ready work is `merge_ready`, and neither makes the stop `complete` while a PR is open. It holds no transcript, result text or log tail.
|
|
14
|
+
|
|
15
|
+
## How a shift ends
|
|
16
|
+
|
|
17
|
+
The state is the word playbook ADR 0003 fixes, on the driver's last line and in `summary.json`, and it is decided from the rows rather than from the exit code alone. `complete` means every issue the shift worked shipped and no closeout stopped part-way. `frontier-empty` means nothing was worked: the column was empty, the snapshot excluded everything, or every admitted issue turned out locked. `review-ready` means the sweep ran to its end and left a person something to act on: a PR open for the merge gate, a park without one, a queued issue that failed or was taken elsewhere, or a shipped pass whose closeout is incomplete. The summary's `review_ready`, `exceptions` and `closeout_incomplete` lists say which, so a designed handoff is never called complete. `sweep-limit` means a cap stopped the shift with work possibly still there: `--max` held a distinct issue back, the dollar cap hit, which the reason names and the counts record as a `budget-stop` outcome, or `--sweeps` ran out with an issue still resumable. `stalled` means a continued issue left the same fingerprint it started with and nothing else was left to continue or admit.
|
|
18
|
+
|
|
19
|
+
The three are told apart by what a person does next. A sweep limit is the driver's bound, not the work's: rerun the shift, or raise the cap, and it picks the resumable issues up from their worktrees. A stalled child is the work's bound: a fresh session with the same evidence produced no new commit, ledger stage, check result or review, so another pass would produce the same, and the summary's `stalled` list names it for a person to look at. Completed work is `complete`: every issue the shift admitted shipped, and nothing is left for anyone. The stop word is the shift's, not the epic's. `complete` says every issue this shift admitted shipped, and nothing about the in-scope children it never admitted: one still blocked, assigned elsewhere, locked by another run or added after the shift started is open work the manifest names with its reason, and the stop line names it too, so an epic is read as done only when its live read shows no such child.
|
|
20
|
+
|
|
21
|
+
A rate limit waits and retries the same pass, until the reset time when the error names one and it is under six hours away, otherwise `--wait` seconds, at most three times per shift. A reset days away is the weekly window, and a thirty-minute wait then a retry beats a sleep that outlives the shift.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# The pass script
|
|
2
|
+
|
|
3
|
+
[ship-pass.sh](../ship-pass.sh) is the second engine: one issue from claim to a green pull request, with the build fork as its model process and, when a check goes red or review feedback needs a decision, up to three reconciliation contexts after it. The stages are `/kryso`'s, the claim, the cut, the build, the prove, the PR, the reconcile, the merge or park and the closeout, run in shell rather than by a model reading the skill. The base decides the merge the way `/kryso`'s stage 6 does: a pass based on the default branch parks at merge with the PR open and the worktree kept, and a pass based on any other branch merges it and closes out, under [The merge and the closeout](reconcile-and-merge.md#the-merge-and-the-closeout). The driver runs it with `--engine script`, and it runs on its own from a terminal:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bash .agents/skills/kryso-shift/ship-pass.sh 37 --note "keep the diff small"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
`ship-pass.sh --help` lists the flags with their defaults. `--second-reader` follows the precedence [Options](driver.md#options) gives, and a value outside the set is refused before the claim. `--timeout`, `--grace` and `--consumed` set the pass's share of [The allowance](allowance.md). The header records `--park-at-merge`, so a resume keeps the PR open too. What `--resume` reuses, and what it refuses, is below.
|
|
10
|
+
|
|
11
|
+
`--workflow NAME` sets the workflow the pass resolves from its base before the claim, with `kryso workflow show`'s resolver, and the pass names it in the ledger header and the record. Without the flag the issue's `workflow:<name>` label sets it, else `default`, and a `workflow:ralph` label wins over the flag. An unknown name, a workflow file the resolver refuses, or two `workflow:` labels fail the pass in preflight with nothing claimed. Each `commands` stage runs at its place, every command in the worktree to its own receipt, `<stage>.<n>`, with no tracker token in its environment, and a command that exits non-zero parks the pass at that stage with the command and its exit in the reason. A workflow without the PR stage proves its branch and parks at the merge gate as `no-pr`, nothing pushed. One without the reconcile leaves the checks to the merge gate's own read.
|
|
12
|
+
|
|
13
|
+
The driver decides each step's `when` on the seam call, the issue's labels and the entry before a judgement stage starts, through the jq module `steps.jq` beside it, with the entry fixed at `issue`, gives the context the steps that hold in the workflow's order, and writes `<stage> steps given ...; left out ...`. A judgement or `repair` stage of the workflow's own runs between the build and prove, once, in a fresh context: under the profile it names, else the repository's profile for its role from the config's `profiles`, else the pass's `--profile`, with `<stage> profile <name> host=<host> login=<login> (<why>)` in the ledger, the line the build gets too. Its prompt holds the ledger records it declares in `reads` and nothing else from earlier contexts. A repair runs on the build stage's profile, settles each finding of the judgement stage before it with a `fixed <n> <sha> <reason>` or `rejected <n> <reason>` line, and parks as `unsettled` when one is left. A repair with no findings to settle writes its done line and starts no context. After each judgement stage, the build included, the driver checks the evidence its steps declare, and a miss parks the pass as `evidence-missing` with the stage, the step and each missing event, receipt or path named. Both parks resume once a person moves the tree. Prove then runs over the final commit.
|
|
14
|
+
|
|
15
|
+
A judgement or repair stage elsewhere, a repair after a stage that is not a judgement stage, any other kind past the default's own, or a build removed or replaced by commands, fails the preflight, because this driver has nothing to run it with there. A stage whose profile, named or bound to its role, the host cannot run fails it too.
|
|
16
|
+
|
|
17
|
+
The pass reads the issue once and works from it. Before the claim it runs the gates of [`/kryso`'s stage 1](../../kryso/reference/stage-1-claim.md#gates), in the order that page numbers them, and that page has the rules. A worktree or an open PR from a branch ending in the issue number is a lock, and the pass ends with `outcome: locked` having touched nothing. The one exception is the worktree the pass would cut itself, left with no ledger by a pass stopped between its cut and its header, which is reused. A collaborator's open PR that closes the issue also ends the pass with `outcome: locked`, and a PR list or collaborator check gh cannot answer ends it with `outcome: failed`. An issue assigned to someone else ends it `locked` too, and one whose assignee cannot be told from the login gh runs as ends it `failed`, with nothing written on the issue either way. Unless the pass is `--swept`, a refusal by the linked PR gate or by a failed PR list or collaborator check adds `agent:blocked` and posts the refusal on the issue, and the reason says what each write did, because there is no ledger before the cut. A live pass holding the issue's authority is a lock too. The brief is the latest comment whose first line says "agent brief", else the issue body, and the brief's first line says which. The claim is the assignee, then `agent:in-progress` added and `agent:blocked` removed in a call of their own, then the card moves to In Progress through the live board discovery `docs/agents/issue-tracker.md` describes, and an issue on no board is a recorded no-op rather than a guess. [Playbook ADR 0031](../../../docs/adr/0031-a-runs-state-is-two-agent-labels-beside-the-triage-state-never-in-place-of-it.md) has when the later stages change the two labels. A park's label write and note follow its park line and are recorded in `logs/park-issue.log`. The worktree goes at `.claude/worktrees/<slug>-<issue>` on `<type>/<slug>-<issue>`, the type read off the labels: `bug` is `fix`, `documentation` is `docs`, `chore` or `dependencies` is `chore`, anything else is `feat`.
|
|
18
|
+
|
|
19
|
+
Before the claim, the pass runs a preflight off the base commit it is about to cut from, so a pass that could not finish spends nothing and claims nothing. The host is on PATH, logged in the way the profile requires and has the flags the profile uses. The config, when there is one, has an install that is one command string, an `env_files` list of paths and a `gate` of name-to-command strings. Every env file is inside the repository, and one the config declares is ignored by git, because copying a tracked or unignored one would put it in the diff. There is a gate, from the config or the package scripts, and the install's and each gate's program is on PATH. The first problem fails the pass with `preflight: <problem>. The pass claimed nothing.`, exit 1, no assignee, no worktree and no model start. A pass that passes writes one `preflight passed` line naming what it checked, env file paths included and never their contents, before its claim lines. A resume skips the preflight, because the claim it guards already happened.
|
|
20
|
+
|
|
21
|
+
The selected host reads the `kryso-build` skill body on stdin, frontmatter stripped and the five arguments substituted, with a Dispatch section after it. No skill invocation is needed in this engine, and the fresh context is the pass script's own doing rather than the skill's Claude-only frontmatter: each run of the fork, a rerun included, is a new top-level `claude -p` or `codex exec`, never a resumed session. The Dispatch section tells the fork it is a fresh session, which run it is under the rerun cap, why a rerun is one, and how its reviewers are held. Where the host can define a sub-agent type with its own tools, Claude with `--agents`, the pass defines `ship-it-reviewer` with Read, Grep and Glob in `logs/reviewer-agents.json` and tells the fork to dispatch both reviewers as it. No shell means no shell-mediated write, which removing Edit and Write alone would leave open. Codex, and a Claude without the flag, get no restriction, and the pass records that on a `build reviewers unrestricted` line. The read-only clause and the tree check stay either way.
|
|
22
|
+
|
|
23
|
+
When the fork returns, the pass runs the checks `/kryso` runs, in shell: commits past the base, a clean tree, the `build committed` and `review triaged` ledger lines, a review that no reviewer voided by moving the tree, a review artefact that quotes the diff, and a triage row with an outcome for every finding. A `review restored` line with no `review recorded` after it is a reviewer that wrote to the tree and a fork that restored it without reviewing the restored tree again: that fails as `review-mutated`, the same as any other check. The quote check tries every backtick-quoted string in an axis section against the saved diff and passes the axis on the first match. An axis marked void or without a spec is recorded as missing and named in the PR body.
|
|
24
|
+
|
|
25
|
+
A failed check appends `build check-failed <which>` to the ledger, reruns the fork once in the same worktree with the same five arguments, and checks again. A second failure is the park line alone, `build parked check-failed <which>`, the way stage 2 words it. The rerun's result lands in `logs/build-2.json` beside the first. Usage is summed, and `cost_usd` is summed where the host reports one. The fork never runs more than twice in one pass: a check rerun spends the pass's one rerun, and a red gate after it parks without a third.
|
|
26
|
+
|
|
27
|
+
The checks that read the ledger read the lines of the build attempt, not the whole ledger. What a build attempt is, and which forks share one, is under "Build attempt" in [the glossary](../../../CONTEXT.md#evidence). A rerun that skips the review therefore cannot pass on the first run's lines, while a continuation that triages and gates the first fork's commit reaches its PR. A review the first fork voided stays void for its continuation. A rerun that only corrects `review.md` after a failed check reaches its PR too, by the one exception the glossary names.
|
|
28
|
+
|
|
29
|
+
A `needs-decision` or `no-feedback-loop` hand-back is still read from the lines the last fork wrote.
|
|
30
|
+
|
|
31
|
+
A pass that stops anywhere after the cut leaves the worktree and the claim where they are, and `--resume` picks the pass up there: a worktree under `.claude/worktrees/` ending in the issue number whose ledger says `engine: script` and names the issue is this engine's, so the claim and the cut are skipped. The base, the branch, the seam and the board are read off the ledger header, the brief's source and the caller note off the brief, and the config off the base sha the header records, so `--base`, `--seam` and `--note` are not read on a resume. The issue's assignees are read again first: an issue assigned to someone else since the claim is refused with `outcome: locked`, a `resume refused foreign-assignee` line and the worktree left as it was, and assignees or a login gh cannot give end the pass `failed` ([playbook ADR 0037](../../../docs/adr/0037-an-issue-assigned-to-someone-else-is-theirs-and-a-run-neither-claims-nor-continues-it.md)). The branch is then fetched and fast-forwarded to its remote, the way `/kryso`'s resume rule says. A base the header names that is missing locally is restored from origin, tracking it, with a `resume base-restored` line, and never from the sha the header recorded or a stale remote-tracking ref ([playbook ADR 0010](../../../docs/adr/0010-integration-branches-carry-a-commit-of-their-own-and-cannot-be-deleted-on-origin.md)). A base origin lacks too parks the pass at the stage the resume re-entered, as `base-missing`. A worktree with no ledger, or a ledger that is another engine's, is refused in one line with `outcome: failed`, because a worktree `/kryso` cut is that run's resume point. The exception is the handoff under [Adopting a stopped shift](sweeps.md#adopting-a-stopped-shift): a ledger whose latest ownership line hands it to the script engine in the shift `KRYSO_SHIFT` names is resumed, whichever engine wrote its header, and a script ledger handed on to `/kryso` is refused the same way another engine's is. A retried pass then never orphans a claimed issue or cuts a second tree.
|
|
32
|
+
|
|
33
|
+
## The checkpoint
|
|
34
|
+
|
|
35
|
+
Where a resume re-enters is not a guess. Every stage boundary rewrites `.kryso/pass/checkpoint.json` in the worktree: the stage (`cut`, `build`, `check`, `prove`, `pr`, `reconcile`, `merge`, `closeout`), its status (`running`, `done`, `parked`, `failed`, `interrupted`), the detail a park names, the head, the PR, the fork count, a fingerprint of the tree and a typed disposition, and two fields of this engine's own that the module writes in the same write from the values the pass hands it: `repairs`, the reconciliation contexts the issue has spent, and `evidence`, the failed-check evidence the last accepted repair addressed. A checkpoint written without them, the interruption's included, keeps the ones the file already had. The ledger gets a `<stage> checkpoint <status>` line each time, before the stage's own line, so the last ledger line stays the stage's and every reader of the ledger sees what it always saw. The disposition says what a resume may do:
|
|
36
|
+
|
|
37
|
+
| Disposition | Where it comes from | What `--resume` does |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `resumable` | a stage running or done, except a finished closeout, a `pr` push or create that failed, a merge that failed or could not be verified, a closeout step that failed, a `reconcile` park on red checks (`ci-red`, `gate-red`), on feedback (`feedback-open`, `feedback-stale`, `feedback-unreadable`) or a timeout | Re-enters that stage, or the one after a stage that finished. A fork runs only when the stage is the build, and a reconciliation context only at reconcile, on a red check with a failure to read or on actionable feedback, under the cap in [The reconciliation context](reconcile-and-merge.md#the-reconciliation-context). |
|
|
40
|
+
| `retry-exhausted` | `build parked check-failed` or `prove parked gate-red`, the pass's own fork rerun spent, or `reconcile parked ci-unchanged`, `repairs-exhausted` or `feedback-exhausted`, a failure the pass's own reconciliation contexts could not move | Reruns the fork with a fresh cap only when the tree's fingerprint changed since the park: a fix committed in the worktree, or a push to the branch. An unchanged tree is refused in one ledger line, `resume refused retry-exhausted`, with nothing spent. A reconcile park re-enters reconcile instead, which reads the evidence again and starts a context only on evidence that changed and with one of the three left, so the cap never resets. |
|
|
41
|
+
| `prerequisite` | `cut parked install-failed` or `prove parked no-gate`, or `<stage> parked base-missing <base>` from a resume whose base is gone locally and on origin, or `prove` or `reconcile parked tree-moved` on a void gate | Re-enters that stage: the install runs again to its own log before any fork, and the gate is derived again. Never straight to the build. A `base-missing` park re-enters the stage it parked at, once the base is back on origin, and a `tree-moved` park the same, with the fork count kept, once the worktree is back on its branch at the head it was proving. |
|
|
42
|
+
| `human-decision` | the fork's own `needs-decision` or `no-feedback-loop` park, or a reconciliation context's own hand-back, `reconcile parked needs-decision` or `out-of-scope`, or `reconcile parked pr-closed`, a PR a person closed without merging while the pass was stopped, or `pr parked over-budget`, a change over its test budget under a testing policy that stops the pass | Reads the PR first. A PR a person merged settles the park: a `resume settled <stage> <word>` line names the park and the merge commit, the merge is verified on origin as a person's, and the closeout runs. Open, closed unmerged or with no PR, refused in one line, `resume refused terminal`, PR and worktree as the park left them. |
|
|
43
|
+
| `terminal` | `merge parked pr-open`, the human merge gate, and `merge parked merge-unready`, evidence read just before a merge that did not hold, and `closeout done`, which the closeout writes into the archived copy once its last step is done | The same: a merge park whose PR a person merged closes out, and any other is refused. Merging is a person's, and a pass that closed out has nothing left to resume. |
|
|
44
|
+
|
|
45
|
+
So a rate limit or a budget stop in the fork resumes at the build, the checks and the gates on a tree the fork finished are not skipped, a pass that pushed but could not open its PR resumes at the PR stage with no second fork and no second prove, and a reconcile park resumes at reconcile: writes an earlier attempt intended and never recorded as done are recovered first, then the feedback and the checks on the existing PR are read again, a settled read moves the pass to the merge gate, the same evidence parks it on the same line, and a red check with a failure to read or a finding that needs a decision gets a reconciliation context where the cap and the allowance allow one. A resume that re-enters a stage up to the merge reads its PR first, before it writes a label or starts a CI wait. A PR a person merged meanwhile skips the reconcile and the merge's policy and evidence: the merge is verified on origin, recorded as `merge merged ... by hand`, and the closeout runs. A PR closed without merging parks as `reconcile parked pr-closed`. A resume onto a closed issue adds no `agent:` label. The PR is opened once: a resume that reaches the PR stage reuses the PR its checkpoint names, or the open PR GitHub has on the branch when a create's answer was lost, and never opens another. A worktree from before the checkpoint existed is placed off its ledger lines, and a checkpoint that is not JSON is refused.
|
|
46
|
+
|
|
47
|
+
## The script engine under the driver
|
|
48
|
+
|
|
49
|
+
With `--engine script`, each pass is one `ship-pass.sh` process, given the queued issue, shift base, note, profile, any explicit budget, model or second-reader override, and whatever followed `--`. A dry run prints that command per pass:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
bash .agents/skills/kryso-shift/ship-pass.sh 36 --base main --note "keep the diff small" --profile claude --effort high --timeout 7200 --grace 30 --budget 20
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The pass script prints the normalized profile, host, billing, effort, nullable `cost_usd`, token usage and session id in its outcome block, and the driver writes them to the shift line as it does for `/kryso`. The `subtype` field is `none`, because the saved result belongs to the fork rather than the pass script. `pass-<n>.json` is the pass script's block, and the fork's own result sits in the worktree at `.kryso/pass/logs/build.json`, which the block names in its `result` field.
|
|
56
|
+
|
|
57
|
+
The pass script's exit codes feed the driver's existing handling. A rate limit, exit 2, is waited out the way a `/kryso` rate limit is, to the reset the fork's result names when it is under six hours away and `--wait` otherwise, and the retry runs the same issue with `--resume`, so it picks up in the worktree the first attempt cut rather than claim and cut again. A budget stop, exit 3, ends the shift with exit 0. An interrupted pass, exit 4, recorded its own stop, and the driver reads its block the way it reads any other. A failed pass counts toward the two-in-a-row stop, and so does an interrupted one. `locked` is that issue's answer: a plain queue moves on, and a stacked one ends with exit 1 the way it does for `nothing-to-take`, because the link is missing either way. A `shipped` pass is done, as it is under the default engine: its merge is verified, and a stacked queue keeps the base it gave that pass. Its block's `closeout` field says whether the issue was closed and the branch deleted, because a closeout that stopped part-way still ships. [Sweeps](sweeps.md#sweeps) has the state the driver types that pass, and [What it leaves behind](outputs.md) the summary's list of them.
|
|
58
|
+
|
|
59
|
+
Under `--sweeps` the script engine follows the sweep contract in [sweeps.md](sweeps.md) with no rules of its own. The driver types each pass's state off the ledger the pass script wrote, in the words both engines use, and a later sweep continues an owned resumable issue with `--resume`: the pass re-enters the stage its checkpoint names, so a reconcile park is read again at reconcile with no fork and no second PR, a fork runs only when the checkpoint stops at the build, and a reconciliation context only on a red check with a failure to read or on actionable feedback, under the issue's cap. The fingerprint, the stall rule, the attempt count, the predecessor, the manifests, the continuation brief and the summary are the driver's and look the same whichever engine ran the pass, and the fork cap and the reconciliation cap are the pass's own: a check failure or a red gate after the pass's rerun, a failure its repair left unchanged and a spent reconciliation cap are `failed` for the shift, a context's `needs-decision` or `out-of-scope` is `human-decision`, and no later sweep resets either cap. Under Claude and Codex alike every pass, a continuation included, is a fresh model context, and the pass script never resumes a host session.
|
|
60
|
+
|
|
61
|
+
`--stack` works the same as with the default engine: pass n+1 bases on the `branch` pass n's block reported when it parked with its PR open, and the pass script fetches that branch from the origin and cuts from it, so the second worktree carries the first pass's commits and its PR targets the first pass's branch. That branch is not the default, so pass n+1 merges into it the way [A stacked queue](driver.md#a-stacked-queue) says. Under a stacked sweep the driver adds `--park-at-merge` instead, under [Stacked sweeps](sweeps.md#stacked-sweeps).
|
|
62
|
+
|
|
63
|
+
The driver's tracker preflight is the same under both engines. Claude adds its print-mode permission and trust warnings. Codex verifies ChatGPT subscription auth and required CLI features. The pass script needs `gh` on PATH and logged in, the `kryso-build` skill directory and `ship-it`'s `ledger.sh` beside `ship-loop`, under `.agents/skills`, or under the `.claude/skills` compatibility path, and the config below. The driver refuses to start under either engine without `ship-it`'s `ledger.sh` in one of those places, because every ledger it reads goes through that module.
|
|
64
|
+
|
|
65
|
+
## The config
|
|
66
|
+
|
|
67
|
+
An adopting repo commits `.kryso/config.json` to name what the pass cannot infer. The pass reads it off its base, never its branch, and reads `.claude/ship-pass.json`, its old place, where it is absent, until 3.0.0, with a warning:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"install": "pnpm install --frozen-lockfile",
|
|
72
|
+
"env_files": [".env", ".env.local"],
|
|
73
|
+
"gate": { "typecheck": "pnpm typecheck", "test": "pnpm test" },
|
|
74
|
+
"retries": 1,
|
|
75
|
+
"ci_wait": 1800,
|
|
76
|
+
"profiles": { "reader": "codex" }
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`profiles` binds a role to the profile a judgement stage of that role runs under when the stage names none. The roles are the glossary's: `plan`, `build`, `helper`, `reader` and `cross-reviewer`. The build stage has the role `build`, and the resolver refuses a file that gives it another. A workflow's own judgement stage has the `role` it takes in a version 2 workflow file, else `reader`. A role the map leaves out runs under the pass's `--profile`, so a repository with no map runs every stage there. A role outside that list, or a profile that does not load, fails the pass as the config is read, with nothing claimed.
|
|
81
|
+
|
|
82
|
+
`gate` maps a name to a command, and every command is expected to exit zero on the base: the pass judges no baselines, so a command that is red on the base is excluded or fixed there. Without the file, the install is inferred from the lockfile and the gate from whichever of the `typecheck`, `lint` and `test` package scripts exist, and none fails the preflight before the claim. A `prove parked no-gate` is what a pass from before the preflight left, and a resume still reads it. Each gate command runs in the worktree to `.kryso/pass/logs/prove-<name>.log`, the command on the first line and `exit=<n>` on the last. The gate proves the committed head, so a tracked file a command rewrites, such as a `dist/` that a test script builds first, is put back to the head after the command, and a `prove <name> restored` line names it. Left changed, it would fail the reconcile stage's clean-tree rule. Untracked files are left to the checks that read them. The prove stage is the only place a pass runs the full suite: the fork runs the typecheck and the tests related to its change. Receipts run one at a time per repository, so under several loops a gate command waits for another worktree's to finish, and the pass's `pass-<n>.err` in the shift directory names the one it waited for. A red command is retried `retries` times before anything else, each run to its own log, `prove-<name>-2.log` beside the first, so a flaky test does not cost a fork rerun. Still red, the pass takes stage 2's rerun rule and no other: it appends `build check-failed gate <log>`, reruns the fork once where the pass has a rerun left, checks its work and proves again from the first command. Red again parks with `prove parked gate-red <name> <log>` and the failing command's tail in the reason, and the park line counts the forks the pass ran, so the reader can see why there was no third. A [void receipt](../../../CONTEXT.md#evidence) is recorded as `prove <name> void (<log>): <why>` and parks the pass at once with `prove parked tree-moved <name> <log> <why>`: no retry, no fork rerun, and no file put back. The checkpoint's head is the one the gate was proving. A shift never continues this park, and a resume takes that head put back or one pushed to the branch on origin, and refuses a worktree on another branch or at any other HEAD, because a moved HEAD may hold a commit no check has read. A resume at the prove reuses the closed receipts an earlier attempt left over the same HEAD, under the rule in [The allowance](allowance.md). The PR body cites the log that went green. `ci_wait` is the number of seconds the reconcile stage waits for checks. Env files are copied from the main checkout when git ignores them, because a tracked one is in the worktree already and an unignored one would dirty the tree. An `env_files` list in the config is the whole list, so an empty one copies nothing. The config is read off the base before anything is claimed, so a broken file fails the pass with nothing touched.
|
|
83
|
+
|
|
84
|
+
The PR's title is the first commit subject past the base. Its body leads with what changed and why, in the words of the commits past the base, then the rest is written from the ledger and the review artefact: the brief's source, `Closes #<issue>`, a table of every gate command with its log and exit, the review counts, the deferred rows verbatim, the missing axes, the same for each accepted repair's review, and the caller note. The card moves to In review. Then the feedback is read and settled under [Feedback](reconcile-and-merge.md#feedback), a base that moved on is merged into the branch under [The moved base](reconcile-and-merge.md#the-moved-base), checks are polled under `ci_wait`, no checks is recorded as `no-ci` unless GitHub reads the PR as conflicting, a timeout parks with the tail, and a red check is read for a reconciliation context under [The reconciliation context](reconcile-and-merge.md#the-reconciliation-context), which parks with the tail when none can be started.
|
|
85
|
+
|
|
86
|
+
## What it prints and leaves
|
|
87
|
+
|
|
88
|
+
stdout is the outcome block as JSON and nothing else: the driver's schema fields plus `profile`, `host`, `billing`, `effort`, nullable `cost_usd`, `usage`, `session`, `result`, the path of the saved host result or `none` before a fork ran, `record`, the path of the pass record or `none` before there was a ledger, and `attempt_id`, which the record carries too. `outcome` is `shipped`, `parked`, `locked`, `nothing-to-take`, `failed`, `rate-limited`, `budget-stop` or `interrupted`. The exit code follows the outcome as `ship-pass.sh --help` lists it, which is how the driver's handling of rate limits, budget stops and interruptions applies to this engine. An interrupted block adds a `deadline` field: the allowance, the grace, the seconds it ran, the signal that ended it, whether its stop was confirmed, the stage and the worktree. A shipped block adds a `closeout` field, `complete` or `incomplete <step>`.
|
|
89
|
+
|
|
90
|
+
Everything else is in the worktree's `.kryso/pass/`, in the shape `/kryso` keeps: the brief, the ledger with an `engine: script` header line and the stage words `ledger.sh` reads, the checkpoint in `checkpoint.json` with this engine's `repairs` and `evidence` fields stamped on it, and the logs, with the fork's result in `logs/build.json` and a rerun's in `logs/build-2.json`, their prompts in `logs/build-prompt.md` and `logs/build-2-prompt.md`, the reviewer agent's definition in `logs/reviewer-agents.json`, each reconciliation context's prompt in `logs/repair-<n>-prompt.md` and its result in `logs/repair-<n>.json`, a repair's review in `logs/review-repair-<n>.md` with its spec and diff beside it, the pass record in `logs/record.json` and a resume's in `logs/record-2.json`, each receipt's queue and run time in `logs/receipt-times.txt`, which the ledger module writes and its `read` returns as `receipt_times`, the diff the checks read in `logs/diff.patch`, the install in `logs/install.log` and a rerun's in `logs/install-2.log`, every gate run in `logs/prove-<name>.log` and its numbered retries, a repair's proof among them, the latest CI read in `logs/ci.log` and each read that led to a repair in `logs/ci-repair-<n>.log`, the second reader's requests in `logs/second-reader.jsonl`, its LLM context's result in `logs/second-reader-llm.json` when that backend ran, and its subsection in `second-reader.md` when the reader is on, and the PR body as the pass last wrote it in `pr-body.md`. A resumed pass appends to the same ledger and numbers on from the logs already there. A pass that merged adds `logs/merge-checks.json` and `logs/merge-feedback.json`, the reads its merge stood on, and its closeout copies the whole of `.kryso/pass/` to `.claude/kryso/shipped/<worktree>-<time>/` before the worktree goes, so the ledger, the logs and the record outlive it. The outcome block's `record` names the copy.
|
|
91
|
+
|
|
92
|
+
With the second reader on, the pass also leaves the audit's requests, its subsection in `second-reader.md` and its ledger line, and the cut leaves its seam call: [The second reader and the seam call](second-reader.md).
|
|
93
|
+
|
|
94
|
+
## What the shim tests cannot cover
|
|
95
|
+
|
|
96
|
+
`pnpm test` runs the driver and the pass script against shim `claude`, `codex` and `gh` binaries in a sandbox repo with a bare origin, and observes exit codes, the shift log, the outcome block, the ledger and logs under `.kryso/pass/`, and what the shims were asked. That proves the plumbing: the flags reach the fork, subscription keys stay absent, the checks and gate run in order, retries and resume happen, and the logs have the documented shape. It cannot prove a live provider login or copied install, so check these by hand once, with a dry run and then one cheap pass:
|
|
97
|
+
|
|
98
|
+
- The reviewer restriction. The shims prove the pass defines the read-only agent and tells the fork to use it. Whether a real fork dispatches its reviewers as that type, and whether the reviewers can still do their job without a shell, is a live trial's to show, one per host.
|
|
99
|
+
- The fork itself. The shim commits a file and writes a review that quotes it. A real fork is a model reading `kryso-build`, and whether it leaves a clean tree, the ledger lines and a review that quotes the diff is that skill's contract, checked by the pass and enforced with one rerun, not proved here.
|
|
100
|
+
- Permissions in print mode. The fork runs under `--permission-prompts none`, and a denied tool call reads to the model as a failure. The allow rules and the trust dialog are the same prerequisites as for `/kryso`, in [What the preflight checks](../SKILL.md#what-the-preflight-checks), and the shim never denies anything.
|
|
101
|
+
- The tracker and the board. The shim answers one issue, one board with one Status field, one PR at one URL and one set of checks. A real repo's board columns, label names and default branch are read live, and a mismatch shows up as a `card failed` ledger line or a `no-gate` park, both recorded rather than guessed.
|
|
102
|
+
- CI and time. The shim's checks are green, red, none or pending at once. A real `ci_wait` is a wall-clock wait on the checks a PR triggers, and a repo with slow or flaky CI tunes `ci_wait` and `retries` in the config.
|
|
103
|
+
- The gate on the base. The pass judges no baselines, and the sandbox's gate is `true`. A repo whose gate is red on the base parks every pass at `gate-red` until the command is fixed there or dropped from the config.
|
|
104
|
+
- The push. The sandbox pushes to a bare repo on disk. A real push needs the credential `git` uses for the origin, which the preflight does not check.
|
|
105
|
+
|
|
106
|
+
## Rationalisations
|
|
107
|
+
|
|
108
|
+
| Excuse | Reality |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| "The pass script's gate went red on a test that is red on `main` too" | The pass judges no baselines. A command that is red on the base is excluded from the config or fixed there, never waited out. |
|
|
111
|
+
| "The fork's check failed on a lockfile, so let the pass push anyway" | Dirty is dirty. The check reruns the fork once, then parks, and the ledger says which one, so a person can read the tree. |
|
|
112
|
+
| "The gate is red for the third time, so rerun the fork again" | Two forks per pass, and the ledger counts them. A third would be the loop the cap exists to stop. Park it and let a person read the tail. |
|
|
113
|
+
| "The pass was rate limited, so cut a fresh worktree and start over" | The claim and the tree are already there. `--resume` re-enters the stage the checkpoint names, in them. A second tree is a second lock on the same issue. |
|
|
114
|
+
| "The worktree is still there, so the continuation reruns the fork and opens the PR again" | The checkpoint says where the pass stopped. A reconcile park is read again at reconcile, with no fork and the PR it already has. A retained worktree is a resume point, not permission to build twice. |
|
|
115
|
+
| "The check failed twice last pass, but a new pass gets a new fork cap" | The cap is the pass's, and the park says it was spent. A resume reruns the fork only when the tree moved since, and the driver never continues that park at all. |
|