✅ fresh
last synced 2026-10-20T11:44:45.791774+00:00 · coverage 100% (
agent-prime)Validation by Beadloom
doc_sync— same source assync-check.
Agent Prime
Cross-IDE context injection via a three-layer architecture.
Layers
AGENTS.md (static) —
.beadloom/AGENTS.mdwith MCP tool list, architecture rules, conventions. Regenerated bygenerate_agents_md(), preserves content below## Custommarker.IDE adapters (pointers) —
.cursorrules,.windsurfrules,.clinerulesfiles that instruct agents to read AGENTS.md. Created bysetup_rules_auto()on bootstrap.The ignore block (one write) —
bootstrap_project()also callsignore_block.ensure_ignore_block(), so the derived state bootstrap is about to create under.beadloom/(the index, and later the guard firing record) does not arrive as untracked churn in the adopter's repository. It is appended once and never rewritten, the result is returned asignore_added/ignore_skipped_reason, andbeadloom initprints it. The same call names the portal's output directory,/site/, withensure_portal_ignored()(BDL-076beadloom-ujzb.13), returned asportal_ignore; it writes nothing when a line already decides forsite/or whensite/already holds files, except untracked files of the portaldocs sitewrote, which theis_portalprobe the CLI hands tobootstrap_project()recognises (beadloom-ujzb.24, m4). Such a top-level folder is not scanned either;bootstrap_project()returns it asgenerated_portals, andinitprints aNot scanned: site/ - ...line for it. See the ignore-block component.The domain-parent post-condition (one invariant, two writers) — every node
bootstrap_project()writes leaves the function with at least one outgoingpart_ofedge, to its classified parent where one exists and to the root service node otherwise. It reads no kind since BDL-067.17: until then it saidkind: domain, the kind today's generated rules require a parent for, whilegenerate_rulesalso writesfeature-needs-parentand the sibling statement inimport_docsalready covered every kind — two writers of one invariant disagreeing about its population (the review of.16, minor 2). One node is carved out and the sentence says so since BDL-067.6: a node whoseref_idis the root's own gets no edge, because an edge from a node to itself is not a parent. Thatref_idcollision was reachable onsrc/<project>/until BDL-069 and is not produced by either writer now — see Two nodes never share a ref_id below; the carve-out stays because this function also runs over a graph a hand edit can reach. The same call writesdomain-needs-parentinto the adopter'srules.ymlwhenever it writes a domain, so a domain without that edge makesinitexit 0 over a graph the very nextlint --strictrejects — measured as rc 0 then rc 1 on a flat TypeScript project (BDL-UX #192).parent_edges.missing_parent_edges(nodes, root_ref_id, parented)enforces it over the whole node list rather than inside the branch that was reported, and reads root_ref_id back from the root node instead of recomputing it, because cluster refs pass through_sanitize_ref_idand the root ref does not.import_docs()is the second writer ofdomainnodes and did not receive the invariant until BDL-067.14: every document the classifier could not place became a domain with no parent, inimported.yml, in the same run that wrotedomain-needs-parentat error severity — soinit --yes --mode bothexited 0 and the nextlint --strictexited 1 on three nodes, BDL-UX #192's signature on a branch the epic had declared covered. It calls the SAME functionbootstrap_projectcalls, and_existing_graph(graph_dir)finds the root by reading the graph on disk: the one node of kindservicethat nopart_ofedge leaves. It attaches every kind, not only the two the generated rules require a parent for, because a post-condition that tracked today's rule set would go stale the next timegenerate_rulesgains a rule. With no single root — an import-only run on a virgin project, or a graph with two unparented services — no parent is named rather than one guessed.Two nodes never share a
ref_id, and that is a writer's duty rather than the loader's. The graph identifies a node BY itsref_id, so a writer that emits one name twice does not write two nodes: it writes one, and the report it prints counts two. On the ordinary single-package src-layout — a project calledmyappholdingsrc/myapp/— the root service takes its name from the manifest and the package takes its from the directory, and those are one string. Measured on the published 4.0.0 wheel:init --yes --mode bootstrapreportedGraph: 2 nodesandbeadloom statusthen reportedNodes: 1. The node dropped was the one carryingsource: src/myapp/, so the package the project is named after was absent from every answer the graph gave, anddomain-needs-parentwent inert rather than red — a rule cannot fail over a node the graph does not hold (BDL-UX #214). The same shape reachedimport_docsthrough the document's file name: two documents calledsetup.mdin two directories, or one named after the project, asked for aref_idthe graph already held.scanner/ref_ids.RefIdAllocatorhands out everyref_idboth writers use.take(preferred, qualifier=...)returns preferred when it is free — which is every node on every project the collision does not touch — thenpreferred-qualifier, thenpreferred-qualifier-2and upwards. Callers pass the node's kind as the qualifier, so the secondmyappis written asmyapp-domainand reads as what it is. WHICH asker keeps the plain name is the caller's judgement and not the allocator's:bootstrap_projectgives the root the project's name first, before any cluster asks, because thatref_idtitles the architecture document and is whatgenerate_rulesnames as the parent every domain must have.import_docsseeds the allocator with theref_idsalready on disk (_existing_graph(...).ref_ids), because it adds to a graph another writer produced;imported.ymlis not among the files read, so a re-import hands out theref_idsit handed out last time.A rename reaches the EDGES as well as the node. Three passes used to recompute a cluster's
ref_idfrom its directory name — the manifest dependency loop,_quick_import_scanand the top-level attachment loop — and a rename that reached only the node would have traded a lost node for an edge naming nothing, which the loader drops just as quietly. All three read theref_idthe cluster was written under, and_quick_import_scantakes that mapping as a parameter rather than recomputing it. The attachment loop's old carve-out — skip the cluster whose sanitized name equals the project's — is gone with the collision it worked around.One post-condition, one implementation, since BDL-067
.21. Until then the two writers carried the same private name in two modules with the same loop body, differing in astr()call and in their parameter order, and the only thing binding them was a docstring naming a symbol.17had renamed away. They had already drifted once and been repaired by editing both — one covered every kind, the other onlydomain(the review of.16, minor 2; the review of.20, major 3).scanner/parent_edges.pynow holdsmissing_parent_edges(nodes, root_ref_id, parented)andparented_by(edges), and both writers import them. What stays each writer's own is the one thing that genuinely differs: whereparentedcomes from. The bootstrap produces the whole graph and reads it off the edges it is about to write; the importer adds to a graph and reads it off the one on disk. A THIRD writer of nodes is caught rather than repaired afterwards:tests/test_one_parent_post_condition_over_every_writer.pyderives the writers from the source — every function that reacheswrite_yaml_atomicand builds a payload holdingnodes— and fails when that set changes.ONE POLICY FOR THE READING SIDE TOO, since BDL-067
.24.graph_files.each_graph_file(graph_dir, *, also_skip=frozenset())states the skip policy once: a file whose name is not a graph file's is skipped, a file that will not read or will not parse is skipped, and a file that parses to anything other than a mapping is skipped — so a caller may readdata["nodes"]without asking again whether it can.rules.ymlbelongs to the policy, because a rules file is not a graph file for any reader;also_skipis the one genuine difference between the callers and is passed at the call site, bydoc_classify._existing_graphalone, namingimported.ymlbecause the run that asks is about to replace it. There were four bodies with four policies until.24—doc_generator._load_graph_from_yaml,doc_generator._patch_docs_field,doc_classify._existing_graphandsetup._graph_file_of_each_node— and two carried no guard at all..21removedgenerate_skeletons' node-list parameter, soinit --bootstrapbegan reading the tree through an unguarded one and a hand-edited.beadloom/_graph/legacy.ymlthat does not parse reached the adopter as a rawyaml.parser.ParserErrortraceback, while the same commit added exactly that guard to two of the siblings and listed it as delivered (the review of.23, major 3). The mapping guard is separate from the parse guard and is needed separately: a graph file holding a top-level list parses without complaint and then raisesAttributeErrorondata.get.tests/test_graph_files_are_read_under_one_policy.pyderives the readers from the source — a function that both LISTS a directory and PARSES YAML, by any name the standard library or PyYAML offers for either — and fails when a fifth body appears underonboarding/or insetup.py. The detector was widened at BDL-067.25:.24's asked forglobwith the literal"*.yml"and foryaml.safe_loadby name, which is the spellingeach_graph_filehappens to use rather than what makes a body a reader, and five bodies that read the directory were measured passing it.The policy covers the readers
init's own modules hold and no others, which is a scope and not a claim about the command.initstill ends in a Python traceback on a graph file it cannot handle, and BDL-067 did not close that (BDL-UX #220, open). MEASURED at.25overinit's own eight (entry point x mode) cells crossed with three shapes of a hand-edited.beadloom/_graph/legacy.yml: 24 runs, of which the 15 that reach the file traceback —--bootstrap,--importand all three wizard modes, on a file that does not parse, on a file whose top level is a list, and on a file carrying an unquoted date. Two frames, both outsideonboarding:application/reindex/indexing.read_declared_docsandgraph/loader.load_graph. The date shape is the one that shows a parse guard would not be enough — every readerinitowns yields that file happily.--yesreaches none of them, and not because a guard works:non_interactive_initreturnsskippedwhen.beadloom/already exists, and--forcedeletes the directory first.graph/diff.py,reindex/change_detection.pyandservices/commands/index_ops.pywalk the directory too. The measurement is pinned in the same test file, which fails as soon as somebody closes it."No single root" counts DISTINCT ref_ids since BDL-067
.17. The candidates were collected into a list and counted there, andbootstrap_projectproduces one root under two node entries on an ordinary project shape: it writes the root service node under the project name and its top-level attachment loop skips the cluster whose sanitized name equals that name. A repository named after one of its own source directories therefore read as two candidates, the import attached nothing, andinit --yes --mode bothexited 1 on every run — measured on a project namedcoreholdingsrc/core/andsrc/orders/(the review of.16, major 1). The graph identifies a node by its ref_id and the loader keeps one node per ref_id, so the population the uniqueness test ranges over is the distinct ref_ids.An import-only run on a virgin project leaves those domains unparented and is green, which rests on one fact and no longer on two: no
rules.ymlis on disk, solint --strictevaluates nothing. The second reason — that--mode importreached no verdict at all — was withdrawn in.17. It held only until the nextiniton the same tree, because the wizard's re-init does not delete.beadloom/, soimported.ymlsurvived into a later bootstrap that wrote the rule and met the nodes. Every branch ofinitthat writes a file under.beadloom/_graph/now takes the verdict.beadloom prime(dynamic) — CLI command and MCP tool that queries the DB for current project state: architecture summary, stale doc-code pairs, lint violations, domain list.One order for all three entry points (BDL-067
.18and.21, BDL-UX #216) —initbootstraps, then imports, then generates the doc skeletons, whether the mode arrived through--yes --mode, through--bootstrapor through the wizard's prompt.non_interactive_init()used to generate the skeletons inside its bootstrap block and import after them, so under--mode bothit classified the documents it had written seconds earlier. Measured on a project withsrc/orders/,src/catalog/and one document of the adopter's own:--yes --mode bothimported four documents —architecture,readme,readme,payments— where the wizard answeringbothimported one. Three of the four are Beadloom's own scaffolding, and the tworeadmenodes are a single ref_id, because the importer names a node after the file stem and the loader keeps one node per ref_id: that graph had already dropped a document it claimed to describe. The defect predates this epic, and.14changed its character — the parent post-condition gives every imported node apart_ofedge to the root, so the wrong graph became structurally valid and both runs exited 0.The ORDER fixes it rather than a filter over the import scan. An exclusion would have to name
docs/architecture.mdanddocs/domains/*/README.md, and those are the ADOPTER's documents whenever the adopter wrote them first —generate_skeletons()never overwrites an existing file — so a filter would drop a real document from the graph and leave the two entry points disagreeing about a different population.generate_skeletons()reads every graph file on disk: renderingdocs/architecture.mdfrom the bootstrap's nodes alone produced a whole-tree document describing part of the tree, which is the same divergence one file further on..18closed that between--yesand the wizard by changing one call. There are three entry points, and--bootstrapstill passed its node list: on a tree carrying a graph file an earlier run had left,init --bootstrapand the wizard answeringbootstrapleft different trees — only the wizard wrotedocs/domains/ledger/README.md, only the wizard'sdocs/architecture.mdnamedledger, and only the wizard's run patched that node'sdocs:field back into the file holding it (the review of.20, major 1). BDL-067.21closed it by REMOVING the parameter rather than by editing the third call site:generate_skeletons(project_root)takes the project root and nothing else, so a document about the whole tree cannot be handed part of the tree by any caller, including one written later. That is an API change for anyone importingbeadloom.onboarding.generate_skeletons.A path the render broke in half is a path nobody can copy. The wizard's
editanswer names the graph file to open, andrichhard-wraps at the console width — 80 when the output is not a terminal — inserting a real newline wherever the line runs out, token or no token. Whether that lands inside.beadloom/_graph/services.ymldepends on how long the project's own path happens to be, so the assertion over it was green on macOS for nine consecutive runs and red on all six CI legs, whose temporary prefix is 68 characters and leaves exactly 12 before the break. The message now prints withsoft_wrap, so the emitted text carries no inserted newline and the terminal folds it visually instead;test_the_path_it_names_survives_the_render_wholeasserts the tail contiguously, which is the only form of the claim a wrap cannot satisfy by accident.
What bootstrap reads per stack
BDL-076 B5–B7 and R2 measured init on one small project per claimed stack (tests/fixtures/site/) and fixed what it drew. A cluster is a folder two levels below a source directory unless a stack's layout says otherwise:
| Stack | Read from | Nodes | Scan paths | Edges in the quick scan |
|---|---|---|---|---|
| Python, JS/TS, Rust and the rest | the folder tree | the folder clusters | the source directories | imports through the scan paths, relative JS/TS specifiers by file |
| Go | the folder tree, go.mod, go.work | the folder clusters | the source directories (cmd, internal, ...) | through the governing go.mod (graph/go_modules.py); the standard library and other modules draw none |
| Java, Kotlin | scanner/jvm_layout.py: every folder holding src/<set>/<java|kotlin>/ with a .java or .kt file | in the root module, the subpackages of the common base package, with their own subpackages as children; a module below the root is one cluster named by its path, with its top-level packages as children | the production roots, src/<set>/<java|kotlin>/, and any other code folder in a module's folder | through the packages the files declare (graph/jvm_packages.py), so Kotlin's layout that omits the root package from the folders resolves; a package declared in several folders reaches the one holding the imported class, and draws no edge when different clusters hold the folders it reaches |
| Swift | scanner/swift_layout.py: every Package.swift, read as text | a library, executable, macro or plugin target whose folder holds .swift; a package below the root is one cluster with its targets as children | the target folders, and any other code folder in a package's folder | through the target the manifest declares |
A test source set (test, integrationTest, testFixtures, androidTest, it) and a Swift test target are never nodes and never scan paths: each is written into tests.mirrors, to the production root or target it tests, and a written mirrors replaces the default trees. A project whose languages include .py gets tests.flat_tests: true beside them (BDL-078). Each layout reports the folders it claimed; project_scan.unclaimed_code() keeps every other folder with code, so a Python or TypeScript service beside a JVM module or a Swift package keeps its node, and _cluster_with_children(claimed=...) leaves claimed folders to their layout.
Since beadloom-ujzb.24 (re-review finding m3) the scan paths leave out only the folders a layout READS: JvmLayout.read_folders (each module's src) and SwiftLayout.read_folders (each target's folder). Code elsewhere in a module's folder (backend/scripts beside backend/src) is a scan path, and its files belong to the module's node, the deepest node whose folder holds them. bootstrap_project() returns that as beside_modules, a CodeBesideModules(scanned, unread), and init prints its sentences:
Also scanned: backend/scripts - code in a module's folder outside its source roots; its files belong to that module's node
Not read: services/run.py - a code file lying directly in a folder that holds a module; a scan path is a folder, and that one would scan the module's test tree too, so move the file into a folder of its own to have it readWith several unread files the second line counts them and names the first five. Both lines are printed by init --yes, init --bootstrap and the wizard, and neither is printed when there is nothing to say.
Not read, and said or known:
- An Xcode project. Its targets list their files in
project.pbxproj, not by folder, so a folder node would carry no edge by construction.swift_layout.unread_swift()counts the.swiftfiles outside every manifest target and the.xcodeproj/.xcworkspacefound, andinitprintsNot read: N .swift files outside any Package.swift target (Xcode: X.xcodeproj). - Gradle
sourceSetswith customsrcDirs, and Maven's<sourceDirectory>. Modules are found by walking for the standardsrc/<set>/<language>/layout; no build file is parsed, so a project name is not taken fromartifactIdorrootProject.nameeither. - A code file lying directly beside a claimed module (
services/x.pynext toservices/billing/holdingsrc/main/java/) is in a cluster and in no scan path, andinitnames it on itsNot read:line. - A portal written below a top-level folder (
docs site --out a/b) is not recognised as the portal, so it is scanned like the project's code. - A flat Python
tests/test_*.pybinds afterinitsince BDL-078 (beadloom-76mk):bootstrap_projectwritestests: {flat_tests: true}for a project whose languages include.py, and such a test binds to the node owning the module its name names, else to the one node its imports reach. A flat test that names no single module and imports into no single node stays unplaced, andinitnames it below itsTests:line. An adopter who raninitbefore this version adds the key or re-runsinit.
A Feature-Sliced frontend, Expo modules and Expo Router (BDL-080 S3)
The fsd preset
presets.detect_preset() tries the fsd preset before every other one, the mobile short-circuit to monolith included. A React Native project in the FSD layout is mobile and layered at once, and read as a monolith its layers became domains and its slices their children, with no layer rule to judge them. A project is FSD when both hold (_is_fsd_frontend):
- the folders: at least three of the six layers,
app,pages,widgets,features,entities,shared(FSD_LAYERS), are folders undersrc/or at the project root;presets.fsd_root()readssrc/first and returns the folder holding them (""for the root), elseNone; - a frontend (BDL-080 S3f): a layer folder holds a
.js,.jsx,.ts,.tsx,.mjs,.cjsor.vuefile of the project's own (not undernode_modules,dist,buildorvendor), or apackage.jsonsits at the project root or in the FSD root.
The second condition came from the S3 review: by folder names alone, a Python tree with src/app, src/entities, src/shared and src/infrastructure was read as FSD, given a frontend's rules and lost a node. That tree is monolith again. The same Python tree beside a tooling package.json (husky, for one) is still FSD by this rule; that residual is the owner's to rule on. init --preset fsd selects the preset by hand.
What init writes for an FSD tree
scanner/fsd_layout.py (read_fsd_layout() -> FsdLayout, fsd_nodes() -> FsdGraph) reads the tree slice by slice. Every node it writes is a component with one tag:
| Folder | Node | Tag | part_of |
|---|---|---|---|
a slice of pages, widgets, features or entities holding code | <layer>-<slice> | fsd-<layer> | the root service |
| a slice inside a slice group (see below) | <layer>-<group>-<slice>, one name more per group inside a group | fsd-<layer> | the root service |
app/, shared/ | a container named app / shared | fsd-app / fsd-shared | the root service |
a segment of app/ or shared/ holding code | <layer>-<segment> | fsd-app / fsd-shared | its container |
a folder beside the layers holding code (components, hooks, stores, ...) | the folder's name | fsd-legacy | the root service |
Expo Router's app/ at the project root (see below) | app-routes | fsd-app | the app container, else the root |
A layer folder is no node: a node per layer would be a tagged container holding every slice in it, and the layer rule reads two ends inside one tagged container as internal, so two widgets importing each other would pass. Legacy folders are nodes because a graph that omits half the code says by omission that it is not there; they stand outside every FSD rule. What the layout claims (FsdLayout.claimed: the whole src/ and the routes folder when the layers are under src/, else the layer and legacy folders at the root) leaves the directory clustering.
Slices and slice groups (BDL-082 S2a, RFC D2, the owner's ruling of 2026-10-13). A folder of a sliced layer is a slice when it holds a standard segment (ui, model, api, lib, config: DEFAULT_SLICE_SEGMENTS) or an index code file at its top. A folder holding neither is a group when it has no code file at its top and a slice below it, at any depth, or when it has code at its top and a folder in it holds a standard segment; otherwise it is one slice. The index is read by graph.rules.is_index_file, the public-API rule's own reader, over the same extensions (.ts .tsx .js .jsx .mjs .cjs .vue), so init and fsd-public-api agree on which folders have a public API. A group has no node. Each folder in it is read the same way in turn, and each slice is named by the whole path (features/auth/login → features-auth-login; features/account/settings/profile → features-account-settings-profile), so register importing login is a crossing between two slices of one layer. A linked folder is not looked into. Measured on 2026-10-13 by beadloom-us5r.5: the specification's group features/auth/{helpers.ts, login/{index, ui/}, register/{index, ui/}} gives features-auth-login and features-auth-register, with register → login one fsd-layers error and helpers.ts one group-top fsd-slice-shape warning. A slice not yet split into segments, features/checkout/{Checkout.vue, store.ts, store2.ts, components/Total.vue, components/Summary/{index.ts, Summary.vue}}, stays one node, features-checkout, holding its 6 files. The code at a group's top belongs to no node, and the shape rule reports it.
No import edge is frozen into the YAML. On an FSD tree bootstrap_project() skips the quick import scan, and the first reindex derives every depends_on edge from the code through tsconfig paths and imports.aliases:. Measured by S3c on its synthetic tree: with scan edges written, a cross-import removed from the code kept fsd-layers red, because the YAML edge was declared; the reindex derived the same 17 of 17 edges.
The rules it writes (rules_gen.generate_fsd_rules(frontend, rules_path), as commented text through write_text_atomic; the count it returns is read back from that text). Eight rules since BDL-082 S2a, where 9.0.0 wrote nine, each with the owner's reason in a comment beside it. The file's header lists the 17 rules @feature-sliced/steiger-plugin 0.8.0 turns on in its recommended set (rules_gen.STEIGER_RECOMMENDED), one line each with what it reports and the rule here that judges the same thing, and it states the slice and group rule above:
| Rule | Type | Severity | What it judges |
|---|---|---|---|
fsd-layers | layers, titled FSD architecture, scope: the root service, allow_skip: true, edge_kind: depends_on | error | the six fsd-<layer> tags, top-down; an @x edge between two entities is no crossing |
fsd-public-api | slice_public_api, tags fsd-pages fsd-widgets fsd-features fsd-entities fsd-shared fsd-app | error | an import into a slice or a segment from outside it lands on its index |
fsd-slice-shape | slice_shape, the four sliced layers' tags, segments: [ui, model, lib, api, config], discouraged: the 69 names of DEFAULT_DISCOURAGED_SEGMENTS | warn | a slice's top holds segments named by purpose and its index; a group's top holds no code |
fsd-cohesion-<layer> (five) | check, for: {kind: component, tag: fsd-<layer>}, max_symbols | warn | widgets 80 symbols; app, features, entities and shared 60 (FSD_COHESION_LIMITS) |
No cohesion check is written for pages: FSD 2.1 is pages-first ("There's no limit to how much code you can place in a page slice as long as your team still finds it easy to navigate"). An existing rules.yml is never rewritten, so a project initialised by 9.0.0 keeps its fsd-cohesion-pages until its owner removes it.
Steiger's script (scanner/steiger_script.py, ensure_steiger_script(project_root, fsd_root) -> SteigerScript). init writes "lint:fsd": "steiger ./<fsd root>" (steiger . for layers at the root) into package.json, unless a script is already named lint:fsd or runs steiger, and prints one line. On the rn-fsd fixture it prints:
Steiger: wrote the script 'lint:fsd' ('steiger ./src') into package.json, the file-level half of the FSD rules; install it with `npm install -D steiger @feature-sliced/steiger-plugin` and add a steiger.config.js with the plugin's recommended setThe file keeps its key order and the indentation of its second line (two spaces for a one-line file), so the diff is the one script: measured by S3f on a tab-indented package.json, git diff --numstat went from 13 insertions and 12 deletions to 2 and 1. It is written whole through write_text_atomic and keeps its permission bits. A package.json that is not a JSON object, or whose scripts is not an object, is left alone and the line says why.
The aliases (scanner/alias_scan.py, scan_bundler_aliases(project_root) -> AliasScan; BDL-080 S3a). On every project, FSD or not, init reads the text of babel.config.{js,cjs,mjs,json}, .babelrc and vite.config.* at the root, in that order, without running them. In an alias: { ... } object it reads each entry whose key is a quoted string or a bare name; in an alias: [ ... ] array, each { find, replacement } whose find is a string. The folder is built from the value's string literals in order (path.resolve(__dirname, 'src', 'shared') is src/shared). A regular-expression alias, a value with no string literal and a folder outside the project are named and not written. The usable aliases go under imports.aliases: in .beadloom/config.yml, and init prints a line for the user to confirm them. On the rn-fsd fixture it prints:
Import aliases: 2 read from babel.config.js by a text scan, not by running it (@ -> src, @modules -> modules); written under imports.aliases: in .beadloom/config.yml - confirm themIts verdict names the code. init lints the graph it wrote. When every error-severity finding is a layers, slice_public_api or slice_shape finding, the code fails the rules, not the scaffold, and init prints Error: your code does not pass the rules this command wrote alongside it., one line per finding, and that each line is a finding about the project, not a defect in the scaffold. The exit code stays 1, what the Gate's lint step says, so a scripted init && ci stops. Measured on 2026-10-13 on a copy of the vue-fsd fixture (21 nodes): init --yes exits 1 with 3 errors, naming the cross-import from features-apply-coupon, the crossing inside the group features/payment from features-payment-pay-button, and the deep import at src/widgets/product-grid/ui/ProductGrid.vue:3. On a copy of rn-fsd (19 nodes) it exits 0.
The code it could not read (BDL-082 S2a, beadloom-us5r.2). After its Index: line init prints one line per language whose files the index holds and no installed parser reads, most files first:
8 TypeScript files, no parser installed — install with: uv tool install "beadloom[languages]"The line is read from the index init has just written (application.reindex.read_unread_code), and _root._echo_unread_code returns whether it printed, so init --bootstrap skips the older No parser available warning where the line already named the files. No exit code moves on it. --yes and --bootstrap print it whenever the index holds such files. The wizard prints it when its own run re-indexed; answered cancel at the graph review, it re-indexes before its verdict and prints no line (BDL-UX #324).
Expo modules
scanner/expo_layout.py (read_expo_layout() -> ExpoLayout, expo_nodes() -> ExpoGraph; BDL-080 S3b) reads every folder below the root that holds expo-module.config.json, on every preset, outside an FSD root and a generated portal. Each is written as:
- component
<name>(source the module folder,part_ofthe root service), whose own code is everything outside its two native folders; - component
<name>-ioswhenios/holds.swift,.mor.mmcode, and<name>-androidwhenandroid/holds.ktor.javacode (Pods,build,.gradleand.cxxskipped), eachpart_ofits module.
The module folders leave the directory clustering and the JVM walk (jvm_layout.read_jvm_layout(project_root, *, skip=...)), and Swift in them is not reported as unread (swift_layout.unread_swift(project_root, layout, *, read=...)). Before S3b the JVM walk took android/ as a Gradle module with a node per package, part of the root, and the Swift in ios/ was in no node. Each module folder becomes a scan path, and the native suffixes join languages. No uses edge is written into the YAML: the reindex derives one from the module to each part its config links (see the import-resolver SPEC). bootstrap_project() returns the layout as expo_modules; init prints nothing about it.
Not read: a repository that is itself one Expo module (its config at the root), and native code an apple.podspecPath or android.path moves out of the two folders.
Expo Router
An Expo app in the FSD layout keeps its routes in app/ at the project root, beside src/, and FSD's guidance for Expo Router reads that folder as the top layer. scanner/expo_router.py (expo_router_routes(project_root); BDL-080 S3e) finds the routes folder by the dependency: package.json's dependencies name expo-router and app/ is a folder at the root. A file test such as app/_layout.* would miss a routes folder holding only index.tsx, because the router makes the root layout optional, and would read a name other tools may use. devDependencies are not read, because the router runs in the shipped app.
When the FSD layers are under src/, fsd_layout writes the routes folder as ONE node, app-routes (source app/, tag fsd-app, part_of the app container, else the root), and FsdLayout.routes names it. With the layers at the root, app/ is the app layer itself and no routes node is written. One node, not one per route: routes as nodes is beadloom-mnuu, after this epic. Before S3e the clustering made a node of each route folder (app/trail/ as trail, outside every layer) and left app/_layout.tsx to the root. Measured on the rn-fsd fixture: fsd-layers judged 12 of 15 depends_on edges before and 15 of 17 after.
Not read: the root option of the expo-router config plugin, and src/app/ as the routes folder, which in an FSD project is the app layer.
The project name of init --project .
project_scan._detect_project_name resolves the path before taking the folder's name (BDL-080 S3e, BDL-UX #313). init --project . used to name the root service '' whenever no pyproject.toml, package.json, go.mod or Cargo.toml named the project. Measured on a copy of the Java fixture: init exited 1 with two domain-needs-parent findings before the fix and 0 after, with the root named after the folder; S3T saw the same exit on the Kotlin and Swift fixtures.
Since BDL-083 S2c the manifest half is project_scan.manifest_project_name, which returns the name with the manifest's file name and no directory fallback. The composition of CLAUDE.md reads it through project_name.composition_project_name, because a composition that takes the directory's name differs between the main checkout, a git worktree and a clean room of the same files (BDL-UX #334). init and prime keep the fallback. A package.json that cannot be read or is not UTF-8 now names nothing and the next manifest is read; before, the read raised UnicodeDecodeError out of init.
Tests
Unit: tests/unit/onboarding/test_an_fsd_project_is_detected_before_every_other_preset.py, tests/unit/onboarding/scanner/test_an_fsd_layout_is_read_slice_by_slice.py, tests/unit/onboarding/scanner/test_an_fsd_layout_reads_slice_groups.py, tests/unit/onboarding/scanner/test_init_and_the_public_api_rule_read_one_index.py, tests/unit/onboarding/scanner/test_init_writes_the_fsd_rules.py, tests/unit/onboarding/scanner/test_init_gives_a_frontend_its_steiger_script.py, tests/unit/onboarding/scanner/test_alias_scan.py, tests/unit/onboarding/scanner/test_expo_layout.py, tests/unit/onboarding/scanner/test_expo_router.py. Integration: tests/integration/onboarding/scanner/test_init_writes_the_aliases_a_bundler_declares.py, tests/integration/onboarding/scanner/test_lint_judges_an_fsd_projects_layers_straight_after_init.py, tests/integration/onboarding/scanner/test_init_names_the_root_after_a_relative_project_path.py, tests/integration/onboarding/scanner/test_init_writes_the_rules_the_specifications_examples_need.py, tests/integration/services/commands/setup/test_the_init_wizard_names_the_code_it_could_not_read.py. Acceptance, under tests/acceptance/onboarding/agent-prime/: init_on_a_feature_sliced_frontend.feature, init_on_an_app_with_expo_modules.feature, init_on_an_fsd_app_with_expo_router.feature, init_reads_layer_named_folders_as_fsd_only_on_a_frontend.feature, init_keeps_a_frontends_package_json_as_it_was_written.feature, init_reads_slice_groups_and_pages_first.feature.
API
prime_context(project_root, *, fmt="markdown")
Returns compact project context. Static layer (config, rules, AGENTS.md) always available. Dynamic layer (DB queries) degrades gracefully without DB.
fmt="markdown"— human-readable output (~1000-1500 tokens)- The finding lists are bounded (
MAX_LISTED_FINDINGS = 10, BDL-061 S4).primeused to print one line per stale pair and per lint violation with no limit, which kept its size promise only while the lists were empty: opting this repository intoscenario-coverage(68 findings) grew the output from 2.6 KB to 13.1 KB — five times the budget, in the artifact whose whole job is to fit in one. The count is never truncated, only the list, and the cut says how many are hidden and which command shows them (beadloom lint/beadloom sync-check) - The stale list counts and names PAIRS (BDL-069
beadloom-yn6i). A pair is a document AND a code file, so three code files of one package give three stale pairs over one document. The health line readsN stale pair(s), the section is## Stale Pairs, and each line is- <doc> <-> <code> (<ref_id>), the pair assync-check's text renders it. Measured before the change on a repository with one README over three stale pairs:Health: 3 stale docsabove three identical lines naming the README alone. The cut note saysstale pair(s)for the same reason.fmt="json"is unchanged:health.stale_docsalready carrieddoc_path,code_pathandref_idper pair - The health line states what the violation count was taken over (BDL-070 A4).
N lint violationssays the same words whether the layer rule judged 357 of 365 livedepends_onedges or all 365, so the line carries a clause per declared layer rule:Health: 0 stale pair(s), 55 lint violations, architecture-layers judged 357 of 365 live depends_on edge(s) | Last reindex: …, printed on this repository on 2026-09-13. The wording isgraph/rules/layer_reach.py::population_phrase, shared with the Gate line and the fourlintrenderings, so one fact has one form. It is one clause per RULE and not per finding, so the bounded list above can grow without it growing; a project that declares no layer rule gets no clause.fmt="json"carries the same list underhealth.layer_populations. Both facts come from ONElintrun, held together onprime.LintSnapshot: reading them separately would lint twice, and a count and a denominator taken over two different indexes are worse than neither fmt="json"— structured dict for programmatic use
setup_rules_auto(project_root)
Auto-detects IDEs by marker files and creates adapter files. Returns list of created file paths.
generate_agents_md(project_root)
Generates .beadloom/AGENTS.md with v2 template. Injects rules from rules.yml. Preserves user content below ## Custom.
Each injected rule is labelled by scanner/rules_gen._detect_rule_type(), which reads the authoring keys from graph.rules.loader.AUTHORING_KEYS rather than from a copy of its own (BDL-073 B3), so every key the loader accepts has a label and the word unknown is left for a rule that names none. check is labelled cardinality and forbid forbid_edge; every other key is its own label. A rule naming two keys, which the loader rejects, is labelled by the first one its author wrote.
refresh_claude_md(project_root, *, dry_run=False)
Regenerates the auto-managed regions of .claude/CLAUDE.md between <!-- beadloom:auto-start SECTION --> / <!-- beadloom:auto-end --> markers and returns the names of the regions whose content changed. Two regions are rendered:
project-info— stack, dependencies, tests, linter, typing, packages and version, every one of them read from the target project's own manifest, tree andflow.yml. A fact that cannot be read is omitted, never substituted, and a section with nothing to say prints what it looked for rather than nothing at all.This sentence was already in this SPEC while the code did otherwise, which is worth stating plainly. Until BDL-UX #183 the version bullet was
application.doctor.get_actual_version()— Beadloom's__version__, correct about Beadloom (BDL-UX #92) and false for every adopter — the architecture line saidDDD packageswhatever the project declared, the stack line matched the project's manifest against Beadloom's own dependency names (sqlite,click,rich,tree-sitter) and stated our Python floor as theirs, and the package scan fell back to looking forsrc/beadloom/inside the adopter's tree. Each read correct on this repository by coincidence. :mod:beadloom.onboarding.scanner.project_factsnow owns every one of those reads, andtests/support/adopter_project.pyrenders non-Beadloom fixtures so a coincidence cannot pass for a measurement again.doc-language— the "ALL documents MUST be written in …" sentence, derived fromlanguage:in.beadloom/flow.yml(defaulten). The scaffolded flow used to state English unconditionally, so a team documenting in another language had to override the shipped default in prose (BDL-UX #136).
refresh_auto_regions(path, project_root, *, dry_run=False)
The same refresh for any file holding the markers, and the body refresh_claude_md runs through. Since BDL-083 S2R pass 1 Major 1 it is how composed_core.refresh_core_regions reaches both files that carry the composed core, .claude/CLAUDE.md and the Cursor core rule .cursor/rules/beadloom-flow.mdc, so one release re-renders project-info in both and setup-rules --refresh leaves the two tools one text. An absent or unreadable file returns [] and nothing is written.
project_facts — what the TARGET project declares about itself
One module, one responsibility: read a fact out of somebody else's project. Nothing in it may consult beadloom.__version__, our package layout, or anything else true of this repository — every value comes from a file under project_root.
| Function | Reads | Unknown |
|---|---|---|
detect_project_version(root) | pyproject.toml ([project], [tool.poetry], then a dynamic version via [tool.hatch.version] / [tool.setuptools.dynamic]), package.json, Cargo.toml | None — the bullet is not rendered |
detect_source_packages(root) | src/<pkg>/<child>/__init__.py under the target | empty set |
detect_requires_python(root) | requires-python, verbatim | None |
detect_declared_dependencies(root) | [project].dependencies or package.json dependencies, first six, declared order | empty tuple |
manifest_text(root) | every readable dependency manifest, concatenated | None — "nothing declares this" and "we could not look" are different answers |
A VCS tag is deliberately not consulted: a tag is a release marker on a commit rather than a statement the project makes about itself, and reading one would need the infrastructure layer onboarding is forbidden to import.
The same reads back beadloom doctor's audit of an adopter's CLAUDE.md. Before BDL-UX #183 that audit compared four claims — version, packages, stack, test framework — against Beadloom's state (get_actual_version(), a scan for src/beadloom/, the literal keyword set {python, sqlite} and the literal string pytest). A TypeScript adopter with a correct file was told their stack claim was missing keywords and their test framework was not pytest. Each check now reads the project, and a fact the project does not declare is reported INFO … not verified rather than as drift — unknown is not zero, and it is not a verdict either.
blank_auto_regions(text)
Replaces every auto-region BODY with a fixed token. config-check compares the composed part of CLAUDE.md against compose("claude", ...); the regions are generated per project and are supposed to move, so blanking them keeps the two checks from reporting each other's drift.
render_auto_regions(text, project_root)
The renderer refresh_auto_regions runs over a file, exposed over a string: returns the text with every auto-region rendered for project_root and the names of the regions that changed. Since BDL-083 S2h it is also what renders the core rule a Cursor agent reads (.cursor/rules/beadloom-flow.mdc), which is why that rule's body and .claude/CLAUDE.md are byte-identical (BDL-UX #356).
setup_mcp_auto(project_root)
Auto-detects editor (claude-code, cursor, windsurf) by marker files and creates MCP config. Returns editor name on success, or None if config already exists.
The server's command is MCP_SERVER_COMMAND, beadloom, the name every clone resolves on its own PATH. Up to 9.0.0 it was shutil.which("beadloom"), so init --bootstrap wrote one machine's absolute path into a committed .mcp.json (BDL-UX #356 e). setup-mcp reads the same constant.
Data Types
ScanResult (TypedDict)
Result of scan_project() — discovered project structure.
class ScanResult(TypedDict):
manifests: list[str] # Found manifest files (pyproject.toml, package.json, etc.)
source_dirs: list[str] # Discovered source directories
file_count: int # Total code file count
languages: list[str] # Detected file extensionsClusterEntry (TypedDict)
A two-level directory cluster produced by _cluster_with_children(), jvm_layout.cluster_packages() and swift_layout.cluster_targets().
class _ClusterPlacement(TypedDict, total=False):
directory: str # The cluster's folder, when not source_dir/name
child_directories: dict[str, str] # A child's folder, when not directory/child
class ClusterEntry(_ClusterPlacement):
files: list[str] # All code files in the cluster
children: dict[str, list[str]] # Child dir name → code files
source_dir: str # Owning top-level source directoryRead a cluster's folder with cluster_directory(name, entry) and a child's with child_directory(name, entry, child), never by joining the names: a JVM package or a Swift target lies deeper than its name says.
IndexCounts / Reindexer (reindex_port.py)
What init needs from the layer above it, stated as a type onboarding owns.
class IndexCounts(Protocol):
symbols_indexed: int # code symbols the run indexed
imports_indexed: int # import statements the run indexed
edges_loaded: int # graph edges the run loaded
docs_indexed: int # documents the run indexed (the wizard reports this one)
Reindexer = Callable[[Path], IndexCounts]interactive_init(project_root, *, reindex, is_portal=None) and non_interactive_init(project_root, *, reindex, mode=..., force=..., is_portal=None) take the re-index as a required keyword argument, and services/commands/setup.py supplies application.reindex.reindex. The optional is_portal probe is handed in for the same reason (beadloom-ujzb.24): setup.py supplies the scaffold's marker test (a file the scaffold ships, at its place in the folder, carrying the generated marker), which lives in application.site.
Why it is handed in. The declared direction is services → application → domains → infrastructure; onboarding is a domain and the re-index is an application use case, so init_flow.py importing beadloom.application.reindex ran against it. It did, twice and function-locally, and that was the only reverse-direction edge of the 357 that inheritance through part_of brings into the layer check's scope on this repository once layer membership is inherited through part_of (BDL-070 beadloom-46am). The inversion moves only where the callable comes from: the call itself still runs after every block that writes a graph file, which is the ordering BDL-067 .14 and .18 established.
Why it is required rather than defaulted. A default meaning "do not re-index" would let a caller take init's verdict over an index the run never refreshed — rc 0 from init, rc 1 from the adopter's next lint --strict, which is exactly what .14 closed. A default that resolves the import lazily would be the layering violation unchanged, and importlib.import_module would remove the derived edge by hiding the import from the scanner, which is the BDL-059 S3 workaround tests/test_no_domain_package_imports_application.py exists to prevent. A required argument fails at the call site instead.
CLI
beadloom prime [--json] [--update] [--project PATH]beadloom setup-rules [--tool cursor|windsurf|cline] [--project PATH]beadloom setup-mcp [--tool claude-code|cursor|windsurf] [--remove] [--project PATH]
MCP
primetool (no parameters) — returns JSON context for agent sessions
Source
src/beadloom/onboarding/scanner/— cohesion-split package;prime.py(prime_context()),agents_md.py(setup_rules_auto(),generate_agents_md(),setup_mcp_auto()),types.py(ScanResult,ClusterEntry), plusbootstrap.py/init_flow.py/project_scan.py/summary.py/entry_points.py/import_scan.py/readme.py/doc_classify.py/rules_gen.py/claude_md.py/constants.py/reindex_port.py, and the stack layoutsjvm_layout.py(read_jvm_layout(),JvmLayout,SourceRoot,is_test_set(),cluster_packages(),jvm_package_directory();JvmLayout.read_folders) andswift_layout.py(read_swift_layout(),SwiftLayout,TargetRoot,cluster_targets(),unread_swift(),UnreadSwift;SwiftLayout.read_folders);project_scan.pyalso holdsunclaimed_code(),UnclaimedCode,CodeBesideModules,generated_portals()andunscanned_portals_sentence(); since BDL-080 S3 the frontend readersfsd_layout.py(read_fsd_layout(),FsdLayout,FsdUnit,fsd_nodes(),FsdGraph,fsd_tag(),FSD_LEGACY_TAG,ROUTES_UNIT),expo_layout.py(read_expo_layout(),ExpoLayout,ExpoModuleUnit,NativePart,expo_nodes(),NATIVE_FOLDERS),expo_router.py(expo_router_routes(),EXPO_ROUTER_PACKAGE),steiger_script.py(ensure_steiger_script(),SteigerScript,SCRIPT_NAME) andalias_scan.py(scan_bundler_aliases(),AliasScan), and inrules_gen.pygenerate_fsd_rules(),fsd_rules_text()andFSD_COHESION_LIMITS; the package__init__.pyre-exports the full public surfacesrc/beadloom/onboarding/presets.py—FSD,FSD_LAYERS,fsd_root()and thefsdbranch ofdetect_preset()src/beadloom/services/commands/query.py—primeCLI commandsrc/beadloom/services/commands/setup.py—setup-rulesandsetup-mcpCLI commandssrc/beadloom/services/mcp_server.py—primeMCP tool