Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/scripts/__tests__/capability-bundle-contract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,25 @@ test('keepalive metrics carry applied bundle metadata and rejection reasons', ()
assert.deepEqual(record.capability_rejection_reasons, ['repo']);
});

test('keepalive metrics ignore malformed capability bundle entries', () => {
const record = buildMetricsRecord({
prNumber: 123,
iteration: 2,
action: 'run',
errorCategory: 'none',
durationMs: 10,
tasksTotal: 3,
tasksComplete: 1,
capabilityBundles: {
applied: [null, 'invalid', [], { capability_id: 'keepalive/static-spa' }],
rejected: [null, 'invalid', [], { reason: 'repo' }],
},
});

assert.deepEqual(record.capability_bundle_ids, ['keepalive/static-spa']);
assert.deepEqual(record.capability_rejection_reasons, ['repo']);
});

test('capability bundle metrics input parser preserves applied and rejected arrays', () => {
const parsed = parseCapabilityBundlesInput(JSON.stringify({
applied: [{ capability_id: 'keepalive/static-spa' }],
Expand Down
8 changes: 6 additions & 2 deletions .github/scripts/keepalive_loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,12 @@ function buildMetricsRecord({
const capabilityResult = capabilityBundles && typeof capabilityBundles === 'object'
? capabilityBundles
: { applied: [], rejected: [] };
const applied = Array.isArray(capabilityResult.applied) ? capabilityResult.applied : [];
const rejected = Array.isArray(capabilityResult.rejected) ? capabilityResult.rejected : [];
const applied = Array.isArray(capabilityResult.applied)
? capabilityResult.applied.filter((bundle) => bundle && typeof bundle === 'object' && !Array.isArray(bundle))
: [];
const rejected = Array.isArray(capabilityResult.rejected)
? capabilityResult.rejected.filter((bundle) => bundle && typeof bundle === 'object' && !Array.isArray(bundle))
Comment thread
stranske marked this conversation as resolved.
Resolved
: [];
return {
pr_number: toNumber(prNumber, 0),
iteration: Math.max(1, toNumber(iteration, 0)),
Expand Down
17 changes: 17 additions & 0 deletions tests/tools/test_llm_registry_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@ def test_bundled_stale_slot_pin_uses_reviewed_registry_selection(
]


def test_bundled_stale_slot_pin_is_debug_only(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
registry_path = tmp_path / "registry.json"
slots_path = tmp_path / "slots.json"
_write_registry(registry_path)
_write_slots(slots_path, model="retired-model", profile="")
monkeypatch.setenv(registry.ENV_MODEL_REGISTRY_CONFIG, str(registry_path))
monkeypatch.delenv(registry.ENV_SLOT_CONFIG, raising=False)
monkeypatch.setattr(registry, "DEFAULT_SLOT_CONFIG_PATH", slots_path)

with caplog.at_level("WARNING"):
registry.load_slot_config()

assert "Skipping unresolved slot model pin" not in caplog.text
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved


def test_noncurrent_selected_model_fails_closed(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
Expand Down
21 changes: 14 additions & 7 deletions tools/llm_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,25 @@ def load_slot_config(*, github_default_model: str = "") -> list[SlotDefinition]:
):
model = explicit_model
elif provider and explicit_model and explicit_model != model:
logger.warning(
"Skipping unresolved slot model pin %s/%s; reviewed %s selection is %s",
provider,
explicit_model,
profile,
model or "unavailable",
)
# A caller-supplied slot file is an allowlist and must fail closed.
# The repository's bundled legacy file is advisory: ignore a stale
# pin and retain the reviewed registry selection for that provider.
if os.environ.get(ENV_SLOT_CONFIG):
logger.warning(
Comment thread
stranske marked this conversation as resolved.
Resolved
"Skipping unresolved slot model pin %s/%s; reviewed %s selection is %s",
provider,
explicit_model,
profile,
model or "unavailable",
)
continue
logger.debug(
"Ignoring advisory bundled slot model pin %s/%s; reviewed %s selection is %s",
provider,
explicit_model,
profile,
model or "unavailable",
)
if provider and configured_profile and not model:
logger.warning(
"Skipping slot with unresolved reviewed profile: %s/%s",
Expand Down
Loading