Repository navigation
Description
Problem
When the exec agent encounters a private (non-exported) function that needs testing, it falls back to writing "documentation-style" tests — local variable assertions that mirror the logic but never call the real function. This produces tests that always pass but catch zero regressions.
Issue #267's executePhaseWithRetry was private, so the exec agent wrote tests like:
const mcpEnabled = true;
const phaseFailed = true;
expect(mcpEnabled && phaseFailed).toBe(true);The fix was to export the function with @internal JSDoc and use dependency injection (executePhaseFn parameter) so tests could mock the inner dependency and call the real function.
Root cause
The exec skill has no guidance for this scenario. When a function can't be imported, the agent improvises — and the path of least resistance is tautological tests that make the test count look right.
Proposed Solution
Add guidance to the exec skill for handling non-exportable functions:
Decision tree for the exec agent
Function needs tests but is not exported?
├── Can it be exported with @internal tag? → Export it, test directly
├── Can a dependency be injected for mocking? → Add optional param, test with mock
├── Can the behavior be tested via a public caller? → Write integration test through the public API
└── None of the above? → Document why tests are limited, do NOT write tautological tests
Explicit anti-pattern warning
Add to exec skill:
NEVER write tests that only assert on local variables. If a test block does not call any imported function, it is tautological and provides no regression protection. If you cannot test a function directly, escalate to integration testing or export with @internal — do not fake the test.
Pattern library
Provide examples of each approach:
- Export with @internal:
/** @internal Exported for testing */
export function privateHelper(...) { ... }- Dependency injection:
export function retry(
...,
executeFn = executePhase, // injectable for tests
) { ... }- Integration test through public API:
it("retries on cold-start failure", async () => {
// Test via runCommand() which internally calls executePhaseWithRetry
const result = await runCommand({ ... });
expect(result.exitCode).toBe(0);
});Acceptance Criteria
- AC-1: Exec skill includes decision tree for testing non-exported functions
- AC-2: Exec skill explicitly warns against tautological tests (local-variable-only assertions)
- AC-3: Exec skill provides code examples for @internal export, dependency injection, and integration testing patterns
- AC-4: If exec agent cannot test a function directly, it must document the limitation rather than writing fake tests
Context
- Origin: QA finding on fix: sequant run fails on first execution, succeeds on retry (cold-start race) #267 — tautological tests for
executePhaseWithRetry - Related: fix: sequant run fails on first execution, succeeds on retry (cold-start race) #267 (MCP fallback retry)
- Related: Test tautology detector issue (complementary — detection vs prevention)
Activity
admarble commentedon Feb 20, 2026
📋 Spec Plan for Issue #300
AC Quality Check
✅ All 4 acceptance criteria are clear and testable.
Scope Assessment
Verdict:⚠️ SCOPE_WARNING - Non-Goals section missing. Quality loop auto-enabled.
Suggested Non-Goals:
Acceptance Criteria with Verification
Implementation Plan
File to modify:
.claude/skills/exec/skill.mdPhase 1: Add New Section
### 3e. Testing Non-Exported Functions (REQUIRED)after section 3d (Lint Check)Phase 2: Content
2. Decision tree (AC-1):
Anti-pattern warning (AC-2): Bold callout with example from fix: sequant run fails on first execution, succeeds on retry (cold-start race) #267
Pattern library (AC-3): Three TypeScript examples
@internalexportDocumentation fallback (AC-4): Template for limitation docs
Phase 3: Integration
6. Cross-reference from existing test sections
7. Verify lint passes
Recommended Workflow
Phases: exec → qa
Quality Loop: enabled (auto-enabled due to scope warning)
Assumptions to Validate
Implementation Readiness
Status: ✅ READY
.claude/skills/exec/skill.md)Worktree: Already created at
feature/300-feat-add-exec-skill-guidance-for-non-exportable-fufeat(#300): add exec skill guidance for testing non-exported functions
admarble commentedon Feb 20, 2026
🚀 Exec Phase Complete
AC Coverage Summary
Files Changed
.claude/skills/exec/SKILL.md- Added section 3e "Testing Non-Exported Functions (REQUIRED)" (+146 lines)Quality Checks
npm run buildnpm run lintnpm testQuality Plan Alignment
N/A - No quality plan in issue (no
/specquality planning section found)Test Coverage Analysis
.claude/skills/exec/SKILL.mdCoverage: Documentation-only change; no code tests needed.
PR Status
✅ Created: #312
Next Steps
/qato verify all AC are satisfiedadmarble commentedon Feb 20, 2026
QA Review for Issue #300
AC Coverage
Coverage: 4/4 AC items fully met
Quality Plan Verification
N/A - No quality plan found in issue comments
CI Status
build (18.x)build (20.x)build (22.x)validate-skillstypecheckvalidate-pluginCI Summary: 3 passed, 3 pending, 0 failed
CI-related AC items: None (no CI-specific AC items in this issue)
Quality Metrics
any)Code Review
Strengths:
Issues:
Test Coverage Analysis
.claude/skills/exec/SKILL.mdCoverage: Documentation-only change; no code tests needed
Skill Command Verification
Skill files changed: 1 (
.claude/skills/exec/SKILL.md).claude/skills/exec/SKILL.mdNote: The new section contains only instructional content and TypeScript code examples. No new CLI commands were added.
Self-Evaluation
Verdict: NEEDS_VERIFICATION
All 4 acceptance criteria are fully met. The implementation is clean, well-structured, and matches the issue specification exactly. However, 3 CI checks (build matrix 18.x, 20.x, 22.x) are still in progress. The verdict will upgrade to READY_FOR_MERGE once CI completes.
Next Steps
/qa 300after CI passes to confirm READY_FOR_MERGEQA completed: All AC met, awaiting CI completion
admarble commentedon Feb 22, 2026
Merged via feat(#300). Non-exportable function testing guidance added to exec skill.
feat(#300): add exec skill guidance for testing non-exported functions
fix(#300): clarify Pattern 2 DI example — acknowledge export requirement
feat(#300): Add exec skill guidance for non-exportable function testi…
admarble commentedon Feb 22, 2026
Documentation Review Complete
This issue contains documentation-only changes. No additional documentation generation required.
Files Modified:
.claude/skills/exec/SKILL.md— Added section 3e: Testing Non-Exported Functions (decision tree, anti-pattern warning, 4 patterns with code examples)Status:
✅ Documentation changes are ready for review and merge.
Ready to merge!
docs: update changelog and what-weve-built for #299 and #300
chore: release v1.17.0