Skip to content

A command reads each canonical file at most once

A command reads each canonical file at most once

majordomus://rule/project.hot-path-reads-once@1active performancedoctrine

it references

referenced by

Rationale

project.derived-once says what to compute once per state version. This rule is the per-invocation form of it, which is where the regressions actually appear: a validator that flattens a policy the loader already flattened, an accessor that re-reads a record per field, a projection that hashes a source the discovery pass hashed. Each is correct and each is invisible until the counters are read. The tool counts its readings precisely so that this rule has a number to be checked against.

Required behaviour

A command loads what it needs in a loader and hands the reading on: the policy, the profiles, the registries, the plan model, the context documents, the knowledge sources are each read once and expanded afterwards. A validator reads through the loader, never through the file. MJ_TIMING=1 prints the yaml_flatten, yaml_flatten_many, sha256_many and git counts of the invocation; the sum of files those readings cover is at most the number of distinct canonical files the command needs.

Failure behaviour

No command decides this rule; a reviewer does, with the counters. No case holds these counts yet. The one that does will hold the counts of doctor and watch on the tool's own repository to the number of distinct canonical files they read, and a change that reads a file twice will fail it.

Verification

MJ_TIMING=1 bin/majordomus doctor 2>&1 >/dev/null | grep count, before and after a change to a loader, a validator or an accessor.

Where this comes from

canonical file
.ai/repo/rules/project/hot-path-reads-once.v1.md
identity
project.hot-path-reads-once@1
also served as
MCP resource majordomus://rule/project.hot-path-reads-once@1 · majordomus entity show rule/project-hot-path-reads-once-1 · GET /api/v1/entity?uri=majordomus://rule/project.hot-path-reads-once@1
in the Cockpit
/cockpit/objects/rule/project-hot-path-reads-once-1

This page is generated from the file above by scripts/generate-site-data; editing the page changes nothing, editing the file changes every surface. The relations above are edges of docs/generated/graph.json, which the executable writes from the same index.

Searches the titles and descriptions of every page this site publishes.