Coverage gate #
The pre-commit hook runs npm run test:coverage and requires 100% line,
statement, function, and branch coverage per file. The committed scope is the
portable core boundary in src/utils/**/*.ts, src/types/**/*.ts, the
metadata services boundary (heading-slug, extract-metadata,
metadata-cache, metadata-cache-persistence), the service layer
(derived-index-engine, derived-index-persistence, document-manager,
file-index, background-indexer, search-service,
search-index-persistence, file-stat-from-history, fuzzy-score,
image-resolver, tab-awareness, url-router, vault-root-url), and the
sync layer (heads, sync-server-config, sync-connection-status), and the format-preservation utilities (hash, lezer, value-blob,
synthesis-cache, registry, core-registry, reconcile-context,
mark-emitter), and the
automerge-markdown core (mutation-context, paste-bounded, errors,
markdown-analysis, claim-set, phase0, markdown-block-analysis,
rich-text-projection, native-block-operations); type declarations are not
executable and are excluded. The layout layer covers gesture-command-utils,
gesture-settings, layout-state, layout-persistence,
sidebar-leaf-persistence, search-create, create-item-path,
file-tree-utils, and file-tree-persistence; type declarations are not
The metadata tests cover Markdown normalization, duplicate disambiguation,
fragment lookup, frontmatter parsing, code-range detection, section building,
link/embed/tag/heading/footnote extraction, backlink resolution, display
titles, resolved links, and IndexedDB persistence. The service layer tests
cover CRDT document management, derived index engine work generation and
snapshot coherence, IndexedDB persistence, file index live subscription
reconciliation and timestamp wiring, background indexer scheduling,
retry/backoff, profiling, and persistence migration, MiniSearch full-text
search with filter predicates and defensive fallbacks for inconsistent state,
search index IndexedDB persistence with upgrade callbacks and malformed-data
validation, FileStat derivation from Automerge change history with clock-skew
defense and binary content support, fuzzy string scoring with tier ordering
and subsequence caps, image blob URL resolution with cache eviction and
concurrent deduplication, cross-tab awareness via BroadcastChannel
announce/ack/close protocol, URL hash fragment routing with foreign-doc
adoption and replaceState dedup, and vault root URL first-boot persistence.
The sync layer tests cover unordered Automerge heads comparison and
canonical key generation, sync-server URL resolution with localStorage/env
fallback and ws/wss scheme validation, and live WebSocket connection-status
registry with adapter hot-swap and pre-init URL suppression. The
format-preservation tests cover FNV-1a hashing, mark emission, Lezer markdown
parsing, mark value blob encoding/decoding with owner and version validation,
LRU-bounded synthesis cache with heads-keyed eviction, construct registry with
owner validation and reserved-name enforcement, core semantic registry
singleton caching, reconcile context with claim bounds and parsed-tree
resolution, and low-level mark-at-path emission with rich-text projection.
The legacy reconcile adapter, content-path mark emission wrapper, draft
coordinator, adapter schema vocabulary, and content-path block normalization
were relocated to tests/format-preservation/harness/legacy; the
characterization corpus that exercises them still runs, but those modules are
no longer part of the production coverage gate. The automerge-markdown tests
cover mutation context tracking with guarded mutations, paste range
validation, draft reconciliation error classification, markdown analysis
with deep-freeze cloning, claim set interval merging with kind promotion
and claim validation, and phase 0 cross-construct cleanup with shielded
range trimming and mark expansion preservation, and markdown block analysis
with prefix parsing, list/quote depth tracking, code fence shielding, and
continuation parent assignment, and rich-text projection with path
validation, coordinate guarding, mark expansion probing, block descriptor
decoding, mark peer splitting and merge, and visible text extraction, and native block operations with
compatibility checking, snapshot reconciliation, block stream updates,
and mutation context guarding. The layout layer tests cover gesture command
execution with user-facing notices, gesture settings localStorage
persistence with version migration and type-validated field fallbacks,
layout state sidebar/right-panel/editor mode transitions with toolbar offset
computation, layout persistence with v1-v5 schema migration and clamped
numeric fields, sidebar leaf persistence with v1-to-v2 migration and old
panel-views incorporation, search-create preview resolution and execute-time
re-resolution with template-backed and blank-file creation paths, file-tree
create-item path parsing with URL adoption and validation, file-tree utility
icon mapping and deprecated sort compatibility, and file-tree expanded
folder persistence with corrupted-data defense.
Performance smoke tests, browser invariants, and integration tests remain
separate executable lanes. They are excluded from instrumentation because V8
instrumentation changes timing and browser-only behavior. Run npm run test,
npm run test:perf, and npm run test:invariants for those lanes.
Reports are emitted to coverage/ in text, JSON, JSON summary, and HTML
formats. The scope should be expanded only when its functional tests can meet
the same four 100% thresholds without weakening the performance or browser
budgets.