feat: w3c vc context for opencert certificate#101
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds OpenCerts Certificate context support to the w3c-context package, including a new context URL constant, template context mapping, and a JSON-LD context definition file with property mappings for certificate attributes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/w3c-context/src/lib/index.ts (1)
83-91: Add a loader regression test for the new context URL.This path depends on the JSON import,
OPENCERTS_CONTEXT_URL, and thetemplateContextsregistration staying in sync. A small test thatawait getDocumentLoader()resolves the OpenCerts URL from cache would guard against future drift.Also applies to: 106-130
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/w3c-context/src/lib/index.ts` around lines 83 - 91, Add a regression test that ensures the new OPENCERTS_CONTEXT_URL is served from the in-memory templateContexts cache by invoking getDocumentLoader() and asserting it resolves the OPENCERTS_CONTEXT_URL without fetching remotely; specifically, write a test that imports OPENCERTS_CONTEXT_URL and templateContexts (symbols: OPENCERTS_CONTEXT_URL, templateContexts) and calls getDocumentLoader() to load OPENCERTS_CONTEXT_URL, expecting a successful cached resolution (no network call) so future changes to the JSON import or templateContexts registration are detected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/w3c-context/src/context/opencerts-context.json`:
- Around line 6-75: Update the vocabulary IRIs by replacing all occurrences of
the placeholder namespace "https://example.com/terms#" used for keys like
admissionDate, graduationDate, recipient, nric, transcript, courseCredit,
courseCode, examinationDate, semester, additionalData, merit, studentId,
transcriptId, certSignatories, and signature with your permanent TrustVC
namespace (replace the placeholder consistently across the file), and fix the
Schema.org mappings by changing "grade" to a valid IRI such as
"https://schema.org/gradeLevel" and "organisation" to the correct type IRI
"https://schema.org/Organization"; then validate the remaining mappings (e.g.,
name->schema.org/name, description->schema.org/description,
issuedOn->schema.org/dateIssued, course->schema.org/course,
position->schema.org/jobTitle) before publishing.
---
Nitpick comments:
In `@packages/w3c-context/src/lib/index.ts`:
- Around line 83-91: Add a regression test that ensures the new
OPENCERTS_CONTEXT_URL is served from the in-memory templateContexts cache by
invoking getDocumentLoader() and asserting it resolves the OPENCERTS_CONTEXT_URL
without fetching remotely; specifically, write a test that imports
OPENCERTS_CONTEXT_URL and templateContexts (symbols: OPENCERTS_CONTEXT_URL,
templateContexts) and calls getDocumentLoader() to load OPENCERTS_CONTEXT_URL,
expecting a successful cached resolution (no network call) so future changes to
the JSON import or templateContexts registration are detected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c1798442-8064-469b-97d8-be6c254f0d05
📒 Files selected for processing (3)
packages/w3c-context/README.mdpackages/w3c-context/src/context/opencerts-context.jsonpackages/w3c-context/src/lib/index.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/w3c-context/src/context/opencerts-context.json`:
- Around line 37-38: The JSON-LD context incorrectly maps "grade" to the
non-existent schema.org predicate https://schema.org/gradeLevel and maps
"organisation" to a class IRI (https://schema.org/Organization) instead of a
predicate; replace both with stable trustvc.io predicate IRIs used elsewhere in
this file (e.g., use something like https://trustvc.io/terms/grade and
https://trustvc.io/terms/organisation) so that "grade" and "organisation" keys
point to predicate IRIs, and update the context publishing path in the context
builder (the code referenced by lib/index.ts that exports this context) to use
the corrected terms. Ensure the new IRIs follow the existing trustvc.io pattern
in this file and preserve any language/term definitions already present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5c07e94e-0d5d-4c2a-a504-672435a637a2
📒 Files selected for processing (1)
packages/w3c-context/src/context/opencerts-context.json
| "grade": { | ||
| "@id": "https://schema.org/gradeLevel" |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In JSON-LD 1.1, if a term in @contextis used as a property, can its@idbe a class IRI such ashttps://schema.org/Organization`? Also, what does Schema.org https://schema.org/gradeLevel represent, and is it intended for academic result values like "A", GPA, or "Distinction"?`
💡 Result:
-
JSON-LD 1.1: can a property term’s
@idbe a class IRI (e.g.,https://schema.org/Organization)?
Yes syntactically: in JSON-LD 1.1 a term definition’s@idvalue may be any IRI/compact IRI/term/etc., and JSON-LD processors generally don’t enforce whether that IRI is “really” an RDF property. However, if you then use that term as a JSON property, the expanded IRI is used as the predicate, so mapping a property term to a class IRI is usually a modeling mistake (you’d typically use that class IRI with@type, not as a predicate). [1] -
What does Schema.org
gradeLevelrepresent, and is it for “A”, GPA, “Distinction”, etc.?
https://schema.org/gradeLevelis not a Schema.org term (the URL returns 404 Not Found). [2]
What people often mean instead is educationalLevel, which Schema.org defines as: “The level in terms of progression through an educational or training context” (e.g., beginner/intermediate/advanced, or formal level/grade schemes). [3] Schema.org’s examples show it being used with a “US Grade Levels” scheme (e.g., grade “2”). [4]
So it’s not intended for academic result values like letter grades (“A”), GPA, or honors (“Distinction”); it’s for the learner’s/credential’s/resource’s level in an education/training progression. [3][4]
Sources
[1] JSON-LD 1.1 spec (term definition @id value constraints) (w3.org)
[2] Schema.org gradeLevel URL (404) ()
[3] Schema.org educationalLevel definition (schema.org)
[4] Schema.org educationalLevel example using “US Grade Levels” (schema.org)
Citations:
- 1: https://www.w3.org/TR/json-ld11/
- 2: https://schema.org/educationalLevel
- 3: https://schema.org/educationalLevel
🏁 Script executed:
fd "opencerts-context.json" -t fRepository: TrustVC/w3c
Length of output: 110
🏁 Script executed:
cat -n packages/w3c-context/src/context/opencerts-context.json | head -100Repository: TrustVC/w3c
Length of output: 2798
Use custom predicates from trustvc.io instead of Schema.org gradeLevel and Organization.
Line 37-38: gradeLevel at https://schema.org/gradeLevel does not exist in Schema.org and is semantically wrong for certificate result values like "A", GPA, or "Distinction".
Line 73-74: organisation uses https://schema.org/Organization, which is a class IRI, not a predicate—a modeling mistake in JSON-LD. Properties should map to predicates, not classes.
Both terms will be published as part of the VC context (via packages/w3c-context/src/lib/index.ts) and become locked into issued credentials, making future migrations difficult. Use custom predicates consistent with the existing trustvc.io terms already used throughout this file.
🔧 Suggested fix
"grade": {
- "@id": "https://schema.org/gradeLevel"
+ "@id": "https://trustvc.io/terms#grade"
},
@@
"organisation": {
- "@id": "https://schema.org/Organization"
+ "@id": "https://trustvc.io/terms#organisation"
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/w3c-context/src/context/opencerts-context.json` around lines 37 -
38, The JSON-LD context incorrectly maps "grade" to the non-existent schema.org
predicate https://schema.org/gradeLevel and maps "organisation" to a class IRI
(https://schema.org/Organization) instead of a predicate; replace both with
stable trustvc.io predicate IRIs used elsewhere in this file (e.g., use
something like https://trustvc.io/terms/grade and
https://trustvc.io/terms/organisation) so that "grade" and "organisation" keys
point to predicate IRIs, and update the context publishing path in the context
builder (the code referenced by lib/index.ts that exports this context) to use
the corrected terms. Ensure the new IRIs follow the existing trustvc.io pattern
in this file and preserve any language/term definitions already present.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/w3c-context/src/context/opencerts-context.json (1)
15-15:⚠️ Potential issue | 🟠 MajorMap
gradeandorganisationto OpenCerts-controlled predicates instead of these Schema.org IRIs.Line 15 uses
https://schema.org/grade, and Line 27 useshttps://schema.org/organization. Those do not look like valid predicate IRIs for these fields, while the rest of this context already uses the OpenCerts namespace for domain-specific terms. Shipping them in a protected VC context will lock incorrect predicates into issued credentials.Suggested fix
- "grade": "https://schema.org/grade", + "grade": "https://schema.opencerts.io/#grade", @@ - "organisation": "https://schema.org/organization" + "organisation": "https://schema.opencerts.io/#organisation"For Schema.org and JSON-LD 1.1, please verify: 1. Is `https://schema.org/grade` a valid Schema.org term? 2. Is `https://schema.org/organization` a valid Schema.org predicate, or is `https://schema.org/Organization` only a class IRI? 3. When a JSON-LD `@context` term like `organisation` is used as a property, should its `@id` map to a predicate IRI rather than a class IRI?Also applies to: 27-27
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/w3c-context/src/context/opencerts-context.json` at line 15, The JSON-LD context currently maps the terms "grade" and "organisation" to Schema.org IRIs ("https://schema.org/grade" and "https://schema.org/organization") which are likely incorrect class IRIs and will lock bad predicates into issued credentials; update the "grade" and "organisation" entries in opencerts-context.json to point to OpenCerts-controlled predicate IRIs used elsewhere in this context (use the existing OpenCerts namespace/predicate pattern already present in the file) and ensure each `@id` is a predicate IRI (not a Schema.org class like Organization); also verify whether Schema.org exposes a predicate for grade and organization before replacing—if not, map both to appropriate open-certs predicates (e.g., the project’s canonical opencerts predicate names) so the context consistently uses the OpenCerts namespace for domain-specific fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@packages/w3c-context/src/context/opencerts-context.json`:
- Line 15: The JSON-LD context currently maps the terms "grade" and
"organisation" to Schema.org IRIs ("https://schema.org/grade" and
"https://schema.org/organization") which are likely incorrect class IRIs and
will lock bad predicates into issued credentials; update the "grade" and
"organisation" entries in opencerts-context.json to point to
OpenCerts-controlled predicate IRIs used elsewhere in this context (use the
existing OpenCerts namespace/predicate pattern already present in the file) and
ensure each `@id` is a predicate IRI (not a Schema.org class like Organization);
also verify whether Schema.org exposes a predicate for grade and organization
before replacing—if not, map both to appropriate open-certs predicates (e.g.,
the project’s canonical opencerts predicate names) so the context consistently
uses the OpenCerts namespace for domain-specific fields.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 47d6a8df-a0b0-4a54-9928-03300aed4215
📒 Files selected for processing (1)
packages/w3c-context/src/context/opencerts-context.json
|
|
# [2.1.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-issuer@2.0.2...@trustvc/w3c-issuer@2.1.0) (2026-04-27) ### Features * w3c vc context for opencert certificate ([#101](#101)) ([0e45032](0e45032))
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.1.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-context@2.0.2...@trustvc/w3c-context@2.1.0) (2026-04-27) ### Features * w3c vc context for opencert certificate ([#101](#101)) ([0e45032](0e45032))
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.1.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-credential-status@2.0.2...@trustvc/w3c-credential-status@2.1.0) (2026-04-27) ### Features * w3c vc context for opencert certificate ([#101](#101)) ([0e45032](0e45032))
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.1.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c-vc@2.0.2...@trustvc/w3c-vc@2.1.0) (2026-04-27) ### Features * w3c vc context for opencert certificate ([#101](#101)) ([0e45032](0e45032))
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.1.0](https://github.com/TrustVC/w3c/compare/@trustvc/w3c@2.0.2...@trustvc/w3c@2.1.0) (2026-04-27) ### Features * w3c vc context for opencert certificate ([#101](#101)) ([0e45032](0e45032))
|
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |





Summary
What is the background of this pull request?
Changes
Issues
What are the related issues or stories?
Releases
Channels: latest
ETA: Any target release date
Summary by CodeRabbit
New Features
Documentation