From c9bbd2e2e8ae575577e0d77d1454be714bcb46f3 Mon Sep 17 00:00:00 2001
From: arko33 <221298156+arko33@users.noreply.github.com>
Date: Thu, 22 Oct 2026 01:51:16 +0700
Subject: [PATCH 1/2] fix: empty-autopsy fallback cleared + runtime metric
count made dynamic + dock label from data + probe backoff
---
packages/ghost/lib/probes.mjs | 16 ++++++++++++++++
src/components/playground/AutopsyPanel.tsx | 9 ++++++---
src/components/playground/TimelineDock.tsx | 4 ++--
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/packages/ghost/lib/probes.mjs b/packages/ghost/lib/probes.mjs
index 707ab94..ad707e4 100644
--- a/packages/ghost/lib/probes.mjs
+++ b/packages/ghost/lib/probes.mjs
@@ -31,7 +31,23 @@ export function createProbes({ url, intervalMs = 4000, fetchImpl = globalThis.fe
}
}
+ // Back off when the target keeps failing (wrong URL, app down, no
+ // /api/health): keep the last sample slot moving but stop hammering the
+ // app — 5 straight failures slow the cadence 8x, 10 straight 30x.
+ let consecutiveFailures = 0;
+ function reschedule() {
+ if (state.timer) clearInterval(state.timer);
+ const slot = intervalMs * (consecutiveFailures >= 10 ? 30 : consecutiveFailures >= 5 ? 8 : 1);
+ state.timer = setInterval(() => void sample(), slot);
+ state.timer.unref?.();
+ }
+
function push(ts, metrics, failed) {
+ if (failed) consecutiveFailures += 1; else consecutiveFailures = 0;
+ if (consecutiveFailures === 5 || consecutiveFailures === 10) {
+ // keep the slot bookkeeping correct while the cadence backs off
+ reschedule();
+ }
state.out({ ts, metrics, probeFailed: failed });
}
diff --git a/src/components/playground/AutopsyPanel.tsx b/src/components/playground/AutopsyPanel.tsx
index d31d742..919d8cb 100644
--- a/src/components/playground/AutopsyPanel.tsx
+++ b/src/components/playground/AutopsyPanel.tsx
@@ -210,7 +210,7 @@ export default function AutopsyPanel({
Runtime metrics
- 28 samples
+ {session.metrics.length} samples
Fix prompt
-
+ {autopsy?.fixPrompt ? : null}
- {autopsy.fixPrompt}
+
+ {autopsy?.fixPrompt ??
+ "No anomaly detected — nothing to heal yet. Keep recording; the engine drafts the heal prompt if a sample breaches a threshold."}
+
);
diff --git a/src/components/playground/TimelineDock.tsx b/src/components/playground/TimelineDock.tsx
index 161caff..f7f70e9 100644
--- a/src/components/playground/TimelineDock.tsx
+++ b/src/components/playground/TimelineDock.tsx
@@ -106,8 +106,8 @@ export default function TimelineDock({
From 3304fd461f1653486fd430b20f13b8857df413dc Mon Sep 17 00:00:00 2001
From: arko33 <221298156+arko33@users.noreply.github.com>
Date: Thu, 22 Oct 2026 01:57:10 +0700
Subject: [PATCH 2/2] fix: non-git repos record file-list checkpoints instead
of failing git add repeatedly; live city never falls back to demo files
---
packages/ghost/ghost.mjs | 20 +++++++++++++++++---
src/components/playground/city.ts | 6 +++++-
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/packages/ghost/ghost.mjs b/packages/ghost/ghost.mjs
index 24e34db..f740e1d 100644
--- a/packages/ghost/ghost.mjs
+++ b/packages/ghost/ghost.mjs
@@ -265,13 +265,25 @@ async function cmdWatch() {
// Mode B — filesystem watcher (works with ANY agent, no events needed)
let burst = null;
- const checkpoint = (label) => {
+ const pendingFiles = new Set();
+ const hasGit = !!session.head;
+ const isNoise = (p) => p.startsWith(".ghost/") || p === ".ghost";
+ const checkpoint = (label, burstFiles = []) => {
try {
+ if (!hasGit) {
+ // Non-git project: shadow-git is unavailable, so record the burst as a
+ // plain file-list checkpoint (paths are facts; no patch to compute).
+ const files = [...new Set(burstFiles)].filter((p) => p && !isNoise(p));
+ if (!files.length) return;
+ const sha = `nogit-${crypto.createHash("sha1").update(files.join("\n") + Date.now()).digest("hex").slice(0, 12)}`;
+ session.checkpoints.push({ ts: new Date().toISOString(), turnNumber: currentTurn(), sha, files });
+ const t = activeTurn();
+ return;
+ }
const snap = shadow.commitSnapshot(repo, `ghost: ${label}`);
if (!snap.diff) return;
// recorder internals (.ghost/*) are bookkeeping, not app files — they
// must never become towers in the city.
- const isNoise = (p) => p.startsWith(".ghost/") || p === ".ghost";
const changedFiles = snap.changedFiles.filter((p) => !isNoise(p));
const churnEntries = Object.entries(parseDiffChurn(snap.diff)).filter(([p]) => !isNoise(p));
if (!changedFiles.length || !churnEntries.length) return;
@@ -287,12 +299,14 @@ async function cmdWatch() {
if (!file) return;
const p = file.split(path.sep)[0];
if (["node_modules", ".next", ".git", ".ghost", "out", ".vercel", "testsprite_tests"].includes(p)) return;
+ pendingFiles.add(file.split(path.sep).join("/"));
if (burst) clearTimeout(burst);
burst = setTimeout(() => {
burst = null;
// no open turn? attribute as estimated turn so nothing is lost
if (!activeTurn()) startTurn({ ts: new Date().toISOString() });
- checkpoint("worktree burst");
+ checkpoint("worktree burst", [...pendingFiles]);
+ pendingFiles.clear();
const t = activeTurn(); if (t && !t.endedAt) t.endedAt = new Date().toISOString();
}, 900);
}); } catch { console.error(" ! recursive watch unavailable on this FS — adapter events only"); }
diff --git a/src/components/playground/city.ts b/src/components/playground/city.ts
index d7c6a19..696b249 100644
--- a/src/components/playground/city.ts
+++ b/src/components/playground/city.ts
@@ -118,7 +118,11 @@ export function buildPlaygroundCity(
turn: firstSeen.get(file.path) ?? 1,
seed: hash(file.path),
}))
- : (KNOWN_FILES.map((path) => {
+ : isLive
+ // live recording without churn data (e.g. not a git repo): no towers —
+ // never fill the user's city with the demo's files.
+ ? []
+ : (KNOWN_FILES.map((path) => {
const snap = snapshotFiles.get(path);
const seed = hash(path);
return {