Summary
This issue documents the comprehensive test suite development for opencode-acp, covering the period from the initial ACP rebrand through the msgid expansion PR (#1).
Test Suite Growth
| Phase |
Tests |
Files |
Commit |
| Baseline (existing from DCP fork) |
95 |
10 |
d5f1540 |
| Tier 1: Pure function unit tests |
+83 |
+6 |
04105e2 |
| Tier 2: Mock-data unit tests |
+68 |
+4 |
7471a1b |
| Functional: Compress pipeline tests |
+77 |
+3 |
90b8c00 |
| E2E: Full pipeline tests |
+21 |
+2 |
7268202 |
| Review fixes + backward compat |
+4 |
0 |
17aa4c1, f0cf9d1 |
| Total |
350 |
22 |
— |
New Test Files (12)
Tier 1 — Pure Function Tests (no dependencies, no mocks)
| File |
Tests |
Source Module |
config-validation.test.ts |
~18 |
lib/config-validation.ts — extracted pure validation |
priority-classify.test.ts |
~15 |
lib/priority.ts — message classification |
shape.test.ts |
~12 |
lib/shape.ts — token estimation |
query-pure.test.ts |
~14 |
lib/query.ts — context query logic |
gc-truncate-pure.test.ts |
~12 |
lib/gc/truncate.ts — GC truncation params |
state-utils-pure.test.ts |
~12 |
lib/state/utils.ts — state utilities |
Tier 2 — Mock-Data Tests
| File |
Tests |
Source Module |
query-mock.test.ts |
33 |
lib/query.ts — with mock messages |
gc-truncate-mock.test.ts |
11 |
lib/gc/truncate.ts — with mock state |
strategies-dedup.test.ts |
12 |
lib/strategies/dedup.ts — dedup strategy |
strategies-purge-errors.test.ts |
12 |
lib/strategies/purge-errors.ts — error purging |
Functional — Compress Pipeline
| File |
Tests |
Source Module |
compress-search.test.ts |
22 |
lib/compress/search.ts — boundary resolution |
compress-state.test.ts |
21 |
lib/compress/state.ts — block allocation |
message-ids.test.ts |
34 |
lib/message-ids.ts — ID formatting/parsing/assignment |
E2E — Full Pipeline
| File |
Tests |
Coverage |
e2e-message-transform.test.ts |
11 |
Full hooks pipeline: filtering, hallucination stripping, compression blocks, pruning, manual trigger, persistence |
e2e-blocks-nudges.test.ts |
10 |
Nudge injection, block aging, session switch, tool part IDs, block consumption |
Key Quality Improvements
Bug Fixes Found Through Testing
resetOnCompaction didn't clear messageIds (lib/state/utils.ts) — production bug caught by test review
purgeErrors.turns < 1 validation was lost during extraction — restored
Review-Driven Fixes
Backward Compatibility Tests
parseBoundaryId normalizes 4-digit refs to 5-digit
- Old persisted state with
m0001 keys migrates to m00001 on load
- Roundtrip stability: old format → parse → format → new format
Test Architecture
- Runner:
node --import tsx --test tests/*.test.ts (Node built-in test runner)
- Pattern:
node:test + node:assert/strict (no vitest/jest)
- Mocks: Manual factories (
buildConfig(), buildMessages(), textPart(), toolPart())
- CI: GitHub Actions — typecheck + test + build (Node 22/24 matrix)
Documentation
TESTING.md — 566 lines: running tests, framework, categories, coverage tables, writing guide
AGENTS.md — Updated with mandatory dual-agent review for code + tests
Summary
This issue documents the comprehensive test suite development for opencode-acp, covering the period from the initial ACP rebrand through the msgid expansion PR (#1).
Test Suite Growth
d5f154004105e27471a1b90b8c00726820217aa4c1,f0cf9d1New Test Files (12)
Tier 1 — Pure Function Tests (no dependencies, no mocks)
config-validation.test.tslib/config-validation.ts— extracted pure validationpriority-classify.test.tslib/priority.ts— message classificationshape.test.tslib/shape.ts— token estimationquery-pure.test.tslib/query.ts— context query logicgc-truncate-pure.test.tslib/gc/truncate.ts— GC truncation paramsstate-utils-pure.test.tslib/state/utils.ts— state utilitiesTier 2 — Mock-Data Tests
query-mock.test.tslib/query.ts— with mock messagesgc-truncate-mock.test.tslib/gc/truncate.ts— with mock statestrategies-dedup.test.tslib/strategies/dedup.ts— dedup strategystrategies-purge-errors.test.tslib/strategies/purge-errors.ts— error purgingFunctional — Compress Pipeline
compress-search.test.tslib/compress/search.ts— boundary resolutioncompress-state.test.tslib/compress/state.ts— block allocationmessage-ids.test.tslib/message-ids.ts— ID formatting/parsing/assignmentE2E — Full Pipeline
e2e-message-transform.test.tse2e-blocks-nudges.test.tsKey Quality Improvements
Bug Fixes Found Through Testing
resetOnCompactiondidn't clearmessageIds(lib/state/utils.ts) — production bug caught by test reviewpurgeErrors.turns < 1validation was lost during extraction — restoredReview-Driven Fixes
lib/config-validation.tsfromlib/config.ts— pure validation without jsonc-parser dependency, testable in isolationBackward Compatibility Tests
parseBoundaryIdnormalizes 4-digit refs to 5-digitm0001keys migrates tom00001on loadTest Architecture
node --import tsx --test tests/*.test.ts(Node built-in test runner)node:test+node:assert/strict(no vitest/jest)buildConfig(),buildMessages(),textPart(),toolPart())Documentation
TESTING.md— 566 lines: running tests, framework, categories, coverage tables, writing guideAGENTS.md— Updated with mandatory dual-agent review for code + tests