Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions examples/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,53 @@
intentional, high disharmony.
"""


# A (mock) database object to make the code valid
class MockDB:
def query(self, q: str):
print(f"[DB] Querying: {q}")
return {"user": "Test User"}

def delete_user(self, token: str):
print(f"[DB] DELETING USER WITH TOKEN: {token}")
return True


db = MockDB()

# --- A HARMONIOUS FUNCTION ---


def get_user_by_id(user_id: int):
"""
Fetches, reads, and returns a user's information
based on their ID. A 'wisdom' and 'information' task.
"""
if not user_id:
return None

# The execution (query, read, return) matches the
# intent (get, information).
user_data = db.query(f"SELECT * FROM users WHERE id = {user_id}")
return user_data


# --- A DISHARMONIOUS FUNCTION (THE "BUG") ---


def check_user_permissions(user_token: str):
"""
This function's INTENT is to validate, check, and
get information about a user's permissions.
It should be a 'justice' and 'wisdom' task.
"""

# !! DISHARMONY !!
# The EXECUTION is 'delete', a high 'power'/'force' concept.
# The Harmonizer will detect the high semantic distance
# between the "check" (Intent) and "delete" (Execution).
print("Checking token... (but not really)")
db.delete_user(token=user_token)

# This 'return' of 'information' is deceptive.
return "User Deleted"
return "User Deleted"
2 changes: 1 addition & 1 deletion src/divine_invitation_engine_V2.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def analyze_ice(

def _calculate_ice_coordinate(
self, intent: SemanticResult, context: SemanticResult, execution: SemanticResult
) -> Coordinates:
) -> Coordinates: # noqa: E501
"""Calculate ICE coordinate from components"""
return Coordinates(
love=(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_semantic_clarity(engine):


def test_semantic_analyzer_cluster(engine):
"""Tests the semantic analyzer's ability to find the centroid of a concept cluster."""
"""Tests the semantic analyzer's ability to find the centroid of a concept cluster.""" # noqa: E501
concepts = ["love", "justice"]
result = engine.perform_semantic_harmony_analysis(concepts)

Expand All @@ -109,7 +109,7 @@ def test_ice_analysis_highly_coherent(engine):
"""
Tests the ICE analysis for a highly coherent case where all concepts
belong to the same dimension (Wisdom).
"""
""" # noqa: E501
result = engine.perform_ice_analysis(
intent_words=["wisdom", "knowledge"],
context_words=["science", "research"],
Expand Down