The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Merge batch 11-03 b1940: #2573 #2804 (#2819)
0xken15672b33a893a4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b55d2856e..5caff6d75 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -400,6 +400,57 @@ jobs:- name: The Redis-backed tests ranrun: node scripts/redis-tests-ran.mjs vitest-results.json+ # The Super Tab integration suite (npm run test:super-tabs, backend/integration), which every backend PR once ran locally+ # for 60-90 minutes behind a per-Mac lock (task #2459). Four shards balanced by integration/ci-durations.json; each+ # integration file starts its own MongoDB replica set (mongodb-memory-server-core), so shards share no database, and the+ # suite opens no Redis (src/lib/noRedis.test-support.ts).+ backend-integration:+ concurrency:+ group: ci-${{ github.event_name }}-${{ github.event.action || 'run' }}-${{ github.event.pull_request.number || github.run_id }}-backend-integration-${{ strategy.job-index }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}+ needs: plan+ if: needs.plan.outputs.ready == 'true' && needs.plan.outputs.backend == 'true'+ name: backend-integration (${{ matrix.shard }})+ runs-on: ubuntu-latest+ timeout-minutes: 20+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4]+ defaults:+ run:+ working-directory: backend+ steps:+ - uses: actions/checkout@v7+ with:+ ref: ${{ env.CI_SOURCE_SHA }}+ - uses: actions/setup-node@v7+ with:+ node-version: 22.23.2+ cache: npm+ cache-dependency-path: backend/package-lock.json+ - run: npm ci --no-audit --no-fund+ # The tests download mongod 7.0.24 into $TMPDIR/harness-super-tab-mongodb-binaries (integration/plans.test-support.ts).+ - uses: actions/cache@v4+ with:+ path: /tmp/harness-super-tab-mongodb-binaries+ key: super-tab-mongod-7.0.24-${{ runner.os }}-${{ runner.arch }}+ - name: Super Tab integration shard+ env:+ SHARD: ${{ matrix.shard }}+ run: >-+ npx vitest run --config vitest.super-tabs.ci.config.ts --shard="$SHARD/4"+ --reporter=default --reporter=json --outputFile.json="$RUNNER_TEMP/integration-$SHARD.json"+ - name: Preserve per-file results (durations refresh integration/ci-durations.json)+ if: ${{ !cancelled() }}+ uses: actions/upload-artifact@v4+ with:+ name: backend-integration-${{ matrix.shard }}+ path: ${{ runner.temp }}/integration-${{ matrix.shard }}.json+ if-no-files-found: warn+ overwrite: true+ retention-days: 7+website-checks:concurrency:group: ci-${{ github.event_name }}-${{ github.event.action || 'run' }}-${{ github.event.pull_request.number || github.run_id }}-website-checks@@ -661,7 +712,7 @@ jobs:required:name: ci/requiredneeds: [plan, process-checks, desktop-tests, companion-subsystems, cli-typecheck, cli-tests, tui-test,- backend-desk, website-checks, os-checks, provider-checks, firmware-checks, pro-firmware-build, pro-golden,+ backend-desk, backend-integration, website-checks, os-checks, provider-checks, firmware-checks, pro-firmware-build, pro-golden,mobile-checks, daemons-checks, pty-checks]if: always()runs-on: ubuntu-latestdiff --git a/backend/integration/ci-durations.json b/backend/integration/ci-durations.jsonnew file mode 100644index 000000000..7dddb5c9e--- /dev/null+++ b/backend/integration/ci-durations.json@@ -0,0 +1,69 @@+{+ "schema": 1,+ "sourceRun": "https://github.com/autonomous-ai/openharness/actions/runs/41630351128",+ "sourceCommit": "7cc0bd0e5d8f08081de4d337e651a9b99d9cf269",+ "description": "Scheduling hints for backend-integration's shards (vitest.super-tabs.ci.config.ts): per-file durations from a passing CI run. Discovery always determines the complete test set.",+ "defaultDurationMs": 30000,+ "durationMs": {+ "integration/atlasSnapshot.test.ts": 500,+ "integration/communityReports.test.ts": 200,+ "integration/harnessSharesIndexPlan.test.ts": 100,+ "integration/harnessSharesList.test.ts": 8100,+ "integration/productUsageConflicts.test.ts": 500,+ "integration/productUsageReceipts.test.ts": 2800,+ "integration/queryStats.test.ts": 500,+ "integration/schemaRelease.test.ts": 15000,+ "integration/shareRaces.test.ts": 500,+ "integration/superTabActivity.test.ts": 1900,+ "integration/superTabAttemptModels.test.ts": 700,+ "integration/superTabAutoJoin.test.ts": 4300,+ "integration/superTabBuddies.test.ts": 22500,+ "integration/superTabBuddyProbes.test.ts": 4800,+ "integration/superTabBuddySessions.test.ts": 8500,+ "integration/superTabCache.test.ts": 4000,+ "integration/superTabCacheDelta.test.ts": 13800,+ "integration/superTabCommandLoads.test.ts": 1000,+ "integration/superTabCosts.test.ts": 3200,+ "integration/superTabDeletion.test.ts": 7000,+ "integration/superTabDeliveryCompaction.test.ts": 1900,+ "integration/superTabEvidence.test.ts": 6000,+ "integration/superTabFollowedThreads.test.ts": 10000,+ "integration/superTabGithub.test.ts": 11500,+ "integration/superTabGroupPlans.test.ts": 2000,+ "integration/superTabHostGroups.test.ts": 2000,+ "integration/superTabHotReads.test.ts": 3200,+ "integration/superTabInbox.test.ts": 28000,+ "integration/superTabIndexes.test.ts": 400,+ "integration/superTabInstructions.test.ts": 2100,+ "integration/superTabInvitationPlans.test.ts": 300,+ "integration/superTabLeaderboard.test.ts": 1200,+ "integration/superTabLegacyDrop.test.ts": 2400,+ "integration/superTabLiveness.test.ts": 105300,+ "integration/superTabMachineNames.test.ts": 1500,+ "integration/superTabMachineRemovals.test.ts": 900,+ "integration/superTabMachineReports.test.ts": 20300,+ "integration/superTabMessagePages.test.ts": 1500,+ "integration/superTabMigration.test.ts": 1000,+ "integration/superTabNamedReads.test.ts": 1000,+ "integration/superTabNotAvailable.test.ts": 2500,+ "integration/superTabNoticeDigest.test.ts": 26500,+ "integration/superTabObserver.test.ts": 1300,+ "integration/superTabProfile.test.ts": 3900,+ "integration/superTabRead.test.ts": 14700,+ "integration/superTabReadMarks.test.ts": 3500,+ "integration/superTabReflection.test.ts": 3300,+ "integration/superTabRouteDecisions.test.ts": 5000,+ "integration/superTabSharing.test.ts": 1100,+ "integration/superTabSwarmBuddy.test.ts": 21300,+ "integration/superTabTaskLines.test.ts": 900,+ "integration/superTabTeam.test.ts": 36400,+ "integration/superTabThreads.test.ts": 600,+ "integration/superTabTidy.test.ts": 24700,+ "integration/superTabWorkflow.test.ts": 600,+ "integration/superTabWorkspaces.test.ts": 5300,+ "integration/superTabs.test.ts": 92400,+ "integration/swarmSweepPlans.test.ts": 100,+ "integration/swarmSweepStarts.test.ts": 100,+ "integration/workerIndexPlans.test.ts": 400+ }+}diff --git a/backend/integration/superTabInbox.test.ts b/backend/integration/superTabInbox.test.tsindex c51a453b1..29952f459 100644--- a/backend/integration/superTabInbox.test.ts+++ b/backend/integration/superTabInbox.test.ts@@ -121,9 +121,12 @@ const personAuthor = (u: AuthUser): Author => ({ kind: 'person', id: u.sub, nameasync function insert(tabId: string, conversationId: string, rows: Array<{ id?: string; text: string; author: Author; thread?: string | null;source?: Record<string, unknown>; recipientIds?: string[]; mentions?: string[] }>) {const ids: string[] = []+ // One createMany, not a create per row: 5,001 creates outlasted Prisma's 5-second transaction limit on a CI runner+ // ("Transaction not found", task #2459), so the test's outcome depended on the machine's speed.await swarmTransaction(db, async tx => {const current = (await parts.loadActive(tx, tabId, { groupIds: [conversationId] })).groups.find(g => g.key === conversationId)!const data = structuredClone(current.data!) as Conversation+ const created: Prisma.SuperTabMessageCreateManyInput[] = []for (const row of rows) {const sequence = (data.messageSeq ?? 0) + 1const id = row.id ?? `m-${randomUUID()}`@@ -135,10 +138,11 @@ async function insert(tabId: string, conversationId: string, rows: Array<{ id?:data.lastActivityAt = new Date().toISOString()if (!row.thread || row.thread === id) data.lastMainSequence = sequence}- await tx.superTabMessage.create({ data: { id, tabId, conversationId, sequence, author: row.author as never, text: row.text,+ created.push({ id, tabId, conversationId, sequence, author: row.author as never, text: row.text,thread: row.thread === undefined ? id : row.thread, recipientIds: row.recipientIds ?? [], mentions: row.mentions ?? [],- ...(row.source ? { source: row.source as never } : {}), createdAt: new Date() } })+ ...(row.source ? { source: row.source as never } : {}), createdAt: new Date() })}+ await tx.superTabMessage.createMany({ data: created })await guardedWrite(tx, tabId, { op: 'update', kind: 'group', key: conversationId, seen: current.version, data }, Date.now())})return idsdiff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex e845037bc..8b3816dd6 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -247,6 +247,17 @@ describe('durable group pull request links', () => {return (group as unknown as { pullRequestUrls?: string[] }).pullRequestUrls}+ it('records a link under the project\'s repository and corrects the record it held before', async () => {+ const tab = (await store.create(owner, randomUUID(), 'Links')).id+ await run(tab, { type: 'tab.project', machineId: 'test-host', project: { cwd: '/work/project', repositoryUrl: null } })+ // Without a repository to judge by, a link is kept as written.+ await run(tab, message('Opened https://github.com/other/project/pull/50'))+ expect(await links(tab, 'lead')).toEqual(['https://github.com/other/project/pull/50'])+ await run(tab, { type: 'project.repository', projectId: 'lead', repositoryUrl: 'https://github.com/example/project' })+ await run(tab, message(`Again ${pr(50)}, and elsewhere https://github.com/example/other/pull/51`))+ expect(await links(tab, 'lead')).toEqual([pr(50)])+ })+it('keeps one link beyond the latest 100 messages', async () => {const { tab } = await fixture()await run(tab, message(`Review ${pr(41)}`))diff --git a/backend/src/lib/ciShards.test.ts b/backend/src/lib/ciShards.test.tsnew file mode 100644index 000000000..06bff4cfa--- /dev/null+++ b/backend/src/lib/ciShards.test.ts@@ -0,0 +1,39 @@+import { describe, expect, it } from 'vitest'+import { durationShards, readTimingHints } from './ciShards.js'++const entry = (key: string, durationMs: number) => ({ key, durationMs, value: key })++describe('CI shards of the Super Tab integration suite (task #2459)', () => {+ it('puts every file in exactly one shard, longest first onto the least-loaded shard', () => {+ const files = [entry('a', 100), entry('b', 600), entry('c', 300), entry('d', 300), entry('e', 200), entry('f', 100)]+ const shards = durationShards(files, 4)+ expect(shards).toEqual([['b'], ['c', 'f'], ['d'], ['e', 'a']])+ expect(shards.flat().sort()).toEqual(['a', 'b', 'c', 'd', 'e', 'f'])+ })++ it('splits evenly enough that no shard holds more than the longest file over its fair share', () => {+ const files = Array.from({ length: 61 }, (_, i) => entry(`f${i}`, ((i * 7919) % 97 + 1) * 1000))+ const shards = durationShards(files, 4)+ const cost = (names: string[]) => names.reduce((sum, name) => sum + files.find(f => f.key === name)!.durationMs, 0)+ const total = cost(files.map(f => f.key))+ for (const shard of shards) expect(cost(shard)).toBeLessThanOrEqual(total / 4 + 97000)+ expect(shards.flat()).toHaveLength(61)+ })++ it('gives more shards than files empty shards, and refuses duplicates or bad counts', () => {+ expect(durationShards([entry('a', 1)], 3)).toEqual([['a'], [], []])+ expect(() => durationShards([entry('a', 1), entry('a', 2)], 2)).toThrow('duplicate')+ expect(() => durationShards([entry('a', 0)], 2)).toThrow('Invalid')+ expect(() => durationShards([entry('a', 1)], 0)).toThrow('positive')+ })++ it('reads hints for integration files only; unknown files are left to the default cost', () => {+ const hints = readTimingHints({ schema: 1, defaultDurationMs: 30000, durationMs: { 'integration/superTabs.test.ts': 400000 } })+ expect(hints.durationMs['integration/superTabs.test.ts']).toBe(400000)+ expect(hints.defaultDurationMs).toBe(30000)+ expect(() => readTimingHints({ schema: 2, defaultDurationMs: 1, durationMs: {} })).toThrow('Invalid')+ expect(() => readTimingHints({ schema: 1, defaultDurationMs: 1, durationMs: { 'src/a.test.ts': 5 } })).toThrow('src/a.test.ts')+ expect(() => readTimingHints({ schema: 1, defaultDurationMs: 1, durationMs: { 'integration/../x.test.ts': 5 } })).toThrow()+ expect(() => readTimingHints({ schema: 1, defaultDurationMs: 1, durationMs: { 'integration/a.test.ts': -1 } })).toThrow()+ })+})diff --git a/backend/src/lib/ciShards.ts b/backend/src/lib/ciShards.tsnew file mode 100644index 000000000..6c742e565--- /dev/null+++ b/backend/src/lib/ciShards.ts@@ -0,0 +1,65 @@+// CI shards of the Super Tab integration suite (backend/vitest.super-tabs.ci.config.ts, task #2459): files are spread over+// the four runners by their recorded durations (backend/integration/ci-durations.json), longest first onto the least-loaded+// shard, as the CLI's vitest.ci.config.ts does (the backend may not import CLI code). Hints never select tests: the+// config's complete discovery list is the only source of files, a new file gets the default cost, and a stale hint for a+// removed file adds nothing.+import { readFileSync } from 'node:fs'+import { relative } from 'node:path'+import { BaseSequencer, type TestSpecification } from 'vitest/node'++export type TimingHints = { defaultDurationMs: number; durationMs: Record<string, number> }++const HINT_PATH = /^integration\/[A-Za-z0-9._/-]+\.test\.ts$/++export function readTimingHints(value: unknown): TimingHints {+ const raw = value as { schema?: unknown; defaultDurationMs?: unknown; durationMs?: unknown } | null+ const positive = (n: unknown): n is number => typeof n === 'number' && Number.isFinite(n) && n > 0+ if (raw?.schema !== 1 || !positive(raw.defaultDurationMs) || !raw.durationMs+ || typeof raw.durationMs !== 'object' || Array.isArray(raw.durationMs)) {+ throw new Error('Invalid integration test timing hints')+ }+ for (const [path, duration] of Object.entries(raw.durationMs)) {+ if (!HINT_PATH.test(path) || path.split('/').includes('..') || !positive(duration)) {+ throw new Error(`Invalid integration test timing hint: ${path}`)+ }+ }+ return { defaultDurationMs: raw.defaultDurationMs, durationMs: raw.durationMs as Record<string, number> }+}++export function durationShards<T>(entries: Array<{ key: string; durationMs: number; value: T }>, count: number): T[][] {+ if (!Number.isSafeInteger(count) || count < 1) throw new Error('Shard count must be a positive integer')+ const keys = new Set<string>()+ for (const entry of entries) {+ if (keys.has(entry.key)) throw new Error(`Invalid duplicate shard entry: ${entry.key}`)+ if (!Number.isFinite(entry.durationMs) || entry.durationMs <= 0) throw new Error(`Invalid shard entry: ${entry.key}`)+ keys.add(entry.key)+ }+ const shards = Array.from({ length: count }, () => ({ cost: 0, values: [] as T[] }))+ const ordered = [...entries].sort((a, b) => b.durationMs - a.durationMs || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))+ for (const entry of ordered) {+ const next = shards.reduce((best, shard) => shard.cost < best.cost+ || (shard.cost === best.cost && shard.values.length < best.values.length) ? shard : best)+ next.cost += entry.durationMs+ next.values.push(entry.value)+ }+ return shards.map(shard => shard.values)+}++/** A Vitest sequencer that shards by [hints]; unsharded runs keep Vitest's default behavior. */+export function createDurationSequencer(hints: TimingHints): typeof BaseSequencer {+ return class extends BaseSequencer {+ override async shard(files: TestSpecification[]): Promise<TestSpecification[]> {+ const shard = this.ctx.config.shard+ if (!shard) return files+ const entries = files.map(spec => {+ const path = relative(this.ctx.config.root, spec.moduleId).replaceAll('\\', '/')+ return { key: `${spec.project.name}\0${spec.pool}\0${path}`, durationMs: hints.durationMs[path] ?? hints.defaultDurationMs, value: spec }+ })+ return durationShards(entries, shard.count)[shard.index - 1]!+ }+ }+}++export function readTimingHintsFile(path: string): TimingHints {+ return readTimingHints(JSON.parse(readFileSync(path, 'utf8')))+}diff --git a/backend/src/superTabs/cards.ts b/backend/src/superTabs/cards.tsindex 11f435cf1..9525e7ed9 100644--- a/backend/src/superTabs/cards.ts+++ b/backend/src/superTabs/cards.ts@@ -1,4 +1,4 @@-import { agentOnly, pullRequestLinks, type Conversation, type MessageDraft } from './model.js'+import { agentOnly, appendPullRequestUrls, projectPullRequestUrl, pullRequestLinks, type Conversation, type MessageDraft } from './model.js'/*** Live cards (Slack parity, Dee 10-29): like a Slack app's message that updates itself, a task or a pull request is one@@ -28,10 +28,10 @@ export function bindTaskCard(group: Conversation, brief: MessageDraft): void {/** A main-chat row linking a pull request this group has no card for becomes its card. A thread reply or an agent-only* notice never does: people read the main chat. */-export function bindPullRequestCards(group: Conversation, message: MessageDraft): void {+export function bindPullRequestCards(group: Conversation, message: MessageDraft, repositoryUrl?: string | null): void {if (message.thread || agentOnly(message.source, message.recipients) || !cardable(message)) returnconst known = new Set(group.cards?.pullRequests?.map(card => card.url))- const fresh = pullRequestLinks(message.text).filter(url => !known.has(url))+ const fresh = pullRequestLinks(message.text, repositoryUrl).filter(url => !known.has(url))if (fresh.length) group.cards = { ...group.cards, pullRequests: [...group.cards?.pullRequests ?? [], ...fresh.map(url => ({ url, messageId: message.id }))] }}@@ -45,3 +45,21 @@ export function recordCardMerged(group: Conversation, url: string, mergedAt: numconst card = pullRequestCard(group, url)if (card) card.mergedAt = Math.min(card.mergedAt ?? mergedAt, mergedAt)}++/** Every link [group] holds is its project's own pull request, once: a link into any other repository (another owner's+ * included) is dropped, a spelling is made the project's, and cards that now name one pull request become one (the earliest+ * message, the earliest merge). */+export function cleanPullRequestLinks(group: Conversation, repositoryUrl: string | null | undefined): void {+ if (group.pullRequestUrls) appendPullRequestUrls(group, [], repositoryUrl)+ const cards = group.cards?.pullRequests+ if (!cards?.some(card => projectPullRequestUrl(card.url, repositoryUrl) !== card.url)) return+ const kept = new Map<string, PullRequestCard>()+ for (const card of cards) {+ const url = projectPullRequestUrl(card.url, repositoryUrl)+ if (!url) continue+ const known = kept.get(url)+ if (!known) kept.set(url, { ...card, url })+ else if (card.mergedAt !== undefined) known.mergedAt = Math.min(known.mergedAt ?? card.mergedAt, card.mergedAt)+ }+ group.cards = { ...group.cards, pullRequests: [...kept.values()] }+}diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex 940b39942..2a6fe197d 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -6,7 +6,7 @@ import { keepUsernames, setUsername, swarmUsernames, usernameOf } from './usernaimport { z } from 'zod'import { tokensByModelSchema } from './costs/tokens.js'import {- activeWork, actorKey, agent, appendPullRequestUrls, author, conversation, crossProjectActive, fail, isLeads, person, stableId, numberConversations, nextConversationNumber, renderWorkTask,+ activeWork, actorKey, agent, appendPullRequestUrls, author, projectPullRequestUrl, conversation, crossProjectActive, fail, isLeads, person, stableId, numberConversations, nextConversationNumber, renderWorkTask,finishWorker, seenMachineIds, SuperTabError, swarmGridName, visibleState, AGENT_ONLY, STATUS_LABELS, forRecipients,type Actor, type AgentConfiguration, type AgentStart, type AgentStartRequest, type BuddySessionEntry, type WorkTask, type Agent, type Author, type Check, type CommandEffects, type Conversation, type SuperTabState,} from './model.js'@@ -34,13 +34,14 @@ import { fixedOriginal, LEDGER_WEEKS, PULL_REQUEST_URL, recordAsked, recordFix,recordReportedModel, recordVerdict } from './leaderboard/record.js'import { WEEK_MS } from './leaderboard/week.js'import { react, reactionSchema, type ReactionTarget } from './reactions.js'+import { githubRepository } from '../github/repository.js'import { shippedAt } from './ship.js'import { syncTaskLines } from './taskLine.js'import { assignedNotice, tellBuddies } from './buddyNews.js'import { bindPullRequestCards, bindTaskCard, pullRequestCard, recordCardMerged } from './cards.js'import { avatarChoice, setAgentAvatar, setMemberAvatar, setStatus, statusSchema, type AvatarUpload } from './profile.js'import { cancelledTags, cancelReason, switchExpired, unfinishedWork } from './tidy.js'-import { BUILT_IN_ROLE_DEFAULTS, agentProjectId, audienceOf, canReadProject, deleteProject, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectAgent, projectMembers, projectOf, projectsOf, readAgent, readConversation, readProject, requestedByLine, sameProject, sharedWithLeads, withRoleDefaults, type SwarmProject, PROJECT_STATUS_MAX } from './projects.js'+import { BUILT_IN_ROLE_DEFAULTS, agentProjectId, audienceOf, groupRepositoryUrl, canReadProject, deleteProject, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectAgent, projectMembers, projectOf, projectsOf, readAgent, readConversation, readProject, requestedByLine, sameProject, sharedWithLeads, withRoleDefaults, type SwarmProject, PROJECT_STATUS_MAX } from './projects.js'import { recordClosing } from './closedAgents.js'import { declinedWith, declinedWithout } from './sharing.js'import { actorLabel, memberChanges, memberRowText, quotedName } from './memberRows.js'@@ -2005,21 +2006,25 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,// One refusal for every link it cannot take, so a link never tells what another project or a private chat holds.const original = command.fixes === undefined ? undefined : fixedOriginal(state, group, command.fixes, mergedAt)?? fail('FIX_LINK', 'No merged pull request in this project matches that link within the last 14 days.', 400)- const shippedAt = group.ledger?.shippedAt, linked = group.pullRequestUrls?.includes(command.pullRequestUrl)- appendPullRequestUrls(group, [command.pullRequestUrl])+ // Only the project's own pull requests are recorded: a link into any other repository, another owner's included, is refused.+ const repositoryUrl = groupRepositoryUrl(state, group), own = githubRepository(repositoryUrl)+ const pullRequestUrl = projectPullRequestUrl(command.pullRequestUrl, repositoryUrl)+ ?? fail('PULL_REQUEST_REPOSITORY', `This pull request is not in the project's repository (${own!.fullName}).`, 400)+ const shippedAt = group.ledger?.shippedAt, linked = group.pullRequestUrls?.includes(pullRequestUrl)+ appendPullRequestUrls(group, [pullRequestUrl], repositoryUrl)recordMerged(group, mergedAt)// Like a Slack app's update: the card shows the merge, and the line goes in the card's thread, once per pull request.// Without a card yet, the group's first ship or a new link still says so, and the line becomes the card. A fix of an// earlier merge says so once more.const fixed = original ? recordFix(original, group, mergedAt) : false- const card = pullRequestCard(group, command.pullRequestUrl)+ const card = pullRequestCard(group, pullRequestUrl)if (fixed || (card ? card.mergedAt === undefined : !linked || group.ledger!.shippedAt !== shippedAt)) {- message(group.id, `Merged ${command.pullRequestUrl}${original ? `, a fix of ${command.fixes}` : ''}`, [], card?.messageId ?? null, SYSTEM_ROW)+ message(group.id, `Merged ${pullRequestUrl}${original ? `, a fix of ${command.fixes}` : ''}`, [], card?.messageId ?? null, SYSTEM_ROW)const posted = effects.messages.at(-1)!if (card) posted.thread = card.messageId- else bindPullRequestCards(group, posted)+ else bindPullRequestCards(group, posted, repositoryUrl)}- recordCardMerged(group, command.pullRequestUrl, mergedAt)+ recordCardMerged(group, pullRequestUrl, mergedAt)break}case 'conversation.archive': {@@ -3197,7 +3202,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,...(!coordinator && short.mentions.length ? { mentions: short.mentions } : {}) })// The task's line says it shipped (taskLine.ts), in place of the Shipped line; its links are kept as that line's were.if (command.status === 'done' && shippedAt(conversation(original, group.id)) == null) {- appendPullRequestUrls(group, [command.result, ...group.checks.map(check => check.evidence)])+ appendPullRequestUrls(group, [command.result, ...group.checks.map(check => check.evidence)], groupRepositoryUrl(state, group))}}if (actor.kind === 'agent') renewOwnTask(state, group, actor.agentId, context.now)@@ -3343,7 +3348,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,if (removed.length) Object.assign(result, credentialResult(removed))for (const draft of effects.messages) {const group = state.conversations.find(c => c.id === draft.conversationId)- if (group) bindPullRequestCards(group, draft)+ if (group) bindPullRequestCards(group, draft, groupRepositoryUrl(state, group))}// A Buddy hears the project-chat rows about its person's proposals and requested work (buddyNews.ts).for (const draft of effects.messages) tellBuddies(state, draft, draft.replyTo && draft.replyTo === context.reply?.id ? context.reply.threadSource ?? null : null)diff --git a/backend/src/superTabs/migration/links.ts b/backend/src/superTabs/migration/links.tsindex 8b6260a2e..01296c253 100644--- a/backend/src/superTabs/migration/links.ts+++ b/backend/src/superTabs/migration/links.ts@@ -1,5 +1,6 @@import type { Prisma } from '@prisma/client'import { appendPullRequestUrls, type SuperTabState } from '../model.js'+import { groupRepositoryUrl } from '../projects.js'/** Groups from before link lists have none. The migration rebuilds theirs once from complete stored history (moved from* store.ts, where every read did it: reads never write once Swarms are in parts, design R8). */@@ -20,6 +21,6 @@ export async function restorePullRequestUrls(tx: Prisma.TransactionClient, tabId...messages.filter(message => message.conversationId === group.id).map(message => message.text),...prior.flatMap(attempt => [...(attempt.checks ?? []).map(check => check.evidence), attempt.assignment?.result]),...group.checks.map(check => check.evidence), group.assignment?.result,- ])+ ], groupRepositoryUrl(state, group))}}diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex 1e5d2ce82..75354f085 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -1,4 +1,5 @@import { createHash } from 'node:crypto'+import { githubRepository } from '../github/repository.js'import { cloneData } from './cloneData.js'import { autoJoinOn } from './autoJoinDomain.js'import { lostReasonWithoutMachine } from './lostReason.js'@@ -386,13 +387,27 @@ export interface TaskLiveness {personId?: string}-/** The GitHub pull request links in [text], each once, in order. */-export const pullRequestLinks = (text: string): string[] => [...new Set([...text.matchAll(/https:\/\/github\.com\/[A-Za-z0-9_-]+\/[A-Za-z0-9_.-]+\/pull\/([1-9][0-9]*)\b/g)]- .filter(match => Number(match[1]) <= Number.MAX_SAFE_INTEGER).map(match => match[0]))]+/** [url] as the project's own pull request, in the project's spelling of owner and repository (GitHub names are not case+ * sensitive); null when it belongs to any other repository, whatever its name, since an owner is never guessed. Without a+ * known GitHub repository nothing can be judged. */+export function projectPullRequestUrl(url: string, repositoryUrl: string | null | undefined): string | null {+ const own = githubRepository(repositoryUrl)+ if (!own) return url+ const match = url.match(/^https:\/\/github\.com\/([A-Za-z0-9_-]+)\/([A-Za-z0-9_.-]+)\/pull\/([1-9][0-9]*)$/)+ if (!match) return null+ return match[1]!.toLowerCase() === own.owner.toLowerCase() && match[2]!.toLowerCase() === own.name.toLowerCase()+ ? `https://github.com/${own.fullName}/pull/${match[3]}` : null+}++/** The GitHub pull request links in [text], each once, in order. With the project's [repositoryUrl], each is that repository's+ * (in the project's spelling) and a link into any other repository is left out, so one pull request is one link. */+export const pullRequestLinks = (text: string, repositoryUrl?: string | null): string[] => [...new Set([...text.matchAll(/https:\/\/github\.com\/[A-Za-z0-9_-]+\/[A-Za-z0-9_.-]+\/pull\/([1-9][0-9]*)\b/g)]+ .filter(match => Number(match[1]) <= Number.MAX_SAFE_INTEGER).flatMap(match => projectPullRequestUrl(match[0], repositoryUrl) ?? []))]-export function appendPullRequestUrls(group: Conversation, texts: Iterable<string | null | undefined>): void {- const urls = new Set(group.pullRequestUrls ?? [])- for (const text of texts) if (text) for (const url of pullRequestLinks(text)) urls.add(url)+/** Adds the pull request links of [texts] to [group] and corrects the ones it holds, by the project's [repositoryUrl]. */+export function appendPullRequestUrls(group: Conversation, texts: Iterable<string | null | undefined>, repositoryUrl?: string | null): void {+ const urls = new Set((group.pullRequestUrls ?? []).flatMap(url => projectPullRequestUrl(url, repositoryUrl) ?? []))+ for (const text of texts) if (text) for (const url of pullRequestLinks(text, repositoryUrl)) urls.add(url)group.pullRequestUrls = [...urls]}export interface Invitation {diff --git a/backend/src/superTabs/native.ts b/backend/src/superTabs/native.tsindex f34b3e585..b0778e65c 100644--- a/backend/src/superTabs/native.ts+++ b/backend/src/superTabs/native.ts@@ -5,7 +5,7 @@ import type { AuthUser } from '../lib/ssoAuth.js'import { isTeamSession, TEAM_SESSION_LIMITED, TEAM_SESSION_MESSAGE } from '../lib/teamSession.js'import { activeWork, agent, appendPullRequestUrls, author, conversation, fail, stableId, SuperTabError,type Actor, type Agent, type Author, type Conversation, type SuperTabState } from './model.js'-import { accessInputs, canReadGroup, readConversation, watchersLost } from './projects.js'+import { accessInputs, canReadGroup, groupRepositoryUrl, readConversation, watchersLost } from './projects.js'import { mayDrive } from './terminal.js'import { CANCELLABLE_DELIVERY } from './pageReads.js'import { cloneData } from './cloneData.js'@@ -231,7 +231,7 @@ export class SuperTabNativeStore {const text = recovery?.source.required ? recovery.text : event.kind === 'gap'? 'Some terminal activity could not be recorded. Check the native session for the full conversation.' : redactCredentials(event.text).text// Leave a legacy group's list absent so the next read can recover its older links too.- if (group.pullRequestUrls !== undefined) appendPullRequestUrls(group, [text])+ if (group.pullRequestUrls !== undefined) appendPullRequestUrls(group, [text], groupRepositoryUrl(state, group))// A required recovery reaches the coordinator; a typed prompt, its answer or any other gap names no one (phase 1).const recipients = turnRecipients(group, target, !!recovery?.source.required)const draft = { id: eventId, conversationId: group.id, author: observedBy, text, replyTo: null, recipients }diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.tsindex f01a1fa47..11f670842 100644--- a/backend/src/superTabs/projects.ts+++ b/backend/src/superTabs/projects.ts@@ -120,6 +120,10 @@ export function groupProject(state: SuperTabState, group: Conversation): SwarmPrreturn projectOf(state, group.projectId ?? 'lead')}+/** The repository address of the project [group] belongs to (null when it has none or the group has no project); never throws. */+export const groupRepositoryUrl = (state: SuperTabState, group: Conversation): string | null =>+ projectsOf(state).find(p => p.id === (group.projectId ?? 'lead'))?.repository?.repositoryUrl ?? null+/** The project a start works in: a project session's own, none for a Swarm-wide Buddy's (Dee, 10-31), else its conversation's. */export function startProject(state: SuperTabState, request: Pick<AgentStartRequest, 'conversationId' | 'buddySession'>): SwarmProject | undefined {if (request.buddySession?.projectId) return projectOf(state, request.buddySession.projectId)diff --git a/backend/src/superTabs/pullRequestRepository.test.ts b/backend/src/superTabs/pullRequestRepository.test.tsnew file mode 100644index 000000000..37205ab0e--- /dev/null+++ b/backend/src/superTabs/pullRequestRepository.test.ts@@ -0,0 +1,96 @@+import { describe, expect, it } from 'vitest'+import { applyCommand, type Command, type CommandContext } from './commands.js'+import { bindPullRequestCards, cleanPullRequestLinks, pullRequestCard } from './cards.js'+import { githubRepository } from '../github/repository.js'+import { appendPullRequestUrls, createSuperTab, projectPullRequestUrl, pullRequestLinks, type Actor, type Conversation } from './model.js'++const REPO = 'https://github.com/autonomous-ai/openharness.git'+const WRONG_OWNER = 'https://github.com/openharness/openharness/pull/1'+const RIGHT = 'https://github.com/autonomous-ai/openharness/pull/1'+const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }++function fixture(repositoryUrl: string | null = REPO) {+ let state = createSuperTab('tab', 'Office', { id: 'owner', email: owner.email }, 'prod')+ state.projects![0]!.repository = { machineId: 'host', cwd: '/work', repositoryUrl }+ let sequence = 0+ const run = (command: Command, context: Partial<CommandContext> = {}) => {+ const effects = applyCommand(state, owner, command, { now: 1000, operationId: `op-${++sequence}`, ...context })+ state = effects.state+ return effects+ }+ const id = run({ type: 'conversation.create', title: 'Links', brief: 'Link.', checks: [] } as Command).result.conversationId as string+ return { run, id, group: () => state.conversations.find(c => c.id === id)!, get state() { return state } }+}++describe('a project\'s pull request links', () => {+ it('reads the repository of an https, ssh or scp address, and nothing for another host', () => {+ for (const url of [REPO, 'https://github.com/autonomous-ai/openharness', '[email protected]:autonomous-ai/openharness.git', 'ssh://[email protected]/autonomous-ai/openharness.git/']) {+ expect(githubRepository(url)).toEqual({ owner: 'autonomous-ai', name: 'openharness', fullName: 'autonomous-ai/openharness' })+ }+ expect(githubRepository('https://gitlab.com/autonomous-ai/openharness')).toBeNull()+ expect(githubRepository(null)).toBeNull()+ })++ it('keeps the project\'s own link in its spelling, and drops any other repository\'s, another owner\'s included', () => {+ expect(projectPullRequestUrl(WRONG_OWNER, REPO)).toBeNull()+ expect(projectPullRequestUrl('https://github.com/AUTONOMOUS-AI/OpenHarness/pull/1', REPO)).toBe(RIGHT)+ expect(projectPullRequestUrl(RIGHT, REPO)).toBe(RIGHT)+ expect(projectPullRequestUrl('https://github.com/autonomous-ai/other/pull/1', REPO)).toBeNull()+ expect(projectPullRequestUrl('https://github.com/x/other/pull/1', 'https://gitlab.com/a/b')).toBe('https://github.com/x/other/pull/1')+ expect(projectPullRequestUrl('https://github.com/x/other/pull/1', null)).toBe('https://github.com/x/other/pull/1')+ })++ it('finds one link per pull request in text', () => {+ expect(pullRequestLinks(`${WRONG_OWNER} ${RIGHT} https://github.com/autonomous-ai/other/pull/1 https://github.com/AUTONOMOUS-AI/OpenHarness/pull/1`, REPO)).toEqual([RIGHT])+ expect(pullRequestLinks(`${WRONG_OWNER} ${RIGHT}`)).toEqual([WRONG_OWNER, RIGHT])+ })++ it('cleans a group\'s record: the other owner\'s link goes and the right one stays, as does another repository\'s removal', () => {+ const group = { pullRequestUrls: [WRONG_OWNER, RIGHT, 'https://github.com/autonomous-ai/other/pull/9'],+ cards: { pullRequests: [{ url: WRONG_OWNER, messageId: 'm1' }, { url: RIGHT, messageId: 'm2', mergedAt: 5 },+ { url: 'https://github.com/AUTONOMOUS-AI/openharness/pull/1', messageId: 'm4', mergedAt: 3 }, { url: 'https://github.com/o/other/pull/9', messageId: 'm3' }] } } as unknown as Conversation+ cleanPullRequestLinks(group, REPO)+ expect(group.pullRequestUrls).toEqual([RIGHT])+ expect(group.cards!.pullRequests).toEqual([{ url: RIGHT, messageId: 'm2', mergedAt: 3 }])+ cleanPullRequestLinks(group, null)+ expect(group.pullRequestUrls).toEqual([RIGHT])+ })++ it('binds one card per pull request, and none for another owner\'s', () => {+ const group = { pullRequestUrls: [] } as unknown as Conversation+ bindPullRequestCards(group, { id: 'm1', conversationId: 'g', author: {} as never, text: `Opened ${WRONG_OWNER}`, replyTo: null, recipients: [] }, REPO)+ expect(group.cards).toBeUndefined()+ bindPullRequestCards(group, { id: 'm2', conversationId: 'g', author: {} as never, text: `Again ${RIGHT}`, replyTo: null, recipients: [] }, REPO)+ bindPullRequestCards(group, { id: 'm3', conversationId: 'g', author: {} as never, text: `Spelled https://github.com/Autonomous-AI/OpenHarness/pull/1`, replyTo: null, recipients: [] }, REPO)+ expect(group.cards!.pullRequests).toEqual([{ url: RIGHT, messageId: 'm2' }])+ expect(pullRequestCard(group, RIGHT)?.messageId).toBe('m2')+ })++ it('records a merge of a link in the project\'s spelling, and refuses another owner\'s', () => {+ const f = fixture()+ expect(() => f.run({ type: 'conversation.merged', conversationId: f.id, pullRequestUrl: WRONG_OWNER })).toThrow(/not in the project's repository/)+ f.run({ type: 'conversation.merged', conversationId: f.id, pullRequestUrl: 'https://github.com/Autonomous-AI/OpenHarness/pull/1' })+ f.run({ type: 'conversation.merged', conversationId: f.id, pullRequestUrl: RIGHT })+ expect(f.group().pullRequestUrls).toEqual([RIGHT])+ expect(f.group().cards!.pullRequests).toEqual([expect.objectContaining({ url: RIGHT, mergedAt: 1000 })])+ })++ it('refuses a merge of a pull request in another repository, saying which one the project uses', () => {+ const f = fixture()+ expect(() => f.run({ type: 'conversation.merged', conversationId: f.id, pullRequestUrl: 'https://github.com/autonomous-ai/other/pull/3' }))+ .toThrow(/not in the project's repository \(autonomous-ai\/openharness\)/)+ expect(f.group().pullRequestUrls ?? []).toEqual([])+ })++ it('takes any link when the project has no GitHub repository to judge by', () => {+ const f = fixture(null)+ f.run({ type: 'conversation.merged', conversationId: f.id, pullRequestUrl: WRONG_OWNER })+ expect(f.group().pullRequestUrls).toEqual([WRONG_OWNER])+ })++ it('adds links from text by the project\'s repository', () => {+ const group = { pullRequestUrls: [WRONG_OWNER] } as unknown as Conversation+ appendPullRequestUrls(group, [`See ${RIGHT} and https://github.com/autonomous-ai/other/pull/4`], REPO)+ expect(group.pullRequestUrls).toEqual([RIGHT])+ })+})diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex 3f9dc145e..6d1755b4b 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -31,7 +31,8 @@ import { noteClaim, recordDeliveryCall } from '../lib/deliveryCalls.js'import { retryTransient } from './retry.js'import { recordReload } from './retryStats.js'import { buddyChatId, swarmBuddyChatId, type ChosenBuddyName } from './buddies.js'-import { accountOf, wordsOf, buddyPerson, canReadAgent, canReadGroup, canWatchAgent, groupProject, ledProject, onTeamAccount, projectOf, projectsOf, agentProjectId, readConversation, readProject, skillModeOf, startProject, type ProjectVisibility, sessionKey, GITHUB_SEEN, type GitHubSeen, type SwarmProject } from './projects.js'+import { cleanPullRequestLinks } from './cards.js'+import { accountOf, wordsOf, buddyPerson, canReadAgent, canReadGroup, groupRepositoryUrl, canWatchAgent, groupProject, ledProject, onTeamAccount, projectOf, projectsOf, agentProjectId, readConversation, readProject, skillModeOf, startProject, type ProjectVisibility, sessionKey, GITHUB_SEEN, type GitHubSeen, type SwarmProject } from './projects.js'import { bindSession, makeProjectPrivate } from './sessionScope.js'import { SESSION_ENDED_KIND, sessionContext, sessionReadsRow, type ContextRow } from './buddySessions.js'import { isBuddy, isBuddyChat, isBuddyReader, refuseBuddyRouting, routingRow } from './buddies.js'@@ -1634,10 +1635,12 @@ export class SuperTabStore {// An agent-only notice changes nothing people see: no link, no unread mark, no project report.const shown = effects.messages.filter(message => !agentOnly(message.source, message.recipients))for (const group of effects.state.conversations) {+ const repositoryUrl = groupRepositoryUrl(effects.state, group)appendPullRequestUrls(group, [...shown.filter(message => message.conversationId === group.id).map(message => message.text),...group.checks.map(check => check.evidence), group.assignment?.result,- ])+ ], repositoryUrl)+ cleanPullRequestLinks(group, repositoryUrl)}if (command.type === 'agent.rebind') {const target = agent(effects.state, command.agentId)diff --git a/backend/vitest.super-tabs.ci.config.ts b/backend/vitest.super-tabs.ci.config.tsnew file mode 100644index 000000000..a5d489eb3--- /dev/null+++ b/backend/vitest.super-tabs.ci.config.ts@@ -0,0 +1,10 @@+import { fileURLToPath } from 'node:url'+import { defineConfig, mergeConfig } from 'vitest/config'+import config from './vitest.super-tabs.config.js'+import { createDurationSequencer, readTimingHintsFile } from './src/lib/ciShards.js'++// PR CI's backend-integration job (.github/workflows/ci.yml): the Super Tab integration suite in four shards balanced by+// integration/ci-durations.json. `npx vitest run --config vitest.super-tabs.ci.config.ts --shard=N/4` reproduces shard N.+const hints = readTimingHintsFile(fileURLToPath(new URL('./integration/ci-durations.json', import.meta.url)))++export default mergeConfig(config, defineConfig({ test: { sequence: { sequencer: createDurationSequencer(hints) } } }))diff --git a/desktop/lib/super_tabs/pull_requests.dart b/desktop/lib/super_tabs/pull_requests.dartindex 5e910a412..a4023f663 100644--- a/desktop/lib/super_tabs/pull_requests.dart+++ b/desktop/lib/super_tabs/pull_requests.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:url_launcher/url_launcher.dart';+import '../core/github_repository.dart';import '../core/pull_request_status.dart';import '../core/open_in_browser.dart';import '../shared/theme/pull_request_icon.dart';@@ -15,37 +16,87 @@ import 'controller.dart';import 'model.dart';import '../widgets/laid_out_list.dart';-List<Uri> superTabPullRequestLinks(String text) => {- for (final match in RegExp(- r'https://github\.com/([A-Za-z0-9_-]+)/([A-Za-z0-9_.-]+)/pull/([1-9][0-9]*)\b',- ).allMatches(text))- if (int.tryParse(match.group(3)!) case final number?- when number <= 9007199254740991)- Uri.parse(match.group(0)!),-}.toList();+/// The pull request links in [text], one per owner, repository and number+/// (GitHub names are not case sensitive), in order.+List<Uri> superTabPullRequestLinks(String text) {+ final seen = <String>{};+ return [+ for (final match in RegExp(+ r'https://github\.com/([A-Za-z0-9_-]+)/([A-Za-z0-9_.-]+)/pull/([1-9][0-9]*)\b',+ ).allMatches(text))+ if (int.tryParse(match.group(3)!) case final number?+ when number <= 9007199254740991 &&+ seen.add(+ '${match.group(1)}/${match.group(2)}/$number'.toLowerCase(),+ ))+ Uri.parse(match.group(0)!),+ ];+}++/// The project's own `owner/repo`, lowercased, when [address] is a GitHub+/// repository in any form git writes one (core/github_repository.dart).+String? _ownRepository(String? address) {+ final identity = address == null ? null : repositoryIdentity(address);+ if (identity == null) return null;+ final slash = identity.indexOf('/');+ return slash > 0 && isGitHubHost(identity.substring(0, slash))+ ? identity.substring(slash + 1)+ : null;+}++/// What each pull request chip says: `repo · PR #n`, with `owner/repo` when+/// the pull request is not in the project's own repository ([repositoryUrl]),+/// or, when the project's is unknown, when two owners share a repository name.+List<String> superTabPullRequestLabels(+ List<Uri> links, {+ String? repositoryUrl,+}) {+ final own = _ownRepository(repositoryUrl);+ final owners = <String, Set<String>>{};+ for (final link in links) {+ owners+ .putIfAbsent(link.pathSegments[1].toLowerCase(), () => {})+ .add(link.pathSegments[0].toLowerCase());+ }+ return [+ for (final link in links)+ () {+ final owner = link.pathSegments[0], repo = link.pathSegments[1];+ final elsewhere = own != null+ ? '$owner/$repo'.toLowerCase() != own+ : owners[repo.toLowerCase()]!.length > 1;+ return '${elsewhere ? '$owner/$repo' : repo} · PR #${link.pathSegments[3]}';+ }(),+ ];+}class SuperTabPullRequestLinks extends StatelessWidget {- const SuperTabPullRequestLinks(this.text, {super.key});+ const SuperTabPullRequestLinks(this.text, {super.key, this.repositoryUrl});final String text;++ /// The project's repository address, when known.+ final String? repositoryUrl;@overrideWidget build(BuildContext context) {final links = superTabPullRequestLinks(text);if (links.isEmpty) return const SizedBox.shrink();+ final labels = superTabPullRequestLabels(+ links,+ repositoryUrl: repositoryUrl,+ );return Padding(padding: const EdgeInsets.only(top: 8),child: Wrap(spacing: 8,runSpacing: 6,children: [- for (final link in links.take(4))+ for (final (i, link) in links.take(4).indexed)OutlinedButton.icon(onPressed: () => unawaited(launchUrl(link, mode: LaunchMode.externalApplication),),icon: const Icon(AppIcons.externalLink, size: 14),- label: Text(- '${link.pathSegments[1]} · PR #${link.pathSegments[3]}',- ),+ label: Text(labels[i]),),],),diff --git a/desktop/lib/super_tabs/ship_row.dart b/desktop/lib/super_tabs/ship_row.dartindex 2ca4ea8bf..7b72db4e6 100644--- a/desktop/lib/super_tabs/ship_row.dart+++ b/desktop/lib/super_tabs/ship_row.dart@@ -105,7 +105,14 @@ class _SuperTabShipRowState extends State<SuperTabShipRow> {agents('Reviewed by', _ids('reviewerIds')),],),- SuperTabPullRequestLinks(_ids('pullRequests').join(' ')),+ SuperTabPullRequestLinks(+ _ids('pullRequests').join(' '),+ repositoryUrl:+ snapshot+ ?.projectFor(message.conversationId)+ ?.repository?['repositoryUrl']+ as String?,+ ),],),);diff --git a/desktop/test/super_tab_ship_test.dart b/desktop/test/super_tab_ship_test.dartindex 3d8e88e4e..f1f136745 100644--- a/desktop/test/super_tab_ship_test.dart+++ b/desktop/test/super_tab_ship_test.dart@@ -1,6 +1,7 @@import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/super_tabs/identity.dart';+import 'package:harness/super_tabs/pull_requests.dart';import 'package:harness/super_tabs/ship_row.dart';import 'super_tab_mentions_test.dart' show showView;@@ -145,6 +146,102 @@ void main() {await tester.pumpAndSettle();});+ group('pull request chips', () {+ const own = 'https://github.com/autonomous-ai/openharness/pull/2527';+ const wrongOwner = 'https://github.com/openharness/openharness/pull/2527';++ test('two links for one pull request are one link, whatever their case', () {+ final links = superTabPullRequestLinks(+ '$own https://github.com/Autonomous-AI/OpenHarness/pull/2527 $own '+ 'https://github.com/autonomous-ai/openharness/pull/2528',+ );+ expect([for (final l in links) l.pathSegments[3]], ['2527', '2528']);+ });++ test('a pull request elsewhere than the project\'s repository names it', () {+ final links = superTabPullRequestLinks('$own $wrongOwner');+ expect(+ superTabPullRequestLabels(+ links,+ repositoryUrl: '[email protected]:autonomous-ai/openharness.git',+ ),+ ['openharness · PR #2527', 'openharness/openharness · PR #2527'],+ );+ });++ test('the project\'s repository is read in every form git writes it', () {+ final links = superTabPullRequestLinks('$own $wrongOwner');+ for (final address in [+ 'ssh://[email protected]:22/autonomous-ai/openharness.git',+ 'ssh://[email protected]:443/Autonomous-AI/OpenHarness.git',+ 'git://github.com/autonomous-ai/openharness',+ 'https://github.com/autonomous-ai/openharness.git/',+ ]) {+ expect(+ superTabPullRequestLabels(links, repositoryUrl: address),+ ['openharness · PR #2527', 'openharness/openharness · PR #2527'],+ reason: address,+ );+ }+ });++ test('without the project\'s repository, owners sharing a name show', () {+ final both = superTabPullRequestLinks('$own $wrongOwner');+ expect(superTabPullRequestLabels(both), [+ 'autonomous-ai/openharness · PR #2527',+ 'openharness/openharness · PR #2527',+ ]);+ expect(superTabPullRequestLabels(both.take(1).toList()), [+ 'openharness · PR #2527',+ ]);+ });++ testWidgets('a ship line with two links for one pull request has one chip', (+ tester,+ ) async {+ await show(+ tester,+ shipServer(+ source: {+ 'pullRequests': [+ own,+ 'https://github.com/Autonomous-AI/openharness/pull/2527',+ 'https://github.com/autonomous-ai/openharness/pull/2528',+ ],+ },+ )..state['project'] = {+ 'machineId': 'm',+ 'cwd': '/work',+ 'repositoryUrl': 'https://github.com/autonomous-ai/openharness',+ },+ );+ expect(find.text('openharness · PR #2527'), findsOneWidget);+ expect(find.text('openharness · PR #2528'), findsOneWidget);+ expect(find.byType(OutlinedButton), findsNWidgets(2));+ await tester.pumpAndSettle();+ });++ testWidgets('a link in another repository shows owner and repository', (+ tester,+ ) async {+ await show(+ tester,+ shipServer(+ source: {+ 'pullRequests': [own, wrongOwner],+ },+ )..state['project'] = {+ 'machineId': 'm',+ 'cwd': '/work',+ 'repositoryUrl': 'https://github.com/autonomous-ai/openharness',+ },+ );+ expect(find.text('openharness · PR #2527'), findsOneWidget);+ expect(find.text('openharness/openharness · PR #2527'), findsOneWidget);+ await tester.pumpAndSettle();+ });+ });+testWidgets('the conversation draws a ship message as the celebration', (tester,) async {diff --git a/docs/plans/2026-11-02-shipped-card-pr-links-plan.md b/docs/plans/2026-11-02-shipped-card-pr-links-plan.mdnew file mode 100644index 000000000..555018c7f--- /dev/null+++ b/docs/plans/2026-11-02-shipped-card-pr-links-plan.md@@ -0,0 +1,109 @@+# Shipped card: PR links of the project's repository, Shipped after the merge Implementation Plan++> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.++**Goal:** A Shipped card shows one chip per pull request of the project's own repository, and the project chat says Shipped only once the work's pull requests have merged.++**Architecture:** The backend keeps pull request links to the project's repository (one helper in `model.ts`, used by every place that records a link) and records each merge by link on the group's ledger; the ship line posts when a Done's delivered pull requests are all merged, at Done or at the last merge. Desktop and phone dedupe and label chips for rows already posted.++**Tech Stack:** TypeScript (vitest, mongodb-memory-server integration suite), Dart/Flutter (Desktop, phone).++**Spec:** Task #2081 (Diego), brief in the Swarm; ruling by the Lead in the task: an owner is never changed; another owner's link is dropped from text and refused when a command records it. Process note: the project's instructions could not be read when work began (`TEAM_SESSION_LIMITED`), so this plan was written after the first code commit rather than before it.++> **Merged with main, 2026-11-03 (River's call in task #2081):** main replaced the project chat's Shipped line with each task's+> own line, which reads shipped at its first recorded merge (`taskLine.ts`, #2633). Task 2 below is therefore superseded and+> removed: its ship logic, ledger fields and tests are gone, and the task line is the ship moment. Tasks 1 and 3 stay; Task 1+> now uses main's `githubRepository` (`backend/src/github/repository.ts`) instead of a second parser. Waiting for every pull+> request before "shipped" would be a follow-up task.++## Global Constraints++- A recorded PR link points at the project's own repository (`autonomous-ai/openharness`); an owner is never guessed or corrected.+- One entry per PR number: a spelling (case) of the project's repository is the project's own.+- Shipped posts once per group, never at a Done with a delivered PR still open, never twice, never for work already announced.+- Chips: one per owner/repo/number; `owner/repo` shown when it differs from the project's repository.+- Feature design rules (AGENTS.md): see Design below.+- The PR body starts with: Requested by [email protected] through Harness.++## Review Focus++- A PR merely mentioned in the task (chat, brief) or closed unmerged must not keep Shipped from posting.+- A merge recorded for a PR with no card (named only in evidence or a thread) must still count.+- A Done that names no PR must ship at its merge; a repeated merge record must not post a second line.+- Work Done and announced under the old rule, then merged or Done again, must not be announced again.+- A fork's PR of the same name (`other-org/openharness`) must not become ours; a project with no GitHub repository must behave as before.++## Design++- growth: a few small ledger fields per group (merged links, awaited links, two marks); link lists only shrink.+- concurrency: inside the command's existing Swarm transaction.+- read cost: no new reads; cleaning touches only groups already loaded for the command.+- scale: constant work per group per command.+- compatibility: old clients draw chips from the same fields; old rows keep their text; a group from before (no `ledger.shipsAfterMerge`) keeps the old announce-once guard.+- migration + rollback: stored groups clean themselves on the next command (task #2002 drops its bad entry, keeps the right one); rolling back leaves cleaned links, which older code accepts.+- audience: the ship line stays in the project chat, never a private conversation.+- identity: N/A.+- failure: a link in another repository through `conversation.merged` is refused with a clear message; links in text are dropped.+- platforms: backend, Desktop, phone.++## What people see++```+Before (task #2002, posted at Done, PRs open)+ 🎉 Shipped: <title> Requested by diego · Built by … · Reviewed by …+ [openharness · PR #2527] [openharness · PR #2527] [openharness · PR #2528] [openharness · PR #2529]+After+ Done, a delivered PR open -> no Shipped line+ all delivered PRs merged -> 🎉 Shipped: <title> [openharness · PR #2527] [openharness · PR #2528] [openharness · PR #2529]+ a link outside the project's repository (old rows only): [other-org/openharness · PR #2527]+```++---++### Task 1: Links of the project's repository (backend)++**Files:**+- Modify: `backend/src/superTabs/model.ts`, `cards.ts`, `projects.ts`, `commands.ts`, `store.ts`, `native.ts`, `migration/links.ts`+- Test: `backend/src/superTabs/pullRequestRepository.test.ts`, `backend/integration/superTabs.test.ts`++**Interfaces:**+- Produces: `githubRepository(url): {owner, repo} | null`; `projectPullRequestUrl(url, repositoryUrl): string | null`; `pullRequestLinks(text, repositoryUrl?)`; `appendPullRequestUrls(group, texts, repositoryUrl?)`; `cleanPullRequestLinks(group, repositoryUrl)`; `groupRepositoryUrl(state, group)`.++- [x] **Step 1: Write the failing tests** — `pullRequestRepository.test.ts`: other owner dropped, spelling kept, other repository refused by `conversation.merged` with `not in the project's repository (autonomous-ai/openharness)`, any link taken without a GitHub repository, stored group cleaned (links, cards, merged and awaited lists), cards bound once.+- [x] **Step 2: Run them to see them fail** — `cd backend && npx vitest run src/superTabs/pullRequestRepository.test.ts` (failed on `main`).+- [x] **Step 3: Implement the helpers in `model.ts` and `cards.ts`; use them where links are recorded** (`commands.ts` merged and Done, `store.ts` per group each command, `native.ts`, `migration/links.ts`).+- [x] **Step 4: Run them to see them pass.**+- [x] **Step 5: Integration test** — `superTabs.test.ts` "records a link under the project's repository and corrects the record it held before".+- [x] **Step 6: Commit.**++### Task 2: Shipped after the merge (backend) — superseded by main's task line (see the note above)++**Files:**+- Modify: `backend/src/superTabs/ship.ts`, `commands.ts`, `leaderboard/record.ts`+- Test: `backend/src/superTabs/ship.test.ts`, `buddyNews.test.ts`, `leaderboard/record.test.ts`, `backend/integration/superTabProfile.test.ts`++**Interfaces:**+- Consumes: Task 1's `pullRequestLinks`.+- Produces: `ledger.mergedUrls`, `ledger.shipWaiting` (the PRs a Done awaits), `ledger.shipPostedAt`, `ledger.shipsAfterMerge`; `mergedPullRequests(group)`, `deliveredPullRequests(group, named)`, `celebrable(before)`, `shipNotice(state, group, author, operationId, named)`.++- [x] **Step 1: Write the failing tests** — `ship.test.ts`: Done with an open PR posts nothing and the merge posts it once; merge first then Done posts at Done; several PRs wait for the last, with or without cards; a mentioned or closed PR never blocks; a Done naming no PR ships at its merge; Done, reassigned, merged, Done posts once and a repeated merge record posts nothing; a group from before this rule is not announced again.+- [x] **Step 2: Run them to see them fail** — failed on `main` (16 failed) and on the first implementation (reviewer's findings).+- [x] **Step 3: Implement** — merge recorded by link in `conversation.merged`; Done awaits the PRs its result names (else its checks'); the merge that completes them posts and clears the wait.+- [x] **Step 4: Run them to see them pass** — `npx vitest run src/superTabs` all pass.+- [x] **Step 5: Existing ship tests record the merge before Done** (`ship.test.ts` `finish`, `buddyNews.test.ts`, `superTabProfile.test.ts`).+- [x] **Step 6: Full Super Tab suite** — `cd backend && npm run test:super-tabs`; result in a PR comment.+- [x] **Step 7: Commit.**++### Task 3: Chips on Desktop and phone++**Files:**+- Modify: `desktop/lib/super_tabs/pull_requests.dart`, `ship_row.dart`, `mobile/lib/swarm/swarm_ship_row.dart`+- Test: `desktop/test/super_tab_ship_test.dart`, `mobile/test/swarm/swarm_ship_row_test.dart`++**Interfaces:**+- Produces: `superTabPullRequestLinks(text)` (one per owner/repo/number, case-insensitive), `superTabPullRequestLabels(links, {repositoryUrl})`, `SuperTabPullRequestLinks(text, {repositoryUrl})`; phone `swarmPullRequestLabels`, `SwarmShip.pullRequests` deduped.++- [x] **Step 1: Write the failing tests** — two links for one PR give one chip; a link outside the project's repository shows `owner/repo`; without the repository, owners sharing a name show.+- [x] **Step 2: Run them** — Flutter is not installed on the builder's Mac: they run in PR CI and in the Tester's step.+- [x] **Step 3: Implement** the helpers and pass the project's repository from the ship row (`snapshot.projectFor(conversationId).repository['repositoryUrl']`).+- [x] **Step 4: Commit.**diff --git a/docs/plans/2026-11-03-super-tab-integration-ci-plan.md b/docs/plans/2026-11-03-super-tab-integration-ci-plan.mdnew file mode 100644index 000000000..a19869745--- /dev/null+++ b/docs/plans/2026-11-03-super-tab-integration-ci-plan.md@@ -0,0 +1,84 @@+# Super Tab integration suite in PR CI — plan++Way of working: the project's Engineer flow (plan first, then each task test first; one review on the pull request).++**Goal:** PR CI runs the backend's Super Tab integration suite (`npm run test:super-tabs`,+`backend/vitest.super-tabs.config.ts`, `backend/integration/`) on every pull request that changes backend code, in at most+four parallel Linux shards, in under 15 minutes, gated by `ci/required`. Engineers stop running the 60–90 minute suite+locally behind a per-Mac lock.++**Architecture:** One new matrix job, `backend-integration` (shards 1–4), in `.github/workflows/ci.yml`. The planner+(`scripts/ci-plan.py`) adds it to the `backend` suite's jobs, so it runs exactly when `backend-desk` runs (a change under+`backend/` or one of the backend's declared cross-reads) and `ci/required` requires it. Files are split across shards+by recorded per-file durations (longest first onto the least-loaded shard), the same method the CLI's+`vitest.ci.config.ts` uses, in a backend copy (`backend/integration/ciSequencer.ts`, `backend/integration/ci-durations.json`,+`backend/vitest.super-tabs.ci.config.ts`): the backend may not import CLI code.++**Tech Stack:** GitHub Actions, Python planner + `unittest`, Vitest 4 custom sequencer, `mongodb-memory-server-core`.++**Spec:** task #2459 (Dee, 2026-11-03).++## Global Constraints++- At most 4 shards (account limit: 20 concurrent jobs). Non-backend PRs run nothing new.+- MongoDB: every integration file already starts its own replica set through `mongodb-memory-server-core` (7.0.24),+ so each shard has its own databases. A MongoDB service container would be a second, unused server; instead the job+ caches the downloaded `mongod` binary (`$TMPDIR/harness-super-tab-mongodb-binaries`). Redis: the suite's setup+ (`src/lib/noRedis.test-support.ts`) keeps every Redis client unconnected and `cacheOn.test-support.ts` uses in-memory+ stamps, so no file reads Redis; no Redis service is added (it would never be used). Recorded deviation from the+ brief's "MongoDB and Redis as services", with this reason.+- No database change. No change to the local `test:super-tabs` behavior.+- Timing-dependent tests the job exposes get a deterministic fix, or a recorded reason in the test.++## Review Focus++- The planner change: `backend-integration` is required whenever `backend` is planned, never on other PRs, and update+ merges no longer reuse a backend result when main changed `backend/integration/` (it is now read by PR CI).+- Sharding: every file in the config's `include` runs exactly once across the four shards.+- Wall time under 15 minutes per shard, measured in CI.++## Tasks++### 1. Planner: the backend suite includes the integration job++Files: `scripts/ci-plan.py`, `scripts/tests/test_ci_plan.py`.+Interfaces: `JOBS["backend"] == {"backend-desk", "backend-integration"}`; `NOT_READ` has no backend entry.++- [ ] Failing test: a backend-only PR requires `backend-integration`; a docs-only and a desktop-only PR do not; a main+ commit under `backend/integration/` reruns (no longer reuses) the backend suite.+- [ ] Run `python3 -m unittest scripts/tests/test_ci_plan.py` and watch it fail.+- [ ] Change `JOBS` and `NOT_READ`; declare any cross-read the scan finds in `backend/integration/`.+- [ ] Tests pass.++### 2. Duration-based shards++Files: `backend/integration/ciSequencer.ts`, `backend/integration/ciSequencer.test.ts`,+`backend/integration/ci-durations.json`, `backend/vitest.super-tabs.ci.config.ts`.++- [ ] Failing test: `durationShards` puts every file in exactly one of N shards, longest first onto the least-loaded+ shard; unknown files get the default cost; invalid hints are refused.+- [ ] Implement; the CI config merges `vitest.super-tabs.config.ts` with the sequencer.++### 3. The CI job++Files: `.github/workflows/ci.yml`.++- [ ] `backend-integration` matrix (shard 1–4), `needs: plan`, `if` ready and backend, Node 22.23.2, `npm ci`, cached+ `mongod`, `npx vitest run --config vitest.super-tabs.ci.config.ts --shard=N/4` with a JSON report uploaded per+ shard; `timeout-minutes: 20`; listed in `ci/required`'s `needs`.+- [ ] actionlint passes (the plan job runs it).++### 4. Measure and stabilize++- [ ] First ready run: per-shard wall time; the sum of per-file durations is the one-job time (the "before").+- [ ] Record the durations into `ci-durations.json`; rebalance if a shard is over 15 minutes.+- [ ] Fix or record each timing-dependent test that fails on CI runners.+- [ ] Red run: a throwaway commit breaking a store command turns `ci/required` red through `backend-integration`; then+ drop it.++### 5. Docs++Files: `docs/validation-and-release.md`.++- [ ] PR CI table: `backend/` runs `backend-desk` and `backend-integration` (four shards); how to reproduce a shard+ locally; the local full-suite rule is now covered by CI.diff --git a/docs/validation-and-release.md b/docs/validation-and-release.mdindex 3c2035dec..190d3cc14 100644--- a/docs/validation-and-release.md+++ b/docs/validation-and-release.md@@ -35,7 +35,7 @@ PR CI is deliberately fast. Each changed component runs only its own Linux suite| `desktop/` | `desktop-tests` (VM suite, four Linux shards) | 5–7 min || `tui/`, `term/` (the TUI builds on it) | `tui-test` (`cargo test`) | a few minutes || `pty/`, `term/`, `tui/vendor/`, the CLI's ptyhost backend (`cli/src/lib/ptyHost/`, `ptyHostBackend*`, `terminalBackend.contract.ts`) | `pty-checks` (`cargo test` for `term` and `pty`, then the ptyhost terminal contract against the built host) | a few minutes |-| `backend/` | `backend-desk` (the backend unit suite, `npm test` in `backend/`) | about 1–2 min |+| `backend/` | `backend-desk` (the backend unit suite, `npm test` in `backend/`) and `backend-integration` (the Super Tab integration suite, `npm run test:super-tabs`, four shards) | unit about 1–2 min; integration about 5 min || `companions/`, `website/`, `os/`, `provider/`, `mobile/`, `daemons/` | that component's one check | 1–4 min || `devices/` | `firmware-checks` | 1–2 min || `devices/harness-pro/` | also `pro-firmware-build` (ESP-IDF v5.5.4 build of `harness_pro.bin`, which must fit `ota_0`) and `pro-golden` (`test/golden.sh --check` with Liberation Sans, on macOS arm64 where the baseline is recorded: float maths in the code-drawn shapes differs on Linux x86-64) | build ~4 min, golden ~1 min |@@ -137,6 +137,18 @@ runs the same fast jobs as PR CI.Each shard has four test workers and the bounded runner's ten-minute budget. Logsand receipts are retained for seven days.+`backend-integration` runs the backend's Super Tab integration suite (`backend/integration/`,+`vitest.super-tabs.config.ts`) on four Linux runners. It replaces the full local run every+backend pull request needed before Ready: CI's run is that evidence, so nobody waits on a+per-Mac lock for it. Each integration file starts its own MongoDB replica set through+`mongodb-memory-server-core` (the job caches the downloaded `mongod`), so the shards share no+database; the suite opens no Redis. `vitest.super-tabs.ci.config.ts` spreads files over the+shards by `integration/ci-durations.json`, longest first onto the least-loaded shard, as the+CLI does below; new files get the default cost and the discovered file list stays+authoritative. Each shard uploads its per-file JSON results (`backend-integration-N`) for+refreshing the hints. Reproduce one shard locally with `npx vitest run --config+vitest.super-tabs.ci.config.ts --shard=N/4` in `backend/`.+CLI's default Vitest suite runs as four file shards on separate runners, retainingits worker cap and isolation. Shard reports and inventories are retained asartifacts for seven days.diff --git a/mobile/lib/swarm/swarm_ship_row.dart b/mobile/lib/swarm/swarm_ship_row.dartindex 9e76a9b4e..5f818fe35 100644--- a/mobile/lib/swarm/swarm_ship_row.dart+++ b/mobile/lib/swarm/swarm_ship_row.dart@@ -26,6 +26,39 @@ final _pullRequest = RegExp(r'^https://github\.com/([A-Za-z0-9_-]+)/([A-Za-z0-9_.-]+)/pull/([1-9][0-9]*)$',);+/// The `owner/repo` a GitHub repository address names (https, ssh or scp+/// form), or null for another host or no address.+String? swarmGithubRepository(String? address) {+ final match = RegExp(+ r'^(?:https?://|ssh://git@|git@)github\.com[/:]([A-Za-z0-9_-]+)/([A-Za-z0-9_.-]+?)(?:\.git)?/?$',+ ).firstMatch(address ?? '');+ return match == null ? null : '${match.group(1)}/${match.group(2)}';+}++/// What each pull request button says (the desktop's+/// `superTabPullRequestLabels`): `repo · PR #n`, with `owner/repo` when the+/// pull request is not in the project's own repository ([repositoryUrl]), or,+/// when the project's is unknown, when two owners share a repository name.+List<String> swarmPullRequestLabels(List<Uri> links, {String? repositoryUrl}) {+ final own = swarmGithubRepository(repositoryUrl)?.toLowerCase();+ final owners = <String, Set<String>>{};+ for (final link in links) {+ owners+ .putIfAbsent(link.pathSegments[1].toLowerCase(), () => {})+ .add(link.pathSegments[0].toLowerCase());+ }+ return [+ for (final link in links)+ () {+ final owner = link.pathSegments[0], repo = link.pathSegments[1];+ final elsewhere = own != null+ ? '$owner/$repo'.toLowerCase() != own+ : owners[repo.toLowerCase()]!.length > 1;+ return '${elsewhere ? '$owner/$repo' : repo} · PR #${link.pathSegments[3]}';+ }(),+ ];+}+/// What a ship line says: what shipped, and who asked, built and reviewed/// it, as ids the Swarm names; its pull requests, at most four.class SwarmShip {@@ -39,10 +72,7 @@ class SwarmShip {builderIds = _ids(message.source['builderIds']),reviewerIds = _ids(message.source['reviewerIds']),pullRequests = List.unmodifiable(- _ids(message.source['pullRequests'])- .where(_pullRequest.hasMatch)- .map(Uri.parse)- .take(4),+ _oneEach(message.source['pullRequests']),);final String title;@@ -50,6 +80,17 @@ class SwarmShip {final List<String> builderIds, reviewerIds;final List<Uri> pullRequests;+ /// GitHub pull requests only, one per owner, repository and number (names are+ /// not case sensitive), at most four.+ static Iterable<Uri> _oneEach(Object? value) {+ final seen = <String>{};+ return _ids(value)+ .where(_pullRequest.hasMatch)+ .map(Uri.parse)+ .where((link) => seen.add(link.path.toLowerCase()))+ .take(4);+ }+static List<String> _ids(Object? value) => List.unmodifiable([for (final id in value is List ? value : const [])?id is String ? id : null,@@ -163,6 +204,14 @@ class _SwarmShipRowState extends State<SwarmShipRow> {('Built by', agents(ship.builderIds)),('Reviewed by', agents(ship.reviewerIds)),].where((credit) => credit.$2.isNotEmpty).toList();+ final labels = swarmPullRequestLabels(+ ship.pullRequests,+ repositoryUrl:+ snapshot+ ?.projectFor(widget.message.conversationId)+ ?.repository?['repositoryUrl']+ as String?,+ );final accent = AppPalette.accentOnSurface;final card = Container(key: ValueKey('swarm-ship-$id'),@@ -266,6 +315,7 @@ class _SwarmShipRowState extends State<SwarmShipRow> {_PullRequestButton(key: ValueKey('swarm-ship-pr-$id-$i'),link: link,+ label: labels[i],),],),@@ -281,13 +331,17 @@ class _SwarmShipRowState extends State<SwarmShipRow> {/// A pull request the ship links, as a button: its repository and number,/// opened in the in-app browser.class _PullRequestButton extends StatelessWidget {- const _PullRequestButton({super.key, required this.link});+ const _PullRequestButton({+ super.key,+ required this.link,+ required this.label,+ });final Uri link;+ final String label;@overrideWidget build(BuildContext context) {- final label = '${link.pathSegments[1]} · PR #${link.pathSegments[3]}';return Semantics(button: true,link: true,diff --git a/mobile/test/swarm/swarm_ship_row_test.dart b/mobile/test/swarm/swarm_ship_row_test.dartindex f3984e55e..a7487e4c3 100644--- a/mobile/test/swarm/swarm_ship_row_test.dart+++ b/mobile/test/swarm/swarm_ship_row_test.dart@@ -92,6 +92,51 @@ void main() {});});+ group('a ship line\'s pull requests', () {+ const own = 'https://github.com/autonomous-ai/openharness/pull/2527';+ const wrongOwner = 'https://github.com/openharness/openharness/pull/2527';++ test('are one link per owner, repository and number', () {+ final ship = SwarmShip.of(+ shipMessage(+ source: {+ 'kind': 'ship',+ 'pullRequests': [+ own,+ 'https://github.com/Autonomous-AI/OpenHarness/pull/2527',+ own,+ 'https://github.com/autonomous-ai/openharness/pull/2528',+ ],+ },+ ),+ );+ expect([for (final link in ship.pullRequests) link.pathSegments[3]], [+ '2527',+ '2528',+ ]);+ });++ test('name their repository only when it is not the project\'s', () {+ final links = [Uri.parse(own), Uri.parse(wrongOwner)];+ expect(+ swarmPullRequestLabels(+ links,+ repositoryUrl: 'https://github.com/autonomous-ai/openharness.git',+ ),+ ['openharness · PR #2527', 'openharness/openharness · PR #2527'],+ );+ expect(swarmPullRequestLabels(links), [+ 'autonomous-ai/openharness · PR #2527',+ 'openharness/openharness · PR #2527',+ ]);+ expect(swarmPullRequestLabels(links.take(1).toList()), [+ 'openharness · PR #2527',+ ]);+ expect(swarmGithubRepository('[email protected]:a/b.git'), 'a/b');+ expect(swarmGithubRepository('https://gitlab.com/a/b'), isNull);+ });+ });+group('when a ship throws confetti', () {final now = DateTime.utc(2026, 10, 28, 3);diff --git a/scripts/ci-plan.py b/scripts/ci-plan.pyindex 89cc0891f..e3efd8090 100644--- a/scripts/ci-plan.py+++ b/scripts/ci-plan.py@@ -30,7 +30,8 @@ JOBS = {"cli": {"cli-typecheck", "cli-tests"},"pro": {"pro-firmware-build", "pro-golden"},"desktop": {"desktop-tests"},- "tui": {"tui-test"}, "backend": {"backend-desk"}, "companions": {"companion-subsystems"},+ # backend-integration: the Super Tab integration suite (backend/integration) in four shards (task #2459).+ "tui": {"tui-test"}, "backend": {"backend-desk", "backend-integration"}, "companions": {"companion-subsystems"},**{name: {name + "-checks"} for name in EXTRA},}MANUAL = {"full": CORE, "all": SUITES, "process": set(), **{name: {name} for name in SUITES}}@@ -62,8 +63,11 @@ SUBCOMPONENTS = {"devices/harness-pro/": "pro"}# test_ci_plan.CrossReadTests scans the components' sources and fails on an undeclared read.# The desktop VM tests run in a sparse checkout of exactly these inputs (ci-source-inputs.py).DEPENDS = {- "backend": ("cli/src/lib/productHealthContract.ts", "cli/src/lib/productUsageContract.ts", "daemons/frames.json",- "desktop/lib/measurement/", "desktop/lib/super_tabs/buddies.dart", "mobile/lib/measurement/",+ # attachments.limits.test.ts compares the attachment size limits each client declares.+ "backend": ("cli/src/lib/productHealthContract.ts", "cli/src/lib/productUsageContract.ts",+ "cli/src/lib/superTabAttachmentProxy.ts", "cli/src/superTabs/attachments.ts", "daemons/frames.json",+ "desktop/lib/measurement/", "desktop/lib/super_tabs/attachment_upload.dart",+ "desktop/lib/super_tabs/buddies.dart", "mobile/lib/measurement/", "mobile/lib/swarm/swarm_outgoing_files.dart","provider/reference-provider/", "tests/fixtures/"),"cli": ("backend/src/lib/deviceAck.vectors.json", "backend/src/lib/deviceAckCore.ts", "desktop/","cli/e2e/harness/", "devices/harness-device/firmware/test/vectors/", "docs/contracts/", "mobile/", "pty/", "tui/"),@@ -92,16 +96,18 @@ DEPENDS = {"cli/src/messages/command.ts", "desktop/lib/core/phone_app_links.dart","desktop/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png"),}-# Folders inside a suite's own component that its PR jobs never read: the backend unit suite-# runs src/**/*.test.ts, and the CLI's typecheck and unit tests cover src/ (end to end runs elsewhere).+# Folders inside a suite's own component that its PR jobs never read: the CLI's typecheck and unit+# tests cover src/ (end to end runs elsewhere). backend/integration is read: backend-integration runs it.# CrossReadTests fails when a file outside the folder refers into it.-NOT_READ = {"backend": ("backend/integration/",), "cli": ("cli/e2e/",)}+NOT_READ = {"cli": ("cli/e2e/",)}# Strings in a suite's files that name another directory's path but are not read by its PR jobs:# test data, or a script run only by hand. {source: (why, {path the scan reports})}.NOT_READS = {**{source: ("test data: owned-code paths and model names", {"desktop/lib/", "desktop/lib/super_tabs/","desktop/lib/super_tabs/roster.dart"})- for source in ("backend/src/superTabs/commands.test.ts",)},+ for source in ("backend/src/superTabs/commands.test.ts", "backend/integration/superTabs.test.ts")},+ **{source: ("test data: a task's owned paths", {"docs/"})+ for source in ("cli/src/superTabs/routeCheapFirst.spec.ts", "cli/src/superTabs/routeCommand.spec.ts")},# cli-tests runs vitest on src/ only; these start the real backend with its installed prisma.**{source: ("end-to-end and local stack scripts, run by hand", {"backend/"})for source in ("cli/e2e/harness/realBackend.ts", "cli/scripts/box-claim-e2e.ts", "cli/scripts/local-stack-peer.ts",diff --git a/scripts/tests/test_ci_plan.py b/scripts/tests/test_ci_plan.pyindex 3441da490..712569834 100644--- a/scripts/tests/test_ci_plan.py+++ b/scripts/tests/test_ci_plan.py@@ -17,6 +17,14 @@ spec.loader.exec_module(planner)class SelectionTests(unittest.TestCase):+ def test_backend_changes_run_the_integration_shards_and_nothing_else_does(self):+ # Task #2459: the Super Tab integration suite runs in PR CI for backend changes only.+ self.assertEqual(planner.JOBS["backend"], {"backend-desk", "backend-integration"})+ self.assertEqual(planner.select(["backend/integration/superTabs.test.ts"])[0], {"backend"})+ others = set().union(*(jobs for suite, jobs in planner.JOBS.items() if suite != "backend"))+ self.assertNotIn("backend-integration", others)+ self.assertNotIn("backend", planner.NOT_READ)+def test_docs_workflows_scripts_and_unknown_paths_need_only_process_checks(self):for path in ["docs/guide.md", "README.md", "docs/images/poster.png", "scripts/ci-plan.py",".github/workflows/ci.yml", "Makefile", "store/tools/runtimes.sh", "surprise.py"]:@@ -337,11 +345,18 @@ class ReuseTests(ReuseFixture):self.assertIn("backend/src/other.ts", plan["reuse"]["rerun"]["backend"])def test_tests_outside_the_pr_suite_do_not_rerun_it(self):- # backend-desk runs src/**/*.test.ts only; cli-tests and cli-typecheck cover cli/src only.- _, main, head = self.scenario(["backend/src/app.ts", "cli/src/a.ts"], ["backend/integration/teams.test.ts", "cli/e2e/run.e2e.ts"])+ # cli-tests and cli-typecheck cover cli/src only; cli/e2e runs in its own workflow.+ _, main, head = self.scenario(["backend/src/app.ts", "cli/src/a.ts"], ["cli/e2e/run.e2e.ts"])plan = self.plan(head, main)self.assertEqual(list(plan["reused"]), ["backend", "cli"])- self.assertEqual(planner.select(["backend/integration/teams.test.ts"])[0], {"backend"})++ def test_a_main_integration_test_change_reruns_the_backend_suite(self):+ # backend-integration runs backend/integration (task #2459), so main's change there was never tested with this PR.+ _, main, head = self.scenario(["backend/src/app.ts"], ["backend/integration/teams.test.ts"])+ plan = self.plan(head, main)+ self.assertEqual(plan["reused"], {})+ self.assertIn("backend/integration/teams.test.ts", plan["reuse"]["rerun"]["backend"])+ self.assertEqual(plan["required_jobs"], sorted({"process-checks", "backend-desk", "backend-integration"}))def test_a_style_allowlist_main_changed_reruns_the_suite_that_checks_it(self):# mobile-checks runs the mobile style check: a list main shrank can fail with this PR's code.@@ -738,10 +753,10 @@ class CrossReadTests(unittest.TestCase):self.assertEqual(planner.undeclared_reads(self.root, "cli"), [])def test_a_read_into_a_folder_the_suite_skips_is_found(self):- self.write("backend/integration/helpers.ts", "export const x = 1")- self.write("backend/src/a.test.ts", "import { x } from '../integration/helpers'")- self.write("backend/integration/b.test.ts", "import { y } from './helpers'; import '../src/a'")- self.assertEqual(planner.undeclared_reads(self.root, "backend"), [("backend/src/a.test.ts", "backend/integration/")])+ self.write("cli/e2e/helpers.ts", "export const x = 1")+ self.write("cli/src/a.spec.ts", "import { x } from '../e2e/helpers'")+ self.write("cli/e2e/b.e2e.ts", "import { y } from './helpers'; import '../src/a'")+ self.assertEqual(planner.undeclared_reads(self.root, "cli"), [("cli/src/a.spec.ts", "cli/e2e/")])def test_a_read_built_at_run_time_needs_its_whole_folder_declared(self):self.write("tui/src/a.rs", 'include_str!("../../backend/src/types/productUsage.ts"); let p = "../../backend/src/";')