Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(sdk): report the exact rubric used for severity classification (#2262)

Aismitcafc6c2651cb
diff --git a/plugins/codex-security/mcp-app/src/workbench/migrations.ts b/plugins/codex-security/mcp-app/src/workbench/migrations.ts
index 654e8d909..f619eb30b 100644
--- a/plugins/codex-security/mcp-app/src/workbench/migrations.ts
+++ b/plugins/codex-security/mcp-app/src/workbench/migrations.ts
@@ -225,7 +225,7 @@ export function applyMigrations(
} else if (item.version === 16) backfill = repairStableTargets(database);
else if (applied.has(item.version)) {
if (
- [2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59].includes(
+ [2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59, 60].includes(
item.version,
)
)
diff --git a/plugins/codex-security/mcp-app/src/workbench/severity.ts b/plugins/codex-security/mcp-app/src/workbench/severity.ts
index ca0c18fa8..8f3065119 100644
--- a/plugins/codex-security/mcp-app/src/workbench/severity.ts
+++ b/plugins/codex-security/mcp-app/src/workbench/severity.ts
@@ -33,6 +33,7 @@ export type SeverityCheckpoint =
findingIds: string[];
assessedAt: string;
rubricSha256: string | null;
+ rubric?: { sha256: string | null; revision?: number };
knowledgeBaseSha256: string | null;
classificationRuns?: number;
}
@@ -94,14 +95,15 @@ export function severityCheckpoint(
database
.prepare(
`INSERT INTO scan_severity_classifications (
- scan_id, finding_ids_json, assessed_at, rubric_sha256, knowledge_base_sha256, classification_runs
- ) VALUES (?, ?, ?, ?, ?, ?)
+ scan_id, finding_ids_json, assessed_at, rubric_sha256, knowledge_base_sha256, classification_runs, rubric_binding_json
+ ) VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(scan_id) DO UPDATE SET
finding_ids_json = excluded.finding_ids_json,
assessed_at = excluded.assessed_at,
rubric_sha256 = excluded.rubric_sha256,
knowledge_base_sha256 = excluded.knowledge_base_sha256,
- classification_runs = excluded.classification_runs`,
+ classification_runs = excluded.classification_runs,
+ rubric_binding_json = excluded.rubric_binding_json`,
)
.run(
payload.scanId,
@@ -110,6 +112,9 @@ export function severityCheckpoint(
payload.rubricSha256,
payload.knowledgeBaseSha256,
payload.classificationRuns ?? null,
+ payload.rubric === undefined
+ ? null
+ : stringifyJson(payload.rubric, 0),
);
// Cache hits are not saved again by the classifier. Keep each scan's own assessments.
database
@@ -208,16 +213,17 @@ export function readSeverityClassification(
.get()
)
return {};
- const hasRunCount = database
+ const columns = database
.prepare("PRAGMA table_info(scan_severity_classifications)")
.all()
- .some((column) => column.name === "classification_runs");
+ .map((column) => column.name);
const row = database
.prepare(
`SELECT json_object(
'findingIds', json(finding_ids_json), 'assessedAt', assessed_at,
'rubricSha256', rubric_sha256, 'knowledgeBaseSha256', knowledge_base_sha256
- ${hasRunCount ? ", 'classificationRuns', classification_runs" : ""}
+ ${columns.includes("classification_runs") ? ", 'classificationRuns', classification_runs" : ""}
+ ${columns.includes("rubric_binding_json") ? ", 'rubric', json(rubric_binding_json)" : ""}
) AS value FROM scan_severity_classifications WHERE scan_id = ?`,
)
.get(scanId);
diff --git a/plugins/codex-security/mcp-app/tests/test_workbench_database.ts b/plugins/codex-security/mcp-app/tests/test_workbench_database.ts
index 870364498..bec376917 100644
--- a/plugins/codex-security/mcp-app/tests/test_workbench_database.ts
+++ b/plugins/codex-security/mcp-app/tests/test_workbench_database.ts
@@ -168,8 +168,35 @@ test("every released schema upgrades to the same current schema and remains idem
}
});
+for (const previewVersion of [58, 59]) {
+ test(`preserves the saved rubric from preview migration ${previewVersion}`, (t) => {
+ const database = memory(t, previewVersion - 1);
+ const rubricMigration = migrations.find((item) => item.version === 60)!;
+ applyMigrations(database, [
+ { ...rubricMigration, version: previewVersion },
+ ]);
+ const rubric = JSON.stringify({ sha256: "a".repeat(64), revision: 2 });
+ database
+ .prepare(
+ "INSERT INTO scan_severity_classifications (scan_id, finding_ids_json, assessed_at, rubric_binding_json) VALUES ('scan', '[]', 'assessed', ?)",
+ )
+ .run(rubric);
+
+ applyMigrations(database);
+ assertMigrationNames(database, 58, 59, 60);
+ assert.equal(
+ database
+ .prepare(
+ "SELECT rubric_binding_json FROM scan_severity_classifications WHERE scan_id = 'scan'",
+ )
+ .get()?.rubric_binding_json,
+ rubric,
+ );
+ });
+}
+
for (const { missingVersions, legacyCheckpoint, mainReader } of [
- { missingVersions: [57, 58, 59], legacyCheckpoint: 0, mainReader: false },
+ { missingVersions: [57, 58, 59, 60], legacyCheckpoint: 0, mainReader: false },
{ missingVersions: [], legacyCheckpoint: 47, mainReader: false },
{ missingVersions: [], legacyCheckpoint: 47, mainReader: true },
{ missingVersions: [], legacyCheckpoint: 48, mainReader: false },
@@ -915,11 +942,17 @@ test("recorded additive migrations restore missing columns and configured error
database.exec(`INSERT INTO deep_scan_runs (scan_id, schema_version, workflow_version, status, phase,
workers, subagents, stop_after_no_new, max_discovery_runs, created_at, updated_at)
VALUES ('scan', 1, 'v1', 'running', 'discovery', 1, 0, 7, 10, 'created', 'updated')`);
- for (const version of [27, 28, 31, 32, 47, 54, 55, 58, 59])
+ for (const version of [27, 28, 31, 32, 47, 54, 55, 58, 59, 60])
database
.prepare("INSERT INTO schema_migrations VALUES (?, ?, 'original')")
.run(version, migrations[version - 1].name);
applyMigrations(database);
+ assert.ok(
+ database
+ .prepare("PRAGMA table_info(scan_severity_classifications)")
+ .all()
+ .some((column) => column.name === "rubric_binding_json"),
+ );
assert.equal(
database.prepare("SELECT service_tier FROM deep_scan_runs").get()
?.service_tier,
diff --git a/plugins/codex-security/scripts/workbench_schema.py b/plugins/codex-security/scripts/workbench_schema.py
index 39e5038ba..f9c23f350 100644
--- a/plugins/codex-security/scripts/workbench_schema.py
+++ b/plugins/codex-security/scripts/workbench_schema.py
@@ -75,7 +75,7 @@ def apply_migrations(
elif version == 16:
should_backfill_targets = repair_stable_targets_migration(connection)
elif version in applied:
- if version in (2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59):
+ if version in (2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59, 60):
repair_additive_migration(connection, version)
elif version == 11:
repair_deep_scan_migration(connection)
diff --git a/plugins/codex-security/shared/workbench-history-repairs.json b/plugins/codex-security/shared/workbench-history-repairs.json
index 1e9ca60b6..22f3a7b65 100644
--- a/plugins/codex-security/shared/workbench-history-repairs.json
+++ b/plugins/codex-security/shared/workbench-history-repairs.json
@@ -1,4 +1,11 @@
[
+ [
+ "WITH input AS (SELECT :history AS history)",
+ "SELECT 'sql' AS operation,",
+ " 'UPDATE schema_migrations SET version = 60 WHERE version = ' || version AS value",
+ "FROM schema_migrations",
+ "WHERE version IN (58, 59) AND name = 'record classification rubric provenance';"
+ ],
[
"-- Move checkpoint previews before source-scope history checks.",
"WITH input AS (SELECT :history AS history)",
diff --git a/plugins/codex-security/shared/workbench-migrations.json b/plugins/codex-security/shared/workbench-migrations.json
index 9468d50a0..db4ca7672 100644
--- a/plugins/codex-security/shared/workbench-migrations.json
+++ b/plugins/codex-security/shared/workbench-migrations.json
@@ -481,5 +481,12 @@
"version": 59,
"name": "retain the launching Deep Scan service tier",
"statements": ["ALTER TABLE deep_scan_runs ADD COLUMN service_tier TEXT;"]
+ },
+ {
+ "version": 60,
+ "name": "record classification rubric provenance",
+ "statements": [
+ "ALTER TABLE scan_severity_classifications ADD COLUMN rubric_binding_json TEXT;"
+ ]
}
]
diff --git a/plugins/codex-security/tests/test_workbench_deep_scan.py b/plugins/codex-security/tests/test_workbench_deep_scan.py
index 777f1fdbe..90924ddd5 100644
--- a/plugins/codex-security/tests/test_workbench_deep_scan.py
+++ b/plugins/codex-security/tests/test_workbench_deep_scan.py
@@ -97,6 +97,9 @@ def start_empty_target_scan(tmp_path: Path, *, config: str | None = None) -> Dee
def restore_v53_schema(state_dir: Path) -> None:
with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:
+ connection.execute(
+ "ALTER TABLE scan_severity_classifications DROP COLUMN rubric_binding_json"
+ )
connection.execute("ALTER TABLE deep_scan_runs DROP COLUMN service_tier")
connection.execute("ALTER TABLE deep_scan_runs DROP COLUMN terminal_reviewed_surface_count")
connection.execute("ALTER TABLE scans DROP COLUMN retained_checkpoint_heads_json")
diff --git a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py
index af07a5741..55f44834f 100644
--- a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py
+++ b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py
@@ -102,6 +102,7 @@ EXPECTED_MIGRATIONS = [
(57, "freeze stopped scan checkpoint selections"),
(58, "record the final Deep Scan reviewed surface count"),
(59, "retain the launching Deep Scan service tier"),
+ (60, "record classification rubric provenance"),
]
diff --git a/sdk/typescript/docs/cli.md b/sdk/typescript/docs/cli.md
index 3c28d4dd7..aaac4125d 100644
--- a/sdk/typescript/docs/cli.md
+++ b/sdk/typescript/docs/cli.md
@@ -1795,6 +1795,12 @@ the original `rubricLabel`, rationale, confidence, and a `reviewTrigger` for
missing facts that could change the result. Exclusions have a null level.
Finding/occurrence IDs and input hashes bind each assessment to its evidence.
+For a single rubric document, the classification result reports the SHA-256 of
+the exact UTF-8 text supplied to the reviewer in `rubricSha256`. For multiple
+documents it reports the digest of the ordered text collection. A bundled or
+remote default also records its `rubricRevision`. Older saved results retain
+their original digest and may omit the revision.
+
Successful assessments checkpoint immediately in local SQLite. Retries reuse
matching evidence, rubric, context hashes, and classification run count; failed/canceled runs keep completed
work. Default-rubric assessments use `source: "rubric"` and a content hash; former
diff --git a/sdk/typescript/src/classify-severity.ts b/sdk/typescript/src/classify-severity.ts
index a026a715d..8ff9c77e2 100644
--- a/sdk/typescript/src/classify-severity.ts
+++ b/sdk/typescript/src/classify-severity.ts
@@ -1,4 +1,8 @@
-import { getDefaultSeverityRubric } from "./severity-rubric.js";
+import { hash } from "node:crypto";
+import {
+ getDefaultSeverityRubric,
+ type SeverityRubricSnapshot,
+} from "./severity-rubric.js";
import { findingEntry } from "./value.js";
import { z } from "zod";
import { CodexSecurityError } from "./errors.js";
@@ -56,18 +60,29 @@ export interface SeverityClassification {
assessedAt: string;
/** Absent on legacy results whose review count was not recorded. */
classificationRuns?: number;
+ /** SHA-256 of the exact policy text, or the ordered document digest for collections and legacy results. */
rubricSha256: string | null;
+ /** Revision of the bundled or remote rubric. Unversioned file inputs and legacy results omit it. */
+ rubricRevision?: number;
knowledgeBaseSha256: string | null;
assessments: SeverityAssessment[];
}
+/** @internal Document collections retain their original checkpoint key. */
+export type SeverityClassificationBinding = Omit<
+ SeverityClassification,
+ "assessments"
+> & {
+ rubricCheckpointSha256: string | null;
+};
+
/** @internal Per-finding persistence used by saved-scan classification. */
export interface SeverityClassificationCheckpoint {
- load(result: SeverityClassification): Promise<SeverityAssessment[]>;
+ load(binding: SeverityClassificationBinding): Promise<SeverityAssessment[]>;
save(
finding: SeverityClassificationFinding,
assessment: SeverityAssessment,
- result: SeverityClassification,
+ binding: SeverityClassificationBinding,
): Promise<void>;
}
@@ -82,6 +97,7 @@ export const severityClassificationSchema = z.strictObject({
assessedAt: z.string().datetime(),
classificationRuns: classificationRunsSchema.optional(),
rubricSha256: digestSchema.nullable(),
+ rubricRevision: z.number().int().positive().optional(),
knowledgeBaseSha256: digestSchema.nullable(),
assessments: z.array(
decisionSchema.extend({
@@ -120,22 +136,38 @@ export async function classifySeverityInternal(
}
ids.add(finding.findingId);
}
- const rubric =
- options.rubricPath === undefined
- ? [(await getDefaultSeverityRubric(options)).markdown]
- : await readDocuments([options.rubricPath], options.signal);
+ let rubric: string[];
+ let defaultRubric: SeverityRubricSnapshot | undefined;
+ if (options.rubricPath === undefined) {
+ defaultRubric = await getDefaultSeverityRubric(options);
+ rubric = [defaultRubric.markdown];
+ } else {
+ rubric = await readDocuments([options.rubricPath], options.signal);
+ }
const knowledge = options.knowledgeBasePaths?.length
? await readDocuments(options.knowledgeBasePaths, options.signal)
: null;
- const result: SeverityClassification = {
- schemaVersion: 1,
+ const rubricCheckpointSha256 = workflowDigest(rubric);
+ const metadata = {
+ schemaVersion: 1 as const,
classificationRuns,
assessedAt: new Date().toISOString(),
- rubricSha256: workflowDigest(rubric),
+ ...(defaultRubric
+ ? {
+ rubricSha256: defaultRubric.sha256,
+ rubricRevision: defaultRubric.revision,
+ }
+ : {
+ rubricSha256:
+ rubric.length === 1
+ ? hash("sha256", rubric[0]!)
+ : rubricCheckpointSha256,
+ }),
knowledgeBaseSha256: knowledge === null ? null : workflowDigest(knowledge),
- assessments: [],
};
- const cached = new Map((await checkpoint?.load(result))?.map(findingEntry));
+ const result: SeverityClassification = { ...metadata, assessments: [] };
+ const binding = { ...metadata, rubricCheckpointSha256 };
+ const cached = new Map((await checkpoint?.load(binding))?.map(findingEntry));
for (const finding of findings) {
options.signal?.throwIfAborted();
const inputSha256 = workflowDigest(finding);
@@ -180,7 +212,7 @@ export async function classifySeverityInternal(
inputSha256,
source: "rubric",
};
- await checkpoint?.save(finding, assessment, result);
+ await checkpoint?.save(finding, assessment, binding);
result.assessments.push(assessment);
}
options.signal?.throwIfAborted();
diff --git a/sdk/typescript/src/severity-store.ts b/sdk/typescript/src/severity-store.ts
index ab3a2cbfd..0b9545335 100644
--- a/sdk/typescript/src/severity-store.ts
+++ b/sdk/typescript/src/severity-store.ts
@@ -3,6 +3,7 @@ import { join } from "node:path";
import {
severityClassificationSchema,
type SeverityClassification,
+ type SeverityClassificationBinding,
type SeverityClassificationCheckpoint,
} from "./classify-severity.js";
import type { JsonObject } from "./config.js";
@@ -42,7 +43,11 @@ export class SeverityStore {
findingIds,
assessedAt: result.assessedAt,
classificationRuns: result.classificationRuns,
- rubricSha256: result.rubricSha256,
+ rubricSha256: result.rubricCheckpointSha256,
+ rubric: {
+ sha256: result.rubricSha256,
+ revision: result.rubricRevision,
+ },
knowledgeBaseSha256: result.knowledgeBaseSha256,
});
return reprocess
@@ -60,7 +65,7 @@ export class SeverityStore {
assessment: {
...assessment,
classificationRuns: result.classificationRuns,
- rubricSha256: result.rubricSha256,
+ rubricSha256: result.rubricCheckpointSha256,
knowledgeBaseSha256: result.knowledgeBaseSha256,
},
});
@@ -82,6 +87,9 @@ export class SeverityStore {
}
const saved = await this.run("read-severity-classification", { scanId });
if (saved["scanId"] === undefined) return undefined;
+ const rubric = saved["rubric"] as
+ { sha256: string | null; revision?: number } | null | undefined;
+ const rubricCheckpointSha256 = saved["rubricSha256"] as string | null;
const result = matchingClassification(
saved["assessments"] as JsonObject[],
{
@@ -89,7 +97,11 @@ export class SeverityStore {
assessedAt: saved["assessedAt"] as string,
classificationRuns: (saved["classificationRuns"] ?? undefined) as
number | undefined,
- rubricSha256: saved["rubricSha256"] as string | null,
+ rubricSha256: rubric?.sha256 ?? rubricCheckpointSha256,
+ ...(rubric?.revision === undefined
+ ? {}
+ : { rubricRevision: rubric.revision }),
+ rubricCheckpointSha256,
knowledgeBaseSha256: saved["knowledgeBaseSha256"] as string | null,
},
);
@@ -136,7 +148,7 @@ export class SeverityStore {
function matchingClassification(
stored: JsonObject[],
- result: Omit<SeverityClassification, "assessments">,
+ { rubricCheckpointSha256, ...result }: SeverityClassificationBinding,
): SeverityClassification {
return severityClassificationSchema.parse({
...result,
@@ -145,7 +157,7 @@ function matchingClassification(
(row) =>
(row["classificationRuns"] ?? undefined) ===
result.classificationRuns &&
- row["rubricSha256"] === result.rubricSha256 &&
+ row["rubricSha256"] === rubricCheckpointSha256 &&
row["knowledgeBaseSha256"] === result.knowledgeBaseSha256,
)
.map(
diff --git a/sdk/typescript/tests-ts/classify-scan-severity.test.ts b/sdk/typescript/tests-ts/classify-scan-severity.test.ts
index 53f1582ce..a04fb4cec 100644
--- a/sdk/typescript/tests-ts/classify-scan-severity.test.ts
+++ b/sdk/typescript/tests-ts/classify-scan-severity.test.ts
@@ -22,6 +22,8 @@ import {
} from "../src/classify-severity.js";
import { Database } from "bun:sqlite";
import { loadContract } from "../src/contract.js";
+import { workflowDigest } from "../src/finding-workflow.js";
+import { defaultSeverityRubric } from "../src/default-severity-rubric.js";
import type { JsonObject } from "../src/config.js";
import type { Finding, FindingsDocument, ScanManifest } from "../src/models.js";
import { prepareScanPublication } from "../src/publication.js";
@@ -541,13 +543,20 @@ test("migration leaves unindexed legacy assessments incomplete until reclassifie
{ environment, codex: recordingClassifier().codex },
);
query(environment, "DROP TABLE scan_severity_assessments");
+ query(
+ environment,
+ "ALTER TABLE scan_severity_classifications DROP COLUMN rubric_binding_json",
+ );
for (const table of [
"finding_severity_assessments",
"scan_severity_classifications",
]) {
query(environment, `ALTER TABLE ${table} DROP COLUMN classification_runs`);
}
- query(environment, "DELETE FROM schema_migrations WHERE version IN (43, 52)");
+ query(
+ environment,
+ "DELETE FROM schema_migrations WHERE version IN (43, 52, 60)",
+ );
expect(
await readScanSeverityClassification(
first.scanDirectory,
@@ -556,7 +565,12 @@ test("migration leaves unindexed legacy assessments incomplete until reclassifie
undefined,
environment,
),
- ).toEqual({ ...classification, classificationRuns: undefined });
+ ).toEqual({
+ ...classification,
+ classificationRuns: undefined,
+ rubricRevision: undefined,
+ rubricSha256: workflowDigest([defaultSeverityRubric]),
+ });
expect(
query(
environment,
@@ -964,7 +978,7 @@ test("migrates existing databases without changing findings and reads older stat
query(environment, "DROP TABLE scan_severity_classifications");
query(
environment,
- "DELETE FROM schema_migrations WHERE version IN (41, 43, 52)",
+ "DELETE FROM schema_migrations WHERE version IN (41, 43, 52, 60)",
);
expect(
(
@@ -1061,7 +1075,7 @@ test("default rubric replaces legacy inherited assessments and respects custom p
}
query(
environment,
- "UPDATE scan_severity_classifications SET rubric_sha256 = NULL",
+ "UPDATE scan_severity_classifications SET rubric_sha256 = NULL, rubric_binding_json = NULL",
);
const legacy = await readScanSeverityClassification(
scanDirectory,
@@ -1076,13 +1090,30 @@ test("default rubric replaces legacy inherited assessments and respects custom p
calls.length = 0;
const result = await classifyScanDirectorySeverity(scanDirectory, options);
expect(calls).toHaveLength(6);
- expect(result.rubricSha256).toMatch(/^[a-f0-9]{64}$/u);
+ expect(result.rubricSha256).toBe(sha256(defaultSeverityRubric));
+ expect(result.rubricRevision).toBe(1);
expect(
result.assessments.every(
(a) => a.source === "rubric" && a.level === "medium",
),
).toBe(true);
+ expect(
+ await readScanSeverityClassification(
+ scanDirectory,
+ scanId,
+ findings,
+ undefined,
+ environment,
+ ),
+ ).toMatchObject({
+ rubricSha256: result.rubricSha256,
+ rubricRevision: result.rubricRevision,
+ });
calls.length = 0;
+ query(
+ environment,
+ "UPDATE scan_severity_classifications SET rubric_binding_json = NULL",
+ );
expect(
(await classifyScanDirectorySeverity(scanDirectory, options)).assessments,
).toEqual(result.assessments);
diff --git a/sdk/typescript/tests-ts/classify-severity.test.ts b/sdk/typescript/tests-ts/classify-severity.test.ts
index 638751e79..586388dee 100644
--- a/sdk/typescript/tests-ts/classify-severity.test.ts
+++ b/sdk/typescript/tests-ts/classify-severity.test.ts
@@ -1,3 +1,4 @@
+import { hash } from "node:crypto";
import { defaultSeverityRubric } from "../src/default-severity-rubric.js";
import { workflowDigest } from "../src/finding-workflow.js";
import { modelResponseText } from "./support/model-response-text.js";
@@ -93,7 +94,8 @@ test.each([undefined, "0", "true", " 1"])(
expect(JSON.parse(calls[0]!.prompt.split("\n\n").at(-1)!).rubric).toEqual([
defaultSeverityRubric,
]);
- expect(result.rubricSha256).toBe(workflowDigest([defaultSeverityRubric]));
+ expect(result.rubricSha256).toBe(hash("sha256", defaultSeverityRubric));
+ expect(result.rubricRevision).toBe(1);
expect(result.assessments[0]).toMatchObject({
findingId: finding.findingId,
occurrenceId: finding.occurrenceId,
@@ -135,9 +137,8 @@ test("opt-in fetches only the named config once for all reviews", async () => {
remoteConfig.value.markdown,
]);
}
- expect(result.rubricSha256).toBe(
- workflowDigest([remoteConfig.value.markdown]),
- );
+ expect(result.rubricSha256).toBe(hash("sha256", remoteConfig.value.markdown));
+ expect(result.rubricRevision).toBe(remoteConfig.value.revision);
});
test.each([
@@ -163,7 +164,8 @@ test.each([
expect(JSON.parse(calls[0]!.prompt.split("\n\n").at(-1)!).rubric).toEqual([
defaultSeverityRubric,
]);
- expect(result.rubricSha256).toBe(workflowDigest([defaultSeverityRubric]));
+ expect(result.rubricSha256).toBe(hash("sha256", defaultSeverityRubric));
+ expect(result.rubricRevision).toBe(1);
},
);
@@ -213,7 +215,10 @@ test("supplies complete evidence and separate policy/context to a restricted str
...assessed,
source: "rubric",
});
- expect(result.rubricSha256).toMatch(/^[a-f0-9]{64}$/u);
+ expect(result.rubricSha256).toBe(
+ hash("sha256", "Assign MEDIUM to bounded unauthorized metadata reads."),
+ );
+ expect(result.rubricRevision).toBeUndefined();
expect(result.knowledgeBaseSha256).toMatch(/^[a-f0-9]{64}$/u);
expect(calls).toHaveLength(3);
expect(new Set(calls.map((call) => call.thread)).size).toBe(3);
@@ -268,6 +273,17 @@ test("represents policy exclusions independently from Low", async () => {
expect(validateSeverityClassification(result, [finding])).toEqual(result);
});
+test("rubric directories retain the ordered document digest without a revision", async () => {
+ const directory = await temporaryDirectory();
+ await writeFile(join(directory, "01.md"), "First policy");
+ await writeFile(join(directory, "02.md"), "Second policy");
+ const result = await classifySeverity([], { rubricPath: directory });
+ expect(result.rubricSha256).toBe(
+ workflowDigest(["First policy", "Second policy"]),
+ );
+ expect(result.rubricRevision).toBeUndefined();
+});
+
test("classifies imported reports without severity using the default rubric", async () => {
const {
severity: _severity,