Skip to content

Relocate the untrusted-content fence primitives from engine/agent to engine/governance #380

Closed

Description

@JAORMX

Context

PR #366 (#363) graduated the WebSearch tool body into engine/adapter/search/. The tool body calls agent.FenceUntrusted (the single-source-of-truth LLM01 untrusted-content fence, engine/agent/fence.go), so the graduated package imports engine/agent — making it the first engine/adapter package to import the agent loop, growing that adapter's dependency cone (~5×: agent + governance + prompt + port + team + session + tool + x/sync/errgroup).

This was the pragmatic call (Option B in the PR): the alternative of copying ~560 lines of fence code (Option A) duplicates the most volatile security enumeration in the repo (framingHeaderSurfaces) with real drift risk, against AGENTS.md's "exactly one fence implementation". But the dep-cone cost is real and recorded in the engine-adapter-search depguard rule's NOTE.

Proposal

Relocate the fence primitives — UntrustedFence, WriteUntrustedBlock, FenceUntrusted, NeutraliseFraming and their private helpers — from engine/agent to engine/governance (stdlib-only, session-free, no cycle). This restores engine/adapter/search to a tiny cone ({session, tool, governance}) while keeping a single source of truth.

Blast radius (why it's a follow-up, not bundled into #363)

  • engine/governance is a guarded core package under task api:check / engine/COMPATIBILITY.md — relocating the exported fence API is a public-surface change (likely an api:update + CHANGELOG note + possibly its own ADR).
  • ~6 production files + ~4 test files in engine/agent reference the fence; the re-export shim (alias in engine/agent for back-compat) or a clean break must be decided.
  • Consumers (cmd/mecatequi, mecatui, internal/app/scheduler_*, engine/agent renderers, engine/adapter/search) all import agent.FenceUntrusted today.

Surfaced from the #363 review (the depguard NOTE) — see PR #366 "The one design decision".

Activity

  1. added
    enhancement
    atrium-convergence
    on Aug 4, 2026
  2. removed
    atrium-convergence
    on Aug 27, 2026
  3. self-assigned this
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions