Commit Graph

9 Commits

Author SHA1 Message Date
Magal 30742f1643 fix(memtrace): make MCP timeout detection accurate and reliable
- fail() no longer emits MEMTRACE_MCP_ERROR_TIMEOUT (STDERR-only)
- McpClient.spawn() wrapped with withTimeout(spawnPromise, TIMEOUT_MS)
- McpClient.sendRequest() wrapped with withTimeout(requestPromise, TIMEOUT_MS)
- runSingleQuery non-timeout catch uses inline console.error
- Add 7 new timeout-accuracy tests (39/39 pass)
- Fix 6 existing test assertions for non-timeout exit-1 paths
- Story 4.1 complete
2026-05-20 15:50:28 -03:00
Magal aecd1ac27b feat(story-4.2): implement autonomous server recovery workflow (Phase 2)
Created memtrace-restart.mjs: cross-platform MCP server recovery script that terminates stale processes and verifies server operability via MCP initialize handshake. Added npm script memtrace:restart. Created bmad-memtrace-recovery skill. Includes 8 tests, all passing with 32/32 adapter regression.
2026-05-20 10:52:25 -03:00
Magal 3a94cc4571 fix(adapter): apply code review patches for timeout detection reliability
- Add NaN date warning in checkIndexFreshness and queryListRepos
- Add --batch unsupported query pre-flight validation in main()
- Emit JSON error on freshness failure for non-list_repos queries
- Add STDERR warning when resolveRepoId falls back to 'project'
- Fix diagnostic catch block to process.exit(1) on failure
- Handle Windows root drive path in resolveRepoId
- Improve batch empty target expansion error message
- Add 4 new tests: unsupported batch query, env var fallback,
  auto-detection, all-failing batch
- 32/32 tests passing
2026-05-20 06:54:26 -03:00
Magal 72e293f346 feat(story-3.4): implement server concurrency throttling and freshness check
Add --check-freshness flag (index freshness gate blocking stale data),
--batch flag (sequential for...of query processing, anti-Promise.all),
and freshness metadata in list_repos output.

Code review patches applied:
- Reset 7 patch findings (AC #4 real diagnostic, null guards,
  shutdown separation, empty target validation)
- Resolved 3 deferred edge cases (Date.parse NaN, falsy 0, type guard)
- Resolved 4 pre-existing issues (infinite while-loop guard,
  resolveRepoId cross-platform, empty fallback, JSON error logging)

Closes story-3.4
2026-05-19 19:22:39 -03:00
Magal abd758e7ee feat(adapter): add hierarchical summarization via --summarize flag (Story 3.3)
Adds --summarize flag to memtrace-adapter.mjs for token-budgeted
hierarchical summarization of get_impact blast radius responses:
- summarizeBlastRadius(): groups by directory prefix, extracts depth<=2
  critical dependents, builds module impact with top symbols, enforces
  <=2000 token budget via progressive while-loop trimming
- estimateTokens(): chars/4 * 1.15 buffer safety margin
- Cross-platform path support (/[\\\\/]/ regex), NaN/Infinity depth guards
- Non-object entry guards, JSON.stringify try/catch
- total_critical field added for count transparency

Workflow files updated to use --summarize flag:
- bmad-dev-story/SKILL.md step 5, bmad-quick-dev step files
- bmad-code-review and gds-code-review auditors check for --summarize

6 summarization tests added. 42/42 tests passing (adapter 20 +
qa-memtrace 10 + validate-dead-code 12).
2026-05-19 18:41:01 -03:00
Magal bf572f945f fix(quality-gate): switch qa-memtrace to async readFile and fix coverage null guard (Story 2.3)
- Replace sync readFileSync with async readFile from fs/promises
- Fix blast radius empty check: total_count === 0 → affected_symbols.length === 0
- Fix null-safe coverage access: cov.startsWith → (mod.coverage || '').startsWith('Partial:')
- Add await to readJsonFile calls in main()
2026-05-19 17:51:20 -03:00
Magal ffb430ed99 feat(adapter): implement MCP query adapter with get_impact, list_repos, and find_dead_code (Stories 3.1-3.2)
- Add memtrace-adapter.mjs: standalone Node.js MCP client over stdio
  with 10000ms timeout, MEMTRACE_MCP_ERROR_TIMEOUT token,
  structured JSON output matching qa-memtrace.mjs contract
- Support --query get_impact (blast radius), --query find_dead_code
  (dead code detection with repo_id + file_path scoping),
  --query list_repos (index freshness)
- Add 14 automated tests: 9 CLI arg handling + 5 MCP integration
- Update dev-story SKILL.md step 5 to use adapter for blast radius
  and dead-code queries, with empty-results skip for pitfall validation
- Update quick-dev step-03-implement and step-oneshot workflows
- Extend code-review acceptance auditors with adapter usage verification
  and dead-code adapter check
- Fix raw memtrace_get_impact reference in SKILL.md (review patch)
2026-05-19 17:50:32 -03:00
Magal 792fb50745 feat(quality-gate): implement pitfall-catalog validation for dead code (Story 2.4)
Create pitfalls-catalog.json with 6 false-positive pattern categories for
find_dead_code. Implement validate-dead-code.mjs classification engine
(SUSPECT/FALSE_POS/GHOST) with 10s timeout, input validation, null
guards, file size/candidate caps, and unique test filenames.

Integrate as Step 5c in bmad-dev-story, bmad-quick-dev workflows, and
expand code-review Acceptance Auditors in bmad-code-review and
gds-code-review.

Code review patches applied: status conditional, TimeoutError class,
fail() scoped timeout token, JSON parse error context, single regex
compilation, null/type guards, MSW pattern fix, Ignored section for
FALSE_POS/GHOST in SKILL.md.

Tests: 12/12 validate-dead-code + 10/10 qa-memtrace passing.
2026-05-19 14:25:52 -03:00
Magal 79b3f7d9dc feat(quality-gate): implement mathematical blocking quality gate (Phase 2)
- Create qa-memtrace.mjs - standalone Node.js script computing set
  intersection of blast radius nodes vs test coverage, with 10s timeout
  and MEMTRACE_MCP_ERROR_TIMEOUT token emission
- Create qa-memtrace.test.mjs with 10 automated test cases
- Integrate mathematical gate into bmad-dev-story step 5, bmad-quick-dev
  step-03-implement and step-oneshot
- Expand bmad-code-review and gds-code-review Acceptance Auditors with
  mathematical gate ground-truth checks
- Fix .gitignore to track .agents/skills/ and _bmad/scripts/memtrace/
2026-05-19 14:00:56 -03:00