feat(dispatch): idea_link op dispatch_review (IDEA-251, T-253) #220

Merged
janpeter merged 1 commit from claude/idea-251-idea-link into main 2026-10-13 00:31:31 +02:00
Owner

IDEA-251 · T3 (T-253): dispatch_review accepts an optional idea_link. The tool checks the caller's own idea before submitting and writes the link after submitting, and the dispatch result always comes back.

Change

  • Submodule vendor/scrum4me-shared bumped from 6109a4a to f1e78df (S1). The only schema change is the model DispatchIdeaLink plus its back-relations.
    • prisma/schema.prisma was regenerated.
    • The CURRENT_SHARED_COMMIT pin in __tests__/ppe-bundle1-parity.test.ts moves along, as in earlier bumps.
  • dispatch-common.ts: submit is split into submitRaw (returns { idempotency_key, dispatch }) and submit, which wraps it in toolJson. dispatch_task is unchanged.
  • dispatch-review.ts:
    • Schema: idea_link: { idea_id, idea_phase: z.enum(UsageIdeaPhase) }, strict and optional. It never reaches the dispatch input.
    • Without idea_link: exactly the old path.
    • With idea_link, in this order:
      1. requireWriteAccess + prisma.idea.findFirst({ where: { id, user_id, product_id }, select: { id: true } }); no row → DISPATCH_FORBIDDEN and no submit.
      2. submitRaw.
      3. In its own try/catch: INSERT … ON CONFLICT (request_id) DO NOTHING, then a read-back.
        • Same values → linked; different stored values → conflict with those values.
        • On any error, only the ownership lookup runs again, in its own try/catch and reusing auth.userId. A completed lookup with no row → failed/IDEA_GONE; otherwise failed/LINK_ERROR.
        • Nothing after the submit can escape to withDispatchErrors.
    • One sentence added to the tool description.
  • Implementation notes:
    • buildInput runs before the ownership check, so invalid input fails with DISPATCH_INVALID_INPUT before any lookup, and still before any submit.
    • A link error is logged as console.error('dispatch_idea_link_write_failed', <message>).

Tests (__tests__/dispatch/tools.test.ts)

  • Own idea: fetch is called once, the body has no idea_link, and the status is linked. The findFirst where args { id, user_id, product_id } are asserted.
  • Foreign, other-product or unknown idea: DISPATCH_FORBIDDEN, no fetch and no insert.
  • Repeat with the same values: linked. The insert SQL contains ON CONFLICT (request_id) DO NOTHING.
  • Different stored phase: conflict with the stored values.
  • Failure paths, in all of which dispatch and idempotency_key remain and requireWriteAccess is called once:
    • insert error + idea gone → IDEA_GONE;
    • insert error + idea still there → LINK_ERROR;
    • insert error + diagnostic lookup throws → LINK_ERROR;
    • read-back throws → LINK_ERROR;
    • empty read-back → LINK_ERROR.
  • Without idea_link: the body is identical, with no auth and no prisma calls.
  • Schema: an unknown phase, a missing phase, a missing idea_id or an extra key → inputSchema.safeParse fails.

Verification (local)

  • npm test, including typecheck:tests: 271 files and 2692 tests passed, 84 skipped.
  • npm run build: green.

Rollout (JP authorizes each step separately)

  • Only once the T2 apply/check in production is green (Scrum4Me#369: migration + contract).
  • Pin each host to the new deploy tag: 154 first, then max2.
  • Check per container that the tool schema knows idea_link.

References

  • Spec rev 2 §4 and plan rev 2 §T3 (GO/GO): scrum4me-workers, branch claude/idea-251-spec.

Merge by JP.

🤖 Generated with Claude Code

**IDEA-251 · T3 (T-253)**: `dispatch_review` accepts an optional `idea_link`. The tool checks the caller's own idea before submitting and writes the link after submitting, and the dispatch result always comes back. ## Change - **Submodule** `vendor/scrum4me-shared` bumped from `6109a4a` to `f1e78df` (S1). The only schema change is the model `DispatchIdeaLink` plus its back-relations. - `prisma/schema.prisma` was regenerated. - The `CURRENT_SHARED_COMMIT` pin in `__tests__/ppe-bundle1-parity.test.ts` moves along, as in earlier bumps. - **`dispatch-common.ts`:** `submit` is split into `submitRaw` (returns `{ idempotency_key, dispatch }`) and `submit`, which wraps it in `toolJson`. `dispatch_task` is unchanged. - **`dispatch-review.ts`:** - **Schema:** `idea_link: { idea_id, idea_phase: z.enum(UsageIdeaPhase) }`, strict and optional. It never reaches the dispatch input. - **Without `idea_link`:** exactly the old path. - **With `idea_link`, in this order:** 1. `requireWriteAccess` + `prisma.idea.findFirst({ where: { id, user_id, product_id }, select: { id: true } })`; no row → `DISPATCH_FORBIDDEN` and no submit. 2. `submitRaw`. 3. In its own try/catch: `INSERT … ON CONFLICT (request_id) DO NOTHING`, then a read-back. - Same values → `linked`; different stored values → `conflict` with those values. - On any error, only the ownership lookup runs again, in its own try/catch and reusing `auth.userId`. A completed lookup with no row → `failed/IDEA_GONE`; otherwise `failed/LINK_ERROR`. - Nothing after the submit can escape to `withDispatchErrors`. - One sentence added to the tool description. - **Implementation notes:** - `buildInput` runs before the ownership check, so invalid input fails with `DISPATCH_INVALID_INPUT` before any lookup, and still before any submit. - A link error is logged as `console.error('dispatch_idea_link_write_failed', <message>)`. ## Tests (`__tests__/dispatch/tools.test.ts`) - **Own idea:** `fetch` is called once, the body has no `idea_link`, and the status is `linked`. The `findFirst` where args `{ id, user_id, product_id }` are asserted. - **Foreign, other-product or unknown idea:** `DISPATCH_FORBIDDEN`, no `fetch` and no insert. - **Repeat with the same values:** `linked`. The insert SQL contains `ON CONFLICT (request_id) DO NOTHING`. - **Different stored phase:** `conflict` with the stored values. - **Failure paths, in all of which `dispatch` and `idempotency_key` remain and `requireWriteAccess` is called once:** - insert error + idea gone → `IDEA_GONE`; - insert error + idea still there → `LINK_ERROR`; - insert error + diagnostic lookup throws → `LINK_ERROR`; - read-back throws → `LINK_ERROR`; - empty read-back → `LINK_ERROR`. - **Without `idea_link`:** the body is identical, with no auth and no prisma calls. - **Schema:** an unknown phase, a missing phase, a missing `idea_id` or an extra key → `inputSchema.safeParse` fails. ## Verification (local) - `npm test`, including `typecheck:tests`: 271 files and 2692 tests passed, 84 skipped. - `npm run build`: green. ## Rollout (JP authorizes each step separately) - Only once the T2 apply/check in production is green (Scrum4Me#369: migration + contract). - Pin each host to the new deploy tag: 154 first, then max2. - Check per container that the tool schema knows `idea_link`. ## References - Spec rev 2 §4 and plan rev 2 §T3 (GO/GO): scrum4me-workers, branch `claude/idea-251-spec`. Merge by JP. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(dispatch): idea_link op dispatch_review (IDEA-251, T-253)
Some checks failed
CI / Final merge attestation and immutable publication (pull_request) Has been skipped
CI / PR candidate (never published) (pull_request) Failing after 7m59s
7adc138132
Shared-bump naar f1e78df (DispatchIdeaLink), submitRaw naast submit, eigenaarscheck
vóór submit en link-rij na submit zonder het dispatch-resultaat ooit te verbergen.
Parity-test volgt de nieuwe shared-pin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
s4m-codex-reviewer left a comment

APPROVED

Findings:

  • Geen findings.

plan gekoppeld via pr_refs (product scrum4me-workers): T-253 (scrum4me-workers), onder ST-078. Er is niets weggelaten (omitted is leeg).

De diff voldoet aan de T-253-scope: eigendomscheck op gebruiker én product vóór submit, idea_link buiten de dispatch-input, idempotente insert en teruglezing, conflict met opgeslagen waarden en behoud van dispatch/idempotency_key bij koppelfouten. Het pad zonder idea_link en dispatch_task blijven conform hun bestaande contract. De shared-bump bevat uitsluitend het geplande DispatchIdeaLink-model, terugrelaties en bijbehorende schematest; het gegenereerde consumerschema sluit daarop aan.

Architectuur en patronen getoetst aan de productdocs over schema-sync, shared-runtime en typecheck-scope. Tool- en schemabeschrijvingen zijn bijgewerkt. De overige storycriteria (database-uitrol, verwijderen van ideeën en Scrum Usage) vallen buiten deze PR; de PR claimt uitsluitend T-253 en documenteert de T2 apply/check als uitrolvoorwaarde.

Verificatie op commit 7adc138132:

  • npm run build: geslaagd.
  • npm test, inclusief typecheck:tests: 271 bestanden geslaagd, 2692 tests geslaagd, 84 tests overgeslagen.
  • Gegenereerd schema laat de checkout schoon; diff-check geslaagd.

De live database-uitrol is niet uitgevoerd of gevalideerd binnen deze review.

# APPROVED Findings: - Geen findings. plan gekoppeld via pr_refs (product scrum4me-workers): T-253 (scrum4me-workers), onder ST-078. Er is niets weggelaten (omitted is leeg). De diff voldoet aan de T-253-scope: eigendomscheck op gebruiker én product vóór submit, idea_link buiten de dispatch-input, idempotente insert en teruglezing, conflict met opgeslagen waarden en behoud van dispatch/idempotency_key bij koppelfouten. Het pad zonder idea_link en dispatch_task blijven conform hun bestaande contract. De shared-bump bevat uitsluitend het geplande DispatchIdeaLink-model, terugrelaties en bijbehorende schematest; het gegenereerde consumerschema sluit daarop aan. Architectuur en patronen getoetst aan de productdocs over schema-sync, shared-runtime en typecheck-scope. Tool- en schemabeschrijvingen zijn bijgewerkt. De overige storycriteria (database-uitrol, verwijderen van ideeën en Scrum Usage) vallen buiten deze PR; de PR claimt uitsluitend T-253 en documenteert de T2 apply/check als uitrolvoorwaarde. Verificatie op commit 7adc138132f82ec290a9367be87b679514e02093: - npm run build: geslaagd. - npm test, inclusief typecheck:tests: 271 bestanden geslaagd, 2692 tests geslaagd, 84 tests overgeslagen. - Gegenereerd schema laat de checkout schoon; diff-check geslaagd. De live database-uitrol is niet uitgevoerd of gevalideerd binnen deze review.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/scrum4me-mcp!220
No description provided.