1.12 Coverage gate + flaky-test stabilization (§2.3) #27

Closed
opened 2026-11-03 07:13:06 +01:00 by amiryahaya · 4 comments
Owner

Wire coverlet + ≥ 80% line-coverage gate into CI/pre-push; triage flaky backend tests.

Evidence at resume (2026-11-03): 26–29 failures varying between runs (677 total), SQLite 'FOREIGN KEY constraint failed' during seed/teardown (seed-ordering/cleanup races); pre-push hook tolerates them under a threshold; Debug-config 'dotnet test' broken on this machine (testhost 18.6.0 deps-manifest error — use 'dotnet run --project tests/SsdidDrive.Api.Tests/ -c Release' like the hook does). Baseline was 629/629 green in March.

Exit: coverage gate enforced ≥ 80% on API project; backend suite passes with ZERO tolerated failures for 3 consecutive runs.

Part of epic #2. Source: §5 (1.12) + §2.3

Wire coverlet + ≥ 80% line-coverage gate into CI/pre-push; triage flaky backend tests. **Evidence at resume (2026-11-03)**: 26–29 failures varying between runs (677 total), SQLite 'FOREIGN KEY constraint failed' during seed/teardown (seed-ordering/cleanup races); pre-push hook tolerates them under a threshold; Debug-config 'dotnet test' broken on this machine (testhost 18.6.0 deps-manifest error — use 'dotnet run --project tests/SsdidDrive.Api.Tests/ -c Release' like the hook does). Baseline was 629/629 green in March. **Exit**: coverage gate enforced ≥ 80% on API project; backend suite passes with ZERO tolerated failures for 3 consecutive runs. Part of epic #2. Source: §5 (1.12) + §2.3
Author
Owner

ROOT CAUSE FOUND by baseline review (#B-1, 08-code-baseline-review.md): the flakiness is NOT test infrastructure — fixtures are clean. Commit 997f657 (Mar 24) wired SsdidAuditSink.cs:36 to write audit rows with ActorId=Guid.Empty (FK violation vs users.id) fire-and-forget into the request-scoped DbContext → poisons handlers' awaited SaveChanges → intermittent 500s on wallet register/login paths. Today's run log: 371 audit_log FK failures + 51 provisioning 500s; March logs (pre-997f657) have none. Fix lands in #B-1; this task then verifies 3 consecutive zero-failure runs and wires the ≥80% coverage gate. Also: Debug dotnet test is broken because the project uses xunit.v3 MTP runner with no VSTest infra — use dotnet run -c Release (hook's invocation) until #B-1 follow-up adds UseMicrosoftTestingPlatformRunner.

**ROOT CAUSE FOUND by baseline review (#B-1, 08-code-baseline-review.md):** the flakiness is NOT test infrastructure — fixtures are clean. Commit 997f657 (Mar 24) wired SsdidAuditSink.cs:36 to write audit rows with ActorId=Guid.Empty (FK violation vs users.id) fire-and-forget into the request-scoped DbContext → poisons handlers' awaited SaveChanges → intermittent 500s on wallet register/login paths. Today's run log: 371 audit_log FK failures + 51 provisioning 500s; March logs (pre-997f657) have none. Fix lands in #B-1; this task then verifies 3 consecutive zero-failure runs and wires the ≥80% coverage gate. Also: Debug `dotnet test` is broken because the project uses xunit.v3 MTP runner with no VSTest infra — use `dotnet run -c Release` (hook's invocation) until #B-1 follow-up adds UseMicrosoftTestingPlatformRunner.
Author
Owner

Progress update (2026-11-04, commit d44329b) — coverage gate is LIVE, issue stays open until the 80% floor:

  • scripts/coverage-gate.sh: suite under coverlet, enforces zero tolerated failures AND a line-coverage floor on FailSulit.Api. Excludes EF migrations (35k generated designer/snapshot lines), top-level Program, and compiler-generated OpenApi helpers. Measured baseline: 74.7% Debug / 75.7% Release (700 tests).
  • Wired into the pre-push hook (replaces the retired <=140-failure tolerance — hook is now strictly zero-tolerance + coverage) and into api-ci.yml (push/PR triggers re-enabled, coverage step added).
  • Exit criterion "zero tolerated failures, 3 consecutive runs": met — 3 consecutive gated Release runs, 700/700, 75.65% each.
  • Exit criterion ">= 80% enforced": NOT yet — floor is live at the ratchet baseline (73, one-way). Remaining known gaps: OIDC verify/callback (~280 lines, needs a fake-IdP harness), EmailRegisterVerify (~65), GetRootFolderContents (~106 — also the #38 root-folder ownership bug area), HmacAuthMiddleware (~75).

Plan: close the four gaps test-by-test, ratcheting COVERAGE_MIN with each landed batch until the floor reaches 80, then close this issue.

**Progress update (2026-11-04, commit `d44329b`) — coverage gate is LIVE, issue stays open until the 80% floor:** - `scripts/coverage-gate.sh`: suite under coverlet, enforces zero tolerated failures AND a line-coverage floor on FailSulit.Api. Excludes EF migrations (35k generated designer/snapshot lines), top-level Program, and compiler-generated OpenApi helpers. **Measured baseline: 74.7% Debug / 75.7% Release (700 tests).** - Wired into the pre-push hook (replaces the retired <=140-failure tolerance — hook is now strictly zero-tolerance + coverage) and into `api-ci.yml` (push/PR triggers re-enabled, coverage step added). - **Exit criterion "zero tolerated failures, 3 consecutive runs": met** — 3 consecutive gated Release runs, 700/700, 75.65% each. - **Exit criterion ">= 80% enforced": NOT yet** — floor is live at the ratchet baseline (73, one-way). Remaining known gaps: OIDC verify/callback (~280 lines, needs a fake-IdP harness), EmailRegisterVerify (~65), GetRootFolderContents (~106 — also the #38 root-folder ownership bug area), HmacAuthMiddleware (~75). Plan: close the four gaps test-by-test, ratcheting `COVERAGE_MIN` with each landed batch until the floor reaches 80, then close this issue.
Author
Owner

Ratchet update (2026-11-04, PR #46 merged): floor raised 73 -> 78. Measured 78.7% Debug / 79.6% Release on 726 tests (was 74.7/75.7 on 700).

Closed gaps: GetRootFolderContents (5 tests), EmailRegisterVerify (9), HmacAuthMiddleware (12). Coverage work surfaced a real production bug — fixed via #44 (no-tracking user mutation broke personal-tenant persistence).

Remaining gap to the 80% exit: OIDC verify/callback (~280 lines, needs a fake-IdP harness) — that harness is the next chunk of work. Zero-tolerance + ratchet both enforced by the pre-push hook and (once the runner is healthy) api-ci.

**Ratchet update (2026-11-04, PR #46 merged):** floor raised **73 -> 78**. Measured **78.7% Debug / 79.6% Release** on 726 tests (was 74.7/75.7 on 700). Closed gaps: GetRootFolderContents (5 tests), EmailRegisterVerify (9), HmacAuthMiddleware (12). Coverage work surfaced a real production bug — fixed via #44 (no-tracking user mutation broke personal-tenant persistence). **Remaining gap to the 80% exit: OIDC verify/callback (~280 lines, needs a fake-IdP harness)** — that harness is the next chunk of work. Zero-tolerance + ratchet both enforced by the pre-push hook and (once the runner is healthy) api-ci.
Author
Owner

CLOSED — 80% exit gate satisfied. PR #48 (squash a2b2f0d): FakeIdpServer harness (in-process OIDC provider on HttpListener) + 19 flow tests covering authorize/callback/verify/link end-to-end over real HTTP. Prod seam: provider endpoints config-overridable; validator honors explicitly-configured http:// metadata and fails closed as 401 (garbage tokens previously leaked 500s).

Coverage: 82.51% Release / 81.77% Debug (746 tests, zero failures); floor raised 78 → 80. Suite green ×3 + pre-push hook green (build + tests + coverage gate). Flaky stabilization complete: hook is zero-tolerance and green.

**CLOSED — 80% exit gate satisfied.** PR #48 (squash `a2b2f0d`): FakeIdpServer harness (in-process OIDC provider on HttpListener) + 19 flow tests covering authorize/callback/verify/link end-to-end over real HTTP. Prod seam: provider endpoints config-overridable; validator honors explicitly-configured http:// metadata and fails closed as 401 (garbage tokens previously leaked 500s). **Coverage: 82.51% Release / 81.77% Debug (746 tests, zero failures); floor raised 78 → 80.** Suite green ×3 + pre-push hook green (build + tests + coverage gate). Flaky stabilization complete: hook is zero-tolerance and green.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/failsulit#27
No description provided.