Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
trust review: name what a held lower-tier write would do to a take or timeline row
garrytan59736a27227d
diff --git a/src/core/trust/owner-actions.ts b/src/core/trust/owner-actions.tsindex 4e25c872d0..c83cf95532 100644--- a/src/core/trust/owner-actions.ts+++ b/src/core/trust/owner-actions.ts@@ -258,9 +258,11 @@ function proposalSummary(p: TrustProposalRow, verb: 'Accept' | 'Dismiss' | 'Reveif (verb === 'Revert') return `Revert the agent edit of ${page}: restore version ${s.version_id ?? '?'} and its tier "${trustLabel(s.prior_tier)}"`;return `Dismiss ${trustProposalRef(p.id)}: ${page} stays "${trustLabel(s.edited_tier)}"`;}- const target = `${p.target_table === 'facts' ? 'f' : p.target_table === 'takes' ? 't' : ''}${p.target_id}`;+ const target = `${p.target_table === 'facts' ? 'f' : p.target_table === 'takes' ? 't' : p.target_table === 'timeline_entries' ? 'timeline row ' : ''}${p.target_id}`;const related = p.related_id === null ? '' : ` with ${p.related_table === 'facts' ? 'f' : p.related_table === 'takes' ? 't' : ''}${p.related_id}`;- const what = p.action === 'forget' ? `forget ${target}` : p.action.startsWith('supersede') ? `supersede ${target}${related}` : `${p.action.replace('_', ' ')} ${target}${related}`;+ // W1 #6783 §12 (a): a held take or timeline row names what the lower-tier write asked for.+ const held = p.action === 'forget' && p.target_table !== 'facts' ? ({ removed: 'remove', replaced: 'replace', deactivated: 'deactivate', detail_changed: 'rewrite' } as Record<string, string>)[String(p.before_state.change)] : undefined;+ const what = held ? `${held} ${target} as the page now says` : p.action === 'forget' ? `forget ${target}` : p.action.startsWith('supersede') ? `supersede ${target}${related}` : `${p.action.replace('_', ' ')} ${target}${related}`;return verb === 'Accept' ? `Accept ${trustProposalRef(p.id)}: ${what} (raises trust over "${trustLabel(storedTrustTier(p.before_state.prior_tier ?? p.before_state.tier))}")`: `Dismiss ${trustProposalRef(p.id)}: do not ${what}`;}diff --git a/src/core/trust/review.ts b/src/core/trust/review.tsindex 1c7698f2d9..86231f22ec 100644--- a/src/core/trust/review.ts+++ b/src/core/trust/review.ts@@ -74,7 +74,10 @@ const snippet = (text: unknown, max = 80): string => {return flat.length > max ? `${flat.slice(0, max - 3)}...` : flat;};const trust = (...args: string[]): string[] => ['gbrain', 'trust', ...args];-const rowRef = (table: string | null, id: number | null): string => id === null ? '' : `${table === 'facts' ? 'f' : table === 'takes' ? 't' : table === 'pages' ? 'page ' : ''}${id}`;+const rowRef = (table: string | null, id: number | null): string => id === null ? ''+ : `${table === 'facts' ? 'f' : table === 'takes' ? 't' : table === 'pages' ? 'page ' : table === 'timeline_entries' ? 'timeline row ' : ''}${id}`;+/** W1 #6783 §12 (a): what a held lower-tier write would have done (trust/fence-guard.ts). */+const HELD_VERBS: Record<string, string> = { removed: 'remove', replaced: 'replace', deactivated: 'deactivate', detail_changed: 'rewrite' };export function parseTrustReviewKind(value: string): string {if ((TRUST_REVIEW_KINDS as readonly string[]).includes(value) || PROPOSAL_ACTIONS.includes(value)) return value;@@ -106,8 +109,8 @@ async function pageOf(engine: BrainEngine, p: TrustProposalRow): Promise<stringconst [f] = await engine.executeRaw<{ slug: string | null }>('SELECT source_markdown_slug AS slug FROM facts WHERE id = $1', [p.target_id]);return f?.slug ? pageRef(p.source_id, f.slug) : null;}- if (p.target_table === 'takes') {- const [t] = await engine.executeRaw<{ slug: string }>('SELECT p.slug FROM takes t JOIN pages p ON p.id = t.page_id WHERE t.id = $1', [p.target_id]);+ if (p.target_table === 'takes' || p.target_table === 'timeline_entries') {+ const [t] = await engine.executeRaw<{ slug: string }>(`SELECT p.slug FROM ${p.target_table} t JOIN pages p ON p.id = t.page_id WHERE t.id = $1`, [p.target_id]);return t ? pageRef(p.source_id, t.slug) : null;}return null;@@ -127,7 +130,8 @@ function proposalItem(p: TrustProposalRow, page: string | null): TrustReviewItemconst tier = storedTrustTier(p.after_state.tier ?? p.before_state.related_tier ?? p.before_state.new_tier);const target = rowRef(p.target_table, p.target_id);const related = rowRef(p.related_table, p.related_id);- const what = p.action === 'forget' ? `An agent asked to forget ${target}`+ const held = p.action === 'forget' ? HELD_VERBS[String(p.before_state.change)] : undefined;+ const what = held ? `A lower-trust write would ${held} ${target}` : p.action === 'forget' ? `An agent asked to forget ${target}`: `${related || 'A lower-trust write'} would ${p.action === 'confirm' ? 'confirm' : 'supersede'} ${target}`;return {ref, kind: 'proposal', detail: p.action, source_id: p.source_id, page, day: day(p.created_at), created_at: p.created_at,