# E-025 — A pre-edit gate installed on `PostToolUse` would have arrived too late

- Status: integration false negative prevented before real use; operational effectiveness not yet observed.

## Objective hierarchy

- Main objective: detect and stop agent drift early with measurable evidence.
- Product objective: enforce the explicit task flow before a structured edit in Claude and Codex.
- Round: `R-EVIDENCE-CONTEXT`, which incorporates `task-flow`, work context, and comparable evidence.

## Observed trajectory

After implementing the gate that responds `permissionDecision: deny` without a `task-flow: ready`, the first edit to the global configurations matched the `PostToolUse` block by textual pattern. The JSON was valid and the hook existed, but it would have run after the write: it would observe the missing preflight too late to fulfill its objective.

## Expected and actual behavior

The expected behavior was a denial before `Edit|Write`. The actual behavior of that first installation would have been a post-edit observation. Explicit validation of the hook topology — event and matcher, not just parseable JSON — caught the difference before opening an agent session that could mutate.

## Correction and evidence

The `PostToolUse` block was removed and installed under `PreToolUse` with matcher `Edit|Write` in the global Claude and Codex configuration files. Both configurations again parse as JSON and point to the same `src/pre-edit-gate.mjs`. The regression `test/pre-edit-gate.test.mjs` tests denying before a preflight and allowing after `task-flow: ready` against the current contract hash.

## Classification and limits

This is a **prevented** integration false negative, not an organic finding from the agent, nor evidence that the gate already reduces drift. The test covers the gate's local semantics; it remains to verify that each harness interprets the permission output as a block during an actual new session.

## Impact on the thesis

A hook installed on the wrong event can produce flawless telemetry but zero early intervention. Integration evidence must therefore include lifecycle placement, denial capability, and a real trial, not just the presence of the script or a valid configuration file.

## Verifiable follow-up

In the next new Claude and Codex session, attempt a structured edit without running `oguard task-flow --json`; record whether both block it. Then run the preflight and verify that a permitted edit generates normal telemetry. If either fails to block, record a separate episode per harness.
