Skip to content

fix(validate-k9): drop premature continue so pedigree.metadata.name resolves#6

Closed
hyperpolymath wants to merge 1 commit into
mainfrom
fix/pedigree-depth-tracking
Closed

fix(validate-k9): drop premature continue so pedigree.metadata.name resolves#6
hyperpolymath wants to merge 1 commit into
mainfrom
fix/pedigree-depth-tracking

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Single-line fix for a brace-depth tracking bug in validate-k9.sh.

Symptom

Validate K9 contracts fails on every consumer that uses the canonical K9 templates with name under pedigree.metadata:

::error::Pedigree block missing 'name' field (in pedigree.metadata.name or pedigree.name)

even though the file has pedigree.metadata.name = "…".

Root cause

In the scanner loop (around line 148), the pedigree-opener line is detected and in_pedigree=true is set, then continue skips the brace-counting code below for that same line. So the { on pedigree = { is never added to pedigree_depth. When the first inner block (e.g. security = { … }) closes, pedigree_depth drops to 0 and in_pedigree flips back to false — even though we are still nested inside pedigree. Anything declared after that (metadata = { name = … }) is never scanned.

Fix

Delete the orphan continue. The block immediately below (if [[ "" == "true" ]]) then processes the pedigree-opener line, counts its {, and depth tracking stays consistent.

Test plan

  • Run on template-yard.k9.ncl / template-kennel.k9.ncl / template-hunt.k9.ncl from the canonical K9 set: should pass.
  • CI on this repo passes.

… resolves

The pedigree block opener (`pedigree = {`) was matched, `in_pedigree=true`
was set, then `continue` skipped the brace-counting block below for *that
same line*. Result: the opening `{` on the pedigree-opener line is never
added to `pedigree_depth`. When the FIRST nested block closes (e.g.
`security = { … },`), `pedigree_depth` drops to 0 and the end-of-pedigree
check fires — even though we are still inside the pedigree block. Any field
declared in a later sibling block (e.g. `metadata = { name = … }`) is
therefore never scanned, and every K9 file that puts `name` under
`pedigree.metadata` is flagged `Missing 'name' field`.

Removing the `continue` lets the brace counter on lines 156-160 process the
pedigree-opener line normally, so depth tracks correctly:

* `pedigree = {` → depth 0 → 1
* `security = {` → depth 1 → 2
* `},` (close security) → depth 2 → 1
* `metadata = {` → depth 1 → 2  ← (was already 0, used to exit here)
* `name = "…"` → matches name field
* `},` (close metadata) → depth 2 → 1
* `},` (close pedigree) → depth 1 → 0, in_pedigree=false

Without this fix, `Validate K9 contracts` is red on every estate consumer
that uses the standard K9 templates (template-yard.k9.ncl,
template-kennel.k9.ncl, template-hunt.k9.ncl, examples/*).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@hyperpolymath
Copy link
Copy Markdown
Owner Author

Superseded — the fix (drop premature continue at the pedigree block opener) is already present in main alongside additional improvements (PATHS_IGNORE infrastructure adopted from hypatia#243). The head branch is older than main. Closing; deleting branch.

@hyperpolymath hyperpolymath deleted the fix/pedigree-depth-tracking branch May 14, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant