ECC/skills
ispaydeu c52a28ace9
fix(observe): 5-layer automated session guard to prevent self-loop observations (#399)
* fix(observe): add 5-layer automated session guard to prevent self-loop observations

observe.sh currently fires for ALL hook events including automated/programmatic
sessions: the ECC observer's own Haiku analysis runs, claude-mem observer
sessions, CI pipelines, and any other tool that spawns `claude --print`.

This causes an infinite feedback loop where automated sessions generate
observations that trigger more automated analysis, burning Haiku tokens with
no human activity.

Add a 5-layer guard block after the `disabled` check:

Layer 1: agent_id payload field — only present in subagent hooks; skip any
         subagent-scoped session (always automated by definition).

Layer 2: CLAUDE_CODE_ENTRYPOINT env var — Claude Code sets this to sdk-ts,
         sdk-py, sdk-cli, mcp, or remote for programmatic/SDK invocations.
         Skip if any non-cli entrypoint is detected. This is universal: catches
         any tool using the Anthropic SDK without requiring tool cooperation.

Layer 3: ECC_HOOK_PROFILE=minimal — existing ECC mechanism; respect it here
         to suppress non-essential hooks in observer contexts.

Layer 4: ECC_SKIP_OBSERVE=1 — cooperative env var any external tool can set
         before spawning automated sessions (explicit opt-out contract).

Layer 5: CWD path exclusions — skip sessions whose working directory matches
         known observer-session path patterns. Configurable via
         ECC_OBSERVE_SKIP_PATHS (comma-separated substrings, default:
         "observer-sessions,.claude-mem").

Also fix observer-loop.sh to set ECC_SKIP_OBSERVE=1 and ECC_HOOK_PROFILE=minimal
before spawning the Haiku analysis subprocess, making the observer loop
self-aware and closing the ECC→ECC self-observation loop without needing
external coordination.

Fixes: observe.sh fires unconditionally on automated sessions (#398)

* fix(observe): address review feedback — reorder guards cheapest-first, fix empty pattern bug

Two issues flagged by Copilot and CodeRabbit in PR #399:

1. Layer ordering: the agent_id check spawns a Python subprocess but ran
   before the cheap env-var checks (CLAUDE_CODE_ENTRYPOINT, ECC_HOOK_PROFILE,
   ECC_SKIP_OBSERVE). Reorder to put all env-var checks first (Layers 1-3),
   then the subprocess-requiring agent_id check (Layer 4). Automated sessions
   that set env vars — the common case — now exit without spawning Python.

2. Empty pattern bug in Layer 5: if ECC_OBSERVE_SKIP_PATHS contains a trailing
   comma or spaces after commas (e.g. "path1, path2" or "path1,"), _pattern
   becomes empty or whitespace-only, and the glob *""* matches every CWD,
   silently disabling all observations. Fix: trim leading/trailing whitespace
   from each pattern and skip empty patterns with `continue`.

* fix: fail closed for non-cli entrypoints

---------

Co-authored-by: Affaan Mustafa <affaan@dcube.ai>
2026-03-12 23:40:03 -07:00
..
agent-harness-construction feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
agentic-engineering feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
ai-first-engineering feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
android-clean-architecture fix: address PR review comments for Kotlin/Android/KMP docs 2026-03-10 20:53:39 -07:00
api-design fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
article-writing feat: add generic content and investor skills 2026-02-27 05:50:23 -08:00
autonomous-loops feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
backend-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
blueprint docs: tighten blueprint install guidance 2026-03-10 19:23:00 -07:00
carrier-relationship-management docs: resolve remaining operational skill comments 2026-03-10 21:13:55 -07:00
claude-api feat: add orchestration workflows and harness skills 2026-03-12 14:49:05 -07:00
clickhouse-io fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
coding-standards fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
compose-multiplatform-patterns docs: tighten kotlin support examples 2026-03-10 20:53:39 -07:00
configure-ecc fix: address remaining orchestration review comments 2026-03-12 15:34:05 -07:00
content-engine feat: add generic content and investor skills 2026-02-27 05:50:23 -08:00
content-hash-cache-pattern fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
continuous-agent-loop feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
continuous-learning feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
continuous-learning-v2 fix(observe): 5-layer automated session guard to prevent self-loop observations (#399) 2026-03-12 23:40:03 -07:00
cost-aware-llm-pipeline fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
cpp-coding-standards fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
cpp-testing chore: replace external repo links with @username attribution 2026-03-03 12:32:35 -08:00
crosspost fix: address remaining orchestration review comments 2026-03-12 15:34:05 -07:00
customs-trade-compliance docs: resolve operational skill review issues 2026-03-10 21:07:36 -07:00
database-migrations fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
deep-research feat: add orchestration workflows and harness skills 2026-03-12 14:49:05 -07:00
deployment-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
django-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
django-security fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
django-tdd fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
django-verification fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
dmux-workflows fix: address remaining orchestration review comments 2026-03-12 15:34:05 -07:00
docker-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
e2e-testing fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
energy-procurement docs: resolve operational skill review issues 2026-03-10 21:07:36 -07:00
enterprise-agent-ops feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
eval-harness feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
exa-search fix: address remaining orchestration review comments 2026-03-12 15:34:05 -07:00
fal-ai-media fix: harden orchestration status and skill docs 2026-03-12 15:07:57 -07:00
foundation-models-on-device fix(skills): improve code examples in iOS 26 skills 2026-02-24 14:39:25 +09:00
frontend-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
frontend-slides chore: replace external repo links with @username attribution 2026-03-03 12:32:35 -08:00
golang-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
golang-testing fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
inventory-demand-planning docs: resolve remaining operational skill comments 2026-03-10 21:13:55 -07:00
investor-materials feat: add generic content and investor skills 2026-02-27 05:50:23 -08:00
investor-outreach feat: add generic content and investor skills 2026-02-27 05:50:23 -08:00
iterative-retrieval fix: harden hook portability and plugin docs 2026-03-09 22:49:43 -07:00
java-coding-standards fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
jpa-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
kotlin-coroutines-flows docs: tighten kotlin support examples 2026-03-10 20:53:39 -07:00
liquid-glass-design fix(skills): improve code examples in iOS 26 skills 2026-02-24 14:39:25 +09:00
logistics-exception-management docs: resolve operational skill review issues 2026-03-10 21:07:36 -07:00
market-research feat: add generic content and investor skills 2026-02-27 05:50:23 -08:00
nanoclaw-repl feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
nutrient-document-processing feat: add security guides and sanitize external links across repo 2026-02-25 07:20:42 -08:00
perl-patterns docs: tighten perl support guidance 2026-03-10 20:42:54 -07:00
perl-security docs: tighten perl support guidance 2026-03-10 20:42:54 -07:00
perl-testing feat: add Perl skills (patterns, security, testing) 2026-03-10 20:42:54 -07:00
plankton-code-quality feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
postgres-patterns chore: replace external repo links with @username attribution 2026-03-03 12:32:35 -08:00
production-scheduling docs: resolve operational skill review issues 2026-03-10 21:07:36 -07:00
project-guidelines-example fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
prompt-optimizer feat(skills): add prompt-optimizer skill and /prompt-optimize command (#418) 2026-03-12 23:40:02 -07:00
python-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
python-testing fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
quality-nonconformance docs: resolve operational skill review issues 2026-03-10 21:07:36 -07:00
ralphinho-rfc-pipeline feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
regex-vs-llm-structured-text fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
returns-reverse-logistics docs: resolve remaining operational skill comments 2026-03-10 21:13:55 -07:00
search-first feat: separate core vs niche skills and enforce research-first default 2026-02-28 10:06:43 -08:00
security-review fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
security-scan fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
skill-stocktake docs: add skill-stocktake agent invocation example 2026-03-10 20:15:38 -07:00
springboot-patterns fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
springboot-security fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
springboot-tdd fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
springboot-verification fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
strategic-compact feat: add orchestration workflows and harness skills 2026-03-12 14:49:05 -07:00
swift-actor-persistence fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
swift-concurrency-6-2 fix(skills): improve code examples in iOS 26 skills 2026-02-24 14:39:25 +09:00
swift-protocol-di-testing fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
swiftui-patterns fix: correct SwiftUI skill ViewModel injection and Equatable comparison 2026-02-17 17:04:31 +02:00
tdd-workflow fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
verification-loop fix: add origin metadata to skills for traceability 2026-02-23 19:00:57 +03:00
video-editing feat: add orchestration workflows and harness skills 2026-03-12 14:49:05 -07:00
videodb fix: restore mainline CI on Windows and markdown lint (#415) 2026-03-12 14:48:21 -07:00
visa-doc-translate feat(skills): add visa-doc-translate skill 2026-02-20 16:25:23 +08:00
x-api fix: harden orchestration status and skill docs 2026-03-12 15:07:57 -07:00