fix(continuous-learning-v2): accept claude-vscode as valid entrypoint - #2134
Conversation
The observe.sh Layer 1 entrypoint guard short-circuits with exit 0 when
CLAUDE_CODE_ENTRYPOINT is not in {cli, sdk-ts, claude-desktop}. Claude
Code's VS Code extension sets CLAUDE_CODE_ENTRYPOINT=claude-vscode, so
VS Code users see no observations recorded — observations.jsonl never
gets created and the instinct pipeline stays empty.
Add claude-vscode to the allowlist, mirroring the precedent in affaan-m#1522
which added claude-desktop the same way.
Add a regression test that spawns observe.sh under bash -x for each
allowed entrypoint (cli, sdk-ts, claude-desktop, claude-vscode) and
each denied entrypoint (unknown-host, claude-cody, mcp), asserting
that allowed entrypoints reach Layer 2's ECC_HOOK_PROFILE check while
denied entrypoints stop at Layer 1.
Fixes affaan-m#2102
📝 WalkthroughWalkthroughThe PR adds ChangesEntrypoint Allowlist Fix and Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
tests/hooks/observe-entrypoint-allowlist.test.js (3)
57-61: ⚡ Quick winAvoid silently swallowing cleanup failures.
Line 57-61 has an empty catch block. At minimum, capture and surface cleanup errors in a controlled way (e.g., debug output) so failures are diagnosable.
As per coding guidelines, "Always handle errors explicitly at every level and never silently swallow errors".
🤖 Prompt for 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. In `@tests/hooks/observe-entrypoint-allowlist.test.js` around lines 57 - 61, The empty catch around fs.rmSync(dir, { recursive: true, force: true }) swallows cleanup errors; update the catch to explicitly handle and surface failures (e.g., log with console.error or the test logger) including the directory name and error object so failures are diagnosable, or rethrow if appropriate for the test; locate the try/catch that wraps fs.rmSync for variable dir in tests/hooks/observe-entrypoint-allowlist.test.js and replace the silent ignore with an explicit error handling statement that records the error details.
103-114: ⚡ Quick winMake Layer 2 trace detection less brittle across Bash/xtrace formats.
LAYER2_TRACE_MARKERcurrently depends on one exact quoted trace literal. A regex-based check for the semantic condition (minimal profile comparison) would reduce false negatives across environments.Proposed robust matcher
-const LAYER2_TRACE_MARKER = "'[' minimal = minimal ']'"; +const LAYER2_TRACE_RE = /\[\s+minimal\s+=\s+minimal\s+\]/; ... - result.stderr.includes(LAYER2_TRACE_MARKER), - `entrypoint ${entrypoint} should reach Layer 2 (expected ${LAYER2_TRACE_MARKER} in trace); stderr tail: ${result.stderr.slice(-400)}` + LAYER2_TRACE_RE.test(result.stderr), + `entrypoint ${entrypoint} should reach Layer 2 (expected minimal-profile check in trace); stderr tail: ${result.stderr.slice(-400)}` ... - !result.stderr.includes(LAYER2_TRACE_MARKER), - `entrypoint ${entrypoint} should stop at Layer 1 (Layer 2 marker ${LAYER2_TRACE_MARKER} should NOT appear); stderr tail: ${result.stderr.slice(-400)}` + !LAYER2_TRACE_RE.test(result.stderr), + `entrypoint ${entrypoint} should stop at Layer 1 (Layer 2 marker should NOT appear); stderr tail: ${result.stderr.slice(-400)}`Also applies to: 126-127
🤖 Prompt for 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. In `@tests/hooks/observe-entrypoint-allowlist.test.js` around lines 103 - 114, The current brittle LAYER2_TRACE_MARKER string check in assertAllowedReachesLayer2 should be replaced with a regex-based assertion that matches the semantic "minimal = minimal" comparison across varying xtrace formats; update the code in assertAllowedReachesLayer2 (and the analogous check at lines ~126-127) to build a RegExp like /\bminimal\s*=\s*minimal\b/ (allowing optional surrounding brackets/quotes and whitespace) and assert that result.stderr.match(...) is truthy so the test is robust across Bash/xtrace variations; keep runObserve usage and error messages but swap the exact-string include checks for the regex match.
43-47: ⚡ Quick winReplace direct
console.logusage in the edited test file.Line 43, Line 46-47, Line 131, and Line 148-149 use
console.log. Please switch to a test logger/helper (orprocess.stdout.write) so this follows repository JS logging rules consistently.As per coding guidelines, "Warn about
console.logstatements in edited files".Also applies to: 131-132, 148-149
🤖 Prompt for 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. In `@tests/hooks/observe-entrypoint-allowlist.test.js` around lines 43 - 47, Replace direct console.log calls used in the test's try/catch reporter (the lines that print ` ✓ ${name}`, ` ✗ ${name}`, and the error message using `err.message`) with the project's test logger or process.stdout.write; locate the usages that reference the local variables `name`, `passed`, and `err` and swap each console.log to the shared test logging helper (or call process.stdout.write with the same formatted strings) so logging follows repository JS logging rules across all occurrences in this test.
🤖 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.
Nitpick comments:
In `@tests/hooks/observe-entrypoint-allowlist.test.js`:
- Around line 57-61: The empty catch around fs.rmSync(dir, { recursive: true,
force: true }) swallows cleanup errors; update the catch to explicitly handle
and surface failures (e.g., log with console.error or the test logger) including
the directory name and error object so failures are diagnosable, or rethrow if
appropriate for the test; locate the try/catch that wraps fs.rmSync for variable
dir in tests/hooks/observe-entrypoint-allowlist.test.js and replace the silent
ignore with an explicit error handling statement that records the error details.
- Around line 103-114: The current brittle LAYER2_TRACE_MARKER string check in
assertAllowedReachesLayer2 should be replaced with a regex-based assertion that
matches the semantic "minimal = minimal" comparison across varying xtrace
formats; update the code in assertAllowedReachesLayer2 (and the analogous check
at lines ~126-127) to build a RegExp like /\bminimal\s*=\s*minimal\b/ (allowing
optional surrounding brackets/quotes and whitespace) and assert that
result.stderr.match(...) is truthy so the test is robust across Bash/xtrace
variations; keep runObserve usage and error messages but swap the exact-string
include checks for the regex match.
- Around line 43-47: Replace direct console.log calls used in the test's
try/catch reporter (the lines that print ` ✓ ${name}`, ` ✗ ${name}`, and the
error message using `err.message`) with the project's test logger or
process.stdout.write; locate the usages that reference the local variables
`name`, `passed`, and `err` and swap each console.log to the shared test logging
helper (or call process.stdout.write with the same formatted strings) so logging
follows repository JS logging rules across all occurrences in this test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c9e4b598-50f4-4623-9044-4304c1a3cbd1
📒 Files selected for processing (2)
skills/continuous-learning-v2/hooks/observe.shtests/hooks/observe-entrypoint-allowlist.test.js
…affaan-m#2134) The observe.sh Layer 1 entrypoint guard short-circuits with exit 0 when CLAUDE_CODE_ENTRYPOINT is not in {cli, sdk-ts, claude-desktop}. Claude Code's VS Code extension sets CLAUDE_CODE_ENTRYPOINT=claude-vscode, so VS Code users see no observations recorded — observations.jsonl never gets created and the instinct pipeline stays empty. Add claude-vscode to the allowlist, mirroring the precedent in affaan-m#1522 which added claude-desktop the same way. Add a regression test that spawns observe.sh under bash -x for each allowed entrypoint (cli, sdk-ts, claude-desktop, claude-vscode) and each denied entrypoint (unknown-host, claude-cody, mcp), asserting that allowed entrypoints reach Layer 2's ECC_HOOK_PROFILE check while denied entrypoints stop at Layer 1. Fixes affaan-m#2102
Summary
The
continuous-learning-v2/observe.shLayer 1 entrypoint guard short-circuits withexit 0whenCLAUDE_CODE_ENTRYPOINTis not in{cli, sdk-ts, claude-desktop}. Claude Code's VS Code extension setsCLAUDE_CODE_ENTRYPOINT=claude-vscode, so VS Code users see no observations recorded —observations.jsonlis never created and the downstream instinct/pattern pipeline stays empty.This PR adds
claude-vscodeto the allowlist alongside the existing entries, mirroring the precedent in #1522 (which addedclaude-desktopfor exactly the same reason). The change is a single-token addition on one line ofskills/continuous-learning-v2/hooks/observe.sh.A new regression test (
tests/hooks/observe-entrypoint-allowlist.test.js) pins the allowlist by spawningobserve.shunderbash -xfor each entrypoint value and asserting that allowed entrypoints reach Layer 2'sECC_HOOK_PROFILEcheck while denied entrypoints stop at Layer 1.Verification
node tests/hooks/observe-entrypoint-allowlist.test.js— 7/7 pass (4 allowed entrypoints reach Layer 2; 3 denied entrypoints stop at Layer 1).node tests/run-all.js— full suite green locally.node scripts/ci/validate-skills.js— pass.npx eslint scripts/**/*.js tests/**/*.js— pass.npx markdownlint-cli '**/*.md' --ignore node_modules— pass.claude-vscode reaches Layer 2to fail, confirming the test pins the allowlist.Fixes #2102
Summary by cubic
Allow
claude-vscodeas a validCLAUDE_CODE_ENTRYPOINTsocontinuous-learning-v2/observe.shno longer exits early for VS Code users. Fixes #2102 by ensuring observations are recorded andobservations.jsonlis created.claude-vscodeto the Layer 1 entrypoint allowlist inskills/continuous-learning-v2/hooks/observe.sh.tests/hooks/observe-entrypoint-allowlist.test.js) to pin the allowlist and verify allowed entrypoints reach Layer 2 (ECC_HOOK_PROFILE).Written for commit 08aacc8. Summary will update on new commits.
Summary by CodeRabbit
New Features
Tests