# configuration/strings/drift.strings.ts

> 264 lines of code and 13 definitions.

Tree: Site tree
Language: typescript
Layer: product
Canonical: https://banes-lab.com/anatomy/tree#file-configuration-strings-drift-strings-ts
Source text: https://banes-lab.com/assets/sources/source.d969025d44795c7b05ba779f04898ffff8cc9f728245063e484f2f9633dca800.generated.txt

## Definitions

- `SURFACE_SHAPE` (lexical_declaration, line 22)
- `RULE_SHAPE` (lexical_declaration, line 25)
- `PREDICATE_DIAGRAM` (lexical_declaration, line 28)
- `REAL_DIAGRAM` (lexical_declaration, line 31)
- `GRID_DIAGRAM` (lexical_declaration, line 34)
- `HEATMAP_DIAGRAM` (lexical_declaration, line 37)
- `CELL_DIAGRAM` (lexical_declaration, line 40)
- `GAP_DIAGRAM` (lexical_declaration, line 43)
- `PREDICATE_SECTION` (lexical_declaration, line 46)
- `GRID_SECTION` (lexical_declaration, line 102)
- `CELL_SECTION` (lexical_declaration, line 158)
- `GAP_SECTION` (lexical_declaration, line 217)
- `DRIFT_SECTIONS` (lexical_declaration, line 277, exported)

## Source

```typescript
import {
    CELL_SECTION_ICON,
    GAP_SECTION_ICON,
    GRID_SECTION_ICON,
    PREDICATE_SECTION_ICON,
} from "#configuration/icons/architecture.icons";
import { CELL_SECTION_ID, GAP_SECTION_ID, GRID_SECTION_ID, PREDICATE_SECTION_ID } from "#core/ids/architecture.ids";
import {
    DIMENSION_SECTION_ID,
    LENS_SECTION_ID,
    REASONING_TAB,
    SURFACE_SECTION_ID,
    UNCOVERED_SECTION_ID,
} from "#core/ids/ontology.ids";
import { ALGO_FACE } from "@govlab/constants";
import { ONTOLOGY_PAGE } from "#core/ids/page.ids";
import type { Section } from "#types/document.types";
import { TYPESCRIPT_LANGUAGE } from "#configuration/constants/code.constants";
import { faceLink } from "#domain/converters/ontology.converter";
import { tabLink } from "#assets/link.assets";

const SURFACE_SHAPE =
    'export const DIMENSIONS = ["identity", "composition", "structure", "relation", "space", "time", "state", "change", "behaviour", "function", "cause", "meaning", "scale", "probability", "novelty"] as const;\nexport const LENSES = ["structural", "temporal", "spatial", "statistical", "frequency", "sequential", "relational", "behavioural", "functional", "semantic", "causal", "predictive", "anomaly", "evolutionary", "fractal", "transformational", "invariant", "optimisation", "complexity"] as const;\n\nexport type Dimension = (typeof DIMENSIONS)[number];\nexport type Lens = (typeof LENSES)[number];\n\nexport type Cell =\n    | { readonly kind: "watched"; readonly invariant: string; readonly predicate: GateId }\n    | { readonly kind: "unwatched"; readonly invariant: string; readonly because: string }\n    | { readonly kind: "undecided"; readonly question: string };\n\nexport type CellKey = readonly [Dimension, Lens];\nexport type RuleSurface = ReadonlyMap<CellKey, Cell | null>;\n\nexport const emptyCells = (surface: RuleSurface): readonly CellKey[] =>\n    [...surface.entries()].flatMap(([cell, held]) => (held === null ? [cell] : []));';

const RULE_SHAPE =
    'export interface Rule<Shape> {\n    readonly cell: CellKey;\n    readonly detect: (tree: Tree) => readonly Shape[];\n    readonly report: (found: Shape) => { readonly invariant: string; readonly remediation: string };\n}\n\nexport interface Declared {\n    readonly predicate: string;\n    readonly status: "runs" | "absent";\n    readonly because: string | null;\n}';

const PREDICATE_DIAGRAM =
    'flowchart TB\n    intent["An architectural intent · a sentence about how the system should be"]\n    question["A question · what can drift, seen through how it drifts"]\n    type["A mathematical type · a set, an ordering, a graph, a number"]\n    predicate["A predicate · computable over the tree"]\n    selects["Selects what to examine next"]\n    closes["Marks when the concern is closed"]\n    habit["A habit · held while the developer remembers"]\n    intent --> question --> type --> predicate\n    predicate --> selects\n    predicate --> closes\n    intent -. without the walk .-> habit';

const REAL_DIAGRAM =
    'flowchart TB\n    design["A design"]\n    intentions["Its intentions · what the author meant"]\n    predicates["Its predicate set · what a check can decide"]\n    author{"Who writes the code?"}\n    person["The developer · intentions survive by attention, for a while"]\n    model["A model · every intention with no predicate is absent"]\n    real["The architecture that is real · the predicate set"]\n    design --> intentions\n    design --> predicates\n    intentions --> author\n    author -- developer --> person\n    author -- model --> model\n    predicates --> real\n    model -. only this survives .-> real';

const GRID_DIAGRAM =
    'flowchart LR\n    subgraph dimensions["What can drift"]\n        identity["identity"]\n        relation["relation"]\n        change["change"]\n        meaning["meaning"]\n    end\n    subgraph lenses["How it drifts"]\n        structural["structurally"]\n        relational["relationally"]\n        sequential["sequentially"]\n        semantic["semantically"]\n    end\n    cell["A cell · one invariant, watched, unwatched with a reason, or undecided"]\n    identity --> cell\n    relation --> cell\n    change --> cell\n    meaning --> cell\n    structural --> cell\n    relational --> cell\n    sequential --> cell\n    semantic --> cell';

const HEATMAP_DIAGRAM =
    'block-beta\n    columns 5\n    corner[" "] structural["structural"] relational["relational"] sequential["sequential"] semantic["semantic"]\n    identity["identity"] i1["watched"] i2["unwatched · declared"] i3["undecided"] i4["watched"]\n    relation["relation"] r1["watched"] r2["watched"] r3["undecided"] r4["unwatched · declared"]\n    change["change"] c1["undecided"] c2["watched"] c3["watched"] c4["undecided"]\n    meaning["meaning"] m1["unwatched · declared"] m2["undecided"] m3["watched"] m4["watched"]';

const CELL_DIAGRAM =
    'flowchart TB\n    enumerate["Enumerate the checks that exist"]\n    map["Map each to its cell · dimension by lens"]\n    walk["Walk the grid"]\n    empty{"Empty cell?"}\n    name["Name the invariant that should hold there"]\n    decide{"Can the invariant be stated?"}\n    author["Author the predicate, or record the cell as deliberately unwatched"]\n    undecided["An undecided intent · the finding is the design, never the rule"]\n    enumerate --> map --> walk --> empty\n    empty -- yes --> name --> decide\n    decide -- yes --> author\n    decide -- no --> undecided';

const GAP_DIAGRAM =
    'flowchart TB\n    called["A predicate the method calls for"]\n    exists{"Does the tree run it?"}\n    runs["Declared present · it runs in the chain"]\n    absent["Declared absent · named in the one document that binds method to tree"]\n    assumed["Assumed · the document describes an upgrade the tree never made"]\n    called --> exists\n    exists -- yes --> runs\n    exists -- no --> absent\n    exists -. neither written down .-> assumed';

const PREDICATE_SECTION: Section = {
    icon: PREDICATE_SECTION_ICON,
    id: PREDICATE_SECTION_ID,
    intro: "This section covers how an architectural intent becomes a predicate a check can run. The reasoning axis of the ontology turns a question into a type and a type into a predicate, as shown in <cite>intent to predicate</cite>, and the same axis is walked on a request in resolving a message on the methodology page. How much of a design is real depends on who writes the code, as shown in <cite>what is real</cite>.",
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, every architectural intent is stated as a question about what can drift, seen through how it drifts, and the question is resolved to a type. What exists is a set, how parts are arranged is an ordering, what connects is a graph, and how sure you are is a number. The predicate is derived from the type and run over the tree as a check.",
                    boundary:
                        "Determinism lives in the predicate and never in the judgement that authored it. Which cells are worth watching is a decision, while whether a cell's predicate holds is a computation. The decision stays with the developer and the computation with the check, and a predicate never encodes taste.",
                    cause: "An intention has no objector, so its first violation is silent, and a system whose rules are silent is governed by attention rather than by structure.",
                    decision:
                        "The architecture is counted by what the gate refuses rather than by what the document states.",
                    failureMode:
                        "A design document states twelve principles, the codebase honours four, and no reviewer can say which four without reading everything, because the other eight were never anything a check could evaluate.",
                    kind: "lesson",
                    principle:
                        "For this reason an architecture is its predicate set, and a predicate selects what to examine and marks when the concern is closed.",
                    problem:
                        "Architecture is usually a set of intentions, and an intention cannot be evaluated, so neither the developer nor the model can say how much of the architecture is real.",
                    validation:
                        "To check this, list the architectural claims your system makes. Beside each, name the predicate that decides it and where that predicate runs. A claim with no predicate beside it is a sentence in a document, and the document is the only place it holds.",
                },
                { caption: "intent to predicate", kind: "mermaid", text: PREDICATE_DIAGRAM },
            ],
            title: "Question, type, predicate",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: "The double duty is what makes derivation possible. The predicate that says an export is unreachable is the same predicate that says reachability is covered, so one reading tells you where to work and the other tells you the dimension is watched. A project that has the first without the second accumulates checks by incident, and one that has both can derive its checks from its invariants.",
                },
                {
                    kind: "text",
                    text: "Policy as code is the canon's name for the whole move, and fitness functions are the same predicates run against an architecture rather than a request. Static analysis is where most predicates live, because a shape in a tree can be decided without running anything, and design by contract is the same idea one level down, with preconditions, postconditions and invariants that a check can evaluate rather than a comment can promise.",
                },
                { caption: "what is real", kind: "mermaid", text: REAL_DIAGRAM },
            ],
            title: "A predicate does two jobs",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: "The coverage question is then answered from the grid described in what can drift, seen through how it drifts, rather than from a count of rules. Security theater is what a count produces, with the presence of controls standing in for their coverage. A predicate set answers the other question, which cells have something that can disagree with them, and that is the only sense in which an architecture is enforced.",
                },
            ],
            title: "Coverage from the grid, never from a count",
        },
    ],
    title: "From intent to predicate",
};

const GRID_SECTION: Section = {
    icon: GRID_SECTION_ICON,
    id: GRID_SECTION_ID,
    intro: `This section covers the coverage grid and its two closed axes. The <a href="${tabLink(ONTOLOGY_PAGE, REASONING_TAB, DIMENSION_SECTION_ID)}">dimensions</a> are what can drift and the <a href="${tabLink(ONTOLOGY_PAGE, REASONING_TAB, LENS_SECTION_ID)}">lenses</a> are how it drifts, and a cell is one invariant that must hold, watched by a predicate or declared unwatched with its reason, as shown in <cite>two axes, one cell</cite> and <cite>a corner</cite> and typed in <cite>a rule surface</cite>. Because both axes are closed, the cells are enumerable, so the cells nothing watches are enumerable too, and a rule set is measured against the grid rather than against the incidents that happened to produce it.`,
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, the dimensions along which the system can drift and the lenses through which each drift is seen are named as two lists. Every existing check is placed in the cell it watches, one invariant per cell, and an empty cell is read as a drift class nothing watches.",
                    boundary:
                        "The grid enumerates where drift can be watched and says nothing about which cells deserve a rule. A full grid is not the goal. The goal is a grid whose every cell is watched, unwatched with a stated reason, or marked undecided, and the undecided cells carry the design decisions still to make.",
                    cause: "Without closed axes there is nothing to divide by, so coverage is reported as a count that grows with every incident and never says what is missing.",
                    decision: "The axes are closed before anything is counted, so the count has a denominator.",
                    failureMode:
                        "A suite reports hundreds of passing tests, the surface that fails in production was one none of them reached, and the green run was evidence over the wrong set.",
                    kind: "lesson",
                    principle:
                        "For this reason coverage is a grid of what can drift against how it drifts, and an unmeasured cell is unknown rather than clean.",
                    problem:
                        "A rule set with no denominator reports how many checks exist, which says nothing about how many drift classes have none.",
                    validation:
                        "To check this, take the checks you have and place each in its cell, then count the empty cells. If you cannot place a check, its invariant was never stated, and if you cannot count the empties, the axes were never closed.",
                },
                { caption: "two axes, one cell", kind: "mermaid", text: GRID_DIAGRAM },
            ],
            title: "Two closed axes",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: "A module reaching across a boundary is relation seen relationally, and a circular dependency is relation seen structurally. Two files claiming one role is identity seen structurally. A manifest entry rotting is composition seen through evolution. A discriminated union gaining a case nothing handles is change seen sequentially. A registry written and never read is function seen functionally. Intent living in a comment is meaning seen semantically. The same defect at every scale is scale seen fractally, and a convention followed everywhere except here is novelty seen as anomaly.",
                },
                { caption: "a corner", kind: "mermaid", text: HEATMAP_DIAGRAM },
                { code: SURFACE_SHAPE, kind: "code", language: TYPESCRIPT_LANGUAGE, title: "a rule surface" },
            ],
            title: "The axes, and a cell read off them",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: `The same grid projected onto correctness is the <a href="${tabLink(ONTOLOGY_PAGE, REASONING_TAB, SURFACE_SECTION_ID)}">test-surface catalogue</a>. Every surface a unit can fail in names its failure modes, its technique, its predicate and its evidence source, and its verdict domain carries unknown as a value distinct from pass. Property-based testing and specification-based testing are techniques a surface names, and chaos engineering is the technique for the surfaces only a running system can fail in.`,
                },
                {
                    kind: "text",
                    text: `An unmeasured surface is unknown rather than clean, as described in unknown is not pass and recorded in ${faceLink(ALGO_FACE, "evidence-verdict", "the evidence verdict")}. Test pyramid inversion and the mock mirage are the two ways a green run stops being evidence, and ${faceLink(ALGO_FACE, "coverage-completion", "completion")} is the absence of required surfaces still unknown, never a percentage, because a percentage averages the surfaces that matter with the ones that cannot fail.`,
                },
            ],
            title: "Projected onto correctness",
        },
    ],
    title: "What can drift, seen through how it drifts",
};

const CELL_SECTION: Section = {
    icon: CELL_SECTION_ICON,
    id: CELL_SECTION_ID,
    intro: "This section covers the walk over the grid that plans coverage, shown in <cite>the walk</cite>, and the step in it where a cell resists an invariant.",
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, the grid is walked with the checks that exist, and every empty cell is treated as a question rather than a gap. Where the invariant states itself, the predicate is authored. The unwatched cells are recorded with their reasons, so the unassessed set stays countable and a later reader can tell a decision from an oversight.",
                    boundary:
                        "A cell whose predicate nothing could ever disagree with is not authored. It is held with the forgone property written down, for the reason described in the check comes first on the methodology page.",
                    cause: "A rule set built by incident has a shape decided by which incidents happened, and the drift classes that never produced an incident are exactly the ones with nothing watching them.",
                    decision:
                        "Authoring stops when a cell resists, and the design is decided before the check, because the cell is saying the convention it would enforce was never chosen.",
                    failureMode:
                        "A team adds a check after every outage, the check count grows, and the failure that ships next lives in a cell the outages never happened to touch.",
                    kind: "lesson",
                    principle:
                        "For this reason a cell that resists an invariant is an undecided intent rather than a missing rule.",
                    problem:
                        "Checks accumulate by incident, so the covered cells are the ones that already failed and the uncovered ones are the ones that will.",
                    validation:
                        "To check this, find an empty cell and try to state its invariant in one sentence that could be false. If the sentence comes, you were missing a check. If it does not, you are missing a decision, and no check can be written until it is made.",
                },
                { caption: "the walk", kind: "mermaid", text: CELL_DIAGRAM },
            ],
            title: "Walk the grid",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: "Two invariants keep this a method rather than a rule pile. The first is that no rule exists without a consuming failure mode. A rule earns its place only if a real drift class fires it, because a rule nothing can violate is ceremony, and ceremony costs the same review attention as a real rule, which is how a rule set stops being read.",
                },
                {
                    kind: "text",
                    text: "The second is that the rule set is derived while the judgement that authored it is not. Which cells need watching is a deterministic function of the architecture's declared invariants, whether an invariant was worth declaring is a decision, and the determinism stays in the predicate rather than in the deciding.",
                },
            ],
            title: "Two invariants of the walk",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: `The ${faceLink(ALGO_FACE, "surface-grid-walk", "walk itself")} and the ${faceLink(ALGO_FACE, "uncovered-gap-derivation", "gap it derives")} are records in the canon, and the cells the canon has not yet covered are <a href="${tabLink(ONTOLOGY_PAGE, REASONING_TAB, UNCOVERED_SECTION_ID)}">listed rather than assumed away</a>.`,
                },
                {
                    kind: "text",
                    text: "Gap analysis is the activity, and a resisting cell is its most useful output. A cell whose invariant states itself was a missing rule. A cell whose invariant will not state itself is an architecture review waiting to happen, and an architecture decision record is where its answer lands, so the next walk finds a decision rather than the same empty cell.",
                },
            ],
            title: "The walk in the canon",
        },
    ],
    title: "A cell that resists an invariant",
};

const GAP_SECTION: Section = {
    icon: GAP_SECTION_ICON,
    id: GAP_SECTION_ID,
    intro: "This section covers how a rule reports what it finds and how a method declares what it lacks. Every cell that earns a rule renders two ways from one entry, a detect half and a report half, as typed in <cite>a rule entry</cite>. Every predicate the method calls for is either running in the tree or declared absent in the one document that binds the method to the tree, as shown in <cite>running or absent</cite>. A method that cannot say which of its own predicates are missing has not measured itself, and a document that describes an upgrade the tree never made is the schema drift described in a system is a graph.",
    subsections: [
        {
            blocks: [
                {
                    application:
                        "In practice, each rule is authored as one entry with a detect half and a report half, discovered by shape and consumed whole by the gate. One document names every predicate the method calls for and states, for each, whether the tree runs it.",
                    boundary:
                        "A declared gap is not a license. Naming a predicate as absent keeps the document honest and leaves the drift class unwatched, so an absent predicate is still a cell to decide, and the declaration only says that the decision has not been made yet.",
                    cause: "A blocking message names a rule without its reason, so the same violation returns from the next author, and a document that only describes the ideal cannot be checked against the tree, so its gaps are found by failure rather than by reading.",
                    decision:
                        "The report half is written beside the detect half rather than a blocking message alone, and an absence is named in the binding document rather than left to be assumed.",
                    failureMode:
                        "A check refuses a change with a message that names a rule id, the author works around the id, and the document that describes the method lists a predicate that has never run anywhere.",
                    kind: "lesson",
                    principle:
                        "For this reason a rule detects and reports from one entry, and a predicate the tree does not run is declared absent, never assumed.",
                    problem:
                        "Checks that only block teach nothing, and methods that only describe cannot say which of their own predicates exist.",
                    validation:
                        "To check this, take any finding your gate prints and ask whether it names the invariant and the remediation. Then take the document that describes your method and ask, for each predicate it calls for, whether the tree runs it. A finding that names only a rule, or a predicate that cannot be located, is the gap.",
                },
                { caption: "running or absent", kind: "mermaid", text: GAP_DIAGRAM },
            ],
            title: "Detect, report, declare",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: "The detect half is the predicate that fires on the violating shape. The report half is the message that names the invariant and the remediation, so the failure teaches the convention rather than only blocking. Auto-remediation follows where the remediation has one correct answer, and where it does not the report still carries the handle a reasoning agent needs.",
                },
                {
                    kind: "text",
                    text: "Enforcement then follows the registry pattern, with one entry per rule discovered by shape through auto-discovery and consumed by the gate, and the whole set failing the build on drift. Where a project already has a registry primitive for code, enforcement reuses it rather than inventing a second one.",
                },
                { code: RULE_SHAPE, kind: "code", language: TYPESCRIPT_LANGUAGE, title: "a rule entry" },
            ],
            title: "One entry, two halves",
        },
        {
            blocks: [
                {
                    kind: "text",
                    text: "The walk is also how the gaps are named. A predicate the method calls for and the tree does not have is declared absent, in the one document that binds the method to the tree, rather than assumed. The epistemic and structural predicates normally exist and run, deciding whether something is reachable, consumed, grounded, drifting or covered.",
                },
                {
                    kind: "text",
                    text: "The conative ones are the usual gap, such as a computed worth over branches, a detector for a run that stops making progress, and a calibrated confidence rather than a threshold. The methodology page keeps its own list under the same title, the honest gaps, and the two lists are one declaration read from two sides.",
                },
            ],
            title: "Declared absent, never assumed",
        },
    ],
    title: "The honest gaps",
};

export const DRIFT_SECTIONS: readonly Section[] = [PREDICATE_SECTION, GRID_SECTION, CELL_SECTION, GAP_SECTION];
```
