diff --git a/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs b/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs index a090311f4e9..dae0031f60c 100644 --- a/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs +++ b/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs @@ -17,7 +17,7 @@ const LABELS = [ 'Terminal · SSH/WSL', 'Chat · SSH/WSL' ] -const CELL = /^(?:supported(?:: .+)?|refused `([a-z_]+)`: .+|n\/a: .+)$/ +const CELL = /^(?:supported(?:: .+)?|refused `([a-z]+(?:_[a-z]+)+)`: .+|n\/a: .+)$/ // Both catalog lists are generated from the registry: methods with shared params, then those without. export function registeredMethods(catalogText) { @@ -41,7 +41,7 @@ export function declaredSections(markdown) { return sections } -/** `codeExists` says whether Orca throws a refusal code. */ +/** `codeExists` says whether a refusal code is an error code in the source. */ export function censusProblems(methods, sections, codeExists) { const problems = [] const declared = new Set() @@ -64,7 +64,7 @@ export function censusProblems(methods, sections, codeExists) { `${method}: "${value}" is not supported, refused \`\`: , or n/a: .` ) } else if (match[1] && !codeExists(match[1])) { - problems.push(`${method}: Orca never throws refusal code ${match[1]}.`) + problems.push(`${method}: ${match[1]} is not an error code in src/main or src/shared.`) } } } @@ -76,22 +76,13 @@ export function censusProblems(methods, sections, codeExists) { return problems } -// Codes Orca throws: an OrchestrationError's code, an RPC errorResponse's code, or a shared orchestration code table. -const THROWN_CODE = [ - /OrchestrationError\(\s*'([a-z_]+)'/g, - /errorResponse\(\s*[^,()]+,\s*[^,()]+,\s*'([a-z_]+)'/g -] - -export function thrownRefusalCodes(sources) { +// Error codes are snake_case words joined by underscores; a lone word such as `question` is data, not a code. +// This catches typos and invented codes, not a real code declared for the wrong method. +export function sourceErrorCodes(sources) { const codes = new Set() - for (const [rel, text] of sources) { - const patterns = /^src\/shared\/orchestration\/.+-codes\.ts$/.test(rel) - ? [...THROWN_CODE, /:\s*'([a-z_]+)'/g] - : THROWN_CODE - for (const pattern of patterns) { - for (const match of text.matchAll(pattern)) { - codes.add(match[1]) - } + for (const text of sources.values()) { + for (const match of text.matchAll(/'([a-z]+(?:_[a-z]+)+)'/g)) { + codes.add(match[1]) } } return codes @@ -99,7 +90,7 @@ export function thrownRefusalCodes(sources) { export function main(root = process.cwd()) { const read = (rel) => readFileSync(path.join(root, rel), 'utf8') - const codes = thrownRefusalCodes( + const codes = sourceErrorCodes( readTrackedSources(root, ['src/main', 'src/shared'], (rel) => /(? codes.has(code) diff --git a/src/main/runtime/orchestration/orchestration-parity.md b/src/main/runtime/orchestration/orchestration-parity.md index f2a422d9b0f..b4e2f4aa4fd 100644 --- a/src/main/runtime/orchestration/orchestration-parity.md +++ b/src/main/runtime/orchestration/orchestration-parity.md @@ -30,7 +30,7 @@ Each line is `supported` (or `supported: `), ``refused ``: ` - Terminal · Local: supported - Chat · Local: supported: refused `session_caller_not_live` while the chat is released -- Terminal · Paired: supported: only `--peek`, which reads the paired Orca's mailbox; a consuming check is refused `stable_pane_required`, since that mailbox can never receive this caller's mail +- Terminal · Paired: supported: only reads that consume nothing (`--peek`, `--all`) of the paired Orca's mailbox; a consuming check is refused `stable_pane_required`, since that mailbox can never receive this caller's mail - Chat · Paired: refused `session_caller_host_boundary`: a session id names a caller only on its own Orca - Terminal · SSH/WSL: supported - Chat · SSH/WSL: refused `session_caller_host_boundary`: chat agents do not run in SSH or WSL