Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/master' into capy/w1-trust-guards

garrytanbf87947b1837
diff --cc src/core/behavior-change-notice.ts
index 802fa99a9c,7b12cf89f2..e6ad06e910
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -642,9 -642,9 +642,12 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.249.0', text: 'On a brain without managed persistence, `extract_facts` (and the v0.32.2 fence step) now fences unfenced facts of a database-only page (no recorded file and none at its slug path) into the page\'s database body when such a write is database-only (`sync.write_through` off, or on Postgres an unbound source with `persistence.unbound_write=database_only`, which stamps the page `unbound_source`), instead of reporting a missing canonical file and halting the facts fence every run. Without that opt-in the rows stay unfenced and their page skips reconciliation, but they no longer count as pending (`legacyRowsPending`) or trigger the guard; doctor `fence_integrity` lists them under `unbound_legacy_facts` and asks the user about the opt-in, and the migration reports them as `skipped_unbound_source`.' },
{ since: '0.60.249.0', text: 'On a brain without managed persistence, `gbrain restore` / `restore_page` of a soft-deleted page whose recorded file is gone from the checkout now refuses (`source_changed`, detail `canonical_file_absent`) when the restore writes no file, instead of restoring a page the next `gbrain sync --full` deletes again. Put the file back and sync, or pass `--detach` (`detach: true`) to restore it database-only (`database_only_reason=detached`, no `source_path`); a file synced back at its path binds the page again. New doctor check `missing_recorded_files` lists live pages a full sync would delete this way.' },
{ since: '0.60.250.0', text: 'Remote agents and token-floor connections now get stored contradiction findings from `find_contradictions` instead of an availability note or a refusal: only findings whose two sides they can read now, each side re-read live with its `source_id` and `trust_tier`, never the stored report text; `min_trust` and the token floor filter instead of refusing. A local `gbrain find-contradictions --source <id>` (or `GBRAIN_SOURCE`) now gets that scoped view instead of the note; the bare command still reads the whole stored run.' },
- // W1 #6783 §12 (a) and (b).
- { since: '0.60.250.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.250.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, `gbrain trust claim-sources --relower`, 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.' },
+ // 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, `gbrain trust claim-sources --relower`, 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 --cc src/core/persistence/canonical-projections.ts
index e9b8d7a0c4,c1a94208b3..3f5a4da307
--- a/src/core/persistence/canonical-projections.ts
+++ b/src/core/persistence/canonical-projections.ts
@@@ -452,10 -429,17 +452,18 @@@ export async function prepareCanonicalP
expired_at text,source text,confidence real,claim_metric text,claim_value double precision,claim_unit text,claim_period text,attributed_to text)
WHERE f.source_id=$1 AND f.source_markdown_slug=$2 AND f.row_num=r.row_num`, [sourceId, slug, fieldRows]) : Promise.resolve([]);
const checkTakes = () => refuseCollisions(tx, id);
- const dropTakes = () => tx.executeRaw('DELETE FROM takes WHERE page_id=$1 AND row_num=ANY($2::integer[])', [id, takeRowsGone]);
+ const dropTakes = () => tx.executeRaw('DELETE FROM takes WHERE page_id=$1 AND row_num=ANY($2::integer[])', [id, takeRowsGone.filter(n => !heldRowNums.has(n))]);
- // Full canonical versions include resolution fields; a revert restores those
- // fields from Markdown too, without the ordinary immutable-resolution API.
- const resolutions = JSON.stringify(projectedTakes.map(take => ({ row_num: take.rowNum, resolved_at: take.resolvedAt ?? null,
+ // A fence row's resolution cells are written as Markdown says, so a revert to a version that carries them restores
+ // them. A row without resolution cells keeps the stored resolution (a database-only grade, e.g. unmanaged
- // grade_takes) unless its claim changed in place, which drops the old claim's grade.
- const fenceResolved = takes.filter(take => take.resolvedAt !== undefined || take.resolvedQuality !== undefined);
- const claims = JSON.stringify(takes.map(take => ({ row_num: take.rowNum, claim: take.claim })));
- const clearChangedResolutions = () => takes.length ? tx.executeRaw(`UPDATE takes k SET resolved_at=NULL,resolved_quality=NULL,
++ // grade_takes) unless its claim changed in place, which drops the old claim's grade. A held take keeps its grade:
++ // the guard decided before any of these statements run (W1 #6783 §6.2).
++ const fenceResolved = projectedTakes.filter(take => take.resolvedAt !== undefined || take.resolvedQuality !== undefined);
++ const claims = JSON.stringify(projectedTakes.map(take => ({ row_num: take.rowNum, claim: take.claim })));
++ const clearChangedResolutions = () => projectedTakes.length ? tx.executeRaw(`UPDATE takes k SET resolved_at=NULL,resolved_quality=NULL,
+ resolved_outcome=NULL,resolved_source=NULL,resolved_value=NULL,resolved_unit=NULL,resolved_by=NULL
+ FROM jsonb_to_recordset($2::text::jsonb) AS n(row_num integer,claim text)
+ WHERE k.page_id=$1 AND k.row_num=n.row_num AND k.resolved_at IS NOT NULL AND k.claim IS DISTINCT FROM n.claim`, [id, claims]) : Promise.resolve([]);
+ const resolutions = JSON.stringify(fenceResolved.map(take => ({ row_num: take.rowNum, resolved_at: take.resolvedAt ?? null,
resolved_quality: take.resolvedQuality ?? null,
resolved_outcome: take.resolvedQuality === 'correct' ? true : take.resolvedQuality === 'incorrect' ? false : null,
resolved_source: take.resolvedEvidence ?? null, resolved_value: take.resolvedValue ?? null, resolved_unit: take.resolvedUnit ?? null,
@@@ -495,13 -478,10 +503,13 @@@
() => pipelined(tx, [expireFacts, ...timelineRows])));
if (guard.rows.length) await step('facts', () => tx.insertFacts(guard.rows, { source_id: sourceId })); // gbrain-allow-direct-insert: canonical fence projection shares the journal publication transaction
const contested = await step('fact_trust', () => guard.finish(tx));
+ // W1 #6783 §12 (b): a fence row's field rewrite can lower a more trusted fact (the tier trigger); what was derived from it follows.
+ const above = factRows.length ? await factsAboveWriter(tx, sourceId, slug) : [];
- await step('fact_fields', () => pipelined(tx, [factFields, checkTakes, dropTakes]));
+ await step('fact_fields', () => pipelined(tx, [factFields, checkTakes, dropTakes, clearChangedResolutions]));
- if (takes.length) {
+ if (above.length) await propagateFactLowering(tx, above);
+ if (projectedTakes.length) {
await step('takes', async () => {
- await tx.addTakesBatch(takes.map(t => takesPreparation.toCanonicalBatchInput(id, t)));
+ await tx.addTakesBatch(projectedTakes.map(t => takesPreparation.toCanonicalBatchInput(id, t)));
await resolveTakes();
});
}