Skip to content

Record

View source on GitHub

Records hold document data. Use the project's Vault for filesystem access and collection operations. Pass overwrite=True to replace an existing record.

Record

Bases: BaseModel

A lightweight, validated research document.

Attributes:

Name Type Description
id str

Bundle-relative concept path, without the .md suffix.

title str | None

Optional OKF display title.

markdown Markdown

Markdown content of the record.

parent_id str | None

Optional relative path of a parent record.

related_to list[str]

Optional relative paths of related records.

type str

Nonblank, producer-defined OKF concept type.

commit str | None

Optional commit hash associated with the record.

status Literal['draft', 'stable', 'deprecated']

OKF concept lifecycle: draft, stable, or deprecated.

state str | None

Optional workflow-defined research progress.

decision str | None

Optional record decision.

branch str | None

Optional record branch.

type class-attribute instance-attribute

type: str = Field(
    ..., description="OKF concept type.", min_length=1
)

title class-attribute instance-attribute

title: str | None = Field(
    default=None, description="Optional OKF display title."
)

description class-attribute instance-attribute

description: str | None = Field(
    default=None,
    description="Optional short description of the concept.",
)

status class-attribute instance-attribute

status: Literal["draft", "stable", "deprecated"] = Field(
    default="stable",
    description="OKF concept lifecycle status.",
)

resource class-attribute instance-attribute

resource: str | None = Field(
    default=None,
    description="Optional URI or path to an associated resource.",
)

tags class-attribute instance-attribute

tags: list[str] = Field(
    default_factory=list,
    description="Tags that categorize this concept.",
)

generated class-attribute instance-attribute

generated: dict[str, Any] = Field(
    default_factory=dict,
    description="Generated metadata for this concept.",
)

verified class-attribute instance-attribute

verified: list[dict[str, Any]] | None = Field(
    default=None,
    description="Verification evidence associated with this concept.",
)

id class-attribute instance-attribute

id: str = Field(
    ...,
    description="Bundle-relative concept path, without the .md suffix.",
)

markdown class-attribute instance-attribute

markdown: Markdown = Field(
    default_factory=lambda: Markdown(""),
    description="Markdown content of the record.",
)

parent_id class-attribute instance-attribute

parent_id: str | None = Field(
    default=None,
    description="Optional bundle-relative ID of a parent record.",
)

related_to class-attribute instance-attribute

related_to: list[str] = Field(
    default_factory=list,
    description="Bundle-relative IDs of related records.",
)

commit class-attribute instance-attribute

commit: str | None = Field(
    default=None,
    description="Optional commit hash associated with the record.",
)

decision class-attribute instance-attribute

decision: str | None = Field(
    default=None,
    description="Optional decision recorded for this concept.",
)

branch class-attribute instance-attribute

branch: str | None = Field(
    default=None,
    description="Optional version-control branch associated with it.",
)

state class-attribute instance-attribute

state: str | None = Field(
    default=None,
    description="Optional workflow-defined research progress state.",
)

metadata property

metadata: dict[str, Any]

Return the record's serialized metadata, excluding its Markdown body.

Vault

Read and write Markdown records under a bundle root.

Record IDs are paths relative to root without the .md suffix. Call :meth:validate to check relationships across the collection.

Create a vault for the given records directory without creating it.

root instance-attribute

root = Path(root).absolute()

file_path

file_path(record_id: str) -> Path

Return the contained Markdown path for an ID without checking existence.

View source on GitHub

load

load(record_id: str) -> Record

Load one record by ID without scanning or validating other records.

View source on GitHub

create

create(id: str, **fields: Any) -> Record

Validate and save a new record at id.

Refuses to replace existing files.

View source on GitHub

list

list() -> builtins.list[Record]

Load records recursively in ID order; ignore index.md and log.md.

Relationships between records are not checked.

View source on GitHub

children

children(record_id: str) -> builtins.list[Record]

Return records that declare record_id as their parent, sorted by ID.

View source on GitHub

descendants

descendants(record_id: str) -> builtins.list[Record]

Return transitive descendants by declared parent IDs.

Tolerates cycles and missing nodes.

View source on GitHub

save

save(record: Record, *, overwrite: bool = False) -> Path

Validate and atomically write one record.

Replace existing files only with overwrite=True. Relationships are not checked.

View source on GitHub

update

update(record: Record, patch: RecordUpdate) -> Record

Apply supplied fields and save the record; markdown replaces its body.

The ID cannot be changed, and relationships to other records are not checked.

View source on GitHub

delete

delete(record_id: str) -> None

Delete one record and remove its empty parent directory if possible.

Other records' references are unchanged; call :meth:validate to find dangling IDs.

View source on GitHub

validate

validate() -> None

Scan the collection and check that declared parent and related IDs exist.

Parent cycles are allowed.

View source on GitHub