Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(access): A2 guard and plan fixes — policy-git spawns use gitChildEnv and run async off the sync path, folder rules load bounded YAML, deletion inventory classifies the folder-policy columns, v282 functions pin pg_temp, coverage check inlined for the vector walk (GBRA-218)
garrytanb1cb468af94d
diff --git a/src/commands/doctor/checks/folder-access.ts b/src/commands/doctor/checks/folder-access.tsindex 25062339c3..050a159adf 100644--- a/src/commands/doctor/checks/folder-access.ts+++ b/src/commands/doctor/checks/folder-access.ts@@ -76,7 +76,7 @@ async function invalid(engine: BrainEngine, sources: string[]): Promise<Check> {const first = found[0]!;return { name, status: 'fail', details: { sources: found },message: `The folder-rule file of ${found.map(f => `${f.source} does not validate (reads as nobody: ${f.prefixes.join(', ')})`).join('; ')}. The last applied rules stay in force. Fix .gbrain/access.yml, commit it and sync the source.`,- fix: { ...agentFix(['gbrain', 'access', 'rule', 'list', '--source', first.source, '--json'], 'Lists each problem in the file with its line, read-only; fix the file, commit it with gbrain git commit-push and run gbrain sync --source <id> --no-pull.', name,+ fix: { ...agentFix(['gbrain', 'access', 'rule', 'list', '--source', first.source, '--json'], 'Lists each problem in the file with its line, read-only. Fix the file and commit it with gbrain git commit-push; then run gbrain sync --source <id> --no-pull.', name,{ docs: 'docs/guides/write-refusals.md#access_policy_invalid' }), verify: doctorVerify(name) } };}diff --git a/src/core/access/folder-rules.ts b/src/core/access/folder-rules.tsindex 67f2b4cdf2..318795d6f3 100644--- a/src/core/access/folder-rules.ts+++ b/src/core/access/folder-rules.ts@@ -26,7 +26,8 @@* and gain entries applies the intersection.*/import { createHash } from 'node:crypto';-import { load, JSON_SCHEMA } from 'js-yaml';+import { JSON_SCHEMA } from 'js-yaml';+import { loadBoundedYaml } from '../data-frontmatter.ts';import { ACCESS_ID_RE, normalizePrincipal } from './principals.ts';export interface FolderRule {@@ -149,7 +150,7 @@ function ruleLines(text: string): Array<number> {export function parsePolicyYaml(text: string): ParsedPolicy {let doc: unknown;try {- doc = load(text, { schema: JSON_SCHEMA, json: false });+ doc = loadBoundedYaml(text, { schema: JSON_SCHEMA });} catch (e) {const mark = (e as { mark?: { line?: number } }).mark;return { ok: false, problems: [{ line: typeof mark?.line === 'number' ? mark.line + 1 : null, message: `not valid YAML: ${(e as Error).message.split('\n')[0]}` }], prefixes: null };diff --git a/src/core/access/policy-git.ts b/src/core/access/policy-git.tsindex 296638a33c..5d66beb583 100644--- a/src/core/access/policy-git.ts+++ b/src/core/access/policy-git.ts@@ -21,6 +21,8 @@ import { join } from 'node:path';import type { BrainEngine } from '../engine.ts';import { opError, OperationError } from '../ops/contract.ts';import { readSyncAnchor } from '../sync-anchor.ts';+import { gitChildEnv } from '../git-env.ts';+import { gitAsync } from '../sync-git.ts';import { acquireCommitLock, checkoutRoot, commitAndPush, COMMIT_LOCK_ENV, type CommitPushResult } from '../git/commit-push.ts';import { parsePolicyYaml, rulebookDigest, serializePolicyYaml, type FolderRule, type PolicyProblem } from './folder-rules.ts';import { clearPolicyInvalid, getRevision, listRevisions, markPolicyInvalid, proposeRevision, readAccessStore, writeAccessStore, type ProposalResult, type RestampProgress } from './policy.ts';@@ -39,21 +41,28 @@ export async function sourcePolicyRoot(engine: BrainEngine, sourceId: string): P/** Whether `root` is inside a git work tree. */export function isGitWorkTree(root: string): boolean {- const r = spawnSync('git', ['-C', root, 'rev-parse', '--is-inside-work-tree'], { encoding: 'utf8' });+ const r = spawnSync('git', ['-C', root, 'rev-parse', '--is-inside-work-tree'], { encoding: 'utf8', env: gitChildEnv() });return r.status === 0 && r.stdout.trim() === 'true';}function gitShow(root: string, rev: string, path: string): string | null {- const r = spawnSync('git', ['show', `${rev}:./${path}`], { cwd: root, encoding: 'utf8', maxBuffer: 4 * 1024 * 1024 });+ const r = spawnSync('git', ['show', `${rev}:./${path}`], { cwd: root, encoding: 'utf8', maxBuffer: 4 * 1024 * 1024, env: gitChildEnv() });return r.status === 0 ? r.stdout : null;}+/** isGitWorkTree without blocking the event loop, for sync (a resident runs it in-process on a commit). */+async function isGitWorkTreeAsync(root: string): Promise<boolean> {+ return gitAsync(root, ['rev-parse', '--is-inside-work-tree'], { silenceStderr: true }).then(out => out === 'true', () => false);+}+export interface CommittedPolicy { yml: string | null; approved: string | null; commit: string | null }/** The policy files as committed at `rev` (never the working tree), and the last commit that touched access.yml. */-export function readCommittedPolicy(root: string, rev = 'HEAD'): CommittedPolicy {- const log = spawnSync('git', ['log', '-1', '--format=%h %an', rev, '--', POLICY_FILE], { cwd: root, encoding: 'utf8' });- return { yml: gitShow(root, rev, POLICY_FILE), approved: gitShow(root, rev, APPROVED_FILE), commit: log.status === 0 && log.stdout.trim() ? log.stdout.trim() : null };+export async function readCommittedPolicy(root: string, rev = 'HEAD'): Promise<CommittedPolicy> {+ const show = (path: string) => gitAsync(root, ['show', `${rev}:./${path}`], { silenceStderr: true, raw: true }).catch(() => null);+ const [yml, approved, log] = await Promise.all([show(POLICY_FILE), show(APPROVED_FILE),+ gitAsync(root, ['log', '-1', '--format=%h %an', rev, '--', POLICY_FILE], { silenceStderr: true }).catch(() => '')]);+ return { yml, approved, commit: log || null };}export interface GitPolicySyncResult {@@ -71,7 +80,7 @@ export interface GitPolicySyncResult {export async function syncGitPolicy(engine: BrainEngine, sourceId: string, root: string, opts: { rev?: string; onProgress?: (p: RestampProgress) => void } = {}): Promise<GitPolicySyncResult> {const store = await readAccessStore(engine, sourceId);if (store === 'database') return { source_id: sourceId, state: 'skipped', reason: 'database_store' };- const files = readCommittedPolicy(root, opts.rev ?? 'HEAD');+ const files = await readCommittedPolicy(root, opts.rev ?? 'HEAD');if (files.yml === null && files.approved === null && store !== 'git') return { source_id: sourceId, state: 'skipped', reason: 'no_policy' };let approvedFile: GitPolicySyncResult['approved_file'] = 'absent';if (files.approved !== null) {@@ -170,7 +179,7 @@ export async function writeApprovedFile(root: string, rules: FolderRule[], messa/** Sync's hook: apply the committed policy of a source when its store is git (or unset and the commit holds a policy file). */export async function syncAccessPolicyAt(engine: BrainEngine, sourceId: string, root: string | null | undefined, rev = 'HEAD', log?: (line: string) => void): Promise<GitPolicySyncResult | null> {- if (!root || !existsSync(root) || !isGitWorkTree(root)) return null;+ if (!root || !existsSync(root) || !await isGitWorkTreeAsync(root)) return null;const result = await syncGitPolicy(engine, sourceId, root, { rev });if (result.state === 'skipped') return result;if (result.state === 'invalid') {diff --git a/src/core/deletion-inventory.ts b/src/core/deletion-inventory.tsindex f3f3ad7613..21312497e1 100644--- a/src/core/deletion-inventory.ts+++ b/src/core/deletion-inventory.ts@@ -38,6 +38,11 @@ const ROWS: readonly Row[] = [['access_group_members', 'out_of_scope', 'no_memory_text', 'group_id member_id'],['access_groups', 'out_of_scope', 'no_memory_text', 'id'],['access_members', 'out_of_scope', 'no_memory_text', 'id display_name'],+ ['access_pending_coverage', 'out_of_scope', 'no_memory_text', 'source_id prefix reason detail'],+ ['access_policy_migrations', 'out_of_scope', 'no_memory_text', 'id source_id direction phase receipts'],+ ['access_policy_revisions', 'out_of_scope', 'no_memory_text', 'source_id rules digest origin proposed_by approved_by change_kind operation_id'],+ ['access_policy_state', 'out_of_scope', 'no_memory_text', 'source_id'],+ ['access_rules', 'out_of_scope', 'no_memory_text', 'source_id rule_id prefix readable_by created_by'],['access_tokens', 'out_of_scope', 'secret_material', 'name token_hash scopes permissions source_grant source_id federated_read allowed_operations takes_holders min_trust private_pages member_id may_act_for'],['belief_events', 'swept', 'belief_ledger', 'event_key source_id slug subject_kind subject_key event_type origin trust_tier writer_tier tier_basis visibility value value_hash prior_hash state_hash cause claim_fp redacted_fields'],['belief_page_lifetimes', 'out_of_scope', 'text_free_ledger', 'source_id slug'],@@ -133,7 +138,7 @@ const ROWS: readonly Row[] = [['page_view_digests', 'out_of_scope', 'no_memory_text', 'revision view audience sha256'],['page_versions', 'swept', 'page_versions', 'compiled_truth frontmatter timeline title type tags source_path write_principal_kind write_principal_id archived_principal_kind archived_principal_id trust_tier write_origin body_storage content_hash'],['page_write_guards', 'out_of_scope', 'no_memory_text', 'slug'],- ['pages', 'swept', 'page_body', 'source_id slug type page_kind title compiled_truth timeline frontmatter content_hash effective_date_source import_filename database_only_reason withheld_source_path contextual_retrieval_mode corpus_generation search_vector source_path ingested_via source_uri source_kind embedding_signature revision_principal_kind revision_principal_id trust_tier write_origin body_storage body_flags truth_lead timeline_lead links_extract_failure page_readers'],+ ['pages', 'swept', 'page_body', 'source_id slug type page_kind title compiled_truth timeline frontmatter content_hash effective_date_source import_filename database_only_reason withheld_source_path contextual_retrieval_mode corpus_generation search_vector source_path ingested_via source_uri source_kind embedding_signature revision_principal_kind revision_principal_id trust_tier write_origin body_storage body_flags truth_lead timeline_lead links_extract_failure page_readers folder_rule_ids'],['persistence_consumers', 'out_of_scope', 'no_memory_text', 'kind mode pool version nonce minted_under persistence_home host_json_path pid_ns boot_id process_start'],['persistence_counters', 'out_of_scope', 'no_memory_text', 'key'],['persistence_effects', 'swept', 'effect_recovery', 'kind data state source_id error_code outcome recovery claim_owner'],diff --git a/src/core/error-registry.ts b/src/core/error-registry.tsindex 39cadc8839..948462e937 100644--- a/src/core/error-registry.ts+++ b/src/core/error-registry.ts@@ -65,8 +65,8 @@ export const CODES = {absent_from_worktree: { class: 'caller', retryable: false, reasons: ['skip_worktree', 'deleted_locally'], summary: "Sync held one file that is committed at HEAD but missing from the working tree (a sparse checkout or a skip-worktree bit, or a local deletion that is not committed); the rest of the source synced.", why: "Sync imports from the working tree, so it cannot import a file that is not on disk, and treating it as deleted would drop a committed file silently. Whether the file comes back or its deletion is committed is the user's choice; classic sync re-screens the hold on every run.", docs: 'docs/guides/write-refusals.md#absent_from_worktree', suggestion: 'Restore the file (git restore -- <path>, or widen the sparse checkout) and the next sync imports it; or commit the deletion with gbrain git commit-push -m <msg> -- <path> and the next sync clears the hold.' },access_command_failed: { class: 'caller', summary: "Google connect credential error: access command failed.", docs: 'docs/guides/google-connect.md#troubleshooting' },access_member_disabled: { class: 'host_only', actor: 'user', reasons: ['disabled', 'removed', 'missing', 'malformed'], summary: "The credential (access token, OAuth client or stdio binding) is bound to a member who is disabled, removed or missing, so it was refused at verification and nothing was read.", why: 'A credential bound to a member reads as that member. While the member cannot read, the credential is refused rather than silently treated as unbound.', docs: 'docs/guides/write-refusals.md#access_member_disabled', suggestion: 'Ask the brain operator to enable the member (gbrain access member enable <id>) or rebind the credential (gbrain auth rescope --token <name>|--client <id> --member <id>|none).' },- access_policy_invalid: { class: 'host_only', actor: 'user', docs: 'docs/guides/write-refusals.md#access_policy_invalid', summary: "A source's folder-rule policy (the committed .gbrain/access.yml, or a file given to gbrain access rule import) does not validate, so it was not applied: the last applied rules stay in force and every prefix the bad file names reads as nobody (the whole source when its prefixes cannot be read).", why: 'A typo in an access file must never open a folder: an unreadable revision keeps the previous rules and hides what it touches until it is fixed.', suggestion: 'Show each problem with its line (gbrain access rule list --source <id>), fix the file, commit it with gbrain git commit-push and sync the source (gbrain sync --source <id> --no-pull).', fix: { argv: ['gbrain', 'access', 'rule', 'list', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Lists the applied rules and each problem in the policy file with its line; changes nothing.' } },- access_policy_pending: { class: 'retryable', docs: 'docs/guides/write-refusals.md#access_policy_pending', summary: "A narrowing change to a source's folder rules is still being applied to its pages, so the prefixes it touches read as nobody until it finishes; pages under other prefixes keep the last applied rules.", why: 'Pages under a newly restricted folder are restamped in batches; until the last batch and its re-check pass land, they read as nobody instead of under the old rules.', suggestion: 'Retry shortly. If it stays pending, the apply was interrupted: the brain host finishes it with gbrain access resume --source <id> (database store) or gbrain sync --source <id> --no-pull (git store).', fix: { argv: ['gbrain', 'access', 'rule', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Shows the pending prefixes and the revision being applied; changes nothing.' } },+ access_policy_invalid: { class: 'host_only', actor: 'user', docs: 'docs/guides/write-refusals.md#access_policy_invalid', summary: "A source's folder-rule policy (the committed .gbrain/access.yml, or a file given to gbrain access rule import) does not validate, so it was not applied: the last applied rules stay in force and every prefix the bad file names reads as nobody (the whole source when its prefixes cannot be read).", why: 'A typo in an access file must never open a folder: an unreadable revision keeps the previous rules and hides what it touches until it is fixed.', suggestion: 'Show each problem with its line (gbrain access rule list --source <id>). Fix the file, commit it with gbrain git commit-push and sync the source (gbrain sync --source <id> --no-pull).', fix: { argv: ['gbrain', 'access', 'rule', 'list', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Lists the applied rules and each problem in the policy file with its line; changes nothing.' } },+ access_policy_pending: { class: 'retryable', docs: 'docs/guides/write-refusals.md#access_policy_pending', summary: "A narrowing change to a source's folder rules is still being applied to its pages, so the prefixes it touches read as nobody until it finishes; pages under other prefixes keep the last applied rules.", why: 'Pages under a newly restricted folder are restamped in batches; until the last batch and its re-check pass land, they read as nobody instead of under the old rules.', suggestion: 'Retry shortly. If it stays pending, the apply was interrupted: the brain host finishes it with gbrain access resume --source <id> (database store); a git store finishes with gbrain sync --source <id> --no-pull.', fix: { argv: ['gbrain', 'access', 'rule', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Shows the pending prefixes and the revision being applied; changes nothing.' } },access_policy_widening_held: { class: 'consent', actor: 'user', summary: "A change to a source's folder rules widens who may read (a rule removed, readers added, the old folder of a moved prefix), so it is recorded but held: the previous rules stay in force until an operator previews it with gbrain access apply --source <id> and approves the printed plan with --yes --expect <plan_hash> on the brain host.", why: 'Write access to the policy (a git commit or a rule edit) must not be enough to open a folder; widening needs a host-side preview and an explicit approval.', suggestion: 'Ask the user whether to approve the widening; the brain host previews it with gbrain access apply --source <id>.', fix: { argv: ['gbrain', 'access', 'apply', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Previews the held widening (pages and members gaining access) and prints the plan hash an approval binds; changes nothing.' } },access_policy_store_mismatch: { class: 'host_only', actor: 'user', summary: "A source's persisted folder-rule store (sources.config.access_store) disagrees with what this host sees (a git store with no visible work tree, or a database store whose root became a repository), so the persisted store and its applied rules stay in force and nothing switches on its own.", why: 'Inferring the store per host would let a missing checkout or a stray git init change which rules apply; only gbrain access rule migrate moves them, and neither direction widens.', suggestion: 'On the brain host, preview the move with gbrain access rule migrate --source <id>, then apply it by adding --yes.', fix: { argv: ['gbrain', 'access', 'rule', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Shows the persisted store and the applied rules; changes nothing.' } },access_rule_invalid: { class: 'caller', docs: 'docs/guides/write-refusals.md#access_rule_invalid', summary: 'A folder rule given to gbrain access rule add is invalid (its prefix is not a literal lower-case folder ending in /, holds .. or *, its readers are not member ids or group:<id>, or another rule already covers the prefix), so nothing was written.', why: 'Prefixes are matched literally against slugs; a pattern or a typo would silently restrict the wrong pages or none.', suggestion: 'Write the prefix as a slug folder ending in / (partners/alice-example/) and the readers as member ids or group:<id>.' },@@ -888,7 +888,7 @@ export const NOTICE_CODES = {mention_index: { kind: 'degraded', summary: 'The entity mention index is pending, off, failed or does not cover this page type, so references listed for an entity may be incomplete.' },degraded_recall: { kind: 'degraded', summary: 'A retrieval stage that affects recall did not run; an empty or thin result is not proof of absence. A failed rerank names its reason (timeout, budget, rate_limited, unreachable, auth, provider_error), the fused-order fallback and the session\'s count of reranker-degraded calls; timeout and rate_limited say to repeat the call after a delay, the rest point at doctor\'s reranker_health.' },source_binding_narrowed: { kind: 'info', summary: "A GBRAIN_SOURCE / .gbrain-source binding narrowed an unqualified read that came back empty; the fix reads another source explicitly." },- access_policy_pending: { kind: 'degraded', summary: 'A read touched a source whose folder rules are being narrowed or whose policy file does not validate: pages under the affected prefixes read as nobody until the brain host finishes it, so a missing page there is not proof the brain has nothing on it; the fix shows the policy state, then the host runs gbrain access resume --source <id> (database store) or gbrain sync --source <id> --no-pull (git store).' },+ access_policy_pending: { kind: 'degraded', summary: 'A read touched a source whose folder rules are being narrowed or whose policy file does not validate: pages under the affected prefixes read as nobody until the brain host finishes it, so a missing page there is not proof the brain has nothing on it; the fix shows the policy state, then the host runs gbrain access resume --source <id> (database store); a git store finishes with gbrain sync --source <id> --no-pull.' },degraded_dedup: { kind: 'info', summary: 'remember ran without an embedding provider, so only exact duplicates are detected.' },facts_calibration_unmeasured: { kind: 'info', summary: 'recall --question ranked facts with semantic matching on an embedding model whose fact admission floors were never measured (`facts_calibration: {status: "unmeasured", model_key}`); a short facts list is weaker evidence of "nothing matched". Once per brain per session; the fix is the read-only `gbrain doctor --only fact_admission_floors --json`.' },private_fact_not_pushed: { kind: 'info', summary: 'remember saved a private fact: only local CLI recall reads it, and session hooks never push it into a new agent session.' },diff --git a/src/core/schema-migrations/v282-folder-access-rules.ts b/src/core/schema-migrations/v282-folder-access-rules.tsindex 0e6fa791b9..899aba0f42 100644--- a/src/core/schema-migrations/v282-folder-access-rules.ts+++ b/src/core/schema-migrations/v282-folder-access-rules.ts@@ -83,16 +83,16 @@ CREATE TABLE IF NOT EXISTS access_policy_migrations (updated_at TIMESTAMPTZ NOT NULL DEFAULT now());CREATE OR REPLACE FUNCTION gbrain_access_folder_rules(p_source TEXT, p_slug TEXT) RETURNS TEXT[]- LANGUAGE sql STABLE PARALLEL SAFE SET search_path = pg_catalog, public AS $fn$+ LANGUAGE sql STABLE PARALLEL SAFE SET search_path = pg_catalog, public, pg_temp AS $fn$SELECT array_agg(p_source || ':' || r.rule_id ORDER BY r.rule_id COLLATE "C")FROM access_rules r WHERE r.source_id = p_source AND starts_with(p_slug, r.prefix)$fn$;CREATE OR REPLACE FUNCTION gbrain_access_pending_covers(p_source TEXT, p_slug TEXT) RETURNS boolean- LANGUAGE sql STABLE PARALLEL SAFE SET search_path = pg_catalog, public AS $fn$+ LANGUAGE sql STABLE PARALLEL SAFE SET search_path = pg_catalog, public, pg_temp AS $fn$SELECT EXISTS (SELECT 1 FROM access_pending_coverage c WHERE c.source_id = p_source AND starts_with(p_slug, c.prefix))$fn$;CREATE OR REPLACE FUNCTION gbrain_access_stamp_folder_rules() RETURNS trigger- LANGUAGE plpgsql SET search_path = pg_catalog, public AS $fn$+ LANGUAGE plpgsql SET search_path = pg_catalog, public, pg_temp AS $fn$BEGINIF EXISTS (SELECT 1 FROM access_policy_state s WHERE s.source_id = NEW.source_id) THENPERFORM 1 FROM access_policy_state s WHERE s.source_id = NEW.source_id FOR SHARE;@@ -107,7 +107,7 @@ DROP TRIGGER IF EXISTS pages_access_stamp_folder_rules ON pages;CREATE TRIGGER pages_access_stamp_folder_rules BEFORE INSERT OR UPDATE OF slug, source_id, folder_rule_ids ON pagesFOR EACH ROW EXECUTE FUNCTION gbrain_access_stamp_folder_rules();CREATE OR REPLACE FUNCTION gbrain_access_origin_restricted(p_id INTEGER, p_source_id TEXT, p_type TEXT, fm JSONB) RETURNS boolean- LANGUAGE plpgsql STABLE PARALLEL SAFE SET search_path = pg_catalog, public AS $fn$+ LANGUAGE plpgsql STABLE PARALLEL SAFE SET search_path = pg_catalog, public, pg_temp AS $fn$BEGINIF p_type = 'atom' THENIF EXISTS (SELECT 1 FROM pages o WHERE o.source_id = p_source_id AND o.slug = fm->>'source_slug'diff --git a/src/core/search/private-visibility.ts b/src/core/search/private-visibility.tsindex bb1203849a..bffc93bf9a 100644--- a/src/core/search/private-visibility.ts+++ b/src/core/search/private-visibility.ts@@ -94,7 +94,7 @@ export function folderRulesAllowedSql(alias: string, satisfied: readonly string[* everything. Outside any caller record the prefixes are read live, so a page under a pending prefix stays hidden.*/function coverageSql(alias: string): string {- if (!callerAccessStore.getStore()) return ` AND NOT gbrain_access_pending_covers(${alias}.source_id, ${alias}.slug)`;+ if (!callerAccessStore.getStore()) return ` AND NOT EXISTS (SELECT 1 FROM access_pending_coverage pc WHERE pc.source_id = ${alias}.source_id AND starts_with(${alias}.slug, pc.prefix))`;const coverage = currentCallerAccess().folderCoverage;if (!coverage.length) return '';return coverage.map(c => !isValidSourceId(c.source_id) || (c.prefix !== '' && !validPrefix(c.prefix)) ? ' AND FALSE'diff --git a/test/access-folder-rules-git.test.ts b/test/access-folder-rules-git.test.tsindex 5741fe488c..1faa44fb1e 100644--- a/test/access-folder-rules-git.test.ts+++ b/test/access-folder-rules-git.test.ts@@ -116,7 +116,7 @@ describe('folder access rules, git store', () => {const applied = await cli(engine, ['apply', '--source', SRC, '--yes', '--expect', preview.plan_hash]);expect({ outcome: applied.git.outcome, path: applied.git.path }).toEqual({ outcome: 'committed_local', path: '.gbrain/access.approved' });expect(git(root, 'log', '-1', '--format=%s')).toContain('approve folder rules');- expect(readCommittedPolicy(root).approved).toContain('id: team');+ expect((await readCommittedPolicy(root)).approved).toContain('id: team');expect((await policyStatus(engine, SRC)).rules.map(r => r.id)).toEqual(['team']);expect((await stamps(engine))['partners/alice-example/plan']).toEqual([`${SRC}:team`]);}, 120_000);@@ -157,7 +157,7 @@ describe('folder access rules, git store', () => {test('gbrain access rule add on a git source commits access.yml through the door and applies it at once', async () => {const r = await cli(engine, ['rule', 'add', '--source', SRC, '--prefix', 'partners/alice-example/', '--readers', 'alice-example', '--id', 'alice', '--yes']);expect({ store: r.store, state: r.state, outcome: r.git.outcome, path: r.git.path }).toEqual({ store: 'git', state: 'applied', outcome: 'committed_local', path: POLICY_FILE });- expect(readCommittedPolicy(root).yml).toContain('id: alice');+ expect((await readCommittedPolicy(root)).yml).toContain('id: alice');expect(git(root, 'status', '--porcelain')).toBe('');expect((await stamps(engine))['partners/alice-example/plan']).toEqual([`${SRC}:alice`, `${SRC}:team`]);}, 120_000);@@ -169,7 +169,7 @@ describe('folder access rules, git store', () => {expect(() => commitPolicyFile(root, POLICY_FILE, () => 'version: 1\nrules: []\n', 'should not land')).toThrow(expect.objectContaining({ code: 'commit_lock_busy' }));});} finally { lock.release(); }- expect(readCommittedPolicy(root).yml).toContain('id: alice');+ expect((await readCommittedPolicy(root)).yml).toContain('id: alice');expect(git(root, 'status', '--porcelain')).toBe('');}, 60_000);@@ -201,7 +201,7 @@ describe('folder access rules, git store', () => {expect((await policyStatus(engine, SRC)).rules).toEqual(rules);const toGit = await cli(engine, ['rule', 'migrate', '--source', SRC, '--yes']);expect({ to: toGit.to, phase: toGit.phase, sync: toGit.receipts.sync }).toEqual({ to: 'git', phase: 'switched', sync: 'unchanged' });- expect(readCommittedPolicy(root).yml).toContain('id: alice');+ expect((await readCommittedPolicy(root)).yml).toContain('id: alice');expect((await policyStatus(engine, SRC)).rules).toEqual(rules);}, 120_000);diff --git a/test/bootstrap.test.ts b/test/bootstrap.test.tsindex 3bfae5cf20..bc00dc3f52 100644--- a/test/bootstrap.test.ts+++ b/test/bootstrap.test.ts@@ -163,6 +163,9 @@ describe('PGLiteEngine#applyForwardReferenceBootstrap', () => {-- The v230 trust generation trigger's WHEN reads pages.source_id, slug and-- deleted_at; a pre-v0.18 brain predates it (v230 recreates it).DROP TRIGGER IF EXISTS trust_generation_update ON pages;+ -- The v282 folder-rule stamp trigger fires on UPDATE OF source_id; a+ -- pre-v0.18 brain predates it too (v282 recreates it).+ DROP TRIGGER IF EXISTS pages_access_stamp_folder_rules ON pages;ALTER TABLE pages DROP COLUMN IF EXISTS source_id;DROP TABLE IF EXISTS sources CASCADE;`);@@ -220,6 +223,9 @@ describe('PGLiteEngine#applyForwardReferenceBootstrap', () => {-- The v230 trust generation trigger's WHEN reads pages.source_id, slug and-- deleted_at; a pre-v0.18 brain predates it (v230 recreates it).DROP TRIGGER IF EXISTS trust_generation_update ON pages;+ -- The v282 folder-rule stamp trigger fires on UPDATE OF source_id; a+ -- pre-v0.18 brain predates it too (v282 recreates it).+ DROP TRIGGER IF EXISTS pages_access_stamp_folder_rules ON pages;ALTER TABLE pages DROP COLUMN IF EXISTS source_id;DROP TABLE IF EXISTS sources CASCADE;ALTER TABLE links DROP CONSTRAINT IF EXISTS links_resolution_type_check;