Repository navigation
Conversation
|
This is PR 3 of 3 you may keep open at a time. |
|
This is PR 3 of 3 you may keep open at a time. |
arrry-hydraDB
left a comment
There was a problem hiding this comment.
Biome format fails on trust.test.ts:437 (CI red). Please run npm run format, update the stale docstring at _export.py:49, and the Ossie table in docs/schema.md.
| placeholder = f"{target}:other" | ||
| concepts.setdefault(source, {"concept": source, "type": "EntityType", "relationships": []}) | ||
| if target != "Any": | ||
| concepts.setdefault(target, {"concept": target, "type": "EntityType", "relationships": []}) |
There was a problem hiding this comment.
Main now rejects undeclared relation targets, so the new tests fail once merged (unknown type Company), and this branch now only adds alias or case variants like Org next to Company. Please rebase and resolve targets to their declared type. Also add a to_ossie case to the conformance pair.
| placeholder = `${target}:other`; | ||
| } | ||
| if (!concepts.has(source)) concepts.set(source, { concept: source, type: "EntityType", relationships: [] }); | ||
| if (target !== "Any" && !concepts.has(target)) { |
There was a problem hiding this comment.
Same here, and the toOssie docstring still needs the update the Python one got.
287eabe to
0bb71c2
Compare
| multiplicity = {"multiplicity": "OneToOne" if relation.to.max_count == 1 else "ManyToOne"} | ||
| for source in relation.from_.types: | ||
| for raw_source in relation.from_.types: | ||
| source = canonical_entity_type(raw_source, schema) |
There was a problem hiding this comment.
Endpoints are canonicalized but not deduplicated, so Person and User sources with Company and Org targets export four identical WORKS_AT_Company relationships under Person. Main gives distinct ones. Please dedupe sources and targets after resolving them.
| placeholder = f"{target}:other" | ||
| concepts.setdefault(source, {"concept": source, "type": "EntityType", "relationships": []}) | ||
| if target != "Any": | ||
| concepts.setdefault(target, {"concept": target, "type": "EntityType", "relationships": []}) |
There was a problem hiding this comment.
Every target is a declared type now, so this never adds anything. Removing it leaves the output byte identical. Please drop it.
| placeholder = `${target}:other`; | ||
| } | ||
| if (!concepts.has(source)) concepts.set(source, { concept: source, type: "EntityType", relationships: [] }); | ||
| if (target !== "Any" && !concepts.has(target)) { |
There was a problem hiding this comment.
Same two points here.
| words = rtype.lower().replace("_", " ") | ||
| targets = relation.to.types or ["Any"] | ||
| raw_targets = relation.to.types or ["Any"] | ||
| targets = list(dict.fromkeys(t if t == "Any" else canonical_entity_type(t, schema) for t in raw_targets)) |
There was a problem hiding this comment.
The Any check runs before canonicalizing, so a type alias spelled Any for Company exports the wildcard instead of Company. Please canonicalize first and treat Any only when it is not a declared alias.
| const words = rtype.toLowerCase().replaceAll("_", " "); | ||
| const targets = relation.to.types.length ? relation.to.types : ["Any"]; | ||
| const rawTargets = relation.to.types.length ? relation.to.types : ["Any"]; | ||
| const targets = [...new Set(rawTargets.map((t) => (t === "Any" ? "Any" : canonicalEntityType(t, schema))))]; |
| return "\n".join(lines) | ||
|
|
||
|
|
||
| def ossie_export(): |
There was a problem hiding this comment.
This repeats the log capture block from neo4j_export_warnings line for line. Please share one helper.
| ) | ||
| words = rtype.lower().replace("_", " ") | ||
| targets = relation.to.types or ["Any"] | ||
| raw_targets = relation.to.types or ["Any"] |
There was a problem hiding this comment.
The Any alias case is fixed, but now a relation with no target types exports whichever entity has the alias Any instead of the wildcard. Please canonicalize only the listed targets and fall back to Any when the list is empty.
| }); | ||
| const words = rtype.toLowerCase().replaceAll("_", " "); | ||
| const targets = relation.to.types.length ? relation.to.types : ["Any"]; | ||
| const rawTargets = relation.to.types.length ? relation.to.types : ["Any"]; |
| assert doc["ontology"][0]["relationships"][0]["roles"] == [{"concept": "Company"}] | ||
|
|
||
|
|
||
| def test_ossie_export_keeps_the_any_wildcard_for_relations_without_targets(): |
There was a problem hiding this comment.
This test passes on main, so it does not cover the change. Please remove it.
| expect(result.ontology[0]!.relationships![0]!.roles).toEqual([{ concept: "Company" }]); | ||
| }); | ||
|
|
||
| it("keeps the Any wildcard for relations without targets", () => { |
There was a problem hiding this comment.
Same here: passes on main. Please remove it.
| */ | ||
| export function ossieExport(): { doc: unknown; warnings: string } { | ||
| const lines: string[] = []; | ||
| const previous = setLogger((message) => lines.push(message)); |
There was a problem hiding this comment.
This repeats the setLogger capture block from neo4jExportWarnings. Please share one helper, like the Python side now does.
|
@arrry-hydraDB check this one too |
| words = rtype.lower().replace("_", " ") | ||
| targets = relation.to.types or ["Any"] | ||
| targets = ( | ||
| list(dict.fromkeys(canonical_entity_type(t, schema) for t in relation.to.types)) |
There was a problem hiding this comment.
#215 now canonicalizes and dedupes endpoint types when the schema is parsed, so this does nothing new: the Ossie output matches main on 30 seeded schemas. Please drop it and keep only the OneToMany warning.
| const words = rtype.toLowerCase().replaceAll("_", " "); | ||
| const targets = relation.to.types.length ? relation.to.types : ["Any"]; | ||
| const targets = relation.to.types.length | ||
| ? [...new Set(relation.to.types.map((t) => canonicalEntityType(t, schema)))] |
| ] | ||
|
|
||
|
|
||
| def test_ossie_export_dedupes_canonicalized_endpoints(): |
There was a problem hiding this comment.
This and the Any alias test at line 371 pass on main after #215. Please remove them.
| ]); | ||
| }); | ||
|
|
||
| it("treats a declared Any alias as its entity type", () => { |
There was a problem hiding this comment.
Same: this and the dedupe test at line 491 pass on main.
933fec0 to
136fcfb
Compare
|
|
||
| @return (dict): the Ossie document and the logged warning lines joined by newlines. | ||
| """ | ||
| doc, warnings = captured_logs(lambda: Schema.model_validate(OSSIE_SPEC).to_ossie()) |
There was a problem hiding this comment.
Both sides leave the warning out on main, so this pair passes on main and nothing in the PR catches the bug. Please make OSSIE_SPEC include a OneToMany relation and assert the OneToMany warning, and keep one unit test per SDK for it (the ones in test_trust.py and trust.test.ts were removed).
| * @return ({ doc: unknown; warnings: string }): the Ossie document and the logged warning lines joined by newlines. | ||
| */ | ||
| export function ossieExport(): { doc: unknown; warnings: string } { | ||
| const { result, logs } = capturedLogs(() => toJsonable(toOssie(Schema.parse(OSSIE_SPEC)))); |
|
@s4chinjha for Arrry's last review (a OneToMany case in the conformance pair, plus one unit test per SDK), I put it on top of your branch as one commit: 0xNexuz@b1f7efd
All three fail with your |
Summary
to_ossie()andtoOssie()emitted relationship roles for custom target concepts that were not present in the ontology document. This draft registers undeclared custom targets while keeping the syntheticAnytarget as a role-only placeholder.Ossie 0.3.0.dev0 has no
OneToManymultiplicity value. The exporters now use the existing left-out warning path when that constraint cannot be represented instead of emitting an unsupported value.The change includes mirrored Python and TypeScript regression tests.
Linked issue
Closes #105
AI Assistance
Checklist
/approved.Breaking changes
None.
Validation
SELFGRAPH_TEST_STORE=kuzu python -m pytest tests/test_trust.py -q(27 passed)npm test -- --run test/trust.test.ts(24 passed)npm run typechecknpm run lintruff checkandruff format --checkon changed Python filesOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.