fix: widen KNOWN_RELS to cover all four sibling plugins' typed relations - #52
Merged
Merged
Conversation
KNOWN_RELS was an 11-entry allow-list; the sibling okf-agent-graph plugin declares 31 typed relations in AGER_SPEC.md and emits them from its own scaffold. On a real AGER bundle this produced 15 "non-standard rel" info lines, 13 of which were false positives that buried 2 genuine typos. Adds the missing 26 relations, a drift-guard test pinning AGER's vocabulary as a subset of KNOWN_RELS, and bumps 0.4.0 -> 0.4.1. Closes #51
) PR #51 added AGER's 26 relations but stopped there. The other three sibling capture plugins (project-knowledge-capture, system-architecture- capture, data-engineering-knowledge-capture) each declare their own typed-edge vocabulary too, and validate was flagging all of it as "non-standard rel" noise. Restructured KNOWN_RELS into CORE_RELS | AGER_RELS | PKC_RELS | SAC_RELS | DEKC_RELS (161 total, up from 37), each a named frozenset citing the plugin, version, and doc/schema path it came from. SAC's vocabulary came from schemas/types.json (what sac_validate.py itself loads at runtime) rather than its prose doc, which undercounts by the entire C4 vocabulary. DEKC's came from the union of its doc and its DEFAULT_RELATIONS constant, since the two disagree in both directions. Rewrote the drift-guard test to parse each installed sibling plugin's live vocabulary source at test time instead of comparing two hardcoded literals, with a subset-check fallback when the plugins aren't installed (CI). On field-ops-knowledge-base's two live bundles this takes "non-standard rel" info lines from 8 -> 0 (knowledge/) and 14 -> 0 (agent-graph/, already fixed by the AGER half of this work).
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.
What this is
scripts/okf-graph.py'sKNOWN_RELSallow-list controls which edge relation namesvalidatetreats as normal vs. flags with anon-standard rel (allowed but uncommon)info line. It started this PR at 11 entries; the first commit widened it to 37 by addingokf-agent-graph's (AGER — OKF Agent Graph Engineering Runtime, the plugin that models multi-agent loop config) vocabulary. That stopped short arbitrarily.This update widens it the rest of the way. OKF (Open Knowledge Format) has four sibling "capture" plugins that write typed edges into knowledge bundles, each declaring its own relation vocabulary on top of OKF's 11 core relations:
okf-agent-graph(AGER) — 26 relations beyond core (already covered by commit 1)project-knowledge-capture(PKC) — 15 relations beyond core (decisions, requirements, features, experiments)system-architecture-capture(SAC) — 84 relations beyond core (services, APIs, infra, C4 diagrams, data flow)data-engineering-knowledge-capture(DEKC) — 38 relations beyond core (tables, pipelines, lineage, BI)None of PKC/SAC/DEKC's relations were in
KNOWN_RELS, so any bundle built with those plugins had every one of its typed edges flagged as "non-standard" — noise that makes filteringvalidateoutput a habit, which is exactly how a real typo gets missed.The fix
KNOWN_RELSis nowCORE_RELS | AGER_RELS | PKC_RELS | SAC_RELS | DEKC_RELS— 161 relations total (up from 37), restructured into five named, source-citedfrozensets instead of one flat literal, so provenance stays readable and a future plugin release is a one-set diff:Each plugin's vocabulary was derived from its own newest-installed docs (
docs/typed-edges.md), then cross-checked against its own enforced code (each plugin'sDEFAULT_RELATIONSPython constant, the list its own capture/link tooling actually validates against) to catch doc drift rather than trust the prose blindly:docs/typed-edges.mdundercounts by 12 relations — it's missing the entire C4 model vocabulary (c4_contains,c4_delivers,c4_implements,c4_uses,c4_view_of,zooms_into, documented instead in a separatedocs/c4-integration.md) and 6 code-structure relations (defines,has_field,invokes,owns_capability,source_of,syncs_with). Usedschemas/types.json'srelations.sacbucket instead — the structured registrysac_validate.pyitself loads at runtime — which is a strict superset of both the doc and the code constant (84 relations).documented_by,has_wireframe,validated_by,wireframes) the code'sDEFAULT_RELATIONSdoesn't, and the code has 4 (aggregates,computes,documents_diagram,joins) the doc doesn't. Used the union of both (38 relations) rather than silently picking one, since wideningKNOWN_RELSis safe either way (see below).Why widening is safe
Confirmed both use sites of
KNOWN_RELSinscripts/okf-graph.py:extract_frontmatter_links(~line 484):rel = (item.get("rel") or item.get("type") or "related_to").strip()already guaranteesrelis non-empty before theKNOWN_RELScheck runs.if rel not in KNOWN_RELS: rel = rel or "related_to"is a no-op for any non-emptyrelregardless ofKNOWN_RELSmembership —rel or "related_to"evaluates torelitself whenrelis truthy. WideningKNOWN_RELScannot change the edge'srelvalue here, before or after this change.validate()(~line 1068):if e.source == "frontmatter" and e.rel not in KNOWN_RELS and e.rel != "links_to": issues.append(info "non-standard rel"...). This is the only placeKNOWN_RELSmembership changes behavior — widening it only removes info-severity messages for now-recognized relations. It does not affecterror/warnissues (thebroken linkerror check is keyed one.target, note.rel) and cannot change which edges get built.Drift-guard test rewrite
The old
test_known_rels_covers_ager_vocabularycompared a hardcoded literal toKNOWN_RELS— close to tautological. Addedtest_known_rels_covers_sibling_plugin_vocabularies, which:docs/typed-edges.md, each plugin'sDEFAULT_RELATIONSconstant, and SAC'sschemas/types.json) and asserts every relation they declare is inKNOWN_RELS— a genuine check that fires the moment a plugin adds a relation this file hasn't caught up with.KNOWN_RELS.Proved the guard actually catches drift: temporarily removed
c4_usesfromSAC_RELS, re-ran the suite — it failed with:— then restored it and confirmed the suite is green again.
Before / after (real bundles — field-ops-knowledge-base)
knowledge/originates_from)agent-graph/Version
Stays at
0.4.1(unreleased) — this PR hasn't merged yet, so the AGER commit's version bump covers this update too. Version-consistency test still passes.Verification
python3 tests/test_okf_graph.py— 31/31 green (was 30)bash tests/test_okf_curate.sh— greenpython3 scripts/okf-graph.py validate sample-okf --strict— 0 errors, 0 warningsCloses #51