Skip to content

refactor(governance): relocate untrusted content fencing - #780

Merged
JAORMX merged 8 commits into
mainfrom
issue-380-governance-fence
Aug 28, 2026
Merged

JAORMX merged 8 commits into
mainfrom
issue-380-governance-fence

Conversation

@JAORMX

@JAORMX JAORMX commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • relocate canonical untrusted-content fencing and framing neutralisation into engine/governance
  • cleanly remove the former engine/agent fence APIs as a documented pre-v1 breaking change
  • remove the engine/adapter/search and engine/adapter/webfetch dependency on the agent loop, with strict depguard and architecture-test coverage
  • restore renderer-derived prompt-forgery regression coverage and document the ownership decision in ADR 0239
  • update API compatibility baselines, changelog, tests, and living documentation

Verification

  • task docs
  • task api:check
  • task lint
  • task test
  • go run ./cmd/mecademo

Closes #380

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — relocate untrusted content fencing

The move is genuinely behaviour-preserving, and I verified that mechanically rather than by reading. Diffing origin/main:engine/agent/fence.go against engine/governance/fence.go yields only: the package line, the neutraliseChildText → NeutraliseDelegationResult rename (7 of 8 hits are comment prose), and StripLoneCodeFence staying behind. The matcher, framingHeaderSurfaces, canonLine, the whole-string fast path, leadingDecoration, both redaction tokens and the %q floor are byte-identical. I also normalised every fence-symbol occurrence per file across the diff and compared counts — no call site silently swapped surfaceResult for surfaceAll or back. StripLoneCodeFence has exactly one definition and four consumers, so the two verdict parsers still share it and no copy crept in. .golangci.yml is a net tightening. task api:check and task test are green locally.

One blocking finding: a prompt-injection regression test was deleted rather than relocated (inline below). Everything else is cheap.

Two things with no line to hang them on

The PR description contradicts the code. It says "retain deprecated engine/agent compatibility forwarders", but commit d90e326 removes them and engine/api/agent.txt drops four symbols. The CHANGELOG gets this right (### Removed, breaking); the description would mislead anyone skimming.

Stale test-name citation. engine/agent/subagent.go:3306 cites TestFramingHeaderCoversTheHarnessNoteFamily, renamed here to TestDelegationResultNeutralisationCoversHarnessNoteFamily. docs/lint's CheckCitations only walks docs/design/*.md, so nothing catches a dead citation in a code comment. (The file isn't in this diff, hence no inline comment.)

Comment thread engine/governance/fence.go Resolved
Comment thread engine/governance/fence.go Resolved
Comment thread .golangci.yml Resolved
Comment thread engine/CHANGELOG.md Resolved
Comment thread AGENTS.md Resolved
Comment thread AGENTS.md Resolved
Comment thread docs/architecture.md Resolved

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked all 9 findings from the previous review after 5167041 — 8 fully addressed (restored prompt-forgery test, trip-wire comment, NeutraliseDelegationResult prohibition, new engine/arch adapter→agent boundary test, ADR 0239, AGENTS.md/architecture.md doc fixes, teamprompt nit).

One residual, low severity: in engine/governance/fence_internal_test.go, TestFramingHeaderIgnoresLeadingDecorationAndSpacing (~line 316) still has the frozen-literal trailer := "agentId: subagent-attacker" with the now-tautological guard if !strings.HasPrefix(trailer, "agentId: ") — only the earlier copy in TestFramingHeaderNormalisesBeforeMatching was cleaned up. Dead code, not a coverage gap (TestDelegationResultMarkersCannotBeForged in engine/agent still covers the live renderer shape). Not blocking — approving.

go test ./agent/... ./governance/... ./arch/... green.

@JAORMX
JAORMX merged commit c29decd into main Aug 28, 2026
21 checks passed
@JAORMX
JAORMX deleted the issue-380-governance-fence branch August 28, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants