From 2fb9a2f4c1676ba525084de28dd1ce19437e10f5 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 16:22:39 +0100 Subject: [PATCH 1/3] fix(pack-census): fixed-string retired match, fragment top-level key allowlist grep -qxF on gstack-removed.list; a fragment carrying a top-level key other than enabledPlugins, deniedMcpServers, disableClaudeAiConnectors or model is RED. T13-unknown-key. --- lib/gstack-removed.list | 2 +- lib/pack-census-fragments.jq | 8 +++++++- lib/pack-census.sh | 5 +++-- lib/tests/pack-census.test.sh | 5 +++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/gstack-removed.list b/lib/gstack-removed.list index 3a49d3a..922f94a 100644 --- a/lib/gstack-removed.list +++ b/lib/gstack-removed.list @@ -1,5 +1,5 @@ # The gstack skills this config never exposes: one name per line, read by -# lib/pack-census.sh (grep -qx), so these comment lines never match. +# lib/pack-census.sh (grep -qxF), so these comment lines never match. # A name listed is in no pack and no profile, `max` included. Pruned # 2026-09-28 (BDR-105); the helpers once housed in lib/gstack-removed.sh # are gone with the symlink toggling (BDR-117). diff --git a/lib/pack-census-fragments.jq b/lib/pack-census-fragments.jq index d079b1d..6b2248d 100644 --- a/lib/pack-census-fragments.jq +++ b/lib/pack-census-fragments.jq @@ -1,6 +1,7 @@ # lib/pack-census-fragments.jq — fragment invariants (lib/pack-census.sh). # $m = manifests [{id,on}]; inputs = lib/profiles/*.json. Prints RED lines, -# and WARN lines for a pack id with no manifest. +# and WARN lines for a pack id with no manifest. A fragment may carry only +# the top-level keys lib/profile.sh reads (an allowlist). def name_of: input_filename | sub(".*/"; ""); def dn: [(.deniedMcpServers // [])[] | .serverName] | sort; [inputs | {f: name_of, frag: .}] as $all @@ -17,6 +18,11 @@ def dn: [(.deniedMcpServers // [])[] | .serverName] | sort; | ( if ($g.enabledPlugins | keys) != $keys then "RED lib/profiles/\($f): key set differs from full.json" else empty end ), + ( ($g | keys) + - ["enabledPlugins", "deniedMcpServers", "disableClaudeAiConnectors", + "model"] + | select(length > 0) + | "RED lib/profiles/\($f): unknown top-level key(s) \(join(", "))" ), ( ["model-router@skills-dir", "security-guidance@claude-code-plugins"][] | select($g.enabledPlugins[.] != true) | "RED lib/profiles/\($f): \(.) must be true" ), diff --git a/lib/pack-census.sh b/lib/pack-census.sh index ec3df47..b9ae5dd 100755 --- a/lib/pack-census.sh +++ b/lib/pack-census.sh @@ -9,7 +9,8 @@ # 1. manifest parses, name = folder; every entry resolves (dangling = # WARN; RED with --installed on a pack ON by manifest); no skill both # flat and in a pack; no retired gstack name (lib/gstack-removed.list). -# 2. fragments lib/profiles/*.json: same key set as full.json; model-router +# 2. fragments lib/profiles/*.json: same key set as full.json, only the +# top-level keys profile.sh reads (allowlist); model-router # + security-guidance true, example-skills + brightdata false # everywhere; full.json packs = manifest defaults. # 3. no reader of the old layout left (scope and terms in check_citers). @@ -62,7 +63,7 @@ check_entry() { # $1 pack dir, $2 entry path red "$n: $s target missing (pack ON)" else echo "WARN $n: $s target missing (installer not run)"; fi fi - [ -f "$REMOVED" ] && grep -qx -- "$s" "$REMOVED" \ + [ -f "$REMOVED" ] && grep -qxF -- "$s" "$REMOVED" \ && red "$n: $s is a retired gstack skill" if [ -n "${seen[$s]:-}" ]; then red "$s listed twice: ${seen[$s]} and $n; run: $(dup_remedy "$s")" diff --git a/lib/tests/pack-census.test.sh b/lib/tests/pack-census.test.sh index 27e3c49..5b6f5d0 100755 --- a/lib/tests/pack-census.test.sh +++ b/lib/tests/pack-census.test.sh @@ -104,6 +104,11 @@ jq '. + {deniedMcpServers: [{serverName: "claude.ai Fictional"}]}' "$FX/lib/prof out="$(census)" check T13-deny-differs "$(grep -c 'zdev.json are identical fragments' <<<"$out")" 0 rm "$FX/lib/profiles/zdev.json" +jq '. + {bogusKey: 1, model: "sonnet"}' "$FX/lib/profiles/dev.json" > "$FX/lib/profiles/zdev.json" +out="$(census)"; rc=$? +check T13-unknown-key-rc "$rc" 1 +check_has T13-unknown-key "$out" "RED lib/profiles/zdev.json: unknown top-level key(s) bogusKey" +rm "$FX/lib/profiles/zdev.json" sed 's/pack-beta@skills-dir": false/pack-beta@skills-dir": false, "pack-ghost@skills-dir": false/' "$FX/lib/profiles/dev.json" > "$FX/lib/profiles/ghost.json" out="$(census)"; rc=$? check_has T14-ghost "$out" "WARN lib/profiles/ghost.json: names pack-ghost with no skills/pack-ghost/" From 061a7cbe6100c276d7599895cf3bf13791c150e6 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 16:23:36 +0100 Subject: [PATCH 2/3] docs: pack-census fragment key allowlist (profiles README, CHANGELOG) --- CHANGELOG.md | 1 + lib/profiles/README.md | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a09b33..a3ef3cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - `cc [profile]` (lib/cc.sh) raises the session's `oom_score_adj` to 500 before `exec claude` (raise-only, silent if the write fails). sshd's systemd override `OOMScoreAdjust=-1000` was inherited through tmux and dtach by every claude started with `cc`, so the OOM killer never picked a runaway session; `systemd-run --scope` rejects that property, hence the write inside the session (BLK-044). Test: `lib/tests/cc.test.sh` T7-oom. - `lib/project-rules.sh` (`extract`, `emit`): the out-path check resolves the rule file's first existing parent physically and refuses (rc 2, `must stay under the project`) a path a symlinked component sends outside the project; 3.0.0 checked `..` lexically only. `emit` goes through the same check and reports `cannot create` or `not written` (no partial file) with rc 2 where it printed `emitted`. An `extract` that wrote the rule but fails to rewrite CLAUDE.md keeps the rule file and the rewritten text in a temp file and names both on stderr with the command to complete or abort; it used to delete both. `/onboard` and `/init-project` keep an existing rule on an rc 2 ending in ` exists` and stop on any other rc 2. Tests: `lib/tests/project-rules.test.sh` T9h (re-asserted), T9z3 to T9z13. - `lib/memory.sh`: `memory_legacy_status` (the v1 status reader behind `memory.sh upgrade`, `/reconcile`, `/prune-memory`) ends an entry's range at the next heading of another entry of the same prefix, any level, outside a code fence, or at `## Index`: a `### BLK-` entry no longer lends its status to the `## BLK-` entry above, and a trailing `## Index` is no longer read. `memory.sh upgrade` on an entry with no strict status word writes the single word of its v1 `Status`/`Statut` label as the dated upgrade status line; when the `## Index` cell disagrees the body word wins and stderr says `kept body , dropped Index ` (the Index used to win); an Index `superseded`/`deprecated` still wins; a label without exactly one word is refused on a blocker and leaves the Index cell on a decision. Control characters from a v1 line or an Index cell print as `?`. `memory.sh journal` leaves exactly one blank line before a new date heading (a file ending with a blank line got two, one without a final newline got none). Tests: `lib/tests/memory.test.sh` T14l-gap, T15-statut-*, T15-bdr-*, T15-idx-*, T15-ctl-*, T15-trailing-index-not-read. +- `lib/pack-census.sh`: the retired gstack skill check matches `lib/gstack-removed.list` as fixed strings (`grep -qxF`); a pack entry name used to be read as a regex. A profile fragment carrying a top-level key other than `enabledPlugins`, `deniedMcpServers`, `disableClaudeAiConnectors` or `model` is now RED (`unknown top-level key(s) `) in `lib/pack-census-fragments.jq`. Test: `lib/tests/pack-census.test.sh` T13-unknown-key. ## [3.0.0] — 2026-11-12 diff --git a/lib/profiles/README.md b/lib/profiles/README.md index 34fd1dd..d479d4b 100644 --- a/lib/profiles/README.md +++ b/lib/profiles/README.md @@ -23,8 +23,9 @@ defaults = `full`. - **audit**: seo, web-validate, gstack-dev, gstack-browser, pr-review-toolkit; read-mostly audits. Invariants (checked by `lib/pack-census.sh`): the same key set in every -fragment; `model-router@skills-dir` and `security-guidance@claude-code-plugins` -true everywhere; `example-skills@anthropic-agent-skills` and -`brightdata-plugin@synced` false everywhere; `full` equal to the manifest -defaults. +fragment; no top-level key other than `enabledPlugins`, `deniedMcpServers`, +`disableClaudeAiConnectors` and `model`; `model-router@skills-dir` and +`security-guidance@claude-code-plugins` true everywhere; +`example-skills@anthropic-agent-skills` and `brightdata-plugin@synced` false +everywhere; `full` equal to the manifest defaults. Add your own profile as another `.json` with the same key set. From c782237d7edb1d89dc217d1d4a666c534cd7132a Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 16:23:37 +0100 Subject: [PATCH 3/3] chore(memory): H3 journal, phase 5 line closed --- .claude/memory/journal.md | 1 + .claude/tasks/TODO.md | 3 +- .../2026-11-13-pack-census-followups-1500.md | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .claude/tasks/contracts/2026-11-13-pack-census-followups-1500.md diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 0d465eb..880b883 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -740,3 +740,4 @@ rules: - /bugfix project-rules-residuals (block H1, phase 0 leftovers): emit via _rules_out_path_ok + write guard, extract keeps tmp+out on rewrite failure, physical parent check (9d5530a, T9h + T9z3-z13, docs cd90080). 3 lenses: BLOCKER silent refusal on a file parent (T9w2), MAJOR section's last copy deleted by r1; callers onboarder/scaffolder stop on rc 2 ≠ exists. LRN-286. - /bugfix memory-sh-residuals (block H2, phase 4a + BUGS-FOUND memory.sh): one awk legacy reader (positional selector, prefix-derived end, ## Index stop, path-safe), one effective status for upgrade (strict else v1 label, written as dated line), control chars → ?, journal one blank line (d8e62c1, +30 checks, docs 5e7a267 incl. MIGRATION --body-file note). r1 (e) would have reopened resolved blockers: 3 lenses + confirmation. LRN-287; BLK-038 resolved. - /bugfix memory-sh-residuals (block H2, phase 4a + BUGS-FOUND memory.sh): one awk legacy reader (positional selector, prefix-derived end, ## Index stop, path-safe), one effective status for upgrade (strict else v1 label, written as dated line), control chars → ?, journal one blank line (d8e62c1, +30 checks, docs 5e7a267 incl. MIGRATION --body-file note). r1 (e) would have reopened resolved blockers: 3 lenses + confirmation. LRN-287; BLK-038 resolved. +- /bugfix pack-census-followups (block H3, phase 5 leftovers): grep -qxF on gstack-removed.list, fragment top-level key allowlist (enabledPlugins, deniedMcpServers, disableClaudeAiConnectors, model; GATE 1 caught model missing from my clarification), T13-unknown-key (2fb9a2f, docs). CAPITALIZE: trivial, no BLK/LRN. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index d0c681f..82b172e 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -55,8 +55,7 @@ Open children of the shipped phases (History 2026-11-12), text verbatim. - Phase 0 / 0b leftovers: done 2026-11-13 (block H1, bugfix/project-rules-residuals 9d5530a, LRN-286): emit via `_rules_out_path_ok` + mkdir/write rc, extract keeps `$tmp` and `$out` on a rewrite failure, physical parent check (`cd -P`, `pwd -P`). - Phase 4a leftovers: done 2026-11-13. faunosteo upgraded in block F (chore/memory-v2 530af1b, user merges); BLK-038 residuals closed in block H2 (bugfix/memory-sh-residuals d8e62c1: stderr `?` for control chars, fixtures for the upgrade messages, journal one blank line; the real-data replay oracle is replaced by the fixture suite, its scratchpad script is gone); MIGRATION.md `--body-file` absolute-path note added (5e7a267). Remaining raw sinks, not phase-tied: reconcile.sh:141 stdout `${st:0:80}`, `check` "heading shape" line. - Phase 1 leftovers: done 2026-11-13 in block E (E1 design hook deleted, BDR-148; E2 Skill routing lines → descriptions, BDR-149). -- Phase 5 leftovers: - - [ ] Follow-ups: `lib/pack-census.sh:67` `grep -qx` → `grep -qxF`; fragment top-level key allowlist in `lib/pack-census-fragments.jq` (today only `enabledPlugins` keys are compared). Done 2026-11-02: MIGRATION step 2 `$root` re-derivation + autostash-conflict note (0463583, 9cd9591). +- Phase 5 leftovers: done 2026-11-13 (block H3, bugfix/pack-census-followups 2fb9a2f): `grep -qxF`, fragment top-level key allowlist (four keys profile.sh reads). - Phase 2 leftovers: - [ ] Phase 2 residuals (stated 2026-11-02): Bash write forms are outside the routing guard (the harness auto-mode "prefer Bash" path); a register.ts reload resets the skill latch; `.claude/worktrees/` writes are code; code-limits state dirs stay in TMPDIR; not caught by a static rule: `… | bash -s`, a sourced `gitflow_finish`, `git -C merge` (soft_deny prose only). - [ ] Phase 2 security gate follow-ups (2026-11-02, non-blocking): MEDIUM `rtk read -n .env` / `rtk read a.txt .env` typed directly pass every static deny (rc 3 → passthrough, no rule) → bench `Bash(rtk read * .env*)`, `Bash(rtk read * */.env*)` + `*/rtk` twins and teach phase2.jq the `* ` shape; LOW code-limits state dir (`mkdir -m 700`, owner check); LOW awk evasions (`system (`, `awk -f`, `gawk`/`mawk`); LOW pre-existing `cat x.key` (no dir prefix) parity gap; doctor.sh:255 jq message should name code-limits and push-guard. MEDIUM rtk read part done 2026-11-06 97c6afc (2 rules, bench R3-R7, LRN-266); the LOWs stay open. diff --git a/.claude/tasks/contracts/2026-11-13-pack-census-followups-1500.md b/.claude/tasks/contracts/2026-11-13-pack-census-followups-1500.md new file mode 100644 index 0000000..4668cce --- /dev/null +++ b/.claude/tasks/contracts/2026-11-13-pack-census-followups-1500.md @@ -0,0 +1,30 @@ +# CONTRACT — pack-census-followups (phase 5 leftovers, block H3) +- date: 2026-11-13 | flow: bugfix | branch: bugfix/pack-census-followups (off develop) +- status: active + +## REQUEST (verbatim — IMMUTABLE) +Follow-ups: `lib/pack-census.sh:67` `grep -qx` → `grep -qxF`; fragment top-level key allowlist in `lib/pack-census-fragments.jq` (today only `enabledPlugins` keys are compared). + +## CLARIFICATIONS +- [gated 2026-11-13, internal; amended after GATE 1: `model` is a documented fragment key, profile.sh:182/216/226, profiles/README.md:5-6] allowlist = the keys lib/profile.sh reads: `enabledPlugins`, `deniedMcpServers`, `disableClaudeAiConnectors`, `model`; any other top-level key → `RED lib/profiles/: unknown top-level key(s) `. + +## ACCEPTANCE CRITERIA +1. Fixed-string match on the retired list. + CHECK: cd /home/bchanot/Documents/claude && echo $(grep -c 'grep -qxF -- "\$s" "\$REMOVED"' lib/pack-census.sh)$(grep -c 'grep -qx -- ' lib/pack-census.sh) + EXPECT: 10 + EVIDENCE: MET exit=0 marker-found :: 10 +2. Unknown top-level key is RED; the four known keys (incl. `model`) pass. + CHECK: cd /home/bchanot/Documents/claude && echo $(grep -c 'unknown top-level key' lib/pack-census-fragments.jq lib/tests/pack-census.test.sh | grep -c ':[1-9]')$(grep -c '"model"' lib/pack-census-fragments.jq) + EXPECT: 21 + EVIDENCE: MET exit=0 marker-found :: 21 +3. Census suite green with the new case; the live profiles pass the allowlist. + CHECK: cd /home/bchanot/Documents/claude && bash lib/tests/pack-census.test.sh 2>&1 | tail -1 + EXPECT: FAIL=0 + EVIDENCE: MET exit=0 marker-found :: PASS=40 FAIL=0 +4. shellcheck -x clean on lib/pack-census.sh; `make test suite=lib/tests/pack-census.test.sh` green. + CHECK: cd /home/bchanot/Documents/claude && shellcheck -x lib/pack-census.sh && PATH=$HOME/.bun/bin:$PATH make test suite=lib/tests/pack-census.test.sh 2>&1 | tail -1 + EXPECT: all suites green + EVIDENCE: MET exit=0 marker-found :: all suites green + +## FILE SCOPE +lib/pack-census.sh (:65 one flag), lib/pack-census-fragments.jq (one RED rule), lib/tests/pack-census.test.sh (one case). CHANGELOG → STEP 7. TODO phase 5 line → STEP 8.