Split pack() into canonical and non-canonical forms#122
Conversation
Greptile SummaryThis PR introduces
Confidence Score: 5/5Safe to merge — the new methods are additive, all call sites in Multi.php are updated, and the deprecated pack() is preserved for backwards compatibility. The core bit-level arithmetic in each strategy was traced against the relevant RFCs and confirmed correct for all allowed prefix lengths. Guards are properly split so exceptions carry the right binary string. The graceful-degradation paths in Composite and Multi are intentional and annotated. No call site was missed and the darsyn/ip-doctrine companion repo makes no direct use of pack(). No files require special attention. Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class EmbeddingStrategyInterface {
<<interface>>
+isEmbedded(binary) bool
+extract(binary) string
+pack(binary) string
}
class CanonicalEmbeddingInterface {
<<interface>>
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
EmbeddingStrategyInterface <|-- CanonicalEmbeddingInterface
class Compatible {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Mapped {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Derived {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Teredo {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Nat64 {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Composite {
-packer EmbeddingStrategyInterface
-strategies list
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
CanonicalEmbeddingInterface <|.. Compatible
CanonicalEmbeddingInterface <|.. Mapped
CanonicalEmbeddingInterface <|.. Derived
CanonicalEmbeddingInterface <|.. Teredo
CanonicalEmbeddingInterface <|.. Nat64
CanonicalEmbeddingInterface <|.. Composite
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
classDiagram
class EmbeddingStrategyInterface {
<<interface>>
+isEmbedded(binary) bool
+extract(binary) string
+pack(binary) string
}
class CanonicalEmbeddingInterface {
<<interface>>
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
EmbeddingStrategyInterface <|-- CanonicalEmbeddingInterface
class Compatible {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Mapped {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Derived {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Teredo {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Nat64 {
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
class Composite {
-packer EmbeddingStrategyInterface
-strategies list
+packIntoCanonical(ipv4) string
+packIntoNonCanonical(ipv6, ipv4) string
}
CanonicalEmbeddingInterface <|.. Compatible
CanonicalEmbeddingInterface <|.. Mapped
CanonicalEmbeddingInterface <|.. Derived
CanonicalEmbeddingInterface <|.. Teredo
CanonicalEmbeddingInterface <|.. Nat64
CanonicalEmbeddingInterface <|.. Composite
Reviews (2): Last reviewed commit: "feature(strategy): ✨ split pack() into c..." | Re-trigger Greptile |
Deprecate `EmbeddingStrategyInterface::pack()` and introduce a temporary `CanonicalEmbeddingInterface` to declare the new `packIntoCanonical()` and `packIntoNonCanonical()` in order to preserve backwards compatibility.
c2f6d92 to
d73eccb
Compare
EmbeddingStrategyInterface::pack().CanonicalEmbeddingInterfaceto declare the newpackIntoCanonical()andpackIntoNonCanonical()in order to preserve backwards compatibility.