@dailephd/my-dev-kit-lab 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +7 -4
  3. package/dist/src/cli/help.js +35 -1
  4. package/dist/src/commands/runExperimentDescribeCommand.js +15 -1
  5. package/dist/src/commands/runExperimentRunCommand.js +177 -4
  6. package/dist/src/evaluation/retrievalQuality/metrics.js +27 -2
  7. package/dist/src/evaluation/retrievalQueryStrategies.js +26 -0
  8. package/dist/src/evaluation/retrievalQueryStrategyEvidence.js +58 -0
  9. package/dist/src/evaluation/runMyDevKitRetrieval.js +60 -51
  10. package/dist/src/evaluation/runSemanticRetrievalStrategy.js +303 -0
  11. package/dist/src/experiments/defaultRegistry.js +4 -0
  12. package/dist/src/experiments/plugins/contextPackGeneration/analysis.js +157 -0
  13. package/dist/src/experiments/plugins/contextPackGeneration/analysisArtifact.js +22 -0
  14. package/dist/src/experiments/plugins/contextPackGeneration/analysisTypes.js +1 -0
  15. package/dist/src/experiments/plugins/contextPackGeneration/buildContextPack.js +84 -0
  16. package/dist/src/experiments/plugins/contextPackGeneration/config.js +39 -0
  17. package/dist/src/experiments/plugins/contextPackGeneration/execution.js +361 -0
  18. package/dist/src/experiments/plugins/contextPackGeneration/executionArtifact.js +17 -0
  19. package/dist/src/experiments/plugins/contextPackGeneration/executionTypes.js +11 -0
  20. package/dist/src/experiments/plugins/contextPackGeneration/identityEvidence.js +71 -0
  21. package/dist/src/experiments/plugins/contextPackGeneration/index.js +19 -0
  22. package/dist/src/experiments/plugins/contextPackGeneration/localSubjectExecution.js +146 -0
  23. package/dist/src/experiments/plugins/contextPackGeneration/localSubjectPrivacy.js +276 -0
  24. package/dist/src/experiments/plugins/contextPackGeneration/metadata.js +24 -0
  25. package/dist/src/experiments/plugins/contextPackGeneration/metrics.js +46 -0
  26. package/dist/src/experiments/plugins/contextPackGeneration/packArtifact.js +17 -0
  27. package/dist/src/experiments/plugins/contextPackGeneration/packEvidence.js +152 -0
  28. package/dist/src/experiments/plugins/contextPackGeneration/packSelectionPolicy.js +305 -0
  29. package/dist/src/experiments/plugins/contextPackGeneration/plugin.js +355 -0
  30. package/dist/src/experiments/plugins/contextPackGeneration/renderContextPack.js +61 -0
  31. package/dist/src/experiments/plugins/contextPackGeneration/types.js +29 -0
  32. package/dist/src/experiments/plugins/contextWindowScaling/localSubjectPrivacy.js +2 -0
  33. package/dist/src/experiments/plugins/index.js +1 -0
  34. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/analysis.js +172 -0
  35. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/analysisArtifact.js +28 -0
  36. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/analysisTypes.js +2 -0
  37. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/config.js +39 -0
  38. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/execution.js +225 -0
  39. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/executionArtifact.js +15 -0
  40. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/index.js +12 -0
  41. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/localSubjectExecution.js +124 -0
  42. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/localSubjectPrivacy.js +176 -0
  43. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/metadata.js +51 -0
  44. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/metrics.js +60 -0
  45. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/plugin.js +292 -0
  46. package/dist/src/experiments/plugins/retrievalQueryStrategyComparison/types.js +1 -0
  47. package/dist/src/report/experiments/buildContextPackGenerationReport.js +171 -0
  48. package/dist/src/report/experiments/buildPluginExperimentReport.js +47 -2
  49. package/dist/src/report/experiments/buildRetrievalQueryStrategyComparisonReport.js +91 -0
  50. package/dist/src/report/experiments/contextPackGenerationReportModel.js +9 -0
  51. package/dist/src/report/experiments/index.js +9 -0
  52. package/dist/src/report/experiments/loadContextPackArtifacts.js +43 -0
  53. package/dist/src/report/experiments/renderContextPackGenerationHtml.js +122 -0
  54. package/dist/src/report/experiments/renderContextPackGenerationText.js +101 -0
  55. package/dist/src/report/experiments/renderPluginExperimentReportHtml.js +6 -0
  56. package/dist/src/report/experiments/renderPluginExperimentReportText.js +16 -0
  57. package/dist/src/report/experiments/renderRetrievalQueryStrategyComparisonHtml.js +96 -0
  58. package/dist/src/report/experiments/renderRetrievalQueryStrategyComparisonText.js +58 -0
  59. package/dist/src/report/experiments/retrievalQueryStrategyComparisonReportModel.js +1 -0
  60. package/dist/src/report/experiments/writePluginExperimentReports.js +2 -0
  61. package/docs/METRICS.md +149 -2
  62. package/package.json +1 -1
package/docs/METRICS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Metrics
2
2
 
3
- This document is the canonical metric glossary for my-dev-kit-lab. It defines every metric that appears in benchmark profiles, prompt variants, controlled experiment artifacts, and rendered reports across the registered experiment plugins (`context-strategy-comparison`, `warm-index-reuse`, `incremental-change-staleness`, `context-window-scaling`, and `retrieval-precision-recall`).
3
+ This document is the canonical metric glossary for my-dev-kit-lab. It defines every metric that appears in benchmark profiles, prompt variants, controlled experiment artifacts, and rendered reports across the registered experiment plugins (`context-strategy-comparison`, `warm-index-reuse`, `incremental-change-staleness`, `context-window-scaling`, `retrieval-precision-recall`, `retrieval-query-strategy-comparison`, and `context-pack-generation`).
4
4
 
5
5
  Related documentation:
6
6
  - [ARCHITECTURE.md](ARCHITECTURE.md) — how metrics flow through the pipeline
@@ -716,8 +716,155 @@ Status: released (v0.8.0). The `retrieval-precision-recall` plugin measures one
716
716
 
717
717
  **External-local runs.** Numeric values and counts are identical in external-local mode. File, symbol, and fact identity lists are replaced by numbered placeholders of the same length (`<redacted file N>`, `<redacted symbol N>`, `<redacted fact N>`), case titles and retrieval warning text are replaced by fixed placeholders, and the artifact carries a fixed identity-redaction marker. A placeholder is a withheld identity, not an empty result.
718
718
 
719
- **Not implemented in v0.8.0.** Ranked retrieval metrics such as MRR, NDCG, MAP, and ranked precision; retrieval-strategy comparison and winners; and query-strategy comparison. Those remain future scope.
719
+ **Not implemented in v0.8.0.** Ranked retrieval metrics such as MRR, NDCG, MAP, and ranked precision; retrieval-strategy comparison and winners; and query-strategy comparison. Strategy comparison was later added by the separate `retrieval-query-strategy-comparison` plugin documented below; ranked metrics remain outside the Lab's scope.
720
720
 
721
721
  **Sources.** Standard set-based precision and recall come from established information-retrieval evaluation: Manning, Raghavan, and Schütze, *Introduction to Information Retrieval*, "Evaluation of unranked retrieval sets" (Stanford online edition, <https://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-unranked-retrieval-sets-1.html>), and the National Institute of Standards and Technology's Text REtrieval Conference (TREC) material on relevance judgments, which treats relevance as a judged, answer-key property of a test collection (<https://trec.nist.gov/data/reljudge_eng.html>; program overview at <https://trec.nist.gov/>). Applying those formulas to file identities and exact symbol-name identities is this Lab's deterministic operationalization. Fact coverage (through the Lab's explicit `factIds` mapping contract) and irrelevant context ratio are Lab-specific deterministic diagnostics, not standardized TREC ranking metrics, and neither source defines the `factIds` contract.
722
722
 
723
723
  See [COMMANDS.md](COMMANDS.md#retrieval-precision-recall-v080), [WORKFLOWS.md](WORKFLOWS.md#retrieval-precision-recall-experiment-v080), and [ARCHITECTURE.md](ARCHITECTURE.md#retrieval-precisionrecall-architecture-v080).
724
+
725
+ ## Retrieval query strategy comparison metrics (v0.8.1)
726
+
727
+ Status: released (v0.8.1). The `retrieval-query-strategy-comparison` plugin runs seven fixed retrieval strategies for each case, with no agent, and compares them. This section is the authoritative definition of its scientific values. Every value is calculated once by the plugin's analysis and persisted in `retrieval-query-strategy-comparison-analysis.json`; reports and generic metrics present those precomputed values and never recalculate them.
728
+
729
+ The seven strategies, in canonical order, are `keyword-search`, `symbol-lookup`, `graph-neighborhood`, `source-slice`, `data-model-graph`, `model-view-lineage`, and `combined-graph-guided`.
730
+
731
+ ### Inherited retrieval-quality metrics
732
+
733
+ v0.8.1 reuses, without change, the v0.8.0 definitions (see [Retrieval precision/recall evidence](#retrieval-precisionrecall-evidence-v080)):
734
+
735
+ - File precision `|R_file ∩ E_file| / |R_file|` and file recall `|R_file ∩ E_file| / |E_file|`.
736
+ - Symbol precision `|R_symbol ∩ E_symbol| / |R_symbol|` and symbol recall `|R_symbol ∩ E_symbol| / |E_symbol|`, over exact, case-sensitive unique symbol names.
737
+ - Fact coverage: covered expected facts divided by expected facts, using only the answer key's explicit `factIds`-to-context mappings.
738
+ - Irrelevant context ratio `|R_file - E_file| / |R_file|`.
739
+ - Retrieved token count: the measured retrieval payload size, `ceil(character count / 4)` through the existing estimator.
740
+
741
+ The strategy-neutral retrieval evidence is adapted to the same generic identity-evidence metric owner that scores the v0.8.0 retrieval evidence, so no command provenance changes any numerator, denominator, identity definition, fact mapping, zero-denominator rule, or availability rule. The ratio metrics keep the `available`, `unavailable`, and `not-applicable` states; unavailable and not-applicable values are never converted to zero.
742
+
743
+ ### Balanced file F1
744
+
745
+ Let `TP_file` be the number of relevant retrieved files, `FP_file` the number of irrelevant retrieved files, and `FN_file` the number of missed files. Then:
746
+
747
+ ```text
748
+ F1_file = 2 * TP_file / (2 * TP_file + FP_file + FN_file)
749
+ ```
750
+
751
+ Availability: if any of the three identity sets is unavailable, F1 is `unavailable` with the reason `quality-identity-sets-unavailable`. If the denominator is zero (no relevant, irrelevant, or missed files at all), F1 is `not-applicable` with the reason `no-positive-or-retrieved-identities`. Otherwise it is `available`, with the numerator `2 * TP_file` and the denominator `2 * TP_file + FP_file + FN_file`.
752
+
753
+ An important edge case: when nothing is retrieved and the expected relevant set is nonempty, `TP = 0`, `FP = 0`, and `FN > 0`, so `F1 = 0` as an available value. It is not `not-applicable`, because retrieval performance against a nonempty relevant set is measurable. The Lab computes F1 from these counts, not by averaging stored precision and recall.
754
+
755
+ ### Balanced symbol F1
756
+
757
+ ```text
758
+ F1_symbol = 2 * TP_symbol / (2 * TP_symbol + FP_symbol + FN_symbol)
759
+ ```
760
+
761
+ `TP_symbol`, `FP_symbol`, and `FN_symbol` are the numbers of relevant retrieved, irrelevant retrieved, and missed symbols, with the identical availability rules and the exact unique symbol-name identity inherited from v0.8.0. There is no fuzzy name matching, semantic matching, node-ID matching, alias handling, or case folding.
762
+
763
+ **Source for F1.** Manning, Christopher D.; Raghavan, Prabhakar; Schütze, Hinrich. *Introduction to Information Retrieval*. Cambridge University Press. Chapter 8, "Evaluation in information retrieval." <https://nlp.stanford.edu/IR-book/pdf/08eval.pdf>. The source establishes that balanced F1 is the harmonic mean of precision and recall, `F1 = 2PR / (P + R)`. The count form above is the equivalent implementation form the Lab uses so that an empty retrieval against a nonempty relevant set is well defined. The source does not specify the Lab's `unavailable` and `not-applicable` policy, which is project-owned.
764
+
765
+ ### Matched complete cases
766
+
767
+ A case participates in cross-strategy aggregation for a scope only when all seven strategies have all four primary objectives available: file F1, symbol F1, fact coverage, and a valid retrieved token count. If any strategy lacks any one of them, the case is excluded from every strategy's aggregate for that scope, so no strategy averages over more cases than another. A treatment's own scientific evidence is still retained when its case is excluded; the rule applies only to cross-strategy aggregation and best-strategy interpretation.
768
+
769
+ ### Macro means
770
+
771
+ For each scope and strategy, over the matched comparison cases only:
772
+
773
+ ```text
774
+ meanFileF1 = sum(case file F1) / matched comparison case count
775
+ meanSymbolF1 = sum(case symbol F1) / matched comparison case count
776
+ meanFactCoverage = sum(case fact coverage) / matched comparison case count
777
+ meanRetrievedTokenCount = sum(case retrieved tokens) / matched comparison case count
778
+ ```
779
+
780
+ Stored values are not rounded. Every included task contributes equally: there is no denominator weighting, no micro averaging, and no weighting by expected files, expected symbols, facts, token count, or task locality.
781
+
782
+ ### Task-type scopes
783
+
784
+ The scopes, in report order, are `overall`, `localized`, `cross-module`, and `broad-change`. `overall` contains every selected case; the other three reuse the existing `taskLocality` metadata (`localized`, `cross-module`, `broad-change`). A case with null or unknown `taskLocality` participates only in `overall`. The Lab does not infer task type from query text.
785
+
786
+ ### Primary objective vector
787
+
788
+ For a strategy in a scope the objective vector is:
789
+
790
+ ```text
791
+ O(strategy, scope) = {
792
+ meanFileF1: maximize,
793
+ meanSymbolF1: maximize,
794
+ meanFactCoverage: maximize,
795
+ meanRetrievedTokenCount: minimize
796
+ }
797
+ ```
798
+
799
+ Only these four objectives determine dominance. File and symbol precision, recall, irrelevant context ratio, duration, and missed counts remain visible diagnostic metrics but are not additional dominance dimensions: F1 already combines precision and recall, and the irrelevant context ratio is algebraically coupled to file precision when both are defined.
800
+
801
+ ### Pareto dominance
802
+
803
+ Strategy A dominates strategy B if and only if all of the following hold:
804
+
805
+ ```text
806
+ A.meanFileF1 >= B.meanFileF1
807
+ AND A.meanSymbolF1 >= B.meanSymbolF1
808
+ AND A.meanFactCoverage >= B.meanFactCoverage
809
+ AND A.meanRetrievedTokenCount <= B.meanRetrievedTokenCount
810
+ AND at least one of those comparisons is strict
811
+ ```
812
+
813
+ There is no epsilon, no tolerance band, no rounding, and no weighting. Two strategies with identical vectors do not dominate each other. The Pareto front of a scope is every strategy that no other strategy dominates.
814
+
815
+ **Source for Pareto dominance.** Emmerich, Michael T. M.; Deutz, André H. "A tutorial on multiobjective optimization: fundamentals and evolutionary methods." *Natural Computing* 17, 585–609 (2018). DOI 10.1007/s11047-018-9685-y. <https://link.springer.com/article/10.1007/s11047-018-9685-y>. It is cited only for the general multiobjective and Pareto framework. The Lab's exact four objectives and its unique-best interpretation are project-owned design choices.
816
+
817
+ ### Best-strategy interpretation
818
+
819
+ This rule is project-owned:
820
+
821
+ - `comparisonCaseCount = 0`: the interpretation is `unavailable`, the Pareto front is empty, and `bestStrategyId` is `null`.
822
+ - The Pareto front has exactly one strategy: the interpretation is `unique-best` and `bestStrategyId` is that strategy.
823
+ - The Pareto front has more than one strategy: the interpretation is `tradeoff` and `bestStrategyId` is `null`.
824
+
825
+ No hidden tie breaker exists: token count, F1, strategy order, alphabetical order, and task locality never select a winner. "No single best strategy" is a valid result.
826
+
827
+ ### No composite score or ranking
828
+
829
+ The plugin does not calculate a weighted composite score, a scalar winner score, a total ordinal ranking, MRR, NDCG, MAP, a statistical significance test, or a confidence interval. No scientifically justified weights exist for combining the four objectives, so the Lab exposes tradeoffs instead of hiding them in an arbitrary scalar. The Pareto-front array is emitted in canonical strategy order for deterministic serialization; that order is not a performance order, and the first entry is not the best strategy.
830
+
831
+ ### External-local runs: science before redaction
832
+
833
+ In external-local mode the scientific analysis runs first, on the real in-memory file, symbol, and fact identities. Only afterward are file, symbol, fact, semantic-node, warning, and case-title identities replaced for persistence. Privacy placeholders are therefore never used to calculate precision, recall, F1, fact coverage, means, Pareto fronts, or `bestStrategyId`, and every numeric value and strategy interpretation is identical to the unredacted analysis.
834
+
835
+ ### Token caveat
836
+
837
+ Retrieved token count is `ceil(character count / 4)` through the existing estimator. It is context-size evidence. It is not provider billing telemetry, not tokenizer-exact model usage, and not a relevant-token attribution.
838
+
839
+ ### Where each value lives
840
+
841
+ `retrieval-query-strategy-comparison-execution.json` holds execution evidence only. `retrieval-query-strategy-comparison-analysis.json` is the scientific truth owner for the metrics, objective vectors, matched scopes, Pareto fronts, and best-strategy interpretation. `report.json`, `report.html`, and `report.txt` present the precomputed analysis and do not recalculate it. The generic experiment metrics (per-treatment values and per-scope objective means) are projections of the same precomputed values.
842
+
843
+ See [COMMANDS.md](COMMANDS.md#retrieval-query-strategy-comparison-v081), [WORKFLOWS.md](WORKFLOWS.md#retrieval-query-strategy-comparison-experiment-v081), and [ARCHITECTURE.md](ARCHITECTURE.md#retrieval-query-strategy-comparison-architecture-v081).
844
+
845
+ ## Context-pack generation metrics (v0.8.2)
846
+
847
+ Status: released in v0.8.2. The `context-pack-generation` plugin runs the fixed paired treatments `raw-full-file` and `context-pack`. It calculates each treatment once and persists the execution and analysis artifacts; reports present those values without recalculating them.
848
+
849
+ ### Reused retrieval-quality measures
850
+
851
+ The plugin reuses the v0.8.0 identity-based measures and availability semantics:
852
+
853
+ - fact coverage from the answer key's explicit fact-to-context mappings;
854
+ - file precision, recall, and balanced F1;
855
+ - symbol precision, recall, and balanced F1; and
856
+ - irrelevant-context ratio where the existing retrieval-quality calculation applies.
857
+
858
+ Precision, recall, F1, fact coverage, and irrelevant-context ratio retain their existing numerator, denominator, unavailable, and not-applicable behavior. There is no new composite quality score.
859
+
860
+ ### Estimated size and paired comparison
861
+
862
+ Both treatments report estimated context size using the existing estimated-token semantics (`ceil(character count / 4)`), not a provider tokenizer or billing measurement. For each matched case, `tokensSaved = rawEstimatedTokens - packEstimatedTokens`; `percentSaved = tokensSaved / rawEstimatedTokens * 100`, with zero when the raw estimate is zero. Negative savings are valid and are not clamped.
863
+
864
+ For each case, the analysis reports pack-minus-raw objective deltas for file F1, symbol F1, fact coverage, and estimated tokens. A case contributes to scope means only when both treatments have all four required measures available. Scope summaries report included and excluded case counts, treatment objective means, mean tokens saved, and percent saved from the means. Existing task-locality scopes are `overall`, `localized`, `cross-module`, and `broad-change`.
865
+
866
+ There is no composite score, winner, or ranking. Tests and call relationships may be included descriptively in a context pack, but the frozen answer key does not provide expected test or call-edge identities; v0.8.2 therefore defines no test-coverage or call-edge-coverage score.
867
+
868
+ In external-local mode, analysis uses real identities before the privacy projection. Redacted placeholders never enter metric calculations. Durable external-local output has no pack body; the report preview presents redacted identities.
869
+
870
+ See [COMMANDS.md](COMMANDS.md#context-pack-generation-v082), [WORKFLOWS.md](WORKFLOWS.md#context-pack-generation-experiment), and [ARCHITECTURE.md](ARCHITECTURE.md#context-pack-generation-architecture-v082).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dailephd/my-dev-kit-lab",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "description": "Evidence, benchmark, and evaluation companion for my-dev-kit.",
6
6
  "bin": {