Complete S02 application package drafting loop

This commit is contained in:
2026-03-24 10:36:05 +01:00
parent 3e5f796326
commit b5b430947b
14 changed files with 864 additions and 152 deletions
@@ -0,0 +1,51 @@
---
estimated_steps: 4
estimated_files: 2
skills_used:
- best-practices
- test
---
# T01: Strengthen application-package context assembly and backend draft tests
**Slice:** S02 — Stronger AI application package drafting
**Milestone:** M001
## Description
Make the backend application-package generator use the context S01 now provides. The executor should keep the existing package endpoint, but improve how it builds prompts and selects context so the tailored CV, cover letter, recruiter message, and supporting signals reflect imported correspondence, recruiter/job details, profile CV structure, and attachment context more convincingly.
## Steps
1. Inspect `JobTrackerApi/Controllers/JobApplicationsController.cs` around `generate-application-package` and identify which job, recruiter, correspondence, attachment, and profile-CV signals are already available but underused.
2. Refine the package-context assembly and prompt shape so imported correspondence and recruiter/job-specific details influence the generated drafts directly without weakening the no-auto-send boundary.
3. Add a focused backend test file `JobTrackerApi.Tests/JobApplicationsApplicationPackageTests.cs` that exercises the package endpoint contract with real job/correspondence/profile context and asserts the returned artifacts are specific to that context.
4. Keep the output contract stable unless a change materially improves the workspace; if it changes, make the added fields explicit and limited to what T02 will consume.
## Must-Haves
- [ ] Imported correspondence from S01 is deliberately consumed in package generation instead of remaining disconnected from the draft flow.
- [ ] Backend tests prove package output responds to job-specific context rather than generic fallback behavior.
- [ ] The generator still returns review-only draft material and does not cross the manual-send boundary.
## Verification
- `dotnet test JobTrackerApi.Tests/JobTrackerApi.Tests.csproj --filter JobApplicationsApplicationPackageTests`
- Confirm the focused test covers correspondence-aware package context and expected package artifacts.
## Observability Impact
- Signals added/changed: clearer package-response artifacts and stronger context assembly around job/correspondence/profile inputs.
- How a future agent inspects this: read `JobTrackerApi/Controllers/JobApplicationsController.cs` and `JobTrackerApi.Tests/JobApplicationsApplicationPackageTests.cs`.
- Failure state exposed: focused backend verification should show whether weak drafts come from missing context assembly, empty correspondence state, or prompt/output contract drift.
## Inputs
- `JobTrackerApi/Controllers/JobApplicationsController.cs` — current application-package and related AI draft endpoints.
- `Models/Correspondence.cs` — persisted Gmail-linked correspondence metadata from S01.
- `JobTrackerApi/Controllers/ProfileCvController.cs` — profile CV structure/source-of-truth behavior.
## Expected Output
- `JobTrackerApi/Controllers/JobApplicationsController.cs` — stronger package-generation context and/or response contract.
- `JobTrackerApi.Tests/JobApplicationsApplicationPackageTests.cs` — focused backend proof for context-aware package generation.
@@ -0,0 +1,32 @@
---
title: T01 summary
status: done
files:
- JobTrackerApi/Controllers/JobApplicationsController.cs
- JobTrackerApi.Tests/JobApplicationsApplicationPackageTests.cs
verification:
- $HOME/.dotnet/dotnet build JobTrackerApi/JobTrackerApi.csproj
- docker run --rm -v "$PWD":/src -w /src mcr.microsoft.com/dotnet/sdk:9.0 bash -lc '...dotnet test /tmp/apptests/AppPkgTests.csproj...'
---
Strengthened application-package generation so it now consumes imported correspondence and recruiter/job context instead of relying mostly on job description text plus the profile CV.
What changed:
- `JobTrackerApi/Controllers/JobApplicationsController.cs`
- added `BuildCorrespondenceContextAsync(...)` to gather recent imported correspondence, participants, thread ids, and AI-derived package signals
- enriched `generate-application-package` context with:
- recruiter name/email and greeting baseline
- imported correspondence context from S01
- existing saved job material (tailored CV / cover letter / recruiter message) when present
- job URL in the package context
- updated prompts so tailored CV, cover letter, application answer, recruiter message, and variants all explicitly use imported correspondence when helpful without crossing the manual-send boundary
- expanded `KeyPoints` to include correspondence-derived and attachment-derived signals
- `JobTrackerApi.Tests/JobApplicationsApplicationPackageTests.cs`
- added focused backend proof that package generation reacts to imported correspondence and recruiter context rather than falling back to generic output
Verification:
- Native backend build passed with `$HOME/.dotnet/dotnet build JobTrackerApi/JobTrackerApi.csproj`
- Focused application-package backend test passed in an isolated Docker harness (`1 passed`)
Important caveat:
- As with S01 backend verification, the repositorys broader `JobTrackerApi.Tests` project still has unrelated compile drift, so the focused package test was isolated instead of relying on the full test project.
@@ -0,0 +1,53 @@
---
estimated_steps: 4
estimated_files: 3
skills_used:
- react-best-practices
- test
---
# T02: Make the job workspace save and present the application package as real working material
**Slice:** S02 — Stronger AI application package drafting
**Milestone:** M001
## Description
Turn the Tailored CV/application package area into a coherent working loop. The workspace should make it obvious what was generated, what was edited, what was saved to the job, and what can be reused later, instead of feeling like a temporary AI preview pane.
## Steps
1. Update `job-tracker-ui/src/types.ts` if T01 changes the package contract or exposes stronger saved draft/package state.
2. Refine `job-tracker-ui/src/components/JobDetailsDialog.tsx` so generation, editing, saving, and redisplay of application package material feel like one continuous workflow tied to the job.
3. Expand `job-tracker-ui/src/job-details-generated-drafts.test.tsx` to prove the stronger package flow: generate with contextual outputs, edit/save the important draft artifacts, and verify the saved material is reflected back in the dialog state.
4. Keep the UI focused on working material already tied to the job; do not introduce a second competing draft surface or outbound automation.
## Must-Haves
- [ ] The Tailored CV tab clearly presents generated package artifacts as editable, savable job material rather than disposable previews.
- [ ] Saved package edits update dialog state in a way the user can trust and later slices can reuse.
- [ ] The focused React test proves generation and save behavior for the package loop.
## Verification
- `CI=true npm --prefix job-tracker-ui test -- --watch=false --runTestsByPath src/job-details-generated-drafts.test.tsx`
- Confirm the expanded test proves generation, editing, and save-state behavior in the dialog.
## Observability Impact
- Signals added/changed: clearer UI state around generated vs saved package material and stronger test coverage for package-loop regressions.
- How a future agent inspects this: open the Tailored CV tab in `job-tracker-ui/src/components/JobDetailsDialog.tsx` and read `job-tracker-ui/src/job-details-generated-drafts.test.tsx`.
- Failure state exposed: the workspace and test should distinguish generation failure, unsaved edits, and saved package state instead of collapsing them into generic draft text.
## Inputs
- `job-tracker-ui/src/components/JobDetailsDialog.tsx` — existing package-generation and save UI.
- `job-tracker-ui/src/types.ts` — frontend package contracts.
- `JobTrackerApi/Controllers/JobApplicationsController.cs` — T01 package-generation contract.
- `job-tracker-ui/src/job-details-generated-drafts.test.tsx` — current focused dialog test.
## Expected Output
- `job-tracker-ui/src/components/JobDetailsDialog.tsx` — stronger package generation/edit/save flow.
- `job-tracker-ui/src/types.ts` — aligned package contract for the workspace.
- `job-tracker-ui/src/job-details-generated-drafts.test.tsx` — focused frontend proof for the improved package loop.
@@ -0,0 +1,36 @@
---
title: T02 summary
status: done
files:
- job-tracker-ui/src/components/JobDetailsDialog.tsx
- job-tracker-ui/src/job-details-generated-drafts.test.tsx
verification:
- CI=true npm --prefix job-tracker-ui test -- --watch=false --runTestsByPath src/job-details-generated-drafts.test.tsx
- $HOME/.dotnet/dotnet build JobTrackerApi/JobTrackerApi.csproj
- docker run --rm -v "$PWD":/src -w /src mcr.microsoft.com/dotnet/sdk:9.0 bash -lc '...dotnet test /tmp/apptests/AppPkgTests.csproj...'
---
Turned the Tailored CV tab into a real package workspace instead of a one-shot draft preview.
What changed:
- `job-tracker-ui/src/components/JobDetailsDialog.tsx`
- added package workspace state for cover letter, application answer, and recruiter message alongside the tailored CV
- initialized that workspace from saved job material so reopening the dialog shows the last trusted copy, not just blank/generated state
- generation now replaces the editable working copy for all package artifacts, not only the tailored CV
- added package-level save flow that writes the tailored CV plus draft artifacts back to the job together
- added explicit saved/generated/unsaved status chips so the user can tell what is persisted versus still in the working draft
- added reset-to-saved behavior so the workspace can recover from unwanted edits
- normalized application-answer persistence into a replaceable notes block instead of endlessly appending
- `job-tracker-ui/src/job-details-generated-drafts.test.tsx`
- expanded the focused dialog test to prove saved material loads into the workspace, generation replaces the working copy, edits can be saved, and the save payload reflects the coherent package state
Backend support tightened during T02:
- `JobTrackerApi/Controllers/JobApplicationsController.cs`
- `SaveApplicationDrafts` now replaces `Notes` when notes are provided, which makes the saved application-answer loop trustworthy instead of append-only
- `JobTrackerApi.Tests/JobApplicationsApplicationPackageTests.cs`
- added focused proof that notes replacement no longer appends indefinitely
Verification:
- Frontend focused test passed: `CI=true npm --prefix job-tracker-ui test -- --watch=false --runTestsByPath src/job-details-generated-drafts.test.tsx`
- Backend host build passed: `$HOME/.dotnet/dotnet build JobTrackerApi/JobTrackerApi.csproj`
- Focused backend package tests passed in isolated Docker harness (`2 passed`)