Repository navigation
fix: preserve language-tagged literals that share a value (#1273) - #1291
Merged
Merged
Conversation
Language-tagged literals with the same string value but different language tags (e.g. "animal"@en and "animal"@fr) were silently deduplicated on insert, dropping all but one variant. Two read paths collapsed distinct facts because they ignored the flake metadata `m` (language tag and list index), which is part of RDF term identity: - range::remove_stale_flakes (overlay-only / genesis read path) keyed its fact dedup on (s, p, o, dt) only. Add `m` so the key matches the canonical Flake identity. This also fixes over-cancellation when deleting one language variant and the silent loss of @list members that repeat a value at different positions. - value_to_otype_okey (binary-overlay encode path) fell back to a fixed lang_id=1 for a novelty-introduced tag not yet in the persisted language dictionary, collapsing every such tag to one OType. Return Unsupported instead so the flake is merged via the raw-flake path, which carries the real metadata and dedups on full identity, mirroring how novelty-only custom datatypes are already handled. Adds regression tests for the genesis, indexed-overlay, delete, list duplicate, and set-collapse scenarios, and documents that the language tag is part of a value's identity.
RDF export attached the novelty overlay so it could see committed-but- not-yet-indexed data, but two gaps dropped or corrupted that data: - Overlay flakes that cannot be encoded into V3 ops (language-tagged literals whose tag is not yet in the persisted language dictionary, plus vector/bigint/decimal and novelty-only custom datatypes) were silently discarded. Switch the overlay translation to the with-untranslated variant and emit those raw flakes directly in every format (Turtle, N-Triples, N-Quads, JSON-LD), deriving the language tag from the flake metadata and the datatype from the flake datatype. Assert/retract set semantics are resolved over the untranslated set before emitting. - The export cursor used a CORE column projection, but the overlay merge requires the full V3 identity (including the list index). Use the full projection so encoded novelty overlay rows merge correctly instead of reading missing columns as defaults. Adds a multi-format export regression test for novelty-only language tags.
Adversarial review raised a concern that export's raw-flake path resolves subject/predicate IRIs via the immutable store without a novelty fallback, which could drop facts in a namespace first introduced after the last index. Add a regression test that exercises exactly that: a brand-new namespace introduced by novelty over an indexed ledger, with both an encoded value (integer) and a raw novelty-only langString. It passes because the public export path loads the ledger fresh, syncing the store's namespace codes with the snapshot's commit chain before export, so both paths resolve the new namespace correctly.
Note that RDF fact identity is (s, p, o, dt, m) and any dedup/stale-removal key omitting the FlakeMeta `m` collapses distinct language-tagged and list facts, so future work in this area recalls it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inserting a subject with several language-tagged values whose strings are
identical but whose
@languagetags differ — e.g."animal"@enand"animal"@fr— silently dropped all but one variant. Ingesting a multilingualSKOS thesaurus lost hundreds of labels, hitting English hardest because EN and
FR share many literal forms.
The root cause is fact identity. A language-tagged literal's identity includes
its language tag, and a list member's includes its position, so both live in the
flake metadata
malongside(s, p, o, dt). The overlay-only read path(
range::remove_stale_flakes, used for committed-but-not-yet-indexed data andgenesis ledgers) keyed its set-semantics dedup on
(s, p, o, dt)only anddropped
m. Two variants that shared a value therefore looked like one fact andcollapsed. The binary-scan path already keyed on the full identity; this just
brings the two into agreement with
Flake's own equality.Adding
mto that key fixes three failure modes from the same omission:matches only the variant it names);
@listmembers that repeat a value at different positions(
["a", "b", "a"]) are no longer collapsed.A second, related path is the binary overlay encoder. When a language tag has
not yet been added to the persisted language dictionary (a fresh tag in novelty
over an indexed ledger), it was encoded with a fixed fallback id, collapsing
every such tag to one value and mis-labelling the survivor. It now declines that
encoding and routes the flake through the raw-flake overlay path — which carries
the real metadata and dedups on full identity — mirroring how novelty-only
custom datatypes are already handled.
Finally, RDF export attaches the same novelty overlay so it can dump
committed-but-unindexed data. It previously discarded any flake it could not
encode into the columnar overlay (the new-tag language literals above, plus
vector/bigint/decimal and novelty-only custom datatypes), and it scanned with a
projection too narrow for the overlay merge. Export now emits those values
directly in every format (Turtle, N-Triples, N-Quads, JSON-LD), deriving the
language tag and datatype from the flake, and scans with the full identity
projection.
Closes #1273.