carlos / platform Public

hosts-used scan: Astra round 1 fixes (2 P1, 2 P2)

Summary

- P1-1 (remote inventory completeness): no sort on the box. find's
  output is hashed and counted directly, the box checks the sum is 64
  hex and the count is digits, and every encoder failure can only make
  the reassembled listing disagree with them. The client also requires
  find's "." line and no empty line. Witnesses: gzip, sha256sum and wc
  replaced by tools that fail after partial output, each ok:false.
- P1-2 (configured vs inventoried namespace): the prefix is read as the
  box reads CARLOS_HIBERNATE_PREFIX, strings.Trim(strings.TrimSpace(v),
  "/"), and only printable ASCII is taken. Witnesses: "///" lists the
  whole bucket, " //instances// " is instances, a tab fails.
- P2-3 (atomic publication): every output write goes through put, which
  stops the scan with exit 2 and leaves the earlier file in place.
  Witness: ulimit -f with SIGXFSZ ignored.
- P2-4 (malformed provider responses): a page must carry a boolean
  IsTruncated, a KeyCount equal to its Contents, and only non-empty
  string keys under the prefix asked for. Witnesses: an entry with no
  Key, {}, and a key outside the prefix.
Agent notes
each new witness was mutation-checked (unchecked put, a
single-slash trim on either side, no prefix check on keys). The dev dry
run still gives 5 ok and the r10w NoSuchBucket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev c912aa0e6ad1176e76614956ccfc9ff247c68963 parent b0e9272
3 files changed, +172 −34
  • cmd/console/hostsused_scan_test.go +116 −17
  • docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r1.md +9 −0
  • scripts/hosts-used-scan-aws.sh +47 −17
diff --git a/cmd/console/hostsused_scan_test.go b/cmd/console/hostsused_scan_test.go
index b6d0688c1..4539bcc89 100644
--- a/cmd/console/hostsused_scan_test.go
+++ b/cmd/console/hostsused_scan_test.go
@@ -38,6 +38,9 @@ type fakeBucket struct {
Keys []string `json:"keys"`
Fail string `json:"fail"` // every call fails with this
FailPage int `json:"fail_page"` // the call for this page (1-based) fails
+ // Malformed answers a page that is no listing: "nokey" (an entry
+ // without a Key), "empty" ({}), "outside" (a key not under the prefix).
+ Malformed string `json:"malformed"`
}
type fakeInstance struct {
@@ -45,6 +48,9 @@ type fakeInstance struct {
Truncate int `json:"truncate"` // keep only this many characters of output
GrowDir string `json:"grow_dir"` // send-commands add a file here: every one...
GrowAt int `json:"grow_at"` // ...or only this instance's nth
+ // Break replaces one tool the box's script runs with one that fails
+ // after writing part of its output.
+ Break string `json:"break"`
}
// fakeAWS is the fake aws CLI. It logs every call's arguments, one JSON
@@ -100,6 +106,17 @@ func fakeListObjects(cfg fakeAWSConfig, opts map[string]string) int {
fmt.Fprintf(os.Stderr, "An error occurred (AccessDenied) when calling the ListObjectsV2 operation: %s\n", b.Fail)
return 254
}
+ switch b.Malformed {
+ case "nokey":
+ fmt.Println(`{"IsTruncated":false,"KeyCount":1,"Contents":[{"Size":1}]}`)
+ return 0
+ case "empty":
+ fmt.Println(`{}`)
+ return 0
+ case "outside":
+ fmt.Println(`{"IsTruncated":false,"KeyCount":1,"Contents":[{"Key":"elsewhere/a.example.com/x"}]}`)
+ return 0
+ }
var keys []string
for _, k := range b.Keys {
if strings.HasPrefix(k, opts["--prefix"]) {
@@ -142,6 +159,12 @@ func fakeSendCommand(dir string, cfg fakeAWSConfig, opts map[string]string) int
}
var stdout, stderr strings.Builder
cmd := exec.Command("sh", "-c", params.Commands[0])
+ if inst.Break != "" {
+ shims := filepath.Join(dir, "shims-"+inst.Break)
+ os.MkdirAll(shims, 0o755)
+ os.WriteFile(filepath.Join(shims, inst.Break), []byte("#!/bin/sh\nhead -c 7\nexit 1\n"), 0o755)
+ cmd.Env = append(os.Environ(), "PATH="+shims+string(os.PathListSeparator)+os.Getenv("PATH"))
+ }
cmd.Stdout, cmd.Stderr = &stdout, &stderr
code, status := 0, "Success"
if err := cmd.Run(); err != nil {
@@ -501,9 +524,19 @@ func TestHostsUsedScanAWSFailsATargetClosed(t *testing.T) {
d = w.box("box:grows-once", "i-0a5", "shop.example.com.db")
w.cfg.Instances["i-0a5"] = fakeInstance{GrowDir: d, GrowAt: 2}
w.coordinates["box:badinst"] = map[string]string{"instance": "i-0a6; rm -rf /", "region": "eu-west-1"}
+ for _, m := range []string{"nokey", "empty", "outside"} {
+ w.bucket("bucket:malformed-"+m, "instances")
+ w.cfg.Buckets["malformed-"+m] = fakeBucket{Malformed: m}
+ }
+ for i, tool := range []string{"gzip", "sha256sum", "wc"} {
+ inst := fmt.Sprintf("i-0b%d", i)
+ w.box("box:broken-"+tool, inst, "shop.example.com.db")
+ w.cfg.Instances[inst] = fakeInstance{Break: tool}
+ }
roster := map[string]any{"targets": []string{"bucket:ok", "bucket:denied", "bucket:page2", "bucket:noprefix", "bucket:nocoords",
- "box:okbox", "box:unsent", "box:nodir", "box:cut", "box:grows", "box:grows-once", "box:badinst", "box:nocoords", "pool:p1"}}
+ "box:okbox", "box:unsent", "box:nodir", "box:cut", "box:grows", "box:grows-once", "box:badinst", "box:nocoords", "pool:p1",
+ "bucket:malformed-nokey", "bucket:malformed-empty", "bucket:malformed-outside", "box:broken-gzip", "box:broken-sha256sum", "box:broken-wc"}}
rosterPath := filepath.Join(w.dir, "roster.json")
writeJSON(t, rosterPath, roster)
got, stderr, code := w.scan(rosterPath, "HOSTS_SCAN_PAGE=40")
@@ -511,24 +544,30 @@ func TestHostsUsedScanAWSFailsATargetClosed(t *testing.T) {
t.Fatalf("scan exit %d, want 1\n%s", code, stderr)
}
ls := byTarget(got)
- if len(got) != 14 || len(ls) != 14 {
- t.Fatalf("want one line for each of 14 targets, got %d: %+v", len(got), got)
+ if len(got) != 20 || len(ls) != 20 {
+ t.Fatalf("want one line for each of 20 targets, got %d: %+v", len(got), got)
}
for target, want := range map[string]string{
- "bucket:ok": "",
- "box:okbox": "",
- "box:grows-once": "",
- "bucket:denied": "AccessDenied",
- "bucket:page2": "AccessDenied",
- "bucket:noprefix": "no prefix for bucket:noprefix",
- "bucket:nocoords": "no prefix for bucket:nocoords",
- "box:unsent": "InvalidInstanceId",
- "box:nodir": "Failed (exit 3)",
- "box:cut": "cut short",
- "box:grows": "changed while it was paged",
- "box:badinst": "is not an instance id",
- "box:nocoords": "no instance for box:nocoords",
- "pool:p1": "does not know this kind of target",
+ "bucket:ok": "",
+ "box:okbox": "",
+ "box:grows-once": "",
+ "bucket:denied": "AccessDenied",
+ "bucket:page2": "AccessDenied",
+ "bucket:noprefix": "no prefix for bucket:noprefix",
+ "bucket:nocoords": "no prefix for bucket:nocoords",
+ "box:unsent": "InvalidInstanceId",
+ "box:nodir": "Failed (exit 3)",
+ "box:cut": "cut short",
+ "box:grows": "changed while it was paged",
+ "box:badinst": "is not an instance id",
+ "box:nocoords": "no instance for box:nocoords",
+ "pool:p1": "does not know this kind of target",
+ "bucket:malformed-nokey": "not a well-formed listing",
+ "bucket:malformed-empty": "not a well-formed listing",
+ "bucket:malformed-outside": "not a well-formed listing",
+ "box:broken-gzip": "does not decode",
+ "box:broken-sha256sum": "Failed (exit 6)",
+ "box:broken-wc": "Failed (exit 6)",
} {
l, ok := ls[target]
switch {
@@ -546,3 +585,63 @@ func TestHostsUsedScanAWSFailsATargetClosed(t *testing.T) {
}
}
}
+
+// TestHostsUsedScanAWSPrefixAsTheBoxReadsIt: the coords' prefix is read as
+// the box reads CARLOS_HIBERNATE_PREFIX, strings.Trim(strings.TrimSpace(v),
+// "/"): "///" is the top level, so the whole bucket is listed, and
+// " //instances// " is instances. A prefix that is not printable ASCII fails.
+func TestHostsUsedScanAWSPrefixAsTheBoxReadsIt(t *testing.T) {
+ w := newScanWorld(t)
+ keys := []string{"top.example.com/db/1", "moves/m.example.com/x", "instances/i.example.com/y"}
+ w.bucket("bucket:slashes", "///", keys...)
+ w.bucket("bucket:padded", " //instances// ", keys...)
+ w.bucket("bucket:tab", "instances\t", keys...)
+ rosterPath := filepath.Join(w.dir, "roster.json")
+ writeJSON(t, rosterPath, map[string]any{"targets": []string{"bucket:slashes", "bucket:padded", "bucket:tab"}})
+ got, stderr, code := w.scan(rosterPath)
+ if code != 1 {
+ t.Fatalf("scan exit %d, want 1\n%s", code, stderr)
+ }
+ ls := byTarget(got)
+ if l := ls["bucket:slashes"]; !l.OK || l.Prefix != "" || !slices.Equal(l.Entries, slices.Sorted(slices.Values(keys))) {
+ t.Errorf("prefix /// = %+v, want the whole bucket with prefix \"\"", l)
+ }
+ if l := ls["bucket:padded"]; !l.OK || l.Prefix != "instances" || !slices.Equal(l.Entries, []string{"instances/i.example.com/y", "moves/m.example.com/x"}) {
+ t.Errorf("prefix \" //instances// \" = %+v, want instances", l)
+ }
+ if l := ls["bucket:tab"]; l.OK || !strings.Contains(l.Error, "not printable ASCII") {
+ t.Errorf("a prefix with a tab = %+v, want ok:false", l)
+ }
+}
+
+// TestHostsUsedScanAWSNeverPublishesAShortFile: when the output cannot be
+// written in full, the scan exits 2 and the earlier output file is left as
+// it was. Many targets with no coordinates fill the output past a
+// one-block file size limit with no other file written.
+func TestHostsUsedScanAWSNeverPublishesAShortFile(t *testing.T) {
+ w := newScanWorld(t)
+ var targets []string
+ for i := range 30 {
+ targets = append(targets, fmt.Sprintf("box:a-box-with-a-long-name-and-no-coordinates-%02d", i))
+ }
+ rosterPath := filepath.Join(w.dir, "roster.json")
+ writeJSON(t, rosterPath, map[string]any{"targets": targets})
+ writeJSON(t, filepath.Join(w.fake, "config.json"), w.cfg)
+ writeJSON(t, w.coordsPath, w.coordinates)
+ out := filepath.Join(w.dir, "scan.jsonl")
+ if err := os.WriteFile(out, []byte("earlier\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ // SIGXFSZ ignored, so a write past the limit fails with EFBIG instead.
+ cmd := exec.Command("bash", "-c", `trap '' XFSZ; ulimit -f 1; exec "$0" "$@"`, scanScript,
+ "--profile", "scan-test", "--targets", w.coordsPath, rosterPath, out)
+ cmd.Env = append(os.Environ(), w.env...)
+ b, err := cmd.CombinedOutput()
+ var ee *exec.ExitError
+ if !errors.As(err, &ee) || ee.ExitCode() != 2 || !strings.Contains(string(b), "could not write") {
+ t.Fatalf("scan = %v, want exit 2 on a failed write\n%s", err, b)
+ }
+ if body, _ := os.ReadFile(out); string(body) != "earlier\n" {
+ t.Errorf("the output file changed: %q", body)
+ }
+}
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r1.md b/docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r1.md
new file mode 100644
index 000000000..762d76526
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-nearest-region-scan-r1.md
@@ -0,0 +1,9 @@
+1. **P1 — Task 11, §§1–2: remote sorting can silently discard the inventory.** At [scripts/hosts-used-scan-aws.sh:137](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/nearest-region-scan/scripts/hosts-used-scan-aws.sh:137), the `sort` exit status is ignored. If it fails from memory or temporary-space exhaustion, the script hashes and encodes its empty or partial output, then exits successfully. Verified with the generated script under `sh`: a failing sort produced exit 0, matching checksum/length/count, and ultimately `ok:true, entries:[""]`. The box mapper ignores that empty entry, so activation can complete without marking orphaned data. Unrestricted `sort` can also spill temporary files onto the box, violating the read-only requirement. **Fix:** check transformation failures and use bounded, memory-only processing that refuses excess input; add a failing-sort witness. **Fault family:** completeness of the remote inventory before checksumming; remote read-only boundary.
+
+2. **P1 — Task 11, §§2–3: prefix normalization can scan the wrong namespace successfully.** [scripts/hosts-used-scan-aws.sh:109](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/nearest-region-scan/scripts/hosts-used-scan-aws.sh:109) removes only one leading and trailing slash. The box configuration removes all surrounding slashes at [internal/activator/activator.go:134](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/nearest-region-scan/internal/activator/activator.go:134), as does the bucket mapper. Verified: `///` becomes an empty prefix on the box, but `/` in the scanner, which lists `//`, `moves/`, and `seeds/` instead of the whole bucket. Top-level replicas are omitted while the target remains `ok:true`. **Fix:** match configuration normalization exactly, or reject noncanonical coordinates before scanning. Test repeated slashes, including an all-slash prefix. **Fault family:** agreement between the configured storage namespace and the inventoried namespace.
+
+3. **P2 — Task 11, §4: failed output writes can publish a partial file with exit 0.** The appends at [scripts/hosts-used-scan-aws.sh:121](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/nearest-region-scan/scripts/hosts-used-scan-aws.sh:121) and [scripts/hosts-used-scan-aws.sh:219](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/nearest-region-scan/scripts/hosts-used-scan-aws.sh:219) are unchecked; `emit_fail` also ignores its write result. If an append fails, such as from disk exhaustion, execution continues to the final rename and can report success with missing or truncated output. **Fix:** abort on any output-write failure, leave the previous destination intact, and publish only after every append succeeds. Add a write-failure witness. **Fault family:** atomic publication and truthful exit status.
+
+4. **P2 — Task 11, §§2,4,6: malformed S3 pages are accepted as complete listings.** At [scripts/hosts-used-scan-aws.sh:96](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/nearest-region-scan/scripts/hosts-used-scan-aws.sh:96), `strings` silently drops missing or non-string keys; missing `IsTruncated` defaults to false. Verified that `{}` succeeds as an empty terminal page and an entry without `Key` disappears without error. **Fix:** validate the response shape, pagination fields, and every key before accepting a page; emit `ok:false` on malformed responses. Extend the fake with those cases. **Fault family:** rejecting malformed provider responses rather than interpreting them as absence.
+
+**NOT READY**
\ No newline at end of file
diff --git a/scripts/hosts-used-scan-aws.sh b/scripts/hosts-used-scan-aws.sh
index 092b6435c..81a6ee40a 100755
--- a/scripts/hosts-used-scan-aws.sh
+++ b/scripts/hosts-used-scan-aws.sh
@@ -38,6 +38,7 @@
# not (the output file is still written), 2 on bad arguments.
# HOSTS_SCAN_POLL, HOSTS_SCAN_WAIT and HOSTS_SCAN_PAGE exist for tests.
set -uo pipefail
+export LC_ALL=C
usage() { echo "usage: hosts-used-scan-aws.sh --profile <aws-profile> --targets <coords.json> <roster.json> <scan.jsonl>" >&2; exit 2; }
profile="" coords=""
while [ $# -gt 0 ]; do
@@ -73,9 +74,15 @@ sha256() { if command -v sha256sum >/dev/null; then sha256sum; else shasum -a 25
# oneline: an AWS error's text, on one line, short enough for a report.
oneline() { tr '\n' ' ' | sed 's/ */ /g; s/^ //; s/ $//' | cut -c1-400; }
+# put <line>: append one line to the output, or stop: a scan whose output
+# could not be written in full is never published.
+put() { printf '%s\n' "$1" >>"$part" || { echo "hosts-used-scan: could not write $part" >&2; exit 2; }; }
fail=0
emit_fail() { # <target name> <kind> <error>
- jq -nc --arg t "$1" --arg k "$2" --arg e "$3" '{target:$t,kind:$k,ok:false,error:$e,entries:[]}' >>"$part"
+ local line
+ line="$(jq -nc --arg t "$1" --arg k "$2" --arg e "$3" '{target:$t,kind:$k,ok:false,error:$e,entries:[]}')" || {
+ echo "hosts-used-scan: could not report $2:$1" >&2; exit 2; }
+ put "$line"
echo "FAIL $2:$1: $3" >&2
fail=1
}
@@ -93,20 +100,34 @@ list_prefix() {
[ -n "$token" ] && set -- "$@" --continuation-token "$token"
resp="$(awsp "$@" 2>"$work/err")" || { err="list s3://$b/$p: $(oneline <"$work/err")"; return 1; }
n=$((n + 1))
- jq -ce '[(.Contents // [])[] | .Key | strings]' <<<"$resp" >>"$work/keys" 2>/dev/null || {
- err="list s3://$b/$p: page $n is not a listing"; return 1; }
- trunc="$(jq -r '.IsTruncated // false' <<<"$resp")"
+ # A page is a listing only when it says whether it is the last, counts
+ # its keys, and every key is a non-empty string under the prefix asked
+ # for. Anything else fails the bucket, never reads as no keys.
+ jq -ce --arg p "$p" 'if type == "object" and (.IsTruncated|type) == "boolean" and (.KeyCount|type) == "number"
+ and ((.Contents // [])|type) == "array" and (.KeyCount == ((.Contents // [])|length))
+ and all((.Contents // [])[]; type == "object" and (.Key|type) == "string" and .Key != "" and (.Key|startswith($p)))
+ then [(.Contents // [])[].Key] else error("malformed") end' <<<"$resp" >>"$work/keys" 2>/dev/null || {
+ err="list s3://$b/$p: page $n is not a well-formed listing"; return 1; }
+ trunc="$(jq -r '.IsTruncated' <<<"$resp")"
[ "$trunc" = true ] || return 0
- token="$(jq -r '.NextContinuationToken // empty' <<<"$resp")"
+ token="$(jq -r '.NextContinuationToken // empty | strings' <<<"$resp")"
[ -n "$token" ] || { err="list s3://$b/$p: page $n is truncated with no continuation token"; return 1; }
done
}
scan_bucket() { # <roster target> <bucket>
- local t="$1" b="$2" prefix region p
+ local t="$1" b="$2" prefix region p line
prefix="$(coord "$t" prefix)" || { emit_fail "$b" bucket "no prefix for $t in $coords"; return; }
region="$(coord "$t" region)" || region=""
- prefix="${prefix#/}"; prefix="${prefix%/}"
+ # The box reads its prefix as strings.Trim(strings.TrimSpace(v), "/")
+ # (internal/activator/activator.go), and so must the scan, or it lists a
+ # namespace the box does not write. Only printable ASCII is taken, so
+ # the trims below are the same as Go's.
+ case "$prefix" in *[!\ -~]*) emit_fail "$b" bucket "prefix for $t is not printable ASCII"; return ;; esac
+ while [ "${prefix# }" != "$prefix" ]; do prefix="${prefix# }"; done
+ while [ "${prefix% }" != "$prefix" ]; do prefix="${prefix% }"; done
+ while [ "${prefix#/}" != "$prefix" ]; do prefix="${prefix#/}"; done
+ while [ "${prefix%/}" != "$prefix" ]; do prefix="${prefix%/}"; done
: >"$work/keys"
err=""
if [ -z "$prefix" ]; then
@@ -116,15 +137,19 @@ scan_bucket() { # <roster target> <bucket>
list_prefix "$b" "$region" "$p" || { emit_fail "$b" bucket "$err"; return; }
done
fi
- jq -cs --arg t "$b" --arg p "$prefix" '{target:$t,kind:"bucket",prefix:$p,ok:true,entries:(add // [] | unique)}' "$work/keys" >"$work/line" || {
+ line="$(jq -cs --arg t "$b" --arg p "$prefix" '{target:$t,kind:"bucket",prefix:$p,ok:true,entries:(add // [] | unique)}' "$work/keys")" || {
emit_fail "$b" bucket "could not assemble the listing"; return; }
- cat "$work/line" >>"$part"
- echo "ok bucket:$b: $(jq '.entries|length' "$work/line") keys" >&2
+ put "$line"
+ echo "ok bucket:$b: $(jq '.entries|length' <<<"$line") keys" >&2
}
# remote_script <data dir> <first char> <last char>: the command the box
-# runs. POSIX sh, as AWS-RunShellScript runs it. Read-only: find, sort and
-# encoders over pipes, nothing written.
+# runs. POSIX sh, as AWS-RunShellScript runs it. Read-only: find and
+# encoders over pipes, nothing written (no sort, which can spill to disk;
+# find's order is stable while the directory is unchanged, and a change
+# shows as a different sum). The sum and count are taken from find's own
+# checked output, so a failed or partial encoder can only make the
+# reassembled listing disagree with them, which fails the box.
remote_script() {
cat <<EOF
export LC_ALL=C
@@ -134,10 +159,12 @@ nl='
bad=\$(find . -maxdepth 3 -name "*\${nl}*" -print) || { echo "find failed under $1" >&2; exit 4; }
[ -z "\$bad" ] || { echo "a path under $1 has a newline in its name" >&2; exit 5; }
list=\$(find . -maxdepth 3 -print) || { echo "find failed under $1" >&2; exit 4; }
-list=\$(printf '%s\n' "\$list" | sort)
sum=\$(printf '%s\n' "\$list" | sha256sum | cut -d' ' -f1)
n=\$(printf '%s\n' "\$list" | wc -l | tr -d ' ')
blob=\$(printf '%s\n' "\$list" | gzip -n -c | base64 | tr -d '\n')
+case "\$sum" in *[!0-9a-f]*|'') sum=bad ;; esac
+case "\$n" in *[!0-9]*|'') n=bad ;; esac
+[ "\${#sum}" -eq 64 ] && [ "\$n" != bad ] && [ -n "\$blob" ] || { echo "could not encode the listing of $1" >&2; exit 6; }
printf 'hosts-used-scan v1 %s %s %s\n' "\$sum" "\${#blob}" "\$n"
printf '%s' "\$blob" | cut -c $2-$3
EOF
@@ -201,7 +228,7 @@ box_listing() {
}
scan_box() { # <roster target> <box>
- local t="$1" x="$2" inst region dir try rc
+ local t="$1" x="$2" inst region dir try rc line
inst="$(coord "$t" instance)" || { emit_fail "$x" box "no instance for $t in $coords"; return; }
region="$(coord "$t" region)" || { emit_fail "$x" box "no region for $t in $coords"; return; }
dir="$(coord "$t" data_dir)" || dir=/data
@@ -214,10 +241,13 @@ scan_box() { # <roster target> <box>
[ "$rc" -eq 2 ] || break
done
[ "$rc" -eq 0 ] || { emit_fail "$x" box "$err"; return; }
- jq -Rnc --arg t "$x" '{target:$t,kind:"box",ok:true,entries:[inputs | select(. != ".") | sub("^\\./"; "")]}' <"$work/listing" >"$work/line" || {
+ # find's output names the directory itself and never an empty path;
+ # anything else is not a listing of it.
+ grep -qx '\.' "$work/listing" && ! grep -q '^$' "$work/listing" || { emit_fail "$x" box "$inst: the listing under $dir is not find's output"; return; }
+ line="$(jq -Rnc --arg t "$x" '{target:$t,kind:"box",ok:true,entries:[inputs | select(. != ".") | sub("^\\./"; "")]}' <"$work/listing")" || {
emit_fail "$x" box "could not assemble the listing"; return; }
- cat "$work/line" >>"$part"
- echo "ok box:$x: $(jq '.entries|length' "$work/line") paths" >&2
+ put "$line"
+ echo "ok box:$x: $(jq '.entries|length' <<<"$line") paths" >&2
}
while IFS= read -r t; do