Skip to main content

A Markdown decomposition core for context graphs: parses Markdown content (frontmatter, structure, and [[wiki-links]]) into provenance-carrying graph nodes and edges. First source = the ecosystem's own memory/decision files; generalizes to any Markdown corpus.

Project description

cjm-markdown-decompose-core

A Markdown decomposition core for context graphs: parses Markdown content (frontmatter, structure, and [[wiki-links]]) into provenance-carrying graph nodes and edges. First source = the ecosystem's own memory/decision files; generalizes to any Markdown corpus.

Modules

  • cjm_markdown_decompose_core.__init__
  • cjm_markdown_decompose_core.extract — Map parsed Markdown onto dev-graph-schema nodes (coarse tier).
  • cjm_markdown_decompose_core.ingest — Flatten decomposed notes into graph elements for idempotent extension.
  • cjm_markdown_decompose_core.parse — Schema-free Markdown parsing (stdlib + PyYAML).
  • cjm_markdown_decompose_core.project — Projections from the decomposed content back out to files.
  • cjm_markdown_decompose_core.relations — Per-source-type relationship harvesting from parsed Markdown.
  • cjm_markdown_decompose_core.sections — Decompose a Markdown body into ordered Section nodes (the navigable unit).
  • tests.test_extract_project — Extract markdown -> NoteNode and project notes -> MEMORY.md index (with idempotency).
  • tests.test_ingest_graphproject — Corpus -> graph elements, and projecting the index back from graph nodes.
  • tests.test_parse — Schema-free Markdown parsing.
  • tests.test_relations — Per-source-type relationship harvesters + profile dispatch + extract wiring.
  • tests.test_sections — Body -> ordered Section nodes: anchors, hierarchy, verbatim text, disambiguation.
  • tests_manual.memory_body_roundtrip — M1 round-trip: memory BODIES -> graph (extend_graph) -> byte-exact file text.
  • tests_manual.memory_roundtrip — Inc 1 round-trip: memory corpus -> graph (extend_graph) -> MEMORY.md projection.
  • tests_manual.notes_slice — Runtime harness: decompose a real christianjmills/posts slice through the full

API

cjm_markdown_decompose_core.extract

  • note_from_file function — Read a Markdown file and map it to a coarse NoteNode.
  • note_from_parsed function — Build a coarse NoteNode from already-parsed Markdown.
  • note_from_text function — Parse + map in one step from in-memory text (hashes the UTF-8 bytes).
  • note_type_from function — Read the memory category from metadata.type (None when absent).
  • slug_from function — Derive the stable slug: frontmatter name if present, else the path.
  • title_from function — Derive a display title: explicit frontmatter title, else the slug titleized.

cjm_markdown_decompose_core.ingest

  • corpus_graph_elements function — Collect notes into the node + edge wire-dict lists extend_graph expects.

cjm_markdown_decompose_core.parse

  • ParsedMarkdown class — The structural decomposition of one Markdown document.
  • extract_headings function — Extract ATX headings (#..######) as (level, text) pairs.
  • extract_wiki_links function — Extract [[wiki-link]] targets from the body, de-duplicated, order-preserved.
  • parse_frontmatter function — Parse frontmatter YAML into a dict (empty dict when absent).
  • parse_markdown function — Parse a Markdown document into frontmatter + body + wiki-links + headings.
  • split_frontmatter function — Split a leading ----delimited YAML frontmatter block from the body.
  • strip_code function — Blank out fenced + inline code spans (replaced with a space, length-agnostic).

cjm_markdown_decompose_core.project

  • first_sentence function — A deterministic terse hook: the description's first sentence, capped.
  • note_index_line function — Render one index line from a note's frontmatter-derived fields.
  • note_text_from_graph_nodes function — Reconstruct a note's file text FROM the graph (frontmatter_raw + ordered raw spans).
  • note_view_from_graph_node function — Reconstruct an index-relevant NoteNode from a queried graph node.
  • render_memory_index function — Render a MEMORY.md index: notes grouped by category, one line each.
  • render_memory_index_from_graph_nodes function — Render the memory index FROM queried graph nodes (the self-hosting path).
  • render_note_text function — Reassemble a note's exact file text from its verbatim parts (lossless mode).
  • render_onboarding_surface function — Render the onboarding surface: orientation + how-to-query + resident PUSH core + landmark map + how-to-pull.

cjm_markdown_decompose_core.relations

  • NoteRelations class — The harvested relationship signals for one note (beyond [[wiki-links]]).
  • detect_profile function — Detect the source-type profile from the frontmatter shape.
  • harvest_aliases function — Harvest aliases (old URLs) -> bare permalinks (alternate identities).
  • harvest_categories function — Harvest categories -> normalized Topic keys (the thematic-clustering facet).
  • harvest_cross_post_links function — Harvest /posts/... markdown links -> (permalink, section anchor) pairs.
  • harvest_relations function — Harvest a note's relationships using its (detected or given) source profile.
  • harvest_series_links function — Harvest /series/... markdown links -> series keys (the membership signal).
  • normalize_permalink function — Reduce a post link to its bare permalink — the path AFTER posts/.
  • slugify function — Normalize a category/tag to a stable key (lowercased, separators collapsed).

cjm_markdown_decompose_core.sections

  • decompose_sections function — Decompose a body into ordered SectionNodes (heading-delimited).
  • heading_anchor function — Slugify a heading to its anchor — the Pandoc/Quarto auto-identifier shape.

tests.test_extract_project

  • test_extraction_is_deterministic function
  • test_first_sentence_takes_boundary_else_caps function
  • test_index_line function
  • test_index_md_identified_by_directory_permalink function
  • test_non_index_and_frontmatter_name_unaffected_by_index_rule function
  • test_note_from_text_uses_frontmatter_name_as_slug function
  • test_render_groups_by_category_in_order function
  • test_render_is_idempotent function
  • test_render_onboarding_surface_coverage_augments_landmark_map function
  • test_render_onboarding_surface_is_deterministic function
  • test_render_onboarding_surface_structure_push_and_landmarks function
  • test_root_level_index_falls_back_to_dir_name function
  • test_slug_falls_back_to_relative_path_when_no_name function

tests.test_ingest_graphproject

  • test_alias_map_heals_a_drifted_reference function
  • test_both_books_converge_on_shared_facets function
  • test_corpus_graph_elements_counts function
  • test_note_view_from_graph_node_dict function
  • test_render_from_graph_nodes_matches_direct_render function
  • test_topic_and_series_nodes_are_deduped_across_notes function

tests.test_parse

  • test_extract_headings function
  • test_extract_wiki_links_dedup_order_preserved function
  • test_extract_wiki_links_ignores_code_spans function
  • test_parse_frontmatter_empty function
  • test_parse_frontmatter_handles_colons_and_nesting function
  • test_parse_markdown_end_to_end function
  • test_parse_markdown_frontmatter_raw_is_lossless_prefix function
  • test_split_frontmatter_absent function
  • test_split_frontmatter_separates_block function

tests.test_relations

  • test_detect_profile function
  • test_extract_drops_self_reference_cross_post_link function
  • test_harvest_aliases_to_permalinks function
  • test_harvest_categories_normalized_deduped function
  • test_harvest_cross_post_links_with_anchors_and_code_stripped function
  • test_harvest_relations_dispatches_by_profile function
  • test_harvest_series_links function
  • test_memory_corpus_unaffected function
  • test_normalize_permalink_variants function
  • test_slugify_normalizes function
  • test_yaml_date_frontmatter_is_json_safe function

tests.test_sections

  • test_decompose_sections_order_levels_hierarchy function
  • test_duplicate_heading_anchor_disambiguated function
  • test_heading_anchor_matches_quarto_slug function
  • test_lossless_body_starting_with_heading_has_no_preamble_node function
  • test_lossless_no_headings_is_one_preamble_node function
  • test_lossless_preamble_is_level0_order0_node function
  • test_lossless_raw_spans_reconstruct_body_byte_exact function
  • test_note_from_text_lossless_round_trip_and_frontmatter_raw function
  • test_note_from_text_with_sections_emits_section_nodes function
  • test_scope_a_carries_no_raw function
  • test_section_text_is_verbatim_immediate_prose function
  • test_structural_edges_membership_and_hierarchy function

tests_manual.memory_body_roundtrip

  • check function
  • main function
  • run function

tests_manual.memory_roundtrip

  • check function
  • main function
  • run function

Dependencies

Depends on: cjm-dev-graph-schema, cjm-substrate Used by: cjm-context-graph-projection, cjm-notebook-decompose-core

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cjm_markdown_decompose_core-0.0.11.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cjm_markdown_decompose_core-0.0.11-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file cjm_markdown_decompose_core-0.0.11.tar.gz.

File metadata

File hashes

Hashes for cjm_markdown_decompose_core-0.0.11.tar.gz
Algorithm Hash digest
SHA256 361f1a1cbb63c41ecb7b8ca1ab4e1a0eb5d79174453e0888eae6bb631dbdbc45
MD5 0883664eaeab8dc345d17ba6f3af8028
BLAKE2b-256 8b4001f99175593fc0ee7614d7b852041633ccee5af4f6e03d00e235bde8f56c

See more details on using hashes here.

File details

Details for the file cjm_markdown_decompose_core-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for cjm_markdown_decompose_core-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 8226444fa0c012da67762ca421f4ebe501d15901b5fe08cab1dd5ed95ae6d9ea
MD5 4cc346c30eb8b388fc46bd6eb79219d9
BLAKE2b-256 4961f3ae052a64ce716973213cc640829108253759d76e1d9e6bd71341377c90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page