feat(compliance-templates): admin-defined typed governance fields with mandatory enforcement (#676) - #731
Open
larsgeorge-db wants to merge 8 commits into
Open
feat(compliance-templates): admin-defined typed governance fields with mandatory enforcement (#676)#731larsgeorge-db wants to merge 8 commits into
larsgeorge-db wants to merge 8 commits into
Conversation
…, #707, #708, #710) Slices 1-4 of PRD #676: - 3 tables (definition/fields/values) + migration p1; polymorphic per-entity values - Value-type engine (String/Numeric/Enum/MultiEnum/Date/Range/Boolean) + is-set - Completeness validator (advisory); mandatory flag as enforcement primitive - Admin CRUD + activation, composed read, replace-all write, 2 RBAC feature keys - Settings page + product-detail button/modal (typed inputs, defaults, hints, read-only aware, advisory indicator) - Pure-function unit tests (91) for the value-type engine and completeness validator
#713) Implement three invariants for compliance template value materialization: 1. Pure reconciler (compliance_reconcile.py): Given active template fields + existing field_ids, proposes default rows for fields lacking stored values. Existing rows never touched (freeze). Pure function, exhaustively tested. 2. Reconcile-on-edit wiring: New manager method reconcile_entity() called from Data Products update path (next to fire_trigger_safe). Materializes defaults for fields without rows. Non-fatal failures logged as warnings. 3. Freeze: Changing a template default never alters stored rows (reconciler only writes for fields with no existing row). Stored/frozen values render read-only via existing composed read. Tests: 28 unit tests covering all reconciler semantics — idempotence, empty defaults, value preservation, mandatory-without-default, mixed scenarios. Related: PRD #676
…#712) The UI Publish button calls set-publication-scope, not /publish, so the completeness gate added to publish_product() was bypassed. Enforce the same mandatory-fields check on the set-publication-scope path (blocking to any non-none scope; no-op when no template is active).
…andatory) Wires the existing field CRUD/reorder endpoints (#709/#711) to the Settings UI, which previously only supported create/activate/delete: - Pencil action opens an edit dialog hydrated from the template's fields - Save diffs against the server: update template attrs, add new fields, update changed ones, delete removed ones, then persist ordering - Destructive-edit guards (type change, field/enum-value removal with stored values) surface as clear error toasts; save aborts without data loss - Wider (max-w-3xl), height-capped, scrollable dialog for larger templates - Fix: update_field value_type guard handled a raw string vs enum (would 500)
…iance values The compliance-template-values feature was registered but never granted in any default role, so PermissionChecker resolved it to NONE and the read routes (composed read + completeness) 403'd for non-admins — hiding the Compliance button entirely for read-only product viewers. Grant the feature in all default roles (in-code defaults + settings.yaml seed): - Data Consumer / Security Officer: READ_ONLY (view the filled template read-only) - Governance Officer / Steward / Producer: READ_WRITE (fill values) The modal already renders read-only when the caller lacks write (inputs disabled, Save hidden, 'Close' instead of 'Cancel'), so read-only users now see the button and a read-only view of the filled-out template.
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.
Summary
Implements PRD #676 — Compliance Templates: admin-defined, typed governance fields with mandatory enforcement, delivered as 9 vertical slices (#706–#714). Governance admins define reusable templates of typed fields (string, enum, boolean, date, number, multi-select) scoped per entity type; producers fill those values on entities; publishing is blocked until all mandatory fields are complete.
Built on the existing controller/repository/manager pattern with polymorphic per-entity value storage (mirrors
entity_tag_associations) and RBAC viaPermissionChecker.What's included
compliance_templates.py+ Alembicp1_add_compliance_templates_tables): 3 tables — template / field / value. Partial unique index enforces one active template per entity-type scope; values are polymorphic (entity_type+entity_id).compliance_value_types.py): purecoerce_value/is_setover aComplianceValueTypeenum — string, enum, boolean, date, number, multi-select.compliance_completeness.py):check_completeness(fields, values); publishing is blocked (409) when mandatory fields are unset. Wired into bothpublish_product()and theset-publication-scoperoute (the actual UI publish path).compliance_reconcile.py): pure diff of template fields vs. stored values so editing a live template materializes/prunes value slots without data loss.${template.<ref>}references resolve against filled compliance values in workflow definitions.compliance-templates-settings.tsx): create / edit / activate / delete templates, add/edit/reorder/remove fields, defaults + hints, destructive-change guards. Wide, scrollable modal.compliance-modal.tsx+data-product-details.tsx): type-aware inputs to fill values; completeness advisory badge; Compliance button surfaces for anyone with read access.settings-compliance-templatesadmin,compliance-template-values). Read routes gated at READ_ONLY, value writes at READ_WRITE. Read-only roles (Data Consumer, Security Officer) can view filled templates; Governance Officer / Steward / Producer can fill them. Seeded in bothsettings.yamland in-codeDEFAULT_ROLE_PERMISSIONS.Testing
tsc --noEmitclean.Notes for reviewers
origin/development; single Alembic head (p1_compliance_templates), chain intact (l1 → p1).docs/SECRETS_MANAGEMENT_SECURITY_ANALYSIS.md(commit0b3920d7, already ondevelopmentandmain) — unrelated to this PR, which does not touch that file. Flagging separately for the team to scrub from history.Closes #676.