mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-19 16:29:42 +01:00
fix(ephemeral): save retained runtime skill bundles at startup and never strand a volume-free server on lost ones (#22190)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A volume-free server keeps no local volume. It must find every file it needs in durable storage. > - Before a volume-free server starts, a data gate refuses to start if records still point at files on a local disk. > - Old native runs can keep runtime skill bundles that a release before #19729 wrote only to its own disk. The gate reports these as `runtime_skill_assets_require_migration`. > - On a volume-free server those files are not on the disk, and no volume can be attached again. So the refusal repeats on every restart, and nothing can clear it. A staging stack crash-looped like this and stayed down. > - This pull request makes the server copy every retained bundle that is still on its disk into durable storage, and start over the bundles that are gone, the same way #20990 handles harness backups. > - The benefit is that a volume-free stack can always start again. No one has to repair it by hand. ## Linked Issues or Issue Description Refs #19675, #19729, #20990 **What happened?** A volume-free staging stack ran for twelve days on a release that kept runtime skill bundles only on its container disk. When that container stopped, every newer release crash-looped at boot with `Volume-free server data is not eligible: runtime_skill_assets_require_migration`. The old container was gone, so the bundles were gone. The deploy could not roll back, and a retry could not help. **Expected behavior** A volume-free server starts. It saves each retained bundle that is still on its disk to durable storage. It starts over a bundle that is not on its disk when the volume-free owner marker proves that no volume is mounted, and restart recovery owns those runs. **Steps to reproduce** 1. Retain a native run with an admitted runtime skill bundle that has no version ID and no durable preservation receipt. 2. Remove the bundle from the instance root. 3. Start the server with `PAPERCLIP_EPHEMERAL_SERVER=true` and the volume-free owner marker present. 4. Startup fails with `runtime_skill_assets_require_migration`, on every restart. ## What Changed - `runtime-skill-preservation.ts`: - The obligation scan is one generator. `hasLocalRuntimeSkillObligations` uses it. - New `preserveLocalRuntimeSkillObligations` copies each obligated run's bundles with `preserveRuntimeSkillAssets` and returns `{ bundles, unsaved }`. - A missing source is decided at its reader: `readLocalManifest`/`readSource` throw `RuntimeSkillSourceAbsent` (other instance root, or a missing directory, manifest or listed file). Only that error marks a run unsaved. Any other failure, including an `ENOENT` from storage or cache work, propagates. - `preserveRuntimeSkillAssets` no longer aborts on an invalid or non-durable existing receipt. It copies the local bytes again and replaces the receipt. - One durability helper (`preservedAssetRowDurable` for metadata, `preservedAssetDurable` with a metadata or object read) replaces the copies in the scan, staging, locking, preservation and rehydration. - `runtime-skill-preservation-reference.ts`: the scan matches only null pins, which is exactly what preservation copies. A non-null pin is a version pin and cannot become an obligation that nothing can settle. - `file-manifest-cache.ts`: new `inspectFileManifest` returns `verified`, `missing` or `changed` from the same walk. `verifyFileManifest` wraps it. - `ephemeral-server-contract.ts`: the gate saves the bundles still on the disk. If none stay unsaved, the blocker clears. Unsaved runs are waived only when the volume-free owner marker is present, with a warning. A save failure still refuses. The decision uses the copy pass result, not another scan. One exported blocker constant. - `ephemeral-migration-data.ts`: offline enrollment accepts the blocker and copies the bundles from the attached volume, in a phase after the package phases. Any unsaved run still fails the enrollment. - `index.ts`: comment update only. - Tests: `ephemeral-server-runtime-skill-startup.test.ts` (real scan, real copy, embedded Postgres) and an S3-gated case in `ephemeral-migration.test.ts`. ## Verification - `cd server && npx vitest run src/__tests__/ephemeral-server-runtime-skill-startup.test.ts` - Red on `origin/master`: 2 of 3 fail with the production error `Volume-free server data is not eligible: runtime_skill_assets_require_migration`. - Green with this change: all cases pass (lost bundle, saved bundle, no marker, mixed present and lost, one missing listed file, non-version pin, mixed pins, non-durable receipt recapture, storage failure, storage ENOENT, unsaved set). - `cd server && npx vitest run src/__tests__/ephemeral-server-startup-run-state.test.ts src/__tests__/runtime-skill-preservation.test.ts` pass (existing gate and preservation behavior unchanged). - `cd server && npx tsc --noEmit -p .` passes. - `ephemeral-migration.test.ts` needs `PAPERCLIP_TEST_S3_ENDPOINT`. It typechecks, but it was not run here. ## Risks - A run whose bundle is lost now starts under restart recovery instead of blocking the whole server. Recovery of that one run can fail. Before, the whole server stayed down, and the bundle was lost anyway. - Startup does more work only when unsaved legacy bundles exist. A current release saves bundles before admission (#19729), so new runs never add this work. - No schema change. No API change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (shell, file edits, test runs). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3c460f20cc
commit
a7ea2a799a
8 files changed
+409
-57
No files matched your search
@@ -49,14 +49,17 @@ export function readRuntimeSkillPreservation(row: Parameters<typeof admittedRunt
|
||||
}
|
||||
|
||||
/** Ordinary admission has no input yet. Only a concrete admitted local asset is
|
||||
* a durability obligation; missing transient version pins alone are not one. */
|
||||
* a durability obligation; missing transient version pins alone are not one.
|
||||
* A local asset is exactly what admittedRuntimeSkills captures: a null pin.
|
||||
* A non-null pin names a version; preservation cannot copy it, so it must not
|
||||
* become an obligation nothing can settle. */
|
||||
export function hasUnversionedRuntimeSkillInputSql() {
|
||||
const skills = sql`${heartbeatRuns.runnerProfileJson} #> '{nativeExecutionInput,runtimeContext,skills}'`;
|
||||
return sql`${heartbeatRuns.runtimeMode} = 'native'
|
||||
and ${heartbeatRuns.runnerProfileJson} #> '{nativeExecutionInput,runtimeContext}' is not null
|
||||
and (jsonb_typeof(${skills}) is distinct from 'array' or exists (
|
||||
select 1 from jsonb_array_elements(case when jsonb_typeof(${skills}) = 'array' then ${skills} else '[]'::jsonb end) s
|
||||
where s->>'versionId' is null or s->>'versionId' !~* '^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}$'))`;
|
||||
where s->>'versionId' is null))`;
|
||||
}
|
||||
|
||||
/** JSON receipts are references just like version FKs. Unknown receipt shapes
|
||||
|
||||
@@ -10,7 +10,7 @@ import { getStorageService } from "../../storage/index.js";
|
||||
import { skillPackageStore, withSkillPackageReadScope } from "../skill-package-store.js";
|
||||
import { assertSkillSnapshotPath, snapshotFile, skillSnapshotHash } from "../skill-snapshot.js";
|
||||
import { ensureSkillCacheDirectory, skillRunNeedsFilesSql } from "../skill-version-cache.js";
|
||||
import { verifyFileManifest } from "../file-manifest-cache.js";
|
||||
import { inspectFileManifest, verifyFileManifest } from "../file-manifest-cache.js";
|
||||
import { logActivity, publishActivity, type ActivityPublication } from "../activity-log.js";
|
||||
import { withRuntimeAssetUse } from "./runtime-asset-retention.js";
|
||||
import { admittedRuntimeSkills, hasUnversionedRuntimeSkillInputSql, readRuntimeSkillPreservation,
|
||||
@@ -41,13 +41,38 @@ function manifestFiles(asset: NativeRuntimeAssetReference, text: string): Manife
|
||||
if (hash(JSON.stringify(files)) !== asset.digest || files.reduce((n, f) => n + f.size, 0) !== asset.totalBytes) throw new Error("runtime_skill_manifest_invalid");
|
||||
return files;
|
||||
}
|
||||
/** The admitted bundle's source is not on this filesystem: its directory,
|
||||
* manifest or a listed file is gone, or it was written under another instance
|
||||
* root. Only the source readers throw it; every other failure is real. */
|
||||
export class RuntimeSkillSourceAbsent extends Error {
|
||||
constructor(readonly reason: "path_mismatch" | "missing") { super(`runtime_skill_source_absent:${reason}`); }
|
||||
}
|
||||
const missingPath = (error: unknown) => ["ENOENT", "ENOTDIR"].includes((error as NodeJS.ErrnoException | undefined)?.code ?? "");
|
||||
async function sourceRead<T>(read: () => Promise<T>): Promise<T> {
|
||||
try { return await read(); }
|
||||
catch (error) { throw missingPath(error) ? new RuntimeSkillSourceAbsent("missing") : error; }
|
||||
}
|
||||
type PackageRow = { contentHash: string; storage: typeof snapshots.$inferSelect.storage } | undefined;
|
||||
/** The one durability test for a preserved asset. "metadata" trusts the
|
||||
* package row; "object" also reads the stored package back. A storage error
|
||||
* during the object read propagates: it is not evidence either way. */
|
||||
function preservedAssetRowDurable(asset: PreservedRuntimeSkill, row: PackageRow) {
|
||||
try { manifestFiles(asset.bundle, asset.manifestText); } catch { return false; }
|
||||
return row?.storage?.provider === "s3" && row.storage.durable === true && row.contentHash === asset.packageContentHash;
|
||||
}
|
||||
async function preservedAssetDurable(store: ReturnType<typeof skillPackageStore>, companyId: string, asset: PreservedRuntimeSkill,
|
||||
verify: "metadata" | "object", signal?: AbortSignal) {
|
||||
const row = await store.descriptor(companyId, asset.packageSnapshotId).catch(() => undefined);
|
||||
if (!preservedAssetRowDurable(asset, row)) return false;
|
||||
return verify === "metadata" || await store.verifyDurable(companyId, asset.packageSnapshotId, signal);
|
||||
}
|
||||
async function readLocalManifest(asset: NativeRuntimeAssetReference) {
|
||||
const root = path.join(resolvePaperclipInstanceRoot(), "runtime-context-assets");
|
||||
const expected = path.join(root, "bundles", asset.digest);
|
||||
if (asset.rootPath !== expected) throw new Error("runtime_skill_source_path_mismatch");
|
||||
await ensureSkillCacheDirectory(expected);
|
||||
await ensureSkillCacheDirectory(path.join(root, "manifests"));
|
||||
const handle = await fs.open(path.join(root, "manifests", `${asset.digest}.json`), constants.O_RDONLY | constants.O_NOFOLLOW);
|
||||
if (asset.rootPath !== expected) throw new RuntimeSkillSourceAbsent("path_mismatch");
|
||||
await sourceRead(() => ensureSkillCacheDirectory(expected));
|
||||
await sourceRead(() => ensureSkillCacheDirectory(path.join(root, "manifests")));
|
||||
const handle = await sourceRead(() => fs.open(path.join(root, "manifests", `${asset.digest}.json`), constants.O_RDONLY | constants.O_NOFOLLOW));
|
||||
let text: string;
|
||||
try {
|
||||
const stat = await handle.stat();
|
||||
@@ -59,10 +84,12 @@ async function readLocalManifest(asset: NativeRuntimeAssetReference) {
|
||||
}
|
||||
async function readSource(asset: NativeRuntimeAssetReference) {
|
||||
const { expected, manifestText, entries } = await readLocalManifest(asset);
|
||||
if (!await verifyFileManifest(expected, entries.map(f => ({ ...f, executable: Boolean(f.mode & 0o111) })))) throw new Error("runtime_skill_source_changed");
|
||||
const inspected = await inspectFileManifest(expected, entries.map(f => ({ ...f, executable: Boolean(f.mode & 0o111) })));
|
||||
if (inspected === "missing") throw new RuntimeSkillSourceAbsent("missing");
|
||||
if (inspected === "changed") throw new Error("runtime_skill_source_changed");
|
||||
const files = [];
|
||||
for (const entry of entries) {
|
||||
const handle = await fs.open(path.join(expected, entry.path), constants.O_RDONLY | constants.O_NOFOLLOW);
|
||||
const handle = await sourceRead(() => fs.open(path.join(expected, entry.path), constants.O_RDONLY | constants.O_NOFOLLOW));
|
||||
try {
|
||||
const stat = await handle.stat();
|
||||
if (!stat.isFile() || stat.nlink !== 1 || stat.size !== entry.size || (stat.mode & 0o777) !== entry.mode) throw new Error("runtime_skill_source_changed");
|
||||
@@ -90,8 +117,7 @@ async function captureSkills(db: Db, companyId: string, admitted: ReturnType<typ
|
||||
async function lockPackages(db: Db, companyId: string, assets: PreservedRuntimeSkill[]) {
|
||||
for (const asset of [...assets].sort((a, b) => a.packageSnapshotId.localeCompare(b.packageSnapshotId))) {
|
||||
const [row] = await db.select().from(snapshots).where(and(eq(snapshots.companyId, companyId), eq(snapshots.id, asset.packageSnapshotId))).for("update");
|
||||
if (!row?.storage || row.storage.provider !== "s3" || row.storage.durable !== true
|
||||
|| row.contentHash !== asset.packageContentHash) throw new Error("runtime_skill_package_not_durable");
|
||||
if (!preservedAssetRowDurable(asset, row)) throw new Error("runtime_skill_package_not_durable");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +142,7 @@ export async function stageNativeRuntimeSkillAssets(db: Db, input: Admission & {
|
||||
if (receipt) {
|
||||
const store = skillPackageStore(db, shared);
|
||||
for (const asset of receipt.assets) {
|
||||
manifestFiles(asset.bundle, asset.manifestText);
|
||||
const row = await store.descriptor(input.companyId, asset.packageSnapshotId);
|
||||
if (row.storage?.provider !== "s3" || row.storage.durable !== true || row.contentHash !== asset.packageContentHash) throw new Error("runtime_skill_package_not_durable");
|
||||
if (!await preservedAssetDurable(store, input.companyId, asset, "metadata")) throw new Error("runtime_skill_package_not_durable");
|
||||
}
|
||||
} else receipt = { schema: RUNTIME_SKILL_PRESERVATION_SCHEMA, inputDigest: admitted.inputDigest,
|
||||
bindingDigest: admitted.bindingDigest, assets: await captureSkills(db, input.companyId, admitted, shared, input.signal) };
|
||||
@@ -144,23 +168,24 @@ export async function preserveRuntimeSkillAssets(db: Db, input: { companyId: str
|
||||
const admitted = admittedRuntimeSkills(source);
|
||||
const store = skillPackageStore(db, storage);
|
||||
const existing = readRuntimeSkillPreservation(source);
|
||||
if (source.runnerProfileJson?.[RUNTIME_SKILL_PRESERVATION_KEY] != null && !existing) throw new Error("runtime_skill_preservation_receipt_invalid");
|
||||
if (existing) {
|
||||
for (const asset of existing.assets) {
|
||||
manifestFiles(asset.bundle, asset.manifestText);
|
||||
const row = await store.descriptor(input.companyId, asset.packageSnapshotId);
|
||||
if (row.storage?.provider !== "s3" || row.storage.durable !== true || row.contentHash !== asset.packageContentHash
|
||||
|| !await store.verifyDurable(input.companyId, asset.packageSnapshotId, input.signal)) throw new Error("runtime_skill_package_not_durable");
|
||||
}
|
||||
return { preserved: existing.assets.length };
|
||||
let durable = true;
|
||||
for (const asset of existing.assets) if (durable) durable = await preservedAssetDurable(store, input.companyId, asset, "object", input.signal);
|
||||
if (durable) return { preserved: existing.assets.length };
|
||||
}
|
||||
// No receipt, an invalid one, or one whose package is not durable: copy the
|
||||
// admitted bytes again and replace it. A missing source throws RuntimeSkillSourceAbsent.
|
||||
const previousReceipt = JSON.stringify(source.runnerProfileJson?.[RUNTIME_SKILL_PRESERVATION_KEY] ?? null);
|
||||
const assets = await captureSkills(db, input.companyId, admitted, storage, input.signal);
|
||||
if (!assets.length) return { preserved: 0 };
|
||||
const publications: ActivityPublication[] = [];
|
||||
await db.transaction(async tx => {
|
||||
const [current] = await tx.select().from(heartbeatRuns).where(where).for("update");
|
||||
if (!current || admittedRuntimeSkills(current).inputDigest !== admitted.inputDigest || current.status !== source.status
|
||||
|| current.finishedAt?.getTime() !== source.finishedAt?.getTime()) throw new Error("runtime_skill_preservation_binding_changed");
|
||||
|| current.finishedAt?.getTime() !== source.finishedAt?.getTime()
|
||||
|| JSON.stringify(current.runnerProfileJson?.[RUNTIME_SKILL_PRESERVATION_KEY] ?? null) !== previousReceipt) {
|
||||
throw new Error("runtime_skill_preservation_binding_changed");
|
||||
}
|
||||
await lockPackages(tx as unknown as Db, input.companyId, assets);
|
||||
await tx.update(heartbeatRuns).set({ runnerProfileJson: { ...current.runnerProfileJson,
|
||||
[RUNTIME_SKILL_PRESERVATION_KEY]: { schema: RUNTIME_SKILL_PRESERVATION_SCHEMA, inputDigest: admitted.inputDigest,
|
||||
@@ -173,9 +198,21 @@ export async function preserveRuntimeSkillAssets(db: Db, input: { companyId: str
|
||||
return { preserved: assets.length };
|
||||
}
|
||||
|
||||
export async function hasLocalRuntimeSkillObligations(db: Db): Promise<boolean> {
|
||||
/** Retained runs whose admitted local skill bundles have no durable receipt. */
|
||||
async function* localRuntimeSkillObligations(db: Db): AsyncGenerator<{ id: string; companyId: string }> {
|
||||
let after: string | undefined;
|
||||
const checkedPackages = new Map<string, { hash: string; storage: typeof snapshots.$inferSelect.storage }>();
|
||||
const checkedPackages = new Map<string, NonNullable<PackageRow>>();
|
||||
// Metadata only: this scan runs before every volume-free start.
|
||||
const durable = async (companyId: string, asset: PreservedRuntimeSkill) => {
|
||||
const key = `${companyId}:${asset.packageSnapshotId}`;
|
||||
let snapshot = checkedPackages.get(key);
|
||||
if (!snapshot) {
|
||||
[snapshot] = await db.select({ contentHash: snapshots.contentHash, storage: snapshots.storage }).from(snapshots)
|
||||
.where(and(eq(snapshots.companyId, companyId), eq(snapshots.id, asset.packageSnapshotId)));
|
||||
if (snapshot) checkedPackages.set(key, snapshot);
|
||||
}
|
||||
return preservedAssetRowDurable(asset, snapshot);
|
||||
};
|
||||
for (;;) {
|
||||
const rows = await db.select({ id: heartbeatRuns.id, companyId: heartbeatRuns.companyId, agentId: heartbeatRuns.agentId,
|
||||
nativeIssueId: heartbeatRuns.nativeIssueId, runnerProfileJson: sql<Record<string, unknown>>`jsonb_build_object(
|
||||
@@ -184,26 +221,45 @@ export async function hasLocalRuntimeSkillObligations(db: Db): Promise<boolean>
|
||||
.from(heartbeatRuns).where(and(retainedRuntimeSkillsSql(), after ? gt(heartbeatRuns.id, after) : undefined))
|
||||
.orderBy(asc(heartbeatRuns.id)).limit(100);
|
||||
for (const row of rows) {
|
||||
let receipt;
|
||||
try { receipt = readRuntimeSkillPreservation(row); } catch { return true; }
|
||||
if (!receipt) return true;
|
||||
for (const asset of receipt.assets) {
|
||||
try { manifestFiles(asset.bundle, asset.manifestText); } catch { return true; }
|
||||
const key = `${row.companyId}:${asset.packageSnapshotId}`;
|
||||
let snapshot = checkedPackages.get(key);
|
||||
if (!snapshot) {
|
||||
[snapshot] = await db.select({ hash: snapshots.contentHash, storage: snapshots.storage }).from(snapshots)
|
||||
.where(and(eq(snapshots.companyId, row.companyId), eq(snapshots.id, asset.packageSnapshotId)));
|
||||
if (snapshot) checkedPackages.set(key, snapshot);
|
||||
}
|
||||
if (snapshot?.storage?.provider !== "s3" || snapshot.storage.durable !== true || snapshot.hash !== asset.packageContentHash) return true;
|
||||
}
|
||||
let receipt: RuntimeSkillPreservation | null;
|
||||
try { receipt = readRuntimeSkillPreservation(row); } catch { receipt = null; }
|
||||
let settled = receipt !== null;
|
||||
for (const asset of receipt?.assets ?? []) if (settled) settled = await durable(row.companyId, asset);
|
||||
if (!settled) yield { id: row.id, companyId: row.companyId };
|
||||
}
|
||||
if (rows.length < 100) return false;
|
||||
if (rows.length < 100) return;
|
||||
after = rows.at(-1)!.id;
|
||||
}
|
||||
}
|
||||
|
||||
export async function hasLocalRuntimeSkillObligations(db: Db): Promise<boolean> {
|
||||
for await (const _ of localRuntimeSkillObligations(db)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Copies every retained bundle this filesystem still holds into durable
|
||||
* storage: the same copy the skill package maintenance command makes. A run
|
||||
* whose bundle source is not here is reported as unsaved, never guessed at.
|
||||
* Any other failure (a changed source, storage) propagates to the caller. */
|
||||
export async function preserveLocalRuntimeSkillObligations(db: Db, options: { signal?: AbortSignal } = {}, storage?: StorageService) {
|
||||
let bundles = 0;
|
||||
const unsaved: string[] = [];
|
||||
await withSkillPackageReadScope(db, async () => {
|
||||
for await (const run of localRuntimeSkillObligations(db)) {
|
||||
options.signal?.throwIfAborted();
|
||||
try {
|
||||
const { preserved } = await preserveRuntimeSkillAssets(db, { companyId: run.companyId, runId: run.id, signal: options.signal }, storage);
|
||||
if (preserved) bundles += preserved;
|
||||
else unsaved.push(run.id);
|
||||
} catch (error) {
|
||||
if (!(error instanceof RuntimeSkillSourceAbsent)) throw error;
|
||||
unsaved.push(run.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
return { bundles, unsaved };
|
||||
}
|
||||
|
||||
/** Existing bounded skill maintenance owns this optional online conversion;
|
||||
* there is no scanner, new execution admission or controller takeover. */
|
||||
export async function migrateRuntimeSkillAssets(db: Db, options: { companyId?: string; after?: string;
|
||||
@@ -231,9 +287,7 @@ export async function rehydratePreservedRuntimeSkill(db: Db, row: Parameters<typ
|
||||
if (!asset) throw new Error("runtime_skill_preservation_required");
|
||||
const files = manifestFiles(asset.bundle, asset.manifestText);
|
||||
const store = skillPackageStore(db);
|
||||
const descriptor = await store.descriptor(row.companyId, asset.packageSnapshotId);
|
||||
if (descriptor.storage?.provider !== "s3" || descriptor.storage.durable !== true
|
||||
|| descriptor.contentHash !== asset.packageContentHash) throw new Error("runtime_skill_package_not_durable");
|
||||
if (!await preservedAssetDurable(store, row.companyId, asset, "metadata")) throw new Error("runtime_skill_package_not_durable");
|
||||
// An intact disposable cache remains useful during a storage outage. Only
|
||||
// use the current host's canonical cache, never the old host's recorded path.
|
||||
const local = { ...skill.bundle, rootPath: path.join(resolvePaperclipInstanceRoot(), "runtime-context-assets", "bundles", skill.bundle.digest) };
|
||||
@@ -242,7 +296,7 @@ export async function rehydratePreservedRuntimeSkill(db: Db, row: Parameters<typ
|
||||
const { expected, entries } = await readLocalManifest(local);
|
||||
return await verifyFileManifest(expected, entries.map(file => ({ ...file, executable: Boolean(file.mode & 0o111) })));
|
||||
} catch (error) {
|
||||
if (["ENOENT", "ENOTDIR"].includes((error as NodeJS.ErrnoException).code ?? "")
|
||||
if (error instanceof RuntimeSkillSourceAbsent || missingPath(error)
|
||||
|| error instanceof SyntaxError || (error instanceof Error && error.message.startsWith("runtime_skill_manifest_"))) return false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user