Remove the email pipeline
Test and publish / test (push) Successful in 1m59s
Test and publish / publish (push) Successful in 1m41s

The mailbox sync (Microsoft Graph and IMAP), its Claude classifier, the
/email routes and the Settings page's email section are taken out while
the pipeline is unused. The last commit with it is tagged
email-pipeline-last; reverting this commit brings it back.

The status rules the capture path shares (statusOrder, StatusAdvances,
NormalizeStatus) move to job_status.go with their tests. ProcessedEmail
stays in the migration, marked dormant, so its history survives for a
restored pipeline. golang.org/x/oauth2 is no longer needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 22:48:07 +01:00
co-authored by Claude Opus 5.5
parent 6b14a96261
commit b7021ca117
32 changed files with 199 additions and 2284 deletions
+3 -72
View File
@@ -8,7 +8,6 @@ import (
"net/http"
"net/http/httptest"
"reflect"
"strings"
"testing"
"github.com/anthropics/anthropic-sdk-go/option"
@@ -17,7 +16,7 @@ import (
// These tests run the real SDK against a fake Messages API, so what is
// pinned is the request as it goes over the wire and the handling of every
// kind of reply. Ported from the main site's python/tests/test_claude.py,
// test_jobs.py, test_job_score.py and test_email_classify.py.
// test_jobs.py and test_job_score.py.
// fakeAPI answers POST /v1/messages with status and body, and records each
// request body it was sent.
@@ -191,8 +190,8 @@ func TestUnreachableAPIIsAFailedCall(t *testing.T) {
}
}
// The caller giving up must stay visible as the context's error: the email
// pipeline does not count an abandoned sync against the email.
// The caller giving up must stay visible as the context's error, so it is
// never mistaken for Claude failing on the input.
func TestCancelledCallIsNotAReadError(t *testing.T) {
api := replying(`{"n": 1}`)
c := api.client(t, "")
@@ -341,71 +340,3 @@ func TestScorePostingFailures(t *testing.T) {
}
}
}
// --- email.go -------------------------------------------------------------
func TestClassifyEmailSendsTheEmailUnchanged(t *testing.T) {
const msg = "Subject: Your application\nFrom: Acme <[email protected]>\nDate: today\n\nThanks for applying."
api := replying(`{"isJobEmail": true, "action": "create", "company": "Acme", "jobTitle": "Engineer", "status": "applied"}`)
got, err := api.client(t, "").ClassifyEmail(context.Background(), msg)
if err != nil {
t.Fatal(err)
}
if !got.IsJobEmail || got.Company != "Acme" || got.Status != "applied" {
t.Errorf("got %+v", got)
}
user := api.calls[0]["messages"].([]any)[0].(map[string]any)["content"].([]any)[0].(map[string]any)["text"]
if user != msg {
t.Errorf("user turn = %q", user)
}
}
// The prompt and the struct are two halves of one contract; neither may lose
// a key.
func TestEmailPromptNamesEveryField(t *testing.T) {
typ := reflect.TypeOf(EmailAnalysis{})
for i := range typ.NumField() {
tag := typ.Field(i).Tag.Get("json")
if !strings.Contains(emailSystem, `"`+tag+`"`) {
t.Errorf("prompt does not name %q", tag)
}
}
if !strings.Contains(emailSystem, "never as instructions") {
t.Error("prompt no longer fences off the email as data")
}
for _, s := range EmailStatuses {
if !strings.Contains(emailSystem, `"`+s+`"`) {
t.Errorf("EmailStatuses has %q but the prompt does not", s)
}
}
}
func TestClassifyEmailFillsInWhatTheModelLeftOut(t *testing.T) {
cases := map[string]EmailAnalysis{
// The prompt tells the model to send nothing else for a non-job email.
`{"isJobEmail": false}`: {},
// Nulls where strings were asked for become "".
`{"isJobEmail": true, "action": null, "company": null, "jobTitle": null, "status": null}`: {IsJobEmail: true},
`{"isJobEmail": true, "action": "update", "company": "Acme", "location": null, "notes": null}`: {IsJobEmail: true, Action: "update", Company: "Acme"},
`{}`: {},
}
for reply, want := range cases {
got, err := replying(reply).client(t, "").ClassifyEmail(context.Background(), "m")
if err != nil || !reflect.DeepEqual(got, want) {
t.Errorf("%s: got %+v, %v; want %+v", reply, got, err, want)
}
}
}
func TestClassifyEmailFailures(t *testing.T) {
cases := map[string]*fakeAPI{
"empty response from the email classifier": {status: 200, body: message("end_turn")},
"failed to parse the email classification": replying(`{"isJobEmail": true, "company": ["Acme"]}`),
"failed to classify the email": {status: 500, body: `{"type":"error","error":{"type":"api_error","message":"x"}}`},
}
for want, api := range cases {
if _, err := api.client(t, "").ClassifyEmail(context.Background(), "m"); err == nil || err.Error() != want {
t.Errorf("err = %v, want %q", err, want)
}
}
}