Mock to internals migration

From ZaxbyHub/opencode-swarm · View interactive version

Mock to internals migration is an AI agent skill from the GitHub repository ZaxbyHub/opencode-swarm. Codex canon for migrating opencode-swarm tests away from Bun mock.module leakage toward _internals dependency-injection seams. Use when touching tests with mock.module, adding test seams, fixing Bun mock isolation failures, or updating source modules for injectable internals.

How to use this skill

Skill file

Mock To Internals Migration

This is the canonical Codex migration protocol (self-contained since the #2966

retired-generated-skill reconciliation; it previously delegated to a retired

generated fork). The host-agnostic rules live in AGENTS.md invariant 7 and

.opencode/skills/writing-tests/SKILL.md; this canon carries the migration's own

procedure and checks.

Required Procedure

separate tool-map constant, a conditional merge in src/agents/index.ts, and

gating tests verifying BOTH the disabled and enabled states.

refactored or extracted (the symbol may have moved).

declaring the conversion complete.

mock.module return object that must remain (Node built-ins especially).

a new mock.module target — mock.module leaks across test files in Bun's

shared test-runner process (AGENTS.md invariant 7; the allowlist is closed by

bun run check:invariants Check 4).

layers.

baseline.

not just the build.

Forbidden Shortcuts

tests before the change.

Reviewer Checks

after barrel changes.

confirming the output equals the single-call output.

marking introduced_by_pr verdicts.

Test Engineer Checks

Also load:

  1. .agents/skills/writing-tests/SKILL.md
  2. .agents/skills/engineering-conventions/SKILL.md if the seam touches

runtime-sensitive code

Codex-specific execution notes:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.