test(server): resolution capture unit + integration coverage (CRU-130) - #373
Merged
Conversation
Covers Phase 1 of the round-trip review flow (CRU-128). Pairs well with the implementation PR so reviewers can see what each new guard protects. Unit tests (apps/server/test/db/agent-manager.test.ts): - updateFeedbackStatus / ...ByParent: ignored rejects without reason, accepts fixed with or without reason, records resolution_reason / resolution_commit / resolved_at, and preserves the audit trail on benign re-resolves (COALESCE + first-transition semantics). - submitReviewResolution: empty / whitespace / over-length summary, non-'complete' review status, still-open items, ignored-without-reason, missing review, happy path (summary + HEAD sha + round 1), upsert on repeat submit, summary trimming, no partial persistence on failure. - persona review last_reviewed_commit: set on create, default null, updated on completePersonaReview, COALESCE preserves it when omitted. HTTP integration tests (resolution-capture-integration.test.ts): - PATCH feedback endpoint: reason type/size validation, ignored-without -reason, happy paths for fixed/ignored, resolution commit not recorded on revert to 'open'. - POST resolution endpoint: summary validation, 409 for open items, ignored-missing-reason, wrong review status, 404 missing parent, happy path persists summary + HEAD + round_number, auth required. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…130) Addresses three low-severity findings from the persona review on PR #373: - Add a 401 test for PATCH /feedback/:feedbackId so an auth-hook regression that accidentally excludes the PATCH route fails loudly instead of relying on the sibling POST /resolution test. - Exercise the manager-level 10,000-character summary cap through handleAgentError on POST /resolution, so HTTP-layer status-code translation for that specific throw path is covered end-to-end. - Add a 404 test for the "both agents exist, no persona_reviews row" branch inside submitReviewResolution's transaction — complements the existing "parent missing" 404 test which short-circuits before the manager runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 test coverage for the review round-trip flow (parent of CRU-127). Backs the resolution-capture implementation landed in #372 / CRU-128 with unit + HTTP integration tests so every new guard has a regression net.
No production code changed — tests only.
Coverage
Unit (
apps/server/test/db/agent-manager.test.ts, additive):updateFeedbackStatus/updateFeedbackStatusByParentignoredrejects without a reason (empty, whitespace-only)fixedaccepted with or without a reasonresolution_reason,resolution_commit,resolved_atpersistedresolved_atdoes not drift on repeat calls; cleared on revert toopensubmitReviewResolutioncompletestateround_number=1persona_reviews.last_reviewed_commitcreatePersonaReview; defaults to nullcompletePersonaReview; COALESCE preserves when omittedHTTP integration (
apps/server/test/resolution-capture-integration.test.ts, new file):PATCH /api/v1/agents/:id/feedback/:feedbackIdignoredwithout reason → 400fixed/ignoredrecord reason + HEAD shaopendoes not recompute resolution commitPOST /api/v1/agents/:id/persona-reviews/:personaAgentId/resolutioncomplete→ 409Follows the
mcp-auth-integration.test.tspattern: inert runtime, isolated test DB,runCommandmocked soresolveHeadShareturns a controlled value.Test plan
pnpm run check(backend + web tsc)pnpm run test— 366 passed, 11 skipped (pre-existing)pnpm run test:e2e— not re-run; no production code changed, no E2E assertions touched