Skip to content

[P1-2][kratos] Corpus calibration baseline #103

Open

Description

@JeremyDev87

Corpus calibration baseline for introduced-only readiness

Goal

stable finding identity(kratos:v1:*)를 consumer CI 정책에 사용하기 전에, 실제 analyze_project 결과를 canonical expected-ID corpus와 비교해 false positive/false negative를 재현 가능하게 관찰하는 P1-2 baseline을 구축합니다.

Source of Truth

Scope

  • fixtures/corpus/manifest.json을 expected identity set의 단일 canonical manifest로 둡니다.
  • 최소 4개 case를 고정합니다: mixed-positive, dynamic-usage negative, route-substring negative, empty/no-op.
  • 전체 corpus에서 6개 finding group을 모두 expected positive로 최소 1회 포함합니다: broken imports, orphan files, dead exports, unused imports, route entrypoints, deletion candidates.
  • evaluator는 각 fixture를 analyze_project로 분석하고, 같은 root의 빈 baseline과 diff_reports_with_identity를 비교해 observed stable ID를 얻습니다.
  • case/kind별 multiplicity-aware TP/FP/FN과 ordered stable ID vector를 결정적으로 출력합니다.
  • baseline은 FP=0/FN=0 및 manifest와 ordered-vector exact match여야 하며, well-formed wrong replacement ID가 FP=1/FN=1로 명시적 실패하는 테스트를 둡니다.
  • 서로 다른 temporary root와 반복 실행에서 결과가 동일함을 검증합니다.
  • 평가 중 fixture/report/.kratos/ 파일을 생성하거나 수정하지 않습니다.

Owned files

  • fixtures/corpus/**
  • crates/kratos-core/tests/corpus_calibration.rs
  • docs/plans/v1-cli-report-contract.md

Inspect-only

  • crates/kratos-core/src/analyze.rs
  • crates/kratos-core/src/model.rs
  • crates/kratos-core/src/report_diff.rs
  • crates/kratos-core/tests/dynamic_usage.rs
  • crates/kratos-core/tests/report_diff.rs
  • crates/kratos-cli/tests/diff_cli.rs
  • .github/workflows/ci.yml
  • package.json

Must not touch

  • Runtime scanner semantics or production finding classification
  • Consumer introduced-only blocking/shadow/enforcement gate or required check
  • Public CLI command/flag additions
  • Report schema v4, source span, SARIF, annotation
  • Workspace/cache/watch/HTML/sweep work
  • .github/workflows/**, package/version metadata, tag/publish/release/deploy/merge/auto-merge

Acceptance criteria

  1. Canonical manifest has unique case IDs/roots, corpus-contained existing paths, identityVersion=1, six explicit finding groups, and sorted full IDs matching lowercase kratos:v1:<64-hex>; repeated IDs preserve duplicate finding multiplicity.
  2. Corpus contains the four required case classes and all six finding groups have at least one expected positive across the corpus.
  3. Real analyze_project + same-root empty-baseline diff_reports_with_identity evaluation reports baseline FP=0/FN=0 and ordered introduced IDs exactly equal the manifest.
  4. A well-formed wrong replacement ID exposes exactly FP=1/FN=1 with case/group/IDs; duplicate multiplicity and reordering cannot be hidden by set conversion.
  5. Repeated evaluation and byte-identical copies under different temporary roots preserve the ordered ID vectors and TP/FP/FN.
  6. Independent semantic witnesses prove mixed locators for all groups, dynamic target discovery/inbound default usage/no dead export, route substring OrphanKind::Module, and empty/no-op zero files/modules/findings/diff.
  7. No .kratos/ or report write occurs and report schema v3 / identity version 1 / existing ReportDiff and CLI compatibility remain intact.
  8. Focused corpus tests, report/CLI compatibility tests, cargo test --workspace, workspace all-target clippy, npm run verify, and git diff --check all exit 0.
  9. Draft PR current-head CI reaches 10/10 success; no merge/release/publish/deploy action is performed.

Validation

cargo test -p kratos-core --test corpus_calibration -- --nocapture
cargo test -p kratos-core --test report_diff
cargo test -p kratos-cli --test diff_cli
cargo test --workspace
cargo clippy --workspace --all-targets --locked
npm run verify
git diff --check

Parallelization

Single serial implementation lane: fixtures, manifest, evaluator, and expected IDs are tightly coupled. Independent reviewers may inspect the final diff read-only.

Wiki Context Manifest

  • Queries: kratos corpus calibration stable finding identity introduced-only, SSoT consistency no silent fallback evidence
  • Authority: [wiki: domains/principles/alex-core-invariants.md]
  • Applied: one canonical manifest, deterministic derived results, explicit mismatch evidence, no silent fallback
  • Gap: no repo-specific Kratos corpus wiki page; live repo/GitHub contracts remain authoritative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions