# ADR-057: CI Health — PR #616 Clippy Block & Nightly Slow-Test Timeout

- **Status**: 🟢 Accepted
- **Date**: 2026-06-11
- **Deciders**: Project maintainers
- **Related**: ADR-038 (Local CI Parity — Clippy/Tests), ADR-041 (Test Health
  Remediation), ADR-056 (Local Storage No Connection Pooling), PR #616,
  `plans/GOAP_CI_ANALYSIS_2026-06-11.md`,
  `plans/GOAP_PRE_EXISTING_ISSUES_FOLLOWUP_2026-06-09.md`

## Context

A repository-wide CI sweep on 2026-06-11 found:

- **1 open PR** (#616, auto-generated by Jules) with the PR CI suite red.
- **0 open issues.**
- The scheduled **Nightly Full Tests** run on `main` red.

### PR #616 — `perf(encoder): optimize cosine similarity calculation`

The substantive change (f32 accumulators + a single `sqrt`, in
`memory-core/src/embeddings/similarity.rs`) is fine. CI is blocked by the PR's
*test harness*, not its perf change:

```
error: this `MutexGuard` is held across an await point
  --> memory-mcp/src/bin/server_impl/storage.rs:294:13
```

To serialize env-var-mutating `#[tokio::test]`s, the PR added a
`static TEST_LOCK: parking_lot::Mutex<()>` and held its guard across
`initialize_*().await`. Under `cargo clippy --tests -- -D warnings` this trips
`clippy::await_holding_lock` and fails the **Quick Check** job. Because `CI`,
`Coverage`, `Security`, and `Performance Benchmarks` gate on Quick Check via
`lewagon/wait-on-check-action`, they all cascade to failure even though they
never ran their own logic. `Semver Check` independently exits 2.

The PR was also cut from a **stale `main`** and deletes several plans files that
landed afterward (`GOAP_MAINTENANCE_2026-06-10.md`,
`GOAP_REMOTE_ANALYSIS_2026-06-10.md`, `remote-repo-*-2026-06-10.md`, and ~51
lines of `GOAP_STATE.md`).

`main` itself is clippy-clean for this file — the violation exists only on the
PR branch.

### Nightly Full Tests (main)

- **Slow Tests**: `do-memory-core::async_extraction::should_scale_processing_with_different_worker_counts`
  hit nextest's 120s slow-timeout (`36 passed, 1 timed out`). The `#[ignore]`d
  test loops `worker_count ∈ [1,2,4,8]`, each iteration creates a new worker
  pool + 20 episodes + `sleep(3s)` without stopping prior pools; it prints the
  `workers=1` result then stalls.
- **Full Test Suite**: exit 95 immediately after an `Insufficient disk space
  (<5G)` runner pre-check — infrastructure, not code.
- **Mutation Testing**: hit the 2h job ceiling (expected for cargo-mutants).

### Missing implementation (carried backlog)

WG-156–162 stubs remain on `main` (e.g. `query_hits: 0, // Not yet implemented`
in `memory-storage-turso/src/cache/wrapper.rs:142`). No `todo!`/`unimplemented!`
macros exist. These are already tracked.

## Decision

1. **Classify PR #616 as blocked by a test-harness clippy violation, not by its
   perf change.** Remediation: replace the `parking_lot::Mutex` guard-across-await
   with `tokio::sync::Mutex` (`.lock().await`) or release the guard before each
   `.await`; rebase onto current `main`; restore the deleted plans files. The
   perf change to `similarity.rs` may merge once the harness is clippy-clean.
2. **Classify the Nightly failure as independent of PR #616.** The
   `should_scale_*` timeout is a real (but `#[ignore]`d, nightly-only) slow-test
   defect to be bounded by stopping pools between iterations and/or draining via
   a poll loop instead of a fixed sleep. The disk-space exit-95 and the mutation
   2h ceiling are infrastructure limits, not regressions.
3. **Keep WG-156–162 on the existing follow-up plan;** no scope added this sweep.

## Consequences

**Positive**
- Clear separation: the PR's perf work is decoupled from its harness defect, so
  reviewers can re-task/fix narrowly instead of rejecting the optimization.
- Nightly red is explained and won't block PR merges (PR CI excludes the
  `#[ignore]`d slow test).
- Documentation regression in PR #616 is flagged before any merge.

**Negative / risks**
- Bot-generated PRs cut from stale bases will keep re-introducing plans deletions
  and clippy-in-tests issues unless the generation prompt / branch base is fixed.
- The slow-test timeout persists on nightly until A3 lands.

**Follow-up actions** (tracked in `plans/GOAP_CI_ANALYSIS_2026-06-11.md`):
A1 clippy fix → A2 rebase+restore plans → A3 bound slow test → A4 nightly disk
headroom → A5 backlog unchanged.
