Skip to content

Latest commit

 

History

History
187 lines (168 loc) · 11.2 KB

AGENTS.md

File metadata and controls

187 lines (168 loc) · 11.2 KB

Agent guide

This repo is dokimi, A/B testing for agent context: it measures whether documentation, a skill, an MCP doc source, or an agent persona prompt improves a coding agent's answers and task outcomes. The content it measures (skills, executable tasks, golden question sets) lives in content repositories and is passed in by path: skill:<path>, --tasks-root, --questions.

All code, tests and CI live in the dokimi/ project directory; run commands from there. The importable package is dokimi (dokimi/dokimi/); the CLI is python cli.py --help.

Done means make ci-local is green

make dev        # once, repo root: .venv with CI's Python, the lock, every CI tool
make ci-local   # every PR CI step, read from .github/workflows/; pass/fail/skip table
make ci-local CI_LOCAL_ARGS='--offline --jobs static,typecheck'   # fast inner loop

A change is ready for a PR when no row of the make ci-local table is FAIL. ci-local diffs against the remote whose URL is intel/dokimi, whatever it is called (CI_LOCAL_ARGS='--remote <name>' overrides). The full pytest run takes 2–3 minutes, longer than a default 2-minute command timeout: give it a 10-minute timeout, and run the test files you touched first. Beyond lint and tests, CI also holds a PR to:

  • 80% coverage of changed lines (when 20+ are measurable): add tests with the change.
  • mypy on the whole package, no module exempt: fix a type error rather than adding an ignore_errors override to pyproject.toml.
  • Imports follow the layers in dokimi/tests/test_import_architecture.py: no upward import, no new cycle, LLM SDKs only in dokimi.llm, spawns only in dokimi.process. Its baselines only shrink.
  • No growth: a file over 800 lines (tests 1000) or a function over complexity 10 fails unless scripts/growth_baseline.json holds it, and then it may only shrink. Split instead; after shrinking, python scripts/check_growth.py --update.
  • No new clones: a block of 40+ AST nodes copied elsewhere in dokimi/, scripts/ or cli.py (locals renamed or not) fails scripts/check_duplicates.py unless scripts/duplicates_baseline.json holds it. Extract the shared code instead.
  • Tests that check behaviour: tests/test_audit_test_quality.py fails a test that only checks types, echoes its input, only checks a mock was called, asserts nothing or repeats another (python scripts/audit_test_quality.py lists them).
  • No silent test narrowing (scripts/check_test_narrowing.py): removing a test, dropping a check, adding skip/xfail, dropping match= or widening pytest.raises, loosening a tolerance or cutting parametrize cases fails unless a commit message or a comment in the test says Test-narrowed: <reason>. So does a skip at the top of a module, and a collect_ignore* or pytest_ignore_collect a conftest.py gains (waived by a commit line).
  • Docs that name a command, flag, path or module must match the tree (tests/test_docs_code_refs.py): rename in code, rename in docs.
  • Tests run offline: a connection off loopback fails the test, so mock LLM and network calls.
  • Tests wait on a condition, not on time: a test that waits for a thread, process or timer uses tests/waiting.py, never time.sleep or threading.Timer. scripts/check_test_timing.py fails a new one unless its baseline holds it (it only shrinks) or the line says # timing-ok: <reason>. A complexity test counts work or uses tests/growth_timing.py, never an elapsed-time assertion.
  • Comments of at most two lines (scripts/check_comment_blocks.py): say the constraint or the reason, and end with an issue or PR URL when a reader needs the backstory. A block of three or more # lines fails once the PR adds or edits a line in it, so shorten an old block when you touch it.
  • No silent except (ruff BLE001, S110, S112): catch the exception you expect, or log it with its traceback, or re-raise. A site that must catch everything says what happens to the failure in # noqa: BLE001 - <reason> (tests/test_noqa_reasons.py fails a bare code).
  • User outcomes (tests/outcomes/*.json, checked by pytest --outcomes): a test marked @pytest.mark.outcome(...) is evidence for a promise in the docs; weaken or drop it only together with the doc and the contract. The same session checks the journey trace (tests/outcomes/journeys.yaml against docs/user-journeys/journeys.md) and writes journeys-result.json; removing a marked cjm-* test fails it, even when outcomes-result.json says pass, if the criterion it evidences has enforce: true.

Before changing a subsystem, read its doc

  • Any module, or where new code goes: dokimi/docs/architecture.md.
  • A static metric: dokimi/docs/contributing-metric.md.
  • A doc source: dokimi/docs/adding-doc-source.md.
  • Repository evaluation (dokimi/dokimi/repos/, cli.py repo …): dokimi/docs/repo-evaluation-contract.md.
  • Skill novelty (dokimi/dokimi/novelty/, cli.py novelty …): dokimi/docs/skill-novelty.md.
  • Executable tasks (Docker + oracle solution + pytest verifier) or harnesses: dokimi/docs/contributing-terminal-bench-task.md. Tasks live in a content repository; the framework reads a checkout via --tasks-root.
  • Anything else: the index, dokimi/docs/documentation-index.md. A new page at any depth under dokimi/docs/ goes in that index (dokimi/tests/test_docs_links.py checks it) and in the nav: of dokimi/mkdocs.yml, the published site.

Registries, bundled in the package (dokimi/dokimi/) so they ship in the wheel:

  • dokimi/dokimi/products.yaml: product identity and doc sources.
  • dokimi/dokimi/intents.yaml: problem/intent domains, and the only domain→product mapping.
  • dokimi/dokimi/config/products.yaml: LLM/runtime config for the eval track; its product identity follows products.yaml (config_check fails on drift).

Persisted formats

  • Every artifact format is a versioned JSON Schema in dokimi/dokimi/schemas/ (<kind>.vN.json). Edit a version in place only to widen it. A change that would reject an artifact already written under it is a new version: add <kind>.v<N+1>.json, point artifacts.SCHEMA_VERSIONS at it, list the old one in SUPERSEDED_VERSIONS. CI's schema_compat step (ci.yml, static) checks this against the PR base.
  • Answer and eval JSON name the two answer conditions with_docs and without_docs, and every stored run uses them: writers, readers, schemas and data files keep those keys. Text people read (report headings, console output) may label the conditions however it reads best.
  • Code that reads answers, eval or arms records goes through dokimi/dokimi/records.py (read/load/records), not .get("with_docs") on the dict: it is the one place that knows the keys the writers write. dokimi/tests/test_records_guard.py fails a new such read and lists the exceptions, which only shrink.

What goes in the tree

  • Runs write to git-ignored output dirs under dokimi/: results/, reports/, answers/, eval/ (not the dokimi/dokimi/eval/ package), baselines/. Logs, coverage files and tarballs stay local too.
  • dokimi/data/ holds only the fixtures this repo's own tests and examples read: data/skills/fastcontext/, data/agent_profiles/, data/explore_tasks/. The one other skill there, data/skills/dokimi-design-evals/, is guidance for using dokimi itself, not a product skill; its links and commands are checked by tests/test_bundled_skills.py. Question sets, product skills and tasks belong in their content repository.
  • A file the package reads at run time goes inside dokimi/dokimi/ and into [tool.setuptools.package-data], or the installed wheel goes without it.
  • Design rationale, status and plans go in the PR description or an issue; the tree has no ADRs or status reports. The one exception is the research register, dokimi/research/records/: one record per idea, experiment, finding, decision or implementation link, negative results included (dokimi/docs/research-register.md).
  • A new file starts with the SPDX header (Copyright (C) <year> Intel Corporation / SPDX-License-Identifier: Apache-2.0) in its comment syntax. CI's license header step (static job) checks it and make ci-local does not: exemptions and the local command are in dokimi/CONTRIBUTING.md.

Commits and pull requests

  • Commit with git commit -s: the repo is public and takes DCO sign-off (CONTRIBUTING.md at the root).
  • A PR that changes dokimi/dokimi/, dokimi/data/ or the [project] (bar project.version) / [tool.setuptools] tables of dokimi/pyproject.toml adds a changelog fragment under dokimi/changelog.d/ (scriv create), never an edit to CHANGELOG.md; the Fragment for package changes step in ci.yml's static job enforces it. Versioning and releases: dokimi/docs/releasing.md.
  • Every change to main is a PR opened from a fork, based on main. Add the fork as its own remote so origin keeps pointing at intel/dokimi: gh repo fork --remote --remote-name fork, then git push -u fork <branch> and gh pr create -R intel/dokimi --base main --head <you>:<branch>. Push branches only to the fork, even with write access to intel/dokimi (bot branches, dependabot/* and renovate/*, are the exception).
  • When a change depends on an open PR, wait for it to merge or put both in one PR; PRs are not stacked on each other's branches.

Before opening a PR

Review it yourself the way REVIEW.md asks a reviewer to, so the first round finds little:

  • For each test of changed behaviour, break the code it covers (flip a condition, drop a branch), confirm the test fails, then revert the break. CI's Mutation of changed lines job (dokimi/scripts/mutate_changed.py) does this for the package lines a PR changes, up to 40 mutants, and lists each surviving mutant in its step summary. A survivor whose module has a candidate test file that did not run is inconclusive, not a gap. It warns, it does not fail: kill a survivor with an assertion, or say in the description why it is equivalent. Run it locally with python scripts/mutate_changed.py --base origin/main from dokimi/.
  • For a bug fix, find every other site with the same bug class. Fix the ones within this PR's scope; list the rest in the description or an issue.
  • Where it applies, run the changed command on a bad input: missing file, empty file, wrong shape, None where a value is expected, a Windows path. Say in the description what you could not run.
  • Trace new error paths and tests to the contract: a new raise, sys.exit or refusal names, in its message, docstring or the PR, the doc, contract or issue that asks for it; a test of new behaviour cites the doc line it checks. python scripts/list_new_error_paths.py --base origin/main (from dokimi/) lists the sites of a raise, a sys.exit or SystemExit call, or a literal exit_code=N; refusals through parser.error or return N are not listed.
  • An unclear requirement goes in the PR description's "Open questions", not into code that guesses: no error path or test the spec cannot be quoted for.
  • Check that the PR title, description, docstrings and changelog fragment say what the code does (exit codes especially).
  • Re-review your own fix commits during review with the same care.