Skip to main content

Module entity

Module entity 

Source
Expand description

The entity module: every object of the layer as an addressable, cross-linked node.

objects.get answers what a file is. This module answers the three further questions a governance object is actually read for, and answers them for every kind at once because none of them is asked of a kind by name:

  • Where does it live? Its route, derived from its kind and identity by crate::entity::slug, the same function the Cockpit resolves a request with.
  • What is it joined to? Its outgoing references and — the half nothing declared — the references that resolve to it, both read from the one relation table the graph and the dangling-reference check already share.
  • Where is it published? Its public documentation page, when the repository’s site publishes its kind: crate::entity::Publication reads site/data/publication.toml and the site’s base_url, the same declaration the site generator builds the pages from, so the address named here is the page the site holds.
  • What can be said about its enforcement? Which of the executable artefacts it names are in the tree, stated as a state a page may not round up, and a pointer to the capability that can prove more where the registry holds one.

Nothing here enumerates kinds, entities or routes. A file added under .ai/ becomes an object, an object has a route, and this capability answers for it — which is the whole of project.entities-are-routable.

One entity is asked for either way a caller already holds it — the URI the layer indexes it by, or the address a reader was given — and the two name the same object:

use majordomus_cli::capability::builtin::entity::{EntityInput, EvidenceState};

let by_uri: EntityInput =
    serde_json::from_value(serde_json::json!({ "uri": "majordomus://rule/project.x@1" }))
        .unwrap();
assert_eq!(by_uri.uri.as_deref(), Some("majordomus://rule/project.x@1"));

let by_route: EntityInput =
    serde_json::from_value(serde_json::json!({ "kind": "rule", "slug": "project-x-1" }))
        .unwrap();
assert_eq!(by_route.kind.as_deref(), Some("rule"));

// a key nobody declared is an error, not a silently ignored field
assert!(serde_json::from_value::<EntityInput>(serde_json::json!({ "url": "x" })).is_err());

// and what the answer may say about enforcement is a state, never a run
let unclaimed = serde_json::to_value(EvidenceState::Unclaimed).unwrap();
assert_eq!(unclaimed, serde_json::json!("unclaimed"));

Structs§

ClaimedArtifact
One executable artefact an object names, and whether the tree holds it.
EntityInput
Which entity: by URI, or by the address it is served at.
EntityView
One object of the layer as an addressable node: what it is, where it is served, what it is joined to, and what can be said about its enforcement.
Evidence
What can be said about an object’s enforcement without running anything.
KindEntry
One kind of the layer, with its address and how many objects it holds.
KindList
Every kind of the layer, each with its route, and every route collision there is.
ProofRef
Where a fuller answer about this entity’s enforcement lives.

Enums§

EvidenceState
What this repository can say about the executable artefacts an object names, and only that. The word is chosen so that no reader can mistake it for a run.

Functions§

module
The canonical declaration of the entity module: the two capabilities that answer for an object and for the catalogue of kinds, with every projection each is exposed through.