Skip to content

fix(frontmatter): knowledgePageFromMarkdown strips an unbalanced trailing quote and breaks 39.7% of recorded checks #184

Description

@drewstone

What happens

knowledgePageFromMarkdown strips a trailing quote from a front-matter value it reads as a wrapper, even when the value's leading character is not that quote. A shell command that ends in a quoted path therefore comes back unbalanced.

import { knowledgePageFromMarkdown } from '@tangle-network/agent-knowledge'

const md = [
  '---',
  'id: x',
  'rung: 4',
  'check: bash "$DISCOVERY_RUN_WORKSPACE/checks/clean.sh"',
  'expect: OK',
  '---',
  '',
  'body',
  '',
].join('\n')

knowledgePageFromMarkdown('/tmp/x.md', md).frontmatter.check
// 'bash "$DISCOVERY_RUN_WORKSPACE/checks/clean.sh'      <- trailing quote gone

Why it matters

verifyGradeableEvidence runs bash -n -c <check> before executing. The mangled command does not parse, so it raises UncheckableClaimError with INVALID_SHELL_SYNTAX_NOTE, and the claim is recorded unrunnable for a reason that has nothing to do with the claim.

Measured 2026-09-01 over every rung >= 4 claim page in one lab (discovery-lab/pursuits/**/kb/pages/*.md): the parser disagrees with the raw ^check: (.*)$ line on 1,492 of 3,762 checks (39.7%). Every one of those grades unrunnable when it is executed through verifyGradeableEvidence.

The dominant shape is a quoted workspace path:

check: python3 "$DISCOVERY_RUN_WORKSPACE/checks/verify_q36_binary_N27.py"
check: python3 -c "import json;r=json.load(open('$DISCOVERY_RUN_WORKSPACE/work/census/results.json'))..."

Expected

A value is unquoted only when the quote is balanced — the first non-space character and the last character are the same quote. bash "..." starts with b, so nothing is stripped.

Versions

@tangle-network/agent-knowledge@11.0.0, node 24.18.0.

Workaround in place

The consumer reads check, expect and evidencePath from the raw ^key: (.*)$ line and keeps the parser for everything else. It carries this issue number in a comment and is removed when this lands.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions