skill-tools-off-mcp s1 fixes: blocked recipe takes a spec id, paged recipes name --cursor, context-pack accepts a UTF-8 BOM and refuses non-cut_spec kinds, bare values and missing campaign/cut/revision
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
05ae3b2368
commit
28a5e613c9
3 changed files with 52 additions and 29 deletions
|
|
@ -217,22 +217,26 @@ in `briefs.md`, which is the one definition of rehydration.
|
|||
must be in this set.
|
||||
- **Target in force:** `huginn target <c>`.
|
||||
- **Rulings in force**, operator directions included: `huginn rulings <c>`.
|
||||
- **Open questions and follow-ups:** `huginn open <c>`. A question's header
|
||||
- **Open questions and follow-ups:** `huginn open <c>`; it pages, so pass `--cursor <next>` until no `next` is
|
||||
returned. A question's header
|
||||
carries `raised_in`. A spec named there is **blocked on the operator**, not
|
||||
waiting on Hands; `huginn blocked <c>` lists those specs.
|
||||
waiting on Hands; `huginn blocked <spec>` takes a spec id and prints the questions holding it.
|
||||
There is no one-command list of blocked specs: run it per spec from
|
||||
`huginn unreported <c>`.
|
||||
- **Open findings**, admitted by Soul: `huginn findings <c>`. `faculty` is
|
||||
declared attribution, not checked by admission (see the gaps below), so a
|
||||
finding or verdict from any other faculty is a defect to raise, not a record
|
||||
to use.
|
||||
- **Specs with no report:** `huginn unreported <c>`. Before briefing Hands on
|
||||
one of them, check `huginn blocked <c>`: a spec it lists waits on a ruling.
|
||||
one of them, check `huginn blocked <spec>`: a question it prints holds the spec for a ruling.
|
||||
- **Reports with no verdict** (Soul's queue): `huginn unjudged <c>`.
|
||||
- **A subject's history**, newest first: `huginn history <id>`. A withdrawn
|
||||
resolution is listed with the withdrawal as its status.
|
||||
- **One cut's record:** `huginn cut <c> <label>`: the spec, reports, verdicts,
|
||||
findings and resolutions. When reading its verdicts and findings, check that
|
||||
`admission.provenance.faculty` is `Soul`.
|
||||
- **The ledger:** `huginn ledger <c>`. Compare each spec's `estimate` with its
|
||||
- **The ledger:** `huginn ledger <c>`; it pages, so pass `--cursor <next>` until
|
||||
no `next` is returned. Compare each spec's `estimate` with its
|
||||
reports' `structural_delta`. A miss gets its explanation in the next report's
|
||||
`deviations`, or in the prose map if it spans cuts.
|
||||
- **Precedent** (before raising a question or recommending a mechanism):
|
||||
|
|
@ -264,7 +268,8 @@ of a claim, and the retry on `Unavailable`.
|
|||
Substrate gaps live under the standing campaign `eureka-substrate`
|
||||
(operator ruling `eureka-substrate:ruling:gap-home`), with labels starting
|
||||
`gap-`. That campaign is also where the substrate is fixed. Every campaign
|
||||
reads its gaps with `huginn gaps`.
|
||||
reads its gaps with `huginn gaps`, which pages: pass `--cursor <next>` until
|
||||
no `next` is returned.
|
||||
|
||||
- **When a run works around a gap that is not there,** Self admits a new
|
||||
`gap-<name>` follow-up under that root. Its source is the document where the
|
||||
|
|
|
|||
|
|
@ -77,11 +77,18 @@ def text_lines(raw):
|
|||
def spec_from_json(obj):
|
||||
if isinstance(obj, dict) and "document" in obj:
|
||||
obj = obj["document"]
|
||||
if isinstance(obj, dict) and "kind" in obj and "value" in obj:
|
||||
obj = obj["value"]
|
||||
if not isinstance(obj, dict) or "base" not in obj or "file_changes" not in obj:
|
||||
if not isinstance(obj, dict) or obj.get("kind") != "cut_spec" or not isinstance(obj.get("value"), dict):
|
||||
raise Fail(4, "spec: not a cut_spec value")
|
||||
return check_spec_shape(obj)
|
||||
obj = obj["value"]
|
||||
if "base" not in obj or "file_changes" not in obj:
|
||||
raise Fail(4, "spec: not a cut_spec value")
|
||||
spec = check_spec_shape(obj)
|
||||
for field, ok in (("campaign", isinstance(spec.get("campaign"), str)),
|
||||
("cut", isinstance(spec.get("cut"), str)),
|
||||
("revision", is_int(spec.get("revision")))):
|
||||
if not ok:
|
||||
raise Fail(4, "spec: %s: InvalidInput" % field)
|
||||
return spec
|
||||
|
||||
|
||||
def is_int(v):
|
||||
|
|
@ -141,9 +148,9 @@ def load_spec(source):
|
|||
unreadable = Fail(4, "spec: unreadable; pipe huginn view --raw <id> or pass a saved file")
|
||||
try:
|
||||
if source == "-":
|
||||
text = sys.stdin.buffer.read().decode("utf-8")
|
||||
text = sys.stdin.buffer.read().decode("utf-8-sig")
|
||||
else:
|
||||
with open(source, encoding="utf-8") as f:
|
||||
with open(source, encoding="utf-8-sig") as f:
|
||||
text = f.read()
|
||||
obj = json.loads(text)
|
||||
except (OSError, ValueError):
|
||||
|
|
|
|||
|
|
@ -436,6 +436,7 @@ wait
|
|||
# context-pack.py: a spec's anchors carried from its base to the worktree (no network)
|
||||
CP=$here/context-pack.py; CF=$here/fixtures/context-pack
|
||||
if py -3 -c pass >/dev/null 2>&1; then PY="py -3"; elif python3 -c pass >/dev/null 2>&1; then PY=python3; else PY=python; fi
|
||||
wrapcp() { $PY -c 'import sys,json; v=json.load(sys.stdin); v=v if "kind" in v else {"kind":"cut_spec","value":dict(campaign="t",cut="x",revision=1,**v)}; json.dump(v,sys.stdout)'; }
|
||||
wp() { cygpath -m "$1" 2>/dev/null || echo "$1"; }
|
||||
R=$T/cp; mkdir -p "$R"; Rw=$(wp "$R")
|
||||
g() { git -C "$R" -c user.name=t -c user.email=t@t -c core.autocrlf=false "$@" >/dev/null 2>&1; }
|
||||
|
|
@ -458,7 +459,7 @@ sed -e '2,3d' -e 's/^b10$/b10-EDITED/' "$R/b.txt" >"$R/b.new"; mv "$R/b.new" "$R
|
|||
sed -e '10,14c\X1\nX2' -e '30,31d' "$R/m.txt" >"$R/m.new"; mv "$R/m.new" "$R/m.txt"
|
||||
g rm -q c.txt; g mv d.txt d2.txt; g add -A; g commit -q -m second
|
||||
sed -i 's/^f5$/f5-UNCOMMITTED/' "$R/f.txt"; printf 'n1\nn2\nn3\n' >"$R/n.txt"
|
||||
sed "s/\"BASE\"/\"$BASE\"/" "$CF/spec.json" >"$T/cp-spec.json"; SP=$(wp "$T/cp-spec.json")
|
||||
sed "s/\"BASE\"/\"$BASE\"/" "$CF/spec.json" | wrapcp >"$T/cp-spec.json"; SP=$(wp "$T/cp-spec.json")
|
||||
cpo() { local s=$1; shift; $PY "$CP" "$s" "$Rw" "$@" >"$T/cp.out" 2>"$T/cp.err"; echo $?; }
|
||||
cchk() { if [ "$3" = "$2" ]; then echo "ok context-pack $1: exit $3"; else echo "FAIL context-pack $1: exit $3, want $2"; fail=1; fi; }
|
||||
cin() { grep -qF -- "$2" "$T/cp.out" && echo "ok context-pack $1" || { echo "FAIL context-pack $1: missing: $2"; fail=1; }; }
|
||||
|
|
@ -501,11 +502,11 @@ cin "renamed window reads the new path" "== [8] d2.txt:4-5"
|
|||
[ "$(grep -c '^\[' "$T/cp.out")" = 24 ] && echo "ok context-pack table lists every anchor" || { echo "FAIL context-pack table count"; fail=1; }
|
||||
{ sed -n 2p "$T/cp.out" | grep -q '^\[7\]' && sed -n 6p "$T/cp.out" | grep -q '^\[24\]' && sed -n 7p "$T/cp.out" | grep -q '^\[1\]'; } && echo "ok context-pack problem anchors first" || { echo "FAIL context-pack problem anchors first"; fail=1; }
|
||||
# deletes naming the file, and a valid range, make the same spec exit 0
|
||||
sed -e 's/"deletes": \[\]/"deletes": [{"path": "c.txt"}]/' -e 's/"end_line": 50/"end_line": 6/' -e 's/"end_line": 11/"end_line": 10/' "$T/cp-spec.json" >"$T/cp-spec0.json"
|
||||
sed -e 's/"deletes": \[\]/"deletes": [{"path": "c.txt"}]/' -e 's/"end_line": 50/"end_line": 6/' -e 's/"end_line": 11/"end_line": 10/' "$T/cp-spec.json" | wrapcp >"$T/cp-spec0.json"
|
||||
r=$(cpo "$(wp "$T/cp-spec0.json")"); cchk "GONE named by deletes, no OUT_OF_RANGE" 0 "$r"
|
||||
cin "GONE in deletes has no qualifier" "[7] c.txt:2-3 GONE #"
|
||||
# unreachable base
|
||||
sed "s/\"$BASE\"/\"deadbeef\"/" "$T/cp-spec.json" >"$T/cp-specb.json"
|
||||
sed "s/\"$BASE\"/\"deadbeef\"/" "$T/cp-spec.json" | wrapcp >"$T/cp-specb.json"
|
||||
r=$(cpo "$(wp "$T/cp-specb.json")"); cchk "unreachable base" 3 "$r"
|
||||
cin "UNRESOLVED hint" "UNRESOLVED base not a commit here: git fetch origin deadbeef"
|
||||
[ "$(grep -c 'UNRESOLVED' "$T/cp.out")" = 24 ] && echo "ok context-pack every anchor UNRESOLVED" || { echo "FAIL context-pack UNRESOLVED count"; fail=1; }
|
||||
|
|
@ -531,7 +532,7 @@ echo '{"base": "'$BASE'", "deletes": [], "file_changes": [
|
|||
{"change": "up", "location": {"path": "../a.txt", "line": 1, "end_line": 1}},
|
||||
{"change": "abs", "location": {"path": "/a.txt", "line": 1, "end_line": 1}},
|
||||
{"change": "drive", "location": {"path": "c:a.txt", "line": 1, "end_line": 1}},
|
||||
{"change": "'$Z70'zzzz", "location": {"path": "a.txt", "line": 1, "end_line": 1}}]}' >"$T/cp-specu.json"
|
||||
{"change": "'$Z70'zzzz", "location": {"path": "a.txt", "line": 1, "end_line": 1}}]}' | wrapcp >"$T/cp-specu.json"
|
||||
r=$(cpo "$(wp "$T/cp-specu.json")"); cchk "unsafe paths" 3 "$r"
|
||||
[ "$(grep -c 'UNRESOLVED path or git diff unusable' "$T/cp.out")" = 3 ] && echo "ok context-pack unsafe paths are UNRESOLVED" || { echo "FAIL context-pack unsafe paths"; fail=1; }
|
||||
cin "a long change is cut at 70 characters" "# $Z70"
|
||||
|
|
@ -539,13 +540,13 @@ cnot "a long change is cut at 70 characters (not 71)" "${Z70}z"
|
|||
# caps
|
||||
{ echo '{"base": "'$BASE'", "deletes": [], "file_changes": ['
|
||||
for i in $(seq 1 30); do echo '{"change": "c'$i'", "location": {"path": "big.txt", "line": '$((i*5))', "end_line": '$((i*5+9))'}}'$([ $i -lt 30 ] && echo ,); done
|
||||
echo ']}'; } >"$T/cp-spec30.json"
|
||||
echo ']}'; } | wrapcp >"$T/cp-spec30.json"
|
||||
r=$(cpo "$(wp "$T/cp-spec30.json")" --max-lines 200); cchk "30 anchors" 0 "$r"
|
||||
[ "$(wc -l <"$T/cp.out")" -le 200 ] && echo "ok context-pack output within --max-lines" || { echo "FAIL context-pack over 200 lines"; fail=1; }
|
||||
[ "$(grep -c '^\[' "$T/cp.out")" = 30 ] && echo "ok context-pack capped output keeps the full table" || { echo "FAIL context-pack capped table"; fail=1; }
|
||||
[ "$(grep -c '^== \[' "$T/cp.out")" = 9 ] && echo "ok context-pack expands 9 windows of 17 lines" || { echo "FAIL context-pack window count: $(grep -c '^== \[' "$T/cp.out")"; fail=1; }
|
||||
cin "rest listed as not expanded" "not expanded: --only 10,11,12"
|
||||
echo '{"base": "'$BASE'", "deletes": [], "file_changes": [{"change": "long", "location": {"path": "big.txt", "line": 20, "end_line": 169}}]}' >"$T/cp-spec1.json"
|
||||
echo '{"base": "'$BASE'", "deletes": [], "file_changes": [{"change": "long", "location": {"path": "big.txt", "line": 20, "end_line": 169}}]}' | wrapcp >"$T/cp-spec1.json"
|
||||
S1=$(wp "$T/cp-spec1.json")
|
||||
r=$(cpo "$S1"); cchk "150-line range" 0 "$r"
|
||||
cin "window cut at 100 lines" "56 more lines: --only 1 --max-lines 160"
|
||||
|
|
@ -554,7 +555,7 @@ r=$(cpo "$S1" --only 1 --max-lines 160); cchk "--only with the suggested --max-l
|
|||
cnot "full window needs no more-lines note" "more lines"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 160 ] && echo "ok context-pack suggested --max-lines is exact" || { echo "FAIL context-pack suggested max: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
# reads, symbols and caller lists
|
||||
sed "s/\"BASE\"/\"$BASE\"/" "$CF/spec-reads.json" >"$T/cp-spec-reads.json"; SR=$(wp "$T/cp-spec-reads.json")
|
||||
sed "s/\"BASE\"/\"$BASE\"/" "$CF/spec-reads.json" | wrapcp >"$T/cp-spec-reads.json"; SR=$(wp "$T/cp-spec-reads.json")
|
||||
r=$(cpo "$SR"); cchk "reads and symbols" 3 "$r"
|
||||
cin "a read that moved" "[r1] a.txt:20-22 MOVED(+3) -> a.txt:23-25"
|
||||
cin "a read on a deleted path is GONE" "[r2] c.txt:2-3 GONE (not named by the spec's deletes)"
|
||||
|
|
@ -594,18 +595,18 @@ r=$(cpo "$SR" --max-lines "$SUGG"); cnot "the suggested --max-lines prints every
|
|||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = "$SUGG" ] && echo "ok context-pack suggested caller --max-lines is exact" || { echo "FAIL context-pack suggested caller max: $(wc -l <"$T/cp.out") vs $SUGG"; fail=1; }
|
||||
{ echo '{"base": "'$BASE'", "deletes": [], "file_changes": ['
|
||||
for i in 1 2 3 4 5 6 7 8 9; do echo '{"change": "s'$i'", "location": {"path": "big.txt", "line": '$i', "end_line": '$i', "symbol": "g'$i'"}}'$([ $i -lt 9 ] && echo ,); done
|
||||
echo ']}'; } >"$T/cp-spec9sym.json"
|
||||
echo ']}'; } | wrapcp >"$T/cp-spec9sym.json"
|
||||
r=$(cpo "$(wp "$T/cp-spec9sym.json")" --max-lines 400); cchk "nine symbols" 0 "$r"
|
||||
[ "$(grep -c '^CALLERS' "$T/cp.out")" = 8 ] && echo "ok context-pack at most 8 caller lists" || { echo "FAIL context-pack caller list count"; fail=1; }
|
||||
cin "the ninth symbol is named" "callers not listed: g9"
|
||||
echo '{"base": "'$BASE'", "deletes": [], "file_changes": [], "reads": [{"why": "w", "location": {"path": "a.txt", "line": 20, "end_line": 22, "symbol": "a21"}}]}' >"$T/cp-spec-r0.json"
|
||||
echo '{"base": "'$BASE'", "deletes": [], "file_changes": [], "reads": [{"why": "w", "location": {"path": "a.txt", "line": 20, "end_line": 22, "symbol": "a21"}}]}' | wrapcp >"$T/cp-spec-r0.json"
|
||||
r=$(cpo "$(wp "$T/cp-spec-r0.json")"); cchk "a spec of one read, symbol present" 0 "$r"
|
||||
cin "a read with a symbol present: no suffix" "[r1] a.txt:20-22 MOVED(+3) -> a.txt:23-25 # w"
|
||||
# caller-list bounds: 50 hits list, 51 count; 20 files; a hit's text is cut at 160; CR and bad bytes
|
||||
{ echo '{"base": "'$BASE'", "deletes": [], "file_changes": ['
|
||||
n=0; for sy in bound_fifty bound_fiftyone spread_sym long_symbol q.zq sym_bad twenty_sym; do n=$((n+1))
|
||||
echo '{"change": "'$sy'", "location": {"path": "anchors.txt", "line": 1, "end_line": 1, "symbol": "'$sy'"}}'$([ $n -lt 7 ] && echo ,); done
|
||||
echo ']}'; } >"$T/cp-specb.json"
|
||||
echo ']}'; } | wrapcp >"$T/cp-specb.json"
|
||||
r=$(cpo "$(wp "$T/cp-specb.json")" --max-lines 400); cchk "caller list bounds" 0 "$r"
|
||||
cin "exactly 50 hits are listed" "CALLERS bound_fifty: 50 hits in 1 files"
|
||||
[ "$(grep -c '^bound50.txt:' "$T/cp.out")" = 50 ] && echo "ok context-pack 50 hits print as lines" || { echo "FAIL context-pack 50 hit lines"; fail=1; }
|
||||
|
|
@ -632,7 +633,7 @@ r=$(cpo "$SR" --only r5); cchk "--only the last read" 3 "$r"; cin "--only r5 pri
|
|||
sed -n 3p "$T/cp.out" | grep -q '^\[r3\]' && echo "ok context-pack a MISSING read sorts with the problem anchors" || { echo "FAIL context-pack MISSING read order"; fail=1; }
|
||||
cin "a GONE read checks its symbol at base" "GONE (not named by the spec's deletes) SYMBOL_MISSING c9"
|
||||
{ echo '{"base": "'$BASE'", "deletes": [], "file_changes": [{"location": {"path": "a.txt", "line": 1, "end_line": 2, "symbol": "zz9"}}],'
|
||||
echo '"reads": [{"location": {"path": "a.txt", "line": 1, "end_line": 2}}, {"why": "'$(printf '%0250d' 0 | tr 0 w)'", "location": {"path": "a.txt", "line": 3, "end_line": 3}}]}'; } >"$T/cp-specw.json"
|
||||
echo '"reads": [{"location": {"path": "a.txt", "line": 1, "end_line": 2}}, {"why": "'$(printf '%0250d' 0 | tr 0 w)'", "location": {"path": "a.txt", "line": 3, "end_line": 3}}]}'; } | wrapcp >"$T/cp-specw.json"
|
||||
r=$(cpo "$(wp "$T/cp-specw.json")"); cchk "a missing symbol alone fails the run" 3 "$r"
|
||||
cin "a symbol absent from an unmoved window" "[1] a.txt:1-2 SAME SYMBOL_MISSING zz9"
|
||||
cnot "an anchor without a change or why gets no filler" "XXXX"
|
||||
|
|
@ -640,7 +641,7 @@ W200=$(printf '%0200d' 0 | tr 0 w); cin "the read caption is cut at 200" "== REA
|
|||
# the caller lists obey --max-lines at every budget, and the suggested value prints them all
|
||||
{ echo '{"base": "'$BASE'", "deletes": [], "file_changes": ['
|
||||
for i in 1 2 3 4 5 6 7 8 9 10; do echo '{"change": "s'$i'", "location": {"path": "big.txt", "line": '$i', "end_line": '$i', "symbol": "g'$i'"}}'$([ $i -lt 10 ] && echo ,); done
|
||||
echo ']}'; } >"$T/cp-spec10sym.json"; S10=$(wp "$T/cp-spec10sym.json")
|
||||
echo ']}'; } | wrapcp >"$T/cp-spec10sym.json"; S10=$(wp "$T/cp-spec10sym.json")
|
||||
r=$(cpo "$S10" --max-lines 400); cin "two symbols past the eighth are named together" "callers not listed: g9,g10"
|
||||
FULLN=$(wc -l <"$T/cp.out" | tr -d ' ')
|
||||
for b in $((FULLN-1)) $((FULLN-3)) $((FULLN-6)) $((FULLN-9)) $((FULLN-30)); do
|
||||
|
|
@ -677,12 +678,22 @@ UNREADABLE="context-pack: spec: unreadable; pipe huginn view --raw <id> or pass
|
|||
r=$(cpo "$T/CANARY-nofile.json"); cchk "unreadable spec file" 4 "$r"; grep -qxF "$UNREADABLE" "$T/cp.err" && echo "ok context-pack names the unreadable spec" || { echo "FAIL context-pack unreadable message: $(cat "$T/cp.err")"; fail=1; }
|
||||
cnot "unreadable spec echoes no path" "CANARY"
|
||||
r=$(cpo "$SP"); cp "$T/cp.out" "$T/cp.want"
|
||||
r=$($PY "$CP" - "$Rw" <"$T/cp-spec.json" >"$T/cp.out" 2>"$T/cp.err"; echo $?); cchk "spec from stdin" 3 "$r"
|
||||
r=$($PY "$CP" - "$Rw" <"$T/cp-spec.json" >"$T/cp.out" 2>"$T/cp.err"; echo $?); cchk "spec from stdin" 3 "$r"; [ "$r" = 3 ] || cat "$T/cp.err"
|
||||
cmp -s "$T/cp.out" "$T/cp.want" && echo "ok context-pack stdin equals the file run" || { echo "FAIL context-pack stdin differs from the file run"; fail=1; }
|
||||
r=$(: | $PY "$CP" - "$Rw" >"$T/cp.out" 2>"$T/cp.err"; echo $?); cchk "empty stdin" 4 "$r"; grep -qxF "$UNREADABLE" "$T/cp.err" && echo "ok context-pack names the empty spec" || { echo "FAIL context-pack empty stdin message"; fail=1; }
|
||||
r=$(echo 'absent t:cut_spec:CANARY-x' | $PY "$CP" - "$Rw" >"$T/cp.out" 2>"$T/cp.err"; echo $?); cchk "an absent line" 4 "$r"; grep -qxF "$UNREADABLE" "$T/cp.err" && echo "ok context-pack names the absent spec" || { echo "FAIL context-pack absent message"; fail=1; }
|
||||
cnot "an absent line echoes no id" "CANARY"
|
||||
echo '{}' >"$T/cp-empty.json"; r=$(cpo "$(wp "$T/cp-empty.json")"); cchk "a spec that is {}" 4 "$r"; grep -qxF "$UNREADABLE" "$T/cp.err" && echo "ok context-pack names the empty object" || { echo "FAIL context-pack {} message"; fail=1; }
|
||||
printf '' | cat - "$T/cp-spec.json" >"$T/cp-bom.json"; r=$(cpo "$(wp "$T/cp-bom.json")"); cchk "a spec file with a UTF-8 BOM" 3 "$r"
|
||||
r=$(cat "$T/cp-bom.json" | $PY "$CP" - "$Rw" >"$T/cp.out" 2>"$T/cp.err"; echo $?); cchk "a spec on stdin with a UTF-8 BOM" 3 "$r"
|
||||
$PY -c 'import json,sys; v=json.load(open(sys.argv[1])); v["kind"]="ruling"; json.dump(v,open(sys.argv[2],"w"))' "$(wp "$T/cp-spec.json")" "$(wp "$T/cp-notspec.json")"
|
||||
r=$(cpo "$(wp "$T/cp-notspec.json")"); cchk "a well-shaped document of another kind" 4 "$r"
|
||||
$PY -c 'import json,sys; json.dump(json.load(open(sys.argv[1]))["value"],open(sys.argv[2],"w"))' "$(wp "$T/cp-spec.json")" "$(wp "$T/cp-bare.json")"
|
||||
r=$(cpo "$(wp "$T/cp-bare.json")"); cchk "a bare value with no kind" 4 "$r"
|
||||
for f in campaign cut revision; do
|
||||
$PY -c 'import json,sys; v=json.load(open(sys.argv[1])); del v["value"][sys.argv[3]]; json.dump(v,open(sys.argv[2],"w"))' "$(wp "$T/cp-spec.json")" "$(wp "$T/cp-noid.json")" $f
|
||||
r=$(cpo "$(wp "$T/cp-noid.json")"); cchk "a spec without $f" 4 "$r"; cnot "no None for a missing $f" "None"
|
||||
done
|
||||
echo '{"kind": "ruling", "value": {"title": "CANARY-title"}}' >"$T/cp-ruling.json"; r=$(cpo "$(wp "$T/cp-ruling.json")"); cchk "a document that is no cut_spec" 4 "$r"; grep -qxF "$UNREADABLE" "$T/cp.err" && echo "ok context-pack names the foreign document" || { echo "FAIL context-pack foreign document message"; fail=1; }
|
||||
cnot "a foreign document echoes no value" "CANARY"
|
||||
grep -qF "usage: " "$T/cp.err" || echo "ok context-pack spec error prints no usage text"
|
||||
|
|
@ -710,7 +721,7 @@ echo '{"base": "'$B2'", "deletes": [], "file_changes": [
|
|||
{"change": "edit on the last line", "location": {"path": "w.txt", "line": 3, "end_line": 5}},
|
||||
{"change": "edit on the first line", "location": {"path": "w.txt", "line": 5, "end_line": 7}},
|
||||
{"change": "after the edit", "location": {"path": "w.txt", "line": 6, "end_line": 8}},
|
||||
{"change": "before the edit", "location": {"path": "w.txt", "line": 1, "end_line": 4}}]}' >"$T/cp-spec2.json"
|
||||
{"change": "before the edit", "location": {"path": "w.txt", "line": 1, "end_line": 4}}]}' | wrapcp >"$T/cp-spec2.json"
|
||||
SP2=$(wp "$T/cp-spec2.json")
|
||||
cp2() { local s=$1; shift; $PY "$CP" "$s" "$R2w" "$@" >"$T/cp.out" 2>"$T/cp.err"; echo $?; }
|
||||
r=$(cp2 "$SP2"); cchk "straddle fixture" 0 "$r"
|
||||
|
|
@ -774,11 +785,11 @@ while read -r nm fld; do
|
|||
grep -qF "context-pack: spec: $fld: InvalidInput" "$T/cp.err" && echo "ok context-pack names $fld" || { echo "FAIL context-pack message for $nm: $(cat "$T/cp.err")"; fail=1; }
|
||||
cnot "wrong-typed spec $nm: no value" "CANARY"; cnot "wrong-typed spec $nm: no traceback" "Traceback"
|
||||
done <"$T/cp-bad.list"
|
||||
echo '{"base": "CANARY-base", "deletes": [], "file_changes": [{"change": "c", "location": {"path": "a.txt", "line": 1, "end_line": 2}}]}' >"$T/cp-specnb.json"
|
||||
echo '{"base": "CANARY-base", "deletes": [], "file_changes": [{"change": "c", "location": {"path": "a.txt", "line": 1, "end_line": 2}}]}' | wrapcp >"$T/cp-specnb.json"
|
||||
r=$(cpo "$(wp "$T/cp-specnb.json")"); cchk "a base that is no sha" 3 "$r"
|
||||
cin "a base that is no sha reads UNRESOLVED" "UNRESOLVED base not a commit here"
|
||||
cin "a base that is no sha is not echoed in the header" "base unresolvable HEAD"
|
||||
echo '{"file_changes": [{"change": "c", "location": {"path": "a.txt", "line": 1}}]}' >"$T/cp-spec-nobase.json"
|
||||
echo '{"file_changes": [{"change": "c", "location": {"path": "a.txt", "line": 1}}]}' | wrapcp >"$T/cp-spec-nobase.json"
|
||||
r=$(cpo "$(wp "$T/cp-spec-nobase.json")"); cchk "a spec value without a base" 4 "$r"
|
||||
grep -qxF "$UNREADABLE" "$T/cp.err" && echo "ok context-pack a missing base is a typed refusal" || { echo "FAIL context-pack missing base: $(cat "$T/cp.err")"; fail=1; }
|
||||
# a --max-lines below the table: the table always lists every anchor and no window prints
|
||||
|
|
@ -798,7 +809,7 @@ r=$(cpo "$S1" --only 1 --max-lines 6); cin "--only below the smallest truncation
|
|||
cnot "--only below the smallest truncation prints no window" "== ["
|
||||
echo '{"base": "'$BASE'", "deletes": [], "file_changes": [
|
||||
{"change": "long", "location": {"path": "big.txt", "line": 20, "end_line": 169}},
|
||||
{"change": "short", "location": {"path": "big.txt", "line": 200, "end_line": 210}}]}' >"$T/cp-spec2w.json"
|
||||
{"change": "short", "location": {"path": "big.txt", "line": 200, "end_line": 210}}]}' | wrapcp >"$T/cp-spec2w.json"
|
||||
r=$(cpo "$(wp "$T/cp-spec2w.json")" --only 1,2 --max-lines 50); cchk "--only two windows" 0 "$r"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 50 ] && echo "ok context-pack --only keeps room for the not-expanded line" || { echo "FAIL context-pack --only reserve: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
cin "--only: the window that no longer fits is listed" "not expanded: --only 2"
|
||||
|
|
@ -810,7 +821,7 @@ cnot "--only: below four lines after the reserve nothing is cut" "== ["
|
|||
cin "--only: both are listed as not expanded" "not expanded: --only 1,2"
|
||||
echo '{"base": "'$B2'", "deletes": [], "file_changes": [
|
||||
{"change": "long", "location": {"path": "big.txt", "line": 20, "end_line": 169}},
|
||||
{"change": "tiny", "location": {"path": "one.txt", "line": 1, "end_line": 1}}]}' >"$T/cp-spec3.json"
|
||||
{"change": "tiny", "location": {"path": "one.txt", "line": 1, "end_line": 1}}]}' | wrapcp >"$T/cp-spec3.json"
|
||||
r=$(cp2 "$(wp "$T/cp-spec3.json")" --only 1,2 --max-lines 100); cchk "--only cut window then a tiny one" 0 "$r"
|
||||
[ "$(wc -l <"$T/cp.out" | tr -d ' ')" = 100 ] && echo "ok context-pack a cut window is charged what it prints" || { echo "FAIL context-pack cut window charge: $(wc -l <"$T/cp.out")"; fail=1; }
|
||||
cin "a cut window leaves no room for the next one" "not expanded: --only 2"
|
||||
|
|
|
|||
Loading…
Reference in a new issue