Schema Validators¶
akms.schema.validators
¶
YAML frontmatter parsers and validators for AKMS v2 schemas.
All parse functions validate schema version and return typed Pydantic models.
parse_node_frontmatter
¶
parse_node_frontmatter(
path: str | Path,
*,
is_local: bool = False,
is_code_mirror: bool = False,
) -> (
GlobalNodeFrontmatter
| LocalNodeFrontmatter
| CodeMirrorNodeFrontmatter
)
Parse and validate a knowledge node's YAML frontmatter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the .md node file. |
required |
is_local
|
bool
|
If True, validates as a local node (allows agent source). |
False
|
is_code_mirror
|
bool
|
If True, validates as a code-mirror node. |
False
|
Returns:
| Type | Description |
|---|---|
GlobalNodeFrontmatter | LocalNodeFrontmatter | CodeMirrorNodeFrontmatter
|
Validated Pydantic model. |
Raises:
| Type | Description |
|---|---|
SchemaVersionError
|
If akms_schema doesn't match. |
SchemaValidationError
|
If required fields are missing or invalid. |
FileNotFoundError
|
If file doesn't exist. |
Source code in packages/akms/src/akms/schema/validators.py
parse_node_frontmatter_from_dict
¶
parse_node_frontmatter_from_dict(
data: dict[str, Any],
*,
is_local: bool = False,
is_code_mirror: bool = False,
path: str | None = None,
) -> (
GlobalNodeFrontmatter
| LocalNodeFrontmatter
| CodeMirrorNodeFrontmatter
)
Parse and validate frontmatter from a pre-loaded dict.
Useful when frontmatter has already been extracted (e.g., during build).
Source code in packages/akms/src/akms/schema/validators.py
parse_local_state
¶
Parse and validate local_state.yaml.
Returns:
| Type | Description |
|---|---|
LocalStateOverlay
|
Validated LocalStateOverlay model. |
Source code in packages/akms/src/akms/schema/validators.py
parse_agent_memory
¶
Parse and validate a per-task AgentMemory file.
Returns:
| Type | Description |
|---|---|
AgentMemory
|
Validated AgentMemory model. |
Source code in packages/akms/src/akms/schema/validators.py
parse_pcd
¶
Parse and validate a Phase Completion Document.
Returns:
| Type | Description |
|---|---|
PCD
|
Validated PCD model with zone extraction methods. |
Source code in packages/akms/src/akms/schema/validators.py
parse_propagation_config
¶
Parse and validate propagation_config.yaml.
Returns:
| Type | Description |
|---|---|
PropagationConfig
|
Validated PropagationConfig model. |