Skip to content
Merged
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
The table of contents is too big for display.
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

- **Utility helpers have focused import paths.** Use `dokimi.frontmatter` for frontmatter, `dokimi.files` for input and filesystem guards, `dokimi.digest` for digests, `dokimi.model_names` for model identity and `dokimi.records` for `question_id`. `dokimi.utils` keeps public import aliases. Private helpers and test patch targets use the defining module.
8 changes: 6 additions & 2 deletions dokimi/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ points up:
| tracks | `runner`, `runs`, `report`, `subjects`, `novelty`, `harnesses`, `agent_run`, `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`, `llm_providers`, `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`, `llm_providers`, `process`, `container_policy`, `docker_cmd`, `caching`, `config`, `registry`, `intents`, `defaults`, `console`, `digest`, `files`, `frontmatter`, `model_names`, `utils` (compatibility imports), `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.

`dokimi.utils` keeps public import aliases. Import private helpers and patch
moved helpers in their defining modules, for example `dokimi.digest` for
`tree_digest`.

## Static documentation track

Lives under `dokimi/{ingest,metrics,gate,runner,report}`. `gate/` and
Expand Down Expand Up @@ -478,7 +482,7 @@ deterministic checks on it; `dokimi memory lint`. Guide: [memory.md](memory.md).
and Windows reader threads close theirs at EOF. `dokimi/process_hooks.py` holds what the signal
handler runs before the kill (notices) and after it (hooks): a run directory records its stop there. `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
2 changes: 1 addition & 1 deletion dokimi/dokimi/agent_run/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from urllib.parse import urlsplit

from dokimi.repos.events import TRACE_FORMATS
from dokimi.utils import InputError
from dokimi.files import InputError

_WINDOWS = os.name == "nt"
_NPM_ENTRYPOINTS = {
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/agent_run/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from dokimi import process
from dokimi.harnesses.tasks import TaskSpec
from dokimi.utils import InputError
from dokimi.files import InputError

from .scoring import PROCESS_POINTS

Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/agent_run/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pathlib import Path
from typing import Any

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

from .scoring import usage_summary

Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/agent_run/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from dokimi.harnesses.tasks import TaskSpec
from dokimi.repos.events import convert
from dokimi.repos.transcript import Transcript
from dokimi.utils import InputError, tree_digest
from dokimi.digest import tree_digest
from dokimi.files import InputError

from .adapters import Adapter, Route, Unavailable, adapter_for
from .checker import SYSTEM_ENV, check, inconclusive, refuse_workspace_checker, session_env
Expand Down
8 changes: 4 additions & 4 deletions dokimi/dokimi/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from dokimi.atomic_write import write_bytes_in_place_or_atomic
from dokimi.dokimi_commit import dokimi_commit
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 @@ -303,14 +303,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 @@ -400,7 +400,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 @@ -459,7 +459,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 @@ -17,7 +17,7 @@
from dokimi import artifacts
from dokimi.artifacts import SCHEMA_DIR
from dokimi.dokimi_commit import dokimi_commit
from dokimi.utils import InputError
from dokimi.files import InputError

SCHEMA_VERSION = "cli_output.v1"
STATUSES = ("complete", "partial", "budget_stopped", "cancelled", "failed")
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
DEFAULT_JUDGE_PROVIDER,
)
from dokimi.repos.l0.config import new_failures
from dokimi.utils import InputError
from dokimi.files import InputError

if TYPE_CHECKING:
from dokimi.repos import RepoSource
Expand Down
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/agent_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from dokimi import cli_flags, cli_output
from dokimi.artifacts import save_artifact, stamp
from dokimi.exit_codes import EXIT_FAILURE, EXIT_INCONCLUSIVE
from dokimi.utils import InputError
from dokimi.files import InputError


def _live_cost(rows: list[dict[str, Any]]) -> dict[str, Any]:
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 @@ -16,7 +16,7 @@
from pathlib import Path
from dokimi import cli_flags
from dokimi.cli_model_ref import add_model_flag
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 @@ -52,7 +52,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 @@ -25,7 +25,7 @@
DEFAULT_MAX_TOKENS_PER_QUESTION,
DEFAULT_RETRIEVAL_TOP_K,
)
from dokimi.utils import InputError
from dokimi.files import InputError


def _load_questions(path: str) -> list:
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 @@ -19,7 +19,8 @@
from dokimi.report.arms_pairs import print_pairs_note, shown_mean
from dokimi.report.arms_report import ask_summary_lines
from dokimi.llm import ANSWER_PROVIDERS
from dokimi.utils import InputError, question_id, read_json_input
from dokimi.files import InputError, read_json_input
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 @@ -16,7 +16,7 @@
from dokimi.cli_model_ref import add_model_flag
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 @@ -32,7 +32,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 @@ -28,7 +28,7 @@
)
from dokimi.external.catalog_rates import RateTally, text_lines
from dokimi.llm import ANSWER_PROVIDERS, PROVIDER_ALIASES, is_litellm_route
from dokimi.utils import InputError
from dokimi.files import InputError


def _print_strict_reasons(rows: list, strict: bool) -> None:
Expand Down Expand Up @@ -520,7 +520,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 @@ -543,7 +543,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 @@ -21,7 +21,7 @@
from dokimi import __version__
from dokimi.atomic_write import keep_owner_group_mode
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, read_json_input
from dokimi.files import InputError, read_json_input
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 @@ -27,14 +27,14 @@
from dokimi.external.findings import locate
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 @@ -176,7 +176,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 dokimi.cli_types import non_negative_int, unit_interval
from dokimi.exit_codes import EXIT_INCONCLUSIVE
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/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dokimi.llm import ANSWER_PROVIDERS
from dokimi.harnesses.delivery import run
from dokimi.report.delivery import render
from dokimi.utils import InputError
from dokimi.files import InputError


def _cost_summary(observations: list[dict]) -> dict:
Expand Down
Loading
Loading