Skip to content

Fix/nearest qualifier clean - #113

Merged
omakszewska merged 5 commits into
Solvro:mainfrom
omakszewska:fix/nearest-qualifier-clean
Sep 27, 2026
Merged

omakszewska merged 5 commits into
Solvro:mainfrom
omakszewska:fix/nearest-qualifier-clean

Conversation

@omakszewska

Copy link
Copy Markdown
Collaborator

Refs #104

Relationship types are now a closed set. Aliases map known variants to the canonical type, and anything unknown becomes RELATED_TO, logged as a warning.
Category → item edges get one direction and one type. The type comes from the qualifier on the page nearest above the item (pożądane → RECOMMENDS, wymagane/niezbędne → REQUIRES), so pages that list both kinds work too.
A Topic end takes the label from its pair, and an unattached item is linked to the nearest category above it.
A reproducibility test and a benchmark script compare graph shape across runs.

Pending (needs an API key): running the script on the R1–R4 page and checking the R2 questions on a rebuilt graph. Deploying requires one full re-ingest.

@Dominik-Galus Dominik-Galus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. A group heading above a category becomes one of its items, with the edge reversed (must fix). _resolve_topic_ends ignores edge direction. I gave it real page 4 text with the heading written as a Topic:
    MERGE (g:Topic {title: 'W grupie pracownikow badawczych'}) -> (g:Criterion …)
    MERGE (g)-[:HAS_CRITERION]->(cc) -> (g)<-[:HAS_CRITERION]-(cc)
    "Dorobek naukowy" now "has criterion" W grupie pracowników badawczych: the hierarchy is inverted. That group → category link is exactly what the fused "Działalność dydaktyczna" (11 = 6 + 8) needs to be preserved. Fix: infer a Topic's label only when the direction agrees:
  • Topic as the source of an edge to an item → it's a category.
  • Topic as the target of an edge from a category → it's an item.
  • Otherwise leave it alone.
  1. A qualifier word anywhere in prose flips criterion edges (must fix). The "nearest qualifier above" rule reads any wymagan*, niezbedn* or pozadan* token on the page. The OTM-R policy PDF has these words in prose on 7 pages ("wymagania", "niezbędne dokumenty"). A probe on p15 with a CriterionCategory → Criterion edge:
    MERGE (cc)-[:HAS_CRITERION]->(c) -> MERGE (cc)-[:REQUIRES]->(c)
    On top of that, page_relationship_type gives every item whose title isn't found on the page the page's single qualifier type. Fix: count only qualifiers on a heading line (short, ending in :), placed between the category's title and the item.

  2. Pair edges of an uncontrolled type get a second edge instead of a rewrite (should fix). Only HAS_CRITERION, REQUIRES, RECOMMENDS and RELATED_TO count as "linked". In PR run 1 on p1 the model wrote HAS_SUBCOMPETENCY ×25. Those items counted as unlinked, and the log shows Rewrote 25 … added MERGE (node5)-[:REQUIRES]->(node6)…. The graph ends up with both edges per item, and the run's signature differs from runs 2–3. Fix: decide "controlled" by the label pair, not by a list of types.

@omakszewska

Copy link
Copy Markdown
Collaborator Author
  1. Fixed: a Topic's label is now inferred only when the edge direction agrees (Topic → item makes it a category, category → Topic makes it an item); a Topic pointing at a category is left alone. Your p4 case is a regression test.
  2. Fixed differently: criterion edges are now always HAS_CRITERION, since retrieval only distinguishes RECOMMENDS/REQUIRES for competencies. Qualifiers are read only from heading lines (short, not a list row or a sentence, ending in ":" or naming kompetencje/kryteria), and the page-level fallback uses the same lines. I didn't restrict it to "between the category title and the item", because on the R1–R4 page "pożądane" sits in the page title, above the stage headings.
  3. Fixed: the label pair decides which edges are category → item, whatever their type, so HAS_SUBCOMPETENCY is rewritten in place instead of getting a second edge. Your run-1 shape is now a variant in the reproducibility test.

Could you re-run your three runs on p1 and p4?

@Dominik-Galus Dominik-Galus left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated deletions:

  • the module docstring of tests/data_pipeline/test_completeness.py (the #53 / #78 history), plus ~12 per-test docstrings
  • the module docstring of tests/test_llm_determinism_config.py (the #52 rationale)
  • Polish test strings translated to English ("Pierwszy punkt regulaminu" -> "First policy point")
  • is_code_token moved to text_normalization with its docstring cut to one line, losing the #106 reasoning

On that graph R2's items are Criterion under a CompetencyCategory. Neither configured pair (CompetencyCategory<->Competency, CriterionCategory<->Criterion) matches that, so the pass leaves it unchanged; a probe confirms it.

omakszewska added a commit to omakszewska/ml-mcp that referenced this pull request Sep 27, 2026
@omakszewska
omakszewska force-pushed the fix/nearest-qualifier-clean branch from c73144f to 9f46bf9 Compare September 27, 2026 20:49

@Dominik-Galus Dominik-Galus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ok

@omakszewska
omakszewska added this pull request to the merge queue Sep 27, 2026
Merged via the queue into Solvro:main with commit ec25ba5 Sep 27, 2026
5 checks passed
@omakszewska
omakszewska deleted the fix/nearest-qualifier-clean branch September 27, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants