Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
fix(record): stop polling a remote the background cannot reach
Erenf8df314112c1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 82a0c07..e221bba 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Fixed- A `prepare-commit-msg` hook of your own that sets its own `trap ... EXIT` or ends with `exec` no longer drops the `Thought:` trailer: cogit now runs your lines as a child and adds the trailer once they finish. Existing hooks update on the next chat message.+- With an SSH key that has a passphrase and no ssh-agent, the records that follow a push are no longer lost: the background send used to retry the remote every 3 seconds for 10 minutes (each a failed login) and then drop them. It now stops at the first failure and keeps them queued, and `cogit doctor` says to add the key to ssh-agent or run `cogit record-sync send` from a terminal.## [1.1.0] - 2026-11-06### Changeddiff --git a/packages/cli/src/commands/doctor.ts b/packages/cli/src/commands/doctor.tsindex abf8d37..07393a7 100644--- a/packages/cli/src/commands/doctor.ts+++ b/packages/cli/src/commands/doctor.ts@@ -328,7 +328,7 @@ const CHECK_SPECS: CheckSpec[] = [id: "record",status: "warn",message: `${sync.pending} session record${sync.pending === 1 ? "" : "s"} could not be sent: ${sync.sendError}`,- fix: "check your access to the remote; the next session start tries again",+ fix: "check your access to the remote; the next session start tries again. An SSH key with a passphrase needs ssh-agent (`ssh-add`), since a background send cannot ask for it; `cogit record-sync send` sends from this terminal",};if (sync.downloadError !== undefined && !sync.downloaded)return {diff --git a/packages/cli/src/record-sync.ts b/packages/cli/src/record-sync.tsindex 8135545..060a6a1 100644--- a/packages/cli/src/record-sync.ts+++ b/packages/cli/src/record-sync.ts@@ -576,7 +576,9 @@ export async function countUnsentRecords(/*** Whether the remote now holds what the hook saw going out. `pre-push` runs before* the push, and also for `--dry-run` and for a push the remote goes on to reject;- * git has no hook for "it worked", so this asks the remote.+ * git has no hook for "it worked", so this asks the remote. `unreachable` means+ * the background cannot ask at all: an SSH key with a passphrase and no agent+ * fails every time, and asking again only piles up failed logins.*/export async function pushLanded(root: string,@@ -584,20 +586,21 @@ export async function pushLanded(ref: string,sha: string,wait: { intervalMs: number; timeoutMs: number } = { intervalMs: 3000, timeoutMs: 600_000 },-): Promise<boolean> {+): Promise<"landed" | "missing" | "unreachable"> {const remote = await syncRemote(root, env);- if (remote === undefined) return false;+ if (remote === undefined) return "missing";const deadline = Date.now() + wait.timeoutMs;for (;;) {const seen = await runGit(root, ["ls-remote", remote, ref], quietEnv(env));+ if (seen.code !== 0) return "unreachable";if (seen.stdout.toString("utf8").split("\n").some((line) => line.startsWith(`${sha}\t`)))- return true;- if (Date.now() >= deadline) return false;+ return "landed";+ if (Date.now() >= deadline) return "missing";await sleep(wait.intervalMs);}}@@ -606,6 +609,9 @@ export async function pushLanded(* The background half of `git push`: once the code has landed (`after` names the* ref and hash the hook saw; a push with nothing to send has none), queues what the* remote does not have and sends it. A dry run or a rejected push queues nothing.+ * A remote the background cannot reach still gets the queue: the send fails the+ * same way, so the records wait with the reason `doctor` shows instead of being+ * dropped without a word.*/export async function sendAfterPush(root: string,@@ -615,8 +621,14 @@ export async function sendAfterPush(): Promise<number> {if (after !== undefined) {const split = after.lastIndexOf("=");- if (!(await pushLanded(root, env, after.slice(0, split), after.slice(split + 1), wait)))- return 0;+ const landing = await pushLanded(+ root,+ env,+ after.slice(0, split),+ after.slice(split + 1),+ wait,+ );+ if (landing === "missing") return 0;}await queueRecords(root, env);return sendRecords(root, env);diff --git a/packages/cli/test/record-sync.test.ts b/packages/cli/test/record-sync.test.tsindex 0c7972b..d08beb7 100644--- a/packages/cli/test/record-sync.test.ts+++ b/packages/cli/test/record-sync.test.ts@@ -467,7 +467,21 @@ describe("the record on its own refs", () => {expect(await sendAfterPush(alice, env)).toBe(1);await git(alice, "remote", "remove", "origin");- expect(await pushLanded(alice, env, "refs/heads/main", head, quick)).toBe(false);+ expect(await pushLanded(alice, env, "refs/heads/main", head, quick)).toBe("missing");+ });++ it("queues at once when the background cannot reach the remote, instead of polling", async () => {+ await record(alice, "s1", "First", "[email protected]");+ const head = (await git(alice, "rev-parse", "HEAD")).trim();+ // Like an SSH key with a passphrase and no agent: every ask fails.+ await git(alice, "remote", "set-url", "origin", join(alice, "gone.git"));+ const started = Date.now();+ // The default wait (10 minutes) would hang the test if it kept polling.+ expect(await sendAfterPush(alice, env, `refs/heads/main=${head}`)).toBe(0);+ expect(Date.now() - started).toBeLessThan(10_000);+ const status = await recordSyncStatus(alice, env);+ expect(status.pending).toBe(1);+ expect(status.sendError).toBeDefined();});describe("a project that used to commit its record", () => {