test(coverage): scheduler + embed + generate tests; enforce coverage in CI#60
Merged
Conversation
…rce coverage in CI
Closes the 4 agent-memory audit gaps (2 MED + 2 LOW). Toolchain is node:test.
M1 agent-memory-sync cron scheduler: 28 tests for parseCron (wildcard/step/
range/list + 10 invalid-expr throws) and nextScheduleTick (step/range/list,
hour+day-of-week boundaries, month + year-end rollover, the 525600-iteration
cap), with exact-timestamp value assertions.
M2 memory-router embed/provider.ts: 11 tests stubbing global fetch for
embedBatch (ok -> exact URL/method/headers/body + sorted vectors; non-ok
429/500 -> throws; network + AbortError propagation; body-read fallback) and
resolveProviderConfig (missing key -> null, default/custom model, custom baseUrl).
L2 memory-digest-cli generate command: 8 tests for registerGenerateCommand
option parsing (6 defaults, overrides, boolean flags, short aliases).
L1 CI coverage enforcement: each package's test:coverage now passes
--test-coverage-{lines,branches,functions} thresholds (node:test native, src
only via --test-coverage-exclude); the CI step runs test:coverage so the gate
is enforced. Calibrated below measured, negative-control verified.
Also fixes two real CI gaps surfaced while wiring coverage:
- memory-router `test` glob `tests/**/*.test.ts` was unquoted, so the shell
expanded it to one-level subdirs and the 19 top-level tests/*.test.ts files
(tool, query-cache, ...) never ran in CI. Quoting it lets Node's native
glob run the full suite: 43 -> 231 tests now execute.
- agent-memory-sync scheduler test now loads src (under tsx) instead of dist,
so coverage measures source and the suite no longer depends on a prior build
(the package had no pretest:build). Switched the package to node --import tsx.
Refs: tc-audit-2026-06-27
…coverage Adversarial review (9/9 prod mutations killed) flagged that memory-router's coverage number double-counted dist + src: tests/coverage/real-corpus.test.ts loads ../../dist/*, and --test-coverage-exclude only dropped tests/**, so low-coverage compiled modules (drift.js 13%, applier.js 8%, ...) polluted the figure (65.28) the thresholds were calibrated against. - Add --test-coverage-exclude='dist/**' so the gate measures source only; true src coverage is 96.10/85.80/85.84, so recalibrated the thresholds to 90/80/80 (was 60/73/62, far too low). Negative-control verified. - Add pretest:coverage=npm run build so `npm run test:coverage` works on a fresh local checkout (real-corpus.test.ts requires dist; CI already had an explicit Build step so CI was unaffected). Pre-existing scheduler step=0 infinite-loop and the generate.ts action-body coverage are tracked in a follow-up (out of scope for this test PR). Refs: tc-audit-2026-06-27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the 4 agent-memory test-coverage audit gaps (2 MED + 2 LOW). Toolchain is node:test (node --test) with tsx.
test:coveragenow passes node:test native--test-coverage-{lines,branches,functions}thresholds (src only via--test-coverage-exclude), and the CI step runstest:coverageso coverage regressions fail the build. Calibrated below measured, negative-control verified.Two real CI gaps fixed while wiring coverage
tests/**/*.test.ts), so the shell expanded it to one-level subdirs and the 19 top-leveltests/*.test.tsfiles never ran in CI. Quoting it lets Node's native glob run the full suite: 43 -> 231 tests now execute.src/under tsx instead of compileddist/, so coverage measures source and the suite no longer silently depends on a prior build (the package had nopretest:build).Adversarial verify
Reviewer ran 9 prod-source mutations (all killed; no inert tests in the mutated paths) and confirmed both CI fixes. It flagged that memory-router's coverage number was double-counting
dist/(real-corpus.test.ts loads compiled output) — folded--test-coverage-exclude='dist/**', which revealed true src coverage is 96/86/86 and let me recalibrate the thresholds up to 90/80/80, plus addedpretest:coveragefor local dev. A pre-existing schedulerstep=0infinite-loop (validateCronExpression('*/0 * * * *')hangs) and the generate.ts action-body coverage are tracked in a MEDIUM follow-up (out of scope for a test PR).Refs: tc-audit-2026-06-27