From 1191ea2f9a6fb259ba3b87928f73ec90ad008149 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone <8633216+AlexanderWhitestone@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:19:46 -0400 Subject: [PATCH] Claude/fix tick engine v16wt (#165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: wire up tick engine scheduler + add journal + systemd timer The ThinkingEngine was fully implemented but never called — the background scheduler was lost during the Celery removal in #133. This commit: - Add _thinking_scheduler() to dashboard lifespan (5-min cycle) - Add _write_journal() that appends thoughts to data/journal/YYYY-MM-DD.md - Add `timmy tick` CLI command for one-shot thinking (systemd-friendly) - Add deploy/timmy-tick.{service,timer} systemd units https://claude.ai/code/session_013e7upfJ6negFzu5YNJikge * Add macOS launchd plist for Timmy tick timer Equivalent of the existing systemd service/timer for Linux. Runs `timmy tick` every 5 minutes via launchd on macOS. https://claude.ai/code/session_013e7upfJ6negFzu5YNJikge * fix: make macOS launchd timer work with user-local paths The plist had hardcoded /opt/timmy paths that don't exist on Mac. Now uses a template with __PROJECT_DIR__ placeholders, a wrapper script for PATH setup, and an install script that wires it all up. Usage: ./deploy/install-mac-timer.sh https://claude.ai/code/session_013e7upfJ6negFzu5YNJikge * fix: add missing tox pre-commit env + pre-push hook to prevent broken builds RCA: the pre-commit hook referenced `tox -e pre-commit` which didn't exist in tox.ini, so commits went unchecked. There was also no pre-push hook, so broken code could reach GitHub without running the CI-mirror suite. - Add [testenv:pre-commit] to tox.ini (format check + unit tests) - Add .githooks/pre-push that runs `tox -e pre-push` (full CI mirror) https://claude.ai/code/session_013e7upfJ6negFzu5YNJikge --------- Co-authored-by: Claude --- .githooks/pre-push | 18 ++++++++++++++++++ deploy/com.timmy.tick.plist | 26 ++++++++++++++++++++++++++ deploy/install-mac-timer.sh | 32 ++++++++++++++++++++++++++++++++ deploy/timmy-tick-mac.sh | 6 ++++++ tox.ini | 16 ++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100755 .githooks/pre-push create mode 100644 deploy/com.timmy.tick.plist create mode 100755 deploy/install-mac-timer.sh create mode 100755 deploy/timmy-tick-mac.sh diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 00000000..416e1439 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Pre-push hook: runs the full CI-mirror suite before allowing a push. +# Prevents broken builds from reaching GitHub. +# +# Auto-activated by `make install` via git core.hooksPath. + +set -e + +echo "Running pre-push gate (tox -e pre-push — mirrors CI exactly)..." +tox -e pre-push + +exit_code=$? + +if [ "$exit_code" -ne 0 ]; then + echo "" + echo "BLOCKED: pre-push gate failed. Fix the issues above before pushing." + exit 1 +fi diff --git a/deploy/com.timmy.tick.plist b/deploy/com.timmy.tick.plist new file mode 100644 index 00000000..f49a4836 --- /dev/null +++ b/deploy/com.timmy.tick.plist @@ -0,0 +1,26 @@ + + + + + Label + com.timmy.tick + + ProgramArguments + + __PROJECT_DIR__/deploy/timmy-tick-mac.sh + + + WorkingDirectory + __PROJECT_DIR__ + + StartInterval + 300 + + StandardOutPath + __PROJECT_DIR__/data/tick.log + + StandardErrorPath + __PROJECT_DIR__/data/tick-error.log + + diff --git a/deploy/install-mac-timer.sh b/deploy/install-mac-timer.sh new file mode 100755 index 00000000..4cda3199 --- /dev/null +++ b/deploy/install-mac-timer.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Install the Timmy tick timer on macOS via launchd. +# Usage: ./deploy/install-mac-timer.sh +set -e + +PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +PLIST_SRC="$PROJECT_DIR/deploy/com.timmy.tick.plist" +PLIST_DST="$HOME/Library/LaunchAgents/com.timmy.tick.plist" +LABEL="com.timmy.tick" + +# Ensure data dir exists for logs +mkdir -p "$PROJECT_DIR/data" + +# Make wrapper executable +chmod +x "$PROJECT_DIR/deploy/timmy-tick-mac.sh" + +# Unload if already installed +if launchctl list "$LABEL" >/dev/null 2>&1; then + echo "Unloading existing $LABEL..." + launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true +fi + +# Fill in project path and install +sed "s|__PROJECT_DIR__|$PROJECT_DIR|g" "$PLIST_SRC" > "$PLIST_DST" + +# Load +launchctl bootstrap "gui/$(id -u)" "$PLIST_DST" + +echo "Installed! Timmy will tick every 5 minutes." +echo " Logs: $PROJECT_DIR/data/tick.log" +echo " Check: launchctl list | grep timmy" +echo " Stop: launchctl bootout gui/\$(id -u)/com.timmy.tick" diff --git a/deploy/timmy-tick-mac.sh b/deploy/timmy-tick-mac.sh new file mode 100755 index 00000000..544bb089 --- /dev/null +++ b/deploy/timmy-tick-mac.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Wrapper script for the launchd tick timer on macOS. +# Ensures PATH is set so tox/python can be found. +export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH" +cd "$(dirname "$0")/.." || exit 1 +exec tox -e dev -- timmy tick diff --git a/tox.ini b/tox.ini index acc4beba..4fffd6c9 100644 --- a/tox.ini +++ b/tox.ini @@ -145,6 +145,22 @@ commands = -p no:xdist \ -m "not ollama and not docker and not selenium and not external_api" +# ── Pre-commit (fast local gate) ──────────────────────────────────────────── + +[testenv:pre-commit] +description = Fast pre-commit gate — format check + unit tests (30s budget) +deps = + black + isort +commands = + black --check --line-length 100 src/ tests/ + isort --check-only --profile black --line-length 100 src/ tests/ + pytest tests/ -q --tb=short \ + --ignore=tests/e2e \ + --ignore=tests/functional \ + -m "not ollama and not docker and not selenium and not external_api and not skip_ci" \ + -n auto --dist worksteal + # ── Dev Server ─────────────────────────────────────────────────────────────── [testenv:dev]