Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ on:
paths:
- 'dokimi/fuzz/**'
- 'dokimi/dokimi/llm_json.py'
- 'dokimi/dokimi/utils.py'
- 'dokimi/dokimi/frontmatter.py'
- 'dokimi/dokimi/files.py'
- 'dokimi/dokimi/records.py'
- 'dokimi/dokimi/digest.py'
- 'dokimi/dokimi/model_names.py'
- 'dokimi/dokimi/eval/checklist.py'
- 'dokimi/dokimi/eval/pairwise.py'
- 'dokimi/dokimi/eval/reference_checks.py'
Expand Down
3 changes: 3 additions & 0 deletions dokimi/changelog.d/20261124_120000_napetrov_arch-c14.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- **`dokimi.utils` names moved to focused modules.** Import from the new home: `parse_frontmatter`, `parse_frontmatter_strict`, `describe_yaml_error` from `dokimi.frontmatter`; `InputError`, `read_json_input`, `read_json_input_bytes`, `refuse_device`, `is_symlink_loop`, `retry_writable` from `dokimi.files`; `key_bytes`, `digest_text`, `file_digest`, `tree_digest`, `file_contents`, `link_text`, `git_tree`, `GitTree` from `dokimi.digest`; `model_identity`, `same_model`, `same_evaluator`, `warn_judge_independence`, `warn_recorded_self_judge`, `check_bedrock_model` from `dokimi.model_names`; `question_id` from `dokimi.records`. No behavior changes. The old module still re-exports these names for compatibility.
4 changes: 2 additions & 2 deletions dokimi/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ points up:
| tracks | `runner`, `runs`, `report`, `subjects`, `novelty`, `harnesses`, `context`, `repos`, `explore`, `tool_preference`, `external`, `dashboard`, `orchestrator`, `datasets_export`, `coverage`, `task_formats`, and the checkers `config_check`, `schema_check`, `schema_compat` |
| evaluation | `eval`, `personas`, `questions`, `treatments`, `plugins` |
| components | `ingest`, `metrics`, `gate`, `mcp`, `skills`, `agent_profiles` |
| foundation | `__init__` (the `dokimi` package itself), `_version`, `artifacts`, `records`, `llm`, `process`, `container_policy`, `docker_cmd`, `caching`, `config`, `registry`, `intents`, `defaults`, `console`, `utils`, `metrics/usage.py` |
| foundation | `__init__` (the `dokimi` package itself), `_version`, `artifacts`, `records`, `llm`, `process`, `container_policy`, `docker_cmd`, `caching`, `config`, `registry`, `intents`, `defaults`, `console`, `digest`, `files`, `frontmatter`, `model_names`, `utils`, `metrics/usage.py` |

So `report` (a track) can call `gate` (a component), and `gate` cannot import
`report`. The sections below follow the tracks, not the layers.
Expand Down Expand Up @@ -477,7 +477,7 @@ deterministic checks on it; `dokimi memory lint`. Guide: [memory.md](memory.md).
decides who owns each pipe, so an interrupted launch closes its streams exactly once
and Windows reader threads close theirs at EOF. `FakeRunner` is its test adapter: code that spawns
takes a `runner` argument.
- Bad input: a library loader raises `dokimi.utils.InputError`, naming the file, and
- Bad input: a library loader raises `dokimi.files.InputError`, naming the file, and
never ends the process. `cli.main` prints `Error: <message>` and exits 2; exit 1 stays
the verdict of a gate. `tests/test_import_architecture.py` allows an exit only in the
frontend.
Expand Down
2 changes: 1 addition & 1 deletion dokimi/docs/judge-panel-study.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ What exists:
EFFECT` or `NOT MEASURED`. Judges that fail `--validity` do not vote. `--strict` makes
`JUDGE-DEPENDENT` an error. This is the right shape, per-judge numbers rather than an
average that hides the spread, and it already guards against "(one judge)" results.
- **Self-judging** is a warning on an exact model match (`utils.warn_judge_independence`).
- **Self-judging** is a warning on an exact model match (`dokimi.model_names.warn_judge_independence`).
It never refuses, and a judge from the same family passes silently.

What is missing (each item was needed to produce this note):
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/agent_profiles/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pathlib import Path
from typing import List

from dokimi.utils import parse_frontmatter
from dokimi.frontmatter import parse_frontmatter


@dataclass
Expand Down
8 changes: 4 additions & 4 deletions dokimi/dokimi/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from dokimi._version import __version__
from dokimi.atomic_write import write_bytes_in_place_or_atomic
from dokimi.process_io import json_utf8_bytes
from dokimi.utils import InputError, read_json_input
from dokimi.files import InputError, read_json_input

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -292,14 +292,14 @@ def save_artifact(kind: str, data: dict, path: Path | str, *, ensure_ascii: bool
process that last saved it, so an artifact built from a loaded one takes the new run's id.
``data`` itself is not mutated.
- A ``novelty`` payload with ``status`` or ``partial`` (what a ``--max-usd`` stop keeps) is
refused with :class:`~dokimi.utils.InputError`, as :func:`load_artifact` refuses it: nothing
refused with :class:`~dokimi.files.InputError`, as :func:`load_artifact` refuses it: nothing
is written, since ``runs`` would list the file as a finished run.
- The payload is validated first. :class:`ArtifactValidationError` means nothing was
written at ``path`` (a file already there is untouched); the rejected payload is kept
at ``<name>.rejected`` so a paid run is not lost to a schema problem. A later valid
save to ``path`` removes that ``<name>.rejected`` (only that sibling), so a leftover
always belongs to the latest attempt; if it cannot be removed the save still stands and
a warning is logged. :class:`~dokimi.utils.InputError` means ``DOKIMI_RUN_ID`` is malformed
a warning is logged. :class:`~dokimi.files.InputError` means ``DOKIMI_RUN_ID`` is malformed
(``cli.main`` refuses it before a command runs): nothing is written at ``path`` and the payload
is kept at ``<name>.rejected`` the same way. ``KeyError`` means ``kind`` is not registered in
:data:`SCHEMA_VERSIONS`.
Expand Down Expand Up @@ -389,7 +389,7 @@ def _is_partial_novelty(kind: str, data: dict) -> bool:
def load_artifact(kind: str, path: Path | str, *, validate: bool = True) -> dict:
"""Read and (optionally) validate an artifact of ``kind`` from ``path``.

Every failure is an :class:`~dokimi.utils.InputError` naming ``path``: a file that is
Every failure is an :class:`~dokimi.files.InputError` naming ``path``: a file that is
missing, unreadable, not UTF-8 or JSON, not a JSON object, or that fails the schema, and
the partial file of an unfinished novelty or arms run.
"""
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def main() -> None:
tolerate_console_encoding()
from dokimi import cli_output
from dokimi.artifacts import run_id
from dokimi.utils import InputError
from dokimi.files import InputError

cli_output.reset() # before the parse: a usage error prints its document from there
args = parse_args()
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/cli_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dokimi._version import __version__
from dokimi import artifacts
from dokimi.artifacts import SCHEMA_DIR
from dokimi.utils import InputError
from dokimi.files import InputError

SCHEMA_VERSION = "cli_output.v1"
STATUSES = ("complete", "partial", "budget_stopped", "cancelled", "failed")
Expand Down
4 changes: 2 additions & 2 deletions dokimi/dokimi/commands/answer_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import argparse
import json
from pathlib import Path
from dokimi.utils import InputError, read_json_input
from dokimi.files import InputError, read_json_input


def cmd_questions_import(args: argparse.Namespace) -> None:
Expand Down Expand Up @@ -50,7 +50,7 @@ def cmd_eval_reference(args: argparse.Namespace) -> None:
except ValueError as e: # ArtifactValidationError: names the record and the fix
raise InputError(str(e)) from e
if not args.no_judge:
from dokimi.utils import warn_recorded_self_judge
from dokimi.model_names import warn_recorded_self_judge

warn_recorded_self_judge(data, [(args.judge_model, args.judge_provider)], "eval score reference")
try:
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
DEFAULT_MAX_TOKENS_PER_QUESTION,
DEFAULT_RETRIEVAL_TOP_K,
)
from dokimi.utils import InputError
from dokimi.files import InputError


def _load_runtime_config() -> dict:
Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/commands/arms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from dokimi.commands.novelty_budget import fresh_partial_destination
from dokimi.exit_codes import EXIT_FAILURE, EXIT_USAGE
from dokimi.llm import ANSWER_PROVIDERS
from dokimi.utils import InputError, question_id
from dokimi.files import InputError
from dokimi.records import question_id
from dokimi.write_probe import can_write
from dokimi.eval.judge import JUDGE_PROVIDERS
from dokimi.defaults import (
Expand Down
4 changes: 2 additions & 2 deletions dokimi/dokimi/commands/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

from dokimi.artifacts import _write_target, save_artifact
from dokimi.atomic_write import write_bytes_atomic
from dokimi.utils import model_identity, same_model
from dokimi.model_names import model_identity, same_model
from dokimi.commands import baseline_regression
from dokimi.commands._output import exit_on_rejected
from dokimi.exit_codes import EXIT_INVALID
from dokimi.utils import InputError, read_json_input, read_json_input_bytes
from dokimi.files import InputError, read_json_input, read_json_input_bytes

BASELINES_DIR = Path("baselines/eval")

Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/baseline_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import math
from decimal import Decimal, InvalidOperation

from dokimi.utils import InputError
from dokimi.files import InputError
from dokimi.records import BASELINE, CONTEXT, Record


Expand Down
5 changes: 3 additions & 2 deletions dokimi/dokimi/commands/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dokimi import cli_flags
from dokimi.eval.judge_sampling import check_judge_sampling
from dokimi.llm import CALLER_CHOICES, PROVIDER_ALIASES, PROVIDERS, credential_env_var, resolve_api_key, resolve_model
from dokimi.utils import warn_judge_independence as _warn_judge_independence
from dokimi.model_names import warn_judge_independence as _warn_judge_independence
from dokimi.eval.judge import JUDGE_PROVIDERS
from dokimi.defaults import (
DEFAULT_ANSWER_MODEL,
Expand All @@ -30,7 +30,8 @@
from dokimi.commands.library import _load_registry
from dokimi.exit_codes import EXIT_USAGE
from dokimi.llm_cli import SamplingError
from dokimi.utils import InputError, check_bedrock_model, refuse_device
from dokimi.files import InputError, refuse_device
from dokimi.model_names import check_bedrock_model


def _refuse_judge_sampling(args: argparse.Namespace) -> None:
Expand Down
4 changes: 2 additions & 2 deletions dokimi/dokimi/commands/cache_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def usable_cache_dir(raw: str | None, use: str = RETENTION_USE, *, label: str =
call or a clone (#701, #765). ``use`` closes the message: "pass a directory <use>"; ``label`` names the
setting at its start (``--cache-dir`` unless the caller says otherwise: #826).
"""
from dokimi.utils import InputError
from dokimi.files import InputError

if not raw:
return None
Expand Down Expand Up @@ -53,7 +53,7 @@ def resolved_cache_dir(raw: str | None, use: str, *, label: str) -> Path | None:
A path that cannot be resolved (an unreadable ancestor, a symbolic link loop) raises ``InputError`` naming ``label``.
The resolved path is returned: the cache is made there.
"""
from dokimi.utils import InputError
from dokimi.files import InputError

if not raw:
return None
Expand Down
6 changes: 3 additions & 3 deletions dokimi/dokimi/commands/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ok_text, plain_note, print_skill_row, skill_row, skipped_note, unrestricted_and_risky,
)
from dokimi.external.catalog_rates import RateTally, text_lines
from dokimi.utils import InputError
from dokimi.files import InputError


def _print_strict_reasons(rows: list, strict: bool) -> None:
Expand Down Expand Up @@ -489,7 +489,7 @@ def cmd_catalog_formats(args: argparse.Namespace) -> None:

def _question_sources(specs: list) -> list:
"""Each ``--questions PATH=LABEL`` as a (questions, rule) source."""
from dokimi.utils import read_json_input
from dokimi.files import read_json_input

sources = []
for spec in specs:
Expand All @@ -512,7 +512,7 @@ def _trigger_set_sources(specs: list, catalog) -> list:
any other source. TARGET names the skill a skill-creator set was written for.
"""
from dokimi.external import trigger_set as ts
from dokimi.utils import read_json_input
from dokimi.files import read_json_input

names = {s.name for s in catalog}
out = []
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/catalog_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from dokimi import __version__
from dokimi.artifacts import save_artifact
from dokimi.utils import InputError
from dokimi.files import InputError

_OUTPUTS = ("catalog.json", "plan.json", "result.json", "report.md")
_REPORT_HEADER = "# Catalog static evaluation"
Expand Down
4 changes: 2 additions & 2 deletions dokimi/dokimi/commands/catalog_novelty.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from dokimi.cli_types import unit_interval
from dokimi.commands.novelty_run import stops_at_cap
from dokimi.novelty.sweep import bundle_instances, read_rows, resumable, summarize, summary_lines
from dokimi.utils import InputError
from dokimi.files import InputError

if TYPE_CHECKING:
from dokimi.novelty.client import SpendCap
Expand Down Expand Up @@ -113,7 +113,7 @@ def directory(self) -> Path:
def _skill_digest(skill_md: Path) -> str:
"""The digest a resumed run compares: the directory tree, and the entry point's loaded content
(a symlinked SKILL.md changes its target's text without changing the link the tree digest reads)."""
from dokimi.utils import tree_digest
from dokimi.digest import tree_digest

entry = hashlib.sha256(skill_md.read_bytes()).hexdigest()
tree = tree_digest(skill_md.parent.resolve(), tracked={}) # resolved: tree_digest hashes a symlinked ROOT by its link text
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/catalog_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pathlib import Path
from dokimi import cli_flags
from dokimi.atomic_write import write_text_atomic
from dokimi.utils import InputError
from dokimi.files import InputError
from dokimi.write_probe import can_write


Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/catalog_provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pathlib import Path

from dokimi import cli_flags
from dokimi.utils import InputError
from dokimi.files import InputError


def _rel(skill_dir: Path, root: Path) -> str:
Expand Down
6 changes: 3 additions & 3 deletions dokimi/dokimi/commands/catalog_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
from dokimi.external.catalog_rates import RateTally, text_lines
from dokimi.external.listing import listed_chars
from dokimi.external.skill_format import NOT_CHECKED_CODES, not_checked
from dokimi.utils import InputError
from dokimi.files import InputError


def _listing_source(entry):
"""``(file, meta, body, directory name, at root, sha256 of the bytes read)`` of the SKILL.md ``repo budget`` would read for the entry, None when
it is not named ``SKILL.md``, cannot be read or resolves outside the catalog root. The directory name and ``at root`` are
those of the directory the skill is listed in, not of a symlink target."""
from dokimi.utils import parse_frontmatter
from dokimi.frontmatter import parse_frontmatter

if entry.path is None:
return None
Expand Down Expand Up @@ -174,7 +174,7 @@ def skill_dir_digest(entry, outputs: Iterable[Path] = ()) -> Optional[str]:

Files in *outputs* (resolved paths) that sit in the directory are left out. None when it cannot be read.
"""
from dokimi.utils import tree_digest
from dokimi.digest import tree_digest

path = entry.skill.path.parent if entry.loaded and entry.skill is not None else entry.path
if path is not None and path.name == "SKILL.md":
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import NoReturn

from dokimi.cli_types import non_negative_int, unit_interval
from dokimi.utils import InputError, refuse_device
from dokimi.files import InputError, refuse_device


def cmd_context_trace(args: argparse.Namespace) -> None:
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from dokimi import cli_flags
from dokimi.commands._output import exit_on_rejected
from dokimi.utils import InputError
from dokimi.files import InputError


def cmd_dashboard_generate(args: argparse.Namespace) -> None:
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import argparse
from pathlib import Path
from dokimi.utils import InputError
from dokimi.files import InputError


def cmd_dataset_export(args: argparse.Namespace) -> None:
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/eval_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pathlib import Path

from dokimi.exit_codes import EXIT_FAILURE, EXIT_USAGE
from dokimi.utils import InputError
from dokimi.files import InputError


METRICS = ("weighted", "core_rare_critical", "rare_critical")
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/eval_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import TYPE_CHECKING

from dokimi.exit_codes import EXIT_FAILURE
from dokimi.utils import InputError
from dokimi.files import InputError

if TYPE_CHECKING:
from dokimi.novelty.needs import NeedGraph
Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/commands/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from dokimi.eval.judge_validity import DEFAULT_MIN_ACCURACY, NoUsablePairs
from dokimi.commands._output import save_artifact_or_exit
from dokimi.exit_codes import EXIT_INCONCLUSIVE
from dokimi.utils import InputError, warn_judge_independence, warn_recorded_self_judge
from dokimi.files import InputError
from dokimi.model_names import warn_judge_independence, warn_recorded_self_judge


_warn_judge_independence = warn_judge_independence
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import NoReturn

from dokimi import cli_flags
from dokimi.utils import InputError
from dokimi.files import InputError

_TASKS_ROOT_HELP = (
"Directory of exploration task YAML files (default: data/explore_tasks of a "
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/headroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from dokimi.artifacts import ENVELOPE_KEYS
from dokimi.commands._output import exit_on_unwritable
from dokimi.eval.judge_context import PROTOCOL_MIXED
from dokimi.utils import InputError
from dokimi.files import InputError


def _read_json(path) -> Any:
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import argparse
import sys
from pathlib import Path
from dokimi.utils import InputError
from dokimi.files import InputError


def cmd_ingest_docling(args: argparse.Namespace) -> None:
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

from pathlib import Path
from dokimi.utils import InputError, refuse_device
from dokimi.files import InputError, refuse_device


def read_text_or_exit(path: str | None, flag: str) -> str | None:
Expand Down
Loading
Loading