MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / decidePassiveUpdateTarget

Function decidePassiveUpdateTarget

apps/kimi-code/src/cli/update/rollout.ts:95–150  ·  view source on GitHub ↗
(
  currentVersion: string,
  latest: string | null,
  manifest: UpdateManifest | null,
  deviceId: string,
  now: Date,
  bypassRollout = false,
)

Source from the content-addressed store, hash-verified

93 * raw latest version.
94 */
95export function decidePassiveUpdateTarget(
96 currentVersion: string,
97 latest: string | null,
98 manifest: UpdateManifest | null,
99 deviceId: string,
100 now: Date,
101 bypassRollout = false,
102): PassiveUpdateDecision {
103 if (bypassRollout) {
104 if (latest === null) {
105 return { target: null, reason: 'no-latest', bucket: null, delaySeconds: null, eligibleAt: null };
106 }
107 const target = selectUpdateTarget(currentVersion, latest);
108 return {
109 target,
110 reason: target === null ? 'not-newer' : 'experimental',
111 bucket: null,
112 delaySeconds: null,
113 eligibleAt: null,
114 };
115 }
116
117 if (manifest === null) {
118 if (latest === null) {
119 return { target: null, reason: 'no-latest', bucket: null, delaySeconds: null, eligibleAt: null };
120 }
121 const target = selectUpdateTarget(currentVersion, latest);
122 return {
123 target,
124 reason: target === null ? 'not-newer' : 'no-manifest',
125 bucket: null,
126 delaySeconds: null,
127 eligibleAt: null,
128 };
129 }
130
131 const target = selectUpdateTarget(currentVersion, manifest.version);
132 if (target === null) {
133 return { target: null, reason: 'not-newer', bucket: null, delaySeconds: null, eligibleAt: null };
134 }
135
136 const bucket = rolloutBucket(deviceId, manifest.version);
137 const delaySeconds = rolloutDelayForBucket(manifest.rollout, bucket);
138 const publishedAt = Date.parse(manifest.publishedAt);
139 const eligibleAt = Number.isFinite(publishedAt)
140 ? new Date(publishedAt + delaySeconds * 1000).toISOString()
141 : null;
142 const eligible = isRolloutEligible(manifest, deviceId, now);
143 return {
144 target: eligible ? target : null,
145 reason: eligible ? 'eligible' : 'held',
146 bucket,
147 delaySeconds,
148 eligibleAt,
149 };
150}
151
152export function selectPassiveUpdateTarget(

Callers 5

rollout.test.tsFile · 0.90
runUpdatePreflightFunction · 0.90

Calls 4

selectUpdateTargetFunction · 0.90
rolloutBucketFunction · 0.85
rolloutDelayForBucketFunction · 0.85
isRolloutEligibleFunction · 0.85

Tested by

no test coverage detected