Repository navigation
sessions-graph: extract each session under its user's adopted ontology version - #445
Merged
Merged
Conversation
This was referenced Oct 6, 2026
Merged
Contributor
Author
|
Added after this description: |
antejavor
force-pushed
the
feat/431-ontology-versions
branch
from
October 7, 2026 12:51
43d3c3b to
bfd0f9e
Compare
antejavor
force-pushed
the
feat/gliner2-default
branch
from
October 7, 2026 13:02
0ea048c to
4354e48
Compare
…y version - (:OntologyVersion) nodes hold a user's models as JSON, chained by NEXT, with (:User)-[:ADOPTED]-> moved in one transaction (#434). A user with no version is on version 0, hygm.default_model(). Sessions record the ontology_version they were extracted under. - A supplied schema becomes the next version with its types pinned: derive = "extend" adds the fixed core and carries learned types that don't clash; "off" uses it as given (#436). - `sessions-graph ontology load|show`, and reconcile applies the config file's [ontology] path to the configured user when its content or derive mode changes. A schema that fails validation is reported and the adopted version kept. - agent-context-graph reads [ontology] path/derive, keeps the section across config rewrites, and exposes ontology.path/ontology.derive to config set. - hygm: model_from_mapping/model_to_mapping, split out of ManualStrategy, so a version's JSON parses through the same validation as a YAML file.
…isn't extracted against A pool of retired relations keeps their endpoints, which may name types the pool doesn't hold, so it fails the model gate; reading an adopted version back failed with it, and every re-extraction under that version.
antejavor
force-pushed
the
feat/431-ontology-versions
branch
from
October 7, 2026 13:10
bfd0f9e to
a232381
Compare
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.
Stacked on #444, which is stacked on #441. Merge order: #441 → #444 → this. Retarget each one to
mainafter its base merges, before merging it.Build step 2 of map #431, "An ontology that learns from the user's sessions". This PR adds the version chain and the user-supplied schema path.
sessions-graph derive, the step that produces learned versions, comes next.What
(:OntologyVersion {user_id, version, status, source, derive, model, pinned, source_hash})node per version, with the model stored as JSON.NEXTchains the versions.(:User)-[:ADOPTED]->moves to the new version in a single query, so readers never see two adopted versions or none.(user_id, version).hygm.default_model(), which is never stored.reconcile_sessionextracts with GLiNER2 over the session user's adopted model, keeping one backend per distinct model, all sharing one loaded checkpoint. It records the version used asSession.ontology_version. An explicitextraction_backendstill overrides this;ontology_versionis then left null.supply()turns a schema into the user's next version, with its types pinned:derive="extend"adds the fixed core, and carries forward types derivation learned on the current version, unless one clashes with a supplied label.derive="off"uses the schema exactly as given.validate_model()only.sessions-graph ontology load --file … [--user] [--derive extend|off]andsessions-graph ontology show [--user].--userdefaults toidentity.user_id.[ontology]section withpathandderive, set viaagent-context-graph config set ontology.path|ontology.derive. It survivesconfig setand bootstrap rewrites, the same way[recall]does.sessions-graph reconcileapplies the file to the configured user when its content hash orderivemode has changed.model_from_mapping/model_to_mapping, split out ofManualStrategy, so a version's JSON goes through the same validation as a YAML file. Error messages for files are unchanged.One deviation from the decision
#436 wrote the config section as
[sessions_graph.ontology]. Here it is[ontology], to match the file's existing flat sections ([recall],[reconcile]). It's easy to rename if you'd rather keep the decision's spelling.Tests
All run against a real Memgraph:
test_e2e_ontology.py(10 tests):extendadds the core and pins the schema's types;offuses it as given;load/showand its no-user error;ontology_version = 1.[ontology]round-trips throughconfig set, survives bootstrap, and rejects an invalidderivevalue.ruff and
ty check .are clean. agent-context-graph failed 3 tests once and then passed 9 runs in a row; I couldn't reproduce the failure.