3.8 KiB
3.8 KiB
estimated_steps, estimated_files, skills_used
| estimated_steps | estimated_files | skills_used | ||
|---|---|---|---|---|
| 4 | 4 |
|
T01: Add linked Gmail thread refresh to the backend contract
Slice: S01 — Smarter Gmail import and matching Milestone: M001
Description
Finish the backend half of S01 by making already-imported Gmail threads refreshable for a single job. The executor should build on the existing job-aware matching/import flow already present in GmailController, keep the scope bounded to known linked thread ids, and return a clear refresh result that distinguishes new imports from duplicate-only refreshes and disconnected/failure states.
Steps
- Inspect the current Gmail import code in
JobTrackerApi/Controllers/GmailController.cs, the Gmail API wrapper inJobTrackerApi/Services/GmailOAuthService.cs, and the currentGmailControllerTestscoverage to identify the smallest thread-refresh contract that can satisfy R002. - Add a job-scoped linked-thread refresh path in
JobTrackerApi/Controllers/GmailController.csthat loads one owned job, gathers distinct linkedExternalThreadIdvalues from its correspondence, fetches Gmail messages for those known threads, and imports only unseenExternalMessageIdvalues into the same job. - Extend
JobTrackerApi/Services/GmailOAuthService.cswith the thread-level retrieval helper(s) needed by that controller path, and keep diagnostics bounded to counts, ids, timestamps, and connection state rather than full message bodies. - Expand
JobTrackerApi.Tests/GmailControllerTests.csto cover successful refresh with a new inbound reply, successful refresh with a new user-sent reply, duplicate-only refresh, disconnected Gmail state, and invalid/inaccessible job handling.
Must-Haves
- The refresh path operates on already-linked Gmail thread ids for one owned job; it does not introduce inbox-wide watch/history infrastructure for this slice.
- New Gmail replies import into the same
JobApplicationwith existing duplicate protection based onExternalMessageId. - The refresh contract exposes enough status to tell whether the run imported new messages, found only duplicates, or could not run because Gmail/job state was invalid.
Verification
dotnet test JobTrackerApi.Tests/JobTrackerApi.Tests.csproj --filter GmailControllerTests- Confirm the updated tests assert at least one new-message refresh, one duplicate-only refresh, and one failure-path outcome.
Observability Impact
- Signals added/changed: linked-thread refresh result counts, last refresh/sync timestamp updates, and explicit disconnected/invalid-job outcomes.
- How a future agent inspects this: read the refresh DTO and controller action in
JobTrackerApi/Controllers/GmailController.csand the focused assertions inJobTrackerApi.Tests/GmailControllerTests.cs. - Failure state exposed: the API should make it obvious whether nothing happened because there were no linked threads, Gmail was disconnected, every message was already imported, or the job was not accessible.
Inputs
JobTrackerApi/Controllers/GmailController.cs— current job-aware Gmail matching and import endpoints.JobTrackerApi/Services/GmailOAuthService.cs— current Gmail list/detail helpers and connection status updates.JobTrackerApi.Tests/GmailControllerTests.cs— existing Gmail controller test coverage.JobTrackerApi/Program.cs— existing Gmail/correspondence runtime wiring and compatibility guards.
Expected Output
JobTrackerApi/Controllers/GmailController.cs— adds the linked-thread refresh contract for one job.JobTrackerApi/Services/GmailOAuthService.cs— adds thread-fetch support used by refresh.JobTrackerApi.Tests/GmailControllerTests.cs— proves refresh success, duplicate-only, and failure-path behavior.JobTrackerApi/Program.cs— updates any wiring needed for the new refresh flow or diagnostics.