diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 4d0207d..26f1d0c 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -676,3 +676,4 @@ rules: ## 2026-10-31 - Phase 4a per-repo pass: 12 repos upgraded to v2 on chore/memory-v2 (game headings demoted, trucks bullet Indexes dropped + BLK-001 resolved, robin BLK-013/015 closures kept); BLK-038 found (upgrade cemented prose false-closed) → /bugfix 2dae528, 3 lenses + confirmation, verifier CONFORME 6/6, security PASS, real-data replay oracle over 13 repos; game/zq redone with user statuses. LRN-244, LRN-245. faunosteo prepared off-repo (V1-2 active). - Step 2 suites: /hotfix 40a993c (absolute ~/.claude/rules paths in interviewer + guardrails) + 7899670 (analyzer memory field dropped), security PASS x2. Measured design hook: 59 fires, 0 web-building Reads (no once-per-session). Probe: Bash sed -n loads path rules like Read. Census blind spots: 0 real citations. +- /feat citers-blind-spots 5bd0de4: census reads nested lib paths, home prefixes, templates/project-rules, citer-aware .claude/rules; 3 lenses + confirmation (0 BLOCKER), verifier ECARTS x1 (SC2088/SC2016 suppressions) → fixtures rewritten, CONFORME, security PASS. /hotfix 3330f0b geo/seo '(dispatcher applies)'. diff --git a/.claude/tasks/contracts/2026-10-31-citers-blind-spots-0100.md b/.claude/tasks/contracts/2026-10-31-citers-blind-spots-0100.md new file mode 100644 index 0000000..5f849d2 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-31-citers-blind-spots-0100.md @@ -0,0 +1,21 @@ +# CONTRACT — citers-blind-spots + +## REQUEST (verbatim — IMMUTABLE) +Close the doctrine-citers census blind spots (TODO phase 1): lib/tests/doctrine-citers.test.sh (1) `_citers_extract_files` regex `(rules|lib)/[a-z0-9-]+\.md` misses nested `lib//x.md § Y` (e.g. lib/project-archetypes/*.md); (2) the real-census FILES list scans `skills agents lib rules hooks` only, not `templates/` nor `.claude/rules/`; (3) a citation of `.claude/rules/.md § X` is read as `rules/.md` (header comment admits it). Measured 2026-10-31: 0 real citations in these spots today, so the fix is preventive; each extension needs a flip-test fixture proving it bites. + +## CLARIFICATIONS +- Plan r2: `.claude/tasks/plans/2026-10-31-citers-blind-spots-0100.md`. T3 keeps its old scan roots; a bare `.claude/rules/` resolves by citer (this repo's .claude/rules → itself; skills/agents/templates → templates/project-rules). `~/.claude/…` and `$HOME/.claude/…` prefixes map to this repo's tree; a bare `.claude/rules/` is a project path. + +## ACCEPTANCE CRITERIA +1. The citers suite is green and holds the new checks T8a-T8h (plan r2); existing T1-T7c unchanged and green. + CHECK: cd /home/bchanot/Documents/claude && out=$(make test suite=lib/tests/doctrine-citers.test.sh 2>&1) && printf '%s\n' "$out" | grep -q 'FAIL=0' && for n in T8a-nested-lib-resolves T8b-nested-lib-dangling T8c-project-rules-resolve T8d-project-rules-not-user-rules T8e-home-prefix-maps-to-repo T8f-scan-lists T8g-left-boundary T8h-template-rules-path; do grep -q "$n" lib/tests/doctrine-citers.test.sh || exit 1; done && echo CITERS-OK + EXPECT: CITERS-OK + EVIDENCE: MET exit=0 marker-found :: CITERS-OK +2. The new checks bite: with the extraction, mapping and scan lists reverted to develop's versions (fixtures kept), T8a/T8b/T8c/T8d/T8f/T8g/T8h fail (the executor reports which); T8e fails against the r3 ERE with the home-prefix alternative removed (its own negative control). Judged by the verifier (the executor reports the negative control). +3. Shellcheck clean, no added line over 80 columns, BSD-portable ERE (no grep -P). + CHECK: cd /home/bchanot/Documents/claude && shellcheck lib/tests/doctrine-citers.test.sh && [ "$(git diff develop -- lib/tests/doctrine-citers.test.sh | grep '^+' | grep -v '^+++' | awk 'length($0) > 81' | wc -l)" = 0 ] && ! git diff develop -- lib/tests/doctrine-citers.test.sh | grep '^+' | grep -q 'grep -P' && echo LINT-OK + EXPECT: LINT-OK + EVIDENCE: MET exit=0 marker-found :: LINT-OK + +## FILE SCOPE +- lib/tests/doctrine-citers.test.sh diff --git a/.claude/tasks/contracts/2026-10-31-dispatcher-applies-0300.md b/.claude/tasks/contracts/2026-10-31-dispatcher-applies-0300.md new file mode 100644 index 0000000..91ce7e2 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-31-dispatcher-applies-0300.md @@ -0,0 +1,18 @@ +# CONTRACT — dispatcher-applies + +## REQUEST (verbatim — IMMUTABLE) +Agent description losses: user pick 2026-10-31 = restore "(dispatcher applies)" on geo-analyzer + seo-analyzer only; the rest closed (bodies keep it). + +## CLARIFICATIONS +none (hotfix autofill) + +## ACCEPTANCE CRITERIA +1. Symptom gone: both descriptions say the fix bundle is applied by the dispatcher; nothing else in the frontmatter changes. + CHECK: cd /home/bchanot/Documents/claude && grep -q '^description: GEO audit agent.*emits a fix bundle (dispatcher applies) and a scored report' agents/geo-analyzer.md && grep -q "^description: 'Classical SEO audit agent.*Emits a fix bundle (dispatcher applies) + scored report" agents/seo-analyzer.md && [ "$(git diff develop -- agents/geo-analyzer.md agents/seo-analyzer.md | grep -c '^[-+][^-+]')" = 4 ] && echo DESC-OK + EXPECT: DESC-OK + EVIDENCE: pending +2. Build/tests green: agent frontmatter / routing suites pass. + +## FILE SCOPE +- agents/geo-analyzer.md +- agents/seo-analyzer.md diff --git a/.claude/tasks/plans/2026-10-31-citers-blind-spots-0100.md b/.claude/tasks/plans/2026-10-31-citers-blind-spots-0100.md new file mode 100644 index 0000000..29e710e --- /dev/null +++ b/.claude/tasks/plans/2026-10-31-citers-blind-spots-0100.md @@ -0,0 +1,109 @@ +# /feat citers-blind-spots — PLAN r2 + +r2 2026-10-31 after 3 lenses: simplicity SOLID (2 MINOR), correctness CONCERNS(3), +robustness CONCERNS(2). No BLOCKER. Changes named in § R2 CHANGES. + +FEAT: doctrine-citers census blind spots — rule 7, 1 file +(lib/tests/doctrine-citers.test.sh), one hoisted path ERE + citer-aware target +mapping + a second scan list for T6 + flip-tests. + +## Facts (2026-10-31, measured by the lenses) +- develop's ERE `(rules|lib)/[a-z0-9-]+\.md` emits no row for a nested + `lib/sub/x.md § Y` (blind, and a missing row reads as "resolves"). +- No left boundary: `templates/project-rules/ci.md § X` is read as + `rules/ci.md`; `foo-rules/x.md` matches from `rules/`. +- Real census FILES (`find skills agents lib rules hooks`) feeds BOTH T3 + (`CLAUDE.md "X"` vs CLAUDE.global.md) and T6 (file citations). + `templates/` (12 .md) and `.claude/rules/` (4 .md) are never scanned. In + those two trees `CLAUDE.md` means a PROJECT CLAUDE.md (templates/project- + CLAUDE.md, templates/project-rules/ci.md:10), so T3 must not see them. +- Bare `.claude/rules/.md` has two meanings: inside this repo's own + `.claude/rules/*` it is this repo; in skills/agents/templates it names the + TARGET project's copy, emitted from `templates/project-rules/.md` + (agents/onboarder.md:135, agents/scaffolder.md:85). +- 5 live home-prefixed citations (agents/interviewer.md:26, agents/commit- + changer.md:220, lib/architecture-defaults.md:49, hooks/design-toolchain- + reminder.sh:78, CLAUDE.global.md:261) resolve today through the suffix and + must keep resolving against this repo (`~/.claude/{rules,lib}` link here). +- 0 real citations in any blind spot today: preventive. + +## Plan +- [ ] One path ERE, hoisted into a variable used by both grep branches of + `_citers_extract_files` (lines ≤ 80 cols, may span two assignments): + left boundary `(^|[^A-Za-z0-9_-])` (captured, dropped by sed), then + `((~|\$[{]?HOME[}]?)/\.claude/|\.claude/)?(templates/project-)?` + `(rules|lib)/([a-z0-9-]+/)*[a-z0-9-]+\.md`. + ONE sed over the `{ branch1; branch2; }` output strips an OPTIONAL + boundary char of class `[^A-Za-z0-9_~$.-]` (absent at column 1: never eat + the path's own first char) and a home prefix (`~/.claude/`, `$HOME/.claude/`, `${HOME}/.claude/`) + → repo-relative target. A bare `.claude/` stays in the target. +- [ ] `citers_check_files`: citer-aware mapping of a bare `.claude/rules/` + target: citer path matches `.claude/rules/*` (or `*/.claude/rules/*`) → + or `rules/*` (rules/README.md cites this repo's own .claude/rules) → keep + `.claude/rules/.md` (resolves against `$root/.claude/rules`); a citer + under skills/ agents/ templates/ lib/ hooks/ or CLAUDE.global.md → + `templates/project-rules/.md`. A bare `.claude/lib/` + stays as is (resolves against `$root/.claude/lib`, absent → DANGLING). +- [ ] Scan lists: `FILES` (T3) unchanged roots `skills agents lib rules hooks`; + new `FILES_ALL` = FILES roots + `templates` + `.claude/rules` (same name + filter and excludes, find roots on a continuation line) feeds T6. +- [ ] Header comment: lines 2-3 (scope list), 11-13, 59-63 (drop "would be + read as rules/.md"): nested dirs, home prefixes, the citer-aware + `.claude/rules/` rule, `templates/project-rules/`, T3 vs T6 lists; an + absolute `/home//…` path is unsupported (resolved as a bare + `.claude/…` or suffix). +- [ ] Fixtures (in the `$FIX` block, before the real census), check names: + T8a-nested-lib-resolves: `_citers_extract_files` on `lib/sub/x.md § Alpha` + emits exactly one `:lib/sub/x.md:Alpha` row AND citers_check_files rc 0 + with `$FIX/lib/sub/x.md` holding `## Alpha`. + T8b-nested-lib-dangling: `lib/sub/x.md § Beta` → rc 1, culprit named. + T8c-project-rules-resolve: a citer at `$FIX/.claude/rules/c.md` citing + `.claude/rules/p.md § Gamma`, `$FIX/.claude/rules/p.md` holds `## Gamma`, + no `$FIX/rules/p.md` → rc 0. + T8d-project-rules-not-user-rules: a skill-side citer (`$FIX/s.md`) citing + `.claude/rules/q.md § Delta`: rc 0 when `$FIX/templates/project-rules/ + q.md` holds `## Delta`; rc 1 when only `$FIX/rules/q.md` and + `$FIX/.claude/rules/q.md` hold it. + T8e-home-prefix-maps-to-repo: `~/.claude/rules/api.md § Versioning`, + `${HOME}/.claude/lib/cc.md § WRITE`, and quoted + `$HOME/.claude/lib/cc.md § "WRITE (before the commit)"` → rc 0 + (`# shellcheck disable=SC2016` on the single-quoted printf). Includes + column-1 lines (`~/.claude/…`, `$HOME/.claude/…`). T8e is a guard of + the new code, NOT a flip-test vs develop (develop resolves these by + suffix): its negative control = the r3 ERE without the home + alternative → the targets go bare `.claude/…` → DANGLING. + T8c also carries a column-1 `.claude/rules/p.md § Gamma` line. + T8g-left-boundary: `foo-rules/api.md § Versioning` → no row extracted. + T8h-template-rules-path: `templates/project-rules/t.md § Eps` resolves + against `$FIX/templates/project-rules/t.md` → rc 0; with a wrong label + → rc 1. + T8f-scan-lists (placed right after the mapfiles): FILES_ALL holds ≥1 + `templates/` and ≥1 `.claude/rules/` path; FILES holds none. +- [ ] T3 runs on FILES, T6 on FILES_ALL + CLAUDE.global.md; T4-T7c unchanged. + +## Edge cases +- grep -o is leftmost: a home or `templates/project-` prefix is captured + whole when present. +- `$HOME` / `${HOME}` are literal text in the scanned sources. +- BSD-safe ERE, `/usr/bin/grep` pinned, no grep -P, no lookbehind. + +## R2 CHANGES +- ERE hoisted once, nested prefix, left boundary, `${HOME}`, `templates/ + project-` (simplicity 1, correctness 4/8, robustness 3/4). +- Citer-aware `.claude/rules/` mapping (correctness 2, robustness 1; + simplicity 2 documents it). +- T3 keeps the old roots, T6 gets FILES_ALL (correctness 3, robustness 2). +- T8a asserts the extracted row (correctness 1); T8e quoted + `${HOME}` + (robustness 5); T8g, T8h added; T8f after mapfile (correctness 6); header + lines 2-3 (correctness 7); live count 5 (correctness 5). + +## R3 CHANGES (confirmation correctness CONCERNS(1), folded, no 3rd pass) +- T8e reclassified: guard of the new code, own negative control (C1). +- Boundary strip optional and excludes `~ $ .`; column-1 fixtures (C2). +- Citers under rules/ map bare `.claude/rules/` to this repo (C3). +- `\$[{]?HOME[}]?` instead of `\$\{?HOME\}?` (C4). + +## Disposition +Honors BDR-100 (the census is the mechanism) and LRN-096 (each extension has +a flip-test that fails on develop's extractor: T8a row assert, T8b, T8c, T8d, +T8g, T8h, T8f; T8e guards the new home mapping with its own negative control). diff --git a/CHANGELOG.md b/CHANGELOG.md index 273c13a..a996708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - `.gitignore` and `templates/gitignore/standard.gitignore` un-ignore `.claude/rules/` (`!.claude/rules/` after `.claude/*`); `lib/gitflow-test.sh` asserts the socle line. - Context diet (BDR-125 phase 1): `CLAUDE.global.md` keeps one always-on line for the architecture defaults and points to `lib/architecture-defaults.md`. Design work moves to `rules/web-building.md` § "Design work — full toolchain", and `hooks/design-toolchain-reminder.sh` now tells the model to Read it and no longer fires on `/` paths, `~/.claude/` and `$HOME/.claude/` prefixes (mapped to this repo) and `templates/project-rules/`; a bare `.claude/rules/` citation resolves by citer (this repo's own rules from `.claude/rules/` or `rules/`, else `templates/project-rules/`); T6 also scans `templates/` and `.claude/rules/`, T3 keeps its roots. ### Removed - `rules/default-language.md`: its content is `lib/architecture-defaults.md` § Default language. diff --git a/agents/geo-analyzer.md b/agents/geo-analyzer.md index c4d84f0..1405750 100644 --- a/agents/geo-analyzer.md +++ b/agents/geo-analyzer.md @@ -1,6 +1,6 @@ --- name: geo-analyzer -description: GEO audit agent for AI search engines, dispatched by /geo and /seo. AI crawlers, llms.txt, entity signals, Schema.org; emits a fix bundle and a scored report. Classical SEO → seo-analyzer. +description: GEO audit agent for AI search engines, dispatched by /geo and /seo. AI crawlers, llms.txt, entity signals, Schema.org; emits a fix bundle (dispatcher applies) and a scored report. Classical SEO → seo-analyzer. tools: Read, Edit, Write, Bash, Grep, Glob, WebFetch, WebSearch model: opus effort: xhigh diff --git a/agents/seo-analyzer.md b/agents/seo-analyzer.md index 0281e93..460d2bb 100644 --- a/agents/seo-analyzer.md +++ b/agents/seo-analyzer.md @@ -1,6 +1,6 @@ --- name: seo-analyzer -description: 'Classical SEO audit agent (Google, Bing), dispatched from /seo: Core Web Vitals, on-page, technical, local SEO, legal (FR). Emits a fix bundle + scored report. AI/GEO → geo-analyzer.' +description: 'Classical SEO audit agent (Google, Bing), dispatched from /seo: Core Web Vitals, on-page, technical, local SEO, legal (FR). Emits a fix bundle (dispatcher applies) + scored report. AI/GEO → geo-analyzer.' tools: Read, Edit, Write, Bash, Grep, Glob, WebFetch, WebSearch model: opus effort: xhigh diff --git a/lib/tests/doctrine-citers.test.sh b/lib/tests/doctrine-citers.test.sh index 7ed785b..4bacae2 100644 --- a/lib/tests/doctrine-citers.test.sh +++ b/lib/tests/doctrine-citers.test.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash # lib/tests/doctrine-citers.test.sh — every citation of a CLAUDE.global.md -# section or bold label from skills/agents/lib/rules/hooks must resolve -# (BDR-100). Born from the 2026-09-24 density pass: a bold label was reworded -# and five skills kept pointing at "§ Language" for a day. A flip-test proves +# section or bold label from skills/agents/lib/rules/hooks (file citations +# also from templates/ and .claude/rules/) must resolve (BDR-100). Born from +# the 2026-09-24 density pass: a bold label was reworded and five skills kept +# pointing at "§ Language" for a day. A flip-test proves # the checker bites before the real census runs (LRN-096). # # Only citations that NAME the doctrine count: `CLAUDE.md "Section"` and @@ -10,7 +11,7 @@ # skill's own sections and are out of scope. # Since BDR-125 phase 1 doctrine also lives in rules/ and lib/: a # `rules/.md § Label` / `lib/.md § Label` citation resolves against -# that file (T4-T6). +# that file (T4-T6), nested dirs and `~/.claude/` prefixes included. set -u ROOT="$(cd "$(dirname "$0")/../.." && pwd)" pass=0; fail=0 @@ -55,26 +56,51 @@ citers_check() { # _citers_extract_files … → "file:line:target:name" per citation of a # heading in another doctrine file: `rules/.md § Label` or -# `lib/.md § Label`, backticks around the path and quotes around the -# label allowed. A quoted label runs to its closing quote (`—` included); an -# unquoted one ends at the first character that is not a letter, space or -# hyphen: quote a label that prose follows. A citation of -# `.claude/rules/.md § X` would be read as `rules/.md` (none exist; -# ERE has no lookbehind and the portability census bans grep -P). +# `lib/.md § Label` (nested dirs allowed: `lib//.md`), backticks +# around the path and quotes around the label allowed. A quoted label runs to +# its closing quote (`—` included); an unquoted one ends at the first +# character that is not a letter, space or hyphen: quote a label that prose +# follows. The path needs a left boundary (`foo-rules/x.md` is not +# `rules/x.md`). A `~/.claude/`, `$HOME/.claude/` or `${HOME}/.claude/` prefix +# maps to this repo's tree and is dropped from the target; a bare +# `.claude/` stays (see citers_check_files); `templates/project-rules/.md` +# is its own target. An absolute `/home//…` path is unsupported (read as +# a bare `.claude/…` or by its suffix). +CITE_PATH='(^|[^A-Za-z0-9_-])((~|\$[{]?HOME[}]?)/\.claude/|\.claude/)?' +CITE_PATH+='(templates/project-)?(rules|lib)/([a-z0-9-]+/)*[a-z0-9-]+\.md' +# Strip: optional boundary char (absent at column 1, never `~ $ .`) and the +# home prefix. +CITE_STRIP='s/^([^:]+:[0-9]+):[^A-Za-z0-9_~$.-]?' +CITE_STRIP+='((~|\$[{]?HOME[}]?)\/\.claude\/)?(.*\.md)`? § ?' _citers_extract_files() { - /usr/bin/grep -nHoE '(rules|lib)/[a-z0-9-]+\.md`? § ?"[^"]{2,60}"' "$@" 2>/dev/null \ - | sed -E 's/^([^:]+:[0-9]+):(.*\.md)`? § ?"([^"]+)"$/\1:\2:\3/' - /usr/bin/grep -nHoE '(rules|lib)/[a-z0-9-]+\.md`? § ?[A-Z][A-Za-z][A-Za-z -]{1,40}' "$@" 2>/dev/null \ - | sed -E 's/^([^:]+:[0-9]+):(.*\.md)`? § ?(.*)$/\1:\2:\3/; s/[[:space:]]+$//' + { + /usr/bin/grep -nHoE "$CITE_PATH"'`? § ?"[^"]{2,60}"' "$@" 2>/dev/null + /usr/bin/grep -nHoE "$CITE_PATH"'`? § ?[A-Z][A-Za-z][A-Za-z -]{1,40}' \ + "$@" 2>/dev/null + } | sed -E \ + -e "$CITE_STRIP"'"([^"]+)"$/\1:\4:\5/' \ + -e t \ + -e "$CITE_STRIP"'(.*)$/\1:\4:\5/' \ + -e 's/[[:space:]]+$//' } # citers_check_files … → DANGLING lines; rc = their count (capped 99) +# A bare `.claude/rules/.md` is a project path: cited from this repo's own +# rules (`.claude/rules/*`, `rules/*`) it is this repo's file, from anywhere +# else (skills, agents, templates…) it names the copy emitted from +# `templates/project-rules/.md`. citers_check_files() { local root="$1" line file lno target name n=0; shift while IFS= read -r line; do [ -n "$line" ] || continue file="${line%%:*}"; lno="$(printf '%s' "$line" | cut -d: -f2)" target="$(printf '%s' "$line" | cut -d: -f3)"; name="${line#*:*:*:}" + case "$target:$file" in + .claude/rules/*:.claude/rules/*|.claude/rules/*:*/.claude/rules/*|\ + .claude/rules/*:rules/*) ;; + .claude/rules/*:*) + target="templates/project-rules/${target#.claude/rules/}" ;; + esac if [ ! -f "$root/$target" ] || ! _citers_resolve "$root/$target" "$name"; then echo "DANGLING: $file:$lno → $target § \"$name\""; n=$((n+1)) fi @@ -114,14 +140,74 @@ check T5d-quoted-label-whole "$(printf '%s\n' "$out" | grep -c 'full kit')" 1 check T5b-missing-file-named "$(printf '%s\n' "$out" | grep -c 'rules/none.md')" 1 check T5c-prefix-not-a-heading "$(printf '%s\n' "$out" | grep -c '"Version"')" 1 +# T8a-T8h: blind spots of the file-citation census (nested dirs, project +# rules, home prefixes, left boundary, templates) +mkdir -p "$FIX/lib/sub" "$FIX/.claude/rules" "$FIX/templates/project-rules" +printf '## Alpha\n' > "$FIX/lib/sub/x.md" +printf 'nested: lib/sub/x.md § Alpha\n' > "$FIX/n1.md" +rows=$(_citers_extract_files "$FIX/n1.md") +citers_check_files "$FIX" "$FIX/n1.md" >/dev/null +check T8a-nested-lib-resolves "$rows|$?" "$FIX/n1.md:1:lib/sub/x.md:Alpha|0" +printf 'nested: lib/sub/x.md § Beta\n' > "$FIX/n2.md" +out=$(citers_check_files "$FIX" "$FIX/n2.md"); rc=$? +hits=$(printf '%s\n' "$out" | grep -c 'lib/sub/x.md') +check T8b-nested-lib-dangling "$rc|$hits" "1|1" +printf '## Gamma\n' > "$FIX/.claude/rules/p.md" +printf '.claude/rules/p.md § Gamma\nalso .claude/rules/p.md § Gamma.\n' \ + > "$FIX/.claude/rules/c.md" +citers_check_files "$FIX" "$FIX/.claude/rules/c.md" >/dev/null +check T8c-project-rules-resolve "$?" 0 +printf 'skill: .claude/rules/q.md § Delta.\n' > "$FIX/s.md" +printf '## Delta\n' > "$FIX/templates/project-rules/q.md" +citers_check_files "$FIX" "$FIX/s.md" >/dev/null; rc1=$? +rm "$FIX/templates/project-rules/q.md" +printf '## Delta\n' > "$FIX/rules/q.md" +printf '## Delta\n' > "$FIX/.claude/rules/q.md" +citers_check_files "$FIX" "$FIX/s.md" >/dev/null +check T8d-project-rules-not-user-rules "$rc1|$?" "0|1" +{ + printf '%s/.claude/rules/api.md § Versioning.\n' '~' + printf '%s/.claude/lib/cc.md § WRITE.\n' "\$HOME" + printf 'tilde: %s/.claude/rules/api.md § Versioning.\n' '~' + printf 'braces: %s/.claude/lib/cc.md § WRITE.\n' "\${HOME}" + printf 'quoted: %s/.claude/lib/cc.md § "WRITE (before the commit)".\n' \ + "\$HOME" +} > "$FIX/h.md" +rows=$(_citers_extract_files "$FIX/h.md" | wc -l) +citers_check_files "$FIX" "$FIX/h.md" >/dev/null +check T8e-home-prefix-maps-to-repo "$rows|$?" "5|0" +printf 'prose: foo-rules/api.md § Versioning\n' > "$FIX/b.md" +check T8g-left-boundary "$(_citers_extract_files "$FIX/b.md")" "" +printf '## Eps\n' > "$FIX/templates/project-rules/t.md" +printf 'tpl: templates/project-rules/t.md § Eps.\n' > "$FIX/t1.md" +printf 'tpl: templates/project-rules/t.md § Zeta.\n' > "$FIX/t2.md" +citers_check_files "$FIX" "$FIX/t1.md" >/dev/null; rc1=$? +citers_check_files "$FIX" "$FIX/t2.md" >/dev/null +check T8h-template-rules-path "$rc1|$?" "0|1" + # ── real census: the repo's own citers against CLAUDE.global.md ────────────── mapfile -t FILES < <(cd "$ROOT" && find skills agents lib rules hooks -type f \( -name '*.md' -o -name '*.sh' \) \ -not -path 'skills/graphify/*' -not -path 'skills/impeccable/*' -not -path 'skills/synced/*' \ -not -path 'agents/impeccable-*' -not -path 'lib/tests/*' | sort) +# T6 also scans the templates and this repo's own project rules; T3 must not +# (there `CLAUDE.md` means a project CLAUDE.md, not the doctrine). +mapfile -t FILES_ALL < <(cd "$ROOT" && find skills agents lib rules hooks \ + templates .claude/rules -type f \( -name '*.md' -o -name '*.sh' \) \ + -not -path 'skills/graphify/*' -not -path 'skills/impeccable/*' \ + -not -path 'skills/synced/*' -not -path 'agents/impeccable-*' \ + -not -path 'lib/tests/*' | sort) +# T8f: the T6 list reaches the two blind trees, the T3 list does not +all_hits=$(printf '%s\n' "${FILES_ALL[@]}" | grep -c '^templates/') +rules_hits=$(printf '%s\n' "${FILES_ALL[@]}" | grep -c '^\.claude/rules/') +t3_hits=$(printf '%s\n' "${FILES[@]}" \ + | grep -c -e '^templates/' -e '^\.claude/') +check T8f-scan-lists "$([ "$all_hits" -ge 1 ] && [ "$rules_hits" -ge 1 ] \ + && [ "$t3_hits" -eq 0 ] && echo ok)" ok out=$(cd "$ROOT" && citers_check CLAUDE.global.md "${FILES[@]}"); rc=$? [ -n "$out" ] && printf '%s\n' "$out" check T3-repo-citations-resolve "$rc" 0 -out=$(cd "$ROOT" && citers_check_files "$ROOT" "${FILES[@]}" CLAUDE.global.md); rc=$? +out=$(cd "$ROOT" && citers_check_files "$ROOT" "${FILES_ALL[@]}" \ + CLAUDE.global.md); rc=$? [ -n "$out" ] && printf '%s\n' "$out" check T6-repo-file-citations-resolve "$rc" 0 # T7: the real citers bite — the same two files against a copy of