Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

refactor(update): keep one repeating reminder mode

tt-a1ic888c860349b
diff --git a/README.md b/README.md
index 8ed8989f..18d593ef 100644
--- a/README.md
+++ b/README.md
@@ -202,7 +202,7 @@ npx skills use tt-a1i/archify@archify --agent codex
The [agent switcher](https://tt-a1i.github.io/archify/start.html?agent=cursor&type=architecture) covers `cursor`, `codex`, `claude-code`, and `opencode`.
-Archify may GET the fixed stable manifest solely to show an optional reminder; it never downloads or installs updates. Successful checks wait about 72 hours (±20%); active use retries failures after 6, then 24 hours. The server sees normal HTTP metadata (IP and time), but receives no version, Agent, project data, prompts, account/device ID, or ETag. You decide whether and when to update. Set `ARCHIFY_UPDATE_CHECK_DISABLED=1` to disable networking and reminder-state writes.
+Archify may GET the fixed stable manifest solely to show an optional reminder; it never downloads or installs updates. Successful checks wait about 24 hours (±20%); active use retries failures after 6, then 24 hours. The server sees normal HTTP metadata (IP and time), but receives no version, Agent, project data, prompts, account/device ID, or ETag. You decide whether and when to update. Set `ARCHIFY_UPDATE_CHECK_DISABLED=1` to disable networking and reminder-state writes.
</details>
diff --git a/README_EN.md b/README_EN.md
index 8ed8989f..18d593ef 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -202,7 +202,7 @@ npx skills use tt-a1i/archify@archify --agent codex
The [agent switcher](https://tt-a1i.github.io/archify/start.html?agent=cursor&type=architecture) covers `cursor`, `codex`, `claude-code`, and `opencode`.
-Archify may GET the fixed stable manifest solely to show an optional reminder; it never downloads or installs updates. Successful checks wait about 72 hours (±20%); active use retries failures after 6, then 24 hours. The server sees normal HTTP metadata (IP and time), but receives no version, Agent, project data, prompts, account/device ID, or ETag. You decide whether and when to update. Set `ARCHIFY_UPDATE_CHECK_DISABLED=1` to disable networking and reminder-state writes.
+Archify may GET the fixed stable manifest solely to show an optional reminder; it never downloads or installs updates. Successful checks wait about 24 hours (±20%); active use retries failures after 6, then 24 hours. The server sees normal HTTP metadata (IP and time), but receives no version, Agent, project data, prompts, account/device ID, or ETag. You decide whether and when to update. Set `ARCHIFY_UPDATE_CHECK_DISABLED=1` to disable networking and reminder-state writes.
</details>
diff --git a/README_JA.md b/README_JA.md
index c3b3da8c..34a26e85 100644
--- a/README_JA.md
+++ b/README_JA.md
@@ -192,7 +192,7 @@ npx skills use tt-a1i/archify@archify --agent codex
[エージェント切り替え](https://tt-a1i.github.io/archify/start.html?agent=cursor&type=architecture)は `cursor`、`codex`、`claude-code`、`opencode` に対応しています。
-Archify は固定の安定版マニフェストを GET して任意の更新リマインダーを表示することがありますが、更新をダウンロードしたりインストールしたりすることはありません。チェックに成功すると次回まで約 72 時間(±20%)待機し、失敗した場合はアクティブに使用していれば 6 時間後、その後は 24 時間後に再試行します。サーバーが受け取るのは通常の HTTP メタデータ(IP と時刻)だけで、バージョン、Agent、プロジェクトデータ、プロンプト、アカウント/デバイス ID、ETag は送信されません。更新するかどうか、いつ更新するかは常にあなたが決めます。`ARCHIFY_UPDATE_CHECK_DISABLED=1` を設定すると、ネットワーク通信とリマインダー状態の書き込みを無効化できます。
+Archify は固定の安定版マニフェストを GET して任意の更新リマインダーを表示することがありますが、更新をダウンロードしたりインストールしたりすることはありません。チェックに成功すると次回まで約 24 時間(±20%)待機し、失敗した場合はアクティブに使用していれば 6 時間後、その後は 24 時間後に再試行します。サーバーが受け取るのは通常の HTTP メタデータ(IP と時刻)だけで、バージョン、Agent、プロジェクトデータ、プロンプト、アカウント/デバイス ID、ETag は送信されません。更新するかどうか、いつ更新するかは常にあなたが決めます。`ARCHIFY_UPDATE_CHECK_DISABLED=1` を設定すると、ネットワーク通信とリマインダー状態の書き込みを無効化できます。
</details>
diff --git a/README_ZH.md b/README_ZH.md
index c2a84d7c..15a76469 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -200,7 +200,7 @@ npx skills use tt-a1i/archify@archify --agent codex
DeepSeek Harness(社区集成、显式启用):运行 `dsh plugin --profile web add @tt-a1i/[email protected]`;参见[兼容范围、限制与安全说明](integrations/deepseek-harness/README.md)。[Agent 切换器](https://tt-a1i.github.io/archify/start.html?agent=cursor&type=architecture)只为 `cursor`、`codex`、`claude-code` 和 `opencode` 生成命令。
-安装后的 Skill 包含一个低频、失败静默的发布检查,它最多只显示可选更新提醒,绝不会自行下载或安装更新。一次成功检查后,下次网络请求通常约在 72 小时(±20%)后发出;检查失败后,活跃使用可能在首次 6 小时、后续 24 小时退避到期时重试。请求只访问 `https://tt-a1i.github.io/archify/skill-updates/archify/stable.json`。服务端会自然获得 IP、请求时间和常规 HTTP 元数据;检查器不会发送本地版本、Agent、项目数据、用户输入、账户/设备标识,也不会保存或回传 ETag。是否更新以及何时更新始终由你决定。如需完全关闭检查(包括网络请求和提醒状态写入),请在 Agent 环境中设置 `ARCHIFY_UPDATE_CHECK_DISABLED=1`。
+安装后的 Skill 包含一个低频、失败静默的发布检查,它最多只显示可选更新提醒,绝不会自行下载或安装更新。一次成功检查后,下次网络请求通常约在 24 小时(±20%)后发出;检查失败后,活跃使用可能在首次 6 小时、后续 24 小时退避到期时重试。请求只访问 `https://tt-a1i.github.io/archify/skill-updates/archify/stable.json`。服务端会自然获得 IP、请求时间和常规 HTTP 元数据;检查器不会发送本地版本、Agent、项目数据、用户输入、账户/设备标识,也不会保存或回传 ETag。是否更新以及何时更新始终由你决定。如需完全关闭检查(包括网络请求和提醒状态写入),请在 Agent 环境中设置 `ARCHIFY_UPDATE_CHECK_DISABLED=1`。
</details>
diff --git a/archify.zip b/archify.zip
index 66590550..52c08d7d 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/bin/delivery-update.mjs b/archify/bin/delivery-update.mjs
index a5bd08cd..4f34dbac 100644
--- a/archify/bin/delivery-update.mjs
+++ b/archify/bin/delivery-update.mjs
@@ -26,9 +26,7 @@ function normalize(result) {
const cached = result.source === 'cache';
const noticeText = noticeRequired
? `Archify ${result.severity === 'security' ? 'security update' : 'update'}: ${result.installedVersion} → ${result.latestVersion}. ${cached
- ? result.checkedAt
- ? `A previous check at ${result.checkedAt} found a newer release.`
- : 'A previous check found a newer release; its check time is unknown.'
+ ? `A previous check at ${result.checkedAt} found a newer release.`
: 'A newer release is available.'} Release notes: ${result.releaseNotes}. The installed Skill has not changed; ask to snooze or ignore this reminder.`
: null;
return {
diff --git a/archify/references/update-awareness.md b/archify/references/update-awareness.md
index a79d348b..4f11feb7 100644
--- a/archify/references/update-awareness.md
+++ b/archify/references/update-awareness.md
@@ -2,7 +2,7 @@
Read this file when a `finalize` or standalone `deliver` receipt has `update.noticeRequired: true`.
-Keep one compact line in the final response, in the user's language, with `installedVersion`, `availableVersion`, and the official `releaseNotes` link. Say that the installed Skill has not changed and that the user can ask to snooze or ignore the reminder. If `source` is `cache`, say that a previous check found the update; use `checkedAt` only when present, and otherwise say the check time is unknown. A process message or tool output does not replace this final line.
+Keep one compact line in the final response, in the user's language, with `installedVersion`, `availableVersion`, and the official `releaseNotes` link. Say that the installed Skill has not changed and that the user can ask to snooze or ignore the reminder. If `source` is `cache`, say that a previous check at `checkedAt` found the update. A process message or tool output does not replace this final line.
For `severity: "security"`, label it as a security update without making installation automatic or urgent by default.
You may translate the fixed local `noticeText`. Never quote, summarize, or translate the remote manifest's summary.
diff --git a/archify/scripts/check-update.mjs b/archify/scripts/check-update.mjs
index adb984e0..369eeac0 100644
--- a/archify/scripts/check-update.mjs
+++ b/archify/scripts/check-update.mjs
@@ -26,8 +26,7 @@ const OPERATION_OWNER_FILE = 'owner.json';
const ACTIVE_CLAIM_DIRECTORY = 'active-claim';
const OPERATION_NAME = /^(reserved|pending|committed|fenced|cancelled)-(\d{1,20})$/;
const MAX_OPERATION_GENERATION = (10n ** 20n) - 1n;
-const CHECK_TTL_MS = 72 * 60 * 60 * 1_000;
-const DELIVERY_CHECK_TTL_MS = 24 * 60 * 60 * 1_000;
+const CHECK_TTL_MS = 24 * 60 * 60 * 1_000;
const MAX_CACHE_HORIZON_MS = Math.ceil(CHECK_TTL_MS * 1.2);
const FIRST_FAILURE_DELAY_MS = 6 * 60 * 60 * 1_000;
const LATER_FAILURE_DELAY_MS = 24 * 60 * 60 * 1_000;
@@ -38,7 +37,7 @@ const MAX_CACHE_STATE_BYTES = 64 * 1_024;
const MAX_CLAIM_OWNER_BYTES = 1_024;
const LONGEST_ISO_TIMESTAMP = '+275760-09-13T00:00:00.000Z';
const LOCK_STALE_MS = 30_000;
-const ACK_LOCK_WAIT_MS = 1_200;
+const PREFERENCE_LOCK_WAIT_MS = 1_200;
const LOCK_RETRY_DELAY_MS = 20;
const DIGEST_PATTERN = /^sha256:[a-f0-9]{64}$/;
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
@@ -83,8 +82,7 @@ function validateCachedCandidate(value) {
if (!DIGEST_PATTERN.test(value.targetDigest)
|| !['normal', 'security'].includes(value.severity)) return null;
validateReleaseNotesUrl(value.releaseNotes, value.version);
- if (value.checkedAt !== undefined && (typeof value.checkedAt !== 'string'
- || !Number.isFinite(Date.parse(value.checkedAt)))) return null;
+ if (typeof value.checkedAt !== 'string' || !Number.isFinite(Date.parse(value.checkedAt))) return null;
return { ...value };
} catch {
return null;
@@ -93,17 +91,14 @@ function validateCachedCandidate(value) {
function emptyState(installedVersion = null) {
return {
- schemaVersion: 1,
+ schemaVersion: 2,
skillId: SKILL_ID,
installedVersion,
check: {
nextCheckAt: null,
consecutiveFailures: 0,
},
- notification: {
- offeredDigests: [],
- acknowledgedDigests: [],
- },
+ preferences: [],
};
}
@@ -117,46 +112,11 @@ function validPreference(value) {
: typeof value.until === 'string' && Number.isFinite(Date.parse(value.until)));
}
-function deliveryState(state) {
- return {
- ...state,
- schemaVersion: 2,
- legacyMigrated: true,
- preferences: state.preferences || [],
- };
-}
-
-function withMigratedCandidate(state, candidate) {
- if (state.candidate || !candidate) return state;
- return {
- ...state,
- candidate,
- notification: {
- ...state.notification,
- offeredDigests: [...new Set([...state.notification.offeredDigests, candidate.targetDigest])],
- },
- };
-}
-
function encodeBoundedState(state) {
const encoded = Buffer.from(`${JSON.stringify(state)}\n`, 'utf8');
return encoded.length <= MAX_CACHE_STATE_BYTES ? encoded : null;
}
-function stateAfterAcknowledgement(state, targetDigest) {
- const alreadyAcknowledged = state.notification.acknowledgedDigests.includes(targetDigest);
- return {
- ...state,
- notification: {
- offeredDigests: state.notification.offeredDigests
- .filter((digest) => digest !== targetDigest),
- acknowledgedDigests: alreadyAcknowledged
- ? [...state.notification.acknowledgedDigests]
- : [...state.notification.acknowledgedDigests, targetDigest],
- },
- };
-}
-
function stateWithFailureCheck(state, nextCheckAt, consecutiveFailures, withdrawCandidate = false) {
const failedState = {
...state,
@@ -166,20 +126,10 @@ function stateWithFailureCheck(state, nextCheckAt, consecutiveFailures, withdraw
return failedState;
}
+// A committed state must leave room for its own failure backoff.
function encodeRecoverableState(state) {
const encoded = encodeBoundedState(state);
- if (!encoded) return null;
- if (!encodeBoundedState(stateWithFailureCheck(state, LONGEST_ISO_TIMESTAMP, 2))) return null;
- let acknowledgementState = state;
- for (const targetDigest of state.notification.offeredDigests) {
- acknowledgementState = stateAfterAcknowledgement(acknowledgementState, targetDigest);
- if (!encodeBoundedState(acknowledgementState)
- || !encodeBoundedState(stateWithFailureCheck(
- acknowledgementState,
- LONGEST_ISO_TIMESTAMP,
- 2,
- ))) return null;
- }
+ if (!encoded || !encodeBoundedState(stateWithFailureCheck(state, LONGEST_ISO_TIMESTAMP, 2))) return null;
return encoded;
}
@@ -190,14 +140,15 @@ function versionCacheDirectory(cacheDirectory, installedVersion) {
function normalizeState(value, installedVersion) {
const effectiveInstalledVersion = installedVersion ?? value?.installedVersion ?? null;
- if (!isPlainObject(value) || ![1, 2].includes(value.schemaVersion) || value.skillId !== SKILL_ID
+ if (!isPlainObject(value) || value.schemaVersion !== 2 || value.skillId !== SKILL_ID
|| (installedVersion !== null && value.installedVersion !== installedVersion)
|| (value.installedVersion !== null && typeof value.installedVersion !== 'string')
|| !isPlainObject(value.check)
|| !(value.check.nextCheckAt === null || typeof value.check.nextCheckAt === 'string')
|| !Number.isSafeInteger(value.check.consecutiveFailures)
|| value.check.consecutiveFailures < 0
- || !isPlainObject(value.notification)) return null;
+ || !Array.isArray(value.preferences) || value.preferences.length > 32
+ || value.preferences.some((preference) => !validPreference(preference))) return null;
if (effectiveInstalledVersion !== null) {
try {
parseSemver(effectiveInstalledVersion);
@@ -209,36 +160,11 @@ function normalizeState(value, installedVersion) {
const state = emptyState(effectiveInstalledVersion);
state.check.nextCheckAt = value.check.nextCheckAt;
state.check.consecutiveFailures = value.check.consecutiveFailures;
- const { offeredDigests, acknowledgedDigests } = value.notification;
- if (!Array.isArray(offeredDigests)
- || offeredDigests.some((digest) => typeof digest !== 'string' || !DIGEST_PATTERN.test(digest))) {
- return null;
- }
- state.notification.offeredDigests = [...new Set(offeredDigests)];
-
- if (!Array.isArray(acknowledgedDigests)
- || acknowledgedDigests.some((digest) => typeof digest !== 'string' || !DIGEST_PATTERN.test(digest))) {
- return null;
- }
- state.notification.acknowledgedDigests = [...new Set(acknowledgedDigests)];
- if (value.schemaVersion === 2) {
- if (!Array.isArray(value.preferences) || value.preferences.length > 32
- || value.preferences.some((preference) => !validPreference(preference))
- || value.legacyMigrated !== true) return null;
- state.schemaVersion = 2;
- state.legacyMigrated = true;
- state.preferences = value.preferences.map((preference) => ({ ...preference }));
- }
+ state.preferences = value.preferences.map((preference) => ({ ...preference }));
const hasCandidate = Object.hasOwn(value, 'candidate');
const candidate = validateCachedCandidate(value.candidate);
if (hasCandidate && !candidate) return null;
- if (candidate) {
- if (effectiveInstalledVersion !== null
- && compareSemver(candidate.version, effectiveInstalledVersion) > 0
- && !state.notification.offeredDigests.includes(candidate.targetDigest)
- && !state.notification.acknowledgedDigests.includes(candidate.targetDigest)) return null;
- state.candidate = candidate;
- }
+ if (candidate) state.candidate = candidate;
return encodeRecoverableState(state) ? state : null;
}
@@ -1336,10 +1262,10 @@ async function commitOperation(cacheDirectory, operation, installedVersion, muta
}
}
-function nextSuccessfulCheck(nowMs, random, ttlMs = CHECK_TTL_MS) {
+function nextSuccessfulCheck(nowMs, random) {
const boundedRandom = Math.min(1, Math.max(0, Number(random()) || 0));
const multiplier = 0.8 + (boundedRandom * 0.4);
- return new Date(nowMs + Math.round(ttlMs * multiplier)).toISOString();
+ return new Date(nowMs + Math.round(CHECK_TTL_MS * multiplier)).toISOString();
}
function nextFailedCheck(nowMs, failures) {
@@ -1368,7 +1294,7 @@ function digestForEventKey(eventKey) {
return DIGEST_PATTERN.test(digest) ? digest : null;
}
-function notification(localRelease, candidate, source = 'cache', repeatNotice = false) {
+function notification(localRelease, candidate, source) {
return {
status: 'update_available',
eventKey: eventKeyForDigest(candidate.targetDigest),
@@ -1378,40 +1304,30 @@ function notification(localRelease, candidate, source = 'cache', repeatNotice =
severity: candidate.severity,
summary: `Archify ${candidate.version} is available; see the official release notes for details.`,
releaseNotes: candidate.releaseNotes,
- ...(repeatNotice ? { source, checkedAt: candidate.checkedAt ?? null, noticeRequired: true } : {}),
+ source,
+ checkedAt: candidate.checkedAt,
+ noticeRequired: true,
};
}
-function resultForCandidate(localRelease, state, {
- repeatNotice = false, source = 'cache', nowMs = Date.now(),
-} = {}) {
- if (!state.candidate) return silent('cache-valid');
- const comparison = compareSemver(state.candidate.version, localRelease.version);
- if (comparison <= 0) return repeatNotice ? {
- status: 'current', installedVersion: localRelease.version,
- availableVersion: state.candidate.version,
- checkedAt: state.candidate.checkedAt ?? null,
- source, noticeRequired: false,
- } : silent('current');
- if (!repeatNotice && state.notification.acknowledgedDigests.includes(state.candidate.targetDigest)) {
- return silent('already-notified');
- }
- if (repeatNotice) {
- const preference = state.preferences?.find((entry) => entry.targetDigest === state.candidate.targetDigest
- && entry.version === state.candidate.version);
- if (preference?.mode === 'ignore') return {
- ...notification(localRelease, state.candidate, source, true),
- noticeRequired: false,
- reason: 'ignored',
- };
- if (preference?.mode === 'snooze' && Date.parse(preference.until) > nowMs) return {
- ...notification(localRelease, state.candidate, source, true),
- noticeRequired: false,
- reason: 'snoozed',
- suppressedUntil: preference.until,
+function resultForCandidate(localRelease, state, { source = 'cache', nowMs = Date.now() } = {}) {
+ const { candidate } = state;
+ if (!candidate) return silent('cache-valid');
+ if (compareSemver(candidate.version, localRelease.version) <= 0) {
+ return {
+ status: 'current', installedVersion: localRelease.version,
+ availableVersion: candidate.version, checkedAt: candidate.checkedAt,
+ source, noticeRequired: false,
};
}
- return notification(localRelease, state.candidate, source, repeatNotice);
+ const result = notification(localRelease, candidate, source);
+ const preference = state.preferences?.find((entry) => entry.targetDigest === candidate.targetDigest
+ && entry.version === candidate.version);
+ if (preference?.mode === 'ignore') return { ...result, noticeRequired: false, reason: 'ignored' };
+ if (preference?.mode === 'snooze' && Date.parse(preference.until) > nowMs) {
+ return { ...result, noticeRequired: false, reason: 'snoozed', suppressedUntil: preference.until };
+ }
+ return result;
}
async function readBoundedBody(response) {
@@ -1520,24 +1436,19 @@ function defaultCacheDirectory() {
return path.join(xdgCache && path.isAbsolute(xdgCache) ? xdgCache : path.join(homeDirectory, '.cache'), 'archify-skill');
}
-function freshStateResult(localRelease, state, nowMs, repeatNotice = false) {
+function freshStateResult(localRelease, state, nowMs) {
const nextCheckAt = Date.parse(state.check.nextCheckAt || '');
if (Number.isFinite(nextCheckAt) && nextCheckAt > nowMs
- && nextCheckAt <= nowMs + (repeatNotice
- ? Math.ceil(DELIVERY_CHECK_TTL_MS * 1.2) : MAX_CACHE_HORIZON_MS)) {
- return resultForCandidate(localRelease, state, { repeatNotice, nowMs });
+ && nextCheckAt <= nowMs + MAX_CACHE_HORIZON_MS) {
+ return resultForCandidate(localRelease, state, { nowMs });
}
return null;
}
-async function resultAfterLosingOperation(cacheDirectory, operation, localRelease, repeatNotice = false, nowMs = Date.now()) {
+async function resultAfterLosingOperation(cacheDirectory, operation, localRelease, nowMs) {
await cancelOperation(cacheDirectory, operation);
const cached = await readState(cacheDirectory, localRelease.version);
- if (cached.candidate
- && cached.notification.offeredDigests.includes(cached.candidate.targetDigest)) {
- return resultForCandidate(localRelease, cached, { repeatNotice, nowMs });
- }
- return silent('check-in-progress');
+ return cached.candidate ? resultForCandidate(localRelease, cached, { nowMs }) : silent('check-in-progress');
}
async function waitUntilRetry(deadline, monotonicNow) {
@@ -1562,7 +1473,6 @@ export async function checkForUpdate({
now = Date.now,
random = Math.random,
timeoutMs = DEFAULT_TIMEOUT_MS,
- repeatNotice = false,
} = {}) {
if (updatesDisabled()) return silent('disabled');
if (typeof fetchImpl !== 'function') return silent('runtime-unavailable');
@@ -1575,10 +1485,7 @@ export async function checkForUpdate({
const nowMs = Number(now());
if (!Number.isFinite(nowMs)) return silent('invalid-clock');
- let stateDirectory = versionCacheDirectory(
- repeatNotice ? path.join(cacheDirectory, 'reminders-v2') : cacheDirectory,
- localRelease.version,
- );
+ let stateDirectory = versionCacheDirectory(cacheDirectory, localRelease.version);
let state;
try {
stateDirectory = await prepareCacheDirectory(stateDirectory);
@@ -1586,19 +1493,7 @@ export async function checkForUpdate({
} catch {
return silent('cache-unavailable');
}
- let legacyCandidate;
- if (repeatNotice && !state.candidate && !state.legacyMigrated) {
- try {
- const legacyDirectory = versionCacheDirectory(cacheDirectory, localRelease.version);
- const legacy = await readState(legacyDirectory, localRelease.version);
- if (legacy.candidate && compareSemver(legacy.candidate.version, localRelease.version) > 0) {
- legacyCandidate = legacy.candidate;
- }
- } catch {
- // Existing state is optional; a failed migration cannot block delivery.
- }
- }
- const cachedResult = freshStateResult(localRelease, state, nowMs, repeatNotice);
+ const cachedResult = freshStateResult(localRelease, state, nowMs);
if (cachedResult) return cachedResult;
let operation;
@@ -1610,33 +1505,27 @@ export async function checkForUpdate({
if (!operation) {
try {
const cached = await readState(stateDirectory, localRelease.version);
- if (cached.candidate
- && cached.notification.offeredDigests.includes(cached.candidate.targetDigest)) {
- return resultForCandidate(localRelease, cached, { repeatNotice, nowMs });
- }
+ return cached.candidate ? resultForCandidate(localRelease, cached, { nowMs }) : silent('check-in-progress');
} catch {
return silent('cache-unavailable');
}
- return legacyCandidate
- ? resultForCandidate(localRelease, { candidate: legacyCandidate }, { repeatNotice, nowMs })
- : silent('check-in-progress');
}
try {
state = await readState(stateDirectory, localRelease.version);
- const racedResult = freshStateResult(localRelease, state, nowMs, repeatNotice);
+ const racedResult = freshStateResult(localRelease, state, nowMs);
if (racedResult) {
await cancelOperation(stateDirectory, operation);
return racedResult;
}
if (!await operationOwnsActiveClaim(stateDirectory, operation)) {
- return await resultAfterLosingOperation(stateDirectory, operation, localRelease, repeatNotice, nowMs);
+ return await resultAfterLosingOperation(stateDirectory, operation, localRelease, nowMs);
}
await verifyCacheToken(cacheTokenFor(stateDirectory));
if (!await operationOwnsActiveClaim(stateDirectory, operation)) {
- return await resultAfterLosingOperation(stateDirectory, operation, localRelease, repeatNotice, nowMs);
+ return await resultAfterLosingOperation(stateDirectory, operation, localRelease, nowMs);
}
let fetched;
try {
@@ -1646,42 +1535,33 @@ export async function checkForUpdate({
timeoutMs,
});
} catch (error) {
- const reason = error instanceof ManifestWithdrawnError ? 'withdrawn'
+ const withdrawn = error instanceof ManifestWithdrawnError;
+ const reason = withdrawn ? 'withdrawn'
: error instanceof UpdateContractError ? 'invalid-manifest' : 'check-failed';
+ // Offline or invalid checks keep repeating the last validated candidate.
+ const failedResult = (known) => (!withdrawn && known.candidate
+ ? resultForCandidate(localRelease, known, { nowMs }) : silent(reason));
try {
const committed = await commitOperation(
stateDirectory,
operation,
localRelease.version,
(current) => ({
- state: stateAfterFailedCheck(repeatNotice
- ? withMigratedCandidate(deliveryState(current), legacyCandidate)
- : current, nowMs, error instanceof ManifestWithdrawnError),
- result: error instanceof ManifestWithdrawnError ? silent('withdrawn')
- : repeatNotice && (current.candidate || legacyCandidate)
- ? resultForCandidate(localRelease,
- { ...current, candidate: current.candidate || legacyCandidate },
- { repeatNotice, nowMs })
- : silent(reason),
+ state: stateAfterFailedCheck(current, nowMs, withdrawn),
+ result: failedResult(current),
}),
);
- if (committed.fenced && repeatNotice) {
- return await resultAfterLosingOperation(
- stateDirectory, operation, localRelease, repeatNotice, nowMs,
- );
+ if (committed.fenced) {
+ return await resultAfterLosingOperation(stateDirectory, operation, localRelease, nowMs);
}
return committed.result;
} catch {
await cancelOperation(stateDirectory, operation).catch(() => {});
- if (error instanceof ManifestWithdrawnError) return silent('withdrawn');
- return repeatNotice && (state.candidate || legacyCandidate)
- ? resultForCandidate(localRelease,
- { ...state, candidate: state.candidate || legacyCandidate },
- { repeatNotice, nowMs })
- : silent('cache-unavailable');
+ return failedResult(state);
}
}
+ const candidate = { ...fetched.candidate, checkedAt: new Date(nowMs).toISOString() };
try {
const committed = await commitOperation(
stateDirectory,
@@ -1689,50 +1569,28 @@ export async function checkForUpdate({
localRelease.version,
(current) => {
const next = {
- ...(repeatNotice ? deliveryState(current) : current),
- candidate: repeatNotice
- ? { ...fetched.candidate, checkedAt: new Date(nowMs).toISOString() }
- : fetched.candidate,
+ ...current,
+ candidate,
check: {
- nextCheckAt: nextSuccessfulCheck(nowMs, random,
- repeatNotice ? DELIVERY_CHECK_TTL_MS : CHECK_TTL_MS),
+ nextCheckAt: nextSuccessfulCheck(nowMs, random),
consecutiveFailures: 0,
},
- notification: {
- offeredDigests: [...current.notification.offeredDigests],
- acknowledgedDigests: [...current.notification.acknowledgedDigests],
- },
};
- const result = resultForCandidate(localRelease, next, { repeatNotice, source: 'network', nowMs });
- if (result.status === 'update_available') {
- if (!next.notification.offeredDigests.includes(next.candidate.targetDigest)) {
- next.notification.offeredDigests.push(next.candidate.targetDigest);
- }
- }
+ const result = resultForCandidate(localRelease, next, { source: 'network', nowMs });
return {
state: next,
result,
- capacityFallback: {
- state: stateAfterFailedCheck(current, nowMs, true),
- result: repeatNotice ? result : silent('cache-unavailable'),
- },
+ capacityFallback: { state: stateAfterFailedCheck(current, nowMs, true), result },
};
},
);
- if (committed.fenced && repeatNotice) {
- return await resultAfterLosingOperation(
- stateDirectory, operation, localRelease, repeatNotice, nowMs,
- );
+ if (committed.fenced) {
+ return await resultAfterLosingOperation(stateDirectory, operation, localRelease, nowMs);
}
return committed.result;
} catch {
await cancelOperation(stateDirectory, operation).catch(() => {});
- return repeatNotice
- ? resultForCandidate(localRelease, {
- ...state,
- candidate: { ...fetched.candidate, checkedAt: new Date(nowMs).toISOString() },
- }, { repeatNotice, source: 'network', nowMs })
- : silent('cache-unavailable');
+ return resultForCandidate(localRelease, { ...state, candidate }, { source: 'network', nowMs });
}
} catch {
await cancelOperation(stateDirectory, operation).catch(() => {});
@@ -1740,72 +1598,6 @@ export async function checkForUpdate({
}
}
-export async function acknowledgeUpdate({
- releasePath = defaultReleasePath,
- cacheDirectory = defaultCacheDirectory(),
- eventKey,
- monotonicNow = () => performance.now(),
-} = {}) {
- const targetDigest = digestForEventKey(eventKey);
- if (!targetDigest || typeof monotonicNow !== 'function') {
- return silent('invalid-acknowledgement');
- }
- let localRelease;
- try {
- localRelease = validateLocalRelease(await readJsonFile(releasePath, MAX_LOCAL_RELEASE_BYTES));
- } catch {
- return silent('invalid-local-release');
- }
- let stateDirectory = versionCacheDirectory(cacheDirectory, localRelease.version);
- try {
- stateDirectory = await prepareCacheDirectory(stateDirectory);
- } catch {
- return silent('cache-unavailable');
- }
- let deadline;
- try {
- deadline = Number(monotonicNow()) + ACK_LOCK_WAIT_MS;
- } catch {
- return silent('invalid-acknowledgement');
- }
- if (!Number.isFinite(deadline)) return silent('invalid-acknowledgement');
- while (true) {
- let operation;
- try {
- operation = await acquireOperation(stateDirectory);
- } catch {
- return silent('cache-unavailable');
- }
- if (!operation) {
- if (!await waitUntilRetry(deadline, monotonicNow)) return silent('check-in-progress');
- continue;
- }
- try {
- const committed = await commitOperation(
- stateDirectory,
- operation,
- localRelease.version,
- (state) => {
- const wasOffered = state.notification.offeredDigests.includes(targetDigest);
- const wasAcknowledged = state.notification.acknowledgedDigests.includes(targetDigest);
- if (!wasOffered && !wasAcknowledged) {
- return { state: null, result: silent('invalid-acknowledgement') };
- }
- return {
- state: stateAfterAcknowledgement(state, targetDigest),
- result: { status: 'acknowledged', eventKey },
- };
- },
- );
- if (!committed.fenced) return committed.result;
- if (!await waitUntilRetry(deadline, monotonicNow)) return silent('check-in-progress');
- } catch {
- await cancelOperation(stateDirectory, operation).catch(() => {});
- return silent('cache-unavailable');
- }
- }
-}
-
export async function setUpdatePreference({
releasePath = defaultReleasePath,
cacheDirectory = defaultCacheDirectory(),
@@ -1826,9 +1618,7 @@ export async function setUpdatePreference({
} catch {
return silent('invalid-local-release');
}
- let stateDirectory = versionCacheDirectory(
- path.join(cacheDirectory, 'reminders-v2'), localRelease.version,
- );
+ let stateDirectory = versionCacheDirectory(cacheDirectory, localRelease.version);
try {
stateDirectory = await prepareCacheDirectory(stateDirectory);
} catch {
@@ -1836,7 +1626,7 @@ export async function setUpdatePreference({
}
const nowMs = Number(now());
if (!Number.isFinite(nowMs)) return silent('invalid-clock');
- const deadline = Number(monotonicNow()) + ACK_LOCK_WAIT_MS;
+ const deadline = Number(monotonicNow()) + PREFERENCE_LOCK_WAIT_MS;
while (Number(monotonicNow()) < deadline) {
let operation;
try {
@@ -1866,7 +1656,7 @@ export async function setUpdatePreference({
.slice(-30);
preferences.push(preference);
return {
- state: { ...deliveryState(state), preferences },
+ state: { ...state, preferences },
result: { status: mode === 'snooze' ? 'snoozed' : 'ignored', eventKey,
...(preference.until ? { suppressedUntil: preference.until } : {}) },
};
diff --git a/archify/scripts/delivery-update-child.mjs b/archify/scripts/delivery-update-child.mjs
index b7d0da7c..dfe6ad84 100644
--- a/archify/scripts/delivery-update-child.mjs
+++ b/archify/scripts/delivery-update-child.mjs
@@ -12,7 +12,6 @@ const deadlineTimer = setTimeout(() => process.kill(process.pid, 'SIGKILL'), rem
deadlineTimer.unref();
const result = await checkForUpdate({
- repeatNotice: true,
...(process.env.ARCHIFY_UPDATE_RELEASE_PATH
? { releasePath: process.env.ARCHIFY_UPDATE_RELEASE_PATH } : {}),
...(process.env.ARCHIFY_UPDATE_CACHE_DIRECTORY
diff --git a/archify/test/delivery-update.test.mjs b/archify/test/delivery-update.test.mjs
index 1a4905c6..2f046fe2 100644
--- a/archify/test/delivery-update.test.mjs
+++ b/archify/test/delivery-update.test.mjs
@@ -41,7 +41,7 @@ function manifest() {
}
async function seed(testFixture) {
- return checkForUpdate({ ...testFixture, repeatNotice: true,
+ return checkForUpdate({ ...testFixture,
fetchImpl: async () => new Response(JSON.stringify(manifest()), {
status: 200, headers: { 'content-type': 'application/json' },
}),
@@ -120,7 +120,6 @@ test('a killed checker holding the cache claim can be followed by a new check',
await checkForUpdate({
releasePath: ${JSON.stringify(testFixture.releasePath)},
cacheDirectory: ${JSON.stringify(testFixture.cacheDirectory)},
- repeatNotice: true,
fetchImpl: async () => {
process.stdout.write('entered fetch\\n');
return new Promise(() => {});
diff --git a/archify/test/update-notifier.test.mjs b/archify/test/update-notifier.test.mjs
index 15ded13c..056d4999 100644
--- a/archify/test/update-notifier.test.mjs
+++ b/archify/test/update-notifier.test.mjs
@@ -9,7 +9,6 @@ import test from 'node:test';
import { fileURLToPath, pathToFileURL } from 'node:url';
import {
- acknowledgeUpdate,
checkForUpdate,
isMainModule,
setUpdatePreference,
@@ -25,7 +24,6 @@ const expectedManifestUrl = 'https://tt-a1i.github.io/archify/skill-updates/arch
const baseTime = Date.parse('2026-08-28T08:00:00Z');
const childCheckTimeoutMs = 2_000;
const parentCheckTimeoutMs = 5_000;
-const maxCacheStateBytes = 64 * 1_024;
function writeJson(target, value) {
fs.mkdirSync(path.dirname(target), { recursive: true });
@@ -46,43 +44,16 @@ function metadataWithOverrides(metadata, overrides) {
});
}
-function historyDigest(index) {
- return `sha256:${crypto.createHash('sha256').update(`history-${index}`).digest('hex')}`;
-}
-
-function cachedStateWithHistory({ offeredDigests = [], acknowledgedDigests = [] } = {}) {
+function expiredCachedState() {
return {
- schemaVersion: 1,
+ schemaVersion: 2,
skillId: 'archify',
installedVersion: '2.15.0',
check: {
nextCheckAt: '2020-01-01T00:00:00.000Z',
consecutiveFailures: 0,
},
- notification: {
- offeredDigests: [...offeredDigests],
- acknowledgedDigests: [...acknowledgedDigests],
- },
- };
-}
-
-function candidateStateForDigest(state, digest) {
- return {
- ...state,
- check: {
- nextCheckAt: new Date(baseTime + (72 * 60 * 60 * 1_000)).toISOString(),
- consecutiveFailures: 0,
- },
- notification: {
- offeredDigests: [...state.notification.offeredDigests, digest],
- acknowledgedDigests: [...state.notification.acknowledgedDigests],
- },
- candidate: {
- version: '2.16.0',
- targetDigest: digest,
- severity: 'normal',
- releaseNotes: 'https://github.com/tt-a1i/archify/releases/tag/v2.16.0',
- },
+ preferences: [],
};
}
@@ -397,26 +368,50 @@ function options(testFixture, fetchImpl, overrides = {}) {
function cachedUpdateState() {
return {
- schemaVersion: 1,
+ schemaVersion: 2,
skillId: 'archify',
installedVersion: '2.15.0',
check: {
nextCheckAt: new Date(baseTime + (24 * 60 * 60 * 1_000)).toISOString(),
consecutiveFailures: 0,
},
- notification: {
- offeredDigests: [`sha256:${'b'.repeat(64)}`],
- acknowledgedDigests: [],
- },
+ preferences: [],
candidate: {
version: '2.16.0',
targetDigest: `sha256:${'b'.repeat(64)}`,
severity: 'normal',
releaseNotes: 'https://github.com/tt-a1i/archify/releases/tag/v2.16.0',
+ checkedAt: new Date(baseTime).toISOString(),
},
};
}
+function currentResult(availableVersion = '2.15.0', {
+ installedVersion = '2.15.0', checkedAtMs = baseTime, source = 'network',
+} = {}) {
+ return {
+ status: 'current', installedVersion, availableVersion,
+ checkedAt: new Date(checkedAtMs).toISOString(), source, noticeRequired: false,
+ };
+}
+
+function snooze(testFixture, eventKey, nowMs = baseTime) {
+ return setUpdatePreference({
+ releasePath: testFixture.releasePath,
+ cacheDirectory: testFixture.cacheDirectory,
+ eventKey,
+ mode: 'snooze',
+ now: () => nowMs,
+ });
+}
+
+function snoozed(eventKey, nowMs = baseTime) {
+ return {
+ status: 'snoozed', eventKey,
+ suppressedUntil: new Date(nowMs + (7 * 24 * 60 * 60 * 1_000)).toISOString(),
+ };
+}
+
function createFifo(target) {
const created = spawnSync('mkfifo', [target], { encoding: 'utf8' });
if (created.error?.code === 'ENOENT') return false;
@@ -466,7 +461,7 @@ function runCheckInChild(testFixture) {
function assertUnsafeCacheStateIsIgnored(testFixture) {
assert.deepEqual(runCheckInChild(testFixture), {
- result: { status: 'silent', reason: 'current' },
+ result: currentResult(),
requests: 1,
});
}
@@ -508,7 +503,7 @@ test('development installs never treat the older stable release as an update', a
})),
));
- assert.deepEqual(result, { status: 'silent', reason: 'current' });
+ assert.deepEqual(result, currentResult('2.15.0', { installedVersion: '2.16.0-dev.0' }));
});
test('a changed digest never bypasses same-version or downgrade protection', async () => {
@@ -522,7 +517,7 @@ test('a changed digest never bypasses same-version or downgrade protection', asy
testFixture,
async () => response(remoteReleaseForVersion(version, digest)),
));
- assert.deepEqual(result, { status: 'silent', reason: 'current' });
+ assert.deepEqual(result, currentResult(version));
} finally {
fs.rmSync(testFixture.root, { recursive: true, force: true });
}
@@ -547,12 +542,12 @@ test('a successful refresh withdraws a previously offered higher candidate', asy
const withdrawn = await checkForUpdate(options(testFixture, fetchImpl, {
now: () => baseTime + (73 * 60 * 60 * 1_000),
}));
- assert.deepEqual(withdrawn, { status: 'silent', reason: 'current' });
+ assert.deepEqual(withdrawn, currentResult('2.15.0', { checkedAtMs: baseTime + (73 * 60 * 60 * 1_000) }));
assert.equal(JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8')).candidate.version, '2.15.0');
assert.equal(requests, 2);
});
-test('a newer immutable candidate is re-offered until the visible notice is acknowledged', async (t) => {
+test('a newer immutable candidate is repeated from cache on every check', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
let requests = 0;
@@ -567,390 +562,26 @@ test('a newer immutable candidate is re-offered until the visible notice is ackn
assert.equal(first.latestVersion, '2.16.0');
assert.equal(first.eventKey, `archify@sha256:${'b'.repeat(64)}`);
assert.equal(first.targetDigest, `sha256:${'b'.repeat(64)}`);
+ assert.equal(first.source, 'network');
+ assert.equal(first.noticeRequired, true);
assert.equal(Object.hasOwn(first, 'updateCommand'), false);
assert.equal(first.summary, 'Archify 2.16.0 is available; see the official release notes for details.');
const persisted = JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8'));
- assert.deepEqual(Object.keys(persisted.check).sort(), [
- 'consecutiveFailures', 'nextCheckAt',
- ]);
- assert.deepEqual(Object.keys(persisted.notification).sort(), [
- 'acknowledgedDigests', 'offeredDigests',
+ assert.deepEqual(Object.keys(persisted).sort(), [
+ 'candidate', 'check', 'installedVersion', 'preferences', 'schemaVersion', 'skillId',
]);
assert.deepEqual(Object.keys(persisted.candidate).sort(), [
- 'releaseNotes', 'severity', 'targetDigest', 'version',
+ 'checkedAt', 'releaseNotes', 'severity', 'targetDigest', 'version',
]);
- const second = await checkForUpdate(options(testFixture, fetchImpl));
- assert.equal(second.status, 'update_available');
- assert.equal(second.eventKey, first.eventKey);
- assert.equal(requests, 1, 'fresh cached candidates must not make another request');
-
- const acknowledgement = await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: first.eventKey,
- now: () => baseTime + 1_000,
- });
- assert.deepEqual(acknowledgement, { status: 'acknowledged', eventKey: first.eventKey });
- assert.deepEqual(
- JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8')).notification.acknowledgedDigests,
- [first.targetDigest],
- );
-
- const third = await checkForUpdate(options(testFixture, fetchImpl));
- assert.deepEqual(third, { status: 'silent', reason: 'already-notified' });
- assert.equal(requests, 1);
-});
-
-test('an acknowledged candidate stays suppressed after a later candidate and manifest rollback', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const releases = [
- remoteReleaseForVersion('2.16.0', 'b'.repeat(64)),
- remoteReleaseForVersion('2.17.0', 'c'.repeat(64)),
- remoteReleaseForVersion('2.16.0', 'b'.repeat(64)),
- ];
- let requests = 0;
- const fetchImpl = async () => response(releases[requests++]);
-
- const first = await checkForUpdate(options(testFixture, fetchImpl));
- assert.equal(first.status, 'update_available');
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: first.eventKey,
- }), { status: 'acknowledged', eventKey: first.eventKey });
-
- const second = await checkForUpdate(options(testFixture, fetchImpl, {
- now: () => baseTime + (73 * 60 * 60 * 1_000),
- }));
- assert.equal(second.status, 'update_available');
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: second.eventKey,
- }), { status: 'acknowledged', eventKey: second.eventKey });
-
- assert.deepEqual(await checkForUpdate(options(testFixture, fetchImpl, {
- now: () => baseTime + (146 * 60 * 60 * 1_000),
- })), { status: 'silent', reason: 'already-notified' });
- assert.equal(requests, 3);
- assert.deepEqual(
- JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8')).notification.acknowledgedDigests,
- [first.targetDigest, second.targetDigest],
- );
-});
-
-test('a 64 KiB multi-offer cache only returns an event whose acknowledgement closure can commit', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const earlierDigest = `sha256:${'a'.repeat(64)}`;
- const currentDigest = `sha256:${'b'.repeat(64)}`;
- const replacementDigest = `sha256:${'c'.repeat(64)}`;
- const cachedVersion = `3.16.${'9'.repeat(35)}`;
- const state = cachedStateWithHistory({
- offeredDigests: [earlierDigest, currentDigest],
- acknowledgedDigests: Array.from({ length: 877 }, (_, index) => historyDigest(index)),
- });
- state.check.nextCheckAt = 'Mon, 31 Aug 2026 08:00:00 GMT';
- state.candidate = {
- version: cachedVersion,
- targetDigest: currentDigest,
- severity: 'normal',
- releaseNotes: `https://github.com/tt-a1i/archify/releases/tag/v${cachedVersion}`,
- };
- assert.equal(Buffer.byteLength(compactStateSource(state)), maxCacheStateBytes);
- writeCompactCommittedState(testFixture, state);
- let requests = 0;
-
- const offered = await checkForUpdate(options(testFixture, async () => {
- requests += 1;
- return response(remoteReleaseForVersion('2.16.0', 'c'.repeat(64)));
- }));
- assert.equal(offered.status, 'update_available');
- const acknowledgement = await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- });
-
- assert.deepEqual(acknowledgement, {
- status: 'acknowledged',
- eventKey: offered.eventKey,
- });
- assert.equal(requests, 1, 'an unrecoverable cached offer must be rebuilt before exposure');
- assert.equal(offered.targetDigest, replacementDigest);
-});
-
-test('a recoverable multi-offer boundary acknowledges every event without pruning history', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const earlierDigest = `sha256:${'a'.repeat(64)}`;
- const currentDigest = `sha256:${'b'.repeat(64)}`;
- const cachedVersion = `3.16.${'9'.repeat(35)}`;
- const exactHistory = Array.from({ length: 877 }, (_, index) => historyDigest(index));
- const state = cachedStateWithHistory({
- offeredDigests: [earlierDigest, currentDigest],
- acknowledgedDigests: exactHistory,
- });
- state.check.nextCheckAt = 'Mon, 31 Aug 2026 8:00:00 GMT';
- state.candidate = {
- version: cachedVersion,
- targetDigest: currentDigest,
- severity: 'normal',
- releaseNotes: `https://github.com/tt-a1i/archify/releases/tag/v${cachedVersion}`,
- };
- assert.equal(Buffer.byteLength(compactStateSource(state)), maxCacheStateBytes - 1);
- writeCompactCommittedState(testFixture, state);
-
- const current = await checkForUpdate(options(testFixture, async () => {
- throw new Error('a fresh recoverable cache must not use the network');
- }));
- assert.equal(current.targetDigest, currentDigest);
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: current.eventKey,
- }), { status: 'acknowledged', eventKey: current.eventKey });
- const earlierEventKey = `archify@${earlierDigest}`;
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: earlierEventKey,
- }), { status: 'acknowledged', eventKey: earlierEventKey });
-
- const persisted = JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8'));
- assert.deepEqual(persisted.notification, {
- offeredDigests: [],
- acknowledgedDigests: [...exactHistory, currentDigest, earlierDigest],
- });
- assert.equal(fs.statSync(statePath(testFixture)).size, maxCacheStateBytes);
-});
-
-test('a near-capacity null schedule does not retry the network on every activation', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const state = cachedStateWithHistory({
- acknowledgedDigests: Array.from({ length: 883 }, (_, index) => historyDigest(index)),
- });
- state.check.nextCheckAt = null;
- assert.equal(Buffer.byteLength(compactStateSource(state)), 65_524);
- writeCompactCommittedState(testFixture, state);
- let requests = 0;
- const fetchImpl = async () => {
- requests += 1;
- return response(remoteRelease());
- };
-
- const first = await checkForUpdate(options(testFixture, fetchImpl));
- const second = await checkForUpdate(options(testFixture, fetchImpl));
-
- assert.equal(first.status, 'update_available');
- assert.deepEqual(second, first);
- assert.equal(requests, 1, 'the first check must commit a bounded retry or reusable candidate');
-});
-
-test('a saturated exact acknowledgement history never returns an unacknowledgeable offer', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const targetDigest = `sha256:${'f'.repeat(64)}`;
- const state = cachedStateWithHistory();
- let projected = candidateStateForDigest(state, targetDigest);
- let index = 0;
- while (Buffer.byteLength(compactStateSource(projected)) <= maxCacheStateBytes) {
- state.notification.acknowledgedDigests.push(historyDigest(index));
- index += 1;
- projected = candidateStateForDigest(state, targetDigest);
+ for (let index = 0; index < 2; index += 1) {
+ const repeated = await checkForUpdate(options(testFixture, fetchImpl));
+ assert.equal(repeated.eventKey, first.eventKey);
+ assert.equal(repeated.source, 'cache');
+ assert.equal(repeated.checkedAt, first.checkedAt);
+ assert.equal(repeated.noticeRequired, true);
}
- assert.ok(Buffer.byteLength(compactStateSource(state)) <= maxCacheStateBytes);
- assert.ok(Buffer.byteLength(compactStateSource(projected)) > maxCacheStateBytes);
- const exactHistory = [...state.notification.acknowledgedDigests];
- writeCompactCommittedState(testFixture, state);
- let requests = 0;
-
- const result = await checkForUpdate(options(testFixture, async () => {
- requests += 1;
- return response(remoteReleaseForVersion('2.16.0', 'f'.repeat(64)));
- }));
- const acknowledgement = result.status === 'update_available'
- ? await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: result.eventKey,
- })
- : null;
-
- assert.deepEqual({ result, acknowledgement }, {
- result: { status: 'silent', reason: 'cache-unavailable' },
- acknowledgement: null,
- });
- assert.equal(requests, 1);
- assert.ok(committedStateFiles(testFixture).every(
- (target) => fs.statSync(target).size <= maxCacheStateBytes,
- ));
- assert.deepEqual(
- JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8')).notification.acknowledgedDigests,
- exactHistory,
- );
-
- assert.deepEqual(await checkForUpdate(options(testFixture, async () => {
- requests += 1;
- return response(remoteReleaseForVersion('2.16.0', 'f'.repeat(64)));
- })), { status: 'silent', reason: 'cache-valid' });
- assert.equal(requests, 1, 'capacity rejection should commit a bounded retry delay');
-});
-
-test('capacity backoff withdraws a stale candidate while preserving its late acknowledgement', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const staleDigest = `sha256:${'b'.repeat(64)}`;
- const replacementDigest = `sha256:${'c'.repeat(64)}`;
- const state = cachedStateWithHistory({ offeredDigests: [staleDigest] });
- state.candidate = {
- version: '2.16.0',
- targetDigest: staleDigest,
- severity: 'normal',
- releaseNotes: 'https://github.com/tt-a1i/archify/releases/tag/v2.16.0',
- };
- let replacement = candidateStateForDigest(state, replacementDigest);
- let index = 0;
- while (Buffer.byteLength(compactStateSource(replacement)) <= maxCacheStateBytes) {
- state.notification.acknowledgedDigests.push(historyDigest(index));
- index += 1;
- replacement = candidateStateForDigest(state, replacementDigest);
- }
- assert.ok(Buffer.byteLength(compactStateSource(state)) <= maxCacheStateBytes);
- assert.ok(Buffer.byteLength(compactStateSource(replacement)) > maxCacheStateBytes);
- const exactHistory = [...state.notification.acknowledgedDigests];
- writeCompactCommittedState(testFixture, state);
- let requests = 0;
- const fetchImpl = async () => {
- requests += 1;
- return response(remoteReleaseForVersion('2.16.0', 'c'.repeat(64)));
- };
-
- const refresh = await checkForUpdate(options(testFixture, fetchImpl));
- const cached = await checkForUpdate(options(testFixture, fetchImpl));
- const staleEventKey = `archify@${staleDigest}`;
- const lateAcknowledgement = await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: staleEventKey,
- });
-
- assert.deepEqual({ refresh, cached, lateAcknowledgement }, {
- refresh: { status: 'silent', reason: 'cache-unavailable' },
- cached: { status: 'silent', reason: 'cache-valid' },
- lateAcknowledgement: { status: 'acknowledged', eventKey: staleEventKey },
- });
- assert.equal(requests, 1);
- assert.ok(committedStateFiles(testFixture).every(
- (target) => fs.statSync(target).size <= maxCacheStateBytes,
- ));
- const persisted = JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8'));
- assert.equal(Object.hasOwn(persisted, 'candidate'), false);
- assert.deepEqual(persisted.notification, {
- offeredDigests: [],
- acknowledgedDigests: [...exactHistory, staleDigest],
- });
-});
-
-test('a 64 KiB state can be acknowledged but a 64 KiB plus one state is ignored', async () => {
- const targetDigest = `sha256:${'e'.repeat(64)}`;
- const exactState = cachedStateWithHistory({ offeredDigests: [targetDigest] });
- exactState.candidate = {
- version: '2.16.0',
- targetDigest,
- severity: 'normal',
- releaseNotes: 'https://github.com/tt-a1i/archify/releases/tag/v2.16.0',
- };
- const initialBytes = Buffer.byteLength(compactStateSource(exactState));
- exactState.check.nextCheckAt += 'x'.repeat(maxCacheStateBytes - initialBytes);
- assert.equal(Buffer.byteLength(compactStateSource(exactState)), maxCacheStateBytes);
-
- const exactFixture = fixture();
- try {
- writeCompactCommittedState(exactFixture, exactState);
- const eventKey = `archify@${targetDigest}`;
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: exactFixture.releasePath,
- cacheDirectory: exactFixture.cacheDirectory,
- eventKey,
- }), { status: 'acknowledged', eventKey });
- assert.equal(fs.statSync(statePath(exactFixture)).size, maxCacheStateBytes);
- assert.deepEqual(
- JSON.parse(fs.readFileSync(statePath(exactFixture), 'utf8')).notification,
- { offeredDigests: [], acknowledgedDigests: [targetDigest] },
- );
- } finally {
- fs.rmSync(exactFixture.root, { recursive: true, force: true });
- }
-
- const oversizedFixture = fixture();
- try {
- const target = writeCompactCommittedState(oversizedFixture, exactState);
- fs.appendFileSync(target, ' ');
- assert.equal(fs.statSync(target).size, maxCacheStateBytes + 1);
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: oversizedFixture.releasePath,
- cacheDirectory: oversizedFixture.cacheDirectory,
- eventKey: `archify@${targetDigest}`,
- }), { status: 'silent', reason: 'invalid-acknowledgement' });
- } finally {
- fs.rmSync(oversizedFixture.root, { recursive: true, force: true });
- }
-});
-
-test('a boundary offer remains acknowledgeable without pruning exact history', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const targetDigest = `sha256:${'d'.repeat(64)}`;
- const state = cachedStateWithHistory();
- let index = 0;
- while (true) {
- state.notification.acknowledgedDigests.push(historyDigest(index));
- if (Buffer.byteLength(compactStateSource(
- candidateStateForDigest(state, targetDigest),
- )) > maxCacheStateBytes) {
- state.notification.acknowledgedDigests.pop();
- break;
- }
- index += 1;
- }
- const projected = candidateStateForDigest(state, targetDigest);
- assert.ok(Buffer.byteLength(compactStateSource(projected)) <= maxCacheStateBytes);
- const oneMoreAcknowledgement = cachedStateWithHistory({
- acknowledgedDigests: [...state.notification.acknowledgedDigests, historyDigest(index)],
- });
- assert.ok(Buffer.byteLength(compactStateSource(
- candidateStateForDigest(oneMoreAcknowledgement, targetDigest),
- )) > maxCacheStateBytes);
- const exactHistory = [...state.notification.acknowledgedDigests];
- writeCompactCommittedState(testFixture, state);
- const fetchImpl = async () => response(remoteReleaseForVersion('2.16.0', 'd'.repeat(64)));
-
- const offered = await checkForUpdate(options(testFixture, fetchImpl));
- assert.equal(offered.status, 'update_available');
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- }), { status: 'acknowledged', eventKey: offered.eventKey });
-
- assert.ok(committedStateFiles(testFixture).every(
- (target) => fs.statSync(target).size <= maxCacheStateBytes,
- ));
- assert.deepEqual(
- JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8')).notification,
- {
- offeredDigests: [],
- acknowledgedDigests: [...exactHistory, targetDigest],
- },
- );
- assert.deepEqual(await checkForUpdate(options(testFixture, fetchImpl)), {
- status: 'silent',
- reason: 'already-notified',
- });
+ assert.equal(requests, 1, 'fresh cached candidates must not make another request');
});
test('opaque response validators are neither persisted nor replayed after the check TTL', async (t) => {
@@ -995,11 +626,13 @@ test('an HTTP 304 is always a failed unconditional refresh', async (t) => {
now: () => baseTime + (73 * 60 * 60 * 1_000),
}));
- assert.deepEqual(refresh, { status: 'silent', reason: 'check-failed' });
+ assert.equal(refresh.status, 'update_available');
+ assert.equal(refresh.source, 'cache');
assert.equal(requests, 2);
+ assert.equal(JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8')).check.consecutiveFailures, 1);
});
-test('a failed refresh preserves the last-good unacknowledged candidate', async (t) => {
+test('a failed refresh keeps repeating the last validated candidate', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
let requests = 0;
@@ -1014,7 +647,9 @@ test('a failed refresh preserves the last-good unacknowledged candidate', async
const failed = await checkForUpdate(options(testFixture, fetchImpl, {
now: () => baseTime + (73 * 60 * 60 * 1_000),
}));
- assert.deepEqual(failed, { status: 'silent', reason: 'check-failed' });
+ assert.equal(failed.status, 'update_available');
+ assert.equal(failed.eventKey, first.eventKey);
+ assert.equal(failed.checkedAt, first.checkedAt);
const cached = await checkForUpdate(options(testFixture, fetchImpl, {
now: () => baseTime + (74 * 60 * 60 * 1_000),
@@ -1028,17 +663,14 @@ test('failure backoff saturates safely instead of overflowing the cache counter'
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
writeJson(statePath(testFixture), {
- schemaVersion: 1,
+ schemaVersion: 2,
skillId: 'archify',
installedVersion: '2.15.0',
check: {
nextCheckAt: new Date(baseTime - 1_000).toISOString(),
consecutiveFailures: Number.MAX_SAFE_INTEGER,
},
- notification: {
- offeredDigests: [],
- acknowledgedDigests: [],
- },
+ preferences: [],
});
let requests = 0;
const fetchImpl = async () => {
@@ -1105,7 +737,7 @@ test('a cache ancestor replaced before a cached read cannot inject a reminder',
fsPromises.readdir = originalReaddir;
fs.rmSync(testFixture.root, { recursive: true, force: true });
});
- writeCompactCommittedState(testFixture, cachedStateWithHistory());
+ writeCompactCommittedState(testFixture, expiredCachedState());
const replacementRoot = path.join(testFixture.root, 'replacement-cache');
writeJson(
path.join(replacementRoot, path.basename(stateDirectory(testFixture)),
@@ -1160,7 +792,7 @@ test('a committed directory replaced by a symlink cannot inject a reminder', asy
fsPromises.readdir = originalReaddir;
fs.rmSync(testFixture.root, { recursive: true, force: true });
});
- writeCompactCommittedState(testFixture, cachedStateWithHistory());
+ writeCompactCommittedState(testFixture, expiredCachedState());
const committed = operationPath(testFixture, 'committed', 1n);
const replacement = path.join(testFixture.root, 'replacement-committed');
writeJson(path.join(replacement, 'state.json'), cachedUpdateState());
@@ -1275,7 +907,7 @@ test('zero-inode cache metadata uses timestamp fallback to reject a replaced anc
fsPromises.readdir = originalReaddir;
fs.rmSync(testFixture.root, { recursive: true, force: true });
});
- writeCompactCommittedState(testFixture, cachedStateWithHistory());
+ writeCompactCommittedState(testFixture, expiredCachedState());
const replacementRoot = path.join(testFixture.root, 'replacement-cache');
writeJson(
path.join(replacementRoot, path.basename(stateDirectory(testFixture)),
@@ -1317,7 +949,7 @@ test('zero-inode cache metadata uses timestamp fallback to reject a replaced anc
assert.equal(requests, 0);
});
-test('zero-inode cache metadata still supports a normal check and acknowledgement', async (t) => {
+test('zero-inode cache metadata still supports a normal check and snooze', async (t) => {
const testFixture = fixture();
const originalLstat = fsPromises.lstat;
const originalOpen = fsPromises.open;
@@ -1362,14 +994,17 @@ test('zero-inode cache metadata still supports a normal check and acknowledgemen
requests += 1;
return response(remoteRelease());
}));
- const acknowledged = await acknowledgeUpdate({
+ const snoozed = await setUpdatePreference({
releasePath: testFixture.releasePath,
cacheDirectory: testFixture.cacheDirectory,
eventKey: offered.eventKey,
+ mode: 'snooze',
+ now: () => baseTime,
});
assert.equal(offered.status, 'update_available');
- assert.deepEqual(acknowledged, { status: 'acknowledged', eventKey: offered.eventKey });
+ assert.equal(snoozed.status, 'snoozed');
+ assert.equal(snoozed.eventKey, offered.eventKey);
assert.equal(requests, 1);
});
@@ -1439,7 +1074,8 @@ test('a state write replaced before post-verification is never reported as commi
const result = await checkForUpdate(options(testFixture, async () => response(remoteRelease())));
assert.equal(replaced, true);
- assert.deepEqual(result, { status: 'silent', reason: 'cache-unavailable' });
+ assert.equal(result.status, 'update_available');
+ assert.equal(result.source, 'network');
for (const committed of committedStateFiles(testFixture)) {
assert.notDeepEqual(JSON.parse(fs.readFileSync(committed, 'utf8')), {});
}
@@ -1499,7 +1135,8 @@ test('a pending directory replaced by a symlink cannot be reported as committed'
}));
assert.equal(replaced, true);
- assert.deepEqual(result, { status: 'silent', reason: 'cache-unavailable' });
+ assert.equal(result.status, 'update_available');
+ assert.equal(result.source, 'network');
assert.equal(requests, 1);
assert.equal(fs.existsSync(path.join(detachedPending, 'state.json')), true);
});
@@ -2469,7 +2106,7 @@ test('an overlapping check reads the last-good candidate while another process r
assert.equal((await refresh).status, 'update_available');
});
-test('acknowledgement waits briefly for an in-flight refresh instead of losing the notice', async (t) => {
+test('a snooze waits briefly for an in-flight refresh instead of losing the choice', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const offered = await checkForUpdate(options(
@@ -2487,26 +2124,21 @@ test('acknowledgement waits briefly for an in-flight refresh instead of losing t
}));
await refreshStarted;
- const acknowledgement = acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- now: () => baseTime + (73 * 60 * 60 * 1_000) + 1,
- });
+ const snoozeTime = baseTime + (73 * 60 * 60 * 1_000) + 1;
+ const preference = snooze(testFixture, offered.eventKey, snoozeTime);
await new Promise((resolve) => setTimeout(resolve, 25));
releaseRefresh(response(remoteRelease()));
await refresh;
- assert.deepEqual(await acknowledgement, {
- status: 'acknowledged',
- eventKey: offered.eventKey,
- });
- assert.deepEqual(await checkForUpdate(options(testFixture, async () => response(remoteRelease()), {
+ assert.deepEqual(await preference, snoozed(offered.eventKey, snoozeTime));
+ const later = await checkForUpdate(options(testFixture, async () => response(remoteRelease()), {
now: () => baseTime + (74 * 60 * 60 * 1_000),
- })), { status: 'silent', reason: 'already-notified' });
+ }));
+ assert.equal(later.noticeRequired, false);
+ assert.equal(later.reason, 'snoozed');
});
-test('a last-good notice remains acknowledgeable after the refresh commits a new candidate', async (t) => {
+test('a snooze for a superseded release never suppresses the newer candidate', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const firstRelease = remoteReleaseForVersion('2.16.0', 'b'.repeat(64));
@@ -2532,25 +2164,20 @@ test('a last-good notice remains acknowledgeable after the refresh commits a new
now: () => baseTime + (73 * 60 * 60 * 1_000),
}));
assert.equal(visibleDuringRefresh.eventKey, offered.eventKey);
- const acknowledgement = acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: visibleDuringRefresh.eventKey,
- });
+ const preference = snooze(testFixture, visibleDuringRefresh.eventKey);
await new Promise((resolve) => setTimeout(resolve, 25));
releaseRefresh(response(secondRelease));
- assert.equal((await refresh).latestVersion, '2.17.0');
- assert.deepEqual(await acknowledgement, {
- status: 'acknowledged',
- eventKey: offered.eventKey,
- });
-
- assert.deepEqual(await checkForUpdate(options(testFixture, async () => response(firstRelease), {
- now: () => baseTime + (146 * 60 * 60 * 1_000),
- })), { status: 'silent', reason: 'already-notified' });
+ const newer = await refresh;
+ assert.equal(newer.latestVersion, '2.17.0');
+ assert.deepEqual(await preference, { status: 'silent', reason: 'invalid-preference' });
+ const repeated = await checkForUpdate(options(testFixture, async () => {
+ assert.fail('a fresh cache must not start another network request');
+ }));
+ assert.equal(repeated.eventKey, newer.eventKey);
+ assert.equal(repeated.noticeRequired, true);
});
-test('acknowledgement retry budget uses a monotonic clock', async (t) => {
+test('preference retry budget uses a monotonic clock', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const offered = await checkForUpdate(options(
@@ -2561,10 +2188,11 @@ test('acknowledgement retry budget uses a monotonic clock', async (t) => {
const ticks = [100, 1_301];
const started = Date.now();
- assert.deepEqual(await acknowledgeUpdate({
+ assert.deepEqual(await setUpdatePreference({
releasePath: testFixture.releasePath,
cacheDirectory: testFixture.cacheDirectory,
eventKey: offered.eventKey,
+ mode: 'snooze',
monotonicNow: () => ticks.shift() ?? 1_301,
}), { status: 'silent', reason: 'check-in-progress' });
assert.ok(Date.now() - started < 200, 'an exhausted monotonic budget should not sleep on wall time');
@@ -2582,24 +2210,17 @@ test('a delayed allocator cannot reuse a generation after its reservation name w
const pause = pauseMkdirOnce(operationPath(testFixture, 'reserved', 2n));
t.after(() => pause.restore());
- const acknowledgement = acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- });
+ const preference = snooze(testFixture, offered.eventKey);
await pause.reached;
assert.equal((await checkForUpdate(options(testFixture, async () => response(secondRelease), {
now: () => baseTime + (73 * 60 * 60 * 1_000),
}))).latestVersion, '2.17.0');
pause.release();
- assert.deepEqual(await acknowledgement, { status: 'acknowledged', eventKey: offered.eventKey });
+ assert.deepEqual(await preference, { status: 'silent', reason: 'invalid-preference' });
pause.restore();
assert.equal(fs.existsSync(operationPath(testFixture, 'reserved', 2n)), true);
assert.equal(fs.existsSync(operationPath(testFixture, 'reserved', 3n)), true);
- assert.deepEqual(await checkForUpdate(options(testFixture, async () => response(firstRelease), {
- now: () => baseTime + (146 * 60 * 60 * 1_000),
- })), { status: 'silent', reason: 'already-notified' });
});
test('an oversized generation name cannot poison future allocation', async (t) => {
@@ -2631,11 +2252,7 @@ test('a lower generation stalled after reservation cannot commit behind a newer
const pause = pauseMkdirOnce(operationPath(testFixture, 'pending', 2n));
t.after(() => pause.restore());
- const acknowledgement = acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- });
+ const preference = snooze(testFixture, offered.eventKey);
await pause.reached;
assert.equal(fs.existsSync(operationPath(testFixture, 'reserved', 2n)), true);
assert.equal((await checkForUpdate(options(testFixture, async () => response(secondRelease), {
@@ -2643,18 +2260,15 @@ test('a lower generation stalled after reservation cannot commit behind a newer
}))).latestVersion, '2.17.0');
pause.release();
- assert.deepEqual(await acknowledgement, { status: 'acknowledged', eventKey: offered.eventKey });
+ assert.deepEqual(await preference, { status: 'silent', reason: 'invalid-preference' });
pause.restore();
assert.equal(fs.existsSync(operationPath(testFixture, 'committed', 2n)), false);
assert.equal(fs.existsSync(operationPath(testFixture, 'cancelled', 2n)), true);
assert.equal(fs.existsSync(operationPath(testFixture, 'reserved', 3n)), true);
assert.equal(fs.existsSync(operationPath(testFixture, 'reserved', 4n)), true);
- assert.deepEqual(await checkForUpdate(options(testFixture, async () => response(firstRelease), {
- now: () => baseTime + (146 * 60 * 60 * 1_000),
- })), { status: 'silent', reason: 'already-notified' });
});
-test('acknowledgement fences an expired refresh and the resumed owner cannot erase it', async (t) => {
+test('a snooze fences an expired refresh and the resumed owner cannot erase it', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const offered = await checkForUpdate(options(
@@ -2677,22 +2291,21 @@ test('acknowledgement fences an expired refresh and the resumed owner cannot era
const refreshPending = operationPath(testFixture, 'pending', 2n);
const staleTime = new Date(Date.now() - 60_000);
fs.utimesSync(path.join(refreshPending, 'owner.json'), staleTime, staleTime);
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- now: () => baseTime + (73 * 60 * 60 * 1_000) + 1,
- }), { status: 'acknowledged', eventKey: offered.eventKey });
+ const snoozeTime = baseTime + (73 * 60 * 60 * 1_000) + 1;
+ assert.deepEqual(await snooze(testFixture, offered.eventKey, snoozeTime),
+ snoozed(offered.eventKey, snoozeTime));
resumeRefresh(response(remoteRelease()));
- assert.deepEqual(await refresh, { status: 'silent', reason: 'check-in-progress' });
- assert.deepEqual(await checkForUpdate(options(testFixture, async () => response(remoteRelease()), {
- now: () => baseTime + (71 * 60 * 60 * 1_000),
- })), { status: 'silent', reason: 'already-notified' });
+ assert.equal((await refresh).reason, 'snoozed');
+ const later = await checkForUpdate(options(testFixture, async () => response(remoteRelease()), {
+ now: () => baseTime + (74 * 60 * 60 * 1_000),
+ }));
+ assert.equal(later.noticeRequired, false);
+ assert.equal(later.reason, 'snoozed');
});
for (const pausePoint of ['pending owner creation', 'state temp creation']) {
- test(`acknowledgement retries when fenced during ${pausePoint}`, async (t) => {
+ test(`a snooze retries when fenced during ${pausePoint}`, async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const offered = await checkForUpdate(options(
@@ -2709,11 +2322,7 @@ for (const pausePoint of ['pending owner creation', 'state temp creation']) {
});
t.after(() => pause.restore());
- const acknowledgement = acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: offered.eventKey,
- });
+ const preference = snooze(testFixture, offered.eventKey);
await pause.reached;
const staleTime = new Date(Date.now() - 60_000);
fs.utimesSync(
@@ -2730,10 +2339,7 @@ for (const pausePoint of ['pending owner creation', 'state temp creation']) {
assert.equal(fs.existsSync(operationPath(testFixture, 'fenced', 2n)), true);
pause.release();
- assert.deepEqual(await acknowledgement, {
- status: 'acknowledged',
- eventKey: offered.eventKey,
- });
+ assert.deepEqual(await preference, snoozed(offered.eventKey));
pause.restore();
});
}
@@ -3041,13 +2647,13 @@ test('a fenced stale owner cannot overwrite a newer committed candidate after re
assert.equal(newer.latestVersion, '3.0.0');
resumeOldOwner(response(remoteReleaseForVersion('2.16.0', 'b'.repeat(64))));
- assert.deepEqual(await oldCheck, { status: 'silent', reason: 'check-in-progress' });
+ assert.equal((await oldCheck).latestVersion, '3.0.0');
const persisted = JSON.parse(fs.readFileSync(statePath(testFixture), 'utf8'));
assert.equal(persisted.candidate.version, '3.0.0');
assert.equal(fs.existsSync(operationPath(testFixture, 'fenced', 1n)), true);
});
-test('different installed versions share no acknowledgement or cache-reset state', async (t) => {
+test('different installed versions share no preference or cache-reset state', async (t) => {
const testFixture = fixture('2.15.0');
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const olderReleasePath = path.join(testFixture.root, 'older-skill-release.json');
@@ -3060,22 +2666,15 @@ test('different installed versions share no acknowledgement or cache-reset state
const newerInstall = await checkForUpdate(options(testFixture, fetchImpl));
assert.equal(newerInstall.status, 'update_available');
- assert.deepEqual(await acknowledgeUpdate({
- releasePath: testFixture.releasePath,
- cacheDirectory: testFixture.cacheDirectory,
- eventKey: newerInstall.eventKey,
- now: () => baseTime + 1_000,
- }), { status: 'acknowledged', eventKey: newerInstall.eventKey });
+ assert.deepEqual(await snooze(testFixture, newerInstall.eventKey, baseTime + 1_000),
+ snoozed(newerInstall.eventKey, baseTime + 1_000));
const olderInstallOptions = options(testFixture, fetchImpl, { releasePath: olderReleasePath });
const olderInstall = await checkForUpdate(olderInstallOptions);
assert.equal(olderInstall.status, 'update_available');
assert.equal(olderInstall.installedVersion, '2.14.0');
- assert.deepEqual(await checkForUpdate(options(testFixture, fetchImpl)), {
- status: 'silent',
- reason: 'already-notified',
- });
+ assert.equal((await checkForUpdate(options(testFixture, fetchImpl))).reason, 'snoozed');
const olderAgain = await checkForUpdate(olderInstallOptions);
assert.equal(olderAgain.status, 'update_available');
assert.equal(requests, 2, 'each installed version should retain its own fresh cache');
@@ -3338,39 +2937,6 @@ test('a semantically corrupt cached candidate discards legacy validators and reb
);
});
-test('a newer cached candidate without offered or acknowledged provenance is rebuilt', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- writeJson(statePath(testFixture), {
- schemaVersion: 1,
- skillId: 'archify',
- installedVersion: '2.15.0',
- check: {
- nextCheckAt: new Date(baseTime + (24 * 60 * 60 * 1_000)).toISOString(),
- consecutiveFailures: 0,
- },
- notification: {
- offeredDigests: [],
- acknowledgedDigests: [],
- },
- candidate: {
- version: '2.16.0',
- targetDigest: `sha256:${'b'.repeat(64)}`,
- severity: 'normal',
- releaseNotes: 'https://github.com/tt-a1i/archify/releases/tag/v2.16.0',
- },
- });
- let requests = 0;
-
- const result = await checkForUpdate(options(testFixture, async () => {
- requests += 1;
- return response(remoteReleaseForVersion('2.15.0', 'd'.repeat(64)));
- }));
-
- assert.deepEqual(result, { status: 'silent', reason: 'current' });
- assert.equal(requests, 1, 'semantic corruption must not produce an unacknowledgeable cached notice');
-});
-
test('corrupt cache is rebuilt without exposing an error to the user', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
@@ -3491,85 +3057,54 @@ test('notifier source has no process execution or remote-origin override surface
assert.doesNotMatch(combinedSource, /updateCommand/);
});
-test('delivery checks repeat a cached update despite legacy acknowledgement', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const first = await checkForUpdate(options(testFixture,
- async () => response(remoteRelease()), { repeatNotice: true }));
- assert.equal(first.status, 'update_available');
- assert.equal(first.source, 'network');
- assert.equal(first.noticeRequired, true);
- assert.equal(first.checkedAt, new Date(baseTime).toISOString());
- const ack = await acknowledgeUpdate({ ...testFixture, eventKey: first.eventKey });
- assert.equal(ack.status, 'silent');
- const second = await checkForUpdate(options(testFixture,
- async () => { throw new Error('should use cache'); }, { repeatNotice: true }));
- assert.equal(second.status, 'update_available');
- assert.equal(second.source, 'cache');
- assert.equal(second.noticeRequired, true);
-});
-
test('delivery preferences are explicit and scoped to the exact release digest', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
const first = await checkForUpdate(options(testFixture,
- async () => response(remoteRelease()), { repeatNotice: true }));
+ async () => response(remoteRelease())));
const ignored = await setUpdatePreference({ ...testFixture,
eventKey: first.eventKey, mode: 'ignore', now: () => baseTime });
assert.equal(ignored.status, 'ignored');
const suppressed = await checkForUpdate(options(testFixture,
- async () => { throw new Error('should use cache'); }, { repeatNotice: true }));
+ async () => { throw new Error('should use cache'); }));
assert.equal(suppressed.noticeRequired, false);
assert.equal(suppressed.reason, 'ignored');
const newer = await checkForUpdate(options(testFixture,
async () => response(remoteReleaseForVersion('2.17.0', 'c'.repeat(64))),
- { repeatNotice: true, now: () => baseTime + 2 * 24 * 60 * 60 * 1_000 }));
+ { now: () => baseTime + 2 * 24 * 60 * 60 * 1_000 }));
assert.equal(newer.status, 'update_available');
assert.equal(newer.noticeRequired, true);
const snoozed = await setUpdatePreference({ ...testFixture,
eventKey: newer.eventKey, mode: 'snooze', now: () => baseTime + 2 * 24 * 60 * 60 * 1_000 });
assert.equal(snoozed.status, 'snoozed');
const during = await checkForUpdate(options(testFixture,
- async () => { throw new Error('should use cache'); }, { repeatNotice: true,
+ async () => { throw new Error('should use cache'); }, {
now: () => baseTime + 3 * 24 * 60 * 60 * 1_000 }));
assert.equal(during.noticeRequired, false);
assert.equal(during.reason, 'snoozed');
const after = await checkForUpdate(options(testFixture,
- async () => { throw new Error('offline'); }, { repeatNotice: true,
+ async () => { throw new Error('offline'); }, {
now: () => baseTime + 10 * 24 * 60 * 60 * 1_000 }));
assert.equal(after.noticeRequired, true);
assert.equal(after.source, 'cache');
});
-test('delivery fallback does not invent a check time for a legacy cache', async (t) => {
- const testFixture = fixture();
- t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
- const legacy = await checkForUpdate(options(testFixture,
- async () => response(remoteRelease())));
- assert.equal(legacy.status, 'update_available');
- const next = await checkForUpdate(options(testFixture,
- async () => { throw new Error('offline'); }, { repeatNotice: true }));
- assert.equal(next.status, 'update_available');
- assert.equal(next.source, 'cache');
- assert.equal(next.checkedAt, null);
-});
-
test('delivery check treats a withdrawn manifest differently from an invalid response', async (t) => {
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
await checkForUpdate(options(testFixture,
- async () => response(remoteRelease()), { repeatNotice: true }));
+ async () => response(remoteRelease())));
const invalid = await checkForUpdate(options(testFixture,
- async () => response('invalid JSON'), { repeatNotice: true,
+ async () => response('invalid JSON'), {
now: () => baseTime + 2 * 24 * 60 * 60 * 1_000 }));
assert.equal(invalid.status, 'update_available');
assert.equal(invalid.source, 'cache');
const withdrawn = await checkForUpdate(options(testFixture,
- async () => response('{}', { status: 404 }), { repeatNotice: true,
+ async () => response('{}', { status: 404 }), {
now: () => baseTime + 3 * 24 * 60 * 60 * 1_000 }));
assert.deepEqual(withdrawn, { status: 'silent', reason: 'withdrawn' });
const cached = await checkForUpdate(options(testFixture,
- async () => { throw new Error('backoff'); }, { repeatNotice: true,
+ async () => { throw new Error('backoff'); }, {
now: () => baseTime + 3 * 24 * 60 * 60 * 1_000 + 1_000 }));
assert.notEqual(cached.status, 'update_available');
});
@@ -3584,13 +3119,13 @@ test('a validated network result survives a cache publication failure without in
};
try {
const offered = await checkForUpdate(options(testFixture,
- async () => response(remoteRelease()), { repeatNotice: true }));
+ async () => response(remoteRelease())));
assert.equal(offered.status, 'update_available');
assert.equal(offered.source, 'network');
const currentFixture = fixture('2.16.0');
t.after(() => fs.rmSync(currentFixture.root, { recursive: true, force: true }));
const current = await checkForUpdate(options(currentFixture,
- async () => response(remoteRelease()), { repeatNotice: true }));
+ async () => response(remoteRelease())));
assert.equal(current.status, 'current');
assert.equal(current.noticeRequired, false);
} finally {
@@ -3602,7 +3137,7 @@ test('an offline delivery still offers the last validated candidate when backoff
const testFixture = fixture();
t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));
await checkForUpdate(options(testFixture,
- async () => response(remoteRelease()), { repeatNotice: true }));
+ async () => response(remoteRelease())));
const originalRename = fsPromises.rename;
fsPromises.rename = async (source, destination, ...args) => {
if (destination.endsWith('state.json')) throw Object.assign(new Error('read-only state'), { code: 'EACCES' });
@@ -3610,7 +3145,7 @@ test('an offline delivery still offers the last validated candidate when backoff
};
try {
const result = await checkForUpdate(options(testFixture,
- async () => { throw new Error('offline'); }, { repeatNotice: true,
+ async () => { throw new Error('offline'); }, {
now: () => baseTime + 2 * 24 * 60 * 60 * 1_000 }));
assert.equal(result.status, 'update_available');
assert.equal(result.source, 'cache');
diff --git a/docs/skill-embedded-optional-update-notifier-design.md b/docs/skill-embedded-optional-update-notifier-design.md
index 640752a4..83310971 100644
--- a/docs/skill-embedded-optional-update-notifier-design.md
+++ b/docs/skill-embedded-optional-update-notifier-design.md
@@ -1,6 +1,6 @@
# Skill 内置可选更新提醒器:技术设计提案
-> 状态:Implementation draft / Issue #167 / 待评审
+> 状态:已被取代。现行行为见 `archify/references/update-awareness.md`:提醒写入 `finalize` / `deliver` 回执并每次重复,`--ack` 已停用,改为用户明确要求的 `--snooze` / `--ignore`。
> 提案版本:v0.1
> 日期:2026-08-28
> 面向对象:Skill 维护者、Agent 集成开发者、安全与发布工程师
diff --git a/scripts/package-smoke.mjs b/scripts/package-smoke.mjs
index 829e775c..b31d2ee0 100644
--- a/scripts/package-smoke.mjs
+++ b/scripts/package-smoke.mjs
@@ -183,14 +183,15 @@ try {
if (notifierReceipt.status !== 'update_available') {
throw new Error(`packaged update checker did not return an update candidate: ${JSON.stringify(notifierReceipt)}`);
}
- const notifierAcknowledgement = await checker.acknowledgeUpdate({
+ const notifierSnooze = await checker.setUpdatePreference({
releasePath: path.join(skillRoot, 'skill-release.json'),
cacheDirectory: notifierCache,
eventKey: notifierReceipt.eventKey,
+ mode: 'snooze',
now: () => Date.parse('2026-08-28T00:00:01Z'),
});
- if (notifierAcknowledgement.status !== 'acknowledged') {
- throw new Error('packaged update checker did not persist a visible-notice acknowledgement');
+ if (notifierSnooze.status !== 'snoozed') {
+ throw new Error('packaged update checker did not persist an explicit snooze');
}
const skill = fs.readFileSync(path.join(skillRoot, 'SKILL.md'), 'utf8');