- brain_promote/brain_reject take an optional queue (inbox | needs-review); a name present in both is refused instead of silently acting on the top-level note; brain_pending labels every entry with its queue - parked pdf/txt files are listed (they were invisible); only markdown can be promoted, the others are moved or rejected - promote refuses sources/concepts/entities/wiki as a wing - frontmatterWing reads only a top-level key inside a properly fenced block - docs/raw-inbox.md: the contract, the three env vars, the known limits Each behaviour has a test that fails without it (mutation-checked). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package api
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func writeParked(t *testing.T, brainDir, name, content string) {
|
|
t.Helper()
|
|
dir := filepath.Join(brainDir, "raw", "needs-review")
|
|
require.NoError(t, os.MkdirAll(dir, 0o755))
|
|
require.NoError(t, os.WriteFile(filepath.Join(dir, name), []byte(content), 0o644))
|
|
}
|
|
|
|
func TestListPending_ShowsParkedNotesWithTheirProposal(t *testing.T) {
|
|
dir := t.TempDir()
|
|
writeRaw(t, dir, "fresh.md", "---\ncreated_at: 2026-10-20T08:00:00Z\n---\nA note not yet processed.\n")
|
|
writeParked(t, dir, "unsure.md", "---\nproposed_wing: radar\nproposal_confidence: 0.55\nproposal_reason: \"below threshold\"\ncreated_at: 2026-10-19T08:00:00Z\n---\nBody of the unsure note.\n")
|
|
|
|
got, err := ListPending(dir)
|
|
require.NoError(t, err)
|
|
require.Len(t, got, 2)
|
|
|
|
assert.Equal(t, "unsure.md", got[0].Filename, "oldest first across both queues")
|
|
assert.Equal(t, "needs-review", got[0].Queue)
|
|
assert.Equal(t, "radar", got[0].ProposedWing)
|
|
assert.Equal(t, "below threshold", got[0].ProposalReason)
|
|
assert.InDelta(t, 0.55, got[0].ProposalConfidence, 1e-9)
|
|
assert.Contains(t, got[0].Excerpt, "Body of the unsure note")
|
|
assert.NotContains(t, got[0].Excerpt, "proposed_wing", "excerpt is body, not frontmatter")
|
|
|
|
assert.Equal(t, "fresh.md", got[1].Filename)
|
|
assert.Equal(t, QueueInbox, got[1].Queue)
|
|
assert.Empty(t, got[1].ProposedWing)
|
|
}
|
|
|
|
func TestListPending_ParkedSymlinkIsNotListed(t *testing.T) {
|
|
dir := t.TempDir()
|
|
outside := filepath.Join(t.TempDir(), "secret.md")
|
|
require.NoError(t, os.WriteFile(outside, []byte("outside"), 0o644))
|
|
require.NoError(t, os.MkdirAll(filepath.Join(dir, "raw", "needs-review"), 0o755))
|
|
require.NoError(t, os.Symlink(outside, filepath.Join(dir, "raw", "needs-review", "link.md")))
|
|
|
|
got, err := ListPending(dir)
|
|
require.NoError(t, err)
|
|
assert.Empty(t, got, "same symlink rule as the top level (#153)")
|
|
}
|