Skip to main content

Crate provui_core

Crate provui_core 

Source
Expand description

provui-core — a frontend-neutral UI composition core over prov.

prov describes a plaintext workspace; flower edits structured metadata; leaf edits prose. This crate is the composition of the three, with no opinion about what draws it — the same core is meant to sit under a TUI, a SwiftUI app behind UniFFI, or a test harness:

  • ProvBackend — a flower_core::Backend that edits a prov document’s embedded metadata through prov’s carrier-aware prov::edit::MetaEditor. Lossless: comments, key order, the carrier/format, and the prose body are all preserved. Unlike flower_core::FigBackend (a standalone config file, schema-free), a ProvBackend can carry the workspace schema — the controlled vocabularies and relations resolved from the prov config — so a frontend renders term pickers, spanning-link widgets, and type-directed edits.
  • DocumentSession — one open prov document edited through a flower metadata model and a leaf body editor, reconciled on save.
  • schema_from_config — the adapter turning a resolved prov WorkspaceConfig (+ its vocabularies) into a generic flower_core::Schema for the workspace’s content documents. This is where prov’s controlled vocabularies and spanning relation reach the UI. schema_for_document is the same adapter for one document: a field prov declares under: an index governs only the documents below it, so which declaration a document is edited under is a fact about where it sits.
  • config_schema() — the same trick turned on the config document itself, so the metadata editor a frontend already ships can edit a workspace’s policy instead of a hand-written settings form.
  • facets — what each frontmatter key is to prov: a relation, a pointer at machinery, identity, policy, a declared field, or a value prov only carries. Read off the workspace’s own vocabulary rather than a list this crate keeps.
  • links — the links a document’s frontmatter declares, each with the metadata path it sits at, so “is the row under the cursor a link?” is a question with an answer. Lexical: no filesystem, no registry.
  • body_links — the same question of the prose, answered with a byte range into the body instead of a metadata path. Both kinds carry a prov::Link and a TargetKind, and AnyLink is what lets one resolver answer for both — so following a link from the body caret and following one from the metadata cursor are the same code.
  • findings — what prov’s integrity check says about one document, placed: a broken link becomes a metadata path or a byte range in the body, which is a place an editor can draw. prov reports a relation’s name; this recovers the list index where the document’s own links make that unambiguous, and says so where they do not. DocumentSession::apply_findings then hands each half to the editor that owns it — leaf highlights under the prose, flower Annotations on the rows — so both widgets draw them without the host drawing anything.
  • workspaceWorkspaceView, which finds the workspace a document belongs to and resolves a link to a document you can open. The one piece that reads the filesystem, and read-only. It also runs that backwards: WorkspaceView::reference_to and reference_here give the link text to write to a document — or to a place inside one — in the workspace’s own reference style. Still a read; nothing is written and nothing is registered.

§What this crate will not do for you

It classifies, and it never arranges. Nothing here hides a row, sinks one, reorders them, or makes one read-only — even where it plainly knows enough to: Facets can tell you id is minted and contents is structure, and hands you the lists shaped to go straight into flower’s derived and demoted sets, and then stops.

That is deliberate. An application over prov usually does separate prov’s structure from the values a person typed — diaryx does — but how is a product decision, and a mobile inspector, a terminal band and a settings sheet do not want the same one. The classification is general and lives here once; the arrangement is local and lives in the frontend. provui-tui’s nav module is a worked example of the whole policy, and it is two lines.

Scope: the single-document metadata surface (prov’s edit layer), plus read-only navigation across documents. Relation fields that maintain inverse links across documents belong to prov’s mutate layer — a later, relationship-aware backend, not this one. Following a link reads; retargeting one would write two documents, and this crate’s backend edits one.

Re-exports§

pub use config_schema::CONFIG_READONLY_KEYS;
pub use config_schema::config_schema;
pub use facets::Facet;
pub use facets::Facets;
pub use findings::Finding;
pub use findings::Severity;
pub use findings::Site;
pub use links::TargetKind;
pub use schema::Vocabularies;
pub use schema::schema_for_document;
pub use schema::schema_from_config;
pub use workspace::Destination;
pub use workspace::WorkspaceView;
pub use workspace::reference_here;
pub use workspace::reference_without_workspace;

Modules§

body_links
The links a document’s prose declares — where each one sits in the body text, what it says, and what shape of target it names.
config_schema
The config document → flower schema adapter — crate::schema one module over.
facets
What a frontmatter key is to prov — the classification, offered as a question and never applied.
findings
What is wrong with a document, placed where an editor can draw it.
links
The links a document’s metadata declares — where each one sits, what it says, and what shape of target it names.
rules
The rule builders config_schema is written in.
schema
The prov → flower schema adapter, for a workspace’s content documents.
workspace
Following a link — the one step that needs a workspace to take it in.

Structs§

DocumentSession
One open prov document: a metadata editor and a body editor over the same file, reconciled on save.
Heading
A heading in a document’s prose body.
ProvBackend
A backend over a single prov document, editing its embedded metadata.
SessionError
A session error, carrying a human-readable message. UniFFI-friendly to widen into a typed enum later.

Enums§

Region
Which of a session’s two editors a history step belongs to.

Functions§

annotations_of
The metadata half of a finding list, in flower’s own vocabulary.