π€― 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
β¨ feat(verify): submit check result + evidence in one call, inject acceptance into task prompt (#16214)
Arvin Xu2997ba6a3e7b
diff --git a/apps/cli/man/man1/lh.1 b/apps/cli/man/man1/lh.1index 2aad57c0b07..42932ec9333 100644--- a/apps/cli/man/man1/lh.1+++ b/apps/cli/man/man1/lh.1@@ -1,6 +1,6 @@.\" Code generated by `npm run man:generate`; DO NOT EDIT..\" Manual command details come from the Commander command tree.-.TH LH 1 "" "@lobehub/cli 0.0.35" "User Commands"+.TH LH 1 "" "@lobehub/cli 0.0.36" "User Commands".SH NAMElh \- LobeHub CLI \- manage and connect to LobeHub services.SH SYNOPSISdiff --git a/apps/cli/package.json b/apps/cli/package.jsonindex ecfff5006ae..19aa87213b8 100644--- a/apps/cli/package.json+++ b/apps/cli/package.json@@ -1,6 +1,6 @@{"name": "@lobehub/cli",- "version": "0.0.35",+ "version": "0.0.36","type": "module","bin": {"lh": "./dist/index.js",diff --git a/apps/cli/src/commands/verify.ts b/apps/cli/src/commands/verify.tsindex 7651fa3477f..7f2d5e14ae6 100644--- a/apps/cli/src/commands/verify.ts+++ b/apps/cli/src/commands/verify.ts@@ -646,6 +646,89 @@ export function registerVerifyCommand(program: Command) {printResults(results);});+ // ββββββββββββ submit (builder self-evidence: result + evidence in one call) ββββββββββββ+ verify+ .command('submit')+ .description('Submit a check item β upsert its result and attach evidence in one call')+ .option('--run <verifyRunId>', 'Target verification session (or use --operation)')+ .option('--operation <operationId>', 'Resolve the session from an Agent Run operation id')+ .requiredOption('--item <checkItemId>', 'Plan item id (checkItemId)')+ .option('--type <type>', 'screenshot|gif|video|text|dom_snapshot|transcript')+ .option('--file <path>', 'Local file to upload as the evidence artifact')+ .option('--content <text>', 'Inline text payload (instead of a file)')+ .option('--verdict <verdict>', 'passed|failed|uncertain')+ .option('--title <text>', 'Check item title snapshot')+ .option('--by <capturedBy>', 'agent-browser|cdp|cli|program|llm_judge', 'cli')+ .option('--desc <text>', 'Human-readable caption for the evidence')+ .option('--json [fields]', 'Output JSON')+ .action(+ async (options: {+ by?: string;+ content?: string;+ desc?: string;+ file?: string;+ item: string;+ json?: boolean | string;+ operation?: string;+ run?: string;+ title?: string;+ type?: string;+ verdict?: string;+ }) => {+ if (!options.run && !options.operation) {+ log.error('Provide --run <verifyRunId> or --operation <operationId>');+ process.exit(1);+ }+ const hasEvidence = Boolean(options.file) || Boolean(options.content);+ if (Boolean(options.file) && Boolean(options.content)) {+ log.error('Provide at most one of --file or --content');+ process.exit(1);+ }+ if (hasEvidence && !options.type) {+ log.error('--type is required when attaching evidence');+ process.exit(1);+ }+ if (!hasEvidence && !options.verdict) {+ log.error('Provide evidence (--file/--content) and/or a --verdict');+ process.exit(1);+ }+ const client = await getTrpcClient();+ let fileId: string | undefined;+ if (options.file) {+ const uploaded = await uploadLocalFile(client, options.file);+ fileId = uploaded.id;+ }+ const evidence = hasEvidence+ ? [+ {+ capturedBy: options.by as any,+ content: options.content,+ description: options.desc,+ fileId,+ type: options.type as any,+ },+ ]+ : undefined;+ const res = await client.verify.submitCheckEvidence.mutate({+ checkItemId: options.item,+ checkItemTitle: options.title,+ evidence,+ operationId: options.operation,+ verdict: options.verdict as any,+ verifyRunId: options.run,+ });+ if (options.json !== undefined) {+ outputJson(res, typeof options.json === 'string' ? options.json : undefined);+ return;+ }+ console.log(+ `${pc.green('β')} Submitted ${pc.bold(res.checkResult.id)}` ++ `${res.checkResult.verdict ? ` (${res.checkResult.verdict})` : ''}` ++ `${res.evidence.length > 0 ? ` +${res.evidence.length} evidence` : ''}`,+ );+ },+ );+// ββββββββββββ evidence (artifact entity) ββββββββββββconst evidence = verify.command('evidence').description('Evidence artifacts (verify_evidence)');@@ -721,6 +804,20 @@ export function registerVerifyCommand(program: Command) {);});+ evidence+ .command('delete <evidenceId>')+ .description('Delete an evidence artifact')+ .option('--json [fields]', 'Output JSON')+ .action(async (evidenceId: string, options: { json?: boolean | string }) => {+ const client = await getTrpcClient();+ const result = await client.verify.deleteEvidence.mutate({ id: evidenceId });+ if (options.json !== undefined) {+ outputJson(result, typeof options.json === 'string' ? options.json : undefined);+ return;+ }+ console.log(`${pc.green('β')} Deleted evidence ${pc.bold(result.id)}`);+ });+// ββββββββββββ report (narrative entity) ββββββββββββconst report = verify.command('report').description('Verification reports (verify_reports)');diff --git a/apps/server/src/routers/lambda/__tests__/verify.test.ts b/apps/server/src/routers/lambda/__tests__/verify.test.tsindex 97d188bead2..25972c04b63 100644--- a/apps/server/src/routers/lambda/__tests__/verify.test.ts+++ b/apps/server/src/routers/lambda/__tests__/verify.test.ts@@ -4,6 +4,8 @@ import { verifyRouter } from '@/server/routers/lambda/verify';import { FileService } from '@/server/services/file';const modelMocks = vi.hoisted(() => ({+ createEvidence: vi.fn(),+ findRunByOperation: vi.fn(),findRunById: vi.fn(),findResultById: vi.fn(),getFullFileUrl: vi.fn(),@@ -24,10 +26,17 @@ vi.mock('@/database/models/verifyCheckResult', () => ({vi.mock('@/database/models/verifyRun', () => ({VerifyRunModel: vi.fn(() => ({+ findByOperation: modelMocks.findRunByOperation,findById: modelMocks.findRunById,})),}));+vi.mock('@/database/models/verifyEvidence', () => ({+ VerifyEvidenceModel: vi.fn(() => ({+ create: modelMocks.createEvidence,+ })),+}));+vi.mock('@/server/services/verify', () => ({VerifyExecutorService: class VerifyExecutorService {},VerifyFeedbackService: class VerifyFeedbackService {},@@ -83,6 +92,138 @@ describe('verifyRouter', () => {});});+ describe('submitCheckEvidence', () => {+ it("rejects a run outside the caller's scope before upserting", async () => {+ modelMocks.findRunById.mockResolvedValueOnce(undefined);++ await expect(+ createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ verdict: 'passed',+ verifyRunId: 'other-user-run',+ }),+ ).rejects.toThrow('Verification run not found');++ expect(modelMocks.upsertByCheckItem).not.toHaveBeenCalled();+ expect(modelMocks.createEvidence).not.toHaveBeenCalled();+ });++ it('rejects an evidence item with both inline content and fileId', async () => {+ await expect(+ createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ evidence: [{ content: 'inline', fileId: 'files-1', type: 'text' }],+ verifyRunId: 'run-1',+ }),+ ).rejects.toThrow('Provide exactly one of `content` or `fileId`.');+ });++ it('lazily upserts the check result and attaches evidence in one call', async () => {+ modelMocks.findRunById.mockResolvedValueOnce({ id: 'run-1' });+ modelMocks.upsertByCheckItem.mockResolvedValueOnce({ id: 'result-1', verdict: 'passed' });+ modelMocks.createEvidence.mockResolvedValueOnce({ id: 'evidence-1' });++ const res = await createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ evidence: [{ fileId: 'files-1', type: 'screenshot' }],+ verdict: 'passed',+ verifyRunId: 'run-1',+ });++ expect(modelMocks.upsertByCheckItem).toHaveBeenCalledWith(+ expect.objectContaining({ checkItemId: 'item-1', verdict: 'passed', verifyRunId: 'run-1' }),+ );+ expect(modelMocks.createEvidence).toHaveBeenCalledWith(+ expect.objectContaining({+ checkResultId: 'result-1',+ fileId: 'files-1',+ type: 'screenshot',+ }),+ );+ expect(res).toEqual({+ checkResult: { id: 'result-1', verdict: 'passed' },+ evidence: [{ id: 'evidence-1' }],+ });+ });++ it('allows a verdict-only submit with no evidence', async () => {+ modelMocks.findRunById.mockResolvedValueOnce({ id: 'run-1' });+ modelMocks.upsertByCheckItem.mockResolvedValueOnce({ id: 'result-1', verdict: 'failed' });++ const res = await createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ verdict: 'failed',+ verifyRunId: 'run-1',+ });++ expect(modelMocks.createEvidence).not.toHaveBeenCalled();+ expect(res.evidence).toEqual([]);+ });++ it('requires either verifyRunId or operationId', async () => {+ await expect(+ createCaller().submitCheckEvidence({ checkItemId: 'item-1', verdict: 'passed' } as any),+ ).rejects.toThrow('Provide either `verifyRunId` or `operationId`.');+ });++ it('resolves the run from operationId when no verifyRunId is given', async () => {+ modelMocks.findRunByOperation.mockResolvedValueOnce({ id: 'run-9', plan: [] });+ modelMocks.upsertByCheckItem.mockResolvedValueOnce({ id: 'result-9' });++ await createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ operationId: 'op-1',+ verdict: 'passed',+ });++ expect(modelMocks.findRunByOperation).toHaveBeenCalledWith('op-1');+ expect(modelMocks.upsertByCheckItem).toHaveBeenCalledWith(+ expect.objectContaining({ verifyRunId: 'run-9' }),+ );+ });++ it('does NOT reset required/status on an evidence-only submit (no clobber)', async () => {+ modelMocks.findRunById.mockResolvedValueOnce({ id: 'run-1', plan: [] });+ modelMocks.upsertByCheckItem.mockResolvedValueOnce({ id: 'result-1' });++ await createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ evidence: [{ content: 'note', type: 'text' }],+ verifyRunId: 'run-1',+ });++ const arg = modelMocks.upsertByCheckItem.mock.calls[0][0];+ // Both omitted β drizzle preserves the existing row's values / DB defaults.+ expect(arg.required).toBeUndefined();+ expect(arg.status).toBeUndefined();+ });++ it('hydrates required/verifierType/title from the run plan item', async () => {+ modelMocks.findRunById.mockResolvedValueOnce({+ id: 'run-1',+ plan: [+ { id: 'item-1', index: 2, required: false, title: 'soft check', verifierType: 'llm' },+ ],+ });+ modelMocks.upsertByCheckItem.mockResolvedValueOnce({ id: 'result-1' });++ await createCaller().submitCheckEvidence({+ checkItemId: 'item-1',+ evidence: [{ content: 'note', type: 'text' }],+ verifyRunId: 'run-1',+ });++ expect(modelMocks.upsertByCheckItem).toHaveBeenCalledWith(+ expect.objectContaining({+ checkItemIndex: 2,+ checkItemTitle: 'soft check',+ required: false,+ verifierType: 'llm',+ }),+ );+ });+ });+describe('uploadEvidence', () => {it('rejects evidence with both inline content and fileId', async () => {await expect(diff --git a/apps/server/src/routers/lambda/verify.ts b/apps/server/src/routers/lambda/verify.tsindex 025fc2344cd..0e65a79342c 100644--- a/apps/server/src/routers/lambda/verify.ts+++ b/apps/server/src/routers/lambda/verify.ts@@ -1,4 +1,5 @@import { VerifySkill } from '@lobechat/builtin-skills';+import type { VerifyCheckItem } from '@lobechat/types';import { TRPCError } from '@trpc/server';import { asc, eq } from 'drizzle-orm';import { z } from 'zod';@@ -146,6 +147,18 @@ const resolveCheckResult = async (return result;};+/** Resolve a run from an Agent Run operation id β the handle a builder has in+ * the run-start gap, before any result rows (and thus checkResultIds) exist. */+const resolveRunByOperation = async (ctx: { runModel: VerifyRunModel }, operationId: string) => {+ const run = await ctx.runModel.findByOperation(operationId);++ if (!run) {+ throw new TRPCError({ code: 'NOT_FOUND', message: 'No verification run for this operation' });+ }++ return run;+};+export const verifyRouter = router({// ---- criteria (reusable atomic standards) ----createCriterion: verifyProcedure@@ -490,6 +503,101 @@ export const verifyRouter = router({});}),+ /**+ * Builder self-evidence contract: submit a check item's verdict AND its+ * evidence in one call. The check_result row is created lazily (idempotent+ * upsert on `(verifyRunId, checkItemId)`) so the builder doesn't need a+ * pre-existing `checkResultId` β solving the run-start handle gap. Evidence+ * is optional (attach mid-run) and verdict is optional (set later by review).+ */+ submitCheckEvidence: verifyProcedure+ .input(+ z+ .object({+ checkItemId: z.string(),+ checkItemIndex: z.number().optional(),+ checkItemTitle: z.string().optional(),+ confidence: z.number().min(0).max(1).optional(),+ evidence: z+ .array(+ z+ .object({+ capturedBy: evidenceCapturedBySchema.optional(),+ content: z.string().min(1).optional(),+ description: z.string().optional(),+ fileId: z.string().min(1).optional(),+ type: evidenceTypeSchema,+ })+ .refine((e) => Boolean(e.content) !== Boolean(e.fileId), {+ message: 'Provide exactly one of `content` or `fileId`.',+ }),+ )+ .optional(),+ // The builder may hold only its Agent Run operationId (run-start gap);+ // either handle resolves the session.+ operationId: z.string().optional(),+ required: z.boolean().optional(),+ status: checkStatusSchema.optional(),+ suggestion: z.string().optional(),+ toulmin: toulminSchema.optional(),+ verdict: verdictSchema.optional(),+ verifierType: verifierTypeSchema.optional(),+ verifyRunId: z.string().optional(),+ })+ .refine((d) => Boolean(d.verifyRunId) || Boolean(d.operationId), {+ message: 'Provide either `verifyRunId` or `operationId`.',+ }),+ )+ .mutation(async ({ ctx, input }) => {+ const run = input.verifyRunId+ ? await resolveVerifyRun(ctx, input.verifyRunId)+ : await resolveRunByOperation(ctx, input.operationId!);++ // `required` / `verifierType` / index / title are stable per plan item, so+ // hydrate them from the run plan rather than hardcoding defaults β otherwise+ // an evidence-only submit would flip a soft criterion to required:true on the+ // conflict-update. `status` is mutable lifecycle state: omit it when there's+ // 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 checkResult = await ctx.resultModel.upsertByCheckItem({+ checkItemId: input.checkItemId,+ checkItemIndex: input.checkItemIndex ?? planItem?.index,+ checkItemTitle: input.checkItemTitle ?? planItem?.title,+ completedAt: input.verdict ? new Date() : undefined,+ confidence: input.confidence,+ required: input.required ?? planItem?.required,+ status: input.status ?? (input.verdict ? statusForVerdict(input.verdict) : undefined),+ suggestion: input.suggestion,+ toulmin: input.toulmin,+ verdict: input.verdict,+ verifierType: input.verifierType ?? planItem?.verifierType ?? 'agent',+ verifyRunId: run.id,+ });++ const evidence = input.evidence?.length+ ? await Promise.all(+ input.evidence.map((e) =>+ ctx.evidenceModel.create({+ capturedAt: new Date(),+ capturedBy: e.capturedBy ?? null,+ checkResultId: checkResult.id,+ content: e.content ?? null,+ description: e.description ?? null,+ fileId: e.fileId ?? null,+ type: e.type,+ }),+ ),+ )+ : [];++ return { checkResult, evidence };+ }),+listEvidence: verifyProcedure.input(z.object({ checkResultId: z.string() })).query(async ({ ctx, input }) => {@@ -497,6 +605,19 @@ export const verifyRouter = router({return ctx.evidenceModel.listByCheckResult(result.id);}),+ deleteEvidence: verifyProcedure+ .input(z.object({ id: z.string() }))+ .mutation(async ({ ctx, input }) => {+ const evidence = await ctx.evidenceModel.findById(input.id);++ if (!evidence) {+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Verification evidence not found' });+ }++ await ctx.evidenceModel.delete(evidence.id);+ return { id: evidence.id, success: true };+ }),+upsertReport: verifyProcedure.input(z.object({diff --git a/apps/server/src/services/taskRunner/buildTaskPrompt.ts b/apps/server/src/services/taskRunner/buildTaskPrompt.tsindex 81f1cc50f05..63a71da1c06 100644--- a/apps/server/src/services/taskRunner/buildTaskPrompt.ts+++ b/apps/server/src/services/taskRunner/buildTaskPrompt.ts@@ -4,6 +4,8 @@ import type { TaskItem, TaskTopicHandoff, WorkspaceData } from '@lobechat/types'import type { BriefModel } from '@/database/models/brief';import type { TaskModel } from '@/database/models/task';import type { TaskTopicModel } from '@/database/models/taskTopic';+import { VerifyCriterionModel } from '@/database/models/verifyCriterion';+import { VerifyRubricModel } from '@/database/models/verifyRubric';import type { LobeChatDatabase } from '@/database/type';import { extractFileIdsFromEditorData } from '@/server/services/file/extractFileIdsFromEditorData';import { resolveAttachmentMetadata } from '@/server/services/file/resolveAttachments';@@ -152,6 +154,46 @@ export async function buildTaskPrompt(const taskFiles = toFileMetas(taskFileIds);+ // Delivery-acceptance (verify) context: resolve the task's verify config+ // (with parent inheritance) and the referenced criteria so the builder knows+ // what to self-evidence while it works. Run-time handles (verifyRunId /+ // checkItemId) don't exist yet at prompt-build time β the verify skill+ // resolves those at runtime from the builder's operationId.+ const verifyConfig = await taskModel.resolveVerifyConfig(task.id).catch(() => undefined);+ const verifyEnabled = !!verifyConfig && verifyConfig.enabled !== false;+ let verifyCriteria: Array<{+ required?: boolean;+ requiredEvidence?: Array<{ hint?: string; type: string }>;+ title: string;+ }> = [];+ if (verifyEnabled && (verifyConfig.verifyRubricId || verifyConfig.verifyCriteriaIds?.length)) {+ const criterionModel = new VerifyCriterionModel(db, userId, workspaceId);+ const rubricModel = new VerifyRubricModel(db, userId, workspaceId);+ const collected = (+ await Promise.all([+ verifyConfig.verifyRubricId+ ? rubricModel.getCriteria(verifyConfig.verifyRubricId).catch(() => [])+ : Promise.resolve([]),+ verifyConfig.verifyCriteriaIds?.length+ ? criterionModel.findByIds(verifyConfig.verifyCriteriaIds).catch(() => [])+ : Promise.resolve([]),+ ])+ ).flat();+ const seen = new Set<string>();+ verifyCriteria = collected+ .filter((c) => !seen.has(c.id) && seen.add(c.id))+ .map((c) => {+ const raw = (c.verifierConfig as Record<string, unknown> | null)?.requiredEvidence;+ return {+ required: c.required,+ requiredEvidence: Array.isArray(raw)+ ? (raw as Array<{ hint?: string; type: string }>)+ : undefined,+ title: c.title,+ };+ });+ }+const prompt = buildTaskRunPrompt({activities: {briefs: briefs.map((b: any) => ({@@ -212,6 +254,14 @@ export async function buildTaskPrompt(priority: task.priority,review: taskModel.getReviewConfig(task) as any,status: task.status,+ verify: verifyEnabled+ ? {+ criteria: verifyCriteria,+ enabled: true,+ maxIterations: verifyConfig?.maxIterations,+ requirement: verifyConfig?.requirement,+ }+ : undefined,subtasks: subtasks.map((s: any) => ({blockedBy: subtaskDepMap.get(s.id),identifier: s.identifier,diff --git a/packages/builtin-skills/src/verify/SKILL.md b/packages/builtin-skills/src/verify/SKILL.mdindex 9b9ee81e9ed..bf256de4c69 100644--- a/packages/builtin-skills/src/verify/SKILL.md+++ b/packages/builtin-skills/src/verify/SKILL.md@@ -4,8 +4,8 @@ description: >Self-evidence for task delivery verification. When you run a task that has averify plan, this skill is the full operating manual: what to prove, whichsurface to prove it on (CLI / web / desktop), how to drive that surface with- agent-browser, how to get past auth, and how to upload each artifact with- `lh verify upload-evidence` so the delivery is judged on real proof β not your+ agent-browser, how to get past auth, and how to submit each artifact with+ `lh verify submit` so the delivery is judged on real proof β not yourword that it works. Triggers on 'verify the task', 'collect evidence', 'proveit works', 'upload evidence', 'verify plan', 'requiredEvidence', or any runthat must self-certify its delivery.@@ -19,10 +19,10 @@ delivery against a **verify plan** β a list of criteria, some of which demanddeclares `requiredEvidence` **cannot pass on your text alone**: if the artifactis missing, the structural gate marks it `uncertain` and the delivery is held.-So while you do the work, capture the proof and upload it. The loop:+So while you do the work, capture the proof and submit it. The loop:```-discover plan β pick the surface β capture evidence per criterion β upload each β self-check coverage+discover plan β pick the surface β capture evidence per criterion β submit each β self-check coverage```Everything here is portable: the hard dependencies are the `lh` CLI (already@@ -40,24 +40,21 @@ no local report directory.then `agent-browser install` (downloads Chrome). Full reference:[references/agent-browser.md](references/agent-browser.md).-## Step 1 β Discover the plan (what to prove + where to attach)+## Step 1 β Discover the plan (what to prove)-Two reads, joined by `checkItemId`:+One read tells you what to prove:```bash-# (a) the frozen plan: each item's id, title, and required evidence typeslh verify plan state "$LOBE_OPERATION_ID" --json--# (b) the pending result rows: maps each checkItemId β checkResultId (the upload handle)-lh verify result list --operation "$LOBE_OPERATION_ID" --json```-From (a), each `verifyPlan[]` item carries `id` (the **checkItemId**), `title`,-`required`, and `verifierConfig.requiredEvidence` (`[{ type, hint }]` β the-artifacts you MUST capture). From (b), each row gives `checkItemId` β `id` (the-**checkResultId** you upload against). Join them so you have, per criterion: the-evidence types required and the checkResultId to attach them to. Exact shapes and-a worked join: [references/plan-format.md](references/plan-format.md).+Each `verifyPlan[]` item carries `id` (the **checkItemId**), `title`, `required`,+and `verifierConfig.requiredEvidence` (`[{ type, hint }]` β the artifacts you MUST+capture). The `checkItemId` is the only handle you need: `lh verify submit` (Step 3)+keys off it plus your operation id and creates the result row for you, so you do+**not** need a `checkResultId` up front. (Result rows generally don't exist yet at+this point β that's expected.) Exact shapes:+[references/plan-format.md](references/plan-format.md).> Only items with a non-empty `requiredEvidence` need an artifact. Items without> it are judged on the deliverable text alone β don't fabricate evidence.@@ -90,35 +87,42 @@ Rules of thumb:login, authenticate that η«― first or every capture lands on the sign-inpage. Recipes and boundaries: [references/auth.md](references/auth.md).-## Step 3 β Capture, then upload each artifact+## Step 3 β Capture, then submit each artifactCapture each required `type` (recipes per surface in-[references/evidence.md](references/evidence.md)), then upload one artifact per-call, attached to the criterion's `checkResultId`:+[references/evidence.md](references/evidence.md)), then submit one artifact per+call with the criterion's `checkItemId`. `lh verify submit` resolves your session+from the operation id, lazily creates/updates the result row, and attaches the+evidence β one call, no `checkResultId` needed:```bash-# CHECK_RESULT_ID is the checkResultId for this criterion (from Step 1).+# CHECK_ITEM_ID is the plan item id for this criterion (from Step 1).# file artifact (screenshot / dom / video)-lh verify evidence upload --check "$CHECK_RESULT_ID" --type screenshot \- --file ./proof/login.png --by agent-browser \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" \+ --type screenshot --file ./proof/login.png --by agent-browser \--desc "Logged-in home renders the workspace switcher"# inline text artifact (stdout / computed value) β no file-lh verify evidence upload --check "$CHECK_RESULT_ID" --type text \- --content "$(your-cli command --json)" --by cli \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" \+ --type text --content "$(your-cli command --json)" --by cli \--desc "command reports success after the change"````--by` records provenance: `agent-browser` | `cdp` | `cli` | `program`. Use-`--file` for binaries, `--content` for text β exactly one of them.+`--file` for binaries, `--content` for text β exactly one. Submit one artifact per+call; call again for each additional one (same `--item` reuses the row). Leave the+pass/fail **verdict** to the review step β only add `--verdict` if your task+explicitly asks you to self-assert the outcome.## Step 4 β Self-check coverage (do not skip)Before you declare the task done, prove every required artifact landed. For each-criterion with `requiredEvidence`, list what you uploaded and confirm each `type`-is present:+criterion with `requiredEvidence`, list what you submitted and confirm each `type`+is present. After submitting, the result rows exist, so map each `checkItemId` to+its `checkResultId` and list that row's evidence:```bash+lh verify result list --operation "$LOBE_OPERATION_ID" --json # checkItemId β checkResultIdlh verify evidence list "$CHECK_RESULT_ID" --json```@@ -136,22 +140,22 @@ Plan item: _"Settings page shows the new 'Beta features' toggle"_,```bashOP="$LOBE_OPERATION_ID"-# 1. discover: find this item's checkResultId-lh verify plan state "$OP" --json # β item id vci_settings, requires screenshot-lh verify result list --operation "$OP" --json # β { checkItemId: vci_settings, id: vcr_77 }+# 1. discover: find this item's checkItemId + required evidence+lh verify plan state "$OP" --json # β item id vci_settings, requires screenshot# 2. η«― = web (frontend change). Auth the session if needed (see references/auth.md).agent-browser --session app open "http://localhost:3000/settings"agent-browser --session app wait --text "Beta features"agent-browser --session app screenshot ./proof/settings-beta.png-# 3. upload against the handle-lh verify evidence upload --check vcr_77 --type screenshot \+# 3. submit: creates the result row + attaches the screenshot in one call+lh verify submit --operation "$OP" --item vci_settings --type screenshot \--file ./proof/settings-beta.png --by agent-browser \--desc "Settings page renders the new Beta features toggle"# 4. self-check-lh verify evidence list vcr_77 --json # β one screenshot present β 1/1 covered+lh verify result list --operation "$OP" --json # β { checkItemId: vci_settings, id: vcr_77 }+lh verify evidence list vcr_77 --json # β one screenshot present β 1/1 covered```## Portability rulesdiff --git a/packages/builtin-skills/src/verify/index.ts b/packages/builtin-skills/src/verify/index.tsindex efc5e031b3c..00efe6b2579 100644--- a/packages/builtin-skills/src/verify/index.ts+++ b/packages/builtin-skills/src/verify/index.ts@@ -21,7 +21,7 @@ export const VerifyIdentifier = 'verify';* depends only on the `lh` CLI and `agent-browser`, so any external builder* (Claude Code / Codex) can run it from a task's working directory: discover the* plan β pick a surface β capture evidence per criterion β `lh verify- * upload-evidence` β self-check coverage.+ * submit` β self-check coverage.** The references carry the full operating manual (agent-browser CLI, web vs* Electron decision + setup, auth recipes, capture recipes), with all@@ -35,7 +35,7 @@ export const VerifySkill: BuiltinSkill = {avatar: 'β ',content,description:- 'Self-evidence for task delivery verification β discover the verify plan, pick the right surface (CLI / web / desktop), drive it with agent-browser, get past auth, capture portable evidence per criterion, and upload each with `lh verify upload-evidence` so the delivery is judged on real proof.',+ 'Self-evidence for task delivery verification β discover the verify plan, pick the right surface (CLI / web / desktop), drive it with agent-browser, get past auth, capture portable evidence per criterion, and submit each with `lh verify submit` so the delivery is judged on real proof.',identifier: VerifyIdentifier,name: 'Verify',resources: toResourceMeta({diff --git a/packages/builtin-skills/src/verify/references/evidence.md b/packages/builtin-skills/src/verify/references/evidence.mdindex 4e21938f605..b1f29f79755 100644--- a/packages/builtin-skills/src/verify/references/evidence.md+++ b/packages/builtin-skills/src/verify/references/evidence.md@@ -43,7 +43,7 @@ Backend / CLI behavior is best proven by the command output itself β upload inno file:```bash-lh verify evidence upload --check "$CHECK_RESULT_ID" --type text \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type text \--content "$(your-cli command --json)" \--by cli --desc "command reports success after the change"```diff --git a/packages/builtin-skills/src/verify/references/plan-format.md b/packages/builtin-skills/src/verify/references/plan-format.mdindex 96e1ec4428d..66fcb721bce 100644--- a/packages/builtin-skills/src/verify/references/plan-format.md+++ b/packages/builtin-skills/src/verify/references/plan-format.md@@ -1,8 +1,10 @@# Verify plan β machine-readable formatThe plan is the contract between the task config and you, the builder. It is-exposed through two `lh` reads keyed off your operation id. This file documents-their shapes and how to join them into a per-criterion worklist.+exposed through `lh verify plan state` keyed off your operation id. This file+documents its shape and how to turn it into a per-criterion worklist. You submit+each criterion's evidence by its `checkItemId` β no separate upload handle to+resolve.## (a) `lh verify plan state $LOBE_OPERATION_ID --json`@@ -39,46 +41,41 @@ confirmed):- `hint` is guidance for what the artifact should show β it is not validated, butfollow it so the reviewer can recognize the proof.-## (b) `lh verify result list --operation $LOBE_OPERATION_ID --json`+## Your worklist β submit by checkItemId-Returns one pending **check result** row per plan item β these carry the upload-handle:+The plan (a) is all you need. For each `verifyPlan[]` item with non-empty+`requiredEvidence`, capture each `type` and submit it by `checkItemId`:++| checkItemId | title | requiredEvidence |+| ------------ | -------------------------------- | ---------------- |+| `vci_a1b2c3` | Login flow reaches the workspace | `screenshot` |++```bash+OP="$LOBE_OPERATION_ID"+lh verify submit --operation "$OP" --item vci_a1b2c3 --type screenshot \+ --file ./proof/home.png --by agent-browser --desc "β¦"+```++`lh verify submit` resolves the session from the operation id and **creates the+check-result row for you** (idempotent on `checkItemId`), then attaches the+evidence β there is no `checkResultId` to look up first.++## Self-check after submitting (optional)++Once you've submitted, the result rows exist. To confirm coverage, read them back+and list each row's evidence:```jsonc+// lh verify result list --operation "$OP" --json[{- "id": "vcr_x9y8z7", // checkResultId β pass this to upload-evidence+ "id": "vcr_x9y8z7", // checkResultId (created by submit)"checkItemId": "vci_a1b2c3", // joins back to verifyPlan[].id- "checkItemTitle": "Login flow reaches the workspace",- "required": true,- "status": "pending",+ "status": "running",},]```-If this returns rows with `status: "pending"`, the handles are ready. If it is-empty, the run did not pre-build result handles β surface that rather than-guessing an id.--## The join β your worklist--Join (a) and (b) on `checkItemId` to get, per criterion, _what to prove_ and-_where to attach it_:--| checkItemId | title | requiredEvidence | checkResultId |-| ------------ | -------------------------------- | ---------------- | ------------- |-| `vci_a1b2c3` | Login flow reaches the workspace | `screenshot` | `vcr_x9y8z7` |--For each row with non-empty `requiredEvidence`: capture each type, then-`lh verify evidence upload --check "$CHECK_RESULT_ID" --type TYPE β¦`.--To build the worklist, dump both reads and join them in your runtime:-```bash-OP="$LOBE_OPERATION_ID"-lh verify plan state "$OP" --json > /tmp/plan.json-lh verify result list --operation "$OP" --json > /tmp/results.json-# join on the id fields:-# plan: verifyPlan[].id == checkItemId-# result: [].checkItemId β [].id == checkResultId+lh verify evidence list "$CHECK_RESULT_ID" --json # confirm each required type is present```diff --git a/packages/builtin-skills/src/verify/references/recording.md b/packages/builtin-skills/src/verify/references/recording.mdindex 2ccdcaf6a04..359fa572564 100644--- a/packages/builtin-skills/src/verify/references/recording.md+++ b/packages/builtin-skills/src/verify/references/recording.md@@ -80,11 +80,11 @@ ffmpeg -y -i ./proof/demo.mp4 \## Upload```bash-lh verify evidence upload --check "$CHECK_RESULT_ID" --type gif \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type gif \--file ./proof/flow.gif --by agent-browser \--desc "Response streams in token-by-token after send"-lh verify evidence upload --check "$CHECK_RESULT_ID" --type video \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type video \--file ./proof/demo.mp4 --by cdp --desc "End-to-end import flow completes"```diff --git a/packages/builtin-skills/src/verify/surfaces/cli.md b/packages/builtin-skills/src/verify/surfaces/cli.mdindex 9fe5343098b..fb5f848d3e1 100644--- a/packages/builtin-skills/src/verify/surfaces/cli.md+++ b/packages/builtin-skills/src/verify/surfaces/cli.md@@ -17,20 +17,20 @@ only when the criterion is actually about rendered UI.for short output, or `--file` for a larger dump.```bash-# CHECK_RESULT_ID is the criterion's checkResultId (from discovery).+# CHECK_ITEM_ID is the criterion's plan item id (from `lh verify plan state`).# short result β inline-lh verify evidence upload --check "$CHECK_RESULT_ID" --type text \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type text \--content "$(your-cli command --json)" \--by cli --desc "command reports the new field after the change"# larger output (test log, full dump) β fileyour-cli command --json > ./proof/result.json-lh verify evidence upload --check "$CHECK_RESULT_ID" --type text \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type text \--file ./proof/result.json --by cli --desc "full result set"# a test run is itself proofyour-test-runner path/to/spec > ./proof/test.log 2>&1-lh verify evidence upload --check "$CHECK_RESULT_ID" --type text \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type text \--file ./proof/test.log --by program --desc "regression spec passes"```diff --git a/packages/builtin-skills/src/verify/surfaces/native.md b/packages/builtin-skills/src/verify/surfaces/native.mdindex ad45132539f..f8e0de5c705 100644--- a/packages/builtin-skills/src/verify/surfaces/native.md+++ b/packages/builtin-skills/src/verify/surfaces/native.md@@ -33,7 +33,7 @@ Upload as evidence (provenance `cli`, since osascript/screencapture areshell-driven):```bash-lh verify evidence upload --check "$CHECK_RESULT_ID" --type screenshot \+lh verify submit --operation "$LOBE_OPERATION_ID" --item "$CHECK_ITEM_ID" --type screenshot \--file ./proof/native-result.png --by cli \--desc "Native app shows the expected state after the change"```diff --git a/packages/database/src/models/verifyRun.ts b/packages/database/src/models/verifyRun.tsindex 91d520949e7..2c8c7a49386 100644--- a/packages/database/src/models/verifyRun.ts+++ b/packages/database/src/models/verifyRun.ts@@ -16,6 +16,10 @@ import { buildWorkspacePayload, buildWorkspaceWhere } from '../utils/workspace';export interface VerifyRunState {verifyPlan: VerifyCheckItem[] | null;verifyPlanConfirmedAt: Date | null;+ /** The session id β exposed so a builder holding only its operationId can+ * resolve the handle needed by `verify.submitCheckEvidence` before any+ * result rows exist (the run-start gap). */+ verifyRunId: string | null;verifyStatus: VerifyRunStatus | null;}@@ -24,6 +28,7 @@ const toState = (run: VerifyRunItem | null | undefined): VerifyRunState | null =? {verifyPlan: (run.plan ?? null) as VerifyCheckItem[] | null,verifyPlanConfirmedAt: run.planConfirmedAt ?? null,+ verifyRunId: run.id,verifyStatus: (run.status ?? null) as VerifyRunStatus | null,}: null;diff --git a/packages/prompts/src/prompts/task/index.test.ts b/packages/prompts/src/prompts/task/index.test.tsindex bff71f17c2d..6eaf7ef87cd 100644--- a/packages/prompts/src/prompts/task/index.test.ts+++ b/packages/prompts/src/prompts/task/index.test.ts@@ -296,6 +296,57 @@ describe('buildTaskRunPrompt', () => {expect(result).not.toContain('<activities>');});+ it('should render the verify delivery-acceptance section with criteria and evidence', () => {+ const result = buildTaskRunPrompt(+ {+ task: {+ id: 'task_root',+ identifier: 'TASK-1',+ instruction: 'ship the feature',+ status: 'running',+ verify: {+ criteria: [+ {+ required: true,+ requiredEvidence: [{ hint: 'full page', type: 'screenshot' }],+ title: 'login page renders',+ },+ { required: false, title: 'console is clean' },+ ],+ enabled: true,+ maxIterations: 2,+ requirement: 'the login flow works end to end',+ },+ },+ },+ NOW,+ );++ expect(result).toContain('Verify β delivery acceptance (maxIterations: 2)');+ expect(result).toContain('Requirement: the login flow works end to end');+ expect(result).toContain('login page renders (required)');+ expect(result).toContain('Β· evidence: screenshot β full page');+ expect(result).toContain('console is clean');+ expect(result).toContain('lh verify');+ });++ it('should omit the verify section when verify is disabled', () => {+ const result = buildTaskRunPrompt(+ {+ task: {+ id: 'task_root',+ identifier: 'TASK-1',+ instruction: 'ship the feature',+ status: 'running',+ verify: { criteria: [{ title: 'x' }], enabled: false, requirement: 'r' },+ },+ },+ NOW,+ );++ expect(result).not.toContain('Verify β delivery acceptance');+ });+it('should include subtasks in task section', () => {const result = buildTaskRunPrompt({diff --git a/packages/prompts/src/prompts/task/index.ts b/packages/prompts/src/prompts/task/index.tsindex 3505c298114..0068f7f4a33 100644--- a/packages/prompts/src/prompts/task/index.ts+++ b/packages/prompts/src/prompts/task/index.ts@@ -382,6 +382,17 @@ export interface TaskRunPromptInput {} | null;status: string;subtasks?: Array<TaskSummary & { blockedBy?: string }>;+ /** Delivery-acceptance criteria the builder must self-evidence while working. */+ verify?: {+ criteria?: Array<{+ required?: boolean;+ requiredEvidence?: Array<{ hint?: string; type: string }>;+ title: string;+ }>;+ enabled?: boolean;+ maxIterations?: number;+ requirement?: string;+ } | null;};/** Pinned documents (workspace) */workspace?: TaskRunPromptWorkspaceNode[];@@ -510,6 +521,33 @@ export const buildTaskRunPrompt = (input: TaskRunPromptInput, now?: Date): strintaskLines.push('Review: (not configured)');}+ // Verify β delivery acceptance (builder self-evidence)+ if (task.verify?.enabled && (task.verify.criteria?.length || task.verify.requirement)) {+ taskLines.push('');+ taskLines.push(+ `Verify β delivery acceptance (maxIterations: ${task.verify.maxIterations || 3}):`,+ );+ if (task.verify.requirement) {+ taskLines.push(` Requirement: ${task.verify.requirement}`);+ }+ if (task.verify.criteria && task.verify.criteria.length > 0) {+ taskLines.push(' Criteria β capture the listed evidence while you work:');+ for (const c of task.verify.criteria) {+ const flag = c.required === false ? '' : ' (required)';+ taskLines.push(` - ${c.title}${flag}`);+ for (const e of c.requiredEvidence ?? []) {+ taskLines.push(` Β· evidence: ${e.type}${e.hint ? ` β ${e.hint}` : ''}`);+ }+ }+ }+ taskLines.push(+ ' Use the `verify` skill to capture each artifact, then submit it with `lh verify',+ );+ taskLines.push(+ ' submit` (the skill resolves your verify run id and check item ids at runtime).',+ );+ }+// Workspaceif (workspace && workspace.length > 0) {const countNodes = (nodes: TaskRunPromptWorkspaceNode[]): number =>