Skip to content

test(go): policy rerank + novelty — formula / sort / Python parity gates#92

Open
couragehong wants to merge 1 commit intofeat/go-migrationfrom
yg/phase-a7-policy-rerank-novelty-tests
Open

test(go): policy rerank + novelty — formula / sort / Python parity gates#92
couragehong wants to merge 1 commit intofeat/go-migrationfrom
yg/phase-a7-policy-rerank-novelty-tests

Conversation

@couragehong
Copy link
Copy Markdown
Contributor

Summary

Python 대비

영역 처리 비고
test_novelty_check.py (5 cases) 전부 포팅 + 보강 boundary just-below / at / just-above
searcher.py::_apply_recency_weighting first-time coverage Python unit test 0건
searcher.py::_filter_by_time first-time coverage
상수 HALF_LIFE_DAYS / SIM_W / REC_W / STATUS_MULTIPLIER / TimeRanges locked-by-value silent drift 차단

강화 포인트 (Python 미가드)

  • 4 novelty class boundary (just-below / at / just-above)
  • 4 status × Score=0.5+decay=1.0 (bracket=0.65) → weight swap (0.3raw + 0.7decay) 회귀 잡음 (기존엔 1.0×statusMul로 swap이 통과해버림)
  • math.Floor age 1.5d → 1d (Python timedelta.days int truncation parity)
  • nil Metadata / empty string ts / wrong type ts / int ts 모든 type-switch path
  • AdjustedScore 정렬: raw≠adjusted 구별 (old_top_raw 0.99/900d vs fresh_top_raw 0.99/0d — sort-by-raw mutation은 stable tie 입력순으로 다른 결과)
  • stable sort tie 입력순 보존
  • in-place mutation backing-array identity (2 hits, copy-then-return 회귀 잡음)
  • cutoff inclusive time.RFC3339Nano (nanosecond 경계 정확 — 기존 RFC3339은 sub-second 잘려서 1초 경계로 둔갑)

Python ↔ Go divergence witness

production rerank.go / novelty.go 의 Phase-A debt 두 건을 테스트 차원에서 명시 lock:

  • banker_round_diverges_from_python (sim=0.12355): Python round banker's → 0.8764 / Go math.Round away-from-zero → 0.8765 (Go semantics lock, TODO 주석)
  • int_timestamp_90d_diverges_from_python (90d-old int ts): Python float(int) coerce → adj=0.85 / Go type-switch skip → adj=1.0 (Go semantics lock, JSON 와이어는 float64라 production unreachable; raw int caller만 영향)

Validation

  • go test -count=1 -race ./internal/policy/ → ok 1.5s, 19 함수 / 77 subtest
  • gofmt -l (이 PR 신규 파일) → clean
  • go vet ./... → clean
  • 사전 self-review: 9건 발견·수정 (중복 케이스 / 잘못된 코멘트 / nil Metadata 누락 등)
  • 사전 multi-agent review: 3 서브에이전트 (adversarial logic / Python parity / Go style) 발견 사항 11건 반영 — HIGH 4 (one_ns_older 1초 → ns / FormulaGate Score≠1.0 / Status bracket≠1.0 / int divergence) + MED 5 (Future 30d / Sort raw≠adjusted / WireValues paired-swap / wrong_type symmetry / Mutates 2 hits) + parity 3 (banker / +00:00 / empty string). citation 1건은 auditor 오류 (mcp/server/server.py 위치 정확) 검증 후 기각.

Cross-Agent Invariants

테스트 파일 2개만 추가. scripts/bootstrap-mcp.sh, agent 스크립트, Codex/Claude/Gemini/OpenAI 지시서, SKILL.md, commands/rune/*.toml, AGENT_INTEGRATION.md 모두 미수정 → 모든 invariant trivially 만족.

Notes for Reviewers

  • Risk (Phase-A debt lock-in): int_timestamp_90d_diverges_from_python + banker_round_diverges_from_python 두 건은 현재 Go 동작을 lock-in. Python parity 원하면 별도 production-fix PR (rerank.go type switch에 case int: 추가 / novelty.go math.Round → banker's helper). 두 건 모두 production wire (JSON-decoded float64 / D11 thresholds 0.3/0.7/0.95)에서는 unreachable.
  • Risk (one_ns_older 정정): 기존 self-review 단계엔 time.RFC3339로 작성되어 sub-second 잘림 → 실제로 1초 차였음. RFC3339Nano로 수정하면서 nanosecond 경계 정확 검증.
  • BC: 없음 (test-only).
  • Follow-up PR: domain/schema_test.go (ParseDomain customer_escalation alias divergence + 한글 GenerateRecordID + EnsureEvidenceCertaintyConsistency 3 path) · lifecycle/shutdown_test.go (InflightTracker concurrency + ZeroizeDEK dead-store 가드).

🤖 Generated with Claude Code

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