Skip to content

fix(validation): preserve representable recovery metrics - #488

Draft
seonghobae wants to merge 828 commits into
fix/central-hourly-admission-contractfrom
fix/validation-bias-overflow-safe-mean
Draft

fix(validation): preserve representable recovery metrics#488
seonghobae wants to merge 828 commits into
fix/central-hourly-admission-contractfrom
fix/validation-bias-overflow-safe-mean

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Validation Evidence authority

#488 remains the owner-correct Validation Evidence landing vehicle, stacked on prerequisite #492@794ba9e6dda9f043aa499920fdf609b81b075d7e; protected release authority remains main@a243f18da4a4ca8a8d068c39922537f1f8ed6ad0. Current exact head is 01ca3088b4a4bc514a441c4ab8ca4430219ab9e9. The PR remains Draft/open/mergeable. No force update, destructive rebase, self-approval, gate weakening, coverage exclusion, mutable sibling dependency, copied provider routing, or copied generalized psychometric owner logic is used.

Production validation_core::bias_standard_error still keeps bounded represented-input exact admission for n=3..=16; n=2 retains its direct identity and n>16 remains characterization-only under #491. Reusable generalized/static psychometric arithmetic remains fast-mlsirm-owned. Semantic LLM routing remains contextual-orchestrator-owned through an immutable released contract only.

New large-sample reference characterization

Exact head 01ca3088... adds crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs as a public fallback reference baseline for future #491 admission work. It does not widen production admission and is not an independent scientific oracle.

The fixture uses n=2,047 with one zero residual and 2,046 identical nonzero residuals. For gap = f64::from_bits(0x4330_0000_0000_0001) = 2^52+1, the exact two-level identity is SE(mean)=|gap|/2047; the nearest binary64 is asserted bitwise as 0x4280_0200_4008_0101. The zero anchor is placed at indices 0, 1_023, and 2_046, and each case is evaluated twice to preserve permutation and repeat-determinism evidence. A second specimen uses gap=2^-1074 and requires public InvalidInput, preserving false-zero refusal because the exact positive SE is below the half-minimum-subnormal boundary.

A focused CodeRabbit review on the exact current head found no scientific or determinism defect in this scope. It independently confirmed the binary64 literal, exact two-level identity, unique nearest expected result (not a midpoint tie), anchor-position permutation specimens, minimum-subnormal refusal, and that n=2,047 continues to delegate to the established fallback rather than widening the n=3..=16 exact-proof route. Technical bot review does not substitute for the organization-required approving GitHub review.

RED -> repair -> exact-head GREEN evidence

The new test initially exposed quality-gate REDs rather than being allowed to bypass them. The formatting mismatch was repaired until cargo fmt --all -- --check passed. The next exact-head run then failed Clippy; the only scientific expression changed afterward was the generic integer-to-f64 construction of 2^52+1, replaced by its exact binary64 bit pattern f64::from_bits(0x4330_0000_0000_0001). On 01ca3088..., formatting and Clippy are both GREEN, establishing the causal repair without suppressing lints.

Exact-head run authority on 01ca3088...:

  • Documentation Quality 34515053132: GREEN.
  • Bias SE Exact-Proof Budget 34515053109: GREEN. Immutable artifact 10167332804, bias-se-proof-budget-01ca3088b4a4bc514a441c4ab8ca4430219ab9e9, digest sha256:eb274cedd6b3b40d4a558755af900e42a0f4869b754252faf0d37be645f25acc.
  • Rust Foundation 34515053075: RED only in the owned-production 100% line/branch coverage job. Live PostgreSQL, repository/Python contracts plus SBOM/provenance, rustfmt, Clippy, no-retry test suite, doctests, warning-free rustdoc, and dependency/license/advisory/source policy are GREEN on the same exact head.
  • Current exact-head coverage artifacts are line 10167422485 (sha256:b9043630f0dd6e87b35bb2d8fd296e20593b551b72d9ac767b2146a4b70fc107) and branch 10167481107 (sha256:10b3ef144a15c6e2e998a6cdb21dc3f0709fe4d8760f30ee622a4e7da298e2b8). Both 100% enforcement steps remain RED. Do not claim a coverage reduction from this test until those exact artifact payloads are folded under scripts/check_coverage.py authority.

The last fully parsed production coverage frontier remains the predecessor source authority: 4,449/4,452 branch arms with 3 missing outcomes, all in bias.rs (68-69 positive-SE false-zero refusal, 148 target-usize rational-denominator guard, 589-590 translated nonpositive-dispersion refusal), plus bias_se.rs:307 as a separate unexecuted terminal four-step correction exhaustion line rather than a branch miss. This head changes tests only, not production arithmetic or the coverage denominator; nevertheless exact-current artifact counts are not promoted without parsing the current artifacts.

Resource evidence and #491 boundary

The isolated n=2,047, diameter=2^58+1 resource harness remains characterization evidence. Candidate and fallback run in separate /usr/bin/time -v processes on the identical deterministic geometry, preventing process-RSS attribution leakage. The previously verified specimen records candidate p95 23,306 ns, max RSS 2,176 kB, zero pair-record scratch versus fallback p95 15,385,815 ns, max RSS 100,152 kB, 2,094,081 pair records / 100,515,888 bytes explicit scratch. These are specimen-specific kernel/process measurements, not a portable performance guarantee and not buyer-facing HTTP p95.

The new reference contract closes part of #491's evidence gap for one n=2,047 two-level geometry: bitwise represented-result identity, three anchor-position permutation specimens, repeated determinism, and minimum-subnormal refusal. It does not justify general n>16 admission. Wider production admission still requires a defined admitted domain, deterministic/reference/refusal/permutation evidence over that domain, applicable release CPU/allocator/RSS and buyer-path latency evidence, exact-current-head 100% authored production line+branch coverage, qualifying independent current-head review, code-current TRACEABILITY/product-technical-gap authority, normal #492 prerequisite landing, and immutable released owner contracts.

bias_se.rs:307 also remains a bounded-resource refusal. Candidate/midpoint comparisons are total, but no complete proof yet bounds the actual rounded seed to the correct binary64 interval within a small number of adjacent corrections across integer conversion, division, sqrt, power-of-two restoration, subnormal transition, and maximum-finite boundary. Do not replace the fixed cap with an unbounded loop or return an unverified candidate.

Review / foundation boundary

Organization ruleset 18156473 requires qualifying approval, stale-review dismissal after pushes, review-thread resolution, central required workflows, and non-fast-forward protection. Administrative bypass is not delivery evidence and is not used. #492 remains intentionally Draft at exact 794ba9e6dda9f043aa499920fdf609b81b075d7e; .github#2038 and contextual-orchestrator #1023/#1083 remain the canonical owner path for a released orchestrator/free Actions contract. TEPP must not copy unpublished provider routing/credentials/model selection or consume mutable contextual-orchestrator source as production authority.

Before protected merge, require one exact current head with owned-production 100% authored line+branch coverage, current Rust/security/documentation/review gates, truthful route telemetry, code-current TRACEABILITY/product-technical-gap authority, normal foundation landing, immutable released dependency contracts, rollback/recovery/release evidence where applicable, and qualifying independent review.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@seonghobae seonghobae changed the title fix(validation): preserve representable extreme bias fix(validation): preserve representable recovery metrics Sep 3, 2026
seonghobae added a commit that referenced this pull request Sep 4, 2026
Non-force restack of PR #488 onto protected main after #490. Preserves the complete Validation Evidence lineage while inheriting the centralized hourly-development workflow unchanged.
Add crate-level scientific contracts for the power-scale bias-SE rounding,
nonnegative RMSE-summary support, and zero-multiplier exact-recovery
regressions exposed by exact-head line/branch coverage compilation.

No numerical implementation, fixture, expected bit pattern, skip/xfail, or
coverage denominator changes.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Audit the exact-bias integration crates that participate in line/branch coverage and add crate-level scientific contracts to thirteen remaining files. The docs record represented-input pair-distance, single-rounding, permutation/sign, subtraction-roundoff, and fail-closed underflow invariants without changing fixtures, expected bits, numerical code, skips, or coverage denominators.

This prevents coverage compilation from serially discovering the same missing-doc root cause one crate at a time.

Signed-off-by: Seongho Bae <me@seonghobae.me>
seonghobae added a commit that referenced this pull request Sep 6, 2026
Refresh the checked-in operator register after the #488 root-cause rustdoc audit. Preserve protected-main and owner boundaries, distinguish hosted RED from proactive source-audit repair, and keep current exact-head queued checks from being promoted to GREEN.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Add scientific crate-level contracts for the two integration tests identified by exact-head stable and nightly coverage compilation: RMSE percentile support and overflow-safe bias moments. Preserve behavior, fixtures, expected results, and coverage denominators.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Add scientific crate-level contracts for the stable coverage scale-underflow acceptance regression and the nightly Monte Carlo percentile moment-support regression observed on Rust Foundation 34056254247. Preserve fixtures, expected decisions, production arithmetic, coverage denominators, and fail-closed behavior.

The scale-underflow file also carries the exact Rust 1.98.0 formatting material from same-head Validation Rustfmt Evidence run 34056251889.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair exact-head Rust Foundation coverage REDs by documenting ValidationReport projection invariants and overflow/subnormal RMSE evidence contracts. Preserve numerical implementation, fixtures, expected decisions, coverage denominators, and fail-closed behavior.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair the next exact-head stable/nightly coverage REDs by documenting nonzero correction collisions, zero-RMSE uncertainty coherence, and the strictly positive all-covered Wilson lower bound. Preserve numerical implementation, fixtures, expected decisions, coverage denominators, and fail-closed projection behavior.

The equal-nonzero-correction contract also carries its exact Rust 1.98.0 formatting material from b9792 current-head evidence.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair exact-head stable/nightly coverage REDs by documenting two-replication percentile exhaustion and large-z exact-count Wilson rounding. Preserve numerical implementation, fixtures, expected bits, coverage denominators, and fail-closed evidence semantics.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair current exact-head stable coverage -D missing-docs RED without changing fixtures, numerical behavior, or fail-closed report semantics.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair current exact-head nightly -D missing-docs RED, apply its exact Rust 1.98.0 formatter material, and state that n>16 source-copy arithmetic is characterization rather than independent admission evidence.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair exact-head stable coverage -D missing-docs RED and carry the same-head Rust 1.98.0 formatter material for this file without changing the estimator or fixtures.

Signed-off-by: Seongho Bae <me@seonghobae.me>
Repair exact-head nightly -D missing-docs RED without changing the v1 schema, fixtures, projection checks, or fail-closed deserialization semantics.

Signed-off-by: Seongho Bae <me@seonghobae.me>
@seonghobae seonghobae added bug Something isn't working priority: medium labels Sep 6, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Contributor Author

@coderabbitai review exact a68055f108fc30b9b56348e8a5381ab436c813b3 resource-evidence slice only. Please verify that bias_se_resource_isolation.rs measures candidate and fallback in separate processes on the same deterministic odd-dyadic n=2047 geometry, preserves exact-result identity, does not widen production admission, and that .github/workflows/bias-se-proof-budget.yml binds evidence to the PR head, keeps 25 samples, read-only permissions/pinned actions, and reports candidate/fallback RSS without attributing the combined-process RSS. Treat any provenance, resource-comparison, overflow, misleading-evidence, or reproducibility defect as actionable. Do not suggest provider/model routing, coverage exclusion, sample reduction, private artificial scientific fixtures, or n>16 activation.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='a68055f108fc30b9b56348e8a5381ab436c813b3'
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"

echo '== Exact commit identity =='
git rev-parse HEAD
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"
echo '== Focused changed paths =='
git diff --name-status "$parent" "$head"
echo '== Focused diff =='
git diff --find-renames --unified=120 "$parent" "$head" -- \
  crates/validation_core/tests/bias_se_resource_isolation.rs \
  .github/workflows/bias-se-proof-budget.yml \
  crates/validation_core/src/bias_se.rs \
  Cargo.toml

echo '== Resource-isolation test outline and contents =='
ast-grep outline crates/validation_core/tests/bias_se_resource_isolation.rs \
  --items all --type function,struct,enum,impl 2>/dev/null || true
cat -n crates/validation_core/tests/bias_se_resource_isolation.rs

echo '== Relevant test symbols and process invocations =='
rg -n -C 20 --type rust \
  '\b(candidate|fallback|child|Command|process|2047|odd|dyadic|exact|to_bits|bias_standard_error|wide|rss|sample)\b' \
  crates/validation_core/tests/bias_se_resource_isolation.rs crates/validation_core

echo '== Exact workflow =='
cat -n .github/workflows/bias-se-proof-budget.yml
echo '== Workflow security, provenance, measurement, and labels =='
rg -n -C 10 \
  'permissions:|contents: read|actions/checkout@|actions/upload-artifact@|persist-credentials|EVIDENCE_SHA|pull_request\.head\.sha|github\.sha|git rev-parse|25|sample|isolation|candidate|fallback|RSS|rss|allocator|time -v|artifact' \
  .github/workflows/bias-se-proof-budget.yml

echo '== Harness definitions and workflow target references =='
rg -n -C 16 --type rust \
  '\b(bias_se_exact_proof_budget|bias_se_resource_isolation|hybrid_narrow_wide_pair|buffered_quadratic|two_pass_quadratic)\b' \
  crates Cargo.toml

echo '== Production admission boundaries =='
rg -n -C 18 --type rust \
  '\b(pub )?fn bias_standard_error\b|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error' \
  crates/validation_core/src/bias_se.rs crates/validation_core/src/bias.rs

echo '== Exact-head workflow runs =='
gh api "repos/${repo}/actions/runs?head_sha=${head}&per_page=100" \
  --jq '.workflow_runs[] | {id,name,event,status,conclusion,head_sha,head_branch,path,created_at,updated_at}'
echo '== Exact-head check runs =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}'
echo '== PR state =='
gh pr view 488 --repo "$repo" --json headRefOid,isDraft,state,mergeStateStatus,statusCheckRollup \
  --jq '{headRefOid,isDraft,state,mergeStateStatus,checks:[.statusCheckRollup[]|{name,status,conclusion,detailsUrl}]}'

Length of output: 3571


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='a68055f108fc30b9b56348e8a5381ab436c813b3'
parent='6b00d719566b074d2c0b14066efb65eaa8fa296b'
example='crates/validation_core/examples/bias_se_resource_isolation.rs'
workflow='.github/workflows/bias-se-proof-budget.yml'

echo '== Exact example diff and full source =='
git diff --find-renames --unified=160 "$parent" "$head" -- "$example"
ast-grep outline "$example" --items all --type function,struct,enum,impl 2>/dev/null || true
cat -n "$example"

echo '== Workflow source =='
cat -n "$workflow"

echo '== Example and workflow introduction history =='
git log --reverse --format='%H %P %s' -- "$example" "$workflow"
echo '== All changes to the focused files through exact head =='
git log --reverse --format='%H %s' -- "$example" "$workflow" | while read -r sha rest; do
  echo "----- $sha $rest -----"
  git show --format= --find-renames --unified=80 "$sha" -- "$example" "$workflow"
done

echo '== Exact process, geometry, identity, and measurement references =='
rg -n -C 14 --type rust \
  '\b(Command|args|--child|candidate|fallback|2047|odd|dyadic|to_bits|assert_eq|bias_standard_error|hybrid_narrow_wide_pair|buffered_quadratic|two_pass_quadratic)\b' \
  "$example" crates/validation_core/examples crates/validation_core/src

echo '== Exact workflow evidence controls =='
rg -n -C 12 \
  'permissions:|contents: read|actions/checkout@|actions/upload-artifact@|persist-credentials|EVIDENCE_SHA|pull_request\.head\.sha|github\.sha|git rev-parse|25|sample|isolation|candidate|fallback|RSS|rss|allocator|time -v|artifact' \
  "$workflow"

echo '== Production admission source =='
rg -n -C 18 --type rust \
  '\bpub fn bias_standard_error\b|match\s+.*len|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error' \
  crates/validation_core/src/bias_se.rs crates/validation_core/src/bias.rs

echo '== Exact-head Actions workflow runs =='
gh api "repos/${repo}/actions/runs?head_sha=${head}&per_page=100" \
  --jq '.workflow_runs[] | {id,name,event,status,conclusion,head_sha,head_branch,path,run_attempt,created_at,updated_at}'

echo '== Jobs and artifacts for proof-budget runs on the exact head =='
for id in $(gh api "repos/${repo}/actions/runs?head_sha=${head}&per_page=100" --jq '.workflow_runs[] | select(.path == ".github/workflows/bias-se-proof-budget.yml") | .id'); do
  echo "----- run $id -----"
  gh api "repos/${repo}/actions/runs/${id}/jobs?per_page=100" \
    --jq '.jobs[] | {id,name,status,conclusion,head_sha,started_at,completed_at,steps:[.steps[]|{number,name,status,conclusion}]}'
  gh api "repos/${repo}/actions/runs/${id}/artifacts?per_page=100" \
    --jq '.artifacts[] | {id,name,size_in_bytes,expired,created_at,updated_at,expires_at,digest,workflow_run:{id:.workflow_run.id,head_sha:.workflow_run.head_sha,head_branch:.workflow_run.head_branch}}'
done

echo '== Exact-head check runs and PR state =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}'
gh pr view 488 --repo "$repo" --json headRefOid,isDraft,state,mergeStateStatus,statusCheckRollup \
  --jq '{headRefOid,isDraft,state,mergeStateStatus,checks:[.statusCheckRollup[]|{name,status,conclusion,detailsUrl}]}'

Length of output: 203775


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='a68055f108fc30b9b56348e8a5381ab436c813b3'
example='crates/validation_core/examples/bias_se_resource_isolation.rs'
artifact='10163932916'

echo '== Complete exact resource-isolation example =='
git show "${head}:${example}" | nl -ba

echo '== Exact example change =='
git show --format=fuller --find-renames --unified=120 "$head" -- "$example"

echo '== Focused structural calls from the example =='
ast-grep run --lang rust \
  --pattern 'Command::new($$$)' "$example" 2>/dev/null || true
ast-grep run --lang rust \
  --pattern 'bias_standard_error($$$)' "$example" 2>/dev/null || true

echo '== Immutable artifact file list and contents =='
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
gh api --header 'Accept: application/vnd.github+json' \
  "repos/${repo}/actions/artifacts/${artifact}/zip" > "${tmpdir}/artifact.zip"
unzip -Z1 "${tmpdir}/artifact.zip" | sort
unzip -p "${tmpdir}/artifact.zip" \
  'candidate.csv' 'fallback.csv' 'isolated-rss-summary.csv' \
  'process-resource.txt' 'candidate-process-resource.txt' 'fallback-process-resource.txt' \
  'environment.txt' 'SHA256SUMS'

echo '== Artifact digest recheck =='
sha256sum "${tmpdir}/artifact.zip"
gh api "repos/${repo}/actions/artifacts/${artifact}" \
  --jq '{id,name,digest,expired,workflow_run:{id:.workflow_run.id,head_sha:.workflow_run.head_sha}}'

Length of output: 31244


@seonghobae Review complete for exact head a68055f108fc30b9b56348e8a5381ab436c813b3.

I found no finding in the requested resource-evidence scope.

  • crates/validation_core/examples/bias_se_resource_isolation.rs runs one selected kernel per process. The workflow invokes candidate 25 and fallback 25 in separate /usr/bin/time -v commands.
  • Both modes use the same deterministic odd-dyadic fixture: n = 2,047, with one zero and 2,046 copies of 2^58 + 1.
  • Both modes assert the same exact pair-square sum. The candidate takes the narrow_wide_candidate path. The fallback takes the buffered narrow_pair_fallback path.
  • The candidate output reports zero scratch records and zero scratch payload bytes. The fallback output reports 2,094,081 scratch records and 100,515,888 scratch payload bytes.
  • The artifact records isolated RSS separately: candidate 2,176 kB; fallback 100,152 kB. isolated-rss-summary.csv labels these values by mode.
  • The artifact also retains the 124,708 kB combined-process RSS from bias_se_exact_proof_budget. The workflow does not label this value as candidate-path RSS.
  • The workflow binds EVIDENCE_SHA to github.event.pull_request.head.sha || github.sha, checks out that ref with persist-credentials: false, and fails if git rev-parse HEAD differs from EVIDENCE_SHA.
  • The workflow uses contents: read, pinned checkout and upload actions, and 25 timing samples for each isolated mode.
  • Run 34506253098 completed successfully on the requested head. Artifact 10163932916 is SHA-bound to that head. Its verified digest is sha256:c04be3bb134fc22e780d9551329bb037f2985710ac6f52b2a86d6645b7f68760.
  • The n=2,047 fixture exists only in the characterization example. Production bias_standard_error still limits its exact route to n=3..=16 and delegates other sizes to crate::bias::bias_standard_error.

Rust Foundation remains in progress on this exact head. This review does not replace the pending required checks.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review exact current head a68055f108fc30b9b56348e8a5381ab436c813b3 focusing only on the remaining authored line crates/validation_core/src/bias_se.rs:307 and the exact-rounding termination argument.

Current exact-head authority is now terminal: Rust Foundation 34506253181 is RED only at authored production line/branch coverage; branch artifact 10164093741 (sha256:dd432232767c479ca18a08f2eeb1e4a9ca78158ab666d7371ab68b09df2d8bfe) folds to 4,449/4,452 arms with the same three bias.rs misses, and line artifact 10164033659 (sha256:c30a0e423f3db45a322b79396c8fedfeb186dc0627f559cc6a68df74e18c783f) has only bias.rs:69, bias.rs:590, and bias_se.rs:307 as zero-count authored source lines.

Please verify or refute this candidate source invariant before any mutation: in correctly_rounded_scaled_sqrt_ratio, the exact dyadic-square comparison determines the correct direction relative to the positive target root. A neighbor_is_closer step moves exactly one adjacent positive finite binary64 value in that direction. If the target lies below the minimum positive value or above the maximum finite value, the existing bits == 1 / non-finite-neighbor exits already fail closed. Otherwise the ordered finite binary64 set is finite, each continued step is strictly monotone toward the correctly rounded target interval, midpoint equality retains ties-to-even, and there is no oscillation. Under that argument the arbitrary for _ in 0..4 exhaustion None is not a scientific refusal boundary; a verified monotone loop could preserve fail-closed boundary exits while eliminating the unproved four-step cap and the uncovered terminal line.

Treat termination, denial-of-service/resource bounds, subnormal transitions, overflow/underflow boundaries, midpoint/ties-to-even, or a possible direction reversal as actionable counterexamples. Do not recommend returning an unverified candidate, weakening coverage, adding private/artificial coverage fixtures, widening n>16, or changing provider/dependency contracts.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='a68055f108fc30b9b56348e8a5381ab436c813b3'
src='crates/validation_core/src/bias_se.rs'

echo '== Exact identity =='
git rev-parse HEAD
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"

echo '== Source map =='
ast-grep outline "$src" --items all --type function,struct,enum,impl

echo '== Exact rounder, helpers, and bounded route =='
git show "${head}:${src}" | nl -ba | sed -n '1,390p'
git show "${head}:${src}" | nl -ba | sed -n '390,680p'

echo '== All exact call sites and relevant tests =='
git grep -n -C 30 -E \
  '\b(correctly_rounded_scaled_sqrt_ratio|compare_scaled_ratio_to_dyadic_square|adjacent_midpoint|neighbor_is_closer|positive_finite_dyadic|bias_standard_error|exact_pair_distance_standard_error)\s*\(' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Relevant full test files =='
git ls-tree -r --name-only "$head" -- crates/validation_core/tests |
  grep -Ei '(bias.*(round|dyadic|midpoint|ratio|pair|standard)|standard.*error)' |
  sort |
  while IFS= read -r f; do
    echo "----- $f -----"
    git show "${head}:${f}" | nl -ba
  done

echo '== History of correction loop and exact-comparison implementation =='
git log --reverse --format='%H %P %s' -- "$src"
git log -G 'for _ in 0\.\.4|neighbor_is_closer|correctly_rounded_scaled_sqrt_ratio' \
  --format='%H %P %s' -- "$src"
git show --find-renames --unified=100 18822bc8744e09f2ccc4adaccd34ae40ba006e62 -- "$src"

echo '== Exact head check and artifact metadata =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}'
gh api "repos/${repo}/actions/artifacts/10164093741" \
  --jq '{id,name,digest,expired,workflow_run:{id:.workflow_run.id,head_sha:.workflow_run.head_sha}}'
gh api "repos/${repo}/actions/artifacts/10164033659" \
  --jq '{id,name,digest,expired,workflow_run:{id:.workflow_run.id,head_sha:.workflow_run.head_sha}}'

Length of output: 2660


🏁 Script executed:

#!/bin/bash
set -uo pipefail

repo='ContextualWisdomLab/TEPP'
head='a68055f108fc30b9b56348e8a5381ab436c813b3'
src='crates/validation_core/src/bias_se.rs'

echo '== Source map =='
ast-grep outline "$src" --items all --type function,struct,enum || true

echo '== Exact rounder, helpers, and bounded route =='
git show "${head}:${src}" | nl -ba | sed -n '1,390p'
git show "${head}:${src}" | nl -ba | sed -n '390,680p'

echo '== All exact call sites and relevant tests =='
git grep -n -C 30 -E \
  '\b(correctly_rounded_scaled_sqrt_ratio|compare_scaled_ratio_to_dyadic_square|adjacent_midpoint|neighbor_is_closer|positive_finite_dyadic|bias_standard_error|exact_pair_distance_standard_error)\s*\(' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Relevant full test files =='
git ls-tree -r --name-only "$head" -- crates/validation_core/tests |
  grep -Ei '(bias.*(round|dyadic|midpoint|ratio|pair|standard)|standard.*error)' |
  sort |
  while IFS= read -r f; do
    echo "----- $f -----"
    git show "${head}:${f}" | nl -ba
  done

echo '== History of correction loop and exact-comparison implementation =='
git log -G 'for _ in 0\.\.4|neighbor_is_closer|correctly_rounded_scaled_sqrt_ratio' \
  --format='%H %P %s' -- "$src" || true
git show --find-renames --unified=100 18822bc8744e09f2ccc4adaccd34ae40ba006e62 -- "$src" || true

echo '== Exact head check and artifact metadata =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}' || true
gh api "repos/${repo}/actions/artifacts/10164093741" \
  --jq '{id,name,digest,expired,workflow_run:{id:.workflow_run.id,head_sha:.workflow_run.head_sha}}' || true
gh api "repos/${repo}/actions/artifacts/10164033659" \
  --jq '{id,name,digest,expired,workflow_run:{id:.workflow_run.id,head_sha:.workflow_run.head_sha}}' || true

Length of output: 119223


@seonghobae Review complete for exact head a68055f108fc30b9b56348e8a5381ab436c813b3.

I found one actionable limitation in the proposed invariant.

The invariant proves directionality after a valid correction step.

  • The exact dyadic-square comparison orders a positive candidate against the positive target root.
  • If the target is above the candidate, the upward neighbor is the only possible closer neighbor.
  • If the target is below the candidate, the downward neighbor is the only possible closer neighbor.
  • The midpoint comparison correctly stops at the nearest interval boundary.
  • Midpoint equality retains ties-to-even.
  • The bits == 1 and non-finite-neighbor exits preserve the lower and upper fail-closed boundaries.
  • Therefore, a continued step cannot reverse direction or oscillate.

However, monotonicity over a finite binary64 set does not provide an acceptable resource bound.

The set contains far too many ordered finite values to justify an unbounded correction loop. The proposed argument does not prove a maximum distance between the initial seed

((numerator as f64) / (denominator as f64)).sqrt() * unit

and the correctly rounded target interval. It must account for numerator conversion, division, square root, final scaling, normal/subnormal transitions, and the zero or infinity seed exits.

Without that bound, replacing for _ in 0..4 with an unbounded monotone loop removes a fixed denial-of-service and resource limit. It also changes Line 307 from a fail-closed resource boundary into potentially unbounded work.

Keep the four-pass None at crates/validation_core/src/bias_se.rs Line 307. Remove it only after a complete caller-domain proof establishes a small correction bound from the actual seed to the target rounding interval. The proof must include subnormal and maximum-finite boundary cases. It must preserve the exact candidate comparison, exact midpoint comparison, ties-to-even selection, and existing fail-closed exits.

I found no direction reversal, midpoint, or boundary-handling defect in the current capped loop. The exact-head checks confirm that quality, repository/Python, Live PostgreSQL, documentation, and resource-evidence jobs passed. The production line and branch coverage gate remains RED.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

현재 exact head a68055f108fc30b9b56348e8a5381ab436c813b3bias_se.rs::correctly_rounded_scaled_sqrt_ratio line-307 termination obligation을 다시 좁혔습니다. 이전 검토에서 확인한 monotone/direction proof에 더해 seed-to-target distance의 bounded proof가 성립하는지 complete caller domain 기준으로 독립 검증해 주세요. Source/coverage를 바꾸라는 요청은 아닙니다.

현재 admission은 1 <= numerator <= u128::MAX, 1 <= denominator <= 2^53, unit = 2^e (exact_power_of_two 범위)이고 seed는 ((numerator as f64) / (denominator as f64)).sqrt() * unit입니다. Rust language/library primary contract는 (a) integer→float cast가 nearest, ties-to-even이고, (b) primitive f64 division/multiplication이 IEEE roundTiesToEven이며, (c) f64::sqrt가 rounded infinite-precision squareRoot임을 명시합니다. References: https://doc.rust-lang.org/reference/expressions/operator-expr.html#numeric-cast ; https://doc.rust-lang.org/std/primitive.f64.html (primitive-operation rounding and sqrt precision).

u=2^-53라 두면 numerator as f64의 positive finite relative error는 <=u, denominator는 <=2^53라 exact, division과 sqrt rounding도 각각 <=u입니다. 따라서 power-of-two restoration 전 seed c와 exact y=sqrt(N/D)

(1-u)^2 <= c/y <= (1+u)^2, hence |c/y-1| <= 2u+u^2.

Normal finite restoration에서 exact power-of-two multiplication은 exponent shift이므로 representable 범위 안에서는 추가 rounding이 없고, 이 bound는 한 binade에서 < 2 + 2^-53 local spacings입니다. Since the correctly-rounded result itself is within half a local spacing of the exact target, a finite seed cannot be three adjacent binary64 values away; power-of-two/binade boundaries need the asymmetric lower spacing checked explicitly, but three-step distance is still larger than the bound. In the subnormal-restoration region, pre-restoration error is <~1 minimum-subnormal quantum and the final primitive multiplication contributes at most 0.5 quantum, so seed-to-correct-result is also at most two adjacent values. At the lower zero and upper infinity boundaries the existing bits == 1 / non-finite-neighbor exits remain fail closed rather than returning an unverified candidate.

If this boundary analysis is correct, any finite correctly-roundable target needs at most two neighbor_is_closer moves, and the third iteration must return; the fourth pass and terminal exhaustion are structurally redundant under the current input contract. Please specifically try to falsify this at: (1) just below/above powers of two, (2) normal↔subnormal transition, (3) half-min-subnormal/zero, (4) MAX↔infinity rounding threshold, and (5) numerator cast binade boundaries near u128::MAX. If any step relies on a stronger premise than current Rust/current caller code provides, identify the exact premise. Do not recommend an unbounded loop, returning an unverified candidate, private coverage-only fixtures, coverage exclusions, or widening n>16.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head='a68055f108fc30b9b56348e8a5381ab436c813b3'
src='crates/validation_core/src/bias_se.rs'

echo '== Exact revision identity =='
git show -s --format='head=%H%nparents=%P%nsubject=%s' "$head"
git rev-parse HEAD

echo '== bias_se.rs structure =='
ast-grep outline "$src" --items all --type function,struct,enum,impl

echo '== Exact rounder and helper implementation =='
git show "${head}:${src}" | nl -ba | sed -n '1,340p'

echo '== Exact bounded-route implementation and callers =='
git show "${head}:${src}" | nl -ba | sed -n '340,680p'
git grep -n -C 35 -E \
  '\b(correctly_rounded_scaled_sqrt_ratio|exact_pair_distance_standard_error|exact_power_of_two|bias_standard_error)\s*\(' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Existing boundary and rounding contracts =='
git ls-tree -r --name-only "$head" -- crates/validation_core/tests |
  grep -Ei '(bias.*(round|dyadic|midpoint|ratio|subnormal|overflow|boundary)|standard.*error)' |
  sort |
  while IFS= read -r f; do
    echo "----- $f -----"
    git show "${head}:${f}" | nl -ba
  done

echo '== Exact loop introduction and changes =='
git log -G 'for _ in 0\.\.4|correctly_rounded_scaled_sqrt_ratio|neighbor_is_closer' \
  --format='%H %P %s' -- "$src" || true

Length of output: 1906


🤖 web_search executed:

Rust Reference numeric cast integer to f64 rounding behavior nearest ties to even current documentation

Length of output: 8359


🤖 web_search executed:

Rust primitive f64 division multiplication rounding mode roundTiesToEven and sqrt correctly rounded infinite precision current documentation

Length of output: 13484


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head='a68055f108fc30b9b56348e8a5381ab436c813b3'
src='crates/validation_core/src/bias_se.rs'

echo '== Exact rounder and helpers: Lines 1-340 =='
git show "${head}:${src}" | nl -ba | sed -n '1,340p'

echo '== Exact public route and pair-distance construction: Lines 340-700 =='
git show "${head}:${src}" | nl -ba | sed -n '340,700p'

echo '== Definitions and all repository call sites =='
git grep -n -C 28 -E \
  '\b(correctly_rounded_scaled_sqrt_ratio|exact_pair_distance_standard_error|exact_power_of_two|neighbor_is_closer|adjacent_midpoint|compare_scaled_ratio_to_dyadic_square)\s*\(' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Exact tests that exercise rounding or binary64 boundaries =='
git ls-tree -r --name-only "$head" -- crates/validation_core/tests |
  grep -Ei '(bias.*(round|dyadic|midpoint|ratio|subnormal|overflow|boundary)|standard.*error)' |
  sort |
  while IFS= read -r f; do
    echo "----- $f -----"
    git show "${head}:${f}" | nl -ba
  done

echo '== Arithmetic operations and finite/zero/infinite exits in exact source =='
git show "${head}:${src}" | nl -ba | \
  grep -E -C 8 'as f64|\.sqrt\(\)|/| \* |is_finite|== 0\.0|MIN_POSITIVE|MAX|to_bits|next_after|neighbor' || true

echo '== Current exact head status =='
git show -s --format='head=%H%nsubject=%s' "$head"
git rev-parse HEAD

Length of output: 118296


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head='a68055f108fc30b9b56348e8a5381ab436c813b3'
src='crates/validation_core/src/bias_se.rs'

echo '== exact_power_of_two and seed-entry region =='
git show "${head}:${src}" | nl -ba | sed -n '200,310p'

echo '== All direct internal calls to the private rounder at exact head =='
git grep -n -C 12 'correctly_rounded_scaled_sqrt_ratio(' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs'

echo '== Production-derived bounds before the rounder call =='
git show "${head}:${src}" | nl -ba | sed -n '391,455p'

echo '== Rust toolchain version selected by this revision =='
git ls-tree -r --name-only "$head" | grep -E '(^|/)(rust-toolchain(\.toml)?|Cargo\.toml)$' | while IFS= read -r f; do
  echo "----- $f -----"
  git show "${head}:${f}"
done

Length of output: 65030


🤖 web_search executed:

site:doc.rust-lang.org/reference floating point division multiplication rounding mode roundTiesToEven primitive operators Rust

Length of output: 9676


@seonghobae 리뷰를 완료했습니다. 정확한 head a68055f108fc30b9b56348e8a5381ab436c813b3에서 Line 307의 seed-distance 주장에는 수정이 필요한 전제가 하나 있습니다. 그 전제를 명시하면, 유한하고 양수인 seed가 Line 257에 도달하는 모든 허용 입력에서 두 번의 neighbor_is_closer 이동으로 충분하다는 증명을 확인했습니다.

correctly_rounded_scaled_sqrt_ratio의 실제 production caller는 더 좁은 도메인을 사용합니다. n=3..=16이므로 축소 전 분모는 최대 16² × 15 = 3,840입니다. 축소는 분모를 증가시키지 않습니다. helper 자체의 더 넓은 허용 도메인인 denominator <= 2^53에서도 아래 seed-distance 결과는 성립합니다.

  • u128 as f64는 항상 유한합니다. u128::MAX < 2^128입니다.
  • N / D2^-53 이상입니다. 따라서 division은 normal 결과를 생성합니다.
  • sqrt(N / D)도 normal 결과를 생성합니다.
  • Rust의 nearest-even integer cast와 correctly rounded sqrt 계약은 사용자의 오차 전개를 지지합니다.
  • cast와 division의 오차를 sqrt에 전달하면 sqrt 전의 상대 오차는 (1-u)^2(1+u)^2 사이입니다.
  • correctly rounded sqrt를 포함하면 최종 restoration 전에도 같은 형태의 경계가 유지됩니다.

정상 finite restoration에서는 unit이 정확한 2의 거듭제곱입니다. 따라서 결과가 normal finite이면 multiplication은 exponent shift만 수행하며 추가 반올림을 만들지 않습니다. 이 경우

|c / y - 1| <= 2u + u²

입니다. 한 binade의 최소 local spacing으로 환산한 최악 경계는 < 2 + 2^-53 ULP입니다. 정확한 target의 correctly rounded 결과는 target에서 최대 반 ULP 떨어집니다. 따라서 seed와 올바른 결과 사이의 거리는 세 adjacent binary64 값에 도달할 수 없습니다. power-of-two 경계의 비대칭 spacing도 이 결론을 바꾸지 않습니다.

normal-to-subnormal restoration도 반증하지 못했습니다. subnormal 구간에서는 restoration 전의 상대 오차가 최대값 근처에서도 한 minimum-subnormal quantum보다 작습니다. 최종 multiplication의 nearest-even 반올림과 target의 correctly rounded 반올림은 각각 최대 반 quantum을 더합니다. 따라서 seed와 올바른 nonzero subnormal 결과의 거리는 두 adjacent 값 이하입니다.

다음 경계도 확인했습니다.

  1. 2의 거듭제곱 바로 아래와 위
    아래쪽 spacing과 위쪽 spacing의 비대칭성은 존재합니다. 그러나 상대 오차를 더 작은 쪽 spacing으로 변환해도 세 값 거리에는 도달하지 않습니다.

  2. normal/subnormal 전이
    minimum normal 근처에서도 absolute-error 경계가 minimum-subnormal quantum 기준으로 유지됩니다. 두 이동보다 큰 거리가 생기지 않습니다.

  3. half-minimum-subnormal과 zero
    여기서는 중요한 제한이 있습니다. exact target이 correctly rounds to minimum subnormal이어도 seed가 zero로 round될 수 있습니다. 반대로 exact target이 zero로 round될 수 있어도 seed가 minimum subnormal일 수 있습니다. 현재 코드는 Line 252에서 이 seed를 거부합니다. 따라서 이 경계는 correction loop에 진입하지 않으며, fail-closed 동작을 유지합니다.

  4. f64::MAX와 infinity 전이
    exact target이 finite result로 correctly round될 수 있어도, seed의 선행 반올림 오차가 overflow threshold를 넘길 수 있습니다. 현재 코드는 Line 252에서 non-finite seed를 거부합니다. Line 280의 non-finite neighbor 거부도 상단 경계를 보존합니다. 이 경우도 loop 거리 증명의 대상이 아닙니다.

  5. u128::MAX 근처 numerator cast binade
    cast는 nearest-even입니다. 최대 128-bit numerator는 유한 binary64로 변환됩니다. cast binade 경계와 halfway case는 이미 u 상대오차 경계 안에 있습니다. 이 경계는 세 이동을 요구하는 반례를 만들지 않습니다.

따라서 다음과 같이 범위를 정확히 구분해야 합니다.

  • 증명되는 내용: Line 252를 통과한 유한 양수 seed에 대해서는 올바른 finite binary64 결과까지 최대 두 번의 adjacent correction이면 충분합니다. 세 번째 loop pass는 반드시 return합니다.
  • 증명되지 않는 내용: 모든 finite correctly-roundable exact target이 반드시 loop에 진입한다는 주장입니다. zero 및 infinity 반올림 경계 근처에서는 seed가 먼저 zero 또는 infinity가 될 수 있습니다. 현재 구현은 그 경우를 fail-closed로 거부합니다.

이 제한을 명시하면, 현재 for _ in 0..4의 네 번째 pass와 Line 307 exhaustion은 correction-loop 도메인에서는 구조적으로 불필요합니다. 다만 source 변경 전에는 이 조건부 정리를 코드 문서화와 proof artifact에 명시해야 합니다. 특히 Line 252와 Line 280의 lower/upper fail-closed 경계는 유지해야 합니다.

Rust 1.98.0의 toolchain 지정과 exact_power_of_two[-1074, 1023] 범위도 이 분석과 일치합니다. n=3..=16 admission, exact midpoint 비교, ties-to-even, 그리고 lower/upper refusal semantics에는 변경이 필요하지 않습니다.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact head 0bd9d9eeb9f3d6be27548f46b93e597142f67668, focused only on the new large-sample public reference characterization contract. Verify that the n=2,047 two-level expected binary64 result is correct, the anchor-position cases genuinely test permutation invariance of the established fallback, the minimum-subnormal case preserves false-zero refusal, and nothing in this test implies or silently widens n>16 production exact-proof admission. Treat it as reference-baseline evidence for #491, not as an independent scientific oracle or coverage-driven fixture.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='0bd9d9eeb9f3d6be27548f46b93e597142f67668'
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"

echo '== Exact commit identity =='
git rev-parse HEAD
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"

echo '== Changed paths and focused diff =='
git diff --name-status "$parent" "$head"
git diff --find-renames --unified=140 "$parent" "$head" -- \
  'crates/validation_core/tests/*.rs' \
  crates/validation_core/src/bias.rs \
  crates/validation_core/src/bias_se.rs \
  Cargo.toml

echo '== Added or modified large-sample characterization contracts =='
git diff --name-only "$parent" "$head" -- 'crates/validation_core/tests/*.rs' |
while IFS= read -r file; do
  echo "----- $file -----"
  ast-grep outline "$file" --items all --type function,struct,enum,impl 2>/dev/null || true
  cat -n "$file"
done

echo '== Public route and n=3..=16 exact-admission boundary =='
git show "${head}:crates/validation_core/src/bias_se.rs" | nl -ba | sed -n '330,680p'
git show "${head}:crates/validation_core/src/bias.rs" | nl -ba | sed -n '1,220p'
git grep -n -C 22 -E \
  '\b(pub )?fn bias_standard_error\b|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error|exact_pair_distance_standard_error' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Related public two-level, permutation, subnormal, and false-zero contracts =='
git ls-tree -r --name-only "$head" -- crates/validation_core/tests |
  grep -Ei '(bias.*(large|reference|two.level|permutation|subnormal|false.zero)|standard.*error)' |
  sort |
  while IFS= read -r file; do
    echo "----- $file -----"
    git show "${head}:${file}" | nl -ba | grep -E -C 10 \
      '(2047|2_047|two.level|anchor|permut|MIN|subnormal|false.zero|bias_standard_error|to_bits|expect)' || true
  done

echo '== Exact-head GitHub state =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}' || true
gh pr view 488 --repo "$repo" --json headRefOid,isDraft,state,mergeStateStatus,statusCheckRollup \
  --jq '{headRefOid,isDraft,state,mergeStateStatus,checks:[.statusCheckRollup[]|{name,status,conclusion,detailsUrl}]}' || true

Length of output: 125950


You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Exact head aaf7921a657bc55d0b346943599439839fa4e4e3 is RED only because cargo fmt --all -- --check reports a formatting delta introduced by crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs. Please run the pinned repository formatter or equivalent against this exact head and report the exact rustfmt diff/replacement for that file. Also verify the test semantics: n=2,047, exact two-level expected bits 0x4280_0200_4008_0101, three anchor positions as permutation specimens, and minimum-subnormal false-zero refusal. Do not suggest production admission widening or coverage exclusions.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='aaf7921a657bc55d0b346943599439839fa4e4e3'
file='crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs'

echo '== Exact head =='
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"
git rev-parse HEAD

echo '== Requested test file =='
git show "${head}:${file}" | nl -ba

echo '== Exact-head diff for requested test file =='
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"
git diff --find-renames --unified=120 "$parent" "$head" -- "$file"

echo '== Public route and exact-admission boundary =='
git show "${head}:crates/validation_core/src/bias_se.rs" | nl -ba | sed -n '360,610p'
git grep -n -C 20 -E \
  '\b(pub )?fn bias_standard_error\b|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error|exact_pair_distance_standard_error' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Exact-head checks and Rust Foundation jobs =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {id,name,status,conclusion,details_url,completed_at}'
gh api "repos/${repo}/actions/runs?head_sha=${head}&per_page=100" \
  --jq '.workflow_runs[] | {id,name,path,status,conclusion,head_sha,html_url}' \
  > /tmp/exact-head-runs.json
cat /tmp/exact-head-runs.json

echo '== Rust Foundation formatter logs =='
jq -r '. | select(.name == "Rust Foundation") | .id' /tmp/exact-head-runs.json | while IFS= read -r run_id; do
  [ -n "$run_id" ] || continue
  gh api "repos/${repo}/actions/runs/${run_id}/jobs?per_page=100" \
    --jq '.jobs[] | {id,name,status,conclusion,html_url,steps:[.steps[]|{number,name,conclusion}]}' \
    > "/tmp/rust-jobs-${run_id}.json"
  cat "/tmp/rust-jobs-${run_id}.json"
  jq -r '.id' "/tmp/rust-jobs-${run_id}.json" | while IFS= read -r job_id; do
    [ -n "$job_id" ] || continue
    echo "----- job ${job_id} formatter excerpts -----"
    gh api "repos/${repo}/actions/jobs/${job_id}/logs" 2>/dev/null | \
      grep -E -C 20 'cargo fmt|rustfmt|bias_large_sample_reference_characterization_contract\.rs|Diff in ' || true
  done
done

Length of output: 72861


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
run='34514509582'
job='102996525486'
head='aaf7921a657bc55d0b346943599439839fa4e4e3'
file='crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs'

echo '== Failed job metadata and steps =='
gh api "repos/${repo}/actions/jobs/${job}" \
  --jq '{id,name,status,conclusion,started_at,completed_at,html_url,steps:[.steps[]|{number,name,status,conclusion,started_at,completed_at}]}'

echo '== Failed-job logs: gh run view =='
gh run view "$run" --repo "$repo" --log-failed 2>&1 || true

echo '== Failed-job logs: REST redirect endpoint =='
curl -fsSL \
  -H "Authorization: Bearer $(gh auth token)" \
  -H "Accept: application/vnd.github+json" \
  "https://api.github.com/repos/${repo}/actions/jobs/${job}/logs" \
  2>&1 | grep -E -C 25 \
  'cargo fmt|rustfmt|Diff in |bias_large_sample_reference_characterization_contract\.rs|error:' || true

echo '== Formatter configuration at exact head =='
git ls-tree -r --name-only "$head" | grep -E '(^|/)(rustfmt\.toml|\.rustfmt\.toml|rust-toolchain(\.toml)?)$' | while IFS= read -r config; do
  echo "----- $config -----"
  git show "${head}:${config}"
done

echo '== Candidate long lines in requested test =='
git show "${head}:${file}" | awk 'length($0) > 100 { printf "%d:%d:%s\n", NR, length($0), $0 }'

echo '== Current Rust Foundation run state =='
gh api "repos/${repo}/actions/runs/${run}" \
  --jq '{id,status,conclusion,head_sha,updated_at,html_url}'

Length of output: 16405


@seonghobae Review complete for exact head aaf7921a657bc55d0b346943599439839fa4e4e3.

The pinned Rust 1.98.0 rustfmt log reports these exact replacements in crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs:

-use validation_core::{bias_standard_error, ValidationError};
+use validation_core::{ValidationError, bias_standard_error};
-        let second = bias_standard_error(&truth, &recovered)
-            .expect("deterministic repeated result");
+        let second =
+            bias_standard_error(&truth, &recovered).expect("deterministic repeated result");

The job failed at Check formatting. It did not run Clippy, tests, doctests, rustdoc, or dependency policy. The Rust Foundation workflow remains in progress because production coverage is still running.

I found no scientific-scope issue in the test source.

  • SAMPLE_COUNT is 2_047.
  • The two-level fixture has one zero residual and 2,046 equal residuals.
  • For this geometry, SE(mean) = |gap| / n.
  • With gap = 2^52 + 1, the asserted target is 0x4280_0200_4008_0101.
  • The three anchor indices are 0, 1_023, and 2_046. Each must produce the same expected bits. This tests the established fallback against anchor-position permutations.
  • The false-zero case uses the minimum positive subnormal. Its exact positive result is 2^-1074 / 2047, which is below the half-minimum-subnormal rounding boundary. The asserted Err(ValidationError::InvalidInput) preserves the false-zero refusal.
  • crates/validation_core/src/bias_se.rs keeps exact admission at n=3..=16. For n=2,047, bias_standard_error delegates to crate::bias::bias_standard_error. The test does not widen production exact-proof admission.

The semantics are correct by source review. CI has not executed this test on the exact head because formatting stopped the quality job.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head 40582fb4a01c8f436ee7383a7b909f50f03ea6ee, focusing on the new bias_large_sample_reference_characterization_contract.rs. Verify: (1) for n=2,047 with one zero and 2,046 residuals equal to 2^52+1, the established public fallback should return the nearest binary64 to (2^52+1)/2047, bits 0x4280_0200_4008_0101; (2) moving the zero anchor across first/middle/last positions is a valid permutation-invariance specimen; (3) using 2^-1074 should preserve fail-closed InvalidInput rather than false zero; and (4) this is characterization/reference-baseline evidence only and does not widen the production exact-proof admission above n=16. Flag any scientific, determinism, or test-oracle defect. Do not propose coverage exclusions or provider/routing changes.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Exact head 40582fb4a01c8f436ee7383a7b909f50f03ea6ee now passes cargo fmt --all -- --check but Rust Foundation job 102997534915 fails at cargo clippy --workspace --all-targets --all-features -- -D warnings. Please run that pinned Clippy command against this exact head and report the exact diagnostic in crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs, with the minimal semantics-preserving source fix only.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='40582fb4a01c8f436ee7383a7b909f50f03ea6ee'
file='crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs'
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"

echo '== exact identity =='
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"
git rev-parse HEAD

echo '== changed paths and requested diff =='
git diff --name-status "$parent" "$head"
git diff --find-renames --unified=120 "$parent" "$head" -- "$file"

echo '== requested test source =='
git show "${head}:${file}" | nl -ba

echo '== public route and fallback implementation =='
git show "${head}:crates/validation_core/src/bias_se.rs" | nl -ba | sed -n '360,650p'
git show "${head}:crates/validation_core/src/bias.rs" | nl -ba | sed -n '1,190p'
git grep -n -C 22 -E \
  '\b(pub )?fn bias_standard_error\b|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error|exact_pair_distance_standard_error|standard_error_from_deviations' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== relevant error definitions =='
git grep -n -C 10 -E 'enum ValidationError|InvalidInput' \
  "$head" -- 'crates/validation_core/src/*.rs' || true

echo '== independent exact rounding check =='
python3 - <<'PY'
from fractions import Fraction

n = 2047
p = (1 << 52) + 1
expected = 0x4280_0200_4008_0101

# Decode a positive finite binary64 bit pattern to an exact rational.
def decode(bits):
    exponent = (bits >> 52) & 0x7ff
    fraction = bits & ((1 << 52) - 1)
    if exponent == 0:
        return Fraction(fraction, 1) * Fraction(2) ** -1074
    return Fraction((1 << 52) | fraction, 1) * Fraction(2) ** (exponent - 1023 - 52)

target = Fraction(p, n)
candidate = decode(expected)
below = decode(expected - 1)
above = decode(expected + 1)
mid_lower = (below + candidate) / 2
mid_upper = (candidate + above) / 2

print(f'target={p}/{n}')
print(f'candidate_bits=0x{expected:016x}')
print(f'candidate={candidate.numerator}/{candidate.denominator}')
print(f'target_in_candidate_interval={mid_lower < target < mid_upper}')
print(f'distance_to_candidate={abs(target-candidate)}')
print(f'distance_to_below={abs(target-below)}')
print(f'distance_to_above={abs(target-above)}')
print(f'nearest_unique={abs(target-candidate) < abs(target-below) and abs(target-candidate) < abs(target-above)}')
PY

echo '== exact-head check state =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}' || true
gh pr view 488 --repo "$repo" --json headRefOid,isDraft,state,mergeStateStatus,statusCheckRollup \
  --jq '{headRefOid,isDraft,state,mergeStateStatus,checks:[.statusCheckRollup[]|{name,status,conclusion,detailsUrl}]}' || true

Length of output: 203354


🏁 Script executed:

#!/bin/bash
set -euo pipefail

log='/tmp/coderabbit-shell-logs/shell-output-CCnOCC'

echo '== log section markers =='
rg -n '^== ' "$log"

echo '== exact identity, diff, and requested test =='
sed -n '1,260p' "$log"

echo '== public route section markers and bounded excerpts =='
rg -n -C 10 \
  'pub fn bias_standard_error|exact_pair_distance_standard_error|3\.\.=16|crate::bias::bias_standard_error|SAMPLE_COUNT|anchor|minimum_subnormal' \
  "$log" | head -n 700

echo '== failed quality job diagnostic =='
rg -n -C 30 \
  'Format, lint, test, rustdoc, and dependency policy|cargo fmt|rustfmt|Diff in |error:' \
  "$log" | tail -n 500

Length of output: 119879


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
run='34514810357'
job='102997534915'

echo '== job metadata =='
gh api "repos/${repo}/actions/jobs/${job}" \
  --jq '{id,name,status,conclusion,html_url,steps:[.steps[]|{number,name,status,conclusion}]}'

echo '== failed-job log excerpts =='
gh run view "$run" --repo "$repo" --log-failed 2>&1 | \
  rg -n -C 25 \
  'Check formatting|cargo fmt|rustfmt|Diff in |error(\[|:)|failed|bias_large_sample_reference_characterization_contract' || true

Length of output: 2342


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
job='102997534915'
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

gh api "repos/${repo}/actions/jobs/${job}/logs" > "${tmpdir}/job-log.zip"
unzip -Z1 "${tmpdir}/job-log.zip" | head -n 30
unzip -p "${tmpdir}/job-log.zip" | rg -n -C 30 \
  'Run Clippy|error(\[|:)|warning:|clippy::|bias_large_sample_reference_characterization_contract|could not compile' || true

Length of output: 835


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
job='102997534915'
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

curl -fsSL \
  -H "Authorization: Bearer $(gh auth token)" \
  -H 'Accept: application/vnd.github+json' \
  "https://api.github.com/repos/${repo}/actions/jobs/${job}/logs" \
  -o "${tmpdir}/job-log.zip"

file "${tmpdir}/job-log.zip"
unzip -Z1 "${tmpdir}/job-log.zip" | head -n 20
unzip -p "${tmpdir}/job-log.zip" |
  sed $'s/\x1b\\[[0-9;]*[[:alpha:]]//g' |
  rg -n -C 25 \
    'Run Clippy|error(\[|:)|warning:|clippy::|bias_large_sample_reference_characterization_contract|could not compile' || true

Length of output: 1028


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
job='102997534915'
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

curl -fsSL \
  -H "Authorization: Bearer $(gh auth token)" \
  -H 'Accept: application/vnd.github+json' \
  "https://api.github.com/repos/${repo}/actions/jobs/${job}/logs" \
  -o "${tmpdir}/job-log.zip"

unzip -Z1 "${tmpdir}/job-log.zip" | head -n 20
unzip -p "${tmpdir}/job-log.zip" |
  sed $'s/\x1b\\[[0-9;]*[[:alpha:]]//g' |
  rg -n -C 25 \
    'Run Clippy|error(\[|:)|warning:|clippy::|bias_large_sample_reference_characterization_contract|could not compile' || true

Length of output: 1394


@seonghobae Review complete for exact head 40582fb4a01c8f436ee7383a7b909f50f03ea6ee.

I found no scientific, determinism, or test-oracle defect in the requested scope.

  • The two-level identity is correct. One zero residual and 2,046 residuals equal to gap give SE(mean) = |gap| / 2047.
  • Independent exact rational comparison confirms that 0x4280_0200_4008_0101 is the unique nearest binary64 value to (2^52 + 1) / 2047. It is not a midpoint case.
  • The anchor indices 0, 1_023, and 2_046 preserve the same residual multiset. They are valid first, middle, and last permutation specimens. Each case also repeats the call and checks the same result bits.
  • With gap = 2^-1074, the exact positive result is 2^-1074 / 2047. It is below the half-minimum-subnormal boundary. The expected Err(ValidationError::InvalidInput) preserves the false-zero refusal.
  • The test is explicitly documented as fallback characterization and reference-baseline evidence. It does not act as an independent scientific oracle.
  • crates/validation_core/src/bias_se.rs Line 399 still limits the exact pair-distance route to n=3..=16. For n=2,047, the public API delegates to crate::bias::bias_standard_error at Line 471. The test does not widen production admission.

Exact-head verification remains incomplete. Formatting passed, but Clippy failed, so the test suite did not run. The production coverage job was also still in progress. I could not retrieve the Clippy diagnostic from the Actions log archive in this environment.

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='40582fb4a01c8f436ee7383a7b909f50f03ea6ee'
job='102997534915'
file='crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs'

echo '== Exact revision =='
git show -s --format='head=%H%nparents=%P%nsubject=%s' "$head"
git rev-parse HEAD

echo '== Failed job metadata =='
gh api "repos/${repo}/actions/jobs/${job}" \
  --jq '{id,name,status,conclusion,head_sha,html_url,steps:[.steps[]|{number,name,status,conclusion}]}'

echo '== Failed Clippy diagnostic =='
gh api "repos/${repo}/actions/jobs/${job}/logs" |
  grep -E -C 20 \
  'cargo clippy|bias_large_sample_reference_characterization_contract\.rs|warning:|error:|help:|note:' \
  || true

echo '== Exact affected test source =='
git show "${head}:${file}" | nl -ba

echo '== Exact-head change to affected test =='
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"
git diff --find-renames --unified=100 "$parent" "$head" -- "$file"

echo '== Workspace lint configuration =='
for f in Cargo.toml crates/validation_core/Cargo.toml; do
  if git cat-file -e "${head}:${f}" 2>/dev/null; then
    echo "----- $f -----"
    git show "${head}:${f}"
  fi
done

Length of output: 15313


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
run='34514810357'
job='102997534915'
file='bias_large_sample_reference_characterization_contract.rs'
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

echo '== Failed-step log through gh run view =='
gh run view "$run" --repo "$repo" --log-failed 2>&1 |
  sed -E $'s/\x1B\\[[0-?]*[ -\\/]*[`@-`~]//g' |
  grep -E -C 25 \
  'Run Clippy|cargo clippy|'"$file"'|warning:|error:|help:|note:|clippy::' \
  || true

echo '== Raw job log through REST redirect =='
curl -fsSL \
  -H "Authorization: Bearer $(gh auth token)" \
  -H 'Accept: application/vnd.github+json' \
  "https://api.github.com/repos/${repo}/actions/jobs/${job}/logs" \
  -o "${tmpdir}/job.log"

sed -E $'s/\x1B\\[[0-?]*[ -\\/]*[`@-`~]//g' "${tmpdir}/job.log" |
  grep -E -C 25 \
  'Run Clippy|cargo clippy|'"$file"'|warning:|error:|help:|note:|clippy::' \
  || true

echo '== Unstripped matching raw lines for source coordinates =='
grep -a -n -E \
  "$file|clippy::|error:|warning:" \
  "${tmpdir}/job.log" \
  || true

Length of output: 10627


@seonghobae Review complete for exact head 40582fb4a01c8f436ee7383a7b909f50f03ea6ee.

Rust Foundation job 102997534915 passes formatting and fails only at Clippy.

The exact diagnostic is:

error: casting `u64` to `f64` may cause a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
  --> crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs:25:15
   |
25 |     let gap = (1_u64 << 52) as f64 + 1.0;
   |               ^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-D clippy::cast-precision-loss` implied by `-D clippy::pedantic`

Use an exact binary64 construction. This is the minimal semantics-preserving fix:

let gap = f64::from_bits(0x4330_0000_0000_0001);

This bit pattern is exactly 2^52 + 1. It preserves the expected result bits, the three anchor-position specimens, and the minimum-subnormal false-zero refusal test. It does not change production arithmetic or the n=3..=16 exact-proof admission boundary.

  • Replace the precision-loss-prone u64 cast in crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs with the exact f64::from_bits value.

Failed to handle agent chat message. Please try again.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head 01ca3088b4a4bc514a441c4ab8ca4430219ab9e9, limited to crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs. Verify the analytic two-level identity and expected bits 0x4280_0200_4008_0101 for n=2,047, the first/middle/last anchor permutation specimens, the minimum-subnormal fail-closed InvalidInput, and that the test is reference characterization only and does not widen production exact-proof admission above n=16. Also verify the exact binary64 literal f64::from_bits(0x4330_0000_0000_0001) is 2^52+1. Flag any scientific or determinism defect; do not propose coverage exclusions or admission widening.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='01ca3088b4a4bc514a441c4ab8ca4430219ab9e9'
file='crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs'

echo '== Exact revision =='
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"
git rev-parse HEAD

echo '== Requested test source =='
git show "${head}:${file}" | nl -ba

echo '== Requested test diff =='
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"
git diff --find-renames --unified=120 "$parent" "$head" -- "$file"

echo '== Public admission and fallback routing =='
git show "${head}:crates/validation_core/src/bias_se.rs" | nl -ba | sed -n '380,500p'
git grep -n -C 18 -E \
  '\bpub fn bias_standard_error\b|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error|exact_pair_distance_standard_error' \
  "$head" -- 'crates/validation_core/src/*.rs' 'crates/validation_core/tests/*.rs' || true

echo '== Fallback false-zero behavior and error definition =='
git grep -n -C 16 -E \
  '\bfn bias_standard_error\b|standard_error == 0\.0|InvalidInput|enum ValidationError' \
  "$head" -- crates/validation_core/src/bias.rs crates/validation_core/src/lib.rs crates/validation_core/src/error.rs || true

echo '== Exact rational checks =='
python3 - <<'PY'
from fractions import Fraction

N = 2047
gap = (1 << 52) + 1
expected_bits = 0x4280_0200_4008_0101
gap_bits = 0x4330_0000_0000_0001

def decode(bits):
    sign = -1 if bits >> 63 else 1
    exponent = (bits >> 52) & 0x7ff
    fraction = bits & ((1 << 52) - 1)
    if exponent == 0:
        return sign * Fraction(fraction, 1) * Fraction(2) ** -1074
    assert exponent != 0x7ff
    return sign * Fraction((1 << 52) | fraction, 1) * Fraction(2) ** (exponent - 1023 - 52)

target = Fraction(gap, N)
candidate = decode(expected_bits)
below = decode(expected_bits - 1)
above = decode(expected_bits + 1)
print(f'gap_literal_equals_2^52_plus_1={decode(gap_bits) == gap}')
print(f'two_level_se_identity_target={gap}/{N}')
print(f'expected_bits=0x{expected_bits:016x}')
print(f'unique_nearest={abs(target-candidate) < abs(target-below) and abs(target-candidate) < abs(target-above)}')
print(f'not_a_tie={2*abs(target-candidate) != abs(above-candidate) and 2*abs(target-candidate) != abs(candidate-below)}')
print(f'min_subnormal_target_below_half_quantum={Fraction(1, N) < Fraction(1, 2)}')
PY

echo '== Exact-head checks =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}' || true

Length of output: 123868


@seonghobae Review complete for exact head 01ca3088b4a4bc514a441c4ab8ca4430219ab9e9.

I found no scientific or determinism defect in the requested scope.

  • f64::from_bits(0x4330_0000_0000_0001) is exactly 2^52 + 1.
  • For one zero residual and 2,046 residuals equal to gap, the exact identity is SE(mean) = |gap| / 2047.
  • Exact rational comparison confirms that 0x4280_0200_4008_0101 is the unique nearest binary64 value to (2^52 + 1) / 2047. The value is not a midpoint tie.
  • The anchor indices 0, 1_023, and 2_046 preserve the same residual multiset. They provide first, middle, and last permutation specimens. Each case also repeats the public call and checks identical result bits.
  • With gap = 2^-1074, the exact positive result is 2^-1074 / 2047. It is below the half-minimum-subnormal boundary. The asserted Err(ValidationError::InvalidInput) preserves the false-zero refusal.
  • The file documentation correctly defines this test as fallback reference characterization. It does not define an independent scientific oracle.
  • Production exact-proof admission remains n=3..=16 in crates/validation_core/src/bias_se.rs Line 399. For n=2,047, the public API delegates to crate::bias::bias_standard_error at Line 471. The test does not widen admission.

The exact-head format, lint, test, rustdoc, dependency policy, repository/Python, PostgreSQL, resource-evidence, and governance checks are GREEN. The Production line and branch coverage check is RED.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Exact head 1b50af75a4e2449922252f805552860fbb0494dc: please review only the new characterization delta in crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs against the public validation_core::bias_standard_error contract. Verify the two-level identity SE(mean)^2 = gap^2 * m(n-m) / [n^2(n-1)], the hard-coded nearest-binary64 results for (n,m)=(17,5),(63,21),(255,85),(1023,341) with gap=2^52+1, the prefix/suffix/rotation permutation equivalence, repeat determinism, and that this remains characterization-only with no n>16 production admission change. Treat coverage exclusion, private/artificial coverage fixtures, provider/model changes, or copied production arithmetic as out of scope. Report a finding only if the exact-head delta is scientifically, deterministically, or contractually wrong.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='1b50af75a4e2449922252f805552860fbb0494dc'
file='crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs'
parent="$(git show -s --format=%P "$head" | awk '{print $1}')"

echo '== exact revision =='
git show -s --format='head=%H%nparents=%P%nsubject=%s%ncommit_date=%cI' "$head"
git rev-parse HEAD

echo '== focused delta =='
git diff --find-renames --unified=160 "$parent" "$head" -- "$file"

echo '== full requested test =='
git show "${head}:${file}" | nl -ba

echo '== public API routing and admission boundary =='
git show "${head}:crates/validation_core/src/bias_se.rs" | nl -ba | sed -n '370,500p'
git grep -n -C 18 -E \
  '\bpub fn bias_standard_error\b|3\.\.=16|n\s*<\s*3|n\s*>\s*16|crate::bias::bias_standard_error|exact_pair_distance_standard_error' \
  "$head" -- 'crates/validation_core/src/*.rs'

echo '== exact binary64 validation for stated specimens =='
python3 - <<'PY'
from fractions import Fraction
import struct

gap = (1 << 52) + 1
cases = [(17, 5), (63, 21), (255, 85), (1023, 341)]

def decode(bits):
    sign = -1 if bits >> 63 else 1
    exp = (bits >> 52) & 0x7ff
    frac = bits & ((1 << 52) - 1)
    if exp == 0:
        return sign * Fraction(frac, 1) * Fraction(2) ** -1074
    assert exp != 0x7ff
    return sign * Fraction((1 << 52) | frac, 1) * Fraction(2) ** (exp - 1023 - 52)

def float_bits(value):
    return struct.unpack('>Q', struct.pack('>d', value))[0]

for n, m in cases:
    squared = Fraction(gap * gap * m * (n - m), n * n * (n - 1))
    # Python float sqrt is only used to identify candidate; exact neighbor proof follows.
    candidate_bits = float_bits(float(squared) ** 0.5)
    candidate = decode(candidate_bits)
    below = decode(candidate_bits - 1)
    above = decode(candidate_bits + 1)
    # Compare squared distances to avoid irrational arithmetic:
    # target root nearest interval is bounded by midpoints; test candidate^2 relative to target.
    lower_mid_sq = ((below + candidate) / 2) ** 2
    upper_mid_sq = ((candidate + above) / 2) ** 2
    correct = lower_mid_sq < squared < upper_mid_sq
    print(
        f'n={n} m={m} expected_bits=0x{candidate_bits:016x} '
        f'unique_nearest={correct} '
        f'formula_numerator={gap * gap * m * (n-m)} '
        f'formula_denominator={n*n*(n-1)}'
    )
PY

echo '== exact-head checks =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | {name,status,conclusion,details_url,completed_at}' || true

Length of output: 59038


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/TEPP'
head='1b50af75a4e2449922252f805552860fbb0494dc'
job='103004914630'

echo '== exact asserted-literal checks =='
python3 - <<'PY'
from fractions import Fraction

gap = (1 << 52) + 1
cases = [
    (17, 5, 0x42fd_294a_104a_a492),
    (63, 21, 0x42ee_a713_4c43_1b35),
    (255, 85, 0x42de_49d6_e90b_6ea0),
    (1023, 341, 0x42ce_330b_92b8_7e1b),
]

def decode(bits):
    exponent = (bits >> 52) & 0x7ff
    fraction = bits & ((1 << 52) - 1)
    assert 0 < exponent < 0x7ff
    return Fraction((1 << 52) | fraction, 1) * Fraction(2) ** (exponent - 1023 - 52)

for n, m, bits in cases:
    target_sq = Fraction(gap * gap * m * (n - m), n * n * (n - 1))
    lower, value, upper = decode(bits - 1), decode(bits), decode(bits + 1)
    lower_boundary_sq = ((lower + value) / 2) ** 2
    upper_boundary_sq = ((value + upper) / 2) ** 2
    print(f'n={n} m={m} bits=0x{bits:016x}')
    print(f'  unique_nearest={lower_boundary_sq < target_sq < upper_boundary_sq}')
    print(f'  lower_margin_sign={(target_sq - lower_boundary_sq) > 0}')
    print(f'  upper_margin_sign={(upper_boundary_sq - target_sq) > 0}')
    print(f'  lower_neighbor_is_not_nearer={target_sq > lower_boundary_sq}')
    print(f'  upper_neighbor_is_not_nearer={target_sq < upper_boundary_sq}')
PY

echo '== quality job failure diagnostic =='
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL \
  -H "Authorization: Bearer $(gh auth token)" \
  -H 'Accept: application/vnd.github+json' \
  "https://api.github.com/repos/${repo}/actions/jobs/${job}/logs" \
  -o "${tmpdir}/job.log"
sed -E $'s/\x1B\\[[0-?]*[ -\\/]*[`@-`~]//g' "${tmpdir}/job.log" | \
  rg -n -C 20 \
  'cargo fmt|cargo clippy|error(\[|:)|warning:|clippy::|bias_large_sample_reference_characterization_contract|test result' \
  || true

echo '== exact PR state =='
gh pr view 488 --repo "$repo" --json headRefOid,isDraft,mergeStateStatus,statusCheckRollup \
  --jq '{headRefOid,isDraft,mergeStateStatus,checks:[.statusCheckRollup[]|{name,status,conclusion,detailsUrl}]}' || true

Length of output: 14931


@seonghobae I found one finding in the requested delta.

large_sample_non_singleton_two_level_reference_tracks_exact_count_geometry fails against the current public validation_core::bias_standard_error contract at Line 64 of crates/validation_core/tests/bias_large_sample_reference_characterization_contract.rs.

The analytic identity is correct:

[
SE(\mathrm{mean})^2 =
\frac{\mathrm{gap}^2,m(n-m)}{n^2(n-1)}
]

Exact rational midpoint checks confirm that each hard-coded value is the unique nearest binary64 result for this identity. This includes (n,m)=(17,5) and 0x42fd_294a_104a_a492.

However, the exact-head Rust Foundation job ran the test and reported:

left:  Ok(4827059773688685712)  // 0x42fd_294a_104a_a490
right: Ok(4827059773688685714)  // 0x42fd_294a_104a_a492

The failure occurs on the first new (17,5) prefix specimen. n=17 routes to the established fallback because crates/validation_core/src/bias_se.rs only admits n=3..=16 to the exact-pair route.

Therefore, the new test does not currently characterize the established fallback correctly. It instead asserts a mathematical nearest-result oracle that the fallback does not produce for this specimen. The test also stops before it can establish prefix/suffix/rotation equivalence or repeat determinism for the remaining new specimens.

The delta does not widen the n>16 production exact-proof admission.

You are interacting with an AI system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant