Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(backup): no_remote coverage hint also names bootstrap attach for out-of-band-adopted repos (#4746)

Masa81d01622c8dc
diff --git a/src/core/advisor/collect-backup-coverage.ts b/src/core/advisor/collect-backup-coverage.ts
index 5f781d2382..21051fcce5 100644
--- a/src/core/advisor/collect-backup-coverage.ts
+++ b/src/core/advisor/collect-backup-coverage.ts
@@ -71,7 +71,13 @@ export const collectBackupCoverage: AdvisorCollector = {
severity: 'warn',
title: 'Your agent workspace has no private repo yet — a disk loss loses skills, memory, and identity.',
detail: a.detail,
- fix: { command_argv: a.fix_argv ?? ['gbrain', 'bootstrap', 'repo'] },
+ // No default fallback here (matches source_repo above): coverage.ts
+ // deliberately leaves fix_argv null for this kind since it can't
+ // tell an empty origin (bootstrap repo) from an already-pushed
+ // out-of-band one (bootstrap attach) without a git subprocess — a
+ // hardcoded ['gbrain','bootstrap','repo'] fallback would reintroduce
+ // the same wrong-command-in-the-out-of-band-case bug this exists to fix.
+ fix: { command_argv: a.fix_argv ?? null },
collector: 'backup-coverage',
ask_user: true,
});
diff --git a/src/core/backup/coverage.ts b/src/core/backup/coverage.ts
index b75cc57efe..051d6ef883 100644
--- a/src/core/backup/coverage.ts
+++ b/src/core/backup/coverage.ts
@@ -165,8 +165,16 @@ export async function computeBackupCoverage(
kind: 'bootstrap_workspace',
id: receipt.workspace_dir,
state: 'no_remote',
- detail: 'bootstrap workspace has no private repo yet',
- fix_argv: ['gbrain', 'bootstrap', 'repo'],
+ detail:
+ 'bootstrap workspace has no private repo yet — run `gbrain bootstrap repo` to create one ' +
+ '(this is the right command for a truly empty/unconfigured origin). If this workspace was ' +
+ 'already pushed to an existing repo out-of-band, `bootstrap repo` will refuse — run ' +
+ '`gbrain bootstrap attach` instead to reconcile the receipt.',
+ // No single command is correct here without a git subprocess (coverage.ts is deliberately
+ // file-plane only): an empty/unconfigured origin needs `bootstrap repo`, an already-pushed
+ // one needs `bootstrap attach`, and this check can't tell which case it's in. Leave fix_argv
+ // null rather than advertise a command that's wrong in the out-of-band-adopted case.
+ fix_argv: null,
});
} else {
// THIS workspace's own push status only — a failing entry from some
diff --git a/test/advisor-backup-coverage.serial.test.ts b/test/advisor-backup-coverage.serial.test.ts
index 263d2b8d82..002469043b 100644
--- a/test/advisor-backup-coverage.serial.test.ts
+++ b/test/advisor-backup-coverage.serial.test.ts
@@ -359,7 +359,7 @@ function writeReceipt(ws: string, extra: Record<string, unknown> = {}): void {
}
describe('collectBackupCoverage local — workspace and db_only findings', () => {
- test('receipt without repo_url → backup_workspace_no_repo warn with the bootstrap-repo fix', async () => {
+ test('receipt without repo_url → backup_workspace_no_repo warn, no single-command fix (ambiguous between repo/attach)', async () => {
const ws = join(tmp, 'ws-no-repo');
mkdirSync(ws, { recursive: true });
writeReceipt(ws); // no repo_url → bootstrap_workspace no_remote asset
@@ -373,7 +373,10 @@ describe('collectBackupCoverage local — workspace and db_only findings', () =>
expect(f.severity).toBe('warn');
expect(f.title).toContain('workspace has no private repo');
expect(f.detail).toContain('no private repo yet');
- expect(f.fix.command_argv).toEqual(['gbrain', 'bootstrap', 'repo']);
+ // No default fallback: this check can't tell an empty origin (needs
+ // `bootstrap repo`) from an already-pushed out-of-band one (needs
+ // `bootstrap attach`) without a git subprocess — see coverage.ts.
+ expect(f.fix.command_argv).toBeNull();
expect(f.ask_user).toBe(true);
expect(f.collector).toBe('backup-coverage');
});
diff --git a/test/backup-coverage.serial.test.ts b/test/backup-coverage.serial.test.ts
index 30087a13f4..2c3b8450d6 100644
--- a/test/backup-coverage.serial.test.ts
+++ b/test/backup-coverage.serial.test.ts
@@ -361,7 +361,7 @@ describe('computeBackupCoverage — db_content and empty brain', () => {
// ── Bootstrap workspace via the receipt ─────────────────────────────────────
describe('computeBackupCoverage — bootstrap workspace', () => {
- test('receipt without repo_url → bootstrap_workspace no_remote with bootstrap repo fix', async () => {
+ test('receipt without repo_url → bootstrap_workspace no_remote names both bootstrap repo and attach, fix_argv null', async () => {
const ws = join(tmp, 'ws');
mkdirSync(ws, { recursive: true });
writeReceipt(ws);
@@ -372,7 +372,16 @@ describe('computeBackupCoverage — bootstrap workspace', () => {
expect(asset).toBeDefined();
expect(asset?.id).toBe(ws);
expect(asset?.state).toBe('no_remote');
- expect(asset?.fix_argv).toEqual(['gbrain', 'bootstrap', 'repo']);
+ // This check is file-plane only (no git subprocess) so it can't tell an
+ // empty/unconfigured origin (needs `bootstrap repo`) from an
+ // already-pushed out-of-band one (needs `bootstrap attach`, since
+ // `bootstrap repo` guaranteed-refuses with ORIGIN_NOT_EMPTY there — see
+ // src/core/bootstrap/repo.ts). fix_argv stays null rather than advertise
+ // a command that's wrong in the out-of-band case; the message names both.
+ expect(asset?.fix_argv).toBeNull();
+ expect(asset?.detail).toContain('no private repo yet');
+ expect(asset?.detail).toContain('bootstrap repo');
+ expect(asset?.detail).toContain('bootstrap attach');
expect(s.overall).toBe('warn');
expect(s.totals.no_remote).toBe(1);
});