From 54bdfebd06b3a8033bd5b456be59352ca73a313b Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 8 Nov 2026 19:49:26 +0100 Subject: [PATCH 1/2] fix(memory): partial-stage check sorts and compares in the C locale uutils sort collates by locale while uutils comm expects byte order: comm warned and could miss a dropped partial stage. Both now run with LC_ALL=C. --- lib/memory-commit.sh | 8 +++++--- lib/tests/run-deterministic.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/memory-commit.sh b/lib/memory-commit.sh index 254311c..bae78e3 100755 --- a/lib/memory-commit.sh +++ b/lib/memory-commit.sh @@ -59,9 +59,11 @@ _partial_stages() { read -r mode oid _ < <(git ls-files -s -- "$p") echo "memory-commit: partial stage dropped on: $p (blob $oid;" \ "restore: git update-index --cacheinfo $mode,$oid,$p)" - done < <(comm -12 \ - <(git -c core.quotepath=off diff --cached --name-only -- "$@" | sort) \ - <(git -c core.quotepath=off diff --name-only -- "$@" | sort)) + # C locale for both: a locale sort and a byte-order comm disagree (uutils) + done < <(LC_ALL=C comm -12 \ + <(git -c core.quotepath=off diff --cached --name-only -- "$@" \ + | LC_ALL=C sort) \ + <(git -c core.quotepath=off diff --name-only -- "$@" | LC_ALL=C sort)) } # Surgical commit of the scoped paths only. Returns 0 (ok or no-op), 3 (unsafe). diff --git a/lib/tests/run-deterministic.sh b/lib/tests/run-deterministic.sh index 40c031e..0b83296 100755 --- a/lib/tests/run-deterministic.sh +++ b/lib/tests/run-deterministic.sh @@ -190,6 +190,25 @@ if [ "$rc" -eq 6 ] && [ -z "$staged" ] && [ "$(printf '%s\n' "$err" | grep -cxF if [ "$(printf '%s\n' "$err" | grep -c 'dropped on: .*TODO.md')" -eq 0 ]; then ok "a fully staged file is not listed"; else ko "fully staged TODO.md listed as a dropped partial stage"; fi rm -rf "$d" +echo "== partial stages listed in any locale (sort/comm agree)" +d="$(new_repo)" +printf -- '---\nformat: 2\ntype: decisions_registry\nentry_prefix: BDR\n---\n\n## BDR-001 — kept (2026-10-27)\n- **Status**: accepted\n' \ + > "$d/.claude/memory/decisions.md" +mkdir -p "$d/.claude/tasks/contracts" +printf 'a\n' > "$d/.claude/tasks/TODO.md" +printf 'a\n' > "$d/.claude/tasks/contracts/x.md" +git -C "$d" add -A && git -C "$d" commit -qm v2 +sed 's/kept/edited/' "$d/.claude/memory/decisions.md" > "$d/x.tmp" +cat "$d/x.tmp" > "$d/.claude/memory/decisions.md" +git -C "$d" add .claude/memory/decisions.md +for f in .claude/tasks/TODO.md .claude/tasks/contracts/x.md; do + printf 'b\n' >> "$d/$f"; git -C "$d" add "$f"; printf 'c\n' >> "$d/$f" +done +err="$(cd "$d" && LC_ALL=en_US.UTF-8 bash "$HELPER" commit "chore(memory): locale" 2>&1 >/dev/null)"; rc=$? +n="$(printf '%s\n' "$err" | grep -c 'partial stage dropped on: .claude/tasks/')" +if [ "$rc" -eq 6 ] && [ "$n" -eq 2 ] && ! printf '%s\n' "$err" | grep -q 'sorted order'; then ok "both partial stages named, no sort-order warning (locale vs byte order)"; else ko "rc=$rc n=$n err=[$err]"; fi +rm -rf "$d" + echo printf 'RESULT: %d passed, %d failed\n' "$PASS" "$FAIL" [ "$FAIL" -eq 0 ] From 59a83752c716d33f744e69fbfbe68d715df15642 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 8 Nov 2026 19:51:01 +0100 Subject: [PATCH 2/2] =?UTF-8?q?chore(memory):=20LRN-269=20=E2=80=94=20hotf?= =?UTF-8?q?ix=20comm=20sort=20locale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/memory/journal.md | 1 + .claude/memory/learnings.md | 6 +++++ .../2026-11-08-comm-sort-locale-1947.md | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .claude/tasks/contracts/2026-11-08-comm-sort-locale-1947.md diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 359d4f7..0d5824c 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -705,3 +705,4 @@ rules: ## 2026-11-08 - 2026-11-08: 4d memory feedback built on feature/memory-feedback (8 tasks SDD; plan r1 FATAL(7) → r2 → confirm FATAL(4) → r3; final review I1 locals + I2 per-trigger n; gate 2 hardening x2: checkDir fail-closed, items.json validated, safe repo path). make test green, GATE 0 MET, security PASS 0 findings; live record zenquality cands 11 ms 1408. BDR-140, LRN-267/268. Merged on user signal before GATE 1; live run + verifier after. +- 2026-11-08: /hotfix comm warning: uutils sort locale vs comm byte order in memory-commit _partial_stages; LC_ALL=C both, test red-before (sorted order) then 21/21; security PASS; 54bdfeb. LRN-269. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index 047ac51..f66ff27 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -1990,3 +1990,9 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s - **Pattern**: fixture built from assumption passes its own test → BLOCKERs hide until a challenger reads real data or existing tests. 4d: `-context` toolUseID (real transcripts) and IR11 strict toEqual (existing kit test) both caught only by challenge passes, not by plan TDD. Second: plan "Global Constraints" must copy the user's global limits verbatim; 4d plan dropped "5 locals" → executors complied with the plan, final review flagged I1, extra fix round. - **Context**: feature/memory-feedback 2026-11-06..08: r1 FATAL(7), r2 confirm FATAL(4), final review I1/I2, gate 2 three MEDIUM + one MEDIUM on re-scan. - **Future use**: plan challenge brief asks correctness lens to verify fixture shapes against real data and to grep existing tests asserting changed records; writing-plans Global Constraints = paste CLAUDE.md limits line verbatim. + +## LRN-269 — uutils sort collates by locale, comm expects byte order: pin LC_ALL=C on both (2026-11-08) + +- **Pattern**: uutils coreutils 0.10.0 (Ubuntu 26.04 default `sort`/`comm`): `sort` collates by locale (en_US.UTF-8: `.claude/tasks/contracts/x` before `.claude/tasks/TODO.md`), `comm` expects byte order → `comm: file N is not in sorted order`, rc 1, common lines can be missed. Fix: `LC_ALL=C` on every link (`LC_ALL=C sort` + `LC_ALL=C comm`/`join`). Test discriminates only with `LC_ALL=en_US.UTF-8`; `LC_ALL=''` makes uutils fall back to byte order (bug hidden). +- **Context**: `lib/memory-commit.sh` `_partial_stages`, warning seen on a memory commit; fix 54bdfeb, test in lib/tests/run-deterministic.sh. +- **Future use**: any `sort | comm|join|uniq` pipeline in shell libs: pin C locale on both sides; grep `comm -`/`join -` in review. diff --git a/.claude/tasks/contracts/2026-11-08-comm-sort-locale-1947.md b/.claude/tasks/contracts/2026-11-08-comm-sort-locale-1947.md new file mode 100644 index 0000000..a9a94fa --- /dev/null +++ b/.claude/tasks/contracts/2026-11-08-comm-sort-locale-1947.md @@ -0,0 +1,24 @@ +# CONTRACT — comm-sort-locale +- date: 2026-11-08 | flow: hotfix | branch: bugfix/comm-sort-locale (off develop) +- status: active + +## REQUEST (verbatim — IMMUTABLE) +oui regarde le warning comm + +(context: memory-commit.sh printed "comm: file 2 is not in sorted order" / "comm: input is not in sorted order" on a commit; reproduced: uutils coreutils 0.10.0 sort collates by locale, uutils comm expects byte order.) + +## CLARIFICATIONS + +## ACCEPTANCE CRITERIA +1. _partial_stages sorts and compares in the C locale; no "sorted order" warning; both partial stages listed. + CHECK: cd /home/bchanot/Documents/claude && grep -q 'LC_ALL=C comm' lib/memory-commit.sh && systemd-run --user --scope -q -p TasksMax=256 make test suite=lib/tests/run-deterministic.sh /home/bchanot/.cache/claude-tmp/claude-1000/-home-bchanot-Documents-claude/049658c4-3f30-4849-8ba6-906177262d8a/scratchpad/comm.out 2>&1 && echo C1_GREEN + EXPECT: C1_GREEN + EVIDENCE: MET exit=0 marker-found :: C1_GREEN +2. shellcheck clean. + CHECK: cd /home/bchanot/Documents/claude && shellcheck lib/memory-commit.sh lib/tests/run-deterministic.sh && echo C2_LINT + EXPECT: C2_LINT + EVIDENCE: MET exit=0 marker-found :: C2_LINT + +## FILE SCOPE +- lib/memory-commit.sh +- lib/tests/run-deterministic.sh