From cfb3dbe383c1a0b3f8a65b718d186aec628f2abc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 26 Jan 2026 20:50:29 +0000 Subject: [PATCH] feat: Add HeadyLens module and optimize drift check - Implemented HeadyLens core module and demo script in apps/heady_lens. - Optimized scripts/docs/check_drift.py to use startswith(tuple). - Validated AtomicWriter functionality. - Removed local artifacts. Co-authored-by: HeadyConnection <250789142+HeadyConnection@users.noreply.github.com> --- HeadySystems_v13/apps/heady_lens/README.md | 6 ++++ HeadySystems_v13/apps/heady_lens/__init__.py | 3 ++ HeadySystems_v13/apps/heady_lens/core.py | 37 ++++++++++++++++++++ HeadySystems_v13/apps/heady_lens/demo.py | 33 +++++++++++++++++ HeadySystems_v13/scripts/docs/check_drift.py | 2 +- 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 HeadySystems_v13/apps/heady_lens/README.md create mode 100644 HeadySystems_v13/apps/heady_lens/__init__.py create mode 100644 HeadySystems_v13/apps/heady_lens/core.py create mode 100644 HeadySystems_v13/apps/heady_lens/demo.py diff --git a/HeadySystems_v13/apps/heady_lens/README.md b/HeadySystems_v13/apps/heady_lens/README.md new file mode 100644 index 00000000..5cec5c18 --- /dev/null +++ b/HeadySystems_v13/apps/heady_lens/README.md @@ -0,0 +1,6 @@ +# HeadyLens + +Transparency module to capture and report system explanations. + +## Overview +HeadyLens is responsible for providing transparency into the system's operations, capturing explanations, and reporting them. diff --git a/HeadySystems_v13/apps/heady_lens/__init__.py b/HeadySystems_v13/apps/heady_lens/__init__.py new file mode 100644 index 00000000..b6b33bf2 --- /dev/null +++ b/HeadySystems_v13/apps/heady_lens/__init__.py @@ -0,0 +1,3 @@ +""" +HeadyLens Module +""" diff --git a/HeadySystems_v13/apps/heady_lens/core.py b/HeadySystems_v13/apps/heady_lens/core.py new file mode 100644 index 00000000..a8945d09 --- /dev/null +++ b/HeadySystems_v13/apps/heady_lens/core.py @@ -0,0 +1,37 @@ +""" +Core HeadyLens Logic +""" +import time +from typing import Dict, List, Any + +class HeadyLens: + """ + Captures and reports system explanations. + """ + def __init__(self): + self.explanations: List[Dict[str, Any]] = [] + + def capture(self, source: str, message: str, metadata: Dict[str, Any] = None): + """ + Captures an explanation event. + """ + event = { + "timestamp": time.time(), + "source": source, + "message": message, + "metadata": metadata or {} + } + self.explanations.append(event) + print(f"[HeadyLens] Captured: {message} from {source}") + + def report(self) -> List[Dict[str, Any]]: + """ + Returns all captured explanations. + """ + return self.explanations + + def clear(self): + """ + Clears the explanation log. + """ + self.explanations = [] diff --git a/HeadySystems_v13/apps/heady_lens/demo.py b/HeadySystems_v13/apps/heady_lens/demo.py new file mode 100644 index 00000000..23fc2230 --- /dev/null +++ b/HeadySystems_v13/apps/heady_lens/demo.py @@ -0,0 +1,33 @@ +""" +HeadyLens Demo +""" +import sys +import os + +# Ensure we can import from the module +# Appending HeadySystems_v13 root to sys.path +current_dir = os.path.dirname(os.path.abspath(__file__)) +repo_root = os.path.abspath(os.path.join(current_dir, "../../../")) +if repo_root not in sys.path: + sys.path.append(repo_root) + +try: + from HeadySystems_v13.apps.heady_lens.core import HeadyLens +except ImportError: + # Fallback if run from different context + from apps.heady_lens.core import HeadyLens + +def main(): + print("Initializing HeadyLens Demo...") + lens = HeadyLens() + + lens.capture("SystemBoot", "System initialized successfully.") + lens.capture("AuthModule", "User logged in.", {"user_id": 42}) + + report = lens.report() + print("\n--- HeadyLens Report ---") + for item in report: + print(f"[{item['timestamp']}] {item['source']}: {item['message']}") + +if __name__ == "__main__": + main() diff --git a/HeadySystems_v13/scripts/docs/check_drift.py b/HeadySystems_v13/scripts/docs/check_drift.py index aade3d2f..ad561e83 100644 --- a/HeadySystems_v13/scripts/docs/check_drift.py +++ b/HeadySystems_v13/scripts/docs/check_drift.py @@ -18,7 +18,7 @@ def main() -> int: return 1 changed = [line.strip() for line in diff.splitlines() if line.strip()] - watched_changes = [path for path in changed if any(path.startswith(prefix) for prefix in WATCH_PATHS)] + watched_changes = [path for path in changed if path.startswith(tuple(WATCH_PATHS))] if watched_changes and "docs/" not in " ".join(changed): print("Docs drift detected: operational changes without docs updates.") return 1