mirror of
https://github.com/Jeuners/ECC.git
synced 2026-09-19 19:44:10 +02:00
* 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>
|
||
|---|---|---|
| .. | ||
| agent-harness-construction | ||
| agentic-engineering | ||
| ai-first-engineering | ||
| android-clean-architecture | ||
| api-design | ||
| article-writing | ||
| autonomous-loops | ||
| backend-patterns | ||
| blueprint | ||
| carrier-relationship-management | ||
| claude-api | ||
| clickhouse-io | ||
| coding-standards | ||
| compose-multiplatform-patterns | ||
| configure-ecc | ||
| content-engine | ||
| content-hash-cache-pattern | ||
| continuous-agent-loop | ||
| continuous-learning | ||
| continuous-learning-v2 | ||
| cost-aware-llm-pipeline | ||
| cpp-coding-standards | ||
| cpp-testing | ||
| crosspost | ||
| customs-trade-compliance | ||
| database-migrations | ||
| deep-research | ||
| deployment-patterns | ||
| django-patterns | ||
| django-security | ||
| django-tdd | ||
| django-verification | ||
| dmux-workflows | ||
| docker-patterns | ||
| e2e-testing | ||
| energy-procurement | ||
| enterprise-agent-ops | ||
| eval-harness | ||
| exa-search | ||
| fal-ai-media | ||
| foundation-models-on-device | ||
| frontend-patterns | ||
| frontend-slides | ||
| golang-patterns | ||
| golang-testing | ||
| inventory-demand-planning | ||
| investor-materials | ||
| investor-outreach | ||
| iterative-retrieval | ||
| java-coding-standards | ||
| jpa-patterns | ||
| kotlin-coroutines-flows | ||
| liquid-glass-design | ||
| logistics-exception-management | ||
| market-research | ||
| nanoclaw-repl | ||
| nutrient-document-processing | ||
| perl-patterns | ||
| perl-security | ||
| perl-testing | ||
| plankton-code-quality | ||
| postgres-patterns | ||
| production-scheduling | ||
| project-guidelines-example | ||
| prompt-optimizer | ||
| python-patterns | ||
| python-testing | ||
| quality-nonconformance | ||
| ralphinho-rfc-pipeline | ||
| regex-vs-llm-structured-text | ||
| returns-reverse-logistics | ||
| search-first | ||
| security-review | ||
| security-scan | ||
| skill-stocktake | ||
| springboot-patterns | ||
| springboot-security | ||
| springboot-tdd | ||
| springboot-verification | ||
| strategic-compact | ||
| swift-actor-persistence | ||
| swift-concurrency-6-2 | ||
| swift-protocol-di-testing | ||
| swiftui-patterns | ||
| tdd-workflow | ||
| verification-loop | ||
| video-editing | ||
| videodb | ||
| visa-doc-translate | ||
| x-api | ||