feat(brain): audit-log every tools/call; server-owned write provenance (#147)
Closes #144 (audit line per tools/call) and #145 (origin/written_by stamped on every model-reachable write, surfaced in brain_query/brain_get). Passed pr-gatekeeper after four rounds of adversarial review, verified by execution: #147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Mathias <mthbqv@gmail.com>
This commit was merged in pull request #147.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Only the leading frontmatter is provenance; a body line that looks like a
|
||||
// key is prose (the doc comment's claim, now observed).
|
||||
func TestExtractProvenanceIgnoresBodyLines(t *testing.T) {
|
||||
o, w := extractProvenance("---\ntitle: t\n---\norigin: static\nwritten_by: local-cli\n")
|
||||
assert.Equal(t, "", o)
|
||||
assert.Equal(t, "", w)
|
||||
o, w = extractProvenance("# no frontmatter\norigin: static\n")
|
||||
assert.Equal(t, "", o)
|
||||
assert.Equal(t, "", w)
|
||||
o, w = extractProvenance("---\norigin: jwt\nwritten_by: attacker\n---\norigin: static\n")
|
||||
assert.Equal(t, "jwt", o)
|
||||
assert.Equal(t, "attacker", w)
|
||||
}
|
||||
|
||||
// Round 3 (B1): an indented "---" inside a block scalar is content, not the
|
||||
// closing fence — the same rule as frontmatter.Split.
|
||||
func TestExtractProvenanceUsesTheSharedFenceRule(t *testing.T) {
|
||||
o, w := extractProvenance("---\nk: |\n ---\norigin: jwt\nwritten_by: attacker\n---\nbody\n")
|
||||
assert.Equal(t, "jwt", o)
|
||||
assert.Equal(t, "attacker", w)
|
||||
}
|
||||
Reference in New Issue
Block a user