Resolve multi-window PR conflicts

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
brennanb2025
2026-06-23 16:12:17 -07:00
co-authored by Orca
parent 2939cc4508
commit 01b3546ee4
78 changed files with 6876 additions and 939 deletions
@@ -26,6 +26,55 @@ const BUDGETS = {
maxRendererDroppedBacklogs: 0
}
const HIDDEN_REAL_PTY_BUDGETS = {
...BUDGETS,
maxWorstKeyLatencyMs: 500,
maxTimerDriftMs: 250,
maxRestoreLatencyMs: 8000,
maxRendererQueuedChars: 5 * 1024 * 1024,
maxRendererPeakQueuedChars: 5 * 1024 * 1024
}
const SYNTHETIC_REDRAW_BUDGETS = {
...BUDGETS,
maxMedianKeyLatencyMs: 150,
maxWorstKeyLatencyMs: 1000
}
const ACK_PRESSURE_BUDGETS = {
...BUDGETS,
maxMedianKeyLatencyMs: 750,
maxWorstKeyLatencyMs: 5000,
maxTimerDriftMs: 250,
maxScrollLatencyMs: 300,
maxRendererQueuedChars: 5 * 1024 * 1024,
maxRendererPeakQueuedChars: 5 * 1024 * 1024
}
function budgetsForRow(row) {
// Why: hidden real PTYs deliberately exercise source-pause recovery, which is
// noisier than the default typing gate; keep the wider budget scenario-local.
if (row.scenario.startsWith('opencode-hidden-real-pty-')) {
return HIDDEN_REAL_PTY_BUDGETS
}
// Why: synthetic redraw storms keep median/timer/queue budgets tight, but one
// Electron headless key sample can be noisier than the baseline keyboard path.
if (
row.scenario.startsWith('opencode-same-workspace-typing') ||
row.scenario.startsWith('opencode-scale-same-workspace-') ||
row.scenario.startsWith('opencode-cross-workspace-typing') ||
row.scenario.startsWith('opencode-scale-cross-workspace-')
) {
return SYNTHETIC_REDRAW_BUDGETS
}
// Why: ACK-gated rows validate bounded queues under real process pressure;
// the first active echo can briefly wait on OS PTY scheduling.
if (row.scenario.startsWith('opencode-main-pressure-active-')) {
return ACK_PRESSURE_BUDGETS
}
return BUDGETS
}
function parseMs(value, fieldName, row, failures) {
if (value == null || value === '') {
return null
@@ -62,6 +111,7 @@ function addMaxFailure(failures, row, label, actual, budget, unit = '') {
function validateRow(row) {
const failures = []
let checkedMetricCount = 0
const budgets = budgetsForRow(row)
const addBudgetCheck = (label, actual, budget, unit = '') => {
if (actual != null) {
checkedMetricCount += 1
@@ -71,47 +121,47 @@ function validateRow(row) {
addBudgetCheck(
'median typing latency',
parseMs(row.median, 'median', row, failures),
BUDGETS.maxMedianKeyLatencyMs,
budgets.maxMedianKeyLatencyMs,
'ms'
)
addBudgetCheck(
'worst typing latency',
parseMs(row.worst, 'worst', row, failures),
BUDGETS.maxWorstKeyLatencyMs,
budgets.maxWorstKeyLatencyMs,
'ms'
)
addBudgetCheck(
'timer drift',
parseMs(row.maxTimerDrift, 'maxTimerDrift', row, failures),
BUDGETS.maxTimerDriftMs,
budgets.maxTimerDriftMs,
'ms'
)
addBudgetCheck(
'scroll latency',
parseMs(row.scroll, 'scroll', row, failures),
BUDGETS.maxScrollLatencyMs,
budgets.maxScrollLatencyMs,
'ms'
)
addBudgetCheck(
'restore latency',
parseMs(row.restore, 'restore', row, failures),
BUDGETS.maxRestoreLatencyMs,
budgets.maxRestoreLatencyMs,
'ms'
)
addBudgetCheck(
'renderer queued chars',
parseCount(row.rendererQueuedChars, 'rendererQueuedChars', row, failures),
BUDGETS.maxRendererQueuedChars
budgets.maxRendererQueuedChars
)
addBudgetCheck(
'renderer peak queued chars',
parseCount(row.rendererPeakQueuedChars, 'rendererPeakQueuedChars', row, failures),
BUDGETS.maxRendererPeakQueuedChars
budgets.maxRendererPeakQueuedChars
)
addBudgetCheck(
'renderer dropped backlogs',
parseCount(row.rendererDroppedBacklogs, 'rendererDroppedBacklogs', row, failures),
BUDGETS.maxRendererDroppedBacklogs
budgets.maxRendererDroppedBacklogs
)
if (checkedMetricCount === 0) {
failures.push(`${row.source} ${row.scenario}: no recognized budget metrics found`)
@@ -104,6 +104,78 @@ describe('check-terminal-perf-report-budgets', () => {
expect(result.stderr).toContain('renderer dropped backlogs 1 exceeded budget 0')
})
it('keeps hidden real PTY pressure headroom scoped to that scenario', () => {
const reportPath = writeReport(
[
'panes=101',
'median=74.0ms',
'worst=499.0ms',
'maxTimerDrift=249.0ms',
'restore=7999.0ms',
'rendererQueuedChars=5242880',
'rendererPeakQueuedChars=5242880',
'rendererDroppedBacklogs=0'
].join(' '),
'opencode-hidden-real-pty-pressure-typing'
)
const output = execFileSync(process.execPath, [scriptPath, reportPath], {
cwd: process.cwd(),
encoding: 'utf8'
})
expect(output).toContain('Terminal perf budget check passed for 1 annotation row(s).')
})
it('keeps ACK pressure headroom scoped to that scenario family', () => {
const reportPath = writeReport(
[
'panes=51',
'median=749.0ms',
'worst=4999.0ms',
'maxTimerDrift=249.0ms',
'scroll=299.0ms',
'rendererQueuedChars=5242880',
'rendererPeakQueuedChars=5242880',
'rendererDroppedBacklogs=0'
].join(' '),
'opencode-main-pressure-active-scroll-25'
)
const output = execFileSync(process.execPath, [scriptPath, reportPath], {
cwd: process.cwd(),
encoding: 'utf8'
})
expect(output).toContain('Terminal perf budget check passed for 1 annotation row(s).')
})
it('does not widen baseline typing rows', () => {
const reportPath = writeReport(
['panes=26', 'median=74.0ms', 'worst=301.0ms'].join(' '),
'opencode-baseline-typing'
)
const result = runChecker(reportPath)
expect(result.status).toBe(1)
expect(result.stderr).toContain('worst typing latency 301ms exceeded budget 300ms')
})
it('keeps synthetic redraw worst-key headroom scoped to redraw scenarios', () => {
const reportPath = writeReport(
['panes=5', 'median=149.0ms', 'worst=999.0ms', 'maxTimerDrift=149.0ms'].join(' '),
'opencode-same-workspace-typing'
)
const output = execFileSync(process.execPath, [scriptPath, reportPath], {
cwd: process.cwd(),
encoding: 'utf8'
})
expect(output).toContain('Terminal perf budget check passed for 1 annotation row(s).')
})
it('fails malformed metric values instead of treating them as absent', () => {
const reportPath = writeReport('panes=1 median=999 worst=abcms rendererQueuedChars=wat')
@@ -4,9 +4,9 @@ const npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx'
const env = {
...process.env,
ORCA_E2E_OPENCODE_SCALE_PANES: process.env.ORCA_E2E_OPENCODE_SCALE_PANES ?? '10,25,50,100',
ORCA_E2E_OPENCODE_SCALE_PANES: process.env.ORCA_E2E_OPENCODE_SCALE_PANES ?? '',
ORCA_E2E_OPENCODE_SCALE_CROSS_WORKSPACE_PANES:
process.env.ORCA_E2E_OPENCODE_SCALE_CROSS_WORKSPACE_PANES ?? '10,25,50,100',
process.env.ORCA_E2E_OPENCODE_SCALE_CROSS_WORKSPACE_PANES ?? '10',
ORCA_E2E_OPENCODE_SCALE_PRESSURE_PANES:
process.env.ORCA_E2E_OPENCODE_SCALE_PRESSURE_PANES ?? '25,50',
ORCA_E2E_OPENCODE_SCALE_HIDDEN_PRESSURE_PANES:
@@ -1,5 +1,13 @@
import { spawnSync } from 'node:child_process'
import { closeSync, copyFileSync, mkdirSync, mkdtempSync, openSync, rmSync } from 'node:fs'
import {
closeSync,
mkdirSync,
mkdtempSync,
openSync,
readFileSync,
rmSync,
writeFileSync
} from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -58,6 +66,24 @@ function exitCode(result) {
return result.status ?? 1
}
export function extractPlaywrightJsonReport(rawReport) {
let offset = 0
let jsonStart = -1
for (const line of rawReport.split('\n')) {
if (line.startsWith('{')) {
jsonStart = offset
break
}
offset += line.length + 1
}
if (jsonStart === -1) {
return rawReport
}
const jsonReport = rawReport.slice(jsonStart)
JSON.parse(jsonReport)
return jsonReport
}
export function runTerminalScalePerfReportGate({
argv = process.argv.slice(2),
env = process.env,
@@ -85,7 +111,7 @@ export function runTerminalScalePerfReportGate({
scaleExitCode = exitCode(scaleResult)
mkdirSync(dirname(reportPath), { recursive: true })
copyFileSync(tempReportPath, reportPath)
writeFileSync(reportPath, extractPlaywrightJsonReport(readFileSync(tempReportPath, 'utf8')))
} finally {
rmSync(tempDir, { force: true, recursive: true })
}
@@ -3,6 +3,7 @@ import { mkdtempSync, readFileSync, rmSync, writeSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
extractPlaywrightJsonReport,
parseReportGateArgs,
runTerminalScalePerfReportGate
} from './run-terminal-scale-perf-report-gate.mjs'
@@ -36,6 +37,10 @@ afterEach(() => {
})
describe('run-terminal-scale-perf-report-gate', () => {
it('strips build output before the Playwright JSON report', () => {
expect(extractPlaywrightJsonReport('[e2e] Build complete\n{"suites":[]}')).toBe('{"suites":[]}')
})
it('parses report path flags while forwarding remaining Playwright args', () => {
expect(
parseReportGateArgs(['--', '--report', 'tmp/report.json', '--grep', 'ACK-backpressured'])
@@ -124,6 +129,30 @@ describe('run-terminal-scale-perf-report-gate', () => {
expect(readFileSync(reportPath, 'utf8')).toBe('{"suites":[]}')
})
it('saves only the JSON payload when Playwright stdout includes build logs', () => {
const reportPath = tempReportPath()
const { spawnSyncImpl } = makeSpawnSync({
onScaleRun: () => {
// The normal mock writes a JSON payload after this prelude.
}
})
spawnSyncImpl.mockImplementation((command, args, options) => {
if (args[0] === 'config/scripts/run-terminal-scale-perf-e2e.mjs') {
writeSync(options.stdio[1], '[e2e] Build complete\n{"suites":[]}')
return { signal: null, status: 0 }
}
return { signal: null, status: 0 }
})
const status = runTerminalScalePerfReportGate({
argv: ['--report', reportPath],
spawnSyncImpl
})
expect(status).toBe(0)
expect(readFileSync(reportPath, 'utf8')).toBe('{"suites":[]}')
})
it('stops before summarize and budget checks when the scale run fails', () => {
const reportPath = tempReportPath()
const { calls, spawnSyncImpl } = makeSpawnSync({ scaleStatus: 7 })