Implement a new schema trace playground endpoint - #1259
Conversation
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
There was a problem hiding this comment.
Benchmark (community)
Details
| Benchmark suite | Current: d8a5dba | Previous: 6c15e47 | Ratio |
|---|---|---|---|
Add one schema (0 existing) |
222 ms |
219 ms |
1.01 |
Add one schema (100 existing) |
38 ms |
36 ms |
1.06 |
Add one schema (1000 existing) |
94 ms |
96 ms |
0.98 |
Add one schema (10000 existing) |
756 ms |
787 ms |
0.96 |
Update one schema (1 existing) |
30 ms |
29 ms |
1.03 |
Update one schema (101 existing) |
38 ms |
36 ms |
1.06 |
Update one schema (1001 existing) |
103 ms |
100 ms |
1.03 |
Update one schema (10001 existing) |
780 ms |
800 ms |
0.97 |
Cached rebuild (1 existing) |
12 ms |
12 ms |
1 |
Cached rebuild (101 existing) |
13 ms |
14 ms |
0.93 |
Cached rebuild (1001 existing) |
44 ms |
49 ms |
0.90 |
Cached rebuild (10001 existing) |
338 ms |
347 ms |
0.97 |
Index 100 schemas |
459 ms |
450 ms |
1.02 |
Index 1000 schemas |
1337 ms |
1297 ms |
1.03 |
Index 10000 schemas |
12037 ms |
13155 ms |
0.92 |
Index 10000 schemas (custom meta-schema) |
13738 ms |
14488 ms |
0.95 |
Index 10000 schemas ($ref fan-out) |
14460 ms |
14708 ms |
0.98 |
test/e2e/html: Schema Fetch (p50) |
389 us |
389 us |
1 |
test/e2e/html: Schema Fetch (p99) |
464 us |
511 us |
0.91 |
This comment was automatically generated by workflow using github-action-benchmark.
|
This pull request is too large for Augment to review. The PR exceeds the maximum size limit of 75000 tokens (approximately 300000 characters) for automated code review. Please consider breaking this PR into smaller, more focused changes. |
There was a problem hiding this comment.
1 issue found across 60 files
Not reviewed (too large): test/e2e/html/hurl/playground-schemas-trace.all.hurl (~3,546 lines), test/cli/index/common/rebuild-cache.clitest (~1,024 lines), test/cli/index/common/rebuild-one-to-zero.clitest (~934 lines), test/cli/index/common/rebuild-zero-to-one.clitest (~918 lines), test/cli/index/common/rebuild-comment-removed.clitest (~812 lines), test/cli/index/common/rebuild-comment-updated.clitest (~812 lines), test/cli/index/common/rebuild-extra-files.clitest (~780 lines), test/cli/index/common/rebuild-cache-config-change.clitest (~684 lines), test/cli/index/common/output-verbose-long.clitest (~660 lines), test/cli/index/common/output-verbose-short.clitest (~660 lines), and 3 more - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.
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="src/self/v1/schemas/api/playground/schemas/trace/request.json">
<violation number="1" location="src/self/v1/schemas/api/playground/schemas/trace/request.json:24">
P3: When a caller supplies an inline schema, requiring `type: object` and `$schema` rejects valid boolean schemas (true/false) and schemas written against a default dialect. If the underlying compiler accepts those, loosen the request contract (drop `type: object`/`required` or make `$schema` optional) so the endpoint accepts every schema the compiler can handle; otherwise document the restriction.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| "description": "The JSON Schema to evaluate the instance against", | ||
| "x-lint-exclude": [ "simple_properties_identifiers" ], | ||
| "type": "object", | ||
| "required": [ "$schema" ], |
There was a problem hiding this comment.
P3: When a caller supplies an inline schema, requiring type: object and $schema rejects valid boolean schemas (true/false) and schemas written against a default dialect. If the underlying compiler accepts those, loosen the request contract (drop type: object/required or make $schema optional) so the endpoint accepts every schema the compiler can handle; otherwise document the restriction.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/self/v1/schemas/api/playground/schemas/trace/request.json, line 24:
<comment>When a caller supplies an inline schema, requiring `type: object` and `$schema` rejects valid boolean schemas (true/false) and schemas written against a default dialect. If the underlying compiler accepts those, loosen the request contract (drop `type: object`/`required` or make `$schema` optional) so the endpoint accepts every schema the compiler can handle; otherwise document the restriction.</comment>
<file context>
@@ -0,0 +1,36 @@
+ "description": "The JSON Schema to evaluate the instance against",
+ "x-lint-exclude": [ "simple_properties_identifiers" ],
+ "type": "object",
+ "required": [ "$schema" ],
+ "properties": {
+ "$schema": {
</file context>
| "type": "urn:sourcemeta:one:schema-too-complex", | ||
| "title": "Unprocessable Content", | ||
| "status": 422, | ||
| "detail": "The supplied schema is too complex to compile" |
There was a problem hiding this comment.
TODO: Maybe suggest trying a simpler one OR making it part of the catalog, as ingested ones won't have the limits? i.e. explain why there are limits here
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 19 files (changes from recent commits).
Not reviewed (too large): enterprise/e2e/auth/hurl/mcp-resources.all.hurl (~1,410 lines), test/e2e/html/hurl/playground-unwalkable.json (~1 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
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="src/router/evaluate.cc">
<violation number="1" location="src/router/evaluate.cc:119">
P3: The fallback `$schema` scan walks the entire document including plain data positions (`examples`, `default`, `const`, array elements) and matches any key literally named `$schema` whose string equals the failing identifier. A non-dialect data value named `$schema` would be reported as the failing `reference`/`schemaLocation`, and because the loop stops at the first match it can shadow the real declaring resource. Restrict the search to positions where `$schema` is a genuine resource-dialect declaration (resource roots) rather than any key anywhere in the tree.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| for (const auto &member : entry.first->as_object()) { | ||
| auto nested{entry.second}; | ||
| nested.push_back(member.first); | ||
| if (member.first == "$schema" && member.second.is_string() && |
There was a problem hiding this comment.
P3: The fallback $schema scan walks the entire document including plain data positions (examples, default, const, array elements) and matches any key literally named $schema whose string equals the failing identifier. A non-dialect data value named $schema would be reported as the failing reference/schemaLocation, and because the loop stops at the first match it can shadow the real declaring resource. Restrict the search to positions where $schema is a genuine resource-dialect declaration (resource roots) rather than any key anywhere in the tree.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/router/evaluate.cc, line 119:
<comment>The fallback `$schema` scan walks the entire document including plain data positions (`examples`, `default`, `const`, array elements) and matches any key literally named `$schema` whose string equals the failing identifier. A non-dialect data value named `$schema` would be reported as the failing `reference`/`schemaLocation`, and because the loop stops at the first match it can shadow the real declaring resource. Restrict the search to positions where `$schema` is a genuine resource-dialect declaration (resource roots) rather than any key anywhere in the tree.</comment>
<file context>
@@ -99,13 +100,40 @@ auto unresolvable_reference(const sourcemeta::core::JSON &document,
+ for (const auto &member : entry.first->as_object()) {
+ auto nested{entry.second};
+ nested.push_back(member.first);
+ if (member.first == "$schema" && member.second.is_string() &&
+ member.second.to_string() == identifier) {
+ reference = member.second.to_string();
</file context>
There was a problem hiding this comment.
Benchmark (enterprise)
Details
| Benchmark suite | Current: d8a5dba | Previous: 6c15e47 | Ratio |
|---|---|---|---|
Add one schema (0 existing) |
309 ms |
294 ms |
1.05 |
Add one schema (100 existing) |
117 ms |
119 ms |
0.98 |
Add one schema (1000 existing) |
165 ms |
175 ms |
0.94 |
Add one schema (10000 existing) |
749 ms |
768 ms |
0.98 |
Update one schema (1 existing) |
107 ms |
114 ms |
0.94 |
Update one schema (101 existing) |
116 ms |
123 ms |
0.94 |
Update one schema (1001 existing) |
168 ms |
176 ms |
0.95 |
Update one schema (10001 existing) |
759 ms |
801 ms |
0.95 |
Cached rebuild (1 existing) |
14 ms |
14 ms |
1 |
Cached rebuild (101 existing) |
16 ms |
16 ms |
1 |
Cached rebuild (1001 existing) |
50 ms |
47 ms |
1.06 |
Cached rebuild (10001 existing) |
297 ms |
337 ms |
0.88 |
Index 100 schemas |
406 ms |
551 ms |
0.74 |
Index 1000 schemas |
1512 ms |
1418 ms |
1.07 |
Index 10000 schemas |
13707 ms |
12160 ms |
1.13 |
Index 10000 schemas (custom meta-schema) |
14913 ms |
14144 ms |
1.05 |
Index 10000 schemas ($ref fan-out) |
15082 ms |
14668 ms |
1.03 |
enterprise/e2e/auth: Schema Anonymous (p50) |
397 us |
372 us |
1.07 |
enterprise/e2e/auth: Schema Anonymous (p99) |
505 us |
471 us |
1.07 |
enterprise/e2e/auth: Schema API Key Identity (p50) |
401 us |
377 us |
1.06 |
enterprise/e2e/auth: Schema API Key Identity (p99) |
513 us |
480 us |
1.07 |
enterprise/e2e/auth: Schema API Key SHA256 (p50) |
408 us |
387 us |
1.05 |
enterprise/e2e/auth: Schema API Key SHA256 (p99) |
521 us |
493 us |
1.06 |
enterprise/e2e/auth: Schema JWT (p50) |
534 us |
531 us |
1.01 |
enterprise/e2e/auth: Schema JWT (p99) |
679 us |
682 us |
1.00 |
test/e2e/html: Schema Fetch (p50) |
403 us |
381 us |
1.06 |
test/e2e/html: Schema Fetch (p99) |
486 us |
464 us |
1.05 |
This comment was automatically generated by workflow using github-action-benchmark.
Sourcemeta One gained a new playground trace endpoint (POST /self/v1/api/playground/schemas/trace, sourcemeta/one#1259) that compiles and traces a schema supplied inline, server-side, and resolves $refs into schemas already in the registry — something the client-side WASM compiler can't do since it has no registry access. Adds an engine toggle (WASM / Registry API) so both can be exercised side by side. WASM stays the default since the new endpoint isn't deployed on schemas.sourcemeta.com yet (confirmed via a direct request — 404, matching the "not yet deployed" status reported upstream). Once confirmed working, WASM can be dropped in favor of the registry endpoint. Signed-off-by: itvi-1234 <rjsumit71@gmail.com>
Sourcemeta One gained a server-side endpoint for this exact use case (POST /self/v1/api/playground/schemas/trace, sourcemeta/one#1259): compile and trace a schema supplied inline, with $refs into schemas already in the registry resolved server-side — something the client-side WASM compiler could never do, since it had no registry access. Verified live on schemas.sourcemeta.com, including chained $ref resolution through a real registry schema. Removes src/lib/blaze/ (the compiled Blaze-to-WebAssembly module and its JS evaluator) and resolveEvaluatePath.ts (the $ref-chasing hack that WASM's evaluatePath needed to line up with the pasted schema text) entirely. Schema-panel highlighting now uses the API response's keywordLocation directly, which is already a correct JSON pointer into the posted schema for same-document $refs, and a note is shown for keywords that live inside a referenced registry schema instead of attempting (and failing) to resolve them locally. Signed-off-by: itvi-1234 <rjsumit71@gmail.com>
Signed-off-by: Juan Cruz Viotti jv@jviotti.com