Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: redaction markers are no labeled credential (#7997); company sources keep db_only pages (#8014); db_only fail-closed follow-ups (#8015)
garrytan37014911e4ef
diff --git a/docs/guides/repair.md b/docs/guides/repair.mdindex 8e8f24ab93..37aec25d0c 100644--- a/docs/guides/repair.md+++ b/docs/guides/repair.md@@ -2562,7 +2562,8 @@ sync's history read did not finish, so it could not tell whether a commit heldthe file and kept the page; the provenance below reads the whole history.Reason `storage_invalid` (#8007) means `gbrain.yml`'s storage section did notload, declared `db_only` in a form that resolved no directory, or listed a-deprecated `supabase_only` next to canonical keys (ignored), so the sync+deprecated `supabase_only` next to canonical keys (ignored) whose directory+holds the page and is not also under `db_only`, so the synccould not tell whether the page is database-only and kept it: run`gbrain storage status`, fix `gbrain.yml`, commit it and sync again; the holdclears and the page is decided under the fixed config.diff --git a/docs/storage-tiering.md b/docs/storage-tiering.mdindex fed3ed6b4a..c56d5075c7 100644--- a/docs/storage-tiering.md+++ b/docs/storage-tiering.md@@ -35,7 +35,7 @@ storage:Path requirements:- Each directory must end with `/` for canonical form. The validator auto-normalizes missing trailing slashes (one-time info note shows what changed).-- A tier may also be a one-line flow list, `db_only: [media/x/, 'media/articles/']`. A flow list split over several lines, or a `db_only` key outside `storage:`, resolves no directory: `gbrain storage status` names it, and until it is fixed a managed sync keeps every live page whose file is gone (held as `file_drift` with reason `storage_invalid`) instead of deleting it, because it cannot tell which pages are database-only (#8007). A tier overlap holds them the same way, and so does a deprecated `supabase_only` list next to canonical keys, which canonical keys make gbrain ignore. `gbrain repair file-drift --prefer file` and `sync.apply_held_deletions` skip these pages while the config stays invalid. Fix `gbrain.yml`, commit it and sync again; the holds clear and each page is decided under the fixed config.+- A tier may also be a one-line flow list, `db_only: [media/x/, 'media/articles/']`. A flow list split over several lines, a nested list, an unquoted value holding a space (a missing comma: `[a/ b/]`), or a `db_only` key outside `storage:`, resolves no directory: `gbrain storage status` names it, and until it is fixed a managed sync keeps every live page whose file is gone (held as `file_drift` with reason `storage_invalid`) instead of deleting it, because it cannot tell which pages are database-only (#8007). A tier overlap holds them the same way. A deprecated `supabase_only` list next to canonical keys is ignored (canonical keys win), so the pages under its directories that `db_only` does not also list are held the same way until you move those directories under `db_only`; `gbrain storage status` names them. `gbrain repair file-drift --prefer file` and `sync.apply_held_deletions` skip these pages while the config stays invalid. Fix `gbrain.yml`, commit it and sync again; the holds clear and each page is decided under the fixed config.- A directory cannot appear in both tiers — that's a tier-overlap error and `loadStorageConfig` throws `StorageConfigError`. Edit `gbrain.yml` to remove the overlap and try again.- Any other key under `storage:` is ignored with a warning naming it (a typo such as `kep_db` used to be ignored silently).diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex a706949d2c..d80fca694b 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -47,4 +47,4 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: linksrc/core/search/evidence-delivery.ts 1755 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)src/commands/config.ts 1524 ratchet 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)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 1567 ratchet 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)+src/core/behavior-change-notice.ts 1570 ratchet 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)diff --git a/src/commands/storage.ts b/src/commands/storage.tsindex ad9cb87305..1270b387b9 100644--- a/src/commands/storage.ts+++ b/src/commands/storage.ts@@ -219,6 +219,7 @@ export async function getStorageStatus(): Promise<StorageStatusResult> {const config = repoPath ? loadStorageConfig(repoPath) : null;const warnings = config ? validateStorageConfig(config) : [];+ if (config?.ignored_db_only) warnings.push(`gbrain.yml lists the deprecated supabase_only next to canonical keys, which ignores it: ${config.ignored_db_only.join(', ')}. Move those directories under db_only and remove supabase_only. Until then sync keeps every page under them whose file is gone (#8007).`);if (repoPath && hasUnresolvedDbOnlyDeclaration(repoPath, config)) warnings.push('gbrain.yml declares storage.db_only but no directory resolved from it (a flow list split over lines, or the key outside storage:); list the directories in block style or as one line, db_only: [a/, b/]. Until then sync keeps every page whose file is gone (#8007).');const pagesByTier: PageCountsByTier = { db_tracked: 0, db_only: 0, unspecified: 0 };diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex f5f90d229c..526b711228 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1369,6 +1369,9 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.507.0', id: 'search_quotes_transcript_rows', text: '`search`, `query` and `assemble_evidence` now return a row from a conversation page (type `conversation`, what transcript imports write) with `quoted: "transcript"` and its text wrapped as a quoted excerpt: a line naming the page as source material, then a code fence. Tool-call and function-call JSON inside (Gemini `functionCall` included), and XML-style `function_calls`, `invoke`, `tool_use` and `tool_call` blocks, become `[tool call: <name>, arguments omitted]`. Under `return_unit: auto` an explicit `token_budget` pays for the fence, so a conversation-heavy result can return fewer or shorter rows. Stored pages, ranking, scores and other page types are unchanged; read `quoted` to tell these rows apart, and `get_page` for the text as stored.' },{ since: '0.60.511.0', id: 'storage_invalid_holds_8007', text: 'A managed sync no longer deletes a live page whose file is gone while gbrain.yml\'s storage section is invalid (tiers that overlap), declares `db_only` in a form that resolves no directory (a flow list split over lines, a key outside `storage:`), or lists a deprecated `supabase_only` next to canonical keys (which ignores it): it cannot tell which pages are database-only, so it keeps each such page and holds its path as `file_drift` with `meta.reason` `storage_invalid`. Run `gbrain storage status`, fix gbrain.yml, commit it and sync again; the holds clear and each page is decided under the fixed config. `gbrain repair file-drift --prefer file` and `sync.apply_held_deletions` skip these pages too.' },{ since: '0.60.511.0', id: 'storage_flow_lists_8007', text: 'gbrain.yml storage tiers written as a one-line flow list (`db_only: [media/x/, \'archive/\']`, likewise `db_tracked` and `keep_db`) now take effect; they used to resolve nothing. After upgrading, directories declared that way are treated as declared: sync adds `db_only` ones to .gitignore and publishes new pages there database-only, and `keep_db` ones get database-wins writes. An explicit `db_only: []` declares no directory and no longer makes the sync baseline commit refuse.' },+ { since: 'TBD', id: 'storage_ignored_dirs_8015', text: 'When gbrain.yml lists a deprecated `supabase_only` next to canonical keys (which ignores it), a managed sync now holds only the missing-file pages under the ignored directories `db_only` does not already cover, and deletes other missing-file pages as usual; it used to hold every missing-file page of the source. `gbrain storage status` now names those directories, and the deprecation warning no longer points to a `gbrain doctor --fix` rename that does not exist.' },+ { since: 'TBD', id: 'company_db_only_keep_8014', text: 'A company-brain source now keeps a live page under a declared `storage.db_only` directory when its file is not in the approved manifest, and keeps every such page while its gbrain.yml storage section is invalid, as other managed sources do; it used to delete them.' },+ { since: 'TBD', id: 'redaction_marker_not_credential_7997', text: 'The transcript `labeled_credential` detector no longer reads an importer redaction marker (`login **<REDACTED:user-pattern>**`) as a typed user/password pair, so a correctly redacted page clears `gbrain transcripts audit-secrets`; a password written beside a marker is still found. The audit detector version moves to 3, so `gbrain doctor` asks for a fresh audit once.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/persistence/source-storage.ts b/src/core/persistence/source-storage.tsindex 0872f47980..6dd9339fc5 100644--- a/src/core/persistence/source-storage.ts+++ b/src/core/persistence/source-storage.ts@@ -1,7 +1,7 @@import { statSync } from 'node:fs';import { join } from 'node:path';import { OperationError } from '../ops/contract.ts';-import { hasUnresolvedDbOnlyDeclaration, isDeclaredDbOnlySlug, loadStorageConfig, type StorageConfig } from '../storage-config.ts';+import { dbOnlyVerdict, hasUnresolvedDbOnlyDeclaration, isDeclaredDbOnlySlug, loadStorageConfig, type StorageConfig } from '../storage-config.ts';type Loaded = { version: string; config: StorageConfig | null } | { version: string; cause: unknown };// One parse per gbrain.yml version per source root: bulk scans and migrations@@ -46,8 +46,7 @@ function load(root: string): StorageConfig | null {*/export function sourceDbOnlyVerdict(root: string, slug: string): boolean | 'unknown' {try {- const config = load(root);- return isDeclaredDbOnlySlug(slug, config) || (config?.deprecated_db_only_ignored ? 'unknown' : false);+ return dbOnlyVerdict(slug, load(root));} catch {return 'unknown';}diff --git a/src/core/persistence/sync-discovery.ts b/src/core/persistence/sync-discovery.tsindex 972f72d485..539345e925 100644--- a/src/core/persistence/sync-discovery.ts+++ b/src/core/persistence/sync-discovery.ts@@ -533,11 +533,11 @@ export async function discoverManagedSync(engine: BrainEngine, opts: SyncOpts, cconst included = company.plan.manifest.filter(entry => entry.disposition === 'included');const present = new Set(included.map(entry => syncOriginPath(entry.path)));for (const entry of included) entries.set(entry.path, { path: entry.path, sourcePath: entry.path, action: 'import', working: false, slug: entry.page!.slug });- const pages = await engine.executeRaw<{ source_path: string }>('SELECT source_path FROM pages WHERE source_id=$1 AND deleted_at IS NULL AND source_path IS NOT NULL', [sourceId]);+ const pages = await engine.executeRaw<{ source_path: string; slug: string }>('SELECT source_path, slug FROM pages WHERE source_id=$1 AND deleted_at IS NULL AND source_path IS NOT NULL', [sourceId]);assertDistinctSyncOrigins([...present, ...pages.map(page => page.source_path)]);for (const page of pages) {const origin = syncOriginPath(page.source_path);- if (!present.has(origin)) entries.set(origin, { path: origin, sourcePath: origin, action: 'delete', working: false });+ if (!present.has(origin)) entries.set(origin, { path: origin, sourcePath: origin, action: 'delete', working: false, slug: page.slug });}}const selected = [...entries.values()].sort((a, b) => a.action.localeCompare(b.action) || a.path.localeCompare(b.path));@@ -675,7 +675,7 @@ export async function discoverManagedSync(engine: BrainEngine, opts: SyncOpts, celse winner.renameHeld = held;}}- if (!company) Object.assign(discovered, retireDbOnlyDeletes(root, selected, retired));+ Object.assign(discovered, retireDbOnlyDeletes(root, selected, retired));if (retired.size) discovered.entries = selected.filter(entry => !retired.has(entry));if (collisions.length) discovered.slugCollisions = collisions;// Identities and origin collisions were resolved over the whole target above; only the frozen manifest is cut.diff --git a/src/core/persistence/sync-pass.ts b/src/core/persistence/sync-pass.tsindex 9e24a660b3..fb090a4462 100644--- a/src/core/persistence/sync-pass.ts+++ b/src/core/persistence/sync-pass.ts@@ -24,7 +24,7 @@ import { isReservedSkillBundlePath } from '../skill-reserved-paths.ts';import { resolveSlugRootMode } from '../sync-anchor.ts';import { resolveSlugForPath } from '../sync.ts';import { join } from 'node:path';-import { hasUnresolvedDbOnlyDeclaration, isDeclaredDbOnlySlug, isKeepDbSlug, loadStorageConfig } from '../storage-config.ts';+import { dbOnlyVerdict, hasUnresolvedDbOnlyDeclaration, isDeclaredDbOnlySlug, isKeepDbSlug, loadStorageConfig } from '../storage-config.ts';import { loadActivePackForEngine } from '../schema-pack/engine-resolution.ts';import { currentCompanyBrainSync, getCompanyBrainProfile } from '../company-brain/profile.ts';import { sha256 } from './digest.ts';@@ -810,7 +810,7 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: stepisodeUnsatisfied: input.pass ? !!input.pass.episodeFullId && live && (record ? pages.fullEpisode[at!] : undefined) !== input.pass.episodeFullId: input.full === true && live,derivedCurrent: live && pages.derivedCurrent(at!), fullObligation: input.pass ? !!input.pass.episodeFullId : input.full === true,- keepDb: !mirror && keepDbPrefixes.length > 0 && row && isKeepDbSlug(pages.slug[at!]!, keepDbPrefixes), dbOnly: row && (isDeclaredDbOnlySlug(pages.slug[at!]!, storage) || (dbOnlyUnknown ? 'unknown' : false)),+ keepDb: !mirror && keepDbPrefixes.length > 0 && row && isKeepDbSlug(pages.slug[at!]!, keepDbPrefixes), dbOnly: row && (dbOnlyUnknown ? isDeclaredDbOnlySlug(pages.slug[at!]!, storage) || 'unknown' : dbOnlyVerdict(pages.slug[at!]!, storage)),openWork: row && open.pageIds.has(Number(pages.id[at!])) || open.origins.has(origin),};return { state, ...(row ? { at } : {}), ...(legacyPageless ? { legacyPageless } : {}) };@@ -917,7 +917,7 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: st}return { sourceId, incarnation, root, gitRoot, scope, slugMode, mode, strict, head, baselineCommit, full: input.full === true, kind: kind.kind, kindBlockers: kind.blockers,heldRenames: holds.flatMap(hold => hold.meta.rename_from ? [{ path: toGit(hold.path), rename: hold.meta.rename_from }] : []),- releasableHolds: holds.filter(hold => !domain.has(toGit(hold.path)) || (!dbOnlyUnknown && hold.code === 'file_drift' && hold.meta.reason === 'storage_invalid')).map(hold => hold.path),+ releasableHolds: holds.filter(hold => !domain.has(toGit(hold.path)) || (!dbOnlyUnknown && hold.code === 'file_drift' && hold.meta.reason === 'storage_invalid' && (hold.slug === null || dbOnlyVerdict(hold.slug, storage) !== 'unknown'))).map(hold => hold.path),deletionCandidates: deletionCandidates(holds, path => domain.has(path) && !tree.has(path)&& !(mode === 'working' && (untracked.has(path) || index.has(path))) && !readPresent(root, path, scope), toGit),paths, reconcilable, ...(colon.refusals.size ? { fileRefusals: [...colon.refusals.values()] } : {}), timings_ms: timings, statements: statements + attestationStatements + 3,@@ -968,7 +968,7 @@ async function readLevelSettings(engine: BrainEngine, context: ManagedSyncContexreturn { slugMode: settled(slugModeRead), exclude: settled(excludeRead), pack: settled(packRead), mirror: settled(mirrorRead), workingConfig: settled(workingRead),metafilePages: settled(metafilePagesRead), strict: context.source.config?.canonical === 'git', strategy: input.pass?.strategy ?? (context.source.config?.strategy as string | undefined) ?? 'markdown',includeHidden: [...new Set([...input.pass?.includeHidden ?? [], ...(settled(includeHiddenRead) ?? '').split(/[\n,]/).map(v => v.trim()).filter(Boolean)].map(v => v.endsWith('/') ? `${v}**` : v))],- keepDbPrefixes: storage?.keep_db ?? [], storage, dbOnlyUnknown: storageInvalid || storage?.deprecated_db_only_ignored === true || hasUnresolvedDbOnlyDeclaration(root, storage) };+ keepDbPrefixes: storage?.keep_db ?? [], storage, dbOnlyUnknown: storageInvalid || hasUnresolvedDbOnlyDeclaration(root, storage) };}/** A failed mark, proof or delta read: the round reads again without them (it aborted a Postgres snapshot). */diff --git a/src/core/secret-scan-labeled.ts b/src/core/secret-scan-labeled.tsindex 45b2181c10..105e6528be 100644--- a/src/core/secret-scan-labeled.ts+++ b/src/core/secret-scan-labeled.ts@@ -91,6 +91,15 @@ export const LABELED_CREDENTIAL_PATTERNS: readonly LabeledPattern[] = [{ form: 'single', continuation: 'single', source: `(^\\s{0,8})(${BARE_VALUE})(?=[.,;]?\\s*$)` },];+/**+ * #7997: an importer redaction marker (`<REDACTED:kind>`) with its colon swapped, the same length, so the label+ * patterns read it as one word. Its colon used to split it into a claimed `user:pass` pair, while a credential written+ * beside a marker (`login <REDACTED:user-pattern> / s3cret!`) still matches.+ */+export function neutralizeRedactionMarkers(line: string): string {+ return line.includes('<REDACTED:') ? line.replace(/<REDACTED:(?=[A-Za-z0-9_-]{1,64}>)/g, '<REDACTED_') : line;+}+/** Cheap gate before the label regexes run on a line. */export const LABELED_PRECHECK_RE = /pass|pwd|\bpw\b|log-?in|cred/i;diff --git a/src/core/secret-scan.ts b/src/core/secret-scan.tsindex 8e29e51fbd..c62c7bbeda 100644--- a/src/core/secret-scan.ts+++ b/src/core/secret-scan.ts@@ -38,6 +38,7 @@ import {danglingLabel,labeledEchoEligible,labeledValueIsCredential,+ neutralizeRedactionMarkers,newTableScanState, tableCredentialCells,} from './secret-scan-labeled.ts';@@ -130,6 +131,8 @@ interface CompiledPattern {validate?: (value: string, head: string) => boolean;/** Runs only on the line after one that ends in a dangling credential label of this form. */continuation?: 'single' | 'pair';+ /** The text the regex reads instead of the line, the same length (offsets and reported values come from the line). */+ subject?: (line: string) => string;}interface CorePattern {@@ -759,6 +762,7 @@ function buildPatterns(opts: ScanOpts): CompiledPattern[] {re: new RegExp(p.source, 'gi'),...(p.continuation ? { continuation: p.continuation } : { precheck: (line: string) => LABELED_PRECHECK_RE.test(line) }),validate: (value: string, head: string) => labeledValueIsCredential(value, p.form, head),+ subject: neutralizeRedactionMarkers,});}}@@ -955,14 +959,15 @@ function scanInternal(text: string, opts: ScanOpts): RawHit[] {if (p.continuation && p.continuation !== dangling) continue;if (p.precheck && !p.precheck(line)) continue;p.re.lastIndex = 0;+ const subject = p.subject ? p.subject(line) : line;let m: RegExpExecArray | null;for (;;) {if (work) work.regexExecs++;- m = p.re.exec(line);+ m = p.re.exec(subject);if (m === null) break;if (work) work.candidates[p.name] = (work.candidates[p.name] ?? 0) + 1;- const value = m[2];const start = m.index + m[1].length;+ const value = subject === line ? m[2] : line.slice(start, start + m[2].length);const end = start + value.length;// Zero-width safety: never loop forever on a pathological pattern.if (m[0].length === 0) p.re.lastIndex++;@@ -975,7 +980,7 @@ function scanInternal(text: string, opts: ScanOpts): RawHit[] {}if (p.validate) {if (work) work.validateCalls++;- if (!p.validate(value, m[1])) continue;+ if (!p.validate(value, subject === line ? m[1] : line.slice(m.index, start))) continue;}if (!taken) {taken = new Uint8Array(line.length);diff --git a/src/core/storage-config.ts b/src/core/storage-config.tsindex 5e3e5d8f1a..7b243aa651 100644--- a/src/core/storage-config.ts+++ b/src/core/storage-config.ts@@ -18,10 +18,11 @@ export interface StorageConfig {*/keep_db?: string[];/**- * #8007: a deprecated `supabase_only` list sat next to canonical keys and was ignored (canonical wins), so which pages- * are database-only is ambiguous; a caller deciding whether a missing file deletes its page holds it instead.+ * #8007/#8015: the directories of a deprecated `supabase_only` list that sat next to canonical keys and was ignored+ * (canonical wins), minus those `db_only` already covers. Whether a page under one is database-only is ambiguous, so+ * a caller deciding whether its missing file deletes it holds it instead (`dbOnlyVerdict`).*/- deprecated_db_only_ignored?: true;+ ignored_db_only?: string[];}export type StorageTier = 'db_tracked' | 'db_only' | 'unspecified';@@ -112,9 +113,10 @@ function parseStorageYaml(content: string, unknown: string[] = []): RawStorage |currentList = key as keyof RawStorage;// Inline flow list on one line: `db_only: []` or `db_only: [dir/, 'other/']`.const flow = /^\[(.*)\]$/.exec(indented.slice(colon + 1).trim());- if (flow && !/[[\]]/.test(flow[1]!)) {- const values = [...flow[1]!.matchAll(/\s*("[^"]*"|'[^']*'|[^,]*)\s*(?:,|$)/g)].map((m) => m[1]!.replace(/^["']|["']$/g, '').trim()).filter(Boolean);- raw[currentList] = [...(raw[currentList] ?? []), ...values];+ // A nested list, or an unquoted value holding whitespace (a missing comma: `[a/ b/]`), resolves nothing (#8015).+ const tokens = flow && !/[[\]]/.test(flow[1]!) ? [...flow[1]!.matchAll(/\s*("[^"]*"|'[^']*'|[^,]*)\s*(?:,|$)/g)].map((m) => m[1]!.trim()) : null;+ if (tokens && !tokens.some((token) => !/^["']/.test(token) && /\s/.test(token))) {+ raw[currentList] = [...(raw[currentList] ?? []), ...tokens.map((token) => token.replace(/^["']|["']$/g, '')).filter(Boolean)];}continue;}@@ -132,7 +134,7 @@ function parseStorageYaml(content: string, unknown: string[] = []): RawStorage |* Resolution order (per plan eng-review pass 2 finding #2):* 1. If canonical keys present, use them.* 2. Else if deprecated keys present, map to canonical AND emit a- * once-per-process deprecation warning suggesting `gbrain doctor --fix`.+ * once-per-process deprecation warning asking for a rename by hand.* 3. If both are present, canonical wins. Deprecated keys are ignored* with a stronger warning (the user is mid-migration).*@@ -156,13 +158,12 @@ function normalizeStorageConfig(raw: RawStorage): StorageConfig {console.warn(`Warning: ${which} in gbrain.yml is deprecated and ignored ` +`(canonical keys db_tracked/db_only are present). ` +- `Remove the deprecated keys, or run \`gbrain doctor --fix\`.`,+ `Move their directories under db_tracked / db_only by hand and remove them (see docs/storage-tiering.md).`,);} else {console.warn(`Warning: ${which} in gbrain.yml is deprecated. ` +- `Rename to db_tracked / db_only — see docs/storage-tiering.md. ` +- `Run \`gbrain doctor --fix\` for an automated rename.`,+ `Rename them to db_tracked / db_only by hand — see docs/storage-tiering.md.`,);}}@@ -173,7 +174,7 @@ function normalizeStorageConfig(raw: RawStorage): StorageConfig {db_tracked: raw.db_tracked ?? [],db_only: raw.db_only ?? [],...keep,- ...(raw.supabase_only?.length ? { deprecated_db_only_ignored: true as const } : {}),+ ...(raw.supabase_only?.length ? { ignored_db_only: raw.supabase_only } : {}),};}@@ -355,7 +356,7 @@ export function normalizeAndValidateStorageConfig(input: StorageConfig): Storage}return { db_tracked: tracked.normalized, db_only: dbonly.normalized, ...(keep ? { keep_db: keep.normalized } : {}),- ...(input.deprecated_db_only_ignored ? { deprecated_db_only_ignored: true as const } : {}) };+ ...ignoredDbOnly(input.ignored_db_only, dbonly.normalized) };}/**@@ -391,6 +392,21 @@ export function isDbOnly(slug: string, config: StorageConfig): boolean {* `effectiveDbOnlyDirs`, issue #3766). Only declared dirs count: the* derive-phase defaults may be file-backed on some brains.*/+function ignoredDbOnly(ignored: string[] | undefined, dbOnly: string[]): { ignored_db_only?: string[] } {+ const uncovered = (ignored ?? []).map((dir) => (dir.endsWith('/') ? dir : dir + '/'))+ .filter((dir) => !dbOnly.some((declared) => dir.toLowerCase() === declared.toLowerCase() || matchesTierDir(dir.toLowerCase(), declared.toLowerCase())));+ return uncovered.length ? { ignored_db_only: uncovered } : {};+}++/**+ * #8007/#8015: whether a page slug is database-only under this config, for a delete decision: true under a declared+ * db_only dir, `unknown` under an ignored deprecated `supabase_only` dir that db_only does not cover, false otherwise.+ */+export function dbOnlyVerdict(slug: string, config: StorageConfig | null): boolean | 'unknown' {+ if (isDeclaredDbOnlySlug(slug, config)) return true;+ return config?.ignored_db_only?.some((dir) => matchesTierDir(slug, dir.toLowerCase())) ? 'unknown' : false;+}+export function isDeclaredDbOnlySlug(slug: string, config: StorageConfig | null): boolean {return config?.db_only.some((dir) => matchesTierDir(slug, dir.toLowerCase())) ?? false;}diff --git a/src/core/transcripts/secret-audit.ts b/src/core/transcripts/secret-audit.tsindex d514c6f27e..dba5017108 100644--- a/src/core/transcripts/secret-audit.ts+++ b/src/core/transcripts/secret-audit.ts@@ -17,7 +17,7 @@ import type { BrainEngine } from '../engine.ts';import { scanText } from '../secret-scan.ts';/** Bump when the transcript-lane detectors change, so doctor asks for a fresh audit. */-export const TRANSCRIPT_SECRET_AUDIT_VERSION = 2;+export const TRANSCRIPT_SECRET_AUDIT_VERSION = 3;export const TRANSCRIPT_SECRET_AUDIT_KEY = 'transcripts.secret_audit';const BATCH = 25;const LINES_PER_PAGE = 20;diff --git a/test/company-brain-runtime.test.ts b/test/company-brain-runtime.test.tsindex d094294a79..0dd5d634e5 100644--- a/test/company-brain-runtime.test.ts+++ b/test/company-brain-runtime.test.ts@@ -262,3 +262,28 @@ for (const managed of [false, true]) describe(`company source lifecycle ${manage}}), 120_000);});++describe('#8014: a company source keeps database-only pages its manifest lacks', () => {+ const cases: Array<[string, string, { kept: boolean; stray: boolean }]> = [+ ['a declared db_only page stays and a stray page outside db_only is deleted', 'storage:\n db_only: [archive/]\n', { kept: true, stray: false }],+ ['an invalid gbrain.yml (tiers that overlap) keeps every page whose file is missing', 'storage:\n db_only:\n - archive/\n db_tracked:\n - archive/\n', { kept: true, stray: true }],+ ];+ for (const [name, yml, expected] of cases) test(name, async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const engine of engines) {+ await engine.executeRaw('UPDATE persistence_brain SET enabled=true WHERE singleton=1');+ const root = await fixture();+ const sourceId = `company-${randomUUID().slice(0, 8)}`;+ const input = { brainId: 'company-example', sourceId, path: root, plan: await inspectCompanyBrain({ path: root, profile: 'company-brain' }), remote: false };+ expect((await connectCompanyBrain(engine, input)).ok).toBe(true);+ for (const slug of ['archive/kept', 'notes/stray']) {+ await engine.transaction(tx => withCoordinatedWrite(tx, [sourceId], () => tx.putPage(slug, { type: 'note', title: slug, compiled_truth: 'Database-only body.', timeline: '' }, { sourceId }), TEST_WRITE_ATTRIBUTION));+ await engine.executeRaw('UPDATE pages SET source_path=$1 WHERE source_id=$2 AND slug=$3', [`${slug}.md`, sourceId, slug]);+ }+ const live = async (slug: string) => (await engine.executeRaw<{ live: boolean }>('SELECT deleted_at IS NULL AS live FROM pages WHERE source_id=$1 AND slug=$2', [sourceId, slug]))[0]?.live;+ writeFileSync(join(root, 'gbrain.yml'), yml);+ git(root, 'add', '.'); git(root, 'commit', '-qm', 'Synthetic storage tiers');+ await performSync(engine, { sourceId });+ expect({ kept: await live('archive/kept'), stray: await live('notes/stray') }).toEqual(expected);+ }+ }), 120_000);+});diff --git a/test/secret-scan-redaction-marker-7997.test.ts b/test/secret-scan-redaction-marker-7997.test.tsnew file mode 100644index 0000000000..e3e75081b9--- /dev/null+++ b/test/secret-scan-redaction-marker-7997.test.ts@@ -0,0 +1,80 @@+/**+ * #7997: the transcript importer replaces what it removes with `<REDACTED:kind>` (a user pattern becomes+ * `<REDACTED:user-pattern>`). The labeled_credential pair pattern split that marker at its colon and claimed+ * `login **<REDACTED:user-pattern>**` as a user/password pair, so a correctly redacted page never cleared+ * `gbrain transcripts audit-secrets`, and the pair match swallowed a real password written after the marker. Now:+ * - a marker after a credential label is never a credential, in any label form;+ * - a credential written beside a marker is still claimed, and the marker is left as written;+ * - re-redacting a redacted transcript changes nothing, and the audit reports zero pages for it (PGLite).+ * Credential values are synthetic. Contributed by @Masashi-Ono0611 (#7999, superseded).+ */+import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import { redactFindings, scanText } from '../src/core/secret-scan.ts';+import { redactSession } from '../src/core/transcripts/render.ts';+import { auditTranscriptSecrets } from '../src/core/transcripts/secret-audit.ts';+import type { ParsedSession } from '../src/core/transcripts/types.ts';+import { resetPgliteState } from './helpers/reset-pglite.ts';++const PW = ['Tr0ub4', 'dor&3x'].join('');+const LANE = { highEntropy: true, labeledCredentials: true };++const MARKERS: Array<[string, string]> = [+ ['a user-pattern marker after a bold login label (the reported page line)', 'login **<REDACTED:user-pattern>**'],+ ['a marker after a delimited login label', 'login: <REDACTED:labeled_credential>'],+ ['a marker after a credentials label', 'credentials <REDACTED:user-pattern>'],+ ['a bold marker after creds:', 'creds: **<REDACTED:secret>**'],+ ['a marker after a password label', 'password: <REDACTED:labeled_credential>'],+ ['a marker pair joined by a colon', 'login <REDACTED:user-pattern>:<REDACTED:user-pattern>'],+ ['a marker pair joined by a slash', 'login <REDACTED:user-pattern> / <REDACTED:labeled_credential>'],+];++const BESIDE: Array<[string, string]> = [+ ['a password after a slash beside a bold marker user', `login **<REDACTED:user-pattern>** / ${PW}`],+ ['a password after a slash beside a marker user', `login <REDACTED:user-pattern> / ${PW}`],+ ['a password right after a marker user and colon', `login <REDACTED:user-pattern>:${PW}`],+ ['a password label after a marker on the same line', `<REDACTED:user-pattern> password: ${PW}`],+ ['a login pair before a marker on the same line', `login alice-example / ${PW} <REDACTED:secret>`],+];++describe('#7997: importer redaction markers and labeled_credential', () => {+ for (const [name, line] of MARKERS) test(`${name} is no credential`, () => {+ expect(scanText(line, LANE)).toEqual([]);+ expect(redactFindings(line, LANE).text).toBe(line);+ });++ for (const [name, line] of BESIDE) test(`${name} is still claimed; the marker stays as written`, () => {+ expect(scanText(line, LANE).map(f => f.pattern)).toEqual(['labeled_credential']);+ const out = redactFindings(line, LANE).text;+ expect(out).not.toContain(PW);+ for (const marker of line.match(/<REDACTED:[a-z_-]+>/g) ?? []) expect(out).toContain(marker);+ });++ test('re-redacting an imported transcript that already holds markers changes nothing', () => {+ const session = (text: string): ParsedSession => ({ meta: { harness: 'codex', sessionId: 'marker-0001', startedAt: '2026-10-30T09:00:00.000Z' },+ messages: [{ role: 'user', timestamp: '2026-10-30T09:00:00.000Z', text }] });+ const patterns = [{ regex: /alice-example \/ [^\s*]+/g, source: 'alice-example' }];+ const first = redactSession(session(`login **alice-example / ${PW}**`), { patterns }).session.messages[0]!.text;+ expect(first).not.toContain(PW);+ expect(first).toContain('<REDACTED:');+ const again = redactSession(session(first), { patterns });+ expect(again.redactionCount).toBe(0);+ expect(again.session.messages[0]!.text).toBe(first);+ });+});++describe('#7997: audit-secrets on a redacted corpus', () => {+ let engine: PGLiteEngine;+ beforeAll(async () => { engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); });+ afterAll(async () => { await engine.disconnect(); });+ beforeEach(async () => { await resetPgliteState(engine); });+ const conversation = (slug: string, body: string) => engine.putPage(slug, { type: 'conversation', title: 'session', compiled_truth: body,+ frontmatter: { transcript_import: { harness: 'codex', session_id: slug } } });++ test('a page holding only markers is not affected; a real password beside a marker still is', async () => {+ await conversation('conversations/sessions/2026-10-30-codex-aaaaaaaaaaaa', MARKERS.map(([, line]) => line).join('\n'));+ expect(await auditTranscriptSecrets(engine)).toMatchObject({ pages_scanned: 1, pages_affected: 0, hits_total: 0 });+ await conversation('conversations/sessions/2026-10-30-codex-bbbbbbbbbbbb', `intro\n${BESIDE[0]![1]}`);+ expect(await auditTranscriptSecrets(engine)).toMatchObject({ pages_scanned: 2, pages_affected: 1, hits_total: 1, by_pattern: { labeled_credential: 1 } });+ });+});diff --git a/test/storage-config.test.ts b/test/storage-config.test.tsindex 38cde61933..63d6dfa1b8 100644--- a/test/storage-config.test.ts+++ b/test/storage-config.test.ts@@ -11,6 +11,7 @@ import {normalizeAndValidateStorageConfig,StorageConfigError,isDeclaredDbOnlySlug,+ dbOnlyVerdict,hasUnresolvedDbOnlyDeclaration,__resetMissingStorageWarning,} from '../src/core/storage-config.ts';@@ -193,6 +194,11 @@ describe('loadStorageConfig — real-disk loader', () => {try {writeFileSync(join(tmp, 'gbrain.yml'), "storage:\n db_only: ['a, b/', c/]\n");expect(loadStorageConfig(tmp)!.db_only).toEqual(['a, b/', 'c/']);+ writeFileSync(join(tmp, 'gbrain.yml'), "storage:\n db_only: [a/ b/]\n");+ expect(loadStorageConfig(tmp)?.db_only ?? []).toEqual([]);+ expect(hasUnresolvedDbOnlyDeclaration(tmp, loadStorageConfig(tmp))).toBe(true);+ writeFileSync(join(tmp, 'gbrain.yml'), "storage:\n db_only: ['my notes/', c/]\n");+ expect(loadStorageConfig(tmp)!.db_only).toEqual(['my notes/', 'c/']);writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n db_only: [[a/]]\n');expect(loadStorageConfig(tmp)?.db_only ?? []).toEqual([]);expect(hasUnresolvedDbOnlyDeclaration(tmp, loadStorageConfig(tmp))).toBe(true);@@ -201,10 +207,14 @@ describe('loadStorageConfig — real-disk loader', () => {}});- test('#8007: a deprecated supabase_only list ignored next to canonical keys is flagged, so delete decisions treat db_only as unknown', () => {+ test('#8007/#8015: the dirs of a deprecated supabase_only list ignored next to canonical keys, minus those db_only covers, are unknown to delete decisions', () => {try {writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n db_only: [private/]\n supabase_only:\n - archive/\n');- expect(loadStorageConfig(tmp)).toEqual({ db_tracked: [], db_only: ['private/'], deprecated_db_only_ignored: true });+ const config = loadStorageConfig(tmp);+ expect(config).toEqual({ db_tracked: [], db_only: ['private/'], ignored_db_only: ['archive/'] });+ expect([dbOnlyVerdict('private/x', config), dbOnlyVerdict('archive/x', config), dbOnlyVerdict('notes/x', config)]).toEqual([true, 'unknown', false]);+ writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n db_only: [archive/, private/]\n supabase_only:\n - archive/\n - private/deep/\n');+ expect(loadStorageConfig(tmp)).toEqual({ db_tracked: [], db_only: ['archive/', 'private/'] });writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n db_only: [private/]\n');expect(loadStorageConfig(tmp)).toEqual({ db_tracked: [], db_only: ['private/'] });writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n supabase_only:\n - archive/\n');diff --git a/test/storage-pglite.test.ts b/test/storage-pglite.test.tsindex 2ab1f0c2e4..08c840c086 100644--- a/test/storage-pglite.test.ts+++ b/test/storage-pglite.test.ts@@ -118,6 +118,19 @@ describe('Storage tiering on PGLite — full lifecycle (D8 + D4)', () => {}});+ test('#8015: getStorageStatus names a deprecated supabase_only list canonical keys ignore, only its uncovered dirs', async () => {+ try {+ writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n db_only: [media/x/]\n supabase_only:\n - media/x/\n - archive/\n');+ const status = await getStorageStatus(engine, tmp);+ expect(status.warnings.filter(w => w.includes('deprecated supabase_only'))).toHaveLength(1);+ expect(status.warnings.find(w => w.includes('deprecated supabase_only'))).toContain('ignores it: archive/.');+ writeFileSync(join(tmp, 'gbrain.yml'), 'storage:\n db_only: [media/x/, archive/]\n supabase_only:\n - archive/\n');+ expect((await getStorageStatus(engine, tmp)).warnings.some(w => w.includes('deprecated supabase_only'))).toBe(false);+ } finally {+ cleanup();+ }+ });+test('getStorageStatus scopes page checks to the source that owns the repo path (#4763)', async () => {try {writeGbrainYml();diff --git a/test/sync-storage-invalid-8007.test.ts b/test/sync-storage-invalid-8007.test.tsindex e4aa3fedf0..59a4af834f 100644--- a/test/sync-storage-invalid-8007.test.ts+++ b/test/sync-storage-invalid-8007.test.ts@@ -1,7 +1,8 @@/*** #8007: a managed sync decides whether a page whose file is gone is deleted. A page under a declared storage.db_only dir* is kept (#7324), so when gbrain.yml's storage section cannot be read (tiers that overlap), declares db_only in a form- * that resolves no directory (a flow list split over lines), or ignores a deprecated supabase_only list next to canonical keys, sync cannot tell which pages are database-only. On a real+ * that resolves no directory (a flow list split over lines), or ignores a deprecated supabase_only list next to canonical keys+ * (#8015: then only pages under its directories db_only does not cover), sync cannot tell which pages are database-only. On a real* managed brain (PGLite, and Postgres through the E2E wrapper), this protects:* - the frozen discovery manifest drops every deletion and names it in storageInvalidKept;* - a managed sync, incremental and full, deletes nothing: each missing-file page is held (file_drift, reason@@ -58,7 +59,6 @@ const storageHolds = async (engine: BrainEngine) => ((await readGitHoldListing(econst INVALID = [['tiers that overlap (the storage config cannot load)', 'storage:\n db_only:\n - library/\n db_tracked:\n - library/\n'],['a db_only flow list split over lines (resolves no directory)', 'storage:\n db_only: [library/,\n archive/]\n'],- ['a deprecated supabase_only list next to a canonical key (ignored)', 'storage:\n db_only: [archive/]\n supabase_only:\n - library/\n'],] as const;for (const backend of testBackends()) describe(`[${backend}] #8007: an invalid gbrain.yml never turns a missing file into a deletion`, () => {@@ -101,6 +101,33 @@ for (const backend of testBackends()) describe(`[${backend}] #8007: an invalid gexpect(await storageHolds(engine)).toEqual([]);}, { databaseUrl, setup }), 240_000);+ test('#8015: an ignored deprecated supabase_only list holds only pages under its uncovered dirs; one db_only covers holds nothing', () => managedBrain(async ({ engine, root }) => {+ expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');+ invalidateAndUntrack(root, 'storage:\n db_only: [archive/]\n supabase_only:\n - library/\n');+ const discovered = await discoverManagedSync(engine, OPTS);+ expect(discovered.entries.filter(entry => entry.action === 'delete').map(entry => entry.path)).toEqual(['notes/control.md']);+ expect([...discovered.storageInvalidKept ?? []].sort()).toEqual(['library/card-cached.md', 'library/card-gone.md']);+ await performManagedSync(engine, OPTS);+ await performManagedSync(engine, { ...OPTS, full: true });+ for (const slug of CARDS) expect({ slug, live: await live(engine, slug) }).toEqual({ slug, live: true });+ expect(await live(engine, 'notes/control')).toBe(false);+ expect(await storageHolds(engine)).toEqual(['library/card-cached.md', 'library/card-gone.md']);+ writeFileSync(join(root, 'gbrain.yml'), 'storage:\n db_only: [archive/, library/]\n supabase_only:\n - library/\n');+ commit(root, 'cover the deprecated dir');+ await performManagedSync(engine, OPTS);+ await performManagedSync(engine, { ...OPTS, full: true });+ for (const slug of CARDS) expect({ slug, live: await live(engine, slug) }).toEqual({ slug, live: true });+ expect(await storageHolds(engine)).toEqual([]);+ // #8015: --prefer file never reaches a page under a declared db_only dir: it publishes database-only, so it has no drift.+ const logger = { info() {}, warn() {}, error() {} };+ const repair = await withVerifiedLocalRegistration(engine, await registerLocalWriter(engine, 'cli'), async () =>+ (await repairRunner(engine, { apply: false, logger })).run('file-drift', await resolveRepairScope(engine, 'default'),+ { explicit: true, sourceFlag: 'default', slugs: ['library/card-gone'], prefer: 'file' }));+ expect(repair.details!.pages).toEqual([]);+ expect(repair.listing!.map(row => row.class)).toEqual(['no_drift']);+ expect(await live(engine, 'library/card-gone')).toBe(true);+ }, { databaseUrl, setup }), 240_000);+test('sync.apply_held_deletions never deletes a held missing-file page while gbrain.yml is invalid, a hold with no reason included', () => managedBrain(async ({ engine, root }) => {expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');invalidateAndUntrack(root, INVALID[0][1]);