agent build

This commit is contained in:
2026-08-28 12:21:44 +05:30
parent b6f8655909
commit f7df96c973
138 changed files with 24164 additions and 207 deletions

View File

@@ -188,11 +188,17 @@ func TestOwliverSuggestionsCarryARequestedShape(t *testing.T) {
}
// No match is an empty array, not an error and not null.
//
// "Nothing typed" is deliberately absent from this list. It used to be here,
// and it stopped being a case of "no match" when the endpoint gained an
// organization context: with nothing typed there is now something to rank —
// the state of the data — and TestOwliverHighlightsComeFromTheDatabase covers
// it. A query that WAS typed and matches nothing still answers with nothing,
// which is the case this test exists for.
func TestOwliverSuggestionsEmptyResults(t *testing.T) {
a := newAPI(t)
for _, c := range []struct{ name, query string }{
{"nothing typed", ""},
{"one character", "p"},
{"irrelevant", "sourdough starter recipe"},
} {
@@ -203,9 +209,117 @@ func TestOwliverSuggestionsEmptyResults(t *testing.T) {
})
}
// A real surface the catalogue holds no readings for is the same answer.
if got := suggestions(t, a.do("GET", suggestURL("settings", "owliver"), nil)); len(got) != 0 {
t.Fatalf("settings returned %v", got)
// A real surface the catalogue holds no readings for is the same answer,
// typed against or not.
for _, query := range []string{"owliver", ""} {
if got := suggestions(t, a.do("GET", suggestURL("settings", query), nil)); len(got) != 0 {
t.Fatalf("settings returned %v for query %q", got, query)
}
}
}
/* ── Context ────────────────────────────────────────────────────────────── */
// With nothing typed, the suggestions come from what is in PostgreSQL.
//
// This is the half of the endpoint that a static catalogue cannot serve: the
// panel opens having been told nothing, and what it should offer depends on
// whether this organization has unfinished drafts, unscored candidates or
// positions nobody has applied to. The assertion is not on WHICH readings come
// back — that is the catalogue's business and would pin this test to a ranking
// weight — but that they are real readings, capped, and that the endpoint
// reaches the database at all.
func TestOwliverHighlightsComeFromTheDatabase(t *testing.T) {
a := newAPI(t) // the harness seeds a populated organization
got := suggestions(t, a.do("GET", suggestURL("positions", ""), nil))
if len(got) == 0 {
t.Fatal("a seeded organization offered nothing with an empty query")
}
if len(got) > 3 {
t.Fatalf("%d suggestions, the cap is 3", len(got))
}
for i, s := range got {
text, _ := s["text"].(string)
intent, _ := s["intent"].(string)
if text == "" || intent == "" {
t.Fatalf("suggestion %d is incomplete: %v", i, s)
}
// A highlight is not a shaped request: nothing was typed, so nothing
// asked for a rendering.
if _, present := s["capability"]; present {
t.Fatalf("suggestion %d carries a shape nobody asked for: %v", i, s)
}
for key := range s {
switch key {
case "text", "intent":
default:
t.Fatalf("suggestion %d exposes %q: %v", i, key, s)
}
}
}
}
// The ranking answers to the data, so changing the data changes the answer.
//
// This is the property the whole context read exists for, and the one the panel
// depends on: a position created through the API must change what Owliver
// offers afterwards. No seeded posting is a draft, so unfinished drafts are a
// lever this test owns entirely — one filed here is the only one in the
// organization, and the endpoint has to notice it.
//
// One is the point. A ranking that only reacts to a pile would be a ranking
// that never reacts to the thing that just happened, which is exactly the stale
// suggestion this replaced.
func TestOwliverHighlightsReactToAMutation(t *testing.T) {
a := newAPI(t)
names := func(list []map[string]any) map[string]bool {
out := map[string]bool{}
for _, s := range list {
id, _ := s["intent"].(string)
out[id] = true
}
return out
}
before := names(suggestions(t, a.do("GET", suggestURL("positions", ""), nil)))
if before["position-drafts"] {
t.Skip("the fixture already holds draft positions; this lever is not available")
}
created := a.do("POST", "/api/v1/job-postings", map[string]any{
"title": "Owliver Context Probe", "status": "draft",
})
if created.code != http.StatusCreated {
t.Fatalf("creating the draft: status %d, body %v", created.code, created.body)
}
after := names(suggestions(t, a.do("GET", suggestURL("positions", ""), nil)))
if !after["position-drafts"] {
t.Fatalf("filing a draft did not surface the drafts reading: %v", after)
}
}
// A talent caller is offered no organization-wide count.
//
// The counts behind a highlight are org-wide by construction, and talent's rows
// are narrowed by the policy table — so answering "eleven candidates are
// waiting" to someone entitled to see one of them would leak the other ten
// through an integer. Nothing on the operator pages may reach them.
func TestOwliverHighlightsAreNotOfferedToTalent(t *testing.T) {
r := newRBAC(t)
for _, page := range []string{"positions", "candidates", "control-center", "analytics"} {
if got := suggestions(t, r.as(r.talA, "GET", suggestURL(page, ""), nil)); len(got) != 0 {
t.Fatalf("%s offered talent %v", page, got)
}
}
// An operator on the same pages is offered something, so the assertion
// above is about the role rather than about the pages being empty.
if got := suggestions(t, r.as(r.admin, "GET", suggestURL("positions", ""), nil)); len(got) == 0 {
t.Fatal("an admin was offered nothing either — the fixture proves nothing")
}
}