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
27 changes: 27 additions & 0 deletions reviews/plat-1650-code-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: SR-1613
title: "Code review of PLAT-1650 PR #66 default US and EU profiles"
type: SpecReview
analysis: code-review
review_set: subset
scope: "agent-ix/spec-objects-security; spec_objects_security/profiles/eu-device-gdpr-ai-act.yaml, spec_objects_security/profiles/us-device-cybersecurity-hipaa.yaml, tests/test_profiles.py (PR #66 at ffbf8fe7c7dade4d9d61f8af92300b554419eeb1), reviewed against FR-020, FR-021, NFR-002 and PLAT-1650 AC1-7"
---
# SR-1613: Code review of PLAT-1650 PR #66 default US and EU profiles

## Summary

Ticket: PLAT-1650. The change adds the two profile YAML files and extends the profile tests. The exact keys and versions match the released US and EU GitHub module tags. Both profiles omit `context`, so the profile does not bind product-specific dimensions. The tests install those modules through Quoin's supported `github:` source at their release tags, resolve each profile key against installed module manifests, and run `quire publish-check` against each declaring module. No upstream corpus or source module declaration is copied into this repository.

The focused suite passed: `poetry run pytest -o addopts= tests/test_profiles.py tests/test_clause_sets.py -q` → 45 passed. The repository's default pytest addopts could not run in this environment because pytest-cov and pytest-json-report options were unavailable; clearing those addopts allowed the focused test files to run successfully.

CLI review used Quoin 0.35.0 with a fresh module config, the released US/EU pack tags, and this PR's module tree. `quoin profile evaluate` exited 0 for web-app-baseline (2 evaluated, 0 unavailable), US (3 evaluated, 0 unavailable), and EU (4 evaluated, 0 unavailable). With the EU module omitted, selecting the EU profile still exited 0 and reported all four EU keys unavailable (0 evaluated, 4 unavailable). Missing product dimensions remain unresolved, as expected. Packaging configuration already includes every `profiles/*.yaml` file in wheel and sdist, and npm's package file list and staging script include `profiles/`; the new files therefore follow the existing package paths.

## Verdict

**PASS**: no findings. The profile names are among the three allowed names; keys use only authority, id and version; the US and EU profiles carry no product facts; and the selected public sources match FR-021's intended source table. The PR does not change the module manifest, source-module declarations, publish-check implementation, or packaging scripts.

## Findings

| ID | Severity | Summary | Refs |
| --- | --- | --- | --- |
| FND-001 | low | No findings (placeholder) | - |
27 changes: 27 additions & 0 deletions reviews/plat-1650-gap-analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: SR-1614
title: "Gap analysis of PLAT-1650 PR #66 default US and EU profiles"
type: SpecReview
analysis: gap-analysis
review_set: subset
scope: "agent-ix/spec-objects-security; spec_objects_security/profiles/eu-device-gdpr-ai-act.yaml, spec_objects_security/profiles/us-device-cybersecurity-hipaa.yaml, tests/test_profiles.py and spec/tests.md (PR #66 at ffbf8fe7c7dade4d9d61f8af92300b554419eeb1), against FR-020, FR-021, NFR-002 and PLAT-1650 AC1-7"
---
# SR-1614: Gap analysis of PLAT-1650 PR #66 default US and EU profiles

## Summary

Ticket: PLAT-1650. Quoin's computed Test Matrix binds the applicable profile tests to FR-020-AC-1..6, FR-021-AC-1..3 and AC-5, and NFR-002-AC-1..2 and M-1..2. The new profile keys have direct assertions, and the fixture test changes a key version to ensure an undeclared key is refused with that key named. FR-021-AC-4, AC-6 and AC-7 are inspection criteria: both new profiles omit context, name only the public sources in the requirement, and list the keys declared by the newly released US/EU pack modules.

`quoin matrix --repo . --json` shows all applicable Test criteria tagged. The matrix also reports 43 untagged criteria in FR-022, FR-025, FR-026, FR-027 and NFR-005; the same 43 criteria are untagged on `origin/main` at 82ac619, so this PR introduces no matrix gap.

The ticket's seven acceptance criteria were reviewed: shipped profiles and allowed names (AC1); declared keys and a negative changed-version case (AC2); publish-check for each key (AC3); absent profile context (AC4); CLI evaluation with all packs and with the EU pack omitted (AC5); wheel and npm inclusion through existing glob/list/staging rules (AC6); and public, non-licensed sources (AC7). The focused test files passed, 45 total. CLI evaluation produced 2/2 web, 3/3 US, and 4/4 EU sets evaluated when modules were installed; with the EU module omitted, the EU profile reports 4 unavailable and exits 0.

## Verdict

**PASS**: no findings. All changed Test criteria are tagged and have test binders. The remaining untagged rows reproduce unchanged on clean `origin/main` and do not concern this diff.

## Findings

| ID | Severity | Summary | Refs |
| --- | --- | --- | --- |
| FND-001 | low | No findings (placeholder) | - |
17 changes: 17 additions & 0 deletions spec_objects_security/profiles/eu-device-gdpr-ai-act.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
schemaVersion: source-profile-v1
name: eu-device-gdpr-ai-act
title: EU device, GDPR, and AI Act
description: EU medical-device, data-protection, and high-risk AI sources.
clauseSets:
- authority: eu
id: mdr-2017-745
version: "2026-07-19"
- authority: eu-mdcg
id: mdcg-2019-16
version: rev1
- authority: eu
id: gdpr-2016-679
version: "2016-05-04"
- authority: eu
id: ai-act-2024-1689
version: "2026-07-27"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schemaVersion: source-profile-v1
name: us-device-cybersecurity-hipaa
title: US device cybersecurity and HIPAA
description: US device cybersecurity statute, FDA guidance, and HIPAA Security Rule sources.
clauseSets:
- authority: us-congress
id: fdca-524b
version: "2026-10-15"
- authority: us-fda
id: premarket-cybersecurity
version: "2026-02-03"
- authority: us-hhs
id: 45-cfr-164-subpart-c
version: "2026-11-12"
104 changes: 95 additions & 9 deletions tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import json
import os
import pathlib
import re
import subprocess

import pytest
Expand All @@ -26,6 +27,10 @@
"eu-device-gdpr-ai-act",
"web-app-baseline",
}
PUBLISHED_PACK_SOURCES = (
"github:agent-ix/spec-clauses-us-health//spec_clauses_us_health@v0.1.0",
"github:agent-ix/spec-clauses-eu-law//spec_clauses_eu_law@v0.1.0",
)


class ProfileError(ValueError):
Expand Down Expand Up @@ -200,7 +205,7 @@ def test_shipped_profile_names_are_among_the_three_defaults() -> None:
assert names <= ALLOWED_NAMES, sorted(names - ALLOWED_NAMES)


@pytest.mark.trace("TC-206", "FR-021-AC-1", "FR-021-AC-5")
@pytest.mark.trace("TC-166", "FR-021-AC-1")
def test_web_app_baseline_profile_is_shipped_with_only_its_public_sets() -> None:
path = PROFILES_DIR / "web-app-baseline.yaml"
assert path.is_file()
Expand All @@ -214,6 +219,41 @@ def test_web_app_baseline_profile_is_shipped_with_only_its_public_sets() -> None
assert "context" not in profile


@pytest.mark.trace("TC-166", "FR-021-AC-1")
def test_us_device_profile_names_the_published_public_sets() -> None:
path = PROFILES_DIR / "us-device-cybersecurity-hipaa.yaml"
assert path.is_file()
profile = validate_profile(path)
assert profile["clauseSets"] == [
{"authority": "us-congress", "id": "fdca-524b", "version": "2026-10-15"},
{
"authority": "us-fda",
"id": "premarket-cybersecurity",
"version": "2026-02-03",
},
{
"authority": "us-hhs",
"id": "45-cfr-164-subpart-c",
"version": "2026-11-12",
},
]
assert "context" not in profile


@pytest.mark.trace("TC-166", "FR-021-AC-1")
def test_eu_device_profile_names_the_published_public_sets() -> None:
path = PROFILES_DIR / "eu-device-gdpr-ai-act.yaml"
assert path.is_file()
profile = validate_profile(path)
assert profile["clauseSets"] == [
{"authority": "eu", "id": "mdr-2017-745", "version": "2026-07-19"},
{"authority": "eu-mdcg", "id": "mdcg-2019-16", "version": "rev1"},
{"authority": "eu", "id": "gdpr-2016-679", "version": "2016-05-04"},
{"authority": "eu", "id": "ai-act-2024-1689", "version": "2026-07-27"},
]
assert "context" not in profile


def declared_keys(module_dir: pathlib.Path) -> set[tuple[str, str, str]]:
"""The clause-set keys a module's manifest lists, read from its set files."""
manifest = yaml.safe_load((module_dir / "manifest.yaml").read_text()) or {}
Expand All @@ -231,24 +271,48 @@ def declared_keys(module_dir: pathlib.Path) -> set[tuple[str, str, str]]:

@pytest.fixture(scope="session")
def reference_modules(tmp_path_factory: pytest.TempPathFactory) -> list[pathlib.Path]:
"""The reference module set: the modules `quoin module
ensure-defaults` installs into a fresh home, plus this module.
"""The reference module set: Quoin defaults, both published packs, and us.

Built from scratch rather than read from an ambient install, so a stale or
unpublished local module cannot make a profile pass or fail. It is only
built when a shipped profile needs it.
"""
home = tmp_path_factory.mktemp("reference-home")
result = subprocess.run(
[engine_tool("quoin"), "module", "ensure-defaults"],
env={**os.environ, "IX_HOME": str(home)},
[
engine_tool("quoin"),
"module",
"ensure-defaults",
"--config-root",
str(home),
],
env=os.environ.copy(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0, result.stderr
for source in PUBLISHED_PACK_SOURCES:
result = subprocess.run(
[
engine_tool("quoin"),
"module",
"install",
source,
"--config-root",
str(home),
],
env=os.environ.copy(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0, f"{source}: {result.stderr}"
installed = sorted((home / "filament" / "modules").glob("*"))
return [PACKAGE_ROOT, *(d for d in installed if (d / "manifest.yaml").is_file())]
return [
PACKAGE_ROOT,
*(d for d in installed if (d / "manifest.yaml").is_file()),
]


def declaring_module(
Expand Down Expand Up @@ -291,14 +355,36 @@ def _shipped_keys(path: pathlib.Path) -> list[tuple[str, str, str]]:
]


def assert_profile_keys_declared(
path: pathlib.Path, modules: list[pathlib.Path]
) -> None:
for key in _shipped_keys(path):
module = declaring_module(key, modules)
assert module is not None, f"{path.stem}: no module declares {key}"


@pytest.mark.trace("TC-167", "FR-021-AC-2")
@pytest.mark.parametrize("path", shipped_profiles(), ids=lambda p: p.stem)
def test_every_shipped_key_is_declared_by_a_reference_module(
path: pathlib.Path, reference_modules: list[pathlib.Path]
) -> None:
for key in _shipped_keys(path):
module = declaring_module(key, reference_modules)
assert module, f"{path.stem}: no module declares {key}"
assert_profile_keys_declared(path, reference_modules)


@pytest.mark.trace("TC-167", "FR-021-AC-2")
def test_a_profile_with_an_unpublished_version_fails_with_its_key(
tmp_path: pathlib.Path, reference_modules: list[pathlib.Path]
) -> None:
source = PROFILES_DIR / "us-device-cybersecurity-hipaa.yaml"
data = validate_profile(source)
data["clauseSets"][0]["version"] = "unpublished-version"
path = tmp_path / source.name
path.write_text(yaml.safe_dump(data, sort_keys=False))
changed_key = tuple(
data["clauseSets"][0][field] for field in ("authority", "id", "version")
)
with pytest.raises(AssertionError, match=re.escape(str(changed_key))):
assert_profile_keys_declared(path, reference_modules)


@pytest.mark.trace("TC-168", "TC-174", "FR-021-AC-3", "NFR-002-AC-2", "NFR-002-M-2")
Expand Down
Loading