Skip to content

Commit 97f5f45

Browse files
skydudieclaude
andcommitted
v0.69.0: toRdf harness — compare RDF datasets as sets (dedupe quads) (+1 toRdf)
- The toRdf comparison now de-duplicates quads before comparing, matching the RDF data model (a dataset is a SET of quads, compared up to isomorphism). The same value reached through two @index keys yields the same triple once its @index is dropped in RDF; our toNQuads already serialises a proper de-duplicated set, but the harness's line-multiplicity comparison wrongly demanded the reference fixture's duplicate lines (#te036). No library code changed — the processor's toRdf output is unchanged and remains a valid (de-duplicated) RDF dataset. W3C (toEqual gate): toRdf 459->460 (+1); expand 378, compact 246 (100%) unchanged. Unit 285 green; phpstan max clean; pint clean; 0 regressions. The remaining 7 toRdf failures are all genuine blockers (same set as the expansion tail): tc031, tc032, tc033, te128, ter56, tin06, tjs10. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0b31c4c commit 97f5f45

4 files changed

Lines changed: 43 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.69.0] - 2026-06-10
11+
12+
toRdf harness: compare RDF datasets as sets (de-duplicate quads).
13+
14+
W3C JSON-LD 1.1 test suite (corrected `toEqual` gate):
15+
16+
```
17+
expand compact toRdf
18+
v0.68.0: 378 246 459
19+
v0.69.0: 378 246 460 (+1 toRdf)
20+
```
21+
22+
### Fixed (test harness)
23+
24+
- The toRdf comparison now de-duplicates quads before comparing, matching the
25+
RDF data model (a dataset is a *set* of quads, compared up to isomorphism).
26+
The same value reached through two `@index` keys yields the same triple once
27+
its `@index` is dropped in RDF; our `toNQuads` already serialises a proper
28+
de-duplicated set, but the harness's line-multiplicity comparison wrongly
29+
expected the reference fixture's duplicate lines (`#te036`). No library code
30+
changed — the processor's toRdf output is unchanged and remains a valid
31+
(de-duplicated) RDF dataset.
32+
33+
The remaining 7 toRdf failures are all genuine environment/spec-accommodation
34+
blockers — the same set as expansion's tail: `#tc031` (offline relative URL),
35+
`#tc032`/`#tc033` (unused-context error), `#te128` (shared-context circular
36+
ref), `#ter56` (VC `@context`-term accommodation), `#tin06` (json.api),
37+
`#tjs10` (PHP `json_decode` `{}`-vs-`[]`).
38+
1039
## [0.68.0] - 2026-06-10
1140

1241
toRdf: JSON Canonicalization Scheme for `@json` literals.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A PHP implementation of the [JSON-LD 1.1](https://www.w3.org/TR/json-ld11/) spec
3131
- [x] Custom `DocumentLoader` interface
3232
- [~] Expansion (§5.5) — implemented; ~378/385 of the W3C expand suite (the remaining 7 are environment/spec-accommodation blockers)
3333
- [x] Compaction (§5.6) — **246/246 of the W3C compact suite (100%)**: container-maps (incl. property-valued `@index`, `@type`-map node refs), keyword recursion, `@nest`, nested `@list`, `@graph` maps, `@reverse` (incl. per-value term selection and containers), full inverse-context term scoring (list/direction-aware, `@json` literals), property-/type-scoped contexts with scoped `@base`/`@vocab`, IRI relativisation, expand-first normalisation, the `compactArrays` option, §5.7 prefix rules and error conditions
34-
- [~] Serialize JSON-LD to RDF (§7 / `toRdf`) — implemented; ~459/467 of the W3C toRdf suite (N-Quads output incl. `rdfDirection`, `produceGeneralizedRdf`, and JCS `@json` canonicalization)
34+
- [~] Serialize JSON-LD to RDF (§7 / `toRdf`) — implemented; **460/467 of the W3C toRdf suite** (the remaining 7 are environment/spec-accommodation blockers); N-Quads output incl. `rdfDirection`, `produceGeneralizedRdf`, and JCS `@json` canonicalization
3535

3636
> Suite numbers from v0.42.0 use the spec-accurate `toEqual` comparison
3737
> (object-key order insignificant, array order significant); earlier numbers

tests/W3c/Algorithms/ToRdfTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ function normaliseNQuads(string $nquads): string
120120
static fn (string $line): string => remapNQuadsLine($line, static fn (string $label): string => $map[$label] ?? $label),
121121
$lines,
122122
);
123+
// An RDF dataset is a SET of quads, so duplicate quads (e.g. the same value
124+
// reached through two @index keys, whose @index is dropped in RDF — #te036)
125+
// are semantically irrelevant: compare datasets up to set membership.
126+
$relabelled = array_values(array_unique($relabelled));
123127
sort($relabelled, SORT_STRING);
124128

125129
return implode("\n", $relabelled);
@@ -241,10 +245,13 @@ function nQuadsIsomorphic(array $a, array $b): bool
241245
*/
242246
function nQuadsLines(string $nquads): array
243247
{
244-
return array_values(array_filter(
248+
// Deduplicate: a dataset is a set, so exact-duplicate quads do not affect
249+
// isomorphism (the count-based prune in nQuadsIsomorphic must see set
250+
// cardinality, not line multiplicity).
251+
return array_values(array_unique(array_filter(
245252
array_map('trim', explode("\n", $nquads)),
246253
static fn (string $l): bool => $l !== '',
247-
));
254+
)));
248255
}
249256

250257
it('serialises to RDF per W3C manifest', function (TestCase $test) {

tests/W3c/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ composer test:all
5050
## Current score
5151

5252
```
53-
Expansion: 378 passed / 7 failed (v0.68.0)
54-
Compaction: 246 passed / 0 failed (v0.68.0) ← 100%
55-
toRdf: 459 passed / 8 failed (v0.68.0)
53+
Expansion: 378 passed / 7 failed (v0.69.0)
54+
Compaction: 246 passed / 0 failed (v0.69.0) ← 100%
55+
toRdf: 460 passed / 7 failed (v0.69.0) ← remaining 7 are blockers
5656
```
5757

5858
> v0.42.0 corrected the expand/compact comparison from `toEqualCanonicalizing`
@@ -137,6 +137,7 @@ Each Phase 4 PR:
137137
| v0.66.0 | 378 | +0 | toRdf: reject double-fragment (non-well-formed) IRIs (+2 toRdf)|
138138
| v0.67.0 | 378 | +0 | toRdf: empty node → blank node; @id-vanished node dropped (+2 toRdf)|
139139
| v0.68.0 | 378 | +0 | toRdf: JSON Canonicalization Scheme (ECMAScript numbers) for @json (+1 toRdf)|
140+
| v0.69.0 | 378 | +0 | toRdf harness: compare RDF datasets as sets (dedupe quads) (+1 toRdf — remaining 7 are blockers)|
140141

141142
### Notes on v0.4.0
142143

0 commit comments

Comments
 (0)