Skip to content

Index markdown headers to enable section validation and deep-linking #547

@phernandez

Description

@phernandez

Summary

Indexing markdown section headers (## Heading) in the parser would unlock two capabilities from a single change:

  1. Section validation — schemas could declare required sections and validate that observations appear in the correct section
  2. Deep-linking — permalinks could point to sections within documents (e.g., memory://note#section)

Current State

  • The parser is completely section-agnostic — observations and relations are extracted by pattern matching regardless of which ## section they appear under
  • The validator receives flat (category, content) tuples with no section context
  • Section headers like ## Observations, ## Relations, ## Background are purely organizational/visual

Proposed Changes

Parser

  • Track which section each observation/relation was extracted from
  • Index section headers as searchable/queryable metadata
  • Preserve section context through the parse → validate pipeline

Schema Format Extension

The picoschema format could extend with a sections key:

schema:
  name: string
  role?: string
sections:
  - Background
  - Methods
  - Findings

Deep-linking

With headers indexed, permalinks could reference specific sections:

  • memory://coffee-brewing-methods#methods
  • memory://auth-service#observations

Context

  • Schema system core (parser, resolver, validator, inference, diff) has 100+ tests at high coverage
  • Schema router integration tests completed (8 tests in tests/api/v2/test_schema_router.py)
  • Router search_fn bug was fixed during test work — was returning search index metadata instead of full entity_metadata

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions