Commit 8d4dcf3bc1
8d4dcf3bc1b992f976fd1899d1bfd25062f482b4
parent: 98892ddc23
Verified · cmc
cmc <hello@cleberg.net> · 2026-10-24 05:41 UTC
Make the intelligence gate a named capability
The intelligence breakdown was hidden behind a bare
`FeatureAccessService.currentTier != .proPlus` in two view bodies, so it
appeared in no search for hasAccess(to:) and in no part of the capability
table. P1 audited the table and missed it; it surfaced only because its
placeholder copy sat three lines from one being deleted in !11.
It stays Pro+. Unlike pricing and reputation the data is real and renders, and
unlike the ownership and DNS history derivations it is substantive analysis —
inferred provider with evidence, classification with reasons, risk signals,
ownership and hosting transitions, subdomain intelligence, a timeline. Free
already sees the computed verdict through the ungated risk and insight cards;
Pro+ sees the working.
As a capability it reaches the tier table, the paywall and
enabledFeatureLabels, and a test can assert it.
Also removes what !11's reputation deletion orphaned: scoreReputation could no
longer pass its own guard, so the function, its call site and the dead
"flagged by a configured reputation source" insight are gone.
Layout: unified · split
DomainDig/ContentView.swift
+1 −1
| @@ -436,7 +436,7 @@ struct ContentView: View { |
| 436 | IntelligenceSectionView( |
436 | IntelligenceSectionView( |
| 437 | isCollapsed: sectionCollapsedBinding(.intelligence), |
437 | isCollapsed: sectionCollapsedBinding(.intelligence), |
| 438 | report: report, |
438 | report: report, |
| 439 | showsPlaceholder: FeatureAccessService.currentTier != .proPlus |
439 | showsPlaceholder: !FeatureAccessService.hasAccess(to: .intelligenceDetail) |
| 440 | ) |
440 | ) |
| 441 | } |
441 | } |
| 442 | |
442 | |
DomainDig/DomainInsightEngine.swift
−17
| @@ -192,7 +192,6 @@ enum DomainInsightEngine { |
| 192 | tally.add(4, "Observed risk has increased materially since the previous snapshot", .negative) |
192 | tally.add(4, "Observed risk has increased materially since the previous snapshot", .negative) |
| 193 | } |
193 | } |
| 194 | } |
194 | } |
| 195 | scoreReputation(snapshot, into: &tally) |
| |
| 196 | |
195 | |
| 197 | let clampedScore = min(max(tally.score, 0), 100) |
196 | let clampedScore = min(max(tally.score, 0), 100) |
| 198 | let level: RiskLevel |
197 | let level: RiskLevel |
| @@ -330,19 +329,6 @@ enum DomainInsightEngine { |
| 330 | } |
329 | } |
| 331 | } |
330 | } |
| 332 | |
331 | |
| 333 | private static func scoreReputation(_ snapshot: LookupSnapshot, into tally: inout RiskTally) { |
| |
| 334 | guard let reputation = snapshot.reputation else { return } |
| |
| 335 | switch reputation.status { |
| |
| 336 | case .listed: |
| |
| 337 | let sourceList = reputation.listedSources.isEmpty ? "" : " (\(reputation.listedSources.joined(separator: ", ")))" |
| |
| 338 | tally.add(25, "Domain is flagged by a configured reputation source\(sourceList)", .negative) |
| |
| 339 | case .clean: |
| |
| 340 | tally.add(0, "Domain is clean against the configured reputation source", .positive) |
| |
| 341 | case .unknown: |
| |
| 342 | break |
| |
| 343 | } |
| |
| 344 | } |
| |
| 345 | |
| |
| 346 | private static func insights( |
332 | private static func insights( |
| 347 | for snapshot: LookupSnapshot, |
333 | for snapshot: LookupSnapshot, |
| 348 | previousSnapshot: LookupSnapshot?, |
334 | previousSnapshot: LookupSnapshot?, |
| @@ -353,9 +339,6 @@ enum DomainInsightEngine { |
| 353 | ) -> [String] { |
339 | ) -> [String] { |
| 354 | var items: [String] = [] |
340 | var items: [String] = [] |
| 355 | |
341 | |
| 356 | if snapshot.reputation?.status == .listed { |
| |
| 357 | items.append("Domain is flagged by a configured reputation source") |
| |
| 358 | } |
| |
| 359 | if let group = subdomainGroups.first(where: { $0.label == "staging" || $0.label == "dev" }) { |
342 | if let group = subdomainGroups.first(where: { $0.label == "staging" || $0.label == "dev" }) { |
| 360 | items.append("Multiple \(group.label) subdomains suggest non-production environments are exposed") |
343 | items.append("Multiple \(group.label) subdomains suggest non-production environments are exposed") |
| 361 | } |
344 | } |
DomainDig/FeatureAccessService.swift
+5 −2
| @@ -31,6 +31,7 @@ enum FeatureCapability: String, CaseIterable, Identifiable { |
| 31 | case extendedSubdomains |
31 | case extendedSubdomains |
| 32 | case sharedPortfolios |
32 | case sharedPortfolios |
| 33 | case auditDepth |
33 | case auditDepth |
| |
34 | case intelligenceDetail |
| 34 | |
35 | |
| 35 | var id: String { rawValue } |
36 | var id: String { rawValue } |
| 36 | |
37 | |
| @@ -58,6 +59,8 @@ enum FeatureCapability: String, CaseIterable, Identifiable { |
| 58 | return "Shared portfolios" |
59 | return "Shared portfolios" |
| 59 | case .auditDepth: |
60 | case .auditDepth: |
| 60 | return "Unlimited audits" |
61 | return "Unlimited audits" |
| |
62 | case .intelligenceDetail: |
| |
63 | return "Intelligence detail" |
| 61 | } |
64 | } |
| 62 | } |
65 | } |
| 63 | } |
66 | } |
| @@ -169,7 +172,7 @@ enum FeatureAccessService { |
| 169 | case .workflows, .batchOperations, .automatedMonitoring, .localAlerts, .advancedExports, |
172 | case .workflows, .batchOperations, .automatedMonitoring, .localAlerts, .advancedExports, |
| 170 | .extendedSubdomains: |
173 | .extendedSubdomains: |
| 171 | return "Available in Pro" |
174 | return "Available in Pro" |
| 172 | case .sharedPortfolios, .auditDepth: |
175 | case .sharedPortfolios, .auditDepth, .intelligenceDetail: |
| 173 | return "Available in Pro+" |
176 | return "Available in Pro+" |
| 174 | case .limitedTracking: |
177 | case .limitedTracking: |
| 175 | return "Tracking is limited on Free" |
178 | return "Tracking is limited on Free" |
| @@ -231,7 +234,7 @@ enum FeatureAccessService { |
| 231 | static func upgradePrompt(for capability: FeatureCapability) -> UpgradePromptContext { |
234 | static func upgradePrompt(for capability: FeatureCapability) -> UpgradePromptContext { |
| 232 | let title: String |
235 | let title: String |
| 233 | switch capability { |
236 | switch capability { |
| 234 | case .sharedPortfolios, .auditDepth: |
237 | case .sharedPortfolios, .auditDepth, .intelligenceDetail: |
| 235 | title = "Available in Pro+" |
238 | title = "Available in Pro+" |
| 236 | default: |
239 | default: |
| 237 | title = "Available in Pro" |
240 | title = "Available in Pro" |
DomainDig/HistoryView.swift
+1 −1
| @@ -183,7 +183,7 @@ struct HistoryDetailView: View { |
| 183 | IntelligenceSectionView( |
183 | IntelligenceSectionView( |
| 184 | isCollapsed: .constant(false), |
184 | isCollapsed: .constant(false), |
| 185 | report: report, |
185 | report: report, |
| 186 | showsPlaceholder: FeatureAccessService.currentTier != .proPlus |
186 | showsPlaceholder: !FeatureAccessService.hasAccess(to: .intelligenceDetail) |
| 187 | ) |
187 | ) |
| 188 | .padding(.top, 8) |
188 | .padding(.top, 8) |
| 189 | DomainSectionView( |
189 | DomainSectionView( |
DomainDig/PaywallView.swift
+2 −1
| @@ -10,7 +10,7 @@ struct PaywallView: View { |
| 10 | NavigationStack { |
10 | NavigationStack { |
| 11 | List { |
11 | List { |
| 12 | Section { |
12 | Section { |
| 13 | Text("Pro unlocks scale, background monitoring, alerts, exports, and extended subdomain discovery. Pro+ adds shared portfolios and unlimited audits.") |
13 | Text("Pro unlocks scale, background monitoring, alerts, exports, and extended subdomain discovery. Pro+ adds shared portfolios, unlimited audits, and the full intelligence breakdown.") |
| 14 | .font(appDensity.font(.body, design: .default)) |
14 | .font(appDensity.font(.body, design: .default)) |
| 15 | .foregroundStyle(Color(.appTextSecondary)) |
15 | .foregroundStyle(Color(.appTextSecondary)) |
| 16 | .fixedSize(horizontal: false, vertical: true) |
16 | .fixedSize(horizontal: false, vertical: true) |
| @@ -29,6 +29,7 @@ struct PaywallView: View { |
| 29 | Section("What Pro+ Unlocks") { |
29 | Section("What Pro+ Unlocks") { |
| 30 | featureRow("Shared portfolios") |
30 | featureRow("Shared portfolios") |
| 31 | featureRow("Unlimited audit sessions") |
31 | featureRow("Unlimited audit sessions") |
| |
32 | featureRow("Intelligence detail") |
| 32 | } |
33 | } |
| 33 | |
34 | |
| 34 | Section("Subscription") { |
35 | Section("Subscription") { |
DomainDigTests/FeatureAccessTests.swift
+13 −1
| @@ -58,6 +58,7 @@ final class FeatureAccessTests: XCTestCase { |
| 58 | |
58 | |
| 59 | XCTAssertFalse(pro.capabilities.contains(.sharedPortfolios)) |
59 | XCTAssertFalse(pro.capabilities.contains(.sharedPortfolios)) |
| 60 | XCTAssertFalse(pro.capabilities.contains(.auditDepth)) |
60 | XCTAssertFalse(pro.capabilities.contains(.auditDepth)) |
| |
61 | XCTAssertFalse(pro.capabilities.contains(.intelligenceDetail)) |
| 61 | } |
62 | } |
| 62 | |
63 | |
| 63 | func testProLiftsTheAllowances() { |
64 | func testProLiftsTheAllowances() { |
| @@ -71,11 +72,22 @@ final class FeatureAccessTests: XCTestCase { |
| 71 | |
72 | |
| 72 | // MARK: Pro+ |
73 | // MARK: Pro+ |
| 73 | |
74 | |
| 74 | func testProPlusAddsSharedPortfoliosAndAuditDepth() { |
75 | func testProPlusAddsSharedPortfoliosAuditDepthAndIntelligence() { |
| 75 | let proPlus = FeatureAccessService.entitlements(for: .proPlus) |
76 | let proPlus = FeatureAccessService.entitlements(for: .proPlus) |
| 76 | |
77 | |
| 77 | XCTAssertTrue(proPlus.capabilities.contains(.sharedPortfolios)) |
78 | XCTAssertTrue(proPlus.capabilities.contains(.sharedPortfolios)) |
| 78 | XCTAssertTrue(proPlus.capabilities.contains(.auditDepth)) |
79 | XCTAssertTrue(proPlus.capabilities.contains(.auditDepth)) |
| |
80 | XCTAssertTrue(proPlus.capabilities.contains(.intelligenceDetail)) |
| |
81 | } |
| |
82 | |
| |
83 | /// The intelligence breakdown was gated by a bare `currentTier != .proPlus` |
| |
84 | /// in two view bodies, which no audit of the capability table could see. It |
| |
85 | /// is a capability now so the table, the paywall and `enabledFeatureLabels` |
| |
86 | /// all agree, and so a test like this one can exist at all. |
| |
87 | func testIntelligenceDetailIsAProPlusCapability() { |
| |
88 | XCTAssertFalse(FeatureAccessService.entitlements(for: .free).capabilities.contains(.intelligenceDetail)) |
| |
89 | XCTAssertFalse(FeatureAccessService.entitlements(for: .pro).capabilities.contains(.intelligenceDetail)) |
| |
90 | XCTAssertTrue(FeatureAccessService.entitlements(for: .proPlus).capabilities.contains(.intelligenceDetail)) |
| 79 | } |
91 | } |
| 80 | |
92 | |
| 81 | /// The finding this table replaces: Pro+ cost twice Pro and its only |
93 | /// The finding this table replaces: Pro+ cost twice Pro and its only |