Appendix B - 3. Component & zone model

The Structure of Component & zone model — its shape at a glance:

A typed registry names each component's zone once. Consumers read the registry instead of re-inferring from paths, and a reverse-mapping test walks the real tree and asserts parity in both directions.

flowchart LR
  Reg[(Component registry)] --> Lints[Boundary lints]
  Reg --> Dispatch[Dispatch]
  Reg --> Inject[Context injection]
  Tree[(Real directory tree)] --> RM{{Reverse-mapping test}}
  Reg --> RM

Accessible description: a typed component registry feeds three consumers — boundary lints, dispatch, and context injection — so they read one answer. A reverse-mapping test compares the registry against the real directory tree and fails on divergence.

Projected from the catalogue entry system-models / Component & zone model.

On this page: Intent · Motivation · Applicability · Structure · Sample Code · Consequences · Example use within DocAble · Related Patterns

Intent

Intent — A typed catalogue of every component's code zone (focus-dirs, tags, boundary kind, external seams, read surfaces), so "which component owns this file, and what may touch it" is a queried fact, not a guess.

Motivation

Governance constantly asks "which component owns this file? what zone is it in? what boundary kind, what seams?" Answered ad hoc, with a hardcoded path list here and a grep there, those answers drift the moment a component is added or a directory moves, and the tool keeps passing while reasoning about a stale map. It is also the map an agent needs to know where it is in a large codebase.

Applicability

Structure

The Structure diagram appears at the top of this page.

Sample Code

A frozen record names each component's zone. Ownership is a lookup that finds the record whose directory prefixes the path, and a reverse-mapping check asserts every real directory maps back to exactly one component — the parity that stops the map staling as directories move.

from dataclasses import dataclass
import sys

@dataclass(frozen=True)
class Component:
    name: str
    focus_dir: str      # the directory prefix this component owns
    boundary: str       # e.g. "leaf" / "group" / "external-seam"

REGISTRY = [
    Component("editor", "src/editor/", "leaf"),
    Component("worker", "src/worker/", "leaf"),
]

def owner_of(path: str) -> str | None:
    for c in REGISTRY:
        if path.startswith(c.focus_dir):
            return c.name
    return None

def reverse_map(real_dirs: set[str]) -> list[str]:
    """Every real top-level dir must map to exactly one component (no unmodeled zone)."""
    owned = {c.focus_dir for c in REGISTRY}
    return [f"'{d}' exists but no component owns it" for d in sorted(real_dirs - owned)]

if __name__ == "__main__":
    # `list_real_dirs` enumerates the code tree's owned directories.
    findings = reverse_map(list_real_dirs())
    for f in findings:
        print(f"UNMODELED-ZONE: {f}")
    sys.exit(1 if findings else 0)

Consequences

Example use within DocAble

Contents
© James C. Davis, 2026–present