Skip to content

feat: add lib/mock-gsd-agent.cjs with fake Task() agent stubs#259

Merged
snipcodeit merged 1 commit intomainfrom
issue/248-create-lib-mock-gsd-agent-cjs-with-fake-ta
Mar 6, 2026
Merged

feat: add lib/mock-gsd-agent.cjs with fake Task() agent stubs#259
snipcodeit merged 1 commit intomainfrom
issue/248-create-lib-mock-gsd-agent-cjs-with-fake-ta

Conversation

@snipcodeit
Copy link
Owner

Summary

Closes #248

Milestone Context

Milestone v6 — Local Testing & Simulation Framework
Phase Phase 47: Mock Infrastructure
GSD Route plan-phase
Depends on #247 (lib/mock-github.cjs) — PR #258

Changes

lib/mock-gsd-agent.cjs (new)

Core mock module that intercepts Task() spawns in tests.

API:

  • activate([scenario]) — activate with optional scenario override directory
  • deactivate() — restore state, preserve call log
  • spawnStub({ subagent_type, prompt, model, description }) — record spawn, return fixture output
  • getCallLog() — returns { subagent_type, prompt, model, description, output, timestamp }[]
  • clearCallLog() — reset call log without deactivating
  • setResponse(agentType, output) — inline override (highest precedence)
  • isActive() — guard check
  • getSpawnCount([agentType]) — total or filtered spawn count
  • assertSpawned(agentType) — throws AssertionError if agent type was not spawned

Fixture resolution order:

  1. Inline override (setResponse())
  2. Scenario fixture: test/fixtures/agents/<scenario>/<agent-type>.json
  3. Base fixture: test/fixtures/agents/<agent-type>.json
  4. Empty string (unknown type)

test/fixtures/agents/ (new)

Base fixture files for all 5 standard GSD agent types:

File Default Output
gsd-planner.json ## PLANNING COMPLETE response
gsd-executor.json ## EXECUTION COMPLETE response
gsd-verifier.json ## VERIFICATION PASSED response
gsd-plan-checker.json ## VERIFICATION PASSED response
general-purpose.json Comment classification JSON result

Test Plan

  • lib/mock-gsd-agent.cjs requires without error: node -e "require('./lib/mock-gsd-agent.cjs')"
  • All 9 exports present: activate, deactivate, spawnStub, getCallLog, clearCallLog, setResponse, isActive, getSpawnCount, assertSpawned
  • test/fixtures/agents/ has exactly 5 JSON files
  • spawnStub() records call with correct shape
  • Scenario override: scenario fixture takes precedence over base fixture
  • setResponse() inline override: overrides scenario and base fixtures
  • activate() resets call log and inline overrides
  • deactivate() preserves call log
  • getSpawnCount() returns total; getSpawnCount('gsd-planner') returns filtered count
  • assertSpawned('gsd-planner') passes after spawn; throws for unspawned type
  • spawnStub() throws with descriptive error before activate()

Smoke test run: 26/26 tests passed.

🤖 Generated with Claude Code

Implements a fake GSD agent runner for offline MGW pipeline testing.
The module intercepts Task() spawns, returns configurable fixture outputs,
and records spawn calls for assertion.

- lib/mock-gsd-agent.cjs: core mock module with activate/deactivate/
  spawnStub/getCallLog/setResponse/isActive/getSpawnCount/assertSpawned API
- test/fixtures/agents/: base fixture files for all 5 agent types
  (gsd-planner, gsd-executor, gsd-verifier, gsd-plan-checker, general-purpose)

API mirrors lib/mock-github.cjs (PR #258) for consistency:
- Same activate/deactivate/setResponse/getCallLog/isActive pattern
- Scenario support: test/fixtures/agents/<scenario>/ overrides base fixtures
- Inline overrides have highest precedence

Closes #248

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the core Changes to core library label Mar 6, 2026
snipcodeit pushed a commit that referenced this pull request Mar 6, 2026
Configures vitest as the primary test runner for the v6 Local Testing
& Simulation Framework (Phase 47: Mock Infrastructure, issue #249).

Changes:
- package.json: add vitest ^2.0.0 devDependency; npm test → vitest run;
  npm run test:watch → vitest; npm run test:node preserves existing
  node --test runner for .test.cjs files
- vitest.config.js: node environment, setupFiles: ['./test/setup.js'],
  includes .test.js/.spec.js, excludes .test.cjs (node:test incompatible)
- test/setup.js: auto-activates mock-github and mock-gsd-agent in
  beforeEach/afterEach; conditional require — works when PRs #258/#259
  are not yet merged to main; exports mockGitHub/mockGsdAgent
- test/loadFixture.js: loadFixture(name) helper that reads from
  test/fixtures/; supports namespaced paths (e.g. 'github/issue-view');
  throws descriptive errors on missing/invalid fixtures

Closes #249

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@snipcodeit snipcodeit merged commit 82ab664 into main Mar 6, 2026
4 of 5 checks passed
@snipcodeit snipcodeit deleted the issue/248-create-lib-mock-gsd-agent-cjs-with-fake-ta branch March 6, 2026 11:18
snipcodeit added a commit that referenced this pull request Mar 6, 2026
…260)

Configures vitest as the primary test runner for the v6 Local Testing
& Simulation Framework (Phase 47: Mock Infrastructure, issue #249).

Changes:
- package.json: add vitest ^2.0.0 devDependency; npm test → vitest run;
  npm run test:watch → vitest; npm run test:node preserves existing
  node --test runner for .test.cjs files
- vitest.config.js: node environment, setupFiles: ['./test/setup.js'],
  includes .test.js/.spec.js, excludes .test.cjs (node:test incompatible)
- test/setup.js: auto-activates mock-github and mock-gsd-agent in
  beforeEach/afterEach; conditional require — works when PRs #258/#259
  are not yet merged to main; exports mockGitHub/mockGsdAgent
- test/loadFixture.js: loadFixture(name) helper that reads from
  test/fixtures/; supports namespaced paths (e.g. 'github/issue-view');
  throws descriptive errors on missing/invalid fixtures

Closes #249

Co-authored-by: Stephen Miller <Stephen@betterbox.pw>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create lib/mock-gsd-agent.cjs with fake Task() agent stubs

1 participant