57 lines
3.6 KiB
Markdown
57 lines
3.6 KiB
Markdown
---
|
|
estimated_steps: 4
|
|
estimated_files: 5
|
|
skills_used:
|
|
- best-practices
|
|
- test
|
|
---
|
|
|
|
# T02: Persist Gmail thread metadata and harden import continuity
|
|
|
|
**Slice:** S01 — Smarter Gmail import and matching
|
|
**Milestone:** M001
|
|
|
|
## Description
|
|
|
|
Make imported Gmail correspondence durable enough to support real thread continuity. This task extends persistence and import handling so that once the user chooses a suggested Gmail message or thread, the app keeps the metadata needed for dedupe, timeline continuity, and later reply/follow-up context instead of collapsing everything down to a bare message body.
|
|
|
|
## Steps
|
|
|
|
1. Extend `Models/Correspondence.cs` so Gmail imports can retain thread/message identity and sender/recipient metadata that downstream slices can trust.
|
|
2. Update `JobTrackerApi/Controllers/GmailController.cs` import paths and `JobTrackerApi/Controllers/CorrespondenceController.cs` response behavior so imported records populate and expose the new Gmail metadata while keeping the existing no-auto-send boundary intact.
|
|
3. Update `JobTrackerApi/Program.cs` startup compatibility guards for SQLite/MySQL so older dev databases can gain the new correspondence columns without breaking local startup.
|
|
4. Add or extend `JobTrackerApi.Tests/GmailControllerTests.cs` assertions for repeat single-message imports, repeat thread imports, and import result payloads that distinguish imported vs skipped work.
|
|
|
|
## Must-Haves
|
|
|
|
- [ ] Imported Gmail correspondence keeps message/thread identity plus sender/recipient metadata in `Models/Correspondence.cs` rather than forcing later slices to re-derive it.
|
|
- [ ] Import endpoints clearly report imported vs skipped outcomes and continue deduping on repeat imports.
|
|
- [ ] Runtime schema guards in `JobTrackerApi/Program.cs` are updated alongside the model change so legacy/dev databases remain bootable.
|
|
|
|
## Verification
|
|
|
|
- `dotnet test JobTrackerApi.Tests/JobTrackerApi.Tests.csproj --filter GmailControllerTests`
|
|
- Confirm the tests prove duplicate single-message import handling, duplicate thread import handling, and the enriched import payload contract.
|
|
|
|
## Observability Impact
|
|
|
|
- Signals added/changed: persisted Gmail metadata on correspondence records and explicit imported/skipped counts from Gmail import actions.
|
|
- How a future agent inspects this: inspect `Models/Correspondence.cs`, the import payloads in `JobTrackerApi/Controllers/GmailController.cs`, and startup column guards in `JobTrackerApi/Program.cs`.
|
|
- Failure state exposed: repeat imports should now reveal whether the issue is dedupe, missing metadata persistence, or schema mismatch on startup.
|
|
|
|
## Inputs
|
|
|
|
- `JobTrackerApi/Controllers/GmailController.cs` — T01 job-aware matching/import contract and existing import behavior.
|
|
- `Models/Correspondence.cs` — current correspondence persistence model.
|
|
- `JobTrackerApi/Controllers/CorrespondenceController.cs` — current correspondence list/create/delete surface.
|
|
- `JobTrackerApi/Program.cs` — runtime schema repair path that must stay aligned with new columns.
|
|
- `JobTrackerApi.Tests/GmailControllerTests.cs` — backend Gmail coverage expanded in T01.
|
|
|
|
## Expected Output
|
|
|
|
- `Models/Correspondence.cs` — persists Gmail message/thread and sender/recipient metadata.
|
|
- `JobTrackerApi/Controllers/GmailController.cs` — populates and reports the new import metadata cleanly.
|
|
- `JobTrackerApi/Controllers/CorrespondenceController.cs` — exposes the enriched correspondence records back to the UI.
|
|
- `JobTrackerApi/Program.cs` — keeps legacy/dev DB startup safe after the schema change.
|
|
- `JobTrackerApi.Tests/GmailControllerTests.cs` — proves continuity and duplicate-import behavior.
|