/** * Write-time layout lint. * * `brain-structure.md` defines the layout invariants and `structure-audit.md` * checks them periodically. Nothing checked them at the moment a page was * written, so a write to a path the spec forbids succeeded silently and the * violation was only found later — if anyone ran the audit at all. * * The cost of that gap is not tidiness. An instruction file naming a write-back * target that does not exist does not fail: the target gets created, the write * reports success, and the page everyone else reads goes stale. On one project * that ran for four months — a video sat recorded as "in edit ~50%" ten weeks * after it published, because state was being written to a phantom `active/` * tree nothing else read (GH #458). * * Warnings only. Never blocks, never throws. Brains hold years of legacy layout * and a hard failure mid-session is worse than a misfiled page — the point is to * tell the agent while it still has the context to fix it. * * Path-only, no I/O: this runs on every write, and a round trip per write to * check the spec would cost more than the spec is worth. That constraint shapes * which rules are here — see the note on scope below. * * GH #764 added one caller-supplied input, `declaredRootDirs`, so a wiki can * widen the sanctioned set via `instructions/brain-structure.md` frontmatter. * The function below still does zero I/O itself — resolving that set (which * does need a read) lives in `./rootFolders.js`, and callers skip the read * entirely except on the one write shape that could possibly need it. */ export interface LayoutWarning { /** Stable machine-readable rule id, so callers can filter. */ rule: string; path: string; message: string; } /** * Directories permitted at the brain root, from `brain-structure.md`'s * "cross-cutting root after a clean audit" list, plus the two system paths. */ export declare const SANCTIONED_ROOT_DIRS: Set; /** * Check a write target against the layout invariants. * * Scope note: every rule here concerns the brain root or the top level of * `projects/`. That is deliberate, and not only because those are the * unambiguous cases. A project may declare its own filing system in * `projects//readme.md` frontmatter, and a declared project is audited * against that skill's rules rather than the Operator invariants — but an * override only ever governs the inside of its own folder. Keeping every rule * outside project subtrees means no rule here can fire wrongly on a * `mind-palace` project, without needing to read a readme to find out. * * Invariant 2 (thin project roots) is the notable omission. Its threshold is a * count of loose files, which cannot be known from a path, and its allowed-list * half would fire on the majority of legitimate writes in projects that predate * the rule. It stays with the audit until there is data on how often it would * actually fire. * * `declaredRootDirs` (GH #764) is the effective root-folder set — the * hardcoded default union whatever a wiki declared in its own * `instructions/brain-structure.md` frontmatter (`additional_root_folders:`, * resolved by `resolveEffectiveRootDirs` in `./rootFolders.js`). It defaults * to the hardcoded set so every existing caller keeps its old behaviour. Only * `unsanctioned-root-folder` consults it — the declaration is additive-only * and cannot suppress any other invariant. This function stays pure and * I/O-free; resolving the declared set is the caller's job. */ export declare function lintLayout(name: string, declaredRootDirs?: Set): LayoutWarning[]; /** Lint several targets at once, e.g. a bundle push. Order is preserved. */ export declare function lintLayoutMany(names: string[], declaredRootDirs?: Set): LayoutWarning[]; export interface StructureDivergence { totalPages: number; undeclared: Array<{ dir: string; pageCount: number; }>; orphanDeclared: string[]; declaredShare: number; /** * Advisory-only, one line, present only when `undeclared` is non-empty. No * threshold and no severity: GH #790 Part A adds a nudge, not enforcement. */ nudge?: string; } /** * Measure how far a brain's actual root-folder layout has drifted from the * declared set — read-only, no I/O, no enforcement. Slice 1 of GH #752: the * write-time lint above can only ever flag one write at a time and cannot see * page counts, so it has no way to tell "a mistyped path" from "a folder * something has been filing into for months". This gives the periodic audit * that view without changing what the lint does on a single write. */ export declare function computeStructureDivergence(pageNames: string[], declaredRootDirs: Set): StructureDivergence; //# sourceMappingURL=layoutLint.d.ts.map