feat: prototype CTA XP report automation flow#203
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87d1ca9a61
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!existing) { | ||
| return { allowed: true, reason: "first_run" }; | ||
| } |
There was a problem hiding this comment.
Enforce free-run guardrail with atomic reservation
The one-free-report gate can be bypassed under concurrent requests because eligibility (canRunFreeReport) and persistence (recordFreeReportRun) are split into separate operations: two requests for the same owner can both see no record and both proceed before either write lands. In the integration flow described in this commit (check, then dispatch, then store), this allows duplicate free runs for one org; use a transactional check-and-set (or reserve the key before dispatch) to close the race.
Useful? React with 👍 / 👎.
|
The one-free-report-per-org guard is still race-prone in the current API shape.
For the intended Deno KV integration, this should probably be a single atomic check-and-set operation, for example using a versionstamp check on the org key before dispatching. The service API could expose one |
Summary
This PR adds a testable prototype for the call-to-action flow requested in #196:
owner/repoor URL)What was added
cta-xp-report/src/ctaReportService.jsnormalizeRepositorycanRunFreeReport/recordFreeReportRunsignDispatchPayloadbuildReportLinkcomposeEmailcta-xp-report/test/ctaReportService.test.jscta-xp-report/README.mdREADME.MDupdated with prototype entryValidation
All tests pass (
4/4).Notes
InMemoryKvStoreis intentionally simple; production wiring should use Deno KV/Redis.Closes #196