Skip to content

Accept KR predicate_id compatibility alias - #297

Merged
witbrock merged 1 commit into
mainfrom
jvnautosci-2592-kr-predicate-alias
Jul 23, 2026
Merged

witbrock merged 1 commit into
mainfrom
jvnautosci-2592-kr-predicate-alias

Conversation

@witbrock

Copy link
Copy Markdown
Member

Outcome

Accept the model-facing predicate_id compatibility alias at the generic KR materialisation guard boundary and canonicalise it to predicate before downstream relationship resolution/assertion.

Safety boundary

  • Reject conflicting predicate and predicate_id values.
  • Perform mutation only after the whole relationship batch validates, avoiding partial canonicalisation on rejection.
  • Apply the same contract to plan and resolved-relationship phases.
  • No PhD- or spreadsheet-specific semantic policy is added to Python.

Validation

  • 39 focused KR materialisation/workflow/control-flow tests pass.
  • Ruff passes on changed files.
  • git diff --check passes.
  • Independent review found no concrete blocker and spot-checked immutable and atomic-rejection behaviour.

Jira: JVNAUTOSCI-2592

Copilot AI review requested due to automatic review settings July 23, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the generic KR materialisation guard to accept a compatibility alias (predicate_id) in relationship specs, canonicalising it to predicate at the guard boundary (with conflict detection) so downstream relationship resolution/assertion sees a consistent shape.

Changes:

  • Add predicate alias canonicalisation logic (predicate_id → predicate) for both plan and resolved-relationship phases, rejecting conflicting values.
  • Update guard validation to apply canonicalisation only after full-batch validation (avoiding partial mutations on rejection).
  • Add focused tests covering alias normalisation and conflict rejection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/backend/test_kr_materialisation_guard_service.py Adds tests for accepting predicate_id alias, canonicalising it to predicate, and rejecting conflicts.
src/backend/services/kr_materialisation_guard_service.py Implements predicate_id compatibility alias handling and canonicalisation for relationship-spec validation in both phases.

Comment on lines +163 to +185

plan = validate_kr_materialisation_guard(
guard_contract=_guard(),
phase="plan",
concept_specs=_concept_specs(),
relationship_specs=relationship_specs,
)
resolved = validate_kr_materialisation_guard(
guard_contract=_guard(),
phase="resolved_relationships",
concept_specs=_concept_specs(),
relationship_specs=relationship_specs,
concept_iteration_results=_concept_results(),
resolved_relationship_specs=resolved_relationship_specs,
)

assert plan["guard_passed"] is True
assert resolved["guard_passed"] is True
assert relationship_specs[0]["predicate"] == "#V#has_doctoral_programme"
assert (
resolved_relationship_specs[0]["predicate"]
== "#V#has_doctoral_programme"
)
@witbrock
witbrock merged commit b81cc9e into main Jul 23, 2026
5 checks passed
@witbrock
witbrock deleted the jvnautosci-2592-kr-predicate-alias branch July 28, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants