Skip to content

feat(views): add native compliance precision contract - #123

Merged
chubirka merged 1 commit into
developmentfrom
feat/compliance-precision-view-fnfe42sg
Nov 6, 2026
Merged

chubirka merged 1 commit into
developmentfrom
feat/compliance-precision-view-fnfe42sg

Conversation

@chubirka

@chubirka chubirka commented Nov 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Add the ephemeral compliance-precision ViewModel wrapper without artifact/storage/model-binding or version changes.
  • Reuse the packaged compliance-assessment framework-id schema via a local registry reference.
  • Document compliance review precision versus evaluator calibration, null/unmeasured values, and Core-owned arithmetic.
  • Cover consumer validity boundaries, raw hostile IDs, unknown fields, and local framework resolution.

Verification

  • make setup once for the fresh worktree.
  • make lint-fix: passed.
  • TRAUST_TEST_DATABASE_URL=postgresql://traust:traust-test-only@127.0.0.1:60395/contracts_compliance_precision_fnfe42sg make test: 1435 passed, including SQLite and isolated PostgreSQL.
  • Built wheel /tmp/contracts-compliance-precision-fnfe42sg-dist/traust_contracts-0.0.0-py3-none-any.whl; installed it with isolated uv outside the source worktree. Loaded the packaged new schema and 46 artifact resources; valid framework accepted, unknown framework rejected, zero external retrievals.
  • Normal commit and push hooks passed; no bypass.

Core integration supplies its existing artifact registry when validating this view. JSON Schema validates shape/ranges, not count arithmetic or derived flags.

@chubirka
chubirka requested a review from a team as a code owner November 6, 2026 19:47
@openshift-ci

openshift-ci Bot commented Nov 6, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chubirka

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 6, 2026
@qodo-for-traust-sci

Copy link
Copy Markdown

PR Summary by Qodo

Add compliance precision Insight view contract

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Add an ephemeral compliance-precision schema that wraps native calibration results without
 creating a stored artifact.
• Reuse the packaged framework vocabulary and define strict field, count, and precision boundaries.
• Test local reference resolution and invalid inputs; document unmeasured precision and Core-owned
 calculations.
Diagram

graph TD
  Producer["Detection Quality Service"] --> Core["Core ViewModel"] --> Schema["Precision View Schema"] --> Registry["Artifact Schema Registry"]
  Core --> Insight["Insight Consumer"]
Loading
High-Level Assessment

Keep the ephemeral schema and local reference to the existing framework vocabulary. Duplicating the framework IDs would risk drift, while creating a persisted artifact would misrepresent a derived review view; neither offers a meaningful advantage here.

Files changed (3) +215 / -0

Enhancement (1) +54 / -0
compliance-precision.schema.jsonDefine an ephemeral compliance precision view schema +54/-0

Define an ephemeral compliance precision view schema

• Adds a strict calibration wrapper with nonnegative counts, bounded gates and measured precision, nullable unmeasured precision, and boolean review flags. References the packaged compliance-assessment framework ID definition instead of maintaining another vocabulary.

views_schema/v1/compliance-precision.schema.json

Tests (1) +137 / -0
test_compliance_precision_view.pyTest the compliance precision contract's validity boundaries +137/-0

Test the compliance precision contract's validity boundaries

• Covers local framework resolution, empty and unmeasured populations, range endpoints, and raw hostile check IDs. Parameterized cases reject invalid values, missing required fields, and unknown fields at every object boundary.

tests/test_compliance_precision_view.py

Documentation (1) +24 / -0
README.mdExplain compliance precision semantics and consumer responsibilities +24/-0

Explain compliance precision semantics and consumer responsibilities

• Documents the wrapper, local framework resolution, and strict validation boundaries. Distinguishes review precision from evaluator calibration or coverage, and assigns arithmetic, derived flags, and rendering to Core rather than JSON Schema.

README.md

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-for-traust-sci

Copy link
Copy Markdown

Code Review by Qodo


View medium (1)
Remediation recommended
1. Core cannot produce this view 🔗 Cross-repo conflict
Description
The new schema requires assessments, checks, and gate, but the mounted traust-core declares
calibrate_compliance(framework) with a ComplianceCalibration result containing only framework,
scalar precision, and efficacy. If the documented native-result wrapper is integrated against
that Core contract, passing gate fails at the call, while wrapping its declared result fails
schema validation; the Core implementation is currently a stub, so this is an integration
incompatibility rather than an observed production failure.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new view contract describes a native Core result that the mounted Core API does not accept or return.

## Fix Focus Areas
- views_schema/v1/compliance-precision.schema.json[10-27]
- README.md[143-165]
- /cross_repos/traust-core/src/traust_core/v1/services/detection_quality.py[56-59]
- /cross_repos/traust-core/src/traust_core/v1/models/detection_quality.py[104-107]

## Recommended Fix
Confirm the intended companion Core revision. Either align the view contract and documentation with the result Core will actually expose, or coordinate a Core implementation and model change that accepts the documented gate and produces the required fields; update Core's contracts pin and add an integration regression test before adopting the view.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


@chubirka

chubirka commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Companion implementation is now published: traust-core#387, immutable Core commit 8fd9d03884b570d2d7267d414037afce7a6fa652.

The Qodo cross-repository finding is inspecting an older mounted Core snapshot. The actual native producer is implemented, not a stub:

  • ComplianceCalibration and CheckPrecision already contain framework, assessments, checks, gate, derived per-check precision and flags.
  • calibrate_compliance already accepts keyword gate and counts recorded documents/check firings/human overrides. Neither its signature nor scoring semantics was changed for this view.
  • The companion registers the typed {calibration: ...} view and validates it with this packaged schema plus the local artifact registry. 194 focused SQLite/PostgreSQL/REST cases, 11,575 unit tests, and a real HTTP-server publication smoke passed; raw model/reference resolution and no data writes were exercised.

Core stays draft for dependency reconciliation/re-pin: its pre-existing contracts#117 dependency must be retained, so validation uses a separate temporary integration ref; this schema PR remains only its three additive view files. The downstream Traust draft will preserve the existing flat JSON contract while using the canonical wrapper internally.

@chubirka
chubirka merged commit 2de84c9 into development Nov 6, 2026
3 of 4 checks passed
chubirka added a commit that referenced this pull request Nov 6, 2026
Development landed the reworked remediation-scheduling slice (#117, #121, #123):
run_order gains work_item_id plus fork_url/fork_branch, the remediation /
remediation_finding tables are retired (remediation.schema.json is the system
of record), and the upgrades/ channel is dropped (7c9554c). This merge takes
development's decisions wholesale for the DB surface and keeps this branch's
sole addition: the benchmark-scorecards view contract, its tests and README
section, layered after the compliance-precision section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant