First off, thank you for considering contributing to the Logseq Matryca Parser (Logos Protocol)!
This repository is the foundational AST engine for Matryca.ai, designed to preserve the spatial hierarchy of thought in Logseq graphs. We value deterministic logic, strict typing, and high performance.
To maintain the architectural integrity of the project, please follow the guidelines below.
User-facing behavior is documented in:
README.md— overview, quickstart, and feature matrixdocs/CLEAN_CODE_ARCHITECTURE.md— Clean Code & Clean Architecture (rings, SOLID, layer boundaries)docs/ARCHITECTURE.md— LOGOS, SYNAPSE,LogseqGraph, agents, and data flowdocs/internal/LOCAL_CODE_STUDY.md— maintainer local code audit runbook (not for public issues/CHANGELOG)docs/logseq_ast_primer.md— Logseq Spatial Markdown domain rulesCHANGELOG.md— shipped releases (current: 1.6.0) and Unreleased changes (Keep a Changelog)docs/RELEASE_PROCESS.md— version bump, tag, and PyPI publish checklistdocs/CODEQL.md— CodeQL default setup (no customcodeql.yml)docs/GOOD_FIRST_ISSUES.md— curated starter tasks for new contributorsdocs/COOKBOOK.md— integration recipes (Synapse, graph query, watcher)docs/README.md— documentation index (active vs historical)docs/rfc/OLLAMA_RAG.md— draft RFC for Ollama local RAG (#34)docs/quality/— architecture backlog, GitHub roadmap (v1.6), triagedocs/internal/STATIC_ANALYSIS_POLICY.md— Ghost Tooling policy (vendor-agnostic CI and public docs)
When you add or change observable parser or graph behavior, update the relevant doc sections and add a bullet under ## [Unreleased] in CHANGELOG.md (see .cursor/rules/05-auto-changelog.mdc).
CI and automation in this repository are limited to the core runtime and standard open-source linters (Ruff, Mypy, Pytest, CodeQL). Do not add third-party AST indexers, experimental analysis scripts, or custom MCP servers to the public tree, workflows, or pyproject.toml. See docs/internal/STATIC_ANALYSIS_POLICY.md.
Maintainers closing PRs that propose such integrations may use:
"Closing this PR. We've decided to keep our CI and automation scripts strictly focused on the core runtime and standard linters (e.g., ruff/mypy). Advanced local static analysis tools and experimental scripts will be maintained outside the main repository to keep the codebase lightweight, vendor-agnostic, and to reduce maintenance overhead."
New to the codebase? Start here:
- Pick a task from
docs/GOOD_FIRST_ISSUES.md(label:good first issueon GitHub). - Comment on the issue so others know you are working on it.
- Set up with
uv sync --all-extrasand confirmmake allis green onmain. - Branch using
feat/…,test/…, ordocs/…naming (see workflow below). - Submit one PR per issue, branched from
main(Fixes #123).
Tier 1 tasks are test-only — no parser changes, ideal for learning CliRunner and pytest patterns in tests/. Tier 2 is documentation. Tier 3 adds small CLI or FORGE features with explicit acceptance criteria.
Avoid for a first PR: changes to
logos_core.pyPydantic models (open a design issue first) and large stack-machine refactors inlogos_parser.py.
The project applies Robert C. Martin's Clean Architecture (dependency rule, inward dependencies) and Clean Code (SRP, meaningful names, tests as specification) across src/logseq_matryca_parser/.
| Practice | Where it shows up |
|---|---|
| Dependency Rule | Entities + use cases must not import Typer, Rich, or optional AI/viz frameworks — tests/test_layer_boundary.py |
| Fat modules, thin edges | Parse/index in graph / logos_parser; KINETIC and adapters delegate |
| Public graph API | iter_canonical_pages(), page_for_node(), iter_attached_nodes(), is_tracked_markdown_path() |
| Tests as spec | pytest + tmp_path vaults; make all gate |
SSOT: docs/CLEAN_CODE_ARCHITECTURE.md · audit backlog: docs/quality/CLEAN_ARCH_BACKLOG.md · Cursor rule: .cursor/rules/08-clean-code-architecture.mdc.
Good first issues (Clean Architecture — Tier 4): docs/GOOD_FIRST_ISSUES.md § Tier 4 (label clean-code).
Ghost Tooling: do not name vendor AST indexers in issues or PRs; maintainers may use local graph-based code audit per docs/internal/LOCAL_CODE_STUDY.md. Run make vendor-name-check before docs PRs.
Before writing any code, please understand our core principles:
- The Graph is Sacred: Logos does not guess or chunk text arbitrarily. It reconstructs the exact hierarchical tree based on spatial indentation.
- Deterministic Output: Given the same
.mdfile, the parser must always produce the exact same AST and identical UUIDs. - No Bloat: We strictly limit external dependencies to maximize compatibility with AOT compilers (like Nuitka) and ensure blazing-fast execution.
Note: The
logos_core.pymodule is the beating heart of the protocol. If your PR proposes changes to the Pydantic V2 models within it, please open an Issue for discussion first.
This project uses uv for dependency management and a virtual environment in .venv/. Do not use pip install -e . — CI and local workflows both go through uv.
-
Fork and Clone:
git clone https://github.com/YOUR-USERNAME/logseq-matryca-parser.git cd logseq-matryca-parser -
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Sync the environment (project + optional extras + dev tools from
pyproject.toml):uv sync --all-extras
-
Optional — install pre-commit hooks (Ruff + Mypy, aligned with CI):
uv run pre-commit install
If
pre-commitis not yet available, add it once withuv tool install pre-commitoruv add --dev pre-commit.
Whether it's a bug fix or a new feature (like a new exporter in forge.py), check the Issues tab first — especially good first issues. If it's a new idea, open an Issue to discuss it with the maintainers before investing hours of work.
Create a branch from main using the following naming format:
feat/your-feature-name(for new features)bugfix/issue-number-description(for bug fixes)docs/update-readme(for documentation)
Example:
git checkout -b feat/add-html-exporter- If you fix a bug, write a unit test in
tests/that fails without your patch and passes with it. - If you add a feature, ensure it is covered by a comprehensive test.
CI runs the same commands as your local environment: uv sync --all-extras, then make lint, make check, and make test. Before committing, run the full gate:
make allAs of v1.6.0, make all runs 456 pytest cases with ≥80% line coverage on src/logseq_matryca_parser (currently ~91%), plus make vendor-name-check. New contributors should mirror patterns in docs/GOOD_FIRST_ISSUES.md and the module map in that file’s Test suite section.
Or run each step individually:
make lint # Ruff (with auto-fix)
make check # Mypy on src/, tests/, examples/
make test # Pytest on tests/Equivalent uv run invocations:
uv run ruff check . --fix
uv run mypy src/ tests/ examples/
uv run pytest -v tests/We follow Conventional Commits. Your commit messages should be structured like this:
feat(forge): add XML export functionalityfix(parser): resolve stack overflow on deep indentationdocs: update setup instructions
- Push your branch and open a PR against the
mainbranch (one issue per PR). - Describe why the change is needed.
- Link the relevant Issue (e.g.,
Fixes #123). One issue per PR — do not stack multiple issues on a single branch. - Ensure all GitHub Actions (CI) checks pass.
This project follows the Contributor Covenant. By participating, you agree to uphold a professional, respectful, and constructive community.
Report unacceptable behavior to marco@marcoporcellato.it.
By contributing to this project, you agree that your contributions will be licensed under its Apache 2.0 License.