Federation Prompts¶
Ten prompts for registering namespaces, resolving entities across projects, tracking changes, and operating the FCC federation module. Each prompt includes a code snippet and a description of the expected output.
Table of Contents¶
- Register a Namespace
- List All Registered Namespaces
- Resolve an Entity Across Projects
- Track Changes to a Federated Entity
- Build a Federation Registry
- Cross-Project Entity Discovery
- Namespace Conflict Detection
- Federated Knowledge Graph Query
- Entity Provenance Chain
- Cross-Project Assessment
1. Register a Namespace¶
Register a new project namespace in the federation registry.
from fcc.federation.namespace import NamespaceRegistry
registry = NamespaceRegistry()
registry.register(
namespace="my_project",
display_name="My Research Project",
base_uri="https://example.org/my-project/",
description="A research project using FCC for data analysis workflows",
owner="research-team"
)
print(f"Registered namespaces: {registry.list()}")
Expected output: The namespace registry now contains the new project alongside the 11 pre-defined ecosystem namespaces. The list() method returns all registered namespace identifiers.
2. List All Registered Namespaces¶
Enumerate the 11 pre-defined ecosystem namespaces and any custom additions.
from fcc.federation.namespace import NamespaceRegistry
registry = NamespaceRegistry()
for ns in registry.list():
info = registry.get(ns)
print(f"{ns:20s} | {info.display_name:30s} | {info.base_uri}")
Expected output: A table of all ecosystem namespaces including fcc, paom, aome, and others, each with its display name and base URI. These represent the projects that can federate with FCC.
3. Resolve an Entity Across Projects¶
Find equivalent entities in a target namespace for a given source entity.
from fcc.federation.resolver import EntityResolver
from fcc.federation.namespace import NamespaceRegistry
registry = NamespaceRegistry()
resolver = EntityResolver(namespace_registry=registry)
matches = resolver.resolve(
entity_id="RC",
source_namespace="fcc",
target_namespace="paom"
)
for match in matches:
print(f"FCC:RC -> PAOM:{match.entity_id} (confidence: {match.confidence:.2f}, method: {match.method})")
Expected output: A list of entities in the PAOM namespace that correspond to the FCC Research Crafter, with confidence scores and the resolution method used (name matching, embedding similarity, or explicit mapping).
4. Track Changes to a Federated Entity¶
Record and query changes to entities across federation boundaries.
from fcc.federation.tracker import ChangeTracker
tracker = ChangeTracker()
tracker.record(
entity_id="RC",
namespace="fcc",
change_type="updated",
description="Added new responsibility: knowledge graph construction",
version="0.8.0"
)
history = tracker.get_history(entity_id="RC", namespace="fcc")
for entry in history:
print(f"[{entry.timestamp}] {entry.change_type}: {entry.description}")
Expected output: A chronological list of changes made to the RC persona in the FCC namespace. Each entry includes a timestamp, change type (created, updated, deprecated, deleted), description, and version.
5. Build a Federation Registry¶
Create a full federation registry connecting multiple projects.
from fcc.federation.registry import FederationRegistry
from fcc.federation.namespace import NamespaceRegistry
from fcc.federation.resolver import EntityResolver
from fcc.federation.tracker import ChangeTracker
ns_registry = NamespaceRegistry()
resolver = EntityResolver(namespace_registry=ns_registry)
tracker = ChangeTracker()
federation = FederationRegistry(
namespace_registry=ns_registry,
resolver=resolver,
tracker=tracker
)
print(f"Federation ready with {len(ns_registry.list())} namespaces")
Expected output: A fully assembled FederationRegistry that combines namespace management, entity resolution, and change tracking into a single coordinated system.
6. Cross-Project Entity Discovery¶
Discover all entities across all namespaces that match a search query.
from fcc.federation.registry import FederationRegistry
results = federation.discover(
query="data governance",
namespaces=["fcc", "paom", "aome"]
)
for result in results:
print(f"{result.namespace}:{result.entity_id} | {result.name} | Score: {result.score:.3f}")
Expected output: Entities from multiple namespaces that relate to data governance, ranked by relevance. This enables cross-project discovery without knowing which namespace contains the relevant entities.
7. Namespace Conflict Detection¶
Identify conflicting entity definitions across namespaces.
from fcc.federation.resolver import EntityResolver
conflicts = resolver.detect_conflicts(
entity_id="DGS",
namespaces=["fcc", "paom", "aome"]
)
for conflict in conflicts:
print(f"Conflict: {conflict.field} differs between {conflict.ns_a} and {conflict.ns_b}")
print(f" {conflict.ns_a}: {conflict.value_a}")
print(f" {conflict.ns_b}: {conflict.value_b}")
Expected output: A list of fields where the DGS entity definition differs across namespaces (e.g., different role descriptions, different constraint lists). This helps identify integration issues before federating.
8. Federated Knowledge Graph Query¶
Query across federated knowledge graphs with cross-namespace edge traversal.
from fcc.knowledge.federation import FederatedKnowledgeGraph
federated_kg = FederatedKnowledgeGraph(namespace_registry=ns_registry)
federated_kg.register_graph("fcc", fcc_graph)
federated_kg.register_graph("paom", paom_graph)
# Find all cross-namespace relationships
cross_edges = federated_kg.get_cross_namespace_edges()
for edge in cross_edges:
print(f"{edge.source_ns}:{edge.source_id} --[{edge.edge_type}]--> {edge.target_ns}:{edge.target_id}")
Expected output: Edges that connect nodes in different namespaces, showing how entities in one project relate to entities in another. These cross-namespace relationships are the backbone of federated knowledge.
9. Entity Provenance Chain¶
Trace the full provenance of a federated entity back to its origin.
from fcc.federation.tracker import ChangeTracker
tracker = ChangeTracker()
provenance = tracker.get_provenance_chain(
entity_id="DGS",
namespace="fcc"
)
print(f"Provenance chain for FCC:DGS ({len(provenance)} entries):")
for entry in provenance:
print(f" [{entry.version}] {entry.change_type}: {entry.description}")
if entry.derived_from:
print(f" Derived from: {entry.derived_from.namespace}:{entry.derived_from.entity_id}")
Expected output: A chain of provenance entries showing how the DGS persona evolved over time, including any derivation relationships to entities in other namespaces. This provides full audit trail for federated entities.
10. Cross-Project Assessment¶
Assess alignment and maturity across multiple federated projects.
from fcc.objectmodel.federation import assess_cross_project
assessment = assess_cross_project(
projects=["fcc", "paom", "aome"],
namespace_registry=ns_registry,
resolver=resolver
)
print(f"Overall alignment score: {assessment.alignment_score:.2f}")
print(f"Coverage gaps: {len(assessment.gaps)}")
for gap in assessment.gaps:
print(f" {gap.namespace}: missing {gap.entity_type} coverage for {gap.capability}")
Expected output: A CrossProjectAssessment with an alignment score (0.0 to 1.0) measuring how well the projects' entity models correspond, plus a list of coverage gaps where one project defines capabilities that others lack.