Skip to content

Implement an rdf command for converting into JSON-LD#791

Merged
jviotti merged 7 commits into
mainfrom
rdf-command
Jul 8, 2026
Merged

Implement an rdf command for converting into JSON-LD#791
jviotti merged 7 commits into
mainfrom
rdf-command

Conversation

@jviotti

@jviotti jviotti commented Jul 8, 2026

Copy link
Copy Markdown
Member

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Review in cubic

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added 3 commits July 8, 2026 16:52
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti jviotti changed the title [WIP] Implement an rdf command for converting into JSON-LD Implement an rdf command for converting into JSON-LD Jul 8, 2026
@jviotti jviotti marked this pull request as ready for review July 8, 2026 20:37
@augmentcode

augmentcode Bot commented Jul 8, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR introduces a new jsonschema rdf CLI command that promotes a valid JSON/YAML instance into JSON-LD using x-jsonld-* schema annotations.

Changes:

  • Added rdf command wiring (CMake + command dispatch + CLI help) and linked the JSON-LD core library
  • Implemented src/command_rdf.cc to compile schemas with JSON-LD annotation collection and emit expanded JSON-LD, with optional flattening/compaction
  • Refactored schema bundling/framing/compilation error handling into shared helpers in src/utils.h, and reused them from validate
  • Extended error printing to include document JSON Pointer locations where available
  • Updated shell completions (bash/zsh) and README/docs to expose the new command
  • Added a comprehensive RDF test suite covering success cases, stdin/YAML inputs, and failure/error-reporting scenarios

Technical Notes: The rdf command enforces a 2019-09+ base dialect (annotation collection requirement) and maps JSON-LD context/compaction errors into consistent CLI exit codes and error formats.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/main.cc Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 86 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/rdf/fail_compact_context_invalid_json.sh">

<violation number="1" location="test/rdf/fail_compact_context_invalid_json.sh:27">
P3: Each test run should capture **both** stdout and stderr so the unused stream is verified empty. In the text-variant run (line 27–29), stderr is captured but stdout is not; if an accidental log line or summary reaches stdout, the test won't catch it. In the JSON-variant run (line 39–42), stdout with `--json` is captured but stderr is not; text leaking to stderr alongside the JSON output would go undetected. Recommendation: redirect the unused stream to a separate file and assert it is empty, or use a helper that captures both.</violation>
</file>

<file name="test/rdf/pass_keyword_type.sh">

<violation number="1" location="test/rdf/pass_keyword_type.sh:33">
P1: The expected `@type` array has the IRIs in reverse order compared to the schema's `x-jsonld-type`. The schema specifies `["https://schema.org/Person", "https://schema.org/Agent"]` (Person first), but the expected output lists Agent first. The implementation in `vendor/blaze/src/output/output_jsonld.cc` preserves insertion order via `push_back` without sorting, so this test will fail on `diff`.</violation>
</file>

<file name="test/rdf/pass_keyword_container_index.sh">

<violation number="1" location="test/rdf/pass_keyword_container_index.sh:18">
P1: Expected output silently drops the object keys ("a", "b") which should be preserved as `@index` values per `@container: @index` semantics. In JSON-LD, `@container: @index` means the keys of the source object map to `@index` properties on each entry — analogous to how `@language` maps keys to `@language` in `pass_keyword_container_language.sh`. Without the `@index` field, the output loses the identity of each indexed entry.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread test/rdf/pass_keyword_container_index.sh
Comment thread test/rdf/pass_keyword_type.sh
Comment thread test/rdf/fail_invalid_instance_stdin.sh
Comment thread src/utils.h
Comment thread test/rdf/fail_compact_context_invalid_json.sh
Comment thread src/main.cc Outdated
jviotti added 3 commits July 8, 2026 17:57
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti jviotti merged commit 1ce3b97 into main Jul 8, 2026
15 checks passed
@jviotti jviotti deleted the rdf-command branch July 8, 2026 22:57
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jul 9, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [sourcemeta/jsonschema](https://github.com/sourcemeta/jsonschema) | minor | `v16.0.0` → `v16.1.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>sourcemeta/jsonschema (sourcemeta/jsonschema)</summary>

### [`v16.1.0`](https://github.com/sourcemeta/jsonschema/releases/tag/v16.1.0)

[Compare Source](sourcemeta/jsonschema@v16.0.0...v16.1.0)

#### What's Changed

- Update the README banner by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;783](sourcemeta/jsonschema#783)
- Rename `SOURCEMETA_JSONSCHEMA_CURL_SO` to `SOURCEMETA_CORE_CURL_SO` by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;784](sourcemeta/jsonschema#784)
- Fix some validation edge cases due to over optimisations in `validate --fast` by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;785](sourcemeta/jsonschema#785)
- Fix YAML syntax errors not properly caught by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;787](sourcemeta/jsonschema#787)
- Various minor fixes and performance optimisations by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;790](sourcemeta/jsonschema#790), [#&#8203;789](sourcemeta/jsonschema#789), [#&#8203;788](sourcemeta/jsonschema#788), and [#&#8203;786](sourcemeta/jsonschema#786)
- Implement an `rdf` command for converting into JSON-LD by [@&#8203;jviotti](https://github.com/jviotti) in [#&#8203;791](sourcemeta/jsonschema#791)

**Full Changelog**: <sourcemeta/jsonschema@v16.0.0...v16.1.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNTYuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI1Ni4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant