Repository navigation
Conversation
Applies the changes from #8 that are either provably behaviour-preserving or test-only. Fixes an overflow trap in MarkdownDetector.detect. `score * score * score` was evaluated in Int before the Float conversion, so it trapped once the score reached 2_097_152 — verified reachable with a ~5 MB heading-dense log, which previously exited with SIGTRAP and now returns normally. Moving the gate arithmetic to Double changes no decision: a brute-force comparison of the old and new gate over 9,003,000 (score, lines) combinations found zero differences. Lowers the platform floor from macOS 26 to macOS 13. Nothing in the package required macOS 26; `Grid` in MarkdownTableView is the only constraint below that, and it is macOS 13+. Builds clean at the new floor with no code changes. Adds Hashable to MarkdownBlock, InlineNode, and MarkdownTableModel, and Equatable to MarkdownStyle. All conformances are synthesised. This lets SwiftUI diff parsed content instead of re-rendering on every parent update, and is a prerequisite for the streaming work in #8 §2.5. Adds the missing `import Foundation` to MarkdownDetector, which used components(separatedBy:) while relying on Markdown to re-export Foundation. Adds coverage for two previously untested behaviours: the http/https link allowlist that DESIGN.md requires, and the presentation-intent union that keeps `***bold italic***` carrying both intents on one run. Both pass against current behaviour; removing the allowlist makes the first fail with 5 issues, so it is not vacuous. Testing them required relaxing InlineTextView.attributedString(for:) from private to internal. README: corrects the Development commands, which referenced a Packages/MarkdownKit path that does not exist in this repository, and records the new platform requirement. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Greptile SummaryThe PR fixes an integer-overflow trap in Markdown detection while preserving its decision thresholds, lowers the supported macOS floor to 13, and adds synthesized value conformances to parsed models and styles.
Confidence Score: 5/5The PR appears safe to merge, with no concrete correctness or security defects identified in the changed code. The overflow-safe arithmetic preserves the established detector gates, the new conformances cover complete value graphs, and the rendering tests pin existing security and formatting behavior without changing production output.
|
| Filename | Overview |
|---|---|
| Package.swift | Lowers the declared macOS deployment target to 13; reviewed package source uses APIs compatible with that floor. |
| Sources/MarkdownKit/Detection/MarkdownDetector.swift | Moves score arithmetic into Double, preventing the prior integer-overflow trap without changing established reachable gate decisions. |
| Sources/MarkdownKit/Model/MarkdownBlock.swift | Adds structurally synthesized Hashable conformances across the recursive block and inline value graph. |
| Sources/MarkdownKit/Model/MarkdownTableModel.swift | Adds synthesized hashing to the table, cell, and alignment models without changing table normalization. |
| Sources/MarkdownKit/Styling/MarkdownStyle.swift | Adds synthesized equality across all stored style tokens and heading styles. |
| Sources/MarkdownKit/Rendering/MarkdownInlineRenderer.swift | Widens one rendering helper to internal visibility solely to enable direct regression testing. |
| Tests/MarkdownKitTests/InlineTextViewTests.swift | Adds focused tests for safe URL-scheme activation and preservation of nested presentation intents. |
| README.md | Documents macOS 13 support, installation from the currently available branch, and corrected local build commands. |
Reviews (1): Last reviewed commit: "fix: overflow-safe detection, macOS 13 f..." | Re-trigger Greptile
This was referenced Aug 28, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applies the subset of #8 that is either provably behaviour-preserving or test-only. Everything here was verified by building and running, not by inspection.
Deliberately excluded: the depth cap (#8 §1.1),
.disableSmartOpts(§1.3), and everything in the "not low risk" tier. Those change output or architecture and deserve their own PRs.What's in
Overflow trap in
MarkdownDetector.detect(#8 §1.2)Float(score * score * score)evaluated the multiplication inIntbefore converting, so it trapped atscore >= 2_097_152.score 2097152, enable=true.(score, lines)combinations — zero decisions differ. The six boundary cases inmathematicalBoundaryContractstill pass unchanged.Platform floor: macOS 26 → macOS 13 (#8 §3.1)
Nothing in the package needed macOS 26. I rebuilt from a clean
.buildat each floor: macOS 14 and 13 both compile with zero errors and zero warnings, no code changes. macOS 12 fails, and only onGridinMarkdownTableView.swift, which is macOS 13+ — so 13 is the true floor. This only widens support; behaviour on macOS 26 is identical.Hashable/Equatableon the model (#8 §2.5)MarkdownBlock,InlineNode,MarkdownTableModel(+Cell,ColumnAlignment) getHashable;MarkdownStyle(+ heading styles) getsEquatable. All synthesised — no hand-written conformances. This lets SwiftUI diff parsed content instead of re-rendering on every parent update, and is the prerequisite for the incremental-parse work in §2.5.Worth noting explicitly: this is additive public API, so it's a permanent commitment. It's the conformance you'd want regardless, but it's the one change here that can't be quietly reverted later.
import FoundationinMarkdownDetector(#8 §1.5)components(separatedBy:)was resolving only becauseMarkdownre-exports Foundation. Pure hygiene, zero behaviour change.Two regression tests (#8 §7)
New
InlineTextViewTests:onlyHTTPAndHTTPSLinksAreActionable— pins the allowlistDESIGN.mdrequires ("Treat input as untrusted"). Covershttps,http, uppercaseHTTPS, and assertsjavascript:,file:,data:,runbot:,mailto:, and empty destinations stay inert while their label text remains visible. This was the one security-relevant behaviour in the package with no coverage.nestedEmphasisUnionsPresentationIntents— pins the intent-union logic that keeps***bold italic***carrying both.stronglyEmphasizedand.emphasizedon one run. It's the subtlest code in the renderer and had no test.Both pass against current behaviour — they pin what already works rather than demanding a fix. I mutation-tested the first one: removing the scheme check makes it fail with 5 issues, so it isn't vacuous.
This required relaxing
InlineTextView.attributedString(for:)fromprivatetointernal. No public API impact.Docs
Developmentreferenced--package-path Packages/MarkdownKit, a path that doesn't exist in this repo. Plainswift build/swift testwork.branch: "main"— there are no tags yet, see Package assessment: correctness, performance, platform reach, and packaging #8 §3.5)..gitignore:.DS_Store,.swiftpm/,xcuserdata/,*.xcodeproj.Verification
Closes part of #8. Remaining from that issue, in the order suggested there: the depth cap (§1.1, the one crash still open),
.disableSmartOpts(§1.3), task-list checkboxes (§4), accessibility and text selection (§6), and the detector prefix cap plusdetectAsync(§2.3).🤖 Generated with Claude Code