diff --git a/.github/workflows/caches.yaml b/.github/workflows/caches.yaml index d279da5..e9dfffc 100644 --- a/.github/workflows/caches.yaml +++ b/.github/workflows/caches.yaml @@ -34,7 +34,7 @@ concurrency: jobs: prune: - uses: farcloser/limen/.github/workflows/limen-caches.yaml@879e912a093a5a036ba9508dbb3e448178ae876c # v0.30.0 + uses: farcloser/limen/.github/workflows/limen-caches.yaml@558f7ae692e9df0c5055e9ac2d1d6c66172544f3 # v0.31.0 permissions: # Listing and deleting caches is an Actions write. actions: write diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e785fe6..f43d419 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,7 @@ concurrency: jobs: limen: - uses: farcloser/limen/.github/workflows/limen-verify.yaml@879e912a093a5a036ba9508dbb3e448178ae876c # v0.30.0 + uses: farcloser/limen/.github/workflows/limen-verify.yaml@558f7ae692e9df0c5055e9ac2d1d6c66172544f3 # v0.31.0 permissions: contents: read with: diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 122fda2..403e202 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -31,7 +31,7 @@ concurrency: jobs: scan: - uses: farcloser/limen/.github/workflows/limen-security.yaml@879e912a093a5a036ba9508dbb3e448178ae876c # v0.30.0 + uses: farcloser/limen/.github/workflows/limen-security.yaml@558f7ae692e9df0c5055e9ac2d1d6c66172544f3 # v0.31.0 permissions: contents: read diff --git a/.github/workflows/update-aqua-checksum.yaml b/.github/workflows/update-aqua-checksum.yaml index f531086..9bde735 100644 --- a/.github/workflows/update-aqua-checksum.yaml +++ b/.github/workflows/update-aqua-checksum.yaml @@ -20,7 +20,7 @@ concurrency: jobs: update: - uses: farcloser/limen/.github/workflows/limen-update-aqua-checksum.yaml@879e912a093a5a036ba9508dbb3e448178ae876c # v0.30.0 + uses: farcloser/limen/.github/workflows/limen-update-aqua-checksum.yaml@558f7ae692e9df0c5055e9ac2d1d6c66172544f3 # v0.31.0 permissions: contents: write # To approve the pull request's runs on the head the job pushes. diff --git a/.hermetic/aqua-checksums.json b/.hermetic/aqua-checksums.json index 0d49af7..42dd262 100644 --- a/.hermetic/aqua-checksums.json +++ b/.hermetic/aqua-checksums.json @@ -66,28 +66,28 @@ "algorithm": "sha256" }, { - "id": "github_release/github.com/farcloser/limen/v0.30.0/limen_0.30.0_darwin_arm64.tar.gz", - "checksum": "A677C91750F7FBC2E3C69ED19FE6B0BCD16FEC9E416D0EE1366984341E041F1E", + "id": "github_release/github.com/farcloser/limen/v0.31.0/limen_0.31.0_darwin_arm64.tar.gz", + "checksum": "D8404E731EF9B916A2D321BC61A7059E0BAB4E1EE7F6C2F2DA42B18EA235B018", "algorithm": "sha256" }, { - "id": "github_release/github.com/farcloser/limen/v0.30.0/limen_0.30.0_linux_amd64.tar.gz", - "checksum": "D2EEE32CEDED00766D76487C30527B1EFDA8A3FDF8ED37EA1C0AAEFB726C44CA", + "id": "github_release/github.com/farcloser/limen/v0.31.0/limen_0.31.0_linux_amd64.tar.gz", + "checksum": "68835DD45ECAEF03ACBE3948E6E2C8D8F763D7D14B2BD49ECF977C45D2239493", "algorithm": "sha256" }, { - "id": "github_release/github.com/farcloser/limen/v0.30.0/limen_0.30.0_linux_arm64.tar.gz", - "checksum": "220E1E62FC1F96D06076F4BF4E253A70A5E2DA29A34CC49F03142EBE348B6A4F", + "id": "github_release/github.com/farcloser/limen/v0.31.0/limen_0.31.0_linux_arm64.tar.gz", + "checksum": "58EE3B5E9370C99D98D8CDE5486B2D7B5AC36BBA054581D20CCC0CDE856A2DD5", "algorithm": "sha256" }, { - "id": "github_release/github.com/farcloser/limen/v0.30.0/limen_0.30.0_windows_amd64.tar.gz", - "checksum": "7FB4410E6C18E3996B57309CF6670ADD6A4134E4B459C30503C10FCA503F14BD", + "id": "github_release/github.com/farcloser/limen/v0.31.0/limen_0.31.0_windows_amd64.tar.gz", + "checksum": "95B93DB705A0581F43320BEE01311F4E311AECA3D4663B00AC3EE602FC733529", "algorithm": "sha256" }, { - "id": "github_release/github.com/farcloser/limen/v0.30.0/limen_0.30.0_windows_arm64.tar.gz", - "checksum": "B74BC9AFF2B6110DADFA10D3A2DB0F28B7D2C16B4CC51A23212E22AE2E3C702F", + "id": "github_release/github.com/farcloser/limen/v0.31.0/limen_0.31.0_windows_arm64.tar.gz", + "checksum": "A98E72D1E8DEAF3497FE4BB62C34E547CD8ED55B39A008000AAFEC4EC8BEEC48", "algorithm": "sha256" }, { diff --git a/.hermetic/hermetic.yaml b/.hermetic/hermetic.yaml index 51297b7..2ac0da3 100644 --- a/.hermetic/hermetic.yaml +++ b/.hermetic/hermetic.yaml @@ -19,7 +19,7 @@ registries: packages: # The limen this repository runs, and with it every canonical file it # writes: the one canonical pin kept here, where Renovate bumps it. - - name: farcloser/limen@v0.30.0 # renovate: depName=farcloser/limen + - name: farcloser/limen@v0.31.0 # renovate: depName=farcloser/limen registry: local # This repository's own tools, beyond limen's canonical set: yq for the # issue-forms validation (.justfile). diff --git a/.limen/just/lint.just b/.limen/just/lint.just index f141155..da09adb 100644 --- a/.limen/just/lint.just +++ b/.limen/just/lint.just @@ -42,7 +42,7 @@ just: (_banner "lint" "just") # The list goes through a file, never a process substitution: on the # windows-11-arm runners, bash runs emulated, and a `< <(...)` whose child # runs a program intermittently crashes it mid-recipe — exit 4 or 127, no - # output. A pipeline does not. Same in every shared recipe + # output. A pipeline has not been seen to. Same in every shared recipe # (design/WINDOWS-ARM-EXIT-4.md). list=$(mktemp "${TMPDIR:-/tmp}/lint-just.XXXXXX") trap 'rm -f "$list"' EXIT @@ -319,47 +319,143 @@ converge: (_banner "lint" "converge") tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/lint-converge.XXXXXX") trap 'rm -rf "$tmpdir"' EXIT # The declaration, held to what the checksum workflow accepts: one tracked - # regular file under git's own name for it, outside the directories that - # are git's, GitHub's or limen's. + # regular file under git's own name for it, or, ending in a slash, a + # directory that holds tracked files, under git's own name too; either + # outside the directories that are git's, GitHub's or limen's. + # Whether git tracks exactly this name: literal, so a name is no + # pattern, and NUL-ended, so a name git would quote is compared as it is. + tracked_as() { + printf '%s\0' "$1" > "$tmpdir/want" + git --literal-pathspecs ls-files -z -- "$1" > "$tmpdir/got" 2> /dev/null || return 1 + cmp -s "$tmpdir/want" "$tmpdir/got" + } : > "$tmpdir/declared" + : > "$tmpdir/declared-dirs" while IFS= read -r line || [ -n "$line" ]; do path="${line%$'\r'}" case "$path" in '' | '#'*) continue ;; esac - if [ "$(git ls-files -- "$path")" != "$path" ] || [ ! -f "$path" ] || [ -L "$path" ]; then - echo ".converge: $path is not a tracked regular file under that exact name." >&2 - exit 1 - fi case "$path" in - .git/* | .github/* | .limen/* | .hermetic/*) + .git | .git/* | .github | .github/* | .limen | .limen/* | .hermetic | .hermetic/*) echo ".converge: $path is not a path a derived file may have." >&2 exit 1 ;; esac + case "$path" in + */) + # Literal, so a name is no pattern. The first path git lists + # carries the directory's own spelling or the entry was not + # it; a path git refuses outright lists nothing. + git --literal-pathspecs ls-files -z -- "$path" > "$tmpdir/under" 2> /dev/null || : > "$tmpdir/under" + first="" + IFS= read -r -d '' first < "$tmpdir/under" || true + if [ -z "$first" ] || [ "${first#"$path"}" = "$first" ] || [ ! -d "$path" ] || [ -L "${path%/}" ]; then + echo ".converge: $path is not a directory of tracked files under that exact name." >&2 + exit 1 + fi + printf '%s\n' "$path" >> "$tmpdir/declared-dirs" + continue + ;; + esac + if ! tracked_as "$path" || [ ! -f "$path" ] || [ -L "$path" ]; then + echo ".converge: $path is not a tracked regular file under that exact name." >&2 + exit 1 + fi printf '%s\n' "$path" >> "$tmpdir/declared" done < .converge - # The lint observes, never mutates: the declared files are restored as - # they were found on every exit, a failing recipe's included. + under_declared_dir() { + while IFS= read -r dir; do + case "$1" in + "$dir"?*) return 0 ;; + esac + done < "$tmpdir/declared-dirs" + return 1 + } + # The regular files git sees under the declared directories, tracked or + # not, ignored ones aside: what the checksum workflow would carry. + # NUL-separated, a name being anything but that. + listed() { + : > "$1" + while IFS= read -r dir; do + git --literal-pathspecs ls-files -z --cached --others --exclude-standard -- "$dir" > "$tmpdir/raw" + while IFS= read -r -d '' path; do + if [ -f "$path" ] && [ ! -L "$path" ]; then + printf '%s\0' "$path" >> "$1" + fi + done < "$tmpdir/raw" + done < "$tmpdir/declared-dirs" + } + # The lint observes, never mutates: the declared files, and every file + # under a declared directory, are restored as they were found on every + # exit, a failing recipe's included; what the recipe created there goes. mkdir -p "$tmpdir/snapshot" while IFS= read -r path; do mkdir -p "$tmpdir/snapshot/$(dirname "$path")" cp "$path" "$tmpdir/snapshot/$path" done < "$tmpdir/declared" + listed "$tmpdir/dirs-before" + while IFS= read -r -d '' path; do + mkdir -p "$tmpdir/snapshot/${path%/*}" + cp "$path" "$tmpdir/snapshot/$path" + done < "$tmpdir/dirs-before" + # No link stands on the way to a path, or in its place: where the recipe + # left one, at the file or at any directory above it, a removal or a copy + # would go through it, into whatever it points at. No tracked path runs + # through a link, so any that is there is the recipe's. + # shellcheck disable=SC2329 # called from restore + make_way() { + local way="" part + local -a parts + IFS=/ read -r -a parts <<< "$1" + for part in "${parts[@]}"; do + way="${way:+$way/}$part" + if [ -L "$way" ]; then + rm -f "$way" + fi + done + rm -rf "$1" + case "$1" in + */*) mkdir -p "${1%/*}" ;; + esac + } # shellcheck disable=SC2329 # trap-invoked restore() { while IFS= read -r path; do + make_way "$path" cp "$tmpdir/snapshot/$path" "$path" done < "$tmpdir/declared" + listed "$tmpdir/dirs-now" + while IFS= read -r -d '' path; do + if [ ! -f "$tmpdir/snapshot/$path" ]; then + rm -f "$path" + rmdir -p "${path%/*}" 2> /dev/null || true + fi + done < "$tmpdir/dirs-now" + while IFS= read -r -d '' path; do + make_way "$path" + cp "$tmpdir/snapshot/$path" "$path" + done < "$tmpdir/dirs-before" rm -rf "$tmpdir" } trap restore EXIT - git status --porcelain --untracked-files=all > "$tmpdir/before" + # NUL-ended, as the checksum workflow reads it: a name git would quote + # (a space, a non-ASCII letter) is then the name itself. + git status --porcelain -z --untracked-files=all > "$tmpdir/before" + # shellcheck disable=SC2329 # called from the loop below + was_before() { + while IFS= read -r -d '' seen; do + if [ "$seen" = "$1" ]; then + return 0 + fi + done < "$tmpdir/before" + return 1 + } # By name, as every shared recipe calls it: the pinned just, first on the # PATH. Its own path, pasted here unquoted, is backslashes on Windows, # which bash strips. just converge - git status --porcelain --untracked-files=all > "$tmpdir/after" + git status --porcelain -z --untracked-files=all > "$tmpdir/after" failed=0 while IFS= read -r path; do if ! cmp -s "$path" "$tmpdir/snapshot/$path"; then @@ -367,11 +463,39 @@ converge: (_banner "lint" "converge") failed=1 fi done < "$tmpdir/declared" - # What the recipe touched beside the declared files: the status lines - # that were not there before it ran. - while IFS= read -r entry; do + # A declared directory is derived whole: a file changed, a file the + # recipe makes that is not there, a file there the recipe no longer + # makes. + listed "$tmpdir/dirs-after" + while IFS= read -r -d '' path; do + if [ ! -f "$path" ] || [ -L "$path" ]; then + echo "$path is no longer made by 'just converge' — run it and commit the result." >&2 + failed=1 + elif ! cmp -s "$path" "$tmpdir/snapshot/$path"; then + echo "$path is not what 'just converge' makes of this tree — run it and commit the result." >&2 + failed=1 + fi + done < "$tmpdir/dirs-before" + while IFS= read -r -d '' path; do + if [ ! -f "$tmpdir/snapshot/$path" ]; then + echo "$path is made by 'just converge' and is not in this tree — run it and commit the result." >&2 + failed=1 + fi + done < "$tmpdir/dirs-after" + # What the recipe touched beside what is declared: the status lines that + # were not there before it ran. Under a declared directory anything but + # a regular file or a deletion is one too: the checksum workflow carries + # nothing else. + while IFS= read -r -d '' entry; do path="${entry:3}" - if grep -Fxq -- "$entry" "$tmpdir/before" || grep -Fxq -- "$path" "$tmpdir/declared"; then + if was_before "$entry" || grep -Fxq -- "$path" "$tmpdir/declared"; then + continue + fi + if under_declared_dir "$path"; then + if [ -L "$path" ] || { [ -e "$path" ] && [ ! -f "$path" ]; }; then + echo "'just converge' made $path, which is not a regular file: the checksum workflow carries regular files alone." >&2 + failed=1 + fi continue fi echo "'just converge' changed $path, which .converge does not declare: the checksum workflow commits declared files alone." >&2 diff --git a/AGENTS.md b/AGENTS.md index 56975b1..a9cb6f6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -166,16 +166,16 @@ chapter; the procedure is limen's `skills/contribute`. assessment or misreads the code, say so with the evidence and settle it between the two sessions, the reviewer's 🛑 included (the reviewer may miss what the owner knows; the owner may miss the cross-cutting picture). A deadlock goes to the human, as the exception. -- **An issue is work the human has tabled; a defect in another repository is a message.** - A GitHub issue records work the human has decided on and deferred ("table it for - later"), in the repository it belongs to, one per real item, written so its owner can - act on it; never a scratch, `TODO` or notes file, and never an issue for a passing note. - It is not where a session parks what it does not do now: a suggestion that needs a scope - or product decision, a reviewer's 💡 included, is put to the human then and there and - settled in the current change or dropped, never filed to decide later. A defect or a - request in a repository another session owns goes to that session as a message with - what, why and where; that session fixes it, and the human hears about it as a pull - request. +- **An issue is a bug, or work not done on the spot; a question for the human is asked, + never filed.** A bug met on the way, and work that is real and not done now, are logged + as GitHub issues in the repository they belong to, one per real item, written so that + whoever takes it can act on it; never a scratch, `TODO` or notes file. The tracker is not + a scratchpad for what a session wants to ask the human: a question, and a suggestion + that needs a scope or product decision, a reviewer's 💡 included, is put to the human + then and there and settled, never filed to decide later. A defect or a request in a + repository another session owns goes to that session as a message with what, why and + where; that session fixes it, or logs it there when it does not fix it now, and the + human hears about it as a pull request or an issue. ## Code