diff --git a/changelog.d/fixed-19157-betty-plain-spec-design.md b/changelog.d/fixed-19157-betty-plain-spec-design.md new file mode 100644 index 0000000000..2f010173e5 --- /dev/null +++ b/changelog.d/fixed-19157-betty-plain-spec-design.md @@ -0,0 +1 @@ +- Betty now treats plain requests such as "start a spec for this", "write a spec for X" and "draft a design for X" as a Spek session draft, the same as "Spek session" wording; the draft still waits for approval, and statements like "the spec says" or "the design review happened" are not requests ([#19157](https://github.com/hivecommons/hive/issues/19157)). diff --git a/src/docs/meetings.md b/src/docs/meetings.md index 6f751e9568..1e20e188a0 100644 --- a/src/docs/meetings.md +++ b/src/docs/meetings.md @@ -411,7 +411,7 @@ People in the meeting can ask Betty, spoken or typed in the meeting chat, to dra | "Betty, start a Spek session on calendar sync" | a Spek session | handed to the Inbox `spek_rfc` destination: a hive agent drafts the spec with spektacular and publishes it to the repo | | "Betty, save that as a knowledge note" | a knowledge note | written to the `meetings` knowledge vault, the same write meeting notes use | -- **Recognising a request.** The line must be addressed to her (her name opens or closes it, with or without a comma before a verb such as "open", "file", "make", "start" or "save") and ask to make an item ("issue", "bug", "ticket", "RFC", "Spek session", "knowledge note"). Questions about an item ("what's the issue with the lobby?") and negations ("don't open an issue") are not requests. +- **Recognising a request.** The line must be addressed to her (her name opens or closes it, with or without a comma before a verb such as "open", "file", "make", "start" or "save") and ask to make an item ("issue", "bug", "ticket", "RFC", "Spek session", "knowledge note"). Plain "spec" and "design" (and their plurals) also count as a Spek session when they are the object of a request: "Betty, start a spec for this", "can you write a spec for the login flow", "draft a design for X" (verbs: start, write, draft, create, kick off, open, make; optionally led by "can you", "could you", "please"). Statements about a spec ("the spec says", "per the design", "the design review happened") are not requests. Questions about an item ("what's the issue with the lobby?") and negations ("don't open an issue") are not requests. - **Drafting.** Betty drafts a short title and body from the request and the last three minutes of the meeting, with a link back to the meeting (the dashboard's Meetings section, when `dashboard.public_url` is set) and a transcript excerpt. The repo is a monitored repo the request names ("in spektacular", "hivecommons/spektacular"), else `meetings.persona.actions.default_repo`, else `inbox.spek.repo`, else `project.primary_repo`, else the first repo. A repo the model suggests is used only when it is a monitored repo. With no meetings model she drafts from the request itself. - **Confirmation.** She replies in the meeting chat: "Drafted an issue: ''. It's waiting for approval in the hive." If the request does not say what the item is about and nothing was said before it, she asks one clarifying question ("Happy to draft an issue. What should it be about?") and drafts from the asker's next line (or "never mind" drops it). The model may ask that one question too; it never asks twice. - **Approval.** Speaker identity in a meeting is only a display name, so nothing is created from the meeting. Every draft lands in **Drafts from meetings** in the Calendar section, with the meeting, who asked (display name), the body and the transcript excerpt. The hive owner or a read-write user can **Edit** (type, title, body, repo), **Approve** or **Reject** it. Approval creates the item; a failed creation stays in the list with its error and can be approved again after a fix. diff --git a/src/pkg/meetings/betty/actions.go b/src/pkg/meetings/betty/actions.go index 4110f54eef..648b1fb677 100644 --- a/src/pkg/meetings/betty/actions.go +++ b/src/pkg/meetings/betty/actions.go @@ -163,6 +163,16 @@ func actionNoun(w []string, i int) (actions.Type, int, bool) { if next == "session" { return actions.TypeSpek, 1, true } + if plainSpekRequest(w, i) { + return actions.TypeSpek, 0, true + } + case "specs", "design", "designs": + if plainSpekRequest(w, i) { + if next == "doc" || next == "document" || next == "session" { + return actions.TypeSpek, 1, true + } + return actions.TypeSpek, 0, true + } case "knowledge": switch next { case "note", "item", "fact", "entry", "base": @@ -175,6 +185,44 @@ func actionNoun(w []string, i int) (actions.Type, int, bool) { return "", 0, false } +// maxWordsBeforeSpekNoun bounds the words between the verb and "spec" or +// "design" ("write up a quick spec"). +const maxWordsBeforeSpekNoun = 4 + +// requestLeads may open a request before its verb ("can you please start"). +var requestLeads = map[string]bool{ + "please": true, "can": true, "could": true, "would": true, "will": true, "you": true, + "go": true, "ahead": true, "and": true, "just": true, "now": true, "also": true, + "let's": true, "lets": true, "let": true, "us": true, +} + +// notSpekDesignFollows are words after "design" that name something else +// ("design review", "design meeting"). +var notSpekDesignFollows = map[string]bool{ + "review": true, "reviews": true, "meeting": true, "meetings": true, "decision": true, "decisions": true, + "choice": true, "choices": true, "pattern": true, "patterns": true, +} + +// plainSpekRequest reports whether "spec" or "design" at w[i] is the object of +// a request: only request lead words, then an action verb, then a few words. +// "the spec says" and "per the design" are talk about a spec, not a request. +func plainSpekRequest(w []string, i int) bool { + if i+1 < len(w) && notSpekDesignFollows[w[i+1]] { + return false + } + for v := 0; v < i; v++ { + if actionVerbs[w[v]] { + for _, x := range w[:v] { + if !requestLeads[x] { + return false + } + } + return i-v-1 <= maxWordsBeforeSpekNoun + } + } + return false +} + func subjectOf(w []string) string { if len(w) > 0 && subjectLead[w[0]] { w = w[1:] diff --git a/src/pkg/meetings/betty/actions_test.go b/src/pkg/meetings/betty/actions_test.go index 33877ceb1b..4240bc7e52 100644 --- a/src/pkg/meetings/betty/actions_test.go +++ b/src/pkg/meetings/betty/actions_test.go @@ -147,6 +147,60 @@ func TestDetectAction(t *testing.T) { } } +func TestDetectActionPlainSpecAndDesign(t *testing.T) { + positive := []struct{ rest, subject string }{ + {"start a spec for this", ""}, + {"can you write a spec for the login flow", "the login flow"}, + {"draft a design for the inbox", "the inbox"}, + {"could you please create a design doc for calendar sync", "calendar sync"}, + {"please kick off a spec for onboarding", "onboarding"}, + {"open a spec on rate limits", "rate limits"}, + {"make a design for the lobby", "the lobby"}, + {"write up a quick spec about retries", "retries"}, + {"let's start designs for the dashboard", "the dashboard"}, + {"go ahead and write specs for the api", "the api"}, + } + for _, c := range positive { + typ, subject, ok := DetectAction(c.rest) + if typ != actions.TypeSpek || subject != c.subject || !ok { + t.Errorf("DetectAction(%q) = %q, %q, %v; want spek, %q, true", c.rest, typ, subject, ok, c.subject) + } + } + negative := []string{ + "the spec says we retry twice", + "per the design we cache it", + "we spec'd that last week", + "i need to inspect the logs", + "that is a special case", + "be more specific about the spec", + "the design review happened yesterday", + "what does the design say", + "don't write a spec for that", + "we should start with the design", + "is there a spec for this", + "start a design review", + "the spec is a draft", + } + for _, rest := range negative { + if typ, _, ok := DetectAction(rest); ok { + t.Errorf("DetectAction(%q) = %q, true; want no action", rest, typ) + } + } +} + +func TestPlainSpecStillNeedsApproval(t *testing.T) { + a := newActionRig(t, nil, nil) + a.e.Observe(Line{Who: "Cy", Text: "betty start a spec for calendar sync", Spoken: true}) + a.reply() + d := a.only() + if d.Type != actions.TypeSpek || d.Status != actions.StatusPending { + t.Fatalf("draft %+v", d) + } + if a.created() != 0 { + t.Fatal("nothing may be created before approval") + } +} + func TestRepoMention(t *testing.T) { repos := []string{"hivecommons/hive", "hivecommons/spektacular"} cases := map[string]string{