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>
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
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)
|
|
}
|