Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: an as_of read checks the chosen edition's trust tier against the floor; min host version names the release that adds as_of

garrytanaab5f0dcef46
diff --git a/src/core/ops/valid-time-read.ts b/src/core/ops/valid-time-read.ts
index 312d7bb703..02ffd6606f 100644
--- a/src/core/ops/valid-time-read.ts
+++ b/src/core/ops/valid-time-read.ts
@@ -17,6 +17,7 @@ import { renderAction, type Action } from '../agent-output.ts';
import { assertExplicitSourceLive, federatedSearchScope, pageNotFoundError, parseSourceIdParam, validatePageSlug } from './context.ts';
import { inlineBodyBytes } from './get-page-body.ts';
import { pageTrustForRead } from './get-page-projection.ts';
+import { admitsTrust, type TrustTier } from '../trust/tier.ts';
import { isCalendarDate } from '../link-validity.ts';
import { replacedBecauseSql } from '../engine-sql/pages.ts';
import { callerReadersAllowedSql, privacyForCaller, privateLinkOriginFilterFragment, privatePagesFilterForCaller, privatePagesFilterFragment, privateSnapshotFilterFragment, resolveExcludePrivatePages } from '../search/private-visibility.ts';
@@ -326,7 +327,10 @@ export async function getPageAsOf(ctx: OperationContext, p: Record<string, unkno
const { identity, pin, picked, loaded, amendments } = read;
const row = picked.row;
const missing = () => pageNotFoundError(ctx, slug, { includeDeleted: false, sourceIdParam });
- if (!(await pageTrustForRead(ctx, { id: identity.id }, p.min_trust))) throw missing();
+ const admitted = await pageTrustForRead(ctx, { id: identity.id }, p.min_trust);
+ if (!admitted) throw missing();
+ const floor = admitted.eligibility.floor;
+ if (floor && row && !admitsTrust((row.tier ?? 'unknown') as TrustTier, floor)) throw missing();
if (!row) {
const snap = await ctx.engine.readPageSnapshot(identity.slug, { sourceId: identity.source_id });
if (!snap) throw missing();
diff --git a/src/core/valid-time.ts b/src/core/valid-time.ts
index bb1449cb0f..6d3479dd54 100644
--- a/src/core/valid-time.ts
+++ b/src/core/valid-time.ts
@@ -132,7 +132,7 @@ export function currentValidTime(frontmatter: Record<string, unknown> | null | u
* The first release whose get_page answers `as_of` (echoing `valid_time.as_of`). Stamped with the release at ship time;
* the client names it in `host_upgrade_required`.
*/
-export const VALID_TIME_MIN_HOST_VERSION = '0.60.475.0';
+export const VALID_TIME_MIN_HOST_VERSION = '0.60.570.0';
/**
* B4 version skew: an `as_of` read's reply must echo `valid_time.as_of`. An older host ignores the parameter and
diff --git a/test/valid-time-gbra217.test.ts b/test/valid-time-gbra217.test.ts
index eed224c7b3..bec26b6a60 100644
--- a/test/valid-time-gbra217.test.ts
+++ b/test/valid-time-gbra217.test.ts
@@ -27,6 +27,7 @@ import { asOfExitCode, formatGetPage, validTimeLine } from '../src/cli/page-rend
import { utcToday } from '../src/core/link-validity.ts';
import { unquoteTranscriptText } from '../src/core/search/transcript-quote.ts';
import { testBackends, requirePostgresTestDatabase } from './helpers/test-backends.ts';
+import { withTrustPromotion } from '../src/core/persistence/context.ts';
import { importSegmented } from './helpers/segmented-privacy-fixture.ts';
type R = Record<string, any>;
@@ -159,6 +160,18 @@ for (const backend of testBackends()) {
expect(after.last_in_force.compiled_truth).toContain('receipts required');
});
+ test('a remote as_of read refuses a chosen edition below the trust floor, even when the current page meets it', async () => {
+ const slug = fresh('floor');
+ await put(slug, 'January canary text.', ["valid_from: '2026-01-01'"]);
+ await put(slug, 'June curated text.', ["valid_from: '2026-06-01'"]);
+ await engine.transaction(tx => withTrustPromotion(tx, 'operator_curated', () => tx.executeRaw("UPDATE pages SET trust_tier = 'operator_curated' WHERE slug = $1 AND source_id = 'default'", [slug])));
+ const current = await read(slug, '2026-07-01', true, { min_trust: 'operator_curated' });
+ expect(unquoteTranscriptText(String(current.compiled_truth ?? current.window?.text ?? ''), slug)).toContain('June curated text.');
+ const old = await refusal(read(slug, '2026-03-01', true, { min_trust: 'operator_curated' }));
+ expect(old?.code).toBe('page_not_found');
+ expect((await read(slug, '2026-03-01')).compiled_truth).toContain('January canary text.');
+ });
+
test('B-T1: a date-only change and a same-body renewal are flagged ambiguous_edition_dates', async () => {
const slug = fresh('dateonly');
await put(slug, 'Same text.', ["valid_from: '2026-01-01'"]);