diff --git a/CATES-v1.0.md b/CATES-v1.0.md index 47521ef..bb72058 100644 --- a/CATES-v1.0.md +++ b/CATES-v1.0.md @@ -16,6 +16,14 @@ > [Modern Agent Assurance](docs/MODERN-AGENT-ASSURANCE.md). That proposal is > non-normative, manually assessed, and not implemented as additional analyzer > rules, scores, or gates. +> +> Scores deduct detected findings from 100; they are not earned assurance. +> A critical finding can coexist with an A-grade. Exclusions, suppressions, +> severity overrides and scan scope affect comparisons. Static token-impact +> estimates may overlap and are not measured runtime savings. +> [Optional runtime records](docs/RUNTIME-EVIDENCE.md) can accompany reports, +> but are caller-reported, not independently verified, and never affect these +> v1 predicates, scores or gates. ## Abstract @@ -25,7 +33,8 @@ CATES is designed as an actionable, tool-verifiable standard for this space — Configuration content consumes context when an assistant actually loads it. Loading, caching, billing, and context limits vary by client and model. CATES -provides discipline for managing that footprint without sacrificing capability. +provides discipline for managing that footprint. Capability and task outcomes +must be evaluated independently before adopting configuration changes. --- diff --git a/README.md b/README.md index 8d5d787..2160651 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,19 @@ The **initial scan remains a static configuration assessment**, not a bill or proof of economic performance. For end-to-end costs and accepted-task outcomes, use the separate, opt-in [experimental economics assessment](#experimental-end-to-end-token-economics). +**A grade is not an assurance certificate.** Scores start at 100 and deduct +detected findings after policy overrides and exclusions; one critical finding +can coexist with an A. Reports highlight unresolved critical findings regardless +of grade and disclose disabled/suppressed findings and discovery limits. +No findings does not establish safety, effective permissions or task correctness. +Compare scores only under the same policy and scan scope. + +To pair static results with controlled permission probes and before/after +accepted-task costs, attach [optional runtime evidence](docs/RUNTIME-EVIDENCE.md): +`cates-analyzer . --runtime-evidence runtime-evidence.json`. +These records are **caller-reported, not independently verified**, and never +change scores, conformance levels or CI gates. + The [Modern Agent Assurance proposal](docs/MODERN-AGENT-ASSURANCE.md) records the October 29, 2026 standards review and current primary sources. It adds manual guidance for skills, effective permissions, MCP authorization, and @@ -57,7 +70,7 @@ the npm and GHCR installation paths documented in the release notes become the recommended options. The package installs two commands: **`cates-analyzer`** (reports inefficiencies) -and **`cates-optimize`** (deliberately applies the lossless fixes — see +and **`cates-optimize`** (deliberately applies structurally checked edits — see [Optimizer](#-optimizer--apply-lossless-fixes-cates-optimize)). The programmatic package API is ESM-only; CommonJS callers must use dynamic `import()`. @@ -354,7 +367,7 @@ rules: suppressions: - ruleId: SEC004 file: .github/copilot-instructions.md - reason: Covered by organization-level prompt protection + reason: Legacy wording criterion waived; host access controls reviewed separately owner: @platform-team expires: 2026-12-31 ``` @@ -427,7 +440,8 @@ cates-analyzer . --min-score 85 --fail-on critical,high ### 4. Refactor toward the CATES recommendations Every report contains a `recommendations` block, prioritized and -estimated in tokens saved per invocation. Start at priority 1 and work +estimated as heuristic configuration-token impacts, not measured savings. Impacts +can overlap and may not reflect actual client loading. Start at priority 1 and work down — each item lists the affected files, the safety classification, and whether it's autofixable. @@ -446,16 +460,17 @@ manifest (`cates-analyzer demo --limit 25`). The analyzer **reports** what's inefficient. `cates-optimize` is a **separate, deliberately-run tool** that **acts on that report**: it rewrites your Copilot primitives (instructions, prompts, chat modes, agents, skills, rules files) to be -as token-efficient as possible **while guaranteeing no loss of function**, then -prints a report of what it achieved and the estimated efficiency gain. +reduce configuration source tokens using structural text checks, then +prints source-token counts and a static re-score. It does **not** establish +unchanged model behavior, task quality, request-token reductions or lower bills. It is intentionally **not** wired into `cates-analyzer` — you run it on purpose. -### The guarantee +### What the checks establish -`cates-optimize` only applies **lossless** transforms — it never rewrites, -reorders, or rescopes guidance. It strips only mechanically-redundant or no-op -bytes: +`cates-optimize` retains the legacy `lossless` safety label for compatibility. +It removes duplicates, recognized filler and whitespace; even these edits can +change how a model follows instructions. Available transformations: | Optimizer | Rule | What it removes | | --- | --- | --- | @@ -464,9 +479,11 @@ bytes: | `remove-filler` | TE003 | Standalone lines that only restate model defaults (e.g. "You are a helpful assistant") | | `whitespace` | — | Trailing whitespace, blank-line runs (code fences untouched) | -Before writing any file, the tool verifies the **meaningful-instruction set** and -**every code block** are byte-for-byte preserved, then **re-scores with the same -CATES engine** so the before/after numbers are exact. Anything that needs human +Before writing any file, the tool compares a **normalized set of non-filler lines +and code-line entries**, then **re-scores with the same CATES engine**. +The signature ignores order and repetition and uses heuristic filler matching; +it does not prove byte-identical code blocks or semantic/behavioral equivalence. +Run representative before/after tasks before adopting edits. Anything that needs human judgement (restructuring always-loaded context, extracting big code examples, rewriting forced verbosity or negative-constraint lists, deduping across files, removing secrets) is **left untouched** and surfaced as "remaining opportunities". @@ -492,7 +509,7 @@ cates-optimize . --only dedupe-lines,whitespace The report leads with the headline efficiency gain (token reduction on active and always-loaded config), a before/after table (tokens, CATES score, findings), the -per-file changes, the no-loss-of-function guarantee log, and the remaining +per-file changes, the text-check details and limitations, and the remaining manual opportunities. ## 🧪 Experimental: cache & output shaping @@ -663,7 +680,7 @@ Policy suppressions can be used for documented false positives or temporary acce suppressions: - ruleId: SEC004 file: .github/copilot-instructions.md - reason: Covered by organization-level prompt protection + reason: Legacy wording criterion waived; host access controls reviewed separately expires: 2026-12-31 ``` diff --git a/docs/AGENTIC-SDLC.md b/docs/AGENTIC-SDLC.md index 8abed55..f8dc154 100644 --- a/docs/AGENTIC-SDLC.md +++ b/docs/AGENTIC-SDLC.md @@ -1,5 +1,13 @@ # Agentic SDLC for CATES +Static scores and conformance are configuration criteria, not runtime approval. +Before adopting agent configuration changes, use controlled allow/deny probes, +independent task acceptance and before/after cost per accepted task. +Attach redacted records with `--runtime-evidence` as described in +[runtime evidence](RUNTIME-EVIDENCE.md); these are reported, not verified, +and do not change the existing score or gates. Keep runtime release decisions +with the evaluation system and human approvers. + One issue, one agent workstream, one PR, existing delivery gates. No new orchestrator, hosted model, paid automation, or secret is required. This is a human-triggered coding-agent lifecycle, not an unattended merge bot. diff --git a/docs/RUNTIME-EVIDENCE.md b/docs/RUNTIME-EVIDENCE.md new file mode 100644 index 0000000..383a888 --- /dev/null +++ b/docs/RUNTIME-EVIDENCE.md @@ -0,0 +1,95 @@ +# Pairing static assessment with runtime evidence + +CATES is a static configuration analyzer, not a runtime enforcement plane. +Existing rules, scores, thresholds, conformance criteria and gates remain +unchanged. Reports include `assessment` metadata describing static scope, +discovery limits and policy exclusions. SEC004 still checks legacy non-disclosure +wording for compatibility; that wording does not protect secrets or enforce access. + +## Optional records, not certification + +Copy `examples/runtime-evidence.json` to a local file and replace the placeholders +with records from your own controlled evaluations: + +```bash +cates-analyzer . --runtime-evidence runtime-evidence.json +cates-analyzer review https://github.com/OWNER/REPO --runtime-evidence runtime-evidence.json --format json +``` + +The CLI reads one regular JSON file up to 100,000 bytes. It never runs probes, +contacts models, fetches evidence references, or sends telemetry. The library +accepts the same object as `analyze({ repoPath, runtimeEvidence })` or +`analyzeInMemory({ files, runtimeEvidence })`. Both service endpoints, +`POST /api/analyze` and `POST /api/scan`, accept `runtimeEvidence` alongside +their normal input; it is not a policy setting. Service body limits still apply. + +Records appear separately in pretty/JSON/SARIF output as **reported, not verified**. +The dashboard's optional runtime evidence file input attaches the same JSON with +your next scan and shows check statuses, unassessed kinds and outcome summaries. +Failed probes and +missing checks stay visible but **do not change static scores or gates**. +If runtime checks must block delivery, gate on your evaluation system's results, +not a CATES grade or a submitted claim of success. + +Use only redacted records and artifact references: no secrets, raw sensitive +prompts, credentials or private transcript contents. Records are included in +reports and API responses; treat shared reports accordingly. + +## What to collect + +Use a disposable environment and synthetic data; do not test destructive +operations or real exfiltration against production. + +| Check kind | Evidence to record | +| --- | --- | +| `effective-configuration` | Actual client/version, loaded instructions, precedence, effective tool/host permissions, sandbox and relevant backend authorization | +| `permission-allow` | A controlled permitted operation and the observed result | +| `permission-deny` | A controlled forbidden operation and the observed denial at the enforcing host/service boundary, not just model refusal | +| `task-acceptance` | Representative task execution and independent acceptance criteria, including tests and human review where needed | + +Each check has a description and `pass`, `fail` or `not-run` status. +Pass/fail records require an evidence reference. At most 50 checks are accepted; +text fields are bounded to 512 characters. Missing and not-run check kinds are +explicitly unassessed. A passed probe establishes only the tested case, not +universal permission enforcement. CATES validates the record shape, not its truth. + +`context` records the claimed revision, client, model and environment; +`recordedAt` must be an ISO timestamp with a timezone. **CATES does not verify +revision correspondence, freshness, client version, provenance or artifact +contents.** Independently confirm these match the configuration being assessed. +The example is an unexecuted template, not evidence of a passing system. + +## Compare outcomes, not just shorter prompts + +Optional `outcomes.baseline` and `outcomes.candidate` cohorts record revision, +task-suite identity, client, model, environment, attempted/accepted task counts, +total cost, currency, whether all attempts are included, and an evidence reference. +Acceptance must use the same criteria across both cohorts. Count unsuccessful, +abandoned and retried work in the costs; use the existing +[economics ledger](TOKEN-ECONOMICS.md) for request-level accounting. + +CATES reports acceptance rate and cost per accepted task. Cost per accepted task +is **unknown (`null`)** if cost is missing, all attempts were not included, or +no task was accepted. Zero attempted tasks also yields an unknown acceptance rate. +Unknown is never replaced with zero cost or zero improvement. + +A cost comparison is reported only when task-suite, client, model, environment +and currency labels match, the candidate matches the reported context, and both +cost rates are known. The delta is candidate minus baseline; negative means a +lower reported cost per accepted task. Matching labels alone do not control task +difficulty, workload mix or measurement error: this is a **descriptive comparison, +not causal savings, ROI or statistical evidence of improvement**. + +## Compatibility + +Legacy savings field names (`estimatedTokenWaste`, `tokenSavings`, +`conservativeTokensPerInvocation`, `projectedTokensPerInvocation`, +`estimatedTokensSavedPerInvocation`, `efficiencyGainPct`) remain available. +Their numeric calculations are unchanged; interpret them as static heuristics or +source-token changes, never measured runtime savings. + +Optimizer `safety: "lossless"` and per-file `functionPreserved` remain legacy +text-check labels. `guarantee.noLossOfFunction` now returns **false**, because +behavioral equivalence was never established. Use +`guarantee.textPreservationChecksPassed` for structural-check status; +`guarantee.behaviorPreservation` is `"not-assessed"`, including no-change runs. diff --git a/examples/runtime-evidence.json b/examples/runtime-evidence.json new file mode 100644 index 0000000..529c0e2 --- /dev/null +++ b/examples/runtime-evidence.json @@ -0,0 +1,44 @@ +{ + "version": 1, + "recordedAt": "2026-01-01T00:00:00Z", + "context": { + "revision": "REPLACE_WITH_TESTED_REVISION", + "client": "REPLACE_WITH_CLIENT_AND_VERSION", + "model": "REPLACE_WITH_MODEL_AND_VERSION", + "environment": "REPLACE_WITH_DISPOSABLE_ENVIRONMENT" + }, + "checks": [ + { "kind": "effective-configuration", "description": "Capture effective loading, precedence and host/service permissions", "status": "not-run" }, + { "kind": "permission-allow", "description": "Probe an explicitly permitted operation with synthetic data", "status": "not-run" }, + { "kind": "permission-deny", "description": "Probe a forbidden operation and confirm host/service denial", "status": "not-run" }, + { "kind": "task-acceptance", "description": "Evaluate representative tasks against independent acceptance criteria", "status": "not-run" } + ], + "outcomes": { + "baseline": { + "revision": "REPLACE_WITH_BASELINE_REVISION", + "taskSuite": "REPLACE_WITH_TASK_SUITE_ID", + "client": "REPLACE_WITH_CLIENT_AND_VERSION", + "model": "REPLACE_WITH_MODEL_AND_VERSION", + "environment": "REPLACE_WITH_DISPOSABLE_ENVIRONMENT", + "attemptedTasks": 0, + "acceptedTasks": 0, + "totalCost": null, + "currency": "USD", + "includesAllAttempts": false, + "evidence": "UNEXECUTED_TEMPLATE_REPLACE_WITH_REDACTED_ARTIFACT_REFERENCE" + }, + "candidate": { + "revision": "REPLACE_WITH_TESTED_REVISION", + "taskSuite": "REPLACE_WITH_TASK_SUITE_ID", + "client": "REPLACE_WITH_CLIENT_AND_VERSION", + "model": "REPLACE_WITH_MODEL_AND_VERSION", + "environment": "REPLACE_WITH_DISPOSABLE_ENVIRONMENT", + "attemptedTasks": 0, + "acceptedTasks": 0, + "totalCost": null, + "currency": "USD", + "includesAllAttempts": false, + "evidence": "UNEXECUTED_TEMPLATE_REPLACE_WITH_REDACTED_ARTIFACT_REFERENCE" + } + } +} diff --git a/package.json b/package.json index b5bd20b..a02d92b 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,9 @@ "docs/TOKEN-ECONOMICS.md", "docs/COPILOT-HYGIENE.md", "docs/MODERN-AGENT-ASSURANCE.md", - "examples/economics.json" + "docs/RUNTIME-EVIDENCE.md", + "examples/economics.json", + "examples/runtime-evidence.json" ], "scripts": { "build": "tsc && chmod +x dist/cli/index.js dist/optimizer/cli.js", diff --git a/service/api/handlers.ts b/service/api/handlers.ts index 828235b..f852758 100644 --- a/service/api/handlers.ts +++ b/service/api/handlers.ts @@ -71,6 +71,7 @@ async function runAnalyzeInMemory(req: AnalyzeRequest): Promise> includeFiles: resolved.includeFiles, scanSubpath: resolved.scanSubpath, tokenizer: req.tokenizer, + runtimeEvidence: req.runtimeEvidence, ...policyOptions, }; const result = await analyze(options); diff --git a/service/shared/schemas.ts b/service/shared/schemas.ts index e5cc5d4..373beb2 100644 --- a/service/shared/schemas.ts +++ b/service/shared/schemas.ts @@ -2,6 +2,7 @@ // Licensed under the MIT license. import { z } from 'zod'; import { AnalyzerOptionsSchema, CopilotTargetSchema } from '../../src/types.js'; +import { RuntimeEvidenceSchema } from '../../src/assurance.js'; // ─── Shared scalar schemas ─────────────────────────────────────────────────── @@ -69,6 +70,7 @@ export const FilePayloadSchema = z.object({ export const AnalyzeRequestSchema = z .object({ + runtimeEvidence: RuntimeEvidenceSchema.optional(), files: z .array(FilePayloadSchema) .min(1) @@ -87,6 +89,7 @@ export type AnalyzeRequest = z.infer; export const ScanRequestSchema = z .object({ + runtimeEvidence: RuntimeEvidenceSchema.optional(), // Must be a GitHub URL — argv-injection guards in parseGitHubLink will // additionally validate the components before any shell-out happens. url: z diff --git a/service/web/app.js b/service/web/app.js index 75d508a..c63346d 100644 --- a/service/web/app.js +++ b/service/web/app.js @@ -34,10 +34,35 @@ const hasCoreFiles = data.discovery.files.some(file => file.isActive); $('r-score').textContent = hasCoreFiles ? data.score.overall : '—'; $('r-score').className = 'value ' + (hasCoreFiles ? gradeClass(data.score.grade) : ''); + const excludedCritical = [...(data.suppressedFindings ?? []), ...(data.disabledFindings ?? [])] + .filter(finding => finding.severity === 'critical').length; + if (data.score.criticalCount > 0 || excludedCritical > 0) $('r-score').className = 'value grade-F'; $('r-grade').textContent = hasCoreFiles ? data.score.grade : 'No active core-scan files'; $('r-findings').textContent = data.findings.length; $('r-critical').textContent = data.score.criticalCount + ' critical'; + $('r-critical-warning').hidden = data.score.criticalCount === 0 && excludedCritical === 0; + $('r-critical-warning').textContent = `${data.score.criticalCount} unresolved CRITICAL finding(s), regardless of grade.${excludedCritical ? ` ${excludedCritical} additional critical finding(s) excluded by policy; not scored.` : ''}`; + $('r-policy-scope').textContent = `Scope: ${data.discovery.files.filter(file => file.isActive).length} discovered active file(s) only; unrecognized, excluded and external surfaces are not assessed. Policy exclusions: ${data.suppressedFindings?.length ?? 0} suppressed finding(s), ${data.disabledFindings?.length ?? 0} disabled finding(s). Disabled rules/dimensions: ${[...(data.disabledRuleIds ?? []), ...(data.disabledDimensions ?? [])].join(', ') || 'none reported'}.`; + const runtime = data.runtimeEvidence; + $('r-runtime-warning').hidden = !runtime?.failedChecks; + $('r-runtime-warning').textContent = runtime?.failedChecks + ? `${runtime.failedChecks} REPORTED RUNTIME FAILURE(S). Not independently verified; static grade unchanged.` + : ''; + $('r-runtime-summary').textContent = runtime + ? `REPORTED, NOT VERIFIED: ${runtime.context.client}, revision ${runtime.context.revision}, recorded ${runtime.recordedAt}. ${runtime.failedChecks} reported failed check(s). Unassessed: ${runtime.unassessedChecks.join(', ') || 'none reported missing; scope unverified'}. ${runtime.note}` + : 'No runtime evidence supplied. Effective loading, permissions, task correctness and actual costs remain unassessed.'; + $('r-runtime-checks').innerHTML = (runtime?.checks ?? []).map(check => + `

${escape(check.kind)}: ${escape(check.status)} — ${escape(check.description)}${check.evidence ? ` (${escape(check.evidence)})` : ''}

` + ).join(''); + const outcomes = runtime?.outcomes; + $('r-runtime-outcomes').hidden = !outcomes; + $('r-runtime-outcomes').textContent = outcomes + ? ['baseline', 'candidate'].map(key => { + const cohort = outcomes[key]; + return `${key}: ${cohort.acceptedTasks}/${cohort.attemptedTasks} tasks accepted; cost/accepted task: ${cohort.costPerAcceptedTask ?? 'unknown'} ${cohort.currency}.`; + }).join(' ') + ` Change (candidate minus baseline): ${outcomes.costPerAcceptedTaskChange ?? 'unknown/not comparable'}. ${outcomes.note}` + : ''; $('r-tokens').textContent = (data.discovery?.alwaysLoadedTokens ?? 0).toLocaleString(); $('r-waste').textContent = data.score.estimatedTokenWaste.toLocaleString(); @@ -275,13 +300,20 @@ } }); + async function runtimeEvidencePayload() { + const file = $('runtime-evidence-file').files?.[0]; + if (!file) return {}; + if (file.size > 100_000) throw new Error('Runtime evidence exceeds 100,000 bytes.'); + return { runtimeEvidence: JSON.parse(await file.text()) }; + } + $('run-paste').addEventListener('click', async () => { const content = $('paste-content').value; const path = $('paste-type').value; if (!content.trim()) return showError('Paste some content first.'); const btn = $('run-paste'); btn.disabled = true; $('paste-status').textContent = 'Scoring…'; try { - const body = { files: [{ path, content }] }; + const body = { files: [{ path, content }], ...await runtimeEvidencePayload() }; const policy = policyPayload(); if (policy) body.policy = policy; const data = await postJson('/api/analyze', body); @@ -298,7 +330,7 @@ if (!url) return showError('Enter a GitHub URL first.'); const btn = $('run-scan'); btn.disabled = true; $('scan-status').textContent = 'Cloning + scoring (this can take a few seconds)…'; try { - const body = { url }; + const body = { url, ...await runtimeEvidencePayload() }; const policy = policyPayload(); if (policy) body.policy = policy; const data = await postJson('/api/scan', body); diff --git a/service/web/index.html b/service/web/index.html index 53f2480..ecab017 100644 --- a/service/web/index.html +++ b/service/web/index.html @@ -52,6 +52,7 @@ .row > label.field { flex: 1 1 220px; } .row > * { min-width: 0; } button, select { min-height: 44px; } + input[type=file] { min-height: 44px; max-width: 100%; color: var(--text); font: inherit; } button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; } @@ -87,7 +88,8 @@ .finding-card { padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; } .finding-card p { margin: 8px 0 0; line-height: 1.5; } .finding-card header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } - .scope-note { padding: 12px 14px; border-left: 3px solid var(--warn); background: var(--panel); line-height: 1.5; } + .scope-note { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); line-height: 1.5; overflow-wrap: anywhere; } + #r-critical-warning, #r-runtime-warning { color: var(--bad); border-color: var(--bad); font-weight: 700; } .profile-description { margin-bottom: 0; } .pill { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; } @@ -166,6 +168,19 @@

CATES Service

Adds configuration hygiene and coverage notes without changing your stable score. Organization policies and runtime behavior still need verification.

+
+ Optional runtime evidence · reported, not verified +
+ +

Sent to this service with your next scan. + Do not include secrets or sensitive transcripts. CATES validates the record shape, + not its truth; evidence never changes static scores or gates.

+
+
+
Rule & dimension toggles · export as .cates.yml
@@ -237,14 +252,32 @@

CATES Service