Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

test(ok): pin the unreadable-reference row the merge silently changed (#3114)

tim-inkeepdc0fbd56cc28
diff --git a/packages/server/src/skill-path-classifier-equivalence.test.ts b/packages/server/src/skill-path-classifier-equivalence.test.ts
index 0af3f9c98..f045fa4a9 100644
--- a/packages/server/src/skill-path-classifier-equivalence.test.ts
+++ b/packages/server/src/skill-path-classifier-equivalence.test.ts
@@ -14,7 +14,7 @@
* the walk to `inspectSkillPathEntry` and keep only their own mapping on top —
* if a change collapses those two mappings, the disagreement rows below fail.
*/
-import { mkdirSync, mkdtempSync, realpathSync, symlinkSync, writeFileSync } from 'node:fs';
+import { mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { parseSkillDir } from '@inkeep/open-knowledge-core/skills-catalog';
@@ -139,6 +139,30 @@ describe('the two classifiers DISAGREE, deliberately', () => {
});
});
+// The reference bundle can be unreadable at classification time (a concurrent
+// delete between the caller resolving its realpath and this call). The two
+// classifiers used to disagree here and now do not: projection always returned
+// `different`, migration hash-compared and could return `same-copy`. Unifying
+// on the shared walk adopted projection's answer for both. That is the SAFE
+// direction for migration, whose `same-copy` branch deletes the store dir, so
+// the row is pinned deliberately rather than left to drift back.
+describe('the reference bundle is gone', () => {
+ test('a byte-identical real dir reads as `different` for BOTH once the reference is unreadable', () => {
+ const dest = join(root, 'same-copy-orphaned');
+ writeSkill(dest, 'canonical body');
+ // Same bytes, so this is `same-copy` while the reference is readable.
+ expect(classifyBoth(dest)).toEqual({ projection: 'same-copy', migration: 'same-copy' });
+
+ const canonicalReal = realpathSync(canonical);
+ rmSync(canonical, { recursive: true, force: true });
+ expect(classifyInPlaceDest(dest, canonical, canonicalHash)).toBe('different');
+ expect(classifyHostEntry(dest, canonicalReal, canonicalHash)).toEqual({
+ kind: 'occupied',
+ by: 'different',
+ });
+ });
+});
+
describe('projection-only outcomes stay reachable', () => {
test('`canonical-dir` when dest IS the canonical path verbatim', () => {
expect(classifyInPlaceDest(canonical, canonical, canonicalHash)).toBe('canonical-dir');
diff --git a/packages/server/src/skill-path-entry.ts b/packages/server/src/skill-path-entry.ts
index 5362b021b..fa4c97507 100644
--- a/packages/server/src/skill-path-entry.ts
+++ b/packages/server/src/skill-path-entry.ts
@@ -20,6 +20,12 @@
* | symlink → nothing (dangling) | link (removable) | occupied(foreign-link) |
* | dir that IS the reference | canonical-dir | same-copy |
*
+ * One row the two USED to disagree on and no longer do: when the reference dir
+ * itself is unreadable, projection always answered `different` while migration
+ * hash-compared and could answer `same-copy`. The shared walk adopts
+ * projection's answer for both, which is the safe direction because migration's
+ * `same-copy` branch deletes the store dir. Pinned in the equivalence suite.
+ *
* Those rows are not oversights. Migration treats a dangling link as foreign on
* purpose — an OK projection whose store source is about to move would not
* dangle, so a dangling one belongs to something else and reconcile's orphan