Repository navigation
Settle the relations a deleted relation retired instead of leaving them dangling - #58
Conversation
|
This is PR 1 of 3 you may keep open at a time. |
arrry-hydraDB
left a comment
There was a problem hiding this comment.
With max_count 2 and facts A, B, C, D, deleting C restores A instead of B. Please re-settle the whole endpoint, leave LLM-judged retirements retired, and lock both endpoints, as noted on #23. Reuse the existing settle logic instead of a second copy.
|
Thanks, all three are addressed in f2c677a.
One behaviour to check with you: if an endpoint holds more current relations than Both SDKs are updated, with tests for each case. The PR description now has the full table. |
arrry-hydraDB
left a comment
There was a problem hiding this comment.
Please inline the one-use _slots and _retired_by wrappers (_ops.py:1764, 2048), drop the docstring on the pass-through at access.ts:148, and add a conformance case for re-settling.
|
Done in 6b653b9.
|
| ) | ||
| for edge in stale: | ||
| rel = rels[edge["props"]["id"]] | ||
| tracker.admit(rel.id, rel.type, rel.from_entity, rel.to_entity, _rank(rel)) |
There was a problem hiding this comment.
With max_count on both ends, this can restore a fact that replaying the inserts without the deleted relation does not have, in 2 of 12 seeded cases, in both SDKs on every backend. Please settle both endpoints together as insert does. Main also changed _ended in Contradictions, so please rebase.
…em dangling Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nted, as insert does Co-Authored-By: Claude Opus 5.5 <[email protected]>
6b653b9 to
2410d96
Compare
|
Rebased on main and fixed in 2410d96.
|
Summary
Implements #23. Deleting a relation at a
max_countendpoint now settles that endpoint again, assupersedewould have settled it without the deleted relation. Before, whatever the deleted relation had retired stayed retired, with aninvalidated_bynaming a relation that no longer existed.Rule. For each constrained endpoint a deleted relation sat at:
supersederetired there is admitted back intoContradictions, with its stored rank. A retirement counts as a supersede one when itsinvalidated_byis a relation of that endpoint group.Contradictions.settlekeeps the newestmax_countcurrent.as_ofreads show it valid from its start.settlenames another relation or time, andinvalidated_known_atis kept, soknown_atreads from before the delete are unchanged.replace_sourceretirement: itsinvalidated_bynames no relation of the endpoint, so it is never admitted and stays as it is.max_count: 1: Acme, Globexmax_count: 1: Acme, Globex, Initechinvalidated_byInitech at Initech's timemax_count: 1: Acme, Globex, Initechmax_count: 2: A, B, C, Dmax_count: 2: A, B, CWhere it applies
relations.delete,entities.delete, andmaintenance.prune. All three go throughdelete_relation/delete_entities, which now take the schema's caps from the resource.maintenance.dedupe_relations: a relation a folded duplicate had retired is re-pointed to the survivor, which states the same fact.Implementation
Contradictions.admitandContradictions.settle, unchanged. The only refactors are lifting_cap_slotsout ofContradictions._slots, and_endpoint_edgesout of_contradiction_check(endpointEdgesout ofconstrainedCurrentin TypeScript), so delete and insert read endpoints the same way.max_count, or at an endpoint with no supersede history, writes nothing extra.DeleteResultgainsrestored_relations, whichprunealso reports underdeleted. It is mirrored in TypeScript, and the CLI and MCP output pick it up throughDeleteResult.Tests, mirrored in
tests/test_contradiction.py/tests/test_trust.pyandtypescript/test/temporal.test.ts/trust.test.ts:entities.deletepath, withas_ofreads after a restore and in a re-pointed gap;The new tests fail on
main. I also updated the existing tests that compare a whole delete result, since the dict now has the new key.Verified with
pyteston Kuzu and HydraDB,npm teston Kuzu (conformance included), and the temporal, maintenance, integration, and trust suites on HydraDB.ruff check,ruff format --check,npm run lint, andnpm run typecheckare clean. The only failures are two existing tests that also fail onmainon macOS:test_error_reasons_fill_empty_messages_and_strip_driver_boilerplatehard-codes Linux errno 111, and the CLI pipe test runshead -c 0, which macOSheadrejects.Docs:
resources.md(updating and deleting),schema.md(contradictions), andmaintenance.md(prune, dedupe).Linked issue
Closes #23
AI Assistance
Checklist
/approved.Breaking changes
None to the API. Behaviour changes in one case: deleting a relation at a
max_countendpoint now settles that endpoint again, which is the point of #23.DeleteResultgains arestored_relationsfield (0 when nothing comes back), so code that compares a whole delete result to a fixed dict sees one more key.