Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbrain",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.",
"author": {
"name": "Garry Tan",
Expand Down
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbrain",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.",
"author": {
"name": "Garry Tan",
Expand Down
2 changes: 1 addition & 1 deletion BOOTSTRAP_FOR_AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- gbrain-runbook-stamp: 0.60.20.0 -->
<!-- gbrain-runbook-stamp: 0.60.21.0 -->
<!-- This stamp must equal the VERSION file at every release; CI enforces it
(scripts/check-bootstrap-tag.sh). `gbrain bootstrap status` compares it to
the installed binary and warns on skew. -->
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ credits are retained; no result has been reassigned to another provider. Origina
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).

## [0.60.21.0] - 2026-09-30

**A `git` command GBrain stops early no longer leaves your brain repo locked.**

v0.60.16.0 gave every background `git` call a deadline so a lost exit signal can't hang the write queue. When it stopped a command, though, it killed `git` outright. If that happened in the middle of `git add` or `git commit`, git never got to remove its lock file, and every later git call in that repo failed until someone deleted the lock. That showed up as pages stuck in the queue with "git unavailable" after the owner process was shut down or restarted mid-write.

Now GBrain asks `git` to stop first and gives it two seconds to clean up its lock. Only then does it force the kill. The deadline still holds: a `git` that ignores the request is stopped at most two seconds later.

Nothing to configure and nothing to run after upgrading. If you hit this on v0.60.16.0, remove the leftover `.git/index.lock` in your brain repo once.

### To take advantage of v0.60.21.0

`gbrain upgrade` is all you need. There is no migration.

### Itemized changes

- `execFileBounded` (`src/core/brain-repo-durability.ts`) now sends SIGTERM at its deadline or on abort, and escalates to SIGKILL after a 2 second grace period. It still settles from its own timer if the exit event never arrives.
- `test/bounded-child-exec.test.ts` adds a case where a child holding a lock file removes it on SIGTERM, plus one where a child ignoring SIGTERM is still stopped within the bound.
## [0.60.20.0] - 2026-09-30

**Fix wave 4: managed syncs stop wedging on big write histories, one bad email or issue no longer stops a connector forever, stuck upgrade migrations finish, and you can finally leave managed mode.**
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.60.20.0
0.60.21.0
2 changes: 1 addition & 1 deletion openclaw.plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "gbrain-context-engine",
"name": "gbrain",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Personal knowledge brain with Postgres + pgvector hybrid search",
"family": "bundle-plugin",
"kind": "context-engine",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"bun": ">=1.3.11"
},
"license": "MIT",
"version": "0.60.20.0",
"version": "0.60.21.0",
"overrides": {
"@ai-sdk/provider-utils": "4.0.33",
"@hono/node-server": "^2.0.5",
Expand Down
2 changes: 1 addition & 1 deletion plugin-variants/gbrain-coding/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbrain-coding",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)",
"author": {
"name": "Garry Tan",
Expand Down
2 changes: 1 addition & 1 deletion plugin-variants/gbrain-coding/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbrain-coding",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)",
"author": {
"name": "Garry Tan",
Expand Down
2 changes: 1 addition & 1 deletion plugin-variants/gbrain-coding/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- gbrain-plugin-tree-stamp: 0.60.20.0 -->
<!-- gbrain-plugin-tree-stamp: 0.60.21.0 -->
# gbrain-coding (generated persona variant — do not hand-edit)

Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant.
Expand Down
2 changes: 1 addition & 1 deletion plugin-variants/gbrain-daily/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbrain-daily",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)",
"author": {
"name": "Garry Tan",
Expand Down
2 changes: 1 addition & 1 deletion plugin-variants/gbrain-daily/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gbrain-daily",
"version": "0.60.20.0",
"version": "0.60.21.0",
"description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)",
"author": {
"name": "Garry Tan",
Expand Down
2 changes: 1 addition & 1 deletion plugin-variants/gbrain-daily/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- gbrain-plugin-tree-stamp: 0.60.20.0 -->
<!-- gbrain-plugin-tree-stamp: 0.60.21.0 -->
# gbrain-daily (generated persona variant — do not hand-edit)

Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant.
Expand Down
2 changes: 1 addition & 1 deletion plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- gbrain-plugin-tree-stamp: 0.60.20.0 -->
<!-- gbrain-plugin-tree-stamp: 0.60.21.0 -->
# gbrain plugin skill tree (generated — do not hand-edit)

This tree is the curated skill set for the gbrain Codex and Claude Code
Expand Down
50 changes: 46 additions & 4 deletions src/core/brain-repo-durability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync, rmSync, statSync, renameSync,
} from 'fs';
import { join, dirname, relative, isAbsolute } from 'path';
import { execFile, execFileSync, execSync, type ExecFileException } from 'child_process';
import { execFile, execFileSync, execSync, type ChildProcess, type ExecFileException } from 'child_process';
import {
GIT_ENV, GIT_ENV_AUTH, divergenceSafePull, detectDefaultBranch, pushProbe,
type PullOutcome, type PushProbeResult,
Expand Down Expand Up @@ -474,6 +474,24 @@ export function isDurabilityHardened(repoPath: string): boolean {
}
}

const BOUNDED_EXEC_TERM_GRACE_MS = 2_000;

/**
* Whether a stopped child has exited even if the runtime lost its exit event:
* on Linux an exited-but-unreaped child is a zombie ('Z' in /proc/<pid>/stat).
* Elsewhere only the delivered exit counts, so the grace timer bounds the wait.
*/
function childHasExited(child: ChildProcess): boolean {
if (child.exitCode !== null || child.signalCode !== null) return true;
if (process.platform !== 'linux' || child.pid === undefined) return false;
try {
const stat = readFileSync(`/proc/${child.pid}/stat`, 'utf8');
return stat.slice(stat.lastIndexOf(')') + 2).startsWith('Z');
} catch {
return true;
}
}

export interface BoundedExecOptions {
timeout: number;
env?: NodeJS.ProcessEnv;
Expand All @@ -488,6 +506,11 @@ export interface BoundedExecOptions {
* (bun:test `expect().resolves/.rejects`, oven-sh/bun#30301): execFile's
* callback and its own `timeout` then never fire and the child stays a zombie,
* so the deadline and abort are enforced with our own timer.
*
* Stopping sends SIGTERM first so git can remove its lockfiles (a SIGKILLed
* `git add`/`commit` leaves `.git/index.lock` behind and every later git call
* in that worktree fails), then SIGKILLs after a short grace period and
* settles from the timer even if the exit event never arrives.
*/
export function execFileBounded(file: string, args: string[], options: BoundedExecOptions): Promise<{ error: ExecFileException | null; stdout: string; stderr: string }> {
const { timeout, signal, ...rest } = options;
Expand All @@ -500,10 +523,29 @@ export function execFileBounded(file: string, args: string[], options: BoundedEx
signal?.removeEventListener('abort', onAbort);
resolve({ error, stdout, stderr });
};
const child = execFile(file, args, { ...rest, encoding: 'utf8' }, (error, stdout, stderr) => finish(error, stdout, stderr));
let stopped: ExecFileException | null = null;
let escalation: ReturnType<typeof setTimeout> | undefined;
let poll: ReturnType<typeof setInterval> | undefined;
const settleStopped = () => {
clearTimeout(escalation);
clearInterval(poll);
finish(stopped, '', '');
};
const child = execFile(file, args, { ...rest, encoding: 'utf8' }, (error, stdout, stderr) => {
clearTimeout(escalation);
clearInterval(poll);
if (stopped) finish(stopped, '', '');
else finish(error, stdout, stderr);
});
const stop = (message: string, code: string) => {
child.kill('SIGKILL');
finish(Object.assign(new Error(message), { code, killed: true, signal: 'SIGKILL' as const }), '');
if (stopped) return;
stopped = Object.assign(new Error(message), { code, killed: true, signal: 'SIGTERM' as const });
child.kill('SIGTERM');
poll = setInterval(() => { if (childHasExited(child)) settleStopped(); }, 25);
escalation = setTimeout(() => {
child.kill('SIGKILL');
settleStopped();
}, BOUNDED_EXEC_TERM_GRACE_MS);
};
const timer = setTimeout(() => stop(`${file} did not finish within ${timeout}ms`, 'ETIMEDOUT'), timeout);
const onAbort = () => stop(`${file} was aborted`, 'ABORT_ERR');
Expand Down
2 changes: 1 addition & 1 deletion templates/bootstrap/template-repo/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gbrain agent workspace — template

<!-- gbrain-template-stamp: 0.60.20.0 -->
<!-- gbrain-template-stamp: 0.60.21.0 -->

This repository is the **"Use this template"** distribution artifact for a
[gbrain](https://github.com/garrytan/gbrain) personal-agent workspace — the same
Expand Down
16 changes: 16 additions & 0 deletions test/bounded-child-exec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ test('bounded execution stops a running child on abort and at its deadline', asy
preAborted.abort();
expect((await execFileBounded('sleep', ['30'], { timeout: 60_000, signal: preAborted.signal })).error).toMatchObject({ code: 'ABORT_ERR' });
});

test('a stopped child gets SIGTERM first so it can remove its lockfile, then SIGKILL after the grace period', async () => {
const lock = join(dir, 'index.lock');
const script = `touch '${lock}'; trap "rm -f '${lock}'; exit 143" TERM; while :; do sleep 0.05; done`;
const abort = new AbortController();
const running = execFileBounded('sh', ['-c', script], { timeout: 60_000, signal: abort.signal });
await Bun.sleep(200);
expect(await Bun.file(lock).exists()).toBe(true);
abort.abort();
expect((await running).error).toMatchObject({ code: 'ABORT_ERR', killed: true });
expect(await Bun.file(lock).exists()).toBe(false);
const started = performance.now();
const stubborn = await execFileBounded('sh', ['-c', 'trap "" TERM; while :; do sleep 0.05; done'], { timeout: 100 });
expect(stubborn.error).toMatchObject({ code: 'ETIMEDOUT', killed: true });
expect(performance.now() - started).toBeLessThan(5000);
});
Loading