Skip to content

refactor(cache): collapse loader binding and narrow failure-handling seam - #30

Merged
DavidHLP merged 3 commits into
mainfrom
refactor/loader-binding-failure-seam
Sep 20, 2026
Merged

DavidHLP merged 3 commits into
mainfrom
refactor/loader-binding-failure-seam

Conversation

@DavidHLP

@DavidHLP DavidHLP commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Summary

按 2026-09-20 架构审查决策(两份候选全部采纳)收窄两个内部 module 的测试专用调用协议:

  • Loader:删除 LoaderOrchestrator 三参未绑定构造器与七参 orchestrate 入口;六参构造器构造期以 Objects.requireNonNull 校验三个必需回调,四参入口成为唯一实例入口;LoaderOrchestratorTest 全部迁移到构造绑定路径,新增构造校验、同实例双 key、null 命中用例。
  • 失败处理:删除显式策略的 public handleException 转发重载与全链路无效的 key/pattern 参数;测试改经真实 operation 驱动策略,以独立 SimpleMeterRegistry 断言 operation/kind/strategy tags(字面量期望,不读取生产策略表);handleError_clean_acceptsPattern 替换为 typed PARTIAL_CLEANfinalizeFailure 行为测试。

公开缓存使用方式、handler/observer 契约、序列化格式、指标命名均不变。

Checklist

  • ./mvnw clean verify -B passes (remote-dev @ c32097d: 916 tests, 0 failures, coverage checks met).
  • ./mvnw checkstyle:check -B passes (remote-dev @ c32097d).
  • New behavior has tests (构造 null 回调 ×3、同实例双 key、null-value 命中、typed PARTIAL_CLEAN 最终化、null-input 拒绝).
  • Redis integration tests use AbstractRedisIntegrationTest (仅 4 处 Mockito stub 参数位调整;由完整 verify 覆盖).
  • bash scripts/ci/check-test-names.sh passes (remote-dev).
  • bash scripts/ci/check-docs-contracts.sh passes (remote-dev).
  • No dated/task-local documents added; Javadoc of changed internal entries updated in place.
  • Checked against STABILITY.md — internal module only; stable seams and allowlisted nested types untouched.
  • No over-engineering: no new types, adapters, dependencies or config surface.
  • Javadoc/Chinese rationale consistent with existing style.
  • Conventional Commits (refactor(cache) ×2).
  • Packaged consumer gate scripts/ci/check-external-consumer.sh passes (remote-dev; required RESICACHE_JDK21 override to zulu-21 — script default temurin path absent on that host, environment note only).

定向单测另过:-Punit -Dtest=LoaderOrchestratorTest,CacheErrorHandlerTest,RedisProCacheLoadPathTest,RedisProCacheWriterFailureTest,CacheFailureReporterTest,FailureLogKeyPrivacyTest → 74/74。GitHub Actions 全绿。

Backward compatibility

  • 内部实现收窄:LoaderOrchestratorCacheErrorHandler 均为 package-private 内部类型;不改变公开 seam、wire 格式或默认行为。失败计数、脱敏日志、typed failure 最终化契约保持。
  • No user-visible default/metric-namespace change → no CHANGELOG entry (consistent with prior internal refactors, e.g. 6adf2e3).

…entry

The 3-arg unbound constructor and the 7-arg per-call callback entry only
existed to serve the old test wiring protocol; production RedisProCache
already binds the three callbacks at construction. Delete both shallow
entries, validate the required callbacks with Objects.requireNonNull at
construction (assembly errors now fail at construction, not per call),
and have executeSyncLoad/executeLoad read the bound final fields so all
loader behavior flows through the single 4-arg orchestrate seam.

Migrate every LoaderOrchestratorTest case onto the same constructor-bound
path the production adapter uses, preserving the bloom / sync / hit /
null / loader-failure / write-back-tolerance assertions, and add the
constructor-validation, cross-call no-state, and null-value-wrapper-hit
cases required by the accepted design (L01-L10, §2.5).
The 5-arg handleException(strategy) overload existed only for tests and
exercised operation/strategy combinations production never selects; every
failure now routes through the operation-driven handleError seam. The
key/pattern parameter was threaded through both handleError forms and the
private helper but never used by the failure implementation, so it is gone.

Migrated CacheErrorHandlerTest to real operations, proving the per-operation
strategy through metric tags with independently written expectations, added a
typed PARTIAL_CLEAN + finalizeFailure behavior test for the partial-clean
kind, and moved the key-privacy sentinel into the exception message.
@DavidHLP
DavidHLP marked this pull request as ready for review September 19, 2026 16:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 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-19T16:46:10.290934Z 7bc9572 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.

Trailing whitespace on javadoc and builder lines, one tab-indented
BloomFilterConfig block and two files missing their final newline all
violated the committed .editorconfig rules (4-space indent, trim trailing
whitespace, insert final newline) that no automated check enforces.

Whitespace-only: `git diff -w` against the parent is empty, so compiled
bytecodes and behavior are unchanged. testcontainers.properties gained its
missing trailing newline so the file ends like every other tracked text file.
@DavidHLP
DavidHLP merged commit 6289143 into main Sep 20, 2026
10 checks passed
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