infinity-context 0.1.0__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.
- infinity_context-0.1.0.dist-info/METADATA +239 -0
- infinity_context-0.1.0.dist-info/RECORD +1053 -0
- infinity_context-0.1.0.dist-info/WHEEL +5 -0
- infinity_context-0.1.0.dist-info/entry_points.txt +9 -0
- infinity_context-0.1.0.dist-info/licenses/LICENSE +201 -0
- infinity_context-0.1.0.dist-info/top_level.txt +8 -0
- infinity_context_adapters/__init__.py +1 -0
- infinity_context_adapters/cognee/__init__.py +5 -0
- infinity_context_adapters/cognee/adapter.py +364 -0
- infinity_context_adapters/embeddings/__init__.py +6 -0
- infinity_context_adapters/embeddings/noop_adapter.py +5 -0
- infinity_context_adapters/embeddings/openai_adapter.py +104 -0
- infinity_context_adapters/extraction/__init__.py +41 -0
- infinity_context_adapters/extraction/content.py +828 -0
- infinity_context_adapters/extraction/docling_engine.py +255 -0
- infinity_context_adapters/extraction/document_normalization.py +434 -0
- infinity_context_adapters/extraction/factory.py +69 -0
- infinity_context_adapters/extraction/fallback_context.py +137 -0
- infinity_context_adapters/extraction/file_detection.py +378 -0
- infinity_context_adapters/extraction/image_evidence.py +319 -0
- infinity_context_adapters/extraction/media_tools.py +579 -0
- infinity_context_adapters/extraction/openai_json.py +356 -0
- infinity_context_adapters/extraction/openai_vision.py +722 -0
- infinity_context_adapters/extraction/prompts/__init__.py +1 -0
- infinity_context_adapters/extraction/prompts/semantic_memory_v1.md +20 -0
- infinity_context_adapters/extraction/schemas/__init__.py +1 -0
- infinity_context_adapters/extraction/schemas/semantic_memory_v1.json +62 -0
- infinity_context_adapters/extraction/transcription/__init__.py +11 -0
- infinity_context_adapters/extraction/transcription/openai_adapter.py +400 -0
- infinity_context_adapters/extraction/transcription_engine.py +544 -0
- infinity_context_adapters/extraction/video_evidence.py +129 -0
- infinity_context_adapters/extraction/whisper_engine.py +386 -0
- infinity_context_adapters/features/__init__.py +7 -0
- infinity_context_adapters/features/context_building/__init__.py +53 -0
- infinity_context_adapters/features/context_building/candidate_provider_chain.py +68 -0
- infinity_context_adapters/features/context_building/graphiti_candidate_provider.py +44 -0
- infinity_context_adapters/features/context_building/in_memory_candidate_provider.py +62 -0
- infinity_context_adapters/features/context_building/postgres_candidate_provider.py +44 -0
- infinity_context_adapters/features/context_building/qdrant_candidate_provider.py +44 -0
- infinity_context_adapters/features/context_building/query_request.py +99 -0
- infinity_context_adapters/features/context_building/records.py +113 -0
- infinity_context_adapters/features/document_ingestion/__init__.py +74 -0
- infinity_context_adapters/features/document_ingestion/composition.py +69 -0
- infinity_context_adapters/features/document_ingestion/extraction_adapter.py +114 -0
- infinity_context_adapters/features/document_ingestion/in_memory_chunk_index.py +67 -0
- infinity_context_adapters/features/document_ingestion/in_memory_document_store.py +176 -0
- infinity_context_adapters/features/document_ingestion/postgres_document_store.py +110 -0
- infinity_context_adapters/features/document_ingestion/qdrant_chunk_index.py +49 -0
- infinity_context_adapters/features/document_ingestion/records.py +88 -0
- infinity_context_adapters/features/memory_facts/__init__.py +53 -0
- infinity_context_adapters/features/memory_facts/graphiti_fact_projection.py +111 -0
- infinity_context_adapters/features/memory_facts/in_memory_fact_store.py +200 -0
- infinity_context_adapters/features/memory_facts/postgres_fact_store.py +126 -0
- infinity_context_adapters/features/memory_facts/qdrant_fact_projection.py +100 -0
- infinity_context_adapters/features/memory_scopes/__init__.py +44 -0
- infinity_context_adapters/features/memory_scopes/in_memory_scope_store.py +189 -0
- infinity_context_adapters/features/memory_scopes/postgres_scope_store.py +121 -0
- infinity_context_adapters/features/memory_scopes/records.py +86 -0
- infinity_context_adapters/graphiti/__init__.py +5 -0
- infinity_context_adapters/graphiti/adapter.py +613 -0
- infinity_context_adapters/graphiti/identity_evidence.py +711 -0
- infinity_context_adapters/graphiti/scope_identity.py +31 -0
- infinity_context_adapters/local_blob.py +101 -0
- infinity_context_adapters/noop/__init__.py +16 -0
- infinity_context_adapters/noop/adapters.py +156 -0
- infinity_context_adapters/noop/runtime.py +21 -0
- infinity_context_adapters/postgres/__init__.py +19 -0
- infinity_context_adapters/postgres/asset_mappers.py +348 -0
- infinity_context_adapters/postgres/asset_repositories.py +865 -0
- infinity_context_adapters/postgres/benchmark_projection_schema.py +241 -0
- infinity_context_adapters/postgres/benchmark_run_completion.py +645 -0
- infinity_context_adapters/postgres/benchmark_run_repositories.py +908 -0
- infinity_context_adapters/postgres/benchmark_writer_fence.py +139 -0
- infinity_context_adapters/postgres/canonical_keyword_trigram.py +31 -0
- infinity_context_adapters/postgres/canonical_retrieval_batching.py +388 -0
- infinity_context_adapters/postgres/fact_repositories.py +766 -0
- infinity_context_adapters/postgres/mappers.py +745 -0
- infinity_context_adapters/postgres/migrations/0001_core_facts.sql +95 -0
- infinity_context_adapters/postgres/migrations/0002_threads_documents_chunks.sql +97 -0
- infinity_context_adapters/postgres/migrations/0003_suggestions.sql +24 -0
- infinity_context_adapters/postgres/migrations/0004_service_tokens.sql +16 -0
- infinity_context_adapters/postgres/migrations/0005_data_classification_lite.sql +8 -0
- infinity_context_adapters/postgres/migrations/0006_service_token_usage_metadata.sql +5 -0
- infinity_context_adapters/postgres/migrations/0007_service_token_permissions.sql +2 -0
- infinity_context_adapters/postgres/migrations/0008_service_token_memory_scope.sql +2 -0
- infinity_context_adapters/postgres/migrations/0009_outbox_lifecycle_hardening.sql +15 -0
- infinity_context_adapters/postgres/migrations/0010_fact_taxonomy.sql +14 -0
- infinity_context_adapters/postgres/migrations/0011_asset_extractions.sql +66 -0
- infinity_context_adapters/postgres/migrations/0012_asset_extraction_execution_hardening.sql +20 -0
- infinity_context_adapters/postgres/migrations/0012_usage_governance.sql +33 -0
- infinity_context_adapters/postgres/migrations/0013_context_link_suggestions.sql +44 -0
- infinity_context_adapters/postgres/migrations/0014_memory_anchors.sql +26 -0
- infinity_context_adapters/postgres/migrations/0015_users_acl.sql +36 -0
- infinity_context_adapters/postgres/migrations/0016_managed_benchmark_runs.sql +27 -0
- infinity_context_adapters/postgres/migrations/0017_managed_benchmark_writer_fence.sql +104 -0
- infinity_context_adapters/postgres/migrations/0018_benchmark_projection_manifest.sql +51 -0
- infinity_context_adapters/postgres/migrations/0019_managed_benchmark_sealed_fence.sql +131 -0
- infinity_context_adapters/postgres/migrations/0020_benchmark_cleanup_completion.sql +219 -0
- infinity_context_adapters/postgres/migrations/0021_benchmark_unsealed_abort.sql +64 -0
- infinity_context_adapters/postgres/migrations/0022_canonical_keyword_trigram.sql +5 -0
- infinity_context_adapters/postgres/models.py +878 -0
- infinity_context_adapters/postgres/projection_fence.py +80 -0
- infinity_context_adapters/postgres/repositories.py +906 -0
- infinity_context_adapters/postgres/repository_helpers.py +115 -0
- infinity_context_adapters/postgres/scope_repositories.py +540 -0
- infinity_context_adapters/postgres/unit_of_work.py +785 -0
- infinity_context_adapters/postgres/usage_repositories.py +128 -0
- infinity_context_adapters/postgres/user_repositories.py +164 -0
- infinity_context_adapters/provider_errors.py +73 -0
- infinity_context_adapters/qdrant/__init__.py +5 -0
- infinity_context_adapters/qdrant/identity_evidence.py +504 -0
- infinity_context_adapters/qdrant/vector_adapter.py +718 -0
- infinity_context_adapters/s3_blob.py +242 -0
- infinity_context_cli/__init__.py +5 -0
- infinity_context_cli/__main__.py +6 -0
- infinity_context_cli/cli.py +964 -0
- infinity_context_cli/config.py +184 -0
- infinity_context_cli/doctor.py +397 -0
- infinity_context_cli/local_experience.py +250 -0
- infinity_context_cli/mcp_config.py +124 -0
- infinity_context_cli/onboarding.py +542 -0
- infinity_context_cli/runtime.py +179 -0
- infinity_context_contracts/__init__.py +16 -0
- infinity_context_contracts/_json.py +32 -0
- infinity_context_contracts/capabilities.py +67 -0
- infinity_context_contracts/common.py +54 -0
- infinity_context_contracts/features/__init__.py +12 -0
- infinity_context_contracts/features/context_building.py +248 -0
- infinity_context_contracts/features/document_ingestion.py +277 -0
- infinity_context_contracts/features/memory_facts.py +236 -0
- infinity_context_contracts/features/memory_scopes.py +329 -0
- infinity_context_contracts/health.py +23 -0
- infinity_context_core/__init__.py +76 -0
- infinity_context_core/agent_behavior_contract.py +72 -0
- infinity_context_core/application/__init__.py +580 -0
- infinity_context_core/application/anchor_creative_work_filters.py +148 -0
- infinity_context_core/application/anchor_event_extraction.py +1571 -0
- infinity_context_core/application/anchor_extraction.py +1144 -0
- infinity_context_core/application/anchor_identity_normalization.py +90 -0
- infinity_context_core/application/anchor_relation_projection.py +203 -0
- infinity_context_core/application/anchor_temporal_window.py +172 -0
- infinity_context_core/application/asset_extraction_mapping.py +236 -0
- infinity_context_core/application/asset_upload_policy.py +952 -0
- infinity_context_core/application/auto_apply.py +72 -0
- infinity_context_core/application/auto_memory.py +527 -0
- infinity_context_core/application/capture_policy.py +61 -0
- infinity_context_core/application/chunker.py +93 -0
- infinity_context_core/application/context_action_role_evidence.py +890 -0
- infinity_context_core/application/context_action_role_labels.py +176 -0
- infinity_context_core/application/context_action_roles.py +2365 -0
- infinity_context_core/application/context_action_subject_policy.py +71 -0
- infinity_context_core/application/context_activity_companion.py +120 -0
- infinity_context_core/application/context_activity_duration_rerank.py +118 -0
- infinity_context_core/application/context_activity_participant_grounding.py +87 -0
- infinity_context_core/application/context_aggregation_answer_slots.py +586 -0
- infinity_context_core/application/context_aggregation_evidence_text.py +409 -0
- infinity_context_core/application/context_aggregation_rerank.py +145 -0
- infinity_context_core/application/context_aggregation_subject.py +137 -0
- infinity_context_core/application/context_allergy_condition_inference.py +146 -0
- infinity_context_core/application/context_anchor_identity.py +157 -0
- infinity_context_core/application/context_anchor_intent_ranking.py +84 -0
- infinity_context_core/application/context_anchor_relations.py +67 -0
- infinity_context_core/application/context_anchors.py +393 -0
- infinity_context_core/application/context_answer_evidence_types.py +14 -0
- infinity_context_core/application/context_answer_unit_shapes.py +207 -0
- infinity_context_core/application/context_artifact_evidence.py +893 -0
- infinity_context_core/application/context_attribution_lexicon.py +254 -0
- infinity_context_core/application/context_awareness_cause_rerank.py +109 -0
- infinity_context_core/application/context_baby_birth_evidence.py +91 -0
- infinity_context_core/application/context_birdwatching_schedule_rerank.py +130 -0
- infinity_context_core/application/context_bm25_ranking.py +450 -0
- infinity_context_core/application/context_book_author_preference_exact_turns.py +110 -0
- infinity_context_core/application/context_building_legacy_candidate_adapter.py +530 -0
- infinity_context_core/application/context_canonical_fact_retrieval.py +409 -0
- infinity_context_core/application/context_causal_reason_rerank.py +145 -0
- infinity_context_core/application/context_choice_reason_rerank.py +109 -0
- infinity_context_core/application/context_collectors.py +931 -0
- infinity_context_core/application/context_commonality_rerank.py +428 -0
- infinity_context_core/application/context_community_membership_inference.py +139 -0
- infinity_context_core/application/context_competition_count_exact_turns.py +383 -0
- infinity_context_core/application/context_conflicting_evidence_rerank.py +282 -0
- infinity_context_core/application/context_conversation_counterparty.py +260 -0
- infinity_context_core/application/context_count_cardinality.py +164 -0
- infinity_context_core/application/context_creative_work_count_exact_turns.py +517 -0
- infinity_context_core/application/context_diagnostics.py +55 -0
- infinity_context_core/application/context_diagnostics_bundle_keys.py +433 -0
- infinity_context_core/application/context_diagnostics_bundle_projection.py +711 -0
- infinity_context_core/application/context_diagnostics_item_projection.py +410 -0
- infinity_context_core/application/context_diagnostics_primitives.py +131 -0
- infinity_context_core/application/context_diagnostics_ranking.py +143 -0
- infinity_context_core/application/context_diagnostics_signals.py +209 -0
- infinity_context_core/application/context_diagnostics_sources.py +82 -0
- infinity_context_core/application/context_dialogue_authority.py +382 -0
- infinity_context_core/application/context_distinct_set_evidence.py +994 -0
- infinity_context_core/application/context_distinct_set_selection.py +335 -0
- infinity_context_core/application/context_domain_rerank_apply.py +310 -0
- infinity_context_core/application/context_domain_rerank_signals.py +2391 -0
- infinity_context_core/application/context_domain_rerank_types.py +14 -0
- infinity_context_core/application/context_english_activity_displacement_answer_support.py +128 -0
- infinity_context_core/application/context_english_lifestyle_inference.py +122 -0
- infinity_context_core/application/context_english_lifestyle_inference_answer_support.py +291 -0
- infinity_context_core/application/context_english_temporal_dates.py +53 -0
- infinity_context_core/application/context_evidence_priority.py +262 -0
- infinity_context_core/application/context_evidence_reservation_safety.py +208 -0
- infinity_context_core/application/context_exercise_performance_rerank.py +71 -0
- infinity_context_core/application/context_food_inventory_exact_turns.py +583 -0
- infinity_context_core/application/context_frequency_rerank.py +109 -0
- infinity_context_core/application/context_future_plan_timing_rerank.py +110 -0
- infinity_context_core/application/context_generic_behavior_inference.py +348 -0
- infinity_context_core/application/context_geo_residence_aliases.py +149 -0
- infinity_context_core/application/context_hydration.py +329 -0
- infinity_context_core/application/context_identity_fact_rerank.py +362 -0
- infinity_context_core/application/context_identity_rerank.py +76 -0
- infinity_context_core/application/context_identity_terms.py +15 -0
- infinity_context_core/application/context_inference_evidence.py +484 -0
- infinity_context_core/application/context_inference_evidence_terms.py +744 -0
- infinity_context_core/application/context_internal_diagnostics.py +61 -0
- infinity_context_core/application/context_item_evidence.py +108 -0
- infinity_context_core/application/context_item_purchase_evidence.py +49 -0
- infinity_context_core/application/context_keyword_aggregation_prefilter.py +63 -0
- infinity_context_core/application/context_keyword_ranking.py +178 -0
- infinity_context_core/application/context_lexical.py +750 -0
- infinity_context_core/application/context_lifecycle_rerank.py +502 -0
- infinity_context_core/application/context_link_candidate_policy.py +864 -0
- infinity_context_core/application/context_link_expansion.py +727 -0
- infinity_context_core/application/context_link_expansion_items.py +441 -0
- infinity_context_core/application/context_link_policy.py +451 -0
- infinity_context_core/application/context_link_source_enrichment.py +120 -0
- infinity_context_core/application/context_media_time.py +368 -0
- infinity_context_core/application/context_museum_visit_policy.py +66 -0
- infinity_context_core/application/context_named_person_preference.py +313 -0
- infinity_context_core/application/context_national_park_inference.py +93 -0
- infinity_context_core/application/context_object_attribute_rerank.py +416 -0
- infinity_context_core/application/context_object_mismatch.py +63 -0
- infinity_context_core/application/context_occupational_role_identity.py +961 -0
- infinity_context_core/application/context_ordinal_sequence.py +134 -0
- infinity_context_core/application/context_owner_grounding.py +408 -0
- infinity_context_core/application/context_packer.py +858 -0
- infinity_context_core/application/context_packer_answer_slots.py +733 -0
- infinity_context_core/application/context_packer_answer_support.py +3101 -0
- infinity_context_core/application/context_packer_answer_support_patterns.py +1267 -0
- infinity_context_core/application/context_packer_answer_support_slots.py +1209 -0
- infinity_context_core/application/context_packer_answer_support_utils.py +473 -0
- infinity_context_core/application/context_packer_diagnostics.py +48 -0
- infinity_context_core/application/context_packer_exact_literal_turns.py +697 -0
- infinity_context_core/application/context_packer_exact_prepasses.py +758 -0
- infinity_context_core/application/context_packer_exact_turn_utils.py +133 -0
- infinity_context_core/application/context_packer_identity_policy.py +155 -0
- infinity_context_core/application/context_packer_inference_reservation.py +113 -0
- infinity_context_core/application/context_packer_inventory_prepasses.py +359 -0
- infinity_context_core/application/context_packer_inventory_slots.py +771 -0
- infinity_context_core/application/context_packer_marker_coverage.py +409 -0
- infinity_context_core/application/context_packer_rendering.py +338 -0
- infinity_context_core/application/context_packer_selection.py +487 -0
- infinity_context_core/application/context_packer_source_policy.py +123 -0
- infinity_context_core/application/context_paired_evidence_requirements.py +78 -0
- infinity_context_core/application/context_paired_evidence_roles.py +64 -0
- infinity_context_core/application/context_person_activity_exact_turns.py +375 -0
- infinity_context_core/application/context_person_aliases.py +49 -0
- infinity_context_core/application/context_person_kinship.py +296 -0
- infinity_context_core/application/context_person_occupation.py +240 -0
- infinity_context_core/application/context_person_relation_inventory.py +755 -0
- infinity_context_core/application/context_person_residence.py +398 -0
- infinity_context_core/application/context_person_team_membership.py +305 -0
- infinity_context_core/application/context_pet_ownership.py +223 -0
- infinity_context_core/application/context_polarity_rerank.py +338 -0
- infinity_context_core/application/context_policy.py +107 -0
- infinity_context_core/application/context_political_inference.py +128 -0
- infinity_context_core/application/context_possession_source.py +161 -0
- infinity_context_core/application/context_precise_temporal_evidence.py +156 -0
- infinity_context_core/application/context_preference_goal_rerank.py +428 -0
- infinity_context_core/application/context_preference_inference.py +335 -0
- infinity_context_core/application/context_property_interaction_evidence.py +659 -0
- infinity_context_core/application/context_provider_retrieval_terms.py +95 -0
- infinity_context_core/application/context_quality.py +488 -0
- infinity_context_core/application/context_quantity_evidence_patterns.py +254 -0
- infinity_context_core/application/context_quantity_evidence_slots.py +750 -0
- infinity_context_core/application/context_quantity_pending_clothing.py +200 -0
- infinity_context_core/application/context_query_artifact_inventory_expansions.py +76 -0
- infinity_context_core/application/context_query_decomposition.py +879 -0
- infinity_context_core/application/context_query_decomposition_answer_policy.py +707 -0
- infinity_context_core/application/context_query_decomposition_contracts.py +28 -0
- infinity_context_core/application/context_query_decomposition_event_policy.py +535 -0
- infinity_context_core/application/context_query_decomposition_inventory_policy.py +767 -0
- infinity_context_core/application/context_query_decomposition_shared.py +300 -0
- infinity_context_core/application/context_query_duration.py +171 -0
- infinity_context_core/application/context_query_entity_relation_expansions.py +212 -0
- infinity_context_core/application/context_query_event_summary_expansions.py +80 -0
- infinity_context_core/application/context_query_expansion.py +200 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part1.py +1279 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part2.py +770 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part3.py +982 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part4.py +1334 -0
- infinity_context_core/application/context_query_expansion_rule_catalog_part5.py +517 -0
- infinity_context_core/application/context_query_expansion_rule_terms.py +269 -0
- infinity_context_core/application/context_query_expansion_rules.py +66 -0
- infinity_context_core/application/context_query_expansion_selection.py +892 -0
- infinity_context_core/application/context_query_financial_resources_inference.py +92 -0
- infinity_context_core/application/context_query_food_expansions.py +89 -0
- infinity_context_core/application/context_query_frequency.py +194 -0
- infinity_context_core/application/context_query_game_expansions.py +141 -0
- infinity_context_core/application/context_query_health_lifestyle_expansions.py +178 -0
- infinity_context_core/application/context_query_identity_terms.py +81 -0
- infinity_context_core/application/context_query_intent.py +33 -0
- infinity_context_core/application/context_query_intent_common.py +29 -0
- infinity_context_core/application/context_query_intent_contracts.py +92 -0
- infinity_context_core/application/context_query_intent_extraction.py +614 -0
- infinity_context_core/application/context_query_intent_keys.py +499 -0
- infinity_context_core/application/context_query_intent_matching.py +407 -0
- infinity_context_core/application/context_query_organization_summary_expansions.py +75 -0
- infinity_context_core/application/context_query_personal_fact_expansions.py +314 -0
- infinity_context_core/application/context_query_pet_activity_expansions.py +329 -0
- infinity_context_core/application/context_query_preference_expansions.py +97 -0
- infinity_context_core/application/context_query_project_summary_expansions.py +60 -0
- infinity_context_core/application/context_query_relevance_ranking.py +76 -0
- infinity_context_core/application/context_query_sports_expansions.py +48 -0
- infinity_context_core/application/context_query_state_transition.py +53 -0
- infinity_context_core/application/context_query_support_role.py +165 -0
- infinity_context_core/application/context_query_temporal_expansions.py +18 -0
- infinity_context_core/application/context_query_travel_expansions.py +134 -0
- infinity_context_core/application/context_query_vehicle_expansions.py +79 -0
- infinity_context_core/application/context_query_workflow_expansions.py +233 -0
- infinity_context_core/application/context_query_workflow_intent.py +65 -0
- infinity_context_core/application/context_quote_scanner.py +342 -0
- infinity_context_core/application/context_rank_dedupe.py +171 -0
- infinity_context_core/application/context_rank_fusion.py +191 -0
- infinity_context_core/application/context_ranked_activity_reservation.py +586 -0
- infinity_context_core/application/context_ranked_evidence_coverage_reservation.py +427 -0
- infinity_context_core/application/context_ranked_evidence_priority_reservation.py +37 -0
- infinity_context_core/application/context_ranked_evidence_selection.py +260 -0
- infinity_context_core/application/context_ranking.py +3681 -0
- infinity_context_core/application/context_ranking_reason_policy.py +31 -0
- infinity_context_core/application/context_ranking_reason_priorities.py +859 -0
- infinity_context_core/application/context_ranking_reason_scores.py +519 -0
- infinity_context_core/application/context_recommendation_answer_support.py +358 -0
- infinity_context_core/application/context_recommendation_exact_turns.py +360 -0
- infinity_context_core/application/context_relation_requirement.py +498 -0
- infinity_context_core/application/context_relationship_status_evidence.py +83 -0
- infinity_context_core/application/context_relative_duration_evidence.py +61 -0
- infinity_context_core/application/context_relevance.py +430 -0
- infinity_context_core/application/context_reported_obligation_attribution.py +416 -0
- infinity_context_core/application/context_reporting_frames.py +338 -0
- infinity_context_core/application/context_requirement_coverage.py +767 -0
- infinity_context_core/application/context_requirement_guard.py +503 -0
- infinity_context_core/application/context_requirement_patterns.py +943 -0
- infinity_context_core/application/context_requirement_ranking.py +181 -0
- infinity_context_core/application/context_requirement_signals.py +101 -0
- infinity_context_core/application/context_rerank_domain_heuristics.py +433 -0
- infinity_context_core/application/context_rerank_evidence_signals.py +400 -0
- infinity_context_core/application/context_rerank_relevance.py +131 -0
- infinity_context_core/application/context_retrieval_performance.py +153 -0
- infinity_context_core/application/context_review_items.py +338 -0
- infinity_context_core/application/context_score_signal_rerank.py +21 -0
- infinity_context_core/application/context_short_story_progress_evidence.py +119 -0
- infinity_context_core/application/context_snippets.py +545 -0
- infinity_context_core/application/context_social_education_inference.py +265 -0
- infinity_context_core/application/context_social_inventory_rerank.py +329 -0
- infinity_context_core/application/context_source_family.py +100 -0
- infinity_context_core/application/context_source_grounding.py +277 -0
- infinity_context_core/application/context_source_sibling_answer_evidence_repair.py +1983 -0
- infinity_context_core/application/context_source_sibling_contracts.py +35 -0
- infinity_context_core/application/context_source_sibling_evidence.py +405 -0
- infinity_context_core/application/context_source_sibling_evidence_rules.py +798 -0
- infinity_context_core/application/context_source_sibling_evidence_shared.py +449 -0
- infinity_context_core/application/context_source_sibling_identity.py +114 -0
- infinity_context_core/application/context_source_sibling_inventory_evidence.py +28 -0
- infinity_context_core/application/context_source_sibling_patterns.py +946 -0
- infinity_context_core/application/context_source_sibling_place_evidence.py +561 -0
- infinity_context_core/application/context_source_sibling_policy.py +988 -0
- infinity_context_core/application/context_source_sibling_scoring.py +721 -0
- infinity_context_core/application/context_source_siblings.py +363 -0
- infinity_context_core/application/context_speaker_attribution.py +574 -0
- infinity_context_core/application/context_speaker_disambiguation.py +108 -0
- infinity_context_core/application/context_stage_diagnostics.py +111 -0
- infinity_context_core/application/context_state_evidence.py +196 -0
- infinity_context_core/application/context_state_residence_inference.py +163 -0
- infinity_context_core/application/context_state_transition_pairing.py +401 -0
- infinity_context_core/application/context_temporal_answer_grounding.py +187 -0
- infinity_context_core/application/context_temporal_hints.py +485 -0
- infinity_context_core/application/context_temporal_intent_policy.py +146 -0
- infinity_context_core/application/context_temporal_interval_requirements.py +107 -0
- infinity_context_core/application/context_temporal_metadata.py +29 -0
- infinity_context_core/application/context_temporal_query.py +1358 -0
- infinity_context_core/application/context_temporal_ranges.py +471 -0
- infinity_context_core/application/context_temporal_session_order.py +439 -0
- infinity_context_core/application/context_temporal_source_identity.py +426 -0
- infinity_context_core/application/context_temporal_source_turn.py +1290 -0
- infinity_context_core/application/context_temporal_source_turn_labels.py +265 -0
- infinity_context_core/application/context_temporal_source_turn_patterns.py +186 -0
- infinity_context_core/application/context_temporal_source_turn_types.py +62 -0
- infinity_context_core/application/context_travel_hobby_writing_evidence.py +176 -0
- infinity_context_core/application/context_travel_place_evidence.py +23 -0
- infinity_context_core/application/document_fragments.py +206 -0
- infinity_context_core/application/document_text.py +203 -0
- infinity_context_core/application/dto.py +311 -0
- infinity_context_core/application/dto_anchors.py +143 -0
- infinity_context_core/application/dto_assets.py +234 -0
- infinity_context_core/application/dto_benchmark_runs.py +114 -0
- infinity_context_core/application/dto_context.py +176 -0
- infinity_context_core/application/dto_context_links.py +170 -0
- infinity_context_core/application/dto_facts.py +275 -0
- infinity_context_core/application/dto_suggestions_capture.py +199 -0
- infinity_context_core/application/dto_workspace.py +101 -0
- infinity_context_core/application/extraction_coordinates.py +56 -0
- infinity_context_core/application/extraction_resource_policy.py +796 -0
- infinity_context_core/application/extractor.py +147 -0
- infinity_context_core/application/memory_digest_renderer.py +215 -0
- infinity_context_core/application/multimodal_manifest.py +418 -0
- infinity_context_core/application/normalize.py +29 -0
- infinity_context_core/application/observed_anchor_resolution.py +243 -0
- infinity_context_core/application/related_facts.py +144 -0
- infinity_context_core/application/review_payloads.py +104 -0
- infinity_context_core/application/safe_payload.py +86 -0
- infinity_context_core/application/semantic_dedupe.py +943 -0
- infinity_context_core/application/sensitive_text.py +39 -0
- infinity_context_core/application/source_refs.py +263 -0
- infinity_context_core/application/storage_key_safety.py +13 -0
- infinity_context_core/application/temporal_validity.py +31 -0
- infinity_context_core/application/use_cases/__init__.py +1 -0
- infinity_context_core/application/use_cases/anchors.py +1165 -0
- infinity_context_core/application/use_cases/asset_extraction_support.py +273 -0
- infinity_context_core/application/use_cases/asset_extractions.py +1454 -0
- infinity_context_core/application/use_cases/assets.py +463 -0
- infinity_context_core/application/use_cases/benchmark_runs.py +877 -0
- infinity_context_core/application/use_cases/benchmark_unsealed_abort.py +147 -0
- infinity_context_core/application/use_cases/blob_storage_cleanup.py +289 -0
- infinity_context_core/application/use_cases/blob_storage_integrity.py +351 -0
- infinity_context_core/application/use_cases/build_context.py +995 -0
- infinity_context_core/application/use_cases/build_context_final_packing.py +59 -0
- infinity_context_core/application/use_cases/build_context_item_projection.py +839 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation.py +908 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation_seeds.py +132 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation_selection.py +280 -0
- infinity_context_core/application/use_cases/build_context_keyword_aggregation_support.py +161 -0
- infinity_context_core/application/use_cases/build_context_requirement_guard.py +156 -0
- infinity_context_core/application/use_cases/build_context_source_selection.py +935 -0
- infinity_context_core/application/use_cases/build_memory_digest.py +203 -0
- infinity_context_core/application/use_cases/build_memory_insights.py +979 -0
- infinity_context_core/application/use_cases/consolidate_capture.py +806 -0
- infinity_context_core/application/use_cases/context_link_crud.py +196 -0
- infinity_context_core/application/use_cases/context_link_reviews.py +441 -0
- infinity_context_core/application/use_cases/context_link_suggestions.py +1060 -0
- infinity_context_core/application/use_cases/context_link_visibility.py +106 -0
- infinity_context_core/application/use_cases/context_links.py +33 -0
- infinity_context_core/application/use_cases/delete_document.py +71 -0
- infinity_context_core/application/use_cases/delete_thread_memory.py +55 -0
- infinity_context_core/application/use_cases/duplicate_merge_resolution.py +307 -0
- infinity_context_core/application/use_cases/ensure_scope.py +29 -0
- infinity_context_core/application/use_cases/expire_suggestions.py +36 -0
- infinity_context_core/application/use_cases/export_graph.py +684 -0
- infinity_context_core/application/use_cases/fact_relations.py +204 -0
- infinity_context_core/application/use_cases/forget_fact.py +43 -0
- infinity_context_core/application/use_cases/get_capabilities.py +213 -0
- infinity_context_core/application/use_cases/get_capture.py +16 -0
- infinity_context_core/application/use_cases/get_session_status.py +23 -0
- infinity_context_core/application/use_cases/ingest_document.py +376 -0
- infinity_context_core/application/use_cases/ingest_episode.py +263 -0
- infinity_context_core/application/use_cases/list_captures.py +25 -0
- infinity_context_core/application/use_cases/memory_browser.py +414 -0
- infinity_context_core/application/use_cases/operations_console.py +293 -0
- infinity_context_core/application/use_cases/process_document.py +83 -0
- infinity_context_core/application/use_cases/purge_capture.py +34 -0
- infinity_context_core/application/use_cases/query_documents.py +42 -0
- infinity_context_core/application/use_cases/query_facts.py +57 -0
- infinity_context_core/application/use_cases/receive_capture.py +238 -0
- infinity_context_core/application/use_cases/related_facts.py +47 -0
- infinity_context_core/application/use_cases/remember_fact.py +145 -0
- infinity_context_core/application/use_cases/spaces_memory_scopes.py +134 -0
- infinity_context_core/application/use_cases/suggestions.py +804 -0
- infinity_context_core/application/use_cases/update_fact.py +43 -0
- infinity_context_core/application/use_cases/usage.py +49 -0
- infinity_context_core/application/use_cases/users.py +138 -0
- infinity_context_core/domain/__init__.py +1 -0
- infinity_context_core/domain/aggregation_admission.py +200 -0
- infinity_context_core/domain/anchor_entities.py +316 -0
- infinity_context_core/domain/assets.py +654 -0
- infinity_context_core/domain/capture.py +321 -0
- infinity_context_core/domain/distinct_set_membership.py +69 -0
- infinity_context_core/domain/entities.py +103 -0
- infinity_context_core/domain/entity_policies.py +119 -0
- infinity_context_core/domain/entity_types.py +150 -0
- infinity_context_core/domain/errors.py +53 -0
- infinity_context_core/domain/events.py +14 -0
- infinity_context_core/domain/extraction.py +529 -0
- infinity_context_core/domain/idempotency.py +12 -0
- infinity_context_core/domain/memory_item_entities.py +426 -0
- infinity_context_core/domain/source_refs.py +91 -0
- infinity_context_core/domain/suggestion_entities.py +236 -0
- infinity_context_core/domain/taxonomy.py +121 -0
- infinity_context_core/domain/usage.py +221 -0
- infinity_context_core/domain/workspace_entities.py +269 -0
- infinity_context_core/features/__init__.py +7 -0
- infinity_context_core/features/context_building/__init__.py +3 -0
- infinity_context_core/features/context_building/application/__init__.py +92 -0
- infinity_context_core/features/context_building/application/candidate_fusion.py +136 -0
- infinity_context_core/features/context_building/application/coverage_reservation_selector.py +212 -0
- infinity_context_core/features/context_building/application/handlers.py +155 -0
- infinity_context_core/features/context_building/application/inference_evidence_reservation.py +592 -0
- infinity_context_core/features/context_building/application/provider_pipeline.py +61 -0
- infinity_context_core/features/context_building/application/queries.py +107 -0
- infinity_context_core/features/context_building/application/use_cases.py +78 -0
- infinity_context_core/features/context_building/domain/__init__.py +95 -0
- infinity_context_core/features/context_building/domain/budget.py +97 -0
- infinity_context_core/features/context_building/domain/context.py +157 -0
- infinity_context_core/features/context_building/domain/evidence_obligations.py +60 -0
- infinity_context_core/features/context_building/domain/feature.py +15 -0
- infinity_context_core/features/context_building/domain/prompt_sections.py +150 -0
- infinity_context_core/features/context_building/domain/query_pipeline.py +276 -0
- infinity_context_core/features/context_building/domain/rendering.py +102 -0
- infinity_context_core/features/context_building/ports/__init__.py +8 -0
- infinity_context_core/features/context_building/ports/candidates.py +36 -0
- infinity_context_core/features/context_building/public.py +165 -0
- infinity_context_core/features/context_building/tests/test_application_ports_public_skeleton.py +575 -0
- infinity_context_core/features/context_building/tests/test_domain_context_building_skeleton.py +402 -0
- infinity_context_core/features/document_ingestion/__init__.py +3 -0
- infinity_context_core/features/document_ingestion/application/__init__.py +31 -0
- infinity_context_core/features/document_ingestion/application/commands.py +62 -0
- infinity_context_core/features/document_ingestion/application/use_cases.py +273 -0
- infinity_context_core/features/document_ingestion/domain/__init__.py +61 -0
- infinity_context_core/features/document_ingestion/domain/chunking.py +297 -0
- infinity_context_core/features/document_ingestion/domain/errors.py +22 -0
- infinity_context_core/features/document_ingestion/domain/feature.py +18 -0
- infinity_context_core/features/document_ingestion/domain/source_document.py +228 -0
- infinity_context_core/features/document_ingestion/ports/__init__.py +21 -0
- infinity_context_core/features/document_ingestion/ports/indexing.py +51 -0
- infinity_context_core/features/document_ingestion/ports/repositories.py +56 -0
- infinity_context_core/features/document_ingestion/public.py +95 -0
- infinity_context_core/features/document_ingestion/tests/test_application_handlers.py +226 -0
- infinity_context_core/features/document_ingestion/tests/test_application_ports_public_skeleton.py +334 -0
- infinity_context_core/features/document_ingestion/tests/test_domain_chunking_skeleton.py +79 -0
- infinity_context_core/features/document_ingestion/tests/test_domain_source_document_skeleton.py +101 -0
- infinity_context_core/features/memory_facts/__init__.py +3 -0
- infinity_context_core/features/memory_facts/application/__init__.py +37 -0
- infinity_context_core/features/memory_facts/application/commands.py +89 -0
- infinity_context_core/features/memory_facts/application/handlers.py +241 -0
- infinity_context_core/features/memory_facts/application/use_cases.py +47 -0
- infinity_context_core/features/memory_facts/domain/__init__.py +35 -0
- infinity_context_core/features/memory_facts/domain/fact.py +98 -0
- infinity_context_core/features/memory_facts/domain/feature.py +15 -0
- infinity_context_core/features/memory_facts/ports/__init__.py +31 -0
- infinity_context_core/features/memory_facts/ports/clock.py +14 -0
- infinity_context_core/features/memory_facts/ports/ids.py +19 -0
- infinity_context_core/features/memory_facts/ports/outbox.py +26 -0
- infinity_context_core/features/memory_facts/ports/repositories.py +30 -0
- infinity_context_core/features/memory_facts/ports/unit_of_work.py +43 -0
- infinity_context_core/features/memory_facts/public.py +79 -0
- infinity_context_core/features/memory_facts/tests/test_application_handlers.py +332 -0
- infinity_context_core/features/memory_facts/tests/test_application_ports_public_skeleton.py +318 -0
- infinity_context_core/features/memory_facts/tests/test_domain_fact_skeleton.py +222 -0
- infinity_context_core/features/memory_scopes/__init__.py +3 -0
- infinity_context_core/features/memory_scopes/application/__init__.py +55 -0
- infinity_context_core/features/memory_scopes/application/commands.py +102 -0
- infinity_context_core/features/memory_scopes/application/errors.py +27 -0
- infinity_context_core/features/memory_scopes/application/handlers.py +226 -0
- infinity_context_core/features/memory_scopes/application/use_cases.py +68 -0
- infinity_context_core/features/memory_scopes/domain/__init__.py +59 -0
- infinity_context_core/features/memory_scopes/domain/errors.py +22 -0
- infinity_context_core/features/memory_scopes/domain/feature.py +18 -0
- infinity_context_core/features/memory_scopes/domain/policies.py +197 -0
- infinity_context_core/features/memory_scopes/domain/scope.py +178 -0
- infinity_context_core/features/memory_scopes/ports/__init__.py +25 -0
- infinity_context_core/features/memory_scopes/ports/clock.py +14 -0
- infinity_context_core/features/memory_scopes/ports/ids.py +13 -0
- infinity_context_core/features/memory_scopes/ports/repositories.py +40 -0
- infinity_context_core/features/memory_scopes/ports/unit_of_work.py +39 -0
- infinity_context_core/features/memory_scopes/public.py +111 -0
- infinity_context_core/features/memory_scopes/tests/test_application_ports_public_skeleton.py +824 -0
- infinity_context_core/features/memory_scopes/tests/test_domain_scope_skeleton.py +428 -0
- infinity_context_core/memory_scope_snapshot_preview.py +863 -0
- infinity_context_core/memory_scope_snapshots.py +206 -0
- infinity_context_core/ports/__init__.py +164 -0
- infinity_context_core/ports/adapters.py +217 -0
- infinity_context_core/ports/assets.py +270 -0
- infinity_context_core/ports/auth.py +68 -0
- infinity_context_core/ports/auto_memory.py +71 -0
- infinity_context_core/ports/benchmark_runs.py +205 -0
- infinity_context_core/ports/capabilities.py +324 -0
- infinity_context_core/ports/captures.py +53 -0
- infinity_context_core/ports/clock.py +11 -0
- infinity_context_core/ports/derived_projection_policy.py +72 -0
- infinity_context_core/ports/extraction.py +201 -0
- infinity_context_core/ports/graph_evidence.py +170 -0
- infinity_context_core/ports/ids.py +11 -0
- infinity_context_core/ports/projection_fence.py +27 -0
- infinity_context_core/ports/repositories.py +563 -0
- infinity_context_core/ports/transcription.py +63 -0
- infinity_context_core/ports/unit_of_work.py +77 -0
- infinity_context_core/ports/usage.py +36 -0
- infinity_context_core/ports/vector_projection_evidence.py +230 -0
- infinity_context_core/ports/vision.py +36 -0
- infinity_context_core/processes/__init__.py +3 -0
- infinity_context_core/processes/document_memory_pipeline/__init__.py +3 -0
- infinity_context_core/processes/document_memory_pipeline/contracts.py +44 -0
- infinity_context_core/processes/document_memory_pipeline/process.py +72 -0
- infinity_context_core/processes/document_memory_pipeline/public.py +21 -0
- infinity_context_core/reporting.py +105 -0
- infinity_context_mcp/__init__.py +5 -0
- infinity_context_mcp/__main__.py +6 -0
- infinity_context_mcp/adapters/__init__.py +1 -0
- infinity_context_mcp/adapters/http_gateway.py +940 -0
- infinity_context_mcp/agent_behavior_bench.py +1731 -0
- infinity_context_mcp/agent_behavior_bench_metrics.py +419 -0
- infinity_context_mcp/agent_behavior_bench_redaction.py +149 -0
- infinity_context_mcp/agent_behavior_bench_types.py +127 -0
- infinity_context_mcp/agent_behavior_scenarios.py +35 -0
- infinity_context_mcp/agent_behavior_scenarios_core.py +484 -0
- infinity_context_mcp/agent_behavior_scenarios_realistic.py +473 -0
- infinity_context_mcp/agent_behavior_scenarios_transcript.py +196 -0
- infinity_context_mcp/agent_behavior_transcripts.py +231 -0
- infinity_context_mcp/agent_behavior_types.py +66 -0
- infinity_context_mcp/agent_behavior_utils.py +29 -0
- infinity_context_mcp/application/__init__.py +1 -0
- infinity_context_mcp/application/context_link_review.py +109 -0
- infinity_context_mcp/application/local_runtime.py +473 -0
- infinity_context_mcp/application/normalization.py +36 -0
- infinity_context_mcp/application/obsidian.py +568 -0
- infinity_context_mcp/application/policy.py +160 -0
- infinity_context_mcp/application/ports.py +324 -0
- infinity_context_mcp/application/prepare.py +254 -0
- infinity_context_mcp/application/readiness.py +71 -0
- infinity_context_mcp/application/review_batch.py +62 -0
- infinity_context_mcp/application/service.py +701 -0
- infinity_context_mcp/application/service_base.py +29 -0
- infinity_context_mcp/application/service_constants.py +89 -0
- infinity_context_mcp/application/service_context_links.py +224 -0
- infinity_context_mcp/application/service_duplicates.py +62 -0
- infinity_context_mcp/application/service_facts.py +461 -0
- infinity_context_mcp/application/service_helpers.py +179 -0
- infinity_context_mcp/application/service_lifecycle.py +348 -0
- infinity_context_mcp/application/service_policy.py +74 -0
- infinity_context_mcp/application/service_query.py +384 -0
- infinity_context_mcp/application/service_resources.py +192 -0
- infinity_context_mcp/application/service_response.py +95 -0
- infinity_context_mcp/application/service_scope.py +132 -0
- infinity_context_mcp/application/service_suggestions.py +820 -0
- infinity_context_mcp/application/suggest_batch.py +71 -0
- infinity_context_mcp/application/usage_guide.py +74 -0
- infinity_context_mcp/bench.py +279 -0
- infinity_context_mcp/config.py +213 -0
- infinity_context_mcp/domain/__init__.py +1 -0
- infinity_context_mcp/domain/context_links.py +117 -0
- infinity_context_mcp/domain/local_runtime_models.py +56 -0
- infinity_context_mcp/domain/memory_browser.py +35 -0
- infinity_context_mcp/domain/models.py +1036 -0
- infinity_context_mcp/domain/obsidian_models.py +67 -0
- infinity_context_mcp/domain/policy.py +112 -0
- infinity_context_mcp/domain/prepare_models.py +24 -0
- infinity_context_mcp/plugin_hook.py +873 -0
- infinity_context_mcp/plugin_hook_settings.py +253 -0
- infinity_context_mcp/server.py +133 -0
- infinity_context_mcp/server_context_tools.py +404 -0
- infinity_context_mcp/server_fact_tools.py +928 -0
- infinity_context_mcp/server_hardening.py +54 -0
- infinity_context_mcp/server_local_runtime_tools.py +164 -0
- infinity_context_mcp/server_obsidian_tools.py +380 -0
- infinity_context_mcp/server_query_tools.py +626 -0
- infinity_context_mcp/server_request_mapping.py +73 -0
- infinity_context_mcp/server_resources.py +187 -0
- infinity_context_mcp/server_response.py +26 -0
- infinity_context_obsidian/__init__.py +5 -0
- infinity_context_obsidian/cli.py +594 -0
- infinity_context_obsidian/conflicts.py +110 -0
- infinity_context_obsidian/doctor.py +319 -0
- infinity_context_obsidian/domain.py +92 -0
- infinity_context_obsidian/frontmatter.py +68 -0
- infinity_context_obsidian/gateway.py +66 -0
- infinity_context_obsidian/layout.py +179 -0
- infinity_context_obsidian/note_format.py +159 -0
- infinity_context_obsidian/plugin_bundle/__init__.py +1 -0
- infinity_context_obsidian/plugin_bundle/main.js +5 -0
- infinity_context_obsidian/plugin_bundle/manifest.json +10 -0
- infinity_context_obsidian/plugin_bundle/styles.css +123 -0
- infinity_context_obsidian/plugin_install.py +139 -0
- infinity_context_obsidian/ports.py +72 -0
- infinity_context_obsidian/setup.py +202 -0
- infinity_context_obsidian/state.py +85 -0
- infinity_context_obsidian/sync.py +741 -0
- infinity_context_obsidian/vault.py +61 -0
- infinity_context_sdk/__init__.py +1049 -0
- infinity_context_sdk/_payloads.py +401 -0
- infinity_context_sdk/_redaction.py +31 -0
- infinity_context_sdk/anchors.py +249 -0
- infinity_context_sdk/assets.py +554 -0
- infinity_context_sdk/capabilities.py +199 -0
- infinity_context_sdk/context.py +540 -0
- infinity_context_sdk/context_bundle_diagnostics.py +905 -0
- infinity_context_sdk/context_payload_utils.py +219 -0
- infinity_context_sdk/export.py +123 -0
- infinity_context_sdk/scopes.py +74 -0
- infinity_context_sdk/thread_memory.py +55 -0
- infinity_context_server/__init__.py +5 -0
- infinity_context_server/__main__.py +19 -0
- infinity_context_server/admin.py +832 -0
- infinity_context_server/admin_invariants.py +388 -0
- infinity_context_server/admin_outbox.py +130 -0
- infinity_context_server/admin_projection_repair.py +374 -0
- infinity_context_server/api/__init__.py +1 -0
- infinity_context_server/api/auth.py +432 -0
- infinity_context_server/api/dependencies.py +9 -0
- infinity_context_server/api/errors.py +94 -0
- infinity_context_server/api/legacy_client.py +356 -0
- infinity_context_server/api/policy.py +35 -0
- infinity_context_server/api/public_payload.py +27 -0
- infinity_context_server/api/v1/__init__.py +54 -0
- infinity_context_server/api/v1/anchors.py +469 -0
- infinity_context_server/api/v1/assets.py +409 -0
- infinity_context_server/api/v1/capabilities.py +144 -0
- infinity_context_server/api/v1/captures.py +329 -0
- infinity_context_server/api/v1/context.py +362 -0
- infinity_context_server/api/v1/context_links.py +611 -0
- infinity_context_server/api/v1/diagnostics.py +333 -0
- infinity_context_server/api/v1/digest.py +107 -0
- infinity_context_server/api/v1/documents.py +164 -0
- infinity_context_server/api/v1/episodes.py +146 -0
- infinity_context_server/api/v1/export.py +184 -0
- infinity_context_server/api/v1/facts.py +265 -0
- infinity_context_server/api/v1/health.py +24 -0
- infinity_context_server/api/v1/insights.py +100 -0
- infinity_context_server/api/v1/internal_memory_comparison_runs.py +406 -0
- infinity_context_server/api/v1/memory_browser.py +183 -0
- infinity_context_server/api/v1/operations.py +81 -0
- infinity_context_server/api/v1/scope_resolution.py +389 -0
- infinity_context_server/api/v1/source_refs.py +111 -0
- infinity_context_server/api/v1/spaces_memory_scopes.py +141 -0
- infinity_context_server/api/v1/suggestions.py +237 -0
- infinity_context_server/api/v1/thread_memory.py +74 -0
- infinity_context_server/api/v1/usage.py +75 -0
- infinity_context_server/api/v1/users.py +164 -0
- infinity_context_server/auth_scope.py +492 -0
- infinity_context_server/auth_tokens.py +283 -0
- infinity_context_server/backpressure.py +47 -0
- infinity_context_server/benchmark_projection_absence.py +155 -0
- infinity_context_server/benchmark_projection_delete_outbox.py +162 -0
- infinity_context_server/composition.py +897 -0
- infinity_context_server/config.py +223 -0
- infinity_context_server/db.py +39 -0
- infinity_context_server/deployment_readiness.py +205 -0
- infinity_context_server/derived_identity_evidence.py +987 -0
- infinity_context_server/derived_identity_target.py +39 -0
- infinity_context_server/derived_projection_policy.py +85 -0
- infinity_context_server/diagnostics.py +536 -0
- infinity_context_server/doctor.py +71 -0
- infinity_context_server/eval.py +3066 -0
- infinity_context_server/eval_auto_memory.py +1735 -0
- infinity_context_server/eval_auto_memory_metrics.py +224 -0
- infinity_context_server/eval_auto_memory_types.py +75 -0
- infinity_context_server/eval_case_catalog.py +1590 -0
- infinity_context_server/eval_case_runner.py +1100 -0
- infinity_context_server/eval_common.py +336 -0
- infinity_context_server/eval_constants.py +310 -0
- infinity_context_server/eval_fixtures.py +150 -0
- infinity_context_server/eval_graph.py +92 -0
- infinity_context_server/eval_hybrid.py +99 -0
- infinity_context_server/eval_multimodal_offline.py +697 -0
- infinity_context_server/eval_prompt_contract.py +402 -0
- infinity_context_server/eval_scorecard.py +2627 -0
- infinity_context_server/eval_semantic_linking.py +1526 -0
- infinity_context_server/eval_semantic_retrieval_api_canary.py +405 -0
- infinity_context_server/eval_semantic_retrieval_canary.py +359 -0
- infinity_context_server/eval_types.py +88 -0
- infinity_context_server/evidence_bundle.py +523 -0
- infinity_context_server/extraction_capabilities.py +1234 -0
- infinity_context_server/features/__init__.py +3 -0
- infinity_context_server/features/context_building/__init__.py +5 -0
- infinity_context_server/features/context_building/benchmark_budget.py +29 -0
- infinity_context_server/features/context_building/composition.py +49 -0
- infinity_context_server/features/context_building/context_requests.py +151 -0
- infinity_context_server/features/context_building/contracts.py +96 -0
- infinity_context_server/features/context_building/digest_api_responses.py +225 -0
- infinity_context_server/features/context_building/digest_requests.py +65 -0
- infinity_context_server/features/context_building/insights_api_responses.py +132 -0
- infinity_context_server/features/context_building/legacy_api_responses.py +875 -0
- infinity_context_server/features/context_building/mappers.py +205 -0
- infinity_context_server/features/context_building/public.py +66 -0
- infinity_context_server/features/context_building/routes.py +44 -0
- infinity_context_server/features/document_ingestion/__init__.py +5 -0
- infinity_context_server/features/document_ingestion/asset_requests.py +45 -0
- infinity_context_server/features/document_ingestion/asset_responses.py +365 -0
- infinity_context_server/features/document_ingestion/composition.py +49 -0
- infinity_context_server/features/document_ingestion/contracts.py +104 -0
- infinity_context_server/features/document_ingestion/mappers.py +386 -0
- infinity_context_server/features/document_ingestion/public.py +58 -0
- infinity_context_server/features/document_ingestion/routes.py +44 -0
- infinity_context_server/features/memory_facts/__init__.py +7 -0
- infinity_context_server/features/memory_facts/compatibility.py +204 -0
- infinity_context_server/features/memory_facts/composition.py +72 -0
- infinity_context_server/features/memory_facts/contracts.py +187 -0
- infinity_context_server/features/memory_facts/mappers.py +620 -0
- infinity_context_server/features/memory_facts/public.py +168 -0
- infinity_context_server/features/memory_facts/routes.py +118 -0
- infinity_context_server/features/memory_facts/suggestion_requests.py +283 -0
- infinity_context_server/features/memory_facts/suggestion_responses.py +382 -0
- infinity_context_server/features/memory_scopes/__init__.py +5 -0
- infinity_context_server/features/memory_scopes/compatibility.py +231 -0
- infinity_context_server/features/memory_scopes/composition.py +49 -0
- infinity_context_server/features/memory_scopes/contracts.py +103 -0
- infinity_context_server/features/memory_scopes/graph_export_responses.py +93 -0
- infinity_context_server/features/memory_scopes/mappers.py +290 -0
- infinity_context_server/features/memory_scopes/public.py +136 -0
- infinity_context_server/features/memory_scopes/routes.py +185 -0
- infinity_context_server/features/memory_scopes/snapshot_compatibility.py +146 -0
- infinity_context_server/features/memory_scopes/thread_memory_requests.py +127 -0
- infinity_context_server/llm_provider_readiness.py +267 -0
- infinity_context_server/longmemeval_session_identity.py +167 -0
- infinity_context_server/main.py +68 -0
- infinity_context_server/mem0_benchmark_auth_challenge.py +160 -0
- infinity_context_server/memora_comparison.py +658 -0
- infinity_context_server/memory_comparison_answer_context.py +2442 -0
- infinity_context_server/memory_comparison_answer_context_backfill.py +1027 -0
- infinity_context_server/memory_comparison_answer_context_diagnostics.py +694 -0
- infinity_context_server/memory_comparison_answer_context_inspection.py +103 -0
- infinity_context_server/memory_comparison_answer_context_retrieval_slice.py +175 -0
- infinity_context_server/memory_comparison_answer_context_risks.py +223 -0
- infinity_context_server/memory_comparison_backend_target.py +41 -0
- infinity_context_server/memory_comparison_benchmark.py +651 -0
- infinity_context_server/memory_comparison_benchmark_compact.py +387 -0
- infinity_context_server/memory_comparison_benchmark_compact_fast_gate.py +387 -0
- infinity_context_server/memory_comparison_benchmark_compact_samples.py +931 -0
- infinity_context_server/memory_comparison_benchmark_config.py +105 -0
- infinity_context_server/memory_comparison_benchmark_control.py +215 -0
- infinity_context_server/memory_comparison_benchmark_execution.py +238 -0
- infinity_context_server/memory_comparison_benchmark_identity.py +65 -0
- infinity_context_server/memory_comparison_benchmark_metrics.py +686 -0
- infinity_context_server/memory_comparison_benchmark_replay.py +400 -0
- infinity_context_server/memory_comparison_benchmark_shared.py +284 -0
- infinity_context_server/memory_comparison_bounded_provider.py +295 -0
- infinity_context_server/memory_comparison_bundle_partial_support.py +107 -0
- infinity_context_server/memory_comparison_bundle_planner.py +3521 -0
- infinity_context_server/memory_comparison_bundle_source_windows.py +247 -0
- infinity_context_server/memory_comparison_candidate_features.py +2014 -0
- infinity_context_server/memory_comparison_candidate_fusion.py +893 -0
- infinity_context_server/memory_comparison_candidate_risks.py +124 -0
- infinity_context_server/memory_comparison_canonical_source_hash.py +109 -0
- infinity_context_server/memory_comparison_case_identity.py +100 -0
- infinity_context_server/memory_comparison_case_loader.py +123 -0
- infinity_context_server/memory_comparison_chat_completions.py +402 -0
- infinity_context_server/memory_comparison_clean_state.py +607 -0
- infinity_context_server/memory_comparison_clean_state_http.py +120 -0
- infinity_context_server/memory_comparison_clean_state_runner.py +103 -0
- infinity_context_server/memory_comparison_cli.py +295 -0
- infinity_context_server/memory_comparison_codex_canary.py +315 -0
- infinity_context_server/memory_comparison_codex_llm.py +345 -0
- infinity_context_server/memory_comparison_compact_gap_report.py +289 -0
- infinity_context_server/memory_comparison_comparative_preference.py +71 -0
- infinity_context_server/memory_comparison_conversation_ingestion.py +198 -0
- infinity_context_server/memory_comparison_evidence.py +877 -0
- infinity_context_server/memory_comparison_evidence_commitment.py +20 -0
- infinity_context_server/memory_comparison_failure_diagnostics.py +809 -0
- infinity_context_server/memory_comparison_full_canonical_evidence.py +746 -0
- infinity_context_server/memory_comparison_full_canonical_source_evidence_trust.py +450 -0
- infinity_context_server/memory_comparison_full_delete_evidence.py +670 -0
- infinity_context_server/memory_comparison_full_delete_evidence_trust.py +441 -0
- infinity_context_server/memory_comparison_full_delete_evidence_witnesses.py +308 -0
- infinity_context_server/memory_comparison_full_execution_validation.py +697 -0
- infinity_context_server/memory_comparison_full_execution_validation_slots.py +655 -0
- infinity_context_server/memory_comparison_full_methodology.py +556 -0
- infinity_context_server/memory_comparison_full_policy_component_validation.py +899 -0
- infinity_context_server/memory_comparison_full_profiles.py +398 -0
- infinity_context_server/memory_comparison_full_run_component_sets.py +304 -0
- infinity_context_server/memory_comparison_full_run_components.py +787 -0
- infinity_context_server/memory_comparison_full_run_evidence.py +759 -0
- infinity_context_server/memory_comparison_full_scope.py +244 -0
- infinity_context_server/memory_comparison_full_source_evidence.py +866 -0
- infinity_context_server/memory_comparison_full_verdict.py +252 -0
- infinity_context_server/memory_comparison_gold_blind.py +654 -0
- infinity_context_server/memory_comparison_gold_blind_answer_contract.py +492 -0
- infinity_context_server/memory_comparison_gold_blind_contract.py +760 -0
- infinity_context_server/memory_comparison_gold_blind_dispatch_models.py +34 -0
- infinity_context_server/memory_comparison_gold_blind_execution_validation.py +170 -0
- infinity_context_server/memory_comparison_gold_blind_judge_binding.py +167 -0
- infinity_context_server/memory_comparison_gold_blind_judge_capability.py +387 -0
- infinity_context_server/memory_comparison_gold_blind_retrieval_contract.py +413 -0
- infinity_context_server/memory_comparison_gold_blind_run_proof.py +880 -0
- infinity_context_server/memory_comparison_gold_blind_run_validation.py +109 -0
- infinity_context_server/memory_comparison_gold_blind_validation.py +319 -0
- infinity_context_server/memory_comparison_http.py +921 -0
- infinity_context_server/memory_comparison_http_ingest_observation.py +710 -0
- infinity_context_server/memory_comparison_http_ingest_request.py +204 -0
- infinity_context_server/memory_comparison_intent.py +2925 -0
- infinity_context_server/memory_comparison_latency.py +455 -0
- infinity_context_server/memory_comparison_llm.py +473 -0
- infinity_context_server/memory_comparison_location_roles.py +169 -0
- infinity_context_server/memory_comparison_locomo_cases.py +328 -0
- infinity_context_server/memory_comparison_locomo_expected_turn.py +297 -0
- infinity_context_server/memory_comparison_locomo_transport.py +873 -0
- infinity_context_server/memory_comparison_longmemeval_cases.py +339 -0
- infinity_context_server/memory_comparison_managed_attestation.py +771 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_abort_http.py +120 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_contracts.py +715 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_http.py +855 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_recovery_http.py +164 -0
- infinity_context_server/memory_comparison_managed_benchmark_registry_wire.py +890 -0
- infinity_context_server/memory_comparison_managed_composite_assembler.py +524 -0
- infinity_context_server/memory_comparison_managed_corpus_projection.py +653 -0
- infinity_context_server/memory_comparison_managed_execution_receipts.py +991 -0
- infinity_context_server/memory_comparison_managed_http_derived_evidence.py +724 -0
- infinity_context_server/memory_comparison_managed_http_exact_cleanup.py +476 -0
- infinity_context_server/memory_comparison_managed_http_execution.py +673 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle.py +905 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle_credentials.py +83 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle_evidence.py +366 -0
- infinity_context_server/memory_comparison_managed_http_lifecycle_registration.py +106 -0
- infinity_context_server/memory_comparison_managed_http_policy_lifecycle.py +894 -0
- infinity_context_server/memory_comparison_managed_http_policy_material_projection.py +315 -0
- infinity_context_server/memory_comparison_managed_http_policy_receipts.py +219 -0
- infinity_context_server/memory_comparison_managed_http_policy_registry_evidence.py +177 -0
- infinity_context_server/memory_comparison_managed_http_policy_requirements.py +824 -0
- infinity_context_server/memory_comparison_managed_http_policy_support.py +108 -0
- infinity_context_server/memory_comparison_managed_http_policy_validation.py +762 -0
- infinity_context_server/memory_comparison_managed_ingest_manifest.py +449 -0
- infinity_context_server/memory_comparison_managed_live_admission.py +886 -0
- infinity_context_server/memory_comparison_managed_live_cli.py +536 -0
- infinity_context_server/memory_comparison_managed_live_composition.py +636 -0
- infinity_context_server/memory_comparison_managed_llm_execution.py +850 -0
- infinity_context_server/memory_comparison_managed_llm_execution_dispatch.py +269 -0
- infinity_context_server/memory_comparison_managed_llm_execution_ports.py +225 -0
- infinity_context_server/memory_comparison_managed_mem0_auth.py +65 -0
- infinity_context_server/memory_comparison_managed_mem0_runtime_authority.py +241 -0
- infinity_context_server/memory_comparison_managed_mem0_runtime_http.py +541 -0
- infinity_context_server/memory_comparison_managed_plan_builder.py +685 -0
- infinity_context_server/memory_comparison_managed_preflight.py +907 -0
- infinity_context_server/memory_comparison_managed_preflight_cli.py +431 -0
- infinity_context_server/memory_comparison_managed_production_cli.py +325 -0
- infinity_context_server/memory_comparison_managed_production_composition.py +140 -0
- infinity_context_server/memory_comparison_managed_production_ports.py +194 -0
- infinity_context_server/memory_comparison_managed_production_runner.py +450 -0
- infinity_context_server/memory_comparison_managed_projection_manifest.py +438 -0
- infinity_context_server/memory_comparison_managed_provider_calls.py +450 -0
- infinity_context_server/memory_comparison_managed_quality_projection.py +347 -0
- infinity_context_server/memory_comparison_managed_registry_policy_lifecycle.py +677 -0
- infinity_context_server/memory_comparison_managed_run.py +892 -0
- infinity_context_server/memory_comparison_managed_run_contract.py +454 -0
- infinity_context_server/memory_comparison_managed_run_ports.py +79 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials.py +916 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_capability.py +361 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_context.py +132 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_integrity.py +213 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_models.py +81 -0
- infinity_context_server/memory_comparison_managed_runtime_credentials_targets.py +28 -0
- infinity_context_server/memory_comparison_mem0_contract.py +491 -0
- infinity_context_server/memory_comparison_mem0_http_observation.py +296 -0
- infinity_context_server/memory_comparison_mem0_locomo_prompts.py +328 -0
- infinity_context_server/memory_comparison_mem0_longmemeval_prompts.py +365 -0
- infinity_context_server/memory_comparison_mem0_official_chat.py +504 -0
- infinity_context_server/memory_comparison_mem0_official_prompt_renderer.py +307 -0
- infinity_context_server/memory_comparison_mem0_oss_contract.py +456 -0
- infinity_context_server/memory_comparison_mem0_oss_manifest.py +563 -0
- infinity_context_server/memory_comparison_mem0_platform_contract.py +467 -0
- infinity_context_server/memory_comparison_mem0_runtime_attestation.py +861 -0
- infinity_context_server/memory_comparison_models.py +398 -0
- infinity_context_server/memory_comparison_openai_official_transport.py +525 -0
- infinity_context_server/memory_comparison_preflight.py +1147 -0
- infinity_context_server/memory_comparison_probe_transport.py +154 -0
- infinity_context_server/memory_comparison_prompt_policy.py +603 -0
- infinity_context_server/memory_comparison_provider_provenance.py +392 -0
- infinity_context_server/memory_comparison_quality_accessors.py +339 -0
- infinity_context_server/memory_comparison_quality_actionable_gaps.py +2038 -0
- infinity_context_server/memory_comparison_quality_answer_context_gaps.py +450 -0
- infinity_context_server/memory_comparison_quality_answer_context_risks.py +75 -0
- infinity_context_server/memory_comparison_quality_bundle_gaps.py +860 -0
- infinity_context_server/memory_comparison_quality_bundle_table.py +805 -0
- infinity_context_server/memory_comparison_quality_diagnostics.py +2798 -0
- infinity_context_server/memory_comparison_quality_fusion.py +241 -0
- infinity_context_server/memory_comparison_quality_query_plan_gaps.py +533 -0
- infinity_context_server/memory_comparison_quality_query_role_gaps.py +845 -0
- infinity_context_server/memory_comparison_quality_query_roles.py +815 -0
- infinity_context_server/memory_comparison_quality_rerank_gaps.py +492 -0
- infinity_context_server/memory_comparison_quality_selected_weakness.py +544 -0
- infinity_context_server/memory_comparison_quality_support.py +921 -0
- infinity_context_server/memory_comparison_query_integrity.py +301 -0
- infinity_context_server/memory_comparison_query_plan.py +524 -0
- infinity_context_server/memory_comparison_query_terms.py +2055 -0
- infinity_context_server/memory_comparison_relation_support.py +2100 -0
- infinity_context_server/memory_comparison_rerank.py +3209 -0
- infinity_context_server/memory_comparison_rerank_intents.py +405 -0
- infinity_context_server/memory_comparison_rerank_policies.py +1726 -0
- infinity_context_server/memory_comparison_rerank_policy.py +675 -0
- infinity_context_server/memory_comparison_rerank_shapes.py +152 -0
- infinity_context_server/memory_comparison_rerank_terms.py +973 -0
- infinity_context_server/memory_comparison_rerank_text.py +722 -0
- infinity_context_server/memory_comparison_retrieval_policy.py +108 -0
- infinity_context_server/memory_comparison_retrieval_width.py +383 -0
- infinity_context_server/memory_comparison_service_probe.py +278 -0
- infinity_context_server/memory_comparison_service_probes.py +547 -0
- infinity_context_server/memory_comparison_session_identity_contract.py +328 -0
- infinity_context_server/memory_comparison_source_identity.py +1655 -0
- infinity_context_server/memory_comparison_subscription_chat.py +717 -0
- infinity_context_server/memory_comparison_subscription_live_probe.py +323 -0
- infinity_context_server/memory_comparison_subscription_probe.py +368 -0
- infinity_context_server/memory_comparison_target_identity.py +42 -0
- infinity_context_server/memory_comparison_temporal_grounding.py +771 -0
- infinity_context_server/memory_comparison_token_budget_contract.py +665 -0
- infinity_context_server/memory_comparison_token_latency.py +136 -0
- infinity_context_server/memory_scope_transfer.py +933 -0
- infinity_context_server/memory_scope_transfer_assets.py +181 -0
- infinity_context_server/memory_scope_transfer_conflicts.py +565 -0
- infinity_context_server/memory_scope_transfer_context.py +295 -0
- infinity_context_server/memory_scope_transfer_extractions.py +390 -0
- infinity_context_server/memory_scope_transfer_facts.py +65 -0
- infinity_context_server/memory_scope_transfer_records.py +630 -0
- infinity_context_server/memory_scope_transfer_relations.py +84 -0
- infinity_context_server/memory_scope_transfer_remap.py +710 -0
- infinity_context_server/memory_scope_transfer_scope.py +267 -0
- infinity_context_server/memory_scope_transfer_support.py +108 -0
- infinity_context_server/memory_scope_transfer_temporal.py +24 -0
- infinity_context_server/metrics.py +264 -0
- infinity_context_server/official_public_benchmark.py +979 -0
- infinity_context_server/pagination.py +60 -0
- infinity_context_server/processes/__init__.py +38 -0
- infinity_context_server/processes/extractions.py +40 -0
- infinity_context_server/processes/outbox.py +47 -0
- infinity_context_server/processes/projections.py +372 -0
- infinity_context_server/provider_budget.py +59 -0
- infinity_context_server/provider_circuit.py +333 -0
- infinity_context_server/public_benchmark.py +2532 -0
- infinity_context_server/public_benchmark_artifacts.py +91 -0
- infinity_context_server/public_benchmark_case_diagnostics.py +231 -0
- infinity_context_server/public_benchmark_checkpoint.py +751 -0
- infinity_context_server/public_benchmark_environment.py +102 -0
- infinity_context_server/public_benchmark_execution.py +445 -0
- infinity_context_server/public_benchmark_http.py +39 -0
- infinity_context_server/public_benchmark_manifest.py +129 -0
- infinity_context_server/public_benchmark_metrics.py +645 -0
- infinity_context_server/public_benchmark_metrics_policy.py +117 -0
- infinity_context_server/public_benchmark_models.py +112 -0
- infinity_context_server/public_benchmark_progress.py +224 -0
- infinity_context_server/public_benchmark_results.py +76 -0
- infinity_context_server/public_benchmark_run_diagnostics.py +163 -0
- infinity_context_server/public_benchmark_selection.py +379 -0
- infinity_context_server/public_benchmark_transport.py +62 -0
- infinity_context_server/public_benchmark_unsupported.py +228 -0
- infinity_context_server/ranked_evidence_answer_support.py +665 -0
- infinity_context_server/ranked_evidence_document_seed_contract.py +30 -0
- infinity_context_server/ranked_evidence_evaluator_helpers.py +135 -0
- infinity_context_server/ranked_evidence_retrieval_request.py +36 -0
- infinity_context_server/ranked_evidence_seed_case.py +109 -0
- infinity_context_server/ranked_evidence_semantic_gate.py +980 -0
- infinity_context_server/ranked_evidence_semantic_gate_cli.py +137 -0
- infinity_context_server/ranked_evidence_semantic_gate_decision.py +163 -0
- infinity_context_server/ranked_evidence_semantic_metrics.py +375 -0
- infinity_context_server/ranked_evidence_session_identity.py +100 -0
- infinity_context_server/storage_maintenance.py +187 -0
- infinity_context_server/top_evidence_dataset_profile.py +442 -0
- infinity_context_server/top_evidence_policy.py +274 -0
- infinity_context_server/top_evidence_preflight.py +693 -0
- infinity_context_server/web/assets/memory-browser-capture.js +252 -0
- infinity_context_server/web/assets/memory-browser-operations.js +143 -0
- infinity_context_server/web/assets/memory-browser-review.js +687 -0
- infinity_context_server/web/assets/memory-browser.css +854 -0
- infinity_context_server/web/assets/memory-browser.js +3299 -0
- infinity_context_server/web/index.html +261 -0
- infinity_context_server/web_ui.py +29 -0
- infinity_context_server/worker.py +380 -0
|
@@ -0,0 +1,2627 @@
|
|
|
1
|
+
"""Memory quality scorecard evaluation helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from collections.abc import Mapping, Sequence
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from infinity_context_core.agent_behavior_contract import (
|
|
10
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_CASE_COUNT_FLOORS,
|
|
11
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_IDS,
|
|
12
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_INTEGRITY_CHECKS,
|
|
13
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_SET,
|
|
14
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_TAG_METRICS,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
from infinity_context_server.eval_constants import (
|
|
18
|
+
_AGENT_BEHAVIOR_ACCEPTED_SCENARIO_SETS,
|
|
19
|
+
_AGENT_BEHAVIOR_RATE_FLOORS,
|
|
20
|
+
_AGENT_BEHAVIOR_ZERO_COUNT_METRICS,
|
|
21
|
+
_AGENT_LIVE_SMOKE_REQUIRED_AGENT_CLI_CHECKS,
|
|
22
|
+
_AGENT_LIVE_SMOKE_REQUIRED_GENERATED_MCP_CHECKS,
|
|
23
|
+
_AGENT_LIVE_SMOKE_SUITE_ALIASES,
|
|
24
|
+
_FULL_PROVIDER_CANARY_SUITE_ALIASES,
|
|
25
|
+
_FULL_PROVIDER_REQUIRED_ADAPTERS,
|
|
26
|
+
_FULL_PROVIDER_REQUIRED_CHECK_KEYS,
|
|
27
|
+
_MEMORY_QUALITY_SCORECARD_MIN_CASE_COUNTS,
|
|
28
|
+
_MEMORY_QUALITY_SCORECARD_MIN_EXTRACTION_CASES,
|
|
29
|
+
_MEMORY_QUALITY_SCORECARD_MIN_SCORE_10,
|
|
30
|
+
_MEMORY_QUALITY_SCORECARD_MIN_SEMANTIC_EXTRACTION_CASES,
|
|
31
|
+
_MEMORY_QUALITY_SCORECARD_REQUIRED_SUITES,
|
|
32
|
+
_MULTIMODAL_LIVE_PROVIDER_CANARY_SUITE_ALIASES,
|
|
33
|
+
_MULTIMODAL_LIVE_PROVIDER_REQUIRED_REQUIREMENTS,
|
|
34
|
+
_PUBLIC_MEMORY_BENCHMARK_COMPETITIVE_FLOORS,
|
|
35
|
+
_PUBLIC_MEMORY_BENCHMARK_DATASET_SOURCE_KINDS,
|
|
36
|
+
_PUBLIC_MEMORY_BENCHMARK_NAME_ALIASES,
|
|
37
|
+
_PUBLIC_MEMORY_BENCHMARK_OFFICIAL_SOURCE_KINDS,
|
|
38
|
+
_PUBLIC_MEMORY_BENCHMARK_REQUIRED,
|
|
39
|
+
_PUBLIC_MEMORY_BENCHMARK_SUITE_ALIASES,
|
|
40
|
+
_QUALITY_GOLDEN_PRECISION_GATE,
|
|
41
|
+
_QUALITY_GOLDEN_RECALL_GATE,
|
|
42
|
+
_SMALL_GOLDEN_PRECISION_GATE,
|
|
43
|
+
_SMALL_GOLDEN_RECALL_GATE,
|
|
44
|
+
AGENT_BEHAVIOR_BENCH_SUITE,
|
|
45
|
+
AGENT_LIVE_SMOKE_SUITE,
|
|
46
|
+
AUTO_MEMORY_GOLDEN_SUITE,
|
|
47
|
+
FULL_PROVIDER_CANARY_SUITE,
|
|
48
|
+
GRAPH_NATIVE_GOLDEN_SUITE,
|
|
49
|
+
LOCAL_EXPERIENCE_PROOF_SUITE,
|
|
50
|
+
LONG_MEMORY_ABILITY_CASE_IDS,
|
|
51
|
+
LONG_MEMORY_GOLDEN_SUITE,
|
|
52
|
+
LONG_MEMORY_REQUIRED_CASE_IDS,
|
|
53
|
+
MEMORY_QUALITY_SCORECARD_SUITE,
|
|
54
|
+
MULTIMODAL_LIVE_PROVIDER_CANARY_SUITE,
|
|
55
|
+
MULTIMODAL_OFFLINE_GOLDEN_SUITE,
|
|
56
|
+
PROMPT_CONTRACT_SUITE,
|
|
57
|
+
PUBLIC_MEMORY_BENCHMARK_SUITE,
|
|
58
|
+
QUALITY_GOLDEN_MEMORY_ABILITY_CASE_IDS,
|
|
59
|
+
QUALITY_GOLDEN_REQUIRED_CASE_IDS,
|
|
60
|
+
QUALITY_GOLDEN_SUITE,
|
|
61
|
+
SEMANTIC_LINKING_GOLDEN_SUITE,
|
|
62
|
+
SEMANTIC_LINKING_REQUIRED_CASE_IDS,
|
|
63
|
+
SMALL_GOLDEN_SUITE,
|
|
64
|
+
)
|
|
65
|
+
from infinity_context_server.top_evidence_policy import (
|
|
66
|
+
TOP_EVIDENCE_PROVENANCE_CHECKS,
|
|
67
|
+
TOP_EVIDENCE_SAFETY_CHECKS,
|
|
68
|
+
TopEvidenceReportPolicy,
|
|
69
|
+
top_evidence_provenance_summary,
|
|
70
|
+
top_evidence_safety_summary,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
_SEMANTIC_LINKING_REQUIRED_CHECKS = (
|
|
74
|
+
"top_fact_beats_distractor",
|
|
75
|
+
"event_call_beats_recent_chat",
|
|
76
|
+
"temporal_intent_links_recent_fact_without_text_match",
|
|
77
|
+
"document_chunk_evidence_suggested",
|
|
78
|
+
"person_project_and_org_anchors_suggested",
|
|
79
|
+
"anchor_evidence_confidence_and_observed_at_exposed",
|
|
80
|
+
"same_name_person_project_anchors_separate",
|
|
81
|
+
"explicit_alias_anchor_identity_terms_rank_correct_target",
|
|
82
|
+
"high_impact_relation_requires_explicit_signal",
|
|
83
|
+
"evidence_relation_requires_source_signal",
|
|
84
|
+
"mentions_relation_requires_entity_signal",
|
|
85
|
+
"top_suggestion_approves_to_link",
|
|
86
|
+
"unrelated_capture_has_no_candidates",
|
|
87
|
+
"cross_scope_fact_not_suggested",
|
|
88
|
+
)
|
|
89
|
+
_DEDUP_MERGE_QUALITY_CASE_IDS = (
|
|
90
|
+
"pending_conflict_review_visible",
|
|
91
|
+
"pending_duplicate_merge_review_visible",
|
|
92
|
+
)
|
|
93
|
+
_DEDUP_MERGE_AUTO_CASE_IDS = (
|
|
94
|
+
"capture_replay_is_idempotent",
|
|
95
|
+
"approved_fact_creates_duplicate_merge_review",
|
|
96
|
+
)
|
|
97
|
+
_DEDUP_MERGE_SEMANTIC_CHECKS = (
|
|
98
|
+
"high_impact_relation_requires_explicit_signal",
|
|
99
|
+
"weak_overlap_below_review_threshold_denied",
|
|
100
|
+
"cross_scope_fact_not_suggested",
|
|
101
|
+
)
|
|
102
|
+
_LOCAL_EXPERIENCE_MIN_MCP_TOOL_COUNT = 40
|
|
103
|
+
_LOCAL_EXPERIENCE_PROVENANCE_POLICY = TopEvidenceReportPolicy(
|
|
104
|
+
expected_generators=frozenset({"scripts/local_experience_proof.py"}),
|
|
105
|
+
provenance_suites=frozenset({LOCAL_EXPERIENCE_PROOF_SUITE}),
|
|
106
|
+
)
|
|
107
|
+
_RETRIEVAL_CONTEXT_QUALITY_CASE_IDS = (
|
|
108
|
+
"longmemeval_knowledge_update_current_truth",
|
|
109
|
+
"updated_provider_current_only",
|
|
110
|
+
"temporal_supersedes_current_only",
|
|
111
|
+
"linked_temporal_supersedes_current_only",
|
|
112
|
+
"relative_time_current_fact_not_last_week_fact",
|
|
113
|
+
"contradicted_fact_hidden_by_default",
|
|
114
|
+
"contradicted_fact_visible_only_in_stale_review",
|
|
115
|
+
"document_architecture_precision",
|
|
116
|
+
"document_source_diversity_preserves_secondary_source",
|
|
117
|
+
"hybrid_document_beats_single_source",
|
|
118
|
+
"context_diversity_preserves_fact_and_chunk_evidence",
|
|
119
|
+
"multimodal_source_refs_recall_with_citations",
|
|
120
|
+
"multilingual_multimodal_source_refs_recall",
|
|
121
|
+
"multimodal_evidence_metadata_contract",
|
|
122
|
+
"multimodal_visual_region_query_requires_bbox",
|
|
123
|
+
"media_timestamp_query_selects_matching_evidence",
|
|
124
|
+
"canonical_project_anchor_recall_with_citation",
|
|
125
|
+
"canonical_event_anchor_recall_by_identity",
|
|
126
|
+
"event_anchor_relation_expands_linked_person_project_facts",
|
|
127
|
+
"person_event_project_precision",
|
|
128
|
+
"multilingual_recent_person_project_recall",
|
|
129
|
+
"longmemeval_multilingual_entity_abstention",
|
|
130
|
+
"same_person_time_wrong_project_does_not_pull_atlas",
|
|
131
|
+
"mixed_language_wrong_project_returns_no_context",
|
|
132
|
+
"wrong_project_anchor_deflects_generic_match",
|
|
133
|
+
"longmemeval_source_attribution_project_anchor",
|
|
134
|
+
"identifier_like_query_deflects_partial_marker",
|
|
135
|
+
"unrelated_query_returns_no_context_items",
|
|
136
|
+
"cross_memory_scope_secret_hidden",
|
|
137
|
+
"multi_memory_scope_explicit_recall",
|
|
138
|
+
"thread_current_visible_without_neighbor",
|
|
139
|
+
"thread_other_visible_without_current",
|
|
140
|
+
"prompt_injection_evidence_only",
|
|
141
|
+
"mixed_script_event_anchor_recall_by_query_intent",
|
|
142
|
+
)
|
|
143
|
+
_MULTIMODAL_DOCKER_LIVE_PROOF_SUITE = "infinity-context-multimodal-docker-live-proof"
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _ratio(passed: int, total: int) -> float:
|
|
147
|
+
if total <= 0:
|
|
148
|
+
return 0.0
|
|
149
|
+
return round(passed / total, 4)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def memory_quality_scorecard_policy_snapshot(
|
|
153
|
+
*,
|
|
154
|
+
require_top_evidence: bool,
|
|
155
|
+
) -> dict[str, object]:
|
|
156
|
+
return {
|
|
157
|
+
"schema_version": 1,
|
|
158
|
+
"suite": MEMORY_QUALITY_SCORECARD_SUITE,
|
|
159
|
+
"require_top_evidence": require_top_evidence,
|
|
160
|
+
"minimum_maturity_score_10": _MEMORY_QUALITY_SCORECARD_MIN_SCORE_10,
|
|
161
|
+
"required_suites": list(_MEMORY_QUALITY_SCORECARD_REQUIRED_SUITES),
|
|
162
|
+
"min_case_counts": dict(_MEMORY_QUALITY_SCORECARD_MIN_CASE_COUNTS),
|
|
163
|
+
"auto_memory": {
|
|
164
|
+
"min_extraction_cases": _MEMORY_QUALITY_SCORECARD_MIN_EXTRACTION_CASES,
|
|
165
|
+
"min_semantic_extraction_cases": (
|
|
166
|
+
_MEMORY_QUALITY_SCORECARD_MIN_SEMANTIC_EXTRACTION_CASES
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
"multimodal_offline": {
|
|
170
|
+
"required_checks": [
|
|
171
|
+
"vision_linking_accuracy",
|
|
172
|
+
"metadata_only_visual_linking_accuracy",
|
|
173
|
+
"audio_linking_accuracy",
|
|
174
|
+
"video_linking_accuracy",
|
|
175
|
+
"temporal_audio_linking_accuracy",
|
|
176
|
+
"similar_wrong_project_precision",
|
|
177
|
+
"empty_audio_no_candidate_rate",
|
|
178
|
+
"prompt_injection_guard_rate",
|
|
179
|
+
"evidence_metadata_exposed",
|
|
180
|
+
"retrieval_evidence_coverage_profile",
|
|
181
|
+
],
|
|
182
|
+
"requires_no_false_positives": True,
|
|
183
|
+
"requires_prompt_injection_guard": True,
|
|
184
|
+
"requires_evidence_metadata": True,
|
|
185
|
+
"requires_retrieval_evidence_coverage_profile": True,
|
|
186
|
+
},
|
|
187
|
+
"retrieval_context_memory_layer": {
|
|
188
|
+
"required_quality_case_ids": list(_RETRIEVAL_CONTEXT_QUALITY_CASE_IDS),
|
|
189
|
+
"required_memory_abilities": sorted(QUALITY_GOLDEN_MEMORY_ABILITY_CASE_IDS),
|
|
190
|
+
"requires_hybrid_retrieval": True,
|
|
191
|
+
"requires_document_recall": True,
|
|
192
|
+
"requires_citations": True,
|
|
193
|
+
"requires_answer_support": True,
|
|
194
|
+
"requires_retrieval_trace": True,
|
|
195
|
+
"requires_precise_locations": True,
|
|
196
|
+
"requires_stale_filtering": True,
|
|
197
|
+
"requires_multimodal_evidence_locations": True,
|
|
198
|
+
"requires_no_scope_thread_or_restricted_leaks": True,
|
|
199
|
+
"source_text_policy": "untrusted_evidence",
|
|
200
|
+
},
|
|
201
|
+
"longitudinal_memory": {
|
|
202
|
+
"required_case_ids": list(LONG_MEMORY_REQUIRED_CASE_IDS),
|
|
203
|
+
"required_memory_abilities": sorted(LONG_MEMORY_ABILITY_CASE_IDS),
|
|
204
|
+
"requires_multi_session_reasoning": True,
|
|
205
|
+
"requires_temporal_reasoning": True,
|
|
206
|
+
"requires_knowledge_update": True,
|
|
207
|
+
"requires_abstention": True,
|
|
208
|
+
"requires_source_attribution": True,
|
|
209
|
+
"requires_multilingual_entity_disambiguation": True,
|
|
210
|
+
},
|
|
211
|
+
"dedup_merge_conflict_resolution": {
|
|
212
|
+
"required_quality_case_ids": list(_DEDUP_MERGE_QUALITY_CASE_IDS),
|
|
213
|
+
"required_auto_memory_case_ids": list(_DEDUP_MERGE_AUTO_CASE_IDS),
|
|
214
|
+
"required_semantic_checks": list(_DEDUP_MERGE_SEMANTIC_CHECKS),
|
|
215
|
+
"requires_no_duplicate_suggestions": True,
|
|
216
|
+
"requires_replay_idempotency": True,
|
|
217
|
+
"requires_review_before_merge": True,
|
|
218
|
+
"requires_no_cross_scope_duplicate_targets": True,
|
|
219
|
+
},
|
|
220
|
+
"cloud_self_host_readiness": {
|
|
221
|
+
"required_live_proof_suite": _MULTIMODAL_DOCKER_LIVE_PROOF_SUITE,
|
|
222
|
+
"storage_readiness_schema_version": "asset-storage-deployment-readiness-v2",
|
|
223
|
+
"requires_s3_compatible_hosted_backend": True,
|
|
224
|
+
"requires_local_and_s3_storage_ports": True,
|
|
225
|
+
"requires_external_migration_runner_contract": True,
|
|
226
|
+
"migration_runner_service": "infinity_context_migrate",
|
|
227
|
+
"requires_safe_diagnostics": True,
|
|
228
|
+
"requires_storage_cleanup_contract": True,
|
|
229
|
+
"requires_scope_storage_quota": True,
|
|
230
|
+
"live_proof_required_for_production_claim": True,
|
|
231
|
+
},
|
|
232
|
+
"full_provider": {
|
|
233
|
+
"required_adapters": list(_FULL_PROVIDER_REQUIRED_ADAPTERS),
|
|
234
|
+
"required_checks": list(_FULL_PROVIDER_REQUIRED_CHECK_KEYS),
|
|
235
|
+
"requires_mcp_lifecycle": True,
|
|
236
|
+
"top_evidence_requires_provenance": True,
|
|
237
|
+
"top_evidence_required_provenance_checks": list(TOP_EVIDENCE_PROVENANCE_CHECKS),
|
|
238
|
+
"top_evidence_requires_safety_scan": True,
|
|
239
|
+
"top_evidence_required_safety_checks": list(TOP_EVIDENCE_SAFETY_CHECKS),
|
|
240
|
+
},
|
|
241
|
+
"multimodal_live_provider": {
|
|
242
|
+
"suite_aliases": list(_MULTIMODAL_LIVE_PROVIDER_CANARY_SUITE_ALIASES),
|
|
243
|
+
"required_requirements": list(_MULTIMODAL_LIVE_PROVIDER_REQUIRED_REQUIREMENTS),
|
|
244
|
+
"requires_contract_matrix": True,
|
|
245
|
+
"requires_live_vision": True,
|
|
246
|
+
"requires_live_audio_transcription": True,
|
|
247
|
+
"requires_invalid_key_probe": True,
|
|
248
|
+
"requires_no_secret_leak_guard": True,
|
|
249
|
+
"top_evidence_requires_provenance": True,
|
|
250
|
+
"top_evidence_required_provenance_checks": list(TOP_EVIDENCE_PROVENANCE_CHECKS),
|
|
251
|
+
"top_evidence_requires_safety_scan": True,
|
|
252
|
+
"top_evidence_required_safety_checks": list(TOP_EVIDENCE_SAFETY_CHECKS),
|
|
253
|
+
},
|
|
254
|
+
"agent_behavior": {
|
|
255
|
+
"accepted_scenario_sets": list(_AGENT_BEHAVIOR_ACCEPTED_SCENARIO_SETS),
|
|
256
|
+
"top_evidence_required_scenario_set": (AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_SET),
|
|
257
|
+
"top_evidence_required_case_count_floors": dict(
|
|
258
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_CASE_COUNT_FLOORS
|
|
259
|
+
),
|
|
260
|
+
"top_evidence_required_scenario_tag_metrics": dict(
|
|
261
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_TAG_METRICS
|
|
262
|
+
),
|
|
263
|
+
"top_evidence_required_scenario_integrity_checks": list(
|
|
264
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_INTEGRITY_CHECKS
|
|
265
|
+
),
|
|
266
|
+
"top_evidence_required_canonical_scenario_count": len(
|
|
267
|
+
AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_IDS
|
|
268
|
+
),
|
|
269
|
+
"rate_floors": dict(_AGENT_BEHAVIOR_RATE_FLOORS),
|
|
270
|
+
"zero_count_metrics": list(_AGENT_BEHAVIOR_ZERO_COUNT_METRICS),
|
|
271
|
+
"top_evidence_requires_provenance": True,
|
|
272
|
+
"top_evidence_required_provenance_checks": list(TOP_EVIDENCE_PROVENANCE_CHECKS),
|
|
273
|
+
"top_evidence_requires_safety_scan": True,
|
|
274
|
+
"top_evidence_required_safety_checks": list(TOP_EVIDENCE_SAFETY_CHECKS),
|
|
275
|
+
},
|
|
276
|
+
"agent_live_smoke": {
|
|
277
|
+
"suite_aliases": list(_AGENT_LIVE_SMOKE_SUITE_ALIASES),
|
|
278
|
+
"required_generated_mcp_checks": list(_AGENT_LIVE_SMOKE_REQUIRED_GENERATED_MCP_CHECKS),
|
|
279
|
+
"required_agent_cli_checks": list(_AGENT_LIVE_SMOKE_REQUIRED_AGENT_CLI_CHECKS),
|
|
280
|
+
"requires_strict_agent_cli": True,
|
|
281
|
+
"top_evidence_requires_provenance": True,
|
|
282
|
+
"top_evidence_required_provenance_checks": list(TOP_EVIDENCE_PROVENANCE_CHECKS),
|
|
283
|
+
"top_evidence_requires_safety_scan": True,
|
|
284
|
+
"top_evidence_required_safety_checks": list(TOP_EVIDENCE_SAFETY_CHECKS),
|
|
285
|
+
},
|
|
286
|
+
"local_experience": {
|
|
287
|
+
"suite": LOCAL_EXPERIENCE_PROOF_SUITE,
|
|
288
|
+
"requires_quickstart_live": True,
|
|
289
|
+
"requires_doctor_ready": True,
|
|
290
|
+
"requires_visual_memory_smoke": True,
|
|
291
|
+
"requires_mcp_digest": True,
|
|
292
|
+
"requires_reviewed_search": True,
|
|
293
|
+
"requires_token_safety": True,
|
|
294
|
+
"minimum_mcp_tool_count": _LOCAL_EXPERIENCE_MIN_MCP_TOOL_COUNT,
|
|
295
|
+
},
|
|
296
|
+
"public_benchmark": {
|
|
297
|
+
"required_benchmarks": list(_PUBLIC_MEMORY_BENCHMARK_REQUIRED),
|
|
298
|
+
"competitive_floors": {
|
|
299
|
+
name: dict(floor)
|
|
300
|
+
for name, floor in _PUBLIC_MEMORY_BENCHMARK_COMPETITIVE_FLOORS.items()
|
|
301
|
+
},
|
|
302
|
+
"top_evidence_requires_provenance": True,
|
|
303
|
+
"top_evidence_required_provenance_checks": list(TOP_EVIDENCE_PROVENANCE_CHECKS),
|
|
304
|
+
"top_evidence_requires_safety_scan": True,
|
|
305
|
+
"top_evidence_required_safety_checks": list(TOP_EVIDENCE_SAFETY_CHECKS),
|
|
306
|
+
"top_evidence_requires_dataset_fingerprint": True,
|
|
307
|
+
"top_evidence_requires_dataset_source_metadata": True,
|
|
308
|
+
"top_evidence_requires_dataset_source_hash_match": True,
|
|
309
|
+
"top_evidence_requires_dataset_path_label": True,
|
|
310
|
+
"top_evidence_requires_dataset_source_case_count": True,
|
|
311
|
+
"top_evidence_rejects_raw_dataset_paths": True,
|
|
312
|
+
"top_evidence_requires_unique_case_ids": True,
|
|
313
|
+
"top_evidence_rejects_duplicate_case_ids": True,
|
|
314
|
+
"top_evidence_requires_official_url_for_official_sources": True,
|
|
315
|
+
"top_evidence_allowed_dataset_source_kinds": list(
|
|
316
|
+
_PUBLIC_MEMORY_BENCHMARK_DATASET_SOURCE_KINDS
|
|
317
|
+
),
|
|
318
|
+
},
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _load_scorecard_suite_reports(paths: Sequence[Path]) -> dict[str, dict[str, object]]:
|
|
323
|
+
reports: dict[str, dict[str, object]] = {}
|
|
324
|
+
for path in paths:
|
|
325
|
+
try:
|
|
326
|
+
payload = json.loads(path.read_text(encoding="utf-8"))
|
|
327
|
+
except OSError as exc:
|
|
328
|
+
raise ValueError(f"Unable to read scorecard suite report: {path}") from exc
|
|
329
|
+
except json.JSONDecodeError as exc:
|
|
330
|
+
raise ValueError(f"Invalid scorecard suite report JSON: {path}") from exc
|
|
331
|
+
if not isinstance(payload, dict):
|
|
332
|
+
raise ValueError(f"Scorecard suite report must be a JSON object: {path}")
|
|
333
|
+
suite = payload.get("suite")
|
|
334
|
+
if not isinstance(suite, str) or not suite:
|
|
335
|
+
raise ValueError(f"Scorecard suite report is missing suite name: {path}")
|
|
336
|
+
if suite in reports:
|
|
337
|
+
raise ValueError(f"Duplicate scorecard suite report for suite: {suite}")
|
|
338
|
+
reports[suite] = payload
|
|
339
|
+
return reports
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def build_memory_quality_scorecard(
|
|
343
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
344
|
+
*,
|
|
345
|
+
require_top_evidence: bool = False,
|
|
346
|
+
) -> dict[str, object]:
|
|
347
|
+
required_suites = _MEMORY_QUALITY_SCORECARD_REQUIRED_SUITES
|
|
348
|
+
missing_suites = tuple(suite for suite in required_suites if suite not in suite_results)
|
|
349
|
+
suites = {
|
|
350
|
+
suite: _scorecard_suite_summary(suite_results.get(suite)) for suite in required_suites
|
|
351
|
+
}
|
|
352
|
+
capabilities = {
|
|
353
|
+
"coverage_floors": _scorecard_coverage_floors(suite_results, suites),
|
|
354
|
+
"canonical_recall_precision": _scorecard_canonical_recall_precision(suite_results),
|
|
355
|
+
"retrieval_context_memory_layer": (
|
|
356
|
+
_scorecard_retrieval_context_memory_layer(suite_results)
|
|
357
|
+
),
|
|
358
|
+
"longitudinal_memory": _scorecard_longitudinal_memory(suite_results),
|
|
359
|
+
"auto_memory_admission": _scorecard_auto_memory_admission(suite_results),
|
|
360
|
+
"semantic_linking": _scorecard_semantic_linking(suite_results),
|
|
361
|
+
"dedup_merge_conflict_resolution": (
|
|
362
|
+
_scorecard_dedup_merge_conflict_resolution(suite_results)
|
|
363
|
+
),
|
|
364
|
+
"cloud_self_host_readiness": _scorecard_cloud_self_host_readiness(suite_results),
|
|
365
|
+
"multimodal_evidence_retrieval": _scorecard_multimodal_evidence_retrieval(
|
|
366
|
+
suite_results
|
|
367
|
+
),
|
|
368
|
+
"graph_native_recall": _scorecard_graph_native_recall(suite_results),
|
|
369
|
+
"scope_and_safety": _scorecard_scope_and_safety(suite_results),
|
|
370
|
+
"prompt_context_contract": _scorecard_prompt_context_contract(suite_results),
|
|
371
|
+
}
|
|
372
|
+
external_evidence = _scorecard_external_evidence(
|
|
373
|
+
suite_results,
|
|
374
|
+
require_top_evidence=require_top_evidence,
|
|
375
|
+
)
|
|
376
|
+
all_suite_checks_ok = all(summary["ok"] is True for summary in suites.values())
|
|
377
|
+
all_capabilities_ok = all(capability["ok"] is True for capability in capabilities.values())
|
|
378
|
+
check_values = (
|
|
379
|
+
*(summary["ok"] is True for summary in suites.values()),
|
|
380
|
+
*(capability["ok"] is True for capability in capabilities.values()),
|
|
381
|
+
)
|
|
382
|
+
passed_checks = sum(1 for value in check_values if value)
|
|
383
|
+
total_checks = len(check_values)
|
|
384
|
+
score_percent = _ratio(passed_checks, total_checks)
|
|
385
|
+
maturity_score_10 = round(score_percent * 10, 2)
|
|
386
|
+
gates = {
|
|
387
|
+
"required_suites_present": not missing_suites,
|
|
388
|
+
"all_suites_ok": all_suite_checks_ok,
|
|
389
|
+
"all_capabilities_ok": all_capabilities_ok,
|
|
390
|
+
"maturity_score_min": maturity_score_10 >= _MEMORY_QUALITY_SCORECARD_MIN_SCORE_10,
|
|
391
|
+
}
|
|
392
|
+
if require_top_evidence:
|
|
393
|
+
gates["top_library_external_evidence"] = (
|
|
394
|
+
external_evidence["top_library_comparison_ready"] is True
|
|
395
|
+
)
|
|
396
|
+
failures = _scorecard_failures(
|
|
397
|
+
missing_suites=missing_suites,
|
|
398
|
+
suites=suites,
|
|
399
|
+
capabilities=capabilities,
|
|
400
|
+
gates=gates,
|
|
401
|
+
)
|
|
402
|
+
ok = all(gates.values())
|
|
403
|
+
return {
|
|
404
|
+
"suite": MEMORY_QUALITY_SCORECARD_SUITE,
|
|
405
|
+
"status": "ok" if ok else "failed",
|
|
406
|
+
"ok": ok,
|
|
407
|
+
"benchmark_scope": (
|
|
408
|
+
"internal deterministic public-API suites; not a LOCOMO or LongMemEval substitute"
|
|
409
|
+
),
|
|
410
|
+
"score": {
|
|
411
|
+
"passed_checks": passed_checks,
|
|
412
|
+
"total_checks": total_checks,
|
|
413
|
+
"score_percent": score_percent,
|
|
414
|
+
"maturity_score_10": maturity_score_10,
|
|
415
|
+
"minimum_maturity_score_10": _MEMORY_QUALITY_SCORECARD_MIN_SCORE_10,
|
|
416
|
+
},
|
|
417
|
+
"suites": suites,
|
|
418
|
+
"capabilities": capabilities,
|
|
419
|
+
"external_evidence": external_evidence,
|
|
420
|
+
"gates": gates,
|
|
421
|
+
"metrics": _scorecard_metrics(suite_results),
|
|
422
|
+
"failures": failures,
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def _scorecard_suite_summary(result: dict[str, object] | None) -> dict[str, object]:
|
|
427
|
+
if result is None:
|
|
428
|
+
return {
|
|
429
|
+
"ok": False,
|
|
430
|
+
"status": "missing",
|
|
431
|
+
"case_count": 0,
|
|
432
|
+
"failure_count": 1,
|
|
433
|
+
}
|
|
434
|
+
metrics = _scorecard_result_metrics(result)
|
|
435
|
+
cases = result.get("cases")
|
|
436
|
+
failures = result.get("failures", ())
|
|
437
|
+
if isinstance(cases, list | tuple):
|
|
438
|
+
case_count = len(cases)
|
|
439
|
+
else:
|
|
440
|
+
case_count = metrics.get("case_count")
|
|
441
|
+
if not isinstance(case_count, int):
|
|
442
|
+
case_count = 0
|
|
443
|
+
return {
|
|
444
|
+
"ok": bool(result.get("ok")),
|
|
445
|
+
"status": result.get("status", "ok" if result.get("ok") else "failed"),
|
|
446
|
+
"case_count": case_count,
|
|
447
|
+
"failure_count": len(failures) if isinstance(failures, list | tuple) else 0,
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _scorecard_coverage_floors(
|
|
452
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
453
|
+
suites: Mapping[str, dict[str, object]],
|
|
454
|
+
) -> dict[str, object]:
|
|
455
|
+
quality_result = suite_results.get(QUALITY_GOLDEN_SUITE)
|
|
456
|
+
semantic_result = suite_results.get(SEMANTIC_LINKING_GOLDEN_SUITE)
|
|
457
|
+
long_memory_result = suite_results.get(LONG_MEMORY_GOLDEN_SUITE)
|
|
458
|
+
quality_metrics = _scorecard_result_metrics(suite_results.get(QUALITY_GOLDEN_SUITE))
|
|
459
|
+
semantic_metrics = _scorecard_result_metrics(suite_results.get(SEMANTIC_LINKING_GOLDEN_SUITE))
|
|
460
|
+
long_memory_metrics = _scorecard_result_metrics(suite_results.get(LONG_MEMORY_GOLDEN_SUITE))
|
|
461
|
+
auto_metrics = _scorecard_result_metrics(suite_results.get(AUTO_MEMORY_GOLDEN_SUITE))
|
|
462
|
+
checks = {
|
|
463
|
+
f"{suite}_case_count": int(suites[suite].get("case_count", 0)) >= minimum
|
|
464
|
+
for suite, minimum in _MEMORY_QUALITY_SCORECARD_MIN_CASE_COUNTS.items()
|
|
465
|
+
}
|
|
466
|
+
checks["quality_required_case_coverage_rate"] = (
|
|
467
|
+
quality_metrics.get("required_case_coverage_rate") == 1.0
|
|
468
|
+
)
|
|
469
|
+
checks["quality_missing_required_case_count"] = (
|
|
470
|
+
quality_metrics.get("missing_required_case_count") == 0
|
|
471
|
+
)
|
|
472
|
+
checks["quality_memory_ability_coverage_rate"] = (
|
|
473
|
+
quality_metrics.get("memory_ability_coverage_rate") == 1.0
|
|
474
|
+
)
|
|
475
|
+
checks["quality_missing_memory_ability_cases"] = (
|
|
476
|
+
quality_metrics.get("missing_memory_ability_cases") == {}
|
|
477
|
+
)
|
|
478
|
+
checks["quality_failed_memory_ability_cases"] = (
|
|
479
|
+
quality_metrics.get("failed_memory_ability_cases") == {}
|
|
480
|
+
)
|
|
481
|
+
checks["semantic_linking_required_case_coverage_rate"] = (
|
|
482
|
+
semantic_metrics.get("required_case_coverage_rate") == 1.0
|
|
483
|
+
)
|
|
484
|
+
checks["semantic_linking_missing_required_case_count"] = (
|
|
485
|
+
semantic_metrics.get("missing_required_case_count") == 0
|
|
486
|
+
)
|
|
487
|
+
checks["long_memory_ability_coverage_rate"] = (
|
|
488
|
+
long_memory_metrics.get("memory_ability_coverage_rate") == 1.0
|
|
489
|
+
)
|
|
490
|
+
checks["long_memory_missing_memory_ability_cases"] = (
|
|
491
|
+
long_memory_metrics.get("missing_memory_ability_cases") == {}
|
|
492
|
+
)
|
|
493
|
+
checks["long_memory_failed_memory_ability_cases"] = (
|
|
494
|
+
long_memory_metrics.get("failed_memory_ability_cases") == {}
|
|
495
|
+
)
|
|
496
|
+
checks.update(
|
|
497
|
+
_scorecard_required_case_checks(
|
|
498
|
+
quality_result,
|
|
499
|
+
prefix="quality",
|
|
500
|
+
required_case_ids=QUALITY_GOLDEN_REQUIRED_CASE_IDS,
|
|
501
|
+
)
|
|
502
|
+
)
|
|
503
|
+
checks.update(
|
|
504
|
+
_scorecard_required_case_checks(
|
|
505
|
+
semantic_result,
|
|
506
|
+
prefix="semantic_linking",
|
|
507
|
+
required_case_ids=SEMANTIC_LINKING_REQUIRED_CASE_IDS,
|
|
508
|
+
)
|
|
509
|
+
)
|
|
510
|
+
checks.update(
|
|
511
|
+
_scorecard_required_case_checks(
|
|
512
|
+
long_memory_result,
|
|
513
|
+
prefix="long_memory",
|
|
514
|
+
required_case_ids=LONG_MEMORY_REQUIRED_CASE_IDS,
|
|
515
|
+
)
|
|
516
|
+
)
|
|
517
|
+
checks["auto_memory_extraction_case_count"] = (
|
|
518
|
+
int(auto_metrics.get("extraction_case_count", 0))
|
|
519
|
+
>= _MEMORY_QUALITY_SCORECARD_MIN_EXTRACTION_CASES
|
|
520
|
+
)
|
|
521
|
+
checks["auto_memory_semantic_extraction_case_count"] = (
|
|
522
|
+
int(auto_metrics.get("extraction_semantic_case_count", 0))
|
|
523
|
+
>= _MEMORY_QUALITY_SCORECARD_MIN_SEMANTIC_EXTRACTION_CASES
|
|
524
|
+
)
|
|
525
|
+
return _scorecard_capability("coverage_floors", checks)
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def _scorecard_required_case_checks(
|
|
529
|
+
result: Mapping[str, object] | None,
|
|
530
|
+
*,
|
|
531
|
+
prefix: str,
|
|
532
|
+
required_case_ids: Sequence[str],
|
|
533
|
+
) -> dict[str, bool]:
|
|
534
|
+
case_ids = set(_scorecard_case_ids(result))
|
|
535
|
+
return {
|
|
536
|
+
f"{prefix}_required_case_{case_id}": case_id in case_ids
|
|
537
|
+
for case_id in required_case_ids
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def _scorecard_case_ids(result: Mapping[str, object] | None) -> tuple[str, ...]:
|
|
542
|
+
if result is None:
|
|
543
|
+
return ()
|
|
544
|
+
raw_cases = result.get("cases")
|
|
545
|
+
if not isinstance(raw_cases, list | tuple):
|
|
546
|
+
return ()
|
|
547
|
+
case_ids: list[str] = []
|
|
548
|
+
for raw_case in raw_cases:
|
|
549
|
+
case_id = raw_case.get("case_id") if isinstance(raw_case, Mapping) else raw_case
|
|
550
|
+
if isinstance(case_id, str) and case_id:
|
|
551
|
+
case_ids.append(case_id)
|
|
552
|
+
return tuple(case_ids)
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
def _scorecard_canonical_recall_precision(
|
|
556
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
557
|
+
) -> dict[str, object]:
|
|
558
|
+
small = _scorecard_result_metrics(suite_results.get(SMALL_GOLDEN_SUITE))
|
|
559
|
+
quality = _scorecard_result_metrics(suite_results.get(QUALITY_GOLDEN_SUITE))
|
|
560
|
+
checks = {
|
|
561
|
+
"small_recall_at_5": float(small.get("recall_at_5", 0.0)) >= _SMALL_GOLDEN_RECALL_GATE,
|
|
562
|
+
"small_precision_at_5": (
|
|
563
|
+
float(small.get("precision_at_5", 0.0)) >= _SMALL_GOLDEN_PRECISION_GATE
|
|
564
|
+
),
|
|
565
|
+
"quality_recall_at_5": (
|
|
566
|
+
float(quality.get("recall_at_5", 0.0)) >= _QUALITY_GOLDEN_RECALL_GATE
|
|
567
|
+
),
|
|
568
|
+
"quality_precision_at_5": (
|
|
569
|
+
float(quality.get("precision_at_5", 0.0)) >= _QUALITY_GOLDEN_PRECISION_GATE
|
|
570
|
+
),
|
|
571
|
+
"answer_support_rate": quality.get("answer_support_rate") == 1.0,
|
|
572
|
+
"answer_support_breakdown_rate": (
|
|
573
|
+
quality.get("answer_support_breakdown_rate") == 1.0
|
|
574
|
+
),
|
|
575
|
+
"document_recall_at_5": float(quality.get("document_recall_at_5", 0.0)) >= 0.95,
|
|
576
|
+
"retrieval_trace_support_rate": (
|
|
577
|
+
quality.get("retrieval_trace_support_rate") == 1.0
|
|
578
|
+
),
|
|
579
|
+
"retrieval_trace_location_contract_rate": (
|
|
580
|
+
quality.get("retrieval_trace_location_contract_rate") == 1.0
|
|
581
|
+
),
|
|
582
|
+
"retrieval_answerability_contract_rate": (
|
|
583
|
+
quality.get("retrieval_answerability_contract_rate") == 1.0
|
|
584
|
+
),
|
|
585
|
+
"no_candidate_abstention_rate": (
|
|
586
|
+
quality.get("no_candidate_abstention_rate") == 1.0
|
|
587
|
+
),
|
|
588
|
+
"no_candidate_leak_count": quality.get("no_candidate_leak_count") == 0,
|
|
589
|
+
"memory_ability_coverage_rate": (
|
|
590
|
+
quality.get("memory_ability_coverage_rate") == 1.0
|
|
591
|
+
),
|
|
592
|
+
"missing_memory_ability_cases": (
|
|
593
|
+
quality.get("missing_memory_ability_cases") == {}
|
|
594
|
+
),
|
|
595
|
+
"failed_memory_ability_cases": (
|
|
596
|
+
quality.get("failed_memory_ability_cases") == {}
|
|
597
|
+
),
|
|
598
|
+
"precise_citation_contract_rate": (
|
|
599
|
+
quality.get("precise_citation_contract_rate") == 1.0
|
|
600
|
+
),
|
|
601
|
+
"item_contract_support_rate": quality.get("item_contract_support_rate") == 1.0,
|
|
602
|
+
"item_contract_failure_count": quality.get("item_contract_failure_count") == 0,
|
|
603
|
+
}
|
|
604
|
+
return _scorecard_capability("canonical_recall_precision", checks)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def _scorecard_retrieval_context_memory_layer(
|
|
608
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
609
|
+
) -> dict[str, object]:
|
|
610
|
+
quality_result = suite_results.get(QUALITY_GOLDEN_SUITE)
|
|
611
|
+
quality = _scorecard_result_metrics(suite_results.get(QUALITY_GOLDEN_SUITE))
|
|
612
|
+
multimodal = _scorecard_result_metrics(
|
|
613
|
+
suite_results.get(MULTIMODAL_OFFLINE_GOLDEN_SUITE)
|
|
614
|
+
)
|
|
615
|
+
quality_case_ids = set(_scorecard_case_ids(quality_result))
|
|
616
|
+
checks = {
|
|
617
|
+
**{
|
|
618
|
+
f"quality_case_{case_id}": case_id in quality_case_ids
|
|
619
|
+
for case_id in _RETRIEVAL_CONTEXT_QUALITY_CASE_IDS
|
|
620
|
+
},
|
|
621
|
+
"quality_recall_at_5": (
|
|
622
|
+
float(quality.get("recall_at_5", 0.0)) >= _QUALITY_GOLDEN_RECALL_GATE
|
|
623
|
+
),
|
|
624
|
+
"quality_precision_at_5": (
|
|
625
|
+
float(quality.get("precision_at_5", 0.0)) >= _QUALITY_GOLDEN_PRECISION_GATE
|
|
626
|
+
),
|
|
627
|
+
"document_recall_at_5": float(quality.get("document_recall_at_5", 0.0)) >= 0.95,
|
|
628
|
+
"hybrid_retrieval_rate": quality.get("hybrid_retrieval_rate") == 1.0,
|
|
629
|
+
"citation_support_rate": quality.get("citation_support_rate") == 1.0,
|
|
630
|
+
"source_citation_failure_count": quality.get("source_citation_failure_count") == 0,
|
|
631
|
+
"answer_support_rate": quality.get("answer_support_rate") == 1.0,
|
|
632
|
+
"answer_support_breakdown_rate": (
|
|
633
|
+
quality.get("answer_support_breakdown_rate") == 1.0
|
|
634
|
+
),
|
|
635
|
+
"retrieval_trace_support_rate": (
|
|
636
|
+
quality.get("retrieval_trace_support_rate") == 1.0
|
|
637
|
+
),
|
|
638
|
+
"retrieval_trace_location_contract_rate": (
|
|
639
|
+
quality.get("retrieval_trace_location_contract_rate") == 1.0
|
|
640
|
+
),
|
|
641
|
+
"retrieval_answerability_contract_rate": (
|
|
642
|
+
quality.get("retrieval_answerability_contract_rate") == 1.0
|
|
643
|
+
),
|
|
644
|
+
"no_candidate_abstention_rate": (
|
|
645
|
+
quality.get("no_candidate_abstention_rate") == 1.0
|
|
646
|
+
),
|
|
647
|
+
"no_candidate_leak_count": quality.get("no_candidate_leak_count") == 0,
|
|
648
|
+
"memory_ability_coverage_rate": (
|
|
649
|
+
quality.get("memory_ability_coverage_rate") == 1.0
|
|
650
|
+
),
|
|
651
|
+
"missing_memory_ability_cases": (
|
|
652
|
+
quality.get("missing_memory_ability_cases") == {}
|
|
653
|
+
),
|
|
654
|
+
"failed_memory_ability_cases": (
|
|
655
|
+
quality.get("failed_memory_ability_cases") == {}
|
|
656
|
+
),
|
|
657
|
+
"precise_citation_contract_rate": (
|
|
658
|
+
quality.get("precise_citation_contract_rate") == 1.0
|
|
659
|
+
),
|
|
660
|
+
"item_contract_support_rate": quality.get("item_contract_support_rate") == 1.0,
|
|
661
|
+
"item_contract_failure_count": quality.get("item_contract_failure_count") == 0,
|
|
662
|
+
"multi_memory_scope_recall_at_5": (
|
|
663
|
+
quality.get("multi_memory_scope_recall_at_5") == 1.0
|
|
664
|
+
),
|
|
665
|
+
"thread_recall_at_5": quality.get("thread_recall_at_5") == 1.0,
|
|
666
|
+
"stale_memory_rate": quality.get("stale_memory_rate") == 0.0,
|
|
667
|
+
"deleted_memory_leak_count": quality.get("deleted_memory_leak_count") == 0,
|
|
668
|
+
"cross_memory_scope_leak_count": (
|
|
669
|
+
quality.get("cross_memory_scope_leak_count") == 0
|
|
670
|
+
),
|
|
671
|
+
"cross_thread_leak_count": quality.get("cross_thread_leak_count") == 0,
|
|
672
|
+
"restricted_memory_leak_count": (
|
|
673
|
+
quality.get("restricted_memory_leak_count") == 0
|
|
674
|
+
),
|
|
675
|
+
"prompt_injection_promoted_count": (
|
|
676
|
+
quality.get("prompt_injection_promoted_count") == 0
|
|
677
|
+
),
|
|
678
|
+
"context_token_overflow_count": quality.get("context_token_overflow_count") == 0,
|
|
679
|
+
"critical_failure_count": quality.get("critical_failure_count") == 0,
|
|
680
|
+
"harmful_context_rate": quality.get("harmful_context_rate") == 0.0,
|
|
681
|
+
"multimodal_retrieval_evidence_location_coverage_rate": (
|
|
682
|
+
multimodal.get("retrieval_evidence_location_coverage_rate") == 1.0
|
|
683
|
+
),
|
|
684
|
+
"multimodal_retrieval_evidence_location_gap_count": (
|
|
685
|
+
multimodal.get("retrieval_evidence_location_gap_count") == 0
|
|
686
|
+
),
|
|
687
|
+
"multimodal_false_positive_count": multimodal.get("false_positive_count") == 0,
|
|
688
|
+
"multimodal_prompt_injection_guard_rate": (
|
|
689
|
+
multimodal.get("prompt_injection_guard_rate") == 1.0
|
|
690
|
+
),
|
|
691
|
+
}
|
|
692
|
+
return _scorecard_capability("retrieval_context_memory_layer", checks)
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
def _scorecard_longitudinal_memory(
|
|
696
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
697
|
+
) -> dict[str, object]:
|
|
698
|
+
metrics = _scorecard_result_metrics(suite_results.get(LONG_MEMORY_GOLDEN_SUITE))
|
|
699
|
+
checks = {
|
|
700
|
+
"multi_session_recall_at_5": metrics.get("multi_session_recall_at_5") == 1.0,
|
|
701
|
+
"temporal_update_accuracy": metrics.get("temporal_update_accuracy") == 1.0,
|
|
702
|
+
"preference_synthesis_recall": metrics.get("preference_synthesis_recall") == 1.0,
|
|
703
|
+
"long_document_recall_at_5": float(metrics.get("long_document_recall_at_5", 0.0)) >= 0.95,
|
|
704
|
+
"no_candidate_abstention_rate": (
|
|
705
|
+
metrics.get("no_candidate_abstention_rate") == 1.0
|
|
706
|
+
),
|
|
707
|
+
"no_candidate_leak_count": metrics.get("no_candidate_leak_count") == 0,
|
|
708
|
+
"memory_ability_coverage_rate": (
|
|
709
|
+
metrics.get("memory_ability_coverage_rate") == 1.0
|
|
710
|
+
),
|
|
711
|
+
"missing_memory_ability_cases": (
|
|
712
|
+
metrics.get("missing_memory_ability_cases") == {}
|
|
713
|
+
),
|
|
714
|
+
"failed_memory_ability_cases": (
|
|
715
|
+
metrics.get("failed_memory_ability_cases") == {}
|
|
716
|
+
),
|
|
717
|
+
"long_safety_leak_count": metrics.get("long_safety_leak_count") == 0,
|
|
718
|
+
"stale_memory_rate": metrics.get("stale_memory_rate") == 0.0,
|
|
719
|
+
}
|
|
720
|
+
return _scorecard_capability("longitudinal_memory", checks)
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
def _scorecard_auto_memory_admission(
|
|
724
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
725
|
+
) -> dict[str, object]:
|
|
726
|
+
metrics = _scorecard_result_metrics(suite_results.get(AUTO_MEMORY_GOLDEN_SUITE))
|
|
727
|
+
checks = {
|
|
728
|
+
"extraction_positive_recall_rate": (metrics.get("extraction_positive_recall_rate") == 1.0),
|
|
729
|
+
"extraction_operation_accuracy": metrics.get("extraction_operation_accuracy") == 1.0,
|
|
730
|
+
"extraction_kind_accuracy": metrics.get("extraction_kind_accuracy") == 1.0,
|
|
731
|
+
"extraction_admission_accuracy": metrics.get("extraction_admission_accuracy") == 1.0,
|
|
732
|
+
"extraction_ttl_accuracy": metrics.get("extraction_ttl_accuracy") == 1.0,
|
|
733
|
+
"extraction_target_hint_accuracy": metrics.get("extraction_target_hint_accuracy") == 1.0,
|
|
734
|
+
"extraction_false_positive_count": metrics.get("extraction_false_positive_count") == 0,
|
|
735
|
+
"extraction_false_negative_count": metrics.get("extraction_false_negative_count") == 0,
|
|
736
|
+
"wrong_auto_apply_count": metrics.get("wrong_auto_apply_count") == 0,
|
|
737
|
+
"active_fact_before_review_count": metrics.get("active_fact_before_review_count") == 0,
|
|
738
|
+
"secret_leakage_count": metrics.get("secret_leakage_count") == 0,
|
|
739
|
+
"assistant_low_trust_violation_count": (
|
|
740
|
+
metrics.get("assistant_low_trust_violation_count") == 0
|
|
741
|
+
),
|
|
742
|
+
"target_resolution_violation_count": (
|
|
743
|
+
metrics.get("target_resolution_violation_count") == 0
|
|
744
|
+
),
|
|
745
|
+
"review_operation_violation_count": (metrics.get("review_operation_violation_count") == 0),
|
|
746
|
+
}
|
|
747
|
+
return _scorecard_capability("auto_memory_admission", checks)
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
def _scorecard_graph_native_recall(
|
|
751
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
752
|
+
) -> dict[str, object]:
|
|
753
|
+
metrics = _scorecard_result_metrics(suite_results.get(GRAPH_NATIVE_GOLDEN_SUITE))
|
|
754
|
+
checks = {
|
|
755
|
+
"graph_recall_rate": metrics.get("graph_recall_rate") == 1.0,
|
|
756
|
+
"graph_hydration_rate": metrics.get("graph_hydration_rate") == 1.0,
|
|
757
|
+
"graph_status_ok_rate": metrics.get("graph_status_ok_rate") == 1.0,
|
|
758
|
+
"graph_safety_leak_count": metrics.get("graph_safety_leak_count") == 0,
|
|
759
|
+
"graph_stale_drop_count": int(metrics.get("graph_stale_drop_count", 0)) >= 4,
|
|
760
|
+
"canonical_only_graph_skip_count": (metrics.get("canonical_only_graph_skip_count") == 1),
|
|
761
|
+
}
|
|
762
|
+
return _scorecard_capability("graph_native_recall", checks)
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
def _scorecard_semantic_linking(
|
|
766
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
767
|
+
) -> dict[str, object]:
|
|
768
|
+
result = suite_results.get(SEMANTIC_LINKING_GOLDEN_SUITE)
|
|
769
|
+
metrics = _scorecard_result_metrics(result)
|
|
770
|
+
checks_raw = result.get("checks", {}) if isinstance(result, dict) else {}
|
|
771
|
+
checks_map = checks_raw if isinstance(checks_raw, Mapping) else {}
|
|
772
|
+
checks = {
|
|
773
|
+
"ranking_accuracy": metrics.get("ranking_accuracy") == 1.0,
|
|
774
|
+
"event_linking_accuracy": metrics.get("event_linking_accuracy") == 1.0,
|
|
775
|
+
"temporal_intent_recall": metrics.get("temporal_intent_recall") == 1.0,
|
|
776
|
+
"document_chunk_linking_accuracy": (metrics.get("document_chunk_linking_accuracy") == 1.0),
|
|
777
|
+
"anchor_recall_rate": metrics.get("anchor_recall_rate") == 1.0,
|
|
778
|
+
"anchor_disambiguation_rate": metrics.get("anchor_disambiguation_rate") == 1.0,
|
|
779
|
+
"mixed_script_event_anchor_rate": (
|
|
780
|
+
metrics.get("mixed_script_event_anchor_rate") == 1.0
|
|
781
|
+
),
|
|
782
|
+
"anchor_review_evidence_rate": metrics.get("anchor_review_evidence_rate") == 1.0,
|
|
783
|
+
"high_impact_relation_policy_safety": (
|
|
784
|
+
metrics.get("high_impact_relation_policy_safety") == 1.0
|
|
785
|
+
),
|
|
786
|
+
"evidence_relation_policy_safety": (
|
|
787
|
+
metrics.get("evidence_relation_policy_safety") == 1.0
|
|
788
|
+
),
|
|
789
|
+
"mentions_relation_policy_safety": (
|
|
790
|
+
metrics.get("mentions_relation_policy_safety") == 1.0
|
|
791
|
+
),
|
|
792
|
+
"review_approval_rate": metrics.get("review_approval_rate") == 1.0,
|
|
793
|
+
"false_positive_count": metrics.get("false_positive_count") == 0,
|
|
794
|
+
"cross_scope_leak_count": metrics.get("cross_scope_leak_count") == 0,
|
|
795
|
+
**{
|
|
796
|
+
f"semantic_check_{check_name}": checks_map.get(check_name) is True
|
|
797
|
+
for check_name in _SEMANTIC_LINKING_REQUIRED_CHECKS
|
|
798
|
+
},
|
|
799
|
+
}
|
|
800
|
+
return _scorecard_capability("semantic_linking", checks)
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
def _scorecard_dedup_merge_conflict_resolution(
|
|
804
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
805
|
+
) -> dict[str, object]:
|
|
806
|
+
quality_result = suite_results.get(QUALITY_GOLDEN_SUITE)
|
|
807
|
+
auto_result = suite_results.get(AUTO_MEMORY_GOLDEN_SUITE)
|
|
808
|
+
semantic_result = suite_results.get(SEMANTIC_LINKING_GOLDEN_SUITE)
|
|
809
|
+
auto_metrics = _scorecard_result_metrics(auto_result)
|
|
810
|
+
semantic_metrics = _scorecard_result_metrics(semantic_result)
|
|
811
|
+
semantic_checks_raw = (
|
|
812
|
+
semantic_result.get("checks", {}) if isinstance(semantic_result, dict) else {}
|
|
813
|
+
)
|
|
814
|
+
semantic_checks = semantic_checks_raw if isinstance(semantic_checks_raw, Mapping) else {}
|
|
815
|
+
quality_case_ids = set(_scorecard_case_ids(quality_result))
|
|
816
|
+
auto_case_ids = set(_scorecard_case_ids(auto_result))
|
|
817
|
+
checks = {
|
|
818
|
+
**{
|
|
819
|
+
f"quality_case_{case_id}": case_id in quality_case_ids
|
|
820
|
+
for case_id in _DEDUP_MERGE_QUALITY_CASE_IDS
|
|
821
|
+
},
|
|
822
|
+
**{
|
|
823
|
+
f"auto_memory_case_{case_id}": case_id in auto_case_ids
|
|
824
|
+
for case_id in _DEDUP_MERGE_AUTO_CASE_IDS
|
|
825
|
+
},
|
|
826
|
+
"auto_memory_duplicate_suggestion_count": (
|
|
827
|
+
_scorecard_int(auto_metrics.get("duplicate_suggestion_count")) == 0
|
|
828
|
+
),
|
|
829
|
+
"auto_memory_replay_duplicate_suggestion_count": (
|
|
830
|
+
_scorecard_int(auto_metrics.get("replay_duplicate_suggestion_count")) == 0
|
|
831
|
+
),
|
|
832
|
+
"auto_memory_wrong_auto_apply_count": (
|
|
833
|
+
_scorecard_int(auto_metrics.get("wrong_auto_apply_count")) == 0
|
|
834
|
+
),
|
|
835
|
+
"auto_memory_active_fact_before_review_count": (
|
|
836
|
+
_scorecard_int(auto_metrics.get("active_fact_before_review_count")) == 0
|
|
837
|
+
),
|
|
838
|
+
"auto_memory_target_resolution_violation_count": (
|
|
839
|
+
_scorecard_int(auto_metrics.get("target_resolution_violation_count")) == 0
|
|
840
|
+
),
|
|
841
|
+
"auto_memory_review_operation_violation_count": (
|
|
842
|
+
_scorecard_int(auto_metrics.get("review_operation_violation_count")) == 0
|
|
843
|
+
),
|
|
844
|
+
**{
|
|
845
|
+
f"semantic_check_{check_name}": semantic_checks.get(check_name) is True
|
|
846
|
+
for check_name in _DEDUP_MERGE_SEMANTIC_CHECKS
|
|
847
|
+
},
|
|
848
|
+
"semantic_linking_false_positive_count": (
|
|
849
|
+
_scorecard_int(semantic_metrics.get("false_positive_count")) == 0
|
|
850
|
+
),
|
|
851
|
+
"semantic_linking_cross_scope_leak_count": (
|
|
852
|
+
_scorecard_int(semantic_metrics.get("cross_scope_leak_count")) == 0
|
|
853
|
+
),
|
|
854
|
+
}
|
|
855
|
+
return _scorecard_capability("dedup_merge_conflict_resolution", checks)
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
def _scorecard_cloud_self_host_readiness(
|
|
859
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
860
|
+
) -> dict[str, object]:
|
|
861
|
+
docker_report = suite_results.get(_MULTIMODAL_DOCKER_LIVE_PROOF_SUITE)
|
|
862
|
+
checks = {
|
|
863
|
+
"policy_requires_s3_compatible_hosted_backend": True,
|
|
864
|
+
"policy_requires_external_migration_runner_contract": True,
|
|
865
|
+
"policy_requires_storage_cleanup_contract": True,
|
|
866
|
+
"policy_requires_safe_diagnostics": True,
|
|
867
|
+
"policy_requires_scope_storage_quota": True,
|
|
868
|
+
}
|
|
869
|
+
if isinstance(docker_report, Mapping):
|
|
870
|
+
storage = _scorecard_docker_storage_readiness(docker_report)
|
|
871
|
+
production = _scorecard_storage_production_readiness(storage)
|
|
872
|
+
checks.update(
|
|
873
|
+
{
|
|
874
|
+
"docker_live_storage_readiness_report_present": bool(storage),
|
|
875
|
+
"docker_live_storage_readiness_v2": (
|
|
876
|
+
storage.get("schema_version")
|
|
877
|
+
== "asset-storage-deployment-readiness-v2"
|
|
878
|
+
),
|
|
879
|
+
"docker_live_self_host_ready": storage.get("self_host_ready") is True,
|
|
880
|
+
"docker_live_recommends_s3_for_hosted": (
|
|
881
|
+
storage.get("recommended_hosted_backend") == "s3"
|
|
882
|
+
),
|
|
883
|
+
"docker_live_blob_identity_sha256": (
|
|
884
|
+
storage.get("blob_identity") == "sha256"
|
|
885
|
+
),
|
|
886
|
+
"docker_live_duplicate_detection_sha256": (
|
|
887
|
+
storage.get("duplicate_detection") == "exact_sha256"
|
|
888
|
+
),
|
|
889
|
+
"docker_live_scope_storage_quota": (
|
|
890
|
+
_scorecard_int(storage.get("scope_storage_quota_bytes")) > 0
|
|
891
|
+
and storage.get("scope_storage_quota_enforced") is True
|
|
892
|
+
),
|
|
893
|
+
"docker_live_storage_cleanup_supported": (
|
|
894
|
+
storage.get("storage_cleanup_supported") is True
|
|
895
|
+
),
|
|
896
|
+
"docker_live_safe_diagnostics": storage.get("safe_diagnostics") is True,
|
|
897
|
+
"docker_live_schema_management_mode": (
|
|
898
|
+
storage.get("schema_management_mode")
|
|
899
|
+
in {"auto_create", "external_migration_runner"}
|
|
900
|
+
),
|
|
901
|
+
"docker_live_server_profile_disallows_auto_schema": (
|
|
902
|
+
storage.get("auto_create_schema_allowed_in_server_profile") is False
|
|
903
|
+
),
|
|
904
|
+
"docker_live_migration_runner_contract": (
|
|
905
|
+
isinstance(storage.get("migration_runner_required"), bool)
|
|
906
|
+
and storage.get("migration_runner_service")
|
|
907
|
+
== "infinity_context_migrate"
|
|
908
|
+
and storage.get("migration_strategy") == "external_forward_migrations"
|
|
909
|
+
),
|
|
910
|
+
"docker_live_storage_production_readiness_contract": (
|
|
911
|
+
production.get("ok") is True
|
|
912
|
+
),
|
|
913
|
+
"docker_live_storage_production_targets_present": (
|
|
914
|
+
production.get("targets_present") is True
|
|
915
|
+
),
|
|
916
|
+
"docker_live_storage_operator_actions_bounded": (
|
|
917
|
+
production.get("operator_actions_bounded") is True
|
|
918
|
+
),
|
|
919
|
+
}
|
|
920
|
+
)
|
|
921
|
+
return _scorecard_capability("cloud_self_host_readiness", checks)
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
def _scorecard_docker_storage_readiness(
|
|
925
|
+
report: Mapping[str, object],
|
|
926
|
+
) -> Mapping[str, object]:
|
|
927
|
+
components = report.get("components")
|
|
928
|
+
if not isinstance(components, Mapping):
|
|
929
|
+
return {}
|
|
930
|
+
capabilities = components.get("capabilities")
|
|
931
|
+
if not isinstance(capabilities, Mapping):
|
|
932
|
+
return {}
|
|
933
|
+
storage = capabilities.get("storage_readiness")
|
|
934
|
+
return storage if isinstance(storage, Mapping) else {}
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
def _scorecard_storage_production_readiness(
|
|
938
|
+
storage: Mapping[str, object],
|
|
939
|
+
) -> dict[str, object]:
|
|
940
|
+
production = storage.get("production_readiness")
|
|
941
|
+
if not isinstance(production, Mapping):
|
|
942
|
+
return {
|
|
943
|
+
"ok": False,
|
|
944
|
+
"targets_present": False,
|
|
945
|
+
"operator_actions_bounded": False,
|
|
946
|
+
}
|
|
947
|
+
requirement_status = production.get("requirement_status")
|
|
948
|
+
self_host = production.get("self_host")
|
|
949
|
+
hosted_team = production.get("hosted_team")
|
|
950
|
+
required_status_keys = {
|
|
951
|
+
"asset_storage_configured",
|
|
952
|
+
"asset_storage_ready",
|
|
953
|
+
"s3_compatible_backend",
|
|
954
|
+
"external_migration_runner",
|
|
955
|
+
"backup_policy",
|
|
956
|
+
"object_lifecycle_policy",
|
|
957
|
+
"maintenance_worker",
|
|
958
|
+
"cleanup_apply",
|
|
959
|
+
"s3_region",
|
|
960
|
+
}
|
|
961
|
+
status_ok = isinstance(requirement_status, Mapping) and all(
|
|
962
|
+
isinstance(requirement_status.get(key), bool) for key in required_status_keys
|
|
963
|
+
)
|
|
964
|
+
self_host_ok = _scorecard_storage_production_target_ok(self_host)
|
|
965
|
+
hosted_team_ok = _scorecard_storage_production_target_ok(hosted_team)
|
|
966
|
+
operator_actions_bounded = all(
|
|
967
|
+
_scorecard_storage_operator_actions_bounded(target)
|
|
968
|
+
for target in (self_host, hosted_team)
|
|
969
|
+
)
|
|
970
|
+
targets_present = self_host_ok and hosted_team_ok
|
|
971
|
+
return {
|
|
972
|
+
"ok": (
|
|
973
|
+
production.get("schema_version") == "asset-storage-production-readiness-v1"
|
|
974
|
+
and status_ok
|
|
975
|
+
and targets_present
|
|
976
|
+
and operator_actions_bounded
|
|
977
|
+
),
|
|
978
|
+
"targets_present": targets_present,
|
|
979
|
+
"operator_actions_bounded": operator_actions_bounded,
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
def _scorecard_storage_production_target_ok(target: object) -> bool:
|
|
984
|
+
if not isinstance(target, Mapping):
|
|
985
|
+
return False
|
|
986
|
+
return (
|
|
987
|
+
isinstance(target.get("production_ready"), bool)
|
|
988
|
+
and isinstance(target.get("blocking_requirements"), list)
|
|
989
|
+
and isinstance(target.get("operator_actions"), list)
|
|
990
|
+
)
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
def _scorecard_storage_operator_actions_bounded(target: object) -> bool:
|
|
994
|
+
if not isinstance(target, Mapping):
|
|
995
|
+
return False
|
|
996
|
+
actions = target.get("operator_actions")
|
|
997
|
+
if not isinstance(actions, list):
|
|
998
|
+
return False
|
|
999
|
+
return len(actions) <= 12 and all(
|
|
1000
|
+
isinstance(action, str) and 0 < len(action) <= 80 for action in actions
|
|
1001
|
+
)
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
def _scorecard_multimodal_evidence_retrieval(
|
|
1005
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1006
|
+
) -> dict[str, object]:
|
|
1007
|
+
result = suite_results.get(MULTIMODAL_OFFLINE_GOLDEN_SUITE)
|
|
1008
|
+
metrics = _scorecard_result_metrics(result)
|
|
1009
|
+
gates_raw = result.get("gates", {}) if isinstance(result, dict) else {}
|
|
1010
|
+
gates = gates_raw if isinstance(gates_raw, Mapping) else {}
|
|
1011
|
+
checks_raw = result.get("checks", {}) if isinstance(result, dict) else {}
|
|
1012
|
+
check_map = checks_raw if isinstance(checks_raw, Mapping) else {}
|
|
1013
|
+
checks = {
|
|
1014
|
+
"pass_rate": metrics.get("pass_rate") == 1.0,
|
|
1015
|
+
"case_count": int(metrics.get("case_count", 0)) >= 10,
|
|
1016
|
+
"false_positive_count": metrics.get("false_positive_count") == 0,
|
|
1017
|
+
"vision_linking_accuracy": metrics.get("vision_linking_accuracy") == 1.0,
|
|
1018
|
+
"metadata_only_visual_linking_accuracy": (
|
|
1019
|
+
metrics.get("metadata_only_visual_linking_accuracy") == 1.0
|
|
1020
|
+
),
|
|
1021
|
+
"audio_linking_accuracy": metrics.get("audio_linking_accuracy") == 1.0,
|
|
1022
|
+
"video_linking_accuracy": metrics.get("video_linking_accuracy") == 1.0,
|
|
1023
|
+
"temporal_audio_linking_accuracy": (
|
|
1024
|
+
metrics.get("temporal_audio_linking_accuracy") == 1.0
|
|
1025
|
+
),
|
|
1026
|
+
"similar_wrong_project_precision": (
|
|
1027
|
+
metrics.get("similar_wrong_project_precision") == 1.0
|
|
1028
|
+
),
|
|
1029
|
+
"empty_audio_no_candidate_rate": (
|
|
1030
|
+
metrics.get("empty_audio_no_candidate_rate") == 1.0
|
|
1031
|
+
),
|
|
1032
|
+
"prompt_injection_guard_rate": (
|
|
1033
|
+
metrics.get("prompt_injection_guard_rate") == 1.0
|
|
1034
|
+
),
|
|
1035
|
+
"retrieval_evidence_location_coverage_rate": (
|
|
1036
|
+
metrics.get("retrieval_evidence_location_coverage_rate") == 1.0
|
|
1037
|
+
),
|
|
1038
|
+
"retrieval_evidence_location_gap_count": (
|
|
1039
|
+
metrics.get("retrieval_evidence_location_gap_count") == 0
|
|
1040
|
+
),
|
|
1041
|
+
"gate_case_count": gates.get("case_count") is True,
|
|
1042
|
+
"gate_all_cases_passed": gates.get("all_cases_passed") is True,
|
|
1043
|
+
"gate_evidence_metadata_exposed": (
|
|
1044
|
+
gates.get("evidence_metadata_exposed") is True
|
|
1045
|
+
),
|
|
1046
|
+
"gate_retrieval_evidence_coverage_profile": (
|
|
1047
|
+
gates.get("retrieval_evidence_coverage_profile") is True
|
|
1048
|
+
),
|
|
1049
|
+
"check_prompt_injection_guard": (
|
|
1050
|
+
check_map.get("prompt_injection_guard") is True
|
|
1051
|
+
),
|
|
1052
|
+
"check_evidence_metadata_exposed": (
|
|
1053
|
+
check_map.get("evidence_metadata_exposed") is True
|
|
1054
|
+
),
|
|
1055
|
+
"check_retrieval_evidence_coverage_profile": (
|
|
1056
|
+
check_map.get("retrieval_evidence_coverage_profile") is True
|
|
1057
|
+
),
|
|
1058
|
+
}
|
|
1059
|
+
return _scorecard_capability("multimodal_evidence_retrieval", checks)
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
def _scorecard_scope_and_safety(
|
|
1063
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1064
|
+
) -> dict[str, object]:
|
|
1065
|
+
small = _scorecard_result_metrics(suite_results.get(SMALL_GOLDEN_SUITE))
|
|
1066
|
+
quality = _scorecard_result_metrics(suite_results.get(QUALITY_GOLDEN_SUITE))
|
|
1067
|
+
long = _scorecard_result_metrics(suite_results.get(LONG_MEMORY_GOLDEN_SUITE))
|
|
1068
|
+
auto = _scorecard_result_metrics(suite_results.get(AUTO_MEMORY_GOLDEN_SUITE))
|
|
1069
|
+
graph = _scorecard_result_metrics(suite_results.get(GRAPH_NATIVE_GOLDEN_SUITE))
|
|
1070
|
+
checks = {
|
|
1071
|
+
"deleted_memory_leak_count": (
|
|
1072
|
+
int(small.get("deleted_memory_leak_count", 0))
|
|
1073
|
+
+ int(quality.get("deleted_memory_leak_count", 0))
|
|
1074
|
+
+ int(long.get("deleted_memory_leak_count", 0))
|
|
1075
|
+
)
|
|
1076
|
+
== 0,
|
|
1077
|
+
"cross_scope_leak_count": (
|
|
1078
|
+
int(small.get("cross_memory_scope_leak_count", 0))
|
|
1079
|
+
+ int(quality.get("cross_memory_scope_leak_count", 0))
|
|
1080
|
+
+ int(quality.get("cross_thread_leak_count", 0))
|
|
1081
|
+
+ int(long.get("cross_memory_scope_leak_count", 0))
|
|
1082
|
+
+ int(long.get("cross_thread_leak_count", 0))
|
|
1083
|
+
+ int(graph.get("graph_safety_leak_count", 0))
|
|
1084
|
+
)
|
|
1085
|
+
== 0,
|
|
1086
|
+
"restricted_memory_leak_count": (
|
|
1087
|
+
int(quality.get("restricted_memory_leak_count", 0))
|
|
1088
|
+
+ int(long.get("restricted_memory_leak_count", 0))
|
|
1089
|
+
)
|
|
1090
|
+
== 0,
|
|
1091
|
+
"prompt_injection_promoted_count": (
|
|
1092
|
+
int(small.get("prompt_injection_promoted_count", 0))
|
|
1093
|
+
+ int(quality.get("prompt_injection_promoted_count", 0))
|
|
1094
|
+
+ int(long.get("prompt_injection_promoted_count", 0))
|
|
1095
|
+
+ int(auto.get("prompt_injection_promoted_count", 0))
|
|
1096
|
+
)
|
|
1097
|
+
== 0,
|
|
1098
|
+
"secret_leakage_count": int(auto.get("secret_leakage_count", 0)) == 0,
|
|
1099
|
+
"harmful_context_rate": (
|
|
1100
|
+
float(quality.get("harmful_context_rate", 0.0))
|
|
1101
|
+
+ float(long.get("harmful_context_rate", 0.0))
|
|
1102
|
+
)
|
|
1103
|
+
== 0.0,
|
|
1104
|
+
"context_token_overflow_count": (
|
|
1105
|
+
int(small.get("context_token_overflow_count", 0))
|
|
1106
|
+
+ int(quality.get("context_token_overflow_count", 0))
|
|
1107
|
+
+ int(long.get("context_token_overflow_count", 0))
|
|
1108
|
+
)
|
|
1109
|
+
== 0,
|
|
1110
|
+
}
|
|
1111
|
+
return _scorecard_capability("scope_and_safety", checks)
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
def _scorecard_prompt_context_contract(
|
|
1115
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1116
|
+
) -> dict[str, object]:
|
|
1117
|
+
result = suite_results.get(PROMPT_CONTRACT_SUITE, {})
|
|
1118
|
+
checks_raw = result.get("checks", {})
|
|
1119
|
+
checks_map = checks_raw if isinstance(checks_raw, dict) else {}
|
|
1120
|
+
checks = {
|
|
1121
|
+
"snapshot_safe": checks_map.get("snapshot_safe") is True,
|
|
1122
|
+
"snapshot_exists": checks_map.get("snapshot_exists") is True,
|
|
1123
|
+
"matches_snapshot": checks_map.get("matches_snapshot") is True,
|
|
1124
|
+
}
|
|
1125
|
+
return _scorecard_capability("prompt_context_contract", checks)
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
def _scorecard_external_evidence(
|
|
1129
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1130
|
+
*,
|
|
1131
|
+
require_top_evidence: bool = False,
|
|
1132
|
+
) -> dict[str, object]:
|
|
1133
|
+
full_provider = _scorecard_find_full_provider_report(suite_results)
|
|
1134
|
+
multimodal_live_provider = _scorecard_find_multimodal_live_provider_report(suite_results)
|
|
1135
|
+
agent_behavior = _scorecard_find_agent_behavior_report(suite_results, full_provider)
|
|
1136
|
+
agent_live_smoke = _scorecard_find_agent_live_smoke_report(suite_results)
|
|
1137
|
+
local_experience = _scorecard_find_local_experience_report(suite_results)
|
|
1138
|
+
full_provider_summary = _scorecard_full_provider_evidence_summary(
|
|
1139
|
+
full_provider,
|
|
1140
|
+
require_top_evidence=require_top_evidence,
|
|
1141
|
+
)
|
|
1142
|
+
multimodal_live_provider_summary = _scorecard_multimodal_live_provider_evidence_summary(
|
|
1143
|
+
multimodal_live_provider,
|
|
1144
|
+
require_top_evidence=require_top_evidence,
|
|
1145
|
+
)
|
|
1146
|
+
agent_behavior_summary = _scorecard_agent_behavior_evidence_summary(
|
|
1147
|
+
agent_behavior,
|
|
1148
|
+
require_top_evidence=require_top_evidence,
|
|
1149
|
+
)
|
|
1150
|
+
agent_live_smoke_summary = _scorecard_agent_live_smoke_evidence_summary(
|
|
1151
|
+
agent_live_smoke,
|
|
1152
|
+
require_top_evidence=require_top_evidence,
|
|
1153
|
+
)
|
|
1154
|
+
local_experience_summary = _scorecard_local_experience_evidence_summary(
|
|
1155
|
+
local_experience,
|
|
1156
|
+
require_top_evidence=require_top_evidence,
|
|
1157
|
+
)
|
|
1158
|
+
public_benchmark_summary = _scorecard_public_benchmark_evidence_summary(
|
|
1159
|
+
suite_results,
|
|
1160
|
+
full_provider=full_provider,
|
|
1161
|
+
require_top_evidence=require_top_evidence,
|
|
1162
|
+
)
|
|
1163
|
+
full_provider_ok = full_provider_summary["ok"] is True
|
|
1164
|
+
multimodal_live_provider_ok = multimodal_live_provider_summary["ok"] is True
|
|
1165
|
+
agent_behavior_ok = agent_behavior_summary["ok"] is True
|
|
1166
|
+
agent_live_smoke_ok = agent_live_smoke_summary["ok"] is True
|
|
1167
|
+
local_experience_ok = local_experience_summary["ok"] is True
|
|
1168
|
+
public_benchmark_ok = public_benchmark_summary["ok"] is True
|
|
1169
|
+
confidence_tier = _scorecard_confidence_tier(
|
|
1170
|
+
full_provider_ok=full_provider_ok,
|
|
1171
|
+
multimodal_live_provider_ok=multimodal_live_provider_ok,
|
|
1172
|
+
agent_behavior_ok=agent_behavior_ok,
|
|
1173
|
+
agent_live_smoke_ok=agent_live_smoke_ok,
|
|
1174
|
+
local_experience_ok=local_experience_ok,
|
|
1175
|
+
public_benchmark_ok=public_benchmark_ok,
|
|
1176
|
+
)
|
|
1177
|
+
|
|
1178
|
+
evidence_gaps = []
|
|
1179
|
+
if not full_provider_summary["present"]:
|
|
1180
|
+
evidence_gaps.append("full_provider_canary_missing")
|
|
1181
|
+
elif not full_provider_ok:
|
|
1182
|
+
evidence_gaps.append("full_provider_canary_failed")
|
|
1183
|
+
if full_provider_summary.get("provenance_ok") is False:
|
|
1184
|
+
evidence_gaps.append("full_provider_canary_provenance_failed")
|
|
1185
|
+
if full_provider_summary.get("safety_ok") is False:
|
|
1186
|
+
evidence_gaps.append("full_provider_canary_safety_failed")
|
|
1187
|
+
if not multimodal_live_provider_summary["present"]:
|
|
1188
|
+
evidence_gaps.append("multimodal_live_provider_canary_missing")
|
|
1189
|
+
elif not multimodal_live_provider_ok:
|
|
1190
|
+
evidence_gaps.append("multimodal_live_provider_canary_failed")
|
|
1191
|
+
if multimodal_live_provider_summary.get("provenance_ok") is False:
|
|
1192
|
+
evidence_gaps.append("multimodal_live_provider_canary_provenance_failed")
|
|
1193
|
+
if multimodal_live_provider_summary.get("safety_ok") is False:
|
|
1194
|
+
evidence_gaps.append("multimodal_live_provider_canary_safety_failed")
|
|
1195
|
+
if multimodal_live_provider_summary.get("provider_key_present") is False:
|
|
1196
|
+
evidence_gaps.append("multimodal_live_provider_key_missing")
|
|
1197
|
+
if not agent_behavior_summary["present"]:
|
|
1198
|
+
evidence_gaps.append("agent_behavior_benchmark_missing")
|
|
1199
|
+
elif not agent_behavior_ok:
|
|
1200
|
+
evidence_gaps.append("agent_behavior_benchmark_failed")
|
|
1201
|
+
if agent_behavior_summary.get("provenance_ok") is False:
|
|
1202
|
+
evidence_gaps.append("agent_behavior_benchmark_provenance_failed")
|
|
1203
|
+
if agent_behavior_summary.get("safety_ok") is False:
|
|
1204
|
+
evidence_gaps.append("agent_behavior_benchmark_safety_failed")
|
|
1205
|
+
if agent_behavior_summary.get("quality_floor_ok") is False:
|
|
1206
|
+
evidence_gaps.append("agent_behavior_quality_floor_failed")
|
|
1207
|
+
if not agent_live_smoke_summary["present"]:
|
|
1208
|
+
evidence_gaps.append("agent_live_smoke_missing")
|
|
1209
|
+
elif not agent_live_smoke_ok:
|
|
1210
|
+
evidence_gaps.append("agent_live_smoke_failed")
|
|
1211
|
+
if agent_live_smoke_summary.get("provenance_ok") is False:
|
|
1212
|
+
evidence_gaps.append("agent_live_smoke_provenance_failed")
|
|
1213
|
+
if agent_live_smoke_summary.get("safety_ok") is False:
|
|
1214
|
+
evidence_gaps.append("agent_live_smoke_safety_failed")
|
|
1215
|
+
if agent_live_smoke_summary.get("quality_floor_ok") is False:
|
|
1216
|
+
evidence_gaps.append("agent_live_smoke_quality_floor_failed")
|
|
1217
|
+
if not public_benchmark_summary["present"]:
|
|
1218
|
+
evidence_gaps.append("public_benchmark_evidence_missing")
|
|
1219
|
+
elif not public_benchmark_ok:
|
|
1220
|
+
evidence_gaps.append("public_benchmark_evidence_failed")
|
|
1221
|
+
if public_benchmark_summary.get("provenance_ok") is False:
|
|
1222
|
+
evidence_gaps.append("public_benchmark_provenance_failed")
|
|
1223
|
+
if public_benchmark_summary.get("safety_ok") is False:
|
|
1224
|
+
evidence_gaps.append("public_benchmark_safety_failed")
|
|
1225
|
+
if public_benchmark_summary.get("dataset_evidence_ok") is False:
|
|
1226
|
+
evidence_gaps.append("public_benchmark_dataset_evidence_failed")
|
|
1227
|
+
if public_benchmark_summary.get("competitive_floor_ok") is False:
|
|
1228
|
+
evidence_gaps.append("public_benchmark_competitive_floor_failed")
|
|
1229
|
+
top_library_ready = (
|
|
1230
|
+
full_provider_ok
|
|
1231
|
+
and multimodal_live_provider_ok
|
|
1232
|
+
and agent_behavior_ok
|
|
1233
|
+
and agent_live_smoke_ok
|
|
1234
|
+
and public_benchmark_ok
|
|
1235
|
+
)
|
|
1236
|
+
readiness = _scorecard_external_evidence_readiness(
|
|
1237
|
+
full_provider_ok=full_provider_ok,
|
|
1238
|
+
multimodal_live_provider_ok=multimodal_live_provider_ok,
|
|
1239
|
+
agent_behavior_ok=agent_behavior_ok,
|
|
1240
|
+
agent_live_smoke_ok=agent_live_smoke_ok,
|
|
1241
|
+
local_experience_ok=local_experience_ok,
|
|
1242
|
+
public_benchmark_ok=public_benchmark_ok,
|
|
1243
|
+
top_library_ready=top_library_ready,
|
|
1244
|
+
evidence_gaps=evidence_gaps,
|
|
1245
|
+
)
|
|
1246
|
+
|
|
1247
|
+
return {
|
|
1248
|
+
"confidence_tier": confidence_tier,
|
|
1249
|
+
"required_for_gate": require_top_evidence,
|
|
1250
|
+
"top_library_comparison_ready": top_library_ready,
|
|
1251
|
+
"readiness": readiness,
|
|
1252
|
+
"benchmark_note": (
|
|
1253
|
+
"Internal deterministic suites are the local quality gate. "
|
|
1254
|
+
"Full-provider, multimodal live-provider, real-agent and public benchmark reports are "
|
|
1255
|
+
"optional evidence for production/top-library comparison claims."
|
|
1256
|
+
),
|
|
1257
|
+
"evidence_gaps": evidence_gaps,
|
|
1258
|
+
"full_provider_canary": full_provider_summary,
|
|
1259
|
+
"multimodal_live_provider": multimodal_live_provider_summary,
|
|
1260
|
+
"agent_behavior_benchmark": agent_behavior_summary,
|
|
1261
|
+
"agent_live_smoke": agent_live_smoke_summary,
|
|
1262
|
+
"local_experience": local_experience_summary,
|
|
1263
|
+
"public_benchmark": public_benchmark_summary,
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
def _scorecard_external_evidence_readiness(
|
|
1268
|
+
*,
|
|
1269
|
+
full_provider_ok: bool,
|
|
1270
|
+
multimodal_live_provider_ok: bool,
|
|
1271
|
+
agent_behavior_ok: bool,
|
|
1272
|
+
agent_live_smoke_ok: bool,
|
|
1273
|
+
local_experience_ok: bool,
|
|
1274
|
+
public_benchmark_ok: bool,
|
|
1275
|
+
top_library_ready: bool,
|
|
1276
|
+
evidence_gaps: Sequence[str],
|
|
1277
|
+
) -> dict[str, object]:
|
|
1278
|
+
ok_components = [
|
|
1279
|
+
name
|
|
1280
|
+
for name, ok in (
|
|
1281
|
+
("full_provider", full_provider_ok),
|
|
1282
|
+
("multimodal_live_provider", multimodal_live_provider_ok),
|
|
1283
|
+
("agent_behavior", agent_behavior_ok),
|
|
1284
|
+
("agent_live_smoke", agent_live_smoke_ok),
|
|
1285
|
+
("public_benchmark", public_benchmark_ok),
|
|
1286
|
+
)
|
|
1287
|
+
if ok
|
|
1288
|
+
]
|
|
1289
|
+
if top_library_ready:
|
|
1290
|
+
level = "top_library_comparison_ready"
|
|
1291
|
+
elif full_provider_ok and multimodal_live_provider_ok and public_benchmark_ok:
|
|
1292
|
+
level = "provider_and_public_benchmark_verified"
|
|
1293
|
+
elif not ok_components and local_experience_ok:
|
|
1294
|
+
level = "local_experience_verified"
|
|
1295
|
+
elif ok_components:
|
|
1296
|
+
level = "external_partial"
|
|
1297
|
+
else:
|
|
1298
|
+
level = "internal_deterministic_only"
|
|
1299
|
+
return {
|
|
1300
|
+
"schema_version": "memory-external-evidence-readiness-v1",
|
|
1301
|
+
"level": level,
|
|
1302
|
+
"score_10": round(10 * len(ok_components) / 5, 2),
|
|
1303
|
+
"ok_components": ok_components,
|
|
1304
|
+
"local_experience_ready": local_experience_ok,
|
|
1305
|
+
"blocking_gaps": list(evidence_gaps),
|
|
1306
|
+
"next_actions": _scorecard_external_evidence_next_actions(evidence_gaps),
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
def _scorecard_external_evidence_next_actions(
|
|
1311
|
+
evidence_gaps: Sequence[str],
|
|
1312
|
+
) -> list[str]:
|
|
1313
|
+
actions: list[str] = []
|
|
1314
|
+
gap_set = set(evidence_gaps)
|
|
1315
|
+
if "multimodal_live_provider_key_missing" in gap_set:
|
|
1316
|
+
actions.append("configure_live_provider_key")
|
|
1317
|
+
for gap, action in (
|
|
1318
|
+
("full_provider_canary_missing", "run_full_provider_canary"),
|
|
1319
|
+
("full_provider_canary_failed", "fix_full_provider_canary"),
|
|
1320
|
+
(
|
|
1321
|
+
"multimodal_live_provider_canary_missing",
|
|
1322
|
+
"run_multimodal_live_provider_canary",
|
|
1323
|
+
),
|
|
1324
|
+
(
|
|
1325
|
+
"multimodal_live_provider_canary_failed",
|
|
1326
|
+
"rerun_multimodal_live_provider_canary_after_fix",
|
|
1327
|
+
),
|
|
1328
|
+
("agent_behavior_benchmark_missing", "run_agent_behavior_benchmark"),
|
|
1329
|
+
("agent_behavior_benchmark_failed", "fix_agent_behavior_benchmark"),
|
|
1330
|
+
("agent_live_smoke_missing", "run_agent_live_smoke"),
|
|
1331
|
+
("agent_live_smoke_failed", "fix_agent_live_smoke"),
|
|
1332
|
+
("public_benchmark_evidence_missing", "run_official_public_benchmark_canary"),
|
|
1333
|
+
("public_benchmark_evidence_failed", "fix_public_benchmark_evidence"),
|
|
1334
|
+
(
|
|
1335
|
+
"public_benchmark_competitive_floor_failed",
|
|
1336
|
+
"increase_public_benchmark_case_count_to_competitive_floor",
|
|
1337
|
+
),
|
|
1338
|
+
("public_benchmark_dataset_evidence_failed", "fix_public_benchmark_dataset_metadata"),
|
|
1339
|
+
):
|
|
1340
|
+
if gap in gap_set:
|
|
1341
|
+
actions.append(action)
|
|
1342
|
+
if any(gap.endswith("_provenance_failed") for gap in gap_set):
|
|
1343
|
+
actions.append("regenerate_external_reports_on_clean_commit")
|
|
1344
|
+
if any(gap.endswith("_safety_failed") for gap in gap_set):
|
|
1345
|
+
actions.append("fix_external_report_secret_redaction")
|
|
1346
|
+
return list(dict.fromkeys(actions))
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
def _scorecard_find_full_provider_report(
|
|
1350
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1351
|
+
) -> dict[str, object] | None:
|
|
1352
|
+
for suite in _FULL_PROVIDER_CANARY_SUITE_ALIASES:
|
|
1353
|
+
result = suite_results.get(suite)
|
|
1354
|
+
if result is not None:
|
|
1355
|
+
return result
|
|
1356
|
+
return None
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
def _scorecard_find_multimodal_live_provider_report(
|
|
1360
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1361
|
+
) -> dict[str, object] | None:
|
|
1362
|
+
for suite in _MULTIMODAL_LIVE_PROVIDER_CANARY_SUITE_ALIASES:
|
|
1363
|
+
result = suite_results.get(suite)
|
|
1364
|
+
if result is not None:
|
|
1365
|
+
return result
|
|
1366
|
+
return None
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
def _scorecard_find_agent_behavior_report(
|
|
1370
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1371
|
+
full_provider: dict[str, object] | None,
|
|
1372
|
+
) -> dict[str, object] | None:
|
|
1373
|
+
result = suite_results.get(AGENT_BEHAVIOR_BENCH_SUITE)
|
|
1374
|
+
if result is not None:
|
|
1375
|
+
return result
|
|
1376
|
+
if full_provider is None:
|
|
1377
|
+
return None
|
|
1378
|
+
nested = full_provider.get("agent_behavior")
|
|
1379
|
+
return nested if isinstance(nested, dict) else None
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
def _scorecard_find_agent_live_smoke_report(
|
|
1383
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1384
|
+
) -> dict[str, object] | None:
|
|
1385
|
+
for suite in _AGENT_LIVE_SMOKE_SUITE_ALIASES:
|
|
1386
|
+
result = suite_results.get(suite)
|
|
1387
|
+
if result is not None:
|
|
1388
|
+
return result
|
|
1389
|
+
return None
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
def _scorecard_find_local_experience_report(
|
|
1393
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1394
|
+
) -> dict[str, object] | None:
|
|
1395
|
+
return suite_results.get(LOCAL_EXPERIENCE_PROOF_SUITE)
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
def _scorecard_confidence_tier(
|
|
1399
|
+
*,
|
|
1400
|
+
full_provider_ok: bool,
|
|
1401
|
+
multimodal_live_provider_ok: bool,
|
|
1402
|
+
agent_behavior_ok: bool,
|
|
1403
|
+
agent_live_smoke_ok: bool,
|
|
1404
|
+
local_experience_ok: bool,
|
|
1405
|
+
public_benchmark_ok: bool,
|
|
1406
|
+
) -> str:
|
|
1407
|
+
labels = []
|
|
1408
|
+
if full_provider_ok:
|
|
1409
|
+
labels.append("full_provider")
|
|
1410
|
+
if multimodal_live_provider_ok:
|
|
1411
|
+
labels.append("multimodal_live_provider")
|
|
1412
|
+
if agent_behavior_ok:
|
|
1413
|
+
labels.append("agent_behavior")
|
|
1414
|
+
if agent_live_smoke_ok:
|
|
1415
|
+
labels.append("agent_live_smoke")
|
|
1416
|
+
if local_experience_ok:
|
|
1417
|
+
labels.append("local_experience")
|
|
1418
|
+
if public_benchmark_ok:
|
|
1419
|
+
labels.append("public_benchmark")
|
|
1420
|
+
if not labels:
|
|
1421
|
+
return "internal_deterministic"
|
|
1422
|
+
return "_and_".join(labels) + "_evaluated"
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
def _scorecard_agent_live_smoke_evidence_summary(
|
|
1426
|
+
result: dict[str, object] | None,
|
|
1427
|
+
*,
|
|
1428
|
+
require_top_evidence: bool = False,
|
|
1429
|
+
) -> dict[str, object]:
|
|
1430
|
+
if result is None:
|
|
1431
|
+
return {"present": False, "ok": None}
|
|
1432
|
+
checks_raw = result.get("checks")
|
|
1433
|
+
checks_map = checks_raw if isinstance(checks_raw, Mapping) else {}
|
|
1434
|
+
generated_mcp = checks_map.get("generated_mcp")
|
|
1435
|
+
generated_mcp_map = generated_mcp if isinstance(generated_mcp, Mapping) else {}
|
|
1436
|
+
agent_cli = checks_map.get("agent_cli")
|
|
1437
|
+
agent_cli_map = agent_cli if isinstance(agent_cli, Mapping) else {}
|
|
1438
|
+
required_checks: dict[str, bool] = {
|
|
1439
|
+
"result_ok": result.get("ok") is True,
|
|
1440
|
+
"strict_agent_cli_enabled": result.get("strict_agent_cli") is True,
|
|
1441
|
+
"generated_mcp_checks_present": bool(generated_mcp_map),
|
|
1442
|
+
"agent_cli_checks_present": bool(agent_cli_map),
|
|
1443
|
+
}
|
|
1444
|
+
for name in _AGENT_LIVE_SMOKE_REQUIRED_GENERATED_MCP_CHECKS:
|
|
1445
|
+
required_checks[f"generated_mcp_{name}_ok"] = _scorecard_live_check_ok(
|
|
1446
|
+
generated_mcp_map.get(name),
|
|
1447
|
+
ok_key="ok",
|
|
1448
|
+
expected=True,
|
|
1449
|
+
)
|
|
1450
|
+
for name in _AGENT_LIVE_SMOKE_REQUIRED_AGENT_CLI_CHECKS:
|
|
1451
|
+
required_checks[f"agent_cli_{name}_ok"] = _scorecard_live_check_ok(
|
|
1452
|
+
agent_cli_map.get(name),
|
|
1453
|
+
ok_key="status",
|
|
1454
|
+
expected="ok",
|
|
1455
|
+
)
|
|
1456
|
+
failed_required_checks = sorted(
|
|
1457
|
+
check for check, ok in required_checks.items() if ok is not True
|
|
1458
|
+
)
|
|
1459
|
+
provenance = top_evidence_provenance_summary(result)
|
|
1460
|
+
safety = top_evidence_safety_summary(result)
|
|
1461
|
+
quality_ok = not failed_required_checks
|
|
1462
|
+
return {
|
|
1463
|
+
"present": True,
|
|
1464
|
+
"suite": result.get("suite", AGENT_LIVE_SMOKE_SUITE),
|
|
1465
|
+
"ok": quality_ok
|
|
1466
|
+
and (not require_top_evidence or (provenance["ok"] is True and safety["ok"] is True)),
|
|
1467
|
+
"quality_ok": quality_ok,
|
|
1468
|
+
"quality_floor_ok": quality_ok,
|
|
1469
|
+
"provenance_ok": provenance["ok"] if require_top_evidence else None,
|
|
1470
|
+
"provenance": provenance,
|
|
1471
|
+
"safety_ok": safety["ok"] if require_top_evidence else None,
|
|
1472
|
+
"safety": safety,
|
|
1473
|
+
"strict_agent_cli": result.get("strict_agent_cli"),
|
|
1474
|
+
"required_checks": required_checks,
|
|
1475
|
+
"failed_required_checks": failed_required_checks,
|
|
1476
|
+
"generated_mcp": _scorecard_live_check_statuses(generated_mcp_map),
|
|
1477
|
+
"agent_cli": _scorecard_live_check_statuses(agent_cli_map),
|
|
1478
|
+
"generated_mcp_failures": _scorecard_string_list(result.get("generated_mcp_failures")),
|
|
1479
|
+
"agent_cli_failures": _scorecard_string_list(result.get("agent_cli_failures")),
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
def _scorecard_local_experience_evidence_summary(
|
|
1484
|
+
result: dict[str, object] | None,
|
|
1485
|
+
*,
|
|
1486
|
+
require_top_evidence: bool = False,
|
|
1487
|
+
) -> dict[str, object]:
|
|
1488
|
+
if result is None:
|
|
1489
|
+
return {"present": False, "ok": None}
|
|
1490
|
+
components_raw = result.get("components")
|
|
1491
|
+
components = components_raw if isinstance(components_raw, Mapping) else {}
|
|
1492
|
+
quickstart_live = _scorecard_mapping(components.get("quickstart_live"))
|
|
1493
|
+
doctor = _scorecard_mapping(components.get("doctor"))
|
|
1494
|
+
visual_smoke = _scorecard_mapping(components.get("local_visual_smoke"))
|
|
1495
|
+
visual_checks = _scorecard_mapping(visual_smoke.get("checks"))
|
|
1496
|
+
mcp_tool_count = _scorecard_int(visual_smoke.get("mcp_tool_count"))
|
|
1497
|
+
required_checks = {
|
|
1498
|
+
"result_ok": result.get("ok") is True,
|
|
1499
|
+
"quickstart_live_ok": quickstart_live.get("ok") is True,
|
|
1500
|
+
"quickstart_live_ready": quickstart_live.get("local_experience_status") == "ready",
|
|
1501
|
+
"doctor_ok": doctor.get("ok") is True,
|
|
1502
|
+
"doctor_ready": doctor.get("local_experience_status") == "ready",
|
|
1503
|
+
"visual_smoke_ok": visual_smoke.get("ok") is True,
|
|
1504
|
+
"mcp_tool_count_min": (
|
|
1505
|
+
mcp_tool_count is not None and mcp_tool_count >= _LOCAL_EXPERIENCE_MIN_MCP_TOOL_COUNT
|
|
1506
|
+
),
|
|
1507
|
+
"visual_memory_visible": visual_checks.get("visual_memory_visible") is True,
|
|
1508
|
+
"pending_review_created": visual_checks.get("pending_review_created") is True,
|
|
1509
|
+
"mcp_digest_ready": visual_checks.get("mcp_digest_ready") is True,
|
|
1510
|
+
"mcp_digest_evidence_only": visual_checks.get("mcp_digest_evidence_only") is True,
|
|
1511
|
+
"mcp_digest_token_safe": visual_checks.get("mcp_digest_token_safe") is True,
|
|
1512
|
+
"mcp_reviewed_search_ready": visual_checks.get("mcp_reviewed_search_ready") is True,
|
|
1513
|
+
"mcp_reviewed_search_grounded": (
|
|
1514
|
+
visual_checks.get("mcp_reviewed_search_grounded") is True
|
|
1515
|
+
),
|
|
1516
|
+
"mcp_reviewed_search_cited": visual_checks.get("mcp_reviewed_search_cited") is True,
|
|
1517
|
+
"mcp_reviewed_search_source_bound": (
|
|
1518
|
+
visual_checks.get("mcp_reviewed_search_source_bound") is True
|
|
1519
|
+
),
|
|
1520
|
+
"mcp_reviewed_search_token_safe": (
|
|
1521
|
+
visual_checks.get("mcp_reviewed_search_token_safe") is True
|
|
1522
|
+
),
|
|
1523
|
+
"generated_mcp_raw_token_absent": visual_checks.get("raw_token_absent") is True,
|
|
1524
|
+
"generated_mcp_token_not_included": visual_checks.get("token_not_included") is True,
|
|
1525
|
+
}
|
|
1526
|
+
failed_required_checks = sorted(
|
|
1527
|
+
check for check, ok in required_checks.items() if ok is not True
|
|
1528
|
+
)
|
|
1529
|
+
provenance = top_evidence_provenance_summary(
|
|
1530
|
+
result,
|
|
1531
|
+
policy=_LOCAL_EXPERIENCE_PROVENANCE_POLICY,
|
|
1532
|
+
allow_dirty_top_evidence=True,
|
|
1533
|
+
)
|
|
1534
|
+
safety = _scorecard_local_experience_safety_summary(result)
|
|
1535
|
+
quality_ok = not failed_required_checks
|
|
1536
|
+
return {
|
|
1537
|
+
"present": True,
|
|
1538
|
+
"suite": result.get("suite", LOCAL_EXPERIENCE_PROOF_SUITE),
|
|
1539
|
+
"ok": quality_ok
|
|
1540
|
+
and (not require_top_evidence or (provenance["ok"] is True and safety["ok"] is True)),
|
|
1541
|
+
"quality_ok": quality_ok,
|
|
1542
|
+
"provenance_ok": provenance["ok"] if require_top_evidence else None,
|
|
1543
|
+
"provenance": provenance,
|
|
1544
|
+
"safety_ok": safety["ok"] if require_top_evidence else None,
|
|
1545
|
+
"safety": _scorecard_bounded_safety_summary(safety),
|
|
1546
|
+
"required_checks": required_checks,
|
|
1547
|
+
"failed_required_checks": failed_required_checks,
|
|
1548
|
+
"mcp_tool_count": mcp_tool_count,
|
|
1549
|
+
"ui_url": visual_smoke.get("ui_url") or result.get("ui_url"),
|
|
1550
|
+
"review_url": visual_smoke.get("review_url"),
|
|
1551
|
+
"readiness_score": quickstart_live.get("readiness_score"),
|
|
1552
|
+
"retrieval_answerability_status": visual_smoke.get("retrieval_answerability_status"),
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
def _scorecard_local_experience_safety_summary(
|
|
1557
|
+
result: Mapping[str, object],
|
|
1558
|
+
) -> dict[str, object]:
|
|
1559
|
+
raw = top_evidence_safety_summary(result)
|
|
1560
|
+
raw_checks = _scorecard_mapping(raw.get("checks"))
|
|
1561
|
+
checks = {
|
|
1562
|
+
"no_sensitive_text": raw_checks.get("no_sensitive_text") is True,
|
|
1563
|
+
"local_path_count_bounded": _scorecard_int(raw.get("local_path_count")) is not None,
|
|
1564
|
+
}
|
|
1565
|
+
failed_checks = sorted(check for check, ok in checks.items() if ok is not True)
|
|
1566
|
+
return {
|
|
1567
|
+
"ok": not failed_checks,
|
|
1568
|
+
"checks": checks,
|
|
1569
|
+
"failed_checks": failed_checks,
|
|
1570
|
+
"local_path_count": _scorecard_int(raw.get("local_path_count")),
|
|
1571
|
+
"sensitive_path_count": _scorecard_int(raw.get("sensitive_path_count")),
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
def _scorecard_live_check_ok(
|
|
1576
|
+
value: object,
|
|
1577
|
+
*,
|
|
1578
|
+
ok_key: str,
|
|
1579
|
+
expected: object,
|
|
1580
|
+
) -> bool:
|
|
1581
|
+
return isinstance(value, Mapping) and value.get(ok_key) == expected
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
def _scorecard_bounded_safety_summary(summary: Mapping[str, object]) -> dict[str, object]:
|
|
1585
|
+
return {
|
|
1586
|
+
"ok": summary.get("ok"),
|
|
1587
|
+
"checks": summary.get("checks") if isinstance(summary.get("checks"), Mapping) else {},
|
|
1588
|
+
"failed_checks": _scorecard_string_list(summary.get("failed_checks")),
|
|
1589
|
+
"local_path_count": _scorecard_int(summary.get("local_path_count")),
|
|
1590
|
+
"sensitive_path_count": _scorecard_int(summary.get("sensitive_path_count")),
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
def _scorecard_live_check_statuses(
|
|
1595
|
+
checks: Mapping[object, object],
|
|
1596
|
+
) -> dict[str, object]:
|
|
1597
|
+
statuses: dict[str, object] = {}
|
|
1598
|
+
for name, value in checks.items():
|
|
1599
|
+
if not isinstance(name, str) or not isinstance(value, Mapping):
|
|
1600
|
+
continue
|
|
1601
|
+
if "status" in value:
|
|
1602
|
+
statuses[name] = value.get("status")
|
|
1603
|
+
elif "ok" in value:
|
|
1604
|
+
statuses[name] = value.get("ok")
|
|
1605
|
+
return statuses
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
def _scorecard_string_list(value: object) -> list[str]:
|
|
1609
|
+
if not isinstance(value, Sequence) or isinstance(value, str | bytes | bytearray):
|
|
1610
|
+
return []
|
|
1611
|
+
return [item for item in value if isinstance(item, str)]
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
def _scorecard_public_benchmark_evidence_summary(
|
|
1615
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1616
|
+
*,
|
|
1617
|
+
full_provider: dict[str, object] | None = None,
|
|
1618
|
+
require_top_evidence: bool = False,
|
|
1619
|
+
) -> dict[str, object]:
|
|
1620
|
+
reports = _scorecard_public_benchmark_reports(suite_results)
|
|
1621
|
+
if full_provider is not None:
|
|
1622
|
+
nested = full_provider.get("public_benchmark")
|
|
1623
|
+
if isinstance(nested, dict):
|
|
1624
|
+
reports.append(nested)
|
|
1625
|
+
benchmarks: dict[str, dict[str, object]] = {}
|
|
1626
|
+
for report in reports:
|
|
1627
|
+
_scorecard_collect_public_benchmarks(report, benchmarks)
|
|
1628
|
+
missing = [name for name in _PUBLIC_MEMORY_BENCHMARK_REQUIRED if name not in benchmarks]
|
|
1629
|
+
ok = (
|
|
1630
|
+
bool(reports)
|
|
1631
|
+
and not missing
|
|
1632
|
+
and all(benchmarks[name]["ok"] is True for name in _PUBLIC_MEMORY_BENCHMARK_REQUIRED)
|
|
1633
|
+
)
|
|
1634
|
+
competitive_floor = _scorecard_public_benchmark_competitive_floor(benchmarks)
|
|
1635
|
+
quality_ok = ok and competitive_floor["ok"] is True
|
|
1636
|
+
provenance_reports = [top_evidence_provenance_summary(report) for report in reports]
|
|
1637
|
+
provenance_ok = bool(provenance_reports) and all(
|
|
1638
|
+
report["ok"] is True for report in provenance_reports
|
|
1639
|
+
)
|
|
1640
|
+
safety_reports = [top_evidence_safety_summary(report) for report in reports]
|
|
1641
|
+
safety_ok = bool(safety_reports) and all(report["ok"] is True for report in safety_reports)
|
|
1642
|
+
safety = _scorecard_combined_safety_summary(safety_reports)
|
|
1643
|
+
dataset_evidence = _scorecard_public_benchmark_dataset_evidence_summary(reports)
|
|
1644
|
+
dataset_evidence_ok = dataset_evidence["ok"] is True
|
|
1645
|
+
ok = quality_ok and (
|
|
1646
|
+
not require_top_evidence or (provenance_ok and safety_ok and dataset_evidence_ok)
|
|
1647
|
+
)
|
|
1648
|
+
return {
|
|
1649
|
+
"present": bool(reports),
|
|
1650
|
+
"ok": ok,
|
|
1651
|
+
"quality_ok": quality_ok,
|
|
1652
|
+
"provenance_ok": provenance_ok if require_top_evidence else None,
|
|
1653
|
+
"provenance_reports": provenance_reports,
|
|
1654
|
+
"safety_ok": safety_ok if require_top_evidence else None,
|
|
1655
|
+
"safety": safety,
|
|
1656
|
+
"safety_reports": safety_reports,
|
|
1657
|
+
"dataset_evidence_ok": dataset_evidence_ok if require_top_evidence else None,
|
|
1658
|
+
"dataset_evidence": dataset_evidence,
|
|
1659
|
+
"suite": PUBLIC_MEMORY_BENCHMARK_SUITE,
|
|
1660
|
+
"required_benchmarks": list(_PUBLIC_MEMORY_BENCHMARK_REQUIRED),
|
|
1661
|
+
"missing_benchmarks": missing,
|
|
1662
|
+
"competitive_floor_ok": competitive_floor["ok"],
|
|
1663
|
+
"competitive_floor": competitive_floor,
|
|
1664
|
+
"benchmark_count": len(benchmarks),
|
|
1665
|
+
"benchmarks": benchmarks,
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
|
|
1669
|
+
def _scorecard_public_benchmark_reports(
|
|
1670
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
1671
|
+
) -> list[dict[str, object]]:
|
|
1672
|
+
reports: list[dict[str, object]] = []
|
|
1673
|
+
for suite, result in suite_results.items():
|
|
1674
|
+
if suite in _PUBLIC_MEMORY_BENCHMARK_SUITE_ALIASES:
|
|
1675
|
+
reports.append(result)
|
|
1676
|
+
continue
|
|
1677
|
+
if _scorecard_normalize_public_benchmark_name(suite):
|
|
1678
|
+
reports.append(result)
|
|
1679
|
+
return reports
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
def _scorecard_combined_safety_summary(
|
|
1683
|
+
reports: Sequence[Mapping[str, object]],
|
|
1684
|
+
) -> dict[str, object]:
|
|
1685
|
+
failed_checks = sorted(
|
|
1686
|
+
{
|
|
1687
|
+
check
|
|
1688
|
+
for report in reports
|
|
1689
|
+
for check in report.get("failed_checks", ())
|
|
1690
|
+
if isinstance(check, str)
|
|
1691
|
+
}
|
|
1692
|
+
)
|
|
1693
|
+
checks = {
|
|
1694
|
+
check: bool(reports) and check not in failed_checks for check in TOP_EVIDENCE_SAFETY_CHECKS
|
|
1695
|
+
}
|
|
1696
|
+
return {
|
|
1697
|
+
"ok": bool(reports) and not failed_checks,
|
|
1698
|
+
"checks": checks,
|
|
1699
|
+
"failed_checks": failed_checks,
|
|
1700
|
+
"sensitive_path_count": sum(
|
|
1701
|
+
int(report.get("sensitive_path_count", 0)) for report in reports
|
|
1702
|
+
),
|
|
1703
|
+
"sensitive_paths": [
|
|
1704
|
+
path
|
|
1705
|
+
for report in reports
|
|
1706
|
+
for path in report.get("sensitive_paths", ())
|
|
1707
|
+
if isinstance(path, str)
|
|
1708
|
+
][:10],
|
|
1709
|
+
"local_path_count": sum(int(report.get("local_path_count", 0)) for report in reports),
|
|
1710
|
+
"local_paths": [
|
|
1711
|
+
path
|
|
1712
|
+
for report in reports
|
|
1713
|
+
for path in report.get("local_paths", ())
|
|
1714
|
+
if isinstance(path, str)
|
|
1715
|
+
][:10],
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
|
|
1719
|
+
def _scorecard_public_benchmark_dataset_evidence_summary(
|
|
1720
|
+
reports: Sequence[Mapping[str, object]],
|
|
1721
|
+
) -> dict[str, object]:
|
|
1722
|
+
report_summaries: list[dict[str, object]] = []
|
|
1723
|
+
missing_reports: list[str] = []
|
|
1724
|
+
for index, report in enumerate(reports):
|
|
1725
|
+
report_label = str(report.get("suite") or f"report_{index}")
|
|
1726
|
+
benchmark_names = _scorecard_public_benchmark_names_in_report(report)
|
|
1727
|
+
report_failures = _scorecard_public_benchmark_report_failures(report)
|
|
1728
|
+
missing_fingerprints = [
|
|
1729
|
+
name
|
|
1730
|
+
for name in benchmark_names
|
|
1731
|
+
if not _scorecard_public_benchmark_has_dataset_fingerprint(report, name)
|
|
1732
|
+
]
|
|
1733
|
+
source_failures = {
|
|
1734
|
+
name: _scorecard_public_benchmark_dataset_source_failures(report, name)
|
|
1735
|
+
for name in benchmark_names
|
|
1736
|
+
}
|
|
1737
|
+
missing_sources = [name for name, failures in source_failures.items() if failures]
|
|
1738
|
+
ok = (
|
|
1739
|
+
bool(benchmark_names)
|
|
1740
|
+
and not report_failures
|
|
1741
|
+
and not missing_fingerprints
|
|
1742
|
+
and not missing_sources
|
|
1743
|
+
)
|
|
1744
|
+
if not ok:
|
|
1745
|
+
missing_reports.append(report_label)
|
|
1746
|
+
report_summaries.append(
|
|
1747
|
+
{
|
|
1748
|
+
"report": report_label,
|
|
1749
|
+
"ok": ok,
|
|
1750
|
+
"benchmarks": benchmark_names,
|
|
1751
|
+
"report_failures": list(report_failures),
|
|
1752
|
+
"missing_benchmarks": sorted(set(missing_fingerprints) | set(missing_sources)),
|
|
1753
|
+
"missing_dataset_fingerprints": missing_fingerprints,
|
|
1754
|
+
"missing_dataset_sources": missing_sources,
|
|
1755
|
+
"dataset_source_failures": {
|
|
1756
|
+
name: list(failures) for name, failures in source_failures.items() if failures
|
|
1757
|
+
},
|
|
1758
|
+
"has_dataset_hash": _scorecard_nonempty_string(report.get("dataset_hash")),
|
|
1759
|
+
"has_dataset_hashes": isinstance(report.get("dataset_hashes"), Mapping),
|
|
1760
|
+
"has_dataset_sources": isinstance(report.get("dataset_sources"), Mapping),
|
|
1761
|
+
}
|
|
1762
|
+
)
|
|
1763
|
+
return {
|
|
1764
|
+
"ok": bool(reports) and not missing_reports,
|
|
1765
|
+
"report_count": len(reports),
|
|
1766
|
+
"missing_reports": missing_reports,
|
|
1767
|
+
"reports": report_summaries,
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
def _scorecard_public_benchmark_names_in_report(
|
|
1772
|
+
report: Mapping[str, object],
|
|
1773
|
+
) -> list[str]:
|
|
1774
|
+
names: set[str] = set()
|
|
1775
|
+
raw_items = report.get("benchmarks")
|
|
1776
|
+
if isinstance(raw_items, list | tuple):
|
|
1777
|
+
for item in raw_items:
|
|
1778
|
+
if isinstance(item, Mapping):
|
|
1779
|
+
name = _scorecard_normalize_public_benchmark_name(
|
|
1780
|
+
item.get("name") or item.get("benchmark") or item.get("suite")
|
|
1781
|
+
)
|
|
1782
|
+
if name:
|
|
1783
|
+
names.add(name)
|
|
1784
|
+
name = _scorecard_normalize_public_benchmark_name(
|
|
1785
|
+
report.get("benchmark") or report.get("name") or report.get("suite")
|
|
1786
|
+
)
|
|
1787
|
+
if name:
|
|
1788
|
+
names.add(name)
|
|
1789
|
+
metrics = _scorecard_result_metrics(dict(report))
|
|
1790
|
+
for benchmark in _PUBLIC_MEMORY_BENCHMARK_REQUIRED:
|
|
1791
|
+
if f"{benchmark}_accuracy" in metrics or f"{benchmark}_case_count" in metrics:
|
|
1792
|
+
names.add(benchmark)
|
|
1793
|
+
return sorted(names)
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
def _scorecard_public_benchmark_report_failures(
|
|
1797
|
+
report: Mapping[str, object],
|
|
1798
|
+
) -> tuple[str, ...]:
|
|
1799
|
+
failures: list[str] = []
|
|
1800
|
+
if _scorecard_nonempty_string(report.get("dataset_path")):
|
|
1801
|
+
failures.append("dataset_path_not_redacted")
|
|
1802
|
+
checks = report.get("checks")
|
|
1803
|
+
if isinstance(checks, Mapping) and checks.get("unique_case_ids") is False:
|
|
1804
|
+
failures.append("duplicate_case_ids")
|
|
1805
|
+
metrics = _scorecard_result_metrics(dict(report))
|
|
1806
|
+
duplicate_count = _scorecard_int(metrics.get("duplicate_case_id_count"))
|
|
1807
|
+
if duplicate_count is not None and duplicate_count > 0 and "duplicate_case_ids" not in failures:
|
|
1808
|
+
failures.append("duplicate_case_ids")
|
|
1809
|
+
return tuple(failures)
|
|
1810
|
+
|
|
1811
|
+
|
|
1812
|
+
def _scorecard_public_benchmark_has_dataset_fingerprint(
|
|
1813
|
+
report: Mapping[str, object],
|
|
1814
|
+
benchmark: str,
|
|
1815
|
+
) -> bool:
|
|
1816
|
+
return _scorecard_public_benchmark_dataset_fingerprint(report, benchmark) is not None
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
def _scorecard_public_benchmark_dataset_source_failures(
|
|
1820
|
+
report: Mapping[str, object],
|
|
1821
|
+
benchmark: str,
|
|
1822
|
+
) -> tuple[str, ...]:
|
|
1823
|
+
failures: list[str] = []
|
|
1824
|
+
dataset_sources = report.get("dataset_sources")
|
|
1825
|
+
if not isinstance(dataset_sources, Mapping):
|
|
1826
|
+
return ("dataset_sources_missing",)
|
|
1827
|
+
source = dataset_sources.get(benchmark)
|
|
1828
|
+
if not isinstance(source, Mapping):
|
|
1829
|
+
return ("dataset_source_missing",)
|
|
1830
|
+
source_kind = source.get("source_kind")
|
|
1831
|
+
sha256 = source.get("sha256")
|
|
1832
|
+
size_bytes = source.get("size_bytes")
|
|
1833
|
+
path_label = source.get("path_label")
|
|
1834
|
+
official_url = source.get("official_url")
|
|
1835
|
+
source_case_count = source.get("case_count")
|
|
1836
|
+
expected_sha256 = _scorecard_public_benchmark_dataset_fingerprint(report, benchmark)
|
|
1837
|
+
expected_case_count = _scorecard_public_benchmark_case_count(report, benchmark)
|
|
1838
|
+
if source_kind not in _PUBLIC_MEMORY_BENCHMARK_DATASET_SOURCE_KINDS:
|
|
1839
|
+
failures.append("source_kind_not_allowed")
|
|
1840
|
+
if not _scorecard_nonempty_string(sha256):
|
|
1841
|
+
failures.append("sha256_missing")
|
|
1842
|
+
elif sha256 != expected_sha256:
|
|
1843
|
+
failures.append("sha256_mismatch")
|
|
1844
|
+
if not isinstance(size_bytes, int) or size_bytes <= 0:
|
|
1845
|
+
failures.append("size_bytes_missing")
|
|
1846
|
+
if not isinstance(source_case_count, int) or source_case_count <= 0:
|
|
1847
|
+
failures.append("case_count_missing")
|
|
1848
|
+
elif source_case_count != expected_case_count:
|
|
1849
|
+
failures.append("case_count_mismatch")
|
|
1850
|
+
if not _scorecard_nonempty_string(path_label):
|
|
1851
|
+
failures.append("path_label_missing")
|
|
1852
|
+
if source_kind in _PUBLIC_MEMORY_BENCHMARK_OFFICIAL_SOURCE_KINDS and not (
|
|
1853
|
+
_scorecard_nonempty_string(official_url)
|
|
1854
|
+
):
|
|
1855
|
+
failures.append("official_url_missing")
|
|
1856
|
+
return tuple(failures)
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
def _scorecard_public_benchmark_dataset_fingerprint(
|
|
1860
|
+
report: Mapping[str, object],
|
|
1861
|
+
benchmark: str,
|
|
1862
|
+
) -> str | None:
|
|
1863
|
+
dataset_hash = report.get("dataset_hash")
|
|
1864
|
+
if _scorecard_nonempty_string(dataset_hash):
|
|
1865
|
+
return str(dataset_hash).strip()
|
|
1866
|
+
dataset_hashes = report.get("dataset_hashes")
|
|
1867
|
+
if isinstance(dataset_hashes, Mapping):
|
|
1868
|
+
benchmark_hash = dataset_hashes.get(benchmark)
|
|
1869
|
+
if _scorecard_nonempty_string(benchmark_hash):
|
|
1870
|
+
return str(benchmark_hash).strip()
|
|
1871
|
+
return None
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
def _scorecard_public_benchmark_case_count(
|
|
1875
|
+
report: Mapping[str, object],
|
|
1876
|
+
benchmark: str,
|
|
1877
|
+
) -> int | None:
|
|
1878
|
+
raw_items = report.get("benchmarks")
|
|
1879
|
+
if isinstance(raw_items, list | tuple):
|
|
1880
|
+
for item in raw_items:
|
|
1881
|
+
if not isinstance(item, Mapping):
|
|
1882
|
+
continue
|
|
1883
|
+
name = _scorecard_normalize_public_benchmark_name(
|
|
1884
|
+
item.get("name") or item.get("benchmark") or item.get("suite")
|
|
1885
|
+
)
|
|
1886
|
+
if name == benchmark:
|
|
1887
|
+
return _scorecard_public_benchmark_item_case_count(item)
|
|
1888
|
+
name = _scorecard_normalize_public_benchmark_name(
|
|
1889
|
+
report.get("benchmark") or report.get("name") or report.get("suite")
|
|
1890
|
+
)
|
|
1891
|
+
if name == benchmark:
|
|
1892
|
+
return _scorecard_public_benchmark_item_case_count(report)
|
|
1893
|
+
metrics = _scorecard_result_metrics(dict(report))
|
|
1894
|
+
return _scorecard_int(metrics.get(f"{benchmark}_case_count"))
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
def _scorecard_public_benchmark_item_case_count(
|
|
1898
|
+
item: Mapping[str, object],
|
|
1899
|
+
) -> int | None:
|
|
1900
|
+
metrics = _scorecard_result_metrics(dict(item))
|
|
1901
|
+
return _scorecard_int(metrics.get("case_count", item.get("case_count")))
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
def _scorecard_nonempty_string(value: object) -> bool:
|
|
1905
|
+
return isinstance(value, str) and bool(value.strip())
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
def _scorecard_collect_public_benchmarks(
|
|
1909
|
+
report: dict[str, object],
|
|
1910
|
+
benchmarks: dict[str, dict[str, object]],
|
|
1911
|
+
) -> None:
|
|
1912
|
+
raw_items = report.get("benchmarks", ())
|
|
1913
|
+
if isinstance(raw_items, list | tuple):
|
|
1914
|
+
for item in raw_items:
|
|
1915
|
+
if isinstance(item, dict):
|
|
1916
|
+
name = _scorecard_normalize_public_benchmark_name(
|
|
1917
|
+
item.get("name") or item.get("benchmark") or item.get("suite")
|
|
1918
|
+
)
|
|
1919
|
+
if name:
|
|
1920
|
+
benchmarks[name] = _scorecard_public_benchmark_item_summary(
|
|
1921
|
+
item,
|
|
1922
|
+
parent_ok=report.get("ok") is True,
|
|
1923
|
+
)
|
|
1924
|
+
|
|
1925
|
+
metrics = _scorecard_result_metrics(report)
|
|
1926
|
+
for benchmark in _PUBLIC_MEMORY_BENCHMARK_REQUIRED:
|
|
1927
|
+
if benchmark in benchmarks:
|
|
1928
|
+
continue
|
|
1929
|
+
name = _scorecard_normalize_public_benchmark_name(
|
|
1930
|
+
report.get("benchmark") or report.get("name") or report.get("suite")
|
|
1931
|
+
)
|
|
1932
|
+
if name == benchmark:
|
|
1933
|
+
benchmarks[name] = _scorecard_public_benchmark_item_summary(
|
|
1934
|
+
report,
|
|
1935
|
+
parent_ok=report.get("ok") is True,
|
|
1936
|
+
)
|
|
1937
|
+
elif f"{benchmark}_accuracy" in metrics:
|
|
1938
|
+
benchmarks[benchmark] = {
|
|
1939
|
+
"ok": report.get("ok") is True,
|
|
1940
|
+
"accuracy": metrics.get(f"{benchmark}_accuracy"),
|
|
1941
|
+
"case_count": metrics.get(f"{benchmark}_case_count"),
|
|
1942
|
+
"report_suite": report.get("suite"),
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
def _scorecard_public_benchmark_item_summary(
|
|
1947
|
+
item: dict[str, object],
|
|
1948
|
+
*,
|
|
1949
|
+
parent_ok: bool,
|
|
1950
|
+
) -> dict[str, object]:
|
|
1951
|
+
metrics = _scorecard_result_metrics(item)
|
|
1952
|
+
accuracy = metrics.get("accuracy", item.get("accuracy"))
|
|
1953
|
+
case_count = metrics.get("case_count", item.get("case_count"))
|
|
1954
|
+
item_ok = item.get("ok")
|
|
1955
|
+
summary: dict[str, object] = {
|
|
1956
|
+
"ok": item_ok is True if isinstance(item_ok, bool) else parent_ok,
|
|
1957
|
+
"accuracy": accuracy,
|
|
1958
|
+
"case_count": case_count,
|
|
1959
|
+
"report_suite": item.get("suite"),
|
|
1960
|
+
}
|
|
1961
|
+
for key in (
|
|
1962
|
+
"expected_term_count",
|
|
1963
|
+
"covered_expected_term_count",
|
|
1964
|
+
"evidence_ref_count",
|
|
1965
|
+
"covered_evidence_ref_count",
|
|
1966
|
+
):
|
|
1967
|
+
value = _scorecard_int(metrics.get(key))
|
|
1968
|
+
if value is not None:
|
|
1969
|
+
summary[key] = value
|
|
1970
|
+
for key in ("expected_term_coverage", "evidence_ref_coverage"):
|
|
1971
|
+
value = _scorecard_float(metrics.get(key))
|
|
1972
|
+
if value is not None:
|
|
1973
|
+
summary[key] = value
|
|
1974
|
+
return summary
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
def _scorecard_public_benchmark_competitive_floor(
|
|
1978
|
+
benchmarks: Mapping[str, dict[str, object]],
|
|
1979
|
+
) -> dict[str, object]:
|
|
1980
|
+
checks: dict[str, dict[str, object]] = {}
|
|
1981
|
+
for name, floor in _PUBLIC_MEMORY_BENCHMARK_COMPETITIVE_FLOORS.items():
|
|
1982
|
+
benchmark = benchmarks.get(name)
|
|
1983
|
+
accuracy = _scorecard_float(benchmark.get("accuracy") if benchmark else None)
|
|
1984
|
+
case_count = _scorecard_int(benchmark.get("case_count") if benchmark else None)
|
|
1985
|
+
min_accuracy = float(floor["min_accuracy"])
|
|
1986
|
+
min_case_count = int(floor["min_case_count"])
|
|
1987
|
+
checks[name] = {
|
|
1988
|
+
"ok": (
|
|
1989
|
+
benchmark is not None
|
|
1990
|
+
and benchmark.get("ok") is True
|
|
1991
|
+
and accuracy is not None
|
|
1992
|
+
and accuracy >= min_accuracy
|
|
1993
|
+
and case_count is not None
|
|
1994
|
+
and case_count >= min_case_count
|
|
1995
|
+
),
|
|
1996
|
+
"accuracy": accuracy,
|
|
1997
|
+
"min_accuracy": min_accuracy,
|
|
1998
|
+
"case_count": case_count,
|
|
1999
|
+
"min_case_count": min_case_count,
|
|
2000
|
+
}
|
|
2001
|
+
failed = sorted(name for name, check in checks.items() if check["ok"] is not True)
|
|
2002
|
+
return {
|
|
2003
|
+
"ok": not failed,
|
|
2004
|
+
"failed_benchmarks": failed,
|
|
2005
|
+
"benchmarks": checks,
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
|
|
2009
|
+
def _scorecard_normalize_public_benchmark_name(value: object) -> str | None:
|
|
2010
|
+
if not isinstance(value, str):
|
|
2011
|
+
return None
|
|
2012
|
+
normalized = value.strip().lower().replace(" ", "-").replace("_", "-")
|
|
2013
|
+
for canonical, aliases in _PUBLIC_MEMORY_BENCHMARK_NAME_ALIASES.items():
|
|
2014
|
+
if normalized == canonical or normalized in {alias.replace("_", "-") for alias in aliases}:
|
|
2015
|
+
return canonical
|
|
2016
|
+
return None
|
|
2017
|
+
|
|
2018
|
+
|
|
2019
|
+
def _scorecard_full_provider_evidence_summary(
|
|
2020
|
+
result: dict[str, object] | None,
|
|
2021
|
+
*,
|
|
2022
|
+
require_top_evidence: bool = False,
|
|
2023
|
+
) -> dict[str, object]:
|
|
2024
|
+
if result is None:
|
|
2025
|
+
return {"present": False, "ok": None}
|
|
2026
|
+
checks = result.get("checks", {})
|
|
2027
|
+
checks_map = checks if isinstance(checks, dict) else {}
|
|
2028
|
+
adapters = result.get("adapters", {})
|
|
2029
|
+
adapters_map = adapters if isinstance(adapters, dict) else {}
|
|
2030
|
+
mcp = result.get("mcp", {})
|
|
2031
|
+
mcp_map = mcp if isinstance(mcp, dict) else {}
|
|
2032
|
+
required_checks = {
|
|
2033
|
+
**{
|
|
2034
|
+
check_key: checks_map.get(check_key) is True
|
|
2035
|
+
for check_key in _FULL_PROVIDER_REQUIRED_CHECK_KEYS
|
|
2036
|
+
},
|
|
2037
|
+
**{
|
|
2038
|
+
f"{adapter_name}_adapter_ok": adapters_map.get(adapter_name) == "ok"
|
|
2039
|
+
for adapter_name in _FULL_PROVIDER_REQUIRED_ADAPTERS
|
|
2040
|
+
},
|
|
2041
|
+
"mcp_lifecycle_included": bool(mcp_map) and mcp_map.get("ok") is True,
|
|
2042
|
+
}
|
|
2043
|
+
check_values = [value is True for value in checks_map.values()]
|
|
2044
|
+
failed_required_checks = sorted(
|
|
2045
|
+
check for check, ok in required_checks.items() if ok is not True
|
|
2046
|
+
)
|
|
2047
|
+
provenance = top_evidence_provenance_summary(result)
|
|
2048
|
+
safety = top_evidence_safety_summary(result)
|
|
2049
|
+
quality_ok = result.get("ok") is True and not failed_required_checks
|
|
2050
|
+
return {
|
|
2051
|
+
"present": True,
|
|
2052
|
+
"suite": result.get("suite", FULL_PROVIDER_CANARY_SUITE),
|
|
2053
|
+
"ok": quality_ok
|
|
2054
|
+
and (not require_top_evidence or (provenance["ok"] is True and safety["ok"] is True)),
|
|
2055
|
+
"quality_ok": quality_ok,
|
|
2056
|
+
"provenance_ok": provenance["ok"] if require_top_evidence else None,
|
|
2057
|
+
"provenance": provenance,
|
|
2058
|
+
"safety_ok": safety["ok"] if require_top_evidence else None,
|
|
2059
|
+
"safety": safety,
|
|
2060
|
+
"required_checks": required_checks,
|
|
2061
|
+
"failed_required_checks": failed_required_checks,
|
|
2062
|
+
"checks_ok_count": sum(1 for value in check_values if value),
|
|
2063
|
+
"checks_total": len(check_values),
|
|
2064
|
+
"adapters": {
|
|
2065
|
+
name: adapters_map.get(name)
|
|
2066
|
+
for name in ("qdrant", "graphiti", "embeddings", "cognee")
|
|
2067
|
+
if name in adapters_map
|
|
2068
|
+
},
|
|
2069
|
+
"mcp_included": mcp_map.get("skipped") is not True if mcp_map else None,
|
|
2070
|
+
"prod_load_included": isinstance(result.get("prod_load"), dict),
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
def _scorecard_multimodal_live_provider_evidence_summary(
|
|
2075
|
+
result: dict[str, object] | None,
|
|
2076
|
+
*,
|
|
2077
|
+
require_top_evidence: bool = False,
|
|
2078
|
+
) -> dict[str, object]:
|
|
2079
|
+
if result is None:
|
|
2080
|
+
return {"present": False, "ok": None}
|
|
2081
|
+
proof_matrix = result.get("proof_matrix")
|
|
2082
|
+
proof_matrix_map = proof_matrix if isinstance(proof_matrix, Mapping) else {}
|
|
2083
|
+
requirements = proof_matrix_map.get("requirements")
|
|
2084
|
+
requirements_map = requirements if isinstance(requirements, Mapping) else {}
|
|
2085
|
+
summary = proof_matrix_map.get("summary")
|
|
2086
|
+
summary_map = summary if isinstance(summary, Mapping) else {}
|
|
2087
|
+
contract_passed = _scorecard_int(summary_map.get("contract_requirements_passed"))
|
|
2088
|
+
contract_total = _scorecard_int(summary_map.get("contract_requirements_total"))
|
|
2089
|
+
live_passed = _scorecard_int(summary_map.get("live_requirements_passed"))
|
|
2090
|
+
live_total = _scorecard_int(summary_map.get("live_requirements_total"))
|
|
2091
|
+
required_checks: dict[str, bool] = {
|
|
2092
|
+
"result_ok": result.get("ok") is True,
|
|
2093
|
+
"proof_matrix_present": bool(requirements_map),
|
|
2094
|
+
"provider_key_present": result.get("provider_key_present") is True,
|
|
2095
|
+
"contract_requirements_passed": (
|
|
2096
|
+
contract_total is not None
|
|
2097
|
+
and contract_total > 0
|
|
2098
|
+
and contract_passed == contract_total
|
|
2099
|
+
),
|
|
2100
|
+
"live_requirements_passed": (
|
|
2101
|
+
live_total is not None and live_total > 0 and live_passed == live_total
|
|
2102
|
+
),
|
|
2103
|
+
}
|
|
2104
|
+
requirement_reasons: dict[str, str] = {}
|
|
2105
|
+
for name in _MULTIMODAL_LIVE_PROVIDER_REQUIRED_REQUIREMENTS:
|
|
2106
|
+
requirement = requirements_map.get(name)
|
|
2107
|
+
requirement_map = requirement if isinstance(requirement, Mapping) else {}
|
|
2108
|
+
ok = requirement_map.get("ok") is True
|
|
2109
|
+
required_checks[f"{name}_ok"] = ok
|
|
2110
|
+
if not ok:
|
|
2111
|
+
reason = requirement_map.get("reason")
|
|
2112
|
+
status = requirement_map.get("status")
|
|
2113
|
+
if isinstance(reason, str) and reason:
|
|
2114
|
+
requirement_reasons[name] = reason
|
|
2115
|
+
elif isinstance(status, str) and status:
|
|
2116
|
+
requirement_reasons[name] = status
|
|
2117
|
+
else:
|
|
2118
|
+
requirement_reasons[name] = "missing"
|
|
2119
|
+
failed_required_checks = sorted(
|
|
2120
|
+
check for check, ok in required_checks.items() if ok is not True
|
|
2121
|
+
)
|
|
2122
|
+
provenance = top_evidence_provenance_summary(result)
|
|
2123
|
+
safety = top_evidence_safety_summary(result)
|
|
2124
|
+
quality_ok = not failed_required_checks
|
|
2125
|
+
return {
|
|
2126
|
+
"present": True,
|
|
2127
|
+
"suite": result.get("suite", MULTIMODAL_LIVE_PROVIDER_CANARY_SUITE),
|
|
2128
|
+
"ok": quality_ok
|
|
2129
|
+
and (not require_top_evidence or (provenance["ok"] is True and safety["ok"] is True)),
|
|
2130
|
+
"quality_ok": quality_ok,
|
|
2131
|
+
"provider_key_present": result.get("provider_key_present") is True,
|
|
2132
|
+
"provenance_ok": provenance["ok"] if require_top_evidence else None,
|
|
2133
|
+
"provenance": provenance,
|
|
2134
|
+
"safety_ok": safety["ok"] if require_top_evidence else None,
|
|
2135
|
+
"safety": safety,
|
|
2136
|
+
"required_checks": required_checks,
|
|
2137
|
+
"failed_required_checks": failed_required_checks,
|
|
2138
|
+
"requirement_reasons": requirement_reasons,
|
|
2139
|
+
"proof_matrix_summary": {
|
|
2140
|
+
"contract_requirements_passed": contract_passed,
|
|
2141
|
+
"contract_requirements_total": contract_total,
|
|
2142
|
+
"live_requirements_passed": live_passed,
|
|
2143
|
+
"live_requirements_total": live_total,
|
|
2144
|
+
},
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
def _scorecard_agent_behavior_evidence_summary(
|
|
2149
|
+
result: dict[str, object] | None,
|
|
2150
|
+
*,
|
|
2151
|
+
require_top_evidence: bool = False,
|
|
2152
|
+
) -> dict[str, object]:
|
|
2153
|
+
if result is None:
|
|
2154
|
+
return {"present": False, "ok": None}
|
|
2155
|
+
metrics = _scorecard_result_metrics(result)
|
|
2156
|
+
gates = result.get("gates", {})
|
|
2157
|
+
gates_map = gates if isinstance(gates, dict) else {}
|
|
2158
|
+
gate_values = [value is True for value in gates_map.values()]
|
|
2159
|
+
metric_keys = (
|
|
2160
|
+
"tool_choice_accuracy",
|
|
2161
|
+
"search_before_write_rate",
|
|
2162
|
+
"update_vs_duplicate_rate",
|
|
2163
|
+
"document_routing_accuracy",
|
|
2164
|
+
"answer_support_rate",
|
|
2165
|
+
"scenario_count",
|
|
2166
|
+
"live_session_case_count",
|
|
2167
|
+
"live_session_pass_rate",
|
|
2168
|
+
"transcript_corpus_case_count",
|
|
2169
|
+
"transcript_corpus_pass_rate",
|
|
2170
|
+
"adversarial_case_count",
|
|
2171
|
+
"adversarial_pass_rate",
|
|
2172
|
+
"unsafe_write_count",
|
|
2173
|
+
"secret_leak_count",
|
|
2174
|
+
"cross_scope_leak_count",
|
|
2175
|
+
"stale_leak_count",
|
|
2176
|
+
"deleted_leak_count",
|
|
2177
|
+
"critical_safety_failures",
|
|
2178
|
+
)
|
|
2179
|
+
required_checks = _scorecard_agent_behavior_required_checks(
|
|
2180
|
+
result=result,
|
|
2181
|
+
metrics=metrics,
|
|
2182
|
+
gates=gates_map,
|
|
2183
|
+
require_top_evidence=require_top_evidence,
|
|
2184
|
+
)
|
|
2185
|
+
failed_required_checks = sorted(
|
|
2186
|
+
check for check, ok in required_checks.items() if ok is not True
|
|
2187
|
+
)
|
|
2188
|
+
provenance = top_evidence_provenance_summary(result)
|
|
2189
|
+
safety = top_evidence_safety_summary(result)
|
|
2190
|
+
quality_ok = result.get("ok") is True and not failed_required_checks
|
|
2191
|
+
return {
|
|
2192
|
+
"present": True,
|
|
2193
|
+
"suite": result.get("suite", AGENT_BEHAVIOR_BENCH_SUITE),
|
|
2194
|
+
"ok": quality_ok
|
|
2195
|
+
and (not require_top_evidence or (provenance["ok"] is True and safety["ok"] is True)),
|
|
2196
|
+
"quality_ok": quality_ok,
|
|
2197
|
+
"provenance_ok": provenance["ok"] if require_top_evidence else None,
|
|
2198
|
+
"provenance": provenance,
|
|
2199
|
+
"safety_ok": safety["ok"] if require_top_evidence else None,
|
|
2200
|
+
"safety": safety,
|
|
2201
|
+
"scenario_set": result.get("scenario_set"),
|
|
2202
|
+
"model": result.get("model"),
|
|
2203
|
+
"quality_floor_ok": not failed_required_checks,
|
|
2204
|
+
"required_checks": required_checks,
|
|
2205
|
+
"failed_required_checks": failed_required_checks,
|
|
2206
|
+
"gates_ok_count": sum(1 for value in gate_values if value),
|
|
2207
|
+
"gates_total": len(gate_values),
|
|
2208
|
+
"metrics": {key: metrics[key] for key in metric_keys if key in metrics},
|
|
2209
|
+
"scenario_evidence": _scorecard_agent_behavior_scenario_evidence(result),
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
def _scorecard_agent_behavior_required_checks(
|
|
2214
|
+
*,
|
|
2215
|
+
result: dict[str, object],
|
|
2216
|
+
metrics: Mapping[str, object],
|
|
2217
|
+
gates: Mapping[str, object],
|
|
2218
|
+
require_top_evidence: bool,
|
|
2219
|
+
) -> dict[str, bool]:
|
|
2220
|
+
checks = {
|
|
2221
|
+
"scenario_set_realistic_or_better": (
|
|
2222
|
+
result.get("scenario_set") in _AGENT_BEHAVIOR_ACCEPTED_SCENARIO_SETS
|
|
2223
|
+
),
|
|
2224
|
+
"all_reported_gates_pass": bool(gates) and all(value is True for value in gates.values()),
|
|
2225
|
+
}
|
|
2226
|
+
for metric, floor in _AGENT_BEHAVIOR_RATE_FLOORS.items():
|
|
2227
|
+
value = _scorecard_float(metrics.get(metric))
|
|
2228
|
+
checks[f"{metric}_min"] = value is not None and value >= floor
|
|
2229
|
+
for metric in _AGENT_BEHAVIOR_ZERO_COUNT_METRICS:
|
|
2230
|
+
value = _scorecard_int(metrics.get(metric))
|
|
2231
|
+
checks[f"{metric}_zero"] = value == 0
|
|
2232
|
+
if require_top_evidence:
|
|
2233
|
+
checks["scenario_set_all_for_top_evidence"] = (
|
|
2234
|
+
result.get("scenario_set") == AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_SET
|
|
2235
|
+
)
|
|
2236
|
+
for metric, floor in AGENT_BEHAVIOR_TOP_EVIDENCE_CASE_COUNT_FLOORS.items():
|
|
2237
|
+
value = _scorecard_int(metrics.get(metric))
|
|
2238
|
+
checks[f"{metric}_min_{floor}"] = value is not None and value >= floor
|
|
2239
|
+
scenario_evidence = _scorecard_agent_behavior_scenario_evidence(result)
|
|
2240
|
+
scenario_count = _scorecard_int(scenario_evidence.get("scenario_count"))
|
|
2241
|
+
metric_scenario_count = _scorecard_int(metrics.get("scenario_count"))
|
|
2242
|
+
checks["scenario_reports_present"] = scenario_evidence["present"] is True
|
|
2243
|
+
checks["scenario_reports_well_formed"] = scenario_evidence.get("invalid_entry_count") == 0
|
|
2244
|
+
checks["scenario_report_ids_present"] = scenario_evidence.get("missing_id_count") == 0
|
|
2245
|
+
checks["scenario_report_ids_unique"] = scenario_evidence.get("duplicate_id_count") == 0
|
|
2246
|
+
checks["scenario_reports_all_passed"] = scenario_evidence.get("non_passed_count") == 0
|
|
2247
|
+
checks["canonical_scenario_ids_present"] = (
|
|
2248
|
+
scenario_evidence.get("missing_canonical_id_count") == 0
|
|
2249
|
+
)
|
|
2250
|
+
scenario_count_floor = AGENT_BEHAVIOR_TOP_EVIDENCE_CASE_COUNT_FLOORS["scenario_count"]
|
|
2251
|
+
checks[f"scenario_report_count_min_{scenario_count_floor}"] = (
|
|
2252
|
+
scenario_count is not None and scenario_count >= scenario_count_floor
|
|
2253
|
+
)
|
|
2254
|
+
checks["scenario_report_count_matches_metric"] = (
|
|
2255
|
+
scenario_count is not None
|
|
2256
|
+
and metric_scenario_count is not None
|
|
2257
|
+
and scenario_count == metric_scenario_count
|
|
2258
|
+
)
|
|
2259
|
+
tag_counts = scenario_evidence.get("tag_counts")
|
|
2260
|
+
tag_counts_map = tag_counts if isinstance(tag_counts, Mapping) else {}
|
|
2261
|
+
for metric, tag in AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_TAG_METRICS.items():
|
|
2262
|
+
tag_count = _scorecard_int(tag_counts_map.get(tag))
|
|
2263
|
+
metric_count = _scorecard_int(metrics.get(metric))
|
|
2264
|
+
checks[f"{tag}_scenario_report_count_matches_metric"] = (
|
|
2265
|
+
tag_count is not None and metric_count is not None and tag_count == metric_count
|
|
2266
|
+
)
|
|
2267
|
+
return checks
|
|
2268
|
+
|
|
2269
|
+
|
|
2270
|
+
def _scorecard_agent_behavior_scenario_evidence(
|
|
2271
|
+
result: Mapping[str, object],
|
|
2272
|
+
) -> dict[str, object]:
|
|
2273
|
+
scenarios = result.get("scenarios")
|
|
2274
|
+
if not isinstance(scenarios, list):
|
|
2275
|
+
return {
|
|
2276
|
+
"present": False,
|
|
2277
|
+
"scenario_count": None,
|
|
2278
|
+
"tag_counts": {},
|
|
2279
|
+
"invalid_entry_count": None,
|
|
2280
|
+
"missing_id_count": None,
|
|
2281
|
+
"duplicate_id_count": None,
|
|
2282
|
+
"non_passed_count": None,
|
|
2283
|
+
"missing_canonical_id_count": None,
|
|
2284
|
+
"missing_canonical_ids": [],
|
|
2285
|
+
}
|
|
2286
|
+
tag_counts = {tag: 0 for tag in AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_TAG_METRICS.values()}
|
|
2287
|
+
seen_ids: set[str] = set()
|
|
2288
|
+
invalid_entry_count = 0
|
|
2289
|
+
missing_id_count = 0
|
|
2290
|
+
duplicate_id_count = 0
|
|
2291
|
+
non_passed_count = 0
|
|
2292
|
+
for scenario in scenarios:
|
|
2293
|
+
if not isinstance(scenario, Mapping):
|
|
2294
|
+
invalid_entry_count += 1
|
|
2295
|
+
continue
|
|
2296
|
+
scenario_id = scenario.get("id")
|
|
2297
|
+
if not isinstance(scenario_id, str) or not scenario_id.strip():
|
|
2298
|
+
missing_id_count += 1
|
|
2299
|
+
elif scenario_id in seen_ids:
|
|
2300
|
+
duplicate_id_count += 1
|
|
2301
|
+
else:
|
|
2302
|
+
seen_ids.add(scenario_id)
|
|
2303
|
+
if scenario.get("status") != "passed":
|
|
2304
|
+
non_passed_count += 1
|
|
2305
|
+
tags = scenario.get("tags")
|
|
2306
|
+
if not isinstance(tags, list):
|
|
2307
|
+
continue
|
|
2308
|
+
tag_set = {tag for tag in tags if isinstance(tag, str)}
|
|
2309
|
+
for tag in tag_counts:
|
|
2310
|
+
if tag in tag_set:
|
|
2311
|
+
tag_counts[tag] += 1
|
|
2312
|
+
missing_canonical_ids = sorted(set(AGENT_BEHAVIOR_TOP_EVIDENCE_SCENARIO_IDS) - seen_ids)
|
|
2313
|
+
return {
|
|
2314
|
+
"present": True,
|
|
2315
|
+
"scenario_count": len(scenarios),
|
|
2316
|
+
"tag_counts": tag_counts,
|
|
2317
|
+
"invalid_entry_count": invalid_entry_count,
|
|
2318
|
+
"missing_id_count": missing_id_count,
|
|
2319
|
+
"duplicate_id_count": duplicate_id_count,
|
|
2320
|
+
"non_passed_count": non_passed_count,
|
|
2321
|
+
"missing_canonical_id_count": len(missing_canonical_ids),
|
|
2322
|
+
"missing_canonical_ids": missing_canonical_ids,
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
def _scorecard_capability(name: str, checks: Mapping[str, bool]) -> dict[str, object]:
|
|
2327
|
+
failed = sorted(check for check, ok in checks.items() if not ok)
|
|
2328
|
+
return {
|
|
2329
|
+
"name": name,
|
|
2330
|
+
"ok": not failed,
|
|
2331
|
+
"checks": dict(checks),
|
|
2332
|
+
"failed_checks": failed,
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
def _scorecard_failures(
|
|
2337
|
+
*,
|
|
2338
|
+
missing_suites: tuple[str, ...],
|
|
2339
|
+
suites: Mapping[str, dict[str, object]],
|
|
2340
|
+
capabilities: Mapping[str, dict[str, object]],
|
|
2341
|
+
gates: Mapping[str, bool],
|
|
2342
|
+
) -> list[dict[str, object]]:
|
|
2343
|
+
failures: list[dict[str, object]] = []
|
|
2344
|
+
for suite in missing_suites:
|
|
2345
|
+
failures.append(
|
|
2346
|
+
{
|
|
2347
|
+
"case_id": suite,
|
|
2348
|
+
"category": "suite",
|
|
2349
|
+
"reason": "missing_suite_result",
|
|
2350
|
+
}
|
|
2351
|
+
)
|
|
2352
|
+
for suite, summary in suites.items():
|
|
2353
|
+
if summary["ok"] is not True:
|
|
2354
|
+
failures.append(
|
|
2355
|
+
{
|
|
2356
|
+
"case_id": suite,
|
|
2357
|
+
"category": "suite",
|
|
2358
|
+
"reason": "suite_not_ok",
|
|
2359
|
+
}
|
|
2360
|
+
)
|
|
2361
|
+
for capability_name, capability in capabilities.items():
|
|
2362
|
+
if capability["ok"] is not True:
|
|
2363
|
+
failures.append(
|
|
2364
|
+
{
|
|
2365
|
+
"case_id": capability_name,
|
|
2366
|
+
"category": "capability",
|
|
2367
|
+
"reason": "capability_gate_failed",
|
|
2368
|
+
"failed_checks": capability["failed_checks"],
|
|
2369
|
+
}
|
|
2370
|
+
)
|
|
2371
|
+
for gate, ok in gates.items():
|
|
2372
|
+
if not ok:
|
|
2373
|
+
failures.append(
|
|
2374
|
+
{
|
|
2375
|
+
"case_id": gate,
|
|
2376
|
+
"category": "scorecard_gate",
|
|
2377
|
+
"reason": "scorecard_gate_failed",
|
|
2378
|
+
}
|
|
2379
|
+
)
|
|
2380
|
+
return failures
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
def _scorecard_metrics(
|
|
2384
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
2385
|
+
) -> dict[str, object]:
|
|
2386
|
+
quality = _scorecard_result_metrics(suite_results.get(QUALITY_GOLDEN_SUITE))
|
|
2387
|
+
semantic = _scorecard_result_metrics(suite_results.get(SEMANTIC_LINKING_GOLDEN_SUITE))
|
|
2388
|
+
multimodal = _scorecard_result_metrics(
|
|
2389
|
+
suite_results.get(MULTIMODAL_OFFLINE_GOLDEN_SUITE)
|
|
2390
|
+
)
|
|
2391
|
+
long = _scorecard_result_metrics(suite_results.get(LONG_MEMORY_GOLDEN_SUITE))
|
|
2392
|
+
auto = _scorecard_result_metrics(suite_results.get(AUTO_MEMORY_GOLDEN_SUITE))
|
|
2393
|
+
graph = _scorecard_result_metrics(suite_results.get(GRAPH_NATIVE_GOLDEN_SUITE))
|
|
2394
|
+
return {
|
|
2395
|
+
"quality_recall_at_5": quality.get("recall_at_5", 0.0),
|
|
2396
|
+
"quality_precision_at_5": quality.get("precision_at_5", 0.0),
|
|
2397
|
+
"quality_document_recall_at_5": quality.get("document_recall_at_5", 0.0),
|
|
2398
|
+
"quality_hybrid_retrieval_rate": quality.get("hybrid_retrieval_rate", 0.0),
|
|
2399
|
+
"quality_citation_support_rate": quality.get("citation_support_rate", 0.0),
|
|
2400
|
+
"quality_source_citation_failure_count": quality.get(
|
|
2401
|
+
"source_citation_failure_count",
|
|
2402
|
+
0,
|
|
2403
|
+
),
|
|
2404
|
+
"quality_item_contract_support_rate": quality.get("item_contract_support_rate", 0.0),
|
|
2405
|
+
"quality_item_contract_failure_count": quality.get("item_contract_failure_count", 0),
|
|
2406
|
+
"quality_answer_support_breakdown_rate": quality.get(
|
|
2407
|
+
"answer_support_breakdown_rate",
|
|
2408
|
+
0.0,
|
|
2409
|
+
),
|
|
2410
|
+
"quality_retrieval_trace_support_rate": quality.get(
|
|
2411
|
+
"retrieval_trace_support_rate",
|
|
2412
|
+
0.0,
|
|
2413
|
+
),
|
|
2414
|
+
"quality_retrieval_trace_location_contract_rate": quality.get(
|
|
2415
|
+
"retrieval_trace_location_contract_rate",
|
|
2416
|
+
0.0,
|
|
2417
|
+
),
|
|
2418
|
+
"quality_retrieval_answerability_contract_rate": quality.get(
|
|
2419
|
+
"retrieval_answerability_contract_rate",
|
|
2420
|
+
0.0,
|
|
2421
|
+
),
|
|
2422
|
+
"quality_no_candidate_abstention_rate": quality.get(
|
|
2423
|
+
"no_candidate_abstention_rate",
|
|
2424
|
+
0.0,
|
|
2425
|
+
),
|
|
2426
|
+
"quality_no_candidate_leak_count": quality.get("no_candidate_leak_count", 0),
|
|
2427
|
+
"quality_precise_citation_contract_rate": quality.get(
|
|
2428
|
+
"precise_citation_contract_rate",
|
|
2429
|
+
0.0,
|
|
2430
|
+
),
|
|
2431
|
+
"quality_required_case_coverage_rate": quality.get("required_case_coverage_rate", 0.0),
|
|
2432
|
+
"quality_missing_required_case_count": quality.get("missing_required_case_count", 0),
|
|
2433
|
+
"quality_memory_ability_coverage_rate": quality.get(
|
|
2434
|
+
"memory_ability_coverage_rate",
|
|
2435
|
+
0.0,
|
|
2436
|
+
),
|
|
2437
|
+
"quality_memory_abilities_covered": quality.get("memory_abilities_covered", 0),
|
|
2438
|
+
"quality_memory_ability_count": quality.get("memory_ability_count", 0),
|
|
2439
|
+
"quality_multi_memory_scope_recall_at_5": quality.get(
|
|
2440
|
+
"multi_memory_scope_recall_at_5",
|
|
2441
|
+
0.0,
|
|
2442
|
+
),
|
|
2443
|
+
"quality_thread_recall_at_5": quality.get("thread_recall_at_5", 0.0),
|
|
2444
|
+
"quality_stale_memory_rate": quality.get("stale_memory_rate", 0.0),
|
|
2445
|
+
"quality_deleted_memory_leak_count": quality.get("deleted_memory_leak_count", 0),
|
|
2446
|
+
"quality_cross_memory_scope_leak_count": quality.get(
|
|
2447
|
+
"cross_memory_scope_leak_count",
|
|
2448
|
+
0,
|
|
2449
|
+
),
|
|
2450
|
+
"quality_cross_thread_leak_count": quality.get("cross_thread_leak_count", 0),
|
|
2451
|
+
"quality_restricted_memory_leak_count": quality.get(
|
|
2452
|
+
"restricted_memory_leak_count",
|
|
2453
|
+
0,
|
|
2454
|
+
),
|
|
2455
|
+
"quality_context_token_overflow_count": quality.get(
|
|
2456
|
+
"context_token_overflow_count",
|
|
2457
|
+
0,
|
|
2458
|
+
),
|
|
2459
|
+
"quality_critical_failure_count": quality.get("critical_failure_count", 0),
|
|
2460
|
+
"quality_harmful_context_rate": quality.get("harmful_context_rate", 0.0),
|
|
2461
|
+
"long_no_candidate_abstention_rate": long.get(
|
|
2462
|
+
"no_candidate_abstention_rate",
|
|
2463
|
+
0.0,
|
|
2464
|
+
),
|
|
2465
|
+
"long_no_candidate_leak_count": long.get("no_candidate_leak_count", 0),
|
|
2466
|
+
"long_multi_session_recall_at_5": long.get("multi_session_recall_at_5", 0.0),
|
|
2467
|
+
"long_temporal_update_accuracy": long.get("temporal_update_accuracy", 0.0),
|
|
2468
|
+
"long_memory_ability_coverage_rate": long.get(
|
|
2469
|
+
"memory_ability_coverage_rate",
|
|
2470
|
+
0.0,
|
|
2471
|
+
),
|
|
2472
|
+
"long_memory_abilities_covered": long.get("memory_abilities_covered", 0),
|
|
2473
|
+
"long_memory_ability_count": long.get("memory_ability_count", 0),
|
|
2474
|
+
"auto_extraction_positive_recall_rate": auto.get(
|
|
2475
|
+
"extraction_positive_recall_rate",
|
|
2476
|
+
0.0,
|
|
2477
|
+
),
|
|
2478
|
+
"auto_extraction_operation_accuracy": auto.get(
|
|
2479
|
+
"extraction_operation_accuracy",
|
|
2480
|
+
0.0,
|
|
2481
|
+
),
|
|
2482
|
+
"auto_extraction_admission_accuracy": auto.get(
|
|
2483
|
+
"extraction_admission_accuracy",
|
|
2484
|
+
0.0,
|
|
2485
|
+
),
|
|
2486
|
+
"auto_duplicate_suggestion_count": auto.get("duplicate_suggestion_count", 0),
|
|
2487
|
+
"auto_replay_duplicate_suggestion_count": auto.get(
|
|
2488
|
+
"replay_duplicate_suggestion_count",
|
|
2489
|
+
0,
|
|
2490
|
+
),
|
|
2491
|
+
"auto_wrong_auto_apply_count": auto.get("wrong_auto_apply_count", 0),
|
|
2492
|
+
"auto_active_fact_before_review_count": auto.get(
|
|
2493
|
+
"active_fact_before_review_count",
|
|
2494
|
+
0,
|
|
2495
|
+
),
|
|
2496
|
+
"auto_target_resolution_violation_count": auto.get(
|
|
2497
|
+
"target_resolution_violation_count",
|
|
2498
|
+
0,
|
|
2499
|
+
),
|
|
2500
|
+
"auto_review_operation_violation_count": auto.get(
|
|
2501
|
+
"review_operation_violation_count",
|
|
2502
|
+
0,
|
|
2503
|
+
),
|
|
2504
|
+
"semantic_linking_ranking_accuracy": semantic.get("ranking_accuracy", 0.0),
|
|
2505
|
+
"semantic_linking_event_linking_accuracy": semantic.get(
|
|
2506
|
+
"event_linking_accuracy",
|
|
2507
|
+
0.0,
|
|
2508
|
+
),
|
|
2509
|
+
"semantic_linking_temporal_intent_recall": semantic.get(
|
|
2510
|
+
"temporal_intent_recall",
|
|
2511
|
+
0.0,
|
|
2512
|
+
),
|
|
2513
|
+
"semantic_linking_document_chunk_linking_accuracy": semantic.get(
|
|
2514
|
+
"document_chunk_linking_accuracy",
|
|
2515
|
+
0.0,
|
|
2516
|
+
),
|
|
2517
|
+
"semantic_linking_anchor_recall_rate": semantic.get("anchor_recall_rate", 0.0),
|
|
2518
|
+
"semantic_linking_anchor_disambiguation_rate": semantic.get(
|
|
2519
|
+
"anchor_disambiguation_rate",
|
|
2520
|
+
0.0,
|
|
2521
|
+
),
|
|
2522
|
+
"semantic_linking_mixed_script_event_anchor_rate": semantic.get(
|
|
2523
|
+
"mixed_script_event_anchor_rate",
|
|
2524
|
+
0.0,
|
|
2525
|
+
),
|
|
2526
|
+
"semantic_linking_anchor_review_evidence_rate": semantic.get(
|
|
2527
|
+
"anchor_review_evidence_rate",
|
|
2528
|
+
0.0,
|
|
2529
|
+
),
|
|
2530
|
+
"semantic_linking_high_impact_relation_policy_safety": semantic.get(
|
|
2531
|
+
"high_impact_relation_policy_safety",
|
|
2532
|
+
0.0,
|
|
2533
|
+
),
|
|
2534
|
+
"semantic_linking_evidence_relation_policy_safety": semantic.get(
|
|
2535
|
+
"evidence_relation_policy_safety",
|
|
2536
|
+
0.0,
|
|
2537
|
+
),
|
|
2538
|
+
"semantic_linking_mentions_relation_policy_safety": semantic.get(
|
|
2539
|
+
"mentions_relation_policy_safety",
|
|
2540
|
+
0.0,
|
|
2541
|
+
),
|
|
2542
|
+
"semantic_linking_review_approval_rate": semantic.get("review_approval_rate", 0.0),
|
|
2543
|
+
"semantic_linking_required_case_coverage_rate": semantic.get(
|
|
2544
|
+
"required_case_coverage_rate",
|
|
2545
|
+
0.0,
|
|
2546
|
+
),
|
|
2547
|
+
"semantic_linking_missing_required_case_count": semantic.get(
|
|
2548
|
+
"missing_required_case_count",
|
|
2549
|
+
0,
|
|
2550
|
+
),
|
|
2551
|
+
"semantic_linking_false_positive_count": semantic.get("false_positive_count", 0),
|
|
2552
|
+
"semantic_linking_cross_scope_leak_count": semantic.get("cross_scope_leak_count", 0),
|
|
2553
|
+
"multimodal_offline_pass_rate": multimodal.get("pass_rate", 0.0),
|
|
2554
|
+
"multimodal_offline_false_positive_count": multimodal.get(
|
|
2555
|
+
"false_positive_count",
|
|
2556
|
+
0,
|
|
2557
|
+
),
|
|
2558
|
+
"multimodal_offline_prompt_injection_guard_rate": multimodal.get(
|
|
2559
|
+
"prompt_injection_guard_rate",
|
|
2560
|
+
0.0,
|
|
2561
|
+
),
|
|
2562
|
+
"multimodal_offline_retrieval_evidence_location_coverage_rate": multimodal.get(
|
|
2563
|
+
"retrieval_evidence_location_coverage_rate",
|
|
2564
|
+
0.0,
|
|
2565
|
+
),
|
|
2566
|
+
"multimodal_offline_retrieval_evidence_location_gap_count": multimodal.get(
|
|
2567
|
+
"retrieval_evidence_location_gap_count",
|
|
2568
|
+
0,
|
|
2569
|
+
),
|
|
2570
|
+
"graph_recall_rate": graph.get("graph_recall_rate", 0.0),
|
|
2571
|
+
"graph_hydration_rate": graph.get("graph_hydration_rate", 0.0),
|
|
2572
|
+
"safety_leak_count": _scorecard_safety_leak_count(suite_results),
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
|
|
2576
|
+
def _scorecard_safety_leak_count(
|
|
2577
|
+
suite_results: Mapping[str, dict[str, object]],
|
|
2578
|
+
) -> int:
|
|
2579
|
+
total = 0
|
|
2580
|
+
for suite in (
|
|
2581
|
+
SMALL_GOLDEN_SUITE,
|
|
2582
|
+
QUALITY_GOLDEN_SUITE,
|
|
2583
|
+
LONG_MEMORY_GOLDEN_SUITE,
|
|
2584
|
+
AUTO_MEMORY_GOLDEN_SUITE,
|
|
2585
|
+
GRAPH_NATIVE_GOLDEN_SUITE,
|
|
2586
|
+
):
|
|
2587
|
+
metrics = _scorecard_result_metrics(suite_results.get(suite))
|
|
2588
|
+
for key in (
|
|
2589
|
+
"deleted_memory_leak_count",
|
|
2590
|
+
"cross_memory_scope_leak_count",
|
|
2591
|
+
"cross_thread_leak_count",
|
|
2592
|
+
"restricted_memory_leak_count",
|
|
2593
|
+
"prompt_injection_promoted_count",
|
|
2594
|
+
"secret_leakage_count",
|
|
2595
|
+
"graph_safety_leak_count",
|
|
2596
|
+
):
|
|
2597
|
+
total += int(metrics.get(key, 0))
|
|
2598
|
+
return total
|
|
2599
|
+
|
|
2600
|
+
|
|
2601
|
+
def _scorecard_result_metrics(result: dict[str, object] | None) -> dict[str, object]:
|
|
2602
|
+
if result is None:
|
|
2603
|
+
return {}
|
|
2604
|
+
metrics = result.get("metrics", {})
|
|
2605
|
+
return metrics if isinstance(metrics, dict) else {}
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
def _scorecard_mapping(value: object) -> Mapping[object, object]:
|
|
2609
|
+
return value if isinstance(value, Mapping) else {}
|
|
2610
|
+
|
|
2611
|
+
|
|
2612
|
+
def _scorecard_float(value: object) -> float | None:
|
|
2613
|
+
if isinstance(value, bool):
|
|
2614
|
+
return None
|
|
2615
|
+
if isinstance(value, int | float):
|
|
2616
|
+
return float(value)
|
|
2617
|
+
return None
|
|
2618
|
+
|
|
2619
|
+
|
|
2620
|
+
def _scorecard_int(value: object) -> int | None:
|
|
2621
|
+
if isinstance(value, bool):
|
|
2622
|
+
return None
|
|
2623
|
+
if isinstance(value, int):
|
|
2624
|
+
return value
|
|
2625
|
+
if isinstance(value, float) and value.is_integer():
|
|
2626
|
+
return int(value)
|
|
2627
|
+
return None
|