Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 18 additions & 21 deletions config/agents.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1128,32 +1128,32 @@ status = "verified-live"
provenance = "measured"

[catalog.routes."claude.openrouter-free".e2e.evidence]
at = "2026-11-01T00:00:00Z"
at = "2026-11-21T08:25:00Z"
source = "live-e2e"
sha = "fe67db6e8d27fc2b1b0f604ec2299eafb6e3f4e2"
note = "Real response + Bash tool call, claude 2.1.314."
sha = "9547021c2da03170e883dec307223c12f4a8480d"
note = "Real response + shell tool call (file create verified on disk) via agent launcher print mode, claude 2.1.328, 2026-11-21."

[catalog.routes."opencode.openrouter-free".e2e]
value = [{ model = "nvidia/nemotron-3-ultra-550b-a55b:free", tool_call = true }]
status = "verified-live"
provenance = "measured"

[catalog.routes."opencode.openrouter-free".e2e.evidence]
at = "2026-11-01T00:00:00Z"
at = "2026-11-21T08:25:00Z"
source = "live-e2e"
sha = "fe67db6e8d27fc2b1b0f604ec2299eafb6e3f4e2"
note = "Real response + Bash tool call, opencode 2.2.3."
sha = "9547021c2da03170e883dec307223c12f4a8480d"
note = "Real response + shell tool call (file create verified on disk) through the launcher run mode, opencode 2.3.2, 2026-11-21."

[catalog.routes."omp.openrouter-free".e2e]
value = [{ model = "nvidia/nemotron-3-ultra-550b-a55b:free", tool_call = true }]
status = "verified-live"
provenance = "measured"

[catalog.routes."omp.openrouter-free".e2e.evidence]
at = "2026-11-04T00:00:00Z"
at = "2026-11-21T08:20:00Z"
source = "live-e2e"
sha = "bed3716a5008c424a3b2bf97204f1d8ebafe8a6b"
note = "Real response + Bash tool call, OMP 18.16.0."
sha = "9547021c2da03170e883dec307223c12f4a8480d"
note = "Real response + shell tool call (file create verified on disk) via agent launcher print mode, omp 19.0.0, 2026-11-21."

[catalog.routes."claude.opencode-go".quota]
scope = "plan"
Expand Down Expand Up @@ -1597,31 +1597,28 @@ note = "Real response + tool call + file edits through the launcher, claude 2.1.
[catalog.routes."opencode.kilo".e2e]
value = [
{ model = "nvidia/nemotron-3-ultra-550b-a55b:free", tool_call = true },
{ model = "kilo-auto/free", tool_call = true },
{ model = "cohere/north-mini-code:free", tool_call = true },
]
status = "verified-live"
provenance = "measured"

[catalog.routes."opencode.kilo".e2e.evidence]
at = "2026-11-13T00:00:00Z"
at = "2026-11-21T08:20:00Z"
source = "live-e2e"
sha = "65a2bbc21d3e8dc889669c7bb818e567358a891f"
note = "Real response + tool call + file edits through the launcher, opencode 2.2.7; create-task and bug-fix task."
sha = "9547021c2da03170e883dec307223c12f4a8480d"
note = "Real response + shell tool call (file create verified on disk) through the launcher run mode, opencode 2.3.2, 2026-11-21. kilo-auto/free and cohere/north-mini-code:free dropped from this attestation pending re-verification."

[catalog.routes."omp.kilo".e2e]
value = [
{ model = "nvidia/nemotron-3-ultra-550b-a55b:free", tool_call = true },
{ model = "kilo-auto/free", tool_call = true },
]
status = "verified-live"
provenance = "measured"

[catalog.routes."omp.kilo".e2e.evidence]
at = "2026-11-13T00:00:00Z"
at = "2026-11-21T08:20:00Z"
source = "live-e2e"
sha = "65a2bbc21d3e8dc889669c7bb818e567358a891f"
note = "Real response + bash/edit tool calls + bun test through the launcher, omp 18.18.9; create-task and bug-fix task."
sha = "9547021c2da03170e883dec307223c12f4a8480d"
note = "Real response + shell tool calls (file create verified on disk) through agent task run, omp 19.0.0, 2026-11-21. kilo-auto/free dropped from this attestation pending re-verification."

[catalog.routes."claude.requesty".e2e]
value = [
Expand Down Expand Up @@ -1669,10 +1666,10 @@ status = "verified-live"
provenance = "measured"

[catalog.routes."omp.groq".e2e.evidence]
at = "2026-11-13T00:00:00Z"
at = "2026-11-21T08:20:00Z"
source = "live-e2e"
sha = "65a2bbc21d3e8dc889669c7bb818e567358a891f"
note = "Real response + bash/edit tool calls + bun test through the launcher, omp 18.18.9; create-task 320s and the bug-fix task."
sha = "9547021c2da03170e883dec307223c12f4a8480d"
note = "Real response + shell tool calls (file create verified on disk) through agent task run, omp 19.0.0, 2026-11-21."

# ---------------------------------------------------------------------------
# Fallback profiles (issue #136 / T020, Epic #86): opt-in continuity profiles
Expand Down
19 changes: 17 additions & 2 deletions script/agent.catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ import { ContractError, isUsable } from "./agent/contract";
const REPO = dirname(dirname(realpathSync(import.meta.path)));
const REAL_CONFIG = join(REPO, "config", "agents.toml");

/** Reference clock for freshness checks: fresh for every recorded evidence date. */
const NOW = Date.parse("2026-11-06T12:00:00Z");
/** Reference clock for freshness checks, anchored just after the freshest
* committed e2e evidence (set in beforeAll once the catalog is loaded).
* A fixed calendar date made this suite break on every evidence renewal —
* the same date-dependent trap as dotfiles#203; deriving `now` from the
* catalog keeps the freshness check itself exercised without coupling the
* suite to the renewal calendar. Operator-facing staleness detection lives
* in `agent check` warnings, not here. */
let NOW = Date.parse("2026-11-06T12:00:00Z");

let catalog: Catalog;

Expand Down Expand Up @@ -75,6 +81,15 @@ note = "fixture"
describe("loadCatalog: real config", () => {
beforeAll(() => {
catalog = loadCatalog(REAL_CONFIG);
let freshest = 0;
for (const route of Object.values(catalog.routes)) {
for (const attested of [route.e2e, route.restriction]) {
const at = attested?.evidence?.at;
const ms = typeof at === "string" ? Date.parse(at) : NaN;
if (Number.isFinite(ms) && ms > freshest) freshest = ms;
}
}
if (freshest > 0) NOW = freshest + 24 * 60 * 60 * 1000;
});

test("real config catalog validates (malformed catalog fails here)", () => {
Expand Down
25 changes: 19 additions & 6 deletions script/agent.fallback-exec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import { describe, it, expect } from "bun:test";;
import { classifyFailure, executeWithFallback, FallbackExhaustedError, CATEGORY_FACTS, CATEGORY_SEVERITY, FALLBACK_CIRCUIT_BREAKER_THRESHOLD, FALLBACK_CIRCUIT_BREAKER_RESET_MS, FALLBACK_MAX_RETRIES_PER_CANDIDATE, FALLBACK_MAX_TOTAL_RETRIES, type FallbackAttemptRecord } from "./agent/fallback-exec.ts";;
import { loadConfig } from "./agent/config.ts";;
import { loadConfig } from "./agent/config.ts";
import { loadCatalog } from "./agent/catalog.ts";
import { seedAttestationsFromCatalog } from "./agent/fallback.ts";;
import { ContractError, formatRouteId, parseRouteId } from "./agent/contract.ts";;
import { dirname, join } from "node:path";;
import { realpathSync } from "node:fs";;
Expand Down Expand Up @@ -256,11 +258,22 @@ describe("executeWithFallback", () => {

describe("FallbackExhaustedError", () => {
const realConfigPath = join(repoRoot(), "config", "agents.toml");
// The committed catalog e2e evidence is dated 2026-11-13; pin the
// resolution clock inside its 7-day freshness window so the suite does not
// silently start rejecting every candidate once wall-clock time passes it.
// The freshness check itself still runs — it just evaluates a fixed `now`.
const EVIDENCE_FRESH_NOW_MS = Date.parse("2026-11-14T00:00:00Z");
// Anchor the resolution clock just after the FRESHEST committed e2e
// evidence, whatever its date: pinning a fixed calendar date made the
// suite break every time evidence aged past (or was renewed beyond) the
// pin — the same date-dependent trap as dotfiles#203. Deriving `now` from
// the catalog keeps the freshness check itself running while making the
// mechanics under test independent of the renewal calendar. Staleness
// detection for operators lives in `agent check` warnings / `agent
// fallback`, not in this suite.
const catalogFactsForClock = loadCatalog(realConfigPath);
let freshestEvidenceMs = 0;
for (const attestation of seedAttestationsFromCatalog(catalogFactsForClock).values()) {
const at = attestation.evidence?.at ?? attestation.value?.evidence?.at;
const ms = typeof at === "string" ? Date.parse(at) : NaN;
if (Number.isFinite(ms) && ms > freshestEvidenceMs) freshestEvidenceMs = ms;
}
const EVIDENCE_FRESH_NOW_MS = freshestEvidenceMs + 24 * 60 * 60 * 1000;

/** Run the executor against a real profile with a stub task function. */
async function exhaustWith(
Expand Down
35 changes: 34 additions & 1 deletion script/agent/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ export function cmdCheck(config: Config): number {
// tables: a malformed profile (bad primary_route, bad cap, bad billing) must
// fail CI here rather than at `agent fallback` time with a stack trace.
let profileCount = 0;
let parsedToml: Record<string, unknown>;
try {
const parsedToml = parseTomlTable(readFileSync(config.path, "utf8"), config.path);
parsedToml = parseTomlTable(readFileSync(config.path, "utf8"), config.path);
for (const id of listFallbackProfiles(parsedToml)) {
parseFallbackProfile(parsedToml, id);
profileCount++;
Expand All @@ -263,6 +264,38 @@ export function cmdCheck(config: Config): number {
}
throw error;
}
// Attestation freshness is time-dependent: committed e2e evidence older
// than DEFAULT_MAX_EVIDENCE_AGE_MS silently disables every fallback
// candidate (dotfiles#203). Surface rejections as warnings on every
// `agent check` run — CI prints them — without failing the structural
// check, since renewal needs real provider calls CI cannot perform.
try {
const catalogFacts = loadCatalog(config.path);
const catalogLike = buildFallbackCatalog(config, catalogFacts);
const attestationMap = mergeAttestations(
seedAttestationsFromCatalog(catalogFacts),
loadCatalogAttestations(),
);
for (const id of listFallbackProfiles(parsedToml)) {
const profile = parseFallbackProfile(parsedToml, id);
if (profile === null) continue;
const resolution = resolveFallbackProfile(
profile,
catalogLike,
attestationMap,
getPrimaryQuotaScope(catalogFacts, profile.primaryRoute),
);
for (const rejected of resolution.rejected) {
const target = rejected.candidate
? `${rejected.candidate.route}/${rejected.candidate.model}`
: "(unresolved)";
console.log(`warning: fallback '${id}' rejects ${target}: ${rejected.reason}`);
}
}
} catch {
// Resolution warnings are advisory; structural validation above already
// failed closed on malformed input.
}
console.log(
`config OK: ${config.path} ` +
`(${Object.keys(config.providers).length} providers, ` +
Expand Down
Loading