diff --git a/brain/braintest/bench.go b/brain/braintest/bench.go index 7280222..b97a654 100644 --- a/brain/braintest/bench.go +++ b/brain/braintest/bench.go @@ -10,12 +10,14 @@ import ( "testing" "time" - "github.com/google/uuid" - "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/userhash" ) +func randid() string { + return strconv.FormatUint(rand.Uint64(), 16) + "-" + strconv.FormatUint(rand.Uint64(), 16) +} + // BenchLearn runs benchmarks on the brain's speed with recording new tuples. // The learner returned by new must be safe for concurrent use. func BenchLearn(ctx context.Context, b *testing.B, new func(ctx context.Context, b *testing.B) brain.Learner, cleanup func(brain.Learner)) { @@ -40,9 +42,9 @@ func BenchLearn(ctx context.Context, b *testing.B, new func(ctx context.Context, for pb.Next() { t++ toks[len(toks)-1] = strconv.FormatInt(t, 10) - id := uuid.New() + id := randid() u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{})))) - err := brain.Learn(ctx, l, "bocchi", u, id, time.Unix(t, 0), toks) + err := brain.Learn(ctx, l, "bocchi", id, u, time.Unix(t, 0), toks) if err != nil { b.Errorf("error while learning: %v", err) } @@ -78,9 +80,9 @@ func BenchLearn(ctx context.Context, b *testing.B, new func(ctx context.Context, for pb.Next() { t++ rand.Shuffle(len(toks), func(i, j int) { toks[i], toks[j] = toks[j], toks[i] }) - id := uuid.New() + id := randid() u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{})))) - err := brain.Learn(ctx, l, "bocchi", u, id, time.Unix(t, 0), toks[:8]) + err := brain.Learn(ctx, l, "bocchi", id, u, time.Unix(t, 0), toks[:8]) if err != nil { b.Errorf("error while learning: %v", err) } @@ -112,9 +114,9 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context, } for t := range size { toks[len(toks)-1] = strconv.FormatInt(t, 10) - id := uuid.New() + id := randid() u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{})))) - err := brain.Learn(ctx, br, "bocchi", u, id, time.Unix(t, 0), toks) + err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(t, 0), toks) if err != nil { b.Errorf("error while learning: %v", err) } @@ -157,9 +159,9 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context, } for t := range size { rand.Shuffle(len(toks), func(i, j int) { toks[i], toks[j] = toks[j], toks[i] }) - id := uuid.New() + id := randid() u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{})))) - err := brain.Learn(ctx, br, "bocchi", u, id, time.Unix(t, 0), toks) + err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(t, 0), toks) if err != nil { b.Errorf("error while learning: %v", err) } @@ -202,9 +204,9 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context, } for t := range size { rand.Shuffle(len(toks), func(i, j int) { toks[i], toks[j] = toks[j], toks[i] }) - id := uuid.New() + id := randid() u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{})))) - err := brain.Learn(ctx, br, "bocchi", u, id, time.Unix(t, 0), toks) + err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(t, 0), toks) if err != nil { b.Errorf("error while learning: %v", err) } diff --git a/brain/braintest/braintest.go b/brain/braintest/braintest.go index bff542a..a6d80ac 100644 --- a/brain/braintest/braintest.go +++ b/brain/braintest/braintest.go @@ -9,8 +9,6 @@ import ( "testing" "time" - "github.com/google/uuid" - "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/userhash" ) @@ -33,70 +31,70 @@ func these(s ...string) func() []string { } var messages = [...]struct { - ID uuid.UUID + ID string User userhash.Hash Tag string Time time.Time Tokens func() []string }{ { - ID: uuid.UUID{1}, + ID: "1", User: userhash.Hash{2}, Tag: "kessoku", Time: time.Unix(0, 0), Tokens: these("member ", "bocchi "), }, { - ID: uuid.UUID{2}, + ID: "2", User: userhash.Hash{2}, Tag: "kessoku", Time: time.Unix(1, 0), Tokens: these("member ", "ryou "), }, { - ID: uuid.UUID{3}, + ID: "3", User: userhash.Hash{3}, Tag: "kessoku", Time: time.Unix(2, 0), Tokens: these("member ", "nijika "), }, { - ID: uuid.UUID{4}, + ID: "4", User: userhash.Hash{3}, Tag: "kessoku", Time: time.Unix(3, 0), Tokens: these("member ", "kita "), }, { - ID: uuid.UUID{5}, + ID: "5", User: userhash.Hash{2}, Tag: "sickhack", Time: time.Unix(0, 0), Tokens: these("member ", "bocchi "), }, { - ID: uuid.UUID{6}, + ID: "6", User: userhash.Hash{2}, Tag: "sickhack", Time: time.Unix(1, 0), Tokens: these("member ", "ryou "), }, { - ID: uuid.UUID{7}, + ID: "7", User: userhash.Hash{3}, Tag: "sickhack", Time: time.Unix(2, 0), Tokens: these("member ", "nijika "), }, { - ID: uuid.UUID{8}, + ID: "8", User: userhash.Hash{3}, Tag: "sickhack", Time: time.Unix(3, 0), Tokens: these("member ", "kita "), }, { - ID: uuid.UUID{9}, + ID: "9", User: userhash.Hash{4}, Tag: "sickhack", Time: time.Unix(43, 0), @@ -107,7 +105,7 @@ var messages = [...]struct { func learn(ctx context.Context, t *testing.T, br brain.Learner) { t.Helper() for _, m := range messages { - if err := brain.Learn(ctx, br, m.Tag, m.User, m.ID, m.Time, m.Tokens()); err != nil { + if err := brain.Learn(ctx, br, m.Tag, m.ID, m.User, m.Time, m.Tokens()); err != nil { t.Fatalf("couldn't learn message %v: %v", m.ID, err) } } @@ -266,8 +264,8 @@ func testCombinatoric(ctx context.Context, br brain.Brain) func(t *testing.T) { for _, toks[5] = range band { toks := toks for len(toks) > 1 { - id := uuid.New() - err := brain.Learn(ctx, br, "bocchi", u, id, time.Unix(0, 0), toks) + id := randid() + err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(0, 0), toks) if err != nil { t.Fatalf("couldn't learn init: %v", err) } diff --git a/brain/braintest/braintest_test.go b/brain/braintest/braintest_test.go index 764c031..803c032 100644 --- a/brain/braintest/braintest_test.go +++ b/brain/braintest/braintest_test.go @@ -9,8 +9,6 @@ import ( "testing" "time" - "github.com/google/uuid" - "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/brain/braintest" "github.com/zephyrtronium/robot/userhash" @@ -20,21 +18,21 @@ import ( // to verify that the integration tests test the correct things. type membrain struct { mu sync.Mutex - tups map[string]map[string][]string // map of tags to map of prefixes to suffixes - users map[userhash.Hash][][3]string // map of hashes to tag and prefix+suffix - ids map[string]map[uuid.UUID][][2]string // map of tags to map of ids to prefix+suffix - tms map[string]map[int64][][2]string // map of tags to map of timestamps to prefix+suffix + tups map[string]map[string][]string // map of tags to map of prefixes to suffixes + users map[userhash.Hash][][3]string // map of hashes to tag and prefix+suffix + ids map[string]map[string][][2]string // map of tags to map of ids to prefix+suffix + tms map[string]map[int64][][2]string // map of tags to map of timestamps to prefix+suffix } var _ brain.Brain = (*membrain)(nil) -func (m *membrain) Learn(ctx context.Context, tag string, user userhash.Hash, id uuid.UUID, t time.Time, tuples []brain.Tuple) error { +func (m *membrain) Learn(ctx context.Context, tag, id string, user userhash.Hash, t time.Time, tuples []brain.Tuple) error { m.mu.Lock() defer m.mu.Unlock() if m.tups == nil { m.tups = make(map[string]map[string][]string) m.users = make(map[userhash.Hash][][3]string) - m.ids = make(map[string]map[uuid.UUID][][2]string) + m.ids = make(map[string]map[string][][2]string) m.tms = make(map[string]map[int64][][2]string) } if m.tups[tag] == nil { @@ -42,7 +40,7 @@ func (m *membrain) Learn(ctx context.Context, tag string, user userhash.Hash, id } r := m.tups[tag] if m.ids[tag] == nil { - m.ids[tag] = make(map[uuid.UUID][][2]string) + m.ids[tag] = make(map[string][][2]string) } ids := m.ids[tag] if m.tms[tag] == nil { @@ -79,14 +77,14 @@ func (m *membrain) Forget(ctx context.Context, tag string, tuples []brain.Tuple) return nil } -func (m *membrain) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) error { +func (m *membrain) ForgetMessage(ctx context.Context, tag, id string) error { m.mu.Lock() defer m.mu.Unlock() - u := m.ids[tag][msg] + u := m.ids[tag][id] for _, v := range u { m.forgetLocked(tag, v[0], v[1]) } - delete(m.ids[tag], msg) + delete(m.ids[tag], id) return nil } diff --git a/brain/kvbrain/forget.go b/brain/kvbrain/forget.go index 58cc587..2226416 100644 --- a/brain/kvbrain/forget.go +++ b/brain/kvbrain/forget.go @@ -11,7 +11,6 @@ import ( "time" "github.com/dgraph-io/badger/v4" - "github.com/google/uuid" "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/userhash" @@ -22,13 +21,13 @@ type past struct { k uint8 key [256][][]byte - id [256]uuid.UUID + id [256]string user [256]userhash.Hash time [256]int64 // unix nano } // record associates a message with a knowledge key. -func (p *past) record(id uuid.UUID, user userhash.Hash, nanotime int64, keys [][]byte) { +func (p *past) record(id string, user userhash.Hash, nanotime int64, keys [][]byte) { p.mu.Lock() p.key[p.k] = slices.Grow(p.key[p.k][:0], len(keys))[:len(keys)] for i, key := range keys { @@ -42,12 +41,12 @@ func (p *past) record(id uuid.UUID, user userhash.Hash, nanotime int64, keys [][ } // findID finds all keys corresponding to the given UUID. -func (p *past) findID(msg uuid.UUID) [][]byte { +func (p *past) findID(id string) [][]byte { r := make([][]byte, 0, 64) p.mu.Lock() defer p.mu.Unlock() for k, v := range p.id { - if v == msg { + if v == id { keys := p.key[k] r = slices.Grow(r, len(keys)) for _, v := range keys { @@ -149,12 +148,12 @@ func (br *Brain) Forget(ctx context.Context, tag string, tuples []brain.Tuple) e // ForgetMessage forgets everything learned from a single given message. // If nothing has been learned from the message, it should be ignored. -func (br *Brain) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) error { +func (br *Brain) ForgetMessage(ctx context.Context, tag, id string) error { past, _ := br.past.Load(tag) if past == nil { return nil } - keys := past.findID(msg) + keys := past.findID(id) batch := br.knowledge.NewWriteBatch() defer batch.Cancel() for _, key := range keys { @@ -165,7 +164,7 @@ func (br *Brain) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) e } err := batch.Flush() if err != nil { - return fmt.Errorf("couldn't commit deleting message %v: %w", msg, err) + return fmt.Errorf("couldn't commit deleting message %v: %w", id, err) } return nil } diff --git a/brain/kvbrain/forget_test.go b/brain/kvbrain/forget_test.go index 74bcfbe..4c7acd5 100644 --- a/brain/kvbrain/forget_test.go +++ b/brain/kvbrain/forget_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/dgraph-io/badger/v4" - "github.com/google/uuid" "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/userhash" @@ -19,7 +18,7 @@ func TestPastRecord(t *testing.T) { ch := make(chan struct{}) for i := range len(p.id) { go func() { - p.record(uuid.UUID{1, byte(i)}, userhash.Hash{2, byte(i)}, int64(i), [][]byte{{4, byte(i)}, {5}}) + p.record("1"+string(byte(i)), userhash.Hash{2, byte(i)}, int64(i), [][]byte{{4, byte(i)}, {5}}) ch <- struct{}{} }() } @@ -34,7 +33,7 @@ func TestPastRecord(t *testing.T) { if want := [][]byte{{4, byte(time)}, {5}}; !slices.EqualFunc(key, want, bytes.Equal) { t.Errorf("wrong association between key and time: want %v, got %v", want, key) } - if want := (uuid.UUID{1, byte(time)}); id != want { + if want := ("1" + string(byte(time))); id != want { t.Errorf("wrong association between id and time: want %v, got %v", want, id) } if want := (userhash.Hash{2, byte(time)}); user != want { @@ -44,7 +43,7 @@ func TestPastRecord(t *testing.T) { // Do it again to verify we overwrite. for i := range len(p.id) { go func() { - p.record(uuid.UUID{5, byte(i)}, userhash.Hash{6, byte(i)}, int64(i), [][]byte{{8, byte(i)}, {9}}) + p.record("5"+string(byte(i)), userhash.Hash{6, byte(i)}, int64(i), [][]byte{{8, byte(i)}, {9}}) ch <- struct{}{} }() } @@ -59,7 +58,7 @@ func TestPastRecord(t *testing.T) { if want := [][]byte{{8, byte(time)}, {9}}; !slices.EqualFunc(key, want, bytes.Equal) { t.Errorf("wrong association between key and time: want %v, got %v", want, key) } - if want := (uuid.UUID{5, byte(time)}); id != want { + if want := ("5" + string(byte(time))); id != want { t.Errorf("wrong association between id and time: want %v, got %v", want, id) } if want := (userhash.Hash{6, byte(time)}); user != want { @@ -69,18 +68,18 @@ func TestPastRecord(t *testing.T) { } func TestPastFindID(t *testing.T) { - uu := uuid.UUID{1} + uu := "1" p := past{ k: 127, key: [256][][]byte{255: {[]byte("bocchi")}}, - id: [256]uuid.UUID{255: uu}, + id: [256]string{255: uu}, user: [256]userhash.Hash{255: {2}}, time: [256]int64{255: 3}, } if got, want := p.findID(uu), [][]byte{[]byte("bocchi")}; !slices.EqualFunc(got, want, bytes.Equal) { t.Errorf("wrong key: want %q, got %q", want, got) } - if got := p.findID(uuid.Max); got != nil { + if got := p.findID("fake"); got != nil { t.Errorf("non-nil key %q finding fake uuid", got) } } @@ -94,11 +93,11 @@ func TestPastFindDuring(t *testing.T) { 2: {[]byte("nijika")}, 3: {[]byte("kita")}, }, - id: [256]uuid.UUID{ - 0: {2}, - 1: {3}, - 2: {4}, - 3: {1}, + id: [256]string{ + 0: "2", + 1: "3", + 2: "4", + 3: "1", }, user: [256]userhash.Hash{ 0: {3}, @@ -132,11 +131,11 @@ func TestPastFindUser(t *testing.T) { 200: {[]byte("nijika")}, 255: {[]byte("kita")}, }, - id: [256]uuid.UUID{ - 127: {2}, - 192: {3}, - 200: {4}, - 255: {1}, + id: [256]string{ + 127: "2", + 192: "3", + 200: "4", + 255: "1", }, user: [256]userhash.Hash{ 127: {8}, @@ -163,7 +162,7 @@ func TestPastFindUser(t *testing.T) { func BenchmarkPastRecord(b *testing.B) { var p past - uu := uuid.UUID{1} + uu := "1" user := userhash.Hash{2} b.ReportAllocs() for i := range b.N { @@ -174,19 +173,19 @@ func BenchmarkPastRecord(b *testing.B) { func BenchmarkPastFindID(b *testing.B) { var p past for i := range len(p.id) { - p.record(uuid.UUID{byte(i)}, userhash.Hash{byte(i)}, int64(i), [][]byte{{byte(i)}}) + p.record(string(byte(i)), userhash.Hash{byte(i)}, int64(i), [][]byte{{byte(i)}}) } b.ReportAllocs() b.ResetTimer() for i := range b.N { - use(p.findID(uuid.UUID{byte(i)})) + use(p.findID(string(byte(i)))) } } func BenchmarkPastFindDuring(b *testing.B) { var p past for i := range len(p.id) { - p.record(uuid.UUID{byte(i)}, userhash.Hash{byte(i)}, int64(i), [][]byte{{byte(i)}}) + p.record(string(byte(i)), userhash.Hash{byte(i)}, int64(i), [][]byte{{byte(i)}}) } b.ReportAllocs() b.ResetTimer() @@ -198,7 +197,7 @@ func BenchmarkPastFindDuring(b *testing.B) { func BenchmarkPastFindUser(b *testing.B) { var p past for i := range len(p.id) { - p.record(uuid.UUID{byte(i)}, userhash.Hash{byte(i)}, int64(i), [][]byte{{byte(i)}}) + p.record(string(byte(i)), userhash.Hash{byte(i)}, int64(i), [][]byte{{byte(i)}}) } b.ReportAllocs() b.ResetTimer() @@ -212,7 +211,7 @@ func use(x [][]byte) {} func TestForget(t *testing.T) { type message struct { - id uuid.UUID + id string user userhash.Hash tag string time time.Time @@ -228,7 +227,7 @@ func TestForget(t *testing.T) { name: "none", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -247,14 +246,14 @@ func TestForget(t *testing.T) { }, }, want: map[string]string{ - mkey("kessoku", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("kessoku", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, { name: "suffix", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -273,14 +272,14 @@ func TestForget(t *testing.T) { }, }, want: map[string]string{ - mkey("kessoku", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("kessoku", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, { name: "prefix", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -299,14 +298,14 @@ func TestForget(t *testing.T) { }, }, want: map[string]string{ - mkey("kessoku", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("kessoku", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, { name: "tag", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "sickhack", time: time.Unix(0, 0), @@ -325,14 +324,14 @@ func TestForget(t *testing.T) { }, }, want: map[string]string{ - mkey("sickhack", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("sickhack", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, { name: "match", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -356,7 +355,7 @@ func TestForget(t *testing.T) { name: "single", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -368,7 +367,7 @@ func TestForget(t *testing.T) { }, }, { - id: uuid.UUID{2}, + id: "2", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -387,7 +386,7 @@ func TestForget(t *testing.T) { }, }, want: map[string]string{ - mkey("kessoku", "ryou\xffbocchi\xff\xff", uuid.UUID{2}): "kita", + mkey("kessoku", "ryou\xffbocchi\xff\xff", "2"): "kita", }, }, } @@ -401,7 +400,7 @@ func TestForget(t *testing.T) { } br := New(db) for _, msg := range c.msgs { - err := br.Learn(ctx, msg.tag, msg.user, msg.id, msg.time, msg.tups) + err := br.Learn(ctx, msg.tag, msg.id, msg.user, msg.time, msg.tups) if err != nil { t.Errorf("failed to learn: %v", err) } @@ -416,7 +415,7 @@ func TestForget(t *testing.T) { func TestForgetMessage(t *testing.T) { type message struct { - id uuid.UUID + id string user userhash.Hash tag string time time.Time @@ -425,14 +424,14 @@ func TestForgetMessage(t *testing.T) { cases := []struct { name string msgs []message - uu uuid.UUID + uu string want map[string]string }{ { name: "single", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -441,14 +440,14 @@ func TestForgetMessage(t *testing.T) { }, }, }, - uu: uuid.UUID{1}, + uu: "1", want: map[string]string{}, }, { name: "several", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -458,14 +457,14 @@ func TestForgetMessage(t *testing.T) { }, }, }, - uu: uuid.UUID{1}, + uu: "1", want: map[string]string{}, }, { name: "tagged", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "sickhack", time: time.Unix(0, 0), @@ -474,16 +473,16 @@ func TestForgetMessage(t *testing.T) { }, }, }, - uu: uuid.UUID{1}, + uu: "1", want: map[string]string{ - mkey("sickhack", "bocchi\xff\xff", uuid.UUID{1}): "ryou", + mkey("sickhack", "bocchi\xff\xff", "1"): "ryou", }, }, { name: "unseen", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(0, 0), @@ -492,9 +491,9 @@ func TestForgetMessage(t *testing.T) { }, }, }, - uu: uuid.UUID{2}, + uu: "2", want: map[string]string{ - mkey("kessoku", "bocchi\xff\xff", uuid.UUID{1}): "ryou", + mkey("kessoku", "bocchi\xff\xff", "1"): "ryou", }, }, } @@ -508,7 +507,7 @@ func TestForgetMessage(t *testing.T) { } br := New(db) for _, msg := range c.msgs { - err := br.Learn(ctx, msg.tag, msg.user, msg.id, msg.time, msg.tups) + err := br.Learn(ctx, msg.tag, msg.id, msg.user, msg.time, msg.tups) if err != nil { t.Errorf("failed to learn: %v", err) } @@ -523,7 +522,7 @@ func TestForgetMessage(t *testing.T) { func TestForgetDuring(t *testing.T) { type message struct { - id uuid.UUID + id string user userhash.Hash tag string time time.Time @@ -539,7 +538,7 @@ func TestForgetDuring(t *testing.T) { name: "single", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(1, 0), @@ -559,7 +558,7 @@ func TestForgetDuring(t *testing.T) { name: "several", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(1, 0), @@ -571,7 +570,7 @@ func TestForgetDuring(t *testing.T) { }, }, { - id: uuid.UUID{2}, + id: "2", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(1, 0), @@ -591,7 +590,7 @@ func TestForgetDuring(t *testing.T) { name: "none", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(5, 0), @@ -606,14 +605,14 @@ func TestForgetDuring(t *testing.T) { a: 0, b: 2, want: map[string]string{ - mkey("kessoku", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("kessoku", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, { name: "tagged", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "sickhack", time: time.Unix(1, 0), @@ -628,7 +627,7 @@ func TestForgetDuring(t *testing.T) { a: 0, b: 2, want: map[string]string{ - mkey("sickhack", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("sickhack", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, } @@ -642,7 +641,7 @@ func TestForgetDuring(t *testing.T) { } br := New(db) for _, msg := range c.msgs { - err := br.Learn(ctx, msg.tag, msg.user, msg.id, msg.time, msg.tups) + err := br.Learn(ctx, msg.tag, msg.id, msg.user, msg.time, msg.tups) if err != nil { t.Errorf("failed to learn: %v", err) } @@ -659,7 +658,7 @@ func TestForgetDuring(t *testing.T) { func TestForgetUserSince(t *testing.T) { type message struct { - id uuid.UUID + id string user userhash.Hash tag string time time.Time @@ -675,7 +674,7 @@ func TestForgetUserSince(t *testing.T) { name: "match", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(1, 0), @@ -694,7 +693,7 @@ func TestForgetUserSince(t *testing.T) { name: "different", msgs: []message{ { - id: uuid.UUID{1}, + id: "1", user: userhash.Hash{2}, tag: "kessoku", time: time.Unix(1, 0), @@ -708,7 +707,7 @@ func TestForgetUserSince(t *testing.T) { }, user: userhash.Hash{1}, want: map[string]string{ - mkey("kessoku", "ryou\xffbocchi\xff\xff", uuid.UUID{1}): "kita", + mkey("kessoku", "ryou\xffbocchi\xff\xff", "1"): "kita", }, }, } @@ -722,7 +721,7 @@ func TestForgetUserSince(t *testing.T) { } br := New(db) for _, msg := range c.msgs { - err := br.Learn(ctx, msg.tag, msg.user, msg.id, msg.time, msg.tups) + err := br.Learn(ctx, msg.tag, msg.id, msg.user, msg.time, msg.tups) if err != nil { t.Errorf("failed to learn: %v", err) } diff --git a/brain/kvbrain/learn.go b/brain/kvbrain/learn.go index bc0addf..cd41467 100644 --- a/brain/kvbrain/learn.go +++ b/brain/kvbrain/learn.go @@ -7,8 +7,6 @@ import ( "fmt" "time" - "github.com/google/uuid" - "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/userhash" ) @@ -18,7 +16,7 @@ import ( // denote the start of the message and end with one empty suffix to denote // the end; all other tokens are non-empty. Each tuple's prefix has entropy // reduction transformations applied. -func (br *Brain) Learn(ctx context.Context, tag string, user userhash.Hash, id uuid.UUID, t time.Time, tuples []brain.Tuple) error { +func (br *Brain) Learn(ctx context.Context, tag, id string, user userhash.Hash, t time.Time, tuples []brain.Tuple) error { if len(tuples) == 0 { return errors.New("no tuples to learn") } diff --git a/brain/kvbrain/learn_test.go b/brain/kvbrain/learn_test.go index 284c78d..9f1bd33 100644 --- a/brain/kvbrain/learn_test.go +++ b/brain/kvbrain/learn_test.go @@ -6,18 +6,17 @@ import ( "time" "github.com/dgraph-io/badger/v4" - "github.com/google/uuid" "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/brain/braintest" "github.com/zephyrtronium/robot/userhash" ) -func mkey(tag, toks string, id uuid.UUID) string { +func mkey(tag, toks, id string) string { b := make([]byte, 0, 8+len(toks)+len(id)) b = hashTag(b, tag) b = append(b, toks...) - b = append(b, id[:]...) + b = append(b, id...) return string(b) } @@ -51,11 +50,11 @@ func dbcheck(t *testing.T, db *badger.DB, want map[string]string) { } func TestLearn(t *testing.T) { - uu := uuid.UUID{':', ')', ':', ')', ':', ')', ':', ')', ':', ')', ':', ')', ':', ')', ':', ')'} + uu := ":)" h := userhash.Hash{2} cases := []struct { name string - id uuid.UUID + id string user userhash.Hash tag string time time.Time @@ -129,7 +128,7 @@ func TestLearn(t *testing.T) { t.Fatal(err) } br := New(db) - if err := br.Learn(ctx, c.tag, c.user, c.id, c.time, c.tups); err != nil { + if err := br.Learn(ctx, c.tag, c.id, c.user, c.time, c.tups); err != nil { t.Errorf("failed to learn: %v", err) } dbcheck(t, db, c.want) diff --git a/brain/kvbrain/speak_test.go b/brain/kvbrain/speak_test.go index aec6921..52b2d79 100644 --- a/brain/kvbrain/speak_test.go +++ b/brain/kvbrain/speak_test.go @@ -9,14 +9,13 @@ import ( "github.com/dgraph-io/badger/v4" "github.com/dgraph-io/badger/v4/options" - "github.com/google/uuid" "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/brain/braintest" ) func TestSpeak(t *testing.T) { - uu := uuid.UUID{':', ')', ':', ')', ':', ')', ':', ')', ':', ')', ':', ')', ':', ')', ':', ')'} + uu := ":)" cases := []struct { name string kvs [][2]string @@ -102,15 +101,15 @@ func TestSpeak(t *testing.T) { { name: "uniform", kvs: [][2]string{ - {mkey("kessoku", "\xff", uuid.UUID{1}), "bocchi "}, - {mkey("kessoku", "bocchi \xff\xff", uuid.UUID{1}), "ryou "}, - {mkey("kessoku", "ryou \xffbocchi \xff\xff", uuid.UUID{1}), ""}, - {mkey("kessoku", "\xff", uuid.UUID{2}), "bocchi "}, - {mkey("kessoku", "bocchi \xff\xff", uuid.UUID{2}), "nijika "}, - {mkey("kessoku", "nijika \xffbocchi \xff\xff", uuid.UUID{2}), ""}, - {mkey("kessoku", "\xff", uuid.UUID{3}), "bocchi "}, - {mkey("kessoku", "bocchi \xff\xff", uuid.UUID{3}), "kita "}, - {mkey("kessoku", "kita \xffbocchi \xff\xff", uuid.UUID{3}), ""}, + {mkey("kessoku", "\xff", "1"), "bocchi "}, + {mkey("kessoku", "bocchi \xff\xff", "1"), "ryou "}, + {mkey("kessoku", "ryou \xffbocchi \xff\xff", "1"), ""}, + {mkey("kessoku", "\xff", "2"), "bocchi "}, + {mkey("kessoku", "bocchi \xff\xff", "2"), "nijika "}, + {mkey("kessoku", "nijika \xffbocchi \xff\xff", "2"), ""}, + {mkey("kessoku", "\xff", "3"), "bocchi "}, + {mkey("kessoku", "bocchi \xff\xff", "3"), "kita "}, + {mkey("kessoku", "kita \xffbocchi \xff\xff", "3"), ""}, }, want: []string{ "bocchi ryou ", diff --git a/brain/learn.go b/brain/learn.go index eba8ff1..2d98f6a 100644 --- a/brain/learn.go +++ b/brain/learn.go @@ -5,8 +5,6 @@ import ( "slices" "time" - "github.com/google/uuid" - "github.com/zephyrtronium/robot/tpool" "github.com/zephyrtronium/robot/userhash" ) @@ -28,7 +26,7 @@ type Learner interface { // of the message. The positions of each in the argument are not guaranteed. // Each tuple's prefix has entropy reduction transformations applied. // Tuples in the argument may share storage for prefixes. - Learn(ctx context.Context, tag string, user userhash.Hash, id uuid.UUID, t time.Time, tuples []Tuple) error + Learn(ctx context.Context, tag, id string, user userhash.Hash, t time.Time, tuples []Tuple) error // Forget removes a set of recorded tuples. // The tuples provided are as for Learn. // If a tuple has been recorded multiple times, only the first @@ -37,7 +35,7 @@ type Learner interface { Forget(ctx context.Context, tag string, tuples []Tuple) error // ForgetMessage forgets everything learned from a single given message. // If nothing has been learned from the message, it should be ignored. - ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) error + ForgetMessage(ctx context.Context, tag, id string) error // ForgetDuring forgets all messages learned in the given time span. ForgetDuring(ctx context.Context, tag string, since, before time.Time) error // ForgetUser forgets all messages associated with a userhash. @@ -47,7 +45,7 @@ type Learner interface { var tuplesPool tpool.Pool[[]Tuple] // Learn records tokens into a Learner. -func Learn(ctx context.Context, l Learner, tag string, user userhash.Hash, id uuid.UUID, t time.Time, toks []string) error { +func Learn(ctx context.Context, l Learner, tag, id string, user userhash.Hash, t time.Time, toks []string) error { if len(toks) == 0 { return nil } @@ -55,7 +53,7 @@ func Learn(ctx context.Context, l Learner, tag string, user userhash.Hash, id uu defer func() { tuplesPool.Put(tt[:0]) }() tt = slices.Grow(tt, len(toks)+1) tt = tupleToks(tt, toks) - return l.Learn(ctx, tag, user, id, t, tt) + return l.Learn(ctx, tag, id, user, t, tt) } // Forget removes tokens from a Learner. diff --git a/brain/learn_test.go b/brain/learn_test.go index e88db4f..46b00fd 100644 --- a/brain/learn_test.go +++ b/brain/learn_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/google/go-cmp/cmp" - "github.com/google/uuid" "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/userhash" @@ -18,7 +17,7 @@ type testLearner struct { err error } -func (t *testLearner) Learn(ctx context.Context, tag string, user userhash.Hash, id uuid.UUID, tm time.Time, tuples []brain.Tuple) error { +func (t *testLearner) Learn(ctx context.Context, tag, id string, user userhash.Hash, tm time.Time, tuples []brain.Tuple) error { t.learned = append(t.learned, tuples...) return t.err } @@ -28,7 +27,7 @@ func (t *testLearner) Forget(ctx context.Context, tag string, tuples []brain.Tup return nil } -func (t *testLearner) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) error { +func (t *testLearner) ForgetMessage(ctx context.Context, tag, id string) error { return nil } @@ -79,7 +78,7 @@ func TestLearn(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { var l testLearner - err := brain.Learn(context.Background(), &l, "", userhash.Hash{}, uuid.UUID{}, time.Unix(0, 0), c.msg) + err := brain.Learn(context.Background(), &l, "", "", userhash.Hash{}, time.Unix(0, 0), c.msg) if err != nil { t.Error(err) } diff --git a/brain/sqlbrain/forget.go b/brain/sqlbrain/forget.go index a9197e3..353e922 100644 --- a/brain/sqlbrain/forget.go +++ b/brain/sqlbrain/forget.go @@ -4,10 +4,8 @@ import ( "context" _ "embed" "fmt" - "slices" "time" - "github.com/google/uuid" "zombiezen.com/go/sqlite" "zombiezen.com/go/sqlite/sqlitex" @@ -49,11 +47,11 @@ func (br *Brain) Forget(ctx context.Context, tag string, tuples []brain.Tuple) ( // ForgetMessage forgets everything learned from a single given message. // If nothing has been learned from the message, nothing happens. -func (br *Brain) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) (err error) { +func (br *Brain) ForgetMessage(ctx context.Context, tag, id string) (err error) { conn, err := br.db.Take(ctx) defer br.db.Put(conn) if err != nil { - return fmt.Errorf("couldn't get connection to forget message %v: %w", msg, err) + return fmt.Errorf("couldn't get connection to forget message %v: %w", id, err) } defer sqlitex.Transaction(conn)(&err) { @@ -64,12 +62,12 @@ func (br *Brain) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) ( ` st, err := conn.Prepare(forget) if err != nil { - return fmt.Errorf("couldn't prepare delete for message %v: %w", msg, err) + return fmt.Errorf("couldn't prepare delete for message %v: %w", id, err) } st.SetText(":tag", tag) - st.SetBytes(":id", msg[:]) + st.SetText(":id", id) if err := allsteps(st); err != nil { - return fmt.Errorf("couldn't delete message %v: %w", msg, err) + return fmt.Errorf("couldn't delete message %v: %w", id, err) } } { @@ -77,12 +75,12 @@ func (br *Brain) ForgetMessage(ctx context.Context, tag string, msg uuid.UUID) ( const forget = `UPDATE knowledge SET deleted = 'CLEARMSG' WHERE tag=:tag AND id=:id` st, err := conn.Prepare(forget) if err != nil { - return fmt.Errorf("couldn't prepare delete for tuples of message %v: %w", msg, err) + return fmt.Errorf("couldn't prepare delete for tuples of message %v: %w", id, err) } st.SetText(":tag", tag) - st.SetBytes(":id", msg[:]) + st.SetText(":id", id) if err := allsteps(st); err != nil { - return fmt.Errorf("couldn't delete tuples of message %v: %w", msg, err) + return fmt.Errorf("couldn't delete tuples of message %v: %w", id, err) } } return nil @@ -112,7 +110,6 @@ func (br *Brain) ForgetDuring(ctx context.Context, tag string, since time.Time, } st.SetText(":tag", tag) // Now forget tuples by the IDs. - id := make([]byte, 0, 16) for { ok, err := sm.Step() if err != nil { @@ -121,14 +118,8 @@ func (br *Brain) ForgetDuring(ctx context.Context, tag string, since time.Time, if !ok { break } - idk := sm.ColumnIndex("id") - if idk < 0 { - panic("sqlbrain: no index for id column") - } - l := sm.ColumnLen(idk) - id = slices.Grow(id[:0], l)[:l] - sm.ColumnBytes(idk, id) - st.SetBytes(":id", id) + id := sm.GetText("id") + st.SetText(":id", id) if err := allsteps(st); err != nil { return fmt.Errorf("couldn't step delete for tuples in time span: %w", err) } @@ -160,7 +151,6 @@ func (br *Brain) ForgetUser(ctx context.Context, user *userhash.Hash) error { return fmt.Errorf("couldn't prepare delete for tuples from user: %w", err) } // Now forget by the IDs. - id := make([]byte, 0, 16) for { ok, err := sm.Step() if err != nil { @@ -170,15 +160,9 @@ func (br *Brain) ForgetUser(ctx context.Context, user *userhash.Hash) error { break } tag := sm.GetText("tag") - idk := sm.ColumnIndex("id") - if idk < 0 { - panic("sqlbrain: no index for id column") - } - l := sm.ColumnLen(idk) - id = slices.Grow(id[:0], l)[:l] - sm.ColumnBytes(idk, id) + id := sm.GetText("id") st.SetText(":tag", tag) - st.SetBytes(":id", id) + st.SetText(":id", id) if err := allsteps(st); err != nil { return fmt.Errorf("couldn't step delete for tuples from user: %w", err) } diff --git a/brain/sqlbrain/forget_test.go b/brain/sqlbrain/forget_test.go index 3d63f51..1f33a1e 100644 --- a/brain/sqlbrain/forget_test.go +++ b/brain/sqlbrain/forget_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/google/uuid" - "github.com/zephyrtronium/robot/brain" "github.com/zephyrtronium/robot/brain/sqlbrain" "github.com/zephyrtronium/robot/userhash" @@ -18,7 +16,7 @@ func TestForget(t *testing.T) { { tag: "結束", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: strings.Fields("喜多 虹夏 リョウ ぼっち"), Suffix: ""}, @@ -31,7 +29,7 @@ func TestForget(t *testing.T) { { tag: "結束", user: userhash.Hash{4}, - id: uuid.UUID{5}, + id: "5", t: 6, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -41,7 +39,7 @@ func TestForget(t *testing.T) { { tag: "結束", user: userhash.Hash{7}, - id: uuid.UUID{8}, + id: "8", t: 9, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -51,7 +49,7 @@ func TestForget(t *testing.T) { { tag: "sickhack", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -62,67 +60,67 @@ func TestForget(t *testing.T) { initKnow := []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, @@ -130,25 +128,25 @@ func TestForget(t *testing.T) { initMsgs := []msg{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", time: 9, user: userhash.Hash{7}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -198,68 +196,68 @@ func TestForget(t *testing.T) { know: []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, @@ -283,72 +281,72 @@ func TestForget(t *testing.T) { know: []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, @@ -368,68 +366,68 @@ func TestForget(t *testing.T) { know: []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, @@ -455,69 +453,69 @@ func TestForget(t *testing.T) { know: []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", deleted: ref("FORGET"), }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "", suffix: "bocchi", deleted: ref("FORGET"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, @@ -537,67 +535,67 @@ func TestForget(t *testing.T) { know: []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "bocchi\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{8}, + id: "8", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", deleted: ref("FORGET"), @@ -616,7 +614,7 @@ func TestForget(t *testing.T) { t.Fatalf("couldn't open brain: %v", err) } for _, m := range learn { - err := br.Learn(ctx, m.tag, m.user, m.id, time.Unix(0, m.t), m.tups) + err := br.Learn(ctx, m.tag, m.id, m.user, time.Unix(0, m.t), m.tups) if err != nil { t.Errorf("failed to learn %v/%v: %v", m.tag, m.id, err) } @@ -646,7 +644,7 @@ func TestForgetMessage(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: strings.Fields("kita nijika ryo bocchi"), Suffix: ""}, @@ -659,7 +657,7 @@ func TestForgetMessage(t *testing.T) { { tag: "kessoku", user: userhash.Hash{4}, - id: uuid.UUID{5}, + id: "5", t: 6, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -669,7 +667,7 @@ func TestForgetMessage(t *testing.T) { { tag: "sickhack", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"kikuri"}, Suffix: ""}, @@ -680,55 +678,55 @@ func TestForgetMessage(t *testing.T) { initKnow := []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -736,19 +734,19 @@ func TestForgetMessage(t *testing.T) { initMsgs := []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -756,78 +754,78 @@ func TestForgetMessage(t *testing.T) { cases := []struct { name string tag string - id uuid.UUID + id string know []know msgs []msg }{ { name: "none", tag: "kessoku", - id: uuid.UUID{}, + id: "", know: initKnow, msgs: initMsgs, }, { name: "first", tag: "kessoku", - id: uuid.UUID{2}, + id: "2", know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -835,20 +833,20 @@ func TestForgetMessage(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -857,61 +855,61 @@ func TestForgetMessage(t *testing.T) { { name: "second", tag: "kessoku", - id: uuid.UUID{5}, + id: "5", know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", deleted: ref("CLEARMSG"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", deleted: ref("CLEARMSG"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -919,20 +917,20 @@ func TestForgetMessage(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, deleted: ref("CLEARMSG"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -941,60 +939,60 @@ func TestForgetMessage(t *testing.T) { { name: "tagged", tag: "sickhack", - id: uuid.UUID{2}, + id: "2", know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", deleted: ref("CLEARMSG"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", deleted: ref("CLEARMSG"), @@ -1003,19 +1001,19 @@ func TestForgetMessage(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, deleted: ref("CLEARMSG"), @@ -1033,7 +1031,7 @@ func TestForgetMessage(t *testing.T) { t.Fatalf("couldn't open brain: %v", err) } for _, m := range learn { - err := br.Learn(ctx, m.tag, m.user, m.id, time.Unix(0, m.t), m.tups) + err := br.Learn(ctx, m.tag, m.id, m.user, time.Unix(0, m.t), m.tups) if err != nil { t.Errorf("failed to learn %v/%v: %v", m.tag, m.id, err) } @@ -1060,7 +1058,7 @@ func TestForgetDuring(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: strings.Fields("kita nijika ryo bocchi"), Suffix: ""}, @@ -1073,7 +1071,7 @@ func TestForgetDuring(t *testing.T) { { tag: "kessoku", user: userhash.Hash{4}, - id: uuid.UUID{5}, + id: "5", t: 6, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -1083,7 +1081,7 @@ func TestForgetDuring(t *testing.T) { { tag: "sickhack", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"kikuri"}, Suffix: ""}, @@ -1094,55 +1092,55 @@ func TestForgetDuring(t *testing.T) { initKnow := []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -1150,19 +1148,19 @@ func TestForgetDuring(t *testing.T) { initMsgs := []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -1191,60 +1189,60 @@ func TestForgetDuring(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -1252,20 +1250,20 @@ func TestForgetDuring(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -1279,57 +1277,57 @@ func TestForgetDuring(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", deleted: ref("TIME"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -1337,20 +1335,20 @@ func TestForgetDuring(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, deleted: ref("TIME"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -1364,62 +1362,62 @@ func TestForgetDuring(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", deleted: ref("TIME"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -1427,21 +1425,21 @@ func TestForgetDuring(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, deleted: ref("TIME"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, deleted: ref("TIME"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -1455,56 +1453,56 @@ func TestForgetDuring(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", deleted: ref("TIME"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", deleted: ref("TIME"), @@ -1513,19 +1511,19 @@ func TestForgetDuring(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, deleted: ref("TIME"), @@ -1543,7 +1541,7 @@ func TestForgetDuring(t *testing.T) { t.Fatalf("couldn't open brain: %v", err) } for _, m := range learn { - err := br.Learn(ctx, m.tag, m.user, m.id, time.Unix(0, m.t), m.tups) + err := br.Learn(ctx, m.tag, m.id, m.user, time.Unix(0, m.t), m.tups) if err != nil { t.Errorf("failed to learn %v/%v: %v", m.tag, m.id, err) } @@ -1571,7 +1569,7 @@ func TestForgetUser(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: strings.Fields("kita nijika ryo bocchi"), Suffix: ""}, @@ -1584,7 +1582,7 @@ func TestForgetUser(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{5}, + id: "5", t: 6, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -1594,7 +1592,7 @@ func TestForgetUser(t *testing.T) { { tag: "sickhack", user: userhash.Hash{4}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"kikuri"}, Suffix: ""}, @@ -1605,55 +1603,55 @@ func TestForgetUser(t *testing.T) { initKnow := []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -1661,19 +1659,19 @@ func TestForgetUser(t *testing.T) { initMsgs := []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{1}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{4}, }, @@ -1696,62 +1694,62 @@ func TestForgetUser(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "bocchi\x00", suffix: "", deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "bocchi", deleted: ref("CLEARCHAT"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -1759,21 +1757,21 @@ func TestForgetUser(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, deleted: ref("CLEARCHAT"), }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{1}, deleted: ref("CLEARCHAT"), }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{4}, }, @@ -1790,7 +1788,7 @@ func TestForgetUser(t *testing.T) { t.Fatalf("couldn't open brain: %v", err) } for _, m := range learn { - err := br.Learn(ctx, m.tag, m.user, m.id, time.Unix(0, m.t), m.tups) + err := br.Learn(ctx, m.tag, m.id, m.user, time.Unix(0, m.t), m.tups) if err != nil { t.Errorf("failed to learn %v/%v: %v", m.tag, m.id, err) } diff --git a/brain/sqlbrain/learn.go b/brain/sqlbrain/learn.go index 2dcb572..8e0a023 100644 --- a/brain/sqlbrain/learn.go +++ b/brain/sqlbrain/learn.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/google/uuid" "zombiezen.com/go/sqlite/sqlitex" "github.com/zephyrtronium/robot/brain" @@ -13,7 +12,7 @@ import ( ) // Learn records a set of tuples. -func (br *Brain) Learn(ctx context.Context, tag string, user userhash.Hash, id uuid.UUID, t time.Time, tuples []brain.Tuple) (err error) { +func (br *Brain) Learn(ctx context.Context, tag, id string, user userhash.Hash, t time.Time, tuples []brain.Tuple) (err error) { conn, err := br.db.Take(ctx) defer br.db.Put(conn) if err != nil { @@ -31,7 +30,7 @@ func (br *Brain) Learn(ctx context.Context, tag string, user userhash.Hash, id u p = prefix(p[:0], tt.Prefix) s = append(s[:0], tt.Suffix...) st.SetText(":tag", tag) - st.SetBytes(":id", id[:]) + st.SetText(":id", id) st.SetBytes(":prefix", p) st.SetBytes(":suffix", s) _, err := st.Step() @@ -46,7 +45,7 @@ func (br *Brain) Learn(ctx context.Context, tag string, user userhash.Hash, id u return fmt.Errorf("couldn't prepare message insert: %w", err) } sm.SetText(":tag", tag) - sm.SetBytes(":id", id[:]) + sm.SetText(":id", id) sm.SetInt64(":time", t.UnixNano()) sm.SetBytes(":user", user[:]) _, err = sm.Step() diff --git a/brain/sqlbrain/learn_test.go b/brain/sqlbrain/learn_test.go index 5dac6fd..24502b0 100644 --- a/brain/sqlbrain/learn_test.go +++ b/brain/sqlbrain/learn_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/google/uuid" "zombiezen.com/go/sqlite" "zombiezen.com/go/sqlite/sqlitex" @@ -21,14 +20,14 @@ import ( type learn struct { tag string user userhash.Hash - id uuid.UUID + id string t int64 tups []brain.Tuple } type know struct { tag string - id uuid.UUID + id string prefix string suffix string deleted *string @@ -36,7 +35,7 @@ type know struct { type msg struct { tag string - id uuid.UUID + id string time int64 user userhash.Hash deleted *string @@ -50,7 +49,7 @@ func contents(t *testing.T, conn *sqlite.Conn, know []know, msgs []msg) { opts := sqlitex.ExecOptions{ Named: map[string]any{ ":tag": want.tag, - ":id": want.id[:], + ":id": want.id, ":prefix": []byte(want.prefix), ":suffix": []byte(want.suffix), }, @@ -79,7 +78,7 @@ func contents(t *testing.T, conn *sqlite.Conn, know []know, msgs []msg) { opts := sqlitex.ExecOptions{ Named: map[string]any{ ":tag": want.tag, - ":id": want.id[:], + ":id": want.id, ":time": want.time, ":user": want.user[:], }, @@ -125,7 +124,7 @@ func TestLearn(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: strings.Fields("kita nijika ryo bocchi"), Suffix: ""}, @@ -139,31 +138,31 @@ func TestLearn(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "kita\x00nijika\x00ryo\x00bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "nijika\x00ryo\x00bocchi\x00", suffix: "kita", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "ryo\x00bocchi\x00", suffix: "nijika", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "ryo", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, @@ -171,7 +170,7 @@ func TestLearn(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -183,7 +182,7 @@ func TestLearn(t *testing.T) { { tag: "結束", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: strings.Fields("喜多 虹夏 リョウ ぼっち"), Suffix: ""}, @@ -197,31 +196,31 @@ func TestLearn(t *testing.T) { know: []know{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "喜多\x00虹夏\x00リョウ\x00ぼっち\x00", suffix: "", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "虹夏\x00リョウ\x00ぼっち\x00", suffix: "喜多", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "リョウ\x00ぼっち\x00", suffix: "虹夏", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "ぼっち\x00", suffix: "リョウ", }, { tag: "結束", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "ぼっち", }, @@ -229,7 +228,7 @@ func TestLearn(t *testing.T) { msgs: []msg{ { tag: "結束", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -241,7 +240,7 @@ func TestLearn(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -251,7 +250,7 @@ func TestLearn(t *testing.T) { { tag: "kessoku", user: userhash.Hash{4}, - id: uuid.UUID{5}, + id: "5", t: 6, tups: []brain.Tuple{ {Prefix: []string{"ryo"}, Suffix: ""}, @@ -262,25 +261,25 @@ func TestLearn(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "ryo\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", prefix: "", suffix: "ryo", }, @@ -288,13 +287,13 @@ func TestLearn(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "kessoku", - id: uuid.UUID{5}, + id: "5", time: 6, user: userhash.Hash{4}, }, @@ -306,7 +305,7 @@ func TestLearn(t *testing.T) { { tag: "kessoku", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"bocchi"}, Suffix: ""}, @@ -316,7 +315,7 @@ func TestLearn(t *testing.T) { { tag: "sickhack", user: userhash.Hash{1}, - id: uuid.UUID{2}, + id: "2", t: 3, tups: []brain.Tuple{ {Prefix: []string{"kikuri"}, Suffix: ""}, @@ -327,25 +326,25 @@ func TestLearn(t *testing.T) { know: []know{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "bocchi\x00", suffix: "", }, { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "bocchi", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "kikuri\x00", suffix: "", }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", prefix: "", suffix: "kikuri", }, @@ -353,13 +352,13 @@ func TestLearn(t *testing.T) { msgs: []msg{ { tag: "kessoku", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, { tag: "sickhack", - id: uuid.UUID{2}, + id: "2", time: 3, user: userhash.Hash{1}, }, @@ -376,7 +375,7 @@ func TestLearn(t *testing.T) { t.Fatalf("couldn't open brain: %v", err) } for _, m := range c.learn { - err := br.Learn(ctx, m.tag, m.user, m.id, time.Unix(0, m.t), m.tups) + err := br.Learn(ctx, m.tag, m.id, m.user, time.Unix(0, m.t), m.tups) if err != nil { t.Errorf("failed to learn %v/%v: %v", m.tag, m.id, err) } diff --git a/brain/sqlbrain/schema.sql b/brain/sqlbrain/schema.sql index b53396b..feb9c74 100644 --- a/brain/sqlbrain/schema.sql +++ b/brain/sqlbrain/schema.sql @@ -4,7 +4,7 @@ CREATE TABLE knowledge ( -- Tag or tenant for the entry. tag TEXT NOT NULL, -- Message ID, particularly UUID. - id BLOB NOT NULL, + id TEXT NOT NULL, -- Prefix stored with entropy-reduced tokens in reverse order, -- with each token terminated by \x00 in the string. prefix BLOB NOT NULL, @@ -26,7 +26,7 @@ CREATE TABLE messages ( -- Tag or tenant for the message. tag TEXT NOT NULL, -- Message ID, particularly UUID. - id BLOB NOT NULL, + id TEXT NOT NULL, -- Message timestamp as nanoseconds from the UNIX epoch. -- May be null for messages imported from other sources or for messages -- deleted before being fully learned. diff --git a/go.mod b/go.mod index e396697..943ec01 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/BurntSushi/toml v1.4.0 github.com/dgraph-io/badger/v4 v4.2.0 github.com/google/go-cmp v0.6.0 - github.com/google/uuid v1.6.0 github.com/urfave/cli/v3 v3.0.0-alpha9 gitlab.com/zephyrtronium/pick v1.0.0 gitlab.com/zephyrtronium/tmi v0.0.0-20240325132202-7adf62e91c49 @@ -29,7 +28,7 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect - github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect @@ -39,13 +38,9 @@ require ( go.opencensus.io v0.24.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.24.0 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.34.2 // indirect - modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect modernc.org/libc v1.58.0 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect modernc.org/sqlite v1.32.0 // indirect - modernc.org/strutil v1.2.0 // indirect - modernc.org/token v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index 6af6c84..a0faab1 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,9 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -31,8 +27,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= -github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -48,14 +42,10 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/flatbuffers v24.3.7+incompatible h1:BxGUkIQnOciBu33bd5BdvqY8Qvo0O/GR4SPhh7x9Ed0= -github.com/google/flatbuffers v24.3.7+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI= github.com/google/flatbuffers v24.3.25+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -64,22 +54,15 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= -github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= @@ -102,13 +85,10 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/urfave/cli/v3 v3.0.0-alpha9 h1:P0RMy5fQm1AslQS+XCmy9UknDXctOmG/q/FZkUFnJSo= github.com/urfave/cli/v3 v3.0.0-alpha9/go.mod h1:0kK/RUFHyh+yIKSfWxwheGndfnrvYSmYFVeKCh03ZUc= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= gitlab.com/zephyrtronium/pick v1.0.0 h1:69HZtpcbLu9gl5UoKl9YcwdiSuZ3BIuGQkHp2NmG5hI= gitlab.com/zephyrtronium/pick v1.0.0/go.mod h1:jWZNNgIzAdXRkR0LFbpYckLo4ikhoQRXNm/vJuXUmVI= gitlab.com/zephyrtronium/tmi v0.0.0-20240325132202-7adf62e91c49 h1:o9bho6E5B8uhpSSvyGnM/ds52dzJowGNJESJ9EQn5X0= @@ -118,9 +98,6 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -129,7 +106,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -139,15 +117,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -155,38 +127,20 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -197,15 +151,14 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= @@ -223,10 +176,6 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -238,20 +187,24 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= -modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= -modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY= +modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ= +modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= +modernc.org/ccgo/v4 v4.20.7 h1:skrinQsjxWfvj6nbC3ztZPJy+NuwmB3hV9zX/pthNYQ= +modernc.org/ccgo/v4 v4.20.7/go.mod h1:UOkI3JSG2zT4E2ioHlncSOZsXbuDCZLvPi3uMlZT5GY= +modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= +modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= +modernc.org/gc/v2 v2.5.0 h1:bJ9ChznK1L1mUtAQtxi0wi5AtAs5jQuw4PrPHO5pb6M= +modernc.org/gc/v2 v2.5.0/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= modernc.org/libc v1.58.0 h1:TebzsKutZdvJposq9SA1atw3yBfrB+u03A8rpN0I+Qc= modernc.org/libc v1.58.0/go.mod h1:EY/egGEU7Ju66eU6SBqCNYaFUDuc4npICkMWnU5EE3A= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= -modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= -modernc.org/sqlite v1.29.1 h1:19GY2qvWB4VPw0HppFlZCPAbmxFU41r+qjKZQdQ1ryA= -modernc.org/sqlite v1.29.1/go.mod h1:hG41jCYxOAOoO6BRK66AdRlmOcDzXf7qnwlwjUIOqa0= +modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= +modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= +modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= modernc.org/sqlite v1.32.0 h1:6BM4uGza7bWypsw4fdLRsLxut6bHe4c58VeqjRgST8s= modernc.org/sqlite v1.32.0/go.mod h1:UqoylwmTb9F+IqXERT8bW9zzOWN8qwAIcLdzeBZs4hA= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= diff --git a/privmsg.go b/privmsg.go index 866550c..d5dbf61 100644 --- a/privmsg.go +++ b/privmsg.go @@ -9,7 +9,6 @@ import ( "unicode" "unicode/utf8" - "github.com/google/uuid" "gitlab.com/zephyrtronium/tmi" "golang.org/x/sync/errgroup" @@ -176,13 +175,8 @@ func (robo *Robot) learn(ctx context.Context, ch *channel.Channel, hasher userha slog.DebugContext(ctx, "no learn tag", slog.String("in", ch.Name)) return } - id, err := uuid.Parse(msg.ID) - if err != nil { - slog.ErrorContext(ctx, "failed to parse message id", slog.String("err", err.Error()), slog.String("id", msg.ID)) - // Continue on with a zero UUID. - } user := hasher.Hash(new(userhash.Hash), msg.Sender, msg.To, msg.Time()) - if err := brain.Learn(ctx, robo.brain, ch.Learn, *user, id, msg.Time(), brain.Tokens(nil, msg.Text)); err != nil { + if err := brain.Learn(ctx, robo.brain, ch.Learn, msg.ID, *user, msg.Time(), brain.Tokens(nil, msg.Text)); err != nil { slog.ErrorContext(ctx, "failed to learn", slog.String("err", err.Error())) } }