/sync-gbrain reports failed pushes and imports instead of OK, and one bad queued path no longer blocks artifacts sync (#4455)

/sync-gbrain now says when an artifacts push failed or memory pages
failed to import, instead of printing OK and "pushed", and one malformed
queued path (from a skill started where the project slug was empty) no
longer stops artifacts sync for every project.

Why: people trusted those rows and lost track of unsynced work; fixes
#4445, #4418 and #4417.

Nothing to do after upgrading: a stuck `projects//timeline.jsonl` record
is dropped and reported on the next sync.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p1/specialist-batched#2 reader=testing
Review-Finding: p1/specialist-batched#3 reader=testing
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-17 18:34:52 +00:00
1 parent 88da124dbc
commit bc64f5e210
11 files changed
+451 -58

No files matched your search

@@ -164,6 +164,14 @@ case "$1" in
fi
echo '${sources}' ;;
import)
if [ -n "$GBRAIN_REFUSE_IMPORTS" ]; then
( cd "$2" && find . -name '*.md' -type f | sed 's#^[.]/##' ) | while read -r p; do
echo " Warning: skipped $p: Managed import must run on the active canonical owner for the selected source." >&2
done
n=$( cd "$2" && find . -name '*.md' -type f | wc -l | tr -d ' ')
echo "{\\"status\\":\\"success\\",\\"imported\\":0,\\"skipped\\":0,\\"errors\\":$n,\\"total_files\\":$n}"
exit 0
fi
# One import per gbrain source (A4): pages of one ingest run accumulate;
# a new run (different parent pid) starts a fresh list.
if [ "$(cat "${stagedList}.ppid" 2>/dev/null)" != "$PPID" ]; then echo "$PPID" > "${stagedList}.ppid"; : > "${stagedList}"; fi
@@ -459,3 +467,49 @@ describe.skipIf(process.platform === "win32")("memory stage transcript consent",
}
});
});
// #4417: gstack-memory-ingest exits 0 when gbrain refuses single pages (they
// are retried next run), and the memory row used to read only that exit code,
// so it printed OK with every page refused.
describe.skipIf(process.platform === "win32")("memory stage failure counts (#4417)", () => {
test("pages gbrain refuses make the row ERR with the count and the first cause", () => {
const sb = sandbox();
try {
const r = runSync(sb, ["--incremental"], { GBRAIN_REFUSE_IMPORTS: "1" });
const stage = memoryStage(sb) as { ok: boolean; warn?: boolean; summary: string };
expect(stage.ok).toBe(false);
expect(stage.summary).toMatch(/^0 imported, [1-9][0-9]* failed [(]retried next run/);
expect(stage.summary).toContain("Managed import must run on the active canonical owner");
expect(r.stdout).toMatch(/ERR +memory +0 imported, [1-9][0-9]* failed/);
expect(r.stdout).not.toMatch(/OK +memory/);
expect(r.status).toBe(1);
// The refusal clears: the same pages import and the row is OK again.
const ok = runSync(sb, ["--incremental"]);
expect(ok.status).toBe(0);
expect(memoryStage(sb).ok).toBe(true);
expect(ok.stdout).toMatch(/OK +memory/);
} finally {
sb.cleanup();
}
});
// A transcript that cannot be parsed is never stamped, so it is counted on
// every run; it must not turn the row ERR for good.
test("an unparseable transcript is a note on an OK row, every run", () => {
const sb = sandbox({ mode: "all" });
try {
writeFileSync(join(sb.home, ".claude", "projects", "work-acme", "empty0001.jsonl"), "");
for (let run = 0; run < 2; run++) {
const r = runSync(sb, ["--incremental"]);
const stage = memoryStage(sb) as { ok: boolean; warn?: boolean; summary: string };
expect(stage.ok).toBe(true);
expect(stage.warn).toBeUndefined();
expect(stage.summary).toContain("1 source file(s) could not be parsed and were skipped");
expect(r.status).toBe(0);
}
} finally {
sb.cleanup();
}
});
});