agentevolve-optimizer 0.5.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.
- agent_evolve/__init__.py +722 -0
- agent_evolve/agentic.py +2800 -0
- agent_evolve/api.py +767 -0
- agent_evolve/application/__init__.py +1580 -0
- agent_evolve/application/action_allocation.py +744 -0
- agent_evolve/application/action_allocation_frame.py +347 -0
- agent_evolve/application/action_allocation_frame_commit.py +185 -0
- agent_evolve/application/action_allocation_frame_commit_v3.py +184 -0
- agent_evolve/application/action_allocation_frame_v3.py +338 -0
- agent_evolve/application/action_archive_value.py +497 -0
- agent_evolve/application/action_evidence_consistency.py +455 -0
- agent_evolve/application/action_forecast_partitioning.py +1471 -0
- agent_evolve/application/action_metric_projection.py +211 -0
- agent_evolve/application/action_role_value.py +680 -0
- agent_evolve/application/action_score_authorities.py +363 -0
- agent_evolve/application/action_structural_signature.py +116 -0
- agent_evolve/application/action_target_realization.py +402 -0
- agent_evolve/application/agentic_evolution.py +7734 -0
- agent_evolve/application/agentic_portfolio_residual_expert.py +835 -0
- agent_evolve/application/anchor_residual_identification.py +463 -0
- agent_evolve/application/archive_conditioned_action_target.py +208 -0
- agent_evolve/application/artifact_journal.py +246 -0
- agent_evolve/application/artifact_replay.py +347 -0
- agent_evolve/application/budgeted_optimizer.py +1828 -0
- agent_evolve/application/calibrated_campaign.py +485 -0
- agent_evolve/application/calibrated_current_prefix_forecast_opportunity.py +322 -0
- agent_evolve/application/calibrated_positive_gain_opportunity.py +1581 -0
- agent_evolve/application/campaign_capacity_recourse.py +254 -0
- agent_evolve/application/campaign_contextual_outcomes.py +119 -0
- agent_evolve/application/campaign_diagnostic_blocks.py +930 -0
- agent_evolve/application/campaign_evidence_registry.py +262 -0
- agent_evolve/application/campaign_execution.py +2537 -0
- agent_evolve/application/campaign_generation_audit.py +942 -0
- agent_evolve/application/campaign_learning.py +1812 -0
- agent_evolve/application/campaign_learning_runtime.py +1977 -0
- agent_evolve/application/campaign_search_phase.py +227 -0
- agent_evolve/application/campaign_selector_context_extension.py +220 -0
- agent_evolve/application/campaign_variation_envelope.py +649 -0
- agent_evolve/application/campaign_variation_trace.py +451 -0
- agent_evolve/application/candidate_archive_consequence.py +128 -0
- agent_evolve/application/causal_opportunity_portfolio_gate.py +385 -0
- agent_evolve/application/composite_outcome_updater.py +145 -0
- agent_evolve/application/composition_portfolio_selection.py +363 -0
- agent_evolve/application/concurrent_stage.py +144 -0
- agent_evolve/application/contextual_action_allocation.py +181 -0
- agent_evolve/application/contextual_campaign_outcomes.py +267 -0
- agent_evolve/application/contextual_campaign_planning.py +1366 -0
- agent_evolve/application/contextual_delayed_credit.py +651 -0
- agent_evolve/application/contextual_search_controller.py +2374 -0
- agent_evolve/application/current_prefix_forecast_opportunity.py +714 -0
- agent_evolve/application/decision_metric_projection.py +112 -0
- agent_evolve/application/derived_action_semantics.py +129 -0
- agent_evolve/application/detailed_evaluation.py +449 -0
- agent_evolve/application/earned_lineage.py +1011 -0
- agent_evolve/application/effective_choice_audit.py +484 -0
- agent_evolve/application/empirical_consequence_calibration.py +908 -0
- agent_evolve/application/evaluation_accounting.py +325 -0
- agent_evolve/application/evaluation_cache.py +199 -0
- agent_evolve/application/evaluation_escrow.py +547 -0
- agent_evolve/application/evaluation_recourse.py +253 -0
- agent_evolve/application/event_recorder.py +151 -0
- agent_evolve/application/evolution_campaign.py +1840 -0
- agent_evolve/application/executable_hypothesis.py +323 -0
- agent_evolve/application/factorial_branch_pilot.py +772 -0
- agent_evolve/application/finite_acquisition_capacity_recourse.py +672 -0
- agent_evolve/application/finite_acquisition_residual_expert.py +373 -0
- agent_evolve/application/finite_acquisition_variation_envelope.py +802 -0
- agent_evolve/application/finite_action_hypothesis_semantics.py +446 -0
- agent_evolve/application/finite_action_selection.py +188 -0
- agent_evolve/application/finite_action_set.py +306 -0
- agent_evolve/application/finite_action_transition.py +537 -0
- agent_evolve/application/finite_variation_eligibility.py +296 -0
- agent_evolve/application/forecast_geometry_portfolio.py +799 -0
- agent_evolve/application/forecast_opportunity_shadow_calibration.py +316 -0
- agent_evolve/application/front_proximity_admission.py +311 -0
- agent_evolve/application/front_proximity_parent_basis.py +458 -0
- agent_evolve/application/frozen_hurdle_score.py +659 -0
- agent_evolve/application/g3_causal_screen.py +2257 -0
- agent_evolve/application/g3_causal_validation.py +1046 -0
- agent_evolve/application/g3_postseal_curation.py +818 -0
- agent_evolve/application/gated_agentic_generator.py +205 -0
- agent_evolve/application/generation_feedback.py +293 -0
- agent_evolve/application/generative_proposal_journal.py +185 -0
- agent_evolve/application/geometry_conditional_elasticity.py +453 -0
- agent_evolve/application/global_wave_action_allocation.py +1151 -0
- agent_evolve/application/head_mass_conditional_seat.py +268 -0
- agent_evolve/application/identifiable_reflection_evidence.py +1147 -0
- agent_evolve/application/identifiable_reflection_learning.py +395 -0
- agent_evolve/application/identifiable_reflection_request.py +364 -0
- agent_evolve/application/in_memory_residual_archive.py +341 -0
- agent_evolve/application/insight_memory.py +1804 -0
- agent_evolve/application/live_runtime_manifest.py +758 -0
- agent_evolve/application/llm_task_queue.py +769 -0
- agent_evolve/application/matched_finite_action_block.py +409 -0
- agent_evolve/application/materialized_action_broker.py +2328 -0
- agent_evolve/application/materialized_action_constraints.py +83 -0
- agent_evolve/application/materialized_variation.py +211 -0
- agent_evolve/application/multi_option_evolution.py +1536 -0
- agent_evolve/application/outcome_adaptive_action_racing.py +2827 -0
- agent_evolve/application/outcome_adaptive_residual_campaign_runtime.py +580 -0
- agent_evolve/application/outcome_adaptive_residual_portfolio_evolution.py +3671 -0
- agent_evolve/application/outcome_conditioned_portfolio_selection.py +1374 -0
- agent_evolve/application/outcome_relation.py +193 -0
- agent_evolve/application/paired_allocation_comparison.py +241 -0
- agent_evolve/application/paired_block_schedule.py +127 -0
- agent_evolve/application/parent_measurement.py +226 -0
- agent_evolve/application/pareto_archive.py +811 -0
- agent_evolve/application/portfolio_campaign_runtime.py +4739 -0
- agent_evolve/application/portfolio_evolution.py +2950 -0
- agent_evolve/application/portfolio_hypothesis_observations.py +814 -0
- agent_evolve/application/portfolio_memory_attribution.py +581 -0
- agent_evolve/application/portfolio_memory_dose.py +788 -0
- agent_evolve/application/portfolio_memory_matched_control.py +938 -0
- agent_evolve/application/portfolio_memory_transfer.py +297 -0
- agent_evolve/application/portfolio_optimization_memory.py +363 -0
- agent_evolve/application/portfolio_outcome_feedback.py +1613 -0
- agent_evolve/application/portfolio_projection.py +335 -0
- agent_evolve/application/portfolio_recombination.py +2032 -0
- agent_evolve/application/post_evolution_reflection.py +834 -0
- agent_evolve/application/postcommit_rank_authority.py +245 -0
- agent_evolve/application/precommitted_portfolio_racing.py +2762 -0
- agent_evolve/application/prequential_archive_opportunity_calibration.py +1154 -0
- agent_evolve/application/prequential_residual_exploration.py +343 -0
- agent_evolve/application/prequential_score_portfolio.py +954 -0
- agent_evolve/application/projections.py +292 -0
- agent_evolve/application/protected_action_committee.py +1027 -0
- agent_evolve/application/protected_branch_pilot.py +376 -0
- agent_evolve/application/protected_current_prefix_forecast_opportunity.py +552 -0
- agent_evolve/application/provider_replay.py +910 -0
- agent_evolve/application/rank_balanced_causal_pilot.py +1372 -0
- agent_evolve/application/recombination_residual_expert.py +403 -0
- agent_evolve/application/reflection_workflow.py +571 -0
- agent_evolve/application/region_conditional_credit.py +911 -0
- agent_evolve/application/residual_campaign_runtime.py +531 -0
- agent_evolve/application/residual_headroom_campaign_runtime.py +459 -0
- agent_evolve/application/residual_headroom_ledger.py +1544 -0
- agent_evolve/application/residual_learning_transaction.py +396 -0
- agent_evolve/application/residual_portfolio_evolution.py +1228 -0
- agent_evolve/application/residual_reachability.py +749 -0
- agent_evolve/application/residual_stage_credit.py +499 -0
- agent_evolve/application/same_prefix_paired_audit.py +1580 -0
- agent_evolve/application/semantic_coverage_score_portfolio.py +838 -0
- agent_evolve/application/sequential_lineage_allocation.py +1017 -0
- agent_evolve/application/sequential_market_replay.py +1395 -0
- agent_evolve/application/sequential_residual_campaign_runtime.py +305 -0
- agent_evolve/application/sequential_residual_portfolio_evolution.py +940 -0
- agent_evolve/application/single_score_action_allocation.py +299 -0
- agent_evolve/application/source_exposure_allocation.py +906 -0
- agent_evolve/application/staged_memory.py +210 -0
- agent_evolve/application/stratified_cold_start_allocation.py +732 -0
- agent_evolve/application/support_guarded_hurdle_score.py +549 -0
- agent_evolve/application/target_conditioned_action_forecast.py +595 -0
- agent_evolve/application/target_conditioned_campaign.py +566 -0
- agent_evolve/application/treatment_assignment.py +201 -0
- agent_evolve/application/trusted_objective_evidence.py +217 -0
- agent_evolve/application/two_stage_action_evolution.py +1131 -0
- agent_evolve/application/v8lite_allocation_policy.py +1083 -0
- agent_evolve/application/v9_candidate_policy.py +1303 -0
- agent_evolve/bootstrap.py +108 -0
- agent_evolve/campaign_presets.py +517 -0
- agent_evolve/campaign_profiles.py +452 -0
- agent_evolve/campaign_variation_topology.py +288 -0
- agent_evolve/campaign_workload.py +950 -0
- agent_evolve/cli.py +797 -0
- agent_evolve/contract.py +241 -0
- agent_evolve/core/__init__.py +91 -0
- agent_evolve/core/action_semantics.py +411 -0
- agent_evolve/core/authored.py +105 -0
- agent_evolve/core/formatting.py +286 -0
- agent_evolve/core/optimization_semantics.py +324 -0
- agent_evolve/core/problem.py +167 -0
- agent_evolve/core/results.py +323 -0
- agent_evolve/core/stats.py +70 -0
- agent_evolve/core/telemetry.py +100 -0
- agent_evolve/domain/__init__.py +89 -0
- agent_evolve/domain/artifact.py +162 -0
- agent_evolve/domain/durable_text.py +68 -0
- agent_evolve/domain/event.py +1454 -0
- agent_evolve/domain/finite_action_set.py +426 -0
- agent_evolve/domain/finite_variation.py +526 -0
- agent_evolve/domain/generative_emission.py +559 -0
- agent_evolve/domain/ids.py +163 -0
- agent_evolve/domain/inline_text.py +106 -0
- agent_evolve/domain/insight.py +27 -0
- agent_evolve/domain/lineage.py +737 -0
- agent_evolve/domain/llm_task_queue.py +960 -0
- agent_evolve/domain/outcome.py +96 -0
- agent_evolve/domain/patch.py +854 -0
- agent_evolve/domain/typed_json.py +542 -0
- agent_evolve/domain/variation_space.py +158 -0
- agent_evolve/driver.py +1014 -0
- agent_evolve/harness/__init__.py +29 -0
- agent_evolve/harness/base.py +242 -0
- agent_evolve/harness/directives.py +163 -0
- agent_evolve/harness/generative_seal.py +479 -0
- agent_evolve/harness/registry.py +41 -0
- agent_evolve/infrastructure/__init__.py +39 -0
- agent_evolve/infrastructure/artifacts/__init__.py +6 -0
- agent_evolve/infrastructure/artifacts/_verification.py +67 -0
- agent_evolve/infrastructure/artifacts/filesystem.py +343 -0
- agent_evolve/infrastructure/artifacts/in_memory.py +73 -0
- agent_evolve/infrastructure/asyncio_runtime.py +109 -0
- agent_evolve/infrastructure/authored_runtime.py +188 -0
- agent_evolve/infrastructure/authored_worker.py +171 -0
- agent_evolve/infrastructure/clock.py +53 -0
- agent_evolve/infrastructure/events/__init__.py +6 -0
- agent_evolve/infrastructure/events/_validation.py +89 -0
- agent_evolve/infrastructure/events/in_memory.py +56 -0
- agent_evolve/infrastructure/events/jsonl.py +193 -0
- agent_evolve/infrastructure/exception_provenance.py +215 -0
- agent_evolve/infrastructure/ids.py +118 -0
- agent_evolve/infrastructure/lineage_codec.py +1836 -0
- agent_evolve/infrastructure/outcome_adaptive_phase_journal.py +170 -0
- agent_evolve/infrastructure/residual_headroom_journal.py +221 -0
- agent_evolve/infrastructure/resource_lease.py +370 -0
- agent_evolve/infrastructure/sanitization/__init__.py +8 -0
- agent_evolve/infrastructure/sanitization/strict_json.py +484 -0
- agent_evolve/infrastructure/sequential_phase_journal.py +170 -0
- agent_evolve/infrastructure/stream_liveness.py +383 -0
- agent_evolve/infrastructure/subprocess_boundary.py +136 -0
- agent_evolve/integrations/__init__.py +1 -0
- agent_evolve/integrations/botorch/__init__.py +28 -0
- agent_evolve/integrations/botorch/finite_qlognehvi.py +190 -0
- agent_evolve/integrations/botorch/finite_qlognehvi_batch.py +155 -0
- agent_evolve/integrations/botorch/finite_qlognehvi_batch_identity.py +20 -0
- agent_evolve/integrations/botorch/finite_qlognehvi_batch_worker.py +55 -0
- agent_evolve/integrations/botorch/finite_qlognehvi_identity.py +22 -0
- agent_evolve/integrations/botorch/finite_qlognehvi_worker.py +55 -0
- agent_evolve/integrations/botorch/subprocess_qlognehvi.py +261 -0
- agent_evolve/integrations/botorch/subprocess_qlognehvi_batch.py +273 -0
- agent_evolve/integrations/completion.py +242 -0
- agent_evolve/integrations/pydantic_ai/__init__.py +441 -0
- agent_evolve/integrations/pydantic_ai/action_forecast.py +1068 -0
- agent_evolve/integrations/pydantic_ai/agentic_generator.py +2308 -0
- agent_evolve/integrations/pydantic_ai/async_generator.py +1604 -0
- agent_evolve/integrations/pydantic_ai/boundary_codec.py +1526 -0
- agent_evolve/integrations/pydantic_ai/calibrated_portfolio_campaign.py +756 -0
- agent_evolve/integrations/pydantic_ai/calibrated_portfolio_selection.py +7537 -0
- agent_evolve/integrations/pydantic_ai/campaign_acquisition.py +609 -0
- agent_evolve/integrations/pydantic_ai/execution_binding.py +138 -0
- agent_evolve/integrations/pydantic_ai/forecast_geometry_action_committee.py +217 -0
- agent_evolve/integrations/pydantic_ai/harness.py +159 -0
- agent_evolve/integrations/pydantic_ai/heterogeneous_model_execution.py +306 -0
- agent_evolve/integrations/pydantic_ai/hierarchical_residual_adaptive_semantic_view.py +179 -0
- agent_evolve/integrations/pydantic_ai/json_schema_dialect.py +108 -0
- agent_evolve/integrations/pydantic_ai/materialized_hierarchical_residual_expert.py +952 -0
- agent_evolve/integrations/pydantic_ai/materialized_portfolio_judge.py +520 -0
- agent_evolve/integrations/pydantic_ai/model_execution_profile.py +659 -0
- agent_evolve/integrations/pydantic_ai/outbound_request_manifest.py +1170 -0
- agent_evolve/integrations/pydantic_ai/portable_residual_consequence_features.py +575 -0
- agent_evolve/integrations/pydantic_ai/portfolio_selection.py +422 -0
- agent_evolve/integrations/pydantic_ai/progress_aware_openrouter.py +416 -0
- agent_evolve/integrations/pydantic_ai/provider_attempt_join.py +1523 -0
- agent_evolve/integrations/pydantic_ai/provider_free_calibrated_runner.py +607 -0
- agent_evolve/integrations/pydantic_ai/queued_runner.py +2634 -0
- agent_evolve/integrations/pydantic_ai/reconciled_residual_reachability.py +1417 -0
- agent_evolve/integrations/pydantic_ai/residual_forecast_geometry.py +445 -0
- agent_evolve/integrations/pydantic_ai/residual_reachability.py +674 -0
- agent_evolve/integrations/pydantic_ai/residual_semantic_cells.py +239 -0
- agent_evolve/integrations/pydantic_ai/sealed_output_replay.py +1068 -0
- agent_evolve/integrations/pydantic_ai/semantic_coverage_residual_portfolio.py +770 -0
- agent_evolve/integrations/pydantic_ai/semantic_decision_replay.py +383 -0
- agent_evolve/integrations/pydantic_ai/support_adaptive_residual_portfolio.py +135 -0
- agent_evolve/integrations/pydantic_ai/trusted_residual_prompt_context.py +143 -0
- agent_evolve/integrations/pydantic_ai/validated_openrouter_model.py +107 -0
- agent_evolve/integrations/pymoo_adapter.py +242 -0
- agent_evolve/policies/__init__.py +17 -0
- agent_evolve/policies/check.py +469 -0
- agent_evolve/policies/emit_scaffold.py +451 -0
- agent_evolve/policies/feedback/__init__.py +37 -0
- agent_evolve/policies/feedback/held_out_asn.py +1325 -0
- agent_evolve/policies/genetic.py +607 -0
- agent_evolve/policies/llm_backoff.py +183 -0
- agent_evolve/policies/llm_chooser.py +226 -0
- agent_evolve/policies/llm_generator.py +1760 -0
- agent_evolve/policies/llm_init.py +267 -0
- agent_evolve/policies/llm_operator.py +109 -0
- agent_evolve/policies/llm_prior.py +194 -0
- agent_evolve/policies/llm_surrogate.py +334 -0
- agent_evolve/policies/measurement_evidence.py +704 -0
- agent_evolve/policies/memory/__init__.py +223 -0
- agent_evolve/policies/memory/balanced_subset_blocks.py +707 -0
- agent_evolve/policies/memory/compatibility_matching.py +593 -0
- agent_evolve/policies/memory/global_falsification.py +1841 -0
- agent_evolve/policies/memory/prompt_shape.py +503 -0
- agent_evolve/policies/memory/randomized_subset.py +714 -0
- agent_evolve/policies/memory/staged_causal.py +1270 -0
- agent_evolve/policies/memory/treatment_compliance.py +759 -0
- agent_evolve/policies/objective_resolution/__init__.py +17 -0
- agent_evolve/policies/objective_resolution/fixed_grid.py +364 -0
- agent_evolve/policies/operator_portfolio.py +407 -0
- agent_evolve/policies/reguidance.py +1133 -0
- agent_evolve/policies/reward/__init__.py +83 -0
- agent_evolve/policies/reward/affine_candidate_consequence.py +156 -0
- agent_evolve/policies/reward/affine_candidate_consequence_3d.py +159 -0
- agent_evolve/policies/reward/affine_hypervolume.py +490 -0
- agent_evolve/policies/reward/affine_hypervolume_3d.py +567 -0
- agent_evolve/policies/reward/contextual_marginal_utility.py +318 -0
- agent_evolve/policies/reward/frozen_archive.py +360 -0
- agent_evolve/policies/reward/frozen_wave_archive.py +368 -0
- agent_evolve/policies/search_state.py +208 -0
- agent_evolve/policies/selection/__init__.py +345 -0
- agent_evolve/policies/selection/acquisition_certified_slate.py +684 -0
- agent_evolve/policies/selection/affine_frontier_context.py +330 -0
- agent_evolve/policies/selection/affine_frontier_target.py +473 -0
- agent_evolve/policies/selection/archive_elite.py +1346 -0
- agent_evolve/policies/selection/calibrated_portfolio_binding.py +640 -0
- agent_evolve/policies/selection/calibrated_slate.py +1394 -0
- agent_evolve/policies/selection/calibrated_slate_codec.py +579 -0
- agent_evolve/policies/selection/common_candidate_pool.py +685 -0
- agent_evolve/policies/selection/diagnostic_sampling.py +319 -0
- agent_evolve/policies/selection/disjoint_pairs.py +479 -0
- agent_evolve/policies/selection/elite_explorer.py +719 -0
- agent_evolve/policies/selection/finite_action.py +187 -0
- agent_evolve/policies/selection/finite_option_prompt_projection.py +377 -0
- agent_evolve/policies/selection/finite_palette_evidence.py +247 -0
- agent_evolve/policies/selection/forecast_calibration.py +922 -0
- agent_evolve/policies/selection/frontier_probe_slate.py +814 -0
- agent_evolve/policies/selection/frozen_archive_pairs.py +762 -0
- agent_evolve/policies/selection/full_support_slate.py +91 -0
- agent_evolve/policies/selection/meaningful_direction.py +240 -0
- agent_evolve/policies/selection/memory_dose_feasibility.py +259 -0
- agent_evolve/policies/selection/model_anchored_slate.py +826 -0
- agent_evolve/policies/selection/phenotype_recourse.py +979 -0
- agent_evolve/policies/selection/proposal_support.py +368 -0
- agent_evolve/policies/selection/random_portfolio.py +254 -0
- agent_evolve/policies/selection/regret_bounded_slate.py +1084 -0
- agent_evolve/policies/selection/residual_frontier.py +463 -0
- agent_evolve/policies/selection/residual_frontier_target.py +605 -0
- agent_evolve/policies/selection/structural_posterior_slate.py +1571 -0
- agent_evolve/policies/selection/target_conditioned_allocator.py +648 -0
- agent_evolve/policies/selection/target_conditioned_features.py +812 -0
- agent_evolve/policies/selection/target_conditioned_prequential.py +1527 -0
- agent_evolve/policies/selection/task_keyed_palette.py +906 -0
- agent_evolve/policies/semantics.py +147 -0
- agent_evolve/policies/structure.py +362 -0
- agent_evolve/policies/structured_output_budget.py +62 -0
- agent_evolve/policies/surrogate.py +696 -0
- agent_evolve/policies/variation/__init__.py +1 -0
- agent_evolve/policies/variation/compositional_finite_catalog.py +426 -0
- agent_evolve/policies/variation/crossover_inheritance.py +575 -0
- agent_evolve/policies/variation/disjoint_recombination.py +611 -0
- agent_evolve/policies/variation/exact_composition_capacity.py +214 -0
- agent_evolve/policies/variation/exact_parent_crossover.py +950 -0
- agent_evolve/policies/variation/multiscale_restart_catalog.py +372 -0
- agent_evolve/policies/variation/source_union_finite_catalog.py +403 -0
- agent_evolve/policies/variation/typed_patch.py +1981 -0
- agent_evolve/policies/weighted_prior.py +394 -0
- agent_evolve/ports/__init__.py +383 -0
- agent_evolve/ports/action_allocation.py +733 -0
- agent_evolve/ports/action_allocation_frame.py +1153 -0
- agent_evolve/ports/action_allocation_frame_commit.py +294 -0
- agent_evolve/ports/action_allocation_frame_commit_v3.py +432 -0
- agent_evolve/ports/action_allocation_frame_v3.py +995 -0
- agent_evolve/ports/action_forecast.py +1568 -0
- agent_evolve/ports/action_metric_projection.py +165 -0
- agent_evolve/ports/agentic_generator.py +1561 -0
- agent_evolve/ports/archive_context.py +136 -0
- agent_evolve/ports/artifact_sanitizer.py +44 -0
- agent_evolve/ports/artifact_store.py +225 -0
- agent_evolve/ports/clock.py +13 -0
- agent_evolve/ports/contextual_search_allocation.py +827 -0
- agent_evolve/ports/decision_metric_projection.py +258 -0
- agent_evolve/ports/event_store.py +55 -0
- agent_evolve/ports/executable_hypothesis.py +557 -0
- agent_evolve/ports/finite_acquisition.py +377 -0
- agent_evolve/ports/finite_acquisition_batch.py +296 -0
- agent_evolve/ports/finite_acquisition_batch_json.py +164 -0
- agent_evolve/ports/finite_acquisition_json.py +247 -0
- agent_evolve/ports/finite_acquisition_space.py +168 -0
- agent_evolve/ports/finite_action_selection.py +348 -0
- agent_evolve/ports/finite_action_set.py +256 -0
- agent_evolve/ports/frontier_target.py +396 -0
- agent_evolve/ports/generation_failure.py +43 -0
- agent_evolve/ports/hard_feasibility.py +233 -0
- agent_evolve/ports/id_factory.py +34 -0
- agent_evolve/ports/llm_task_queue.py +93 -0
- agent_evolve/ports/objective_resolution.py +419 -0
- agent_evolve/ports/paired_allocation_comparison.py +401 -0
- agent_evolve/ports/paired_block_schedule.py +475 -0
- agent_evolve/ports/parent_measurement.py +336 -0
- agent_evolve/ports/portfolio_memory_dose.py +643 -0
- agent_evolve/ports/portfolio_selection.py +3169 -0
- agent_evolve/ports/postcommit_rank_authority.py +467 -0
- agent_evolve/ports/presented_action_evidence.py +794 -0
- agent_evolve/ports/resource_lease.py +162 -0
- agent_evolve/ports/structured_generator.py +734 -0
- agent_evolve/ports/structured_output_budget.py +120 -0
- agent_evolve/ports/subprocess_boundary.py +138 -0
- agent_evolve/ports/treatment_assignment.py +466 -0
- agent_evolve/ports/variation_catalog.py +76 -0
- agent_evolve/ports/variation_source.py +226 -0
- agent_evolve/proposal_mode.py +157 -0
- agent_evolve/proposers/__init__.py +10 -0
- agent_evolve/proposers/random_proposer.py +188 -0
- agent_evolve/provider_accounting.py +163 -0
- agent_evolve/py.typed +0 -0
- agent_evolve/reference_method.py +1570 -0
- agent_evolve/session/__init__.py +11 -0
- agent_evolve/session/authorship.py +864 -0
- agent_evolve/session/evaluate.py +236 -0
- agent_evolve/session/fidelity.py +237 -0
- agent_evolve/session/genetic_loop.py +742 -0
- agent_evolve/session/loop.py +803 -0
- agent_evolve/session/screening.py +671 -0
- agent_evolve/settings.py +376 -0
- agent_evolve/workload_kit.py +368 -0
- agent_evolve/workload_prompt.py +398 -0
- agentevolve_optimizer-0.5.0.dist-info/METADATA +599 -0
- agentevolve_optimizer-0.5.0.dist-info/RECORD +414 -0
- agentevolve_optimizer-0.5.0.dist-info/WHEEL +5 -0
- agentevolve_optimizer-0.5.0.dist-info/entry_points.txt +2 -0
- agentevolve_optimizer-0.5.0.dist-info/licenses/LICENSE +21 -0
- agentevolve_optimizer-0.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
"""Provider-neutral contracts for prompt-visible evidence consistency.
|
|
2
|
+
|
|
3
|
+
These values describe evidence that a benchmark has already authenticated and
|
|
4
|
+
presented to an action-forecast request. They do not authorize this package to
|
|
5
|
+
open an outcome store, reinterpret a benchmark receipt, or treat a presented
|
|
6
|
+
value as ground truth. The application assessor only joins these immutable
|
|
7
|
+
values to an exact resolved forecast frame.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import hashlib
|
|
13
|
+
import json
|
|
14
|
+
import math
|
|
15
|
+
import re
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
from agent_evolve.domain.patch import require_sha256
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
_TOKEN = re.compile(r"^[a-z][a-z0-9_.-]{0,95}$")
|
|
23
|
+
_OPTION_ID = re.compile(r"^[a-z][a-z0-9_.-]{0,255}$")
|
|
24
|
+
_METRIC_ID = re.compile(r"^[a-z][a-z0-9_.:-]{0,191}$")
|
|
25
|
+
|
|
26
|
+
_CELL_DOMAIN = b"agent-evolve:presented-action-evidence-cell:v1\x00"
|
|
27
|
+
_POLICY_DOMAIN = b"agent-evolve:presented-action-evidence-consistency-policy:v1\x00"
|
|
28
|
+
_SUBSET_POLICY_DOMAIN = (
|
|
29
|
+
b"agent-evolve:presented-action-evidence-subset-policy:v1\x00"
|
|
30
|
+
)
|
|
31
|
+
_SUBSET_DOMAIN = b"agent-evolve:presented-action-evidence-subset:v1\x00"
|
|
32
|
+
_CELL_ASSESSMENT_DOMAIN = (
|
|
33
|
+
b"agent-evolve:presented-action-evidence-cell-assessment:v1\x00"
|
|
34
|
+
)
|
|
35
|
+
_CELL_SET_DOMAIN = b"agent-evolve:presented-action-evidence-cell-set:v1\x00"
|
|
36
|
+
_ASSESSMENT_DOMAIN = (
|
|
37
|
+
b"agent-evolve:presented-action-evidence-consistency-assessment:v1\x00"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
PRESENTED_ACTION_EVIDENCE_CONSISTENCY_SCOPE = (
|
|
41
|
+
"presented_prompt_evidence_consistency_not_outcome_truth_or_calibration"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _canonical_json(value: object) -> bytes:
|
|
46
|
+
return json.dumps(
|
|
47
|
+
value,
|
|
48
|
+
allow_nan=False,
|
|
49
|
+
ensure_ascii=True,
|
|
50
|
+
separators=(",", ":"),
|
|
51
|
+
sort_keys=True,
|
|
52
|
+
).encode("ascii")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _hash(domain: bytes, value: object) -> str:
|
|
56
|
+
return hashlib.sha256(domain + _canonical_json(value)).hexdigest()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _finite_float(value: object, name: str) -> float:
|
|
60
|
+
if type(value) is not float or not math.isfinite(value):
|
|
61
|
+
raise TypeError(f"{name} must be a finite canonical float")
|
|
62
|
+
return value
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _token(value: object, name: str) -> str:
|
|
66
|
+
if type(value) is not str or _TOKEN.fullmatch(value) is None:
|
|
67
|
+
raise ValueError(f"{name} must use the closed token grammar")
|
|
68
|
+
return value
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _option_id(value: object, name: str) -> str:
|
|
72
|
+
if type(value) is not str or _OPTION_ID.fullmatch(value) is None:
|
|
73
|
+
raise ValueError(f"{name} must use the closed option grammar")
|
|
74
|
+
return value
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _metric_id(value: object, name: str) -> str:
|
|
78
|
+
if type(value) is not str or _METRIC_ID.fullmatch(value) is None:
|
|
79
|
+
raise ValueError(f"{name} must use the closed metric grammar")
|
|
80
|
+
return value
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class PresentedActionEvidenceProvenanceKind(str, Enum):
|
|
84
|
+
"""Closed prompt-view provenance that can authenticate one cell."""
|
|
85
|
+
|
|
86
|
+
CARD_SOURCE_RECEIPT = "card_source_receipt"
|
|
87
|
+
CARD_VIEW_RECEIPT = "card_view_receipt"
|
|
88
|
+
REQUEST_CARD_SNAPSHOT = "request_card_snapshot"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class PresentedActionEvidenceConsistencyFrameKind(str, Enum):
|
|
92
|
+
BLOCK = "block"
|
|
93
|
+
SUBSET = "subset"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass(frozen=True, slots=True, eq=False)
|
|
97
|
+
class PresentedActionEvidenceCell:
|
|
98
|
+
"""One benchmark-injected value exactly as represented to the model.
|
|
99
|
+
|
|
100
|
+
``option_identity_sha256`` identifies the current forecast row to which
|
|
101
|
+
the benchmark maps the presented observation. It need not equal the
|
|
102
|
+
historical option identity inside the action-evidence binding. Keeping
|
|
103
|
+
both identities explicit prevents a benchmark mapping from being inferred
|
|
104
|
+
from names, families, or domain-specific conventions.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
option_identity_sha256: str
|
|
108
|
+
metric_id: str
|
|
109
|
+
presented_delta: float
|
|
110
|
+
card_key: str
|
|
111
|
+
action_evidence_binding_identity_sha256: str
|
|
112
|
+
provenance_kind: PresentedActionEvidenceProvenanceKind
|
|
113
|
+
provenance_sha256: str
|
|
114
|
+
|
|
115
|
+
def __post_init__(self) -> None:
|
|
116
|
+
require_sha256(self.option_identity_sha256, "option_identity_sha256")
|
|
117
|
+
_metric_id(self.metric_id, "metric_id")
|
|
118
|
+
_finite_float(self.presented_delta, "presented_delta")
|
|
119
|
+
_token(self.card_key, "card_key")
|
|
120
|
+
require_sha256(
|
|
121
|
+
self.action_evidence_binding_identity_sha256,
|
|
122
|
+
"action_evidence_binding_identity_sha256",
|
|
123
|
+
)
|
|
124
|
+
if type(self.provenance_kind) is not PresentedActionEvidenceProvenanceKind:
|
|
125
|
+
raise TypeError(
|
|
126
|
+
"provenance_kind must be an exact presented-evidence provenance kind"
|
|
127
|
+
)
|
|
128
|
+
require_sha256(self.provenance_sha256, "provenance_sha256")
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def join_key(self) -> tuple[str, ...]:
|
|
132
|
+
self.__post_init__()
|
|
133
|
+
return (
|
|
134
|
+
self.option_identity_sha256,
|
|
135
|
+
self.metric_id,
|
|
136
|
+
self.card_key,
|
|
137
|
+
self.action_evidence_binding_identity_sha256,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def sort_key(self) -> tuple[str, ...]:
|
|
142
|
+
self.__post_init__()
|
|
143
|
+
return (
|
|
144
|
+
*self.join_key,
|
|
145
|
+
self.provenance_kind.value,
|
|
146
|
+
self.provenance_sha256,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def _unsigned_record(self) -> dict[str, object]:
|
|
150
|
+
self.__post_init__()
|
|
151
|
+
return {
|
|
152
|
+
"schema_version": 1,
|
|
153
|
+
"option_identity_sha256": self.option_identity_sha256,
|
|
154
|
+
"metric_id": self.metric_id,
|
|
155
|
+
"presented_delta_hex": self.presented_delta.hex(),
|
|
156
|
+
"card_key": self.card_key,
|
|
157
|
+
"action_evidence_binding_identity_sha256": (
|
|
158
|
+
self.action_evidence_binding_identity_sha256
|
|
159
|
+
),
|
|
160
|
+
"provenance_kind": self.provenance_kind.value,
|
|
161
|
+
"provenance_sha256": self.provenance_sha256,
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@property
|
|
165
|
+
def cell_sha256(self) -> str:
|
|
166
|
+
return _hash(_CELL_DOMAIN, self._unsigned_record())
|
|
167
|
+
|
|
168
|
+
def to_record(self) -> dict[str, object]:
|
|
169
|
+
return {**self._unsigned_record(), "cell_sha256": self.cell_sha256}
|
|
170
|
+
|
|
171
|
+
def __eq__(self, other: object) -> bool:
|
|
172
|
+
return (
|
|
173
|
+
type(self) is PresentedActionEvidenceCell
|
|
174
|
+
and type(other) is PresentedActionEvidenceCell
|
|
175
|
+
and self.cell_sha256 == other.cell_sha256
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
__hash__ = None
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@dataclass(frozen=True, slots=True, eq=False)
|
|
182
|
+
class PresentedActionEvidenceConsistencyPolicyBinding:
|
|
183
|
+
"""Identified descriptive or fail-closed consistency decision policy.
|
|
184
|
+
|
|
185
|
+
Provenance receipts are mandatory for every policy. With all decision
|
|
186
|
+
controls disabled, the assessment is descriptive and ``passes`` is
|
|
187
|
+
``None``. A later experiment can inject an identified policy that enables
|
|
188
|
+
any combination of the three fail-closed, all-cell requirements.
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
policy_id: str
|
|
192
|
+
policy_version: int
|
|
193
|
+
policy_definition_sha256: str
|
|
194
|
+
maximum_normalized_absolute_error: float | None
|
|
195
|
+
require_direction_agreement: bool
|
|
196
|
+
require_interval_coverage: bool
|
|
197
|
+
|
|
198
|
+
def __post_init__(self) -> None:
|
|
199
|
+
_token(self.policy_id, "policy_id")
|
|
200
|
+
if type(self.policy_version) is not int or self.policy_version <= 0:
|
|
201
|
+
raise ValueError("policy_version must be a positive exact integer")
|
|
202
|
+
require_sha256(self.policy_definition_sha256, "policy_definition_sha256")
|
|
203
|
+
if self.maximum_normalized_absolute_error is not None:
|
|
204
|
+
_finite_float(
|
|
205
|
+
self.maximum_normalized_absolute_error,
|
|
206
|
+
"maximum_normalized_absolute_error",
|
|
207
|
+
)
|
|
208
|
+
if self.maximum_normalized_absolute_error < 0.0:
|
|
209
|
+
raise ValueError(
|
|
210
|
+
"maximum_normalized_absolute_error cannot be negative"
|
|
211
|
+
)
|
|
212
|
+
if type(self.require_direction_agreement) is not bool:
|
|
213
|
+
raise TypeError("require_direction_agreement must be an exact boolean")
|
|
214
|
+
if type(self.require_interval_coverage) is not bool:
|
|
215
|
+
raise TypeError("require_interval_coverage must be an exact boolean")
|
|
216
|
+
|
|
217
|
+
@property
|
|
218
|
+
def decision_applied(self) -> bool:
|
|
219
|
+
self.__post_init__()
|
|
220
|
+
return (
|
|
221
|
+
self.maximum_normalized_absolute_error is not None
|
|
222
|
+
or self.require_direction_agreement
|
|
223
|
+
or self.require_interval_coverage
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
def _unsigned_record(self) -> dict[str, object]:
|
|
227
|
+
self.__post_init__()
|
|
228
|
+
return {
|
|
229
|
+
"schema_version": 1,
|
|
230
|
+
"policy_id": self.policy_id,
|
|
231
|
+
"policy_version": self.policy_version,
|
|
232
|
+
"policy_definition_sha256": self.policy_definition_sha256,
|
|
233
|
+
"authenticated_provenance_required": True,
|
|
234
|
+
"maximum_normalized_absolute_error_hex": (
|
|
235
|
+
None
|
|
236
|
+
if self.maximum_normalized_absolute_error is None
|
|
237
|
+
else self.maximum_normalized_absolute_error.hex()
|
|
238
|
+
),
|
|
239
|
+
"require_direction_agreement": self.require_direction_agreement,
|
|
240
|
+
"require_interval_coverage": self.require_interval_coverage,
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@property
|
|
244
|
+
def binding_sha256(self) -> str:
|
|
245
|
+
return _hash(_POLICY_DOMAIN, self._unsigned_record())
|
|
246
|
+
|
|
247
|
+
def to_record(self) -> dict[str, object]:
|
|
248
|
+
return {**self._unsigned_record(), "binding_sha256": self.binding_sha256}
|
|
249
|
+
|
|
250
|
+
def __eq__(self, other: object) -> bool:
|
|
251
|
+
return (
|
|
252
|
+
type(self) is PresentedActionEvidenceConsistencyPolicyBinding
|
|
253
|
+
and type(other) is PresentedActionEvidenceConsistencyPolicyBinding
|
|
254
|
+
and self.binding_sha256 == other.binding_sha256
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
__hash__ = None
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@dataclass(frozen=True, slots=True, eq=False)
|
|
261
|
+
class PresentedActionEvidenceSubsetPolicyBinding:
|
|
262
|
+
"""Identified benchmark-neutral rule selecting rows from one block."""
|
|
263
|
+
|
|
264
|
+
policy_id: str
|
|
265
|
+
policy_version: int
|
|
266
|
+
policy_definition_sha256: str
|
|
267
|
+
|
|
268
|
+
def __post_init__(self) -> None:
|
|
269
|
+
_token(self.policy_id, "policy_id")
|
|
270
|
+
if type(self.policy_version) is not int or self.policy_version <= 0:
|
|
271
|
+
raise ValueError("policy_version must be a positive exact integer")
|
|
272
|
+
require_sha256(self.policy_definition_sha256, "policy_definition_sha256")
|
|
273
|
+
|
|
274
|
+
def _unsigned_record(self) -> dict[str, object]:
|
|
275
|
+
self.__post_init__()
|
|
276
|
+
return {
|
|
277
|
+
"schema_version": 1,
|
|
278
|
+
"policy_id": self.policy_id,
|
|
279
|
+
"policy_version": self.policy_version,
|
|
280
|
+
"policy_definition_sha256": self.policy_definition_sha256,
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@property
|
|
284
|
+
def binding_sha256(self) -> str:
|
|
285
|
+
return _hash(_SUBSET_POLICY_DOMAIN, self._unsigned_record())
|
|
286
|
+
|
|
287
|
+
def to_record(self) -> dict[str, object]:
|
|
288
|
+
return {**self._unsigned_record(), "binding_sha256": self.binding_sha256}
|
|
289
|
+
|
|
290
|
+
def __eq__(self, other: object) -> bool:
|
|
291
|
+
return (
|
|
292
|
+
type(self) is PresentedActionEvidenceSubsetPolicyBinding
|
|
293
|
+
and type(other) is PresentedActionEvidenceSubsetPolicyBinding
|
|
294
|
+
and self.binding_sha256 == other.binding_sha256
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
__hash__ = None
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
@dataclass(frozen=True, slots=True, eq=False)
|
|
301
|
+
class PresentedActionEvidenceSubsetBinding:
|
|
302
|
+
"""Authenticated ordered row subset of one exact forecast block receipt."""
|
|
303
|
+
|
|
304
|
+
subset_policy: PresentedActionEvidenceSubsetPolicyBinding
|
|
305
|
+
request_sha256: str
|
|
306
|
+
layout_sha256: str
|
|
307
|
+
block_request_sha256: str
|
|
308
|
+
block_spec_sha256: str
|
|
309
|
+
forecast_block_receipt_sha256: str
|
|
310
|
+
block_index: int
|
|
311
|
+
included_global_row_indices: tuple[int, ...]
|
|
312
|
+
included_option_identity_sha256s: tuple[str, ...]
|
|
313
|
+
|
|
314
|
+
def __post_init__(self) -> None:
|
|
315
|
+
if type(self.subset_policy) is not PresentedActionEvidenceSubsetPolicyBinding:
|
|
316
|
+
raise TypeError("subset_policy must be an exact subset-policy binding")
|
|
317
|
+
self.subset_policy.__post_init__()
|
|
318
|
+
for name in (
|
|
319
|
+
"request_sha256",
|
|
320
|
+
"layout_sha256",
|
|
321
|
+
"block_request_sha256",
|
|
322
|
+
"block_spec_sha256",
|
|
323
|
+
"forecast_block_receipt_sha256",
|
|
324
|
+
):
|
|
325
|
+
require_sha256(getattr(self, name), name)
|
|
326
|
+
if type(self.block_index) is not int or self.block_index < 0:
|
|
327
|
+
raise ValueError("block_index must be a non-negative exact integer")
|
|
328
|
+
if type(self.included_global_row_indices) is not tuple or not (
|
|
329
|
+
self.included_global_row_indices
|
|
330
|
+
) or any(
|
|
331
|
+
type(value) is not int for value in self.included_global_row_indices
|
|
332
|
+
):
|
|
333
|
+
raise ValueError(
|
|
334
|
+
"included_global_row_indices must be a non-empty exact tuple"
|
|
335
|
+
)
|
|
336
|
+
if self.included_global_row_indices != tuple(
|
|
337
|
+
sorted(set(self.included_global_row_indices))
|
|
338
|
+
):
|
|
339
|
+
raise ValueError("included global rows must be unique and canonical")
|
|
340
|
+
if any(value < 0 for value in self.included_global_row_indices):
|
|
341
|
+
raise ValueError("included global rows cannot be negative")
|
|
342
|
+
if type(self.included_option_identity_sha256s) is not tuple or len(
|
|
343
|
+
self.included_option_identity_sha256s
|
|
344
|
+
) != len(self.included_global_row_indices):
|
|
345
|
+
raise ValueError(
|
|
346
|
+
"included option identities must exactly cover included rows"
|
|
347
|
+
)
|
|
348
|
+
for index, value in enumerate(self.included_option_identity_sha256s):
|
|
349
|
+
require_sha256(value, f"included_option_identity_sha256s[{index}]")
|
|
350
|
+
if len(set(self.included_option_identity_sha256s)) != len(
|
|
351
|
+
self.included_option_identity_sha256s
|
|
352
|
+
):
|
|
353
|
+
raise ValueError("a subset cannot repeat an option identity")
|
|
354
|
+
|
|
355
|
+
def _unsigned_record(self) -> dict[str, object]:
|
|
356
|
+
self.__post_init__()
|
|
357
|
+
return {
|
|
358
|
+
"schema_version": 1,
|
|
359
|
+
"subset_policy": self.subset_policy.to_record(),
|
|
360
|
+
"request_sha256": self.request_sha256,
|
|
361
|
+
"layout_sha256": self.layout_sha256,
|
|
362
|
+
"block_request_sha256": self.block_request_sha256,
|
|
363
|
+
"block_spec_sha256": self.block_spec_sha256,
|
|
364
|
+
"forecast_block_receipt_sha256": (
|
|
365
|
+
self.forecast_block_receipt_sha256
|
|
366
|
+
),
|
|
367
|
+
"block_index": self.block_index,
|
|
368
|
+
"included_global_row_indices": list(
|
|
369
|
+
self.included_global_row_indices
|
|
370
|
+
),
|
|
371
|
+
"included_option_identity_sha256s": list(
|
|
372
|
+
self.included_option_identity_sha256s
|
|
373
|
+
),
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@property
|
|
377
|
+
def binding_sha256(self) -> str:
|
|
378
|
+
return _hash(_SUBSET_DOMAIN, self._unsigned_record())
|
|
379
|
+
|
|
380
|
+
def to_record(self) -> dict[str, object]:
|
|
381
|
+
return {**self._unsigned_record(), "binding_sha256": self.binding_sha256}
|
|
382
|
+
|
|
383
|
+
def __eq__(self, other: object) -> bool:
|
|
384
|
+
return (
|
|
385
|
+
type(self) is PresentedActionEvidenceSubsetBinding
|
|
386
|
+
and type(other) is PresentedActionEvidenceSubsetBinding
|
|
387
|
+
and self.binding_sha256 == other.binding_sha256
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
__hash__ = None
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
@dataclass(frozen=True, slots=True, eq=False)
|
|
394
|
+
class PresentedActionEvidenceCellAssessment:
|
|
395
|
+
"""One exact presented-value/forecast join with complete provenance."""
|
|
396
|
+
|
|
397
|
+
presented_cell_sha256: str
|
|
398
|
+
global_row_index: int
|
|
399
|
+
option_id: str
|
|
400
|
+
option_identity_sha256: str
|
|
401
|
+
metric_id: str
|
|
402
|
+
presented_delta: float
|
|
403
|
+
p10_delta: float
|
|
404
|
+
p50_delta: float
|
|
405
|
+
p90_delta: float
|
|
406
|
+
direction_agreement: bool
|
|
407
|
+
interval_coverage: bool
|
|
408
|
+
normalized_absolute_error: float
|
|
409
|
+
metric_delta_scale: float
|
|
410
|
+
metric_scale_definition_sha256: str
|
|
411
|
+
card_key: str
|
|
412
|
+
card_source_binding_sha256: str
|
|
413
|
+
card_source_receipt_sha256: str
|
|
414
|
+
card_view_receipt_sha256: str | None
|
|
415
|
+
action_evidence_binding_identity_sha256: str
|
|
416
|
+
source_contrast_id: str
|
|
417
|
+
source_option_id: str
|
|
418
|
+
source_family: str
|
|
419
|
+
source_option_identity_sha256: str
|
|
420
|
+
source_contract_identity_sha256: str
|
|
421
|
+
provenance_kind: PresentedActionEvidenceProvenanceKind
|
|
422
|
+
provenance_sha256: str
|
|
423
|
+
forecast_cites_presented_binding: bool
|
|
424
|
+
|
|
425
|
+
def __post_init__(self) -> None:
|
|
426
|
+
for name in (
|
|
427
|
+
"presented_cell_sha256",
|
|
428
|
+
"option_identity_sha256",
|
|
429
|
+
"metric_scale_definition_sha256",
|
|
430
|
+
"card_source_binding_sha256",
|
|
431
|
+
"card_source_receipt_sha256",
|
|
432
|
+
"action_evidence_binding_identity_sha256",
|
|
433
|
+
"source_contrast_id",
|
|
434
|
+
"source_option_identity_sha256",
|
|
435
|
+
"source_contract_identity_sha256",
|
|
436
|
+
"provenance_sha256",
|
|
437
|
+
):
|
|
438
|
+
require_sha256(getattr(self, name), name)
|
|
439
|
+
if self.card_view_receipt_sha256 is not None:
|
|
440
|
+
require_sha256(
|
|
441
|
+
self.card_view_receipt_sha256,
|
|
442
|
+
"card_view_receipt_sha256",
|
|
443
|
+
)
|
|
444
|
+
if type(self.global_row_index) is not int or self.global_row_index < 0:
|
|
445
|
+
raise ValueError("global_row_index must be a non-negative exact integer")
|
|
446
|
+
_option_id(self.option_id, "option_id")
|
|
447
|
+
_metric_id(self.metric_id, "metric_id")
|
|
448
|
+
_token(self.card_key, "card_key")
|
|
449
|
+
_option_id(self.source_option_id, "source_option_id")
|
|
450
|
+
_token(self.source_family, "source_family")
|
|
451
|
+
for name in (
|
|
452
|
+
"presented_delta",
|
|
453
|
+
"p10_delta",
|
|
454
|
+
"p50_delta",
|
|
455
|
+
"p90_delta",
|
|
456
|
+
"normalized_absolute_error",
|
|
457
|
+
"metric_delta_scale",
|
|
458
|
+
):
|
|
459
|
+
_finite_float(getattr(self, name), name)
|
|
460
|
+
if not self.p10_delta <= self.p50_delta <= self.p90_delta:
|
|
461
|
+
raise ValueError("forecast quantiles must satisfy p10 <= p50 <= p90")
|
|
462
|
+
if self.normalized_absolute_error < 0.0:
|
|
463
|
+
raise ValueError("normalized_absolute_error cannot be negative")
|
|
464
|
+
if self.metric_delta_scale <= 0.0:
|
|
465
|
+
raise ValueError("metric_delta_scale must be positive")
|
|
466
|
+
for name in (
|
|
467
|
+
"direction_agreement",
|
|
468
|
+
"interval_coverage",
|
|
469
|
+
"forecast_cites_presented_binding",
|
|
470
|
+
):
|
|
471
|
+
if type(getattr(self, name)) is not bool:
|
|
472
|
+
raise TypeError(f"{name} must be an exact boolean")
|
|
473
|
+
if type(self.provenance_kind) is not PresentedActionEvidenceProvenanceKind:
|
|
474
|
+
raise TypeError(
|
|
475
|
+
"provenance_kind must be an exact presented-evidence provenance kind"
|
|
476
|
+
)
|
|
477
|
+
expected_cell_sha256 = PresentedActionEvidenceCell(
|
|
478
|
+
option_identity_sha256=self.option_identity_sha256,
|
|
479
|
+
metric_id=self.metric_id,
|
|
480
|
+
presented_delta=self.presented_delta,
|
|
481
|
+
card_key=self.card_key,
|
|
482
|
+
action_evidence_binding_identity_sha256=(
|
|
483
|
+
self.action_evidence_binding_identity_sha256
|
|
484
|
+
),
|
|
485
|
+
provenance_kind=self.provenance_kind,
|
|
486
|
+
provenance_sha256=self.provenance_sha256,
|
|
487
|
+
).cell_sha256
|
|
488
|
+
if self.presented_cell_sha256 != expected_cell_sha256:
|
|
489
|
+
raise ValueError(
|
|
490
|
+
"presented_cell_sha256 differs from the assessed cell fields"
|
|
491
|
+
)
|
|
492
|
+
expected_direction = (
|
|
493
|
+
self.p50_delta == self.presented_delta
|
|
494
|
+
if self.p50_delta == 0.0 or self.presented_delta == 0.0
|
|
495
|
+
else (self.p50_delta > 0.0) == (self.presented_delta > 0.0)
|
|
496
|
+
)
|
|
497
|
+
if self.direction_agreement != expected_direction:
|
|
498
|
+
raise ValueError("direction_agreement differs from the exact deltas")
|
|
499
|
+
expected_coverage = (
|
|
500
|
+
self.p10_delta <= self.presented_delta <= self.p90_delta
|
|
501
|
+
)
|
|
502
|
+
if self.interval_coverage != expected_coverage:
|
|
503
|
+
raise ValueError("interval_coverage differs from the exact quantiles")
|
|
504
|
+
expected_error = (
|
|
505
|
+
abs(self.p50_delta - self.presented_delta) / self.metric_delta_scale
|
|
506
|
+
)
|
|
507
|
+
if self.normalized_absolute_error != expected_error:
|
|
508
|
+
raise ValueError(
|
|
509
|
+
"normalized_absolute_error differs from the exact scale join"
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
@property
|
|
513
|
+
def join_key(self) -> tuple[object, ...]:
|
|
514
|
+
self.__post_init__()
|
|
515
|
+
return (
|
|
516
|
+
self.global_row_index,
|
|
517
|
+
self.metric_id,
|
|
518
|
+
self.card_key,
|
|
519
|
+
self.action_evidence_binding_identity_sha256,
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
@property
|
|
523
|
+
def sort_key(self) -> tuple[object, ...]:
|
|
524
|
+
self.__post_init__()
|
|
525
|
+
return (
|
|
526
|
+
*self.join_key,
|
|
527
|
+
self.provenance_kind.value,
|
|
528
|
+
self.provenance_sha256,
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
def _unsigned_record(self) -> dict[str, object]:
|
|
532
|
+
self.__post_init__()
|
|
533
|
+
return {
|
|
534
|
+
"schema_version": 1,
|
|
535
|
+
"presented_cell_sha256": self.presented_cell_sha256,
|
|
536
|
+
"global_row_index": self.global_row_index,
|
|
537
|
+
"option_id": self.option_id,
|
|
538
|
+
"option_identity_sha256": self.option_identity_sha256,
|
|
539
|
+
"metric_id": self.metric_id,
|
|
540
|
+
"presented_delta_hex": self.presented_delta.hex(),
|
|
541
|
+
"forecast_quantiles": {
|
|
542
|
+
"p10_delta_hex": self.p10_delta.hex(),
|
|
543
|
+
"p50_delta_hex": self.p50_delta.hex(),
|
|
544
|
+
"p90_delta_hex": self.p90_delta.hex(),
|
|
545
|
+
},
|
|
546
|
+
"direction_agreement": self.direction_agreement,
|
|
547
|
+
"interval_coverage": self.interval_coverage,
|
|
548
|
+
"normalized_absolute_error_hex": (
|
|
549
|
+
self.normalized_absolute_error.hex()
|
|
550
|
+
),
|
|
551
|
+
"metric_scale": {
|
|
552
|
+
"delta_scale_hex": self.metric_delta_scale.hex(),
|
|
553
|
+
"definition_sha256": self.metric_scale_definition_sha256,
|
|
554
|
+
},
|
|
555
|
+
"provenance": {
|
|
556
|
+
"card_key": self.card_key,
|
|
557
|
+
"card_source_binding_sha256": (
|
|
558
|
+
self.card_source_binding_sha256
|
|
559
|
+
),
|
|
560
|
+
"card_source_receipt_sha256": (
|
|
561
|
+
self.card_source_receipt_sha256
|
|
562
|
+
),
|
|
563
|
+
"card_view_receipt_sha256": self.card_view_receipt_sha256,
|
|
564
|
+
"action_evidence_binding_identity_sha256": (
|
|
565
|
+
self.action_evidence_binding_identity_sha256
|
|
566
|
+
),
|
|
567
|
+
"source_contrast_id": self.source_contrast_id,
|
|
568
|
+
"source_option_id": self.source_option_id,
|
|
569
|
+
"source_family": self.source_family,
|
|
570
|
+
"source_option_identity_sha256": (
|
|
571
|
+
self.source_option_identity_sha256
|
|
572
|
+
),
|
|
573
|
+
"source_contract_identity_sha256": (
|
|
574
|
+
self.source_contract_identity_sha256
|
|
575
|
+
),
|
|
576
|
+
"provenance_kind": self.provenance_kind.value,
|
|
577
|
+
"provenance_sha256": self.provenance_sha256,
|
|
578
|
+
},
|
|
579
|
+
"forecast_cites_presented_binding": (
|
|
580
|
+
self.forecast_cites_presented_binding
|
|
581
|
+
),
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
@property
|
|
585
|
+
def receipt_sha256(self) -> str:
|
|
586
|
+
return _hash(_CELL_ASSESSMENT_DOMAIN, self._unsigned_record())
|
|
587
|
+
|
|
588
|
+
def to_record(self) -> dict[str, object]:
|
|
589
|
+
return {**self._unsigned_record(), "receipt_sha256": self.receipt_sha256}
|
|
590
|
+
|
|
591
|
+
def __eq__(self, other: object) -> bool:
|
|
592
|
+
return (
|
|
593
|
+
type(self) is PresentedActionEvidenceCellAssessment
|
|
594
|
+
and type(other) is PresentedActionEvidenceCellAssessment
|
|
595
|
+
and self.receipt_sha256 == other.receipt_sha256
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
__hash__ = None
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
@dataclass(frozen=True, slots=True, eq=False)
|
|
602
|
+
class PresentedActionEvidenceConsistencyAssessment:
|
|
603
|
+
"""Authenticated descriptive assessment for one exact block or subset."""
|
|
604
|
+
|
|
605
|
+
frame_kind: PresentedActionEvidenceConsistencyFrameKind
|
|
606
|
+
request_sha256: str
|
|
607
|
+
request_card_snapshot_sha256: str
|
|
608
|
+
experimental_view_receipt_sha256: str
|
|
609
|
+
layout_sha256: str
|
|
610
|
+
block_request_sha256: str
|
|
611
|
+
block_spec_sha256: str
|
|
612
|
+
block_index: int
|
|
613
|
+
forecast_block_receipt_sha256: str
|
|
614
|
+
subset_binding: PresentedActionEvidenceSubsetBinding | None
|
|
615
|
+
policy: PresentedActionEvidenceConsistencyPolicyBinding
|
|
616
|
+
cell_assessments: tuple[PresentedActionEvidenceCellAssessment, ...]
|
|
617
|
+
decision_applied: bool
|
|
618
|
+
passes: bool | None
|
|
619
|
+
|
|
620
|
+
def __post_init__(self) -> None:
|
|
621
|
+
if type(self.frame_kind) is not PresentedActionEvidenceConsistencyFrameKind:
|
|
622
|
+
raise TypeError("frame_kind must be an exact consistency-frame kind")
|
|
623
|
+
for name in (
|
|
624
|
+
"request_sha256",
|
|
625
|
+
"request_card_snapshot_sha256",
|
|
626
|
+
"experimental_view_receipt_sha256",
|
|
627
|
+
"layout_sha256",
|
|
628
|
+
"block_request_sha256",
|
|
629
|
+
"block_spec_sha256",
|
|
630
|
+
"forecast_block_receipt_sha256",
|
|
631
|
+
):
|
|
632
|
+
require_sha256(getattr(self, name), name)
|
|
633
|
+
if type(self.block_index) is not int or self.block_index < 0:
|
|
634
|
+
raise ValueError("block_index must be a non-negative exact integer")
|
|
635
|
+
if self.frame_kind is PresentedActionEvidenceConsistencyFrameKind.BLOCK:
|
|
636
|
+
if self.subset_binding is not None:
|
|
637
|
+
raise ValueError("block assessments forbid subset bindings")
|
|
638
|
+
else:
|
|
639
|
+
if type(self.subset_binding) is not PresentedActionEvidenceSubsetBinding:
|
|
640
|
+
raise TypeError("subset assessments require an exact subset binding")
|
|
641
|
+
self.subset_binding.__post_init__()
|
|
642
|
+
if (
|
|
643
|
+
self.subset_binding.request_sha256 != self.request_sha256
|
|
644
|
+
or self.subset_binding.layout_sha256 != self.layout_sha256
|
|
645
|
+
or self.subset_binding.block_request_sha256
|
|
646
|
+
!= self.block_request_sha256
|
|
647
|
+
or self.subset_binding.block_spec_sha256 != self.block_spec_sha256
|
|
648
|
+
or self.subset_binding.block_index != self.block_index
|
|
649
|
+
or self.subset_binding.forecast_block_receipt_sha256
|
|
650
|
+
!= self.forecast_block_receipt_sha256
|
|
651
|
+
):
|
|
652
|
+
raise ValueError("subset binding differs from the assessment frame")
|
|
653
|
+
if type(self.policy) is not PresentedActionEvidenceConsistencyPolicyBinding:
|
|
654
|
+
raise TypeError("policy must be an exact consistency-policy binding")
|
|
655
|
+
self.policy.__post_init__()
|
|
656
|
+
if type(self.cell_assessments) is not tuple or not self.cell_assessments or any(
|
|
657
|
+
type(value) is not PresentedActionEvidenceCellAssessment
|
|
658
|
+
for value in self.cell_assessments
|
|
659
|
+
):
|
|
660
|
+
raise ValueError("cell_assessments must be a non-empty exact tuple")
|
|
661
|
+
for value in self.cell_assessments:
|
|
662
|
+
value.__post_init__()
|
|
663
|
+
keys = tuple(value.sort_key for value in self.cell_assessments)
|
|
664
|
+
if keys != tuple(sorted(set(keys))):
|
|
665
|
+
raise ValueError("cell assessments must be unique and canonical")
|
|
666
|
+
join_keys = tuple(value.join_key for value in self.cell_assessments)
|
|
667
|
+
if len(set(join_keys)) != len(join_keys):
|
|
668
|
+
raise ValueError("cell assessments cannot repeat an evidence join")
|
|
669
|
+
if type(self.decision_applied) is not bool:
|
|
670
|
+
raise TypeError("decision_applied must be an exact boolean")
|
|
671
|
+
if self.decision_applied != self.policy.decision_applied:
|
|
672
|
+
raise ValueError("decision_applied differs from the identified policy")
|
|
673
|
+
if self.decision_applied:
|
|
674
|
+
if type(self.passes) is not bool:
|
|
675
|
+
raise TypeError("an applied policy requires an exact pass decision")
|
|
676
|
+
expected = all(
|
|
677
|
+
(
|
|
678
|
+
self.policy.maximum_normalized_absolute_error is None
|
|
679
|
+
or cell.normalized_absolute_error
|
|
680
|
+
<= self.policy.maximum_normalized_absolute_error
|
|
681
|
+
)
|
|
682
|
+
and (
|
|
683
|
+
not self.policy.require_direction_agreement
|
|
684
|
+
or cell.direction_agreement
|
|
685
|
+
)
|
|
686
|
+
and (
|
|
687
|
+
not self.policy.require_interval_coverage
|
|
688
|
+
or cell.interval_coverage
|
|
689
|
+
)
|
|
690
|
+
for cell in self.cell_assessments
|
|
691
|
+
)
|
|
692
|
+
if self.passes != expected:
|
|
693
|
+
raise ValueError("pass decision differs from the identified policy")
|
|
694
|
+
elif self.passes is not None:
|
|
695
|
+
raise ValueError("a descriptive policy must not publish pass/fail")
|
|
696
|
+
|
|
697
|
+
@property
|
|
698
|
+
def cell_set_sha256(self) -> str:
|
|
699
|
+
self.__post_init__()
|
|
700
|
+
return _hash(
|
|
701
|
+
_CELL_SET_DOMAIN,
|
|
702
|
+
{
|
|
703
|
+
"schema_version": 1,
|
|
704
|
+
"presented_cell_sha256s": [
|
|
705
|
+
value.presented_cell_sha256 for value in self.cell_assessments
|
|
706
|
+
],
|
|
707
|
+
},
|
|
708
|
+
)
|
|
709
|
+
|
|
710
|
+
def _unsigned_record(self) -> dict[str, object]:
|
|
711
|
+
self.__post_init__()
|
|
712
|
+
count = len(self.cell_assessments)
|
|
713
|
+
return {
|
|
714
|
+
"schema_version": 1,
|
|
715
|
+
"scientific_scope": PRESENTED_ACTION_EVIDENCE_CONSISTENCY_SCOPE,
|
|
716
|
+
"frame_kind": self.frame_kind.value,
|
|
717
|
+
"request_sha256": self.request_sha256,
|
|
718
|
+
"request_card_snapshot_sha256": (
|
|
719
|
+
self.request_card_snapshot_sha256
|
|
720
|
+
),
|
|
721
|
+
"experimental_view_receipt_sha256": (
|
|
722
|
+
self.experimental_view_receipt_sha256
|
|
723
|
+
),
|
|
724
|
+
"layout_sha256": self.layout_sha256,
|
|
725
|
+
"block_request_sha256": self.block_request_sha256,
|
|
726
|
+
"block_spec_sha256": self.block_spec_sha256,
|
|
727
|
+
"block_index": self.block_index,
|
|
728
|
+
"forecast_block_receipt_sha256": (
|
|
729
|
+
self.forecast_block_receipt_sha256
|
|
730
|
+
),
|
|
731
|
+
"subset_binding": (
|
|
732
|
+
None
|
|
733
|
+
if self.subset_binding is None
|
|
734
|
+
else self.subset_binding.to_record()
|
|
735
|
+
),
|
|
736
|
+
"policy": self.policy.to_record(),
|
|
737
|
+
"cell_set_sha256": self.cell_set_sha256,
|
|
738
|
+
"cell_assessments": [
|
|
739
|
+
value.to_record() for value in self.cell_assessments
|
|
740
|
+
],
|
|
741
|
+
"summary": {
|
|
742
|
+
"cell_count": count,
|
|
743
|
+
"mean_normalized_absolute_error_hex": (
|
|
744
|
+
sum(
|
|
745
|
+
value.normalized_absolute_error
|
|
746
|
+
for value in self.cell_assessments
|
|
747
|
+
)
|
|
748
|
+
/ count
|
|
749
|
+
).hex(),
|
|
750
|
+
"maximum_normalized_absolute_error_hex": max(
|
|
751
|
+
value.normalized_absolute_error
|
|
752
|
+
for value in self.cell_assessments
|
|
753
|
+
).hex(),
|
|
754
|
+
"direction_agreement_share_hex": (
|
|
755
|
+
sum(value.direction_agreement for value in self.cell_assessments)
|
|
756
|
+
/ count
|
|
757
|
+
).hex(),
|
|
758
|
+
"interval_coverage_share_hex": (
|
|
759
|
+
sum(value.interval_coverage for value in self.cell_assessments)
|
|
760
|
+
/ count
|
|
761
|
+
).hex(),
|
|
762
|
+
},
|
|
763
|
+
"decision_applied": self.decision_applied,
|
|
764
|
+
"passes": self.passes,
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
@property
|
|
768
|
+
def receipt_sha256(self) -> str:
|
|
769
|
+
return _hash(_ASSESSMENT_DOMAIN, self._unsigned_record())
|
|
770
|
+
|
|
771
|
+
def to_record(self) -> dict[str, object]:
|
|
772
|
+
return {**self._unsigned_record(), "receipt_sha256": self.receipt_sha256}
|
|
773
|
+
|
|
774
|
+
def __eq__(self, other: object) -> bool:
|
|
775
|
+
return (
|
|
776
|
+
type(self) is PresentedActionEvidenceConsistencyAssessment
|
|
777
|
+
and type(other) is PresentedActionEvidenceConsistencyAssessment
|
|
778
|
+
and self.receipt_sha256 == other.receipt_sha256
|
|
779
|
+
)
|
|
780
|
+
|
|
781
|
+
__hash__ = None
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
__all__ = [
|
|
785
|
+
"PRESENTED_ACTION_EVIDENCE_CONSISTENCY_SCOPE",
|
|
786
|
+
"PresentedActionEvidenceCell",
|
|
787
|
+
"PresentedActionEvidenceCellAssessment",
|
|
788
|
+
"PresentedActionEvidenceConsistencyAssessment",
|
|
789
|
+
"PresentedActionEvidenceConsistencyFrameKind",
|
|
790
|
+
"PresentedActionEvidenceConsistencyPolicyBinding",
|
|
791
|
+
"PresentedActionEvidenceProvenanceKind",
|
|
792
|
+
"PresentedActionEvidenceSubsetBinding",
|
|
793
|
+
"PresentedActionEvidenceSubsetPolicyBinding",
|
|
794
|
+
]
|