Skip to main content

Crate openakb_validate

Crate openakb_validate 

Source
Expand description

Validator for OpenAKB agent knowledge base descriptors.

The crate provides structural validation for parsed descriptors (serde_json::Value) against the embedded OpenAKB v1 JSON Schema plus descriptor-local semantic rules. Mode::Strict adds AKB006 unknown-core-property findings. Opt-in async content checks verify referenced bytes when a caller supplies a Resolver.

use openakb_validate::{Mode, validate};
use serde_json::json;

let descriptor = json!({
    "$schema": "https://schema.openakb.org/v1/openakb.schema.json",
    "id": "example-akb",
    "title": "Example AKB",
    "description": "A tiny descriptor for documentation examples.",
    "sources": [
        {
            "id": "SRC-000001",
            "type": "url",
            "uri": "https://docs.example.com/source/"
        }
    ],
    "sections": [
        {
            "id": "SEC-000001",
            "title": "Overview",
            "description": "A section grounded in the primary source.",
            "content_uri": "sections/overview.md",
            "source_ids": ["SRC-000001"]
        }
    ]
});

let result = validate(&descriptor, Mode::Strict);
assert!(result.ok());

Structs§

Advisory
A non-fatal validation advisory.
Citation
One recognized inline citation marker, with source ids in written order.
ContentCheck
One content check and its three-state outcome.
ContentReport
Aggregate result for opt-in content checks.
Finding
A validation finding with a stable diagnostic code.
FullReport
Combined structural and opt-in content validation result.
LocalFileResolver
Resolves scheme-less relative paths under a local base directory.
Unfetchable
A resolver-level fetch failure.
ValidationResult
Complete validation outcome.

Enums§

CheckKind
Content check category.
Code
Stable OpenAKB diagnostic code.
Mode
Validation mode.
Outcome
Three-state outcome for a content check.
Segment
One segment in a JSON Pointer path.

Constants§

CITE_ID_CHARSET
Inline [cite:] id-token characters (spec §4.4): a case-insensitive superset of the typed source-id form. Hyphen last so this doubles as a regex class body.
CITE_ID_MAX_LENGTH
Maximum length of an inline [cite:] id token (spec §4.4).
PARENT_DEPTH_MAX
Maximum allowed depth for parent chains.
STRUCTURAL_DEPTH_MAX
Maximum structural nesting depth a descriptor may reach before crate::validate declines the recursive schema walk and reports AKB011 instead of risking a stack-overflow abort.

Traits§

Resolver
Fetches descriptor-related content bytes.

Functions§

check_content
Runs opt-in content checks against fetched descriptor resources.
extract_citations
Extract one citation entry per recognized marker in Markdown source order.
json_pointer
Builds an RFC 6901 JSON Pointer from path segments.
validate
Validates a parsed OpenAKB descriptor against the embedded schema and descriptor-local semantic rules.
validate_with_content
Runs structural validation and opt-in content checks.