π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(verify): stop off-plan check results from blocking Goal review (#20176)
Arvin Xu5e17d4bb1f8b
diff --git a/apps/server/src/routers/lambda/__tests__/verify.test.ts b/apps/server/src/routers/lambda/__tests__/verify.test.tsindex 1343bcbd7f9..83285b915ac 100644--- a/apps/server/src/routers/lambda/__tests__/verify.test.ts+++ b/apps/server/src/routers/lambda/__tests__/verify.test.ts@@ -638,6 +638,27 @@ describe('verifyRouter', () => {}),);});++ it('rejects a check item that is not in the run plan instead of minting a required row', async () => {+ modelMocks.findRunById.mockResolvedValueOnce({+ id: 'run-1',+ plan: [{ id: 'item-1', index: 0, required: true, title: 'gateway matrix' }],+ });++ await expect(+ createCaller().submitCheckEvidence({+ checkItemId: 'pglite-classification',+ evidence: [{ content: 'grep output', type: 'text' }],+ verdict: 'passed',+ verifyRunId: 'run-1',+ }),+ ).rejects.toThrow(+ 'Check item "pglite-classification" is not in this verification run\'s plan. Use one of: item-1 (gateway matrix)',+ );++ expect(modelMocks.upsertByCheckItem).not.toHaveBeenCalled();+ expect(modelMocks.createEvidence).not.toHaveBeenCalled();+ });});describe('uploadEvidence', () => {diff --git a/apps/server/src/routers/lambda/verify.ts b/apps/server/src/routers/lambda/verify.tsindex 601f60cc8f4..55bf794162b 100644--- a/apps/server/src/routers/lambda/verify.ts+++ b/apps/server/src/routers/lambda/verify.ts@@ -1033,9 +1033,20 @@ export const verifyRouter = router({// no verdict so an existing row keeps its status (and a new row falls to the// DB default 'pending') instead of being reset to 'running'. drizzle omits// undefined fields from both the insert and the conflict-update.- const planItem = (run.plan as VerifyCheckItem[] | null)?.find(- (i) => i.id === input.checkItemId,- );+ const plan = (run.plan as VerifyCheckItem[] | null) ?? [];+ const planItem = plan.find((i) => i.id === input.checkItemId);+ // A planned run owns its checklist. An unknown id used to be upserted as a+ // new row that fell to the column default `required: true`, minting a+ // phantom required check no later round ever plans or re-answers β and the+ // Goal review then judged its stale evidence forever. Name the valid ids+ // so the caller can resubmit under the right one.+ if (plan.length > 0 && !planItem)+ throw new TRPCError({+ code: 'BAD_REQUEST',+ message: `Check item "${input.checkItemId}" is not in this verification run's plan. Use one of: ${plan+ .map((item) => `${item.id} (${item.title})`)+ .join('; ')}`,+ });const checkResult = await ctx.resultModel.upsertByCheckItem({checkItemId: input.checkItemId,diff --git a/apps/server/src/services/verify/__tests__/goalReview.test.ts b/apps/server/src/services/verify/__tests__/goalReview.test.tsindex 532dd2b133c..68ee0074fb6 100644--- a/apps/server/src/services/verify/__tests__/goalReview.test.ts+++ b/apps/server/src/services/verify/__tests__/goalReview.test.ts@@ -185,6 +185,69 @@ describe('Goal automatic Acceptance review', () => {});});+ it('ignores a result filed under an id that no round ever planned', async () => {+ mocks.rounds.mockResolvedValue({+ runs: [+ { id: 'r1', roundIndex: 1, plan: [check] },+ { id: 'r2', roundIndex: 2, plan: [check] },+ ],+ results: [+ { ...result, id: 'orphan', checkItemId: 'pglite-classification', verifyRunId: 'r1' },+ { ...result, id: 'result2', verifyRunId: 'r2' },+ ],+ });+ mocks.predict.mockImplementation(async ({ checkResultId }: { checkResultId: string }) =>+ checkResultId === 'orphan'+ ? { id: 'p-orphan', status: 'judged', action: 'reject', comment: 'Stale evidence.' }+ : { id: 'p1', status: 'judged', action: 'accept' },+ );++ expect(await reviewGoalDelivery(db, 'u1', 't1', 'op1')).toMatchObject({+ status: 'passed',+ predictionIds: ['p1'],+ });+ expect(mocks.predict).toHaveBeenCalledTimes(1);+ });++ it('ignores an off-plan result whose id collides with a planned sourceCriterionId', async () => {+ mocks.rounds.mockResolvedValue({+ runs: [{ id: 'r1', roundIndex: 1, plan: [{ ...check, sourceCriterionId: 'criterion-1' }] }],+ results: [result, { ...result, id: 'orphan', checkItemId: 'criterion-1' }],+ });+ mocks.predict.mockImplementation(async ({ checkResultId }: { checkResultId: string }) =>+ checkResultId === 'orphan'+ ? { id: 'p-orphan', status: 'judged', action: 'reject', comment: 'Stale evidence.' }+ : { id: 'p1', status: 'judged', action: 'accept' },+ );++ expect(await reviewGoalDelivery(db, 'u1', 't1', 'op1')).toMatchObject({+ status: 'passed',+ predictionIds: ['p1'],+ });+ expect(mocks.predict).toHaveBeenCalledWith(+ expect.objectContaining({ checkResultId: 'result1' }),+ );+ expect(mocks.predict).not.toHaveBeenCalledWith(+ expect.objectContaining({ checkResultId: 'orphan' }),+ );+ });++ it('does not fall back to a required orphan when every planned check is optional', async () => {+ mocks.rounds.mockResolvedValue({+ runs: [{ id: 'r1', roundIndex: 1, plan: [{ ...check, required: false }] }],+ results: [+ { ...result, required: false },+ { ...result, id: 'orphan', checkItemId: 'pglite-classification' },+ ],+ });++ expect(await reviewGoalDelivery(db, 'u1', 't1', 'op1')).toMatchObject({+ status: 'errored',+ feedback: expect.stringContaining('Goal Acceptance has no required checks'),+ });+ expect(mocks.predict).not.toHaveBeenCalled();+ });+it('sends missing evidence back and does not mistake skipped review for approval', async () => {mocks.predict.mockResolvedValue({ id: 'p1', status: 'skipped', statusReason: 'no evidence' });expect(await reviewGoalDelivery(db, 'u1', 't1', 'op1')).toMatchObject({ status: 'rejected' });diff --git a/apps/server/src/services/verify/goalReview.ts b/apps/server/src/services/verify/goalReview.tsindex 489a2f7ed77..769098e25f3 100644--- a/apps/server/src/services/verify/goalReview.ts+++ b/apps/server/src/services/verify/goalReview.ts@@ -62,13 +62,26 @@ export const reviewGoalDelivery = async (// draft, or one a CLI-driven verification was appended past β and its// result-less items would otherwise each read as missing evidence and turn a// passing delivery into a rejection.+ const confirmed = runs.filter((round) => !isDraftVerifyRun(round));+ // A result filed under an id its round never planned surfaces as a row of its+ // own, required by default. No later round plans it, so the builder is never+ // asked to re-answer it and it is never flagged as carried forward β its+ // stale evidence was re-judged on every attempt until the budget ran out. The+ // planned checklist is the contract, so each round keeps only the results that+ // answer its own plan items, matched on the exact id: the union keys planned+ // rows by `sourceCriterionId`, which an off-plan id could otherwise collide+ // with. Only a plan-less Acceptance is judged on its results alone.+ const hasPlan = confirmed.some((round) => (round.plan ?? []).length > 0);const checks = buildAcceptanceCheckUnion(- runs- .filter((round) => !isDraftVerifyRun(round))- .map((round) => ({- results: results.filter((result) => result.verifyRunId === round.id),+ confirmed.map((round) => {+ const roundResults = results.filter((result) => result.verifyRunId === round.id);+ if (!hasPlan) return { results: roundResults, run: round };+ const planIds = new Set(((round.plan ?? []) as { id: string }[]).map((item) => item.id));+ return {+ results: roundResults.filter((result) => planIds.has(result.checkItemId)),run: round,- })),+ };+ }),).filter((check) => check.required);if (!checks.length) throw new Error(REVIEW_BLOCKERS.noRequiredChecks);