EntwineMenu
On this page

Architecture

docs/*.md ─────────────┐
                       ├→ Parser → KnowledgeBase ─┬→ Context (complete)
AGENTS.md, SKILL.md … ─┘  (opt-in discovery)      ├→ Site / Knowledge ┐ publication
                                                  └→ Graph / Agents  ┘ policy applies

Crate boundaries

entwine-core owns pure, serializable domain types, including the knowledge role model and its classification rules. It performs no I/O. entwine-engine depends on core and owns scanning, parsing, resolution, validation, projections, and rendering. entwine-cli depends on the engine and owns arguments, output publication, diagnostic presentation, HTTP serving, file watching, init scaffolding, and setup (Git remote inspection and CI templates). Provider detection and CI generation deliberately live in the CLI, never in core or engine. See the decision on publishing.

Canonical representation

Each Markdown document is parsed into events once. The engine extracts metadata, headings, and link positions during that pass, then derives the document's knowledge role from its frontmatter type and canonical path. After all routes are known it resolves URLs in those events and renders the body without parsing again. Unique directed relations are derived from resolved links. Backlinks, navigation, graph nodes, the Knowledge overview, and the context all use that same knowledge model.

Artifact kinds, configuration, and publication

Every Document has a role (what it means) and an ArtifactKind (what kind of file it is: documentation, agent instructions, or skill). Agent artifacts carry AgentDetails (convention, path, scope, skill folder, name, description, resources). Provider file names are data in AgentConvention; no code branches on a brand. Ids of agent artifacts start with repo: so they can never collide with docs/ paths.

entwine.toml is parsed into Config (core type, parsed in the engine) and is optional; all defaults are the zero-config behavior. Discovery (discovery.rs) only reads files and feeds the same parser. Publication is a projection-time decision: the canonical KnowledgeBase and ContextModel always contain discovered artifacts, while project() builds the SiteModel, GraphModel, and agent views from a documentation-only subset unless include_agent_knowledge is set or the artifact is listed in public_agent_paths. The unpublished HTML for a documentation link to an agent file is rendered as a repository reference at resolution time, so no output file mentions it.

Graph

graph_layout.rs computes a deterministic force-directed layout using only arithmetic and sqrt (no trigonometry, so coordinates match across platforms). graph_page.rs renders the static SVG, legend, embedded JSON, and the full text index. graph.js is a dependency-free enhancement; it reads the JSON and mutates the existing SVG. SVG was kept over canvas for accessibility, a no-script fallback, tiny output, and sufficient speed at 250 nodes (see hardening).

The renderer is not the knowledge model. The built-in renderer consumes a SiteModel, never source files. The official Astro website is a separate consumer of product copy and does not render users' documentation.

The page renderer can be selected with [site] renderer = "flowview" in entwine.toml. This remains experimental; omitting it selects the built-in renderer. The default Entwine build supports Rust 1.85 and excludes Flowview's compiler dependency tree. To include it, build with cargo build -p entwine-cli --features flowview-renderer; experimental builds require a newer Rust compiler while Flowview's Oxc dependencies require Rust 1.94. Flowview remains an optional dependency of entwine-engine only and receives a narrow, host-prepared page view. A build without the feature reports an actionable error when Flowview is explicitly selected. See the decision record.

Determinism and safety

Paths, routes, relations, assets, roles, and diagnostics are explicitly sorted. Headings get stable unique IDs. SVG positions depend only on the sorted graph. Links are relative for subpath hosting. Symbolic links and escaping paths are rejected, including by init and setup, which never write through a symlink and never overwrite existing files. Raw HTML is displayed as text except narrowly recognized empty anchors; unsafe URL schemes are errors. Repository references never become knowledge relations.

The CLI stages a complete tree before replacing owned dist/ output. Validation errors preserve the last successful build. Unrelated dist/ directories are never replaced automatically.

See current state and roadmap for the product boundary, and deployment for how the portable dist/ output is published.

Repository sources

The workspace manifest defines the implementation crates. Project instructions describe repository development rules. Repository files remain references, distinct from Markdown knowledge relationships.

Source: docs/architecture.md

Generated by Entwine · Markdown remains the source of truth.