Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

W1: held-removal accept refuses a segmented page; BEHAVIOR_CHANGES rows at 0.60.253.0

garrytan41a759df236f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29118b6932..21d3d61fd6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,7 @@ Agents get the proposal back: `put_page` lists it under `contested`, and a refus
- `src/core/cycle/extract-takes.ts`, `src/core/timeline-extract.ts`: the takes reconcile and the timeline orphan prune keep held rows.
- `src/core/trust/held-removals.ts` (new): the owner accept applies the change as the page now says; a refused `takes_remove` reruns as an owner `takes_remove`. `supersede-handlers.ts` routes take and timeline `forget` proposals to it.
- `src/core/trust/propagation.ts` (new): `propagateTierLowering` walks recorded derivation inputs and lowers each derived row to the least trusted of its current inputs, recording `write_origin.input_lowered`; a row it cannot write is marked `needs_rederive` (reason `input_lowered`). Hooked into owner tier changes, agent page lowering, derived republishes, `gbrain trust claim-sources` relowering, the supersede undo and fence fact-field rewrites.
+- Accepting a held change on a segmented page (only with segmented page storage switched on) refuses with `page_body_segmented`, and the proposal stays pending.
- `gbrain trust review` and the confirm prompt name what a held change would do ("remove t12", "remove timeline row 4").
- No schema change.
- Tests: `test/trust-held-removals.test.ts` runs on PGLite and Postgres and fails without the fix.
diff --git a/scripts/page-body-readers-baseline.tsv b/scripts/page-body-readers-baseline.tsv
index 3fdbf1c584..d300b51f40 100644
--- a/scripts/page-body-readers-baseline.tsv
+++ b/scripts/page-body-readers-baseline.tsv
@@ -518,6 +518,8 @@ src/core/timeline-write-through.ts writeTimelineEntryThrough sql SEGW assertInli
src/core/transcripts/recover.ts userlessCodexSessions sql STREAM
src/core/transcripts/secret-audit.ts auditTranscriptSecrets field STREAM
src/core/transcripts/secret-audit.ts auditTranscriptSecrets sql STREAM
+src/core/trust/held-removals.ts heldRow sql SEGW loads the body for acceptHeldRemoval, which refuses a segmented page (assertInlineBody) before using it
+src/core/trust/held-removals.ts acceptHeldRemoval field SEGW assertInlineBody: refuses a segmented page (page_body_segmented) and the proposal stays pending
src/core/trust/page-handlers.ts markdownWithoutMarker call:serializeMarkdown SEGW
src/core/trust/page-handlers.ts markdownWithoutMarker field SEGW
src/core/trust/page-handlers.ts versionMarkdown call:serializePageToMarkdown SEGW
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index e5c1cad4fe..13e777b583 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -645,9 +645,9 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
// Pre-W1 integrity wave (belief ledger Q6 + inherited purge read gaps). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
{ since: '0.60.251.0', text: 'A take graded only in the database (for example by `grade_takes` on a source without managed persistence) keeps its grade when its page is published again from a fence that has no resolution cells: a prose edit, a re-import, a sync or `revert_version` to a version from before the grade. Before, every such publish erased the grade. A fence that carries resolution cells still writes them, and a take whose claim is edited in place (same row number) now drops the old claim\'s grade.' },
{ since: '0.60.251.0', text: 'After `purge_fact` or a page purge, no read returns the purged text from what the purge hid: a page a purge hid for re-derivation now reads as missing in `get_page` and `fetch` (even with `include_deleted`) and returns no `get_versions` history, and a page purge now hides rows derived from the page and its facts, as `purge_fact` already did. `purge_fact` now redacts every retained version of a page (it stopped after 5,000), and its receipt\'s `pages` and `page_versions` stores also report a page or version that still states the claim in its title or frontmatter, alongside prose (`out_of_scope: source_prose`).' },
- // W1 trust prerequisites (#6783 §12 (a) and (b)). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
- { since: '0.60.251.0', text: 'A write less trusted than a take or timeline row no longer deletes, replaces or deactivates it. A page publish (`put_page`, sync, a maintenance republish) that drops or rewrites such a row, `takes_remove`, the takes reconcile (`gbrain extract takes`) and the timeline orphan prune now keep the row as it is and file a `forget` proposal (`gbrain trust review`): `gbrain trust confirm tp<id>` applies the change, `gbrain trust drop tp<id>` keeps the row. A refused `takes_remove` returns `forget_requires_owner` with the proposal ref. The page text keeps what the writer published, and the put_page response lists the proposals under `contested`.' },
- { since: '0.60.251.0', text: 'Lowering a row\'s trust tier now lowers what was derived from it: facts, takes, pages and timeline rows reached through their recorded derivation inputs drop to the least trusted of their current inputs (an agent edit that lowers a page, an owner tier change, the `gbrain trust claim-sources` relower repair, a derived republish, a fence field rewrite). Raising a tier never promotes a derivative, and recorded history keeps its tiers. A lowered row\'s `write_origin.input_lowered` names the tier it had; on a managed brain a dependent in another source is marked `needs_rederive` instead.' },
+ // W1 trust prerequisites (#6783 §12 (a) and (b)).
+ { since: '0.60.253.0', text: 'A write less trusted than a take or timeline row no longer deletes, replaces or deactivates it. A page publish (`put_page`, sync, a maintenance republish) that drops or rewrites such a row, `takes_remove`, the takes reconcile (`gbrain extract takes`) and the timeline orphan prune now keep the row as it is and file a `forget` proposal (`gbrain trust review`): `gbrain trust confirm tp<id>` applies the change, `gbrain trust drop tp<id>` keeps the row. A refused `takes_remove` returns `forget_requires_owner` with the proposal ref. The page text keeps what the writer published, and the put_page response lists the proposals under `contested`.' },
+ { since: '0.60.253.0', text: 'Lowering a row\'s trust tier now lowers what was derived from it: facts, takes, pages and timeline rows reached through their recorded derivation inputs drop to the least trusted of their current inputs (an agent edit that lowers a page, an owner tier change, the `gbrain trust claim-sources` relower repair, a derived republish, a fence field rewrite). Raising a tier never promotes a derivative, and recorded history keeps its tiers. A lowered row\'s `write_origin.input_lowered` names the tier it had; on a managed brain a dependent in another source is marked `needs_rederive` instead.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/trust/held-removals.ts b/src/core/trust/held-removals.ts
index 2892359489..c3a886420e 100644
--- a/src/core/trust/held-removals.ts
+++ b/src/core/trust/held-removals.ts
@@ -11,7 +11,9 @@
* number (or the timeline entry with its date, source and summary) replaces
* it at the writer's tier, and when the page no longer carries one the row
* is deleted.
- * Dismissing keeps the row (the default reject).
+ * Dismissing keeps the row (the default reject). A segmented page has no body
+ * string to rule the row, so its accept refuses (`page_body_segmented`) and the
+ * proposal stays pending.
*/
import type { BrainEngine } from '../engine.ts';
import { parseTakesFence } from '../takes-fence.ts';
@@ -23,12 +25,13 @@ import { queuePageProjection } from '../page-state/projections.ts';
import { reprojectTimelineRow } from '../persistence/canonical-projections.ts';
import { decisionResult, getTrustProposal, transitionTrustProposal, type TrustDecisionContext, type TrustDecisionResult, type TrustProposalRow } from './proposals.ts';
import { storedTrustTier } from './tier.ts';
+import { assertInlineBody } from '../page-body/page-shape.ts';
-interface HeldPageRow { id: number; page_id: number; source_id: string; slug: string; compiled_truth: string; timeline: string | null }
+interface HeldPageRow { id: number; page_id: number; source_id: string; slug: string; body_storage: 'inline' | 'segmented' | null; compiled_truth: string; timeline: string | null }
async function heldRow(engine: BrainEngine, table: string, id: number): Promise<(HeldPageRow & Record<string, unknown>) | undefined> {
const columns = table === 'takes' ? 'x.row_num, x.claim' : 'x.date::text AS date, x.source, x.summary';
- const [row] = await engine.executeRaw<HeldPageRow & Record<string, unknown>>(`SELECT x.id, x.page_id, ${columns}, p.source_id, p.slug, p.compiled_truth, p.timeline
+ const [row] = await engine.executeRaw<HeldPageRow & Record<string, unknown>>(`SELECT x.id, x.page_id, ${columns}, p.source_id, p.slug, p.body_storage, p.compiled_truth, p.timeline
FROM ${table === 'takes' ? 'takes' : 'timeline_entries'} x JOIN pages p ON p.id = x.page_id WHERE x.id = $1`, [id]);
return row;
}
@@ -50,6 +53,7 @@ export async function acceptHeldRemoval(engine: BrainEngine, proposal: TrustProp
await transitionTrustProposal(engine, proposal.id, 'pending', 'superseded', { decidedBy: ctx.decidedBy });
return decisionResult(proposal, 'accept', 'superseded', { reason: 'row_missing' });
}
+ assertInlineBody(row, 'trust confirm (held removal)');
const body = { compiled_truth: row.compiled_truth, timeline: row.timeline ?? '' };
const fenceRow = table === 'takes' ? parseTakesFence(`${row.compiled_truth}\n${row.timeline ?? ''}`).takes.find(t => t.rowNum === Number(row.row_num)) : undefined;
if (fenceRow && fenceRow.claim === row.claim) {