Skip to content

Add checked definitions, glossary links, and optional previews - #98

Merged
jlevy merged 34 commits into
claude/kpress-v040-devicesfrom
claude/kpress-v040-definitions
Dec 3, 2026
Merged

jlevy merged 34 commits into
claude/kpress-v040-devicesfrom
claude/kpress-v040-definitions

Conversation

@jlevy

@jlevy jlevy commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

KPress stack #100 · Layer 3 of 8
Previous layer #97 · Next layer #101 · Whole-stack guide and latest build

Versioned checked records feed the same glossary entries, authored anchors, native term links, and optional previews. Preview teardown cancels queued hover, drops listeners, and preserves independently bound roots. The module demo connects structural and iconic devices to its checked glossary and includes a plain Markdown control.

The final review hardened glossary URLs and anchor collision checks, preserved related-term links inside previews, isolated repeated term IDs across embedded articles, and made Escape dismiss pointer-opened previews.

The research follow-up preserves the original Ojoshe evidence and updates both module designs after an independent Astra review and new GitHub rendering probes. It records portable source choices, the device interchange fidelity gap, definitions grammar differences, and touch interaction decisions.

This layer adopts the shared paired <k-block> language across the devices and definitions modules. It replaces the earlier optional-module fences, moves module designs beside their code, rewrites the delivery and capability plan, and publishes five sample pages with isolated and combined coverage.

The delivery plan now records the verified alpha, its adopted decisions, and the remaining implementation and review work in Beads under kpr-dutr. The planning-only revision leaves the verified runtime pin at 1e7de36.

This layer introduces the explainer. PR #101 develops it into the source-backed publication and consolidates inspection into Rendered, Source, and HTML. Epic kpr-xlsf tracks the publication.

The authoring and design material now lives in one reference per module. The integration skill and maintained documentation follow the common doc guidelines.

{
  "softschema": {
    "contract": "metabrowser.collection:Collection/v1",
    "envelope": "collection",
    "status": "enforced"
  },
  "collection": {
    "comparison": {
      "merge_base": "de875eeee3c7b8557f1e64b4b1c4970ca408088d",
      "head": "75fcf576281e63ac4c7dc774bfcffdd17dd09e85"
    },
    "items": [
      {
        "title": "One Reference per Module",
        "note": "Start at the module design map and paired-tag grammar. Follow the package-local references for device and definition behavior and adapter contracts.",
        "references": [
          {
            "path": "docs/modules/README.md"
          },
          {
            "path": "docs/kpress-block-language.md"
          },
          {
            "path": "src/kpress/devices/design-devices-module.md"
          },
          {
            "path": "src/kpress/definitions/design-definitions-module.md"
          },
          {
            "path": ".agents/skills/using-kpress/SKILL.md"
          }
        ]
      },
      {
        "title": "Predecessor Research and Remaining Design Decisions",
        "note": "The revised plan records the verified alpha and adopter revisions, the settled paired-tag and composition decisions, and the working directions and review points linked to individual Beads.",
        "references": [
          {
            "path": "docs/project/specs/active/plan-2026-12-01-structural-blocks-and-definitions.md"
          },
          {
            "path": "docs/project/research/README.md"
          },
          {
            "path": "docs/project/research/research-2026-12-01-device-formats-and-portability.md"
          },
          {
            "path": "docs/project/research/research-2026-12-01-definition-formats-and-previews.md"
          }
        ]
      },
      {
        "title": "Versioned data and stable destinations",
        "note": "Review normalized records, URL and reference validation, anchor reservation, and the shared resolution rule for preview and glossary term links.",
        "references": [
          {
            "path": "src/kpress/definitions/records.py"
          },
          {
            "path": "src/kpress/definitions/check.py"
          },
          {
            "path": "src/kpress/definitions/render.py"
          }
        ]
      },
      {
        "title": "Preview interaction and teardown",
        "note": "Check Escape for pointer-opened previews, separate pools for repeated IDs in embedded articles, and teardown when other article roots remain.",
        "references": [
          {
            "path": "src/kpress/format/static/modules/definitions/preview.js"
          },
          {
            "path": "tests/js/definition-preview.test.js"
          }
        ]
      },
      {
        "title": "Runnable glossary",
        "note": "Read the plain, devices, icons, glossary, and combined sample pages. The combined page has device disclosure, local and cross-page term links, and ordinary footnotes.",
        "references": [
          {
            "pull": 97
          },
          {
            "path": "examples/modules/glossary.json"
          },
          {
            "path": "examples/modules/content/glossary.md"
          },
          {
            "path": "examples/modules/content/combined.md"
          }
        ]
      },
      {
        "title": "Source-Backed Explainer and Format Chooser",
        "note": "Open the reading edition and follow KPress core, structural devices, and definitions. The wrapper selects maintained docs and live fixtures at build time. Compare the exact Markdown and HTML with the site YAML and the glossary JSON. The reading and source links work without scripts.",
        "references": [
          {
            "path": "examples/modules/README.md"
          },
          {
            "path": "examples/modules/templates/explainer.md.jinja"
          },
          {
            "path": "examples/modules/build.py"
          },
          {
            "path": "docs/project/specs/active/plan-2026-12-02-kpress-explainer.md"
          },
          {
            "path": "tests/test_playwright_modules.py"
          }
        ]
      },
      {
        "title": "Testing and Documentation Validation",
        "note": "All six hosted CI jobs passed, including the browser tests on the five-page example. Focused checks covered literal source, nesting limits, both module orders, and the combined document. Ojoshe verified 20 glossary destinations, and Thinking’s rebuilt editions preserved their IDs and destinations.",
        "references": [
          {
            "path": "tests/test_playwright_modules.py"
          },
          {
            "path": "examples/modules/README.md"
          }
        ]
      }
    ]
  }
}

Add an opt-in, alpha package for glossary definition data. It needs only
the core dependencies (stdlib, markdown-it-py, mdit-py-plugins), and
`import kpress` does not load it.

- records: frozen records (Alternate, SourceRef, DefinitionGroup,
  DefinitionEntry, DefinitionSet, DefinitionDiagnostic) and the version 1
  JSON interchange. parse_definitions and load_definitions check shape
  only and reject unknown keys at every level, duplicate JSON keys (with
  the key path), wrong types, non-standard constants, and other versions.
  KPressDefinitionsError carries every diagnostic.
- check: check_definitions runs the semantic checks (ids, duplicate ids
  and groups, unknown and self references, blank text, alternates, and
  http(s)-only link safety) in a deterministic order.
- grammar: the defining-sentence emphasis check. short_definition must
  bold exactly expected_defined_forms(entry), parsed like KPress prose so
  escapes, code spans, and math never count as bold; detail and notation
  must not use bold; raw HTML bold is reported.
- contract: MODULE_ID, STABILITY, SCHEMA_VERSION, PUBLIC_API, and the
  DIAGNOSTIC_CODES the checker can emit. None of it joins kpress.contract.

Tests cover every declared code, the round trip, ordering, and the
import boundary (no publisher, PDF, optimizer, Playwright, or CLI).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
`kpress definitions check FILE [--format text|json]` loads and checks a
version 1 JSON definition file. It exits 0 when no diagnostic is an
error, 1 when one is, and 2 when the file cannot be read (argparse
invocation errors also exit 2).

Text output prints one line per diagnostic to stdout, as
`FILE: <location or entry id>: <code>: <message> [field]` with control
characters escaped, and a one-line summary to stderr. JSON output prints
`{"file", "diagnostics", "ok"}` to stdout. The handler imports
kpress.definitions lazily, so other commands never load it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
…initions

DefinitionsModule adds ::: glossary and ::: term <id> entries with authored anchors,
[text](term:<id>) links that resolve on the page or to glossary_href, anchor collision
diagnostics, and an optional preview: a sanitized page-local pool plus a native ESM
behavior that opens from the dotted-underlined term link on hover or keyboard focus.
Pages without term syntax are byte-identical. Docs, the using-kpress skill (with a
mirror drift check), and kpress.yml format.modules.definitions are included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
@jlevy
jlevy added this pull request to stack #99 December 2, 2026 02:18
Paper 1's glossary showed two needs. An entry such as "Kernel and Image" bolds
kernel and image rather than its title, so records gain an optional defined_form for
the primary bold form. Published glossary URLs point at headings, so each entry
heading now carries the authored anchor, reserved ahead of slugging; a same-named
ordinary heading gets a numbered suffix. Docs follow the link-triggered preview.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
…initions

# Conflicts:
#	docs/modules/README.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
…e fences

From the ojoshe sample page: the guide's load_definitions("glossary.json") call
read the str as JSON text, and the typed API never ran the checker. from_file reads
a path, runs check_definitions, and raises KPressDefinitionsError on errors (the
kpress.yml factory now uses it and reports unreadable files). The guide shows
blank lines inside fences, which Flowmark otherwise joins into one line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
From the Paper 1 adoption:
- Records gain an optional teaching_label, so a shared glossary can say which
  paper its backlink goes to without host string rewriting.
- Preview panels reset the term's inline formatting (no all-bold previews under a
  bold term link).
- The landing scroll margin sits on the anchored entry heading.
- Preview math is typeset with KaTeX on first open; the template pool was never
  reached by the page's KaTeX pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5kBhCB4ov4f4pDq8Am3VT
@jlevy
jlevy removed this pull request from stack #99 December 2, 2026 03:08
@jlevy
jlevy added this pull request to stack #100 December 2, 2026 03:08
@jlevy jlevy changed the title feat: the kpress.definitions alpha module (records, checker, entries, term links, previews) Add checked definitions, glossary links, and optional previews Dec 2, 2026
@jlevy
jlevy marked this pull request as ready for review December 2, 2026 03:56
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@jlevy jlevy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review A (senior engineering review, round 1) · head 75fcf57 · base claude/kpress-v040-devices at de875ee
Reviewer: strong tier, requested gpt-6-astra at xhigh · Channel: formal review
Coverage: 84-file layer. Changed runtime and primary contracts; research captures and peripheral docs inventoried.
Tests run: Runtime code and primary contracts reviewed. Research captures and peripheral docs were inventoried. Pinned checker tests passed 209 cases with four scratch-dependent cases excluded.

  • A1 · Low — An interrupted static example rebuild can leave a partially written page or asset. Reuse the atomic writer for individual files. Example build

@jlevy jlevy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review B (security review, round 1) · head 75fcf57 · base claude/kpress-v040-devices at de875ee
Reviewer: strong tier, requested gpt-6-astra at xhigh · Channel: formal review
Coverage: 84-file layer. Changed runtime and primary contracts; research captures and peripheral docs inventoried.
Tests run: Defensive review of strict JSON, URL policy, container matching, sanitization, and preview insertion. Pinned parser and sanitizer probes passed 13 cases.

No security findings. Preview bodies pass through the document sanitizer and native term links retain stable destinations.

@jlevy jlevy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review C (correctness review, round 1) · head 75fcf57 · base claude/kpress-v040-devices at de875ee
Reviewer: strong tier, requested gpt-6-astra at xhigh · Channel: formal review
Coverage: 84-file layer. Changed runtime and primary contracts; research captures and peripheral docs inventoried.
Tests run: Pinned render probes covered link references, footnotes, task lists and source URLs.

  • C1 · Medium — Generated entries go through the complete parser with a disposable environment before the document parses their inlines again. Reference definitions are lost, a footnote can become orphaned, and task markers can disappear before checkbox tokens are emitted. Parse entry blocks into the document environment before the shared inline pass. Snippet parser
  • C2 · Medium — A checked source URL containing a closing parenthesis loses part of its destination when emitted as a bare Markdown link. Serialize the escaped destination inside angle brackets. Source-link rendering

jlevy commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Dispositions for review A at 75fcf57

  • A1: fixed in 6661679. The sample builder installs each finished file atomically. The Pages artifact matched all 131 rendered files. Bead kpr-qttr.

jlevy commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Dispositions for review C at 75fcf57

  • C1: fixed in 6661679. Glossary entries join one document inline pass, preserving references, footnotes, and task boxes. Verified by the focused renderer test. Bead kpr-ztf1.
  • C2: fixed in 6661679. Checked destinations are escaped before use in angle-bracket Markdown. The renderer test and independent probes preserve parentheses and ampersands. Bead kpr-yfbg.

@jlevy
jlevy merged commit 0a8b6ba into main Dec 3, 2026
6 checks passed
@jlevy
jlevy deleted the claude/kpress-v040-definitions branch December 3, 2026 03:19
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.

2 participants