Skip to content

feat(model): statistical Pareto K gates refuse LLM numerical authority - #67

Merged
seonghobae merged 7 commits into
mainfrom
agent/model-selection-pareto-gates
Aug 24, 2026
Merged

feat(model): statistical Pareto K gates refuse LLM numerical authority#67
seonghobae merged 7 commits into
mainfrom
agent/model-selection-pareto-gates

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds model_selection: candidate K must be at least 2 with finite held-out log-likelihood and complexity.
  • A Pareto front drops dominated alternatives; selection prefers higher likelihood, then lower complexity, then smaller K.
  • An LLM vote may later recommend among admissible candidates but cannot define the numerical optimum (ADR 0012).
  • Selected K recovers known truth with computed RMSE (no hardcoded recovery numbers).

Claim boundary

  • Statistical/Pareto admission gate only. Does not fit a topic model, choose a neural backend, or claim a unique true K for every corpus.
  • No new migration number (#45 still owns 0007).
  • Does not recreate in-flight crates (topic_measurement, psychometric_core, compute_backend, concept_dictionary).

Test plan

  • cargo test -p model_selection --offline --lib --tests
  • cargo clippy -p model_selection --all-targets --offline -- -D warnings
  • python3 scripts/check_docstrings.py
  • python3 scripts/check_workspace_contract.py
  • python3 scripts/validate_documentation.py
  • Exact-head CI and independent review

Open in Devin Review

Summary by CodeRabbit

  • 새 기능
    • 통계적으로 검증된 후보를 Pareto 기준으로 필터링하고 최적 후보 K를 선택하는 기능을 추가했습니다.
    • 선택된 K와 실제 토픽 수의 RMSE를 계산할 수 있습니다.
    • LLM 투표가 수치적 최적값을 단독 결정하지 못하도록 검증을 강화했습니다.
  • 문서
    • 모델 선택 기준, 검증 범위, RMSE 및 관련 근거 문서를 추가·갱신했습니다.
  • 테스트
    • 유효하지 않은 후보, 빈 목록, 동률 및 LLM 전용 후보 처리 검증을 추가했습니다.

ADR 0012 requires held-out likelihood/complexity comparison before any
blinded LLM review. This crate admits K>=2 statistical candidates, drops
dominated alternatives, and recovers known truth K with computed RMSE.
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 17 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a2d3c59-3d0b-45c9-a3e9-2e8316699546

📥 Commits

Reviewing files that changed from the base of the PR and between 191f14b and afdb0a2.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • ARCHITECTURE.md
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • crates/model_selection/src/candidate.rs
  • crates/model_selection/src/gate.rs
  • crates/model_selection/tests/pareto_k_gate_contract.rs
  • docs/TRACEABILITY.md
  • docs/adr/0012-temporal-relational-shared-latent-topic-measurement.md
  • docs/adr/README.md
  • docs/research/model-selection-pareto-gates.md
  • docs/research/standards-and-literature.md
  • docs/validation/temporal-event-foundation.md
  • scripts/check_workspace_contract.py
  • tests/quality/test_check_docstrings.py
📝 Walkthrough

Walkthrough

model_selection Rust 크레이트를 워크스페이스에 추가했습니다. 후보 K를 검증하고 Pareto 전선에서 통계 후보를 선택합니다. LLM 전용 후보의 수치 권한을 제한하고 known-K RMSE 검증과 관련 문서를 추가했습니다.

Changes

모델 선택 게이트

Layer / File(s) Summary
워크스페이스 등록
Cargo.toml, crates/model_selection/Cargo.toml, README.md, scripts/check_workspace_contract.py, tests/quality/test_check_docstrings.py, crates/model_selection/tests/crate_contract.rs
model_selection을 workspace 및 default-members에 등록했습니다. 독립 crate 수와 workspace 계약 검사를 11개 기준으로 갱신했습니다.
후보 및 오류 계약
crates/model_selection/src/lib.rs, crates/model_selection/src/error.rs, crates/model_selection/src/candidate.rs, crates/model_selection/tests/pareto_k_gate_contract.rs
ModelCandidateModelSelectionError를 추가했습니다. K, 로그 가능도, 복잡도 입력을 검증하고 LLM 전용 후보를 구분합니다.
Pareto K 선택 및 RMSE
crates/model_selection/src/gate.rs, crates/model_selection/tests/pareto_k_gate_contract.rs
통계 후보의 Pareto 비지배 전선을 구성합니다. 로그 가능도를 우선하고 동률이면 더 작은 K를 선택합니다. 선택된 K의 known-K RMSE를 계산하고 오류 경로를 검증합니다.
설계 및 추적성 문서
ARCHITECTURE.md, CHANGELOG.md, docs/TRACEABILITY.md, docs/adr/*, docs/research/*, docs/validation/*, docs/connectors/*
crate 책임, 후보 K 게이트, LLM 투표 제한, RMSE 증거 및 구현 성숙도 상태를 문서화했습니다. 일부 문서에서는 후행 Markdown 공백만 제거했습니다.

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

Merge Risk: 🟡 Moderate · up to 191f1

The PR adds Pareto-based K admission and selection, but the public API still permits invalid K values below 2, and the claimed recovery behavior is not yet validated with realistic repeated synthetic cases. Documentation also describes planned review behavior and supporting evidence more strongly than the current implementation. Merge should wait for these bounded correctness and evidence issues to be addressed or explicitly accepted.

Sequence Diagram(s)

sequenceDiagram
  participant 호출자
  participant select_candidate_k
  participant ModelCandidate
  participant RMSE 계산기
  호출자->>select_candidate_k: 후보 목록 전달
  select_candidate_k->>ModelCandidate: 통계 후보와 Pareto 전선 검증
  select_candidate_k-->>호출자: 선택된 K 반환
  호출자->>RMSE 계산기: 선택된 K와 truth K 전달
  RMSE 계산기-->>호출자: RMSE 반환
Loading
🚥 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 제목은 통계적 Pareto K 게이트를 추가하고 LLM의 수치적 권한을 제한하는 PR의 주요 변경 사항을 명확하게 요약합니다.
Docstring Coverage ✅ Passed Docstring coverage is 90.48% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 8 files. (13 skipped: 13 unsupported.)
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 agent/model-selection-pareto-gates

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.

# Conflicts:
#	CHANGELOG.md
#	docs/adr/README.md
#	docs/validation/temporal-event-foundation.md
@seonghobae
seonghobae marked this pull request as ready for review August 20, 2026 10:29
@seonghobae

Copy link
Copy Markdown
Contributor Author

Reviewed and integrated current protected main without force-push. I removed the unreachable NoAdmissibleCandidate error/branches: public constructors guarantee that a non-empty non-LLM candidate list has a non-empty Pareto front, so retaining that state would make the 100% coverage contract dishonest.

Current head: 7ff6ae8

Verification at this exact head:

  • cargo fmt --all -- --check
  • cargo test --workspace --offline (all workspace unit, contract, integration, and doctests passed; includes model-selection RMSE/LLM-authority tests)
  • cargo clippy -p model_selection --all-targets --offline -- -D warnings
  • python3 scripts/check_workspace_contract.py
  • python3 scripts/check_docstrings.py
  • python3 scripts/validate_documentation.py
  • git diff --check

Please run protected current-head Checks and obtain the required independent approval before normal merge.

@seonghobae

Copy link
Copy Markdown
Contributor Author

PR #67 current HEAD d735177 (exact remote head). Root causes repaired: impossible partial-diagnostic coverage branches were collapsed into the valid constructor invariant; Pareto ordering now uses the actual likelihood/K contract; realistic invalid-diagnostic and RMSE edge contracts were added; Python docstring contract now accounts for 11 Rust crates. Local proof: Rust 1.97.1 focused fmt/test/clippy passed; branch coverage 1008/1008 (100%); line coverage 2951/2951 (100%); Python quality 89 tests and statement/branch coverage 100%; workspace and docstring contracts passed. No independent qualifying approval or merge was performed.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head review refresh for d735177:

  • Pareto-k diagnostics remain a statistical model-selection gate; the implementation refuses to treat LLM output as numerical or scientific authority.
  • git diff --check, documentation validation, workspace contract, docstring contract, and cargo fmt --all -- --check passed locally.
  • All hosted exact-head checks, including Rust tests, PostgreSQL integration, coverage, security scans, and Strix, pass.
  • No new actionable defect was found at this exact head; no approval is being self-issued.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Exact-head review receipt: merge-conflict repair was completed and pushed at 191f14b8b775292c163a90b85c4f7df7799964eb. Local proof: Rust fmt, documentation validator, workspace contract, model_selection tests, workspace clippy -D warnings, git diff --check, CodeGraph sync, and CodeReviewGraph update. Please run the independent Noema/OpenCode review against this exact SHA; current-head required Checks remain authoritative before merge. @cwl-noema-review @opencode-agent

coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head review receipt

The current CodeRabbit finding is resolved by this head: ModelCandidate::llm_vote_only now returns Result and rejects K < 2; all callers and the invalid-input test were updated. Earlier repeated-truth recovery and research/traceability findings remain addressed by b3854db.

The exact-head Devin comments are informational only: complexity is enforced while constructing the Pareto front, the partial_cmp fallback is unreachable under finite validated diagnostics, the error name is a non-blocking naming nit, and the Pareto-front indexing invariant is covered by the all-LLM guard plus constructors. No current source finding remains unresolved.

Exact-head verification:

  • cargo fmt --all -- --check
  • rustup run 1.97.1 cargo test --workspace --all-features
  • rustup run 1.97.1 cargo clippy --workspace --all-targets --all-features -- -D warnings
  • rustup run 1.97.1 cargo doc --workspace --all-features --no-deps
  • python3 scripts/check_workspace_contract.py
  • python3 scripts/check_docstrings.py
  • line coverage: 3172/3172 (100%)
  • branch coverage: 1140/1140 (100%)
  • git diff --check

Hosted exact-head required Checks are queued with no completed failure observed. There is no qualifying independent approval yet, so this PR remains WAIT_AND_REMEDIATE; no bypass or force merge is authorized.

@seonghobae
seonghobae enabled auto-merge (squash) August 24, 2026 00:58
@opencode-agent
opencode-agent Bot disabled auto-merge August 24, 2026 00:59
@seonghobae
seonghobae enabled auto-merge August 24, 2026 07:29
…-pareto-gates

# Conflicts:
#	ARCHITECTURE.md
#	CHANGELOG.md
#	Cargo.toml
#	README.md
#	docs/TRACEABILITY.md
#	docs/validation/temporal-event-foundation.md
#	scripts/check_workspace_contract.py
#	tests/quality/test_check_docstrings.py
@seonghobae
seonghobae merged commit 1a055f4 into main Aug 24, 2026
23 of 27 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

Open in Devin Review

Comment thread README.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: README prose still says eleven crates

README.md still reads "The eleven bounded crates" while the block below and the workspace now list 12 crates after model_selection was added. Stale prose.

(Refers to this code)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


sources = docstrings.rust_sources(REPOSITORY_ROOT)
crate_roots = sorted(REPOSITORY_ROOT.glob("crates/*/src/lib.rs"))
self.assertEqual(len(crate_roots), 11)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Docstring test hardcodes wrong crate count

The new assertion self.assertEqual(len(crate_roots), 11) hardcodes 11, but adding model_selection brings the workspace to 12 crates, each with a src/lib.rs. The glob returns 12 paths, so the assertion fails and contradicts the next line comparing against len(EXPECTED_CRATES) (12). The quality test suite breaks.

Suggested change
self.assertEqual(len(crate_roots), 11)
self.assertEqual(len(crate_roots), 12)
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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