Skip to content

test(clv2): add coverage for instinct-cli prune, projects ops, promote dry-run, normalize-url - #2374

Merged
affaan-m merged 3 commits into
affaan-m:mainfrom
gaurav0107:test/2302-instinct-cli-coverage
Jun 30, 2026
Merged

affaan-m merged 3 commits into
affaan-m:mainfrom
gaurav0107:test/2302-instinct-cli-coverage

Conversation

@gaurav0107

Copy link
Copy Markdown
Contributor

What Changed

Adds pytest coverage to skills/continuous-learning-v2/scripts/test_parse_instinct.py
for functions in instinct-cli.py that previously had zero or insufficient tests.
No production code is modified — this is a test-only change (+245 lines, one file).

New tests, mapped 1:1 to the gaps in the issue:

  • _normalize_remote_url — scp-style git@host:org/repo.git, https with embedded
    credentials, file:// local paths, .git/trailing-slash stripping, network-URL
    lowercasing, case-preserving local paths, and idempotence.
  • _promote_specific dry-run — asserts dry_run=True returns 0, prints [DRY RUN],
    and writes no file to the global scope (the existing suite only covered the force path).
  • projects delete / gc / merge — invalid-id, not-found, --dry-run, and
    --force paths over the registry and on-disk storage, verifying every destructive
    branch is gated and dry-run leaves state untouched.
  • cmd_prune — --dry-run keeps files; non-dry-run deletes only entries at/over the
    TTL and preserves fresh ones; --quiet suppresses output.

Why This Change

These functions handle destructive operations (project deletion, GC, merge, prune) and
project-identity hashing (_normalize_remote_url), yet several had no regression tests.
Closing these gaps protects user data paths and documents the intended dry-run/force
semantics.

Testing Done

All run locally with CLAUDE_PLUGIN_ROOT unset (clean env):

  • python3 -m pytest skills/continuous-learning-v2/scripts/test_parse_instinct.py →
    90 passed (68 existing + 22 new), 0 failed.
  • node tests/run-all.js → 2898 passed, 0 failed (no regression).
  • node scripts/ci/validate-no-personal-paths.js → pass.
  • node scripts/ci/check-unicode-safety.js → pass.

Tests reuse the existing project_tree / patch_globals fixtures and operate strictly
inside tmp_path; all confirmation prompts are bypassed via force/dry_run, so no test
invokes input().

Type of Change

  • Test coverage (no production behavior change)
  • Bug fix
  • New feature
  • Breaking change

Security & Quality Checklist

  • No production code modified; additive test-only diff
  • Conventional Commits (test(clv2): ...)
  • No personal absolute paths (CI validator passes)
  • Destructive helpers exercised only inside temp dirs
  • No new dependencies

Documentation

No documentation changes required — internal test coverage only.

Fixes #2302

…normalize-url

Add pytest coverage for previously-untested functions in
skills/continuous-learning-v2/scripts/instinct-cli.py:

- _normalize_remote_url: scp/https/file forms, credential + .git
  stripping, network lowercasing, case-preserving local paths, idempotence
- _promote_specific dry-run: returns 0 and writes no global file
- projects delete/gc/merge: invalid-id, not-found, dry-run, and force
  paths over registry + storage, asserting destructive ops are gated
- cmd_prune: dry-run keeps files; non-dry-run deletes only expired; quiet

Test-only change; no production code modified.

Fixes affaan-m#2302
@coderabbitai

coderabbitai Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Added broader test coverage for instinct CLI behavior, including remote URL normalization, project deletion, garbage collection, merging, and pruning.
    • Verified dry-run semantics (no filesystem/registry changes), force actions, missing/invalid project handling, and idempotent URL cleanup.
    • Added checks for quiet mode output suppression and age-based removal of expired items, including the “nothing to do” behavior.

Walkthrough

Adds unit tests in skills/continuous-learning-v2/scripts/test_parse_instinct.py for _normalize_remote_url, _promote_specific dry-run, projects delete/gc/merge, and cmd_prune. No production code is changed.

Changes

instinct-cli test coverage

Layer / File(s) Summary
_normalize_remote_url and _promote_specific dry-run
skills/continuous-learning-v2/scripts/test_parse_instinct.py
Covers empty/None input, scp-style conversion, HTTPS credential/scheme stripping, lowercasing, .git and trailing slash removal, file:// case preservation, idempotency, and _promote_specific dry-run output plus no global file write.
Project delete, gc, and merge tests
skills/continuous-learning-v2/scripts/test_parse_instinct.py
Covers delete invalid-id and missing-project errors, dry-run preservation, force deletion, gc no-candidates and zero-value removal, and merge self-merge rejection, missing source, dry-run, and force-mode storage/registry updates.
cmd_prune tests
skills/continuous-learning-v2/scripts/test_parse_instinct.py
Adds a _pending_item helper and tests dry-run retention, age-based deletion of expired items, and quiet=True output suppression.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • affaan-m/ECC#2009: Adds tests around the same instinct-cli.py project-scoped behaviors and URL normalization paths.
  • affaan-m/ECC#2323: Touches the same project registry and storage maintenance paths exercised by the new delete/gc/merge tests.

Poem

A prune, a merge, a URL made neat,
Dry-runs keep their promises discreet.
Old items fade, new paths align,
And test cases now draw the line.
Quiet clicks where assertions meet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the test coverage added in this PR.
Description check ✅ Passed The description matches the test-only changes and the functions covered in the diff.
Linked Issues check ✅ Passed The new tests cover the requested prune, project ops, _promote_specific dry-run, and URL normalization gaps.
Out of Scope Changes check ✅ Passed Changes are confined to a single test file and align with the coverage-focused objectives.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gaurav0107
gaurav0107 marked this pull request as ready for review June 28, 2026 00:22
@gaurav0107
gaurav0107 requested a review from affaan-m as a code owner June 28, 2026 00:22
@gaurav0107

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/continuous-learning-v2/scripts/test_parse_instinct.py`:
- Around line 1202-1210: The dry-run tests only verify registry/output state and
should also assert the filesystem remains unchanged. Update
`test_projects_gc_dry_run_keeps_entry` to confirm `projects_dir/empty1` still
exists after calling `_cmd_projects_gc`, and update
`test_projects_merge_dry_run_no_changes` to confirm nothing was written under
`dest/instincts/personal`. Use the existing `patch_globals`, `tree`, and
`_cmd_projects_gc` / `_cmd_projects_merge` test setup to add these no-op storage
assertions.
- Around line 1321-1330: The quiet-mode prune test only asserts stdout is empty,
so it can miss unexpected stderr output from cmd_prune. Update
test_cmd_prune_quiet_suppresses_output to also verify capsys.readouterr().err is
empty after calling cmd_prune(args), keeping the check aligned with the quiet
behavior implemented by cmd_prune and its quiet handling in
_collect_pending_instincts/prune output paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 38f2ccf5-e35b-429c-b30a-f1dff0c1ef9a

📥 Commits

Reviewing files that changed from the base of the PR and between 2bc924f and bafea23.

📒 Files selected for processing (1)
  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
📜 Review details
⏰ Context from checks skipped due to timeout. (20)
  • GitHub Check: Greptile Review
  • GitHub Check: Test (windows-latest, Node 22.x, npm)
  • GitHub Check: Test (windows-latest, Node 22.x, yarn)
  • GitHub Check: Test (macos-latest, Node 18.x, yarn)
  • GitHub Check: Test (windows-latest, Node 20.x, npm)
  • GitHub Check: Test (macos-latest, Node 18.x, bun)
  • GitHub Check: Test (windows-latest, Node 18.x, yarn)
  • GitHub Check: Test (macos-latest, Node 20.x, yarn)
  • GitHub Check: Test (windows-latest, Node 22.x, pnpm)
  • GitHub Check: Test (windows-latest, Node 20.x, yarn)
  • GitHub Check: Test (windows-latest, Node 20.x, pnpm)
  • GitHub Check: Test (macos-latest, Node 18.x, pnpm)
  • GitHub Check: Test (macos-latest, Node 18.x, npm)
  • GitHub Check: Test (windows-latest, Node 18.x, npm)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, pnpm)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, bun)
  • GitHub Check: Test (windows-latest, Node 18.x, pnpm)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, yarn)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, npm)
  • GitHub Check: Coverage
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}

📄 CodeRabbit inference engine (.cursor/rules/common-coding-style.md)

**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}: Always create new objects, never mutate existing ones. Use immutable patterns to prevent hidden side effects and enable safe concurrency
Organize code into many small files (200-400 lines typical, 800 lines max) organized by feature/domain rather than by type
Always handle errors explicitly at every level and never silently swallow errors
Always validate all user input before processing at system boundaries
Use schema-based validation where available
Fail fast with clear error messages when validation fails
Never trust external data (API responses, user input, file content)
Ensure code is readable and well-named
Keep functions small (less than 50 lines)
Keep files focused (less than 800 lines)
Avoid deep nesting (more than 4 levels)
Do not use hardcoded values; use constants or configuration instead

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

No hardcoded secrets (API keys, passwords, tokens) - validate before any commit

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}: All user inputs must be validated
Enable CSRF protection on all state-changing endpoints
Verify authentication and authorization for all protected endpoints
Implement rate limiting on all endpoints to prevent abuse
Ensure error messages do not leak sensitive data in responses

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,sql}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

Use parameterized queries to prevent SQL injection

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp,properties,yml,yaml,json,env,config}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

NEVER hardcode secrets in source code - ALWAYS use environment variables or a secret manager

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{py,pyi}

📄 CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

**/*.{py,pyi}: Follow PEP 8 conventions in Python code
Use type annotations on all function signatures in Python
Prefer immutable data structures such as frozen dataclasses and NamedTuple in Python

**/*.{py,pyi}: Auto-format Python files using black/ruff after edit
Run type checking using mypy/pyright after editing Python files

**/*.{py,pyi}: Use Protocol from typing module for duck typing and defining object shapes in Python
Use dataclasses with @dataclass decorator for DTOs (Data Transfer Objects) in Python
Use context managers (with statement) for resource management in Python
Use generators for lazy evaluation and memory-efficient iteration in Python

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

**/*.py: Use black for code formatting in Python
Use isort for import sorting in Python
Use ruff for linting Python code

Avoid using print() statements in Python code; use the logging module instead

**/*.py: Retrieve secrets and API keys from environment variables using os.environ with error handling (raise KeyError if missing) rather than hardcoding credentials
Use bandit for static security analysis in Python projects

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*test*.{py,pyi}

📄 CodeRabbit inference engine (.cursor/rules/python-testing.md)

**/*test*.{py,pyi}: Use pytest as the testing framework for Python projects
Use pytest.mark for test categorization with markers like @pytest.mark.unit and @pytest.mark.integration

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,go,rs,kt,cpp,c,fs}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx,py,java,go,rs,kt,cpp,c,fs}: Write tests before implementation using TDD workflow: write failing test (RED), implement minimal code (GREEN), then refactor (IMPROVE)
Keep functions small (<50 lines) and files focused (<800 lines, typical 200-400 lines)
Avoid deep nesting (>4 levels)

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,go,rs,kt}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx,py,java,go,rs,kt}: Never mutate existing objects; always create new objects with changes applied (Immutability requirement)
Handle errors at every level; provide user-friendly messages in UI code and detailed context in server-side logs
Ensure error messages don't leak sensitive data

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
skills/**/*.{js,ts,py,sh}

📄 CodeRabbit inference engine (AGENTS.md)

Place new workflow contributions in skills/ directory as the canonical workflow surface

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
skills/**/scripts/**

⚙️ CodeRabbit configuration file

skills/**/scripts/**: Review generated or imported scripts as untrusted-input tooling. Flag RCE, path traversal, network fetches without validation, and writes outside the expected workspace.

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
{skills,commands,agents,rules}/**

⚙️ CodeRabbit configuration file

{skills,commands,agents,rules}/**: Focus on prompt-injection resilience, tool-permission scope, destructive action guards, and secret exfiltration risks.

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
🧠 Learnings (1)
📚 Learning: 2026-06-27T15:41:48.588Z
Learnt from: gaurav0107
Repo: affaan-m/ECC PR: 2369
File: skills/continuous-learning-v2/scripts/test_parse_instinct.py:1056-1082
Timestamp: 2026-06-27T15:41:48.588Z
Learning: In this repo, the Ruff configuration for Python files under `skills/continuous-learning-v2/scripts/` selects only `E/F/I/N/W/UP`, and `flake8-pytest-style` (e.g., `PT018`) is not enabled. During code review for files in this directory, don’t assume `PT018` will be enforced by CI/ruff; only raise/test for issues that are covered by the enabled Ruff rules (or confirm the relevant rule is enabled before relying on it).

Applied to files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
🪛 ast-grep (0.44.0)
skills/continuous-learning-v2/scripts/test_parse_instinct.py

[info] 1170-1170: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"proj1": {"name": "p1"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1182-1182: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"proj1": {"name": "p1"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1204-1204: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"empty1": {"name": "e1"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1218-1218: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"empty1": {"name": "e1"}, "full1": {"name": "f1"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1240-1240: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"dest": {"name": "d"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1251-1251: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"src": {"name": "s"}, "dest": {"name": "d"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)


[info] 1266-1266: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"src": {"name": "s"}, "dest": {"name": "d"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🪛 Ruff (0.15.18)
skills/continuous-learning-v2/scripts/test_parse_instinct.py

[warning] 1156-1156: Unused function argument: patch_globals

(ARG001)


[warning] 1162-1162: Unused function argument: patch_globals

(ARG001)


[warning] 1213-1213: Unused function argument: capsys

(ARG001)


[warning] 1233-1233: Unused function argument: patch_globals

(ARG001)


[warning] 1258-1258: Assertion should be broken down into multiple parts

Break down assertion into multiple parts

(PT018)


[warning] 1262-1262: Unused function argument: capsys

(ARG001)


[warning] 1281-1281: Missing return type annotation for private function _pending_item

(ANN202)

Comment thread skills/continuous-learning-v2/scripts/test_parse_instinct.py
Comment thread skills/continuous-learning-v2/scripts/test_parse_instinct.py Outdated
Address CodeRabbit review on affaan-m#2374:

- projects gc/merge dry-run tests now also assert on-disk storage is
  untouched (empty1 project dir survives; nothing copied into dest
  personal), closing the gap where a storage-mutating dry-run regression
  would still pass.
- cmd_prune quiet test now asserts stderr is empty too, not just stdout.
@greptile-apps

greptile-apps Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds 245 lines of new pytest coverage for four previously-uncovered areas in instinct-cli.py: _normalize_remote_url, _promote_specific dry-run, the projects delete/gc/merge commands, and cmd_prune. No production code is touched.

  • _normalize_remote_url — seven tests cover scp-style, https-with-credentials, file-scheme, trailing-slash/.git stripping, network lowercasing, and idempotence; all assertions match the production regex pipeline precisely.
  • Destructive operations — projects delete, gc, and merge each get invalid-id, not-found, dry-run, and force paths; cmd_prune gets dry-run, selective-expiry, quiet, and empty-list paths; every dry-run assertion is backed by a filesystem check confirming state is untouched.
  • Previously-flagged gaps — the symmetric destination-not-found error in _cmd_projects_merge and the empty-pending-list branch in cmd_prune are now covered by test_projects_merge_missing_destination and test_cmd_prune_empty_pending_nothing_to_do respectively.

Confidence Score: 5/5

Test-only change adding 245 lines of regression coverage for destructive operations; no production code modified.

Every new assertion was traced against the production code and confirmed correct — output strings, return codes, filesystem side-effects, and monkeypatching all align. Both gaps flagged in earlier review rounds are now closed. The change is additive and isolated to a single test file.

No files require special attention.

Important Files Changed

Filename Overview
skills/continuous-learning-v2/scripts/test_parse_instinct.py +245 lines of test-only coverage for _normalize_remote_url, _promote_specific dry-run, projects delete/gc/merge, and cmd_prune; all assertions verified against production code behavior, monkeypatching applied correctly through the module object, both previously-flagged gaps are now addressed.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[New Test Coverage] --> B[_normalize_remote_url]
    A --> C[_promote_specific dry-run]
    A --> D[projects delete]
    A --> E[projects gc]
    A --> F[projects merge]
    A --> G[cmd_prune]

    B --> B1[empty / None]
    B --> B2[scp-style git@ URL]
    B --> B3[https + credentials]
    B --> B4[network lowercasing]
    B --> B5[.git + trailing slash]
    B --> B6[file:// case preserve]
    B --> B7[idempotence]

    C --> C1[returns 0]
    C --> C2[prints DRY RUN]
    C --> C3[writes no file]

    D --> D1[invalid ID]
    D --> D2[not found]
    D --> D3[dry-run keeps state]
    D --> D4[force removes dir + registry]

    E --> E1[no candidates]
    E --> E2[dry-run keeps state]
    E --> E3[force removes zero-value only]

    F --> F1[same id]
    F --> F2[missing source]
    F --> F3[missing destination]
    F --> F4[dry-run no changes]
    F --> F5[force moves + removes source]

    G --> G1[dry-run keeps files]
    G --> G2[deletes only expired]
    G --> G3[quiet suppresses output]
    G --> G4[empty list no-op]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[New Test Coverage] --> B[_normalize_remote_url]
    A --> C[_promote_specific dry-run]
    A --> D[projects delete]
    A --> E[projects gc]
    A --> F[projects merge]
    A --> G[cmd_prune]

    B --> B1[empty / None]
    B --> B2[scp-style git@ URL]
    B --> B3[https + credentials]
    B --> B4[network lowercasing]
    B --> B5[.git + trailing slash]
    B --> B6[file:// case preserve]
    B --> B7[idempotence]

    C --> C1[returns 0]
    C --> C2[prints DRY RUN]
    C --> C3[writes no file]

    D --> D1[invalid ID]
    D --> D2[not found]
    D --> D3[dry-run keeps state]
    D --> D4[force removes dir + registry]

    E --> E1[no candidates]
    E --> E2[dry-run keeps state]
    E --> E3[force removes zero-value only]

    F --> F1[same id]
    F --> F2[missing source]
    F --> F3[missing destination]
    F --> F4[dry-run no changes]
    F --> F5[force moves + removes source]

    G --> G1[dry-run keeps files]
    G --> G2[deletes only expired]
    G --> G3[quiet suppresses output]
    G --> G4[empty list no-op]
Loading

Reviews (2): Last reviewed commit: "test(clv2): cover merge missing-destinat..." | Re-trigger Greptile

Comment thread skills/continuous-learning-v2/scripts/test_parse_instinct.py
Comment thread skills/continuous-learning-v2/scripts/test_parse_instinct.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/continuous-learning-v2/scripts/test_parse_instinct.py`:
- Line 1249: Add `@pytest.mark.unit` to the new test function
test_projects_merge_missing_destination so it matches the rest of the test
suite’s unit-test convention. Update the decorator alongside the existing pytest
test definition in test_parse_instinct.py, keeping the change scoped to that
test and any similarly added tests in the same area if present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e8dd41a7-6326-42c9-8647-33c3971c0f76

📥 Commits

Reviewing files that changed from the base of the PR and between 890a6dc and 096b61a.

📒 Files selected for processing (1)
  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
📜 Review details
⏰ Context from checks skipped due to timeout. (28)
  • GitHub Check: Greptile Review
  • GitHub Check: Test (ubuntu-latest, Node 22.x, bun)
  • GitHub Check: Test (windows-latest, Node 18.x, pnpm)
  • GitHub Check: Test (macos-latest, Node 18.x, npm)
  • GitHub Check: Test (windows-latest, Node 22.x, pnpm)
  • GitHub Check: Test (windows-latest, Node 18.x, yarn)
  • GitHub Check: Test (windows-latest, Node 20.x, npm)
  • GitHub Check: Test (macos-latest, Node 18.x, bun)
  • GitHub Check: Test (windows-latest, Node 20.x, pnpm)
  • GitHub Check: Test (ubuntu-latest, Node 22.x, yarn)
  • GitHub Check: Test (windows-latest, Node 22.x, npm)
  • GitHub Check: Test (windows-latest, Node 20.x, yarn)
  • GitHub Check: Test (macos-latest, Node 22.x, pnpm)
  • GitHub Check: Test (ubuntu-latest, Node 22.x, pnpm)
  • GitHub Check: Test (ubuntu-latest, Node 22.x, npm)
  • GitHub Check: Test (macos-latest, Node 22.x, bun)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, npm)
  • GitHub Check: Test (macos-latest, Node 20.x, bun)
  • GitHub Check: Test (ubuntu-latest, Node 20.x, yarn)
  • GitHub Check: Test (windows-latest, Node 22.x, yarn)
  • GitHub Check: Test (ubuntu-latest, Node 20.x, bun)
  • GitHub Check: Test (ubuntu-latest, Node 20.x, npm)
  • GitHub Check: Test (windows-latest, Node 18.x, npm)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, yarn)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, bun)
  • GitHub Check: Test (ubuntu-latest, Node 18.x, pnpm)
  • GitHub Check: Test (ubuntu-latest, Node 20.x, pnpm)
  • GitHub Check: Coverage
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}

📄 CodeRabbit inference engine (.cursor/rules/common-coding-style.md)

**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}: Always create new objects, never mutate existing ones. Use immutable patterns to prevent hidden side effects and enable safe concurrency
Organize code into many small files (200-400 lines typical, 800 lines max) organized by feature/domain rather than by type
Always handle errors explicitly at every level and never silently swallow errors
Always validate all user input before processing at system boundaries
Use schema-based validation where available
Fail fast with clear error messages when validation fails
Never trust external data (API responses, user input, file content)
Ensure code is readable and well-named
Keep functions small (less than 50 lines)
Keep files focused (less than 800 lines)
Avoid deep nesting (more than 4 levels)
Do not use hardcoded values; use constants or configuration instead

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

No hardcoded secrets (API keys, passwords, tokens) - validate before any commit

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}: All user inputs must be validated
Enable CSRF protection on all state-changing endpoints
Verify authentication and authorization for all protected endpoints
Implement rate limiting on all endpoints to prevent abuse
Ensure error messages do not leak sensitive data in responses

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,sql}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

Use parameterized queries to prevent SQL injection

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp,properties,yml,yaml,json,env,config}

📄 CodeRabbit inference engine (.cursor/rules/common-security.md)

NEVER hardcode secrets in source code - ALWAYS use environment variables or a secret manager

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{py,pyi}

📄 CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

**/*.{py,pyi}: Follow PEP 8 conventions in Python code
Use type annotations on all function signatures in Python
Prefer immutable data structures such as frozen dataclasses and NamedTuple in Python

**/*.{py,pyi}: Auto-format Python files using black/ruff after edit
Run type checking using mypy/pyright after editing Python files

**/*.{py,pyi}: Use Protocol from typing module for duck typing and defining object shapes in Python
Use dataclasses with @dataclass decorator for DTOs (Data Transfer Objects) in Python
Use context managers (with statement) for resource management in Python
Use generators for lazy evaluation and memory-efficient iteration in Python

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

**/*.py: Use black for code formatting in Python
Use isort for import sorting in Python
Use ruff for linting Python code

Avoid using print() statements in Python code; use the logging module instead

**/*.py: Retrieve secrets and API keys from environment variables using os.environ with error handling (raise KeyError if missing) rather than hardcoding credentials
Use bandit for static security analysis in Python projects

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*test*.{py,pyi}

📄 CodeRabbit inference engine (.cursor/rules/python-testing.md)

**/*test*.{py,pyi}: Use pytest as the testing framework for Python projects
Use pytest.mark for test categorization with markers like @pytest.mark.unit and @pytest.mark.integration

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,go,rs,kt,cpp,c,fs}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx,py,java,go,rs,kt,cpp,c,fs}: Write tests before implementation using TDD workflow: write failing test (RED), implement minimal code (GREEN), then refactor (IMPROVE)
Keep functions small (<50 lines) and files focused (<800 lines, typical 200-400 lines)
Avoid deep nesting (>4 levels)

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
**/*.{js,ts,jsx,tsx,py,java,go,rs,kt}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx,py,java,go,rs,kt}: Never mutate existing objects; always create new objects with changes applied (Immutability requirement)
Handle errors at every level; provide user-friendly messages in UI code and detailed context in server-side logs
Ensure error messages don't leak sensitive data

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
skills/**/*.{js,ts,py,sh}

📄 CodeRabbit inference engine (AGENTS.md)

Place new workflow contributions in skills/ directory as the canonical workflow surface

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
skills/**/scripts/**

⚙️ CodeRabbit configuration file

skills/**/scripts/**: Review generated or imported scripts as untrusted-input tooling. Flag RCE, path traversal, network fetches without validation, and writes outside the expected workspace.

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
{skills,commands,agents,rules}/**

⚙️ CodeRabbit configuration file

{skills,commands,agents,rules}/**: Focus on prompt-injection resilience, tool-permission scope, destructive action guards, and secret exfiltration risks.

Files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
🧠 Learnings (1)
📚 Learning: 2026-06-27T15:41:48.588Z
Learnt from: gaurav0107
Repo: affaan-m/ECC PR: 2369
File: skills/continuous-learning-v2/scripts/test_parse_instinct.py:1056-1082
Timestamp: 2026-06-27T15:41:48.588Z
Learning: In this repo, the Ruff configuration for Python files under `skills/continuous-learning-v2/scripts/` selects only `E/F/I/N/W/UP`, and `flake8-pytest-style` (e.g., `PT018`) is not enabled. During code review for files in this directory, don’t assume `PT018` will be enforced by CI/ruff; only raise/test for issues that are covered by the enabled Ruff rules (or confirm the relevant rule is enabled before relying on it).

Applied to files:

  • skills/continuous-learning-v2/scripts/test_parse_instinct.py
🪛 ast-grep (0.44.0)
skills/continuous-learning-v2/scripts/test_parse_instinct.py

[info] 1251-1251: use jsonify instead of json.dumps for JSON output
Context: json.dumps({"src": {"name": "s"}})
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🪛 Ruff (0.15.18)
skills/continuous-learning-v2/scripts/test_parse_instinct.py

[warning] 1351-1351: Prefer list over useless lambda

Replace with lambda with list

(PIE807)

🔇 Additional comments (1)
skills/continuous-learning-v2/scripts/test_parse_instinct.py (1)

1250-1255: LGTM!

Also applies to: 1351-1357

Comment thread skills/continuous-learning-v2/scripts/test_parse_instinct.py
@affaan-m
affaan-m merged commit a36148f into affaan-m:main Jun 30, 2026
40 checks passed
affaan-m added a commit that referenced this pull request Jul 4, 2026
* docs: add MRR-biased ECC Pro + AgentShield security roadmap

Output of a multi-agent survey + research pass: capability map of AgentShield
and ECC Pro, triage of every open PR/issue on both repos, and web research on
competitors, unbuilt ideas, and dev-tool demand. 17 items across 4 themes
(now/next/later) scored for free-to-paid conversion, each linked to the real
PRs/issues that implement it. Includes the reusable workflow script that
generated it.

Headline: ecc-agentshield is ~30K downloads/month with near-zero monetization
bridge, and the agent-proximity moat is computed but never rendered. Roadmap
removes trust blockers (FP cluster), makes the moat visible (PR #2320), then
productizes local CLI primitives into hosted Pro surfaces.

* docs(design): add hosted Pro fleet dashboard design (Sentry for agent security)

Implementation-ready architecture for the flagship 'next' roadmap item: a
hosted, multi-repo agent-security posture dashboard built on the existing
ecc-agentshield primitives (evidence-pack bundleDigest + operatorReadback,
watch/drift DriftResult, runtime NDJSON, baseline diff, policy promotion).
Covers free-vs-Pro scope, ingestion/query API grounded in real field names,
data model + time-series rollups, auth/RBAC + redaction guarantees, MVP build
order, and pricing hooks. Companion to ECC-PRO-SECURITY-ROADMAP.md.

* feat(control-pane): serve 3D agent-airspace viz + /api/proximity feed (#2320)

Adds the Layer 4 observability view to the control pane: a self-contained,
dependency-free 3D point-cloud of the agent airspace (positions from the
proximity embedding, sized by working set, colored by collision risk, links
for converging pairs) plus an XSS-safe advisory panel that polls every 5s.

- proximity-viz.js: renderProximityVizHtml() (canvas projection, no external JS)
- server.js: GET /proximity (page) + GET /api/proximity (snapshot.proximity feed)
- test: asserts both routes serve and the feed carries positions/links/advisories

* fix(clv2): escape $HOME before pgrep -f in migrate-homunculus.sh (#2339)

* fix(clv2): escape $HOME before pgrep -f in migrate-homunculus.sh

pgrep -f treats its argument as an extended regular expression, but the
running-observer guard interpolated $HOME unescaped. Paths containing regex
metacharacters (e.g. /home/user.name, /home/c++dev, /home/user (work)) made the
match over-broad or invalid, causing either a false negative (live observer
missed, migration proceeds and risks registry corruption) or a false positive
(migration blocked unnecessarily).

Escape the ERE metacharacters in $HOME via sed before building the pattern so
the home prefix is matched literally while the trailing .*observer-loop\.sh
regex is preserved. Portable across BSD and GNU sed.

Fixes #2301

* test(clv2): add regression test for migrate-homunculus.sh $HOME escaping

Guards the #2301 fix: extracts the script's sed escaping command and asserts
the resulting pgrep -f pattern matches the literal home path while no longer
over-matching a regex-expanded decoy (HOME=/home/user.name must not match
/home/userXname). Also pins that the guard uses escaped_home rather than $HOME
directly. Follows the existing clv2 shell-test convention in
tests/hooks/observe-entrypoint-allowlist.test.js.

Refs #2301

* test(clv2): skip migrate-homunculus escaping test on Windows

The test relies on POSIX bash/sed/grep -E semantics, which differ on the
Windows CI runners. Guard with the same process.platform === 'win32' early
exit used by tests/hooks/observe-subdirectory-detection.test.js so the
bash-dependent assertions only run on POSIX platforms.

Refs #2301

* fix(clv2): harden registry writes and project deletion (#2294, #2297) (#2323)

Two security-priority fixes in continuous-learning-v2/scripts/instinct-cli.py:

- #2294: _write_registry wrote projects.json without the advisory lock that
  _update_registry holds, so concurrent 'projects delete/gc/merge' could race an
  observe-time update and corrupt the registry. Extract the lock into a shared
  _registry_lock() context manager and use it in both writers.

- #2297: _remove_project_storage called shutil.rmtree on PROJECTS_DIR/project_id
  with no containment check. Add defense-in-depth: resolve the path and refuse to
  delete anything that is not strictly inside PROJECTS_DIR (or is the root
  itself), so a relaxed validator or future caller can never cause an
  arbitrary-directory delete.

Adds 5 pytest regression tests (atomic write under lock, contained delete,
missing-dir no-op, traversal refused, root refused). Node integration suite
(tests/scripts/instinct-cli-projects.test.js) green 9/9.

* feat(workflows): add orch-review native Workflow pilot (#2363)

* feat(workflows): add orch-review native Workflow pilot

Port orch-pipeline Phase 5 (Review) to a native Claude Code Workflow
script. The gated outer loop stays in the main conversation; this script
owns only the autonomous review+verify segment between the two human
gates:

1. Review — reviewers fan out in parallel: ecc:code-reviewer always,
   ecc:<language>-reviewer when args.language maps, ecc:security-reviewer
   when the orch-pipeline security trigger matches the diff/paths.
2. Dedup — merge findings across dimensions keyed on the normalized
   evidence snippet, since independent reviewers flag the same line.
3. Verify — each unique CRITICAL/HIGH finding goes to an independent
   adversarial verifier; MEDIUM/LOW pass through as advisory.

The Review->Verify barrier is deliberate: deduping before verification
stops the verifier running N times on the same bug (local testing: 11
raw findings collapsed to 4 unique, ~halving verifier cost).

Existing ECC reviewer subagents are reused via agentType; reviewer
output is validated by JSON schema. args is accepted as an object or a
JSON-encoded string.

- workflows/orch-review.workflow.js — the workflow script
- workflows/README.md — invocation contract, returns shape, follow-ups

CI lint is scoped to scripts/ and tests/, so the script (validated with
node --check) and the README (passes markdownlint) are untouched.

* fix(workflows): fail closed on invalid args and lost review dimensions

Addresses the two safety findings from the PR bot review:

1. Lost review dimension (Greptile P1 / CodeRabbit Major): a reviewer
   agent that returns null or rejects was silently dropped by
   filter(Boolean), so an unreviewed security dimension could still
   return APPROVE. Each dimension's outcome is now captured; failures
   land in failedDimensions and force CHANGES_REQUESTED (incomplete).

2. Invalid args (CodeRabbit Major): an empty diff returned APPROVE and
   bad JSON / non-array changedFiles threw inconsistently. Input is now
   validated up front and rejected with a clear error — the gate fails
   closed instead of approving an unreviewed payload.

Docs (header contract + README) updated for the new return fields
(incomplete, failedDimensions, stats.failed). Remaining bot nits
(evidence minLength, verify-label collision, verified->confirmed
rename, contract drift) deferred as follow-ups.

* fix(workflows): address remaining orch-review review nits

Follow-up to the bot review (deferred items from the safety pass):

- evidence: require minLength 1 in the schema, and fall back to a
  title+line dedup key when evidence is empty, so empty-evidence
  findings in one file no longer collapse onto a single key and drop
  (CodeRabbit).
- verify label: include a slice of the normalized evidence so two
  CRITICAL/HIGH findings from the same file get distinct labels and do
  not alias under resumability (Greptile).
- stats.verified -> stats.confirmed to match the "confirmed" wording
  used in the log and avoid ambiguity vs the refuted count (Greptile);
  header contract and README updated to match.

Verified by running the workflow on a synthetic vulnerable diff:
dedup 12 raw -> 5 unique, stats.confirmed populated, fail-closed fields
(incomplete/failedDimensions) intact.

* fix(workflows): harden verify stage and diff-only verification

Addresses the second-round bot review:

- Verify stage now has the same failure guard as the review stage: a
  rejected verifier no longer nulls out its slot (which crashed the
  later filter). A null return is treated as unconfirmed; a rejection
  keeps the finding as blocking (fail closed) so an unverifiable
  CRITICAL is never silently demoted to advisory (CodeRabbit @221).
- verifyPrompt now instructs the skeptic to judge solely from the
  provided diff text and not to refute merely because the referenced
  file is absent from the working tree (the diff may be an unapplied
  PR). Fixes the false-refute seen when testing on a synthetic diff.

CodeRabbit @81 (evidence minLength) was already addressed in the prior
commit; this is a stale re-post on the unresolved thread.

* fix(workflows): keep unverifiable blockers blocking; stop leaking error text

Second-round bot review (CodeRabbit):

- @218 Treat a null/failed verifier as `unverified`, not refuted. A
  terminal verifier failure or skip no longer demotes a CRITICAL/HIGH
  to advisory; it stays in `blocking` tagged "could not be verified"
  (fail closed). Only a genuine isReal=false verdict is refuted. Adds
  stats.unverified.
- @189 Do not return raw subagent error text. Review/verify failures
  now log the raw message for operators and return only a bounded label
  (failedDimensions[].error = "review agent failed").

Stale re-posts this round (@81 evidence minLength, @224 verify guard)
were already fixed in prior commits.

* docs(workflows): enumerate bounded failedDimensions.error labels

CodeRabbit (trivial): the public contract implied callers get
human-readable error text, but the implementation returns only bounded
labels. Enumerate them in the README returns block.

* Update yarn.lock (#2342)

* Add memxus configuration to mcp-servers.json (#2355)

* Add memxus configuration to mcp-servers.json

Added configuration for Memxus service with API key placeholder and description.

* Revise description in mcp-servers.json

Updated the description to include a note about reviewing stored memories to prevent prompt-injection.

* Update description in mcp-servers.json

Update description in mcp-servers.json

* Fix for docs: Scope Decision Guide table duplicated in SKILL.md and observer.md with minor drift (#2366)

#2306

Co-authored-by: angadsingh7666 <angdsingh7666@gmail.com>

* fix(llm): align Claude provider with current Anthropic API (#2133)

Replace invalid default model IDs (e.g. claude-sonnet-4-7) with current
claude-sonnet-4-6, claude-opus-4-8, and claude-haiku-4-5. Route system
messages to the API system field, enable ephemeral prompt caching, omit
temperature for Opus 4.7/4.8, and surface cache usage metrics. Update the
CLI model picker to match.

Co-authored-by: Vladimir Đuranović <vlada@MacBook-Pro.local>
Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(release): derive approval gate paths from version (#2383)

Co-authored-by: jan <jan@w-saxs001.local>

* fix(release): derive video suite paths from version (#2384)

Co-authored-by: jan <jan@w-saxs001.local>

* ci: isolate OMP workflow verification (#2382)

Co-authored-by: jan <jan@w-saxs001.local>

* fix(tests): resolve 10 failing tests on Windows (#2307)

- resolve-formatter: stop findProjectRoot walk before os.homedir() to
  avoid mistaking global dotfiles (e.g. ~/.prettierrc) for a project root
- instinct-cli-projects: detect python3/python binary at runtime; skip
  gracefully when Python 3 is unavailable instead of crashing with null status
- command-registry: regenerate COMMAND-REGISTRY.json (was stale)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(hooks): quote args when probing Windows .cmd MCP servers via shell (#2343)

On Windows, when a bare-name MCP server command (e.g. codesys-mcp-sp21-plus)
falls back to the .cmd candidate, the probe sets shell:true to work around
Node 18.20+ CVE-2024-27980. However, passing an args array alongside
shell:true causes Node to concatenate the tokens without quoting (DEP0190),
so an arg containing a space (e.g. --codesys-path "C:\Program Files\...") is
re-split by cmd.exe at every space boundary. The child process receives a
truncated path, fails to launch, and the probe declares the server unavailable,
falsely blocking every MCP tool call to that server.

Fix: add a quoteWin() helper that double-quotes any token containing whitespace
or cmd metacharacters. In the useShell branch, build a single properly-quoted
command line string and pass it as the sole argument to spawn() with no separate
args array. The else branch (shell:false, all non-.cmd commands) is unchanged.

Regression test added: on Windows, creates a .cmd shim that echoes its first
positional argument to stderr, probes it with a space-containing path arg, and
asserts the probe succeeds and the arg was not split at the space boundary.

Co-authored-by: Karstein Phobic Nyvold Kvistad <karstein.kvistad@maritimerobotics.com>

* fix(hooks): guard doc-file-warning stdin listeners behind require.main (#2358)

* fix(hooks): guard doc-file-warning stdin listeners behind require.main

doc-file-warning.js registered process.stdin data/end listeners at module
scope while also exporting run(). run-with-flags.js require()s any hook that
exports run() for its in-process fast path, so importing this hook attached
stray stdin listeners to the dispatcher process, corrupting the PreToolUse
stdout JSON contract. This is the exact failure run-with-flags' own SAFETY
comment warns about, and 24 sibling hooks already guard against it.

- Move the stdin entrypoint into main() and gate it behind require.main === module
- pre-write-doc-warn.js now calls main() explicitly instead of relying on the
  import side effect
- Add regression tests: require() attaches no stdin listeners, run()/main()
  stay exported, and the pre-write-doc-warn shim still warns

* docs(hooks): add JSDoc for doc-file-warning main() entrypoint

Satisfies the docstring-coverage pre-merge check; documents the stdin
entrypoint and why it must not run on require().

* fix(windows): prefer PowerShell over bash to prevent zombie process accumulation (#2346)

* fix(windows): prefer PowerShell over bash to prevent zombie process accumulation

On Windows, ECC hook scripts were spawning bash.exe (MSYS2/Git Bash) on
every tool use via findShellBinary(). These processes were not reaped by
Windows, causing 40+ zombie bash.exe/conhost.exe processes per session with
noticeable system lag.

Changes to scripts/hooks/plugin-hook-bootstrap.js:
- Add isPowerShellBin(bin) helper: basename-based detection so full paths
  like C:\Windows\...\powershell.exe are handled correctly
- findShellBinary(): check BASH env var first (preserves escape hatch),
  then on win32 probe pwsh.exe -> powershell.exe -> bash.exe -> bash;
  use correct probe args per shell type; cache result in _cachedShell
- findBashBinary(): separate cached bash-only finder used by spawnShell
  .sh fallback; skips PowerShell binaries even if BASH points to one
- spawnShell(): use isPowerShellBin() to select -NoProfile -NonInteractive
  -File args for PowerShell; .sh scripts fall back to findBashBinary()
  with a skip-warning if no bash found on Windows

observe-runner.js is intentionally unchanged: it always invokes observe.sh
which is bash-only; routing it through PowerShell would silently break it.
The observe.sh -> observe.js migration is tracked separately.

Fixes #2345

* fix(windows): address CodeRabbit and Greptile review comments

- Add timeout: 30000 to all spawnSync probe calls in findShellBinary and
  findBashBinary to prevent hangs on broken/stalled shell candidates
- Add -ExecutionPolicy Bypass to PowerShell -File invocation to fix
  execution on machines with the default Restricted policy (Win10/11)
- Add PowerShell availability skip guard to PS selection test (mirrors
  existing bash skip guard)
- Fix no-bash test to keep PowerShell on PATH so the .sh fallback branch
  is actually exercised rather than hitting shell-unavailable early exit

* test: add timeout to spawnSync probes in Windows test skip guards

---------

Co-authored-by: Christopher J Diamond <diamondcj@leidos.com>

* feat(session): LLM-powered session summary via claude -p (#2388)

Replace mechanical text extraction in session-end.js and pre-compact.js
with LLM-generated summaries using `claude -p`. Summaries now capture
design decisions, resolved bugs, changed files, and carry-over context
rather than just truncated user message snippets.

- Add scripts/lib/llm-summary.js: generateSessionSummary, extractConversationText,
  getContextRemainingPct, getContextThreshold, getLLMModel
- Update scripts/hooks/session-end.js: trigger LLM when context < 20% or
  every 50 messages (env-configurable via ECC_LLM_SUMMARY_*)
- Update scripts/hooks/pre-compact.js: generate LLM summary right before
  compaction and write it to the active session .tmp file
- Add tests/lib/llm-summary.test.js: 18 unit tests
- Update tests/hooks/hooks.test.js: 3 integration tests for new behaviour

Recursion guard: sets ECC_SKIP_LLM_SUMMARY=1 in subprocess env so Stop
hooks fired by the claude -p subprocess do not re-enter summarisation.
Requires no ANTHROPIC_API_KEY — reuses Claude Code's own authentication.

Co-authored-by: Hiroshi Tanaka <hiroshi_tanaka@MBAM3.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(deps): update anthropic requirement from >=0.25.0 to >=0.111.0 (#2329)

Updates the requirements on [anthropic](https://github.com/anthropics/anthropic-sdk-python) to permit the latest version.
- [Release notes](https://github.com/anthropics/anthropic-sdk-python/releases)
- [Changelog](https://github.com/anthropics/anthropic-sdk-python/blob/main/CHANGELOG.md)
- [Commits](https://github.com/anthropics/anthropic-sdk-python/compare/v0.25.0...v0.111.0)

---
updated-dependencies:
- dependency-name: anthropic
  dependency-version: 0.111.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump actions/checkout from 6.0.3 to 7.0.0 (#2328)

Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.3 to 7.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v6.0.3...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml (#2330)

Bumps [slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml](https://github.com/slsa-framework/slsa-github-generator) from 1.4.0 to 2.1.0.
- [Release notes](https://github.com/slsa-framework/slsa-github-generator/releases)
- [Changelog](https://github.com/slsa-framework/slsa-github-generator/blob/main/CHANGELOG.md)
- [Commits](https://github.com/slsa-framework/slsa-github-generator/compare/68bad40844440577b33778c9f29077a3388838e9...f7dd8c54c2067bafc12ca7a55595d5ee9b75204a)

---
updated-dependencies:
- dependency-name: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml
  dependency-version: 2.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump cron from 0.16.0 to 0.17.0 in /ecc2 (#2333)

Bumps [cron](https://github.com/zslayton/cron) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/zslayton/cron/releases)
- [Commits](https://github.com/zslayton/cron/commits)

---
updated-dependencies:
- dependency-name: cron
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): update pytest requirement from >=8.0 to >=9.1.1 (#2324)

Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/8.0.0...9.1.1)

---
updated-dependencies:
- dependency-name: pytest
  dependency-version: 9.1.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): update mypy requirement from >=1.10 to >=2.1.0 (#2326)

Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/python/mypy/compare/v1.10.0...v2.1.0)

---
updated-dependencies:
- dependency-name: mypy
  dependency-version: 2.1.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): update pytest-cov requirement from >=4.1 to >=7.1.0 (#2332)

Updates the requirements on [pytest-cov](https://github.com/pytest-dev/pytest-cov) to permit the latest version.
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v4.1.0...v7.1.0)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-version: 7.1.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump the actions-minor-and-patch group across 1 directory with 3 updates (#2325)

Bumps the actions-minor-and-patch group with 3 updates in the / directory: [actions/setup-node](https://github.com/actions/setup-node), [pnpm/action-setup](https://github.com/pnpm/action-setup) and [softprops/action-gh-release](https://github.com/softprops/action-gh-release).


Updates `actions/setup-node` from 6.3.0 to 6.4.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6.3.0...48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e)

Updates `pnpm/action-setup` from 6.0.8 to 6.0.9
- [Release notes](https://github.com/pnpm/action-setup/releases)
- [Commits](https://github.com/pnpm/action-setup/compare/0e279bb959325dab635dd2c09392533439d90093...0ebf47130e4866e96fce0953f49152a61190b271)

Updates `softprops/action-gh-release` from 3.0.0 to 3.0.1
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/b4309332981a82ec1c5618f44dd2e27cc8bfbfda...718ea10b132b3b2eba29c1007bb80653f286566b)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 6.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions-minor-and-patch
- dependency-name: pnpm/action-setup
  dependency-version: 6.0.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions-minor-and-patch
- dependency-name: softprops/action-gh-release
  dependency-version: 3.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump the cargo-minor-and-patch group across 1 directory with 3 updates (#2387)

Bumps the cargo-minor-and-patch group with 3 updates in the /ecc2 directory: [ratatui](https://github.com/ratatui/ratatui), [anyhow](https://github.com/dtolnay/anyhow) and [uuid](https://github.com/uuid-rs/uuid).


Updates `ratatui` from 0.30.1 to 0.30.2
- [Release notes](https://github.com/ratatui/ratatui/releases)
- [Changelog](https://github.com/ratatui/ratatui/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ratatui/ratatui/compare/ratatui-v0.30.1...ratatui-v0.30.2)

Updates `anyhow` from 1.0.102 to 1.0.103
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.102...1.0.103)

Updates `uuid` from 1.23.3 to 1.23.4
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/v1.23.3...v1.23.4)

---
updated-dependencies:
- dependency-name: ratatui
  dependency-version: 0.30.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
- dependency-name: anyhow
  dependency-version: 1.0.103
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
- dependency-name: uuid
  dependency-version: 1.23.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump eslint from 9.39.2 to 10.6.0 (#2260)

Bumps [eslint](https://github.com/eslint/eslint) from 9.39.2 to 10.6.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v9.39.2...v10.6.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 10.5.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(ci): unbreak main after dependabot batch (checkout SHA + lint) (#2393)

* fix(ci): track actions/checkout v7 SHA in supply-chain workflow test

Dependabot #2328 bumped actions/checkout v6->v7, changing the pinned SHA in
supply-chain-watch.yml; update the test's expected SHA to match.

* Revert "feat(workflows): add orch-review native Workflow pilot (#2363)"

This reverts commit 1031d312ccd16925c903174293b4cec4ecba1001.

* feat: add ecc-recipes skill (#2319)

* feat: add ecc-recipes skill

Maps a described workflow to the right ECC command-group with run-order
and stop condition, and browses command-group recipe families. Fills the
gap between ecc-guide (flat catalog) and prompt-optimizer (single-prompt
match) by adding family grouping, run-order, and stop conditions.
Advisory only; reads commands/ live.

* fix(ecc-recipes): address review

- flatten frontmatter origin/author/version to top-level (repo convention)
- guard unset CMD_DIR before globbing; use find instead of ls
- show burn-warning explicitly in output template

* feat(ecc-recipes): add argument-hint for slash UI

* feat(skills): add mailtrap-email-integration skill (#2288)

Adds a new Tool Integration skill (mailtrap-email-integration) covering transactional email sending patterns: sandbox vs. production separation, API authentication, and domain verification. Focused on patterns that generalize beyond one vendor, per the repo's Skill Adaptation Policy.

* docs(code-tour): document ref-field semantics to prevent PR-tour file-not-found (#2273)

The code-tour skill mentioned the CodeTour 'ref' field only in an example,
with no explanation of its behavior. CodeTour resolves each step's file
content from the git revision named by 'ref' (not the working tree) whenever
ref differs from HEAD, so any file that does not exist at that revision fails
to open with 'The editor could not be opened because the file was not found'
- even though the file is present on disk.

This bit a generated PR tour where ref was set to the base branch (develop):
every file ADDED by the PR is absent on the base, so all new-file steps 404'd
while the tour tree and comments still rendered, making the cause non-obvious.

Adds a 'The ref Field' section explaining the resolution behavior and the
rule that PR tours must pin ref to the branch head (never the base), plus a
validation step to confirm every referenced file exists at the chosen ref.

* fix(gateguard): finish tool-agnostic checklist across edit gate and SKILL.md copies (#2274)

b3268fef (#2272) made the write-gate "confirm no existing file" item
tool-agnostic in the JS hook, but the rest of the checklist surface still
names Glob/Grep. On hosts without those tools the agent still hits a dead
tool call on:
- the edit-gate "list importers" item in the hook (scripts/hooks/gateguard-fact-force.js)
- both checklist items in all three SKILL.md copies (en, ja-JP, zh-CN)

Apply the same wording b3268fef introduced — "(search the tree — Glob/Grep,
or find/grep via Bash)" — to those five remaining spots so the whole gate is
consistent. Prose-only; no logic change.

Follow-up to #2272 / b3268fef.

* feat(skills): harden the file upload validation section in django-security (#2338)

* feat(skills): harden the file upload validation section in django-security

* Update skills/django-security/SKILL.md

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* add missing stuff to second code block

* add import to the top of the code block

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* docs(skills): update Prisma and Zod API patterns for cross-version compatibility (#2336)

* docs(skills): update Prisma and Zod API patterns for cross-version compatibility

- skills/prisma-patterns: show both adapter-based and direct PrismaClient
  initialization side-by-side; update import paths with conditional notes;
  rewrite version header to be release-agnostic
- skills/backend-patterns: fix ZodError.errors -> ZodError.issues
- skills/coding-standards: fix ZodError.errors -> ZodError.issues
- skills/security-review: fix ZodError.errors -> ZodError.issues

These API differences were discovered during implementation of a
full-stack health assessment project. The updated code samples show
both the new and old API forms so the skill remains useful regardless
of which Prisma or Zod version is installed.

Closes #2335

* fix(skills): revert Prisma client imports to '@prisma/client'

The 'prisma' npm package is the CLI tool, not the runtime client.
Using it as an import source would cause compile-time failures on all
versions. '@prisma/client' remains the correct import source for the
generated PrismaClient and Prisma namespace types.

Found by Greptile during PR review.

* feat(skills): make tdd-workflow test-runner aware (npm/pnpm/yarn/bun) (#2347)

* feat(skills): make tdd-workflow test-runner aware (npm/pnpm/yarn/bun)

Add "Step 0: Detect the Test Runner" so the RED/GREEN cycle no longer
hardcodes `npm test`. Distinguishes the package manager from the test
runner (a project can install with Bun yet run Jest/Vitest), adds a runner
command matrix, and warns about `bun test` (native bun:test runner) vs
`bun run test` (runs the package.json script) — a common ESM failure mode.
Adds a Bun native test pattern section and links the bun-runtime skill.

Applied to both the canonical skills/ copy and the .agents/skills/ Codex
subset (manual sync per CONTRIBUTING).

* docs(skills): apply <test>/<coverage> placeholders in tdd-workflow steps

Address review feedback on PR #2347: Step 0 instructs the agent to substitute
the detected runner command, but Steps 3/5/7, Run Coverage Report, Watch Mode,
Pre-Commit, and CI/CD still showed literal `npm test` / `npm run test:coverage`
— so an agent reaching those blocks could run npm test on a pnpm/bun project.
Replace them with the <test> / <test-watch> / <coverage> placeholders from
Step 0. Left untouched: the plan-handoff allowlist example and the Step 8
evidence-table samples (illustrative, not run-this instructions). Applied to
both the canonical and Codex-subset copies.

* docs(skills): make pre-commit lint runner-agnostic via <lint> placeholder

Follow-up to PR #2347 review (CodeRabbit): the pre-commit example still used
`npm run lint`, coupling it to npm after test/coverage were made runner-aware.
Add a `<lint>` column to the Step 0 runner matrix (npm run lint / pnpm lint /
yarn lint / bun run lint) and change the Pre-Commit Hook example to
`<test> && <lint>`. Applied to both the canonical and Codex-subset copies.

* chore: re-trigger CI (flaky windows/node20 npm cell)

* refactor(commands): remove duplicated content in skill-create and learn-eval (#2348)

skill-create: drop the "Example Output" section (53 lines) — it re-rendered
the same skeleton already defined by the Step 3 output template, just with
filled-in `my-app` values.

learn-eval: drop the "Next Action" column from the 5b verdict table — it
duplicated Step 6's "Verdict-specific confirmation flow". The table now
carries Verdict + Meaning, and a pointer to Step 6 as the single source for
each verdict's action.

No behavior, frontmatter, or design-rationale changes.

* chore(catalog): sync manifests after skill batch (#2319 #2288 #2273 #2274 #2338 #2336 #2347 #2348) (#2394)

Regenerate catalog doc counts + command registry after merging the verified
skill/agent batch. Local full suite was green (2924/2924) with these applied.

* fix(clv2): align Python _update_registry schema with shell counterpart (#2369)

* fix(clv2): align Python _update_registry schema with shell counterpart

The Python `_update_registry` in instinct-cli.py wrote registry entries
without the `id` and `created_at` fields, while the shell counterpart in
detect-project.sh writes both. A projects.json entry could therefore have a
different shape depending on which path (Python CLI or shell hook) last
touched it.

Emit the same field set and order as the shell version: id, name, root,
remote, created_at (preserved from any existing entry), last_seen. Add
regression tests asserting field parity and created_at preservation.

Fixes #2299

* fix(clv2): guard _update_registry against a non-dict registry entry

A malformed projects.json (a non-dict value for the current project id, e.g.
null) would make existing.get("created_at", ...) raise and crash the update,
losing the old code's ability to self-heal a corrupt per-entry value. Normalize
existing to {} when it is not a dict so the entry is healed by the rewrite. Add
a regression test for the malformed-entry path.

* test(clv2): assert the first-write created_at == last_seen contract

The new _update_registry tests only checked both timestamps were truthy. On the
initial write both derive from the same `now`, so created_at must equal
last_seen; assert that explicitly so a later refactor that breaks the contract
is caught. Split the compound assertions into single-expression checks.

* fix(clv2): heal a non-dict top-level registry in _update_registry

A projects.json that is valid JSON but not a mapping (e.g. `[]` or a
string) previously crashed _update_registry on registry.get(), before
the per-entry guard could run, so the corrupt file could not be healed.
Guard the top-level shape right after the load and fall back to {} so the
rewrite repairs the file — matching the per-entry healing already in place.

Resolves the remaining CodeRabbit finding on #2299.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* fix(clv2): serialize observer signal-counter to stop dropped increments (#2372)

observe.sh bumps the SIGUSR1 throttle counter in
${PROJECT_DIR}/.observer-signal-counter with an unlocked read-modify-write.
The hook runs on every tool call, so concurrent invocations read the same
value, both increment, and lose a write, signaling the observer at
unpredictable intervals and defeating the #521 throttle.

Serialize the read-modify-write under a lock, and only ever bump the counter
while that lock is held:

- Prefer flock with a bounded -w wait (the OS auto-releases it when the fd
  closes or the process dies, so there is no stale lock and no lost increment);
  on a timeout the tick is skipped rather than bumped unlocked.
- Fall back to an atomic mkdir lock on platforms without flock, with a bounded
  spin. An EXIT trap cleans up on normal completion; INT/TERM traps release the
  lock and exit, so a signal cannot drop the lock and then continue the
  read-modify-write without ownership. If the lock cannot be acquired in the
  budget the tick is skipped rather than raced. No hand-rolled PID stale-reclaim
  (which is racy and can delete a live re-acquirer's lock).
- Guard the counter read against a corrupt (non-integer) file that would abort
  the hook under set -e.

Add tests/hooks/observe-signal-counter-race.test.js: 20 concurrent observe.sh
invocations must not lose increments (exact under flock; at most one dropped on
the best-effort mkdir fallback), the runner rejects on any hook execution
failure or hang, plus content guards for the lock and the corrupt-counter
handling.

Fixes #2296

* fix(clv2): surface SIGALRM timeout drops in observe.sh (#2373)

* fix(clv2): surface SIGALRM timeout drops in observe.sh

The inline-Python observation writers in observe.sh arm a signal.SIGALRM
alarm (8s) so they self-terminate before the async hook's 10s timeout can
orphan them (#2278). The handler _ecc_bail called sys.exit(0) with no
logging, so when the alarm fired the in-flight observation was silently
dropped: nothing was logged, no partial write occurred, and the shell saw
a clean exit. There was no way to detect or count how many observations
were being lost.

Add a single stderr visibility line to both _ecc_bail handlers (the
parse-error fallback path and the main observation-writing path) before
sys.exit(0), using the repo's "[observe]" log prefix. Exit code stays 0:
in a Claude Code hook a non-zero exit signals a block, so changing it
would turn an internal timeout into a user-facing tool block. The warning
goes to stderr (not stdout) because both blocks redirect stdout into the
observations file.

Add tests/hooks/observe-signal-timeout.test.js: a static regression guard
that every _ecc_bail handler logs to stderr before exiting and keeps exit
0, plus a behavioral check that runs the real handler text extracted from
observe.sh and confirms a fired alarm exits 0 and emits the [observe]
warning on stderr only.

Fixes #2300

* test(clv2): exercise both _ecc_bail handlers end-to-end

The behavioral SIGALRM-fire test ran only handlers[0] (the parse-error
fallback path); the main observation-write path (handlers[1]) was covered
only by the static regex guard. The write path is the higher-value one to
verify end-to-end since it carries valid, parseable data that would succeed
given more time, so a silent drop there is the worst case.

Loop the behavioral check over every extracted handler so a regression that
silenced the second handler's stderr write is caught at runtime, not just by
the static guard.

* test(clv2): select timeout handlers by marker, not array index

The behavioral check looped over all extracted _ecc_bail handlers by index.
If an unrelated _ecc_bail were ever added to observe.sh, the loop would
either test the wrong block or be diluted. Filter the handlers to those
carrying the "[observe] SIGALRM timeout" marker so the live SIGALRM check
stays pinned to the two #2300 timeout handlers regardless of array order or
future additions.

* test(clv2): fail fast when python is missing in SIGALRM check

The behavioral test returned early when no python interpreter was found,
which the test harness records as a PASS — so the SIGALRM contract could go
entirely unverified yet still look green. Throw instead, matching the
existing insaits-security-monitor convention of failing when a required
Python runtime is absent, and drop the in-test console.log.

* test(clv2): add coverage for instinct-cli prune, projects ops, promote dry-run, normalize-url (#2374)

* test(clv2): cover instinct-cli prune, projects ops, promote dry-run, normalize-url

Add pytest coverage for previously-untested functions in
skills/continuous-learning-v2/scripts/instinct-cli.py:

- _normalize_remote_url: scp/https/file forms, credential + .git
  stripping, network lowercasing, case-preserving local paths, idempotence
- _promote_specific dry-run: returns 0 and writes no global file
- projects delete/gc/merge: invalid-id, not-found, dry-run, and force
  paths over registry + storage, asserting destructive ops are gated
- cmd_prune: dry-run keeps files; non-dry-run deletes only expired; quiet

Test-only change; no production code modified.

Fixes #2302

* test(clv2): assert dry-run storage no-op and quiet-mode stderr silence

Address CodeRabbit review on #2374:

- projects gc/merge dry-run tests now also assert on-disk storage is
  untouched (empty1 project dir survives; nothing copied into dest
  personal), closing the gap where a storage-mutating dry-run regression
  would still pass.
- cmd_prune quiet test now asserts stderr is empty too, not just stdout.

* test(clv2): cover merge missing-destination and prune empty-pending branches

* fix(clv2): archive observations only after successful analysis in observer-loop (#2386)

analyze_observations moved observations.jsonl into observations.archive/
unconditionally, even when the Claude analysis failed (timeout, non-zero
exit, rate limit). Because the analyzer only reads the live file, a failed
batch was archived and never re-analyzed, silently dropping the instincts
it would have produced.

Return early on a non-zero analysis exit so the archive mv runs only on
success, retaining observations for the next cycle to retry. Resolve the
script's own directory from ${BASH_SOURCE[0]} (SCRIPT_DIR) so sibling
scripts (session-guardian.sh) and relative helpers resolve correctly under
both execution and sourcing, and add a source-guard so observer-loop.sh can
be sourced without starting the loop. Add a regression test covering both
the failure (retain) and success (archive) paths.

Fixes #2370

* feat(continuous-learning-v2): make observer model configurable via ECC_OBSERVER_MODEL (#2390)

* feat(continuous-learning-v2): make observer model configurable via ECC_OBSERVER_MODEL

The observer hardcoded `--model haiku`. Parameterize as "${ECC_OBSERVER_MODEL:-haiku}": the haiku default is preserved (no behavior change for existing users), but users can opt into a stronger model — e.g. `ECC_OBSERVER_MODEL=opus` — for higher-quality instinct extraction. Useful on subscription plans where model cost isn't the limiting factor.

* fix(continuous-learning-v2): address review — update wiring test + docs

- Update source-inspection test to assert the ${ECC_OBSERVER_MODEL:-haiku} defaulting behavior (was matching the literal `claude --model haiku`, which this PR changed). All 31 tests pass.
- Add guidance to raise ECC_OBSERVER_TIMEOUT_SECONDS for slower models (e.g. opus) so the 120s watchdog doesn't kill analysis mid-run.
- Fix now-stale 'Haiku session' comment -> 'observer session' (model is configurable).

* feat(rules,skills): add React Native / Expo rules pack and react-native-patterns skill (#2275)

* feat(rules,skills): add React Native / Expo rules pack and react-native-patterns skill

* fix(rules,skills): address review feedback — safeParse nav example, drop deprecated sentry-expo, memoize list renderItem, clarify New Architecture SDK support

* fix(rules,skills): drop deprecated Flipper, surface permission-denied state in location hook

* Add growth-log skill: methodology for effective learning capture (#2377)

* Add growth-log skill: methodology for writing effective, transferable growth log entries

* Add metadata.origin: ECC frontmatter per repo convention (Greptile feedback)

* Re-sign: apply GPG-verified commit to growth-log branch (rebase artifact, content unchanged)

* docs(growth-log): v1.1.0 — remove personal library structure, generic storage, delivery-gate optional companion

* Stop hook: verify thinking quality at session end — task completeness, assumptions, stale logs, disk space (delivery-gate) (#2378)

* Restore delivery-gate: Stop hook with learning capture enforcement (auto-closed by fork sync, now on clean branch)

* Fix bot findings: log level→INFO (DISK_REMIND dead code), count_edits full transcript (not truncated), memory-dir-absent warning (not silent pass), SKILL.md description accuracy

* Fix CodeRabbit feedback: treat missing memory-dir as all-stale on complex tasks (fail-close instead of fail-open)

* Trigger bot re-review (no logic changes)

* Fix: handle both stdin formats — raw transcript AND JSON with transcript_path (Greptile feedback)

* Add debug log for memory-dir lookup path

* Fix path encoding: replace colon with dash (not strip), matching Claude Code actual encoding on Windows

* Fix SKILL.md: update How It Works for JSON+transcript_path, add English translation to CLAUDE.md block (Greptile feedback)

* Fix: memory-dir absent → warn but don't block (prevents deadlock for new users per Greptile feedback)

* fix: restore daltino-approved voice (thinking quality/收尾铁律) with technical patches

Reverts 'session hygiene' rebranding. Preserves original approved framing
while keeping technical improvements:
- JSON transcript_path parsing documentation
- filesystem mtime staleness check
- 'skip tests for now' rationalization pattern
- disk critically low explicit block condition

* fix: remove stdout JSON echo — Stop hooks write feedback to stderr, not stdout

Previously sys.stdout.write(raw) echoed the raw hook JSON payload to stdout,
which Claude Code displays as the hook's response message. When the hook
blocked (exit 2), Claude saw {"transcript_path":"...","session_id":"..."}
instead of the actual blocking reason from stderr.

This made the gate functionally silent from Claude's perspective — it could
not guide Claude to the corrective action (update growth-log / free disk).

Fix per Greptile feedback: stop echo, let stderr messages reach Claude.

* fix: remove duplicate disk-critical log line

* docs(delivery-gate): v1.1.0 — accurate scope (deterministic checks, not reasoning), warning vs block table, CI/CD analogy, limitations section, self-audit pairing

* fix(delivery-gate): expand rationalization regex coverage (R3/R4) — match "we can fix" and "integration tests" variants

* chore: bump version to 1.1.1 to re-trigger CI checks

* feat: add loop-design-check skill (design + review goal-oriented agent loops) (#2381)

* chore(catalog): sync manifests + fix skill emoji (wave 2) (#2395)

* chore(catalog): sync manifests after skill batch (#2275 #2377 #2378 #2381)

Update skill counts (273 -> 277) across catalog docs after the verified skill batch.

* fix(skills): replace emoji with ASCII in growth-log + loop-design-check

check-unicode-safety (pre-push gate) bans emoji in SKILL.md; the merged #2377
and #2381 slipped through run-all.js. Swap U+274C/U+2705 for 'Avoid:'/'Bad:'/'Good:'.

* fix(plan-orchestrate): detect ecc@ecc marketplace + emit ecc: agent prefix (#2316) (#2409)

* fix(plan-orchestrate): detect ecc@ecc marketplace + emit ecc: agent prefix (#2316)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): resync lockfiles with package.json (eslint 10) + migrate yarn.lock to Yarn 4 format

package.json requires eslint@^10.6.0 but the committed locks pinned 9.39.2, so
npm ci aborted and Yarn 4 hardened mode rejected the stale v1-classic yarn.lock
(YN0028). Regenerate package-lock.json and rewrite yarn.lock in Yarn 4 (berry)
format so npm ci and immutable yarn installs both pass.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): require clean probe exit for Windows shell/bash detection; add pyyaml dev dep

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: affaan <affaan@itomarkets.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410)

* fix(ci): resync lockfiles with package.json (eslint 10) + migrate yarn.lock to Yarn 4 format

package.json requires eslint@^10.6.0 but the committed locks pinned 9.39.2, so
npm ci aborted and Yarn 4 hardened mode rejected the stale v1-classic yarn.lock
(YN0028). Regenerate package-lock.json and rewrite yarn.lock in Yarn 4 (berry)
format so npm ci and immutable yarn installs both pass.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): require clean probe exit for Windows shell/bash detection; add pyyaml dev dep

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368)

The inline node -e resolver blob was duplicated ~60x across hooks.json,
command docs, and translations. Each copy inlined the full ~700-char
plugin-root search using a spread over nested array literals
(p.join(d,'plugins',...s) over [['ecc'],...]), which breaks Windows hook
execution due to shell quoting (#2368).

Collapse every copy to a 250-char locator that loads the committed
resolve-ecc-root module and delegates to resolveEccRoot() — no spread, no
nested array literals, no escaped double quotes. The real search logic now
lives in one tested module. Also route session-start-bootstrap.js through
resolveEccRoot() instead of its own duplicated reimplementation, and fix
the auto-update.md 'marketplace' (singular) typo along the way.

Guard tests updated: discovery behavior is asserted against resolveEccRoot();
the inline is asserted to delegate and to contain no Windows-fragile
constructs.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(resolve-ecc-root): restore full env-unset discovery in inline resolver

Address Greptile review on #2410: when CLAUDE_PLUGIN_ROOT is unset the
delegating inline could only load the resolver module from ~/.claude,
returning ~/.claude without ever reaching the plugin/cache search. Restore
the old inline's discovery breadth (exact plugin roots + versioned cache)
Windows-safely (no spread, nested arrays, or escaped quotes), then delegate
the authoritative decision to resolveEccRoot(). Add regression tests for
plugin-subdir and versioned-cache bootstrap with env unset.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: affaan <affaan@itomarkets.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: docs/COMMAND-REGISTRY.json check fails on fresh Windows clone (missing .gitattributes) (#2437)

* fix: add .gitattributes to force LF line endings for text files

npm run command-registry:check (part of npm test) fails on a fresh clone
on Windows with the common core.autocrlf=true setting: git checks out
docs/COMMAND-REGISTRY.json with CRLF, but generate-command-registry.js
always writes LF, so the strict string comparison in checkRegistry()
never matches. Forcing LF via .gitattributes makes checkouts consistent
across platforms regardless of a contributor's local autocrlf setting.

* fix: normalize CRLF line endings to LF per .gitattributes

pyproject.toml, src/llm/__init__.py, src/llm/prompt/builder.py,
src/llm/providers/claude.py, and tests/test_builder.py had CRLF line
endings committed to the repo, inconsistent with the rest of the
codebase. Renormalized via 'git add --renormalize .' now that
.gitattributes enforces eol=lf.

---------

Co-authored-by: Affaan Mustafa <me@affaanmustafa.com>

* feat(workflows): re-land orch-review workflow + add /orch-review command (#2400)

* feat(workflows): re-land orch-review workflow + add /orch-review command

Re-lands #2363 (reverted by #2393 to unbreak main's lint) and fixes the
root cause so it stays green:

- Restore workflows/orch-review.workflow.js + workflows/README.md.
- eslint.config.js: ignore 'workflows/**/*.workflow.*' and '.claude/workflows/**'
  per the maintainer's note in #2393. Workflow DSL scripts use both top-level
  export (ESM) and top-level return (the runtime wraps them in an async fn),
  which no single eslint sourceType can parse — they must be excluded, not
  lint-fixed. 'npx eslint .' is green with this ignore.
- Add commands/orch-review.md (the /orch-review surface) + regenerate
  docs/COMMAND-REGISTRY.json.

Supersedes #2397 (command-only), which referenced the reverted workflow.

* fix(workflows): address orch-review bot review findings

- Verifier uncertainty no longer demotes blockers (Greptile P1 + CodeRabbit):
  isReal=false only refutes when confidence >= 0.8; low-confidence 'false'
  is treated as uncertain and kept blocking (fail closed).
- Treat the diff (and finding text) as untrusted input in both review and
  verify prompts; ignore embedded directives (prompt-injection hardening).
- Validate changedFiles entries are strings, not just that it is an array.
- Enforce proof for HIGH/CRITICAL in FINDINGS_SCHEMA, not only in the prompt.
- Remove in-place mutation in dimension build + dedup merge (immutable).
- /orch-review: extract & validate a numeric PR id before shelling out to gh.
- Docs: complete the stats example, soften wording, refresh follow-up list.

* style(workflows): apply formatter to orch-review assembly

* fix(plan-orchestrate): detect ecc@ecc marketplace + emit ecc: agent prefix (#2316) (#2409)

* fix(plan-orchestrate): detect ecc@ecc marketplace + emit ecc: agent prefix (#2316)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): resync lockfiles with package.json (eslint 10) + migrate yarn.lock to Yarn 4 format

package.json requires eslint@^10.6.0 but the committed locks pinned 9.39.2, so
npm ci aborted and Yarn 4 hardened mode rejected the stale v1-classic yarn.lock
(YN0028). Regenerate package-lock.json and rewrite yarn.lock in Yarn 4 (berry)
format so npm ci and immutable yarn installs both pass.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): require clean probe exit for Windows shell/bash detection; add pyyaml dev dep

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: affaan <affaan@itomarkets.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410)

* fix(ci): resync lockfiles with package.json (eslint 10) + migrate yarn.lock to Yarn 4 format

package.json requires eslint@^10.6.0 but the committed locks pinned 9.39.2, so
npm ci aborted and Yarn 4 hardened mode rejected the stale v1-classic yarn.lock
(YN0028). Regenerate package-lock.json and rewrite yarn.lock in Yarn 4 (berry)
format so npm ci and immutable yarn installs both pass.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ci): require clean probe exit for Windows shell/bash detection; add pyyaml dev dep

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368)

The inline node -e resolver blob was duplicated ~60x across hooks.json,
command docs, and translations. Each copy inlined the full ~700-char
plugin-root search using a spread over nested array literals
(p.join(d,'plugins',...s) over [['ecc'],...]), which breaks Windows hook
execution due to shell quoting (#2368).

Collapse every copy to a 250-char locator that loads the committed
resolve-ecc-root module and delegates to resolveEccRoot() — no spread, no
nested array literals, no escaped double quotes. The real search logic now
lives in one tested module. Also route session-start-bootstrap.js through
resolveEccRoot() instead of its own duplicated reimplementation, and fix
the auto-update.md 'marketplace' (singular) typo along the way.

Guard tests updated: discovery behavior is asserted against resolveEccRoot();
the inline is asserted to delegate and to contain no Windows-fragile
constructs.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(resolve-ecc-root): restore full env-unset discovery in inline resolver

Address Greptile review on #2410: when CLAUDE_PLUGIN_ROOT is unset the
delegating inline could only load the resolver module from ~/.claude,
returning ~/.claude without ever reaching the plugin/cache search. Restore
the old inline's discovery breadth (exact plugin roots + versioned cache)
Windows-safely (no spread, nested arrays, or escaped quotes), then delegate
the authoritative decision to resolveEccRoot(). Add regression tests for
plugin-subdir and versioned-cache bootstrap with env unset.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: affaan <affaan@itomarkets.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: docs/COMMAND-REGISTRY.json check fails on fresh Windows clone (missing .gitattributes) (#2437)

* fix: add .gitattributes to force LF line endings for text files

npm run command-registry:check (part of npm test) fails on a fresh clone
on Windows with the common core.autocrlf=true setting: git checks out
docs/COMMAND-REGISTRY.json with CRLF, but generate-command-registry.js
always writes LF, so the strict string comparison in checkRegistry()
never matches. Forcing LF via .gitattributes makes checkouts consistent
across platforms regardless of a contributor's local autocrlf setting.

* fix: normalize CRLF line endings to LF per .gitattributes

pyproject.toml, src/llm/__init__.py, src/llm/prompt/builder.py,
src/llm/providers/claude.py, and tests/test_builder.py had CRLF line
endings committed to the repo, inconsistent with the rest of the
codebase. Renormalized via 'git add --renormalize .' now that
.gitattributes enforces eol=lf.

---------

Co-authored-by: Affaan Mustafa <me@affaanmustafa.com>

* chore(catalog): sync command counts (92->93) + register orch-review in agent.yaml surface

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: affaan <affaan@itomarkets.com>
Co-authored-by: Boube <109886533+Cb2i@users.noreply.github.com>
Co-authored-by: Affaan Mustafa <me@affaanmustafa.com>

* docs: replace personal absolute paths with repo-relative agentshield/ paths

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Gaurav Dubey <gauravdubey0107@gmail.com>
Co-authored-by: JongHyeok Park <jonghyeok.park@unitblack.co.kr>
Co-authored-by: Daniel Nguyen <DANIEL@FINHUB.NET.AU>
Co-authored-by: Gabriel Pitrella <gabriel98_@hotmail.com>
Co-authored-by: Angad Singh Thind <angadsthind@gmail.com>
Co-authored-by: angadsingh7666 <angdsingh7666@gmail.com>
Co-authored-by: quadcent <vlada87ns@gmail.com>
Co-authored-by: Vladimir Đuranović <vlada@MacBook-Pro.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Yang Cheng <ycg78@hotmail.com>
Co-authored-by: jan <jan@w-saxs001.local>
Co-authored-by: Tahiti18 <35585881+Tahiti18@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: phobicdotno <spamme.post@gmail.com>
Co-authored-by: Karstein Phobic Nyvold Kvistad <karstein.kvistad@maritimerobotics.com>
Co-authored-by: SSH._.WORLD <ssh97540@gmail.com>
Co-authored-by: ChrisD <cdiamond@diamond.net>
Co-authored-by: Christopher J Diamond <diamondcj@leidos.com>
Co-authored-by: Hiroshi Tanaka <viveregratis1982@gmail.com>
Co-authored-by: Hiroshi Tanaka <hiroshi_tanaka@MBAM3.local>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: KyawZinLatt <mr.kyawzinlattt@gmail.com>
Co-authored-by: Awa Dieudonne <dieudonneawa7@gmail.com>
Co-authored-by: Carlos Carvallo <carloscarvallo87@gmail.com>
Co-authored-by: Jun <39075334+mc856@users.noreply.github.com>
Co-authored-by: jvirgovic <jvirgovic@proton.me>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: weizhiyuan <104509245+m18897829375@users.noreply.github.com>
Co-authored-by: jack-finance-able <jack@finance-able.com>
Co-authored-by: Yeris Rifan <yerisrifan@gmail.com>
Co-authored-by: YuhaoLin2005 <lin_yuhao2005@163.com>
Co-authored-by: Seekers2001 <jiaxinleifm@outlook.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Boube <109886533+Cb2i@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add coverage for cmd_prune, projects delete/gc/merge, _promote_specific dry-run, and _normalize_remote_url

2 participants