/implement: Implementation + green loop (TDD step 5)
Replace the declare mocks with real code, keeping the surface identical, until all checks and tests are green.
When to run
- Previous step:
/unit-test(tests exist and a red run is recorded). - Next step:
/e2e. - Gate (exit):
vp run checkandvp run testboth green, signature parity confirmed.
Procedure
- Replace mocks in-place. In the feature's source file, replace each
declarestatement with its real implementation. Same file, same exports, same signatures. Keep the JSDoc written in/mock(update prose only if behavior details demand it).
- Implementation standards: Effect patterns throughout, tagged errors (the union declared in
/mock), Services/Layers for shared capabilities, Schema at unknown/I-O boundaries,pipe(effect, ...)preferred,Optionfor optionality,readonlydata, explicit type guards.Effect.genvspipeby readability. No JSX-style patterns.
- Signature-parity pass (explicit, not assumed). Diff the implemented exports against the mock surface committed in step 2:
- No export added, removed, or renamed.
- No signature changed (parameters, return types, generics, error union).
Typecheck alone does not catch additions or loosened types. Do this pass deliberately. Any deviation triggers the pause rule: stop implementing, return to /spec and /mock to update spec + surface (and /type-tests + /unit-test if affected), then resume here.
- Green loop. Repeat until both are clean:
1. vp check --fix: auto-fix formatting/lint (safe here: packages just packed by the run tasks).
2. vp run check: pack, then format/lint/typecheck. Must be green.
3. vp run test: pack, then run all node/jsdom tests. Every test from the red phase must now pass; no other test may regress.
Never use bare vp check / vp test as validation. They skip pack and report false cross-package errors (the pack rule).
- Hand off. Next step is
/e2e.
Rules
- Implementation must match mock signatures exactly and behavior must match
specs.md. - If implementation reveals mocks/specs need changes, apply the pause rule: update specs and mocks first, never drift silently.
- Fix the implementation to satisfy the tests; changing a test is only legitimate when the pause rule has first changed the spec it encodes.