fix(observer): hook-resolver — Windows backslash path support

Code-review followup. TOOL_SCRIPT_RE didn't include \ in delimiter
char class — Windows-native commands like `node tools\foo.mjs` fell
through to inline:<sha> fallback. Added \ to char class + inner
[\/\] alternation, normalize match to forward-slash.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-23 13:19:53 +03:00
parent 4665c537e8
commit 7fdf0ba971
3 changed files with 13 additions and 5 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# Brain Status (auto-generated)
Last updated: 2026-05-23T10:10:13.940Z
Last updated: 2026-05-23T10:16:44.994Z
| Контролёр | Состояние | Детали |
|---|---|---|
@@ -8,12 +8,12 @@ Last updated: 2026-05-23T10:10:13.940Z
| C2 Cross-ref consistency | ✅ | [cross-ref-checker] OK — 0 drift in 4 files |
| C3 Observer-of-observer | ✅ | [observer-of-observer] OK — last read 0 week(s) ago |
| C4 Сигнальный статус | ✅ | This file (self-reference) |
| C5 Observer-coverage | ⚠️ | 142 episode(s) this month · Stop-hook + post-commit OK · 21 missed activation(s) — see /brain-retro |
| C5 Observer-coverage | ⚠️ | 143 episode(s) this month · Stop-hook + post-commit OK · 21 missed activation(s) — see /brain-retro |
| C6 Chain map sync | ✅ | [chain-map-checker] OK — 16 chains in sync |
## Метрики (информационные, не алерты)
- Observer evidence: 142 episodes this month, 0 observer_error markers, 64 PII matches before filter
- Observer evidence: 143 episodes this month, 0 observer_error markers, 64 PII matches before filter
- Legacy v1 episodes (not in factor analysis): 5
- Last /brain-retro: 0 day(s) ago
- Использование узлов: см. `/brain-retro` (раз в спринт). missed_activations: 21. **Неиспользованные узлы — не алерт, если профильной задачи не было** (Pravila §16.4 v1.36; capability-readiness; см. memory `feedback_brain_unused_tools_not_problem` — outside-repo memory store).
+2 -2
View File
@@ -13,7 +13,7 @@
import { createHash } from 'node:crypto';
const TOOL_SCRIPT_RE = /(?:^|[\s"'/])(tools\/[\w-]+\.(?:mjs|py|sh))/;
const TOOL_SCRIPT_RE = /(?:^|[\s"'/\\])(tools[\/\\][\w-]+\.(?:mjs|py|sh))/;
const NPX_RE = /(?:^|[\s"'])npx\s+(?:-y\s+)?([\w@/.-]+)/;
/**
@@ -33,7 +33,7 @@ function normalizeCommand(s) {
export function extractScriptName(command) {
const cmd = String(command || '');
const toolMatch = cmd.match(TOOL_SCRIPT_RE);
if (toolMatch) return toolMatch[1];
if (toolMatch) return toolMatch[1].replace(/\\/g, '/');
const npxMatch = cmd.match(NPX_RE);
if (npxMatch) return npxMatch[1];
const sha = createHash('sha256').update(normalizeCommand(cmd)).digest('hex').slice(0, 16);
+8
View File
@@ -31,6 +31,14 @@ describe('extractScriptName', () => {
const b = extractScriptName('node -e "process.exit(1);"');
expect(a).not.toBe(b);
});
it('extracts tools/X.mjs from Windows backslash path', () => {
expect(extractScriptName('node tools\\observer-stop-hook.mjs')).toBe('tools/observer-stop-hook.mjs');
});
it('extracts tools/X.mjs from full Windows abs path with backslashes', () => {
expect(extractScriptName('node C:\\path\\tools\\foo.mjs')).toBe('tools/foo.mjs');
});
});
describe('buildHookMap', () => {