Correctness Wall extension

July 13, 2026 · View on GitHub

B2C patch safety gate for edit and write tool calls, plus an explicit correctness_wall_evaluate tool. Policy checks come from omk-adaptorch-wpl via a relative import (no workspace package.json dependency).

Usage

From the packages/coding-agent directory (or repo root with a valid path):

omk --extension examples/extensions/correctness-wall/index.ts

Copy into user extensions for auto-discovery:

cp -r examples/extensions/correctness-wall ~/.omk/agent/extensions/correctness-wall/

Claim boundaries

  • In scope: unified-diff preview for pending edit/write, fast policy wall (write scope, flags), optional OA adjudication when correctness_wall_evaluate is called with runIds, previewOnly: false, and either an OA fixture file or an explicitly enabled host-injected MCP transport.
  • Out of scope: Replacing core hooks, modifying packages/adaptorch-wpl from this lane, or adding npm workspace dependencies. The extension only imports evaluateCorrectnessWall and AdaptOrchClient from ../../../../adaptorch-wpl/src/index.ts.

Environment variables

VariableDefaultMeaning
OMK_PATCH_SAFETY_WALL_MODEshadowshadow — log/notify only, never block. soft — block BLOCKED unless override. hard — block BLOCKED and INCONCLUSIVE.
OMK_WALL_SCOPE(empty)Comma-separated glob/path prefixes allowed in the diff. Empty means scope checks do not approve any path (out-of-scope diffs can trigger blocking flags when paths are present).
OMK_WALL_OVERRIDEunsetWhen 1 / true / yes, soft mode does not block BLOCKED verdicts (human override).
OMK_WALL_REPAIR_BUDGET1Capped regenerate budget: max blocked attempts per packet (keyed by packetId or SHA-256 of kind + sorted OMK_WALL_SCOPE) before repair hints are treated as exhausted. Also caps hint string count in UI/JSON. Persisted in .omk/wall-cache/repair-budget.json. Hints only — no auto-regenerate.
OMK_WALL_RUN_IDS(empty)Comma-separated AdaptOrch run ids. On edit/write hooks, non-empty IDs enable OA only with either OMK_WALL_OA_FIXTURE_PATH or explicit OMK_WALL_OA_TRANSPORT=mcp/live plus a bound host callMcpTool; otherwise hooks stay preview-only. An unbound MCP facade falls back to preview-only.
OMK_WALL_OA_FIXTURE_PATHunsetPath to OA adjudication fixture JSON. Used when correctness_wall_evaluate runs with previewOnly: false and non-empty runIds, or as the fixture alternative for edit/write hooks. Overridden per call by adjudicationFixturePath.
OMK_WALL_AUTO_REGENERATEunsetWhen 1 / true / yes, correctness_wall_evaluate JSON may include a regeneratePacket (capped hints only; no automatic patch apply).
OMK_WALL_RECEIPT_SIGNING_SECRETunsetWhen set, verification receipts include signedReceipt (HMAC-SHA256 over digest composite). Never log or commit this value.
OMK_WALL_DEEP_PHASEstubdocker records deep-wall intent; hermetic runner still unavailable (batch-2).
OMK_WALL_OA_TRANSPORTfixturemcp or live uses host-injected MCP callMcpTool via setWallAdaptOrchCallTool (see adjudication-fixture.ts). With non-empty OMK_WALL_RUN_IDS and a bound handler, this explicitly enables fixtureless read-only OA hook adjudication; it calls only adaptorch_get_run, adaptorch_get_artifacts, and adaptorch_get_traces. An unbound facade falls back to preview-only.

OA adjudication fixture format

Fixture file (JSON object). Each run_id must define the three AdaptOrch introspection payloads the in-memory client serves:

{
  "wall_version": "1",
  "dispatchRecordId": "local-dev-dispatch",
  "runsById": {
    "run-oa-1": {
      "run": { "run_id": "run-oa-1", "status": "completed" },
      "artifacts": [{ "path": "out.md", "size_bytes": 42 }],
      "traces": [{ "kind": "write", "level": "info" }]
    }
  }
}
  • wall_version: optional string copied onto the verification receipt returned by correctness_wall_evaluate (defaults to extension version 1).
  • dispatchRecordId: optional; passed to OA adjudication when not set elsewhere.
  • runsById: required map; keys must match runIds in the tool call.

createInMemoryAdaptOrchClient (in adjudication-fixture.ts) wraps these entries with the same transport pattern as packages/adaptorch-wpl/test/b2c-wall-oa.test.ts.

Tools

correctness_wall_evaluate

Parameters:

  • kind (string, required)
  • approvedWriteScope (optional string array)
  • previewOnly (optional boolean, default true)
  • diffPath (optional string) — if omitted, returns an INCONCLUSIVE verdict card JSON
  • runIds (optional string array)
  • packetId (optional string)
  • adjudicationFixturePath (optional string) — OA fixture file; falls back to OMK_WALL_OA_FIXTURE_PATH

Returns JSON text: { verdictCard, receipt }, and repairHints when verdictCard.verdict is BLOCKED.

The receipt includes standard VerificationReceipt fields from adaptorch-wpl plus wall_version (from the fixture or default).

Example receipt fragment:

{
  "schemaVersion": 1,
  "evaluatedAt": "2026-07-08T12:00:00.000Z",
  "kind": "code-edit",
  "runIds": ["run-oa-1"],
  "previewOnly": false,
  "wall_version": "1",
  "adjudicationVerdict": "CONFIRMED",
  "policyFlags": []
}

Edit/write gate

On each edit or write tool_call hook:

  1. Build a unified diff preview from event.input (edits or write content).
  2. Call evaluateCorrectnessWall with scope from OMK_WALL_SCOPE. Default previewOnly: true; with non-empty OMK_WALL_RUN_IDS, hooks use previewOnly: false when either an OA fixture path is set or OMK_WALL_OA_TRANSPORT=mcp/live reaches a bound host-injected MCP transport. An unbound facade falls back to preview-only. The live hook path performs read-only OA introspection only.
  3. Apply OMK_PATCH_SAFETY_WALL_MODE blocking rules; blocked calls return { block: true, reason: "<short user message>" }.
  4. Write a summary snapshot to .omk/wall-cache/latest.json (mode, verdict, wouldBlock, compact card summary, timestamp — no full diff or secrets).
  5. In shadow mode, append one NDJSON line per gated tool call to .omk/wall-cache/shadow-telemetry.ndjson (event, wall_version, mode, verdict, wouldBlock, kind, tool, previewOnly, usedOaFixture, timestamp — no diff or secrets).
  6. On BLOCKED, increment per-packet attempts in .omk/wall-cache/repair-budget.json. In shadow mode, append capped repair hints to the UI notification; when attempts >= OMK_WALL_REPAIR_BUDGET, append a repair-budget-exhausted message.

Limitations

  • Edit preview reads the target file from disk relative to session cwd; if the file is missing or paths are wrong, the hook may return INCONCLUSIVE (and block in hard mode).
  • Hook OA requires non-empty OMK_WALL_RUN_IDS plus either a fixture path or explicit OMK_WALL_OA_TRANSPORT=mcp/live with bound host callMcpTool; otherwise hooks remain preview-only. An unbound facade also falls back to preview-only. Explicit correctness_wall_evaluate can still pass runIds, previewOnly: false, and adjudicationFixturePath per call.
  • Relative imports require loading this extension from the monorepo layout (or an equivalent path to adaptorch-wpl and coding-agent sources).