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
56 changes: 56 additions & 0 deletions .github/workflows/attestation-renewal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Attestation renewal

on:
schedule:
# Weekly reminder only: this workflow never calls providers or uses credentials.
- cron: '23 1 * * 1'
workflow_dispatch:

permissions:
contents: read
issues: write

jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
persist-credentials: false
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: '1.4.3'
- name: Install dev dependencies
run: bun install --frozen-lockfile
- name: Report fallback attestation state
run: |
bun script/agent.ts attest status --json > attest-status.json
cat attest-status.json
- name: Remind when measured evidence needs renewal
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
count=$(jq '[.candidates[] | select(.usable == false and (.reason == "attestation-stale" or .reason == "attestation-unknown"))] | length' attest-status.json)
if [ "$count" -eq 0 ]; then
echo "No stale/unknown fallback attestation evidence."
exit 0
fi
summary=$(jq -r '.candidates[] | select(.usable == false and (.reason == "attestation-stale" or .reason == "attestation-unknown")) | "- `\(.profile)` `\(.route)/\(.model)` — \(.reason), evidence=\(.evidence.at // "none")"' attest-status.json)
body=$(cat <<EOF
Weekly attestation renewal reminder (#217).

The read-only report found $count fallback candidate(s) whose measured E2E evidence is stale or absent:

$summary

Renewal procedure: re-run the real route/model probe (`agent task run` for omp routes or the harness-native run/print path for opencode/claude), confirm tool-call/file effects on disk, then update only the measured \`catalog.routes.*.e2e\` entries with the new \`at\`, \`sha\`, and note. Do not mark unverified routes verified-live; do not extend TTL or weaken checks. \`agent attest status --json\` is the read-only status command; this workflow never calls providers or uses credentials.
EOF
)
existing=$(gh issue list --repo "$GITHUB_REPOSITORY" --state open --search 'in:title "Attestation renewal due"' --json number --jq '.[0].number // empty')
if [ -n "$existing" ]; then
gh issue comment "$existing" --repo "$GITHUB_REPOSITORY" --body "$body"
else
gh issue create --repo "$GITHUB_REPOSITORY" --title "Attestation renewal due" --body "$body"
fi
19 changes: 11 additions & 8 deletions docs/adr/ADR-0018.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,17 @@ credentials, customer data or private material.
[`blocked-provider-investigation-2026-11-13`](../research/blocked-provider-investigation-2026-11-13.md);
all three are account-eligibility actions for the account owner, not
repository changes.
- **Attestation freshness is time-bounded.** The committed free-tier evidence
is dated `2026-11-13` and the freshness window is 7 days, so every `$0`
continuity profile stops resolving after about 2026-11-20 until the evidence
is refreshed. This is deliberate (stale capacity claims must not silently
look healthy) but it means the `$0` safety nets are not "set and forget":
re-measure and update the `[catalog.*]` evidence, or accept that the profile
reports no usable candidate. Re-verifying is a bounded, cheap operation
(`agent fallback <id>` shows the reason).
- **Attestation freshness is time-bounded.** Committed E2E evidence expires
7 days after its own `evidence.at`, so every `$0` continuity profile stops
resolving stale candidates until the evidence is refreshed. This is
deliberate (stale capacity claims must not silently look healthy) but it
means the `$0` safety nets are not "set and forget": re-measure and update
the `[catalog.*]` evidence, or accept that the profile reports no usable
candidate. `agent attest status [--json]` is the read-only status surface,
and the scheduled Attestation renewal workflow raises a repository reminder
when a fallback candidate is stale or unknown. Re-verifying stays bounded
and measured: only a real route/model probe may produce `verified-live`
evidence; CI never calls providers or uses credentials for renewal.

## Verification

Expand Down
16 changes: 16 additions & 0 deletions docs/agent-launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,22 @@ Any present restriction blocks; only an explicit `unknown` status is treated as
"no fact". A route with no committed evidence stays `attestation-unknown` and is
not usable.

### Attestation renewal

`agent attest status [--json]` is the read-only renewal report: it lists every
fallback candidate's route/model, usable verdict, rejection reason, attestation
status/provenance, and evidence timestamp/source/SHA without calling a provider
or reading credentials. The scheduled **Attestation renewal** workflow runs the
same report weekly and opens or comments on an issue only when a candidate is
`attestation-stale` or `attestation-unknown`.

Renewal is deliberately manual and measured: run the real route/model probe,
confirm the tool/file effect on disk, then update only that route/model's
committed `catalog.routes.*.e2e` evidence (`at`, `sha`, `note`, and the observed
`tool_call` result). Do not copy another model's evidence, do not mark an
unverified route `verified-live`, and do not extend `DEFAULT_MAX_EVIDENCE_AGE_MS`
or weaken freshness checks to avoid renewal.

## Route coverage notes

`claude.logfare` joins `opencode.logfare`: Logfare serves both an
Expand Down
2 changes: 1 addition & 1 deletion script/agent.help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ describe("human output redaction boundary (#122)", () => {

describe("help data", () => {
test("subcommands and further entries are backed by the usage text", () => {
const usage = "usage:\n agent list\n agent models <provider>\n agent shortcuts\n agent check\n agent guide [topic]\n agent routes [--json]\n agent help\n";
const usage = "usage:\n agent list\n agent models <provider>\n agent shortcuts\n agent check\n agent attest status [--json]\n agent guide [topic]\n agent routes [--json]\n agent help\n";
const data = buildHelpData(usage);
expect(data.usage).toBe(usage);
// Every listed subcommand's first word must exist in the usage text.
Expand Down
21 changes: 21 additions & 0 deletions script/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,27 @@ test(
}),
);

test(
"test_attest_status_reports_candidates_without_provider_calls",
withFixture((fixture) => {
const result = fixture.run(["attest", "status", "--json"], { config: REAL_CONFIG });
check(result.exitCode === 0, result.stderr.toString());
const report = JSON.parse(result.stdout.toString()) as {
candidates: Array<{ profile: string; route: string; model: string; usable: boolean; reason: string | null; evidence: { at?: string } | null }>;
maxEvidenceAgeMs: number;
};
check(report.candidates.length > 0, "attest status must list fallback candidates");
check(report.maxEvidenceAgeMs === 7 * 24 * 60 * 60 * 1000, "freshness window changed unexpectedly");
check(
report.candidates.every((c) => typeof c.profile === "string" && typeof c.route === "string" && typeof c.model === "string"),
"candidate identity fields missing",
);
const bad = fixture.run(["attest"], { config: REAL_CONFIG });
check(bad.exitCode === 2, "bare attest must exit 2");
check(bad.stderr.toString().includes("agent attest status"), bad.stderr.toString());
}),
);

test(
"test_check_validates_fallback_profiles",
withFixture((fixture) => {
Expand Down
6 changes: 5 additions & 1 deletion script/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { parseArgs } from "./agent/args";
import { cmdExec } from "./agent/exec";
import { usageText } from "./agent/help";
import {
cmdAttestStatus,
cmdCheck,
cmdFallback,
cmdGuide,
Expand Down Expand Up @@ -109,7 +110,7 @@ async function main(argv: string[]): Promise<number> {
const config = loadConfig();
const first = argv[0];
if (
!["help", "--help", "-h", "--version", "-V", "list", "check", "models", "shortcuts"].includes(first) &&
!["help", "--help", "-h", "--version", "-V", "list", "check", "models", "shortcuts", "attest"].includes(first) &&
!(first in config.harnesses) &&
shortcutMap(config)[first]
) {
Expand Down Expand Up @@ -144,6 +145,9 @@ async function main(argv: string[]): Promise<number> {
if (action[0] === "check") {
return cmdCheck(config);
}
if (action[0] === "attest") {
return cmdAttestStatus(config, action[2]);
}
if (action[0] === "models") {
return cmdModels(config, action[1]);
}
Expand Down
12 changes: 12 additions & 0 deletions script/agent/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export type Action =
| ["native", string, string[]]
| ["run", string, string, string | null, string[]]
| ["fallback", string, boolean] // profile-id, json
| ["attest", "status", boolean] // renewal status report, json
| ["review", string[]] // `agent review ...` tokens after the verb
| TaskAction
export function parseArgs(argv: string[]): Action {
Expand Down Expand Up @@ -260,6 +261,17 @@ export function parseArgs(argv: string[]): Action {
// harness/provider grammar so 'review' is never mistaken for a harness.
return ["review", argv.slice(1)];
}
if (head === "attest") {
if (argv[1] !== "status") {
throw new AgentError("usage: agent attest status [--json]");
}
let json = false;
for (let i = 2; i < argv.length; i++) {
if (argv[i] === "--json") json = true;
else throw new AgentError(`unexpected argument '${argv[i]}'; usage: agent attest status [--json]`);
}
return ["attest", "status", json];
}
if (head === "fallback") {
if (argv.length < 2) {
throw new AgentError("usage: agent fallback <profile-id> [--json]");
Expand Down
107 changes: 106 additions & 1 deletion script/agent/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { readFileSync } from "node:fs";;
import { join } from "node:path";;
import { getPrimaryQuotaScope, loadCatalog } from "./catalog.ts";;
import { buildFallbackCatalog, listFallbackProfiles, loadCatalogAttestations, mergeAttestations, parseFallbackProfile, resolveFallbackProfile, renderFallbackResolution, seedAttestationsFromCatalog } from "./fallback.ts";;
import { ContractError, parseTomlTable, redactJson, splitRouteKey } from "./contract.ts";;
import { ContractError, DEFAULT_MAX_EVIDENCE_AGE_MS, parseTomlTable, redactJson, splitRouteKey } from "./contract.ts";;
import { routeDefaultModel, type Config, type Harness, type Provider, type Route } from "./config.ts";;
import { AgentError, EXIT_RUNTIME, EXIT_USAGE } from "./errors.ts";;
import { finalize, launchArgv, needsInjection, runInherited, startViaWithSecrets } from "./exec.ts";;
Expand Down Expand Up @@ -306,6 +306,111 @@ export function cmdCheck(config: Config): number {
return 0;
}

/**
* `agent attest status [--json]`: report every fallback candidate's current
* attestation state without executing providers. This is the read-only side of
* the weekly renewal loop: stale/unknown entries identify exactly which
* route+model pairs need a fresh measured E2E before they can be verified.
*/
export function cmdAttestStatus(config: Config, json: boolean): number {
let parsedToml: Record<string, unknown>;
try {
parsedToml = parseTomlTable(readFileSync(config.path, "utf8"), config.path);
} catch (error) {
if (error instanceof ContractError) throw new AgentError(error.message, EXIT_USAGE);
throw error;
}
let catalogFacts;
try {
catalogFacts = loadCatalog(config.path);
} catch (error) {
if (error instanceof ContractError) throw new AgentError(error.message, EXIT_RUNTIME);
throw error;
}
const catalogLike = buildFallbackCatalog(config, catalogFacts);
const attestationMap = mergeAttestations(
seedAttestationsFromCatalog(catalogFacts),
loadCatalogAttestations(),
);
let profileIds: string[];
try {
profileIds = listFallbackProfiles(parsedToml);
} catch (error) {
if (error instanceof ContractError) throw new AgentError(error.message, EXIT_USAGE);
throw error;
}
const rows: Array<Record<string, unknown>> = [];
for (const id of profileIds) {
let profile;
try {
profile = parseFallbackProfile(parsedToml, id);
} catch (error) {
if (error instanceof ContractError) throw new AgentError(error.message, EXIT_USAGE);
throw error;
}
if (profile === null) continue;
let resolution;
try {
resolution = resolveFallbackProfile(
profile,
catalogLike,
attestationMap,
getPrimaryQuotaScope(catalogFacts, profile.primaryRoute),
);
} catch (error) {
if (error instanceof ContractError) throw new AgentError(error.message, EXIT_RUNTIME);
throw error;
}
const usable = new Set(
resolution.usable.map((u) => `${u.candidate.route}#${u.candidate.model}`),
);
for (const candidate of profile.candidates) {
const key = `${candidate.route}#${candidate.model}`;
const att = attestationMap.get(key);
const value = att?.value;
const valueStatus =
typeof value === "object" && value !== null && typeof value.status === "string"
? value.status
: null;
const rejected = resolution.rejected.find(
(r) => r.candidate?.route === candidate.route && r.candidate.model === candidate.model,
);
rows.push({
profile: profile.id,
route: candidate.route,
model: candidate.model,
usable: usable.has(key),
reason: rejected?.reason ?? null,
status: valueStatus ?? att?.status ?? "absent",
provenance: (typeof value === "object" && value !== null ? value.provenance : null) ?? att?.provenance ?? null,
evidence: (typeof value === "object" && value !== null ? value.evidence : null) ?? att?.evidence ?? null,
});
}
}
const generatedAt = new Date().toISOString();
if (json) {
console.log(redactJson({
generatedAt,
maxEvidenceAgeMs: DEFAULT_MAX_EVIDENCE_AGE_MS,
candidates: rows,
}));
return 0;
}
console.log(
`attestation status ${generatedAt} (max evidence age ${Math.round(DEFAULT_MAX_EVIDENCE_AGE_MS / 86400000)}d)`,
);
for (const row of rows) {
const evidence = row.evidence as { at?: string; source?: string; sha?: string } | null;
console.log(
`${String(row.profile)} ${String(row.route)}/${String(row.model)}: ` +
`${row.usable ? "usable" : String(row.reason ?? "unusable")} ` +
`status=${String(row.status)} evidence=${evidence?.at ?? "none"} ` +
`source=${evidence?.source ?? "none"} sha=${evidence?.sha ?? "none"}`,
);
}
return 0;
}

// ---------------------------------------------------------------------------
// Progressive disclosure (issue #88): help --json / guide / routes
// ---------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions script/agent/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ export function buildHelpData(usage: string): HelpData {
{ name: "models <provider>", summary: "credential names and models of a provider" },
{ name: "shortcuts", summary: "list/check/create/remove shortcut entry points" },
{ name: "check", summary: "validate config/agents.toml" },
{ name: "attest status", summary: "report fallback attestation freshness without provider calls" },
{ name: "guide [topic]", summary: "progressive-disclosure guide (see --json)" },
{ name: "routes", summary: "route table with catalog facts (see --json)" },
],
Expand All @@ -667,6 +668,7 @@ usage:
agent models <provider>
agent shortcuts [list|check|create|remove]
agent check
agent attest status [--json]
agent guide [topic]
agent routes [--json]
agent fallback <profile-id> [--json]
Expand Down Expand Up @@ -694,6 +696,9 @@ subcommands:
agent shortcuts remove remove only the entries that point at this
launcher; other files are left untouched
agent check validate config/agents.toml (used by CI)
agent attest status report fallback attestation freshness for every
configured candidate; --json for machine-readable
renewal status (no provider calls)
agent guide [topic] progressive disclosure: routes, status, limits,
distributed, recovery, quality, misfire
agent routes route table with catalog facts (quota scopes,
Expand Down
Loading