From 33b6a7d2f9eb1e833cd3c8ddb94ac527516a733e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:55:58 +0000 Subject: [PATCH 1/5] fix(k9): bring the K9 records up to contract v1.0.0 and validate with the canonical validator (port of rsr-template-repo#247) "Validate K9 contracts" has been red on main since before #74: the old grep validator rejected three files, and the canonical validator (standards 1-formats/k9/tools/k9-validate.sh --strict --layer L2) rejects eight. This ports the template's fix for the same records (rsr-template-repo#247, WO-9 of standards#1058): - coordination.k9 and session/custom-checks.k9 were YAML under a K9 suffix (K9-E005). They become the template's Nickel records coordination.k9.ncl and session/custom-checks.k9.ncl: same content, with a v1.0.0 pedigree. source_of_truth now names standards/3-practice/session-management-standards, the path that exists. - methodology-guard.k9.ncl gains the K9! magic line and a v1.0.0 pedigree; its body (which reads this repo's a2ml directives) is unchanged. - Templates are not components: template-{kennel,yard,hunt}.k9.ncl and examples/setup-repo.k9.ncl carry TODO placeholders, and container/deploy.k9.ncl carries a placeholder Hunt signature and checksum in a pre-v1.0.0 pedigree. All five are renamed *.k9.ncl.in, as the template did. The deploy component's upgrade and signing stay a follow-up, documented in container/README.adoc. - .github/hooks/validate-k9.sh is the template's wrapper around the canonical validator, and the dogfood-gate K9 job checks out standards at the commit the template pins (f0b3cd4c) with sha256-verified Nickel 1.18.0. One validator per family. - root-allow.txt, EXPLAINME, the session, self-validating and container READMEs and the state visualiser follow the renames. Historical audit reports and legacy .a2ml files are left as they are. Checked: the hook passes all 5 tracked K9 records at the pinned standards commit and at standards main; removing a pedigree field from coordination.k9.ncl fails it at L1 and L2. check-root-shape.sh passes; the edited AsciiDoc renders without warnings (STATE-VISUALIZER.adoc's two warnings predate this change). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rp1Fti9phnCG3qrvQJkYEh --- .github/hooks/validate-k9.sh | 379 ++---------------- .github/workflows/dogfood-gate.yml | 80 ++-- .machine_readable/root-allow.txt | 4 +- .machine_readable/self-validating/README.adoc | 10 +- ...setup-repo.k9.ncl => setup-repo.k9.ncl.in} | 0 .../self-validating/methodology-guard.k9.ncl | 13 + ...te-hunt.k9.ncl => template-hunt.k9.ncl.in} | 0 ...ennel.k9.ncl => template-kennel.k9.ncl.in} | 0 ...te-yard.k9.ncl => template-yard.k9.ncl.in} | 0 EXPLAINME.adoc | 4 +- container/README.adoc | 24 +- container/{deploy.k9.ncl => deploy.k9.ncl.in} | 0 coordination.k9 | 43 -- coordination.k9.ncl | 50 +++ docs/STATE-VISUALIZER.adoc | 2 +- session/README.adoc | 2 +- session/custom-checks.k9 | 15 - session/custom-checks.k9.ncl | 52 +++ 18 files changed, 239 insertions(+), 439 deletions(-) rename .machine_readable/self-validating/examples/{setup-repo.k9.ncl => setup-repo.k9.ncl.in} (100%) rename .machine_readable/self-validating/{template-hunt.k9.ncl => template-hunt.k9.ncl.in} (100%) rename .machine_readable/self-validating/{template-kennel.k9.ncl => template-kennel.k9.ncl.in} (100%) rename .machine_readable/self-validating/{template-yard.k9.ncl => template-yard.k9.ncl.in} (100%) rename container/{deploy.k9.ncl => deploy.k9.ncl.in} (100%) delete mode 100644 coordination.k9 create mode 100644 coordination.k9.ncl delete mode 100644 session/custom-checks.k9 create mode 100644 session/custom-checks.k9.ncl diff --git a/.github/hooks/validate-k9.sh b/.github/hooks/validate-k9.sh index c83e290..955c6c8 100755 --- a/.github/hooks/validate-k9.sh +++ b/.github/hooks/validate-k9.sh @@ -2,356 +2,65 @@ # SPDX-License-Identifier: MPL-2.0 # Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) # -# validate-k9.sh — K9 configuration file validation script +# validate-k9.sh — pre-push K9 check, through the canonical validator. # -# Scans for .k9 and .k9.ncl files and validates: -# 1. K9! magic number on line 1 -# 2. Pedigree block presence with required fields (name, version) -# 3. Security level is one of: kennel, yard, hunt (case-insensitive) -# 4. Hunt-level files must have a signature or signature_required field -# 5. SPDX-License-Identifier header presence +# One validator per family (hyperpolymath/standards, +# docs/CONTRACTILE-DESCRIPTILE-VALIDATION.adoc): the grep checks that used to +# live here were a second validator, and they accepted files that contract +# v1.0.0 (D173) rejects. This runs 1-formats/k9/tools/k9-validate.sh from a +# standards checkout over the tracked K9 files, strict, layers L0–L2 (L0–L1 +# when nickel is not installed), as the k9-conformance lane does in CI (.github/workflows/dogfood-gate.yml). The lane +# is the gate; this is the early warning. # # Environment variables: -# INPUT_PATH — Directory to scan (default: .) -# INPUT_STRICT — Promote warnings to errors (default: false) +# INPUT_PATH — Repository to check (default: .) +# STANDARDS_DIR — A hyperpolymath/standards checkout +# (default: ../standards beside the repository) # # Exit codes: -# 0 — All files valid (or only warnings in non-strict mode) -# 1 — Validation errors found +# 0 — Every tracked K9 file passes, or no validator is available (skipped +# with a notice: CI still runs the lane) +# 1 — A file failed set -euo pipefail -# --------------------------------------------------------------------------- -# Configuration -# --------------------------------------------------------------------------- +REPO="${INPUT_PATH:-.}" +STANDARDS_DIR="${STANDARDS_DIR:-$(cd "$REPO/.." && pwd)/standards}" +case "$STANDARDS_DIR" in + /*) ;; + *) STANDARDS_DIR="$PWD/$STANDARDS_DIR" ;; +esac +VALIDATOR="$STANDARDS_DIR/1-formats/k9/tools/k9-validate.sh" -SCAN_PATH="${INPUT_PATH:-.}" -STRICT="${INPUT_STRICT:-false}" -PATHS_IGNORE_RAW="${INPUT_PATHS_IGNORE:-}" -GITHUB_OUTPUT_FILE="${GITHUB_OUTPUT:-/dev/null}" - -# Parse paths-ignore: newline-separated fragments, blank lines and # comments -# stripped. Each fragment is a substring match against the file path. Pattern -# adopted from hyperpolymath/hypatia#243 — content-pattern validators must -# distinguish a target from a vendored / fixture file that legitimately -# contains the very pattern being checked. -PATHS_IGNORE=() -while IFS= read -r _frag; do - # Strip leading and trailing whitespace (canonical bash idiom). - _frag="${_frag#"${_frag%%[![:space:]]*}"}" - _frag="${_frag%"${_frag##*[![:space:]]}"}" - [[ -z "$_frag" || "$_frag" == \#* ]] && continue - PATHS_IGNORE+=("$_frag") -done <<< "$PATHS_IGNORE_RAW" - -# Returns 0 if path should be skipped (matches any ignore fragment) -path_ignored() { - local p="$1" frag - for frag in "${PATHS_IGNORE[@]}"; do - [[ "$p" == *"$frag"* ]] && return 0 - done - return 1 -} - -# Counters -FILES_SCANNED=0 -ERRORS=0 -WARNINGS=0 - -# Valid security levels (the leash metaphor) -VALID_LEVELS="kennel yard hunt" - -# --------------------------------------------------------------------------- -# Helper: emit GitHub annotation -# --------------------------------------------------------------------------- -annotate() { - local level="$1" file="$2" line="$3" message="$4" - echo "::${level} file=${file},line=${line}::${message}" -} - -# --------------------------------------------------------------------------- -# Helper: report issue (respects strict mode) -# --------------------------------------------------------------------------- -report_issue() { - local severity="$1" file="$2" line="$3" message="$4" - - if [[ "$severity" == "warning" && "$STRICT" == "true" ]]; then - severity="error" - fi - - annotate "$severity" "$file" "$line" "$message" - - if [[ "$severity" == "error" ]]; then - ERRORS=$((ERRORS + 1)) - else - WARNINGS=$((WARNINGS + 1)) - fi -} - -# --------------------------------------------------------------------------- -# Helper: normalise a security level string -# --------------------------------------------------------------------------- -# Strips quotes, leading/trailing whitespace, Nickel enum tick prefix -normalise_level() { - local raw="$1" - # Remove surrounding quotes, tick prefix ('Kennel -> Kennel), whitespace - raw="${raw#*=}" # Remove everything before = - raw="${raw//\"/}" # Remove double quotes - raw="${raw//\'/}" # Remove single quotes (Nickel tick) - raw="${raw//,/}" # Remove trailing commas - raw="${raw## }" # Trim leading space - raw="${raw%% }" # Trim trailing space - raw="${raw%%#*}" # Remove inline comments - raw="${raw## }" # Trim again - raw="${raw%% }" - echo "${raw,,}" # Lowercase -} - -# --------------------------------------------------------------------------- -# Validator: check a single K9 file -# --------------------------------------------------------------------------- -validate_k9() { - local file="$1" - FILES_SCANNED=$((FILES_SCANNED + 1)) - - # --- Check 1: K9! magic number on first non-empty line --- - local first_content_line="" - local first_content_line_num=0 - local line_num=0 - - while IFS= read -r line; do - line_num=$((line_num + 1)) - # Skip empty lines - if [[ -z "${line// /}" ]]; then - continue - fi - first_content_line="$line" - first_content_line_num=$line_num - break - done < "$file" - - if [[ "$first_content_line" != "K9!" ]]; then - report_issue "error" "$file" "$first_content_line_num" \ - "Missing K9! magic number. First non-empty line must be exactly 'K9!'" - fi - - # --- Check 2: SPDX header --- - local has_spdx=false - line_num=0 - while IFS= read -r line; do - line_num=$((line_num + 1)) - if [[ $line_num -gt 10 ]]; then - break - fi - if [[ "$line" == *"SPDX-License-Identifier"* ]]; then - has_spdx=true - break - fi - done < "$file" - - if [[ "$has_spdx" == "false" ]]; then - report_issue "warning" "$file" 1 \ - "Missing SPDX-License-Identifier in first 10 lines" - fi - - # --- Check 3: Pedigree block with required fields --- - local has_pedigree=false - local has_pedigree_name=false - local has_pedigree_version=false - local has_security_level=false - local security_level_value="" - local security_level_line=0 - local has_signature_field=false - local in_pedigree=false - local pedigree_depth=0 - - line_num=0 - while IFS= read -r line; do - line_num=$((line_num + 1)) - - # Detect pedigree block start. Note: do NOT `continue` here — the - # `pedigree = {` line itself contains the opening brace that - # establishes the block. Falling through to the brace counter - # below makes depth start at 1, so a subsequent `security = {…},` - # closing brace correctly takes depth to 1 (not 0), keeping us - # inside the pedigree block when later fields (name/version/leash) - # are checked. Previously the `continue` skipped this opening - # brace, depth started at 0, and the first nested block's close - # prematurely terminated the validator's view of the pedigree — - # making `pedigree.metadata.name` invisible. - if [[ "$line" =~ ^[[:space:]]*pedigree[[:space:]]*= ]]; then - has_pedigree=true - in_pedigree=true - pedigree_depth=0 - # fall through - fi - - if [[ "$in_pedigree" == "true" ]]; then - # Track brace depth to know when pedigree block ends - local opens closes - opens="${line//[^\{]/}" - closes="${line//[^\}]/}" - pedigree_depth=$(( pedigree_depth + ${#opens} - ${#closes} )) - - if [[ $pedigree_depth -le 0 && "$has_pedigree" == "true" ]]; then - # Check this final line too before leaving - : - fi - - # Check for name field within pedigree.metadata or pedigree directly. - # Two patterns cover both multi-line and single-line pedigrees: - # 1. ^[[:space:]]+name[[:space:]]*= — the normal multi-line case where - # `name = "..."` appears on its own indented line. - # 2. [[:space:]]name[[:space:]]*= — inline within a single-line - # pedigree assignment such as: - # pedigree = component_pedigree & { name = "foo" } - # (root cause: developer-ecosystem@baab1534 — single-line form - # was missed entirely because the pedigree block opened and - # closed in one line, never reaching the ^[[:space:]]+ check on - # a subsequent iteration.) - if [[ "$line" =~ ^[[:space:]]+name[[:space:]]*= ]] || \ - [[ "$line" =~ [[:space:]]name[[:space:]]*= ]]; then - has_pedigree_name=true - fi - - # Check for version field - if [[ "$line" =~ ^[[:space:]]+(version|schema_version)[[:space:]]*= ]] || \ - [[ "$line" =~ [[:space:]](version|schema_version)[[:space:]]*= ]]; then - has_pedigree_version=true - fi - - # Check for security level (leash field) - if [[ "$line" =~ ^[[:space:]]+(leash|security_level)[[:space:]]*= ]]; then - has_security_level=true - security_level_value="$(normalise_level "$line")" - security_level_line=$line_num - fi - - # Check for signature fields - if [[ "$line" =~ ^[[:space:]]+(signature|signature_required)[[:space:]]*= ]]; then - has_signature_field=true - fi - - # End of pedigree block - if [[ $pedigree_depth -le 0 && "$has_pedigree" == "true" && "$line" == *"}"* ]]; then - in_pedigree=false - fi - fi - - # Also check for signature fields outside pedigree (top-level) - if [[ "$line" =~ ^[[:space:]]*(signature)[[:space:]]*= ]]; then - has_signature_field=true - fi - done < "$file" - - if [[ "$has_pedigree" == "false" ]]; then - report_issue "error" "$file" 1 \ - "Missing pedigree block. K9 files must contain a 'pedigree = { ... }' section" - else - if [[ "$has_pedigree_name" == "false" ]]; then - report_issue "error" "$file" 1 \ - "Pedigree block missing 'name' field (in pedigree.metadata.name or pedigree.name)" - fi - - if [[ "$has_pedigree_version" == "false" ]]; then - report_issue "warning" "$file" 1 \ - "Pedigree block missing 'version' or 'schema_version' field" - fi - fi - - # --- Check 4: Security level validation --- - if [[ "$has_security_level" == "true" ]]; then - local level_valid=false - for valid in $VALID_LEVELS; do - if [[ "$security_level_value" == "$valid" ]]; then - level_valid=true - break - fi - done - - if [[ "$level_valid" == "false" ]]; then - report_issue "error" "$file" "$security_level_line" \ - "Invalid security level '${security_level_value}'. Must be one of: kennel, yard, hunt" - fi - else - if [[ "$has_pedigree" == "true" ]]; then - report_issue "warning" "$file" 1 \ - "No security level (leash/security_level) found in pedigree block" - fi - fi - - # --- Check 5: Hunt-level signature requirement --- - if [[ "$security_level_value" == "hunt" && "$has_signature_field" == "false" ]]; then - report_issue "error" "$file" "$security_level_line" \ - "Hunt-level K9 file must include a 'signature' or 'signature_required' field" - fi -} - -# --------------------------------------------------------------------------- -# Main: discover and validate K9 files -# --------------------------------------------------------------------------- - -echo "::group::K9 Configuration Validation" -echo "Scanning ${SCAN_PATH} for K9 files (.k9, .k9.ncl)..." -echo "" - -# Find all K9 files, excluding .git directory -mapfile -t k9_candidates < <(find "$SCAN_PATH" \( -name '*.k9' -o -name '*.k9.ncl' \) -not -path '*/.git/*' -type f | sort) - -# Apply paths-ignore filter -k9_files=() -SKIPPED=0 -for _f in "${k9_candidates[@]}"; do - if path_ignored "$_f"; then - SKIPPED=$((SKIPPED + 1)) - continue - fi - k9_files+=("$_f") -done +if [ ! -f "$VALIDATOR" ]; then + echo "::notice::K9: no standards checkout at $STANDARDS_DIR (set STANDARDS_DIR to run the validator locally); the k9-conformance lane validates in CI" + exit 0 +fi -if [[ $SKIPPED -gt 0 ]]; then - echo "::notice::Skipped ${SKIPPED} file(s) matching paths-ignore" +# L2 is the Nickel evaluation against the contract; without nickel the +# validator reports those checks as SKIPPED and refuses to call that a pass, +# so stop at L1 here and say so. The lane checks L2 in CI either way. +LAYER=L2 +if ! command -v nickel >/dev/null 2>&1; then + echo "::notice::K9: nickel is not installed, so layer L2 (Nickel semantics) is left to the CI lane; checking L0–L1" + LAYER=L1 fi -if [[ ${#k9_files[@]} -eq 0 ]]; then - echo "::notice::No K9 files found in ${SCAN_PATH}" - echo "files_scanned=0" >> "$GITHUB_OUTPUT_FILE" 2>/dev/null || true - echo "errors=0" >> "$GITHUB_OUTPUT_FILE" 2>/dev/null || true - echo "warnings=0" >> "$GITHUB_OUTPUT_FILE" 2>/dev/null || true - echo "::endgroup::" +cd "$REPO" +mapfile -t files < <(git ls-files -- '*.k9.ncl' '*.k9' '*.k9.lock' | sort) +if [ "${#files[@]}" -eq 0 ]; then + echo "::notice::K9: no tracked K9 file" exit 0 fi -echo "Found ${#k9_files[@]} K9 file(s)" -echo "" - -for file in "${k9_files[@]}"; do - echo " Validating: ${file}" - validate_k9 "$file" +errors=0 +for f in "${files[@]}"; do + echo " Validating: $f" + if ! bash "$VALIDATOR" --strict --layer "$LAYER" "$f"; then + errors=$((errors + 1)) + fi done -echo "" -echo "────────────────────────────────────────" -echo "Files scanned: ${FILES_SCANNED}" -echo "Errors: ${ERRORS}" -echo "Warnings: ${WARNINGS}" -echo "Strict mode: ${STRICT}" -echo "────────────────────────────────────────" - -# Write outputs for GitHub Actions -{ - echo "files_scanned=${FILES_SCANNED}" - echo "errors=${ERRORS}" - echo "warnings=${WARNINGS}" -} >> "$GITHUB_OUTPUT_FILE" 2>/dev/null || true - -echo "::endgroup::" - -# Exit with failure if errors were found -if [[ $ERRORS -gt 0 ]]; then - echo "::error::K9 validation failed with ${ERRORS} error(s)" - exit 1 -fi - +echo "K9: ${#files[@]} file(s), ${errors} failing (validator: $VALIDATOR)" +[ "$errors" -eq 0 ] || { echo "::error::K9 validation failed for ${errors} file(s)"; exit 1; } echo "K9 validation passed." -exit 0 diff --git a/.github/workflows/dogfood-gate.yml b/.github/workflows/dogfood-gate.yml index c10b75f..5f74819 100644 --- a/.github/workflows/dogfood-gate.yml +++ b/.github/workflows/dogfood-gate.yml @@ -68,44 +68,68 @@ jobs: name: Validate K9 contracts runs-on: ubuntu-latest timeout-minutes: 15 + permissions: + contents: read + # One validator per family (hyperpolymath/standards, + # docs/CONTRACTILE-DESCRIPTILE-VALIDATION.adoc): the canonical + # 1-formats/k9/tools/k9-validate.sh, strict, through layer L2, at the same + # standards commit rsr-template-repo pins. Ported from rsr-template-repo#247; + # the grep checks this hook used to run were a second validator. + env: + STANDARDS_REF: 'f0b3cd4c464d33e1584f8528c17bce104555e256' + NICKEL_VERSION: '1.18.0' + NICKEL_SHA256: '9cba4dd65ae9915ec61f73033aafcff307a377665a83fd8f530df086763318cb' steps: - name: Checkout repository uses: actions/checkout@v7.0.1 + with: + persist-credentials: false - - name: Check for K9 files - id: detect + - name: Checkout canonical K9 validator + uses: actions/checkout@v7.0.1 + with: + repository: metadatastician/standards + ref: ${{ env.STANDARDS_REF }} + path: .standards-k9 + sparse-checkout: 1-formats/k9 + sparse-checkout-cone-mode: true + persist-credentials: false + + - name: Install sha256-verified Nickel CLI run: | - COUNT=$(find . \( -name '*.k9' -o -name '*.k9.ncl' \) -not -path './.git/*' | wc -l) - CONFIG_COUNT=$(find . \( -name '*.toml' -o -name '*.yaml' -o -name '*.yml' -o -name '*.json' \) \ - -not -path './.git/*' -not -path './node_modules/*' -not -path './.deno/*' \ - -not -name 'package-lock.json' -not -name 'Cargo.lock' -not -name 'deno.lock' | wc -l) - echo "k9_count=$COUNT" >> "$GITHUB_OUTPUT" - echo "config_count=$CONFIG_COUNT" >> "$GITHUB_OUTPUT" - if [ "$COUNT" -eq 0 ] && [ "$CONFIG_COUNT" -gt 0 ]; then - echo "::warning::Found $CONFIG_COUNT config files but no K9 contracts. Run k9iser to generate contracts." - fi + set -euo pipefail + URL="https://github.com/tweag/nickel/releases/download/${NICKEL_VERSION}/nickel-x86_64-linux" + curl -sSfL --proto '=https' --proto-redir '=https' --tlsv1.2 --retry 3 -o "$RUNNER_TEMP/nickel" "$URL" + echo "${NICKEL_SHA256} ${RUNNER_TEMP}/nickel" | sha256sum -c - + chmod +x "$RUNNER_TEMP/nickel" + echo "$RUNNER_TEMP" >> "$GITHUB_PATH" - name: Validate K9 contracts - if: steps.detect.outputs.k9_count > 0 - run: bash .github/hooks/validate-k9.sh - - name: Write summary run: | - K9_COUNT="${{ steps.detect.outputs.k9_count }}" - CFG_COUNT="${{ steps.detect.outputs.config_count }}" - if [ "$K9_COUNT" -eq 0 ]; then - cat <<'EOF' >> "$GITHUB_STEP_SUMMARY" - ## K9 Contract Validation - - :warning: **No K9 contracts found.** Run `k9iser generate .` to generate contracts. - - Generate contracts with: `k9iser generate .` - EOF - else - echo "## K9 Contract Validation" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "Validated **${K9_COUNT}** K9 contract(s) against **${CFG_COUNT}** config file(s)." >> "$GITHUB_STEP_SUMMARY" + set -euo pipefail + rm -rf "$RUNNER_TEMP/standards-k9" + mv "$PWD/.standards-k9" "$RUNNER_TEMP/standards-k9" + if [ ! -f "$RUNNER_TEMP/standards-k9/1-formats/k9/tools/k9-validate.sh" ]; then + echo "::error::K9 validator is missing from the standards checkout" + exit 1 + fi + if ! command -v nickel >/dev/null 2>&1; then + echo "::error::nickel is required for K9 layer L2 validation" + exit 1 fi + STANDARDS_DIR="$RUNNER_TEMP/standards-k9" bash .github/hooks/validate-k9.sh | tee "$RUNNER_TEMP/k9.log" + + - name: Write summary + if: always() + run: | + { + echo "## K9 Contract Validation" + echo "" + echo "Canonical validator (standards \`${STANDARDS_REF:0:7}\`), strict, layer L2:" + echo "" + grep -E '^K9: ' "$RUNNER_TEMP/k9.log" 2>/dev/null || echo "No result line: see the step log." + } >> "$GITHUB_STEP_SUMMARY" # --------------------------------------------------------------------------- # Job 3: Empty-linter — invisible character detection diff --git a/.machine_readable/root-allow.txt b/.machine_readable/root-allow.txt index b74663e..e2caca8 100644 --- a/.machine_readable/root-allow.txt +++ b/.machine_readable/root-allow.txt @@ -30,7 +30,7 @@ CHANGELOG.adoc # Current changelog after the AsciiDoc migration. # ─── Build entry points (must live at root for their tooling) ──────────────── Justfile # delegates phases to build/just/*.just -coordination.k9 # repo-local session binding (template-mandated) +coordination.k9.ncl # repo-local session binding (template-mandated) # ─── Conventional dotfiles (tool-required at root) ─────────────────────────── .editorconfig @@ -51,7 +51,7 @@ ci/ # .gitlab-ci.yml, .pre-commit-config.yaml (root shims docs/ # onboarding/, status/, governance/, ... docs-template/ # template-only: scaffolding docs copied into new repos machine-readable-design/ # template-only: design rationale for .machine_readable/ layout -session/ # dispatch.sh, custom-checks.k9, local-hooks.sh +session/ # dispatch.sh, custom-checks.k9.ncl, local-hooks.sh # Source / test / artifact trees (project-specific but conventional) src/ diff --git a/.machine_readable/self-validating/README.adoc b/.machine_readable/self-validating/README.adoc index 4aca2fd..65a14ee 100644 --- a/.machine_readable/self-validating/README.adoc +++ b/.machine_readable/self-validating/README.adoc @@ -51,7 +51,7 @@ Configuration with Nickel contracts for runtime validation. Evaluated safely wit === Hunt Level (Full Execution) -**File:** `examples/setup-repo.k9.ncl` +**File:** `examples/setup-repo.k9.ncl.in` Full execution with Just recipes. Can run shell commands and modify filesystem. @@ -78,7 +78,7 @@ cp .machine_readable/contractiles/k9/examples/project-metadata.k9.ncl config/met cp .machine_readable/contractiles/k9/examples/ci-config.k9.ncl .github/ci.k9.ncl # Hunt: Full automation -cp .machine_readable/contractiles/k9/examples/setup-repo.k9.ncl scripts/setup.k9.ncl +cp .machine_readable/contractiles/k9/examples/setup-repo.k9.ncl.in scripts/setup.k9.ncl ---- === 2. Validate Components @@ -137,9 +137,9 @@ K9 contractiles integrate with other RSR standards: Use these as starting points for your own K9 components: -- `template-kennel.k9.ncl` - Pure data template -- `template-yard.k9.ncl` - Validated config template -- `template-hunt.k9.ncl` - Full execution template +- `template-kennel.k9.ncl.in` - Pure data template +- `template-yard.k9.ncl.in` - Validated config template +- `template-hunt.k9.ncl.in` - Full execution template == Dependencies diff --git a/.machine_readable/self-validating/examples/setup-repo.k9.ncl b/.machine_readable/self-validating/examples/setup-repo.k9.ncl.in similarity index 100% rename from .machine_readable/self-validating/examples/setup-repo.k9.ncl rename to .machine_readable/self-validating/examples/setup-repo.k9.ncl.in diff --git a/.machine_readable/self-validating/methodology-guard.k9.ncl b/.machine_readable/self-validating/methodology-guard.k9.ncl index 99471d8..9b5dd2a 100644 --- a/.machine_readable/self-validating/methodology-guard.k9.ncl +++ b/.machine_readable/self-validating/methodology-guard.k9.ncl @@ -1,3 +1,4 @@ +K9! # SPDX-License-Identifier: MPL-2.0 # Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) # @@ -8,6 +9,18 @@ # Usage: k9 validate methodology-guard let methodology_guard = { + pedigree = { + schema_version = "1.0.0", + component_type = "validator:methodology-guard", + metadata = { + name = "methodology-guard", + version = "1.0.0", + }, + security = { + leash = 'Yard, + }, + }, + name = "methodology-guard", version = "1.0.0", description = "Validates that agent work respects declared methodology constraints", diff --git a/.machine_readable/self-validating/template-hunt.k9.ncl b/.machine_readable/self-validating/template-hunt.k9.ncl.in similarity index 100% rename from .machine_readable/self-validating/template-hunt.k9.ncl rename to .machine_readable/self-validating/template-hunt.k9.ncl.in diff --git a/.machine_readable/self-validating/template-kennel.k9.ncl b/.machine_readable/self-validating/template-kennel.k9.ncl.in similarity index 100% rename from .machine_readable/self-validating/template-kennel.k9.ncl rename to .machine_readable/self-validating/template-kennel.k9.ncl.in diff --git a/.machine_readable/self-validating/template-yard.k9.ncl b/.machine_readable/self-validating/template-yard.k9.ncl.in similarity index 100% rename from .machine_readable/self-validating/template-yard.k9.ncl rename to .machine_readable/self-validating/template-yard.k9.ncl.in diff --git a/EXPLAINME.adoc b/EXPLAINME.adoc index 2a61d78..c69b7e8 100644 --- a/EXPLAINME.adoc +++ b/EXPLAINME.adoc @@ -17,8 +17,8 @@ How this is implemented: * The local dispatcher (`session/dispatch.sh`) maps canonical commands to central protocol paths in `standards/session-management-standards`. -* Local files (`session/custom-checks.k9`, `session/local-hooks.sh`, - `coordination.k9`) are integration-only. +* Local files (`session/custom-checks.k9.ncl`, `session/local-hooks.sh`, + `coordination.k9.ncl`) are integration-only. Caveat: diff --git a/container/README.adoc b/container/README.adoc index 8ee44cf..0f9cb6c 100644 --- a/container/README.adoc +++ b/container/README.adoc @@ -59,10 +59,12 @@ All files use `{{PLACEHOLDER}}` tokens that are replaced by `just container-init | **vordr** runtime monitoring configuration. Defines health endpoints, crash detection, resource thresholds, and log output. -| `deploy.k9.ncl` -| **k9-svc** deployment component at Hunt trust level. Full pedigree - (L1--L5), environment configs (dev/staging/prod), container - configuration, and rolling deployment strategy. +| `deploy.k9.ncl.in` +| **k9-svc** deployment component at Hunt trust level, kept as a template: + environment configs (dev/staging/prod), container configuration and + rolling deployment strategy. Its pedigree predates K9 contract v1.0.0 and + its signature and checksum are placeholders, so it is not yet a component + (see below). | `0-AI-MANIFEST.a2ml` | AI-readable manifest describing the container directory, file @@ -150,12 +152,20 @@ just container-push selur-compose up --detach ---- -For k9-svc managed deployments: +For k9-svc managed deployments, the deployment component ships as the +template `container/deploy.k9.ncl.in`. It is a `'Hunt` component whose +pedigree predates K9 contract v1.0.0, and its signature +(`PLACEHOLDER-SIGNATURE-REQUIRED-FOR-HUNT`) and checksum are placeholders. +Templates are not components, so the K9 lane does not validate it (as +rsr-template-repo#247 did for the template's own deployment component). +Before it can be used, upgrade its pedigree to contract v1.0.0 (capability +grant, side effects, signature block), sign it, and render it to +`container/deploy.k9.ncl`, which the K9 lane then validates: [source,bash] ---- -# Validate the deployment component -nickel typecheck container/deploy.k9.ncl +# Validate the rendered deployment component +k9-validate.sh --strict --layer L2 container/deploy.k9.ncl # Deploy (requires Hunt-level authorisation) k9-svc deploy container/deploy.k9.ncl --env production diff --git a/container/deploy.k9.ncl b/container/deploy.k9.ncl.in similarity index 100% rename from container/deploy.k9.ncl rename to container/deploy.k9.ncl.in diff --git a/coordination.k9 b/coordination.k9 deleted file mode 100644 index ba31125..0000000 --- a/coordination.k9 +++ /dev/null @@ -1,43 +0,0 @@ -# Thin coordination bindings for central session-management standards - -session_management: - source_of_truth: "standards/session-management-standards" - canonical_commands: - - "intake repo " - - "checkpoint change " - - "verify maintenance " - - "verify substantial " - - "verify release " - - "close planned " - - "close urgent " - - "recover repo " - - "handover full " - - "handover split " - - "handover model " - - "handover human " - -signals: - - name: "session.intake" - command: "intake repo " - - name: "session.checkpoint" - command: "checkpoint change " - - name: "session.verify.maintenance" - command: "verify maintenance " - - name: "session.verify.substantial" - command: "verify substantial " - - name: "session.verify.release" - command: "verify release " - - name: "session.close.planned" - command: "close planned " - - name: "session.close.urgent" - command: "close urgent " - - name: "session.recover" - command: "recover repo " - - name: "session.handover.full" - command: "handover full " - - name: "session.handover.split" - command: "handover split " - - name: "session.handover.model" - command: "handover model " - - name: "session.handover.human" - command: "handover human " diff --git a/coordination.k9.ncl b/coordination.k9.ncl new file mode 100644 index 0000000..69721f8 --- /dev/null +++ b/coordination.k9.ncl @@ -0,0 +1,50 @@ +K9! +# SPDX-License-Identifier: MPL-2.0 +# Thin coordination bindings for central session-management standards + +{ + pedigree = { + schema_version = "1.0.0", + component_type = "session:coordination-binding", + metadata = { + name = "session-coordination", + version = "0.1.0", + }, + security = { + leash = 'Kennel, + }, + }, + + session_management = { + source_of_truth = "standards/3-practice/session-management-standards", + canonical_commands = [ + "intake repo ", + "checkpoint change ", + "verify maintenance ", + "verify substantial ", + "verify release ", + "close planned ", + "close urgent ", + "recover repo ", + "handover full ", + "handover split ", + "handover model ", + "handover human ", + ], + }, + + signals = [ + { name = "session.intake", command = "intake repo " }, + { name = "session.checkpoint", command = "checkpoint change " }, + { name = "session.verify.maintenance", command = "verify maintenance " }, + { name = "session.verify.substantial", command = "verify substantial " }, + { name = "session.verify.release", command = "verify release " }, + { name = "session.close.planned", command = "close planned " }, + { name = "session.close.urgent", command = "close urgent " }, + { name = "session.recover", command = "recover repo " }, + { name = "session.handover.full", command = "handover full " }, + { name = "session.handover.split", command = "handover split " }, + { name = "session.handover.model", command = "handover model " }, + { name = "session.handover.human", command = "handover human " }, + ], +} diff --git a/docs/STATE-VISUALIZER.adoc b/docs/STATE-VISUALIZER.adoc index a79d755..87538b3 100644 --- a/docs/STATE-VISUALIZER.adoc +++ b/docs/STATE-VISUALIZER.adoc @@ -40,7 +40,7 @@ │ │ │ OCI │ │ cerro-torre │ │ │ │ │ │ Build │ │ svalinn/vordr │ │ │ │ │ └──────────┘ └───────────────┘ │ │ - │ │ ct-build.sh deploy.k9.ncl │ │ + │ │ ct-build.sh deploy.k9.ncl.in │ │ │ └──────────────────────────────────┘ │ └────────│─────────────────│──────────────┘ │ │ diff --git a/session/README.adoc b/session/README.adoc index d14a6d7..a6b1de7 100644 --- a/session/README.adoc +++ b/session/README.adoc @@ -11,7 +11,7 @@ Authoritative protocols live in: This repo keeps only thin bindings: * `+dispatch.sh+` maps canonical commands to central protocol paths. -* `+custom-checks.k9+` defines repo-local policy checks. +* `+custom-checks.k9.ncl+` defines repo-local policy checks as a Nickel record. * `+local-hooks.sh+` provides optional repo-specific hook behavior. === Canonical Commands diff --git a/session/custom-checks.k9 b/session/custom-checks.k9 deleted file mode 100644 index bd932fa..0000000 --- a/session/custom-checks.k9 +++ /dev/null @@ -1,15 +0,0 @@ -# Local repository session checks (thin policy layer) -version: "0.1" - -checks: - - id: "session-state-has-next-action" - applies_to: ["close planned", "close urgent", "handover full", "handover split", "handover model", "handover human"] - requirement: "LAST-CANONICAL-COMMAND.md contains next intended action" - - - id: "session-state-has-residual-risks" - applies_to: ["verify maintenance", "verify substantial", "verify release", "recover repo"] - requirement: "Residual risks field is not left blank" - - - id: "session-state-has-recommended-next-protocol" - applies_to: ["intake repo", "checkpoint change", "recover repo", "handover full"] - requirement: "Recommended next protocol is set" diff --git a/session/custom-checks.k9.ncl b/session/custom-checks.k9.ncl new file mode 100644 index 0000000..7f6c01a --- /dev/null +++ b/session/custom-checks.k9.ncl @@ -0,0 +1,52 @@ +K9! +# SPDX-License-Identifier: MPL-2.0 +# Local repository session checks (thin policy layer) + +{ + pedigree = { + schema_version = "1.0.0", + component_type = "session:custom-checks", + metadata = { + name = "custom-session-checks", + version = "0.1.0", + }, + security = { + leash = 'Kennel, + }, + }, + + checks = [ + { + id = "session-state-has-next-action", + applies_to = [ + "close planned", + "close urgent", + "handover full", + "handover split", + "handover model", + "handover human", + ], + requirement = "LAST-CANONICAL-COMMAND.md contains next intended action", + }, + { + id = "session-state-has-residual-risks", + applies_to = [ + "verify maintenance", + "verify substantial", + "verify release", + "recover repo", + ], + requirement = "Residual risks field is not left blank", + }, + { + id = "session-state-has-recommended-next-protocol", + applies_to = [ + "intake repo", + "checkpoint change", + "recover repo", + "handover full", + ], + requirement = "Recommended next protocol is set", + }, + ], +} From 6358f6f754889fa1f5ae63332a4dc58bdc08e702 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:58:49 +0000 Subject: [PATCH 2/5] fix(ci): accept SPDX anywhere in the workflow's leading comment block The Workflow Security Linter required the SPDX line on line 1 of every workflow. `gh actions-lock` prepends its own "managed by" comment, so all 24 workflows now carry SPDX on line 2 and the check has failed on every push to main since (for example run 42904566720 on b015e98). This ports the fix rsr-template-repo already carries, unchanged: the licence line must appear in the leading comment block, before the workflow body. A workflow with no SPDX line, or one placed after the body starts, still fails. No licence header is edited. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rp1Fti9phnCG3qrvQJkYEh --- .github/workflows/workflow-linter.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow-linter.yml b/.github/workflows/workflow-linter.yml index 6070658..069ca40 100644 --- a/.github/workflows/workflow-linter.yml +++ b/.github/workflows/workflow-linter.yml @@ -36,13 +36,15 @@ jobs: failed=0 for file in .github/workflows/*.yml .github/workflows/*.yaml; do [ -f "$file" ] || continue - if ! head -1 "$file" | grep -q "^# SPDX-License-Identifier:"; then + # actions-lock may prepend its own comment. Require the licence + # in the leading comment block, before the workflow body. + if ! awk '/^# SPDX-License-Identifier:/ { found=1 } /^[[:space:]]*[^#[:space:]]/ { exit } END { exit !found }' "$file"; then echo "ERROR: $file missing SPDX header" failed=1 fi done if [ $failed -eq 1 ]; then - echo "Add '# SPDX-License-Identifier: MPL-2.0' as first line" + echo "Add '# SPDX-License-Identifier: MPL-2.0' to the leading comment block" exit 1 fi echo "All workflows have SPDX headers" From 9e5242ba9a20cae4622e4da42494352eb2724c00 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:01:20 +0000 Subject: [PATCH 3/5] fix(ci): pin static-analysis-gate's artifact actions in actions.lock Dependabot (#69) moved static-analysis-gate.yml to actions/upload-artifact@v7.0.2 and actions/download-artifact@v8.0.2 but left actions.lock pinning v7.0.1 and v8.0.1. The SPDX step failed first, so `gh actions-lock --verify-local` never ran on main and the drift went unseen. The workflow's entries now name the refs it uses, the v8.0.2 commit is added, and the two entries nothing references are dropped. upload-artifact@v7.0.2 was already locked for release.yml. download-artifact v8.0.2 resolves to 9000827ccba6bdab643e8b6fd33ac0654aef8333 (git ls-remote on the public repository; the same lookup returns the commits already recorded for v8.0.1 and upload-artifact v7.0.2). The lock is hand-edited because `gh actions-lock` fix mode could not reach the GitHub API from the authoring session. `gh actions-lock --verify-local` (v0.4.1, built from source) failed before this change with "2 ref-changed, 2 stale" and now reports complete coverage for all 25 workflows. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rp1Fti9phnCG3qrvQJkYEh --- .github/workflows/actions.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index 5b27867..4fdad40 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -48,8 +48,8 @@ workflows: - 'actions/checkout@v7.0.1' '.github/workflows/static-analysis-gate.yml': - 'actions/checkout@v7.0.1' - - 'actions/download-artifact@v8.0.1' - - 'actions/upload-artifact@v7.0.1' + - 'actions/download-artifact@v8.0.2' + - 'actions/upload-artifact@v7.0.2' - 'erlef/setup-beam@v1.24.1' '.github/workflows/wellknown-enforcement.yml': - 'actions/checkout@v7.0.1' @@ -66,9 +66,9 @@ dependencies: commit: 'sha1-368f82528645a54fb793d4d04e342629a3f51346' owner_id: 44036562 repo_id: 438112499 - 'actions/download-artifact@v8.0.1': - ref: 'v8.0.1' - commit: 'sha1-3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c' + 'actions/download-artifact@v8.0.2': + ref: 'v8.0.2' + commit: 'sha1-9000827ccba6bdab643e8b6fd33ac0654aef8333' owner_id: 44036562 repo_id: 192626254 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f': @@ -76,11 +76,6 @@ dependencies: commit: 'sha1-bbbca2ddaa5d8feaa63e36b76fdaad77386f024f' owner_id: 44036562 repo_id: 192625955 - 'actions/upload-artifact@v7.0.1': - ref: 'v7.0.1' - commit: 'sha1-043fb46d1a93c77aae656e7c1c64a875d1fc6a0a' - owner_id: 44036562 - repo_id: 192625955 'actions/upload-artifact@v7.0.2': ref: 'v7.0.2' commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9' From 6d2b5ab541ab6132900382a1d3e315e05c1600f1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:13:41 +0000 Subject: [PATCH 4/5] fix(k9): fail closed on routed verdicts; NUL-safe discovery; document the validator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hook counted any exit 0 from k9-validate.sh as a pass. The validator also exits 0 when it routes a file out of scope: a tracked file holding `K9!`, an SPDX comment and `---` is routed to the coordination dialect before L1 or L2 run, and the gate stayed green. Reproduced at the CI pin (f0b3cd4c) and at standards main. The hook now reads the --json verdict and passes a file only on "pass" with exit 0. A routed file fails closed, since nothing in this lane validates the coordination dialect yet. Discovery is NUL-delimited end to end (git ls-files -z, sort -z, mapfile -d ''), so a tracked name with spaces or non-ASCII characters reaches the validator as tracked rather than in core.quotePath form. container/README.adoc now says where the validator comes from (a standards checkout) and invokes it by path, as the hook does. Tested against the pinned validator and standards main: - the branch passes (5 files, L2; L1 without nickel) - a malformed routed file fails (the old hook passed it) - a component missing component_type fails, with its findings printed - a valid file named "café checks.k9.ncl" passes (the old hook failed it) - with no standards checkout the hook still exits 0 with its notice ShellCheck 0.9.0 is clean; the README renders without warnings. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rp1Fti9phnCG3qrvQJkYEh --- .github/hooks/validate-k9.sh | 24 +++++++++++++++++++++--- container/README.adoc | 19 ++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/hooks/validate-k9.sh b/.github/hooks/validate-k9.sh index 955c6c8..8fb1ac5 100755 --- a/.github/hooks/validate-k9.sh +++ b/.github/hooks/validate-k9.sh @@ -20,7 +20,8 @@ # Exit codes: # 0 — Every tracked K9 file passes, or no validator is available (skipped # with a notice: CI still runs the lane) -# 1 — A file failed +# 1 — A file failed, or was routed to a dialect (such as coordination) +# that this lane cannot validate yet set -euo pipefail @@ -47,16 +48,33 @@ if ! command -v nickel >/dev/null 2>&1; then fi cd "$REPO" -mapfile -t files < <(git ls-files -- '*.k9.ncl' '*.k9' '*.k9.lock' | sort) +# NUL-delimited end to end: with core.quotePath, newline output would hand +# the validator a quoted, escaped name instead of the tracked path. +mapfile -d '' -t files < <(git ls-files -z -- '*.k9.ncl' '*.k9' '*.k9.lock' | sort -z) if [ "${#files[@]}" -eq 0 ]; then echo "::notice::K9: no tracked K9 file" exit 0 fi +# A file passes only on the verdict "pass" with exit 0. The validator also +# exits 0 when it routes a file out of scope (verdict "routed", for example +# the coordination dialect), and routed is not passed: nothing here validates +# those dialects yet, so a routed file fails closed. errors=0 for f in "${files[@]}"; do echo " Validating: $f" - if ! bash "$VALIDATOR" --strict --layer "$LAYER" "$f"; then + rc=0 + out="$(bash "$VALIDATOR" --json --strict --layer "$LAYER" -- "$f")" || rc=$? + verdict="$(printf '%s\n' "$out" | sed -n 's/.*"verdict":"\([a-z]*\)".*/\1/p' | head -n 1)" + if [ "$rc" -eq 0 ] && [ "$verdict" = "pass" ]; then + echo " pass" + elif [ "$verdict" = "routed" ]; then + dialect="$(printf '%s\n' "$out" | sed -n 's/.*"dialect":"\([^"]*\)".*/\1/p' | head -n 1)" + echo "::error file=$f::K9: routed to the ${dialect:-unknown} dialect, which this lane cannot validate; routed is not a pass" + errors=$((errors + 1)) + else + printf '%s\n' "$out" + echo "::error file=$f::K9: verdict ${verdict:-none}, exit $rc" errors=$((errors + 1)) fi done diff --git a/container/README.adoc b/container/README.adoc index 0f9cb6c..2fb5c3a 100644 --- a/container/README.adoc +++ b/container/README.adoc @@ -160,12 +160,25 @@ Templates are not components, so the K9 lane does not validate it (as rsr-template-repo#247 did for the template's own deployment component). Before it can be used, upgrade its pedigree to contract v1.0.0 (capability grant, side effects, signature block), sign it, and render it to -`container/deploy.k9.ncl`, which the K9 lane then validates: +`container/deploy.k9.ncl`, which the K9 lane then validates. + +The validator is `1-formats/k9/tools/k9-validate.sh` in a checkout of +https://github.com/metadatastician/standards[standards]; layer L2 also needs +https://nickel-lang.org[Nickel]. The repository's hook runs it over every +tracked K9 file, and looks for the checkout at `../standards` unless +`STANDARDS_DIR` names another: [source,bash] ---- -# Validate the rendered deployment component -k9-validate.sh --strict --layer L2 container/deploy.k9.ncl +# Get the validator: a standards checkout beside this repository +git clone https://github.com/metadatastician/standards ../standards + +# Validate every tracked K9 file, the rendered deployment component included +STANDARDS_DIR=../standards bash .github/hooks/validate-k9.sh + +# Or validate the one file directly +bash ../standards/1-formats/k9/tools/k9-validate.sh --strict --layer L2 \ + container/deploy.k9.ncl # Deploy (requires Hunt-level authorisation) k9-svc deploy container/deploy.k9.ncl --env production From 856fd92b34a22ca3ff593cc40d33e18060cf56d3 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:31:22 +0000 Subject: [PATCH 5/5] style(k9): use [[ ]] for the hook's conditional tests (SonarCloud shell:S7688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No behaviour change. Re-tested against standards f0b3cd4c and main on contractiles and rsr-template-repo: tracked records pass; a routed coordination file fails; a component missing component_type fails with K9-S003; a valid "café checks.k9.ncl" passes; no checkout and no tracked file both exit 0 with a notice. ShellCheck 0.9.0 is clean. The hook stays identical in both repositories. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rp1Fti9phnCG3qrvQJkYEh --- .github/hooks/validate-k9.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/hooks/validate-k9.sh b/.github/hooks/validate-k9.sh index 8fb1ac5..1228da9 100755 --- a/.github/hooks/validate-k9.sh +++ b/.github/hooks/validate-k9.sh @@ -33,7 +33,7 @@ case "$STANDARDS_DIR" in esac VALIDATOR="$STANDARDS_DIR/1-formats/k9/tools/k9-validate.sh" -if [ ! -f "$VALIDATOR" ]; then +if [[ ! -f "$VALIDATOR" ]]; then echo "::notice::K9: no standards checkout at $STANDARDS_DIR (set STANDARDS_DIR to run the validator locally); the k9-conformance lane validates in CI" exit 0 fi @@ -51,7 +51,7 @@ cd "$REPO" # NUL-delimited end to end: with core.quotePath, newline output would hand # the validator a quoted, escaped name instead of the tracked path. mapfile -d '' -t files < <(git ls-files -z -- '*.k9.ncl' '*.k9' '*.k9.lock' | sort -z) -if [ "${#files[@]}" -eq 0 ]; then +if [[ "${#files[@]}" -eq 0 ]]; then echo "::notice::K9: no tracked K9 file" exit 0 fi @@ -66,9 +66,9 @@ for f in "${files[@]}"; do rc=0 out="$(bash "$VALIDATOR" --json --strict --layer "$LAYER" -- "$f")" || rc=$? verdict="$(printf '%s\n' "$out" | sed -n 's/.*"verdict":"\([a-z]*\)".*/\1/p' | head -n 1)" - if [ "$rc" -eq 0 ] && [ "$verdict" = "pass" ]; then + if [[ "$rc" -eq 0 && "$verdict" == "pass" ]]; then echo " pass" - elif [ "$verdict" = "routed" ]; then + elif [[ "$verdict" == "routed" ]]; then dialect="$(printf '%s\n' "$out" | sed -n 's/.*"dialect":"\([^"]*\)".*/\1/p' | head -n 1)" echo "::error file=$f::K9: routed to the ${dialect:-unknown} dialect, which this lane cannot validate; routed is not a pass" errors=$((errors + 1)) @@ -80,5 +80,5 @@ for f in "${files[@]}"; do done echo "K9: ${#files[@]} file(s), ${errors} failing (validator: $VALIDATOR)" -[ "$errors" -eq 0 ] || { echo "::error::K9 validation failed for ${errors} file(s)"; exit 1; } +[[ "$errors" -eq 0 ]] || { echo "::error::K9 validation failed for ${errors} file(s)"; exit 1; } echo "K9 validation passed."