Skip to content

[JUM-821][Test] Cover remaining branch gap for the full-matrix floor - #336

Merged
web2solutions merged 2 commits into
devfrom
kimi/test/JUM-821-coverage-branches-round3
Sep 14, 2026
Merged

web2solutions merged 2 commits into
devfrom
kimi/test/JUM-821-coverage-branches-round3

Conversation

@web2solutions

@web2solutions web2solutions commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Terceira e última rodada de desbloqueio da promoção dev → main (JUM-821, PR #327). A run anterior da #327 passou em tudo exceto coverage: branches: 97.80% < 98% no CI (Linux). Esta PR cobre +37 branch paths com testes funcionais dual-runner, mirando sobretudo código novo que entrou por merges paralelos sem gate de cobertura (metricsQuery/purgeTombstones de JUM-787/804, purgeStores, branches de tombstone-restore de RestAPI.ts) — levando a medição merged local a branches 98.66% (statements 99.86%, lines 99.89%, functions 99.78%).

Problem Statement

Project Tracking (Required)

Branch Promotion Path (Required)

  • Source branch: kimi/test/JUM-821-coverage-branches-round3
  • Target branch: dev
  • Required PR title format: [JUM-XXXX][Nature] <concise outcome>
  • The leading JUM-XXXX matches the single Linear Issue declared above.
  • This task PR targets dev.
  • If this PR targets main, it is a release promotion sourced from dev, references the task PRs/issues already merged into dev, and introduces no unreviewed changes. (Não se aplica: este PR mira dev.)
  • This PR is not a direct task/topic branch promotion to main.

Bidirectional Traceability (Required)

  • Every linked issue already contains this PR URL. (Project Updates do épico cobrem esta frente.)
  • Every linked issue already contains commit hash/range evidence. (Commit desta branch cita JUM-821.)
  • PR description includes mapping of task -> commit(s).
  • Task -> commit(s) mapping:
    • JUM-821: commit desta branch (ver log do PR)

Scope of Change

Somente arquivos de teste (+ test-map.json regenerado). Nenhum código de produção alterado.

Domain / Business Rules

  • packages/persistence-contracts/test/: metricsQuery.test.ts (+6: séries month/week/day, datas inválidas, contrato field/interval, tombstone ''), purgeTombstones.test.ts (+3: deletedAt não-parseável/Date/epoch, hardDelete false, defaults), listQuery.test.ts (+1: sort _id).

Application / Use Cases

  • apps/backend-template/test/unit/: purgeStores.test.ts (novo — adaptPurgeStore com store real, dry-run vs commit, proteção de seed ids), InMemoryRelationalStore.test.ts (+2: hardDelete miss/refs stale, getByRelation com tombstones), RestAPI.test.ts (+1 describe: endpoint /internal/tombstones/purge — 403 non-loopback, loopback IPv4/IPv6-mapped, facade com defaults), AuthService.branches.test.ts (+3: lockout default 900s, logout sem jti, security vazio), entityModelManager.flows.test.ts (+2).

Adapters / Infrastructure

  • packages/sdk-rest-client/test/RestApiClient.test.ts (+4: roteamento x-service-id, fallback core, sem content-type, rejeição não-Error).
  • apps/service-management-api/test/unit/: CatalogDataRepositoryDefaults.test.ts (+1: driver mínimo), catalogCors.test.ts (+1: defaults).

API / Contracts (OpenAPI, DTOs, handlers, controllers)

  • Nenhuma mudança de contrato; testes pinam o contrato vigente do endpoint interno de purge de tombstones (loopback-only, dry-run).

Detailed Technical Changes

  1. Código novo de merges paralelos (JUM-787/804) entrou em dev sem medição de cobertura global (o gate barato de dev não mede) — esta PR paga exatamente essa dívida.
  2. 9 branches documentados como defesa morta estruturalmente inalcançável (ex.: purgeTombstones.ts:128 — evento sempre nasce de store existente; defaults internos de catalogCors.ts protegidos pelo caller) — não cobertos com teste artificial, por decisão explícita.
  3. Descoberta incidental (não alterada): parseInstant em purgeTombstones.ts usa Date.parse(String(value)), então deletedAt numérico (epoch ms) nunca é elegível a purge — teste pina o comportamento vigente; follow-up sugerido se não for intencional.

Architecture and Design Alignment

  • Domain logic remains inside domain/application layers.
  • Controllers/handlers do not instantiate repositories/services directly.
  • Ports/adapters boundaries are respected.
  • No new circular dependencies introduced.
  • Event publishing/listening flow remains consistent.

Security Impact

  • Security impact: nenhum código de produção alterado. Os testes pinam comportamento de segurança existente (endpoint de purge restrito a loopback, 403 para não-loopback).
  • Secrets handling reviewed: [x] Yes [ ] No [ ] N/A
  • Input/output sanitization reviewed: [ ] Yes [ ] No [x] N/A
  • AuthN/AuthZ impact: [ ] Yes [x] No
  • Data exposure risk (password/salt/token/PII): [ ] Yes [x] No
  • Sonar security findings addressed or unaffected: [x] Yes [ ] No

Data and Migration Impact

  • Data model impact: nenhum.
  • Migration required: [ ] Yes [x] No
  • Rollback strategy: revert do merge em dev.

Breaking Changes

None.

Acceptance Criteria

  • Feature/bug behavior matches expected functional outcome. (branches ≥ 98% com folga)
  • Error paths and edge cases are covered. (Objeto desta PR)
  • API contract changes (if any) are documented and validated. (Nenhuma)
  • Architecture boundaries remain enforced.
  • No regression in existing workflows. (265/265 suites, 337/337 browser)

Test Plan (Evidence)

Executado localmente no worktree (verbatim):

  • NODE_ENV=dev bun run test:coverage → Test Suites: 4 skipped, 265 passed, 265 of 269 total / Tests: 55 skipped, 3671 passed, 3726 total
  • bun run test:browser → All specs passed! 337/337 (22 specs, chrome)
  • bun run coverage:check → Coverage threshold check passed: statements 99.86%, lines 99.89%, functions 99.78%, branches 98.66%.
  • bun run test-map:check → OK (suites novas registradas)
  • Todas as suites novas/tocadas verdes também sob bun test (dual-runner, req 106/110)

Gate remoto desta PR (branch-gate) — pendente na criação:

  • pnpm run lint — via branch-gate remoto (pendente)
  • pnpm run deps:check-cycles — via branch-gate remoto (pendente)
  • pnpm run arch:check-boundaries — via branch-gate remoto (pendente)
  • pnpm run arch:check-users-legacy-imports — via branch-gate remoto (pendente)
  • pnpm run test:unit — via branch-gate remoto (pendente)
  • pnpm run oas:check-routes — via branch-gate remoto (pendente)
  • pnpm run build:dev — via branch-gate remoto (pendente)
  • pnpm run ci:smoke — via branch-gate remoto (pendente)
  • pnpm run ci:gate — via branch-gate remoto (pendente)

Coverage

  • Project coverage >= 95%: [x] Yes [ ] No — 99.86% statements / 98.66% branches (merged local); check remoto confirmará
  • Patch coverage >= 95%: [x] Yes [ ] No — patch é 100% testes
  • Codecov status passing: [ ] Yes [ ] No — pendente (check remoto)

SonarQube Cloud

  • Quality Gate passing: [ ] Yes [ ] No — pendente (scan desta PR)
  • New vulnerabilities introduced: [ ] Yes [x] No
  • New security hotspots reviewed: [ ] Yes [ ] No [x] N/A

Performance / Reliability Impact

No measurable impact — somente testes.

Observability

  • Logs updated: [ ] Yes [x] No
  • Metrics/Tracing updated: [ ] Yes [ ] No [x] N/A

Deployment and Rollout

Risks and Mitigations

  1. Risk: margem de branches ainda fina entre a medição local e o CI.
    Mitigation: alvo superado com folga (98.66% vs 98% exigido; CI anterior 97.80% + os +37 paths desta PR); dead branches documentados para referência futura.
  2. Risk: novos merges paralelos em dev introduzirem código descoberto antes da próxima run da [JUM-821][Release] Promote dev to main — public OSS rebind, frontend X-CRUD, service-management monitoring #327.
    Mitigation: watcher com merge imediato ao ficar verde; se o CI acusar regressão, nova rodada de cobertura.

Documentation Updates

  • README updated (if needed) — n/a
  • Additional docs updated (if needed) — n/a
  • Changelog updated/synced (pnpm run changelog:update) — hook de pre-commit regenera

Reviewer Checklist

  • Changes are clear and scoped.
  • Acceptance criteria are testable and satisfied.
  • Tests are sufficient for risk level. (Esta PR é exclusivamente testes)
  • Security and data impacts are addressed.
  • CI checks pass fully. (Pendente — condição de merge)

Note

Low Risk
Only tests, changelog, and test-map metadata change; behavior is pinned, not modified.

Overview
This PR is test-only work for JUM-821: it closes the remaining branch coverage gap under the 98% full-matrix gate (CI had been at 97.80% branches). No production code changes.

New and expanded unit tests target recently merged behavior that lacked coverage: tombstone purge (purgeStores, purgeTombstones, loopback-only /internal/tombstones/purge and purgeTombstones on RestAPI), in-memory store hardDelete/relation-index edge cases, metricsQuery series/validation/tombstone branches, listQuery _id sort fallback, RestApiClient x-service-id routing and error shapes, auth default lockout/logout/RBAC empty-security branches, entity model manager blank custom-domain fallbacks, catalog paging when the driver returns only total, and catalog CORS no-arg defaults. A new purgeStores.test.ts suite is registered in test-map.json (452 suites / 300 unit).

The Darwin disk I/O test is adjusted so cached dlopen failure assertions do not flake on collectedAt timestamps.

Reviewed by Cursor Bugbot for commit 2968c51. Bugbot is set up for automated code reviews on this repo. Configure here.

…(JUM-821)

- metricsQuery, purgeTombstones, purgeStores (JUM-787/804 code), RestAPI
  tombstone-purge branches, InMemoryRelationalStore hardDelete,
  RestApiClient routing, listQuery _id sort, AuthService branches,
  entityModelManager, CatalogDataRepository defaults, catalogCors
- +37 branch paths covered with functional dual-runner tests; 9 dead
  defensive branches documented instead of artificially covered
- test-map.json regenerated

Validated: jest 265/265 suites (3676 tests), browser 337/337,
coverage:check passed (statements 99.86%, lines 99.89%, functions
99.78%, branches 98.66%).
@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_3578c5ad-f002-4d71-b4be-7419bcb4c45e)

… (JUM-821)

The strict whole-object comparison crossed a millisecond boundary on CI
— the error cache is proven by dlopen running exactly once and both
calls surfacing the same failure code, not by identical collectedAt
timestamps (req 134).
@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_d7d2ab6f-c2a9-4510-816d-3b2fb06b05fe)

@sonarqubecloud

Copy link
Copy Markdown

@web2solutions
web2solutions merged commit 222811d into dev Sep 14, 2026
22 of 23 checks passed
@web2solutions
web2solutions deleted the kimi/test/JUM-821-coverage-branches-round3 branch September 14, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant