Why
Seven core GitHub Action scripts in .github/scripts/ lack dedicated test coverage:
agents-guard.js - Critical security guardrail for agents surface
agents_pr_meta_orchestrator.js - PR metadata coordination
keepalive_guard_utils.js - Keepalive safety utilities
keepalive_instruction_template.js - Prompt generation for keepalive
keepalive_orchestrator_gate_runner.js - Gate integration for orchestrator
keepalive_post_work.js - Post-keepalive cleanup operations
merge_manager.js - PR merge automation
These scripts handle critical workflow orchestration and security checks. Without tests, regressions can slip through undetected. The recent API retry integration (PR #151) highlighted how untested code paths can harbor subtle bugs.
Scope
Add comprehensive Node.js test files for the 7 untested scripts listed above. Each test file should:
- Live in
.github/scripts/__tests__/ following existing naming conventions
- Use Node.js built-in test runner (
node:test)
- Mock GitHub API calls and context objects
- Cover happy path, error handling, and edge cases
- Achieve >80% line coverage for the target script
Non-Goals
- Refactoring the scripts themselves (unless blocking testability)
- Adding Python test coverage (separate effort)
- Integration testing with live GitHub API
- Performance benchmarking
Tasks
Round 1: Security-critical scripts
Round 2: Orchestration scripts
Round 3: Keepalive utilities
Round 4: Merge automation
Acceptance criteria
- All 7 test files exist in
.github/scripts/__tests__/
- Each test file has at least 5 test cases covering core functionality
node --test .github/scripts/__tests__/*.test.js passes with 0 failures
- No regressions in existing tests (
Selftest CI workflow passes)
- New tests follow patterns established in existing test files (e.g.,
api-helpers.test.js)
Implementation notes
Files to create:
.github/scripts/__tests__/agents-guard.test.js
.github/scripts/__tests__/keepalive-guard-utils.test.js
.github/scripts/__tests__/agents-pr-meta-orchestrator.test.js
.github/scripts/__tests__/keepalive-orchestrator-gate-runner.test.js
.github/scripts/__tests__/keepalive-instruction-template.test.js
.github/scripts/__tests__/keepalive-post-work.test.js
.github/scripts/__tests__/merge-manager.test.js
Reference files for test patterns:
.github/scripts/__tests__/api-helpers.test.js (mocking patterns)
.github/scripts/__tests__/agents-belt-scan.test.js (context mocking)
.github/scripts/__tests__/detect-changes.test.js (GitHub API mocking)
Scripts to analyze for test design:
# View exports and public API of each script
grep -E "^(module\.exports|exports\.)" .github/scripts/agents-guard.js
grep -E "^(module\.exports|exports\.)" .github/scripts/keepalive_guard_utils.js
# ... etc
Testing
After each round of implementation:
-
Run new tests in isolation:
node --test .github/scripts/__tests__/<new-test>.test.js
-
Run full test suite:
node --test .github/scripts/__tests__/*.test.js
-
Verify CI passes on the PR
Why
Seven core GitHub Action scripts in
.github/scripts/lack dedicated test coverage:agents-guard.js- Critical security guardrail for agents surfaceagents_pr_meta_orchestrator.js- PR metadata coordinationkeepalive_guard_utils.js- Keepalive safety utilitieskeepalive_instruction_template.js- Prompt generation for keepalivekeepalive_orchestrator_gate_runner.js- Gate integration for orchestratorkeepalive_post_work.js- Post-keepalive cleanup operationsmerge_manager.js- PR merge automationThese scripts handle critical workflow orchestration and security checks. Without tests, regressions can slip through undetected. The recent API retry integration (PR #151) highlighted how untested code paths can harbor subtle bugs.
Scope
Add comprehensive Node.js test files for the 7 untested scripts listed above. Each test file should:
.github/scripts/__tests__/following existing naming conventionsnode:test)Non-Goals
Tasks
Round 1: Security-critical scripts
agents-guard.test.jswith tests for label validation, immutable surface checks, and bypass detectionkeepalive-guard-utils.test.jscovering pause label detection and guard state managementRound 2: Orchestration scripts
agents-pr-meta-orchestrator.test.jstesting body section updates and conflict resolutionkeepalive-orchestrator-gate-runner.test.jsfor gate status evaluation and dispatch logicRound 3: Keepalive utilities
keepalive-instruction-template.test.jsvalidating prompt generation and variable substitutionkeepalive-post-work.test.jstesting cleanup operations and state transitionsRound 4: Merge automation
merge-manager.test.jscovering merge eligibility, conflict detection, and squash behaviorAcceptance criteria
.github/scripts/__tests__/node --test .github/scripts/__tests__/*.test.jspasses with 0 failuresSelftest CIworkflow passes)api-helpers.test.js)Implementation notes
Files to create:
.github/scripts/__tests__/agents-guard.test.js.github/scripts/__tests__/keepalive-guard-utils.test.js.github/scripts/__tests__/agents-pr-meta-orchestrator.test.js.github/scripts/__tests__/keepalive-orchestrator-gate-runner.test.js.github/scripts/__tests__/keepalive-instruction-template.test.js.github/scripts/__tests__/keepalive-post-work.test.js.github/scripts/__tests__/merge-manager.test.jsReference files for test patterns:
.github/scripts/__tests__/api-helpers.test.js(mocking patterns).github/scripts/__tests__/agents-belt-scan.test.js(context mocking).github/scripts/__tests__/detect-changes.test.js(GitHub API mocking)Scripts to analyze for test design:
Testing
After each round of implementation:
Run new tests in isolation:
Run full test suite:
node --test .github/scripts/__tests__/*.test.jsVerify CI passes on the PR