From 2fb9a2f4c1676ba525084de28dd1ce19437e10f5 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 16:22:39 +0100 Subject: [PATCH] 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/"