From 564878fa2d238bb59fb8b6420b4107b583005710 Mon Sep 17 00:00:00 2001 From: rebuildup Date: Mon, 23 Nov 2026 20:46:27 +0900 Subject: [PATCH] feat(agent): add read-only attestation renewal status Fallback evidence expires after seven days, but there was no single read-only surface listing which route/model pairs need measured renewal. Add `agent attest status --json` and a weekly workflow that only reports stale/unknown candidates and opens a reminder issue; it never calls providers or uses credentials. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .github/workflows/attestation-renewal.yml | 56 +++++++++++ docs/adr/ADR-0018.md | 19 ++-- docs/agent-launcher.md | 16 ++++ script/agent.help.test.ts | 2 +- script/agent.test.ts | 21 +++++ script/agent.ts | 6 +- script/agent/args.ts | 12 +++ script/agent/commands.ts | 107 +++++++++++++++++++++- script/agent/help.ts | 5 + 9 files changed, 233 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/attestation-renewal.yml diff --git a/.github/workflows/attestation-renewal.yml b/.github/workflows/attestation-renewal.yml new file mode 100644 index 0000000..274ba1c --- /dev/null +++ b/.github/workflows/attestation-renewal.yml @@ -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 <` 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 diff --git a/docs/agent-launcher.md b/docs/agent-launcher.md index 5289556..f6b030a 100644 --- a/docs/agent-launcher.md +++ b/docs/agent-launcher.md @@ -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 diff --git a/script/agent.help.test.ts b/script/agent.help.test.ts index c1da18e..34ba85c 100755 --- a/script/agent.help.test.ts +++ b/script/agent.help.test.ts @@ -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 \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 \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. diff --git a/script/agent.test.ts b/script/agent.test.ts index f501674..c47c356 100644 --- a/script/agent.test.ts +++ b/script/agent.test.ts @@ -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) => { diff --git a/script/agent.ts b/script/agent.ts index 2e9b4e8..6c72d83 100755 --- a/script/agent.ts +++ b/script/agent.ts @@ -50,6 +50,7 @@ import { parseArgs } from "./agent/args"; import { cmdExec } from "./agent/exec"; import { usageText } from "./agent/help"; import { + cmdAttestStatus, cmdCheck, cmdFallback, cmdGuide, @@ -109,7 +110,7 @@ async function main(argv: string[]): Promise { 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] ) { @@ -144,6 +145,9 @@ async function main(argv: string[]): Promise { 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]); } diff --git a/script/agent/args.ts b/script/agent/args.ts index 23d94a3..bf2aae7 100644 --- a/script/agent/args.ts +++ b/script/agent/args.ts @@ -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 { @@ -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 [--json]"); diff --git a/script/agent/commands.ts b/script/agent/commands.ts index 157f336..df9c9c8 100644 --- a/script/agent/commands.ts +++ b/script/agent/commands.ts @@ -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";; @@ -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; + 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> = []; + 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 // --------------------------------------------------------------------------- diff --git a/script/agent/help.ts b/script/agent/help.ts index 0d74857..e9afb4c 100755 --- a/script/agent/help.ts +++ b/script/agent/help.ts @@ -643,6 +643,7 @@ export function buildHelpData(usage: string): HelpData { { name: "models ", 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)" }, ], @@ -667,6 +668,7 @@ usage: agent models agent shortcuts [list|check|create|remove] agent check + agent attest status [--json] agent guide [topic] agent routes [--json] agent fallback [--json] @@ -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,