Features and book maps
A feature README names the folders the feature lives in, and each flow names its steps. From these two things and the book, Warlock works out which files belong to each feature, which files each flow reaches, and which tests prove each criterion. It writes the answers as book maps next to the agent’s files, plus two indexes. You never write or list these files yourself.
Who owns a file
Section titled “Who owns a file”Every source file has at most one owner.
-
A
@feature <id>line in the file’s header comment wins:/*** Deletes accounts that were never verified, seven days after sign-up.* @feature auth*/ -
Otherwise a
foldersentry that names the file itself owns it. An entry with a code-file extension (.ts,.tsx,.jsand the like) is one file, not a folder. This lets a feature own a few files in a folder that holds code of several features, with no tag in the code:folders: [src/app/billing, src/web/components/client/home/pricing-table.tsx]A file entry is more specific than any folder entry, so it wins over the folder of another feature.
-
Otherwise the feature whose
foldersentry holds the file owns it. When two entries hold it (src/webandsrc/web/$sites/client/products), the deepest folder wins.
A file nobody claims has no owner. Two claims of the same strength are a conflict, and the file gets no owner:
| Case | Reported as |
|---|---|
Two different @feature tags in one file | GR3003 |
| Two features list the same folder | GR3003 |
| Two features list the same file | GR3003 |
A @feature tag names no feature | GR3004 (the folders then decide) |
A file under src/app/** with no owner | GR3002 |
Test files (*.test.ts, *.spec.ts) get an owner too, but they never count as a feature’s own, borrowed or
unreached files.
Borrowed files
Section titled “Borrowed files”A feature borrows a file it does not own when one of its own files imports it directly. In the example shop,
orders places an order through the catalog’s products repository, so orders borrows
src/app/catalog/repositories/products.repository.ts. The book entry of that file shows feature: "catalog" and
borrowedBy: ["orders"], and warlock scry --impact lists both features.
The files behind a step
Section titled “The files behind a step”Each step of a flow points at something in the book. The flow’s book map lists the file the step starts from (the
entry) and the project files the entry reaches through imports that run. Imports that are erased at build time
(import type, export type … from, import { type A }, typeof import("…")) are not followed: a page that takes a
type from a barrel does not list the server files behind the barrel.
| Step | Matches | Entry | Files |
|---|---|---|---|
route POST /api/orders | routes with the same method and path (ALL matches any method; :id and [id] are the same, a trailing / is ignored) | the handler’s file, else the routes file | the handler’s imports, plus the routes file alone |
page /products/:id | pages of the sites and screens of the mobile apps the feature lists; :id and [id] are the same, a trailing / is ignored | the first page or screen file | the imports of the page and its setup file (layouts are left out) |
mail, job, event, notification | the thing with that name | its file | its imports |
affects catalog/browse-products | the feature and flow exist | none | none |
outside service payment gateway | not checked | none | none |
found is true when the step matched, false when it did not, and null when the book cannot tell (an outside
service, or a route step before the routes were ever read).
The files behind a route are every file the handler can reach through imports that run. That is not the exact call path: open the handler to see which ones it really uses.
Each step has four file lists, all sorted:
| Field | Holds |
|---|---|
entries | Every file the step starts from: a page and its setup file, each matching route’s handler and routes file, each named file. |
direct | Project files the entries import directly (type-only imports included), minus the entries. Not the routes file’s own imports. |
files | The entries plus everything they reach through imports that run. This is what the step “lists”. |
typeOnlyFiles | Files reached only through type-only imports. They are not in files. |
entry is the first entry. Ownership coverage counts both lists: a file that only a type import reaches still counts
as reached, so GR3006 does not change because of type-only imports. The same holds for the
flows of a book entry and for warlock scry --impact.
Feature book map
Section titled “Feature book map”grimoire/features/<feature>/bookmap.json:
{ "schemaVersion": 1, "feature": "catalog", "own": [ "src/app/catalog/controllers/new-arrivals.controller.ts", "src/app/catalog/controllers/products.controller.ts", "..." ], "borrowed": [ { "file": "src/app/shared/utils/money.ts", "owner": null, "by": ["src/app/catalog/controllers/products.controller.ts"] } ], "routes": [ { "method": "GET", "path": "/api/products", "name": "catalog.products.index", "file": "src/app/catalog/controllers/products.controller.ts" } ], "pages": { "web-client": [ { "route": "/products/:id", "file": "src/web/$sites/client/products/show.page.tsx", "type": "page" } ] }, "unreached": []}own: the files the feature owns.borrowed: files of other features, or of no feature, that its own files import directly, with the importing files underby.routes: API routes whose handler file or routes file the feature owns. Pages are listed underpages.pages: by app, the pages and screens whose page, setup or screen file the feature owns. The key is the app id undergrimoire/apps/; when no app folder matches a site, the site id is used.unreached: own files that no step of any of the feature’s flows reaches. Each one is either behaviour no flow describes yet, or dead code (GR3006). Files with a role that runs by being present (migration, seed, command, main, layout, root) and test helpers only specs import (intests,fixtures,support,test-utils) are left out. A route step reaches the middleware files its matched route names, resolved by the name a file exports or, for a*.middleware.*file, its stem (auth-only.middleware.tsisauthOnly).
Flow book map
Section titled “Flow book map”grimoire/features/<feature>/flows/<flow>.bookmap.json:
{ "schemaVersion": 1, "feature": "catalog", "flow": "new-arrivals", "ref": "catalog/new-arrivals", "steps": [ { "index": 2, "type": "route", "target": "GET /api/products/new-arrivals", "found": true, "entry": "src/app/catalog/controllers/new-arrivals.controller.ts", "entries": [ "src/app/catalog/controllers/new-arrivals.controller.ts", "src/app/catalog/routes.ts" ], "direct": ["src/app/catalog/repositories/products.repository.ts"], "files": ["src/app/catalog/controllers/new-arrivals.controller.ts", "..."], "typeOnlyFiles": [] } ], "criteria": [ { "id": "AC-2", "app": null, "text": "a customer with no country sees the global list", "tests": [ { "file": "src/app/catalog/tests/new-arrivals.test.ts", "line": 17, "name": "returns the global list when the customer has no country", "result": "pass", "stale": false } ], "status": "pass" } ], "shownBy": [ { "app": "web-client", "type": "page", "id": "home", "block": "New arrivals", "file": "grimoire/apps/web-client/pages/home/README.md" } ]}criteria[].tests: every test with a// @proves <feature>/<flow> AC-<n>line above it, and its last result from the test results.resultispass,fail,skipornot-run;staleistruewhen the test file changed after that result.criteria[].status:pass,fail,stale,not-run, orno-testwhen no test proves the criterion.shownBy: the rows of page, screen and layout blocks tables whose Flow column names this flow.
Indexes
Section titled “Indexes”grimoire/features/index.json lists every feature that has a README, by id: its title, status, version, updated
date, apps, origin, flows (id, status, since) and the versions it released. Release numbers and dates come from the
dated sections of the feature’s CHANGELOG.md (## 1.0.0 (2026-10-01)), newest first.
{ "id": "catalog", "title": "Product catalog", "status": "shipped", "version": "2.1", "updated": "2026-11-10", "apps": ["web-client", "mobile"], "origin": null, "flows": [{ "id": "new-arrivals", "status": "shipped", "since": "2.0" }], "releases": [ { "version": "2.0", "release": "1.0.0", "date": "2026-10-01" }, { "version": "1.0", "release": "1.0.0", "date": "2026-10-01" } ]}grimoire/tasks/index.json has three lists, each sorted by task number:
open: tasks ingrimoire/tasks/open/;waiting: the open tasks that wait for the owner, with statuswaiting for approvalor aDecision needed:line;done: tasks ingrimoire/tasks/done/<yyyy-mm>/.
When they are written
Section titled “When they are written”Every command that opens the Grimoire (warlock grimoire build, check, warlock scry, the MCP tools and the
devtools tab) brings these files up to date first:
- a file whose content did not change is not rewritten;
- the book maps of a deleted feature or flow are removed;
- they carry no timestamps, so an unchanged project gives the same files.
Warlock writes only index.json and *.bookmap.json files under grimoire/features/ and grimoire/tasks/. It
never edits a file an agent wrote. All of them are ignored by git (see GRIMOIRE_IGNORE_RULES).
From code
Section titled “From code”openGrimoire(root, adapter, options) from @warlock.js/grimoire runs the whole pipeline and returns a snapshot
with ownership (from resolveOwnership) and collected (from buildCollectedFiles). Pass write: false to
compute everything in memory. writeCollectedFiles(root, collected) writes the collected files on their own.