Skip to content

feat(core): replace 80% size threshold with count-first chain-to-full fallback - #531

Merged
JusterZhu merged 2 commits into
masterfrom
feat/chain-count-threshold
Jun 21, 2026
Merged

feat(core): replace 80% size threshold with count-first chain-to-full fallback#531
JusterZhu merged 2 commits into
masterfrom
feat/chain-count-threshold

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Closes#530

Summary

Replaces the single 80%-of-full-size threshold in DownloadPlanBuilder with a count-first heuristic for choosing between chain packages and a full replacement package.

Before

// 80% of full size thresholdvarthreshold=(long)(bestFull.Size*0.8);if(chainTotal>=threshold)fullpackage

After

// Count-first: too many chain packages → fullif(maxChainBeforeFallback>0&&chainCount>maxChainBeforeFallback)fullpackage// Size guardrail: chain is larger than full → fullif(chainTotal>=bestFull.Size)fullpackage

Why

  • Package count matters. 20 small chain packages have 20 points of failure (download, hash verify, patch apply). Fewer packages = more reliable updates.
  • Runtime fallback already exists. Chain packages are paired with FallbackFull — a failed patch falls back automatically. We don't need an eager 80% threshold at download time.
  • No absolute overpay. Old logic could make users download 400 MB extra (20% of 2 GB). New logic only switches when it genuinely saves data or reliability demands it.
  • Configurable.MaxChainBeforeFallback defaults to 8 in UpdateConfiguration, set to 0 to disable count-based fallback.

Changes

FileChange
UpdateConfiguration.cs+ MaxChainBeforeFallback property (default 8)
DownloadPlanBuilder.csNew count+size heuristic, new parameter
ClientStrategy.csPass MaxChainBeforeFallback to Build
DownloadPlanBuilderTests.cs5 new test cases

🤖 Generated with Claude Code

… fallback
Swap the single 80%-of-full-size heuristic for a two-condition strategy:
1. Chain count exceeds MaxChainBeforeFallback (default 8) → full package
2. Combined chain size >= full size → full package
Add MaxChainBeforeFallback to UpdateConfiguration (default 8), plumb it
through DownloadPlanBuilder.Build() and ClientStrategy. The new logic
stops switching to full when the chain total is only marginally below
the full size — the runtime fallback (FallbackFull) already handles
chain application failures, so an overly eager size threshold is
unnecessary.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CopilotAI review requested due to automatic review settings June 21, 2026 07:06

CopilotAI 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.

…d-AppType tests
Code review fixes:
- Extract duplicated 'switch to full' code block into local function SwitchToFull
- Add missing MaxChainBeforeFallback mapping in ConfigurationMapper
- Add 3 mixed-AppType test cases (Client+Upgrade split scenarios)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JusterZhu
JusterZhuforce-pushed the feat/chain-count-threshold branch from 11c4919 to 0a8c4a2CompareJune 21, 2026 07:09
@JusterZhu
JusterZhu merged commit c6b8233 into masterJun 21, 2026
3 checks passed
@JusterZhu
JusterZhu deleted the feat/chain-count-threshold branch June 21, 2026 07:22
Sign up for freeto 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.

Replace 80% size threshold with count-first chain-to-full fallback heuristic

2 participants

@JusterZhu