From 41324da7acb7c3bfd1d0243fb28777c08886e1c0 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:43:29 +0000 Subject: [PATCH 1/2] fix: capture missing BuildFlexity issue protection in Tracker tests --- .../tracker-host-adapter.test.ts | 51 ++++++++++++++----- .../tracker-host-brief.test.ts | 14 +++++ 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/test/services/projects-sessions/tracker-host-adapter.test.ts b/test/services/projects-sessions/tracker-host-adapter.test.ts index ddc1c285c63..c38563f79e0 100644 --- a/test/services/projects-sessions/tracker-host-adapter.test.ts +++ b/test/services/projects-sessions/tracker-host-adapter.test.ts @@ -4,12 +4,13 @@ import { DatabaseSync } from 'node:sqlite'; import { expect, test, vi } from 'vitest'; import { TrackerAdapterSourceRepository } from '../../../src/repositories/projects-sessions/TrackerAdapterSourceRepository'; import { TrackerNativeRuntimeService } from '../../../src/services/projects-sessions/TrackerNativeRuntimeService'; +import { trackerHostEffectsSchema } from '../../../src/services/projects-sessions/tracker-native-runtime-service/trackerHostEffectsSchema'; import { withTempDir } from '../../support/temporary'; import { measureWorkload } from '../../support/measureWorkload'; const now = () => 1_800_000_000_000; const node = 'daniel-primary-mbp'; -const adapterId = 'github:example/widgets'; +const adapterId = 'github:dafuga/buildflexity'; const signal = new AbortController().signal; test('polls existing GitHub sources only for the designated owner with the isolated CLI profile', () => @@ -33,10 +34,10 @@ async function proveDesignatedPoll(root: string) { adapter: { github: { executable, configDirectory }, followUp: { - target: 'example/widgets', - author: 'fixture-tester', + target: 'dafuga/buildflexity', + author: 'AndriyParik', additionalAuthors: ['second-tester'], - titlePrefix: 'Fixture Widgets', + titlePrefix: 'BuildFlexity', issueInstructions: 'Use the normal release gate.', instructions: 'Tester owns acceptance for #{issue}.' }, @@ -54,6 +55,7 @@ async function proveDesignatedPoll(root: string) { await runtime.adapter!.tick(signal); await verifyPolledSource(runtime, { events, configDirectory }); await verifyCommentPreview(runtime); + verifyGithubAppLogins(executable, configDirectory); } finally { vi.unstubAllEnvs(); database.close(); @@ -65,10 +67,10 @@ function seedSource(database: DatabaseSync) { database.exec("INSERT INTO adapter_runner VALUES (1, 'another-node')"); const config = { type: 'github', - target: 'example/widgets', + target: 'dafuga/buildflexity', kind: 'task', agent: 'fixture', - project: 'fixture', + project: 'buildflexity', auto_launch: 'never', include_labels: [], exclude_labels: [], @@ -88,16 +90,20 @@ async function verifyPolledSource( ).toEqual({ cursor: now(), last_run: now(), last_error: null }); const listed = await runtime.items.handle(new Request('http://tracker-fixture.invalid/items')); expect(await listed.json()).toMatchObject([ - { title: 'Fixture Widgets #17: Fixture issue', priority: 'urgent' } + { + title: 'BuildFlexity #17: Fixture issue', + priority: 'urgent', + adapter_instructions: expect.stringContaining('Keep this issue open for Andriy') + } ]); const requests = readFileSync(events, 'utf8') .trim() .split('\n') .map((line) => JSON.parse(line)); expect(requests.map(({ argv }) => argv.at(-1))).toEqual([ - expect.stringContaining('repos/example/widgets/issues?state=all'), - 'repos/example/widgets/issues/17/timeline?per_page=100', - expect.stringContaining('repos/example/widgets/issues/comments?since=') + expect.stringContaining('repos/dafuga/buildflexity/issues?state=all'), + 'repos/dafuga/buildflexity/issues/17/timeline?per_page=100', + expect.stringContaining('repos/dafuga/buildflexity/issues/comments?since=') ]); for (const { argv, profile, token } of requests) { expect(argv.slice(0, 5)).toEqual(['api', '--hostname', 'github.com', '--method', 'GET']); @@ -107,6 +113,25 @@ async function verifyPolledSource( } } +function verifyGithubAppLogins(executable: string, configDirectory: string) { + const result = trackerHostEffectsSchema.safeParse({ + mode: 'active', + checkpoint: 'fixture', + adapter: { + github: { executable, configDirectory }, + followUp: { + target: 'dafuga/buildflexity', + author: 'AndriyParik', + additionalAuthors: ['app/buildflexity-qa-bot', 'other-app[bot]'], + titlePrefix: 'BuildFlexity', + issueInstructions: 'Use the normal release gate.', + instructions: 'Tester owns acceptance for #{issue}.' + } + } + }); + expect(result.success).toBe(true); +} + async function verifyCommentPreview(runtime: TrackerNativeRuntimeService) { const seq = runtime.store.maxSeq(); const result = await runtime.adapter?.poll(adapterId, { backfillComments: true, dryRun: true }); @@ -115,7 +140,7 @@ async function verifyCommentPreview(runtime: TrackerNativeRuntimeService) { { action: 'create', external_id: 'comment:199', - url: 'https://github.com/example/widgets/issues/17#issuecomment-199', + url: 'https://github.com/dafuga/buildflexity/issues/17#issuecomment-199', auto_launch: false, priority: 'urgent' } @@ -135,11 +160,11 @@ const issue = { id: 100, number: 17, title: 'Fixture issue', state: 'open', labels: [], created_at: new Date(1799999980000).toISOString(), updated_at: new Date(1799999980000).toISOString(), - user: { login: 'fixture-tester' } + user: { login: 'buildflexity-qa-bot[bot]' } }; if (query.includes('/comments')) { process.stdout.write(JSON.stringify([[{ - id: 199, issue_url: 'https://api.github.com/repos/example/widgets/issues/17', + id: 199, issue_url: 'https://api.github.com/repos/dafuga/buildflexity/issues/17', created_at: new Date(1799999900000).toISOString(), body: 'Correction: retry is unavailable', user: { type: 'User', login: 'second-tester' } }]])); diff --git a/test/services/projects-sessions/tracker-host-brief.test.ts b/test/services/projects-sessions/tracker-host-brief.test.ts index 48004beb4a5..c7a0e6cd9ec 100644 --- a/test/services/projects-sessions/tracker-host-brief.test.ts +++ b/test/services/projects-sessions/tracker-host-brief.test.ts @@ -38,6 +38,20 @@ test('every session brief tells the agent to flag with 2 to 4 options and one re ); expect(harness).toContain('bun run check --item abcdef'); expect(harness).toContain('host queue with `--release` for the combined release'); + expect(harness).not.toContain('BuildFlexity issue handling'); + for (const recovery of [false, true]) { + const buildFlexity = formatTrackerHostBrief( + { ...item, project: 'buildflexity', agent: 'fixture' }, + 'Finish by running tracker done.', + { recovery } + ); + expect(buildFlexity).toContain('buildflexity-qa-bot'); + expect(buildFlexity).toContain('Keep Andriy’s issues open'); + expect(buildFlexity).toContain('Refs #N'); + expect(buildFlexity).toContain('closing references'); + expect(buildFlexity).toContain('live on staging'); + expect(buildFlexity).toContain('needs testing on staging'); + } }); test('every session brief points browser work at the automation Chrome, not the main profile', () => { From 63172021f951c5deeed47f22695b4d1745d846d6 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:45:42 +0000 Subject: [PATCH 2/2] fix: preserve Andriy-owned BuildFlexity issues in Tracker --- .../githubIntakeRecord.ts | 18 ++++++++++++++++ .../readTrackerIntake.ts | 21 ++++++++++++++----- .../trackerHostAdapter.ts | 6 +++++- .../trackerHostBrief.ts | 3 +++ .../trackerHostEffectsSchema.ts | 10 ++++----- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/services/projects-sessions/tracker-adapter-poll-service/githubIntakeRecord.ts b/src/services/projects-sessions/tracker-adapter-poll-service/githubIntakeRecord.ts index c19f061ad5a..a017a6053f7 100644 --- a/src/services/projects-sessions/tracker-adapter-poll-service/githubIntakeRecord.ts +++ b/src/services/projects-sessions/tracker-adapter-poll-service/githubIntakeRecord.ts @@ -18,6 +18,24 @@ import type { TrackerGithubIssue } from '../TrackerAdapterPollService.types'; +const buildFlexityQaApp = 'buildflexity-qa-bot'; + +export const buildFlexityIssueHandling = [ + '## BuildFlexity issue handling', + `Keep Andriy’s issues open, including reports filed from Slack by app/${buildFlexityQaApp} (${buildFlexityQaApp}[bot]). Andriy closes these issues after retesting.`, + 'Use Refs #N in PRs and commits. Check GitHub’s closing references before merging and remove any closing reference to these issues. Leave them open when completing Tracker work.', + 'Once the fix is verified live on staging, request Andriy’s retest through the approved draft path and apply the needs testing on staging label. Only close issues our team opened after verifying the fix live on staging. If authorship is unclear, leave the issue open.' +].join('\n'); + +export function githubAccountLogin(login: string): string { + return login.toLowerCase().replace(/^app\/(.+)$/, '$1[bot]'); +} + +export function isBuildFlexityTester(target: string, actor?: string): boolean { + if (target.toLowerCase() !== 'dafuga/buildflexity' || !actor) return false; + return ['andriyparik', `${buildFlexityQaApp}[bot]`].includes(githubAccountLogin(actor)); +} + export async function readGithubIntakeRecord( source: TrackerAdapterSource, issue: TrackerGithubIssue, diff --git a/src/services/projects-sessions/tracker-adapter-poll-service/readTrackerIntake.ts b/src/services/projects-sessions/tracker-adapter-poll-service/readTrackerIntake.ts index 35e42eaaa3e..66aadf6c3b2 100644 --- a/src/services/projects-sessions/tracker-adapter-poll-service/readTrackerIntake.ts +++ b/src/services/projects-sessions/tracker-adapter-poll-service/readTrackerIntake.ts @@ -17,9 +17,12 @@ import { import { assertTrackerPollActive } from './trackerAdapterPollError'; import { commitTrackerIntake, planTrackerIntake } from './commitTrackerIntake'; import { + buildFlexityIssueHandling, followUpInstructions, + githubAccountLogin, githubCommentEvent, hasFollowUpRequest, + isBuildFlexityTester, planGithubFollowUp, readGithubIntakeRecord } from './githubIntakeRecord'; @@ -68,11 +71,19 @@ function issueAcceptance( issue: TrackerGithubIssue ): string | undefined { const rule = policy?.followUp; - if (!rule) return undefined; const key = String(issue.number); - if (trackerTesterLogin(rule, issue.user?.login) || repository.hasFollowUp(source.id, key)) - return followUpInstructions(rule, key); - return undefined; + const protectedIssue = isBuildFlexityTester(source.target, issue.user?.login); + const instructions = + rule && + (protectedIssue || + trackerTesterLogin(rule, issue.user?.login) || + repository.hasFollowUp(source.id, key)) + ? followUpInstructions(rule, key) + : undefined; + if (!protectedIssue) return instructions; + return [instructions, 'Keep this issue open for Andriy.', buildFlexityIssueHandling] + .filter(Boolean) + .join('\n\n'); } export async function readTrackerComments( @@ -140,7 +151,7 @@ export function trackerTesterLogin(rule: TrackerGithubFollowUpPolicy, actor?: st return Boolean( actor && [rule.author, ...(rule.additionalAuthors ?? [])].some( - (login) => login.toLowerCase() === actor.toLowerCase() + (login) => githubAccountLogin(login) === githubAccountLogin(actor) ) ); } diff --git a/src/services/projects-sessions/tracker-native-runtime-service/trackerHostAdapter.ts b/src/services/projects-sessions/tracker-native-runtime-service/trackerHostAdapter.ts index a8871fb8cbb..843f35a44bb 100644 --- a/src/services/projects-sessions/tracker-native-runtime-service/trackerHostAdapter.ts +++ b/src/services/projects-sessions/tracker-native-runtime-service/trackerHostAdapter.ts @@ -2,6 +2,7 @@ import { TrackerHostProcessAdapter } from '../../../adapters/projects-sessions/TrackerHostProcessAdapter'; import { TrackerAdapterLeaseAdapter } from '../../../adapters/projects-sessions/TrackerAdapterLeaseAdapter'; import { trackerTesterLogin } from '../tracker-adapter-poll-service/readTrackerIntake'; +import { isBuildFlexityTester } from '../tracker-adapter-poll-service/githubIntakeRecord'; import { trackerGithubCli } from './trackerGithubCli'; import type { TrackerHostEffects } from './nativeTrackerHostEffects.types'; import type { TrackerRunReadRepository } from '../../../repositories/projects-sessions/TrackerRunReadRepository'; @@ -37,7 +38,10 @@ export function trackerHostAdapter( titlePrefix: followUp.titlePrefix, instructions: followUp.issueInstructions, priority: (_item, event) => - trackerTesterLogin(followUp, event.actor) ? 'urgent' : 'normal', + trackerTesterLogin(followUp, event.actor) || + (event.kind === 'issue' && isBuildFlexityTester(source.target, event.actor)) + ? 'urgent' + : 'normal', matchesItem: (item) => [item.agent, item.project].some( (name) => name?.toLowerCase() === source.project.toLowerCase() diff --git a/src/services/projects-sessions/tracker-native-runtime-service/trackerHostBrief.ts b/src/services/projects-sessions/tracker-native-runtime-service/trackerHostBrief.ts index 63d6b10ff70..d87175a3ba7 100644 --- a/src/services/projects-sessions/tracker-native-runtime-service/trackerHostBrief.ts +++ b/src/services/projects-sessions/tracker-native-runtime-service/trackerHostBrief.ts @@ -19,6 +19,7 @@ import { trackerSecretSafetyRule } from './trackerSecretSafetyRule'; import { trackerCpuBudgetRule } from '../../../utils/projects-sessions/trackerCpuBudget'; import { trackerContextCheckpointPrefix } from './trackerWatchdogContext'; import { trackerContextLimit } from './trackerHandoffTarget'; +import { buildFlexityIssueHandling } from '../tracker-adapter-poll-service/githubIntakeRecord'; const launchRules = [ 'Never merge into a Greymass repository (stop at PR). For other repos, work on a branch and open a PR; merge only if Daniel authorized it or standing authorization for Harness PRs covers it. Production deploys/promotions require Daniel’s explicit approval.', @@ -59,6 +60,8 @@ export function formatTrackerHostBrief( 'Wrap remote checks/builds in `tracker host-work ssh -- ssh ` and Colima proofs in `tracker host-work colima -- ssh ` (with task-owned teardown).', '', launchRules, + [item.project, item.agent].some((name) => /^buildflexity(?:-app)?$/i.test(name ?? '')) && + `\n${buildFlexityIssueHandling}\n`, '', '## Mock mode for costly app tests', mockModePlanningRule, diff --git a/src/services/projects-sessions/tracker-native-runtime-service/trackerHostEffectsSchema.ts b/src/services/projects-sessions/tracker-native-runtime-service/trackerHostEffectsSchema.ts index e120814bb57..3b46ec648fb 100644 --- a/src/services/projects-sessions/tracker-native-runtime-service/trackerHostEffectsSchema.ts +++ b/src/services/projects-sessions/tracker-native-runtime-service/trackerHostEffectsSchema.ts @@ -7,16 +7,16 @@ import { hostVerify, hostWorktrees, noVerify } from './trackerHostVerifyPolicy'; const absolutePath = z.string().refine(isAbsolute); const driver = absolutePath; +const githubLogin = z + .string() + .regex(/^(?:[a-z0-9][a-z0-9-]{0,38}(?:\[bot\])?|app\/[a-z0-9][a-z0-9-]{0,38})$/i); const adapterPolicy = { manual: z.literal(true).optional(), followUp: z .strictObject({ target: z.string().regex(/^[a-z0-9][a-z0-9-]*\/[a-z0-9_.-]+$/), - author: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{0,38}$/), - additionalAuthors: z - .array(z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{0,38}$/)) - .max(10) - .optional(), + author: githubLogin, + additionalAuthors: z.array(githubLogin).max(10).optional(), titlePrefix: z.string().trim().min(1).max(80), issueInstructions: z.string().trim().min(1).max(6000), instructions: z.string().trim().min(1).max(6000),