Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes

garrytanabc5dd3b5fd0
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index e9ae4a7b25..6a57c1bb9f 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -725,9 +725,12 @@ and keeps stable between one day and one week behind what matters:
- **Roll back.** Dispatch `promote-stable.yml` as a maintainer with `version` set to the
previous stable (`git tag --list 'stable-v*' --sort=-creatordate`, or the
record's `previous` field: `git show stable --no-patch`), `soak_run_url` set to the
- soak run in that version's record tag, `rollback=true` and a `reason`. Clients on
- stable never downgrade on their own; the daily check stays paused until the
- next manual promotion.
+ soak run in that version's record tag, `rollback=true`, a `reason` and `withdraw`
+ set to the version you are rolling back from. `withdraw` puts it on the record's
+ `known_bad` list, so clients that already installed it are offered the previous
+ stable. Without it they stay on the bad release, because clients on stable never
+ downgrade on their own. The daily check stays paused until the next manual
+ promotion.
### The `publish-template` job
diff --git a/scripts/check-install-ref.ts b/scripts/check-install-ref.ts
index 3e1dd7fa01..27e8e62e1b 100644
--- a/scripts/check-install-ref.ts
+++ b/scripts/check-install-ref.ts
@@ -22,7 +22,7 @@ export interface InstallRefDrift { file: string; line: number; found: string; wh
const PIN = /github:garrytan\/gbrain#([A-Za-z][A-Za-z0-9._-]*)/g;
const ARTIFACT = /raw\.githubusercontent\.com\/garrytan\/gbrain\/([A-Za-z0-9._-]+)\/(BOOTSTRAP_FOR_AGENTS\.md|scripts\/setup-in-agent\.sh)/g;
const HELPER_REF = /^gbrain_install_ref=([A-Za-z0-9._-]+)$/gm;
-const EXACT_PIN = /^v|^[0-9]/;
+const EXACT_PIN = /^v|^[0-9]|^[0-9a-f]{7,40}$/;
const OWNER = 'src/core/install-ref.ts';
const skipped = (file: string) => file === 'CHANGELOG.md' || file.startsWith('test/') || file === OWNER;
diff --git a/src/commands/check-update.ts b/src/commands/check-update.ts
index c57c454275..d50ed104e5 100644
--- a/src/commands/check-update.ts
+++ b/src/commands/check-update.ts
@@ -187,7 +187,7 @@ export function extractChangelogBetween(changelog: string, from: string, to: str
* last verified answer for the notice (never for an apply), a missing or invalid
* one drops it.
*/
-function recordFailedCheck(channel: ReleaseChannel, release: Extract<LatestReleaseResult, { ok: false }>, checkedAt: number): void {
+export function recordFailedCheck(channel: ReleaseChannel, release: Extract<LatestReleaseResult, { ok: false }>, checkedAt: number): void {
try {
const prior = readUpdateCache(channel);
if (!('cause' in release)) {
diff --git a/src/commands/self-upgrade.ts b/src/commands/self-upgrade.ts
index 5f37490fd0..ae58335b88 100644
--- a/src/commands/self-upgrade.ts
+++ b/src/commands/self-upgrade.ts
@@ -1,6 +1,6 @@
import { VERSION } from '../version.ts';
import { isValidVersionString } from '../core/semver.ts';
-import { fetchChangelog, fetchLatestRelease } from './check-update.ts';
+import { fetchChangelog, fetchLatestRelease, recordFailedCheck } from './check-update.ts';
import { detectInstallMethod, runUpgrade } from './upgrade.ts';
import {
invalidChannelMessage,
@@ -139,8 +139,8 @@ export async function runSelfUpgrade(args: string[]): Promise<void> {
offered ? { kind: 'upgrade_available', current: VERSION, latest: offered } : { kind: 'up_to_date', current: VERSION },
{ channel, latest, knownBad: release?.knownBad ?? [], checkedAt },
);
- } else if (stableFailure) {
- writeUpdateCache(null, { channel, error: stableFailure, checkedAt });
+ } else if (!result.ok) {
+ recordFailedCheck(channel, result, checkedAt);
}
} catch {
/* best-effort */
diff --git a/test/install-ref.test.ts b/test/install-ref.test.ts
index c88b2280b0..7372c34e27 100644
--- a/test/install-ref.test.ts
+++ b/test/install-ref.test.ts
@@ -37,6 +37,8 @@ describe('install ref lint', () => {
]);
expect(driftIn('docs/x.md', doc).map(d => d.line).sort()).toEqual([1, 4, 5, 7]);
expect(driftIn('CHANGELOG.md', doc)).toEqual([]);
+ expect(driftIn('docs/x.md', `bun add -g github:garrytan/gbrain#${'d'.repeat(40)}\nbun add -g github:garrytan/gbrain#abc1234\n`)).toEqual([]);
+ expect(rewriteText('docs/x.md', `github:garrytan/gbrain#${'a'.repeat(40)}`, 'stable')).toBe(`github:garrytan/gbrain#${'a'.repeat(40)}`);
});
test('TypeScript never spells an install ref; it imports the constant', () => {
diff --git a/test/release-channel-w1.serial.test.ts b/test/release-channel-w1.serial.test.ts
index f465c8b630..c6674b1b19 100644
--- a/test/release-channel-w1.serial.test.ts
+++ b/test/release-channel-w1.serial.test.ts
@@ -260,6 +260,19 @@ for (const brain of ['repo-less', 'repo'] as const) {
expect(readSnooze('stable')).toMatchObject({ version: AHEAD, level: 1 });
});
+ test('self-upgrade --check-only keeps the verified answer on stable_unreadable and drops it on stable_missing', async () => {
+ writeConfig({}, brain);
+ console.log = () => {};
+ serve({ record: record(AHEAD) });
+ await refreshUpdateCache();
+ serve({ record: null });
+ await runSelfUpgrade(['--check-only', '--json']);
+ expect(readUpdateCache('stable')).toMatchObject({ error: { code: 'stable_unreadable' }, marker: { kind: 'upgrade_available', latest: AHEAD } });
+ serve({});
+ await runSelfUpgrade(['--check-only', '--json']);
+ expect(readUpdateCache('stable')).toMatchObject({ error: { code: 'stable_missing' }, marker: null });
+ });
+
test('doctor names a channel that was set and its source (the default stays mode=notify), and warns with the code when stable failed', async () => {
writeConfig({}, brain);
expect(checkSelfUpgradeHealth().message).toBe('mode=notify');