Skip to content

test: ジオデシック strut が閉じた三価ケージであることを検証#288

Merged
GeneralD merged 3 commits into
mainfrom
test/geodesic-trivalent-cage
Jun 14, 2026
Merged

test: ジオデシック strut が閉じた三価ケージであることを検証#288
GeneralD merged 3 commits into
mainfrom
test/geodesic-trivalent-cage

Conversation

@GeneralD

@GeneralD GeneralD commented Jun 14, 2026

Copy link
Copy Markdown
Owner

type breaking scope diff files tests review

#287 で抽出した GeodesicGeometry のテストを補強する。

背景

既存テストは strut が 120 本であることだけを固定していた。しかし面リストや細分化が壊れても、本数 120 を保ったまま双対のトポロジーだけが崩れるケースは検出できない。

変更

各 strut 端点(= icosphere 三角形の centroid = Goldberg 双対の頂点)の接続次数を数え、不変条件を1つ追加する。

  • ハブ(ユニーク頂点)が 80 個ちょうど
  • 全ハブの次数が 3(閉多様体なので各三角形は3辺すべてを共有 → 三価ケージ)
  • 80 × 3 / 2 = 120 で既存の 120-edge テストと整合

座標は値コピーで再利用されるため、1e-6 量子化キーで同一 centroid を1つの identity に畳む(最近接 centroid 間距離 ≈ 0.36 ≫ 1e-6 なので衝突しない)。Foundation 非依存。

補足

双対の「12 pentagon + 30 hexagon」はケージのの話で、strut 端点(頂点)は一様に次数3。エッジリストから面を循環抽出するのは過剰なので、頂点レベルで効く三価性で構造を固定した。

swift test --filter GeodesicGeometryTests → 4 件すべてパス。

Summary by CodeRabbit

Release Notes

  • Chores

    • Version bumped to 2.14.2.
  • Tests

    • Expanded test suite with geodesic geometry validation tests, verifying structural integrity and proper hub formation in geometric constructs.

GeneralD added 2 commits June 15, 2026 04:00
The dual edge list already had a 120-edge invariant, but a malformed
subdivision could hold that count while skewing the hub topology. Count
each strut endpoint's degree and assert all 80 centroids are trivalent
(80 × 3 / 2 = 120), pinning the closed-manifold structure the edge-count
test alone can miss.
Copilot AI review requested due to automatic review settings June 14, 2026 19:01
@GeneralD GeneralD self-assigned this Jun 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@GeneralD, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 45 minutes and 16 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5026fb11-bc8d-4f4c-b22f-0e229601cb1d

📥 Commits

Reviewing files that changed from the base of the PR and between 2dc9864 and ad0f3af.

📒 Files selected for processing (1)
  • Tests/ViewsTests/GeodesicGeometryTests.swift
📝 Walkthrough

Walkthrough

Version string bumped from 2.14.1 to 2.14.2. A private key(_:) helper quantizes Vertex3D coordinates to stable [Int] identities; a new trivalentCage test uses it to assert that GeodesicGeometry.edges produces exactly 80 hubs each with degree 3.

Changes

Version Bump

Layer / File(s) Summary
Version string
Sources/VersionHandler/Resources/version.txt
Single-line update from 2.14.1 to 2.14.2.

Trivalent Cage Test

Layer / File(s) Summary
key helper and trivalentCage assertion
Tests/ViewsTests/GeodesicGeometryTests.swift
Adds private key(_:) that rounds Vertex3D coordinates to a fixed precision for stable endpoint identity, and trivalentCage which groups GeodesicGeometry.edges endpoints by that key and asserts 80 hubs each of degree 3.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related PRs

  • GeneralD/lyra#286: Introduces or exercises the same GeodesicGeometryTests file and GeodesicGeometry wireframe structure that this PR extends with the new trivalentCage test.

Poem

🐇 Hop hop, the version ticks higher,
From .1 to .2, climbing ever higher!
Eighty hubs, each with edges of three,
A trivalent cage — pure geometry!
The geodesic dome stands proud and bright,
Tested and bumped, everything's right. ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is partially related to the changeset, referring to a real aspect of the changes (verifying geodesic struts form a trivalent cage), but it is written in Japanese and is somewhat vague without knowing the language context. The changes do add tests for trivalent cage validation, so the title captures the core intent.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/geodesic-trivalent-cage

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 and usage tips.

@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@GeneralD GeneralD left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

verdict depth findings

ジオデシック幾何構造が「三価ケージ(各頂点の次数が3、合計80頂点)」であることを検証する不変条件テストが追加されました。実装はプロジェクトの規約に適合しており、品質も良好です。パフォーマンスと型安全性の観点から微細な改善提案を添えています。

※自身のPRのため、Approveの代わりにCommentとして投稿します。

/// vertices never collide.
private func key(_ v: Vertex3D) -> [Int] {
[v.x, v.y, v.z].map { Int(($0 * 1_000_000).rounded()) }
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

severity

辞書のキーとして [Int] を使用する代わりに、専用の Hashablestruct を定義することを検討してください。これにより、意図が明確になり、配列の動的確保(ヒープ割り当て)も避けられます。

    private struct QuantizedVertex: Hashable {
        let x, y, z: Int
    }

    private func key(_ v: Vertex3D) -> QuantizedVertex {
        QuantizedVertex(
            x: Int((v.x * 1_000_000).rounded()),
            y: Int((v.y * 1_000_000).rounded()),
            z: Int((v.z * 1_000_000).rounded())
        )
    }

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

action

ご提案どおり専用の Hashable struct QuantizedVertex に置き換えました。意図が明確になり、辺ごとの [Int] 配列確保も 解消 しています。ad0f3af

// triangles, i.e. a vertex of the Goldberg dual. A closed manifold
// makes every triangle share all 3 of its edges, so each centroid is
// trivalent. 80 hubs × 3 / 2 = 120 struts — consistent with edgeCount.
// A broken face list or non-manifold subdivision would drop a hub or

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

severity

flatMap を使用して中間配列を作成する代わりに、reduce で直接集計することで、不要な中間ステップを排除できます。これはプロジェクトの「No Unnecessary Intermediate Steps」という規約により適合します。

        let degree = GeodesicGeometry.edges
            .reduce(into: [[Int]: Int]()) { dict, edge in
                dict[key(edge.0), default: 0] += 1
                dict[key(edge.1), default: 0] += 1
            }

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

action

flatMap の中間配列を 排除 し、両端点を1つの reduce(into:) に直接畳み込みました。ad0f3af

Replace the [Int] dictionary key with a dedicated Hashable QuantizedVertex
struct (clearer intent, no per-edge array allocation) and fold the degree
count directly into one reduce, dropping the intermediate flatMap array.
@GeneralD GeneralD merged commit 5781118 into main Jun 14, 2026
4 checks passed
@GeneralD GeneralD deleted the test/geodesic-trivalent-cage branch June 14, 2026 19:19
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.

2 participants