11 Commits

  • fix: port continuous-learning observer fixes
    Ports continuous-learning observer signal, storage, remote normalization, and v1 deprecation fixes onto current main.
  • fix: add confirmation-prompt guard to start-observer.sh (issue #400)
    - Redirect observer output to temp log before appending to main log
    - Check temp log for confirmation/permission language immediately after start
    - Fail closed with exit 2 if detected, preventing retry loops
  • fix(continuous-learning-v2): observer background process crashes immediately (#312)
    * fix(continuous-learning-v2): observer background process crashes immediately
    
    Three bugs prevent the observer from running:
    
    1. Nested session detection: When launched from a Claude Code session,
       the child process inherits CLAUDECODE env var, causing `claude` CLI
       to refuse with "cannot be launched inside another session". Fix: unset
       CLAUDECODE in the background process.
    
    2. set -e kills the loop: The parent script's `set -e` is inherited by
       the subshell. When `claude` exits non-zero (e.g. max turns reached),
       the entire observer loop dies. Fix: `set +e` in the background process.
    
    3. Subshell dies when parent exits: `( ... ) & disown` loses IO handles
       when the parent shell exits, killing the background process. Fix: use
       `nohup /bin/bash -c '...'` for full detachment, and `sleep & wait`
       to allow SIGUSR1 to interrupt sleep without killing the process.
    
    Additionally, the prompt for Haiku now includes the exact instinct file
    format inline (YAML frontmatter with id/trigger/confidence/domain/source
    fields), since the previous prompt referenced "the observer agent spec"
    which Haiku could not actually read, resulting in instinct files that
    the CLI parser could not parse.
    
    * fix: address review feedback on observer process management
    
    - Use `env` to pass variables to child process instead of quote-splicing,
      avoiding shell injection risk from special chars in paths
    - Add USR1_FIRED flag to prevent double analysis when SIGUSR1 interrupts
      the sleep/wait cycle
    - Track SLEEP_PID and kill it in both TERM trap and USR1 handler to
      prevent orphaned sleep processes from accumulating
    - Consolidate cleanup logic into a dedicated cleanup() function
    
    * fix: guard PID file cleanup against race condition on restart
    
    Only remove PID file in cleanup trap if it still belongs to the
    current process, preventing a restarted observer from losing its
    PID file when the old process exits.
  • feat: project-scoped instinct isolation
    * feat: add project-scoped instinct isolation
    
    * fix(continuous-learning-v2): harden instinct loading and promotion safety; sync v2.1 command docs
    
    * fix(ci): make copilot-setup-steps a valid GitHub Actions workflow
    
    * fix(hooks): stabilize docs warning inline JS regex parsing
  • fix: harden CI validators, shell scripts, and expand test suite
    - Add try-catch around readFileSync in validate-agents, validate-commands,
      validate-skills to handle TOCTOU races and file read errors
    - Add validate-hooks.js and all test suites to package.json test script
      (was only running 4/5 validators and 0/4 test files)
    - Fix shell variable injection in observe.sh: use os.environ instead of
      interpolating $timestamp/$OBSERVATIONS_FILE into Python string literals
    - Fix $? always being 0 in start-observer.sh: capture exit code before
      conditional since `if !` inverts the status
    - Add OLD_VERSION validation in release.sh and use pipe delimiter in sed
      to avoid issues with slash-containing values
    - Add jq dependency check in evaluate-session.sh before parsing config
    - Sync .cursor/ copies of all modified shell scripts
  • fix: harden error handling, fix TOCTOU races, and improve test accuracy
    Core library fixes:
    - session-manager.js: wrap all statSync calls in try-catch to prevent
      TOCTOU crashes when files are deleted between readdir and stat
    - session-manager.js: use birthtime||ctime fallback for Linux compat
    - session-manager.js: remove redundant existsSync before readFile
    - utils.js: fix findFiles TOCTOU race on statSync inside readdir loop
    
    Hook improvements:
    - Add 1MB stdin buffer limits to all PostToolUse hooks to prevent
      unbounded memory growth from large payloads
    - suggest-compact.js: use fd-based atomic read+write for counter file
      to reduce race window between concurrent invocations
    - session-end.js: log when transcript file is missing, check
      replaceInFile return value for failed timestamp updates
    - start-observer.sh: log claude CLI failures instead of silently
      swallowing them, check observations file exists before analysis
    
    Test fixes:
    - Fix blocking hook tests to send matching input (dev server command)
      and expect correct exit code 2 instead of 1
  • feat: v1.1.0 release - session ID tracking, async hooks, new skills
    - Add session ID to session filenames (Issue #62)
    - Add getSessionIdShort() helper for unique per-session tracking
    - Add async hooks documentation with example
    - Create iterative-retrieval skill for progressive context refinement
    - Add continuous-learning-v2 skill with instinct-based learning
    - Add ecc.tools ecosystem section to README
    - Update skills list in README
    
    All 67 tests passing.