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
11 changes: 10 additions & 1 deletion CATES-v1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

---

Expand Down
45 changes: 31 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()`.
Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -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.

Expand All @@ -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 |
| --- | --- | --- |
Expand All @@ -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".
Expand All @@ -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
Expand Down Expand Up @@ -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
```

Expand Down
8 changes: 8 additions & 0 deletions docs/AGENTIC-SDLC.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
95 changes: 95 additions & 0 deletions docs/RUNTIME-EVIDENCE.md
Original file line number Diff line number Diff line change
@@ -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.
44 changes: 44 additions & 0 deletions examples/runtime-evidence.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions service/api/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ async function runAnalyzeInMemory(req: AnalyzeRequest): Promise<HandlerResult<An
const result = await analyzeInMemory({
files: req.files,
tokenizer: req.tokenizer,
runtimeEvidence: req.runtimeEvidence,
...policyOptions,
});
return { ok: true, status: 200, body: result };
Expand All @@ -94,6 +95,7 @@ async function runScan(req: ScanRequest): Promise<HandlerResult<AnalysisResult>>
includeFiles: resolved.includeFiles,
scanSubpath: resolved.scanSubpath,
tokenizer: req.tokenizer,
runtimeEvidence: req.runtimeEvidence,
...policyOptions,
};
const result = await analyze(options);
Expand Down
3 changes: 3 additions & 0 deletions service/shared/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ───────────────────────────────────────────────────

Expand Down Expand Up @@ -69,6 +70,7 @@ export const FilePayloadSchema = z.object({

export const AnalyzeRequestSchema = z
.object({
runtimeEvidence: RuntimeEvidenceSchema.optional(),
files: z
.array(FilePayloadSchema)
.min(1)
Expand All @@ -87,6 +89,7 @@ export type AnalyzeRequest = z.infer<typeof AnalyzeRequestSchema>;

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
Expand Down
Loading