audit

Audit descriptif d’un bundle OKF — inventaire et diagnostic de conformité.

OKF bundle audit — inventory and conformance diagnostic.

class okflint.audit.FileReport(path, depth, lines, chars, is_reserved, okf_status, frontmatter, wikilinks, markdown_links, split_candidate, diagnostics=<factory>)[source]

Bases: object

Analysis report for a .md file in the bundle.

chars: int
depth: int
diagnostics: list[Diagnostic]
frontmatter: dict[str, Any] | None
is_reserved: bool
lines: int
okf_status: Literal['conformant', 'partial', 'non_conformant']
path: str
split_candidate: bool
okflint.audit.analyze_file(file_path, bundle_path, vault_index)[source]

Full analysis of a .md file in the bundle.

Parameters:
  • file_path (Path) – Absolute path of the file.

  • bundle_path (Path) – Bundle root.

  • vault_index (dict[str, list[str]]) – Vault index for wikilink resolution.

Return type:

FileReport

Returns:

FileReport with all fields populated.

okflint.audit.compute_stats(files, vault_total)[source]

Aggregate global statistics for the report.

Only non-reserved files are counted in by_okf_status.

Parameters:
  • files (list[FileReport]) – List of individual file reports.

  • vault_total (int) – Total number of .md files in the entire vault.

Return type:

dict[str, Any]

Returns:

Statistics dictionary.

okflint.audit.get_okf_status(frontmatter)[source]

Determine the OKF status of a concept from its frontmatter.

Parameters:

frontmatter (dict[str, Any] | None) – Parsed frontmatter, or None if absent.

Return type:

Literal['conformant', 'partial', 'non_conformant']

Returns:

‘conformant’ | ‘partial’ | ‘non_conformant’

okflint.audit.run_audit(bundle_paths, vault_paths, *, target_filter=None, vault_index=None, manifest=None)[source]

Orchestrate the full audit of one or more OKF bundle roots.

Accepts RootConfig objects (with exclusion patterns), plain Paths, or a mix thereof. Single-value forms are accepted for backward compatibility.

When vault_index is provided it is reused directly and vault_paths is ignored, allowing the caller to build the index union once for a whole vault and then call run_audit per-bundle without rebuilding.

Parameters:
  • bundle_paths (Sequence[RootConfig | Path] | RootConfig | Path) – Root(s) of the bundle(s) to audit. RootConfig carries per-root exclusion patterns; plain Path implies no exclusions.

  • vault_paths (list[Path] | Path) – Root(s) of the Obsidian vault(s) (for the wikilinks index). Ignored when vault_index is supplied.

  • target_filter (Path | None) – If set, restrict scanning to files under this path. Used when –bundle is combined with –manifest as a sub-filter.

  • vault_index (dict[str, list[str]] | None) – Pre-built file index (stem → list of relative paths). When provided, vault indexing is skipped entirely.

  • manifest (Manifest | None) – When provided, each file is validated through the same engine as validate (core + profile + hygiene diagnostics). When None, diagnostics are core-only (F001/F002).

Return type:

dict[str, Any]

Returns:

Full audit report serialisable as JSON.