From 6fb9a55974f02cc0fb1be010f7847bb020958213 Mon Sep 17 00:00:00 2001 From: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com> Date: Wed, 2 Dec 2026 17:52:58 +0800 Subject: [PATCH 1/2] Update web e2e tests for run guidance retirement Run guidance now returns 409, so the research-space feedback scenario posts discussion feedback that carries the run, task and observation context instead of guidance addressed to a task. The visitor's new-research submit needs a native team since #52. The fixture declares one only for that submit and resets it afterwards, so later scenarios keep the pipeline view. The visitor assertions now check personalExpertSelection and personalExperts and that no module plan is sent. On research pages the language switch sits inside the collapsed navigation menu at 390 px, so a helper opens the menu before clicking English. The skill-research fixture now uses an opencode harness, which selects file-loaded Skill research by default, and asserts the independent coordination sent to the worker. test-web-discussion-guidance.ts covered the retired guidance flow and is removed; the 2026-11-09 implementation note now says so. Co-Authored-By: Claude Opus 5.5 --- docs/collaborative-research-implementation.md | 2 +- scripts/e2e/test-web-discussion-guidance.ts | 811 ------------------ scripts/e2e/test-web-research-space.ts | 181 ++-- scripts/e2e/test-web-skill-research.ts | 19 +- 4 files changed, 74 insertions(+), 939 deletions(-) delete mode 100644 scripts/e2e/test-web-discussion-guidance.ts diff --git a/docs/collaborative-research-implementation.md b/docs/collaborative-research-implementation.md index 95631fd2..a558bc1f 100644 --- a/docs/collaborative-research-implementation.md +++ b/docs/collaborative-research-implementation.md @@ -151,4 +151,4 @@ bun scripts/build.ts --state-root /home/lzh/workspace/scratch/theorem-os/collabo | 最终镜像 | 772 个源文件与固定 Git blobs 相符;四个运行包、53 个内置库模块、十个工具核验通过;七个前端文件与本地验收构建摘要一致 | | 发布与公网 | 维护、排空、私有备份及 checksum 恢复、成对切换和健康/就绪/页面/API/静态摘要检查通过;维护关闭,三个匿名页面的桌面与 390px 手机布局六项通过,无页面脚本错误、溢出或写请求 | -功能源码为 `apps/web/client/researchDiscussionGuidance.tsx`,验收脚本为 `scripts/e2e/test-web-discussion-guidance.ts`。本轮证据位于 `/home/lzh/workspace/outputs/theoremos-discussion-guidance-20261109/`,入口为 `README.md` 与 `verification.json`。浏览器使用真实本地 HTTP、临时研究身份及模拟 Runner;未调用真实模型、未重新进行 Lean 编译或整题 S3 验收,原有 solver 回归结果保留为历史证据。独立数学 campaign、控制器和 next-runtime 保持各自会话所有权。 +功能源码为 `apps/web/client/researchDiscussionGuidance.tsx`,当时的验收脚本为 `scripts/e2e/test-web-discussion-guidance.ts`(运行指导退役、`POST /runs/:id/guidance` 返回 409 后已删除;讨论反馈及其运行/任务上下文由 `scripts/e2e/test-web-research-space.ts` 覆盖)。本轮证据位于 `/home/lzh/workspace/outputs/theoremos-discussion-guidance-20261109/`,入口为 `README.md` 与 `verification.json`。浏览器使用真实本地 HTTP、临时研究身份及模拟 Runner;未调用真实模型、未重新进行 Lean 编译或整题 S3 验收,原有 solver 回归结果保留为历史证据。独立数学 campaign、控制器和 next-runtime 保持各自会话所有权。 diff --git a/scripts/e2e/test-web-discussion-guidance.ts b/scripts/e2e/test-web-discussion-guidance.ts deleted file mode 100644 index 9dcc0cb3..00000000 --- a/scripts/e2e/test-web-discussion-guidance.ts +++ /dev/null @@ -1,811 +0,0 @@ -#!/usr/bin/env bun -import assert from 'node:assert/strict'; -import fs from 'node:fs/promises'; -import os from 'node:os'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import type { BrowserContext, Page, Route } from 'playwright'; -import { readWebConfig } from '../../apps/web/config'; -import { createWebService } from '../../apps/web/server'; -import type { WebRunner } from '../../apps/web/runner'; -import type { WebRunInput, WorkerMessage } from '../../apps/web/shared'; -import type { WebGuidanceInput, WebInspection, WebObservation } from '../../apps/web/collaboration'; -import type { - ResearchFeedback, - ResearchFeedbackInput, - ResearchProjectDetail, - ResearcherProfile, -} from '../../apps/web/researchProjectTypes'; -import { - deferred, - freePort, - postRun, - preferFullCollaboration, - settled, - startBrowser, - webScenario, - writeScenarioReport, - type ScenarioHarness, - type ScenarioSuite, -} from './web-scenario'; - -const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..'); -const output = path.join(root, 'out/web-discussion-guidance'); -await fs.access(path.join(root, 'out/web/research.js')); -await fs.mkdir(output, { recursive: true }); -const dataRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'theoremos-discussion-guidance-')); -const source = 'theorem discussion_fixture : True := by sorry\n', - credential = 'sk-local-discussion-guidance-fixture'; -const now = () => new Date().toISOString(), - digest = (letter: string) => letter.repeat(64); -type Guidance = Extract; -type Control = { observation: WebObservation; emit(): void }; -type Call = { method: string; pathname: string; body: string | null }; -type Harness = ScenarioHarness & { calls: Call[]; effect?: (route: Route) => Promise }; -const controls = new Map(); -const commands: { runId: string; guidance: WebGuidanceInput }[] = []; - -function observation(id: string): WebObservation { - const tasks = [ - { - id: 'lemma', - kind: 'lemma' as const, - objective: 'Prove the supporting fact with its assumptions', - dependsOn: [], - revision: 0, - theoremName: 'supporting_fact', - proofPath: 'Main.lean', - type: 'True', - }, - { - id: 'goal', - kind: 'goal' as const, - objective: 'Prove the original statement', - dependsOn: ['lemma'], - revision: 0, - theoremName: 'discussion_fixture', - proofPath: 'Main.lean', - type: 'True', - }, - ]; - const snapshot = { - schema: 'theoremos.run-observation.v1', - runId: `fixture-${id}`, - stateDigest: digest('a'), - resultDigest: null, - }; - const inspection: WebInspection = { - schema: 'deepscientist.math.inspection.v1', - runId: snapshot.runId, - snapshot, - evidence: 'recorded-not-replayed', - phase: 'cooperative', - problem: { - id: 'discussion-guidance-browser-fixture', - statement: 'Prove True', - formalStatement: 'True', - assumptions: [], - targets: [{ theoremName: 'discussion_fixture', proofPath: 'Main.lean' }], - }, - configuration: { - model: 'fixture', - effort: 'low', - workers: 2, - coordination: 'cooperative', - buildDigest: digest('b'), - environmentDigest: digest('e'), - }, - turns: 1, - planVersion: 'fixture-plan-v1', - scheduling: { - evidence: 'recorded-dispatch-state', - observedWorkers: 0, - working: 0, - proofAssignments: 0, - preparing: 0, - stopping: 0, - idle: 0, - stopped: 0, - }, - knowledge: { - status: 'disabled', - evidence: 'recorded-not-replayed', - attribution: 'model-reported-origin', - retrievalCoverage: 'recorded', - droppedRetrievals: 0, - retrievals: [], - originalUses: [], - uses: [], - }, - tokenBudget: {}, - continuation: {}, - mathematics: { - snapshot: { - schema: 'theorem-os.obligation.v1', - evidence: 'recorded-not-replayed', - acceptance: 'not-assessed', - digest: digest('c'), - obligations: [], - goals: [], - blockers: [], - routes: [], - advisory: [], - }, - recentChanges: [], - retainedChangeLimit: 64, - }, - progress: { - checkedProofTasks: 0, - conditionalProofTasks: 0, - completedResearchTasks: 0, - openProofTasks: ['lemma', 'goal'], - }, - groups: [], - tasks: tasks.map(task => ({ - id: task.id, - kind: task.kind, - objective: task.objective, - group: 'main', - status: 'pending', - control: 'active', - version: `${task.id}-v1`, - theorem: task.theoremName, - type: task.type, - premises: [], - plannedDependencies: task.dependsOn, - attempts: 0, - proof: { status: 'none' }, - parkedBy: [], - parkedRoutes: {}, - })), - workers: [], - statementReviews: [], - edits: [], - }; - return { - schema: 'theorem-os.web-observation.v1', - webRunId: id, - solverRunId: snapshot.runId, - observedAt: now(), - sequence: 1, - evidence: 'recorded-not-replayed', - acceptance: 'not-assessed', - snapshot, - inspection, - plan: { schema: 'deepscientist.math.plan-edit.v1', baseVersion: 'fixture-plan-v1', tasks }, - sources: [], - checks: [], - guidance: [], - coverage: { sources: 'partial', checks: 'partial' }, - }; -} -const runner: WebRunner = { - async readiness() { - return { ready: true, message: 'Disposable discussion guidance browser fixture; no model or Lean' }; - }, - async run(input, send: (message: WorkerMessage) => void, signal) { - await new Promise(resolve => { - const control: Control = { - observation: observation(input.id), - emit() { - this.observation.sequence++; - this.observation.observedAt = now(); - send({ type: 'observation', observation: structuredClone(this.observation) }); - }, - }; - controls.set(input.id, control); - signal.addEventListener('abort', () => resolve(), { once: true }); - control.emit(); - }); - }, - async command(runId, command) { - assert.equal(command.type, 'guidance', 'discussion conversion only sends mathematical guidance'); - if (command.type !== 'guidance') throw new Error('Unexpected non-guidance fixture command'); - commands.push({ runId, guidance: structuredClone(command.guidance) }); - const control = controls.get(runId)!; - const guidance = { - ...command.guidance, - status: 'delivered' as const, - deliveredTo: ['fixture-lead'], - createdAt: now(), - updatedAt: now(), - }; - control.observation.guidance.push(guidance); - control.emit(); - return { id: guidance.id, status: 'delivered', guidance, observation: structuredClone(control.observation) }; - }, -}; -const port = await freePort(), - origin = `http://127.0.0.1:${port}`; -const service = createWebService( - readWebConfig({ - THEOREMOS_WEB_PORT: String(port), - THEOREMOS_WEB_PUBLIC_URL: origin, - THEOREMOS_WEB_STATIC_ROOT: path.join(root, 'out/web'), - THEOREMOS_WEB_DATA_ROOT: dataRoot, - THEOREMOS_WEB_CONCURRENCY: '4', - }), - runner, -); -const browser = await startBrowser(service.server, port), - suite: ScenarioSuite = { origin, output, checks: [], failedScenario: '' }; -const input: WebRunInput = { - providerId: 'openai', - apiKey: credential, - model: 'fixture', - effort: 'low', - environment: 'standard', - source, - task: 'Review discussions through a fixed research run', - maxTurns: 2, - maxRunSeconds: 300, - workers: 2, - coordination: 'cooperative', -}; -const fixture: { - projectId?: string; - statementVersionId?: string; - runId?: string; - ownerId?: string; - authorId?: string; - ownerCookies?: Awaited>; - sources: Record; -} = { sources: {} }; -const projectPath = () => `/api/research/theorems/${fixture.projectId}`; -const feedbackPath = () => `${projectPath()}/feedback`; -const projectUrl = () => - `${origin}/theorems.html?${new URLSearchParams({ id: fixture.projectId!, run: fixture.runId!, version: fixture.statementVersionId! })}`; -const article = (page: Page, item: ResearchFeedback) => page.locator(`article#feedback-${item.id}`); -const sent = (h: Harness, item: ResearchFeedback) => - h.calls.filter( - call => - call.method === 'POST' && - call.pathname === feedbackPath() && - call.body && - JSON.parse(call.body).sourceFeedbackId === item.id, - ); -const reads = (h: Harness) => h.calls.filter(call => call.method === 'GET' && call.pathname === feedbackPath()); -async function httpResult( - page: Page, - method: string, - pathname: string, - body?: unknown, -): Promise<{ status: number; body: T }> { - return page.evaluate( - async ({ method, pathname, body }) => { - const session = await (await fetch('/api/session')).json(); - const response = await fetch(pathname, { - method, - headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'X-CSRF-Token': session.csrfToken }, - ...(body === undefined ? {} : { body: JSON.stringify(body) }), - }); - return { status: response.status, body: await response.json() }; - }, - { method, pathname, body }, - ) as Promise<{ status: number; body: T }>; -} -async function http(page: Page, method: string, pathname: string, body?: unknown) { - const result = await httpResult(page, method, pathname, body); - assert.ok( - result.status >= 200 && result.status < 300, - `Fixture ${method} ${pathname}: ${result.status} ${JSON.stringify(result.body)}`, - ); - return result.body; -} -async function request(page: Page, method: string, pathname: string, action: () => Promise) { - const result = page - .waitForResponse( - response => response.request().method() === method && new URL(response.url()).pathname === pathname, - ) - .then(async response => { - assert.ok(response.ok(), `${method} ${pathname}: ${response.status()}`); - return response.json(); - }); - await action(); - return result; -} -async function profile(page: Page, displayName: string) { - await page.goto(`${origin}/people.html`); - await page.locator('main.research-shell').waitFor(); - const session = await http<{ researcherId: string; profile: ResearcherProfile }>( - page, - 'GET', - '/api/research/session', - ); - await http(page, 'PUT', '/api/research/profile', { - requestId: crypto.randomUUID(), - expectedRevision: session.profile.revision, - displayName, - visibility: 'public', - }); - return session.researcherId; -} -async function discuss(page: Page, text: string, visibility: 'members' | 'public') { - const form = page.locator('form').filter({ has: page.getByLabel('讨论内容', { exact: true }) }); - await form.getByLabel('讨论内容', { exact: true }).fill(text); - await form.locator('select').selectOption(visibility); - const result = await request(page, 'POST', feedbackPath(), () => - form.getByRole('button', { name: '保存讨论', exact: true }).click(), - ); - await article(page, result.item).waitFor(); - return result.item as ResearchFeedback; -} -async function forward(page: Page, item: ResearchFeedback, recipient = 'lead') { - const details = article(page, item).locator('[data-forward-discussion]'); - if (!(await details.evaluate(node => (node as HTMLDetailsElement).open))) await details.locator('summary').click(); - const form = details.locator('[data-discussion-guidance-form]'); - await form.locator('[data-forward-run]').selectOption(fixture.runId!); - await form.locator('[data-forward-recipient] option[value="task:lemma"]').waitFor({ state: 'attached' }); - await form.locator('[data-forward-recipient]').selectOption(recipient); - await form.locator('button[type="submit"]:enabled').waitFor(); - return form; -} -async function fit(page: Page, name: string) { - await settled(page); - assert.equal( - await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), - true, - `${name} has no horizontal overflow`, - ); -} -function reviseLemma() { - const control = controls.get(fixture.runId!)!, - task = control.observation.inspection.tasks.find(task => task.id === 'lemma')!; - control.observation.history = [...(control.observation.history ?? []), structuredClone(task)]; - task.version = 'lemma-v2'; - task.objective = 'Prove the revised fact with explicit hypotheses'; - task.type = 'True ∧ True'; - control.observation.inspection.planVersion = 'fixture-plan-v2'; - control.observation.plan!.baseVersion = 'fixture-plan-v2'; - Object.assign( - control.observation.plan!.tasks.find(task => task.id === 'lemma')!, - { revision: 1, objective: task.objective, type: task.type }, - ); - control.observation.snapshot.stateDigest = digest('d'); - control.emit(); -} -async function feedbacks(page: Page) { - return (await http<{ items: ResearchFeedback[] }>(page, 'GET', feedbackPath())).items; -} -function scenario(name: string, run: (h: Harness) => Promise, setup = false) { - return webScenario(browser, suite, name, run, { - context: { viewport: { width: 1440, height: 1000 }, reducedMotion: 'reduce' }, - init: async context => { - if (!setup && fixture.ownerCookies) await context.addCookies(fixture.ownerCookies); - }, - harness: (page, context) => { - const h: Harness = { page, context, requests: [], calls: [] }; - h.intercept = async route => { - const request = route.request(), - pathname = new URL(request.url()).pathname; - h.calls.push({ - method: request.method(), - pathname, - body: pathname === feedbackPath() ? request.postData() : null, - }); - return (await h.effect?.(route)) ?? false; - }; - return h; - }, - routes: { local: 'Discussion guidance verification stays on the disposable local service' }, - timeout: { label: 'Discussion guidance', seconds: setup ? 100 : 55 }, - failure: { fullPage: true }, - verify: (h, elapsedMs) => ({ name, elapsedMs: elapsedMs(), calls: h.calls }), - }); -} - -try { - await scenario( - 'three identities preserve discussion authorship, forwarding permissions and public visibility', - async h => { - const { page, context } = h; - const others = await Promise.all([ - browser.newContext({ locale: 'zh-CN', viewport: { width: 1440, height: 1000 }, reducedMotion: 'reduce' }), - browser.newContext({ locale: 'zh-CN', viewport: { width: 390, height: 844 }, reducedMotion: 'reduce' }), - ]); - const errors: string[] = [], - external: string[] = []; - try { - for (const other of others) { - await preferFullCollaboration(other); - other.on('page', page => page.on('pageerror', error => errors.push(error.message))); - await other.route(/^https?:\/\//u, async route => { - if (new URL(route.request().url()).origin !== origin) { - external.push(route.request().url()); - await route.abort(); - } else await route.continue(); - }); - } - const author = await others[0].newPage(), - visitor = await others[1].newPage(); - fixture.ownerId = await profile(page, 'Fixture Forwarder A'); - fixture.authorId = await profile(author, 'Fixture Author B'); - const visitorId = await profile(visitor, 'Fixture Public Visitor C'); - assert.equal(new Set([fixture.ownerId, fixture.authorId, visitorId]).size, 3); - let project = ( - await http<{ item: ResearchProjectDetail }>(page, 'POST', '/api/research/theorems', { - requestId: crypto.randomUUID(), - title: 'Discussion to fixed run guidance', - visibility: 'public', - }) - ).item; - fixture.projectId = project.id; - project = ( - await http<{ item: ResearchProjectDetail }>(page, 'POST', `${projectPath()}/versions`, { - requestId: crypto.randomUUID(), - expectedRevision: project.revision, - statement: 'Prove True with explicit supporting assumptions.', - source, - environment: 'standard', - targets: [{ theoremName: 'discussion_fixture', proofPath: 'Main.lean' }], - confirmation: { confirmed: true }, - }) - ).item; - fixture.statementVersionId = project.currentStatementVersionId!; - project = ( - await http<{ item: ResearchProjectDetail }>(page, 'PUT', `${projectPath()}/members/${fixture.authorId}`, { - requestId: crypto.randomUUID(), - expectedRevision: project.revision, - role: 'reader', - }) - ).item; - const run = await postRun({ page }, input); - fixture.runId = run.id; - await http(page, 'POST', `${projectPath()}/runs`, { - requestId: crypto.randomUUID(), - expectedRevision: project.revision, - runId: run.id, - statementVersionId: fixture.statementVersionId, - exposure: 'public', - grants: { guidance: false }, - }); - await author.goto(projectUrl()); - await author.getByLabel('讨论内容', { exact: true }).waitFor(); - const authorsProject = (await http<{ item: ResearchProjectDetail }>(author, 'GET', projectPath())).item; - assert.equal(authorsProject.permissions.member, true); - assert.equal(authorsProject.runs[0].permissions.guidance, false); - for (const [key, text, visibility] of [ - ['members', 'Member discussion: retain the explicit assumptions before changing the proof route.', 'members'], - [ - 'public', - 'Public discussion: explain the dependency between the supporting fact and the original theorem.', - 'public', - ], - ['task', 'Task discussion: make the selected contract assumptions explicit.', 'members'], - ['lost', 'Recovery discussion: preserve the original request while checking a lost response.', 'members'], - ] as const) - fixture.sources[key] = await discuss(author, text, visibility); - assert.equal( - await author.locator('[data-forward-discussion]').count(), - 0, - 'a reader can discuss without permission to forward to a run', - ); - const forbidden = await httpResult(author, 'POST', feedbackPath(), { - requestId: crypto.randomUUID(), - kind: 'guidance', - sourceFeedbackId: fixture.sources.members.id, - text: 'A reader must not send run guidance.', - visibility: 'members', - recipient: { kind: 'lead' }, - target: { - runId: run.id, - statementVersionId: fixture.statementVersionId, - observationRef: { - sequence: controls.get(run.id)!.observation.sequence, - stateDigest: controls.get(run.id)!.observation.snapshot.stateDigest, - }, - }, - }); - assert.equal(forbidden.status, 403); - assert.equal(commands.length, 0); - - await page.goto(projectUrl()); - await article(page, fixture.sources.members).waitFor(); - const membersForm = await forward(page, fixture.sources.members); - assert.equal( - await membersForm.locator('[data-forward-text]').inputValue(), - fixture.sources.members.text, - 'forwarding starts from the original suggestion', - ); - assert.deepEqual( - await membersForm - .locator('[data-forward-visibility] option') - .evaluateAll(options => options.map(option => (option as HTMLOptionElement).value)), - ['members'], - ); - const membersText = 'Forwarded member guidance: review the original assumptions with the Lead.'; - await membersForm.locator('[data-forward-text]').fill(membersText); - const membersDerived = ( - await request(page, 'POST', feedbackPath(), () => - membersForm.getByRole('button', { name: '发送运行指导', exact: true }).click(), - ) - ).item as ResearchFeedback; - assert.equal(membersDerived.sourceFeedbackId, fixture.sources.members.id); - assert.equal(membersDerived.author.id, fixture.ownerId); - assert.equal(membersDerived.visibility, 'members'); - assert.equal(membersDerived.delivery.status, 'delivered'); - assert.equal((JSON.parse(sent(h, fixture.sources.members)[0].body!) as Guidance).visibility, 'members'); - assert.equal(commands.length, 1); - assert.deepEqual(commands[0].guidance.recipient, { kind: 'lead' }); - const derivedArticle = article(page, membersDerived); - await derivedArticle.locator('[data-feedback-source]').waitFor(); - assert.match(await derivedArticle.locator('.research-item-meta').first().innerText(), /Fixture Forwarder A/u); - assert.match(await derivedArticle.locator('[data-feedback-source]').innerText(), /Fixture Author B/u); - await article(page, fixture.sources.members) - .locator(`[data-feedback-forwards] a[href="#feedback-${membersDerived.id}"]`) - .click(); - await page.waitForFunction(id => location.hash === `#feedback-${id}`, membersDerived.id); - await derivedArticle - .locator(`[data-feedback-source] a[href="#feedback-${fixture.sources.members.id}"]`) - .click(); - await page.waitForFunction(id => location.hash === `#feedback-${id}`, fixture.sources.members.id); - assert.equal( - (await feedbacks(page)).find(item => item.id === fixture.sources.members.id)!.text, - fixture.sources.members.text, - ); - const publicAttempt = JSON.parse(sent(h, fixture.sources.members)[0].body!) as Guidance; - const protectedSource = await httpResult(page, 'POST', feedbackPath(), { - ...publicAttempt, - requestId: crypto.randomUUID(), - visibility: 'public', - }); - assert.equal(protectedSource.status, 403, 'a forged public conversion cannot reveal a members-only source'); - assert.equal(commands.length, 1); - - const publicForm = await forward(page, fixture.sources.public); - await publicForm.locator('[data-forward-visibility]').selectOption('public'); - await publicForm - .locator('[data-forward-text]') - .fill('Public forwarded guidance: explain and record the dependency choice.'); - const publicDerived = ( - await request(page, 'POST', feedbackPath(), () => - publicForm.getByRole('button', { name: '发送运行指导', exact: true }).click(), - ) - ).item as ResearchFeedback; - assert.equal(publicDerived.visibility, 'public'); - assert.equal(publicDerived.sourceFeedbackId, fixture.sources.public.id); - await author.reload(); - await article(author, membersDerived).locator('[data-feedback-source]').waitFor(); - assert.match( - await article(author, fixture.sources.members).locator('[data-feedback-forwards]').innerText(), - /Fixture Forwarder A/u, - ); - assert.match( - await article(author, membersDerived).locator('[data-feedback-source]').innerText(), - /Fixture Author B/u, - ); - assert.equal(await author.locator('[data-forward-discussion]').count(), 0); - await visitor.goto(projectUrl()); - await article(visitor, publicDerived).locator('[data-feedback-source]').waitFor(); - const publicRecords = await feedbacks(visitor); - assert.ok(publicRecords.some(item => item.id === fixture.sources.public.id)); - assert.ok(publicRecords.some(item => item.id === publicDerived.id)); - for (const secret of [fixture.sources.members, fixture.sources.task, fixture.sources.lost, membersDerived]) { - assert.equal( - publicRecords.some(item => item.id === secret.id), - false, - ); - assert.equal(await article(visitor, secret).count(), 0); - } - assert.equal(await visitor.locator('.collab-surface').count(), 0); - assert.equal(await visitor.locator('[data-forward-discussion]').count(), 0); - await fit(page, 'forwarding desktop'); - await page.screenshot({ path: path.join(output, 'forward-desktop.png'), fullPage: true }); - await visitor.getByRole('button', { name: 'English', exact: true }).click(); - await visitor.getByRole('heading', { name: 'Discussion to fixed run guidance', exact: true }).waitFor(); - await article(visitor, publicDerived) - .locator('[data-feedback-source]') - .getByText('View original suggestion', { exact: true }) - .waitFor(); - await fit(visitor, 'public English mobile'); - await visitor.screenshot({ path: path.join(output, 'public-en-mobile.png'), fullPage: true }); - fixture.ownerCookies = await context.cookies(); - assert.deepEqual(errors, []); - assert.deepEqual(external, []); - } finally { - await Promise.all(others.map(context => context.close())); - } - }, - true, - ); - - await scenario( - 'task version confirmation and a missing POST retry keep the exact original and newer draft separate', - async h => { - const { page } = h, - source = fixture.sources.task; - await page.goto(projectUrl()); - const form = await forward(page, source, 'task:lemma'); - const originalText = 'Task-specific original guidance for the revised lemma contract.'; - await form.locator('[data-forward-text]').fill(originalText); - reviseLemma(); - await form.locator('[data-forward-confirm-version]').waitFor(); - assert.equal(await form.locator('[data-forward-text]').inputValue(), originalText); - assert.equal( - await form.locator('button[type="submit"]').isDisabled(), - true, - 'a stale task target requires explicit confirmation', - ); - assert.match(await form.locator('[data-forward-version-issue]').innerText(), /lemma-v2/u); - await fit(page, 'task version confirmation'); - await page.screenshot({ path: path.join(output, 'task-version-desktop.png'), fullPage: true }); - await form.locator('[data-forward-confirm-version]').click(); - await form.locator('button[type="submit"]:enabled').waitFor(); - let aborted = false; - h.effect = async route => { - if ( - aborted || - route.request().method() !== 'POST' || - new URL(route.request().url()).pathname !== feedbackPath() - ) - return false; - if (JSON.parse(route.request().postData()!).sourceFeedbackId !== source.id) return false; - aborted = true; - await route.abort('failed'); - return true; - }; - const deliveredBefore = commands.length; - await form.getByRole('button', { name: '发送运行指导', exact: true }).click(); - await form.locator('[data-forward-retry]:enabled').waitFor(); - const originalBody = sent(h, source)[0].body!, - original = JSON.parse(originalBody) as Guidance; - assert.equal(original.target.taskRef!.version, 'lemma-v2'); - assert.equal(original.target.statementVersionId, fixture.statementVersionId); - assert.equal(original.sourceFeedbackId, source.id); - assert.equal(original.text, originalText); - assert.deepEqual(original.recipient, { kind: 'task', id: 'lemma' }); - assert.equal(commands.length, deliveredBefore); - assert.ok(reads(h).length >= 1, 'uncertain submission is checked with a real feedback GET'); - assert.equal( - (await feedbacks(page)).some(item => item.requestId === original.requestId), - false, - ); - const newerText = 'A newer Lead draft remains local while retrying the original task guidance.'; - await form.locator('[data-forward-text]').fill(newerText); - await form.locator('[data-forward-recipient]').selectOption('lead'); - assert.equal(await form.locator('button[type="submit"]').isDisabled(), true); - const writesBefore = sent(h, source).length; - await request(page, 'GET', feedbackPath(), () => form.locator('[data-forward-receipt]').click()); - await form.locator('[data-forward-retry]:enabled').waitFor(); - assert.equal(sent(h, source).length, writesBefore, 'manual receipt inspection does not post'); - const callCount = h.calls.length; - const accepted = await request(page, 'POST', feedbackPath(), () => form.locator('[data-forward-retry]').click()); - await form.locator('[data-forward-pending]').waitFor({ state: 'hidden' }); - assert.equal(sent(h, source).length, 2); - assert.equal(sent(h, source)[1].body, originalBody, 'retry reuses the entire original request body'); - assert.deepEqual( - h.calls - .slice(callCount) - .filter(call => call.pathname === feedbackPath()) - .map(call => call.method), - ['GET', 'POST'], - ); - assert.equal(accepted.item.requestId, original.requestId); - assert.equal(commands.length, deliveredBefore + 1); - assert.equal(commands.at(-1)!.guidance.taskRef!.version, 'lemma-v2'); - assert.equal(await form.locator('[data-forward-text]').inputValue(), newerText); - assert.equal(await form.locator('[data-forward-recipient]').inputValue(), 'lead'); - await form.locator('button[type="submit"]:enabled').waitFor(); - assert.equal( - (await feedbacks(page)).filter( - item => item.sourceFeedbackId === source.id && item.requestId === original.requestId, - ).length, - 1, - ); - await page.setViewportSize({ width: 390, height: 844 }); - await page.getByRole('button', { name: 'English', exact: true }).click(); - await page.getByRole('heading', { name: 'Discussion to fixed run guidance', exact: true }).waitFor(); - const english = await forward(page, source, 'lead'); - await english.getByRole('button', { name: 'Send run guidance', exact: true }).waitFor(); - assert.equal( - await article(page, source).locator('[data-forward-discussion] summary').innerText(), - 'Forward to a run', - ); - await fit(page, 'forward form English mobile'); - await page.screenshot({ path: path.join(output, 'forward-en-mobile.png'), fullPage: true }); - }, - ); - - await scenario( - 'a persisted POST with a lost response is recovered by GET without duplicating delivery or overwriting edits', - async h => { - const { page } = h, - source = fixture.sources.lost; - await page.goto(projectUrl()); - const form = await forward(page, source); - const text = 'An accepted Lead instruction whose response will be lost.'; - await form.locator('[data-forward-text]').fill(text); - // A same-text record from another source is a real response-list distractor, not a mocked GET. - const control = controls.get(fixture.runId!)!; - await http(page, 'POST', feedbackPath(), { - requestId: crypto.randomUUID(), - kind: 'guidance', - sourceFeedbackId: fixture.sources.members.id, - text, - visibility: 'members', - recipient: { kind: 'lead' }, - target: { - runId: fixture.runId, - statementVersionId: fixture.statementVersionId, - observationRef: { - sequence: control.observation.sequence, - stateDigest: control.observation.snapshot.stateDigest, - }, - }, - }); - const accepted = deferred(), - release = deferred(); - let dropped = false; - h.effect = async route => { - if ( - dropped || - route.request().method() !== 'POST' || - new URL(route.request().url()).pathname !== feedbackPath() - ) - return false; - if (JSON.parse(route.request().postData()!).sourceFeedbackId !== source.id) return false; - dropped = true; - const response = await route.fetch(); - assert.equal(response.status(), 201); - accepted.resolve(); - await release.promise; - await route.abort('failed'); - return true; - }; - const deliveredBefore = commands.length; - const newerText = 'New edited draft kept after the original Lead delivery is recovered.'; - try { - await form.getByRole('button', { name: '发送运行指导', exact: true }).click(); - await accepted.promise; - assert.equal(commands.length, deliveredBefore + 1); - await form.locator('[data-forward-text]').fill(newerText); - } finally { - release.resolve(); - } - await form.locator('[data-forward-pending]').waitFor({ state: 'hidden' }); - await form.locator('button[type="submit"]:enabled').waitFor(); - assert.equal(sent(h, source).length, 1, 'recovering a lost response sends no second write'); - assert.equal(commands.length, deliveredBefore + 1, 'the runner receives one delivery'); - assert.ok(reads(h).length >= 1, 'recovery uses the real feedback-list GET'); - assert.equal(await form.locator('[data-forward-text]').inputValue(), newerText); - const original = JSON.parse(sent(h, source)[0].body!) as Guidance; - const recovered = (await feedbacks(page)).filter( - item => - item.sourceFeedbackId === source.id && - item.author.id === fixture.ownerId && - item.requestId === original.requestId, - ); - assert.equal(recovered.length, 1); - assert.equal(recovered[0].text, text); - assert.equal(recovered[0].delivery.status, 'delivered'); - await article(page, recovered[0]).locator('[data-feedback-source]').waitFor(); - await fit(page, 'lost response recovery desktop'); - await page.screenshot({ path: path.join(output, 'recovered-response-desktop.png'), fullPage: true }); - }, - ); - await writeScenarioReport( - path.join(output, 'report.json'), - suite, - 'passed', - undefined, - 'real HTTP, three disposable research identities, mocked runner, no models or Lean', - { checks: suite.checks, deliveredCommands: commands.length }, - { credential }, - ); - console.log(`Discussion guidance browser checks passed: ${output}`); -} catch (error) { - await writeScenarioReport( - path.join(output, 'report.json'), - suite, - 'failed', - error, - 'real HTTP and disposable research identities with a mocked runner', - { checks: suite.checks, deliveredCommands: commands.length }, - { credential, failureRequests: true }, - ); - throw error; -} finally { - await browser.close(); - await service.close(); - await fs.rm(dataRoot, { recursive: true, force: true }); -} diff --git a/scripts/e2e/test-web-research-space.ts b/scripts/e2e/test-web-research-space.ts index 070aad8a..fe9e1c1c 100644 --- a/scripts/e2e/test-web-research-space.ts +++ b/scripts/e2e/test-web-research-space.ts @@ -12,7 +12,17 @@ import type { WorkerInput, WebRunInput, WorkerMessage } from '../../apps/web/sha import type { WebObservation, WebInspection } from '../../apps/web/collaboration'; import type { ResearchFeedback, ResearchProjectDetail, ResearcherProfile } from '../../apps/web/researchProjectTypes'; import type { ResearchAsset, ResearchPublication } from '../../apps/web/researchAssetTypes'; -import { closeSettings, openSettings } from './web-ui-controls'; +import { closeSettings, enterLean, openSettings } from './web-ui-controls'; + +// The runtime declares a native team only for the visitor's new-research submit; earlier steps keep the pipeline view. +let nativeTeam = false; + +/** Research headers keep the language switch inside the navigation menu, which is collapsed until opened. */ +async function switchToEnglish(page: Page) { + const english = page.getByRole('button', { name: 'English', exact: true }); + if (!(await english.isVisible())) await page.locator('[data-navigation-toggle]').click(); + await english.click(); +} import { freePort, postRun, @@ -81,8 +91,8 @@ function observation(id: string): WebObservation { configuration: { model: 'fixture', effort: 'low', - workers: 2, - coordination: 'cooperative', + workers: 1, + coordination: 'independent', buildDigest: hash('b'), environmentDigest: hash('e'), }, @@ -172,7 +182,8 @@ function observation(id: string): WebObservation { } const runner: WebRunner = { async readiness() { - return { ready: true, message: 'Disposable local research UI fixture' }; + // Native-team drafts are only accepted from a runtime that declares it; see `nativeTeam` above. + return { ready: true, nativeTeam, nativeTeamExpertCards: nativeTeam, message: 'Disposable local research UI fixture' }; }, async run(input, send, signal) { inputs.push(input); @@ -192,25 +203,8 @@ const runner: WebRunner = { }); }, async command(id, command) { - const control = controls.get(id); - assert.ok(control); - if (command.type === 'guidance') { - const guidance = { - ...command.guidance, - status: 'delivered' as const, - deliveredTo: ['fixture-lead'], - createdAt: now(), - updatedAt: now(), - }; - control.observation.guidance.push(guidance); - control.emit(); - return { - id: command.guidance.id, - status: 'delivered', - guidance, - observation: structuredClone(control.observation), - }; - } + assert.ok(controls.get(id)); + // Run guidance is retired, so no runner command is expected from these scenarios. throw new Error(`Unexpected fixture command: ${command.type}`); }, }; @@ -238,8 +232,9 @@ const runInput: WebRunInput = { task: 'Disposable collaboration fixture', maxTurns: 2, maxRunSeconds: 60, - workers: 2, - coordination: 'cooperative', + // Retired multi-worker coordination is rejected at creation; runs keep one independent worker. + workers: 1, + coordination: 'independent', }; const created: { projectId?: string; @@ -424,21 +419,7 @@ try { await collaborator.keyboard.press('Space'); await collaborator.getByRole('button', { name: '已关注', exact: true }).waitFor(); await collaborator.locator('[data-collab-task="lemma"]').first().click(); - await collaborator.locator('[data-collab-nav-guide]').click(); - assert.ok( - await collaborator.locator('.research-collaboration').evaluate(node => node.scrollTop > 0), - 'guidance navigation scrolls the research viewport', - ); - await collaborator - .locator('[data-guidance-text]') - .fill('Use the supporting fact and keep its assumptions explicit.'); - await request(collaborator, 'POST', `${projectPath}/runs/${ownRun.id}/guidance`, () => - collaborator.locator('[data-collab-guidance-form] button[type="submit"]').click(), - ); - await collaborator - .getByText('Use the supporting fact and keep its assumptions explicit.', { exact: true }) - .last() - .waitFor(); + // Run guidance is retired (409); the draft, selection and reading position must still survive a refresh. await collaborator.getByLabel('讨论内容', { exact: true }).fill('Draft retained while observations refresh.'); const readingTop = await collaborator.locator('.research-collaboration').evaluate(node => node.scrollTop); controls.get(ownRun.id)!.emit(); @@ -468,7 +449,7 @@ try { 'true', 'mobile research starts with the task list', ); - await collaborator.locator('[data-collab-section-picker]').selectOption('guidance'); + await collaborator.locator('[data-collab-section-picker]').selectOption('records'); assert.ok( await collaborator.locator('.research-collaboration').evaluate(node => node.scrollTop > 0), 'mobile navigation scrolls the research viewport', @@ -529,12 +510,13 @@ try { `/api/research/library/${created.assetId}`, ); assert.equal(downloaded.item.release?.license, 'MIT'); + nativeTeam = true; await visitor.getByRole('button', { name: '用于新研究', exact: true }).click(); - await visitor.locator('.composer-research-selection').waitFor(); - assert.ok( - (await visitor.locator('.composer-research-selection').innerText()).includes('Explicit assumptions Skill'), - ); + // The panel shows a loading line until the selected release is frozen into a configuration. + await visitor.locator('.composer-research-selection', { hasText: 'Explicit assumptions Skill' }).waitFor(); await ready(visitor); + // The workbench opens on the natural-language chat; the Lean composer owns #source and #submit-run. + await enterLean(visitor); await openSettings(visitor); await visitor.locator('#provider').selectOption('openai'); await visitor.locator('#model').fill('fixture'); @@ -549,18 +531,20 @@ try { const started = await request(visitor, 'POST', '/api/runs', () => visitor.locator('#submit-run:enabled').click(), ); + nativeTeam = false; const worker = inputs.find(input => input.id === started.run.id); - assert.ok(worker?.researchConfiguration); - assert.equal(worker.researchConfiguration.skills[0].ref.assetId, created.assetId); - assert.equal(worker.researchConfiguration.skills[0].ref.version, 'v1'); - assert.ok( - worker.researchConfiguration.modulePlan.custom.some(module => - module.instructions.includes('list the hypotheses'), - ), - ); + const configuration = worker?.researchConfiguration; + assert.ok(configuration); + // Codex drafts run as a native team, which freezes the Skill as a personal expert card, not a module plan. + assert.equal(configuration.personalExpertSelection?.skills?.[0]?.assetId, created.assetId); + assert.equal(configuration.personalExpertSelection?.skills?.[0]?.version, 'v1'); + assert.equal(configuration.personalExperts?.[0]?.name, 'Explicit assumptions Skill'); + assert.match(configuration.personalExperts![0]!.knowledge, /Keep assumptions visible/); + assert.equal(worker.input.modulePlan, undefined); const project = await http<{ item: ResearchProjectDetail }>(page, 'GET', projectPath); assert.equal(project.item.versions.length, 1); - assert.ok(project.item.feedback.some(item => item.kind === 'guidance' && item.author.id === b.researcherId)); + assert.ok(project.item.feedback.some(item => item.kind === 'discussion')); + assert.ok(project.item.feedback.every(item => item.kind !== 'guidance'), 'no run guidance is recorded'); created.thirdCookies = await others[1].cookies(); assert.deepEqual(errors, []); assert.deepEqual(external, []); @@ -620,12 +604,13 @@ try { const feedback = async (control: Control, text: string, taskId: string) => { const task = control.observation.inspection.tasks.find(task => task.id === taskId)!; return ( + // Run guidance is retired (409); discussion keeps the saved run/task context for routing and filtering. await http<{ item: ResearchFeedback }>(page, 'POST', `${projectPath}/feedback`, { requestId: crypto.randomUUID(), - kind: 'guidance', + kind: 'discussion', text, - recipient: { kind: 'task', id: task.id }, - target: { + statementVersionId, + context: { runId: control.observation.webRunId, statementVersionId, taskRef: { id: task.id, version: task.version }, @@ -676,14 +661,13 @@ try { status = page.locator('[data-feedback-status]'), search = page.locator('[data-feedback-search]'); const article = (item: ResearchFeedback) => page.locator(`article#feedback-${item.id}`); - const oldArticle = article(historical), - currentArticle = article(current); + const oldArticle = article(historical); const expectedAll = [historical, current, goal, other].map(item => `feedback-${item.id}`).sort(); assert.equal(await scope.inputValue(), 'all', 'the feedback workspace starts with the whole project'); await status.selectOption('all'); assert.deepEqual(await visibleFeedback(page), expectedAll); await oldArticle.getByText('记录采纳决定', { exact: true }).click(); - const reason = 'Keep the v1 rationale while adopting the explicitly linked v2 execution.'; + const reason = 'Keep the v1 rationale for the revised lemma.'; await oldArticle.getByLabel('理由', { exact: true }).fill(reason); const retainedArticle = (await oldArticle.elementHandle())!; await scope.selectOption('task'); @@ -734,12 +718,12 @@ try { await retainedArticle.evaluate((node, id) => node === document.getElementById(id), `feedback-${historical.id}`), true, ); - await oldArticle.getByLabel('证据引用,每行一项').fill('task:lemma@lemma-v2\ntask:goal@goal-v1'); + // Discussion has no bound run, so task evidence refs would be rejected; the rationale alone records the decision. const accepted = await request(page, 'POST', `${projectPath}/feedback/${historical.id}/decision`, () => oldArticle.getByRole('button', { name: '保存决定', exact: true }).click(), ); assert.equal(accepted.item.decision.status, 'accepted'); - assert.equal(accepted.item.execution.status, 'not-started'); + assert.equal(accepted.item.decision.reason, reason); await status.selectOption('accepted'); await oldArticle.waitFor({ state: 'visible' }); assert.deepEqual(await visibleFeedback(page), [`feedback-${historical.id}`]); @@ -747,45 +731,13 @@ try { await scope.selectOption('task'); assert.deepEqual( await visibleFeedback(page), - [historical, current].map(item => `feedback-${item.id}`).sort(), - 'an explicit execution reference can associate the older feedback with v2', + [`feedback-${current.id}`], + 'accepting older discussion does not move it to the revised task version', ); - await oldArticle.locator('.guidance-outcome-details > summary').click(); - const executionLinks = oldArticle.getByRole('link', { name: /^查看执行节点/u }); - assert.equal(await executionLinks.count(), 2, 'both recorded execution nodes can be inspected'); - for (const link of await executionLinks.all()) { - const target = new URL((await link.getAttribute('href'))!, page.url()); - assert.equal(target.searchParams.get('run'), run.id); - assert.equal(target.searchParams.get('version'), statementVersionId); - assert.ok( - ['lemma@lemma-v2', 'goal@goal-v1'].includes( - `${target.searchParams.get('task')}@${target.searchParams.get('taskVersion')}`, - ), - ); - } - await status.selectOption('executing'); - assert.deepEqual(await visibleFeedback(page), []); - const lemma = control.observation.inspection.tasks.find(task => task.id === 'lemma')!; - lemma.status = 'running'; - lemma.attempts = 1; - control.emit(); - await oldArticle.waitFor({ state: 'visible' }); - assert.deepEqual(await visibleFeedback(page), [`feedback-${historical.id}`]); - await status.selectOption('completed'); - assert.deepEqual(await visibleFeedback(page), []); - for (const task of control.observation.inspection.tasks) { - task.status = 'completed'; - task.proof = { status: 'checked' }; - } - control.observation.inspection.progress.openProofTasks = []; - control.observation.inspection.progress.checkedProofTasks = 2; - control.emit(); - await oldArticle.waitFor({ state: 'visible' }); - assert.deepEqual(await visibleFeedback(page), [`feedback-${historical.id}`]); assert.equal( - await currentArticle.evaluate(node => node instanceof HTMLElement && node.hidden), + await oldArticle.evaluate(node => node instanceof HTMLElement && node.hidden), true, - 'an unaccepted current suggestion is not completed by nearby task activity', + 'the accepted v1 discussion stays with v1', ); await fit(page, 'feedback desktop'); await page.screenshot({ path: path.join(output, 'feedback-route-desktop.png'), fullPage: true }); @@ -795,12 +747,14 @@ try { const timeline = page.locator(`a[href="#feedback-${historical.id}"]`).first(); await timeline.click(); assert.equal(new URL(page.url()).hash, `#feedback-${historical.id}`); - await oldArticle.getByText('查看对应节点', { exact: true }).click(); - await page.waitForURL( - url => url.searchParams.get('task') === 'lemma' && url.searchParams.get('taskVersion') === 'lemma-v1', + const returnContext = new URL( + (await oldArticle.locator('[data-discussion-return-context]').getAttribute('href'))!, + page.url(), ); - assert.equal(new URL(page.url()).searchParams.get('run'), run.id); - assert.equal(new URL(page.url()).searchParams.get('version'), statementVersionId); + assert.equal(returnContext.searchParams.get('run'), run.id); + assert.equal(returnContext.searchParams.get('task'), 'lemma'); + assert.equal(returnContext.searchParams.get('taskVersion'), 'lemma-v1', 'discussion keeps its saved version'); + await page.goto(href('lemma', 'lemma-v1')); await page.locator('[data-inspected-task-version]').filter({ hasText: 'lemma-v1' }).waitFor(); assert.match(await page.locator('[data-task-history-notice]').innerText(), /历史/u); assert.match( @@ -823,24 +777,17 @@ try { ); await fit(page, 'historical feedback mobile'); await page.screenshot({ path: path.join(output, 'feedback-route-mobile.png'), fullPage: true }); - const outcomeDetails = oldArticle.locator('.guidance-outcome-details'); - if (!(await outcomeDetails.evaluate(element => (element as HTMLDetailsElement).open))) - await outcomeDetails.locator(':scope > summary').click(); - const executionHref = await oldArticle - .getByRole('link', { name: /^查看执行节点/u }) - .evaluateAll(links => links.map(link => link.getAttribute('href')!)); - const toCurrent = executionHref.find(value => new URL(value, page.url()).searchParams.get('task') === 'lemma')!; - await oldArticle.locator(`a[href="${toCurrent}"]`).click(); - await page.waitForURL(url => url.searchParams.get('taskVersion') === 'lemma-v2'); + await page.goto(href('lemma', 'lemma-v2')); await page.locator('[data-inspected-task-version]').filter({ hasText: 'lemma-v2' }).waitFor(); - await page.getByRole('button', { name: 'English', exact: true }).click(); + await switchToEnglish(page); await page.getByRole('heading', { name: project.item.title, level: 1, exact: true }).waitFor(); assert.equal(await page.locator('html').getAttribute('lang'), 'en'); await status.selectOption('all'); await scope.selectOption('all'); - await oldArticle.getByText('View corresponding node', { exact: true }).waitFor(); - await oldArticle.locator('.guidance-outcome-details > summary').click(); - assert.equal(await oldArticle.getByRole('link', { name: /^View execution node/u }).count(), 2); + assert.match( + await oldArticle.locator('[data-discussion-return-context]').innerText(), + /Return to this step at the saved moment/u, + ); assert.ok((await page.locator('[data-feedback-summary]').innerText()).trim()); await fit(page, 'English feedback mobile'); await page.screenshot({ path: path.join(output, 'feedback-route-en-mobile.png'), fullPage: true }); @@ -916,7 +863,7 @@ try { assert.equal(await page.locator('.skip-link').evaluate(node => node === document.activeElement), true); await page.keyboard.press('Enter'); assert.equal(await page.locator('#main').evaluate(node => node === document.activeElement), true); - await page.getByRole('button', { name: 'English', exact: true }).click(); + await switchToEnglish(page); await page.locator('html[lang="en"]').waitFor(); assert.equal(await page.locator('html').getAttribute('lang'), 'en'); await fit(page, 'English mobile'); diff --git a/scripts/e2e/test-web-skill-research.ts b/scripts/e2e/test-web-skill-research.ts index a0cec643..93fc9553 100644 --- a/scripts/e2e/test-web-skill-research.ts +++ b/scripts/e2e/test-web-skill-research.ts @@ -54,6 +54,8 @@ function skillObservation(input: WorkerInput) { effort: input.input.effort, workers: 1, coordination: 'independent', + // Non-Codex runs only accept observations that name the harness they ran on. + agentHarness: { id: 'opencode', executableDigest: 'c'.repeat(64), configurationDigest: 'd'.repeat(64) }, researchMode: 'skill', researchSkill: { name: 'mathematical-research', digest: mathDigest('frozen-browser-skill'), loading: 'file' }, buildDigest: mathDigest('fixture-build'), @@ -134,7 +136,8 @@ const config = readWebConfig({ THEOREMOS_WEB_DATA_ROOT: dataRoot, THEOREMOS_WEB_CONCURRENCY: '2', }); -config.providers = [{ id: 'fixture', name: 'Offline fixture', baseUrl: 'http://127.0.0.1:1/v1' }]; +// A non-Codex harness selects file-loaded Skill research by itself; the mode selectors stay hidden. +config.providers = [{ id: 'fixture', name: 'Offline fixture', baseUrl: 'http://127.0.0.1:1/v1', harness: 'opencode' }]; const service = createWebService(config, runner), checks: object[] = [], suite: ScenarioSuite = { origin, output, checks, failedScenario: '' }; @@ -151,15 +154,15 @@ try { `skill-create-restore-artifacts-${language}-${width}`, async ({ page }) => { await enterLean(page); - assert.equal(await page.locator('#research-mode').inputValue(), 'legacy'); + assert.equal(await page.locator('#research-mode').inputValue(), 'skill'); + assert.equal(await page.locator('#skill-loading').inputValue(), 'file'); await fillConfig(page, 'source', 'namespace Research\ntheorem original : True := by sorry\nend Research\n'); await page.locator('#task').fill('Prove the original goal.'); await withSettings(page, async () => { - await page.locator('#research-mode').selectOption('skill'); - await page.locator('#skill-loading').selectOption('file'); assert.equal(await page.locator('#workers').inputValue(), '1'); assert.equal(await page.locator('#workers').isDisabled(), true); - assert.equal(await page.locator('input[name="coordination"]:checked').inputValue(), 'independent'); + // The hidden coordination radio keeps the session default; the server pins submissions to independent. + assert.equal(await page.locator('input[name="coordination"]:checked').isDisabled(), true); assert.equal(await page.locator('[data-settings-section="module-plan"]').isVisible(), false); assert.equal(await page.locator('.plan-approval-option').isVisible(), false); }); @@ -175,12 +178,7 @@ try { await page.locator('[data-draft-view="modules"]').click(); await page.locator('.module-skill-mode').waitFor(); assert.equal(await page.locator('.module-layout').isVisible(), false); - await withSettings(page, () => page.locator('#research-mode').selectOption('legacy')); - await showArtifacts(page); - await page.locator('.module-layout').waitFor(); await withSettings(page, async () => { - assert.equal(await page.locator('#workers').isDisabled(), false); - await page.locator('#research-mode').selectOption('skill'); await page.locator('#model').fill('offline-fixture'); await page.locator('#api-key').fill(credential); await page.locator('#max-turns').fill('2'); @@ -209,6 +207,7 @@ try { assert.equal(received.input.researchMode, 'skill'); assert.equal(received.input.skillLoading, 'file'); assert.equal(received.input.workers, 1); + assert.equal(received.input.coordination, 'independent'); assert.equal(received.input.modulePlan, undefined); await selectHistoryRun(page, runId, 'collaboration'); assert.equal(await page.locator('[data-collab-nav-guide]').isVisible(), false); From 013a4bb54604b545e17e35b04f8bb48d826cf996 Mon Sep 17 00:00:00 2001 From: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com> Date: Wed, 2 Dec 2026 18:39:04 +0800 Subject: [PATCH 2/2] Format test-web-research-space.ts with Prettier Co-Authored-By: Claude Opus 5.5 --- scripts/e2e/test-web-research-space.ts | 42 ++++++++++++++++---------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/scripts/e2e/test-web-research-space.ts b/scripts/e2e/test-web-research-space.ts index fe9e1c1c..68071028 100644 --- a/scripts/e2e/test-web-research-space.ts +++ b/scripts/e2e/test-web-research-space.ts @@ -183,7 +183,12 @@ function observation(id: string): WebObservation { const runner: WebRunner = { async readiness() { // Native-team drafts are only accepted from a runtime that declares it; see `nativeTeam` above. - return { ready: true, nativeTeam, nativeTeamExpertCards: nativeTeam, message: 'Disposable local research UI fixture' }; + return { + ready: true, + nativeTeam, + nativeTeamExpertCards: nativeTeam, + message: 'Disposable local research UI fixture', + }; }, async run(input, send, signal) { inputs.push(input); @@ -544,7 +549,10 @@ try { const project = await http<{ item: ResearchProjectDetail }>(page, 'GET', projectPath); assert.equal(project.item.versions.length, 1); assert.ok(project.item.feedback.some(item => item.kind === 'discussion')); - assert.ok(project.item.feedback.every(item => item.kind !== 'guidance'), 'no run guidance is recorded'); + assert.ok( + project.item.feedback.every(item => item.kind !== 'guidance'), + 'no run guidance is recorded', + ); created.thirdCookies = await others[1].cookies(); assert.deepEqual(errors, []); assert.deepEqual(external, []); @@ -605,22 +613,24 @@ try { const task = control.observation.inspection.tasks.find(task => task.id === taskId)!; return ( // Run guidance is retired (409); discussion keeps the saved run/task context for routing and filtering. - await http<{ item: ResearchFeedback }>(page, 'POST', `${projectPath}/feedback`, { - requestId: crypto.randomUUID(), - kind: 'discussion', - text, - statementVersionId, - context: { - runId: control.observation.webRunId, + ( + await http<{ item: ResearchFeedback }>(page, 'POST', `${projectPath}/feedback`, { + requestId: crypto.randomUUID(), + kind: 'discussion', + text, statementVersionId, - taskRef: { id: task.id, version: task.version }, - observationRef: { - sequence: control.observation.sequence, - stateDigest: control.observation.snapshot.stateDigest, + context: { + runId: control.observation.webRunId, + statementVersionId, + taskRef: { id: task.id, version: task.version }, + observationRef: { + sequence: control.observation.sequence, + stateDigest: control.observation.snapshot.stateDigest, + }, }, - }, - }) - ).item; + }) + ).item + ); }; const historical = await feedback( control,