Skip to content

feat(enterprise): assemble governed calibration bundles - #543

Merged
seonghobae merged 13 commits into
mainfrom
feat/enterprise-calibration-bundle
Aug 5, 2026
Merged

feat(enterprise): assemble governed calibration bundles#543
seonghobae merged 13 commits into
mainfrom
feat/enterprise-calibration-bundle

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a bounded fail-closed assembler from exact enterprise issue scoring executions into the existing shared ScoringFacetsCalibrationBundle
  • replay every issue/request/result/engine tuple through the accepted enterprise provenance boundary before shared bundle assembly
  • preserve criterion separation, task-revision and engine identity, connectedness policy, Rust-only psychometric arithmetic, and conservative validity/fairness/causal limits
  • add deterministic order-invariance, delegation, tuple-shape, resource-bound, public-export, documentation, and changelog coverage

Scope

This is the smallest post-#541 prerequisite slice for issue #404. It adds no enterprise-specific fit, report, ranking, utility, valuation, or decision schema and leaves fitting explicit through the existing fit_scoring_facets_bundle() API.

Closes no issue; advances #404.

Summary by CodeRabbit

  • New Features

    • Added an enterprise issue calibration bundle builder for assembling validated calibration data from scoring executions.
    • Added deterministic results, connected-design support, policy forwarding, and a documented execution limit.
    • Exposed the bundle builder and execution limit through the public enterprise issue package.
  • Documentation

    • Expanded guidance for execution replay, bundle assembly, validation responsibilities, and known statistical limitations.
  • Tests

    • Added coverage for ordering, malformed inputs, resource limits, metadata, mappings, exports, and validation errors.

@seonghobae
seonghobae marked this pull request as ready for review August 5, 2026 04:26
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 98002259-3142-4185-ad3d-36cc47720927

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds a governed enterprise issue calibration bundle assembler. It validates bounded execution tuples, replays provenance, creates shared rating records, delegates bundle validation, exposes public symbols, and adds deterministic and adversarial tests.

Changes

Enterprise issue calibration bundle

Layer / File(s) Summary
Bundle assembly and delegated validation
python/fast_mlsirm/scoring/enterprise_issue/calibration.py, docs/doctoring/enterprise-issue-facets-handoff.md, docs/enterprise_issue_facets_calibration_handoff.md
The assembler accepts bounded four-value execution tuples, replays each execution, builds shared rating records, and delegates bundle construction with require_connected.
Public API and behavioral verification
python/fast_mlsirm/scoring/enterprise_issue/__init__.py, tests/test_scoring_enterprise_issue_calibration_bundle.py, CHANGELOG.md, docs/changelog.d/enterprise-issue-calibration-bundle.md
The package exports the execution limit and bundle builder. Tests cover parity, order-independent fingerprints, delegation, malformed collections, tuple arity, and resource limits.
Handoff and scientific boundaries
docs/enterprise_issue_facets_calibration_handoff.md, docs/doctoring/enterprise-issue-facets-handoff.md
The handoff documents record and bundle adapters, validation gates, verification requirements, and limits on validity, model, and causal claims.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant EnterpriseIssueAdapter
  participant SharedCalibrationBuilder
  Caller->>EnterpriseIssueAdapter: Provide bounded execution tuples
  EnterpriseIssueAdapter->>EnterpriseIssueAdapter: Validate tuple shape and replay provenance
  EnterpriseIssueAdapter->>SharedCalibrationBuilder: Pass flattened rating records and policy
  SharedCalibrationBuilder-->>EnterpriseIssueAdapter: Return ScoringFacetsCalibrationBundle
  EnterpriseIssueAdapter-->>Caller: Return calibration bundle
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: assembling governed enterprise calibration bundles.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/enterprise-calibration-bundle

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/fast_mlsirm/scoring/enterprise_issue/calibration.py`:
- Around line 271-294: Update the calibration flow around the execution loop and
build_scoring_facets_calibration_bundle() to pass a lazy generator of
replay-validated records instead of materializing records with a list and
records.extend. Preserve tuple validation and record construction while ensuring
the shared builder enforces MAX_SCORING_FACETS_RATINGS before all derived
records are allocated, and add a regression test covering a small execution
limit with multiple records produced per execution.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f87c6b5-24c7-41be-ac5a-560ced5782d6

📥 Commits

Reviewing files that changed from the base of the PR and between a80a297 and d259a39.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • docs/changelog.d/enterprise-issue-calibration-bundle.md
  • docs/doctoring/enterprise-issue-facets-handoff.md
  • docs/enterprise_issue_facets_calibration_handoff.md
  • python/fast_mlsirm/scoring/enterprise_issue/__init__.py
  • python/fast_mlsirm/scoring/enterprise_issue/calibration.py
  • tests/test_scoring_enterprise_issue_calibration_bundle.py

Comment thread python/fast_mlsirm/scoring/enterprise_issue/calibration.py Outdated

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@opencode-agent @cwl-noema-review Final exact-head review requested for a1d11635818528a52d0c379958947d27e7e7806e. Verify that the bounded enterprise execution assembler replays every exact issue/request/result/engine tuple through build_enterprise_issue_facets_rating_records, lazily yields derived records so the shared rating bound stops allocation and later execution replay, and delegates unchanged to the existing ScoringFacetsCalibrationBundle builder. Confirm deterministic execution-order invariance, exact criterion/task-revision/rater/respondent provenance, strict tuple/resource/connectedness policy, no enterprise-specific fit/report/schema or psychometric arithmetic, complete public docstrings and focused 100% statement/branch coverage, APA 7 doctoring, and authoritative changelog parity. Do not approve or merge unless this exact head's CI, Rust/PyO3, package, GPU-no-skip, fuzz, Security Scan, SAST, unresolved-thread, independent-review, and repository-policy gates all pass.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

requested_sha="a1d11635818528a52d0c379958947d27e7e7806e"
echo "== Checked-out commit =="
git rev-parse HEAD
echo "== Requested commit availability =="
git cat-file -t "$requested_sha"
echo "== Commit metadata =="
git show -s --format='%H%n%P%n%s' "$requested_sha"

echo "== Changed files at requested commit =="
git diff-tree --no-commit-id --name-status -r "$requested_sha"

echo "== Implementation outline =="
ast-grep outline python/fast_mlsirm/scoring/enterprise_issue/calibration.py --items all --view expanded
echo "== Implementation =="
cat -n python/fast_mlsirm/scoring/enterprise_issue/calibration.py

echo "== Enterprise issue package exports =="
cat -n python/fast_mlsirm/scoring/enterprise_issue/__init__.py

echo "== Bundle assembler tests =="
cat -n tests/test_scoring_enterprise_issue_calibration_bundle.py

echo "== Shared bundle builder and record bounds references =="
rg -n -C 4 \
  'def (build_scoring_facets_calibration_bundle|build_enterprise_issue_facets_rating_records)|MAX_.*(RATING|CALIBRATION)|ScoringFacetsCalibrationBundle' \
  python tests

echo "== Documentation and changelog changes =="
git diff "$requested_sha^" "$requested_sha" -- \
  CHANGELOG.md \
  docs/changelog.d/enterprise-issue-calibration-bundle.md \
  docs/doctoring/enterprise-issue-facets-handoff.md \
  docs/enterprise_issue_facets_calibration_handoff.md

echo "== Pull request metadata, checks, reviews, and comments =="
gh pr view 543 --repo ContextualWisdomLab/fast-mlsirm --json headRefOid,statusCheckRollup,reviews,comments
echo "== Open review threads =="
gh api graphql -F owner=ContextualWisdomLab -F name=fast-mlsirm -F number=543 -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          comments(first: 10) { nodes { author { login } body path line } }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)'

Length of output: 76287


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Failed Python CI job log =="
gh run view 30975575201 --repo ContextualWisdomLab/fast-mlsirm --job 92208747655 --log-failed

echo "== Bounded collection implementation =="
ast-grep outline python/fast_mlsirm/scoring/_contract_safety.py --items all --view expanded
rg -n -A80 -B10 '^def bounded_values\b' python/fast_mlsirm/scoring/_contract_safety.py

echo "== Installed shared calibration validation boundary =="
sed -n '1,120p' python/fast_mlsirm/scoring/__init__.py
sed -n '300,360p' python/fast_mlsirm/scoring/_calibration_validation.py
sed -n '1100,1185p' python/fast_mlsirm/scoring/calibration.py

echo "== Full PR diff against merge base =="
base="$(git merge-base origin/main HEAD 2>/dev/null || git merge-base HEAD "$(
  gh pr view 543 --repo ContextualWisdomLab/fast-mlsirm --json baseRefOid --jq .baseRefOid
)")"
git diff --check "$base" HEAD
git diff --find-renames --stat "$base" HEAD
git diff --find-renames "$base" HEAD -- \
  CHANGELOG.md \
  docs/changelog.d/enterprise-issue-calibration-bundle.md \
  docs/doctoring/enterprise-issue-facets-handoff.md \
  docs/enterprise_issue_facets_calibration_handoff.md \
  python/fast_mlsirm/scoring/enterprise_issue/__init__.py \
  python/fast_mlsirm/scoring/enterprise_issue/calibration.py \
  tests/test_scoring_enterprise_issue_calibration_bundle.py

echo "== Test and coverage configuration =="
fd -HI '(^pyproject\.toml$|^pytest\.ini$|^setup\.cfg$|^tox\.ini$|^\.coveragerc$)' . -x sh -c 'echo "---- $1"; cat "$1"' sh {}

echo "== CI and repository-policy workflow definitions =="
fd -HI -t f .github/workflows -x sh -c 'echo "---- $1"; rg -n -C 3 "(python|rust|package|gpu|fuzz|Security|SAST|Noema|OpenCode|coverage|unresolved)" "$1"' sh {}

Length of output: 80080


@seonghobae I cannot approve this exact head.

python CI fails on tests/test_scoring_enterprise_issue_calibration_bundle.py, Line 229. The lazy replay test correctly proves that the second execution is not visited. However, it expects the wrong shared-boundary error:

  • Actual: invalid_records at $.records
  • Expected by the test: invalid_ratings at $.ratings

The installed build_scoring_facets_calibration_bundle() validation wrapper owns this bound. It materializes the lazy record generator through bounded_values(..., "records", ...). With a limit of one, the second record from the first execution raises invalid_records before the generator requests the next execution.

The implementation otherwise meets the requested boundary checks. It validates bounded exact tuples, replays each tuple through build_enterprise_issue_facets_rating_records, lazily yields shared records, forwards require_connected unchanged, and adds no enterprise-specific fit, report, schema, or psychometric arithmetic. The documentation and changelog are consistent. No unresolved review threads were returned.

Rust, package, GPU smoke, fuzz, CodeQL, SAST, Security Scan, Strix, Noema Review, and OpenCode Review passed. The failed Python gate blocks approval.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@opencode-agent @cwl-noema-review Final exact-head review requested for b4b579b43baade0732d877a8de7eaa85940cc822. Verify that the bounded enterprise execution assembler replays every exact issue/request/result/engine tuple through build_enterprise_issue_facets_rating_records, lazily yields derived records so the shared MAX_SCORING_FACETS_RATINGS boundary stops allocation and later execution replay, preserves the established invalid_records/$.records contract, and delegates unchanged to the existing shared calibration-bundle builder. Confirm the branch includes current main, deterministic order invariance, criterion/task-revision/rater/respondent provenance, strict tuple/resource/connectedness policy, no competing schema or psychometric arithmetic, complete public docs and focused statement/branch coverage, authoritative changelog parity, and no unresolved current-head finding. Do not approve or merge unless CI, Rust/PyO3, package, GPU-no-skip, fuzz, Security Scan, SAST, and repository-policy gates pass for this exact head.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/fast-mlsirm"
sha="b4b579b43baade0732d877a8de7eaa85940cc822"

echo "== Exact head =="
printf 'checked-out: '; git rev-parse HEAD
printf 'requested:   '; git rev-parse "$sha"
git show -s --format='commit=%H%nparents=%P%nsubject=%s' "$sha"

echo "== Includes current origin/main =="
git fetch origin main --quiet
main_sha="$(git rev-parse origin/main)"
printf 'origin/main: %s\n' "$main_sha"
if git merge-base --is-ancestor "$main_sha" "$sha"; then
  echo "includes_current_main=yes"
else
  echo "includes_current_main=no"
fi

echo "== Changed files from merge base =="
base="$(git merge-base origin/main "$sha")"
printf 'merge_base: %s\n' "$base"
git diff --check "$base" "$sha"
git diff --name-status "$base" "$sha"

echo "== Enterprise calibration module outline and relevant implementation =="
ast-grep outline python/fast_mlsirm/scoring/enterprise_issue/calibration.py --items all --view expanded
rg -n -A130 -B15 \
  '^(MAX_ENTERPRISE_ISSUE_CALIBRATION_EXECUTIONS|def build_enterprise_issue_facets_calibration_bundle|def build_enterprise_issue_facets_rating_records)' \
  python/fast_mlsirm/scoring/enterprise_issue/calibration.py

echo "== Shared boundary and bounded iterable implementation =="
rg -n -A100 -B15 \
  '^(MAX_SCORING_FACETS_RATINGS|def build_scoring_facets_calibration_bundle|def bounded_values)' \
  python/fast_mlsirm/scoring/calibration.py \
  python/fast_mlsirm/scoring/_contract_safety.py \
  python/fast_mlsirm/scoring/_calibration_validation.py

echo "== Package exports =="
cat -n python/fast_mlsirm/scoring/enterprise_issue/__init__.py

echo "== Focused bundle tests =="
cat -n tests/test_scoring_enterprise_issue_calibration_bundle.py

echo "== New documentation and changelog =="
git diff --find-renames "$base" "$sha" -- \
  CHANGELOG.md \
  docs/changelog.d/enterprise-issue-calibration-bundle.md \
  docs/doctoring/enterprise-issue-facets-handoff.md \
  docs/enterprise_issue_facets_calibration_handoff.md

echo "== Pull request head and check statuses =="
gh pr view 543 --repo "$repo" --json headRefOid,baseRefOid,statusCheckRollup,reviews \
  --jq '{headRefOid,baseRefOid,reviews:[.reviews[]|{author:.author.login,state}],checks:[.statusCheckRollup[]|{name,conclusion,status,workflowName}]}'

echo "== Unresolved non-outdated review threads =="
gh api graphql -F owner=ContextualWisdomLab -F name=fast-mlsirm -F number=543 -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          comments(first: 10) {
            nodes { author { login } body path line }
          }
        }
      }
    }
  }
}' --jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false and .isOutdated == false)]'

Length of output: 86754


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/fast-mlsirm"
sha="b4b579b43baade0732d877a8de7eaa85940cc822"

echo "== PR head and aggregate checks =="
gh pr view 543 --repo "$repo" --json headRefOid,statusCheckRollup --jq \
  '{headRefOid,checks:[.statusCheckRollup[]|{name,workflowName,status,conclusion,detailsUrl}]}'

echo "== Recent workflow runs for the exact head =="
gh run list --repo "$repo" --commit "$sha" --limit 100 \
  --json databaseId,name,status,conclusion,headSha,event,workflowName,url \
  --jq '.[] | {databaseId,name,workflowName,status,conclusion,headSha,event,url}'

echo "== Current unresolved non-outdated review threads =="
gh api graphql -F owner=ContextualWisdomLab -F name=fast-mlsirm -F number=543 -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          comments(first: 1) { nodes { author { login } body path line } }
        }
      }
    }
  }
}' --jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false and .isOutdated == false)]'

Length of output: 10590


@seonghobae I found no code-level blocker on exact head b4b579b43baade0732d877a8de7eaa85940cc822.

The branch includes current main. The assembler validates bounded exact tuples. It replays each tuple through build_enterprise_issue_facets_rating_records(). It lazily streams derived records to the shared bundle boundary. The shared rating bound preserves invalid_records at $.records and stops later execution replay. It forwards require_connected unchanged.

The implementation preserves deterministic order invariance and shared criterion, task-revision, respondent, and rater provenance. It adds no competing schema, fit logic, report logic, or psychometric arithmetic. The public exports, docstrings, doctoring, and changelog are consistent. There are no unresolved current-head review threads.

I cannot approve yet. The exact-head python, rust, gpu-smoke, fuzz, package, and Strix Security Scan gates are still in progress. The completed CodeQL, SAST, Security Scan, OpenCode Review, Noema Review, and repository-policy gates succeeded.

You are interacting with an AI system.

@seonghobae
seonghobae merged commit 84f3251 into main Aug 5, 2026
33 checks passed
@seonghobae
seonghobae deleted the feat/enterprise-calibration-bundle branch August 5, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant