Appendix A - 28. Enforce at the right semantic level

The Structure of Enforce at the right semantic level — its shape at a glance:

Rank the candidate placements as a ladder of widening scope; find the rung where the property is legible; place the mechanism there. Below that rung the check is blind or false-fires; at or above it, the property is decidable.

flowchart TB
  Prop[Property to enforce] --> Q{At what scope is<br/>the property legible?}
  Q --> L1[Rung 1 · one changed file<br/>syntactic check]
  Q --> L2[Rung 2 · reasoning over the diff]
  Q --> L3[Rung 3 · whole worktree / final commit]
  Q --> L4[Rung 4 · whole task on agent return]
  L1 -. below legible scope .-> Miss([Misses, or false-fires])
  L4 ==>|legible here| Fire([Mechanism decides correctly])

Accessible description: a property to enforce is matched against a ladder of placements ordered by widening scope — one changed file, reasoning over the diff, the whole worktree, the whole task on agent return. A mechanism placed below the scope at which the property is legible either misses it or false-fires on a partial state; a mechanism placed at the rung where the property is legible decides correctly.

Projected from the catalogue entry governance-doc-controls / Enforce at the right semantic level.

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

Intent

Intent — Place a mechanism at the granularity where the property it checks first becomes legible, not at the cheapest or earliest point; a check fired below that scope either can't see the property or rejects a legitimate partial state (our instance: model↔code drift is checked when an agent returns from a multi-commit task, never at a per-commit hook where the model is legitimately mid-flight).

Motivation

A property has a scope at which it becomes legible — the smallest window in which enough of the world is visible to decide it true or false. Place a mechanism below that scope and it fails one of two ways:

The reflex is to place a mechanism where it is cheapest and earliest — the pre-commit hook, the single syscall, the one changed file — because that is where enforcement is convenient. Convenience and legibility are different axes, and when they diverge the convenient placement is wrong. The failure recurs at every new mechanism's design, and it is silent: a mis-placed mechanism looks wired, runs green (or red) on every fire, and never enforces the thing it was built for.

Applicability

Structure

The Structure diagram appears at the top of this page.

Sample Code

Placement is a design-time judgment, so the "code" is the decision procedure, not a runtime call: for a given property, pick the coarsest window it needs, and refuse to wire the mechanism any lower. Here the property model_and_code_agree is a claim about a finished unit, so it is legible only at agent-return scope; wiring it at the commit rung is the mis-placement the procedure rejects.

from enum import IntEnum

class Scope(IntEnum):                 # the ladder, ordered by widening semantic scope
    CHANGED_FILE   = 1                # a syntactic check over one file
    DIFF_REASONING = 2                # a pass that reasons over the whole diff
    WORKTREE       = 3                # the whole worktree / final commit
    TASK_RETURN    = 4                # the whole unit of work, when the agent returns

def legible_scope(prop: str) -> Scope:
    # the smallest window in which the property's evidence is fully visible
    if prop == "banned_api_absent":      return Scope.CHANGED_FILE     # evidence is in one file
    if prop == "no_data_exfiltration":   return Scope.DIFF_REASONING   # a SEQUENCE, not one call
    if prop == "model_and_code_agree":   return Scope.TASK_RETURN      # a FINISHED-unit claim
    raise ValueError(f"unranked property: {prop}")

def place_mechanism(prop: str, chosen: Scope) -> None:
    need = legible_scope(prop)
    if chosen < need:                                                  # below legible scope = blind / false-fires
        raise SystemExit(
            f"'{prop}' is legible at {need.name}, not {chosen.name}: "
            "the mechanism would miss it or reject a legitimate partial state"
        )
    wire_mechanism(prop, chosen)                                       # at or above: the property is decidable

Consequences

Example use within DocAble

Contents
© James C. Davis, 2026–present