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.
- mirobodySkill
- translate-health-dataSkill
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
- Distinctive: line 3
Read this before touching the tree.
- Distinctive: line 76
Verify, don't reason: Before deleting "unused" code compute reachability transitively (a sibling may call it).
≈ “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.
Files
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):
| Layer | Where | Installs with | May 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 database | translate/aggregate/, translate/derive/, translate/indicators_info.py, translate/canonical_units.py, translate/value_range_validator.py | [app] | no agent framework |
| ① Collect + storage + MCP | mirobody/documents/, collect/, utils/, user/, task/, mcp/ | [parse] / [app] | no langchain*, langgraph, deepagents |
| ③ Agent | mirobody/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 interpreterWith 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.pylint-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
_v2suffixes, no "kept for backward compatibility". Rename or delete;gitremembers. 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 withserver/envelope.py. Every read of a person's readings goes throughquery.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 intotests/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 atest_*.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/upcomingcome from the clock (meds.slot_state); adherence is counted, never persisted. A storedmissedis a lie the moment the person marks the dose taken. - Logging:
logger = logging.getLogger(__name__)at module top; neverlogging.info(...)on the root logger; no emoji in log lines. - Provider contract:
format_data(self, fmt_input: FormatDataInput) -> StandardPulseDataand_validate_credentials(self, credentials: dict). Guide:docs/provider-guide.md. - Docs are code. Rename a module → grep the
.mdfiles. 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
.envand anything holding a key (the repo's.gitignorecovers.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. Markedprovisionaluntil a second production consumer exists.
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
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.

