Four merge-blocking issues surfaced by the qe-devils-advocate audit.
C1 — effort-resolver YAML loading was silently broken in ESM
src/shared/llm/effort-resolver.ts: replaced
const { readFileSync } = require('fs') with a top-level
import { readFileSync } from 'fs'. The require() call threw
ReferenceError under ESM ("type": "module" in package.json),
caught by the bare try/catch, so the YAML priority tier in the
resolver chain was dead — callers always fell through to the
hardcoded xhigh default. config/fleet-defaults.yaml was a
decorative file. Proven fixed by runtime check:
YAML set to 'medium' → resolveEffortLevel() now returns 'medium'.
C2 — body.effort on every /v1/messages call was unverified shape
src/shared/llm/providers/claude.ts: the previous code
unconditionally set body.effort on every request, regardless of
whether the target model supported it, and used a top-level shape
that is not documented in Anthropic's public Messages API schema.
New behavior: effort is only set when the registry marks the
model supportsEffortXHigh=true (Opus 4.7 today) and is nested
under body.thinking = { type: 'adaptive', effort: <level> },
matching the Anthropic SDK's beta.messages thinking shape.
Non-xhigh models receive no thinking/effort field at all,
eliminating the risk of 400-ing Sonnet 4.6 / Haiku 4.5 calls.
Rationale inline at the call site.
C3 — CYBER_PINNED_AGENTS was missing qe-security-reviewer
qe-security-reviewer lives at .claude/agents/v3/subagents/
(not in .claude/agents/v3/ top level) and was present in the
submitted Cyber Verification application. Without it in the pin
list, that agent could route to Opus 4.7 freely. Added.
Cross-check test now parses the application file and asserts
every CYBER_PINNED_AGENTS entry is named in it — future edits
to either side cannot silently diverge.
C4 — cyber pin only fired in MultiModelExecutor.consult()
Direct HybridRouter.chat() calls from security agents bypassed
the pin. Extracted the pin helpers into src/routing/security/
cyber-pin.ts (applyCyberPin, shouldCyberPin, isOpus47,
CYBER_PINNED_AGENTS, CYBER_PIN_ADVISOR_FALLBACK,
CYBER_PIN_CHAT_FALLBACK). HybridRouter.chat() now applies the
pin post-selectProvider, before executeWithFallback, on both
decision.model and decision.providerModelId — covering
canonical, OpenRouter (dotted), and Bedrock ARN forms.
MultiModelExecutor.consult() imports from the same module so
both paths share one source of truth.
Tests moved tests/routing/advisor/cyber-pin.test.ts →
tests/routing/security/cyber-pin.test.ts and expanded: 19 tests
covering all 4 pinned agents × multiple model-id forms, the
application cross-check, env-flag semantics, non-security
passthrough, and non-4.7 model passthrough.
Verification:
* 0 tsc errors
* 128/128 targeted tests pass (effort-resolver + cyber-pin + advisor + providers)
* 2927/2927 broader regression pass (shared/llm + coordination + routing)
* Runtime proof of C1 fix: YAML 'medium' → resolveEffortLevel() returns 'medium'
Still outstanding from the devil's-advocate audit (deferred to
follow-up, not merge-blocking):
* C5 — Bedrock/OpenRouter model IDs need empirical verification
* C6 — no integration test hits real /v1/messages with 4.7
* H1–H5, M1–M5, L1–L3
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Commit 6 of 6 for ADR-093 Opus 4.7 migration. Opt-out gate behind
AQE_CYBER_VERIFIED env var.
* src/routing/advisor/multi-model-executor.ts: new applyCyberPin()
helper + CYBER_PINNED_AGENTS list (qe-pentest-validator,
qe-security-auditor, qe-security-scanner). When the advisor model
resolves to Opus 4.7 for any of these agents, the pin downgrades
to anthropic/claude-sonnet-4.6 and logs a warning naming the env
var to flip after Cyber Verification Program approval lands.
Non-security agents pass through unchanged. Non-4.7 models pass
through unchanged. Only AQE_CYBER_VERIFIED === 'true' lifts the
pin — '1', 'yes', truthy-but-non-"true" values keep the pin.
* tests/routing/advisor/cyber-pin.test.ts (new): 10 tests covering
all 3 pinned agents with pin-on and pin-off, non-security passthrough,
non-Opus-4.7 passthrough, canonical claude-opus-4-7 form, and
strict "true" semantics.
Fleet inventory note: 3 qe-* security/pentest agents exist. The
Cyber Verification application draft listed 4 (including a
qe-security-reviewer that does not exist in .claude/agents/v3/).
Verification:
* 0 tsc errors
* 75/75 advisor tests pass (+10 new)
* 16555/16564 unit + routing tests pass (9 pre-existing skips)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Commit 5 of 6 for ADR-093 (Commit 4 skipped — no thinking-config
callers to shim; documented in the implementation plan).
* src/routing/advisor/multi-model-executor.ts: DEFAULT_ADVISOR_MODEL
upgraded from 'anthropic/claude-opus-4' to 'anthropic/claude-opus-4.7'.
When TinyDancerRouter sets triggerMultiModel=true (confidence < 0.80,
or < 0.85 for security tasks), MultiModelExecutor.consult() now
dispatches to Opus 4.7 by default via HybridRouter.chat() +
OpenRouter provider.
* tests/routing/advisor/multi-model-executor.test.ts,
tiny-dancer-router-advisor.test.ts: update expected provider model IDs.
SWE-bench Verified 87.6% (vs 80.8% Opus 4.6), SWE-bench Pro 64.3%
(vs 53.4%), CursorBench 70% (vs 58%). Vendor-independence preserved —
consultations still flow through HybridRouter's 7 providers per
ADR-043.
Verification:
* 0 tsc errors
* 65/65 advisor unit tests pass
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Multi-model routing layer with circuit breaking, PII redaction, and
domain-specific prompts for the Queen coordinator.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
125 test files had beforeEach/beforeAll but no afterEach/afterAll,
leaking state between tests and causing order-dependent failures.
Added cleanup to 104 files (skipped 4 archived, 16 import-only):
- 2 critical DB handle leaks (witness-chain): added db.close()
- 7 high-risk service files: added vi.restoreAllMocks()
- 7 beforeAll files: added matching afterAll
- 88 medium/low risk: added afterEach with appropriate cleanup
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add anti-sycophancy scoring, test quality gates, blind review,
EMA calibration, edge-case injection, complexity-driven composition,
and auto-escalation. All features enabled by default (opt-out).
178 tests, 14 new files, 6 config flags.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>