# Layer 6 — Objective Guard Roadmap and Criteria

## Build order

### Phase 0 — Contract and Documentary Dogfooding

Deliverables:

- canonical layer-by-layer documentation;
- reproducible documentary guard;
- research preserved as history;
- explicit MVP criteria.

Gate: `node scripts/validate-docs.mjs` passes without exceptions.

### Phase 1 — Universal Reflection

Deliverables:

- per-edit hook;
- `syntax`, `weak-test`, `stub-prod`, `new-dep` detectors;
- delta-only fingerprints;
- compact output;
- append-only events;
- golden corpus and latency benchmark.

Gate: meets budgets, detects seeded cases, and requires no contract.

Calibration is governed by the [Phase 1 protocol](07-phase-1-calibration-protocol.md): the executable gate is a frozen corpus of 100 scenarios, and organic evidence is observed without promising a baseline error rate.

### Phase 2 — Session and Contract

Deliverables:

- task types;
- original objective and criteria;
- objective scope and sensitive zones;
- evidence obligations;
- per-criterion states;
- auditable exceptions.

Gate: a bugfix cannot close without regression evidence when policy requires it.

### Phase 3 — Incremental Impact

Deliverables:

- workspace discovery;
- initial path/import graph;
- check selection;
- cache per inputs;
- fast and final modes.

Gate: an internal refactor avoids checks for unaffected workspaces without omitting public consumers.

### Protocol hardening for long multi-agent rounds

This work follows the session/contract foundation and precedes dependence on any orchestration product:

- separate versioned governance from local active-round state;
- support inherited definition, implementation, review, and correction subrounds;
- fingerprint pre-existing check failures and compare incrementally;
- classify closure failures by origin and executability;
- accumulate evidence and contradictions per criterion;
- add `objective-status --json` and the closure traceability matrix;
- explain preflight lifetime and invalidation;
- accept generic external correlation IDs.

Gate: two parallel subrounds can inherit one parent objective, contribute and contradict criterion evidence without rewriting it, and close with a reproducible requirement-to-commit matrix.

### Phase 4 — Passive Statistical Signals

Deliverables:

- vectorial surface;
- AUS;
- relative evidence;
- separate calibration and evaluation datasets;
- offline reports without alerting the agent.

Gate: exceeds simple baselines out of sample.

### Phase 5 — Calibrated Intervention

Deliverables:

- control/placebo/guard trial;
- alert policy;
- factor explanation;
- false positive monitoring.

Gate: reduces cost without reducing correct resolution.

## MVP

The product MVP is Phase 1, not the full control plane.

Includes:

1. Locally executable CLI.
2. Generic hook integration.
3. Initial JS/TS support; Java conditioned on spike.
4. Four universal detectors.
5. Fingerprints and delta-only.
6. Maximum five lines per event.
7. Optional JSON with stable codes.
8. Discardable state and append-only event log.
9. Timeout and fail-open visible as `error` in log.
10. Golden corpus and latency measurement.

Does not yet include:

- repo-wide semantic indices;
- task contracts;
- active statistical detector;
- dashboard;
- public plugin SDK;
- distributed execution.

## Acceptance criteria

### Functional

- Detects a newly disabled test and points to the line.
- Detects invalid syntax in the edited file.
- Warns of a new stub in production code.
- Warns of a new dependency.
- Does not re-emit the same fingerprint on next run.
- Summarizes resolved findings.
- Emits valid JSON when requested.
- Records a reproducible event per run.

### Performance

- p95 warm under 200 ms on target machine.
- p95 cold under 400 ms.
- Each detector has individual timeout.

### Quality

- Zero false negatives in frozen golden corpus.
- False positive rate is reported, not hidden.
- User does not need to disable the hook during pilot.
- At least one real or seeded case demonstrates detection before traditional check.

### Protocol

- An `error` never produces `pass`.
- Output identifies its scope.
- Findings include rule, file, location, and reproduction.
- Event log allows reconstruction of trajectory.

## Deferred decisions

### Language

Decided via cold start and parsing spike. Not fixed by preference.

### CLI Name

`oguard` is provisional. Product name is Objective Guard.

### Contract Format

YAML or JSON decided when implementing Phase 2; internally there will be a schema-validated representation.

### Database

SQLite is the initial option for evidence; the MVP only needs state files and JSONL.

### Severity of `new-dep`

Begins as warning. Requires local policy to block.

### Statistics Activation

Not decided by calendar. Depends on calibration, generalization, and intervention trial.

### Orca integration

Deferred. The core first defines generic subround and external-evidence protocols. A future Orca adapter may correlate Run, Task, Dispatch, worker, commit, and completion events without making Orca a runtime dependency of Objective Guard.
