Skip to content

perf(routing): index psychometric context positions once - #1058

Draft
seonghobae wants to merge 3 commits into
ContextualWisdomLab:mainfrom
seonghobae:codex/autoresearch-psychometric-kpi-20260904
Draft

seonghobae wants to merge 3 commits into
ContextualWisdomLab:mainfrom
seonghobae:codex/autoresearch-psychometric-kpi-20260904

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Successor tracking

The complete delta at this PR's head 3c22bf31c33520b128cb2c449d03e3762e1f4c75 is preserved in trusted-branch successor #1067 at 1481c595dc1d16e7bf4b65addaf0bd30322cf2b8. Commit ancestry and tree equality are recorded in docs/product-technical-gap-baseline.md. Review and required-workflow integration continue there. This PR remains open until protected delivery and a fresh full-delta audit; later changes here must also be carried forward.

Outcome

Reduces deterministic Python-side preparation before the Rust-backed psychometric fit without changing scores, item order, or the fail-closed fit contract. Adds a reproducible accuracy-time KPI contract and research traceability.

Root cause

PsychometricRoutingEvidence._fit_locked() repeatedly scanned the complete context list while sorting item keys, making preparation quadratic at the 512-context ceiling.

Minimal change

Build the context-position mapping once. The benchmark now fails with an actionable message below Python 3.12 and the documented command selects Python 3.12, matching the locked NumPy/fast-mlsirm markers while preserving product support for Python 3.10/3.11.

Autoresearch KPI

Same host/source, 512 contexts, 4 models, 2 dichotomous items/context, 9 samples:

  • protected main@2e414d15: median 2.448167 ms
  • performance commit 0561c9b8: median 1.100583 ms
  • change: 55.04% lower

This isolates gateway preparation; it is not an answer-accuracy claim.

Exact-head verification (3c22bf31)

  • uv run --python 3.12 python scripts/benchmark_psychometric_routing.py
  • focused psychometric/paper/gap contracts: 14 passed
  • git diff --check

The Python-runtime review finding is fixed and its thread is resolved. ruff is not present in the locked environment, so no unpinned tool was installed.

Summary by CodeRabbit

  • 성능 개선

    • 심리측정 라우팅의 항목 정렬 처리 효율을 개선해 고정 피팅 게이트웨이 지연 시간을 줄였습니다.
  • 벤치마크

    • 라우팅 오버헤드와 결정 지연 시간을 측정하는 벤치마크를 추가했습니다.
    • 정확도와 지연 시간을 함께 평가할 수 있는 기준과 측정 방법을 문서화했습니다.
  • 테스트

    • 벤치마크의 Python 3.12 실행 요구사항을 검증하는 테스트를 추가했습니다.
  • 문서

    • 심리측정 라우팅 평가 기준, 성능 결과 및 관련 참고문헌을 업데이트했습니다.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 7c64e9f0-c5d3-4139-8a69-d964da3264ed

📥 Commits

Reviewing files that changed from the base of the PR and between 2e414d1 and 3c22bf3.

📒 Files selected for processing (6)
  • contextual_orchestrator/psychometric_routing.py
  • docs/doctoring/measured-routing-evidence.md
  • docs/papers/README.md
  • docs/product-technical-gap-baseline.md
  • scripts/benchmark_psychometric_routing.py
  • tests/test_psychometric_routing.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

심리측정 라우팅의 컨텍스트 위치 조회를 최적화했습니다. Python 3.12 전용 벤치마크를 추가했습니다. 정확도와 지연 시간을 함께 평가하는 문서 기준과 런타임 테스트를 추가했습니다.

Changes

심리측정 라우팅 평가

Layer / File(s) Summary
피팅 항목 위치 조회 최적화
contextual_orchestrator/psychometric_routing.py
context_positions 사전을 사용해 IRT 항목 정렬에서 반복적인 context_ids.index() 호출을 제거했습니다.
Python 3.12 벤치마크 실행
scripts/benchmark_psychometric_routing.py, tests/test_psychometric_routing.py
512개 컨텍스트와 4개 모델을 사용해 9회의 ranked_evidence 지연 시간을 측정합니다. Python 3.12 미만에서는 종료하고 실행 안내를 출력합니다. 결과를 JSON으로 출력합니다.
정확도-시간 평가 기준 문서화
docs/doctoring/measured-routing-evidence.md, docs/papers/README.md, docs/product-technical-gap-baseline.md
벤치마크 측정 결과, held-out 예측 품질, RMSE, 경로 결정 지연 시간, 정확도-시간 수용 기준을 문서화했습니다. He & Qi (2023)와 Song et al. (2025) 참고문헌을 추가했습니다.

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

Merge Risk: ⚪ Minimal · up to 3c22b

This change speeds psychometric routing preparation without changing routing policy, APIs, or item order. No current merge-blocking risk is identified.

Sequence Diagram(s)

sequenceDiagram
  participant Benchmark
  participant PsychometricRoutingEvidence
  participant fast_mlsirm
  Benchmark->>PsychometricRoutingEvidence: 512개 관측값 기록
  Benchmark->>fast_mlsirm: 피팅 및 확률 예측 패치
  Benchmark->>PsychometricRoutingEvidence: ranked_evidence 9회 호출
  PsychometricRoutingEvidence->>fast_mlsirm: 고정 피팅 및 예측 수행
  Benchmark-->>Benchmark: 지연 시간 중앙값과 샘플 결과 출력
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 심리측정 라우팅에서 컨텍스트 위치를 한 번만 인덱싱하는 핵심 성능 개선을 정확하고 간결하게 설명합니다.
Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T14:13:51.251178Z 3c22bf3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2f90116b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/benchmark_psychometric_routing.py Outdated
Signed-off-by: Seongho Bae <me@seonghobae.me>
seonghobae added a commit that referenced this pull request Sep 5, 2026
PR #1067 has exactly the same tree as #1058, already an ancestor of #1064.
Preserve both histories and the complete #1064 tree without reapplying
identical cherry-picked changes. The successor update remains a fast-forward.

Source tree: 8735f95
Predecessors: #1058, #1059, #1061, #1062, #1064.
No predecessor is closed before protected delivery and delta verification.

Signed-off-by: Seongho Bae <me@seonghobae.me>

@opencode-agent opencode-agent 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.

Pull request overview

OpenCode reviewed the current-head product diff. Coverage is a separate gate.

Changed files

  • contextual_orchestrator/psychometric_routing.py — Python module behavior
  • docs/doctoring/measured-routing-evidence.md — operator or user guidance
  • docs/papers/README.md — operator or user guidance
  • docs/product-technical-gap-baseline.md — operator or user guidance
  • scripts/benchmark_psychometric_routing.py — Python module behavior
  • tests/test_psychometric_routing.py — regression suite

Changed behavior

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Python: psychometric_routing.py (2 files)"]
  S1 --> I1["Python module behavior"]
  I1 --> R1["Review risk: Python: psychometric_routing.py (2 files)"]
  R1 --> V1["pytest plus coverage"]
  Evidence --> S2["Docs: measured-routing-evidence.md (3 files)"]
  S2 --> I2["operator or user guidance"]
  I2 --> R2["Review risk: Docs: measured-routing-evidence.md (3 files)"]
  R2 --> V2["docs review"]
  Evidence --> S3["Test: test_psychometric_routing.py"]
  S3 --> I3["regression suite"]
  I3 --> R3["Review risk: Test: test_psychometric_routing.py"]
  R3 --> V3["targeted test run"]
Loading

Findings

No source-backed product finding is synthesized from the coverage gate. A coverage miss belongs in the status comment.

  • Head SHA: 3c22bf31c33520b128cb2c449d03e3762e1f4c75
  • Workflow run: 33897183732
  • Workflow attempt: 1
  • Coverage gate: failure

Review outcome

Coverage is a gate, not the review. This body reviews the changed product files.

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Python: psychometric_routing.py (2 files)"]
  S1 --> I1["Python module behavior"]
  I1 --> R1["Review risk: Python: psychometric_routing.py (2 files)"]
  R1 --> V1["pytest plus coverage"]
  Evidence --> S2["Docs: measured-routing-evidence.md (3 files)"]
  S2 --> I2["operator or user guidance"]
  I2 --> R2["Review risk: Docs: measured-routing-evidence.md (3 files)"]
  R2 --> V2["docs review"]
  Evidence --> S3["Test: test_psychometric_routing.py"]
  S3 --> I3["regression suite"]
  I3 --> R3["Review risk: Test: test_psychometric_routing.py"]
  R3 --> V3["targeted test run"]
Loading

@opencode-agent

opencode-agent Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

Coverage evidence did not pass, so approval is blocked. The formal pull-request review is the source-backed diff review, not this status comment.

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

Labels

maintenance priority: medium Normal-priority or P2 work type: maintenance Maintenance, build, dependency, or operational upkeep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant