Phase 2 part 4: discovery per signal (Claude web search, explee.com)
Each signal's page can search for organizations that show it, by hand or every 7, 14 or 30 days. Claude with the web_search_20260209 server tool (pause_turn resumed) works from the signal's "How to spot it" lines and the profile's targets; a company is kept only if its evidence URL was among the pages searched. explee.com's company search runs the signal's description in the target sizes, scored against the hypothesis, keeping strong matches. Our sites, the inventory, existing prospects, CRM Accounts and suppressed domains are left out. New companies go to Review tagged with the signal. Schema 8 adds discovery_runs (counts, searches, why companies were left out) and the signal's schedule and explee.com description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -687,3 +687,41 @@ func TestSignalsFunnel(t *testing.T) {
|
||||
t.Error("delete")
|
||||
}
|
||||
}
|
||||
|
||||
// The discovery card: what it needs before it can search, its schedule,
|
||||
// and the run list.
|
||||
func TestSignalDiscoveryCard(t *testing.T) {
|
||||
s, h := newTestServer(t, nil)
|
||||
postForm(h, "/signals/new", url.Values{"name": {"Leaving Microsoft 365"}, "spot": {"m365 alternative"},
|
||||
"discover_every_days": {"7"}, "explee_definition": {"managed IT services"}})
|
||||
sig, err := signals.Get(s.DB, 1)
|
||||
if err != nil || sig.DiscoverEveryDays != 7 || sig.ExpleeDefinition != "managed IT services" {
|
||||
t.Fatalf("saved: %+v %v", sig, err)
|
||||
}
|
||||
body := do(h, http.MethodGet, "/signals/1", nil, nil).Body.String()
|
||||
for _, want := range []string{"Find companies", "No searches yet", `<option value="7" selected>Every 7 days</option>`,
|
||||
"Save an explee.com API key"} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("signal page lacks %q", want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(body, `action="/signals/1/discover/claude"`) {
|
||||
t.Error("the web search button shows without an AI key")
|
||||
}
|
||||
if rec := postForm(h, "/signals/1/discover/claude", nil); rec.Code == http.StatusSeeOther {
|
||||
t.Error("a search started without an AI key")
|
||||
}
|
||||
s.Secrets.Set(map[string]string{secrets.ExpleeAPIKey: "k"})
|
||||
if body := do(h, http.MethodGet, "/signals/1", nil, nil).Body.String(); !strings.Contains(body, `action="/signals/1/discover/explee"`) {
|
||||
t.Error("the explee.com button doesn't show with a key and a description")
|
||||
}
|
||||
s.DB.Exec(`INSERT INTO discovery_runs (signal_id, source, status, started_at, found, added, skipped, searches, notes)
|
||||
VALUES (1, 'claude', 'done', '2026-11-21T10:00:00Z', 5, 3, 2, 6, '["Rival: in your inventory (competitor)"]'),
|
||||
(1, 'claude', 'running', '2026-11-21T11:00:00Z', 0, 0, 0, 0, '[]')`)
|
||||
body = do(h, http.MethodGet, "/signals/1/runs", nil, nil).Body.String()
|
||||
for _, want := range []string{"searching…", "3 new", "6 web searches", "Rival: in your inventory", `hx-trigger="every 4s"`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("runs lack %q in %s", want, body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user