# Layer 3 — Signal and decision model of Objective Guard

## Signal classes

### Class A — Deterministic fact

Result reproducible by inspection or execution:

- file does not parse;
- assertion removed;
- test disabled;
- public contract incompatible;
- focused command fails;
- dependency added.

Can operate from day one. Its severity depends on policy, not probability.

### Class B — Incomplete evidence

Describes absence or insufficiency:

- bugfix without reproduction;
- criterion without test or contract;
- partial impact graph;
- required check not executed.

Produces `unknown` or `block` in final mode if policy so establishes.

### Class C — Statistical signal

Describes an unusual trajectory relative to comparable tasks:

- extreme surface;
- architectural dispersion;
- accumulated expansion;
- evidence growing slower than change;
- anomalous probability of rewrite attempt.

Begins in passive mode. Does not imply the code is incorrect.

### Class D — Model-assisted judgment

Can propose localization, classification, criteria, or explanations. Never blocking without translation to a Class A, B, or explicit human policy.

## Change surface

The repository is represented as a typed graph \(G=(V,E)\). Its nodes can be modules, files, or symbols; edges represent imports, calls, inheritance, events, data, and build.

For each step \(t\):

\[
\mathbf{s}_t=
[F_t,L_t,Y_t,M_t,P_t,D_t,H_t,C_t]
\]

| Variable | Meaning |
| --- | --- |
| \(F_t\) | Modified files. |
| \(L_t\) | Line churn. |
| \(Y_t\) | Modified symbols. |
| \(M_t\) | Reached modules. |
| \(P_t\) | Public boundaries touched. |
| \(D_t\) | Distance from target set. |
| \(H_t\) | Entropy of distribution across modules. |
| \(C_t\) | Centrality of modified nodes. |

The target set \(O\) is known in seeded benchmarks. In production it must be derived from the session contract and may be incomplete.

\[
D_t=
\frac{\sum_{v\in C_t}w(v)\min_{o\in O}d_G(v,o)}
{\sum_{v\in C_t}w(v)}
\]

Dispersion across modules is represented by:

\[
H_t=-\sum_i p_i\log p_i
\]

To capture transient changes that later revert:

\[
AUS=\sum_{t=1}^{T}S_t\Delta t
\]

Objective Guard preserves the complete vector. A scalar score may prioritize, but must not hide what factors explain the alert.

The first executable instrumentation uses `trajectory-features-v1`. It preserves (F,L,M,P,H) directly from the event; (D) is for now `outside_scope_ratio`, a **proxy for distance to the objective** and not a graph distance. It defines a descriptive surface (S=F+L+M+P+D+H), with heterogeneous units that must not be interpreted as risk or as probability. The initial AUS is discrete per round, `AUS_round = Σ S_t`: it does not turn periods of human inactivity into area. These formulas and ε = 10⁻⁶ are exported alongside each dataset to prevent implicit recalibration.

## Evidence

Each criterion \(a_j\) possesses state and reproducible evidence. For investigation a predefined ordinal strength can be assigned:

\[
e_j\in\{0,0.25,0.5,0.75,1\}
\]

Total evidence is:

\[
E_t=\sum_j q_je_{j,t}
\]

Weights \(q_j\) must be declared before evaluation and subjected to sensitivity analysis.

The evidence-surface relationship is:

\[
J_t=\frac{E_t+\epsilon}{S_t+\epsilon}
\]

A relevant drift signal is:

\[
\Delta S_t \gg \Delta E_t
\]

This means the solution expands its impact without proportionally demonstrating new criteria.

In `trajectory-features-v1`, all required criteria carry uniform weight and `E = proven_required / required`; if no required criteria exist, `E = 0`. It is a reproducible coverage measure, not semantic evidence that the criterion is well formulated. `J=(E+ε)/(S+ε)` is logged without threshold, ranking, or alert.

For historical comparison, median, MAD, and conformal prediction are preferred over assumed normality. The conformal p-value:

\[
p_t=\frac{1+\#\{i:A_i\ge A_t\}}{n+1}
\]

is interpreted as extremity relative to the comparable sample, not as probability of incorrectness.

### Change amplification

Objective Guard may consume a project-provided change-amplification signal that combines historical change frequency with an impact surface:

\[
A(v)=frequency(v)\times impactSurface(v)
\]

The entity \(v\) may be a file, module, package, service, or another stable unit. `impactSurface` is defined by a repository adapter or external analyzer and may represent reachable tests, downstream modules, pipelines, deployments, or another declared impact unit. The core does not assume a language, filename convention, test framework, graph extractor, or that amplification measures actual CI time.

The signal preserves its factors and baseline instead of exposing only the product. An early evaluation distinguishes:

1. a changed entity that was already an amplification outlier at baseline;
2. a material increase in impact surface during the current round;
3. a new crossing into an outlier region.

A frequency increment caused merely by touching an entity does not by itself mean that the architecture worsened. Therefore, early intervention prioritizes `impactSurface` delta and outlier crossing; touching a pre-existing outlier is contextual risk. Comparisons use declared cohorts and robust or conformal methods rather than a normal distribution over the raw product. Small or non-comparable cohorts lower confidence and cannot silently fall back to a blocking conclusion.

The full history, graph, cohorts, and reference distribution are computed outside the per-edit critical path and stored as a versioned baseline. Early checks evaluate changed entities and their local graph delta against that baseline. A provider reports provenance, units, coverage, gaps, confidence, baseline and candidate values, percentile or robust statistic, and computation duration. Missing provider coverage remains explicit.

Amplification begins as passive telemetry. Existing large development rounds can supply organic trajectories for calibration, but telemetry volume alone does not authorize an alert. After out-of-sample validation, policy may surface a non-blocking warning for a material increase or threshold crossing. It can require justification only after intervention validation, and it can block only when an explicit contract criterion forbids the increase or a separate deterministic violation exists.

## Decision policy

### Objective substitution

`goal-substitution` is initially a deterministic contract signal, not a statistical one. It simultaneously requires:

1. valid contract and active policy;
2. material surface by files or churn;
3. zero observable evidence for the KRs the round declares it contributes to;
4. at least one file outside scope or within an observable non-goal.

With `warn` policy its initial severity is `warning` and it never blocks; with `observe` policy it is logged as an observation without warning the agent. Absence of evidence without a declared deviation does not alert, because it may represent legitimate incremental work. The statistical plane receives these observations passively and does not change the decision until it reaches the pre-registered gates.

| Evidence | Calibration | Default decision |
| --- | --- | --- |
| Deterministic fact of blocking severity | Not required | `block` |
| Non-blocking deterministic fact | Not required | `warn` |
| Required criterion without evidence, fast mode | Not required | `unknown` |
| Required criterion without evidence, final mode | Explicit policy | `block` |
| Uncalibrated statistical signal | Absent | Record, do not alert |
| Calibrated moderate signal | Out-of-sample validated | `warn` or expand checks |
| Calibrated extreme signal | Validated with intervention | Pause and require justification |
| Model judgment | Not applicable | Proposal without authority |

The verdict must include:

```json
{
  "status": "block",
  "scope": "checks_executed_only",
  "new_findings": [],
  "criteria": [],
  "impact": {},
  "checks_run": [],
  "checks_skipped": [],
  "duration_ms": 0,
  "reproduce": "oguard check --finding FINDING_ID"
}
```

A `pass` explicitly declares what was verified and what remained outside.
