# Gap analysis: implementation vs `activitix.spec.md`

Normative spec: [activitix.spec.md](./activitix.spec.md).

---

## Fully covered (including former “open” items)

| Area | Notes |
|------|--------|
| **Spy-style checks** | [`.tests/activitix-spy.test.ts`](../.tests/activitix-spy.test.ts): `completeRecord` → **one** `getByKey` after `startRecord` (cache-backed path); `patchRecord` with warm cache → **zero** `getByKey` (xronox-store cache branch); missing id → **`logger.warn('patchRecord: record not found')`** |
| **`patchRecord` + missing doc** | [Activitix.ts](../src/Activitix.ts) catches xronox-store’s **`no document for key`** error and warns without rethrowing (no extra `getByKey` on the hot path). **Coupling:** substring match on that message — if the store changes copy, adjust activitix + tests. |
| **Pre-extraction gaps** | Shared `XronoxStore`, cold `getRecord`/`patchRecord`, `generateRecordId`, exact stale count (`activitix-gaps.test.ts`), CI scaffold, `LICENSE`, `registry.npmrc`, `clean-spurious-dist.js` |

---

## Intentional deviations

| Topic | Notes |
|--------|--------|
| **`.tests-out/` + CJS tests** | Under `"type": "module"`; see [build-and-test.md](./build-and-test.md). |
| **Duration `startTime`** | `typeof startTime === 'number'` vs spec’s truthy check. |
| **`dotenv` / patch xronox-store version** | Practical vs literal spec snippet. |

---

## Still not automated (needs infra or product hooks)

| Item | Why it stays manual / future |
|------|----------------------------|
| **`close()` + retry queue “drain” under connection errors** | Requires **fault injection** (kill Mongo mid-flight, queue modes) and timing-dependent assertions; not reliable in a portable integration suite without a dedicated harness or xronox-store test hooks. |
| **`mongoRole`-only (nx-config2) smoke test** | Depends on **org-specific nx-config2** files and role names; would fail in a generic clone/CI. Run manually where nx is configured, or add an internal workflow that checks in minimal config fixtures. |

---

## Spec / tree drift (cosmetic)

Bundled **activitix.spec.md** §2–§3 may still list older test paths (`dist/.tests`) and omit `test:spy`, `test:all`, `registry.npmrc`, etc. Treat the repo as source of truth.

---

## Bottom line

What **could** be finished without bespoke infrastructure **is** finished (spy assertions, warn-on-missing patch, docs). What remains is **environment-dependent** (mongoRole + nx) or **chaos-style** (queue drain), which we deliberately leave out of the default test run so `npm run test:all` stays portable.
