Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Hold a lower-trust widening of a private fence fact until the owner accepts it (GST-2511)
garrytan302510b9a6b0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5ce58bd9cc..712b7c9cb6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,11 +14,15 @@ identifiers and attribution are available in the pre-removal Git revision**A visibility repair now closes a fenced fact instead of leaving a world copy beside it.** When `gbrain repair visibility --class facts` made a `## Facts` row private and the stored row was more trusted than the repair, the fence guard kept the original world row live and filed a contested private copy, so remote callers could still read the fact while the page and its file read as fixed. A write that only makes a fence row private now makes the stored row private in place, keeping its id and trust tier, and files no proposal. On a brain without managed persistence the repair makes the fenced row private itself, because that import does not re-project the fence. A write that makes a more trusted private row world is still held for the owner.+**A less trusted write that makes a private fenced fact world no longer stores a world fact before the owner decides.** An agent `put_page` that turned a more trusted private `## Facts` row world (the same claim at its row number or restated at another, or a different claim at its row number) stored its row world at once, so remote recall returned the private claim while the owner's proposal waited, and accepting that proposal then failed as stale. The writer's row is now stored private and contested, its proposal records the widening, `gbrain trust confirm tp<id>` makes the claim world and `gbrain trust drop tp<id>` keeps it private, and later writes of that fence by the same writer, and the background facts reconcile, keep it private meanwhile. A claim the page already holds world is not treated as a widening, and an accept applies the widening only while the page's fence row still asks for world. A `remember` that restates a private claim world is not covered by this change. The page text still holds the visibility the writer wrote, so a remote page read shows that row until the owner decides (GST-2511).+### Itemized changes- `src/core/trust/fence-guard.ts`: a guarded row whose claim the writer kept and whose visibility it only narrowed (world to private) moves to the new row's position and turns private in place, instead of being detached and contested.- `src/core/repair/visibility.ts`: on a brain without managed persistence, a fenced fact row the label write made private in the fence is made private in the database too; `fact_left_readable` and `fact_left_world` stay for the rows that still cannot be closed.- Tests: `test/label-only-repairs.test.ts` (managed and repo-less, PGLite and Postgres) and `test/trust-guarded-supersession.test.ts` (narrowing applies in place; widening stays guarded).+- `src/core/trust/fence-guard.ts`, `src/core/trust/supersede-handlers.ts`: a contested replacement that would make a guarded private row world, or a new world row restating a more trusted private claim of the page, is inserted private, its `supersede_fact` proposal carries `visibility: {from, to}`, the owner's accept sets it (undo restores it), and a lower-tier write keeps that contested row private while its widening is pending, rejected or undone (GST-2511).+- `src/core/cycle/extract-facts.ts`: the fence reconcile keeps the visibility of a contested row whose widening proposal is pending, rejected or undone, instead of widening it to the page's cell (GST-2511).## [0.60.683.0] - 2026-11-11diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex c03ad85608..6dc4c960a5 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -49,5 +49,5 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: linksrc/core/search/evidence-delivery.ts 1759 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move); +7 GBRA-205: EvidencePlan.titleHeader and DeliveryMeta.title_header (interface fields cannot move) and the titles option on the header loader (logic in search/evidence-date.ts; the query budget key lives in search/evidence-packing.ts); +11 #7600: assemble_evidence quotes conversation rows and capEvidenceToBudget counts the quote fence (logic in search/transcript-quote.ts); +2 GBRA-156 /ship review: the cut-path admission and title room count the quote fence; +2 GBRA-156 /ship review pass 2: capEvidenceToBudget counts the fence only for the paths that fence (quote flag; recall counts the text as returned); +4 GST-687: page evidence and the extractive fallback quote below-owner-tier text for untrusted readers (untrusted flag; logic in search/transcript-quote.ts)src/commands/config.ts 1530 ratchet +1 GBRA-216: recall.* config set value refusal (facts/recall-config.ts); +1 GBRA-216: config set refuses a dream.claim_conflicts.mode other than propose|off (refusal in facts/claim-conflicts.ts); new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal); +4 GBRA-377 PR B: skills.resolver.* file-plane routing (doc line, the one-line router and its two dispatch lines; logic in core/setup/skill-resolver-config.ts)src/commands/mcp-expose.ts 1519 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts); +7 GBRA-199: --surface help lines, surfaceChosen option field and the advertise pass-through (registrationAdvertise in core/mcp-registration.ts)-src/core/behavior-change-notice.ts 1741 ratchet +4 train R: #7491/#7492 keyword_identifier_probe and keyword_slug_handles rows and their comment, #7175 keyword phrase row; the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +3 GBRA-200 comment, write-grant refusal and degraded-stamp rows (re-summed at the 0.60.562.0 merge: 1615 + 3); +2 GBRA-280 get_page selector-precedence row and comment (re-summed at the 0.60.569.0 merge: 1619 + 2); the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +2 #7199 (re-port of #7228) classic_drift_rescreen_7199 comment and row; +2 #7931 file_drift_agrees_7931 comment and row; +1 #7950 file_drift_slug_release_7950 row; +1 #7974 file_drift_followups_7974 row; +1 #8059 quoted_fence_marker_8059 row; +2 GBRA-247 #8009 provenance_repair_held_8009 and #7982 pass_transient_streak_7982 rows; +4 GBRA-247 #7973 plain_directory_sync_7973, #7988 managed_marker_own_directory_7988, #7985 former_binding_parked_group_7985 and settle_effects_retire_7985 rows Train S merge: 1570 base + 5 (master since the #8077 base) + 13 (#8077) = 1588.; +2 GST-687 remote_quotes_unverified_text_gst687 row and its comment (re-summed at the gate-ahead on train S 0.60.534.0: 1588 + 2); +2 #8377: the quote fence follow-ups row and its comment; +2 #8384: the quote fence follow-ups 2 row and its comment; +2 #8384 wave 3: the quote fence follow-ups 3 row and its comment; +5 GBRA-218 train M rows (A1 member_read_access_gbra218 and member_access_hatch_scope_gbra218, B shared_agent_audience_gbra231, A2 folder_access_rules_gbra218, folder_access_scoped_role_gbra218), re-summed at the train M merge of master v0.60.541.0: 1596 + 5 = 1601 measured; +3 GST-359 train C rows (C1 qm_attested_actor_gst359, C2 member_facts_gst359, D qm_memory_provider_gst359), re-summed at the train C merge of master v0.60.543.0: 1601 + 3 = 1604 measured; +2 #8424: hook_launcher_8424 row and its comment (rows are data and cannot move), re-summed at the #8418 v0.60.546.0 merge: 1604 + 2 = 1606 measured; +2 #8426: mcp_lane_launcher_8426 row and its comment (rows are data and cannot move); +2 GST-927: empty_nonstring_args_gst927 row and its comment, re-summed at the gate-ahead on master v0.60.550.0 plus #8420: 1610 measured; +2 GBRA-283 Wave A (#8460): engine_keyed_caches_gbra283 row and its comment (rows are data and cannot move); +2 GBRA-287: segmented_freeze_hold_gbra287 and segmented_reexport_gbra287 rows (rows are data and cannot move); +1 GST-1209: segmented_tiling_gst1209 row (rows are data and cannot move); +1 GST-1251: skillopt_loop_deprecated_gst1251 row (rows are data and cannot move); +1 GST-1209 follow-up: untiled_hold_repair_gst1209 row (rows are data and cannot move); +1 GBRA-283 B3a: embedded_scope_required_gbra283 row (rows are data and cannot move); re-summed at the train R merge with v0.60.574.0: 1623 + 4; +2 GST-1387: refresh_fence_refusal_gst1387 row and its comment (rows are data and cannot move); re-summed at the memory train #8481 merge with v0.60.578.0 (1643 measured); +3 GBRA-253 #8109 rows (frontmatter_drift_write_8109, contacts_activity_advance_8109, contact_rows_dedupe_8109; rows are data and cannot move), re-summed at the master v0.60.581.0 merge: 1643 + 3 = 1646 measured; +3 #8123 part C rows: sync_write_through_off_writeback_7084, managed_sync_dry_run_counts_7087, frontmatter_missing_source_dir_7889 (since TBD until the merge slot; re-summed at the 0.60.583.0 merge: 1646 + 3); +4 PR B commit_ledger_prb, doctor_foreign_writers_prb and sources_guard_prb rows and their comment (rows are data and cannot move; since TBD until the merge slot); +1 PR B #8615: file_drift_held_needs_prefer_8615 row; +1 PR B #8617: refresh_source_changed_retry_8617 row; +1 PR B #8662: commit_push_checkout_not_a_source_8662 row (since TBD until the merge slot; rows are data and cannot move); +2 PR B refresh_barrier_prb and commit_push_base_prb rows (re-summed: 1658 measured); +3 convergence PR A: the wave comment and two rows (conversion_content_evidence_pr_a, git_gap_live_pages_pr_a; since TBD until the merge slot; rows are data and cannot move); re-summed at the gate-ahead on master v0.60.592.0 plus #8711: 1658 + 3 = 1661 measured; +4 GST-1094/GST-900 rows (memory_recall scope-read, member-bound acting_user, recall max_chars, unknown_param _meta-only) and +1 qm_scope_writes_gst1113 and +1 recall_question_terms_gst1304 rows (rows are data and cannot move), re-summed at the 0.60.595.0 slot merge: 1661 + 6; +1 GST-1582 refresh_barrier_import_gst1582 row (since TBD until the merge slot; rows are data and cannot move); +2 GST-1601 source_changed_origin_gst1601 and adopt_local_edits_gst1601 rows (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.596.0 merge: 1668 + 2; +1 GST-1623 refresh_barrier_capacity_gst1623 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.599.0 merge: 1670 + 1; +2 GBRA-224 W1 release_channel_stable_default row and its comment; +1 GST-1623 refresh_barrier_later_write_gst1623 row (#8765; rows are data and cannot move); +5 #8766 GST-1623 items 4/6-9 and #8755: the wave comment and four rows (doctor_foreign_writers_partial_gst1623, commit_push_enclosing_repo_gst1623, owner_guard_fail_closed_gst1623, adopt_local_edits_hardening_8755) and +1 managed_sync_kind_reserved_8765 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on master v0.60.608.0 plus #8798: 1674 + 6; +1 GST-1853 refresh_barrier_aborted_refresh_sync_gst1853 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.613.0 merge: 1680 + 1; +1 GST-1674 refresh_refused_merge_recovery_gst1674 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.614.0 merge: 1681 + 1; +1 #8824/#8826/#8767: adopt_local_edits_replay_markers_8824 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8837: 1682 + 1; +1 url_source_origin row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8834: 1683 + 1; +1 #8828: the refresh_replan_own_commits_8828 row (1684 + 1 at the 0.60.618.0 slot); +1 the managed commit-push unpublished-count row; +1 the refresh publish-diverged default row; +1 GST-2051 ungranted_member_writes_gst2051 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-731 think_window_trajectory_gst731 row and +1 GST-1602 purge_cancels_deferred_write_gst1602 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8915 v0.60.621.0: 1688 + 2; +1 GST-2059: owner_reads_private row; +1 #8888: the record-origin checkout lock-down row (re-summed at the Q6 stack on #8934 v0.60.625.0: 1691 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 E1/F3/F4 rows (since TBD until the merge slot), re-summed at the master merge; +1 GBRA-284 personal_sources_gbra284 row (since TBD until the merge slot) (re-summed at the QM wave merge onto master v0.60.626.0: 1692 + 3); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 v3: the qm_personal_structured_gst1158 row (since TBD until the merge slot); +1 #8477 GST-1158 F2 personal-tools row at the QM wave merge (1695 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 #8483 memory_propose row at the QM wave merge (1696 + 1); +1 GST-1094 gap 4: the qm_admin_http_gst1094 row (since TBD until the merge slot); +1 GST-1158: the member_email_link_gst1158 row (since TBD until the merge slot); +2 #8479 member-email rows at the QM wave merge (1697 + 2); +1 GST-2112: ingest_keeps_readers_gst2112 row (re-summed at the Q7 v0.60.627.0 merge: 1692 + 1); +1 #8982 federated_member_writes_8982 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q10 slot on #9009 ee0f4a78: 1694 + 1; +1 GST-2118 pending_ledger_flagged_gst2118 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q12 slot on #9016 afb49de5: 1695 + 1; +1 GBRA-431: read_scope_params_gbra431 row (rows are data and cannot move), re-summed at the #9032 stack merge: 1697 measured; +2 GST-2201 sync_restored_file_gst2201 and purge_keeps_committed_file_gst2201 rows (since is the current VERSION until the merge slot; +1 GST-2243 remember_share_gst2243 row (re-summed at the #9098 stack merge: 1699 + 1); +1 GST-2312 #9024 sync_filter_owned_hold_9024 row (re-summed at the #9064 stack merge: 1700 + 1; rows are data and cannot move); +2 access-privacy wave (0.60.649.0): the owner_private_facts_gst2089 and private_labels_write_ahead_gst2092 rows; +1 GBRA-443 private_labels_batch_exit_gbra443 row (rows are data and cannot move), re-summed at the 0.60.650.0 slot on #9038: 1703 + 1; +1 postgres_tls_default row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.651.0 merge: 1704 + 1; +1 GST-2331 sync_reads_fetch_nothing_gst2331 row (rows are data and cannot move), re-summed at the 0.60.654.0 stack on #9045 6ff5540d: 1705 + 1; +7 QM wave (#9037) rows: attest_scope_read_ops_gst1158, attest_direct_page_writes_deferred_gst1158, personal_sources_gbra284, qm_personal_structured_gst1158, memory_propose_held_writes_gst1158, member_email_link_gst1158, qm_admin_http_gst1094 (re-summed at the 0.60.655.0 stack on #9110 f9b2072e: 1706 + 7); +1 GST-2228 recreated_takes_section_keeps_stored_takes_gst2228 row (since TBD; re-summed at the keep-takes-and-link-dates train merge: 1713 + 1); +1 GST-2228 links_rows_keep_own_dates_gst2228 row (since TBD; re-summed at the same train merge: 1714 + 1); +2 the W1 + memory proposals train (#9133): attest_every_page_write_deferred_gst2249 and memory_proposals_owner_http_gst2407 rows (rows are data and cannot move), re-summed at the #9138 v0.60.661.0 stack merge: 1715 + 2 = 1717 measured; +1 #8903 effect_git_secret_gate_gst1923 row (rows are data and cannot move), re-summed at the 0.60.664.0 stack on #9142 3931adb4: 1717 + 1; +1 GST-2407 PR 3: qm_recall_own_page_contract_v4 row (rows are data and cannot move), re-summed at the 0.60.666.0 stack on #9148 69c12917: 1718 + 1; +2 GST-363 PR 1 and PR 3 (#9135): the serves_several_labels_gst363 and stdio_member_per_harness_gst363 rows; +3 #9134 train rows member_forget_names_host_9101, refresh_fence_retry_id_gst2353 and recorded_read_view_args_gst2214 (rows are data and cannot move), re-summed at the #9134 slot merge onto #8829 dfc24954: 1721 + 3; +3 source-checkouts wave rows (autopilot_git_reconcile_gbra386, unknown_drift_history_rescreen, refresh_abandon_members_gst1465), re-summed at the #9137 stack merge: 1724 + 3; persistence train 13 at 0.60.676.0: its five rows on top of 0.60.675.0; +1 GST-2250 reconcile_publish_opt_out_gst2250 row (since TBD until the merge slot; rows are data and cannot move); +1 #8902 unmanaged_push_history_scan_8902 row (re-summed at the 0.60.678.0 stack on 501742d9: 1733 + 1); +1 GST-2246 maintain_safe_free_phases_gst2246 row (since TBD until the merge slot; rows are data and cannot move), re-summed on the doctor/dream/enrich train at the 0.60.679.0 slot merge onto #9170 82932eda: 1734 + 1; +2 GST-2462 privacy_label_ignored_gst2462 and access_page_rules_gst2462 rows (rows are data and cannot move), re-summed at the #9173 slot merge onto 49a922ef: 1735 + 2; +1 GST-2107 follow-up write_capacity_low_not_refusal_gst2107 row (rows are data and cannot move), re-summed at the 0.60.681.0 slot merge onto #9173 c08d0c8b: 1737 + 1; +1 GST-2490: owner_reads_derived_gst2490 row (rows are data and cannot move); +1 GST-2468: the label_only_operator_repairs_gst2468 row (a BEHAVIOR_CHANGES row cannot move); +1 GST-2487: fence_fact_private_in_place_gst2487 row (since TBD until the merge slot; rows are data and cannot move)+src/core/behavior-change-notice.ts 1742 ratchet +4 train R: #7491/#7492 keyword_identifier_probe and keyword_slug_handles rows and their comment, #7175 keyword phrase row; the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +1 GBRA-156 #7593: private_pages_granted_sources row (re-summed at the 0.60.527.0 merge: 1574 + 1); +3 GBRA-200 comment, write-grant refusal and degraded-stamp rows (re-summed at the 0.60.562.0 merge: 1615 + 3); +2 GBRA-280 get_page selector-precedence row and comment (re-summed at the 0.60.569.0 merge: 1619 + 2); the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +2 #7199 (re-port of #7228) classic_drift_rescreen_7199 comment and row; +2 #7931 file_drift_agrees_7931 comment and row; +1 #7950 file_drift_slug_release_7950 row; +1 #7974 file_drift_followups_7974 row; +1 #8059 quoted_fence_marker_8059 row; +2 GBRA-247 #8009 provenance_repair_held_8009 and #7982 pass_transient_streak_7982 rows; +4 GBRA-247 #7973 plain_directory_sync_7973, #7988 managed_marker_own_directory_7988, #7985 former_binding_parked_group_7985 and settle_effects_retire_7985 rows Train S merge: 1570 base + 5 (master since the #8077 base) + 13 (#8077) = 1588.; +2 GST-687 remote_quotes_unverified_text_gst687 row and its comment (re-summed at the gate-ahead on train S 0.60.534.0: 1588 + 2); +2 #8377: the quote fence follow-ups row and its comment; +2 #8384: the quote fence follow-ups 2 row and its comment; +2 #8384 wave 3: the quote fence follow-ups 3 row and its comment; +5 GBRA-218 train M rows (A1 member_read_access_gbra218 and member_access_hatch_scope_gbra218, B shared_agent_audience_gbra231, A2 folder_access_rules_gbra218, folder_access_scoped_role_gbra218), re-summed at the train M merge of master v0.60.541.0: 1596 + 5 = 1601 measured; +3 GST-359 train C rows (C1 qm_attested_actor_gst359, C2 member_facts_gst359, D qm_memory_provider_gst359), re-summed at the train C merge of master v0.60.543.0: 1601 + 3 = 1604 measured; +2 #8424: hook_launcher_8424 row and its comment (rows are data and cannot move), re-summed at the #8418 v0.60.546.0 merge: 1604 + 2 = 1606 measured; +2 #8426: mcp_lane_launcher_8426 row and its comment (rows are data and cannot move); +2 GST-927: empty_nonstring_args_gst927 row and its comment, re-summed at the gate-ahead on master v0.60.550.0 plus #8420: 1610 measured; +2 GBRA-283 Wave A (#8460): engine_keyed_caches_gbra283 row and its comment (rows are data and cannot move); +2 GBRA-287: segmented_freeze_hold_gbra287 and segmented_reexport_gbra287 rows (rows are data and cannot move); +1 GST-1209: segmented_tiling_gst1209 row (rows are data and cannot move); +1 GST-1251: skillopt_loop_deprecated_gst1251 row (rows are data and cannot move); +1 GST-1209 follow-up: untiled_hold_repair_gst1209 row (rows are data and cannot move); +1 GBRA-283 B3a: embedded_scope_required_gbra283 row (rows are data and cannot move); re-summed at the train R merge with v0.60.574.0: 1623 + 4; +2 GST-1387: refresh_fence_refusal_gst1387 row and its comment (rows are data and cannot move); re-summed at the memory train #8481 merge with v0.60.578.0 (1643 measured); +3 GBRA-253 #8109 rows (frontmatter_drift_write_8109, contacts_activity_advance_8109, contact_rows_dedupe_8109; rows are data and cannot move), re-summed at the master v0.60.581.0 merge: 1643 + 3 = 1646 measured; +3 #8123 part C rows: sync_write_through_off_writeback_7084, managed_sync_dry_run_counts_7087, frontmatter_missing_source_dir_7889 (since TBD until the merge slot; re-summed at the 0.60.583.0 merge: 1646 + 3); +4 PR B commit_ledger_prb, doctor_foreign_writers_prb and sources_guard_prb rows and their comment (rows are data and cannot move; since TBD until the merge slot); +1 PR B #8615: file_drift_held_needs_prefer_8615 row; +1 PR B #8617: refresh_source_changed_retry_8617 row; +1 PR B #8662: commit_push_checkout_not_a_source_8662 row (since TBD until the merge slot; rows are data and cannot move); +2 PR B refresh_barrier_prb and commit_push_base_prb rows (re-summed: 1658 measured); +3 convergence PR A: the wave comment and two rows (conversion_content_evidence_pr_a, git_gap_live_pages_pr_a; since TBD until the merge slot; rows are data and cannot move); re-summed at the gate-ahead on master v0.60.592.0 plus #8711: 1658 + 3 = 1661 measured; +4 GST-1094/GST-900 rows (memory_recall scope-read, member-bound acting_user, recall max_chars, unknown_param _meta-only) and +1 qm_scope_writes_gst1113 and +1 recall_question_terms_gst1304 rows (rows are data and cannot move), re-summed at the 0.60.595.0 slot merge: 1661 + 6; +1 GST-1582 refresh_barrier_import_gst1582 row (since TBD until the merge slot; rows are data and cannot move); +2 GST-1601 source_changed_origin_gst1601 and adopt_local_edits_gst1601 rows (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.596.0 merge: 1668 + 2; +1 GST-1623 refresh_barrier_capacity_gst1623 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.599.0 merge: 1670 + 1; +2 GBRA-224 W1 release_channel_stable_default row and its comment; +1 GST-1623 refresh_barrier_later_write_gst1623 row (#8765; rows are data and cannot move); +5 #8766 GST-1623 items 4/6-9 and #8755: the wave comment and four rows (doctor_foreign_writers_partial_gst1623, commit_push_enclosing_repo_gst1623, owner_guard_fail_closed_gst1623, adopt_local_edits_hardening_8755) and +1 managed_sync_kind_reserved_8765 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on master v0.60.608.0 plus #8798: 1674 + 6; +1 GST-1853 refresh_barrier_aborted_refresh_sync_gst1853 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.613.0 merge: 1680 + 1; +1 GST-1674 refresh_refused_merge_recovery_gst1674 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.614.0 merge: 1681 + 1; +1 #8824/#8826/#8767: adopt_local_edits_replay_markers_8824 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8837: 1682 + 1; +1 url_source_origin row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8834: 1683 + 1; +1 #8828: the refresh_replan_own_commits_8828 row (1684 + 1 at the 0.60.618.0 slot); +1 the managed commit-push unpublished-count row; +1 the refresh publish-diverged default row; +1 GST-2051 ungranted_member_writes_gst2051 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-731 think_window_trajectory_gst731 row and +1 GST-1602 purge_cancels_deferred_write_gst1602 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the gate-ahead on #8915 v0.60.621.0: 1688 + 2; +1 GST-2059: owner_reads_private row; +1 #8888: the record-origin checkout lock-down row (re-summed at the Q6 stack on #8934 v0.60.625.0: 1691 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 E1/F3/F4 rows (since TBD until the merge slot), re-summed at the master merge; +1 GBRA-284 personal_sources_gbra284 row (since TBD until the merge slot) (re-summed at the QM wave merge onto master v0.60.626.0: 1692 + 3); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 GST-1158 v3: the qm_personal_structured_gst1158 row (since TBD until the merge slot); +1 #8477 GST-1158 F2 personal-tools row at the QM wave merge (1695 + 1); +1 GST-1158 F9: the attest_direct_page_writes_deferred_gst1158 row (since TBD until the merge slot); +1 #8483 memory_propose row at the QM wave merge (1696 + 1); +1 GST-1094 gap 4: the qm_admin_http_gst1094 row (since TBD until the merge slot); +1 GST-1158: the member_email_link_gst1158 row (since TBD until the merge slot); +2 #8479 member-email rows at the QM wave merge (1697 + 2); +1 GST-2112: ingest_keeps_readers_gst2112 row (re-summed at the Q7 v0.60.627.0 merge: 1692 + 1); +1 #8982 federated_member_writes_8982 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2116 commit_push_skipped_paths_gst2116 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q10 slot on #9009 ee0f4a78: 1694 + 1; +1 GST-2118 pending_ledger_flagged_gst2118 row (since TBD until the merge slot; rows are data and cannot move), re-summed at the Q12 slot on #9016 afb49de5: 1695 + 1; +1 GBRA-431: read_scope_params_gbra431 row (rows are data and cannot move), re-summed at the #9032 stack merge: 1697 measured; +2 GST-2201 sync_restored_file_gst2201 and purge_keeps_committed_file_gst2201 rows (since is the current VERSION until the merge slot; +1 GST-2243 remember_share_gst2243 row (re-summed at the #9098 stack merge: 1699 + 1); +1 GST-2312 #9024 sync_filter_owned_hold_9024 row (re-summed at the #9064 stack merge: 1700 + 1; rows are data and cannot move); +2 access-privacy wave (0.60.649.0): the owner_private_facts_gst2089 and private_labels_write_ahead_gst2092 rows; +1 GBRA-443 private_labels_batch_exit_gbra443 row (rows are data and cannot move), re-summed at the 0.60.650.0 slot on #9038: 1703 + 1; +1 postgres_tls_default row (since TBD until the merge slot; rows are data and cannot move), re-summed at the master v0.60.651.0 merge: 1704 + 1; +1 GST-2331 sync_reads_fetch_nothing_gst2331 row (rows are data and cannot move), re-summed at the 0.60.654.0 stack on #9045 6ff5540d: 1705 + 1; +7 QM wave (#9037) rows: attest_scope_read_ops_gst1158, attest_direct_page_writes_deferred_gst1158, personal_sources_gbra284, qm_personal_structured_gst1158, memory_propose_held_writes_gst1158, member_email_link_gst1158, qm_admin_http_gst1094 (re-summed at the 0.60.655.0 stack on #9110 f9b2072e: 1706 + 7); +1 GST-2228 recreated_takes_section_keeps_stored_takes_gst2228 row (since TBD; re-summed at the keep-takes-and-link-dates train merge: 1713 + 1); +1 GST-2228 links_rows_keep_own_dates_gst2228 row (since TBD; re-summed at the same train merge: 1714 + 1); +2 the W1 + memory proposals train (#9133): attest_every_page_write_deferred_gst2249 and memory_proposals_owner_http_gst2407 rows (rows are data and cannot move), re-summed at the #9138 v0.60.661.0 stack merge: 1715 + 2 = 1717 measured; +1 #8903 effect_git_secret_gate_gst1923 row (rows are data and cannot move), re-summed at the 0.60.664.0 stack on #9142 3931adb4: 1717 + 1; +1 GST-2407 PR 3: qm_recall_own_page_contract_v4 row (rows are data and cannot move), re-summed at the 0.60.666.0 stack on #9148 69c12917: 1718 + 1; +2 GST-363 PR 1 and PR 3 (#9135): the serves_several_labels_gst363 and stdio_member_per_harness_gst363 rows; +3 #9134 train rows member_forget_names_host_9101, refresh_fence_retry_id_gst2353 and recorded_read_view_args_gst2214 (rows are data and cannot move), re-summed at the #9134 slot merge onto #8829 dfc24954: 1721 + 3; +3 source-checkouts wave rows (autopilot_git_reconcile_gbra386, unknown_drift_history_rescreen, refresh_abandon_members_gst1465), re-summed at the #9137 stack merge: 1724 + 3; persistence train 13 at 0.60.676.0: its five rows on top of 0.60.675.0; +1 GST-2250 reconcile_publish_opt_out_gst2250 row (since TBD until the merge slot; rows are data and cannot move); +1 #8902 unmanaged_push_history_scan_8902 row (re-summed at the 0.60.678.0 stack on 501742d9: 1733 + 1); +1 GST-2246 maintain_safe_free_phases_gst2246 row (since TBD until the merge slot; rows are data and cannot move), re-summed on the doctor/dream/enrich train at the 0.60.679.0 slot merge onto #9170 82932eda: 1734 + 1; +2 GST-2462 privacy_label_ignored_gst2462 and access_page_rules_gst2462 rows (rows are data and cannot move), re-summed at the #9173 slot merge onto 49a922ef: 1735 + 2; +1 GST-2107 follow-up write_capacity_low_not_refusal_gst2107 row (rows are data and cannot move), re-summed at the 0.60.681.0 slot merge onto #9173 c08d0c8b: 1737 + 1; +1 GST-2490: owner_reads_derived_gst2490 row (rows are data and cannot move); +1 GST-2468: the label_only_operator_repairs_gst2468 row (a BEHAVIOR_CHANGES row cannot move); +1 GST-2487: fence_fact_private_in_place_gst2487 row (since TBD until the merge slot; rows are data and cannot move); +1 GST-2511: fence_fact_widening_held_gst2511 row (since TBD until the merge slot; rows are data and cannot move)src/commands/auth.ts 1503 ratchet new row: crossed the 1500 unlisted cap at the v0.60.595.0 merge: GST-1113 --attest-sources help lines plus GST-1158 F3 --attest-read help lines (3); CLI help lines cannot movediff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex fb92c5aaac..7af44aec46 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1538,6 +1538,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.676.0', id: 'ingest_backfill_409_recovery_gst2112', text: 'A `revision_backfill_pending` refusal (a write to a page the revision backfill has not reached, including the 409 a webhook capture to such a page gets from `POST /ingest`) now names the command that resumes the backfill, `gbrain apply-migrations --force-schema` on the brain host, instead of `gbrain apply-migrations --yes`, which does not resume it once the schema is current. A capture answered 409 stores and queues nothing, so its sender sends it again after the backfill; an `ingest_capture` job already queued for such a page goes straight to dead and is re-run with `gbrain jobs retry <id>`.' },{ since: '0.60.683.0', id: 'label_only_operator_repairs_gst2468', text: '`gbrain repair visibility` and `gbrain repair private-labels` now write a page through a label-only door: the page keeps its trust tier, files no `lower_page` proposal, and its file changes only on the label lines (other keys, their order and the body are kept). Before, `repair visibility` wrote through `put_page`, which lowered the page to agent_written and re-rendered its frontmatter. On a brain without managed persistence, `repair visibility` edits the label lines of a page\'s file in its source checkout and imports it with the tier kept (`private-labels` still holds such a page as `file_backed`). New `gbrain repair visibility --slug <page>` makes named pages private, preview first. New read-only `gbrain trust backfill --label-lowerings` lists `lower_page` proposals as label-only or content by proposer. A plain `put_page` still lowers as an agent edit.' },{ since: 'TBD', id: 'fence_fact_private_in_place_gst2487', text: 'A page write that only makes a `## Facts` row private (same claim, world to private) now makes the stored row private in place, keeping its id and trust tier, even when the row is more trusted than the writer. Before, such a row stayed live and world beside a contested private copy, so `gbrain repair visibility --class facts` could leave a fact remote callers still read while the page and its file read as fixed (`fact_left_readable`, `fact_left_world`). On a brain without managed persistence the repair now also makes the fenced row private. A write that makes a more trusted private row world is still held for the owner as before.' },+ { since: 'TBD', id: 'fence_fact_widening_held_gst2511', text: 'A page write by a writer less trusted than a private `## Facts` row that makes it world (the same claim at its row number or any other, or a different claim at its row number) no longer stores a world copy before the owner decides. The writer\'s row is stored private and contested, the trusted row stays private, and the `supersede_fact` proposal records the widening: `gbrain trust confirm tp<id>` applies it while the page\'s fence row still asks for world (the claim becomes world, confirmed), `gbrain trust drop tp<id>` keeps it private, and later writes of the same fence by such a writer, and the background facts reconcile, keep the contested row private. The `remember` route is not covered. Before, the writer\'s world row was live at once, so remote recall and other fact reads returned the private claim while the proposal waited, and accepting the proposal failed as stale (`scope_changed`). The page text keeps the visibility the writer wrote.' },{ since: '0.60.678.0', id: 'unmanaged_push_history_scan_8902', text: 'Four pushes from a checkout that is not a managed worktree now scan every local commit they publish for secrets, not only what they just wrote: the access-policy commit (`gbrain access rule` and the other policy writers), the durability-scaffolding commit of `gbrain sources harden`, `gbrain sources push`, and the first push of `gbrain bootstrap repo` (the whole history, since the remote has no such branch yet). A credential that a commit made with plain `git commit` added, even one a later commit removed, or one in a commit message, now refuses `publish_secret_found` naming the file, line, rule and commit (never the value), and nothing is pushed; history the scan cannot read in full refuses `publish_scan_unreadable`. The local commits stay where they are. `gbrain sources push` now pushes the exact commit it scanned, leased on the remote tip it read, and an allowlist (`.gbrain-scan-allow`) edit it commits itself still publishes; one a script committed is left for the user to review and push. Remove the value from the unpublished commits, or allowlist a false positive by fingerprint, then rerun.' },{ since: '0.60.680.0', id: 'privacy_label_ignored_gst2462', text: 'A page write (put_page, `gbrain import`, `gbrain sync`) that stores a page with an `access` or `confidentiality` value gbrain does not read as private (for example `access: personal`) and no `visibility` now carries one `privacy_label_ignored` safety notice: it names the key and value (a bulk run counts pages by value and names no page), says remote callers read the page like an unlabelled one and, on a source with a git checkout, that the label does not keep it out of git, and asks before adding `visibility: private`. `gbrain doctor --only privacy_label_ignored` counts such pages by value (a warning when the value plainly means private). Who can read a page is unchanged: the recognized values and `visibility.honor_aliases` are as before.' },{ since: '0.60.680.0', id: 'access_page_rules_gst2462', text: 'A folder rule can now name one exact page: `gbrain access rule add --slug <page> --readers <list>` (`slug:` in `.gbrain/access.yml`) restricts that page alone, never a folder of the same name, without writing the page, so a page at the source root or one whose file left git can be narrowed. A write refused because the page\'s file is missing now names this route beside the ghost-page repair. Upgrade every gbrain host that shares the brain before adding a page rule. Reads are decided in the database, so an older host still keeps the page restricted, but it refuses its own `gbrain access rule` commands and, on a git-backed source, stops syncing that source with `stored rulebook holds a malformed rule` until it is upgraded.' },diff --git a/src/core/cycle/extract-facts.ts b/src/core/cycle/extract-facts.tsindex a3f27cfb55..25a4685243 100644--- a/src/core/cycle/extract-facts.ts+++ b/src/core/cycle/extract-facts.ts@@ -458,7 +458,20 @@ async function planFenceReconcile(db: BrainEngine, page: PageFenceInput, slug: sif (desired && desired.fact === fact.fact) matched.set(desired.row_num, fact);else stale.push(fact);}- const updates = extracted.filter(f => {+ // GST-2511: a contested row whose widening the owner has not accepted keeps its visibility; the fence's world cell is+ // the lower-tier writer's request, which only the owner's accept applies (trust/fence-guard.ts).+ const widening = extracted.flatMap(f => {+ const fact = matched.get(f.row_num);+ return fact && fact.visibility !== 'world' && (f.visibility ?? 'private') === 'world' ? [Number(fact.id)] : [];+ });+ const heldWidening = new Set(widening.length ? (await db.executeRaw<{ id: number }>(+ `SELECT related_id AS id FROM trust_proposals WHERE source_id = $1 AND action = 'supersede_fact' AND related_table = 'facts'+ AND related_id = ANY($2::bigint[]) AND status IN ('pending', 'rejected', 'undone') AND before_state->'visibility' IS NOT NULL`,+ [sourceId, widening])).map(r => Number(r.id)) : []);+ const updates = extracted.map((f): FenceExtractedFact => {+ const fact = matched.get(f.row_num);+ return fact && heldWidening.has(Number(fact.id)) ? { ...f, visibility: fact.visibility as FenceExtractedFact['visibility'] } : f;+ }).filter(f => {const fact = matched.get(f.row_num);return fact !== undefined && factCellsDiffer(fact, f);});diff --git a/src/core/trust/fence-guard.ts b/src/core/trust/fence-guard.tsindex 16e3636e5f..5b2304a02d 100644--- a/src/core/trust/fence-guard.ts+++ b/src/core/trust/fence-guard.ts@@ -12,7 +12,12 @@* private (same claim, world to private, GST-2487) it moves there and turns* private in place, keeping its id and tier. Otherwise the new row at its old* position is inserted contested with a `supersede_fact` proposal, or, when- * the writer removed it, a `forget` proposal asks the owner.+ * the writer removed it, a `forget` proposal asks the owner. A new world row+ * that replaces a guarded non-world row, or restates the claim of a more+ * trusted non-world fact of the page at any row number, is inserted at that+ * row's visibility and its proposal carries the widening, which only the+ * owner's accept applies (GST-2511); until then later writes of the same+ * fence keep that contested row narrower.* - Row gate (ENG-1): every new fence row is gated like other fact writers at* the writer's tier; a held row is not inserted (the hold keeps it), a* flagged row records its receipt after insert.@@ -50,14 +55,21 @@ export async function guardFenceRows<T extends FenceFact>(tx: BrainEngine, input/** #8819: rows the fence never held, which this write keeps as they are. */ kept?: readonly number[] },expire: () => Promise<unknown>): Promise<FenceGuard<T>> {const { sourceId, slug, incoming } = input;- const guarded = (await tx.executeRaw<{ id: number; row_num: number; fact: string; visibility: string; trust_tier: string }>(- `SELECT f.id, f.row_num, f.fact, f.visibility, f.trust_tier FROM facts f+ // GST-2511: a contested row a widening proposal stored narrower (pending, rejected or undone) is held at its visibility+ // against a writer that could not widen the row it contests, while the fence still asks for world at its position.+ const held = `f.visibility <> 'world' AND EXISTS (SELECT 1 FROM trust_proposals tp WHERE tp.action = 'supersede_fact' AND tp.related_table = 'facts'+ AND tp.related_id = f.id AND tp.status IN ('pending', 'rejected', 'undone') AND tp.before_state->'visibility' IS NOT NULL+ AND ${trustRankSql("tp.before_state->'old'->>'tier'")} > ${WRITER_RANK})+ AND EXISTS (SELECT 1 FROM jsonb_to_recordset($3::text::jsonb) AS w(row_num integer, fact text, visibility text)+ WHERE w.row_num = f.row_num AND w.fact = f.fact AND w.visibility = 'world')`;+ const guarded = (await tx.executeRaw<{ id: number; row_num: number; fact: string; visibility: string; trust_tier: string; above: boolean }>(+ `SELECT f.id, f.row_num, f.fact, f.visibility, f.trust_tier, ${trustRankSql('f.trust_tier')} > ${WRITER_RANK} AS above FROM facts fWHERE f.source_id = $1 AND f.source_markdown_slug = $2 AND f.row_num IS NOT NULL AND f.expired_at IS NULLAND (COALESCE(f.source, '') NOT LIKE 'cli:extract-conversation-facts%'OR EXISTS (SELECT 1 FROM jsonb_to_recordset($3::text::jsonb) AS c(row_num integer) WHERE c.row_num = f.row_num))AND NOT EXISTS (SELECT 1 FROM jsonb_to_recordset($3::text::jsonb) AS n(row_num integer, fact text, visibility text)WHERE n.row_num = f.row_num AND n.fact = f.fact AND n.visibility = f.visibility)- AND ${trustRankSql('f.trust_tier')} > ${WRITER_RANK}+ AND (${trustRankSql('f.trust_tier')} > ${WRITER_RANK} OR (${held}))ORDER BY f.row_num FOR UPDATE`, [sourceId, slug, incoming])).filter(row => !input.kept?.includes(Number(row.id)));if (guarded.length) await tx.executeRaw('UPDATE facts SET row_num = NULL WHERE id = ANY($1::bigint[])', [guarded.map(g => Number(g.id))]);await expire();@@ -71,6 +83,14 @@ export async function guardFenceRows<T extends FenceFact>(tx: BrainEngine, inputconst moves: Array<{ id: number; row_num: number; visibility: string }> = [];for (const g of guarded) {const free = rows.filter(r => r.fact === g.fact && !occupied.has(r.row_num));+ if (!g.above) {+ const target = free.find(r => r.row_num === Number(g.row_num));+ if (!target) continue;+ moves.push({ id: Number(g.id), row_num: target.row_num, visibility: g.visibility });+ occupied.add(target.row_num);+ rows = rows.filter(r => r !== target);+ continue;+ }const target = free.find(r => r.visibility === g.visibility) ?? (g.visibility === 'world' ? free.find(r => r.visibility === 'private') : undefined);if (!target) { contested.push(g); continue; }moves.push({ id: Number(g.id), row_num: target.row_num, visibility: target.visibility ?? g.visibility });@@ -88,6 +108,25 @@ export async function guardFenceRows<T extends FenceFact>(tx: BrainEngine, inputconst cfg = rows.some(r => !occupied.has(r.row_num)) && compareTrust((await writerTrust(tx)).tier, 'tool_observed') < 0 ? await input.cfg(tx) : null;// Only a row this write inserts at a guarded row's old position replaces it; a moved row never does.const fresh = new Set(rows.filter(r => !occupied.has(r.row_num)).map(r => r.row_num));+ // GST-2511: a new world row that replaces a guarded non-world row, or restates the claim of a non-world fact of this page+ // more trusted than the writer, is inserted at that row's visibility; its proposal carries the widening, which only the+ // owner's accept applies.+ const widened = new Map<number, { from: string; copy?: { id: number; trust_tier: string } }>();+ for (const g of contested) {+ const at = rows.find(r => r.row_num === Number(g.row_num) && fresh.has(r.row_num));+ if (at && g.visibility !== 'world' && at.visibility === 'world') widened.set(at.row_num, { from: g.visibility });+ }+ const restated = rows.filter(r => fresh.has(r.row_num) && r.visibility === 'world' && !widened.has(r.row_num));+ const trustedPrivate = restated.length ? await tx.executeRaw<{ id: number; fact: string; visibility: string; trust_tier: string }>(+ `SELECT f.id, f.fact, f.visibility, f.trust_tier FROM facts f WHERE f.source_id = $1 AND f.source_markdown_slug = $2 AND f.expired_at IS NULL+ AND f.visibility <> 'world' AND f.fact = ANY($3::text[]) AND ${trustRankSql('f.trust_tier')} > ${WRITER_RANK}+ AND NOT EXISTS (SELECT 1 FROM facts w WHERE w.source_id = $1 AND w.source_markdown_slug = $2 AND w.expired_at IS NULL AND w.visibility = 'world' AND w.fact = f.fact)+ ORDER BY f.id`, [sourceId, slug, restated.map(r => r.fact)]) : [];+ for (const r of restated) {+ const copy = trustedPrivate.find(t => t.fact === r.fact);+ if (copy) widened.set(r.row_num, { from: copy.visibility, copy: { id: Number(copy.id), trust_tier: copy.trust_tier } });+ }+ if (widened.size) rows = rows.map(r => fresh.has(r.row_num) && widened.has(r.row_num) ? { ...r, visibility: widened.get(r.row_num)!.from } : r);for (const row of rows) {if (!cfg || occupied.has(row.row_num)) { inserted.push(row); continue; }const decision = decideFactWrite({ fact: row.fact, context: row.context ?? null, source: row.source ?? null }, { sourceId, slug,@@ -108,13 +147,20 @@ export async function guardFenceRows<T extends FenceFact>(tx: BrainEngine, inputconst replacement = fresh.has(Number(g.row_num)) ? await at(Number(g.row_num)) : undefined;if (replacement) {refs.push((await recordContestedFact(db, { sourceId, oldId: Number(g.id), oldTier: storedTrustTier(g.trust_tier), newId: Number(replacement.id),- newTier: storedTrustTier(replacement.trust_tier), guard: 'fence_projection' })).proposal_ref);+ newTier: storedTrustTier(replacement.trust_tier), guard: 'fence_projection',+ ...(widened.has(Number(g.row_num)) ? { visibility: { from: widened.get(Number(g.row_num))!.from, to: 'world' } } : {}) })).proposal_ref);} else {const { id } = await insertTrustProposal(db, { action: 'forget', sourceId, target: { table: 'facts', id: Number(g.id) }, proposer: 'fence_projection',before: { guard: 'fence_projection', fact: { id: Number(g.id), tier: storedTrustTier(g.trust_tier) }, writer_tier: (await writerTrust(db)).tier, slug } });refs.push(`tp${id}`);}}+ for (const [rowNum, { from, copy }] of widened) {+ const restatement = copy ? await at(rowNum) : undefined;+ if (!copy || !restatement) continue;+ refs.push((await recordContestedFact(db, { sourceId, oldId: copy.id, oldTier: storedTrustTier(copy.trust_tier), newId: Number(restatement.id),+ newTier: storedTrustTier(restatement.trust_tier), guard: 'fence_projection', visibility: { from, to: 'world' } })).proposal_ref);+ }for (const { row, decision } of gated) {const stored = await at(row.row_num);if (stored) await recordFlaggedRow(db, decision, { table: 'facts', id: Number(stored.id), sourceId });diff --git a/src/core/trust/supersede-handlers.ts b/src/core/trust/supersede-handlers.tsindex 8ba91c584e..dbaaf50f75 100644--- a/src/core/trust/supersede-handlers.ts+++ b/src/core/trust/supersede-handlers.ts@@ -73,10 +73,12 @@ export async function lexicalContestCandidate(engine: BrainEngine, sourceId: str}/** The pending supersede_fact proposal for a contested write, inside its publication transaction. */-export async function recordContestedFact(tx: BrainEngine, input: { sourceId: string; oldId: number; oldTier: TrustTier; newId: number; newTier: TrustTier; guard: string }): Promise<{ proposal_ref: string }> {+export async function recordContestedFact(tx: BrainEngine, input: { sourceId: string; oldId: number; oldTier: TrustTier; newId: number; newTier: TrustTier; guard: string;+ /** GST-2511: the widening the writer asked for; the new row is stored at `from` and the owner's accept sets `to`. */ visibility?: { from: string; to: string } }): Promise<{ proposal_ref: string }> {const { id } = await insertTrustProposal(tx, {action: 'supersede_fact', sourceId: input.sourceId, target: { table: 'facts', id: input.oldId }, related: { table: 'facts', id: input.newId },- proposer: input.guard, before: { guard: input.guard, old: { id: input.oldId, tier: input.oldTier }, new: { id: input.newId, tier: input.newTier } },+ proposer: input.guard, before: { guard: input.guard, old: { id: input.oldId, tier: input.oldTier }, new: { id: input.newId, tier: input.newTier },+ ...(input.visibility ? { visibility: input.visibility } : {}) },});return { proposal_ref: trustProposalRef(id) };}@@ -172,6 +174,27 @@ function pairOf(row: TrustProposalRow): PairProposal | null {};}+/**+ * The visibility change a contested fence widening asked for (GST-2511), from the proposal's before_state; null unless+ * `newId` is the contested row (the reversed view confirms the old row and widens nothing).+ */+async function requestedVisibility(engine: BrainEngine, id: number, newId: number): Promise<{ from: string; to: string } | null> {+ const row = await getTrustProposal(engine, id);+ const visibility = row?.before_state.visibility as { from?: unknown; to?: unknown } | undefined;+ return row?.related_id === newId && typeof visibility?.from === 'string' && typeof visibility.to === 'string' ? { from: visibility.from, to: visibility.to } : null;+}++/** GST-2511: the page's fence still asks for `visibility` at the fact's row (same number and claim); a later write that narrowed it withdrew the widening. */+async function fenceAsks(engine: BrainEngine, factId: number, visibility: string): Promise<boolean> {+ const [fact] = await engine.executeRaw<{ fact: string; row_num: number | null; slug: string | null; source_id: string }>(+ 'SELECT fact, row_num, source_markdown_slug AS slug, source_id FROM facts WHERE id = $1', [factId]);+ if (!fact?.slug || fact.row_num === null) return false;+ const snapshot = await engine.readPageSnapshot(fact.slug, { sourceId: fact.source_id });+ if (!snapshot) return false;+ const { pageFenceRowKeys } = await import('../generations/fence-evidence.ts');+ return (await pageFenceRowKeys(engine, snapshot.page, fact.slug, fact.source_id)).has(`${Number(fact.row_num)}\u0000${fact.fact}\u0000${visibility}`);+}+export const TRUST_PAIR_STORE: PairProposalStore = {name: 'trust',async get(engine, id, lock) {@@ -186,17 +209,22 @@ export const TRUST_PAIR_STORE: PairProposalStore = {: undefined;return transitionTrustProposal(engine, id, fromPair(from) as TrustProposalRow['status'], fromPair(to) as TrustProposalRow['status'], after ? { after } : {});},- /** CEO-9: the owner's accept also confirms the new fact. */+ /** CEO-9: the owner's accept also confirms the new fact, and applies the widening its writer asked for (GST-2511). */async onAccept(tx, proposal) {+ const requested = await requestedVisibility(tx, proposal.id, proposal.new_fact_id);+ const widen = requested && await fenceAsks(tx, proposal.new_fact_id, requested.to) ? requested : null;await withTrustPromotion(tx, 'user_confirmed', () => tx.executeRaw(- `UPDATE facts SET trust_tier = 'user_confirmed' WHERE id = $1 AND source_id = $2`, [proposal.new_fact_id, proposal.source_id]));+ `UPDATE facts SET trust_tier = 'user_confirmed'${widen ? ', visibility = $3' : ''} WHERE id = $1 AND source_id = $2`,+ [proposal.new_fact_id, proposal.source_id, ...(widen ? [widen.to] : [])]));for (const id of [proposal.old_fact_id, proposal.new_fact_id]) await queueTierProjection(tx, 'facts', id);},/** Undo returns the new fact to the tier it had before the accept confirmed it (lowering needs no promotion). */async onUndo(tx, proposal) {const row = await getTrustProposal(tx, proposal.id);const prior = storedTrustTier((row?.before_state.new as { tier?: unknown } | undefined)?.tier);- await tx.executeRaw(`UPDATE facts SET trust_tier = $3 WHERE id = $1 AND source_id = $2`, [proposal.new_fact_id, proposal.source_id, prior]);+ const widen = await requestedVisibility(tx, proposal.id, proposal.new_fact_id);+ await tx.executeRaw(`UPDATE facts SET trust_tier = $3${widen ? ', visibility = $4' : ''} WHERE id = $1 AND source_id = $2`,+ [proposal.new_fact_id, proposal.source_id, prior, ...(widen ? [widen.from] : [])]);for (const id of [proposal.old_fact_id, proposal.new_fact_id]) await queueTierProjection(tx, 'facts', id);// W1 #6783 §12 (b): what was derived from the confirmed row while it was confirmed follows it back down.await propagateTierLowering(tx, [{ table: 'facts', id: proposal.new_fact_id }]);diff --git a/test/trust-guarded-supersession.test.ts b/test/trust-guarded-supersession.test.tsindex 6ac141a33f..39933997cf 100644--- a/test/trust-guarded-supersession.test.ts+++ b/test/trust-guarded-supersession.test.ts@@ -99,6 +99,9 @@ import { withTrustPromotion } from '../src/core/persistence/context.ts';import { decideTrustProposal } from '../src/core/trust/decide.ts';import { parseTrustProposalRef } from '../src/core/trust/proposals.ts';import { enableTrustProtections } from './helpers/trust-protections.ts';+import { addMember } from '../src/core/access/members.ts';+import { dispatchToolCall } from '../src/mcp/dispatch.ts';+import { runExtractFacts } from '../src/core/cycle/extract-facts.ts';async function confirmFact(b: Brain, id: number) {await b.engine.transaction(tx => withCoordinatedWrite(tx, [b.sourceId], () => withTrustPromotion(tx, 'user_confirmed', () =>@@ -246,12 +249,15 @@ describe('guarded fence re-projection (A5, ENG-1)', () => {const after = await live();const by = (fact: string) => after.filter(r => r.fact === fact);expect(by('Ivy lives in Lyon')).toEqual([{ id: Number(before[0]!.id), fact: 'Ivy lives in Lyon', visibility: 'private', row_num: 1, trust_tier: 'user_confirmed' }]);- // Widening is not a tightening: the confirmed private row stays private and detached, and the world row waits on the owner.+ // GST-2511: widening is not a tightening: the confirmed private row stays private and detached, and the agent's row waits on the+ // owner stored private (no world copy exists before the accept); its proposal carries the widening.expect(by('Ivy keeps bees')).toEqual(expect.arrayContaining([expect.objectContaining({ id: Number(before[1]!.id), visibility: 'private', row_num: null, trust_tier: 'user_confirmed' }),- expect.objectContaining({ visibility: 'world', row_num: 2, trust_tier: 'agent_written' })]));+ expect.objectContaining({ visibility: 'private', row_num: 2, trust_tier: 'agent_written' })]));+ expect(by('Ivy keeps bees').filter(r => r.visibility === 'world')).toEqual([]);const proposals = await listTrustProposals(engine, { sourceId: b.sourceId });expect(proposals.map(p => [p.action as string, p.target_id])).toEqual([['supersede_fact', Number(before[1]!.id)]]);+ expect(proposals[0]!.before_state.visibility).toEqual({ from: 'private', to: 'world' });expect(flipped.contested?.proposal_ref).toMatch(/^tp\d+$/);}}), 90_000);@@ -275,6 +281,175 @@ describe('guarded fence re-projection (A5, ENG-1)', () => {expect(await listTrustProposals(engine, { sourceId: b.sourceId })).toEqual([]);}}), 90_000);++ /** A confirmed fence page (row 1 world, row 2 private), and remote fact reads for an unbound token and a non-owner member. */+ async function widenFixture(engine: BrainEngine, slug: string, claim: string) {+ const b = await brain(engine);+ const as = (r: ReturnType<typeof row>, visibility: string) => ({ ...r, visibility });+ await run(b.local, 'put_page', { slug, content: page('Kim', body([row(1, 'Kim lives in Turin'), as(row(2, claim), 'private')])) });+ const live = () => engine.executeRaw<{ id: number; fact: string; visibility: string; row_num: number | null; trust_tier: string }>(+ 'SELECT id::int AS id, fact, visibility, row_num, trust_tier FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 AND expired_at IS NULL ORDER BY id', [b.sourceId, slug]);+ for (const r of await live()) await confirmFact(b, Number(r.id));+ const member = `member-${randomUUID().slice(0, 8)}`;+ await addMember(engine, member);+ const asMember = { ...b.remote, auth: { ...b.remote.auth!, member: { id: member, groups: [] } } } as OperationContext;+ /** The claims each remote caller's recall returns for the page's entity, through MCP dispatch (which resolves the caller's member access). */+ const remoteClaims = async () => Promise.all([b.remote, asMember].map(async ctx => {+ const out = await dispatchToolCall(engine, 'recall', { entity: slug }, { remote: true, transport: 'http', auth: ctx.auth, sourceId: b.sourceId,+ takesHoldersAllowList: ['world'] }) as { isError?: boolean; content: Array<{ text: string }> };+ expect(out.isError ?? false).toBe(false);+ return (JSON.parse(out.content[0]!.text).facts as Array<{ fact: string }>).map(f => f.fact).sort();+ }));+ /** A remote agent write, or (`local`) a local write after the source's default tier was lowered to agent_written: a writer that reads private rows. */+ const write = async (rows: ReturnType<typeof row>[], prose = '', ctx: 'remote' | 'local' = 'remote') => {+ const content = page('Kim', body(rows).replace('Profile.', `Profile.${prose}`));+ const current = await operationsByName.get_page.handler(b[ctx], { slug, include_content: true }) as Record<string, any>;+ return run(b[ctx], 'put_page', { slug, content, expected_revision: current.revision });+ };+ const lowerSource = async () => {+ const log = console.log;+ console.log = () => {};+ try { await runSetTrust(engine, [b.sourceId, 'agent_written']); } finally { console.log = log; }+ };+ return { b, live, remoteClaims, write, lowerSource };+ }++ test('GST-2511: an agent that makes a confirmed private fence row world exposes nothing to remote fact reads until the owner accepts; later writes keep it private', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ const { b, live, remoteClaims, write } = await widenFixture(engine, 'people/kim-example', 'Kim keeps bees');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ const widened = await write([row(1, 'Kim lives in Turin'), row(2, 'Kim keeps bees')]);+ expect(widened.contested?.proposal_ref).toMatch(/^tp\d+$/);+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ // The agent's next write of the same fence keeps its contested row private and files nothing new.+ await write([row(1, 'Kim lives in Turin'), row(2, 'Kim keeps bees')], ' Updated.');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.visibility === 'world').map(r => r.fact)).toEqual(['Kim lives in Turin']);+ const proposals = await listTrustProposals(engine, { sourceId: b.sourceId });+ expect(proposals.map(p => p.id)).toEqual([parseTrustProposalRef(widened.contested.proposal_ref)!]);+ expect((await decideTrustProposal(engine, proposals[0]!.id, 'accept', owner)).status).toBe('accepted');+ expect(await remoteClaims()).toEqual([['Kim keeps bees', 'Kim lives in Turin'], ['Kim keeps bees', 'Kim lives in Turin']]);+ expect((await live()).find(r => r.fact === 'Kim keeps bees')).toMatchObject({ visibility: 'world', row_num: 2, trust_tier: 'user_confirmed' });+ expect((await live()).filter(r => r.fact === 'Kim keeps bees')).toHaveLength(1);+ // Undo returns the claim to private.+ expect((await decideTrustProposal(engine, proposals[0]!.id, 'undo', owner)).status).toBe('undone');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ }+ }), 90_000);++ test('GST-2511: on a repo-less brain (no managed persistence) the widening is stored private and the owner accept makes it world', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ const { b, live, remoteClaims, write } = await widenFixture(engine, 'people/noa-example', 'Noa keeps bees');+ await disposePersistenceConsumer(engine);+ await engine.executeRaw('UPDATE persistence_brain SET enabled=false WHERE singleton=1');+ try {+ expect(await engine.executeRaw('SELECT p.enabled, s.local_path FROM persistence_brain p, sources s WHERE p.singleton=1 AND s.id=$1', [b.sourceId]))+ .toEqual([{ enabled: false, local_path: null }]);+ const widened = await write([row(1, 'Kim lives in Turin'), row(2, 'Noa keeps bees')]);+ expect(widened.contested?.proposal_ref).toMatch(/^tp\d+$/);+ await write([row(1, 'Kim lives in Turin'), row(2, 'Noa keeps bees')], ' Again.');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.fact === 'Noa keeps bees').map(r => r.visibility)).toEqual(['private', 'private']);+ expect((await decideTrustProposal(engine, parseTrustProposalRef(widened.contested.proposal_ref)!, 'accept', owner)).status).toBe('accepted');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin', 'Noa keeps bees'], ['Kim lives in Turin', 'Noa keeps bees']]);+ expect(await listTrustProposals(engine, { sourceId: b.sourceId })).toEqual([]);+ } finally { await engine.executeRaw('UPDATE persistence_brain SET enabled=true WHERE singleton=1'); }+ }+ }), 90_000);++ test('GST-2511: restating a confirmed private claim world at another row number is stored private too; confirming the old side keeps it private', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ const { previewOwnerAction, applyOwnerAction } = await import('../src/core/trust/owner-actions.ts');+ for (const engine of engines) {+ const { b, live, remoteClaims, write } = await widenFixture(engine, 'people/ona-example', 'Ona keeps bees');+ const [trusted] = (await live()).filter(r => r.fact === 'Ona keeps bees');+ // The remote writer never saw row 2 (#2044 restores it); its copy of the claim lands at row 3.+ const copied = await write([row(1, 'Kim lives in Turin'), row(3, 'Ona keeps bees')]);+ expect(copied.contested?.proposal_ref).toMatch(/^tp\d+$/);+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.fact === 'Ona keeps bees').map(r => [r.row_num, r.visibility])).toEqual([[2, 'private'], [3, 'private']]);+ const ref = `f${trusted!.id}`;+ const preview = await previewOwnerAction(engine, { action: 'confirm', ref });+ const confirmed = await applyOwnerAction(engine, { action: 'confirm', ref }, { binding: preview.binding, confirmation: { via: 'tty' }, by: { kind: 'local_cli', id: 'owner-example' } });+ expect(confirmed).toMatchObject({ detail: { resolved_proposal: copied.contested.proposal_ref } });+ // The owner kept the private row; the agent restating the claim world again is contested again, never live world.+ await write([row(1, 'Kim lives in Turin'), row(4, 'Ona keeps bees')], ' Again.');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.fact === 'Ona keeps bees' && r.visibility === 'world')).toEqual([]);+ expect((await listTrustProposals(engine, { sourceId: b.sourceId, status: 'all' })).map(p => p.status)).toEqual(['rejected', 'pending']);+ }+ }), 90_000);++ test('GST-2511 review: the extract_facts reconcile does not widen a contested row the owner has not decided', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ for (const [claim, rows] of [['Pia keeps bees', (c: string) => [row(1, 'Kim lives in Turin'), row(2, c)]],+ ['Pia keeps hives', (c: string) => [row(1, 'Kim lives in Turin'), { ...row(3, c), source: 'chat-example' }]]] as const) {+ const { b, live, remoteClaims, write } = await widenFixture(engine, 'people/pia-example', claim);+ const widened = await write(rows(claim));+ expect(widened.contested?.proposal_ref).toMatch(/^tp\d+$/);+ await runExtractFacts(engine, { sourceId: b.sourceId, slugs: ['people/pia-example'] });+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.fact === claim && r.visibility === 'world')).toEqual([]);+ }+ }+ }), 90_000);++ test('GST-2511 review: accepting a widening the writer has since withdrawn (wrote the row private again) keeps the claim private', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ const { live, remoteClaims, write } = await widenFixture(engine, 'people/rae-example', 'Rae keeps bees');+ const as = (r: ReturnType<typeof row>, visibility: string) => ({ ...r, visibility });+ const widened = await write([row(1, 'Kim lives in Turin'), row(2, 'Rae keeps bees')]);+ await write([row(1, 'Kim lives in Turin'), as(row(2, 'Rae keeps bees'), 'private')], ' Withdrawn.');+ expect((await decideTrustProposal(engine, parseTrustProposalRef(widened.contested.proposal_ref)!, 'accept', owner)).status).toBe('accepted');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.fact === 'Rae keeps bees')).toEqual([expect.objectContaining({ visibility: 'private', row_num: 2, trust_tier: 'user_confirmed' })]);+ }+ }), 90_000);++ test('GST-2511 review: restating a claim the page already holds world is not a widening', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ const b = await brain(engine);+ const slug = 'people/sol-example';+ await run(b.local, 'put_page', { slug, content: page('Sol', body([row(1, 'Sol keeps bees'), { ...row(2, 'Sol keeps bees'), visibility: 'private' }])) });+ for (const r of await engine.executeRaw<{ id: number }>('SELECT id FROM facts WHERE source_id=$1 AND source_markdown_slug=$2', [b.sourceId, slug])) await confirmFact(b, Number(r.id));+ const current = await operationsByName.get_page.handler(b.remote, { slug, include_content: true }) as Record<string, any>;+ const added = await run(b.remote, 'put_page', { slug, content: page('Sol', body([row(1, 'Sol keeps bees'), row(3, 'Sol keeps bees')])), expected_revision: current.revision });+ expect(added.contested).toBeUndefined();+ expect(await listTrustProposals(engine, { sourceId: b.sourceId })).toEqual([]);+ expect(await engine.executeRaw('SELECT row_num, visibility FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 AND expired_at IS NULL ORDER BY row_num', [b.sourceId, slug]))+ .toEqual([{ row_num: 1, visibility: 'world' }, { row_num: 2, visibility: 'private' }, { row_num: 3, visibility: 'world' }]);+ }+ }), 90_000);++ test('GST-2511: rejecting the widening leaves the claim private, and a later agent write does not widen it', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ const { b, live, remoteClaims, write } = await widenFixture(engine, 'people/lee-example', 'Lee keeps bees');+ const widened = await write([row(1, 'Kim lives in Turin'), row(2, 'Lee keeps bees')]);+ expect((await decideTrustProposal(engine, parseTrustProposalRef(widened.contested.proposal_ref)!, 'reject', owner)).status).toBe('rejected');+ await write([row(1, 'Kim lives in Turin'), row(2, 'Lee keeps bees')], ' Again.');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).filter(r => r.fact === 'Lee keeps bees').map(r => r.visibility)).toEqual(['private', 'private']);+ expect((await listTrustProposals(engine, { sourceId: b.sourceId, status: 'all' })).map(p => p.status)).toEqual(['rejected']);+ }+ }), 90_000);++ test('GST-2511: a different claim written world at a confirmed private row is stored private until the owner accepts the replacement', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ const { b, live, remoteClaims, write, lowerSource } = await widenFixture(engine, 'people/max-example', 'Max keeps bees');+ // A remote writer never sees the private row, so its row at that number is renumbered as a new claim (#2044); a local agent-tier writer reads it.+ await lowerSource();+ const replaced = await write([row(1, 'Kim lives in Turin'), row(2, 'Max keeps honeybees')], '', 'local');+ expect(replaced.contested?.proposal_ref).toMatch(/^tp\d+$/);+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ await write([row(1, 'Kim lives in Turin'), row(2, 'Max keeps honeybees')], ' Again.', 'local');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin'], ['Kim lives in Turin']]);+ expect((await live()).find(r => r.fact === 'Max keeps honeybees')).toMatchObject({ visibility: 'private', row_num: 2, trust_tier: 'agent_written' });+ const id = parseTrustProposalRef(replaced.contested.proposal_ref)!;+ expect((await decideTrustProposal(engine, id, 'accept', owner)).status).toBe('accepted');+ expect(await remoteClaims()).toEqual([['Kim lives in Turin', 'Max keeps honeybees'], ['Kim lives in Turin', 'Max keeps honeybees']]);+ expect((await live()).map(r => r.fact).sort()).toEqual(['Kim lives in Turin', 'Max keeps honeybees']);+ expect(await listTrustProposals(engine, { sourceId: b.sourceId })).toEqual([]);+ }+ }), 90_000);});describe('guarded takes supersession and the takes gate', () => {