Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: recognize stranded stage prompt history (#12222)

Adam Eivyd7dcd6e84a25
diff --git a/scripts/migrations/shippedPromptHistory.guard.test.js b/scripts/migrations/shippedPromptHistory.guard.test.js
index 5be3cf1dba..02b5847932 100644
--- a/scripts/migrations/shippedPromptHistory.guard.test.js
+++ b/scripts/migrations/shippedPromptHistory.guard.test.js
@@ -1,6 +1,8 @@
import { describe, expect, it } from 'vitest';
+import { mkdtempSync, rmSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
+import { tmpdir } from 'os';
import {
findUnacceptedPromptHistory,
isShallowRepository,
@@ -17,6 +19,15 @@ if (!historyAvailable) {
}
describe('shipped stage-prompt history guard', () => {
+ it('treats a source archive without Git metadata as unavailable history', () => {
+ const archive = mkdtempSync(join(tmpdir(), 'shipped-prompt-source-archive-'));
+ try {
+ expect(isShallowRepository(archive)).toBe(true);
+ } finally {
+ rmSync(archive, { recursive: true, force: true });
+ }
+ });
+
it('identifies historical hashes missing from every migration table', () => {
expect(
findUnacceptedPromptHistory({
diff --git a/scripts/migrations/shippedPromptHistory.js b/scripts/migrations/shippedPromptHistory.js
index 928360f628..9a6f62fa9c 100644
--- a/scripts/migrations/shippedPromptHistory.js
+++ b/scripts/migrations/shippedPromptHistory.js
@@ -17,8 +17,13 @@ const runGit = (args, cwd, encoding = 'utf8') =>
stdio: ['ignore', 'pipe', 'pipe'],
});
-export const isShallowRepository = (repoRoot) =>
- runGit(['rev-parse', '--is-shallow-repository'], repoRoot).trim() === 'true';
+export const isShallowRepository = (repoRoot) => {
+ try {
+ return runGit(['rev-parse', '--is-shallow-repository'], repoRoot).trim() !== 'false';
+ } catch {
+ return true;
+ }
+};
const historicalHashes = (repoRoot, files) => {
const wanted = new Set(