Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Credit both fixes of the endless stale link sweep and pin that a top-level page edit still re-checks the link

garrytanbd75760be1a1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fa15ac1305..2af13cba02 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,7 +40,7 @@ identifiers and attribution are available in the pre-removal Git revision
**The admin dashboard's live feed keeps reconnecting after a dropped connection,** and four smaller fixes land with it: the load throttle still applies its concurrency and memory limits when the machine reports no load data (Windows), a `remember` TTL past the representable date range is refused as `invalid_params` instead of throwing, a worker pool whose error callback throws now stops every worker before rejecting, and claude-cli tool loops read the previous turn's prompt cache instead of rewriting the whole transcript to it.
-**The stale link sweep no longer re-extracts one page forever when a bare-name frontmatter link matches a top-level page.** A person page with `founded: ["acme-toolkit"]` resolves that name under `companies/`, so a top-level page named `acme-toolkit` does not satisfy it and the link stays wanted. The wanted-link row was still stamped as if its target existed, which marks its page stale on every pass, so the sweep queued the same page again and again (thousands of extract jobs an hour) and starved lower-priority jobs. Only a slug reference to an existing page is stamped that way now, and a row an earlier release stamped settles the next time its page is extracted, which the sweep does on its own. Reported and first fixed by @akinduroifedayo (#9140).
+**The stale link sweep no longer re-extracts one page forever when a bare-name frontmatter link matches a top-level page.** A person page with `founded: ["acme-toolkit"]` resolves that name under `companies/`, so a top-level page named `acme-toolkit` does not satisfy it and the link stays wanted. The wanted-link row was still stamped as if its target existed, which marks its page stale on every pass, so the sweep queued the same page again and again (thousands of extract jobs an hour) and starved lower-priority jobs. Only a slug reference to an existing page is stamped that way now, and a row an earlier release stamped settles the next time its page is extracted, which the sweep does on its own. Editing the top-level page still re-checks the link once. One narrow case is left for a follow-up release. If the top-level page is created for the first time while that link is being extracted, the link can stay missing until either page is written again. Reported by @akinduroifedayo (#9140) and first fixed by @Masashi-Ono0611 (#9144); @akinduroifedayo's own fix (#9149) also found that narrow case.
### Itemized changes
@@ -71,7 +71,7 @@ identifiers and attribution are available in the pre-removal Git revision
- `src/core/cycle/atom-source-date.ts`: new `transcriptAtomSourceDate` (frontmatter date, else the path date that names the `atoms/<date>/` folder); an undated transcript still gets none. Test: `test/extract-atoms-source-date.test.ts`. Reported by @spiky02plateau (#7268).
- Admin dashboard: the EventSource `onerror` only sets the status from `readyState` and no longer closes the stream; `admin/dist` and `src/admin-embedded.ts` are rebuilt. Test: `test/admin-dashboard-stream-reconnect.test.ts`. Reported by @ramybarsoum (#8913).
- Load throttle (`shouldProceed`), `remember` TTL parsing and the worker pool: see the paragraph above. Tests: `test/backoff.test.ts`, `test/writeback-config.test.ts`, `test/worker-pool.test.ts`. Reported by @ramybarsoum (#8913).
-- `src/core/wanted-links-store.ts` (`replaceWantedLinks`): `checked_at` is `-infinity` only for a `slug` row whose exact page exists; a `name` row gets `now()`, and the existing `ON CONFLICT` update re-stamps old rows on their origin's next extraction. Test: `test/wanted-links.test.ts` and `test/e2e/wanted-links-postgres.test.ts` (`topLevelSlugNameReferenceSettles`: the origin is not stale after one sweep, and a row forced to `-infinity` settles after one more). Reported by @akinduroifedayo (#9140).
+- `src/core/wanted-links-store.ts` (`replaceWantedLinks`): `checked_at` is `-infinity` only for a `slug` row whose exact page exists; a `name` row gets `now()`, and the existing `ON CONFLICT` update re-stamps old rows on their origin's next extraction. Test: `test/wanted-links.test.ts` and `test/e2e/wanted-links-postgres.test.ts` (`topLevelSlugNameReferenceSettles`: the origin is not stale after one sweep, and a row forced to `-infinity` settles after one more; `topLevelSlugNamePageEditWakesOnce`: an edit of the top-level page lists the origin stale once and one sweep settles it). Reported by @akinduroifedayo (#9140); first fixed by @Masashi-Ono0611 (#9144) and also by @akinduroifedayo (#9149).
## [0.60.666.0] - 2026-11-11
diff --git a/test/e2e/wanted-links-postgres.test.ts b/test/e2e/wanted-links-postgres.test.ts
index a0641bd191..a0c7702f11 100644
--- a/test/e2e/wanted-links-postgres.test.ts
+++ b/test/e2e/wanted-links-postgres.test.ts
@@ -7,7 +7,7 @@ import { PostgresEngine } from '../../src/core/postgres-engine.ts';
import { replaceWantedLinks } from '../../src/core/wanted-links.ts';
import { bareNameReferenceSettles, disabledClearsRows, forwardReferenceHeals, impossibleTargetsNeverAbortTheSweep,
impossibleTargetsStayOutOfWrites, onlyUnresolvedAuthoredReferences, privateOriginsStayPrivate,
- restoredTargetHeals, topLevelSlugNameReferenceSettles } from '../helpers/wanted-links-scenarios.ts';
+ restoredTargetHeals, topLevelSlugNamePageEditWakesOnce, topLevelSlugNameReferenceSettles } from '../helpers/wanted-links-scenarios.ts';
const url = process.env.DATABASE_URL;
describe.skipIf(!url)('Postgres wanted pages', () => {
@@ -15,6 +15,7 @@ describe.skipIf(!url)('Postgres wanted pages', () => {
test('only unresolved authored references are wanted', () => onlyUnresolvedAuthoredReferences(url), 180_000);
test('a bare-name reference settles', () => bareNameReferenceSettles(url), 180_000);
test('#9140: a bare-name reference equal to a top-level slug settles', () => topLevelSlugNameReferenceSettles(url), 180_000);
+ test('#9140: editing the top-level page wakes that origin once', () => topLevelSlugNamePageEditWakesOnce(url), 180_000);
test('private origins stay private', () => privateOriginsStayPrivate(url), 180_000);
test('restoring a deleted target heals', () => restoredTargetHeals(url), 180_000);
test('disabling clears rows', () => disabledClearsRows(url), 180_000);
diff --git a/test/helpers/wanted-links-scenarios.ts b/test/helpers/wanted-links-scenarios.ts
index 5c0c65230e..b5e4ec2c27 100644
--- a/test/helpers/wanted-links-scenarios.ts
+++ b/test/helpers/wanted-links-scenarios.ts
@@ -107,6 +107,24 @@ export async function topLevelSlugNameReferenceSettles(databaseUrl?: string) {
}, { databaseUrl });
}
+const staleSlugs = async (engine: BrainEngine) =>
+ (await engine.listStalePagesForExtraction({ versionTs: LINK_EXTRACTOR_VERSION_TS, batchSize: 100 })).map(page => page.slug).sort();
+
+/** #9140: a later write of a bare name's exact-slug page still wakes its origin, and one extraction settles it again. */
+export async function topLevelSlugNamePageEditWakesOnce(databaseUrl?: string) {
+ await managedBrain(async ({ engine, ctx }) => {
+ const first = await put(ctx, 'acme-toolkit', 'Acme toolkit.');
+ await put(ctx, 'people/alice-example', 'Alice.', 'person', 'founded: ["acme-toolkit"]\n');
+ await extractStale(engine);
+ expect(await stale(engine)).toBe(0);
+ await put(ctx, 'acme-toolkit', 'Acme toolkit, edited.', 'note', '', (first.outcome ?? first).revision);
+ expect(await staleSlugs(engine)).toEqual(['acme-toolkit', 'people/alice-example']);
+ await extractStale(engine);
+ expect(await stale(engine)).toBe(0);
+ expect(await wantedRows(engine)).toEqual([{ target_ref: 'acme-toolkit', ref_kind: 'name', producer: 'frontmatter' }]);
+ }, { databaseUrl });
+}
+
/** A remote caller never sees targets referenced only from private pages, nor counts that include them. */
export async function privateOriginsStayPrivate(databaseUrl?: string) {
await managedBrain(async ({ engine, ctx }) => {
diff --git a/test/wanted-links.test.ts b/test/wanted-links.test.ts
index f45e428513..72f319352a 100644
--- a/test/wanted-links.test.ts
+++ b/test/wanted-links.test.ts
@@ -10,12 +10,13 @@ import { collectWantedLinks, possibleWantedRows } from '../src/core/wanted-links
import { LINK_EXTRACTOR_VERSION_TS, type LinkCandidate } from '../src/core/link-extraction.ts';
import { bareNameReferenceSettles, BRACKETED_CODE, disabledClearsRows, FOREIGN_PREFIXES, forwardReferenceHeals,
impossibleTargetsNeverAbortTheSweep, impossibleTargetsStayOutOfWrites, onlyUnresolvedAuthoredReferences, POSSIBLE_WANTED,
- privateOriginsStayPrivate, restoredTargetHeals, topLevelSlugNameReferenceSettles, wantedKeys } from './helpers/wanted-links-scenarios.ts';
+ privateOriginsStayPrivate, restoredTargetHeals, topLevelSlugNamePageEditWakesOnce, topLevelSlugNameReferenceSettles, wantedKeys } from './helpers/wanted-links-scenarios.ts';
test('a link written before its target exists becomes an edge after the target is created', () => forwardReferenceHeals(), 120_000);
test('resolved references, prose paths and code spans are never wanted', () => onlyUnresolvedAuthoredReferences(), 120_000);
test('a bare-name reference matched only by basename settles after one re-extraction', () => bareNameReferenceSettles(), 120_000);
test('#9140: a bare-name reference equal to a top-level slug settles after one re-extraction', () => topLevelSlugNameReferenceSettles(), 120_000);
+test('#9140: editing the top-level page wakes that origin once, and one extraction settles it again', () => topLevelSlugNamePageEditWakesOnce(), 120_000);
test('remote callers never see targets or counts from private origins', () => privateOriginsStayPrivate(), 120_000);
test('restoring a deleted target heals links written while it was deleted', () => restoredTargetHeals(), 120_000);
test('wanted_pages.enabled=false clears an origin\'s rows on its next extraction', () => disabledClearsRows(), 120_000);