- B1: search.extractProvenance locates the frontmatter with
frontmatter.Split (fence at column 0), so an indented "---" inside a
block scalar no longer hides provenance from brain_query.
- B2: brain_edit refuses to edit without a snapshot, and if the stamp
cannot be verified restores the note and reports failure; a failed
restore is reported as exactly that, never as "rolled back".
- B3: internal/provenance gets direct tests for the whole-document
backstop (a stamp that cannot read back is refused), standalone group
decoding, duplicates, lone CR, tab continuations and unclosable
fences. Removing verify or the restore now fails the suite.
- Principals YAML would read as non-strings (true, 123, null, ~) are
quoted instead of refused. An unclosable fence ("---x") is refused
rather than demoted into the body. writeHallNote creates the hall
directory only after the note passes, so a refused write leaves
nothing behind (brain#21).
- MCP brain_ingest (stub LLM) asserted to stamp the caller.
Refs #145 #144
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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)
|
|
}
|