diff --git a/package-lock.json b/package-lock.json index c36f58a..c5ef467 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,17 +9,18 @@ "version": "0.0.0-managed", "license": "AGPL-3.0-or-later", "devDependencies": { - "@agent-ix/quire-cli": "0.45.0", + "@agent-ix/quire-cli": "0.46.0", "@agent-ix/quoin": "0.30.1", "@agent-ix/semantic-core": "0.4.4", + "@agent-ix/spec-objects-architecture": "0.12.0", "@typespec/compiler": "1.15.0", "@typespec/json-schema": "1.15.0" } }, "node_modules/@agent-ix/quire-cli": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli/-/quire-cli-0.45.0.tgz", - "integrity": "sha512-//o8Kjw2aa/rL+DEQKcwMUZzfNyPzPRHFVbSSY8iPrIe9PThgLGby17egCEY+NGwBT0/Ab1i6gHDGFk/E34dlQ==", + "version": "0.46.0", + "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli/-/quire-cli-0.46.0.tgz", + "integrity": "sha512-jl8K25LNM7Ep2Y5EG5wpm39DdPlo1eg96soK6rD0i8IaE7SsTtUc6Ouf4inKKwBumRKoHGnhGgnkx6hgvNK7Dg==", "dev": true, "license": "AGPL-3.0-or-later", "bin": { @@ -29,16 +30,16 @@ "node": ">=16" }, "optionalDependencies": { - "@agent-ix/quire-cli-darwin-arm64": "0.45.0", - "@agent-ix/quire-cli-linux-arm64": "0.45.0", - "@agent-ix/quire-cli-linux-x64": "0.45.0", - "@agent-ix/quire-cli-win32-x64": "0.45.0" + "@agent-ix/quire-cli-darwin-arm64": "0.46.0", + "@agent-ix/quire-cli-linux-arm64": "0.46.0", + "@agent-ix/quire-cli-linux-x64": "0.46.0", + "@agent-ix/quire-cli-win32-x64": "0.46.0" } }, "node_modules/@agent-ix/quire-cli-darwin-arm64": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-darwin-arm64/-/quire-cli-darwin-arm64-0.45.0.tgz", - "integrity": "sha512-M2mSlmgi+QNlj9hWW6k0JPxe/JK6OGMghRl7HHU1GVS6+QHIqhuCmNMbUvNvRdvuYX/RgytqqJbgCB/4Mnq/xw==", + "version": "0.46.0", + "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-darwin-arm64/-/quire-cli-darwin-arm64-0.46.0.tgz", + "integrity": "sha512-skxTN+tC7Ho8ADLk0tXe/obyQi7BIQ/QnPKvA2gHdM6hE1PA0nnPeo28nE91/tFO0M1RDYn+0hzU9E4WFn6PjA==", "cpu": [ "arm64" ], @@ -50,9 +51,9 @@ ] }, "node_modules/@agent-ix/quire-cli-linux-arm64": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-linux-arm64/-/quire-cli-linux-arm64-0.45.0.tgz", - "integrity": "sha512-hCoJrNlBM6Yap/5KF5HiexiDRMqz8sqa6hwkkF2bShQCBjdKbaf4iplv4nLks3+qoc+bIiVZzTaQnUmd6EPDvg==", + "version": "0.46.0", + "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-linux-arm64/-/quire-cli-linux-arm64-0.46.0.tgz", + "integrity": "sha512-Baj2gvj9ejmpaKSc3X+sCe+gObKP84H9D2RKKWeZBifFuUFonK1onFDzMHQbB29QycYCXtxTskrJPDm3AMt1cw==", "cpu": [ "arm64" ], @@ -64,9 +65,9 @@ ] }, "node_modules/@agent-ix/quire-cli-linux-x64": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-linux-x64/-/quire-cli-linux-x64-0.45.0.tgz", - "integrity": "sha512-iqE8I94p5kKcyJyVNU5sSjvMUTRKKuUWUqSm7CYgR45CUV5IBmeVzwhgU6+adGMrGW3UfrPzvGco4F+HgaWksQ==", + "version": "0.46.0", + "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-linux-x64/-/quire-cli-linux-x64-0.46.0.tgz", + "integrity": "sha512-5wJWAD6eIhOBQeMQ2EiALanAK/qjsxa+i57PIvY6zMYFZyJEmOlJYYv38Uqr2viuZs3oFqfx5PkwUDDgAHk+ig==", "cpu": [ "x64" ], @@ -78,9 +79,9 @@ ] }, "node_modules/@agent-ix/quire-cli-win32-x64": { - "version": "0.45.0", - "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-win32-x64/-/quire-cli-win32-x64-0.45.0.tgz", - "integrity": "sha512-CzEadVbqVhIeou3wK9scCb3ycYcZheX2RTTenlSWFoXjFkwDvnuxpdKZM73ngYHAoB2pnxFo3+0f/RewI8kkSA==", + "version": "0.46.0", + "resolved": "https://registry.npmjs.org/@agent-ix/quire-cli-win32-x64/-/quire-cli-win32-x64-0.46.0.tgz", + "integrity": "sha512-2ZVDCpbNxI1Q8W2LqnFk2EftGKJd3uO+/SP2IQEA06XvZVh+r3qiR06cRBsCFrIpZxWGNXXbCmwlxlFBj8gqdA==", "cpu": [ "x64" ], @@ -177,6 +178,13 @@ "@typespec/json-schema": "1.15.0" } }, + "node_modules/@agent-ix/spec-objects-architecture": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@agent-ix/spec-objects-architecture/-/spec-objects-architecture-0.12.0.tgz", + "integrity": "sha512-qTH6U5VT/XZxYWd5LuWdcrsggH/cHG6YqqDfoigW/zrPDFZBycN5D2N3f0XsfJFbLx2xz4He/1M7ThVEKifK1g==", + "dev": true, + "license": "AGPL-3.0-or-later" + }, "node_modules/@babel/code-frame": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", diff --git a/package.json b/package.json index 17eabf3..51d7eae 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,10 @@ "url": "git+https://github.com/agent-ix/spec-objects-security.git" }, "devDependencies": { - "@agent-ix/quire-cli": "0.45.0", + "@agent-ix/quire-cli": "0.46.0", "@agent-ix/quoin": "0.30.1", "@agent-ix/semantic-core": "0.4.4", + "@agent-ix/spec-objects-architecture": "0.12.0", "@typespec/compiler": "1.15.0", "@typespec/json-schema": "1.15.0" } diff --git a/scripts/generate-schemas.mjs b/scripts/generate-schemas.mjs index e85ce0b..5341691 100644 --- a/scripts/generate-schemas.mjs +++ b/scripts/generate-schemas.mjs @@ -112,6 +112,37 @@ function normalize(schemas, base, moduleFiles, coreBase) { for (const [name, schema] of schemas) walk(name, schema); } +/** + * Frontmatter validators compile without the module schema registry (FR-069). + * Keep their closed enum members inline so validation stays offline while the + * regular data schemas can continue to reference the shared enum schemas. + */ +function inlineFrontmatterEnums(schemas) { + const byId = new Map( + schemas.map(([, schema]) => [schema.$id, schema]).filter(([id]) => id), + ); + for (const [name, schema] of schemas) { + if (!name.endsWith("Frontmatter.json")) continue; + const visit = (node) => { + if (Array.isArray(node)) { + for (const item of node) visit(item); + return; + } + if (!node || typeof node !== "object") return; + if (typeof node.$ref === "string") { + const target = byId.get(node.$ref); + if (target && Array.isArray(target.enum)) { + delete node.$ref; + node.type = target.type; + node.enum = [...target.enum]; + } + } + for (const value of Object.values(node)) visit(value); + }; + visit(schema); + } +} + function render(schema) { return `${JSON.stringify(schema, null, 2)}\n`; } @@ -138,6 +169,7 @@ function emit() { } const moduleFiles = new Set(mine.map(([name]) => name)); normalize(mine, base, moduleFiles, semanticCoreBase()); + inlineFrontmatterEnums(mine); const rendered = new Map(mine.map(([name, schema]) => [name, render(schema)])); return rendered; diff --git a/spec/tests.md b/spec/tests.md index d09b06a..ef648a3 100644 --- a/spec/tests.md +++ b/spec/tests.md @@ -152,6 +152,7 @@ the Python package only: neither Node script is measured by it. | NFR-003 | NFR-003-AC-1..2, NFR-003-M-1..2 | TC-204, TC-205 | ✅ | | FR-023 | FR-023-AC-1..10 | TC-206..TC-217 | ✅ AC-7 is an inspection | | FR-024 | FR-024-AC-1..7 | TC-220..TC-223 | ✅ | +| FR-025 | FR-025-AC-8..9, FR-025-AC-11 | TC-244..TC-247 | 🚧 AC-11 starter-rule enum coverage remains with PLAT-1540; other FR-025 criteria remain with their owning tickets | | NFR-004 | NFR-004-AC-1..3, NFR-004-M-1..2 | TC-207, TC-211, TC-213, TC-214 | ✅ | | FR-017 | FR-017-AC-1..7 | TC-175..TC-186 | ✅ `quire clauses` loads strictly and cannot load the real module (the object-type edges come from another module), so TC-181, TC-183, TC-185 and TC-186 evaluate a module that holds only the set files | | FR-026 | FR-026-AC-1..7, FR-026-AC-9..10 | TC-224..TC-236, TC-242..TC-243 | ✅ | @@ -366,6 +367,10 @@ the Python package only: neither Node script is measured by it. | TC-241 | The risk skeleton states `decision: undecided` | Unit | P0 | FR-027-AC-6 | ✅ | | TC-242 | An empty `## Out of scope` section fails validation naming the section | Integration | P0 | FR-026-AC-6 | ✅ | | TC-243 | `semantic.exports` contains twenty-six types including `threat_model` | Unit | P0 | FR-026-AC-10 | ✅ | +| TC-244 | Safeguard and frontmatter schemas admit the declared non-empty unique safeguard lists and reject undeclared values | Unit | P0 | FR-025-AC-8, FR-025-AC-11 | ✅ | +| TC-245 | Control safeguards are optional authored frontmatter, are extracted when present, and the skeleton validates | Integration | P0 | FR-025-AC-8, FR-025-AC-9 | ✅ | +| TC-246 | A control protects a connection and a data sink without a disallowed-target diagnostic | Integration | P0 | FR-025-AC-9 | ✅ | +| TC-247 | Control and data-classification manifests reference their open frontmatter schemas and declare the field locators | Unit | P0 | FR-025-AC-9, FR-025-AC-11 | ✅ | ## Test Environment diff --git a/spec_objects_security/manifest.yaml b/spec_objects_security/manifest.yaml index cca68cf..a58f741 100644 --- a/spec_objects_security/manifest.yaml +++ b/spec_objects_security/manifest.yaml @@ -234,6 +234,7 @@ object_types: after_heading: Invariants required: false - name: data_classification + frontmatter_schema_ref: schemas/DataClassificationFrontmatter.json allowed_links: classifies: [persistable, externally-exposed, sensitive] references: [data_classification] @@ -470,10 +471,11 @@ object_types: after_heading: Properties required: false - name: control + frontmatter_schema_ref: schemas/ControlFrontmatter.json allowed_links: mitigates: [threat, risk, vulnerability, hazard, failure_mode] implements: [policy] - protects: [externally-exposed, asset] + protects: [externally-exposed, asset, connection, data_sink] data_schema: schema: schemas/Control.json body_extraction: @@ -490,6 +492,10 @@ object_types: from: section_body after_heading: Effectiveness required: false + safeguards: + from: frontmatter_field + path: [safeguards] + required: false # FR-005: the typed `## Properties` table the # semantic layer reads. Optional, so existing artifacts stay valid. properties: diff --git a/spec_objects_security/schemas/Control.json b/spec_objects_security/schemas/Control.json index e2f59c4..65309d5 100644 --- a/spec_objects_security/schemas/Control.json +++ b/spec_objects_security/schemas/Control.json @@ -29,6 +29,14 @@ "effectiveness": { "$ref": "https://schemas.agent-ix.org/agent-ix/spec-objects-security/ControlEffectiveness.json" }, + "safeguards": { + "type": "array", + "items": { + "$ref": "https://schemas.agent-ix.org/agent-ix/spec-objects-security/Safeguard.json" + }, + "minItems": 1, + "uniqueItems": true + }, "mitigates": { "type": "array", "items": { diff --git a/spec_objects_security/schemas/ControlFrontmatter.json b/spec_objects_security/schemas/ControlFrontmatter.json new file mode 100644 index 0000000..92f4e9a --- /dev/null +++ b/spec_objects_security/schemas/ControlFrontmatter.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://schemas.agent-ix.org/agent-ix/spec-objects-security/ControlFrontmatter.json", + "type": "object", + "properties": { + "safeguards": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "encrypt-in-transit", + "encrypt-at-rest", + "anonymize", + "pseudonymize", + "obtain-consent", + "restrict-region", + "validate-before-display" + ] + }, + "minItems": 1, + "uniqueItems": true + } + }, + "description": "Frontmatter keys authored on a control document." +} diff --git a/spec_objects_security/schemas/DataClassificationFrontmatter.json b/spec_objects_security/schemas/DataClassificationFrontmatter.json new file mode 100644 index 0000000..6b8e8e8 --- /dev/null +++ b/spec_objects_security/schemas/DataClassificationFrontmatter.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://schemas.agent-ix.org/agent-ix/spec-objects-security/DataClassificationFrontmatter.json", + "type": "object", + "properties": { + "regulated_categories": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "health", + "personal", + "financial" + ] + }, + "minItems": 1, + "uniqueItems": true + } + }, + "description": "Frontmatter keys authored on a data-classification document." +} diff --git a/spec_objects_security/schemas/Safeguard.json b/spec_objects_security/schemas/Safeguard.json new file mode 100644 index 0000000..d3342cf --- /dev/null +++ b/spec_objects_security/schemas/Safeguard.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://schemas.agent-ix.org/agent-ix/spec-objects-security/Safeguard.json", + "type": "string", + "enum": [ + "encrypt-in-transit", + "encrypt-at-rest", + "anonymize", + "pseudonymize", + "obtain-consent", + "restrict-region", + "validate-before-display" + ], + "description": "Safeguards a person may state for a control." +} diff --git a/spec_objects_security/skeletons/control.md b/spec_objects_security/skeletons/control.md index d9b6ac5..f1d6ceb 100644 --- a/spec_objects_security/skeletons/control.md +++ b/spec_objects_security/skeletons/control.md @@ -3,10 +3,12 @@ id: CTRL-001 title: "RefreshTokenRotation" type: control object: control +safeguards: [encrypt-in-transit] ---