Skip to content

feat: w3c vc context for opencert certificate#101

Merged
rongquan1 merged 8 commits into
mainfrom
feat/TT-1235-opencert-certificate-context
Apr 27, 2026
Merged

feat: w3c vc context for opencert certificate#101
rongquan1 merged 8 commits into
mainfrom
feat/TT-1235-opencert-certificate-context

Conversation

@manishdex25
Copy link
Copy Markdown
Contributor

@manishdex25 manishdex25 commented Mar 9, 2026

Summary

What is the background of this pull request?

Changes

  • What are the changes made in this pull request?
  • Change this and that, etc...

Issues

What are the related issues or stories?

Releases

Channels: latest
ETA: Any target release date

Summary by CodeRabbit

  • New Features

    • Added OpenCerts Certificate context support, enabling credential verification workflows with OpenCerts-formatted certificates.
  • Documentation

    • Updated documentation to include OpenCerts Certificate in the list of available pre-cached contexts.

@manishdex25 manishdex25 requested a review from Isaac-kps March 9, 2026 11:12
@manishdex25 manishdex25 self-assigned this Mar 9, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Documentation
packages/w3c-context/README.md
Added OpenCerts Certificate to the list of pre-cached TrustVC Business Contexts.
Context Registration
packages/w3c-context/src/lib/index.ts
Exported new OPENCERTS_CONTEXT_URL constant and registered opencertsContext in the templateContexts map.
Context Definition
packages/w3c-context/src/context/opencerts-demo-context.json
Added new JSON-LD context file defining term mappings for OpenCerts certificate properties (recipient, nric, course, transcript, grade, etc.).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested reviewers

  • nghaninn

Poem

🐰 A context for certs, so shiny and new,
OpenCerts now trusted in TrustVC's bright view,
Term mappings bundled with care and precision,
Another foundation laid down with decision! 📜✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only placeholder text and does not provide any actual background, details about changes, related issues, or release information. Replace placeholders with concrete information: explain the W3C context addition rationale, list specific file additions, reference the related issue (TT-1235), and provide actual release details.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'feat: w3c vc context for opencert certificate' directly describes the main change: adding a W3C VC context for OpenCert certificates. It aligns with the changeset which adds a new OpenCerts context URL, context mapping, and JSON-LD context definition.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/TT-1235-opencert-certificate-context

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the templateContexts registration staying in sync. A small test that await 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

📥 Commits

Reviewing files that changed from the base of the PR and between 25641b7 and 4f0bce9.

📒 Files selected for processing (3)
  • packages/w3c-context/README.md
  • packages/w3c-context/src/context/opencerts-context.json
  • packages/w3c-context/src/lib/index.ts

Comment thread packages/w3c-context/src/context/opencerts-context.json Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0bce9 and 2327730.

📒 Files selected for processing (1)
  • packages/w3c-context/src/context/opencerts-context.json

Comment on lines +37 to +38
"grade": {
"@id": "https://schema.org/gradeLevel"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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:

  1. JSON-LD 1.1: can a property term’s @id be a class IRI (e.g., https://schema.org/Organization)?
    Yes syntactically: in JSON-LD 1.1 a term definition’s @id value 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]

  2. What does Schema.org gradeLevel represent, and is it for “A”, GPA, “Distinction”, etc.?
    https://schema.org/gradeLevel is 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:


🏁 Script executed:

fd "opencerts-context.json" -t f

Repository: TrustVC/w3c

Length of output: 110


🏁 Script executed:

cat -n packages/w3c-context/src/context/opencerts-context.json | head -100

Repository: 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/w3c-context/src/context/opencerts-context.json (1)

15-15: ⚠️ Potential issue | 🟠 Major

Map grade and organisation to OpenCerts-controlled predicates instead of these Schema.org IRIs.

Line 15 uses https://schema.org/grade, and Line 27 uses https://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

📥 Commits

Reviewing files that changed from the base of the PR and between 2327730 and 1708f3c.

📒 Files selected for processing (1)
  • packages/w3c-context/src/context/opencerts-context.json

@manishdex25 manishdex25 requested review from rongquan1 and removed request for Isaac-kps March 12, 2026 06:50
@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

@rongquan1 rongquan1 changed the title feat: added w3c Vc conext for opencert certificate feat: w3c vc context for opencert certificate Apr 27, 2026
@rongquan1 rongquan1 merged commit 0e45032 into main Apr 27, 2026
18 of 19 checks passed
@rongquan1 rongquan1 deleted the feat/TT-1235-opencert-certificate-context branch April 27, 2026 09:01
nghaninn pushed a commit that referenced this pull request Apr 27, 2026
@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Apr 27, 2026
@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Apr 27, 2026
@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

nghaninn pushed a commit that referenced this pull request Apr 27, 2026
@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants