dandelion-memory 1.0.0rc15__py3-none-any.whl
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.
- benchmarks/__init__.py +3 -0
- benchmarks/adapters/__init__.py +29 -0
- benchmarks/adapters/ablations.py +406 -0
- benchmarks/adapters/base.py +72 -0
- benchmarks/adapters/controlled/__init__.py +13 -0
- benchmarks/adapters/controlled/core_archival.py +115 -0
- benchmarks/adapters/controlled/extract_resolve.py +130 -0
- benchmarks/adapters/controlled/hybrid_rag.py +120 -0
- benchmarks/adapters/controlled/no_late_binding.py +113 -0
- benchmarks/adapters/dandelion.py +94 -0
- benchmarks/adapters/native/__init__.py +31 -0
- benchmarks/adapters/native/base.py +45 -0
- benchmarks/adapters/native/dandelion_native.py +164 -0
- benchmarks/adapters/native/dandelion_native_b0.py +165 -0
- benchmarks/adapters/native/dandelion_native_b1.py +170 -0
- benchmarks/adapters/native/dandelion_native_b2.py +169 -0
- benchmarks/adapters/native/dandelion_native_b3.py +171 -0
- benchmarks/adapters/native/dandelion_native_c4.py +261 -0
- benchmarks/adapters/native/dandelion_native_c4_1.py +281 -0
- benchmarks/adapters/native/dandelion_native_c4_2.py +435 -0
- benchmarks/adapters/native/event_evidence_b2.py +616 -0
- benchmarks/adapters/native/evidence_b2.py +609 -0
- benchmarks/adapters/native/letta_native.py +253 -0
- benchmarks/adapters/native/mem0_native.py +219 -0
- benchmarks/adapters/native/store_vector_b0.py +792 -0
- benchmarks/adapters/native/store_vector_b2.py +808 -0
- benchmarks/agent_adapter_stdio_acceptance.py +86 -0
- benchmarks/bootstrap_cross_stack.py +218 -0
- benchmarks/canonical_profile_instrumentation.py +167 -0
- benchmarks/canonical_public_baseline.py +288 -0
- benchmarks/cli.py +525 -0
- benchmarks/collector_public30_offline.py +1653 -0
- benchmarks/datasets/__init__.py +45 -0
- benchmarks/datasets/conversational_generator.py +238 -0
- benchmarks/datasets/generator.py +283 -0
- benchmarks/datasets/holdout_topology_generator.py +290 -0
- benchmarks/datasets/holdout_topology_generator_v2.py +294 -0
- benchmarks/datasets/multi_world.py +1643 -0
- benchmarks/datasets/scale_generator.py +289 -0
- benchmarks/datasets/schema.py +57 -0
- benchmarks/deep_collision_stress.py +199 -0
- benchmarks/evaluators/__init__.py +12 -0
- benchmarks/evaluators/manifest.py +142 -0
- benchmarks/evaluators/metrics.py +277 -0
- benchmarks/evaluators/runner.py +258 -0
- benchmarks/f1_step0/build_dev_measurement_manifest_v1.py +127 -0
- benchmarks/f1_step0/build_dev_measurement_manifest_v2.py +127 -0
- benchmarks/f1_step0/build_dev_measurement_manifest_v3.py +146 -0
- benchmarks/f1_step0/build_ledger.py +143 -0
- benchmarks/f1_step0/build_ledger_v2.py +296 -0
- benchmarks/f1_step0/compare_dev52_readiness_v1.py +106 -0
- benchmarks/f1_step0/locator_public_smoke.py +172 -0
- benchmarks/f1_step0/prepare_dev52_owner_v1.py +133 -0
- benchmarks/f1_step0/prepare_dev52_owner_v2.py +133 -0
- benchmarks/f1_step0/public_identity_probe.py +191 -0
- benchmarks/f1_step0/public_response_mapper.py +101 -0
- benchmarks/f1_step0/real_source_public_preflight.py +244 -0
- benchmarks/f1_step0/run_exact_fusion_dev_experiment_v1.py +83 -0
- benchmarks/f1_step0/scorer.py +110 -0
- benchmarks/f1_step0/source_aware_dev_measurement_v1.py +627 -0
- benchmarks/f1_step0/source_aware_dev_measurement_v2.py +659 -0
- benchmarks/f1_step0/source_aware_dev_measurement_v3.py +776 -0
- benchmarks/f1_step0/test_public_response_mapper.py +110 -0
- benchmarks/f1_step0/test_real_source_public_preflight.py +25 -0
- benchmarks/f1_step0/test_scorer.py +158 -0
- benchmarks/f1_step0/test_source_aware_dev_measurement.py +189 -0
- benchmarks/f1_step0/test_source_aware_dev_measurement_v2.py +263 -0
- benchmarks/f1_step0/test_source_aware_dev_measurement_v3.py +334 -0
- benchmarks/f1_step0/typed_readback_public_smoke.py +181 -0
- benchmarks/forensic_c4_1_dev.py +258 -0
- benchmarks/forensic_c4_dev.py +255 -0
- benchmarks/forensic_deep25_c4_1.py +478 -0
- benchmarks/legacy_migration_acceptance.py +29 -0
- benchmarks/longmemeval_actor.py +497 -0
- benchmarks/longmemeval_agent_judge.py +593 -0
- benchmarks/longmemeval_budget.py +139 -0
- benchmarks/longmemeval_full.py +410 -0
- benchmarks/longmemeval_judge.py +327 -0
- benchmarks/longmemeval_pilot.py +316 -0
- benchmarks/longmemeval_s.py +318 -0
- benchmarks/memory_bench.py +248 -0
- benchmarks/memory_formation/__init__.py +1 -0
- benchmarks/memory_formation/audit.py +801 -0
- benchmarks/memory_formation/real_audit.py +688 -0
- benchmarks/memory_session_acceptance.py +279 -0
- benchmarks/native_codex_host.py +513 -0
- benchmarks/owner_dense_acceptance.py +126 -0
- benchmarks/pilot_seeker_vault.py +266 -0
- benchmarks/prepare_public30_ripgrep_range_owner.py +115 -0
- benchmarks/profile_canonical.py +373 -0
- benchmarks/profile_canonical_lanes.py +405 -0
- benchmarks/profile_search_chunks.py +351 -0
- benchmarks/public_ranges_faq_proof.py +121 -0
- benchmarks/public_repos/build_history_scope_v3.py +330 -0
- benchmarks/public_repos/build_oracle.py +108 -0
- benchmarks/public_repos/build_oracle_v2.py +169 -0
- benchmarks/public_repos/build_oracle_v3.py +176 -0
- benchmarks/public_repos/map_public_v2.py +296 -0
- benchmarks/public_repos/project_prompts_v2.py +31 -0
- benchmarks/public_repos/project_prompts_v3.py +29 -0
- benchmarks/public_repos/ready_admin_v2.py +214 -0
- benchmarks/public_repos/score_public_v2.py +258 -0
- benchmarks/public_repos/test_map_public_v2.py +171 -0
- benchmarks/public_repos/test_public_repo_v2.py +44 -0
- benchmarks/public_repos/test_public_repo_v3.py +46 -0
- benchmarks/public_repos/test_ready_admin_v2.py +117 -0
- benchmarks/public_repos/test_score_public_v2.py +163 -0
- benchmarks/public_repos/test_wire_v2.py +292 -0
- benchmarks/public_repos/wire_v2.py +603 -0
- benchmarks/real_blocker_fix_acceptance.py +155 -0
- benchmarks/real_scan_rescan_acceptance.py +41 -0
- benchmarks/recall_v2_20k_smoke.py +112 -0
- benchmarks/recall_v2_e1_retrieve.py +70 -0
- benchmarks/recall_v2_e1_score.py +271 -0
- benchmarks/recall_v2_e2_prepare.py +69 -0
- benchmarks/recall_v2_e2_public_score.py +91 -0
- benchmarks/recall_v2_e2_score.py +108 -0
- benchmarks/recall_v2_navigation_mcp_replay.py +308 -0
- benchmarks/recall_v2_reader_capture.py +118 -0
- benchmarks/recall_v2_reader_replay.py +136 -0
- benchmarks/run_blind_h10_holdout.py +284 -0
- benchmarks/run_blind_h9_holdout.py +275 -0
- benchmarks/run_c4_2_nightly_scale.py +446 -0
- benchmarks/run_context_scale_simulation.py +189 -0
- benchmarks/run_conversational_bench.py +170 -0
- benchmarks/run_h11_evaluation.py +316 -0
- benchmarks/run_h11_v2_evaluation.py +431 -0
- benchmarks/run_native_fixed12.py +469 -0
- benchmarks/run_native_preflight.py +280 -0
- benchmarks/run_scale_stress.py +225 -0
- benchmarks/solanazation_brownfield_01/build_oracle.py +970 -0
- benchmarks/solanazation_brownfield_01/check_level_a.py +78 -0
- benchmarks/solanazation_brownfield_01/debug_scope.py +13 -0
- benchmarks/solanazation_brownfield_01/evaluate_bootstrap_02.py +570 -0
- benchmarks/solanazation_brownfield_01/evaluate_first_pass.py +306 -0
- benchmarks/solanazation_brownfield_01/generate_dryrun_report.py +222 -0
- benchmarks/solanazation_brownfield_01/generate_manifests.py +146 -0
- benchmarks/solanazation_brownfield_01/inspect_misses.py +29 -0
- benchmarks/solanazation_brownfield_01/run_miss_forensic.py +206 -0
- benchmarks/solanazation_brownfield_01/test_facts.py +15 -0
- benchmarks/statistics/__init__.py +15 -0
- benchmarks/statistics/significance.py +326 -0
- benchmarks/test_native_mcp_preflight.py +229 -0
- benchmarks/test_prepare_public30_range_owner.py +35 -0
- benchmarks/test_public30_source_reference.py +698 -0
- benchmarks/test_recall_v2_e1_reader_input.py +89 -0
- benchmarks/test_recall_v2_navigation_mcp_replay.py +155 -0
- benchmarks/test_recall_v2_reader_replay.py +41 -0
- dandelion/__init__.py +3 -0
- dandelion/__main__.py +11 -0
- dandelion/agent_adapter.py +2369 -0
- dandelion/bootstrap/__init__.py +872 -0
- dandelion/bootstrap/alias_policy.py +50 -0
- dandelion/bootstrap/authority.py +225 -0
- dandelion/bootstrap/canonical_history.py +412 -0
- dandelion/bootstrap/classifier.py +403 -0
- dandelion/bootstrap/component_graph.py +280 -0
- dandelion/bootstrap/discovery.py +279 -0
- dandelion/bootstrap/domain_induction.py +180 -0
- dandelion/bootstrap/domain_topology.py +673 -0
- dandelion/bootstrap/evidence_envelope.py +132 -0
- dandelion/bootstrap/extractors/base.py +171 -0
- dandelion/bootstrap/extractors/exact.py +1234 -0
- dandelion/bootstrap/extractors/generic.py +100 -0
- dandelion/bootstrap/extractors/git_temporal.py +111 -0
- dandelion/bootstrap/extractors/registry.py +345 -0
- dandelion/bootstrap/extractors/relations.py +89 -0
- dandelion/bootstrap/extractors/semantic.py +424 -0
- dandelion/bootstrap/extractors/status.py +218 -0
- dandelion/bootstrap/git_sweeper.py +135 -0
- dandelion/bootstrap/manifest.py +246 -0
- dandelion/bootstrap/quarantine.py +264 -0
- dandelion/bootstrap/report.py +259 -0
- dandelion/bootstrap/root_resolver.py +221 -0
- dandelion/bootstrap/tech_profiler.py +125 -0
- dandelion/bootstrap/topology.py +75 -0
- dandelion/bootstrap/topology_index.py +110 -0
- dandelion/bootstrap/transaction.py +315 -0
- dandelion/canonical_bootstrap.py +257 -0
- dandelion/canonical_memory.py +4130 -0
- dandelion/captured_input.py +295 -0
- dandelion/cli.py +767 -0
- dandelion/config.py +40 -0
- dandelion/derived_index.py +745 -0
- dandelion/domains.py +706 -0
- dandelion/embedder.py +229 -0
- dandelion/event_evidence.py +571 -0
- dandelion/evidence.py +812 -0
- dandelion/evidence_response.py +453 -0
- dandelion/evidence_workspace.py +2360 -0
- dandelion/exact_context.py +129 -0
- dandelion/hydrator.py +124 -0
- dandelion/inspector.py +442 -0
- dandelion/inspector_assets/dandelion-mark.svg +33 -0
- dandelion/inspector_assets/dandelion_graph.js +361 -0
- dandelion/inspector_assets/inspector.css +223 -0
- dandelion/inspector_assets/inspector.html +135 -0
- dandelion/inspector_assets/inspector.js +1059 -0
- dandelion/legacy_import.py +431 -0
- dandelion/live_source_grants.py +133 -0
- dandelion/local_owner.py +114 -0
- dandelion/memory_client.py +252 -0
- dandelion/memory_contract.py +107 -0
- dandelion/memory_owner.py +560 -0
- dandelion/reader_providers.py +118 -0
- dandelion/recall_v2.py +767 -0
- dandelion/reconciler.py +219 -0
- dandelion/request_budget.py +125 -0
- dandelion/retained_basis.py +223 -0
- dandelion/retrieval.py +485 -0
- dandelion/router.py +405 -0
- dandelion/search_terms.py +53 -0
- dandelion/security.py +124 -0
- dandelion/server.py +810 -0
- dandelion/source_content_fts.py +219 -0
- dandelion/source_delivery.py +89 -0
- dandelion/source_history.py +241 -0
- dandelion/source_identity.py +88 -0
- dandelion/source_navigator.py +5 -0
- dandelion/source_reader.py +444 -0
- dandelion/source_references.py +379 -0
- dandelion/source_sections.py +265 -0
- dandelion/store_kv.py +684 -0
- dandelion/store_vector.py +1289 -0
- dandelion/studio.py +325 -0
- dandelion/wal.py +227 -0
- dandelion_memory-1.0.0rc15.dist-info/METADATA +48 -0
- dandelion_memory-1.0.0rc15.dist-info/RECORD +232 -0
- dandelion_memory-1.0.0rc15.dist-info/WHEEL +5 -0
- dandelion_memory-1.0.0rc15.dist-info/entry_points.txt +5 -0
- dandelion_memory-1.0.0rc15.dist-info/licenses/LICENSE +21 -0
- dandelion_memory-1.0.0rc15.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
with open("benchmarks/solanazation_brownfield_01/BOOTSTRAP_02_RESULTS.json", encoding="utf-8") as f:
|
|
4
|
+
data = json.load(f)
|
|
5
|
+
|
|
6
|
+
misses = [r for r in data["results"] if not r["hit_at_1"]]
|
|
7
|
+
out = []
|
|
8
|
+
out.append(f"Total misses: {len(misses)} / {len(data['results'])}\n")
|
|
9
|
+
|
|
10
|
+
for m in misses:
|
|
11
|
+
cands = m.get("candidates", [])
|
|
12
|
+
top_cand = cands[0] if cands else None
|
|
13
|
+
top_src = top_cand.get("source") if top_cand else "NONE"
|
|
14
|
+
top_score = top_cand.get("score", 0.0) if top_cand else 0.0
|
|
15
|
+
top_text = top_cand.get("hydrated_text", "")[:120].replace("\n", " ") if top_cand else ""
|
|
16
|
+
reason = top_cand.get("evidence_reason") if top_cand else "NO_CANDIDATE"
|
|
17
|
+
out.append(f"[{m['id']}] ({m['category']} / {m['expected_type']})")
|
|
18
|
+
out.append(f" Query: {m['query']}")
|
|
19
|
+
out.append(f" Exp: {m['expected_value']}")
|
|
20
|
+
out.append(f" Pred: {m.get('predicted_value')}")
|
|
21
|
+
out.append(f" Top: score={top_score:.3f} src={top_src}")
|
|
22
|
+
out.append(f" {top_text}")
|
|
23
|
+
out.append(f" EvReason: {reason}")
|
|
24
|
+
out.append("-" * 60)
|
|
25
|
+
|
|
26
|
+
with open("benchmarks/solanazation_brownfield_01/misses_summary.txt", "w", encoding="utf-8") as f:
|
|
27
|
+
f.write("\n".join(out))
|
|
28
|
+
|
|
29
|
+
print("Wrote misses_summary.txt successfully")
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"""Deep Forensic Analysis of Misses in Solanazation Brownfield Assimilation.
|
|
2
|
+
|
|
3
|
+
Analyzes all 67 misses from FIRST_PASS_RESULTS.json against:
|
|
4
|
+
- Working tree files on disk
|
|
5
|
+
- Indexed manifest entries in .dandelion/bootstrap_manifest.json
|
|
6
|
+
- KV store facts in .dandelion/facts.json
|
|
7
|
+
- Qdrant points in .dandelion/qdrant
|
|
8
|
+
- Query formulation and expected values
|
|
9
|
+
|
|
10
|
+
Produces: benchmarks/solanazation_brownfield_01/MISS_FORENSIC.json
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
from collections import Counter
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
SOL_ROOT = Path(r"C:\temp\DEEP\Solanazation")
|
|
21
|
+
BENCHMARK_DIR = Path(r"C:\Users\User\Documents\work\Claude\dandelion\benchmarks\solanazation_brownfield_01")
|
|
22
|
+
RESULTS_FILE = BENCHMARK_DIR / "FIRST_PASS_RESULTS.json"
|
|
23
|
+
ORACLE_FILE = BENCHMARK_DIR / "SOLANAZATION_ORACLE.jsonl"
|
|
24
|
+
OUT_FORENSIC = BENCHMARK_DIR / "MISS_FORENSIC.json"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main():
|
|
28
|
+
print(f"Reading evaluation results from {RESULTS_FILE}...")
|
|
29
|
+
with open(RESULTS_FILE, "r", encoding="utf-8") as f:
|
|
30
|
+
eval_data = json.load(f)
|
|
31
|
+
|
|
32
|
+
with open(ORACLE_FILE, "r", encoding="utf-8") as f:
|
|
33
|
+
oracle = {q["id"]: q for q in (json.loads(line) for line in f if line.strip())}
|
|
34
|
+
|
|
35
|
+
with open(SOL_ROOT / ".dandelion" / "bootstrap_manifest.json", "r", encoding="utf-8") as f:
|
|
36
|
+
boot_manifest = json.load(f)
|
|
37
|
+
|
|
38
|
+
with open(SOL_ROOT / ".dandelion" / "facts.json", "r", encoding="utf-8") as f:
|
|
39
|
+
facts_data = json.load(f)
|
|
40
|
+
|
|
41
|
+
indexed_paths = {entry.get("source_path") for entry in boot_manifest.get("entries", {}).values() if entry.get("source_path")}
|
|
42
|
+
fact_keys = {k for k in facts_data.keys() if not k.startswith("__")}
|
|
43
|
+
|
|
44
|
+
misses = [r for r in eval_data["results"] if not r["match"]]
|
|
45
|
+
print(f"Analyzing {len(misses)} misses...")
|
|
46
|
+
|
|
47
|
+
analysis = []
|
|
48
|
+
category_counts = Counter()
|
|
49
|
+
|
|
50
|
+
for r in eval_data["results"]:
|
|
51
|
+
if r["match"]:
|
|
52
|
+
continue
|
|
53
|
+
|
|
54
|
+
qid = r["id"]
|
|
55
|
+
q_meta = oracle[qid]
|
|
56
|
+
src_path = q_meta.get("source_path", "")
|
|
57
|
+
exp_val = str(q_meta.get("expected_value", ""))
|
|
58
|
+
candidates = r.get("candidates", [])
|
|
59
|
+
|
|
60
|
+
classification = "UNRESOLVED"
|
|
61
|
+
root_cause = ""
|
|
62
|
+
evidence_chain = []
|
|
63
|
+
|
|
64
|
+
# 1. Historical Git Log Queries
|
|
65
|
+
if src_path == "git log":
|
|
66
|
+
classification = "HISTORY_EXTRACTION_MISS"
|
|
67
|
+
root_cause = (
|
|
68
|
+
"Fast selective git history extraction in bootstrap runner only targeted "
|
|
69
|
+
"configs and ADRs (0 ADRs found). General git commit history (e.g. gameplay system "
|
|
70
|
+
"commit messages, recent commit shas) was not swept into memory."
|
|
71
|
+
)
|
|
72
|
+
evidence_chain.append("extract_git_temporal ran only on report.configs + report.adrs")
|
|
73
|
+
evidence_chain.append(f"Commit information for query '{r['query']}' was never ingested into WAL/Qdrant")
|
|
74
|
+
|
|
75
|
+
# 2. Nonexistent / Negative Queries (should have abstained, but checked if failed)
|
|
76
|
+
elif src_path == "nonexistent":
|
|
77
|
+
classification = "EVIDENCE_REJECTION"
|
|
78
|
+
root_cause = "Query was negative test but failed to cleanly abstain"
|
|
79
|
+
evidence_chain.append(f"Candidates returned: {len(candidates)}")
|
|
80
|
+
|
|
81
|
+
# 3. Secret Policy False Alarm (SEC-04)
|
|
82
|
+
elif q_meta["category"] == "secret_safety":
|
|
83
|
+
classification = "SECRET_POLICY_FALSE_ALARM"
|
|
84
|
+
root_cause = (
|
|
85
|
+
"Query asked for APK signing keystore password. Retrieval returned a public "
|
|
86
|
+
"documentation chunk from docs/ROADMAP-APK.md discussing signing key policy. "
|
|
87
|
+
"Zero secrets were leaked, but because candidate was public documentation without "
|
|
88
|
+
"a [SECRET_REF: placeholder, strict benchmark metric flagged it as unmasked."
|
|
89
|
+
)
|
|
90
|
+
evidence_chain.append("Top candidate source: docs/ROADMAP-APK.md (public document)")
|
|
91
|
+
evidence_chain.append("Secret leakage check: 0 raw secrets leaked")
|
|
92
|
+
|
|
93
|
+
# 4. Check if file exists on disk vs indexed by bootstrap
|
|
94
|
+
else:
|
|
95
|
+
full_path = SOL_ROOT / src_path
|
|
96
|
+
is_indexed = src_path in indexed_paths or any(src_path in p for p in indexed_paths)
|
|
97
|
+
|
|
98
|
+
if not full_path.exists() and not is_indexed:
|
|
99
|
+
classification = "SOURCE_NOT_PRESENT"
|
|
100
|
+
root_cause = f"Target source path '{src_path}' does not exist on disk in Solanazation."
|
|
101
|
+
evidence_chain.append(f"Checked disk path: {full_path} -> False")
|
|
102
|
+
|
|
103
|
+
elif not is_indexed:
|
|
104
|
+
# File exists on disk, but was not discovered/indexed
|
|
105
|
+
ext = full_path.suffix.lower()
|
|
106
|
+
classification = "DISCOVERY_MISS"
|
|
107
|
+
root_cause = (
|
|
108
|
+
f"File '{src_path}' exists on disk ({full_path.stat().st_size} bytes), but bootstrap "
|
|
109
|
+
f"discovery filter ignores '{ext}' or '{src_path}'. Discovery only supports "
|
|
110
|
+
"standard Node (package.json), Python, and single-file .gradle, ignoring Godot "
|
|
111
|
+
"(project.godot, export_presets.cfg, *.gd), Kotlin/Gradle DSL (*.kt, *.gradle.kts), and JS source files."
|
|
112
|
+
)
|
|
113
|
+
evidence_chain.append(f"File exists on disk: {full_path.exists()}")
|
|
114
|
+
evidence_chain.append(f"File extension: {ext}")
|
|
115
|
+
evidence_chain.append(f"Present in bootstrap_manifest.json: False")
|
|
116
|
+
|
|
117
|
+
else:
|
|
118
|
+
# File WAS indexed by bootstrap!
|
|
119
|
+
if q_meta["category"] == "exact_current":
|
|
120
|
+
classification = "EXACT_EXTRACTION_MISS"
|
|
121
|
+
root_cause = (
|
|
122
|
+
f"Source file '{src_path}' was discovered and cataloged, but the specific exact "
|
|
123
|
+
f"key/attribute '{q_meta.get('source_lines', '')}' was not extracted into KVStore "
|
|
124
|
+
"facts. Only top-level package name and version were extracted."
|
|
125
|
+
)
|
|
126
|
+
evidence_chain.append(f"Source file in manifest: True")
|
|
127
|
+
evidence_chain.append(f"Exact fact keys present in store: {list(fact_keys)}")
|
|
128
|
+
|
|
129
|
+
elif q_meta["category"] == "implementation_status":
|
|
130
|
+
classification = "STATUS_INFERENCE_ERROR"
|
|
131
|
+
root_cause = (
|
|
132
|
+
f"Source file '{src_path}' was ingested into semantic memory, but the retrieval "
|
|
133
|
+
f"query did not score high enough on the specific status attribute or status was "
|
|
134
|
+
"expressed in descriptive prose rather than a structured status enum."
|
|
135
|
+
)
|
|
136
|
+
evidence_chain.append(f"Candidate count: {len(candidates)}")
|
|
137
|
+
if candidates:
|
|
138
|
+
evidence_chain.append(f"Top candidate text: {candidates[0]['hydrated_text'][:100]}...")
|
|
139
|
+
|
|
140
|
+
else:
|
|
141
|
+
# Architecture or Cross-Component
|
|
142
|
+
if len(candidates) == 0:
|
|
143
|
+
classification = "CANDIDATE_GENERATION_MISS"
|
|
144
|
+
root_cause = (
|
|
145
|
+
f"Source file '{src_path}' was indexed, but dense vector and lexical channels "
|
|
146
|
+
"produced zero candidates surviving the evidence gate."
|
|
147
|
+
)
|
|
148
|
+
else:
|
|
149
|
+
classification = "FINAL_RANKING_MISS"
|
|
150
|
+
root_cause = (
|
|
151
|
+
f"Source file '{src_path}' was indexed, and candidates were retrieved, but the top-1 "
|
|
152
|
+
f"candidate was from '{candidates[0].get('source')}' instead of the expected target."
|
|
153
|
+
)
|
|
154
|
+
evidence_chain.append(f"Top candidate source: {candidates[0].get('source')}")
|
|
155
|
+
evidence_chain.append(f"Top candidate score: {candidates[0].get('score')}")
|
|
156
|
+
|
|
157
|
+
category_counts[classification] += 1
|
|
158
|
+
analysis.append({
|
|
159
|
+
"id": qid,
|
|
160
|
+
"query": r["query"],
|
|
161
|
+
"category": q_meta["category"],
|
|
162
|
+
"expected_value": q_meta.get("expected_value"),
|
|
163
|
+
"source_path": src_path,
|
|
164
|
+
"classification": classification,
|
|
165
|
+
"root_cause": root_cause,
|
|
166
|
+
"evidence_chain": evidence_chain,
|
|
167
|
+
"candidate_count": len(candidates),
|
|
168
|
+
"top_candidate": {
|
|
169
|
+
"source": candidates[0].get("source"),
|
|
170
|
+
"domain": candidates[0].get("domain"),
|
|
171
|
+
"score": candidates[0].get("score"),
|
|
172
|
+
"vector_score": candidates[0].get("vector_score"),
|
|
173
|
+
"snippet": candidates[0].get("hydrated_text")[:140] if candidates else None
|
|
174
|
+
} if candidates else None
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
forensic_summary = {
|
|
178
|
+
"total_misses": len(misses),
|
|
179
|
+
"total_queries_evaluated": len(eval_data["results"]),
|
|
180
|
+
"first_pass_recall_at_1": eval_data["summary"]["hit_at_1_percent"],
|
|
181
|
+
"classification_breakdown": {
|
|
182
|
+
k: {
|
|
183
|
+
"count": v,
|
|
184
|
+
"percentage_of_misses": round((v / len(misses)) * 100, 2),
|
|
185
|
+
"percentage_of_total_queries": round((v / len(eval_data["results"])) * 100, 2)
|
|
186
|
+
}
|
|
187
|
+
for k, v in category_counts.most_common()
|
|
188
|
+
},
|
|
189
|
+
"miss_details": analysis
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
with open(OUT_FORENSIC, "w", encoding="utf-8") as f:
|
|
193
|
+
json.dump(forensic_summary, f, indent=2, ensure_ascii=False)
|
|
194
|
+
|
|
195
|
+
print("\n" + "=" * 60)
|
|
196
|
+
print("MISS FORENSIC BREAKDOWN")
|
|
197
|
+
print(f"Total Misses: {len(misses)} / {len(eval_data['results'])}")
|
|
198
|
+
print("-" * 60)
|
|
199
|
+
for cat, data in forensic_summary["classification_breakdown"].items():
|
|
200
|
+
print(f" {cat:32s}: {data['count']:2d} ({data['percentage_of_misses']:5.1f}% of misses | {data['percentage_of_total_queries']:5.1f}% of all)")
|
|
201
|
+
print("=" * 60)
|
|
202
|
+
print(f"Saved complete forensic report to {OUT_FORENSIC}")
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if __name__ == "__main__":
|
|
206
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from dandelion.bootstrap.discovery import discover_project
|
|
3
|
+
from dandelion.bootstrap.root_resolver import resolve_project_root
|
|
4
|
+
from dandelion.bootstrap.extractors.exact import extract_exact_facts
|
|
5
|
+
|
|
6
|
+
report = discover_project(Path(r"C:\temp\DEEP\Solanazation"))
|
|
7
|
+
root_res = resolve_project_root(report)
|
|
8
|
+
facts = extract_exact_facts(report.all_discovered, project_name=root_res.project_name)
|
|
9
|
+
|
|
10
|
+
target_keys = ["main_scene", "package_id", "compile_sdk", "useAndroidX", "port", "express", "version"]
|
|
11
|
+
for k in target_keys:
|
|
12
|
+
matching = [f for f in facts if k.lower() in f.key.lower()]
|
|
13
|
+
print(f"Match for '{k}': {len(matching)} facts")
|
|
14
|
+
for m in matching[:3]:
|
|
15
|
+
print(f" {m.key} = {m.value}")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Statistical tests and significance estimation module."""
|
|
2
|
+
|
|
3
|
+
from benchmarks.statistics.significance import (
|
|
4
|
+
mcnemar_test,
|
|
5
|
+
paired_bootstrap_ci,
|
|
6
|
+
holm_bonferroni,
|
|
7
|
+
compare_systems,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"mcnemar_test",
|
|
12
|
+
"paired_bootstrap_ci",
|
|
13
|
+
"holm_bonferroni",
|
|
14
|
+
"compare_systems",
|
|
15
|
+
]
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"""Statistical significance testing for DandelionBench.
|
|
2
|
+
|
|
3
|
+
Implements:
|
|
4
|
+
1. McNemar's paired test with Edwards' continuity correction
|
|
5
|
+
2. 10,000 paired bootstrap resampling for 95% Confidence Intervals
|
|
6
|
+
3. Holm-Bonferroni correction for multiple baseline comparisons
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import math
|
|
10
|
+
import random
|
|
11
|
+
from typing import Any, Sequence
|
|
12
|
+
from benchmarks.evaluators.metrics import RunScorecard, CaseResult
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def mcnemar_test(
|
|
16
|
+
outcomes_a: Sequence[bool],
|
|
17
|
+
outcomes_b: Sequence[bool],
|
|
18
|
+
) -> tuple[float, float, int, int]:
|
|
19
|
+
"""Calculate McNemar's test with Edwards' continuity correction.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
outcomes_a: Binary correctness outcomes for system A.
|
|
23
|
+
outcomes_b: Binary correctness outcomes for system B.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
(chi2_statistic, p_value, b_discordant, c_discordant)
|
|
27
|
+
where:
|
|
28
|
+
b: System A was correct, System B was incorrect.
|
|
29
|
+
c: System A was incorrect, System B was correct.
|
|
30
|
+
"""
|
|
31
|
+
if len(outcomes_a) != len(outcomes_b):
|
|
32
|
+
raise ValueError("Outcome sequences must have identical length for paired test.")
|
|
33
|
+
|
|
34
|
+
b = sum(1 for a, b_val in zip(outcomes_a, outcomes_b) if a and not b_val)
|
|
35
|
+
c = sum(1 for a, b_val in zip(outcomes_a, outcomes_b) if not a and b_val)
|
|
36
|
+
|
|
37
|
+
discordant = b + c
|
|
38
|
+
if discordant == 0:
|
|
39
|
+
return 0.0, 1.0, 0, 0
|
|
40
|
+
|
|
41
|
+
# Edwards' continuity correction formula: (|b - c| - 1)^2 / (b + c)
|
|
42
|
+
num = max(0.0, abs(b - c) - 1.0) ** 2
|
|
43
|
+
chi2 = num / discordant
|
|
44
|
+
|
|
45
|
+
# For 1 degree of freedom, exact survival function is 1 - erf(sqrt(chi2 / 2))
|
|
46
|
+
p_value = 1.0 - math.erf(math.sqrt(chi2 / 2.0))
|
|
47
|
+
p_value = max(0.0, min(1.0, p_value))
|
|
48
|
+
|
|
49
|
+
return chi2, p_value, b, c
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def paired_bootstrap_ci(
|
|
53
|
+
outcomes_a: Sequence[bool],
|
|
54
|
+
outcomes_b: Sequence[bool],
|
|
55
|
+
n_iterations: int = 10000,
|
|
56
|
+
confidence_level: float = 0.95,
|
|
57
|
+
seed: int = 42,
|
|
58
|
+
) -> tuple[float, float, float, bool]:
|
|
59
|
+
"""Compute empirical paired bootstrap confidence interval for Delta Accuracy.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
outcomes_a: Binary outcomes for system A.
|
|
63
|
+
outcomes_b: Binary outcomes for system B.
|
|
64
|
+
n_iterations: Number of bootstrap iterations (default: 10,000).
|
|
65
|
+
confidence_level: Desired confidence level (default: 0.95).
|
|
66
|
+
seed: Random seed for exact reproducibility.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
(mean_delta_pct, ci_lower_pct, ci_upper_pct, is_significant)
|
|
70
|
+
"""
|
|
71
|
+
n = len(outcomes_a)
|
|
72
|
+
if n != len(outcomes_b):
|
|
73
|
+
raise ValueError("Paired samples must have identical size.")
|
|
74
|
+
|
|
75
|
+
rng = random.Random(seed)
|
|
76
|
+
deltas = []
|
|
77
|
+
|
|
78
|
+
a_vals = [1.0 if x else 0.0 for x in outcomes_a]
|
|
79
|
+
b_vals = [1.0 if x else 0.0 for x in outcomes_b]
|
|
80
|
+
|
|
81
|
+
for _ in range(n_iterations):
|
|
82
|
+
sample_indices = [rng.randint(0, n - 1) for _ in range(n)]
|
|
83
|
+
sum_a = sum(a_vals[idx] for idx in sample_indices)
|
|
84
|
+
sum_b = sum(b_vals[idx] for idx in sample_indices)
|
|
85
|
+
diff_pct = ((sum_a - sum_b) / n) * 100.0
|
|
86
|
+
deltas.append(diff_pct)
|
|
87
|
+
|
|
88
|
+
deltas.sort()
|
|
89
|
+
alpha = 1.0 - confidence_level
|
|
90
|
+
low_idx = int((alpha / 2.0) * n_iterations)
|
|
91
|
+
high_idx = int((1.0 - alpha / 2.0) * n_iterations)
|
|
92
|
+
|
|
93
|
+
mean_delta = ((sum(a_vals) - sum(b_vals)) / n) * 100.0
|
|
94
|
+
ci_lower = deltas[low_idx]
|
|
95
|
+
ci_upper = deltas[min(high_idx, n_iterations - 1)]
|
|
96
|
+
|
|
97
|
+
# Significant if 0 is not inside [ci_lower, ci_upper]
|
|
98
|
+
is_sig = (ci_lower > 0.0) or (ci_upper < 0.0)
|
|
99
|
+
|
|
100
|
+
return mean_delta, ci_lower, ci_upper, is_sig
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def holm_bonferroni(p_values: list[float]) -> list[float]:
|
|
104
|
+
"""Adjust a list of p-values using the step-down Holm-Bonferroni method.
|
|
105
|
+
|
|
106
|
+
Strictly controls Family-Wise Error Rate (FWER) under multiple comparisons.
|
|
107
|
+
"""
|
|
108
|
+
m = len(p_values)
|
|
109
|
+
if m <= 1:
|
|
110
|
+
return list(p_values)
|
|
111
|
+
|
|
112
|
+
indexed = sorted(enumerate(p_values), key=lambda x: x[1])
|
|
113
|
+
adjusted = [0.0] * m
|
|
114
|
+
|
|
115
|
+
running_max = 0.0
|
|
116
|
+
for rank, (original_idx, p_val) in enumerate(indexed):
|
|
117
|
+
multiplier = m - rank
|
|
118
|
+
raw_adj = min(1.0, multiplier * p_val)
|
|
119
|
+
running_max = max(running_max, raw_adj)
|
|
120
|
+
adjusted[original_idx] = running_max
|
|
121
|
+
|
|
122
|
+
return adjusted
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def world_clustered_bootstrap_ci(
|
|
126
|
+
results_a: Sequence[CaseResult],
|
|
127
|
+
results_b: Sequence[CaseResult],
|
|
128
|
+
n_iterations: int = 10000,
|
|
129
|
+
confidence_level: float = 0.95,
|
|
130
|
+
seed: int = 42,
|
|
131
|
+
) -> tuple[float, float, float, bool]:
|
|
132
|
+
"""Compute hierarchical / world-clustered bootstrap confidence interval.
|
|
133
|
+
|
|
134
|
+
Resamples distinct project worlds with replacement to properly model the
|
|
135
|
+
statistical correlation of queries sharing state within each world cluster.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
results_a: List of CaseResult objects from System A.
|
|
139
|
+
results_b: List of CaseResult objects from System B.
|
|
140
|
+
n_iterations: Number of cluster bootstrap iterations (default: 10,000).
|
|
141
|
+
confidence_level: Desired confidence level (default: 0.95).
|
|
142
|
+
seed: Random seed for exact reproducibility.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
(mean_delta_pct, ci_lower_pct, ci_upper_pct, is_significant)
|
|
146
|
+
"""
|
|
147
|
+
dict_a = {r.case_id: r for r in results_a}
|
|
148
|
+
dict_b = {r.case_id: r for r in results_b}
|
|
149
|
+
common_cids = sorted(set(dict_a.keys()) & set(dict_b.keys()))
|
|
150
|
+
if not common_cids:
|
|
151
|
+
return 0.0, 0.0, 0.0, False
|
|
152
|
+
|
|
153
|
+
# Group paired outcomes by world cluster
|
|
154
|
+
world_clusters: dict[str, list[tuple[float, float]]] = {}
|
|
155
|
+
for cid in common_cids:
|
|
156
|
+
ra = dict_a[cid]
|
|
157
|
+
rb = dict_b[cid]
|
|
158
|
+
wid = getattr(ra, "world_id", "") or getattr(rb, "world_id", "")
|
|
159
|
+
if not wid and "-" in cid:
|
|
160
|
+
wid = cid.split("-")[1].lower()
|
|
161
|
+
if not wid:
|
|
162
|
+
wid = "default"
|
|
163
|
+
|
|
164
|
+
if wid not in world_clusters:
|
|
165
|
+
world_clusters[wid] = []
|
|
166
|
+
world_clusters[wid].append((
|
|
167
|
+
1.0 if ra.factual_correct else 0.0,
|
|
168
|
+
1.0 if rb.factual_correct else 0.0,
|
|
169
|
+
))
|
|
170
|
+
|
|
171
|
+
worlds = sorted(world_clusters.keys())
|
|
172
|
+
n_worlds = len(worlds)
|
|
173
|
+
if n_worlds <= 1:
|
|
174
|
+
# Fallback to standard paired bootstrap if unclustered
|
|
175
|
+
a_bools = [dict_a[cid].factual_correct for cid in common_cids]
|
|
176
|
+
b_bools = [dict_b[cid].factual_correct for cid in common_cids]
|
|
177
|
+
return paired_bootstrap_ci(a_bools, b_bools, n_iterations, confidence_level, seed)
|
|
178
|
+
|
|
179
|
+
rng = random.Random(seed)
|
|
180
|
+
deltas = []
|
|
181
|
+
|
|
182
|
+
for _ in range(n_iterations):
|
|
183
|
+
# 1. Resample worlds with replacement
|
|
184
|
+
resampled_worlds = [rng.choice(worlds) for _ in range(n_worlds)]
|
|
185
|
+
sum_a = 0.0
|
|
186
|
+
sum_b = 0.0
|
|
187
|
+
n_queries = 0
|
|
188
|
+
for w in resampled_worlds:
|
|
189
|
+
pairs = world_clusters[w]
|
|
190
|
+
for a_val, b_val in pairs:
|
|
191
|
+
sum_a += a_val
|
|
192
|
+
sum_b += b_val
|
|
193
|
+
n_queries += 1
|
|
194
|
+
if n_queries > 0:
|
|
195
|
+
deltas.append(((sum_a - sum_b) / n_queries) * 100.0)
|
|
196
|
+
|
|
197
|
+
deltas.sort()
|
|
198
|
+
alpha = 1.0 - confidence_level
|
|
199
|
+
low_idx = int((alpha / 2.0) * len(deltas))
|
|
200
|
+
high_idx = int((1.0 - alpha / 2.0) * len(deltas))
|
|
201
|
+
|
|
202
|
+
# Point estimate across all queries
|
|
203
|
+
sum_a_total = sum(1.0 if dict_a[cid].factual_correct else 0.0 for cid in common_cids)
|
|
204
|
+
sum_b_total = sum(1.0 if dict_b[cid].factual_correct else 0.0 for cid in common_cids)
|
|
205
|
+
mean_delta = ((sum_a_total - sum_b_total) / len(common_cids)) * 100.0
|
|
206
|
+
|
|
207
|
+
ci_lower = deltas[low_idx]
|
|
208
|
+
ci_upper = deltas[min(high_idx, len(deltas) - 1)]
|
|
209
|
+
is_sig = (ci_lower > 0.0) or (ci_upper < 0.0)
|
|
210
|
+
|
|
211
|
+
return mean_delta, ci_lower, ci_upper, is_sig
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def compute_per_world_statistics(
|
|
215
|
+
results_a: Sequence[CaseResult],
|
|
216
|
+
results_b: Sequence[CaseResult],
|
|
217
|
+
metric: str = "factual_correct",
|
|
218
|
+
) -> dict[str, dict[str, Any]]:
|
|
219
|
+
"""Compute per-world breakdown of wins, losses, paired deltas, and category counts."""
|
|
220
|
+
dict_a = {r.case_id: r for r in results_a}
|
|
221
|
+
dict_b = {r.case_id: r for r in results_b}
|
|
222
|
+
common_cids = sorted(set(dict_a.keys()) & set(dict_b.keys()))
|
|
223
|
+
|
|
224
|
+
per_world: dict[str, dict[str, Any]] = {}
|
|
225
|
+
for cid in common_cids:
|
|
226
|
+
ra = dict_a[cid]
|
|
227
|
+
rb = dict_b[cid]
|
|
228
|
+
wid = getattr(ra, "world_id", "") or getattr(rb, "world_id", "")
|
|
229
|
+
if not wid and "-" in cid:
|
|
230
|
+
wid = cid.split("-")[1].lower()
|
|
231
|
+
if not wid:
|
|
232
|
+
wid = "default"
|
|
233
|
+
|
|
234
|
+
if wid not in per_world:
|
|
235
|
+
per_world[wid] = {
|
|
236
|
+
"world_id": wid,
|
|
237
|
+
"query_count": 0,
|
|
238
|
+
"wins": 0,
|
|
239
|
+
"losses": 0,
|
|
240
|
+
"ties_success": 0,
|
|
241
|
+
"ties_failure": 0,
|
|
242
|
+
"paired_delta_pct": 0.0,
|
|
243
|
+
"category_composition": {},
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
w_entry = per_world[wid]
|
|
247
|
+
w_entry["query_count"] += 1
|
|
248
|
+
|
|
249
|
+
cat = getattr(ra, "category", "") or getattr(rb, "category", "unknown")
|
|
250
|
+
w_entry["category_composition"][cat] = w_entry["category_composition"].get(cat, 0) + 1
|
|
251
|
+
|
|
252
|
+
a_succ = bool(getattr(ra, metric))
|
|
253
|
+
b_succ = bool(getattr(rb, metric))
|
|
254
|
+
|
|
255
|
+
if a_succ and not b_succ:
|
|
256
|
+
w_entry["wins"] += 1
|
|
257
|
+
elif not a_succ and b_succ:
|
|
258
|
+
w_entry["losses"] += 1
|
|
259
|
+
elif a_succ and b_succ:
|
|
260
|
+
w_entry["ties_success"] += 1
|
|
261
|
+
else:
|
|
262
|
+
w_entry["ties_failure"] += 1
|
|
263
|
+
|
|
264
|
+
for wid, entry in per_world.items():
|
|
265
|
+
q_count = entry["query_count"]
|
|
266
|
+
if q_count > 0:
|
|
267
|
+
entry["paired_delta_pct"] = round(((entry["wins"] - entry["losses"]) / q_count) * 100.0, 2)
|
|
268
|
+
|
|
269
|
+
return per_world
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def compare_systems(
|
|
273
|
+
primary: RunScorecard,
|
|
274
|
+
baseline: RunScorecard,
|
|
275
|
+
metric: str = "factual_correct",
|
|
276
|
+
n_bootstrap: int = 10000,
|
|
277
|
+
) -> dict[str, Any]:
|
|
278
|
+
"""Pairwise statistical comparison between primary system and baseline."""
|
|
279
|
+
# Align by case_id
|
|
280
|
+
dict_a = {r.case_id: getattr(r, metric) for r in primary.raw_results}
|
|
281
|
+
dict_b = {r.case_id: getattr(r, metric) for r in baseline.raw_results}
|
|
282
|
+
|
|
283
|
+
common_cases = sorted(set(dict_a.keys()) & set(dict_b.keys()))
|
|
284
|
+
if not common_cases:
|
|
285
|
+
raise ValueError("No common case_ids found between runs to pair.")
|
|
286
|
+
|
|
287
|
+
outcomes_a = [dict_a[cid] for cid in common_cases]
|
|
288
|
+
outcomes_b = [dict_b[cid] for cid in common_cases]
|
|
289
|
+
|
|
290
|
+
chi2, p_val, b_discord, c_discord = mcnemar_test(outcomes_a, outcomes_b)
|
|
291
|
+
delta, ci_low, ci_high, is_sig = paired_bootstrap_ci(
|
|
292
|
+
outcomes_a, outcomes_b, n_iterations=n_bootstrap
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
# World-clustered bootstrap CI
|
|
296
|
+
w_delta, w_ci_low, w_ci_high, w_is_sig = world_clustered_bootstrap_ci(
|
|
297
|
+
primary.raw_results, baseline.raw_results, n_iterations=n_bootstrap
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
# Per-world audit breakdown
|
|
301
|
+
per_world = compute_per_world_statistics(
|
|
302
|
+
primary.raw_results, baseline.raw_results, metric=metric
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
p_formatted = "< 0.0001" if p_val < 0.0001 else f"{p_val:.4f}"
|
|
306
|
+
p_sci = f"{p_val:.2e}" if p_val < 0.0001 else f"{p_val:.4f}"
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
"primary": primary.system_name,
|
|
310
|
+
"baseline": baseline.system_name,
|
|
311
|
+
"metric": "paired_end_to_end_success",
|
|
312
|
+
"sample_size": len(common_cases),
|
|
313
|
+
"b_discordant (A win)": b_discord,
|
|
314
|
+
"c_discordant (B win)": c_discord,
|
|
315
|
+
"mcnemar_chi2": round(chi2, 4),
|
|
316
|
+
"mcnemar_p_value": p_val,
|
|
317
|
+
"mcnemar_p_formatted": p_formatted,
|
|
318
|
+
"mcnemar_p_scientific": p_sci,
|
|
319
|
+
"delta_pct": round(delta, 2),
|
|
320
|
+
"ci_95_lower": round(ci_low, 2),
|
|
321
|
+
"ci_95_upper": round(ci_high, 2),
|
|
322
|
+
"clustered_ci_95_lower": round(w_ci_low, 2),
|
|
323
|
+
"clustered_ci_95_upper": round(w_ci_high, 2),
|
|
324
|
+
"is_significant": is_sig and w_is_sig,
|
|
325
|
+
"per_world_statistics": per_world,
|
|
326
|
+
}
|