Repository navigation
refactor(governance): relocate untrusted content fencing - #780
Conversation
jhrozek
left a comment
There was a problem hiding this comment.
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.)
jhrozek
left a comment
There was a problem hiding this comment.
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.
…fence # Conflicts: # engine/CHANGELOG.md # llms.txt
…fence # Conflicts: # docs/agent-fabric-protocol.md # llms.txt
…fence # Conflicts: # llms.txt
Summary
engine/governanceengine/agentfence APIs as a documented pre-v1 breaking changeengine/adapter/searchandengine/adapter/webfetchdependency on the agent loop, with strict depguard and architecture-test coverageVerification
task docstask api:checktask linttask testgo run ./cmd/mecademoCloses #380