agentleFS
thetahealththetahealth/mirobody/AGENTS.md

mirobody

AGENTS.md1.4k starsChanged 2 months agoApache-2.0View on GitHub

Read this before touching the tree. It is the short version of CONTRIBUTING.md plus the things an agent gets wrong first. A Python 3.12+ health-data engine in three layers, and the layering is machine-checked (lint-imports, contracts in pyproject.toml): There is one agent, and it is not switched at request time. BaseAgent, the agent/base package and the ChatGPT Apps widgets under agent/resources were removed; do not reintroduce a second harness or a per-agent config suffix. A deployment that wants its own…

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read this before touching the tree.

    line 3
  2. Distinctive:

    Verify, don't reason: Before deleting "unused" code compute reachability transitively (a sibling may call it).

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Working on Mirobody with a coding agent

Read this before touching the tree. It is the short version of CONTRIBUTING.md plus the things an agent gets wrong first.

What this is

A Python 3.12+ health-data engine in three layers, and the layering is machine-checked (lint-imports, contracts in pyproject.toml):

LayerWhereInstalls withMay import
② Translate + the kernel (the library)vocabulary: engine/, lexical.py, units/, value_scale.py, zh_fold.py, _bundle.py, _strtab.py; the pure seam: translate/ (fold, parse, local_day, series, code, devices); semantics: kernel/ (metrics, series, quality, overlay, meds, query, tools, ops, connect, sink, events, evidence, memory, decoders/); toolbox: testing/pip install mirobody (numpy only)each other, nothing else
② Translate, the parts that reach a databasetranslate/aggregate/, translate/derive/, translate/indicators_info.py, translate/canonical_units.py, translate/value_range_validator.py[app]no agent framework
① Collect + storage + MCPmirobody/documents/, collect/, utils/, user/, task/, mcp/[parse] / [app]no langchain*, langgraph, deepagents
③ Agentmirobody/agent/ (one agent: MirobodyAgent, on deepagents), server/[agent] (the harness as a library) / [app]anything

There is one agent, and it is not switched at request time. BaseAgent, the agent/base package and the ChatGPT Apps widgets under agent/resources were removed; do not reintroduce a second harness or a per-agent config suffix. A deployment that wants its own harness REPLACES MirobodyAgent by pointing AGENT_DIRS at its own directory (agent/registry.py). External clients get the engine through mirobody/mcp/ (seven tools: resolve_indicator, convert_unit, normalize_unit, query_health_indicators, query_medications, query_genetic_data, query_pharmacogenomics) — and that list is asserted exactly by the local suite. The agent's config keys are MODELS, PROMPTS, ALLOWED_TOOLS, DISALLOWED_TOOLS, DEFAULT_MODEL, AGENT_NAME — no suffix, and no "provider" (in this project a provider is a device; PROVIDERS was the 1.4.0 spelling).

Setup that actually works from a source clone

git lfs install && git lfs pull         # data bundles; without this `resolve` gets pointer stubs
python -m venv .venv && . .venv/bin/activate
pip install -e '.[app,test]'

The extras are [parse], [agent], [app] and [test]. [agents], plural, was removed in 1.3.0 and is not the same thing as [agent], which 1.4.0 added: pip only WARNS about an unknown extra, so -e '.[agents,test]' quietly installed [test] alone, which is how both CI workflows spent a release running the minimal suite while reporting the full one. If a doc says [agents], [server] or [cn], the doc is wrong.

The gates — run all five before you say "done"

ruff check mirobody examples   # rule set in pyproject.toml; 0 findings on main
python -m compileall -q mirobody
pytest -q               # 253 in a clone (240 pass, 13 strict xfails): the four
                        # shipped gate modules. On `[test]` alone the security
                        # module skips. The regression suite is gitignored
lint-imports            # 6 contracts, must say "0 broken"
python3 -c "import mirobody.kernel.meds, mirobody.kernel.query"   # the library layer, bare interpreter

With a live database, one more — it catches the two things a unit test cannot, a statement that will not parse and a column that is not there:

docker compose exec -T mirobody python - --user 1 < scripts/e2e_health_data.py

lint-imports and pytest must run against the repo source, not an installed wheel in the same venv — otherwise they pass vacuously.

Rules that are not the defaults you would assume

  • No compatibility shims, no _v2 suffixes, no "kept for backward compatibility". Rename or delete; git remembers. When you consolidate two implementations, confirm they are behaviour-identical or name the difference in the commit and the CHANGELOG.
  • Comments say why, with evidence; never what. A stale comment is a bug and part of your change. English only, quoting non-English data is fine.
  • Verify, don't reason. Before deleting "unused" code compute reachability transitively (a sibling may call it). Before repeating a claim from a README, run the command.
  • Every observation write goes through collect/observations.py. Every FastAPI router answers with server/envelope.py. Every read of a person's readings goes through query.HealthQuery. Don't add a sixth INSERT, a fourth envelope, or a second copy of the query — when there were two, the chat answer and the dashboard could disagree about the same Tuesday.
  • A new LIBRARY-LAYER module goes under mirobody/kernel/, into all FOUR import-linter contracts AND into tests/test_library_layer.py::LIBRARY_MODULES. Miss either and the gate is green for the wrong reason. That test is in the maintainers' gitignored suite, so a clone can run only the contracts: name the new module in the PR. It may import stdlib, numpy and its siblings — nothing else — and it must not contain a test_*.py (a test inside the package drags pytest into the library layer).
  • Logs carry ids, counts, durations, status codes and type names. Never a value. The local PHI baseline fails on anything new; it may only shrink. An indicator NAME is not a value but it is still the answer to "what was measured", so it does not go in either. In a broad except, exc_info=not is_driver_exception(e) — a driver's message quotes the SQL with its bound parameters.
  • A prompt may only name tools the harness provides (test_prompts.py, in the maintainers' suite; from a clone, grep the templates for the old name). Renaming a tool means the template and that registry change in the same commit.
  • A decode table says how to convert INTO the catalogue's unit; it never writes the unit down. The unit is metrics.METRICS[name].unit_ucum, so a decoder cannot disagree with the aggregator.
  • Nothing derived is stored. A dose's due/missed/upcoming come from the clock (meds.slot_state); adherence is counted, never persisted. A stored missed is a lie the moment the person marks the dose taken.
  • Logging: logger = logging.getLogger(__name__) at module top; never logging.info(...) on the root logger; no emoji in log lines.
  • Provider contract: format_data(self, fmt_input: FormatDataInput) -> StandardPulseData and _validate_credentials(self, credentials: dict). Guide: docs/provider-guide.md.
  • Docs are code. Rename a module → grep the .md files. The README ships in English and Chinese; English first, then Chinese, and say so if you only changed English. A gate checks the live editions as a set.

Never commit

  • .env and anything holding a key (the repo's .gitignore covers .env, .venv*/, internal/).
  • Real health documents used for local testing. Synthetic fixtures live under the repo-root demo/; anything with a person's data stays outside the tree.

Where things are decided

  • CHANGELOG.md → "Unreleased" gets an entry for every user-visible change, written as what was wrong, what changed, how to tell.
  • docs/roadmap.md → known defects and open design questions; close an item there when you fix it.
  • internal/ is gitignored planning material; nothing there is a promise.
  • docs/pipeline.md → the eleven stages and the ten invariants, each with the failure it prevents. Read it before changing anything between a payload and a stored row.
  • docs/answers.md → the tool surface, the applicability matrix, the envelope and what stops a model looping.
  • docs/medications.md → the medication model, its state tables and its grammar. Marked provisional until a second production consumer exists.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.