Provisional SHACL claim validation + alignment-gap analysis#30
Open
DarrenZal wants to merge 1 commit into
Open
Provisional SHACL claim validation + alignment-gap analysis#30DarrenZal wants to merge 1 commit into
DarrenZal wants to merge 1 commit into
Conversation
…ysis Adds the SHACL-validation scaffolding for claims, OFF by default and NOT yet wired into create_claim — because the koi-processor rfs:Claim JSON-LD (flat keys: claimant_uri/claim_type/statement) does not match the PR #53 LinkML rfs:Claim slot vocabulary (hasClaimant/hasSubject/hasPrimaryImpact/...). A runnable proof demonstrates the gap: an LinkML-slot-aligned claim CONFORMS; today's flat-key claim fails with sh:closed violations. - schema/shacl/claim.shacl.ttl: shape generated from regen-data-standards PR #53 Claim.yaml (linkml ShaclGenerator; provisional until #53 merges) - api/shacl_validation.py: pyshacl wrapped in asyncio.to_thread (never block the single-worker event loop), fail-closed on missing shape, gated by VALIDATE_CLAIMS_SHACL (default false) - docs/claims/shacl-alignment-gap.md: the gap, the proof, two fix options, exact create_claim wiring point - tests/test_shacl_claim_shape.py: codifies the proof (3 tests, green) - requirements.txt: pyshacl>=0.27, rdflib>=7.0 Review branch only — do NOT merge to regen-prod (auto-deploys to personal-koi). Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
What
Scaffolding for SHACL validation of claims, OFF by default and intentionally NOT wired into
create_claim— plus a runnable proof of why it can't be enabled yet.The finding (the real value here)
koi-processor already emits an
rfs:ClaimJSON-LD (used for content hashing) with flat keys:claimant_uri/claim_type/statement/about_uri.The PR #53 LinkML
rfs:Claimshape issh:closedand requires structured slots:schema:name,rfs:hasClaimType,rfs:verificationStatus,rfs:hasClaimant(Entity),rfs:hasSubject(Entity),rfs:hasPrimaryImpact(Impact) — with nested Entity/Impact required slots + controlled-vocab enums.Same
@type, different property vocabulary → today's claims fail validation 100%. Proven executably (pyshacl 0.31 / rdflib 7.6):So SHACL can't be meaningfully enabled until the claim representation is aligned (re-key the JSON-LD to LinkML slots, or extend the claim model — note
hasSubject/hasPrimaryImpactare required but have no source field inClaimCreateRequest). Coordinate upstream with PR #53 + FWG/Marie. Seedocs/claims/shacl-alignment-gap.md.Contents
schema/shacl/claim.shacl.ttl— shape generated from PR #53Claim.yaml(provisional until #53 merges)api/shacl_validation.py—pyshaclwrapped inasyncio.to_thread(never block the single-worker event loop), fail-closed on missing shape, gated byVALIDATE_CLAIMS_SHACL(defaultfalse)docs/claims/shacl-alignment-gap.md— gap, proof, two fix options, exact wiring pointtests/test_shacl_claim_shape.py— codifies the proof (3 tests, green)requirements.txt—pyshacl>=0.27,rdflib>=7.0Safety
Review branch. Do not merge to
regen-produntil the claim model is aligned —regen-prodauto-deploys to personal-koi, and enabling synchronous SHACL on the single-worker hot path is an outage risk (asyncio.to_threadmitigates event-loop blocking, but profile under load first).🤖 Generated with Claude Code