Skip to content

feat(core): validazione dati e metriche di qualità - #37

Merged
ronzim merged 2 commits into
masterfrom
feat/17-validation-quality
Oct 14, 2026
Merged

ronzim merged 2 commits into
masterfrom
feat/17-validation-quality

Conversation

@ronzim

@ronzim ronzim commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Closes #17

Cosa aggiunge

Nuovo modulo packages/core/src/quality.ts, esportato da index.ts:

  • validateDataset(ds, { maxIssues }): controlla punti, voci della timeline e punti dei path. Segnala coordinate non finite o fuori range (lat ±90, lng ±180), timestamp mancanti o non validi e intervalli con fine prima dell'inizio. Restituisce il conteggio per motivo e i primi N problemi con indice.
  • sanitizeDataset(ds): restituisce un nuovo dataset senza punti e voci non validi; dai path toglie solo i punti non validi. Non modifica l'input, come i filtri.
  • computeQualityMetrics(ds, { gapThresholdMinutes, topGaps }):

CLI: --quality stampa validazione e metriche, --sanitize toglie gli elementi non validi prima di filtri ed export.

Test

Note

  • Le metriche ignorano i timestamp non validi, che vengono comunque segnalati da validateDataset.
  • Non c'è ancora integrazione nell'app desktop: si potrebbe mostrare la qualità nella sidebar, in una issue a parte.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CecUKcJiSVnehcZEiXLgtk

- validateDataset: coordinate (finite, lat ±90, lng ±180), timestamp,
  intervalli invertiti e punti dei path, con conteggio per motivo
- sanitizeDataset: nuovo dataset senza gli elementi non validi
- computeQualityMetrics: distribuzione dell'accuratezza, buchi nella
  timeline (o nei punti) e copertura dei path delle activity
- CLI: --quality e --sanitize
- test, incluso il test di regressione per #22 sulla copertura dei path

Closes #17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CecUKcJiSVnehcZEiXLgtk
Copilot AI balanced review requested due to automatic review settings October 14, 2026 06:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

sanitizeDataset removes points/entries but keeps the original dateRange, deviating from the filters' convention of recomputing it and leaving a potentially stale range observable via computeSummary.

2 open findings
What changed in this PR

This PR implements issue #17 by adding a new data-quality module to packages/core. It introduces validateDataset (flags out-of-range/non-finite coordinates, missing/invalid timestamps, reversed intervals, and invalid activity path points), sanitizeDataset (returns a new dataset with invalid items removed, mirroring the filters' immutability), and computeQualityMetrics (accuracy distribution, overlap-aware timeline gaps, and activity path coverage — the metric intended to surface loader bugs like #22). The functions are wired into the public API and the CLI via new --quality and --sanitize flags, and are covered by new unit and CLI tests.

Changes:

  • New quality.ts module with validation, sanitization, and quality-metrics functions, re-exported from index.ts.
  • CLI gains --quality (prints validation + metrics) and --sanitize (drops invalid items before filtering/export), with a dedicated printQuality formatter.
  • 18 new tests (quality + CLI), including a #22 regression asserting 100% activity path coverage on the real-format fixture.
File Description
packages/​core/​src/​quality.ts New module: validateDataset, sanitizeDataset, computeQualityMetrics and supporting types/helpers.
packages/​core/​src/​cli.ts Adds --quality and --sanitize flags, printQuality output, and sanitize step in the load pipeline.
packages/​core/​src/​index.ts Re-exports the new quality API and types.
packages/​core/​tests/​quality.test.ts Unit tests for validation, sanitization, and metrics incl. #22 regression.
packages/​core/​tests/​cli.test.ts CLI tests for --quality and --sanitize.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/core/src/quality.ts Outdated
const path = (e.path ?? []).filter(isValidPathPoint);
return path.length === e.path?.length ? e : { ...e, path };
});
return { ...dataset, points, timeline };
Comment thread packages/core/src/cli.ts Outdated
const before = ds.points.length + ds.timeline.length;
ds = sanitizeDataset(ds);
const removed = before - ds.points.length - ds.timeline.length;
spinner.succeed(`Sanitized — ${removed} invalid items removed`);
…io CLI

Dalla review di Copilot sulla PR #37.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CecUKcJiSVnehcZEiXLgtk
@ronzim
ronzim merged commit 601d3fe into master Oct 14, 2026
7 checks passed
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.

Validazione dati e metriche di qualità

3 participants