Repository navigation
Port math lib and registrum alias api to 1.21.4 移植数学库和注册库别名API到1.21.4 - #130
Conversation
Cherry-pick of 7285ae1 (Add math lib 添加数学库 (Anvil-Dev#122)) adapted to 1.21.4: - javax.annotation nullness instead of jspecify @NullMarked - ResourceLocation instead of Identifier - 1.21.4-style module build script
Cherry-pick of 892ef23 (Add alias api for Registrum 向Registrum加入别名API (Anvil-Dev#128)) adapted to this version.
Reason: shell execution via heredoc Reply |
Reason: recursive delete Reply |
🌿 Roseau API Breaking Change Report
|
Reason: Security scan — [MEDIUM] Archive extraction to sensitive path: Archive command 'tar' extracts to a potentially sensitive location Reply |
代码审查摘要 — PR #130操作: 📋 移植来源核对(与来源分支逐字节比对)
🔴 关键(阻塞合并)
sourceSets { test { compileClasspath += sourceSets.main.compileClasspath; runtimeClasspath += sourceSets.main.compileClasspath } }
tasks.register('runShapeUtilJoinTimingTest', JavaExec) { mainClass = 'dev.anvilcraft.lib.v2.util.ShapeUtilJoinTimingTest' }
tasks.named('check') { dependsOn tasks.named('runShapeUtilJoinTimingTest') }
|
| 被测目标 | 建议场景 | 优先级 |
|---|---|---|
修掉 ShapeUtil 任务后的 :anvillib-math-neoforge-1.21.4:check |
确认 math 的 JUnit 测试仍被执行(useJUnitPlatform() + fuzz 轮数) |
🔴 |
AbstractRegistrum.applyAliases 真实档案路径 |
改名后的方块/物品/BE id 从旧存档(chunk palette、物品栈、BE id)载入成功;并确认注释中"数据包文件名、字符串比较不走别名"的边界 | 🟡 |
MathTestBootstrap.bindValue 反射改绑 |
补一条断言:1.21.4 上同名重复注册确实抛异常(否则该 hack 的存在理由会随版本失效) | 🟢 |
结论: REQUEST_CHANGES — 移植本身质量很高(源分支对齐、注册库别名 API 在 1.21.4 的可用性与语义已核实);唯一阻塞项是 module.math/build.gradle 里 module.util 的测试任务残留会让 build/CI 失败,删除即可;其余为文档同步(README.en.md、PORTING 文档)与注释准确性。
|
💾 Self-improvement review: Patched SKILL.md in skill 'reverse-port-pr-review' (1 replacement). |
The 1.21.4-style module build script was based on module.util/build.gradle and brought three blocks that belong to util: a test sourceSets tweak, the runShapeUtilJoinTimingTest JavaExec task, and a check dependency on it. ShapeUtilJoinTimingTest lives in module.util/src/test, which is not on this module's test runtime classpath, so the task failed with ClassNotFoundException and broke :anvillib-math-neoforge-1.21.4:build.
The Math entries added in the port were missing from README.en.md. Both are packaged into the jar, so English readers had no math coordinates.
The test comments describing MappedRegistry and RegistryLookup named 26.1 even though the behaviour is the same here; they now name this version.
Reason: Security scan — [HIGH] Pipe to interpreter: curl | python3: Command pipes output from 'curl' directly to interpreter 'python3'. Downloaded content will be executed without inspection. Reply |
Reason: Security scan — [MEDIUM] Variation selector characters detected: Content contains Unicode variation selectors (VS1-256). These are commonly used in emoji sequences but may indicate steganographic encoding or obfuscation Reply |
代码审查摘要 — PR #130(重新审查 ·
|
| 上次结论 | 提交 | 复核结果 |
|---|---|---|
🔴 module.math/build.gradle 残留 module.util 的 ShapeUtilJoinTimingTest 任务 / sourceSets 块 / check.dependsOn,会让 build 必挂 |
f95dca5c |
✅ 已删除(git grep ShapeUtil 在 module.math 下无命中);check 无额外依赖,单测仍由 useJUnitPlatform() + addModdingDependenciesTo(sourceSets.test) + junit-bom 提供 |
README.en.md 未同步 Math |
5e033f2d |
✅ Features 表新增 Math 行、新增 Math Module 章节(含 Groovy/Kotlin 依赖片段)、模块 id 列表与「Main 聚合子模块」清单都补了 math——中英已对称 |
| 💡 测试注释误指 26.1 | 92152394 |
✅ MathTestBootstrap、ParseCacheTest 两处改为「1.21.4」 |
🟢 CI 证据(head 92152394)
build-l2 (math, anvillib-math, anvillib_math) / build→ success(Gradlebuild含check→test,即 math 的表达式解析/回写往返、编解码等 JUnit 测试已在 CI 上真实跑过)roseau-l2 (math …) / check→ success;全仓 39 项检查中 37 项已完成且全绿,仅main / build、multiblock (roseau)仍在进行
🟢 移植保真度复核(本次重新独立核对)
- module.math:与来源
dev/1.21.1(PR Add math lib 添加数学库 #122 /7285ea13)逐文件比对,仅 7 个文件有差异,且全部是 1.21.1→1.21.4 的必要适配——build.gradle(util 坐标、data()→clientData())、IFunction.typeOf(getHolderOrThrow→getOrThrow)、MathTestBootstrap(asLookup()→注册表自身、RegistryAccess.registry()→lookup()、补Frozen.freeze()覆写、重复键反射改绑)、4 个测试调用点同步替换。文件集合与来源一一对应,无漏移植、无多余文件。 - registrum 别名 API:
AbstractBuilder.register()/aliasFrom()/addAliases()/getEntryId()与来源dev/1.21.1(PR Add alias api for Registrum 向Registrum加入别名API #128 /892ef231)逐行一致(仅上下文行号漂移),addAlias/applyAliases与 Block/Entity/Fluid 三处addAliases覆写同样一致。 - 别名生效时序正确:
onRegister(普通优先级)注册条目 →onRegisterLate(EventPriority.LOWEST)才applyAliases,因此方块物品、刷怪蛋、桶、flowing_流体等派生条目以及其它模组的条目此刻都已就位;registry.resolve(old).equals(new)守卫正好对应 NeoForge 对重复别名的抛错行为,addAlias内的「同名不同目标」去重也有对应的 error 日志。 - 集成清单齐套:
settings.gradle(include + 项目重命名,与 CI 推导的anvillib-math-neoforge-1.21.4完全对上)、module.main/build.gradle(NOT_DEV 与本地两处jarJar)、.github/modules.json(mathneedsutil,与IFunction实际引用的dev.anvilcraft.lib.v2.util.ISerializer一致)、gradle.properties、mods.toml(字段形态与 registrum 相同,[[mixins]] config与文件名对应)、空 mixins +anvillib.refmap.json(与 network/registrum/util 既有约定一致)、icon.png(与其它模块同一张,md5 相同)。CI 矩阵由modules.json自动生成,新增模块无需改 workflow。
💡 建议(非阻塞)
PORTING_1_21_1_TO_1_21_4.md未同步 — 功能对照表缺 Math 一行,正文两处「聚合全部 17 个功能模块」「17 个模块依赖」现在应为 18。README 已补,这份移植记录文档漏了。.github/modules.json格式 — 新增行的"needs"列比同组邻居少 2 个空格(纯格式)。AbstractRegistrum.addAlias(...)的迟到调用会被静默吞掉 — 别名只写入aliases映射,而applyAliases仅在onRegisterLate执行一次(该监听在FMLCommonSetupEvent还会被注销);若下游在注册期之后调用,既不会应用、也没有任何日志,条目还会长期留在 map 里。加一行if (completedRegistrations.contains(registryType)) log.warn(...),并在 javadoc 明确「必须在注册期调用」,可把「静默失效」变成可诊断(NeoForge 原生registry.addAlias在冻结注册表上会抛错,语义上正好相反)。
🧪 测试建议
| 被测目标 | 建议场景 | 优先级 |
|---|---|---|
AbstractRegistrum.applyAliases |
旧名从旧存档真实载入(chunk palette / 物品栈 / BE id)确实解析到新条目;并覆盖「旧名仍注册 → warn 跳过」「新名未注册 → debug 跳过」两条路径 | 🟡 |
AnvilLibMath / LibRegistries |
空 anvillib_math.mixins.json(required=true、无 mixin、声明的 refmap 不存在)在专用服务器启动时无警告/无缺失 refmap 报错 |
🟢 |
结论: APPROVE — 上次唯一的阻塞项(从 module.util 抄来的测试任务残留)已删除,anvillib-math 的 build(含单元测试)与 roseau 检查在 CI 上均已通过;与来源分支的差异全部是必要的版本适配,派生条目别名覆盖与时序均正确。剩余仅为移植记录文档同步与两处格式/健壮性小建议,可随后续提交处理。
PR 标题「Port math lib and registrum alias api to 1.21.4 移植数学库和注册库别名API到1.21.4」准确且符合 <英文> <中文> 格式,未作修改。
由 Hermes Agent 审查
|
💾 Self-improvement review: Patched SKILL.md in skill 'reverse-port-pr-review' (1 replacement). |
🌿 Roseau API Breaking Change Report
|
|
PR #130 状态为 closed,按 webhook 审查规则(closed/labeled → 停止),本次不进行代码审查,也不发布审查评论。 (由 Hermes Agent 自动判定:非活跃 PR,无需审查) |
No description provided.