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
9 changes: 9 additions & 0 deletions DOMAIN_GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,12 @@ The phenomenon where a language model trained to map "symbol → definition" doe

## Asynchronous Paranoia Protocol
The concurrency model for VANCE dictating that all client states are shifting asynchronously. Every `textDocument/didChange` event triggers a delta-based recalculation. The system queues changes and version-checks reads to prevent reading from a stale state.

## Geometric Density Score (GDS)
A quantifiable metric assessing the informational density of a query domain. Domains with low density (GDS < 0.5) trigger traversal restrictions and require explicit human-in-the-loop (HITL) authorization to prevent hallucinated structural generation in sparse latent regions.

## Contrastive Delta
A metric output summarizing the tension maintained in paraconsistent bounds without resolving to Boolean logic, ensuring the structural isomorphism holds contradictions explicitly.

## Martensite Metrics
A suite of indicators representing the hardening of epistemic tension, such as the stability of the Confidence-Fidelity Divergence Index (CFDI) and the confirmation of intellectual montage (aesthetic tension).
51 changes: 51 additions & 0 deletions src/conceptual_synthesis/tactile_dialectician_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# </think>

import logging
import json
import os
from src.conceptual_synthesis.base_agent import BaseAgent

class TactileDialecticianAgent(BaseAgent):
Expand All @@ -24,6 +26,34 @@ def __init__(self):
self.agent_name = "TactileDialecticianAgent"
self.context_lock_anchor = "PARACONSISTENT_TENSION"

def compute_gds(self, query_domain: str) -> float:
"""
Computes the Geometric Density Score (GDS) for a query domain.
A low GDS (< 0.5) restricts traversal and demands HITL authorization.
"""
# Mock calculation: Use length / unique chars as a proxy for density
if not query_domain:
return 0.0
unique_chars = len(set(query_domain.replace(" ", "")))
length = len(query_domain)
# Bounded between 0 and 1
gds = min(1.0, (unique_chars / max(length, 1)) * 1.5)
return round(gds, 2)

def log_ontological_correction(self, impulse: str, context: dict):
"""
Logs ontological correction impulses to the Symbolic Scar Tissue Archive.
"""
archive_path = "SymbolicScar.jsonl"
log_entry = {
"type": "ontological_correction",
"impulse": impulse,
"context_lens": context.get("lens", "UNKNOWN")
}
with open(archive_path, "a") as f:
f.write(json.dumps(log_entry) + "\n")
Comment on lines +53 to +54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Opening a file for writing without specifying an encoding can lead to platform-dependent UnicodeEncodeError (e.g., on Windows systems where the default encoding is not UTF-8). Additionally, performing file I/O operations without error handling can crash the entire agent's execution loop if there are permission issues or if the disk is full. It is safer to specify encoding="utf-8" and wrap the file write in a try-except block to log any IOError gracefully.

Suggested change
with open(archive_path, "a") as f:
f.write(json.dumps(log_entry) + "\n")
try:
with open(archive_path, "a", encoding="utf-8") as f:
f.write(json.dumps(log_entry) + "\n")
except IOError as e:
logging.error(f"Failed to write to ontological correction archive: {e}")

logging.info(f"Logged ontological correction impulse: {impulse}")

def execute_hickam_ooda_loop(self, context: dict) -> dict:
"""
Executes the Hickam-OODA Loop, producing a Pluriversal Knowledge Capsule.
Expand All @@ -36,9 +66,17 @@ def execute_hickam_ooda_loop(self, context: dict) -> dict:
intent = context.get("intent", "")
drivers = context.get("drivers", [])
lens = context.get("lens", "Default WEIRD Lens")
query_domain = context.get("query_domain", intent)

logging.info("Executing Hickam-OODA Loop (INOCULATE Phase active).")

# Calculate GDS
gds = self.compute_gds(query_domain)
if gds < 0.5:
logging.warning(f"GDS {gds} < 0.5. Restricting traversal. HITL authorization required.")
self.log_ontological_correction("Sparse domain detected; resisting urge to auto-fill ontology.", context)


# 1. HICKAM ORIENTATION
# Reject Parsimony & establish Comorbidity Map
comorbidity_map = []
Expand Down Expand Up @@ -79,9 +117,22 @@ def execute_hickam_ooda_loop(self, context: dict) -> dict:
"symbolic_scar_integrity_maintained": True
}

contrastive_delta = {
"gds_score": gds,
"hitl_required": gds < 0.5,
"delta_tension": "Maintained paraconsistent bounds without boolean collapse."
}

martensite_metrics = {
"cfdi_stability": True, # Assume stable for now, could be dynamic
"aesthetic_tension": "Intellectual montage confirmed."
}

return {
"status": "COMPLETE",
"Hickam_Orientation": hickam_orientation,
"Contrastive_Delta": contrastive_delta,
"Martensite_Metrics": martensite_metrics,
"Pluriversal_Knowledge_Capsule": pluriversal_capsule,
"Verification_Checklist": checklist,
"raw_markers": ["[∇]", "[⊘]", "[Φ]"]
Expand Down
38 changes: 38 additions & 0 deletions tests/test_tactile_dialectician_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,43 @@ def test_hickam_ooda_loop_paraconsistent_tension(self):
self.assertTrue(checklist["epistemic_escrow_secured"])
self.assertTrue(checklist["symbolic_scar_integrity_maintained"])



def test_gds_computation_and_logging(self):
context = {
"intent": "Simple short text",
"query_domain": "A",
"drivers": ["speed"],
"lens": "Test Lens"
}

# Test low GDS (< 0.5)
context["query_domain"] = "AAAA"

result = self.agent.execute_hickam_ooda_loop(context)

self.assertEqual(result["status"], "COMPLETE")
self.assertIn("Contrastive_Delta", result)
self.assertIn("Martensite_Metrics", result)

contrastive_delta = result["Contrastive_Delta"]
self.assertTrue(contrastive_delta["hitl_required"])
self.assertLess(contrastive_delta["gds_score"], 0.5)

# Verify it logged to SymbolicScar.jsonl
import os
self.assertTrue(os.path.exists("SymbolicScar.jsonl"))
with open("SymbolicScar.jsonl", "r") as f:
lines = f.readlines()
last_line = lines[-1]
self.assertIn("ontological_correction", last_line)
self.assertIn("Test Lens", last_line)

# Cleanup
if os.path.exists("SymbolicScar.jsonl"):
os.remove("SymbolicScar.jsonl")
Comment on lines +74 to +85
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If any of the assertions fail during the test, the cleanup code at the end of the test method will not be executed, leaving the temporary SymbolicScar.jsonl file behind. This can pollute the workspace and cause side effects in subsequent test runs. Wrapping the assertions and file reading in a try...finally block ensures that the cleanup is always executed.

Suggested change
# Verify it logged to SymbolicScar.jsonl
import os
self.assertTrue(os.path.exists("SymbolicScar.jsonl"))
with open("SymbolicScar.jsonl", "r") as f:
lines = f.readlines()
last_line = lines[-1]
self.assertIn("ontological_correction", last_line)
self.assertIn("Test Lens", last_line)
# Cleanup
if os.path.exists("SymbolicScar.jsonl"):
os.remove("SymbolicScar.jsonl")
# Verify it logged to SymbolicScar.jsonl
import os
try:
self.assertTrue(os.path.exists("SymbolicScar.jsonl"))
with open("SymbolicScar.jsonl", "r", encoding="utf-8") as f:
lines = f.readlines()
last_line = lines[-1]
self.assertIn("ontological_correction", last_line)
self.assertIn("Test Lens", last_line)
finally:
if os.path.exists("SymbolicScar.jsonl"):
os.remove("SymbolicScar.jsonl")


if __name__ == '__main__':


unittest.main()
Loading