← Back to Pull requests

fix(adoption): close native workflow parity gaps #410

Merged
chubirka merged 85 files (7400 lines) on Nov 10, 2026 20:12 UTC
View on GitHub
chubirka chubirka commented on Nov 09, 2026 21:26 UTC
Author

What

Close the six demonstrated native-workflow parity gaps through existing Core owners:

| Gap | Owner and repair |
|---|---|
| Advisory aliases | Exposure preserves each alias package's ecosystem, ranges, fixes and offline provenance; sweep retains nullable fix availability. |
| CVE replay | Detection quality retains exact original-report bindings and verified human presence; unknown presence never becomes a confirmed miss or benchmark truth. |
| Spend attribution | Spend retains supplied label, size, batch, note and cost; only order-less declarations store canonical repository identity. |
| Repository availability | Portfolio records active/archived/moved/missing/disabled/unknown availability independently from successful commit observations. |
| Claim correction | Findings retain ticketed proposals and authoritative original source bindings, with immutable original occurrences and historical identity aliases. |
| Configuration cap | ConfigMatrix honors nonnegative max_triples, retains judged defaults first and reports omitted coverage. |

Contracts #132 / Shaun's inline review

  • No publication_revision field, historical backfill, or new hand-run schema-upgrade mechanism. Imported producer writes serialize by kind and require advancing database statement time; ties retry within a bounded window and a frozen/backward clock refuses without changing history. SQLite millisecond resolution limits same-kind throughput. Preexisting tied history is not rewritten or assigned invented order.

  • Tracker pairing has one Core write owner used by repository add and update; a finding's repository identity is immutable through Core updates. PostgreSQL finding/ref locks and SQLite write intent serialize admission with the one retained Contracts ref-move guard. No database trigger fan-out is restored. Arbitrary SQL bypassing Core is outside the Core-owned pairing guarantee.

  • Ordered spend stores no independent repository ID. Rollups select the order's repository whenever an order is present, including NULL; declaration identity is used only for order-less events. Mismatched known ordered attribution refuses, and repository-less orders remain unattributed while supplied metadata/cost survives.

  • Configured fresh-schema startup succeeds with the final bootstrap contract and does not require the removed scope-trigger set. Obsolete upgrade/deployment documentation is removed.
  • Exercised verification

    | Completed check | Observed result |
    |---|---:|
    | Full Core unit suite | 12,202 passed; 1 skipped |
    | Full PostgreSQL integration suite | 3,843 passed; 6 skipped |
    | Lint/format | Passed |
    | Isolated production-volume suite | 192 passed; complete-case report |
    | Real SQLite/PostgreSQL runtime scenario | Configured startup; wrong tracker insert/reassignment/finding move refused; ordered/unknown/declaration costs retained; 12 rapid publications ordered on each backend |

    Deterministic regressions cover descending UUIDs with equal timestamps, nonadvancing clock rollback, exact-prior successor checks, and two-connection tracker/ref-move races in both orderings. Existing immutable-evidence and reviewed-claim authorization coverage remains intact.

    Review and adoption order

    Merge traust-security/traust-contracts#132 after independent contracts-owner approval, then this PR, then traust-security/traust#393. #132 includes #131; close #131 as superseded only after replacement merge.

    Schema changes are additive bootstrap only. Existing databases are not upgraded by this batch: that requires the separately designed tracked upgrade feature, not conditional scripts or automatic reconciliation. Human review is still required; no auto-merge or dismissal of requested changes is requested. Product/corpus notes, persisted PQC chokepoints, broad scanner/fleet validation and declared-versus-measured spend reconciliation are unchanged.

    Changed tests (5a27ce56)

    Per the standing test-change policy (test · old → new · why), from the first-pass review round:

    | Test | Old | New | Why |
    |---|---|---|---|
    | test_spend_attribution.py › test_repositoryless_order_ignores_supplied_attribution_but_keeps_metadata | a fleet-wide order's event with an attested repository (id or resolvable URL) recorded with the identity silently dropped | test_fleet_wide_order_spend_refuses_an_attested_repository: both parametrizations now refuse with disagrees; the metadata-survival case moved to test_fleet_wide_order_spend_keeps_unattributed_metadata (unresolvable label) | review note: the attested identity was silently overwritten with None; the schema's run_order_id IS NULL OR repository_id IS NULL forbids preserving it on an ordered row, so it refuses as the repository-scoped mismatch does |

    New tests (not changes): the unchanged-replay no-republish case with a moving clock, the read-the-corpus-once count, and the one-query liveness page.

    Diff: 7400 lines (+6757 / -643) across 85 files Reviewer: smith-xyz Review duration: 1366m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.77) × (1 − Review Confidence (0.72)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.77 · 7400 lines diff across 85 files
    0.77
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.46 · 5 substantive comment(s)
    0.46
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    72%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    25 items
    chubirka chubirka commented on Nov 09, 2026 21:49 UTC
    Author

    Shaun inline review — isolated committed volume acceptance

    192 passed on signed Core 955820eb8700f410b83f2dcb9999e4564d8b4838, with Contracts c22f7c8fb16acede8662331f242dd9d5858746f2. Run in an isolated worktree so unrelated uncommitted changes were not included.

    The generated report is 2,593,791 bytes. The table preserves every query case, statement count, worst execution and corresponding plan key.

    | Case | Statements observed | Worst execution | Plan at worst execution |
    |---|---:|---:|---|
    | test_latest_assessment_uses_ref_kind_index | 1 | 0.011 ms | Index Scan Backward using idx_assessment_ref_kind_occurred on assessment |
    | test_artifact_kind_read_stays_scoped_to_one_assessment[None] | 1 | 0.015 ms | Bitmap Index Scan on idx_artifact_assessment |
    | test_artifact_kind_read_stays_scoped_to_one_assessment[1] | 1 | 0.014 ms | Bitmap Index Scan on idx_artifact_assessment |
    | test_published_artifact_dedupe_uses_the_imported_digest_index | 1 | 0.009 ms | Index Scan using uq_artifact_imported on artifact |
    | test_artifact_id_read_uses_the_primary_key | 1 | 0.007 ms | Index Scan using artifact_pkey on artifact |
    | test_atomic_artifact_retry_reads_the_winner_by_digest | 2 | 0.048 ms | Index Only Scan using idx_artifact_imported_kind on artifact artifact_1 |
    | test_latest_imported_document_of_a_kind_uses_the_kind_index | 1 | 0.007 ms | Index Scan using idx_artifact_imported_kind on artifact |
    | test_imported_history_uses_the_time_ordered_kind_index | 1 | 0.071 ms | Index Scan using idx_artifact_imported_kind on artifact |
    | test_batch_review_evidence_reads_all_companions_by_assessment_index | 1 | 0.015 ms | Bitmap Index Scan on idx_artifact_assessment |
    | test_review_artifact_metadata_batch_uses_the_primary_key | 1 | 0.011 ms | Index Scan using artifact_pkey on artifact |
    | test_latest_imported_document_as_of_uses_the_kind_index | 1 | 0.010 ms | Index Scan using idx_artifact_imported_kind on artifact |
    | test_a_months_window_is_one_bounded_page | 1 | 6.244 ms | Seq Scan on assessment |
    | test_search_by_ref_and_kind_uses_the_covering_index[False] | 1 | 0.011 ms | Index Scan Backward using idx_assessment_ref_kind_occurred on assessment |
    | test_search_by_ref_and_kind_uses_the_covering_index[True] | 1 | 0.008 ms | Index Scan Backward using idx_assessment_ref_kind_occurred on assessment |
    | test_bounded_version_scan_does_not_charge_other_versions | 1 | 7.219 ms | Seq Scan on assessment |
    | test_latest_measurement_at_a_cutoff_uses_the_ref_kind_index | 1 | 0.008 ms | Index Scan Backward using idx_assessment_ref_kind_occurred on assessment |
    | test_validation_recording_and_review_lookups_stay_scoped | 5 | 0.023 ms | Bitmap Index Scan on idx_finding_external_ref_finding |
    | test_one_kind_across_a_repositorys_refs_uses_the_covering_index | 1 | 0.060 ms | Index Scan using idx_assessment_ref_kind_occurred on assessment |
    | test_the_baseline_audit_across_a_repositorys_refs_uses_the_covering_index | 1 | 0.052 ms | Index Scan using idx_assessment_ref_kind_occurred on assessment |
    | test_latest_recorded_returns_one_nonempty_scoped_row_by_index[repo-state] | 2 | 0.064 ms | Bitmap Index Scan on idx_repository_ref_repository |
    | test_latest_recorded_returns_one_nonempty_scoped_row_by_index[repo_state] | 2 | 0.054 ms | Bitmap Index Scan on idx_repository_ref_repository |
    | test_the_feeds_assessments_after_a_cursor_by_index[an hour ago] | 1 | 0.671 ms | Index Scan using idx_assessment_created on assessment |
    | test_the_feeds_assessments_after_a_cursor_by_index[the start] | 1 | 0.192 ms | Index Scan using idx_assessment_created on assessment |
    | test_original_audit_lock_uses_primary_key | 1 | 0.029 ms | Index Scan using assessment_pkey on assessment |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[window] | 26 | 18.570 ms | Parallel Seq Scan on assessment |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[findings] | 26 | 6.766 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[decisions] | 26 | 6.686 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[finding-cwes] | 26 | 5.794 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[cwes] | 26 | 5.434 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[labels] | 29 | 5.443 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[occurrences] | 26 | 6.018 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[assessment-occurrences] | 26 | 5.382 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[locations] | 26 | 5.398 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[refs] | 26 | 6.635 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[repositories-refs] | 26 | 5.470 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[assessments] | 26 | 6.636 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_critical_miss_input_queries_refuse_overflow_at_volume[refs-assessments] | 26 | 6.642 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_keeping_an_advisory_reads_and_writes_by_natural_key[repeat] | 10 | 0.014 ms | Insert on package |
    | test_keeping_an_advisory_reads_and_writes_by_natural_key[new-alias] | 11 | 0.278 ms | Insert on advisory |
    | test_the_blast_radius_walks_dependencies_by_index[typical] | 188 | 3.080 ms | Index Scan using idx_dependency_package on dependency |
    | test_the_blast_radius_walks_dependencies_by_index[hot] | 190 | 3.814 ms | Index Scan using idx_dependency_package on dependency |
    | test_preparing_one_commit_reads_by_index | 208 | 3.084 ms | Index Scan using idx_dependency_package on dependency |
    | test_a_commits_dependencies_read_its_manifest_sbom_by_index | 3 | 0.229 ms | Bitmap Index Scan on package_pkey |
    | test_the_fleet_sweep_reads_every_held_version_in_one_pass | 1 | 557.237 ms | Parallel Index Scan using idx_dependency_package on dependency |
    | test_an_images_packages_read_its_sbom_by_digest | 3 | 0.197 ms | Bitmap Index Scan on package_pkey |
    | test_ingesting_an_image_sbom_again_reads_and_writes_by_natural_key | 3 | 0.007 ms | Insert on image |
    | test_dependency_reach_reads_the_fleet_in_batches | 213 | 11.691 ms | Index Only Scan using dependency_sbom_id_package_id_version_key on dependency |
    | test_findings_judged_a_validity_is_one_statement | 1 | 88.810 ms | Seq Scan on decision |
    | test_confirmed_with_its_historical_spellings_is_one_statement | 1 | 43.881 ms | Seq Scan on decision |
    | test_rule_hits_are_one_statement | 1 | 112.806 ms | Seq Scan on occurrence |
    | test_hot_repository_rollups_keep_query_latency_bounded | 172 | 7.237 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_the_queue_reads_pending_items_by_index_and_candidates_in_one_scan | 152 | 158.067 ms | Seq Scan on decision |
    | test_exact_fingerprint_lookup_is_nonempty_and_index_scoped_at_volume[False-https://forge.example/org/r2] | 1 | 0.004 ms | Index Scan using idx_finding_repository_fingerprint on finding |
    | test_exact_fingerprint_lookup_is_nonempty_and_index_scoped_at_volume[False-https://forge.example/org/r1] | 1 | 0.004 ms | Index Scan using idx_finding_repository_fingerprint on finding |
    | test_exact_fingerprint_lookup_is_nonempty_and_index_scoped_at_volume[True-https://forge.example/org/r2] | 1 | 0.004 ms | Index Scan using idx_finding_repository_fingerprint on finding |
    | test_exact_fingerprint_lookup_is_nonempty_and_index_scoped_at_volume[True-https://forge.example/org/r1] | 1 | 0.003 ms | Index Scan using idx_finding_repository_fingerprint on finding |
    | test_ambiguous_fingerprint_lookup_reads_only_two_matches_at_volume | 3 | 0.055 ms | Insert on finding |
    | test_algorithm_free_fingerprint_miss_is_bounded_at_volume[https://forge.example/org/r2] | 1 | 0.003 ms | Index Scan using idx_finding_repository_fingerprint on finding |
    | test_algorithm_free_fingerprint_miss_is_bounded_at_volume[https://forge.example/org/r1] | 1 | 0.003 ms | Index Scan using idx_finding_repository_fingerprint on finding |
    | test_statement_resend_is_idempotent_at_volume | 5 | 0.025 ms | Insert on decision |
    | test_new_statement_is_retrievable_at_volume | 5 | 0.336 ms | Insert on decision |
    | test_missing_statement_lookup_does_not_scan_at_volume | 3 | 0.003 ms | Index Scan using idx_decision_finding_occurred on decision |
    | test_strong_proof_history_uses_the_finding_index_at_volume | 3 | 0.006 ms | Index Scan using idx_decision_finding_occurred on decision |
    | test_review_page_uses_the_pending_index_at_volume[None-100] | 1 | 1.716 ms | Index Scan using idx_review_item_pending on review_item |
    | test_review_page_uses_the_pending_index_at_volume[needs_manual_test-100] | 1 | 1.178 ms | Index Scan using idx_review_item_pending on review_item |
    | test_review_page_uses_the_pending_index_at_volume[stale_baseline-0] | 1 | 0.817 ms | Index Scan using idx_review_item_pending on review_item |
    | test_pending_review_cursor_pages_through_tied_timestamps | 2 | 2.167 ms | Index Scan using idx_review_item_pending on review_item |
    | test_review_cases_batch_current_context_and_history_by_index | 12 | 2.575 ms | Index Scan using idx_review_item_pending on review_item |
    | test_pending_review_page_filters_by_finding_and_reason | 2 | 1.637 ms | Index Scan using idx_review_item_pending on review_item |
    | test_review_presence_is_an_indexed_exists_query | 3 | 1.584 ms | Index Scan using idx_review_item_pending on review_item |
    | test_finding_admission_lock_is_a_primary_key_lookup[False] | 3 | 0.006 ms | Index Scan using finding_pkey on finding |
    | test_finding_admission_lock_is_a_primary_key_lookup[True] | 3 | 0.003 ms | Index Scan using finding_pkey on finding |
    | test_scoped_tracker_write_admission_stays_bounded_at_volume | 4 | 0.345 ms | Insert on finding_external_ref |
    | test_review_transition_lock_is_a_primary_key_lookup[False] | 2 | 1.585 ms | Index Scan using idx_review_item_pending on review_item |
    | test_review_transition_lock_is_a_primary_key_lookup[True] | 2 | 1.559 ms | Index Scan using idx_review_item_pending on review_item |
    | test_restate_reads_the_decision_and_its_history_by_index | 8 | 0.232 ms | Insert on decision |
    | test_approvers_of_a_decision_read_by_index | 4 | 0.004 ms | Index Scan using idx_decision_finding_occurred on decision |
    | test_decide_reads_the_finding_its_statement_and_history_by_index | 8 | 0.278 ms | Insert on decision |
    | test_baseline_of_a_typical_repository_reads_by_index | 10 | 0.237 ms | Bitmap Index Scan on uq_location_range |
    | test_baseline_of_the_hot_repository_stays_fast | 87 | 23.737 ms | Parallel Seq Scan on location |
    | test_open_count_of_a_typical_repository_reads_by_index | 10 | 0.133 ms | Bitmap Index Scan on idx_decision_finding_occurred |
    | test_open_count_of_the_hot_repository_stays_fast | 87 | 7.441 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_review_surfaces_reads_refs_assessments_and_artifacts_by_index | 4 | 0.023 ms | Index Scan using idx_assessment_ref_kind_occurred on assessment |
    | test_intake_looks_up_each_natural_key_by_index | 7 | 0.004 ms | Bitmap Index Scan on finding_label_finding_id_taxonomy_label_key |
    | test_import_and_queue_lookups_read_by_index | 7 | 0.014 ms | Index Scan using idx_review_item_pending on review_item |
    | test_review_sources_batch_uses_the_finding_index | 2 | 0.004 ms | Index Scan using idx_finding_external_ref_finding on finding_external_ref |
    | test_retained_claim_candidate_query_at_volume | 1 | 18.553 ms | Parallel Seq Scan on decision |
    | test_symbol_pages_start_at_the_lookup_key_and_cursor[first] | 1 | 0.027 ms | Index Scan using idx_location_symbol_page on location |
    | test_symbol_pages_start_at_the_lookup_key_and_cursor[middle] | 1 | 0.076 ms | Index Scan using idx_location_symbol_page on location |
    | test_symbol_pages_start_at_the_lookup_key_and_cursor[deep] | 1 | 0.129 ms | Index Scan using idx_location_symbol_page on location |
    | test_hash_claims_use_the_location_leading_natural_key | 1 | 0.081 ms | Bitmap Index Scan on location_hash_location_id_algorithm_key |
    | test_rollup_trend_and_patterns_read_the_whole_scope_in_bounded_batches | 16716 | 33.963 ms | Bitmap Index Scan on idx_finding_repository_fingerprint |
    | test_registration_uses_the_natural_key_without_scanning[insert-products-product_slug_key] | 1 | 0.032 ms | Insert on product |
    | test_registration_uses_the_natural_key_without_scanning[insert-repositories-repository_url_key] | 1 | 0.060 ms | Insert on repository |
    | test_registration_uses_the_natural_key_without_scanning[insert-releases-release_product_id_version_key] | 1 | 0.075 ms | Insert on release |
    | test_registration_uses_the_natural_key_without_scanning[insert-components-component_release_id_repository_ref_id_key] | 1 | 0.212 ms | Insert on component |
    | test_registration_uses_the_natural_key_without_scanning[insert-teams-team_name_key] | 1 | 0.030 ms | Insert on team |
    | test_registration_uses_the_natural_key_without_scanning[insert-repository_refs-uq_ref_named] | 1 | 0.556 ms | Insert on repository_ref |
    | test_registration_uses_the_natural_key_without_scanning[insert-repository_refs-uq_ref_bare] | 1 | 0.603 ms | Insert on repository_ref |
    | test_registration_uses_the_natural_key_without_scanning[insert-ownerships-uq_ownership_open] | 1 | 0.238 ms | Insert on ownership |
    | test_registration_uses_the_natural_key_without_scanning[repeat-products-product_slug_key] | 2 | 0.010 ms | Insert on product |
    | test_registration_uses_the_natural_key_without_scanning[repeat-repositories-repository_url_key] | 2 | 0.021 ms | Insert on repository |
    | test_registration_uses_the_natural_key_without_scanning[repeat-releases-release_product_id_version_key] | 2 | 0.009 ms | Insert on release |
    | test_registration_uses_the_natural_key_without_scanning[repeat-components-component_release_id_repository_ref_id_key] | 2 | 0.008 ms | Insert on component |
    | test_registration_uses_the_natural_key_without_scanning[repeat-teams-team_name_key] | 2 | 0.010 ms | Insert on team |
    | test_registration_uses_the_natural_key_without_scanning[repeat-repository_refs-uq_ref_named] | 2 | 0.021 ms | Insert on repository_ref |
    | test_registration_uses_the_natural_key_without_scanning[repeat-repository_refs-uq_ref_bare] | 2 | 0.015 ms | Insert on repository_ref |
    | test_registration_uses_the_natural_key_without_scanning[repeat-ownerships-uq_ownership_open] | 2 | 0.016 ms | Insert on ownership |
    | test_current_ownership_uses_the_partial_unique_index | 1 | 0.004 ms | Index Scan using uq_ownership_open on ownership |
    | test_product_page_walks_the_slug_index[first] | 1 | 0.024 ms | Index Scan using product_slug_key on product |
    | test_product_page_walks_the_slug_index[next] | 1 | 0.028 ms | Index Scan using product_slug_key on product |
    | test_default_ref_reads_one_repository_by_index | 1 | 0.024 ms | Bitmap Index Scan on idx_repository_ref_repository |
    | test_observed_default_ref_uses_indexed_queries | 3 | 0.064 ms | Index Scan using idx_assessment_ref_kind_occurred on assessment |
    | test_a_repositorys_private_mirror | 1 | 0.349 ms | Seq Scan on repository |
    | test_casefold_url_lookup_is_a_bounded_scan | 1 | 0.891 ms | Seq Scan on repository |
    | test_inventory_repository_enumeration_is_one_sql_bounded_read[overflow] | 1 | 1.285 ms | Seq Scan on repository |
    | test_inventory_repository_enumeration_is_one_sql_bounded_read[exact] | 1 | 3.370 ms | Seq Scan on repository |
    | test_inventory_related_batches_use_sql_bounds_and_table_owned_reads[ownerships-repository_id-current_for_repositories] | 1 | 0.104 ms | Bitmap Index Scan on uq_ownership_open |
    | test_inventory_related_batches_use_sql_bounds_and_table_owned_reads[teams-id-list_by_ids] | 1 | 0.123 ms | Seq Scan on team |
    | test_inventory_related_batches_use_sql_bounds_and_table_owned_reads[components-repository_ref_id-list_for_refs] | 1 | 0.069 ms | Bitmap Index Scan on idx_component_repository_ref |
    | test_inventory_related_batches_use_sql_bounds_and_table_owned_reads[releases-id-list_by_ids] | 1 | 0.115 ms | Bitmap Index Scan on release_pkey |
    | test_inventory_related_batches_use_sql_bounds_and_table_owned_reads[products-id-list_by_ids] | 1 | 0.093 ms | Seq Scan on product |
    | test_inventory_release_single_id_lookup_uses_primary_key | 1 | 0.007 ms | Index Scan using release_pkey on release |
    | test_inventory_components_span_bounded_indexed_batches | 3 | 0.216 ms | Bitmap Index Scan on idx_component_repository_ref |
    | test_product_lookup_is_one_indexed_read[id] | 1 | 0.004 ms | Index Scan using product_pkey on product |
    | test_product_lookup_is_one_indexed_read[slug] | 1 | 0.003 ms | Index Scan using product_slug_key on product |
    | test_component_page_is_one_bounded_indexed_read[first] | 1 | 0.044 ms | Index Scan Backward using idx_component_created_id on component |
    | test_component_page_is_one_bounded_indexed_read[middle] | 1 | 0.052 ms | Index Scan Backward using idx_component_created_id on component |
    | test_component_page_is_one_bounded_indexed_read[deep] | 1 | 0.056 ms | Index Scan Backward using idx_component_created_id on component |
    | test_the_refs_of_many_repositories_are_one_indexed_read | 1 | 2.865 ms | Bitmap Index Scan on idx_repository_ref_repository |
    | test_refs_by_id_are_one_indexed_read | 1 | 0.305 ms | Bitmap Index Scan on repository_ref_pkey |
    | test_repositories_by_id_are_one_bounded_read | 1 | 0.143 ms | Bitmap Index Scan on repository_pkey |
    | test_repositories_shipping_uses_batched_indexed_reads | 11 | 2.869 ms | Bitmap Index Scan on idx_repository_ref_repository |
    | test_the_products_of_a_repository_are_indexed_reads | 5 | 0.034 ms | Bitmap Index Scan on idx_component_repository_ref |
    | test_the_feeds_releases_after_a_cursor_by_index[a day ago] | 1 | 0.227 ms | Index Scan using idx_release_created on release |
    | test_the_feeds_releases_after_a_cursor_by_index[the start] | 1 | 0.273 ms | Index Scan using idx_release_created on release |
    | test_a_recorded_release_is_indexed_reads | 5 | 0.034 ms | Bitmap Index Scan on repository_ref_id_repository_id_key |
    | test_append_reads_its_layer_by_index | 8 | 0.201 ms | Insert on events |
    | test_verify_reads_one_layer_by_index | 4 | 2.184 ms | Index Scan using events_layer_id_seq_key on events |
    | test_an_events_page_reads_by_index_in_seq_order[first page] | 3 | 0.018 ms | Index Scan using events_layer_id_seq_key on events |
    | test_an_events_page_reads_by_index_in_seq_order[a late page] | 3 | 0.018 ms | Index Scan using events_layer_id_seq_key on events |
    | test_countersign_verifies_its_existing_layer_once_before_append[confirm] | 19 | 2.259 ms | Index Scan using events_layer_id_seq_key on events |
    | test_countersign_verifies_its_existing_layer_once_before_append[reject] | 19 | 2.255 ms | Index Scan using events_layer_id_seq_key on events |
    | test_the_audit_walks_layers_on_the_primary_key[first batch] | 1 | 0.191 ms | Index Scan using layers_pkey on layers |
    | test_the_audit_walks_layers_on_the_primary_key[a late batch] | 2 | 2.315 ms | Index Scan using layers_pkey on layers |
    | test_claim_takes_the_queue_head_by_index | 2 | 0.388 ms | Index Scan using idx_ops_run_order_claim on run_order run_order_1 |
    | test_claim_of_some_assets_walks_the_queue_head_by_index | 2 | 0.107 ms | Index Scan using idx_ops_run_order_claim on run_order run_order_1 |
    | test_claim_selected_order_is_a_primary_key_lookup | 3 | 3.281 ms | Bitmap Index Scan on idx_ops_run_order_lease |
    | test_order_lock_is_a_primary_key_lookup | 3 | 1.449 ms | Bitmap Index Scan on idx_ops_run_order_batch |
    | test_reaper_finds_expired_leases_by_index | 1 | 1.838 ms | Index Scan using idx_ops_run_order_lease on run_order |
    | test_a_tranches_orders_by_index | 2 | 1.403 ms | Bitmap Index Scan on idx_ops_run_order_batch |
    | test_a_repositorys_open_orders_by_index | 2 | 0.005 ms | Index Scan using idx_ops_run_order_repository_state on run_order |
    | test_month_to_date_spend_reads_the_window_by_index | 1 | 10.954 ms | Bitmap Index Scan on idx_ops_spend_event_occurred |
    | test_a_lanes_month_to_date_spend_reads_its_lane_by_index | 1 | 1.822 ms | Bitmap Index Scan on idx_ops_spend_event_lane_occurred |
    | test_spend_by_lane_and_by_month | 2 | 791.702 ms | Parallel Seq Scan on spend_event |
    | test_the_open_order_for_a_repositorys_asset_by_index | 2 | 0.014 ms | Index Scan using idx_ops_run_order_asset_state on run_order |
    | test_an_assets_open_orders_by_index[fleet] | 1 | 0.019 ms | Index Scan using idx_ops_run_order_asset_state on run_order |
    | test_an_assets_open_orders_by_index[page] | 1 | 3.443 ms | Bitmap Index Scan on idx_ops_run_order_asset_state |
    | test_a_page_of_repositories | 1 | 1.462 ms | Seq Scan on repository |
    | test_an_assets_subjects_are_index_only[open] | 1 | 0.768 ms | Index Only Scan using idx_ops_run_order_asset_state on run_order |
    | test_an_assets_subjects_are_index_only[finished this month] | 1 | 2.256 ms | Index Only Scan using idx_ops_run_order_asset_state on run_order |
    | test_an_assets_stale_stops_in_a_window_read_its_index | 1 | 0.010 ms | Index Scan using idx_ops_run_order_asset_state on run_order |
    | test_an_assets_throughput_over_a_month_is_index_only | 1 | 3.394 ms | Index Only Scan using idx_ops_run_order_asset_state on run_order |
    | test_spend_by_repository_joins_the_month_to_its_orders_by_key[None] | 1 | 104.845 ms | Bitmap Index Scan on idx_ops_spend_event_occurred |
    | test_spend_by_repository_joins_the_month_to_its_orders_by_key[True] | 1 | 101.546 ms | Bitmap Index Scan on idx_ops_spend_event_occurred |
    | test_spend_by_repository_joins_the_month_to_its_orders_by_key[False] | 1 | 7.058 ms | Bitmap Index Scan on idx_ops_spend_event_occurred |
    | test_the_feeds_orders_after_a_cursor_by_index[a minute ago] | 1 | 0.022 ms | Bitmap Index Scan on idx_ops_run_order_updated |
    | test_the_feeds_orders_after_a_cursor_by_index[a day ago] | 1 | 2.025 ms | Index Scan using idx_ops_run_order_updated on run_order |
    | test_the_feeds_orders_after_a_cursor_by_index[the start] | 1 | 0.617 ms | Index Scan using idx_ops_run_order_updated on run_order |
    | test_the_last_routed_order_is_read_once_per_start | 1 | 70.145 ms | Parallel Seq Scan on run_order |
    | test_lane_costs_read_settled_orders_in_the_window_by_index | 1 | 38.882 ms | Bitmap Index Scan on idx_ops_spend_event_lane_occurred |
    | test_work_item_orders_read_the_asset_index_not_the_table | 1 | 0.204 ms | Index Scan using idx_ops_run_order_work_item on run_order |
    | test_find_by_work_item_is_one_indexed_read | 1 | 0.010 ms | Index Scan using idx_ops_run_order_work_item on run_order |
    | test_scheduling_orders_read_the_work_item_index | 1 | 0.147 ms | Index Scan using idx_ops_run_order_work_item on run_order |
    | test_decisions_for_assessments_use_the_assessment_index | 1 | 0.274 ms | Index Scan using idx_decision_assessment on decision |
    | test_attempt_tracker_reads_keep_exact_scope_at_volume | 2 | 0.005 ms | Index Scan using idx_finding_external_ref_assessment on finding_external_ref |
    | test_scanner_replay_uses_ref_kind_and_native_timestamp_index | 1 | 0.006 ms | Index Scan using idx_assessment_ref_kind_occurred on assessment |
    | test_prepare_reads_bounded_batches_by_index | 92 | 1.430 ms | Bitmap Index Scan on occurrence_pkey |
    | test_validation_timestamps_are_batched_by_primary_key | 1 | 0.157 ms | Bitmap Index Scan on assessment_pkey |

    | Case | Call | Wall clock (median) |
    |---|---|---|
    | test_a_new_manifest_sbom_writes_in_batches | ingest_sbom(2,000 packages, half new) | 223.51 ms |
    | test_dependency_reach_reads_the_fleet_in_batches | dependency-reach(1,000 repositories) | 2098.65 ms |
    | test_hot_repository_rollups_keep_query_latency_bounded | summary(hot repository, cwe) | 971.87 ms |
    | test_hot_repository_rollups_keep_query_latency_bounded | timeline(hot repository, week) | 1222.66 ms |
    | test_the_queue_reads_pending_items_by_index_and_candidates_in_one_scan | queue(all) | 3748.43 ms |
    | test_the_queue_reads_pending_items_by_index_and_candidates_in_one_scan | queue(hot repository) | 969.75 ms |
    | test_open_count_of_the_hot_repository_stays_fast | open_count(typical repository) | 6.90 ms |
    | test_open_count_of_the_hot_repository_stays_fast | open_count(hot repository) | 755.29 ms |
    | test_rollup_trend_and_patterns_read_the_whole_scope_in_bounded_batches | build(findings-rollup) | 51133.57 ms |
    | test_rollup_trend_and_patterns_read_the_whole_scope_in_bounded_batches | build(findings-trend) | 132103.67 ms |
    | test_rollup_trend_and_patterns_read_the_whole_scope_in_bounded_batches | build(insecure-patterns) | 52201.23 ms |
    | test_an_append_costs_about_an_insert[hot (10k events)] | hot (10k events): append (frontier + root) | 1.81 ms |
    | test_an_append_costs_about_an_insert[hot (10k events)] | hot (10k events): insert only | 1.32 ms |
    | test_an_append_costs_about_an_insert[typical (~24)] | typical (~24): append (frontier + root) | 1.69 ms |
    | test_an_append_costs_about_an_insert[typical (~24)] | typical (~24): insert only | 1.25 ms |
    | test_human_countersign_includes_linear_integrity_admission_cost[confirm-hot (10k events)] | hot (10k events): confirm (full integrity admission + decision + review + frontier append) | 125.67 ms |
    | test_human_countersign_includes_linear_integrity_admission_cost[confirm-typical (~24)] | typical (~24): confirm (full integrity admission + decision + review + frontier append) | 6.99 ms |
    | test_human_countersign_includes_linear_integrity_admission_cost[reject-hot (10k events)] | hot (10k events): reject (full integrity admission + decision + review + frontier append) | 127.60 ms |
    | test_human_countersign_includes_linear_integrity_admission_cost[reject-typical (~24)] | typical (~24): reject (full integrity admission + decision + review + frontier append) | 6.70 ms |

    chubirka chubirka commented on Nov 10, 2026 02:28 UTC
    Author

    /agentic_review

    qodo-for-traust-sci[bot] qodo-for-traust-sci[bot] commented on Nov 10, 2026 02:30 UTC
    Bot

    <h3>PR Summary by Qodo</h3>

    Close native workflow parity gaps in Core

    <code>🐞 Bug fix</code> <code>✨ Enhancement</code> <code>🧪 Tests</code> <code>📝 Documentation</code> <code>⚙️ Configuration changes</code> <code>🕐 40+ Minutes</code>

    <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">

    <details>
    <summary>AI Description</summary>

    <dl>
    <dd>
    <br/>

    ><pre>
    >• Preserve advisory aliases, audited-commit replay evidence, spend attribution, and repository

    availability.

    >• Add human-reviewed finding corrections while retaining original evidence and historical
    identities.

    >• Serialize artifact publication, guard schema upgrades, and expand correctness and performance
    coverage.

    ></pre>

    </dd>
    </dl>

    </details>

    <details>
    <summary>Diagram</summary>

    <dl>
    <dd>

    <br/>

    graph TD
      Providers["Forge and OSV"] --> Services["Core services"] --> Models["Domain models"] --> Publisher["Artifact publisher"] --> Store[("Artifacts and metadata")]
      Services --> Findings["Finding review"] --> Publisher
      Services --> Portfolio["Portfolio and spend"] --> Publisher
    

    </dd>
    </dl>

    </details>

    <details>
    <summary>High-Level Assessment</summary>

    <dl>
    <dd>

    <br/>

    >The following are alternative approaches to this PR:

    <details>
    <summary><b>1. Dedicated workflow tables</b></summary>

    <dl>
    <dd>

  • ➕ Could support indexed queries over individual replay checks, claims, and availability transitions.

  • ➖ Requires more schema migrations and duplicates the existing artifact and assessment history mechanisms.
  • </dd>
    </dl>

    </details>

    >Recommendation: Keep these workflows with their existing Core owners and retained artifact history. Review the revision upgrades and query costs closely: a table-backed approach becomes more attractive only if snapshot reads or claim-history scans cease to meet volume targets.

    </dd>
    </dl>

    </details>

    <details>
    <summary> Files changed (80) <code> +6126 / -533 </code> </summary>

    <dl>
    <dd>

    <br/>

    <details>
    <summary>Enhancement (21) <code> +1832 / -82 </code></summary>

    <dl>
    <dd>

    <details>
    <summary>context.py<code>Wire parity services and enforce additive upgrades</code> <code>+89/-8</code></summary>

    <br/>

    >Wire parity services and enforce additive upgrades

    ><pre>

    >• Registers new artifact kinds and shared service dependencies. Checks publication, spend, and tracker-scope upgrades when opening databases.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-18a62a7c5b773efeea263d8fbef03b63d1a2bc1a91155735e5ddf82d0f3c14fa'>src/traust_core/v1/context/context.py</a>

    </details>

    <details>
    <summary>assessment.py<code>Model imported publication revision</code> <code>+1/-0</code></summary>

    <br/>

    >Model imported publication revision

    ><pre>

    >• Adds an optional positive publication revision to artifact metadata.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-6590fb90b7d5952d69f00089172d0bec313a5f2f1c7d306338cd91c3733fb98a'>src/traust_core/v1/models/assessment.py</a>

    </details>

    <details>
    <summary>cve_replay.py<code>Define human-gated CVE replay results</code> <code>+235/-0</code></summary>

    <br/>

    >Define human-gated CVE replay results

    ><pre>

    >• Models audited bindings, candidates, snapshots, watermarks, and trends. Prevents unknown presence from becoming a confirmed miss.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-d7ca77479353d63f405b50beef052989088719f4403027db62aa2bf9cdbc56c4'>src/traust_core/v1/models/cve_replay.py</a>

    </details>

    <details>
    <summary>finding_claims.py<code>Define corrected claims and immutable bases</code> <code>+43/-0</code></summary>

    <br/>

    >Define corrected claims and immutable bases

    ><pre>

    >• Models claim locations, projected content, and the prior fingerprint, title, decision, and occurrence identities.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-1b2260e1cf2f8bddfcf6fda451945e737a8010ab822e43eadc52e50addaeff2d'>src/traust_core/v1/models/finding_claims.py</a>

    </details>

    <details>
    <summary>inventory.py<code>Model durable repository availability snapshots</code> <code>+40/-6</code></summary>

    <br/>

    >Model durable repository availability snapshots

    ><pre>

    >• Adds explicit availability status and duration, with validation that snapshot identities and times remain consistent.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-e2f6dd665ad5ec3870da363ae7f819ae519231c9dbd58032d89997a83f6ab46d'>src/traust_core/v1/models/inventory.py</a>

    </details>

    <details>
    <summary>observation.py<code>Carry explicit forge availability evidence</code> <code>+4/-1</code></summary>

    <br/>

    >Carry explicit forge availability evidence

    ><pre>

    >• Distinguishes an attempted availability query from an inferred observation and retains status and canonical URL.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-324842c76ccaee5be2095c69e3a61d05bff61978f1cafb73071fef1c17f91765'>src/traust_core/v1/models/observation.py</a>

    </details>

    <details>
    <summary>operations.py<code>Retain spend metadata and degraded outcomes</code> <code>+8/-0</code></summary>

    <br/>

    >Retain spend metadata and degraded outcomes

    ><pre>

    >• Adds repository, label, size, batch, and note fields to spend events and degraded counts to order manifests.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-969d963434648748c5a4404bfcc752b45e227da9c72d76604ae90772ade33a4e'>src/traust_core/v1/models/operations.py</a>

    </details>

    <details>
    <summary>vocabulary.py<code>Expose contract-defined availability statuses</code> <code>+2/-0</code></summary>

    <br/>

    >Expose contract-defined availability statuses

    ><pre>

    >• Loads the liveness-status vocabulary from traust-contracts.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-12b63cc9d5c6f9aa10939fc40617f431f96a8446a45c3a2616f02e5a08fbe433'>src/traust_core/v1/models/vocabulary.py</a>

    </details>

    <details>
    <summary>feeds.py<code>Extend advisory lookup capabilities</code> <code>+6/-0</code></summary>

    <br/>

    >Extend advisory lookup capabilities

    ><pre>

    >• Defines related-advisory and commit-query methods and advertises whether a lookup supports commit queries.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-0af4695be4c92a5b36bf08e9cd7877a9e2d30d20b32c44a8f3b1df0a7ce0ead8'>src/traust_core/v1/providers/feeds.py</a>

    </details>

    <details>
    <summary>forge.py<code>Classify availability from forge metadata</code> <code>+27/-0</code></summary>

    <br/>

    >Classify availability from forge metadata

    ><pre>

    >• Extracts canonical URLs and disabled flags to distinguish moved, disabled, archived, active, and unknown repositories.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-1314d68c831717f405c62b5948175af98ea926acb1a541911d39133d30148c6e'>src/traust_core/v1/providers/forge.py</a>

    </details>

    <details>
    <summary>osv.py<code>Fetch alias records and complete audited-commit answers</code> <code>+124/-7</code></summary>

    <br/>

    >Fetch alias records and complete audited-commit answers

    ><pre>

    >• Traverses related advisories, pages through live commit queries, rejects conflicting or malformed responses, and validates publication timestamps.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-0bad3dd74ecb1f1f9107fbdebaf8445243e00af021d5c98ee3651bac3545cf91'>src/traust_core/v1/providers/osv.py</a>

    </details>

    <details>
    <summary>sources.py<code>Carry availability through source results and errors</code> <code>+13/-1</code></summary>

    <br/>

    >Carry availability through source results and errors

    ><pre>

    >• Adds status and canonical URL to repository information and source failures.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-eb5669dd3e03d8d57117e37f0cfaea2f6b240072533e0715eb090ede52afaa6c'>src/traust_core/v1/providers/sources.py</a>

    </details>

    <details>
    <summary>__init__.py<code>Declare writable assessment unit of work</code> <code>+4/-1</code></summary>

    <br/>

    >Declare writable assessment unit of work

    ><pre>

    >• Exposes the write context required for serialized artifact publication.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-19e67b97e8250c665bacc419debb994025e61531fbe5037531b71ab141d95203'>src/traust_core/v1/repositories/traust/assessments/__init__.py</a>

    </details>

    <details>
    <summary>assessment.py<code>Support locking an original assessment</code> <code>+9/-0</code></summary>

    <br/>

    >Support locking an original assessment

    ><pre>

    >• Adds a primary-key get-for-update read for replay snapshot serialization.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-ecb47124a18d928668b83581116f218d3359d5b476336139fe542bb72ca100b7'>src/traust_core/v1/repositories/traust/assessments/assessment.py</a>

    </details>

    <details>
    <summary>decision.py<code>Locate findings with retained claim decisions</code> <code>+12/-1</code></summary>

    <br/>

    >Locate findings with retained claim decisions

    ><pre>

    >• Adds a distinct finding-ID query for baseline-rewrite decisions backed by artifacts.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-d05c15c6b2e504891e2e2a3d2ba97106bd583e309ac8ea7dfdf0133311a31462'>src/traust_core/v1/repositories/traust/findings/decision.py</a>

    </details>

    <details>
    <summary>detection_quality.py<code>Replay advisories against original audited reports</code> <code>+304/-2</code></summary>

    <br/>

    >Replay advisories against original audited reports

    ><pre>

    >• Queries audited commits and classifies retained report evidence without assuming presence. Stores bound, revisioned snapshots and human adjudications.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-b51b287bf3f573c58ee8fd83155a4151ad27bd9a1c12f6d39ae99e3d957c7a49'>src/traust_core/v1/services/detection_quality.py</a>

    </details>

    <details>
    <summary>claims.py<code>Implement retained, reviewed finding corrections</code> <code>+523/-0</code></summary>

    <br/>

    >Implement retained, reviewed finding corrections

    ><pre>

    >• Validates original report bindings and stages ticketed proposals. Acceptance checks human authority, approvers, stale bases, occurrences, and fingerprint collisions before changing the claim projection.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-4be5119d71f51b74049a039bc8425f61f81addc18b9a148296a469e25470cda6'>src/traust_core/v1/services/findings/claims.py</a>

    </details>

    <details>
    <summary>decisions.py<code>Append authorized claim proposal and acceptance decisions</code> <code>+81/-0</code></summary>

    <br/>

    >Append authorized claim proposal and acceptance decisions

    ><pre>

    >• Restricts claim artifacts to the correction workflow and records digest-bound decisions and independent approvers.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-7437bd807362027e461b1e4e9a5ebdfaa2a9bd745c3c27f0815e5e1d4ed4c4ba'>src/traust_core/v1/services/findings/decisions.py</a>

    </details>

    <details>
    <summary>service.py<code>Expose claim correction and historical read APIs</code> <code>+83/-13</code></summary>

    <br/>

    >Expose claim correction and historical read APIs

    ><pre>

    >• Wires claim requests, acceptance, and as-of reads into FindingService; includes corrected claims in finding queries.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-009c4adddb40cd93a92a30814c9f64290098e45b3309a4cf5e7b58ae58bd654b'>src/traust_core/v1/services/findings/service.py</a>

    </details>

    <details>
    <summary>views.py<code>Project approved claims without rewriting evidence</code> <code>+60/-6</code></summary>

    <br/>

    >Project approved claims without rewriting evidence

    ><pre>

    >• Shows corrected titles, fingerprints, locations, categories, and CWEs, with the appropriate historical claim for as-of reads.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-62f228c6ac27b361fd926128e89a25f6249d12a866010f60d840b1b36987bb2f'>src/traust_core/v1/services/findings/views.py</a>

    </details>

    <details>
    <summary>portfolio.py<code>Persist repository availability independently of repo state</code> <code>+164/-36</code></summary>

    <br/>

    >Persist repository availability independently of repo state

    ><pre>

    >• Publishes availability snapshots, preserves status duration, excludes unqueried repositories from references, and incorporates completed observation failures.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-d877ef0a36f217fca287855409e4a9d200a6373eb1f9b2a4adfcc03fc2eea1f8'>src/traust_core/v1/services/portfolio.py</a>

    </details>

    </dd>
    </dl>

    </details>

    <details>
    <summary>Bug fix (15) <code> +718 / -227 </code></summary>

    <dl>
    <dd>

    <details>
    <summary>artifacts.py<code>Register new artifacts and capture immutable document snapshots</code> <code>+26/-5</code></summary>

    <br/>

    >Register new artifacts and capture immutable document snapshots

    ><pre>

    >• Adds replay, claim, intake, and liveness artifact types. Serialized documents no longer retain the caller&#x27;s mutable mapping.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-38f556e3453e76127a71cb7d85636474ec2bd88b04b776533829eed8f907039e'>src/traust_core/v1/models/artifacts.py</a>

    </details>

    <details>
    <summary>dependencies.py<code>Represent nullable advisory fix availability</code> <code>+2/-1</code></summary>

    <br/>

    >Represent nullable advisory fix availability

    ><pre>

    >• Adds sweep output distinguishing stated fixes, absent fixes, and insufficient package detail.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-29f713821560760f8a46cd80b19b18516db5a49afd398db31839b674564ba507'>src/traust_core/v1/models/dependencies.py</a>

    </details>

    <details>
    <summary>findings.py<code>Keep claim statements out of disposition folds</code> <code>+10/-2</code></summary>

    <br/>

    >Keep claim statements out of disposition folds

    ><pre>

    >• Keys claim decisions to their artifact and ticket, excludes nonjudgment decisions from disposition statements, and permits corrected view locations.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-d30bb132f2c899df0b9594fdc4ad91cb1f0233bec17c0f97bd64afa4720fa088'>src/traust_core/v1/models/findings.py</a>

    </details>

    <details>
    <summary>config_matrix.py<code>Honor requested configuration triple cap</code> <code>+4/-1</code></summary>

    <br/>

    >Honor requested configuration triple cap

    ><pre>

    >• Accepts nonnegative integer max_triples values and passes the cap to matrix enumeration.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-2bc69ea99bcb3fefdd258343b8849fbd56129a24df1e7053b36286fe76b53e2c'>src/traust_core/v1/providers/config_matrix.py</a>

    </details>

    <details>
    <summary>artifact.py<code>Order imported artifacts by serialized revision</code> <code>+32/-4</code></summary>

    <br/>

    >Order imported artifacts by serialized revision

    ><pre>

    >• Stores publication revisions, locks per-kind publication on Postgres, and rejects unversioned imported reads.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-362f910b2e9942dcac13f74b5a53e144157ece00dc661e46c6e528c53edac244'>src/traust_core/v1/repositories/traust/assessments/artifact.py</a>

    </details>

    <details>
    <summary>spend_event.py<code>Persist and group spend attribution</code> <code>+8/-3</code></summary>

    <br/>

    >Persist and group spend attribution

    ><pre>

    >• Adds spend metadata columns and groups by the event&#x27;s repository, falling back to its order for historical events.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-02787ba5d20d675a5cab7eb06258e2cd897244b6224851e4fb5423e818bad3f6'>src/traust_core/v1/repositories/traust_ops/spend_event.py</a>

    </details>

    <details>
    <summary>artifact_publishing.py<code>Stage uploads and serialize imported publication</code> <code>+72/-24</code></summary>

    <br/>

    >Stage uploads and serialize imported publication

    ><pre>

    >• Separates object uploads from metadata writes and assigns per-kind revisions under a lock. Successor publication checks the exact prior artifact.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-79edf32bf9af96ec95faa4c0b1d09e30137055676c71661350a2e9a464ccae85'>src/traust_core/v1/services/artifact_publishing.py</a>

    </details>

    <details>
    <summary>assessment.py<code>Retain original scanner bindings and stage assessment bytes</code> <code>+179/-103</code></summary>

    <br/>

    >Retain original scanner bindings and stage assessment bytes

    ><pre>

    >• Attaches original label-to-fingerprint bindings to native scans. Prepares uploads before recording locks while preserving authorization and atomic metadata writes.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-89865577782c26790d6b00dd07a6c526112cdcd7642abaf7456dca22e5e7fa54'>src/traust_core/v1/services/assessment.py</a>

    </details>

    <details>
    <summary>exposure.py<code>Preserve alias package context across exposure workflows</code> <code>+108/-34</code></summary>

    <br/>

    >Preserve alias package context across exposure workflows

    ><pre>

    >• Combines affected ranges and provenance from related advisories, supports commit queries, and reports nullable sweep fix availability.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-649efa6a2bc66b08ec93f3ab1702b0ca7f1f011101891f872b61ee1dfa8d6b6a'>src/traust_core/v1/services/exposure.py</a>

    </details>

    <details>
    <summary>facts.py<code>Load historical approved claims separately from judgments</code> <code>+28/-4</code></summary>

    <br/>

    >Load historical approved claims separately from judgments

    ><pre>

    >• Loads retained claim history for views and prevents claim-only decisions from changing disposition folds.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-f627bd1651219e63d70acd1be8360b218e6f4fa5058c7809b6307a64447edb28'>src/traust_core/v1/services/findings/facts.py</a>

    </details>

    <details>
    <summary>intake.py<code>Reserve original and corrected finding identities</code> <code>+98/-16</code></summary>

    <br/>

    >Reserve original and corrected finding identities

    ><pre>

    >• Matches accepted historical fingerprints to the same finding and prevents retries from rewriting original occurrences.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-4e6ff08a73246c1bfc1dafd3cfcc31014bf0dc6b9ca4b4b518211ff80e990d2c'>src/traust_core/v1/services/findings/intake.py</a>

    </details>

    <details>
    <summary>records.py<code>Validate assessment-scoped tracker links</code> <code>+13/-4</code></summary>

    <br/>

    >Validate assessment-scoped tracker links

    ><pre>

    >• Requires a scoped tracker&#x27;s assessment and finding to belong to the same repository.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-3998dd04ab08e1fe07e82f9fcad6c56ca4dc9c90058858f04098e335843a809b'>src/traust_core/v1/services/findings/records.py</a>

    </details>

    <details>
    <summary>review.py<code>Route claim reviews through their dedicated acceptance door</code> <code>+10/-1</code></summary>

    <br/>

    >Route claim reviews through their dedicated acceptance door

    ><pre>

    >• Rejects generic review resolution of retained claim proposals.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-94edcb1f2236aa7ab4e9a1b1600b88ca3a750fc158f04ebfebdd90204ddaee46'>src/traust_core/v1/services/findings/review.py</a>

    </details>

    <details>
    <summary>observation.py<code>Separate availability evidence from successful head observations</code> <code>+48/-8</code></summary>

    <br/>

    >Separate availability evidence from successful head observations

    ><pre>

    >• Carries explicit forge status through observation, including failures, without claiming an unavailable repository was observed successfully.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-9b8b949d606fc5a84661ffac7ed76ac879a000272fb6fc5a4c205a0185b78859'>src/traust_core/v1/services/observation.py</a>

    </details>

    <details>
    <summary>operations.py<code>Authorize uploads and resolve spend identity conservatively</code> <code>+80/-17</code></summary>

    <br/>

    >Authorize uploads and resolve spend identity conservatively

    ><pre>

    >• Checks recording authority before staging and again under the lease lock. Resolves spend only through registered identities or its order.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-e617f8e97e0687b2fc96d39cd37e9786c58bb8b6b6c38fedffc3c61b6952cc11'>src/traust_core/v1/services/operations.py</a>

    </details>

    </dd>
    </dl>

    </details>

    <details>
    <summary>Refactor (1) <code> +6 / -1 </code></summary>

    <dl>
    <dd>

    <details>
    <summary>restatement.py<code>Reuse independent-approver authorization for claims</code> <code>+6/-1</code></summary>

    <br/>

    >Reuse independent-approver authorization for claims

    ><pre>

    >• Extracts restatement authority checks for verified human authors and configured independent approvers.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-6b54ee6d7e5a021ff3934419b6ef3a0a2a0f9d4d7e4abb1bcb4e1b86464541c3'>src/traust_core/v1/services/findings/restatement.py</a>

    </details>

    </dd>
    </dl>

    </details>

    <details>
    <summary>Tests (39) <code> +3503 / -218 </code></summary>

    <dl>
    <dd>

    <details>
    <summary>test_artifact_reads.py<code>Check revisioned artifact-read plans</code> <code>+11/-1</code></summary>

    <br/>

    >Check revisioned artifact-read plans

    ><pre>

    >• Updates the import retry fixture with a revision and checks that imported history uses its kind index.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-ed3121eb33fa0b781793d08b803733b1e48044ec7ab197ba83ab07de441f3eac'>perf/queries/test_artifact_reads.py</a>

    </details>

    <details>
    <summary>test_assessments.py<code>Measure original-audit locking</code> <code>+7/-0</code></summary>

    <br/>

    >Measure original-audit locking

    ><pre>

    >• Verifies that locking an assessment uses its primary key.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-b05b214ce08cbd04ed66064e1a4ee4eec52563c20233b08ab8de3f534393f734'>perf/queries/test_assessments.py</a>

    </details>

    <details>
    <summary>test_dependencies.py<code>Adapt advisory volume fixture to related lookups</code> <code>+3/-9</code></summary>

    <br/>

    >Adapt advisory volume fixture to related lookups

    ><pre>

    >• Adds the related-record provider method and retains bounded scan and latency assertions.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-e8394c39bb12bf53b1aa750cfe9934b4259d8bf48675135d9bcc096798df54fb'>perf/queries/test_dependencies.py</a>

    </details>

    <details>
    <summary>test_finding_rollups.py<code>Bound hot-repository rollup latency</code> <code>+1/-2</code></summary>

    <br/>

    >Bound hot-repository rollup latency

    ><pre>

    >• Keeps latency coverage without assuming an unchanged number of fact queries.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-da5ba188a2c77bb83ebb8b3f976fca0979670470e3eb4d0ec7833fd79195ba4d'>perf/queries/test_finding_rollups.py</a>

    </details>

    <details>
    <summary>test_findings.py<code>Validate complete review histories at volume</code> <code>+22/-4</code></summary>

    <br/>

    >Validate complete review histories at volume

    ><pre>

    >• Compares returned review histories with stored decision identities and checks retained-claim candidate query latency.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-121d7b3785ca93ee7fbe2551f593cf3654225a6dd53d9987e9d16c33d7258c16'>perf/queries/test_findings.py</a>

    </details>

    <details>
    <summary>test_ops.py<code>Check repository spend grouping plan</code> <code>+2/-1</code></summary>

    <br/>

    >Check repository spend grouping plan

    ><pre>

    >• Retains index and latency assertions for spend grouped by repository.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-685bc9aa8033ff5638d392e8f28697ade7cd87f6b91cca7f3aef825a56e7097f'>perf/queries/test_ops.py</a>

    </details>

    <details>
    <summary>test_remediation_fold.py<code>Scope remediation fixture findings to its repository</code> <code>+3/-1</code></summary>

    <br/>

    >Scope remediation fixture findings to its repository

    ><pre>

    >• Selects findings belonging to the seeded repository for the remediation fold case.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-69daf6e740feb5a9aacf1e49de4105fe764fd3bc6407b32cfd14a10e780482fb'>perf/queries/test_remediation_fold.py</a>

    </details>

    <details>
    <summary>test_scanner_replay.py<code>Give repeated scanner replay fixtures unique assessors</code> <code>+2/-1</code></summary>

    <br/>

    >Give repeated scanner replay fixtures unique assessors

    ><pre>

    >• Prevents reused volume data from colliding with an earlier scanner assessment.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-28a1efe1ff8da7d82b7dda82a0d381a4ead2da87a135e81aa21a4c87dc462b37'>perf/queries/test_scanner_replay.py</a>

    </details>

    <details>
    <summary>seed.py<code>Seed imported artifact publication revisions</code> <code>+3/-2</code></summary>

    <br/>

    >Seed imported artifact publication revisions

    ><pre>

    >• Assigns per-kind revisions to imported artifacts in the performance dataset.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-b1f3f23d1a841ceba8c34213d024cd9982a37444827b6e59b0669c1368352efa'>perf/seed.py</a>

    </details>

    <details>
    <summary>cve-replay-osv.json<code>Add synthetic audited-commit advisory</code> <code>+25/-0</code></summary>

    <br/>

    >Add synthetic audited-commit advisory

    ><pre>

    >• Provides a dated OSV advisory with an alias and affected Go package for replay tests.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-e24456a11b3ffd9307b6c3d5da87d7b5e84e8eff2033d2f7774e80c29f7950a1'>tests/fixtures/detection_quality/cve-replay-osv.json</a>

    </details>

    <details>
    <summary>test_context.py<code>Exercise local and configured schema upgrades</code> <code>+124/-0</code></summary>

    <br/>

    >Exercise local and configured schema upgrades

    ><pre>

    >• Tests publication and spend history upgrades, configured-database refusal, and partial metadata or tracker-guard states.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-5aa46812442dbd8e1830a0d01231a6737ec9cf6a5014e7f1bad3c13677036eb7'>tests/v1/context/test_context.py</a>

    </details>

    <details>
    <summary>test_services.py<code>Isolate context wiring fixtures</code> <code>+6/-6</code></summary>

    <br/>

    >Isolate context wiring fixtures

    ><pre>

    >• Passes temporary paths to context tests affected by the new database-open checks.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-0fa391cd7f94174fdcdb47a3e976bf86e803283b27b7e714297d2555ca3154f5'>tests/v1/context/test_services.py</a>

    </details>

    <details>
    <summary>test_artifacts.py<code>Verify artifact snapshots resist caller mutation</code> <code>+14/-0</code></summary>

    <br/>

    >Verify artifact snapshots resist caller mutation

    ><pre>

    >• Confirms an artifact document retains its serialized content when the input mapping changes.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-b4fc881e8b59342e75b03eadd54e7ff8ecde62e6b3966b3cabdef0207b85e4b5'>tests/v1/models/test_artifacts.py</a>

    </details>

    <details>
    <summary>test_cve_replay.py<code>Test replay verdict and presence invariants</code> <code>+208/-0</code></summary>

    <br/>

    >Test replay verdict and presence invariants

    ><pre>

    >• Covers identifier and area matches, human evidence, withdrawal, audit bindings, and miss eligibility.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-2ed8043b69fc15b020e6c1d1e016133d17d0a4aa2c3f700f19fc307fcf1bb4e5'>tests/v1/models/test_cve_replay.py</a>

    </details>

    <details>
    <summary>observation_support.py<code>Register liveness artifacts in observation fixtures</code> <code>+9/-2</code></summary>

    <br/>

    >Register liveness artifacts in observation fixtures

    ><pre>

    >• Makes the shared observer fixture capable of publishing availability snapshots.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-8d7196b114d831848f5b3bd4a2b4ead03d3734f0cae6adf074c940b4a1a58006'>tests/v1/observation_support.py</a>

    </details>

    <details>
    <summary>test_config_matrix.py<code>Test configuration caps and omitted coverage</code> <code>+23/-0</code></summary>

    <br/>

    >Test configuration caps and omitted coverage

    ><pre>

    >• Checks requested cap behavior and rejects invalid max_triples inputs.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-9f44e73b4384f0f716f8c4ea2ba77f58be7d1f9cdbc2b40ffa6037c013e95315'>tests/v1/providers/test_config_matrix.py</a>

    </details>

    <details>
    <summary>test_cve_replay.py<code>Test complete OSV commit-query responses</code> <code>+164/-0</code></summary>

    <br/>

    >Test complete OSV commit-query responses

    ><pre>

    >• Covers pagination, source provenance, retries, malformed responses, and unknown identifiers.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-18184c0400a635856691c48d4ab46b69bd2adb6a769fc2c40d1e02a2182815d7'>tests/v1/providers/test_cve_replay.py</a>

    </details>

    <details>
    <summary>test_forge.py<code>Test forge availability classification</code> <code>+70/-0</code></summary>

    <br/>

    >Test forge availability classification

    ><pre>

    >• Checks explicit metadata, ambiguous transport failures, and malformed availability fields.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-28d5d8d493f70d9ea7c62a10e8246a613c3d65465882991b8368c709b6251e5c'>tests/v1/providers/test_forge.py</a>

    </details>

    <details>
    <summary>test_osv.py<code>Test related live and exported advisory records</code> <code>+73/-0</code></summary>

    <br/>

    >Test related live and exported advisory records

    ><pre>

    >• Checks disjoint alias packages, provenance, duplicate exports, and conflicting source records.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-a7e1980f07e1c3be6975a70bdc54bdc819d021e4b176974ecefaf8554d6e0c23'>tests/v1/providers/test_osv.py</a>

    </details>

    <details>
    <summary>conftest.py<code>Version seeded feed imports</code> <code>+3/-1</code></summary>

    <br/>

    >Version seeded feed imports

    ><pre>

    >• Assigns the next publication revision when seeding feed snapshots.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-f721a0a2ddbbeada6f883def70dbb3010007e16f4dff5d9b5a722d41ad055667'>tests/v1/repositories/tables/conftest.py</a>

    </details>

    <details>
    <summary>test_assessments.py<code>Test revision ordering and assessment locks</code> <code>+65/-11</code></summary>

    <br/>

    >Test revision ordering and assessment locks

    ><pre>

    >• Checks equal-timestamp import order, unversioned import refusal, and exact assessment locking.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-591ea8530437fcd7e488971559951edafa4e0de172772a28f0adc37e545e2a2e'>tests/v1/repositories/tables/test_assessments.py</a>

    </details>

    <details>
    <summary>test_code_fact_reads.py<code>Test raw import metadata ownership</code> <code>+18/-5</code></summary>

    <br/>

    >Test raw import metadata ownership

    ><pre>

    >• Updates artifact fixtures and verifies raw imports share the revisioned publication stream.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-059d922c66c0110391536fd0cf280070845d5667492b301d4f8ed65315513d4a'>tests/v1/repositories/tables/test_code_fact_reads.py</a>

    </details>

    <details>
    <summary>test_findings.py<code>Test retained-claim decision lookup</code> <code>+12/-1</code></summary>

    <br/>

    >Test retained-claim decision lookup

    ><pre>

    >• Verifies the candidate query returns distinct findings only for artifact-backed claim decisions.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-e9f7daad1c4fd0a956529c39c435578adb57382cb254f1ea68acb9fe3de915be'>tests/v1/repositories/tables/test_findings.py</a>

    </details>

    <details>
    <summary>test_advisories.py<code>Cover advisory alias context in REST output</code> <code>+9/-0</code></summary>

    <br/>

    >Cover advisory alias context in REST output

    ><pre>

    >• Extends the advisory endpoint regression case for alias-derived package information.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-9f1c5f1403f09e2627768649d520e62fec4dd7a6a9bd8b4c054d85b12869b92e'>tests/v1/rest/exposure/test_advisories.py</a>

    </details>

    <details>
    <summary>test_claims.py<code>Exercise reviewed claim correction end to end</code> <code>+751/-0</code></summary>

    <br/>

    >Exercise reviewed claim correction end to end

    ><pre>

    >• Covers authority, retained bindings, stale proposals, concurrency, retries, historical projection, immutable occurrences, and ledger rollback.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-1f0efe52788847bea5398f5b82a531e47f7157360af552f6685285b902824247'>tests/v1/services/findings/test_claims.py</a>

    </details>

    <details>
    <summary>test_rebaseline.py<code>Distinguish legacy mapping from retained claims</code> <code>+31/-0</code></summary>

    <br/>

    >Distinguish legacy mapping from retained claims

    ><pre>

    >• Confirms ordinary baseline mapping decisions are not treated as claim corrections.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-c9b35f8ee27f87ce3de89603a85210a8a97405b895ff46c29ebbea2986946629'>tests/v1/services/findings/test_rebaseline.py</a>

    </details>

    <details>
    <summary>test_records.py<code>Test tracker assessment scope guards</code> <code>+88/-0</code></summary>

    <br/>

    >Test tracker assessment scope guards

    ><pre>

    >• Covers cross-repository refusal, missing assessments, unscoped links, and scoped retries.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-65a1f780c0461c7f9300aa23b4833c62b32786b879447f330baf21f4861e1903'>tests/v1/services/findings/test_records.py</a>

    </details>

    <details>
    <summary>test_review_cases.py<code>Adjust review-case evidence expectations</code> <code>+6/-1</code></summary>

    <br/>

    >Adjust review-case evidence expectations

    ><pre>

    >• Keeps review evidence coverage aligned with complete decision histories.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-7d56983dd6568980fc0e7a51b3740961ac175b965052501ef9194f72a62729ac'>tests/v1/services/findings/test_review_cases.py</a>

    </details>

    <details>
    <summary>test_artifact_publishing.py<code>Test serialized publication and upload timing</code> <code>+159/-1</code></summary>

    <br/>

    >Test serialized publication and upload timing

    ><pre>

    >• Checks exact-prior successors, concurrent revisions, older-digest refusal, and object uploads outside database write locks.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-0efe7e3a301a1becf89de63cc549e7fd2959515d8e644779a82347760470b7b3'>tests/v1/services/test_artifact_publishing.py</a>

    </details>

    <details>
    <summary>test_assessment.py<code>Adapt assessment recording tests to staged publication</code> <code>+15/-3</code></summary>

    <br/>

    >Adapt assessment recording tests to staged publication

    ><pre>

    >• Retains checks for artifact linking, invalid kinds, digest mismatch, and failed-write rollback.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-3045e2529c14dbfe5c0a943fbc2c7c988a96377ebfccc9ff5a546399fb327918'>tests/v1/services/test_assessment.py</a>

    </details>

    <details>
    <summary>test_assessment_record.py<code>Test recording without upload-held order locks</code> <code>+67/-26</code></summary>

    <br/>

    >Test recording without upload-held order locks

    ><pre>

    >• Adds a slow-upload regression case and adjusts assessment recording expectations for staged bytes.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-b257f1e452586387a7e3179996dd17bf52ff6fe45c2a11719c12116c021602e2'>tests/v1/services/test_assessment_record.py</a>

    </details>

    <details>
    <summary>test_below_range.py<code>Cover below-range publication compatibility</code> <code>+9/-0</code></summary>

    <br/>

    >Cover below-range publication compatibility

    ><pre>

    >• Extends the below-range service regression coverage for the publication changes.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-7e605eeabd655e0e0b98c8b6092ab42e68853af8dcb6e9169dbb23e640248250'>tests/v1/services/test_below_range.py</a>

    </details>

    <details>
    <summary>test_cve_replay.py<code>Test audited replay, watermarks, and human adjudication</code> <code>+690/-0</code></summary>

    <br/>

    >Test audited replay, watermarks, and human adjudication

    ><pre>

    >• Covers original-report bindings, late-visible advisories, incomplete sources, snapshot conflicts, oracle retries, and unknown presence.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-bfd2659bdf7c7239ddbd524b86ea31613e9cfddca25c6222d411da2ad56925e2'>tests/v1/services/test_cve_replay.py</a>

    </details>

    <details>
    <summary>test_exposure_advisories.py<code>Test alias-derived advisory packages</code> <code>+62/-8</code></summary>

    <br/>

    >Test alias-derived advisory packages

    ><pre>

    >• Checks that nonempty primary records still retain aliases&#x27; affected ranges, fixes, and sources.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-175ffe4d9a3c6f721e5eadbb53f31b00b61d4fa14701e4ad8e8eb2ec0bc773fa'>tests/v1/services/test_exposure_advisories.py</a>

    </details>

    <details>
    <summary>test_exposure_impact.py<code>Test shared alias preparation in impact analysis</code> <code>+85/-114</code></summary>

    <br/>

    >Test shared alias preparation in impact analysis

    ><pre>

    >• Checks package ecosystem, version, fix scope, and advisory identity across related aliases; adjusts existing regression cases.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-51f6455c193d8c4ade95a9e6c77d71859d736660be0f61e153225fc11ca12e45'>tests/v1/services/test_exposure_impact.py</a>

    </details>

    <details>
    <summary>test_exposure_sweep.py<code>Test nullable sweep fix availability</code> <code>+34/-2</code></summary>

    <br/>

    >Test nullable sweep fix availability

    ><pre>

    >• Confirms advisories remain listed without a stated fix and distinguishes absent from unknown fix information.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-faa5d6b4a764cd199a05d5ae3e81e5af0ef2b6a6b2c66c9ed1f78c22a9a4375b'>tests/v1/services/test_exposure_sweep.py</a>

    </details>

    <details>
    <summary>test_portfolio_liveness.py<code>Test durable availability and status history</code> <code>+535/-14</code></summary>

    <br/>

    >Test durable availability and status history

    ><pre>

    >• Covers explicit statuses, unknown failures, unqueried repositories, duration preservation, concurrent publication, and separation from repo-state assessments.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-06d895108773cd09f17c5779032023dc44283463e62d766ecb66de45867c9bbc'>tests/v1/services/test_portfolio_liveness.py</a>

    </details>

    <details>
    <summary>test_portfolio_observation_store.py<code>Adapt portfolio observation storage coverage</code> <code>+4/-2</code></summary>

    <br/>

    >Adapt portfolio observation storage coverage

    ><pre>

    >• Aligns observation-store assertions with separately published availability evidence.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-ccbc6a8ddb9a9d7bccbdd22d35b2af1e7f91111a0b7f4ccb822902fb3ed028b3'>tests/v1/services/test_portfolio_observation_store.py</a>

    </details>

    <details>
    <summary>test_spend_attribution.py<code>Test conservative spend attribution</code> <code>+90/-0</code></summary>

    <br/>

    >Test conservative spend attribution

    ><pre>

    >• Checks metadata retention, registered identity resolution, ambiguous labels, order conflicts, and size validation.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-7ed5b68721b373bc61399560ae2e8815f77965c03b8b3bd8a6c03a470aa54b0d'>tests/v1/services/test_spend_attribution.py</a>

    </details>

    </dd>
    </dl>

    </details>

    <details>
    <summary>Documentation (1) <code> +49 / -2 </code></summary>

    <dl>
    <dd>

    <details>
    <summary>README.md<code>Document adoption parity APIs and rollout requirements</code> <code>+49/-2</code></summary>

    <br/>

    >Document adoption parity APIs and rollout requirements

    ><pre>

    >• Describes the six workflow capabilities, evidence and authority rules, and explicit database upgrade requirements.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5'>README.md</a>

    </details>

    </dd>
    </dl>

    </details>

    <details>
    <summary>Other (3) <code> +18 / -3 </code></summary>

    <dl>
    <dd>

    <details>
    <summary>pyproject.toml<code>Pin hardened traust-contracts revision</code> <code>+1/-1</code></summary>

    <br/>

    >Pin hardened traust-contracts revision

    ><pre>

    >• Moves the contract dependency to the revision containing the required schemas and guards.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711'>pyproject.toml</a>

    </details>

    <details>
    <summary>contracts.py<code>Expose publication, spend, and tracker upgrade scripts</code> <code>+15/-0</code></summary>

    <br/>

    >Expose publication, spend, and tracker upgrade scripts

    ><pre>

    >• Adds contract entry points for the additive database upgrades.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-9ab92916bbef7ae7c03f6a6f90fa5d9241b5cea340ccf1b6fb73195c5dae3dbc'>src/traust_core/v1/contracts.py</a>

    </details>

    <details>
    <summary>uv.lock<code>Lock hardened traust-contracts revision</code> <code>+2/-2</code></summary>

    <br/>

    >Lock hardened traust-contracts revision

    ><pre>

    >• Synchronizes the resolved contract Git revision with pyproject.toml.
    ></pre>
    ><a href='https://github.com/traust-security/traust-core/pull/410/files#diff-84321598744d84dbee2318e634c74c9aae39a1c253f1c4bd17ebf9ef2f807b11'>uv.lock</a>

    </details>

    </dd>
    </dl>

    </details>

    </dd>
    </dl>

    </details>

    qodo-for-traust-sci[bot] qodo-for-traust-sci[bot] commented on Nov 10, 2026 02:34 UTC
    Bot

    <h3>Code Review by Qodo</h3>

    <br/>

    <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">

    <details>
    <summary> 1. Small finding views load every claim ID <code>🐞 Bug</code> <code>⭐ New</code></summary>

    <br/>

    <details>

    ><summary>Description</summary>
    ><br/>
    ><pre>

    ><b><i>FindingFacts.load()</i></b> calls the unscoped <b><i>list_finding_ids_with_claims()</i></b> before intersecting its
    >result with the requested finding IDs. Even an empty view or one repository’s view materializes
    >claim-bearing IDs from the entire database, and batched portfolio reads repeat that global work for
    >each batch.
    ></pre>
    ></details>

    <details>

    ><summary>Agent prompt</summary>
    ><br/>
    >
    >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    >
    >## Issue description
    >Finding views fetch all claim-bearing IDs globally before filtering to their requested findings, repeating global work for each portfolio batch.
    >## Fix Focus Areas
    >- src/traust_core/v1/services/findings/facts.py[56-59]
    >- src/traust_core/v1/repositories/traust/findings/decision.py[174-182]
    >## Recommended Fix
    >Add a batched, finding-ID-scoped claim-candidate query and use it in `FindingFacts.load`; return immediately for an empty input. Add regression coverage showing that a small or empty view does not read claim IDs belonging only to other findings.
    >

    <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>

    ></details>

    Dismiss ↗ | View ↗

    </details>

    <details>
    <summary> 2. Corrected views bypass their read limit <code>🐞 Bug</code> <code>⭐ New</code></summary>

    <br/>

    <details>

    ><summary>Description</summary>
    ><br/>
    ><pre>

    ><b><i>FindingFacts.load()</i></b> calls <b><i>approved_claims_for()</i></b> without its <b><i>read_budget</i></b>, and that helper reads
    >decisions, artifacts, and review items without charging the budget. When a requested finding has
    >substantial claim or decision history, a view can materialize records beyond its configured
    >cumulative limit, including decisions made after an as-of cutoff.
    ></pre>
    ></details>

    <details>

    ><summary>Agent prompt</summary>
    ><br/>
    >
    >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    >
    >## Issue description
    >The new batched claim-read path is excluded from the cumulative record budget used by finding views.
    >## Fix Focus Areas
    >- src/traust_core/v1/services/findings/facts.py[104-108]
    >- src/traust_core/v1/services/findings/claims.py[189-216]
    >- src/traust_core/v1/services/artifact_publishing.py[166-173]
    >## Recommended Fix
    >Pass the caller’s `RecordBudget` through claim loading and charge every materialized decision, artifact, and review-item row to it. Preserve the full accepted-claim chain needed for historical restoration, and add a corrected-finding regression that exceeds the budget through claim-history reads alone.
    >

    <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>

    ></details>

    Dismiss ↗ | View ↗

    </details>

    <details>
    <summary> 3. Claim corrections bypass required approvals <code>🐞 Bug</code></summary>

    <br/>

    <details>

    ><summary>Description</summary>
    ><br/>
    ><pre>

    ><b><i>FindingClaims.correct()</i></b> accepts caller-supplied approver names, and
    ><b><i>RestatementPolicy.authorize_claim()</i></b> counts those strings without verifying that the named people
    >approved the correction. When independent approvals are configured, one authorized restater can
    >supply invented names and accept a proposal that changes the finding&#x27;s title and fingerprint.
    ></pre>
    ></details>

    <details>

    ><summary>Agent prompt</summary>
    ><br/>
    >
    >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    >
    >## Issue description
    >Caller-supplied names satisfy the configured independent-approval threshold without proving that those people approved the claim correction.
    >
    >## Fix Focus Areas
    >- src/traust_core/v1/services/findings/claims.py[416-428]
    >- src/traust_core/v1/services/findings/restatement.py[19-29]
    >- src/traust_core/v1/services/findings/decisions.py[318-356]
    >
    >## Recommended Fix
    >Require independently authenticated approval records bound to the proposal and verify them before acceptance; do not count names supplied by the accepting caller as approval proof. Add a regression showing that invented approver names cannot satisfy a nonzero threshold.
    >

    <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>

    ></details>

    Dismiss ↗ | View ↗

    </details>

    <br/>

    <details><summary><ins><strong>View low (1)</strong></ins></summary><br/>
    <img src="https://img.shields.io/badge/Low-634FD1?style=flat-square" height="20px" alt="Informational">

    <details>
    <summary> 4. Contracts dependency is pinned to an unmerged commit <code>🐞 Bug</code></summary>

    <br/>

    <details>

    ><summary>Description</summary>
    ><br/>
    ><pre>

    ><b><i>pyproject.toml</i></b> pins <b><i>traust-contracts</i></b> to commit <b><i>6ba2073…</i></b>, which the description presents as the
    >head of the still-open traust-contracts#132 rather than a merged main revision. If #132 is
    >squash-merged or rebased after its second review, Core keeps depending on that pre-merge SHA, not
    >the commit that was actually reviewed and merged, so the deployed contract can drift from what the
    >contracts repository says it ships.
    ></pre>
    ></details>

    <details>

    ><summary>Agent prompt</summary>
    ><br/>
    >
    >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    >
    >## Issue description
    >The contracts pin points at a commit from an unmerged companion PR.
    >
    >## Fix Focus Areas
    >- pyproject.toml[26-26]
    >
    >## Recommended Fix
    >After traust-contracts#132 merges, update the git pin and `uv.lock` to the merged commit on its main branch, and confirm the generated DDL and upgrade doors are identical.
    >

    <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>

    ></details>

    Dismiss ↗ | View ↗

    </details>

    </details>

    <br/>

    <!-- qodo-self-review-slot -->
    <!-- https://github.com/traust-security/traust-core/commit/5a27ce56fc86e2875c081adfc0dff76c92ea3aa4 -->

    chubirka chubirka commented on Nov 10, 2026 05:44 UTC
    Author

    Tracks the four review notes smith-xyz left on traust-security/traust-contracts#132 (head 3c25257), so this branch stays mergeable on top of the slimmed schema:

    1. Additive bootstrap only — the four reconciliation doors (artifact_publication_revision_upgrade, spend_event_metadata_upgrade, finding_fingerprint_index_upgrade, finding_external_ref_{assessment,scope}_upgrade) are deleted from contracts.py and the context.database wiring; a store that predates the bootstrap fails fast instead of being migrated behind a read.
    2. Publication revision dropped at the producer — the publication_revision column, _require_revision fail-closed reads and revision allocation are gone. A kind's imported stream keeps its (created_at, id) ordering; the per-kind advisory transaction lock plus exact-prior successor checks serialize writers, so each INSERT statement's statement_timestamp() orders the stream deterministically.
    3. Spend attribution stays order-less — ops_spend_event.repository_id is kept only for order-less imported declarations, exactly as in the contracts branch.
    4. Tracker insert path — the contracts trigger now guards only repository moves; the insert path is owned by Core's link_external (services/findings/records.py), which checks the existing (system, ref) row and its scope before inserting, and refuses a cross-scope relink.

    pyproject.toml/uv.lock re-pin traust-contracts to 3c2525778c3cf37dc81d9b650886878c59e05cdd.

    Verification: make lint-fix clean; make test 12,177 passed, 1 skipped; make test-integration 3,818 passed, 6 skipped.

    chubirka chubirka commented on Nov 10, 2026 15:44 UTC
    Author

    Qodo review — per-finding response

    Thank you for the review of 1c97de14. Dispositions below; every code fix carries a regression test verified failing before the fix. The two commits on the branch are 79ae495f (storage ownership boundaries) and the follow-up fixing the remaining findings.

    | # | Finding | Disposition |
    |---|---------|-------------|
    | 1 | INSERT-time pairing tie in get_or_add_with_status | Fixed in 79ae495f — tie gate (assessment_id IS NULL AND kind = … AND created_at >= now) with a bounded retry and RepositoryError on a frozen clock; adversarial-UUID/time-tie tests included |
    | 2 | Sweep KeyError when a fetched record names an unhit alias | Fixed — touched is now built from names actually present in hit; regression: test_a_fetched_record_naming_an_unhit_alias_still_keeps_its_own_hits |
    | 3 | Approver names counted without proof the named people approved | Deferred with rationale — see below |
    | 4 | Older stores: finding_external_ref without assessment_id | Fixed — insert-path guard in 79ae495f; opening such a store is now refused at the door (_finding_external_ref_scope), mirroring the run-order fork precedent; regression: test_a_store_whose_finding_links_predate_the_assessment_scope_is_refused |
    | 5 | Offline OSV alias closure O(n²) | Fixed — ExportedAdvisoryLookup builds a name→records index in __init__ and related() is an indexed BFS; existing transitive disjoint-alias test covers it |
    | 6 | Facts load dropped the decisions read budget | Fixed — list_for_findings(..., until=until, read_budget=read_budget) restored; corrected comes from one narrow list_finding_ids_with_claims() distinct query, deliberately not from the until-bounded set (an acceptance rewrites the finding row, so the historical view must still see the claim chain to restore the pre-claim state — deriving corrected from bounded decisions leaks the post-claim title into the as-of view). Regression: test_views_charge_the_read_budget_only_for_decisions_made_by_as_of |
    | 7 | Oracle adjudicates advisories outside the replay window | Fixed — cve_replay_oracle refuses unless published is known and audited_at < published <= now; regression: test_oracle_adjudicates_only_advisories_published_inside_the_replay_window (three refusals: unknown, not-strictly-after, future) |
    | 8 | Claim author as own approver via human:-prefixed spelling | Fixed — one canonical _approver_identity() normalizer shared by Restatement.independent_approvers, RestatementPolicy.normalize, and the stored form, so human:human:alice can no longer occur; regression: test_the_author_cannot_approve_their_own_claim_under_another_spelling |
    | 9 | Contracts pin points at an unmerged commit | Intentional — the pin tracks the reviewed head of #132 (c22f7c8f) so this branch and #132 can't drift; it will be re-pinned to the merged main SHA when #132 lands. This matches Qodo's own recommended remediation |
    | 10 | approved_claims per-finding query loop | Fixed — list_for_findings on review items and batched approved_claims_for() (one decisions, one artifacts, one review-items query) used by both facts load and intake |

    Finding 3 — approver proof, deferred deliberately

    The recommended fix (independently authenticated approval records bound to the proposal, verified before acceptance) requires new storage and a signing/attestation flow: per-approver records carrying an authenticated principal, bound to the claim artifact digest, verifiable at accept time. That is a contract-level design round (new table, migration, and an API for recording each approver's own authenticated session), not a patch to this review-fix branch.

    What this PR does close is the identity-spoofing surface inside the current model: finding 8's canonical normalization means an author can no longer count themselves under any human:-prefixed or case-varied spelling, and authorize_claim already requires a verified human author. The remaining gap — a different authorized restater naming approvers who never actually approved — is acknowledged and tracked for a dedicated design round; inventing a partial schema here (e.g. storing approver names with a verified flag nobody sets) would be worse than deferring.

    gurnben gurnben commented on Nov 10, 2026 16:10 UTC
    Contributor

    Well-scoped six-gap table; the "unknown presence never becomes a confirmed miss" principle matches the triage lanes' honesty patterns. One intersection to verify: the spend-attribution gap touches the rate-card lineage the worker telemetry already feeds — confirm the order-less declaration shape matches what the worker's usage reporting emits today so the two attribution paths don't diverge.

    gurnben gurnben commented on Nov 10, 2026 17:37 UTC
    Contributor

    @chubirka @gurnben — spend-attribution verification done. The order-less declaration shape is compatible with what the worker's usage reporting emits; no core change made, because the two deltas that exist are design calls, not shape mismatches core can absorb without touching the contracts #132 table this PR tracks. The details:

    The worker's emission, as persisted (entrypoint.sh capture_session_usage → POST /pipeline-jobs/{id}/usage → SCI agent_sessions): model, input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens, cost_usd_reported (CLI), cost_usd_computed (SCI internal/ratecard, preferred over reported), stage + inventory_item_id from the job, created_at.

    Core's order-less declaration (SpendService.record, SpendEvent): run_order_id=None, repository_id/repository_label, provider, model, skill, tokens_in, tokens_out, cost_usd, occurred_at, plus loc/batch/note.

    Where they line up — everything attribution needs maps directly: the repository identity an importer derives from the job's item (repo_url) is exactly what _repository_id resolves (https URL via inventory.find_repository, or a UUID string; an ambiguous label is preserved verbatim with its cost rather than guessed — test_ambiguous_repository_label_preserves_cost_without_guessing); the declared cost_usd is supplied and never repriced, so SCI's computed cost survives into repository rollups; model/tokens_in/tokens_out/occurred_at/skill map one-to-one.

    The two deltas, precisely (for @chubirka — both are importer-side mappings or contracts calls, deliberately not "fixed" here):

    1. Provider. The worker emits model only; the declaration requires provider. Today every ratecard model is Anthropic's wire and the model registry maps model→provider uniquely, so an importer derives it — but silently deriving it inside record() would change declaration semantics (the declarer attests provider + model), so it stays the importer's job unless we decide otherwise.
    2. Cache tokens. The worker emits cache read/creation counts and the ratecard prices them into cost_usd_computed; the declaration persists tokens_in/tokens_out and the priced cost_usd only. Cost — the attribution currency — carries the cache-priced value, so repository rollups cannot diverge; only the token-count vocabulary differs (core rollups have no cache columns). Persisting them would add columns to ops_spend_event, i.e. a contracts #132 schema change.

    One lineage note: SCI's ratecard is a snapshot of the model registry (v0.186.3 list prices, same cost math as RegistryModelCatalog.cost) but without the long-prompt tier core's catalog applies above the prompt threshold. Since declared spend keeps its supplied cost, stored attribution can't diverge — a declared-vs-measured reconciliation would just show the long-prompt delta on long sessions.

    Also confirmed while reading both sides: no importer of worker telemetry into core spend exists yet (SCI's getInventoryUsage keeps the populations separate by design — "core's spend events are order-born"), so this is prospective-compatibility verification, exactly as the comment framed it.

    gurnben gurnben commented on Nov 10, 2026 17:41 UTC
    Contributor

    /agentic_review

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/detection_quality.py:1
    @@ -520,6 +548,286 @@ def calibrate(self, pack: RulePack, scans: Sequence[UUID]) -> Calibration:
                 novel_sample=_novel_sample(hits, truth),
             )
     
    +    def cve_replay(self, since: datetime | None = None) -> CveReplayRun:
    +        """Discover advisories on the exact recorded audits, without admitting their presence."""
    +        now = self._clock.now()
    +        if since is not None:
    +            require_aware_datetime(since, "CVE replay source watermark")
    +            if since > now:
    +                raise ValidationError("CVE replay source watermark must not be in the future")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        exposure.require_commit_advisories()
    +        audits = self._cve_audits()
    +        records = self._cve_records()
    +        snapshots = self._cve_snapshots(records)
    +        answers: dict[str, tuple[AdvisoryRecord, ...]] = {}
    +        pending: list[tuple[CveReplayAudit, tuple[CveReplayCandidate, ...]]] = []
    +        fresh: list[CveReplayCandidate] = []
    +        for audit, report in audits:
    +            prior = snapshots.get(audit.audit_id)
    +            lower = max(audit.audited_at, since or audit.audited_at)
    +            if lower > now or (prior and prior.watermark is not None and prior.watermark > now):
    +                raise ValidationError(f"CVE replay audit {audit.audit_id}: future watermark")
    +            if audit.audited_commit not in answers:
    +                answers[audit.audited_commit] = exposure.advisories_for_commit(
    +                    GitSha.parse(audit.audited_commit)
    +                )
    +            if any(row.published_at is None for row in answers[audit.audited_commit]):
    +                raise ValidationError(
    +                    f"CVE replay audit {audit.audit_id}: advisory publication is unknown"
    +                )
    +            text = "\n".join(report.text_fragments(sections=("findings", "negative_results")))
    +            checks: list[CveReplayCandidate] = []
    +            for advisory in answers[audit.audited_commit]:
    +                published = advisory.published_at
    +                if (
    +                    published is None
    +                    or published <= audit.audited_at
    +                    or not lower <= published <= now
    +                ):
    +                    continue
    +                check = CveReplayCandidate.classify(audit, text, advisory, now)
    +                if (
    +                    prior
    +                    and prior.watermark is not None
    +                    and published < prior.watermark
    +                    and any(old.same_advisory(check) for old in prior.checks)
    +                ):
    +                    continue
    +                checks.append(check)
    +            fresh.extend(checks)
    +            pending.append((audit, tuple(checks)))
    +        changed: list[CveReplaySnapshot] = []
    +        for audit, checks in pending:
    +            prior = snapshots.get(audit.audit_id)
    +            state = CveReplayState(checks=prior.checks if prior else ()).merged(checks)
    +            watermark = max(now, prior.watermark) if prior and prior.watermark else now
    +            if prior and state.checks == prior.checks and watermark == prior.watermark:
    +                continue
    +            snapshot = CveReplaySnapshot(
    +                audit=audit,
    +                revision=prior.revision + 1 if prior else 1,
    +                watermark=watermark,
    +                checks=state.checks,
    +            )
    +            changed.append(snapshot)
    +            snapshots[audit.audit_id] = snapshot
    +        self._cve_commit(changed, records, now)
    +        state = self._cve_state(snapshots)
    +        return CveReplayRun(
    +            checked_at=now,
    +            audited_reports=len(audits),
    +            queried_commits=len(answers),
    +            checks=tuple(fresh),
    +            watermarks=state.watermarks,
    +            candidates=state.candidates(),
    +            trends=state.trends(),
    +        )
    +
    +    def cve_replay_candidates(self) -> CveReplayCandidates:
    +        return self._cve_state(self._cve_snapshots()).candidates()
    +
    +    def cve_replay_trends(self) -> CveReplayTrends:
    +        return self._cve_state(self._cve_snapshots()).trends()
    +
    +    def cve_replay_oracle(
    +        self,
    +        assessment_id: UUID,
    +        advisory: str,
    +        *,
    +        present_at_audit: bool | None = None,
    +        principal: Principal | None = None,
    +        presence_evidence: str | None = None,
    +    ) -> CveReplayCandidate:
    +        """Replay one source advisory, optionally recording a verified person's adjudication."""
    +        if present_at_audit is not None:
    +            if principal is None or not principal.is_verified_human():
    +                raise ForbiddenError("CVE replay presence requires a verified human caller")
    +            if presence_evidence is None:
    +                raise ValidationError("CVE replay presence requires supporting evidence")
    +            require_nonblank(presence_evidence, "CVE replay presence evidence")
    +        elif presence_evidence is not None:
    +            raise ValidationError("CVE replay presence evidence requires a presence verdict")
    +        bound = next((row for row in self._cve_audits() if row[0].audit_id == assessment_id), None)
    +        if bound is None:
    +            raise NotFoundError(f"CVE replay recorded audit {assessment_id}")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        record = exposure.find_advisory(AdvisoryIdentifier(advisory))
    +        if record is None:
    +            raise NotFoundError(f"CVE replay advisory {advisory}")
    +        audit, report = bound
    +        now = self._clock.now()
    +        published = record.published_at
    +        if published is None or not audit.audited_at < published <= now:
    +            raise ValidationError(
    +                f"CVE replay advisory {advisory}: publication must be known, strictly after "
    +                f"the audit ({audit.audited_at.isoformat()}) and no later than now"
    +            )
    +        check = CveReplayCandidate.classify(
    +            audit,
    +            "\n".join(report.text_fragments(sections=("findings", "negative_results"))),
    +            record,
    +            now,
    +            present_at_audit=present_at_audit,
    +            reviewer=principal.ref if principal and present_at_audit is not None else None,
    +            presence_identity_source=(
    +                principal.verified_by if principal and present_at_audit is not None else None
    +            ),
    +            presence_evidence=presence_evidence,
    +        )
    +        records = self._cve_records()
    +        prior = self._cve_snapshots(records).get(audit.audit_id)
    +        state = CveReplayState(checks=prior.checks if prior else ()).merged((check,))
    +        if prior is None or state.checks != prior.checks:
    +            self._cve_commit(
    +                (
    +                    CveReplaySnapshot(
    +                        audit=audit,
    +                        revision=prior.revision + 1 if prior else 1,
    +                        watermark=prior.watermark if prior else None,
    +                        checks=state.checks,
    +                    ),
    +                ),
    +                records,
    +                now,
    +            )
    +        return check
    +
    +    def _cve_audits(self) -> list[tuple[CveReplayAudit, ReportArtifact]]:
    +        records = self._log.documents(
    +            (a for kind in _AUDITS for a in self._log.list_of(kind)),
    +            [ReportArtifact.schema],
    +        )
    +        result = []
    +        seen = set()
    +        for assessment, artifact in records:
    +            if assessment.status != ASSESSMENT_COMPLETED or assessment.repository_ref_id is None:
    +                continue
    +            if assessment.id in seen:
    +                raise ValidationError(
    +                    f"CVE replay audit {assessment.id}: ambiguous recorded reports"
    +                )
    +            seen.add(assessment.id)
    +            ref = self._inventory.get_ref(assessment.repository_ref_id)
    +            repository = self._inventory.get_repository(ref.repository_id)
    +            assert assessment.id is not None and ref.id is not None and artifact.id is not None
    +            report = self._publisher.read(artifact.id, ReportArtifact)
    +            if report.metadata.repository != repository.url or report.metadata.commit != ref.sha:
    +                raise ValidationError(
    +                    f"CVE replay audit {assessment.id}: original report repository and commit "
    +                    "do not match its recorded ref"
    +                )
    +            result.append(
    +                (
    +                    CveReplayAudit(
    +                        repository_id=ref.repository_id,
    +                        repository_ref_id=ref.id,
    +                        repository=repository.url,
    +                        audited_commit=ref.sha,
    +                        audit_id=assessment.id,
    +                        report_artifact_id=artifact.id,
    +                        audited_at=assessment.occurred_at,
    +                    ),
    +                    report,
    +                )
    +            )
    +        return result
    +
    +    def _cve_records(self) -> list[tuple[Assessment, Artifact]]:
    +        return self._log.documents(
    +            self._log.list_of(AssessmentKind.CVE_REPLAY), [CveReplayArtifact.schema]
    +        )
    +
    +    def _cve_snapshots(
    +        self, records: Sequence[tuple[Assessment, Artifact]] | None = None
    +    ) -> dict[UUID, CveReplaySnapshot]:
    +        snapshots: dict[UUID, CveReplaySnapshot] = {}
    +        audits = {audit.audit_id: audit for audit, _ in self._cve_audits()}

    _cve_snapshots needs only audit metadata to bind snapshots, but it calls _cve_audits(), which reads and parses every SECURE_CODE report payload from the object store — so cve_replay() reads the whole corpus twice, and cve_replay_candidates()/trends()/oracle() re-read it on every call. Thread the already-fetched audits in as a parameter, as records already is.

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/detection_quality.py:1
    @@ -520,6 +548,286 @@ def calibrate(self, pack: RulePack, scans: Sequence[UUID]) -> Calibration:
                 novel_sample=_novel_sample(hits, truth),
             )
     
    +    def cve_replay(self, since: datetime | None = None) -> CveReplayRun:
    +        """Discover advisories on the exact recorded audits, without admitting their presence."""
    +        now = self._clock.now()
    +        if since is not None:
    +            require_aware_datetime(since, "CVE replay source watermark")
    +            if since > now:
    +                raise ValidationError("CVE replay source watermark must not be in the future")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        exposure.require_commit_advisories()
    +        audits = self._cve_audits()
    +        records = self._cve_records()
    +        snapshots = self._cve_snapshots(records)
    +        answers: dict[str, tuple[AdvisoryRecord, ...]] = {}
    +        pending: list[tuple[CveReplayAudit, tuple[CveReplayCandidate, ...]]] = []
    +        fresh: list[CveReplayCandidate] = []
    +        for audit, report in audits:
    +            prior = snapshots.get(audit.audit_id)
    +            lower = max(audit.audited_at, since or audit.audited_at)
    +            if lower > now or (prior and prior.watermark is not None and prior.watermark > now):
    +                raise ValidationError(f"CVE replay audit {audit.audit_id}: future watermark")
    +            if audit.audited_commit not in answers:
    +                answers[audit.audited_commit] = exposure.advisories_for_commit(
    +                    GitSha.parse(audit.audited_commit)
    +                )
    +            if any(row.published_at is None for row in answers[audit.audited_commit]):
    +                raise ValidationError(
    +                    f"CVE replay audit {audit.audit_id}: advisory publication is unknown"
    +                )
    +            text = "\n".join(report.text_fragments(sections=("findings", "negative_results")))
    +            checks: list[CveReplayCandidate] = []
    +            for advisory in answers[audit.audited_commit]:
    +                published = advisory.published_at
    +                if (
    +                    published is None
    +                    or published <= audit.audited_at
    +                    or not lower <= published <= now
    +                ):
    +                    continue
    +                check = CveReplayCandidate.classify(audit, text, advisory, now)
    +                if (
    +                    prior
    +                    and prior.watermark is not None
    +                    and published < prior.watermark
    +                    and any(old.same_advisory(check) for old in prior.checks)
    +                ):
    +                    continue
    +                checks.append(check)
    +            fresh.extend(checks)
    +            pending.append((audit, tuple(checks)))
    +        changed: list[CveReplaySnapshot] = []
    +        for audit, checks in pending:
    +            prior = snapshots.get(audit.audit_id)
    +            state = CveReplayState(checks=prior.checks if prior else ()).merged(checks)
    +            watermark = max(now, prior.watermark) if prior and prior.watermark else now
    +            if prior and state.checks == prior.checks and watermark == prior.watermark:

    watermark is always max(now, prior.watermark) = now (later watermarks are refused above), so the skip requires now == prior.watermark and effectively never fires — every run republishes a snapshot per audit, one new artifact + CVE_REPLAY assessment each, embedding the full accumulated checks list. Either drop watermark from the skip equality (same_advisory dedup already prevents re-checking) or make the per-run growth explicit.

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/portfolio.py:1
    @@ -515,49 +546,146 @@ def _liveness_of(self, repositories: Sequence[Repository]) -> list[Liveness]:
                 return []
             ids = [repository.id for repository in repositories if repository.id]
             now = self._clock.now()
    -        observations = self._assessment.population(
    -            now, AssessmentFilter(kind=AssessmentKind.REPO_STATE), ids
    -        ).rows
    -        latest = {row.latest.id: row for row in observations if row.latest}
    -        pushes = {
    -            latest[assessment.id].repository_id: (
    -                assessment.occurred_at,
    -                json.loads(document.payload).get("pushed_at"),
    -            )
    -            for assessment, document in self._require_publisher().documents(
    -                (row.latest for row in latest.values() if row.latest), RepoStateArtifact
    -            )
    -        }
    +        snapshot = self._require_publisher().latest(RepoLivenessArtifact)
    +        recorded = RepoLiveness.of(snapshot).repositories if snapshot is not None else {}
             unaudited = set(
                 self._assessment.population(
                     now,
                     AssessmentFilter(kind=AssessmentKind.SECURE_CODE, status=ASSESSMENT_COMPLETED),
                     ids,
                 ).never_assessed_repository_ids
             )
    -        return [
    -            self._liveness(repository, pushes, unaudited, now.date()) for repository in repositories
    -        ]
    +        rows = []
    +        for repository in repositories:
    +            assert repository.id is not None
    +            row = recorded.get(repository.id) or self._unqueried_liveness(repository, unaudited)
    +            row = self._completed_liveness(row, now)

    _completed_liveness runs an ops.list query plus a full manifest JSON parse per degraded/failed order, per repository, on every page render — the old listing was one population query plus one batched documents read, and no liveness case is in the perf suite. Batch the orders query across the page's repository ids, or persist the completed row when liveness is recorded.

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/operations.py:1
    @@ -1133,13 +1164,50 @@ def record(self, event: SpendEvent) -> SpendEvent:
             # NEED(model-registry): check provider and model against ModelCatalog once it lands.
             with self._uow as uow:
                 order = None if event.run_order_id is None else uow.run_orders.get(event.run_order_id)
    -            saved = uow.spend_events.add(event.model_copy(update={"lane": order and order.lane}))
    +            repository_id = None
    +            if order is None:
    +                repository_id = self._repository_id(event)
    +            elif order.repository_id is not None:

    For a fleet-wide order (order.repository_id is None) the disagreement check is skipped and repository_id stays None, so the event's attested repository_id is silently overwritten in the saved row. Keep self._repository_id(event) in that branch, or refuse the mismatch as the repository-scoped case does.

    smith-xyz smith-xyz requested changes on Nov 10, 2026 18:03 UTC
    Changes Requested Reviewer

    first pass — 4 notes
    <!-- traust-first-pass -->

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/detection_quality.py:1
    @@ -520,6 +548,286 @@ def calibrate(self, pack: RulePack, scans: Sequence[UUID]) -> Calibration:
                 novel_sample=_novel_sample(hits, truth),
             )
     
    +    def cve_replay(self, since: datetime | None = None) -> CveReplayRun:
    +        """Discover advisories on the exact recorded audits, without admitting their presence."""
    +        now = self._clock.now()
    +        if since is not None:
    +            require_aware_datetime(since, "CVE replay source watermark")
    +            if since > now:
    +                raise ValidationError("CVE replay source watermark must not be in the future")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        exposure.require_commit_advisories()
    +        audits = self._cve_audits()
    +        records = self._cve_records()
    +        snapshots = self._cve_snapshots(records)
    +        answers: dict[str, tuple[AdvisoryRecord, ...]] = {}
    +        pending: list[tuple[CveReplayAudit, tuple[CveReplayCandidate, ...]]] = []
    +        fresh: list[CveReplayCandidate] = []
    +        for audit, report in audits:
    +            prior = snapshots.get(audit.audit_id)
    +            lower = max(audit.audited_at, since or audit.audited_at)
    +            if lower > now or (prior and prior.watermark is not None and prior.watermark > now):
    +                raise ValidationError(f"CVE replay audit {audit.audit_id}: future watermark")
    +            if audit.audited_commit not in answers:
    +                answers[audit.audited_commit] = exposure.advisories_for_commit(
    +                    GitSha.parse(audit.audited_commit)
    +                )
    +            if any(row.published_at is None for row in answers[audit.audited_commit]):
    +                raise ValidationError(
    +                    f"CVE replay audit {audit.audit_id}: advisory publication is unknown"
    +                )
    +            text = "\n".join(report.text_fragments(sections=("findings", "negative_results")))
    +            checks: list[CveReplayCandidate] = []
    +            for advisory in answers[audit.audited_commit]:
    +                published = advisory.published_at
    +                if (
    +                    published is None
    +                    or published <= audit.audited_at
    +                    or not lower <= published <= now
    +                ):
    +                    continue
    +                check = CveReplayCandidate.classify(audit, text, advisory, now)
    +                if (
    +                    prior
    +                    and prior.watermark is not None
    +                    and published < prior.watermark
    +                    and any(old.same_advisory(check) for old in prior.checks)
    +                ):
    +                    continue
    +                checks.append(check)
    +            fresh.extend(checks)
    +            pending.append((audit, tuple(checks)))
    +        changed: list[CveReplaySnapshot] = []
    +        for audit, checks in pending:
    +            prior = snapshots.get(audit.audit_id)
    +            state = CveReplayState(checks=prior.checks if prior else ()).merged(checks)
    +            watermark = max(now, prior.watermark) if prior and prior.watermark else now
    +            if prior and state.checks == prior.checks and watermark == prior.watermark:
    +                continue
    +            snapshot = CveReplaySnapshot(
    +                audit=audit,
    +                revision=prior.revision + 1 if prior else 1,
    +                watermark=watermark,
    +                checks=state.checks,
    +            )
    +            changed.append(snapshot)
    +            snapshots[audit.audit_id] = snapshot
    +        self._cve_commit(changed, records, now)
    +        state = self._cve_state(snapshots)
    +        return CveReplayRun(
    +            checked_at=now,
    +            audited_reports=len(audits),
    +            queried_commits=len(answers),
    +            checks=tuple(fresh),
    +            watermarks=state.watermarks,
    +            candidates=state.candidates(),
    +            trends=state.trends(),
    +        )
    +
    +    def cve_replay_candidates(self) -> CveReplayCandidates:
    +        return self._cve_state(self._cve_snapshots()).candidates()
    +
    +    def cve_replay_trends(self) -> CveReplayTrends:
    +        return self._cve_state(self._cve_snapshots()).trends()
    +
    +    def cve_replay_oracle(
    +        self,
    +        assessment_id: UUID,
    +        advisory: str,
    +        *,
    +        present_at_audit: bool | None = None,
    +        principal: Principal | None = None,
    +        presence_evidence: str | None = None,
    +    ) -> CveReplayCandidate:
    +        """Replay one source advisory, optionally recording a verified person's adjudication."""
    +        if present_at_audit is not None:
    +            if principal is None or not principal.is_verified_human():
    +                raise ForbiddenError("CVE replay presence requires a verified human caller")
    +            if presence_evidence is None:
    +                raise ValidationError("CVE replay presence requires supporting evidence")
    +            require_nonblank(presence_evidence, "CVE replay presence evidence")
    +        elif presence_evidence is not None:
    +            raise ValidationError("CVE replay presence evidence requires a presence verdict")
    +        bound = next((row for row in self._cve_audits() if row[0].audit_id == assessment_id), None)
    +        if bound is None:
    +            raise NotFoundError(f"CVE replay recorded audit {assessment_id}")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        record = exposure.find_advisory(AdvisoryIdentifier(advisory))
    +        if record is None:
    +            raise NotFoundError(f"CVE replay advisory {advisory}")
    +        audit, report = bound
    +        now = self._clock.now()
    +        published = record.published_at
    +        if published is None or not audit.audited_at < published <= now:
    +            raise ValidationError(
    +                f"CVE replay advisory {advisory}: publication must be known, strictly after "
    +                f"the audit ({audit.audited_at.isoformat()}) and no later than now"
    +            )
    +        check = CveReplayCandidate.classify(
    +            audit,
    +            "\n".join(report.text_fragments(sections=("findings", "negative_results"))),
    +            record,
    +            now,
    +            present_at_audit=present_at_audit,
    +            reviewer=principal.ref if principal and present_at_audit is not None else None,
    +            presence_identity_source=(
    +                principal.verified_by if principal and present_at_audit is not None else None
    +            ),
    +            presence_evidence=presence_evidence,
    +        )
    +        records = self._cve_records()
    +        prior = self._cve_snapshots(records).get(audit.audit_id)
    +        state = CveReplayState(checks=prior.checks if prior else ()).merged((check,))
    +        if prior is None or state.checks != prior.checks:
    +            self._cve_commit(
    +                (
    +                    CveReplaySnapshot(
    +                        audit=audit,
    +                        revision=prior.revision + 1 if prior else 1,
    +                        watermark=prior.watermark if prior else None,
    +                        checks=state.checks,
    +                    ),
    +                ),
    +                records,
    +                now,
    +            )
    +        return check
    +
    +    def _cve_audits(self) -> list[tuple[CveReplayAudit, ReportArtifact]]:
    +        records = self._log.documents(
    +            (a for kind in _AUDITS for a in self._log.list_of(kind)),
    +            [ReportArtifact.schema],
    +        )
    +        result = []
    +        seen = set()
    +        for assessment, artifact in records:
    +            if assessment.status != ASSESSMENT_COMPLETED or assessment.repository_ref_id is None:
    +                continue
    +            if assessment.id in seen:
    +                raise ValidationError(
    +                    f"CVE replay audit {assessment.id}: ambiguous recorded reports"
    +                )
    +            seen.add(assessment.id)
    +            ref = self._inventory.get_ref(assessment.repository_ref_id)
    +            repository = self._inventory.get_repository(ref.repository_id)
    +            assert assessment.id is not None and ref.id is not None and artifact.id is not None
    +            report = self._publisher.read(artifact.id, ReportArtifact)
    +            if report.metadata.repository != repository.url or report.metadata.commit != ref.sha:
    +                raise ValidationError(
    +                    f"CVE replay audit {assessment.id}: original report repository and commit "
    +                    "do not match its recorded ref"
    +                )
    +            result.append(
    +                (
    +                    CveReplayAudit(
    +                        repository_id=ref.repository_id,
    +                        repository_ref_id=ref.id,
    +                        repository=repository.url,
    +                        audited_commit=ref.sha,
    +                        audit_id=assessment.id,
    +                        report_artifact_id=artifact.id,
    +                        audited_at=assessment.occurred_at,
    +                    ),
    +                    report,
    +                )
    +            )
    +        return result
    +
    +    def _cve_records(self) -> list[tuple[Assessment, Artifact]]:
    +        return self._log.documents(
    +            self._log.list_of(AssessmentKind.CVE_REPLAY), [CveReplayArtifact.schema]
    +        )
    +
    +    def _cve_snapshots(
    +        self, records: Sequence[tuple[Assessment, Artifact]] | None = None
    +    ) -> dict[UUID, CveReplaySnapshot]:
    +        snapshots: dict[UUID, CveReplaySnapshot] = {}
    +        audits = {audit.audit_id: audit for audit, _ in self._cve_audits()}

    _cve_snapshots needs only audit metadata to bind snapshots, but it calls _cve_audits(), which reads and parses every SECURE_CODE report payload from the object store — so cve_replay() reads the whole corpus twice, and cve_replay_candidates()/trends()/oracle() re-read it on every call. Thread the already-fetched audits in as a parameter, as records already is.

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/detection_quality.py:1
    @@ -520,6 +548,286 @@ def calibrate(self, pack: RulePack, scans: Sequence[UUID]) -> Calibration:
                 novel_sample=_novel_sample(hits, truth),
             )
     
    +    def cve_replay(self, since: datetime | None = None) -> CveReplayRun:
    +        """Discover advisories on the exact recorded audits, without admitting their presence."""
    +        now = self._clock.now()
    +        if since is not None:
    +            require_aware_datetime(since, "CVE replay source watermark")
    +            if since > now:
    +                raise ValidationError("CVE replay source watermark must not be in the future")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        exposure.require_commit_advisories()
    +        audits = self._cve_audits()
    +        records = self._cve_records()
    +        snapshots = self._cve_snapshots(records)
    +        answers: dict[str, tuple[AdvisoryRecord, ...]] = {}
    +        pending: list[tuple[CveReplayAudit, tuple[CveReplayCandidate, ...]]] = []
    +        fresh: list[CveReplayCandidate] = []
    +        for audit, report in audits:
    +            prior = snapshots.get(audit.audit_id)
    +            lower = max(audit.audited_at, since or audit.audited_at)
    +            if lower > now or (prior and prior.watermark is not None and prior.watermark > now):
    +                raise ValidationError(f"CVE replay audit {audit.audit_id}: future watermark")
    +            if audit.audited_commit not in answers:
    +                answers[audit.audited_commit] = exposure.advisories_for_commit(
    +                    GitSha.parse(audit.audited_commit)
    +                )
    +            if any(row.published_at is None for row in answers[audit.audited_commit]):
    +                raise ValidationError(
    +                    f"CVE replay audit {audit.audit_id}: advisory publication is unknown"
    +                )
    +            text = "\n".join(report.text_fragments(sections=("findings", "negative_results")))
    +            checks: list[CveReplayCandidate] = []
    +            for advisory in answers[audit.audited_commit]:
    +                published = advisory.published_at
    +                if (
    +                    published is None
    +                    or published <= audit.audited_at
    +                    or not lower <= published <= now
    +                ):
    +                    continue
    +                check = CveReplayCandidate.classify(audit, text, advisory, now)
    +                if (
    +                    prior
    +                    and prior.watermark is not None
    +                    and published < prior.watermark
    +                    and any(old.same_advisory(check) for old in prior.checks)
    +                ):
    +                    continue
    +                checks.append(check)
    +            fresh.extend(checks)
    +            pending.append((audit, tuple(checks)))
    +        changed: list[CveReplaySnapshot] = []
    +        for audit, checks in pending:
    +            prior = snapshots.get(audit.audit_id)
    +            state = CveReplayState(checks=prior.checks if prior else ()).merged(checks)
    +            watermark = max(now, prior.watermark) if prior and prior.watermark else now
    +            if prior and state.checks == prior.checks and watermark == prior.watermark:

    watermark is always max(now, prior.watermark) = now (later watermarks are refused above), so the skip requires now == prior.watermark and effectively never fires — every run republishes a snapshot per audit, one new artifact + CVE_REPLAY assessment each, embedding the full accumulated checks list. Either drop watermark from the skip equality (same_advisory dedup already prevents re-checking) or make the per-run growth explicit.

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/portfolio.py:1
    @@ -515,49 +546,146 @@ def _liveness_of(self, repositories: Sequence[Repository]) -> list[Liveness]:
                 return []
             ids = [repository.id for repository in repositories if repository.id]
             now = self._clock.now()
    -        observations = self._assessment.population(
    -            now, AssessmentFilter(kind=AssessmentKind.REPO_STATE), ids
    -        ).rows
    -        latest = {row.latest.id: row for row in observations if row.latest}
    -        pushes = {
    -            latest[assessment.id].repository_id: (
    -                assessment.occurred_at,
    -                json.loads(document.payload).get("pushed_at"),
    -            )
    -            for assessment, document in self._require_publisher().documents(
    -                (row.latest for row in latest.values() if row.latest), RepoStateArtifact
    -            )
    -        }
    +        snapshot = self._require_publisher().latest(RepoLivenessArtifact)
    +        recorded = RepoLiveness.of(snapshot).repositories if snapshot is not None else {}
             unaudited = set(
                 self._assessment.population(
                     now,
                     AssessmentFilter(kind=AssessmentKind.SECURE_CODE, status=ASSESSMENT_COMPLETED),
                     ids,
                 ).never_assessed_repository_ids
             )
    -        return [
    -            self._liveness(repository, pushes, unaudited, now.date()) for repository in repositories
    -        ]
    +        rows = []
    +        for repository in repositories:
    +            assert repository.id is not None
    +            row = recorded.get(repository.id) or self._unqueried_liveness(repository, unaudited)
    +            row = self._completed_liveness(row, now)

    _completed_liveness runs an ops.list query plus a full manifest JSON parse per degraded/failed order, per repository, on every page render — the old listing was one population query plus one batched documents read, and no liveness case is in the perf suite. Batch the orders query across the page's repository ids, or persist the completed row when liveness is recorded.

    smith-xyz smith-xyz commented on code on Nov 10, 2026 18:03 UTC
    Code Review
    src/traust_core/v1/services/operations.py:1
    @@ -1133,13 +1164,50 @@ def record(self, event: SpendEvent) -> SpendEvent:
             # NEED(model-registry): check provider and model against ModelCatalog once it lands.
             with self._uow as uow:
                 order = None if event.run_order_id is None else uow.run_orders.get(event.run_order_id)
    -            saved = uow.spend_events.add(event.model_copy(update={"lane": order and order.lane}))
    +            repository_id = None
    +            if order is None:
    +                repository_id = self._repository_id(event)
    +            elif order.repository_id is not None:

    For a fleet-wide order (order.repository_id is None) the disagreement check is skipped and repository_id stays None, so the event's attested repository_id is silently overwritten in the saved row. Keep self._repository_id(event) in that branch, or refuse the mismatch as the repository-scoped case does.

    smith-xyz smith-xyz requested changes on Nov 10, 2026 18:03 UTC
    Changes Requested Reviewer

    first pass — 4 notes
    <!-- traust-first-pass -->

    gurnben gurnben commented on code on Nov 10, 2026 18:39 UTC
    Code Review
    src/traust_core/v1/services/detection_quality.py:1
    @@ -520,6 +548,286 @@ def calibrate(self, pack: RulePack, scans: Sequence[UUID]) -> Calibration:
                 novel_sample=_novel_sample(hits, truth),
             )
     
    +    def cve_replay(self, since: datetime | None = None) -> CveReplayRun:
    +        """Discover advisories on the exact recorded audits, without admitting their presence."""
    +        now = self._clock.now()
    +        if since is not None:
    +            require_aware_datetime(since, "CVE replay source watermark")
    +            if since > now:
    +                raise ValidationError("CVE replay source watermark must not be in the future")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        exposure.require_commit_advisories()
    +        audits = self._cve_audits()
    +        records = self._cve_records()
    +        snapshots = self._cve_snapshots(records)
    +        answers: dict[str, tuple[AdvisoryRecord, ...]] = {}
    +        pending: list[tuple[CveReplayAudit, tuple[CveReplayCandidate, ...]]] = []
    +        fresh: list[CveReplayCandidate] = []
    +        for audit, report in audits:
    +            prior = snapshots.get(audit.audit_id)
    +            lower = max(audit.audited_at, since or audit.audited_at)
    +            if lower > now or (prior and prior.watermark is not None and prior.watermark > now):
    +                raise ValidationError(f"CVE replay audit {audit.audit_id}: future watermark")
    +            if audit.audited_commit not in answers:
    +                answers[audit.audited_commit] = exposure.advisories_for_commit(
    +                    GitSha.parse(audit.audited_commit)
    +                )
    +            if any(row.published_at is None for row in answers[audit.audited_commit]):
    +                raise ValidationError(
    +                    f"CVE replay audit {audit.audit_id}: advisory publication is unknown"
    +                )
    +            text = "\n".join(report.text_fragments(sections=("findings", "negative_results")))
    +            checks: list[CveReplayCandidate] = []
    +            for advisory in answers[audit.audited_commit]:
    +                published = advisory.published_at
    +                if (
    +                    published is None
    +                    or published <= audit.audited_at
    +                    or not lower <= published <= now
    +                ):
    +                    continue
    +                check = CveReplayCandidate.classify(audit, text, advisory, now)
    +                if (
    +                    prior
    +                    and prior.watermark is not None
    +                    and published < prior.watermark
    +                    and any(old.same_advisory(check) for old in prior.checks)
    +                ):
    +                    continue
    +                checks.append(check)
    +            fresh.extend(checks)
    +            pending.append((audit, tuple(checks)))
    +        changed: list[CveReplaySnapshot] = []
    +        for audit, checks in pending:
    +            prior = snapshots.get(audit.audit_id)
    +            state = CveReplayState(checks=prior.checks if prior else ()).merged(checks)
    +            watermark = max(now, prior.watermark) if prior and prior.watermark else now
    +            if prior and state.checks == prior.checks and watermark == prior.watermark:
    +                continue
    +            snapshot = CveReplaySnapshot(
    +                audit=audit,
    +                revision=prior.revision + 1 if prior else 1,
    +                watermark=watermark,
    +                checks=state.checks,
    +            )
    +            changed.append(snapshot)
    +            snapshots[audit.audit_id] = snapshot
    +        self._cve_commit(changed, records, now)
    +        state = self._cve_state(snapshots)
    +        return CveReplayRun(
    +            checked_at=now,
    +            audited_reports=len(audits),
    +            queried_commits=len(answers),
    +            checks=tuple(fresh),
    +            watermarks=state.watermarks,
    +            candidates=state.candidates(),
    +            trends=state.trends(),
    +        )
    +
    +    def cve_replay_candidates(self) -> CveReplayCandidates:
    +        return self._cve_state(self._cve_snapshots()).candidates()
    +
    +    def cve_replay_trends(self) -> CveReplayTrends:
    +        return self._cve_state(self._cve_snapshots()).trends()
    +
    +    def cve_replay_oracle(
    +        self,
    +        assessment_id: UUID,
    +        advisory: str,
    +        *,
    +        present_at_audit: bool | None = None,
    +        principal: Principal | None = None,
    +        presence_evidence: str | None = None,
    +    ) -> CveReplayCandidate:
    +        """Replay one source advisory, optionally recording a verified person's adjudication."""
    +        if present_at_audit is not None:
    +            if principal is None or not principal.is_verified_human():
    +                raise ForbiddenError("CVE replay presence requires a verified human caller")
    +            if presence_evidence is None:
    +                raise ValidationError("CVE replay presence requires supporting evidence")
    +            require_nonblank(presence_evidence, "CVE replay presence evidence")
    +        elif presence_evidence is not None:
    +            raise ValidationError("CVE replay presence evidence requires a presence verdict")
    +        bound = next((row for row in self._cve_audits() if row[0].audit_id == assessment_id), None)
    +        if bound is None:
    +            raise NotFoundError(f"CVE replay recorded audit {assessment_id}")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        record = exposure.find_advisory(AdvisoryIdentifier(advisory))
    +        if record is None:
    +            raise NotFoundError(f"CVE replay advisory {advisory}")
    +        audit, report = bound
    +        now = self._clock.now()
    +        published = record.published_at
    +        if published is None or not audit.audited_at < published <= now:
    +            raise ValidationError(
    +                f"CVE replay advisory {advisory}: publication must be known, strictly after "
    +                f"the audit ({audit.audited_at.isoformat()}) and no later than now"
    +            )
    +        check = CveReplayCandidate.classify(
    +            audit,
    +            "\n".join(report.text_fragments(sections=("findings", "negative_results"))),
    +            record,
    +            now,
    +            present_at_audit=present_at_audit,
    +            reviewer=principal.ref if principal and present_at_audit is not None else None,
    +            presence_identity_source=(
    +                principal.verified_by if principal and present_at_audit is not None else None
    +            ),
    +            presence_evidence=presence_evidence,
    +        )
    +        records = self._cve_records()
    +        prior = self._cve_snapshots(records).get(audit.audit_id)
    +        state = CveReplayState(checks=prior.checks if prior else ()).merged((check,))
    +        if prior is None or state.checks != prior.checks:
    +            self._cve_commit(
    +                (
    +                    CveReplaySnapshot(
    +                        audit=audit,
    +                        revision=prior.revision + 1 if prior else 1,
    +                        watermark=prior.watermark if prior else None,
    +                        checks=state.checks,
    +                    ),
    +                ),
    +                records,
    +                now,
    +            )
    +        return check
    +
    +    def _cve_audits(self) -> list[tuple[CveReplayAudit, ReportArtifact]]:
    +        records = self._log.documents(
    +            (a for kind in _AUDITS for a in self._log.list_of(kind)),
    +            [ReportArtifact.schema],
    +        )
    +        result = []
    +        seen = set()
    +        for assessment, artifact in records:
    +            if assessment.status != ASSESSMENT_COMPLETED or assessment.repository_ref_id is None:
    +                continue
    +            if assessment.id in seen:
    +                raise ValidationError(
    +                    f"CVE replay audit {assessment.id}: ambiguous recorded reports"
    +                )
    +            seen.add(assessment.id)
    +            ref = self._inventory.get_ref(assessment.repository_ref_id)
    +            repository = self._inventory.get_repository(ref.repository_id)
    +            assert assessment.id is not None and ref.id is not None and artifact.id is not None
    +            report = self._publisher.read(artifact.id, ReportArtifact)
    +            if report.metadata.repository != repository.url or report.metadata.commit != ref.sha:
    +                raise ValidationError(
    +                    f"CVE replay audit {assessment.id}: original report repository and commit "
    +                    "do not match its recorded ref"
    +                )
    +            result.append(
    +                (
    +                    CveReplayAudit(
    +                        repository_id=ref.repository_id,
    +                        repository_ref_id=ref.id,
    +                        repository=repository.url,
    +                        audited_commit=ref.sha,
    +                        audit_id=assessment.id,
    +                        report_artifact_id=artifact.id,
    +                        audited_at=assessment.occurred_at,
    +                    ),
    +                    report,
    +                )
    +            )
    +        return result
    +
    +    def _cve_records(self) -> list[tuple[Assessment, Artifact]]:
    +        return self._log.documents(
    +            self._log.list_of(AssessmentKind.CVE_REPLAY), [CveReplayArtifact.schema]
    +        )
    +
    +    def _cve_snapshots(
    +        self, records: Sequence[tuple[Assessment, Artifact]] | None = None
    +    ) -> dict[UUID, CveReplaySnapshot]:
    +        snapshots: dict[UUID, CveReplaySnapshot] = {}
    +        audits = {audit.audit_id: audit for audit, _ in self._cve_audits()}

    Fixed in 5a27ce56: _cve_snapshots takes the already-fetched audits as a parameter, as records already did — cve_replay passes the audits it holds, and the oracle passes the ones it fetched for its binding. cve_replay_candidates()/trends() still fetch their own (they have no copy in hand). Regression: test_cve_replay_reads_the_report_corpus_once counts _cve_audits calls during a replay and asserts one.

    gurnben gurnben commented on code on Nov 10, 2026 18:39 UTC
    Code Review
    src/traust_core/v1/services/detection_quality.py:1
    @@ -520,6 +548,286 @@ def calibrate(self, pack: RulePack, scans: Sequence[UUID]) -> Calibration:
                 novel_sample=_novel_sample(hits, truth),
             )
     
    +    def cve_replay(self, since: datetime | None = None) -> CveReplayRun:
    +        """Discover advisories on the exact recorded audits, without admitting their presence."""
    +        now = self._clock.now()
    +        if since is not None:
    +            require_aware_datetime(since, "CVE replay source watermark")
    +            if since > now:
    +                raise ValidationError("CVE replay source watermark must not be in the future")
    +        exposure = self._require(self._exposure, "CVE replay advisory source")
    +        exposure.require_commit_advisories()
    +        audits = self._cve_audits()
    +        records = self._cve_records()
    +        snapshots = self._cve_snapshots(records)
    +        answers: dict[str, tuple[AdvisoryRecord, ...]] = {}
    +        pending: list[tuple[CveReplayAudit, tuple[CveReplayCandidate, ...]]] = []
    +        fresh: list[CveReplayCandidate] = []
    +        for audit, report in audits:
    +            prior = snapshots.get(audit.audit_id)
    +            lower = max(audit.audited_at, since or audit.audited_at)
    +            if lower > now or (prior and prior.watermark is not None and prior.watermark > now):
    +                raise ValidationError(f"CVE replay audit {audit.audit_id}: future watermark")
    +            if audit.audited_commit not in answers:
    +                answers[audit.audited_commit] = exposure.advisories_for_commit(
    +                    GitSha.parse(audit.audited_commit)
    +                )
    +            if any(row.published_at is None for row in answers[audit.audited_commit]):
    +                raise ValidationError(
    +                    f"CVE replay audit {audit.audit_id}: advisory publication is unknown"
    +                )
    +            text = "\n".join(report.text_fragments(sections=("findings", "negative_results")))
    +            checks: list[CveReplayCandidate] = []
    +            for advisory in answers[audit.audited_commit]:
    +                published = advisory.published_at
    +                if (
    +                    published is None
    +                    or published <= audit.audited_at
    +                    or not lower <= published <= now
    +                ):
    +                    continue
    +                check = CveReplayCandidate.classify(audit, text, advisory, now)
    +                if (
    +                    prior
    +                    and prior.watermark is not None
    +                    and published < prior.watermark
    +                    and any(old.same_advisory(check) for old in prior.checks)
    +                ):
    +                    continue
    +                checks.append(check)
    +            fresh.extend(checks)
    +            pending.append((audit, tuple(checks)))
    +        changed: list[CveReplaySnapshot] = []
    +        for audit, checks in pending:
    +            prior = snapshots.get(audit.audit_id)
    +            state = CveReplayState(checks=prior.checks if prior else ()).merged(checks)
    +            watermark = max(now, prior.watermark) if prior and prior.watermark else now
    +            if prior and state.checks == prior.checks and watermark == prior.watermark:

    Fixed in 5a27ce56, taking the first option: the watermark term is dropped from the skip equality — the skip is the checks' equality alone. You were right that it never fired: the run's watermark is always now (a later prior watermark is refused above), so equality held only on a same-instant retry. A no-change run now republishes nothing and leaves the stored watermark where it last published; the per-advisory published < prior.watermark fast path narrows to what the same_advisory merge then covers, so nothing is re-checked. Regression: test_an_unchanged_replay_does_not_republish_per_run runs a replay, advances the clock, re-runs with no newly published advisories and asserts the snapshot rows are unchanged (this test fails on the pre-fix code with a moving clock).

    gurnben gurnben commented on code on Nov 10, 2026 18:40 UTC
    Code Review
    src/traust_core/v1/services/portfolio.py:1
    @@ -515,49 +546,146 @@ def _liveness_of(self, repositories: Sequence[Repository]) -> list[Liveness]:
                 return []
             ids = [repository.id for repository in repositories if repository.id]
             now = self._clock.now()
    -        observations = self._assessment.population(
    -            now, AssessmentFilter(kind=AssessmentKind.REPO_STATE), ids
    -        ).rows
    -        latest = {row.latest.id: row for row in observations if row.latest}
    -        pushes = {
    -            latest[assessment.id].repository_id: (
    -                assessment.occurred_at,
    -                json.loads(document.payload).get("pushed_at"),
    -            )
    -            for assessment, document in self._require_publisher().documents(
    -                (row.latest for row in latest.values() if row.latest), RepoStateArtifact
    -            )
    -        }
    +        snapshot = self._require_publisher().latest(RepoLivenessArtifact)
    +        recorded = RepoLiveness.of(snapshot).repositories if snapshot is not None else {}
             unaudited = set(
                 self._assessment.population(
                     now,
                     AssessmentFilter(kind=AssessmentKind.SECURE_CODE, status=ASSESSMENT_COMPLETED),
                     ids,
                 ).never_assessed_repository_ids
             )
    -        return [
    -            self._liveness(repository, pushes, unaudited, now.date()) for repository in repositories
    -        ]
    +        rows = []
    +        for repository in repositories:
    +            assert repository.id is not None
    +            row = recorded.get(repository.id) or self._unqueried_liveness(repository, unaudited)
    +            row = self._completed_liveness(row, now)

    Fixed in 5a27ce56, the batching option: _completed_orders fetches the page's repositories' finished degraded/failed/refused repo_state orders in ONE indexed query — OrderFilter and the run-order search gained repository_ids (an IN beside the existing single-id path), unused on the REST wire since the orders endpoint builds its filter from individual query parameters (api-check re-run: no schema change). The per-order manifest parses remain (bounded by the actual degraded orders), folded per repository by _fold_completed. Regression: test_a_liveness_page_reads_completed_orders_in_one_query wraps ops.list over a three-repository page and asserts exactly one call carrying all three ids. Persisting the completed row stays open as the bigger design if the manifest parses ever show up hot.

    gurnben gurnben commented on code on Nov 10, 2026 18:40 UTC
    Code Review
    src/traust_core/v1/services/operations.py:1
    @@ -1133,13 +1164,50 @@ def record(self, event: SpendEvent) -> SpendEvent:
             # NEED(model-registry): check provider and model against ModelCatalog once it lands.
             with self._uow as uow:
                 order = None if event.run_order_id is None else uow.run_orders.get(event.run_order_id)
    -            saved = uow.spend_events.add(event.model_copy(update={"lane": order and order.lane}))
    +            repository_id = None
    +            if order is None:
    +                repository_id = self._repository_id(event)
    +            elif order.repository_id is not None:

    Fixed in 5a27ce56, your second option: the disagreement check now runs for EVERY ordered row — a fleet-wide order's event attesting a repository identity (explicit id, or a label that resolves) refuses with the same spend repository disagrees with its run order, because the schema's CHECK (run_order_id IS NULL OR repository_id IS NULL) leaves no room to preserve the attestation on an ordered row (your first option). What survives unchanged: an unresolvable label is supplied metadata, not identity — it rides along and the row stays unattributed, per the PR body's repository-less orders remain unattributed while supplied metadata/cost survives. Rollups still select the order's repository whenever an order is present. Changed test (per the standing policy): test_repositoryless_order_ignores_supplied_attribution_but_keeps_metadata → test_fleet_wide_order_spend_refuses_an_attested_repository (id and URL parametrizations now refuse) + test_fleet_wide_order_spend_keeps_unattributed_metadata (the ambiguous-label survival case); your note is the direction for the change.

    smith-xyz smith-xyz approved these changes on Nov 10, 2026 20:12 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    chubirka chubirka
    Labels
    risk: low confidence: 72.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 76.5% (HIGH) · Higher = larger blast radius
    76.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 72.5% · Lower = rushed or shallow review
    72.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21% · Safe to merge
    21%