Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

GBRA-218 (A2): a moved prefix applies at its new folder at once and holds only the old folder's release (L4)

garrytanbdf0d1abd9fb
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index fc67327ee9..7bb3944d6e 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -139,7 +139,7 @@ More: [docs/guides/write-refusals.md#access_policy_pending](../../docs/guides/wr
| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
|---|---|---|---|---|---|---|
-| A change to a source's folder rules widens who may read (a rule removed, readers added, a prefix moved), 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. | 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. | Ask the user whether to approve the widening; the brain host previews it with gbrain access apply --source <id>. Run: gbrain access apply --source '{source_id}' --json | user | `repeat the read that failed` | 1 | no |
+| 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. | 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. | Ask the user whether to approve the widening; the brain host previews it with gbrain access apply --source <id>. Run: gbrain access apply --source '{source_id}' --json | user | `repeat the read that failed` | 1 | no |
### access_rule_invalid
diff --git a/docs/tutorials/company-brain.md b/docs/tutorials/company-brain.md
index 6975e3c1c8..12e52d7e95 100644
--- a/docs/tutorials/company-brain.md
+++ b/docs/tutorials/company-brain.md
@@ -140,7 +140,7 @@ gbrain access rule add --prefix partners/alice-example/ --readers alice-example,
gbrain access rule list --source team-a # store, revisions, applied rules, anything held or pending
```
-A remote read of a page under a rule needs the caller's member to be on every rule covering it and on the page's own `readable_by`; hatches, grants and `--as` never relax it. Narrowing applies at once. A change that widens (removing a rule or a reader) is held until `gbrain access apply --source team-a` previews who would gain access and `gbrain access apply --source team-a --yes --expect <plan_hash>` approves it. If an apply stops halfway, its prefixes read as nobody until `gbrain access resume --source team-a`. `gbrain access rule history` and `rule revert --to <revision>` work over the revision log, and `gbrain export` carries the applied rules so `gbrain import` installs them before any page.
+A remote read of a page under a rule needs the caller's member to be on every rule covering it and on the page's own `readable_by`; hatches, grants and `--as` never relax it. Narrowing applies at once. Moving a rule's prefix restricts the new folder at once and keeps the old folder under the old readers until approval. A change that widens (removing a rule or a reader, or releasing a moved rule's old folder) is held until `gbrain access apply --source team-a` previews who would gain access and `gbrain access apply --source team-a --yes --expect <plan_hash>` approves it. If an apply stops halfway, its prefixes read as nobody until `gbrain access resume --source team-a`. `gbrain access rule history` and `rule revert --to <revision>` work over the revision log, and `gbrain export` carries the applied rules so `gbrain import` installs them before any page.
On a git-backed source the same rules live in `.gbrain/access.yml`: `rule add|rm` commit it through `gbrain git commit-push`, a hand edit takes effect when you commit it and run `gbrain sync`, and a widening commit stays held until `gbrain access apply` approves it (recorded in `.gbrain/access.approved`). A source keeps the store it had when its first rule was created; `gbrain access rule migrate --source <id>` (preview, then `--yes`) moves the rules when you attach or remove a repo. Remote callers cannot write `.gbrain/`.
diff --git a/src/commands/access-rules.ts b/src/commands/access-rules.ts
index 3faef12b7a..c717c46fa8 100644
--- a/src/commands/access-rules.ts
+++ b/src/commands/access-rules.ts
@@ -76,7 +76,7 @@ const reader = (p: string) => (p.startsWith('member:') ? p.slice(7) : p);
const ruleLine = (r: FolderRule) => ` ${r.id} ${r.prefix} readable by ${r.readable_by.map(reader).join(', ') || 'nobody'}`;
function changeLine(c: RuleChange): string {
- const what = c.kind === 'added' ? 'add rule' : c.kind === 'removed' ? 'remove rule' : c.kind === 'prefix_moved' ? `move rule to ${c.prefix}`
+ const what = c.kind === 'added' ? 'add rule' : c.kind === 'removed' ? 'remove rule' : c.kind === 'prefix_moved' ? `move rule to ${c.prefix}` : c.kind === 'prefix_released' ? 'release the old prefix of moved rule'
: c.kind === 'readers_removed' ? `remove readers ${(c.readers ?? []).map(reader).join(', ')} from` : `add readers ${(c.readers ?? []).map(reader).join(', ')} to`;
return ` ${what} ${c.rule} (${c.prefix}): ${c.narrowing ? 'narrowing, applies at once' : 'widening, held until gbrain access apply'}`;
}
diff --git a/src/core/access/folder-rules.ts b/src/core/access/folder-rules.ts
index 9c06410966..67f2b4cdf2 100644
--- a/src/core/access/folder-rules.ts
+++ b/src/core/access/folder-rules.ts
@@ -18,10 +18,12 @@
*
* classifyRulebook() compares the applied rulebook with a desired one rule by
* rule: an added rule and removed readers narrow and apply at once; a removed
- * rule, added readers and a moved prefix widen and wait for an operator's
- * `gbrain access apply --yes`. Its target (what is applied now) is never wider
- * than the applied rulebook: a rule whose readers both lose and gain entries
- * applies the intersection.
+ * rule and added readers widen and wait for an operator's
+ * `gbrain access apply --yes`. A moved prefix is both: the rule applies at its
+ * new prefix at once, and its old prefix keeps the old readers under a held
+ * rule (heldRuleId) whose release waits for apply. Its target (what is applied
+ * now) is never wider than the applied rulebook: a rule whose readers both lose
+ * and gain entries applies the intersection.
*/
import { createHash } from 'node:crypto';
import { load, JSON_SCHEMA } from 'js-yaml';
@@ -213,7 +215,14 @@ export function rulesFromJson(value: unknown): FolderRule[] {
}));
}
-export type ChangeKind = 'added' | 'removed' | 'readers_removed' | 'readers_added' | 'prefix_moved';
+export type ChangeKind = 'added' | 'removed' | 'readers_removed' | 'readers_added' | 'prefix_moved' | 'prefix_released';
+
+const HELD_RULE_RE = /\.held-[0-9a-f]{8}$/;
+
+/** The id that keeps rule `id`'s old `prefix` restricted after the rule moved, until an operator approves the release. */
+export function heldRuleId(id: string, prefix: string): string {
+ return `${id.slice(0, 50).replace(/[._-]+$/, '')}.held-${createHash('sha256').update(`${id}\u0000${prefix}`).digest('hex').slice(0, 8)}`;
+}
export interface RuleChange {
rule: string;
@@ -242,7 +251,13 @@ export function classifyRulebook(applied: readonly FolderRule[], desired: readon
for (const [id, a] of after) {
const b = before.get(id);
if (!b) { target.push(a); changes.push({ rule: id, kind: 'added', narrowing: true, prefix: a.prefix }); continue; }
- if (b.prefix !== a.prefix) { target.push(b); changes.push({ rule: id, kind: 'prefix_moved', narrowing: false, prefix: a.prefix }); continue; }
+ if (b.prefix !== a.prefix) {
+ const held = { id: heldRuleId(id, b.prefix), prefix: b.prefix, readable_by: b.readable_by };
+ if (before.has(held.id) || after.has(held.id)) { target.push(b); changes.push({ rule: id, kind: 'prefix_moved', narrowing: false, prefix: a.prefix }); continue; }
+ target.push(a, held);
+ changes.push({ rule: id, kind: 'prefix_moved', narrowing: true, prefix: a.prefix }, { rule: held.id, kind: 'prefix_released', narrowing: false, prefix: b.prefix });
+ continue;
+ }
const removed = b.readable_by.filter(p => !a.readable_by.includes(p));
const added = a.readable_by.filter(p => !b.readable_by.includes(p));
target.push({ id, prefix: b.prefix, readable_by: b.readable_by.filter(p => a.readable_by.includes(p)) });
@@ -252,7 +267,7 @@ export function classifyRulebook(applied: readonly FolderRule[], desired: readon
for (const [id, b] of before) {
if (after.has(id)) continue;
target.push(b);
- changes.push({ rule: id, kind: 'removed', narrowing: false, prefix: b.prefix });
+ changes.push({ rule: id, kind: HELD_RULE_RE.test(id) ? 'prefix_released' : 'removed', narrowing: false, prefix: b.prefix });
}
// A desired rule that takes the prefix of a rule the target still holds (an id renamed) leaves two rules on one prefix
// until the removal is approved; both have to pass, which is never wider than either.
diff --git a/src/core/error-registry.ts b/src/core/error-registry.ts
index 827db95364..5df6b63dc8 100644
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@ -67,7 +67,7 @@ export const CODES = {
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_widening_held: { class: 'consent', actor: 'user', summary: "A change to a source's folder rules widens who may read (a rule removed, readers added, a prefix moved), 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_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>.' },
access_member_id_retired: { class: 'caller', summary: "The member id was removed earlier and member ids are never reused, so nothing was created or enabled.", why: 'Pages and audit history may still name a removed id; reusing it would hand that history to a different person.', docs: 'docs/guides/write-refusals.md#access_member_id_retired', suggestion: 'Choose a new member id.', fix: { argv: ['gbrain', 'access', 'member', 'list', '--all', '--json'], consent: [], actor: 'agent', requires_exclusive: false, why: 'Read-only: lists every member id on this brain with its status, removed ones included.', verify: { argv: ['gbrain', 'access', 'member', 'list', '--all', '--json'] } } },
diff --git a/test/access-folder-rules-git.test.ts b/test/access-folder-rules-git.test.ts
index ca411c013d..5741fe488c 100644
--- a/test/access-folder-rules-git.test.ts
+++ b/test/access-folder-rules-git.test.ts
@@ -234,3 +234,52 @@ describe('folder access rules, git store', () => {
} finally { rmSync(bare, { recursive: true, force: true }); rmSync(repo, { recursive: true, force: true }); }
}, 120_000);
});
+
+describe('a moved prefix on a git source (L4)', () => {
+ let root: string;
+ let engine: PGLiteEngine;
+ const hidden = async (slug: string) => {
+ const [row] = await engine.executeRaw<{ hidden: boolean }>(
+ `SELECT (folder_rule_ids IS NOT NULL OR gbrain_access_pending_covers(source_id, slug)) AS hidden FROM pages WHERE source_id = $1 AND slug = $2`, [SRC, slug]);
+ return row?.hidden;
+ };
+
+ beforeAll(async () => {
+ engine = new PGLiteEngine();
+ await engine.connect({ engine: 'pglite' } as never);
+ await engine.initSchema();
+ root = mkdtempSync(join(tmpdir(), 'gbrain-frgit-move-'));
+ git(root, 'init', '-q', '-b', 'main');
+ git(root, 'config', 'user.email', '[email protected]');
+ git(root, 'config', 'user.name', 't');
+ for (const s of ['projects/old-example/doc', 'projects/new-example/doc']) writePage(root, s);
+ writePolicy(root, POLICY([['mv', 'projects/old-example/', 'alice-example']]));
+ git(root, 'add', '-A');
+ git(root, 'commit', '-q', '-m', 'pages and policy');
+ await seedBrain(engine, root);
+ await sync(engine, root, true);
+ }, 120_000);
+
+ afterAll(async () => {
+ await engine.disconnect();
+ rmSync(root, { recursive: true, force: true });
+ });
+
+ test('a committed move restricts the new folder at once; the old folder stays hidden until apply, then opens', async () => {
+ expect({ old: await hidden('projects/old-example/doc'), new: await hidden('projects/new-example/doc') }).toEqual({ old: true, new: false });
+ writePolicy(root, POLICY([['mv', 'projects/new-example/', 'alice-example']]));
+ git(root, 'commit', '-q', '-am', 'move mv');
+ await sync(engine, root);
+ const status = await policyStatus(engine, SRC);
+ expect(status.held.map(h => `${h.kind}:${h.prefix}`)).toEqual(['prefix_released:projects/old-example/']);
+ expect({ old: await hidden('projects/old-example/doc'), new: await hidden('projects/new-example/doc') }).toEqual({ old: true, new: true });
+ expect((await stamps(engine))['projects/new-example/doc']).toEqual([`${SRC}:mv`]);
+ const preview = await cli(engine, ['apply', '--source', SRC]);
+ expect(preview.widening.map((w: { change: { kind: string; prefix: string }; sample: string[] }) => ({ kind: w.change.kind, prefix: w.change.prefix, sample: w.sample })))
+ .toEqual([{ kind: 'prefix_released', prefix: 'projects/old-example/', sample: ['projects/old-example/doc'] }]);
+ const applied = await cli(engine, ['apply', '--source', SRC, '--yes', '--expect', preview.plan_hash]);
+ expect(applied.git.path).toBe('.gbrain/access.approved');
+ expect({ old: await hidden('projects/old-example/doc'), new: await hidden('projects/new-example/doc') }).toEqual({ old: false, new: true });
+ expect((await policyStatus(engine, SRC)).rules.map(r => `${r.id}:${r.prefix}`)).toEqual(['mv:projects/new-example/']);
+ }, 120_000);
+});
diff --git a/test/access-folder-rules.test.ts b/test/access-folder-rules.test.ts
index 7576bb6bcc..fee308027e 100644
--- a/test/access-folder-rules.test.ts
+++ b/test/access-folder-rules.test.ts
@@ -34,7 +34,7 @@ import { noGrantFederatedScope } from '../src/core/source-resolver.ts';
import { dispatchToolCall } from '../src/mcp/dispatch.ts';
import { __resetPrivateVisibilityCacheForTests } from '../src/core/search/private-visibility.ts';
import type { AuthInfo } from '../src/core/ops/contract.ts';
-import { classifyRulebook, folderRulesAllow, matchingRuleIds, parsePolicyYaml, ruleIdForPrefix, serializePolicyYaml, type FolderRule } from '../src/core/access/folder-rules.ts';
+import { classifyRulebook, folderRulesAllow, heldRuleId, matchingRuleIds, parsePolicyYaml, ruleIdForPrefix, serializePolicyYaml, type FolderRule } from '../src/core/access/folder-rules.ts';
import { applyApproved, policySeams, policyStatus, previewApply, proposeRevision, resumePolicy } from '../src/core/access/policy.ts';
import { runAccessRules } from '../src/commands/access-rules.ts';
import { testBackends } from './helpers/test-backends.ts';
@@ -77,12 +77,14 @@ describe('folder-rule grammar', () => {
expect(bad('version: 2\nrules: []\n').problems[0]!.message).toContain('version');
});
- test('classification: additions and removed readers narrow; removals, added readers and moved prefixes are held; the target is never wider', () => {
+ test('classification: additions, removed readers and a moved prefix\'s new folder narrow; removals, added readers and the old folder\'s release are held; the target is never wider', () => {
const applied = [rule('a', 'x/', ['alice-example', 'bob-example']), rule('b', 'y/', ['alice-example']), rule('c', 'z/', ['alice-example'])];
const desired = [rule('a', 'x/', ['alice-example', 'carol-example']), rule('c', 'w/', ['alice-example']), rule('d', 'v/', ['bob-example'])];
const cls = classifyRulebook(applied, desired);
- expect(cls.changes.map(c => `${c.rule}:${c.kind}:${c.narrowing}`).sort()).toEqual(['a:readers_added:false', 'a:readers_removed:true', 'b:removed:false', 'c:prefix_moved:false', 'd:added:true']);
- expect(cls.target).toEqual([rule('a', 'x/', ['alice-example']), rule('b', 'y/', ['alice-example']), rule('c', 'z/', ['alice-example']), rule('d', 'v/', ['bob-example'])]);
+ const held = heldRuleId('c', 'z/');
+ expect(cls.changes.map(c => `${c.rule}:${c.kind}:${c.narrowing}`).sort()).toEqual(['a:readers_added:false', 'a:readers_removed:true', 'b:removed:false', `${held}:prefix_released:false`, 'c:prefix_moved:true', 'd:added:true']);
+ expect(cls.target).toEqual([rule('a', 'x/', ['alice-example']), rule('b', 'y/', ['alice-example']), rule('c', 'w/', ['alice-example']), rule(held, 'z/', ['alice-example']), rule('d', 'v/', ['bob-example'])]);
+ expect(classifyRulebook(cls.target, desired).held.map(c => `${c.rule}:${c.kind}:${c.prefix}`)).toEqual(['a:readers_added:x/', 'b:removed:y/', `${held}:prefix_released:z/`]);
expect(cls.kind).toBe('mixed');
expect(classifyRulebook([], desired).kind).toBe('narrowing');
expect(classifyRulebook(desired, desired).kind).toBe('unchanged');
@@ -377,6 +379,28 @@ for (const kind of testBackends()) {
}
}, 120_000);
+ test('a moved prefix restricts the new folder at once and holds only the old folder\'s release (L4)', async () => {
+ await importFromContent(engine, 'projects/old-example/doc', pageText('old doc', 'canaryfrmvold'), { sourceId: SRC });
+ await importFromContent(engine, 'projects/new-example/doc', pageText('new doc', 'canaryfrmvnew'), { sourceId: SRC });
+ const ok = async (who: string, canary: string) => (await call(who, 'search', { query: canary, match: 'keyword', fields: 'full' })).text.includes(canary);
+ const base = (await policyStatus(engine, SRC)).desired!.rules.filter(r => r.id !== 'mv');
+ expect((await proposeRevision(engine, SRC, [...base, rule('mv', 'projects/old-example/', ['alice-example'])], { origin: 'cli' })).state).toBe('applied');
+ expect({ old: await ok('bob', 'canaryfrmvold'), new: await ok('bob', 'canaryfrmvnew') }).toEqual({ old: false, new: true });
+ const moved = await proposeRevision(engine, SRC, [...base, rule('mv', 'projects/new-example/', ['alice-example'])], { origin: 'cli' });
+ expect({ state: moved.state, changes: moved.changes.map(c => `${c.kind}:${c.narrowing}:${c.prefix}`).sort(), held: moved.held.map(h => `${h.kind}:${h.prefix}`) }).toEqual({
+ state: 'recorded', changes: ['prefix_moved:true:projects/new-example/', 'prefix_released:false:projects/old-example/'], held: ['prefix_released:projects/old-example/'] });
+ for (const who of ['bob', 'unbound']) expect({ who, old: await ok(who, 'canaryfrmvold'), new: await ok(who, 'canaryfrmvnew') }).toEqual({ who, old: false, new: false });
+ expect({ old: await ok('alice', 'canaryfrmvold'), new: await ok('alice', 'canaryfrmvnew') }).toEqual({ old: true, new: true });
+ const preview = await previewApply(engine, SRC);
+ expect(preview.widening.map(w => ({ kind: w.change.kind, prefix: w.change.prefix, pages: w.pages, sample: w.sample, gains: w.gains }))).toEqual([
+ { kind: 'prefix_released', prefix: 'projects/old-example/', pages: 1, sample: ['projects/old-example/doc'], gains: 'every_source_reader' }]);
+ expect((await stamps())[`${SRC}:projects/new-example/doc`]).toEqual([`${SRC}:mv`]);
+ await applyApproved(engine, SRC, { expect: preview.plan_hash! });
+ for (const who of ['bob', 'unbound']) expect({ who, old: await ok(who, 'canaryfrmvold'), new: await ok(who, 'canaryfrmvnew') }).toEqual({ who, old: true, new: false });
+ expect((await stamps())[`${SRC}:projects/old-example/doc`]).toBeNull();
+ expect((await policyStatus(engine, SRC)).held).toEqual([]);
+ }, 240_000);
+
test('property: the SQL predicate and the row helper agree on generated slugs, rules and identities', async () => {
const src = 'fr-prop';
await engine.executeRaw('INSERT INTO sources (id, name) VALUES ($1, $1) ON CONFLICT (id) DO NOTHING', [src]);