Appearance
territory-check.mjs
Holds tools/territory.json total and disjoint over the tracked tree, so every tracked path has exactly one owner and every glob owns something.
Contributor tooling › territory-check.mjs
What it does
Reads the role map in tools/territory.json and the output of git ls-files, then matches every tracked path against every glob. Reports three findings and fails on any of them.
| Finding | Means |
|---|---|
unclaimed | no role glob and no unowned glob matches the path |
overlap | two roles claim the same path |
dead glob | a glob matches no tracked path |
A role carries the globs it may write and the domain context those paths belong to. A path in unowned is claimed without being given a role. This reports only: refusing a write outside a role's territory is a separate step.
Usage
Run through its npm run alias:
bash
npm run territory:partitionOr directly:
bash
node tools/territory-check.mjsOptions
No options.
Inputs and outputs
Reads tools/territory.json and the tracked file list. Writes nothing.
On success, exit 0 and one line naming the tracked path count, the role count, and the contexts the map declares.
On failure, exit 1, one line per finding, then the same summary line with a non-zero finding count.
Examples
Prove the map still covers the tree after adding a directory:
bash
npm run territory:partitionNotes
globToRegExp and partition are exported and pure, and test/tools/territory.test.mjs covers them over hand-built maps rather than the repository's own.
A context of null marks a role whose paths span contexts: test-smith, perf-engineer and the read-only reviewer. Those roles are skipped when the contexts are counted.
Adding a top-level directory fails this check until the map claims it. That refusal is the point: a new directory with no owner is a territory nobody agreed to.
Source
tools/territory-check.mjs — part of Contributor tooling
See also: tools/territory.json the map this reads · tools/check-coverage.mjs the coverage rule this one mirrors for paths