CR-010.R3: compliance packs as data — x-sox (SOX/COSO) financial controls first - #250
Merged
Merged
Conversation
Cherry-picked from private 3798bb86 (private PR #331, merged 7c1cf8b5).
Ships the SOX/COSO financial-controls pack and the data-driven pack format
that makes the NEXT framework authorable without Python.
* NEW graqle/pct/extensions/x_sox.py — frozen XSoxExtension mirroring the
x_ai_eu.py pattern. Binds an AI-assisted decision to a NAMED internal
control, a financial-statement assertion, and a reporting period.
Preparer/reviewer are HMAC-SHA256 pseudonym tokens or the explicit "omit"
sentinel; raw identifiers are rejected at construction, because these
values travel inside long-lived, widely-shared audit artifacts with no
redaction path.
* NEW graqle/compliance/packs/ — pack.yaml + schema.json per framework,
discovered by directory scan over importlib.resources. NIST AI RMF and
ISO 42001 become two data files each. NO entry-point discovery: that is
R10, and a test enforces the boundary.
* NEW graqle/compliance/management_review_gate.py — SOX-vocabulary
counterpart of the Article 14 human-oversight gate. STRICTLY ADDITIVE:
article_14_gate.py is byte-for-byte unmodified (0 diff lines).
* NEW graqle/compliance/_gate_helpers.py — public re-exports of the three
shared validators.
Works without engine changes because taxonomy.py:127 already accepts
^x-[a-z0-9_-]{1,64}$, so this pack's four x-sox-* claim limits validate with
zero taxonomy edit.
VERIFIED ON THIS PUBLIC BASE (597a7c4, not on the private branch):
133 R3 tests; 913 passed/4 skipped (test_compliance + test_pct);
772 passed/6 skipped (test_governance + test_tamper_evidence);
TS-screen 0; article_14_gate.py 0 diff lines; public wheel builds with zero
duplicate entries and ships all 4 pack files. All 8 R3 source files are
byte-identical to private/master.
Refs: CR-010.R3, plan_54c13aec, lesson_20260804T121740
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🛡️ GraQle PR Guardian💥 Blast Radius: 12 modules affected
Total blast radius: 12 🏛️ Governance Verdict
|
| Metric | Value |
|---|---|
| Blast Radius | 12 |
| Files Analyzed | 12 |
| Blocked | 0 |
| SHACL Violations | 0 |
| Verdict | WARN |
🔬 Powered by GraQle PR Guardian v0.1.0 · Scan completed 2026-08-05T20:08:10.657706+00:00
harishquantamix
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CR-010.R3 — Compliance packs as data (
x-soxfinancial controls first)Public cherry-pick of private #331, merged as
7c1cf8b5. Feature commit3798bb86→ this branch asc9bc6456, branched off the current public head597a7c49(public master moved during review — CR-DIST-06 #249 landed in between).Program context: requirement R3 of CR-010, the 16-requirement Enterprise Enhancement Program. R5 · R4 · R1 · R6 already shipped (PyPI 0.83.0); this is the 5th.
What this delivers
GraQle had deep EU AI Act support and no SOX, SOC 2, NIST AI RMF, HIPAA, or ISO 27001 mappings at all. R3 closes that, and — more durably — changes how every future framework gets added.
1.
x-sox— the SOX/COSO vocabulary. An AI-assisted financial-close decision can now carry a machine-readable binding to a named internal control, a financial-statement assertion (existence / completeness / accuracy / cutoff / valuation / rights-and-obligations / presentation-and-disclosure), a reporting period, and management-review linkage with an evidence pointer. An external auditor verifies all of it offline — no GraQle instance required.2. Compliance packs as data. A framework is now two files in a directory —
pack.yaml+schema.json— discovered by directory scan overimportlib.resources. NIST AI RMF and ISO/IEC 42001 (R3's deliverable 2) become data authoring, not engineering.Why this needed no engine change
graqle/compliance/claim_limits/taxonomy.py:127already accepts^x-[a-z0-9_-]{1,64}$, andis_valid_claim_limit(:135-164) admits any value matching it. So this pack's fourx-sox-*claim limits validate with zero taxonomy edit. That verified fact — not a new plugin system — is what makes "authorable as schema + YAML without touching engine code" reachable.Explicitly NOT built: entry-point / plugin discovery. That is R10. A test asserts the loader imports no
importlib.metadata,pkg_resources, orentry_points(machinery.The Article 14 gate is untouched — by design
git diff --stat -- graqle/compliance/article_14_gate.py→ 0 lines, verified on this base.SOX calls it a management review control; the EU AI Act calls it human oversight. Same mechanics, different vocabulary. The tempting move is to rename the existing type to cover both — the adversarial reviewer proposed exactly that (
Article14GateResult→_ReviewGateResult, fieldconfidence→score, old name as an alias). Rejected: four consumers pin that contract (mcp_dev_server.py:9110/9374/12029, two hardcoding"ARTICLE_14_HUMAN_REVIEW_REQUIRED", plusswitch_status.py:91-106republishing the threshold and error code into a public envelope). A rename is a silent 4-module break for zero functional gain. SOX got a sibling module with its own error code (MANAGEMENT_REVIEW_REQUIRED) and result type; regression tests pin the EU surface — field names and order, clauses, error code, threshold, and theswitch_statusprobe envelope.PII posture
preparer_token/reviewer_tokenaccept a 64-char lowercase-hex HMAC-SHA256 token or the explicit"omit"sentinel, and reject raw identifiers at construction — tested against emails, display names, employee IDs, UUIDs, off-by-one lengths, and uppercase hex. The identity↔token mapping stays with the operator and is never written to a pack, token, or evidence artifact. An auditor can still verify segregation of duties (preparer ≠ reviewer) without learning either identity.This is not justified by signature immutability. Measured:
LEAF_HASH_FIELDS(leaf_input_schema.py:28-34) is a frozen 5-tuple andproject_leaf_input()drops every other key, so anx-sox:field cannot enter a leaf hash or signed preimage. The discipline exists because these values live in long-lived, widely-shared audit artifacts.Verified ON THIS PUBLIC BASE (not on the private branch)
A merge commit is a different tree than what was tested; these were re-run against
597a7c49itself.tests/test_compliance/+tests/test_pct/tests/test_governance/+tests/test_tamper_evidence/test_shacl.pyModuleNotFoundError: rdflib, proven pre-existing by stashing all R3 changes and reproducing on pristine masterarticle_14_gate.pydiffprivate/masterTests are unit + adversarial/negative (mandatory P0) + property + regression: calendar-impossible dates, raw-identifier rejection, malformed YAML/JSON, invalid and reserved namespaces, a manifest violating its own schema, duplicate namespaces, UTF-8 BOM handling, and the EU-contract regression set.
Sentinel — 2-pass adversarial → APPROVE, 0 BLOCKERs
Every finding was reproduced before fixing; 4 of 8 were refuted by measurement. Three real ones were fixed: calendar-impossible dates (
"2026-13-45"was accepted — the regex checks shape, not calendar → nowdate.fromisoformat()); namespace shadowing (x-ai-euis a well-formedx-namespace, so a pack could shadow the EU AI Act vocabulary →RESERVED_NAMESPACESguard); and a cross-module private-helper import (→_gate_helperspublic re-exports). A UTF-8 BOM issue that both sentinel passes missed was caught separately: a BOM is fatal tojson.loadsbut tolerated byyaml.safe_load, so a Windows-savedschema.jsonwould have failed as "not valid JSON" while itspack.yamlsibling loaded — now read viaread_bytes().decode("utf-8-sig").Rollback
Revert the single commit. Zero data-loss risk, zero migration: everything is additive (new modules + new package data). No existing record, bundle, or signature changes shape, because
x-soxfields cannot enterLEAF_HASH_FIELDS. No previously-issued bundle is invalidated.Deferred
R3's deliverable 3 — replacing the placeholder review threshold with a calibration-backed value — is deliberately not in this PR. It mutates a live EU AI Act enforcement path whose default is asserted literally at
test_article_14_gate.py:27and republished byswitch_status.py:103. Both gates already carrythreshold_status, so a calibrated value is a drop-in later.Ships in 0.84.0.
🤖 Generated with Claude Code