Skip to content

pi: frontmatter story tags converted to HTML comments break YAML parsing — 10 skills dropped as "Map keys must be unique" (since 2.88.12) #173

Closed

Description

@Googlom

Version: bigpowers 2.88.17 · pi

Since 2.88.12, pi reports [Skill conflicts] at startup and drops 10 skills. The cause is the story-tag conversion from PR #158 (commit 120a0d9, "fix(skills): convert story tags to HTML comment form in all SKILL.md files", closes #140).

Symptom

[Skill conflicts]
  ~/.pi/agent/skills/audit-code/SKILL.md
    Map keys must be unique at line 2, column 1:
<!-- story: e51s04 -->
<!-- story: e45s18 -->
^

Affected skills (all have 2+ markers): audit-code, craft-skill, deepen-architecture, develop-tdd, gate-trace, plan-work, request-review, run-benchmark, stocktake-skills, validate-fix.

Root cause

pi parses skill frontmatter with the yaml npm package (dist/utils/frontmatter.js → parse()), which rejects duplicate keys. Inside a --- block, <!-- story: e45s18 --> is not a comment. YAML reads it as a mapping entry: key <!-- story, value e45s18 -->. Two such lines repeat the key, so the whole frontmatter fails to parse and pi discards the skill.

PR #158 converted every # story: line, including the ones inside the frontmatter block. Only body tags needed the HTML form (the actual request in #140); frontmatter tags were already invisible to the model because pi passes only the body to the skill prompt.

The change is regression-only in frontmatter. Diffing the published tarballs 2.88.9 vs 2.88.17, non-story frontmatter content is byte-identical across all 81 skills; the sole difference is 46 markers rewritten from # story: to <!-- story: … -->.

Why CI does not catch it

  • scripts/validate-skill-yaml.py parses with PyYAML, which accepts duplicate keys silently — it reports "Parse OK: 81".
  • scripts/lib/skill-common.sh:113 (parse_frontmatter) skips <!-- lines, so descriptions still resolve.
  • scripts/lib/trace-stories.py:93 / trace-matrix.py:112 match story:\s*(e\d{2}s\d{2}), which accepts both forms.

Only the pi client is strict, and only at load time.

Context: #109 / BUG-2026-08-06 fixed a different instance of "pi drops skills" (tags above the delimiter). This is the same outcome by another route.

Suggest

In scripts/validate-skill-yaml.py:

  1. Load frontmatter with a loader that rejects duplicate keys (yaml.BaseLoader-independent check, or yaml.safe_load plus an explicit duplicate-key hook).
  2. Add a rule: no <!-- inside the frontmatter block. HTML comments belong in the body, below the closing delimiter.

And revert the frontmatter-level conversion so tags inside --- use # story: eNNsNN again. Body markers can stay in HTML form.

Local workaround on the consumer side, before startup:

cd "$(dirname "$(readlink -f ~/.pi/agent/skills/audit-code)")/.."   # global bigpowers install
python3 - <<'PY'
import glob, re
for f in glob.glob('skills/*/SKILL.md'):
    L = open(f).read().split('\n')
    end = next((i for i in range(1, len(L)) if L[i].strip() == '---'), None)
    if end is None:
        continue
    for i in range(1, end):
        m = re.match(r'^\s*<!--\s*(story:.*?)\s*-->\s*$', L[i])
        if m:
            L[i] = '# ' + m.group(1)
    open(f, 'w').write('\n'.join(L))
PY

After that repair: 45 # story: markers in frontmatter, 98 <!-- story: --> markers in bodies, validate-skill-yaml.py PASS, and pi loads all 82 skills.

Side note, same commit: skills/audit-code/SKILL.md open body contains > **HARD GATE** — **HARD GATE** — Audit must check for: … (duplicated phrase).

I can open a PR with the validator rule and the frontmatter revert if you want it.

Activity

  1. Googlom commented on Oct 31, 2026

    @Googlom
    Author

    sorry, my pi got crazy 😃

  2. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Reopening — this was closed without a fix, and the defect is live in 2.93.3

    Verified today on main (52842a2f, v2.93.3) and on the published npm artifact:

    $ head -5 /Users/…/lib/node_modules/bigpowers/skills/audit-code/SKILL.md
    ---
    <!-- story: e51s04 -->
    <!-- story: e45s18 -->
    <!-- story: e45s31 -->
    name: audit-code
    
    • No revert of 120a0d99 exists: git log --oneline -- skills/audit-code/SKILL.md ends at 6136322a/120a0d99.
    • 39 of 80 skills/*/SKILL.md carry <!-- story: … --> inside the --- block.
    • 10 of them have 2+ markers and are dropped by pi 1.5.0 exactly as described: audit-code, craft-skill, deepen-architecture, develop-tdd, gate-trace, plan-work, request-review, run-benchmark, stocktake-skills, validate-fix.
    • scripts/validate-skill-yaml.py still reports PASS … Parse OK: 160 (PyYAML accepts duplicate keys).

    Note that skills/migrate-spec/SKILL.md shows the correct pattern: tags below the closing ---. The convention is currently applied three different ways across the catalog.

    Re-verified fix shape against pi 1.5.0s own parser (require("yaml").parse, the same package dist/utils/frontmatter.js uses):

    # story: e51s04        → {"name":"audit-code","model":"haiku","effort":"standard","description":"…"}   ✅
    <!-- story: e51s04 --> → ERROR: Map keys must be unique at line 2, column 1                            ❌
    

    So the fix is: tags inside the frontmatter use # story: eNNsNN (YAML comment), tags in the body may keep the HTML form. Splitting the CI gate out as its own issue since it is a separate deliverable.

  3. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Issue batch filed (fix order)

    # Issue Sev
    1 #173 frontmatter HTML comments → 10 skills dropped (this issue, reopened) P0
    2 #207 validate-skill-yaml.py cannot detect this form — CI reported green P0
    3 #208 five install channels → 80 name collisions, pi ranks the wrong copy P1
    4 #209 .agents/skills (Antigravity render) auto-discovered by pi, outranks source P1
    5 #210 tracked .mcp.json → project server blocked on every start P1
    6 #211 directTools in pi's mcp.json, ignored by pi-mcp-adapter P1
    7 #212 no guidance for pi update --extensions P3
    E1 #213 epic: host conformance harness —
    E2 #214 epic: single-channel distribution manifest —
    E3 #215 epic: move metadata out of the Agent Skills frontmatter contract —
    E4 #216 epic: bigpowers doctor —
    E5 #217 epic: MCP integration profile —

    Fix order matters: 1 and 2 are the same defect seen from the artifact and the gate. Doing 2 first makes 1 provably fixed. 3 and 4 are the shouting symptom and its cause. 5/6/7 are config placement and docs.

    Suggested grouping into work: #173 + #207 (one PR, ships as fix(skills)), #208 + #209 (needs the channel decision from #214), #210 + #211 (needs #217).

  4. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Full finding batch (fix order)

    # Issue Sev Group with
    1 #173 frontmatter HTML comments → 10 skills dropped (reopened) P0 #207
    2 #207 validate-skill-yaml.py cannot detect that form — CI reported green P0 #173
    3 #218 rendered .pi/skills ships 0 of 92 bundled assets P1 #209
    4 #208 five install channels → 80 name collisions, wrong copy wins P1 #214
    5 #209 .agents/skills (Antigravity render) auto-discovered by pi P1 #218
    6 #210 tracked .mcp.json → project server blocked every start P1 #217
    7 #211 directTools in pi's mcp.json, ignored by the adapter P1 #217
    8 #212 no guidance for pi update --extensions P3 —
    E1 #213 epic: host conformance harness — —
    E2 #214 epic: single-channel distribution manifest — —
    E3 #215 epic: metadata out of the Agent Skills frontmatter contract — —
    E4 #216 epic: bigpowers doctor — —
    E5 #217 epic: MCP integration profile — —

    Suggested PR split: #173 + #207 (fix(skills)), #218 (fix(dist), needs the assertion first), #208 + #209 (fix(dist), after #214 decides the channel), #210 + #211 + #212 (fix(mcp)/docs).

  5. added
    bug
    quality
    on Nov 6, 2026
  6. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Batch addendum — install/uninstall lifecycle

    Found while executing the machine cleanup with the install paths in hand:

    # Issue Sev Why it matters
    9 #219 install.sh --uninstall is a no-op from a checkout; copy-mode channels are never removable P1 It left 635 entries and a 62 MB copy tree on a real machine; every one had to be removed by hand
    10 #220 bin/setup.js uses .pi/agent/skills for pi's project-local path — pi scans .pi/skills P1 Project-local pi installs silently do nothing

    Both belong to the #214 (single-channel distribution) decision: a channel needs an install path and a recorded uninstall path. #219's fix direction (install manifest at ~/.bigpowers/install-manifest.json) also gives #216 (bigpowers doctor) its data source.

    Also confirmed for #215: the wrong frontmatter form is not only in skills/*/SKILL.md — docs/references/traceability-gate.md and docs/references/tombstones.md describe the story-tag convention, and 39 files under docs/ and specs/ carry <!-- story: --> at line 3. The docs must state the rule that the parser enforces: inside frontmatter only # comments, everything else uses metadata:.

  7. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Batch plan (dependency order = SCOPE order)

    Baseline on main @ 52842a2f, before any change: npm run compliance 0, bash scripts/run-verification-gates.sh 56/56 deterministic gates PASS, bash scripts/trace-stories.sh --strict 0. Green baseline — no pre-existing red gate. One baseline defect logged locally instead of filed: sync-skills.sh regenerates 162 committed specs/ artifacts (506k deletions) because they were built with .claude/worktrees/** present → recorded as BUG-2026-11-06-sync-specs-artifact-churn.

    Batch Issues Mode Files Depends on
    B1 #173, #207 sequential, one branch skills/*/SKILL.md, skills-lock.json, scripts/validate-skill-yaml.py, tests/test-skill-frontmatter-strict.sh, scripts/lib/golden-suite-gates.sh —
    B2 #218 ‖ #219+#220 parallel, worktree each #218: scripts/lib/sync-render.sh, scripts/lib/sync-post.sh · #219/#220: scripts/install.sh, scripts/lib/install-targets-*.sh, bin/setup.js —
    B3 #209 → #208 sequential scripts/lib/install-targets-b.sh, bin/setup.js, new distribution-targets.yaml, scripts/sync-skills.sh, scripts/install.sh #218 (render fidelity), #219 (install record)
    B4 #210 ‖ #211 ‖ #212 parallel, docs/config .mcp.json, bin/setup.js, scripts/validate-mcp-package.sh, docs/references/bigpowers-mcp.md, docs/references/agent-tooling.md —
    B5 #213 → #215 → #214 → #217 → #216 build-epic, one story at a time harness, metadata, distribution manifest, MCP profile, doctor B1–B4 (each epic verifies the fixes above)

    PR split: #173 + #207 → one fix(skills)/fix(ci) pair, because the validator must reject exactly what the data fix removes (B1). #218 alone. #209 + #208 together once the render target moves, since the channel manifest is what stops the collision returning. #210 + #211 + #212 may ride one fix(mcp)/docs PR (different files, same subject). #219 + #220 one fix(install) PR.

    Docs note for #215: the wrong frontmatter form is documented as correct in docs/references/traceability-gate.md and docs/references/tombstones.md, and 39 files under docs/ and specs/ carry <!-- story: --> at line 3. The rule to write down: inside the frontmatter only # comments; everything else goes in metadata: or the body. #215 owns that rewrite; B1 only fixes the shipped data.

    Gates policy: every batch rebases on main, re-runs full Preflight, and merges only with all workflows green. No gate, test or workflow is weakened to get there.

    Status updates follow as new comments; this table is not edited.

  8. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Batch B1 — shipped

    Issue Status PR Test evidence CI
    #173 frontmatter HTML comments → 10 skills dropped ✅ merged, closed #221 pi 1.5.0's own parser: 80/80 parse, 0 failures; pre-fix tree reproduces 22 R4 violations green
    #207 validator cannot detect it ✅ merged, closed #221 new skill-frontmatter-strict gate 5/5; golden suite 57/57 green

    Merged as 28110b81 (squash). main pulled, branch and worktree removed.

    What changed: 22 skills/*/SKILL.md (43 markers) now use # story: inside the fence; validate-skill-yaml.py gained R4 (no HTML comment in the block) and R5 (no duplicate top-level key), both dependency-free so they fire with the bundled simple_yaml fallback; tests/test-skill-frontmatter-strict.sh drives the real validator over throw-away trees and is wired into scripts/lib/golden-suite-gates.sh.

    Decisions logged in specs/state.yaml under decisions:: baseline-preflight, batch-order, sync-skills-specs-churn (reverted 162 committed specs/ artifacts rather than committing 506k lines of churn → BUG-2026-11-06-sync-specs-artifact-churn, out of SCOPE), frontmatter-form, epic-tracking.

    Not in scope of this PR, by design: model, effort and phase are bigpowers extensions rather than Agent Skills spec keys — pi tolerates unknown keys, so they load, but the separation is #215's job. Recorded there.

    Next: B2 — #218 (rendered targets ship 0 of 92 bundled assets) in parallel with #219 + #220 (install/uninstall lifecycle).

  9. added a commit that references this issue on Nov 6, 2026
  10. github-actions commented on Nov 6, 2026

    @github-actions

    🎉 This issue has been resolved in version 2.93.4 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  11. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Batch B2 — shipped

    Issue Status PR Evidence CI
    #218 rendered payloads ship 0 of 92 assets ✅ merged, closed #223 find .pi/skills -mindepth 2 -type f ! -name SKILL.md → 92; render-assets gate 4/4 green
    #219 uninstall no-op from checkout ✅ merged, closed #224 install-manifest gate 6/6 (repo-root + node_modules + chained hop + foreign-link + copy-mode replay) green
    #220 pi project-local path .pi/agent/skills ✅ merged, closed #224 install-helpers ALL PASS; local target now .pi/skills green

    Merged: 7726939a (#223), 6172b559 (#224). Branch + worktree removed, local main == origin/main.

    Notes:

    Next: B3 — #209 (relocate the Antigravity render target out of pi discovery) → #208 (single-channel manifest + collision report).

  12. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Batch B3 — #209 shipped

    Issue Status PR Evidence CI
    #209 .agents/skills render target auto-discovered by pi ✅ merged, closed #225 render-targets-not-discoverable gate 5/5; render now .bigpowers/rendered/antigravity/skills green

    Merged 24bbbd94 (squash). No worktree (worked on a feature branch of the main checkout).

    Next in B3: #208 — single-channel distribution + --verify duplicate-root report, then B4 (#210, #211, #212).

  13. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Batch B3 — shipped

    Issue Status PR Evidence CI
    #209 .agents/skills render auto-discovered by pi ✅ merged, closed #225 render-targets-not-discoverable gate 5/5 green
    #208 five channels → 80 collisions ✅ merged, closed #226 verify-distribution gate 4/4 (clean / package-only / conflict / symlink-only) green

    Merged 24bbbd94 (#225), 6a55a91d (#226). No worktrees (feature branches of the main checkout).

    #208 scope note: this PR ships the diagnostic + documented contract (verify-distribution.sh --strict, install.sh --verify, channel matrix in docs/references/agent-tooling.md). The full single-channel manifest (distribution-targets.yaml + exclusive-per-host setup) is multi-story and is tracked as epic #214 — noted in the PR body.

    Next: B4 — #210 (tracked .mcp.json blocked project server), #211 (directTools doc), #212 (pi update --extensions guidance).

  14. danielvm-git commented on Nov 6, 2026

    @danielvm-git
    Owner

    Final summary — all 10 concrete issues closed, 5 epics planned

    # Issue PR State
    #173 frontmatter HTML comments → 10 skills dropped #221 ✅ closed
    #207 validator couldn't detect it #221 ✅ closed
    #218 rendered payloads shipped 0/92 assets #223 ✅ closed
    #219 install.sh --uninstall no-op + copy-mode #224 ✅ closed
    #220 pi project-local path .pi/agent/skills #224 ✅ closed
    #209 .agents/skills render auto-discovered by pi #225 ✅ closed
    #208 five channels → 80 collisions #226 ✅ closed
    #210 tracked .mcp.json blocked project server #227 ✅ closed
    #211 directTools in the wrong file #227 ✅ closed
    #212 no pi update --extensions guidance #227 ✅ closed
    #213–#217 epics #228 🗂️ capsules created, open (build-epic next)

    CI results

    Every PR merged green: sync, skill-verify, story-verify, verification-gates all pass; release/pages skip as expected. Golden suite grew from 56 → 61 deterministic gates across this batch:

    Gate decisions logged in specs/state.yaml

    baseline-preflight (green before any change), batch-order, sync-skills-specs-churn (reverted 162 committed artifacts → BUG-2026-11-06-sync-specs-artifact-churn, out of SCOPE), frontmatter-form, epic-tracking, bug-batch-complete, epic-intake, main-protected-recovery.

    Deferred / out of SCOPE

    Final state

    • main == origin/main == 40713cd3, working tree clean.
    • 11 bug records registered in specs/bugs/registry.yaml (10 from the batch + 1 local finding).
    • No leftover feature branches or worktrees from this run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugqualityreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions