Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(access): v276 access_member_links and the attest right columns (GST-359 C1)
garrytan1cf6a0498dcc
diff --git a/src/core/deletion-inventory.ts b/src/core/deletion-inventory.tsindex eb593b4eeb..23ab7da4cd 100644--- a/src/core/deletion-inventory.ts+++ b/src/core/deletion-inventory.ts@@ -37,8 +37,9 @@ type Row = [table: string, cls: InventoryClass, reason: string, columns: string,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_member_links', 'out_of_scope', 'no_memory_text', 'system external_id member_id'],['access_members', 'out_of_scope', 'no_memory_text', 'id display_name'],- ['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'],+ ['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 attest_actor attest_ops'],['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'],['belief_redactions', 'out_of_scope', 'text_free_ledger', 'source_id subject_key field field_hash released_hash'],@@ -108,10 +109,10 @@ const ROWS: readonly Row[] = [['minion_lease_pressure_log', 'out_of_scope', 'no_memory_text', 'lease_key queue_name job_name model provider'],['minion_self_fix_log', 'out_of_scope', 'no_memory_text', 'classifier_bucket policy_applied outcome'],['needs_rederive', 'out_of_scope', 'text_free_ledger', 'derived_table derived_id source_id reason'],- ['oauth_clients', 'out_of_scope', 'secret_material', 'client_id client_secret_hash client_name redirect_uris grant_types scope token_endpoint_auth_method source_id federated_read bound_tools bound_source_id bound_brain_id bound_slug_prefixes surface surface_set_by allowed_operations delegated_slug_prefixes delegated_namespace grant_profile grant_repair_reasons source_grant takes_holders min_trust registered_via private_pages member_id may_act_for'],+ ['oauth_clients', 'out_of_scope', 'secret_material', 'client_id client_secret_hash client_name redirect_uris grant_types scope token_endpoint_auth_method source_id federated_read bound_tools bound_source_id bound_brain_id bound_slug_prefixes surface surface_set_by allowed_operations delegated_slug_prefixes delegated_namespace grant_profile grant_repair_reasons source_grant takes_holders min_trust registered_via private_pages member_id may_act_for attest_actor attest_ops'],['oauth_codes', 'out_of_scope', 'secret_material', 'code_hash client_id scopes code_challenge code_challenge_method redirect_uri state resource'],['oauth_grant_audit', 'out_of_scope', 'no_memory_text', 'client_id actor action before_grant after_grant'],- ['oauth_tokens', 'out_of_scope', 'secret_material', 'token_hash token_type client_id scopes resource'],+ ['oauth_tokens', 'out_of_scope', 'secret_material', 'token_hash token_type client_id scopes resource grant_type'],['op_checkpoint_paths', 'out_of_scope', 'no_memory_text', 'op fingerprint path'],['op_checkpoints', 'out_of_scope', 'no_memory_text', 'op fingerprint completed_keys'],['open_loops', 'swept', 'open_loops', 'source_id dedup_key loop_type counterparty_slug counterparty_source_id counterparty_email summary evidence thread_id page_slug status detector closed_by'],diff --git a/src/core/schema-migrations/latest.generated.ts b/src/core/schema-migrations/latest.generated.tsindex 4f1b5b8a21..4059749ed5 100644--- a/src/core/schema-migrations/latest.generated.ts+++ b/src/core/schema-migrations/latest.generated.ts@@ -4,4 +4,4 @@// The highest schema migration version (migrate.ts LATEST_VERSION), importable without// loading the migrations themselves.-export const LATEST_SCHEMA_VERSION = 275;+export const LATEST_SCHEMA_VERSION = 276;diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.tsindex 3bfb31d5a7..b04d5f0eaf 100644--- a/src/core/schema-migrations/registry.generated.ts+++ b/src/core/schema-migrations/registry.generated.ts@@ -276,6 +276,7 @@ import { v272 } from './v272-git-canonical-declared.ts';import { v273 } from './v273-principal-private-pages.ts';import { v274 } from './v274-member-read-access.ts';import { v275 } from './v275-folder-access-rules.ts';+import { v276 } from './v276-qm-actor-links.ts';// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the// runner sorts by version before applying.@@ -550,4 +551,5 @@ export const MIGRATIONS: Migration[] = [v273,v274,v275,+ v276,];diff --git a/src/core/schema-migrations/v276-qm-actor-links.ts b/src/core/schema-migrations/v276-qm-actor-links.tsnew file mode 100644index 0000000000..3a856bbff3--- /dev/null+++ b/src/core/schema-migrations/v276-qm-actor-links.ts@@ -0,0 +1,39 @@+import type { Migration } from './types.ts';++// Applied by src/core/migrate.ts on the next initSchema(); see docs/ENGINES.md+// ("Canonical schema sources") for when schema.sql or a TS fragment also changes.+//+// GST-359 C1 (GBRA-218, stacked on v274/v275): an attested actor. A trusted+// system's credential (only 'qm' today) may name the person a call serves in+// a header; gbrain maps that person's opaque canonical id to a member through+// access_member_links (system, external_id) and reads as that member.+// external_id is 1-256 visible ASCII characters, compared exactly (no case+// folding); one member may hold several ids. The right to attest is a+// credential column pair: attest_actor (the system name, NULL = none) and+// attest_ops (the operations an attested call may run; NULL = the default+// memory pair). oauth_tokens.grant_type records which OAuth grant issued each+// token, so the right is honoured only for client-credentials tokens (NULL on+// tokens issued before this migration: never attested). Database only, so a+// repo-less brain gets it unchanged. Nothing is rewritten on upgrade.+// No schema.sql mirror: like v274 and v275, these exist only through+// migrations. Provisional number (C1 placeholder): renumbered at the merge slot.+export const v276: Migration = {+ version: 276,+ name: 'qm_actor_links',+ idempotent: true,+ sql: `+CREATE TABLE IF NOT EXISTS access_member_links (+ system TEXT NOT NULL CHECK (system ~ '^[a-z][a-z0-9_-]{0,31}$'),+ external_id TEXT NOT NULL CHECK (length(external_id) BETWEEN 1 AND 256 AND external_id ~ '^[!-~]+$'),+ member_id TEXT NOT NULL REFERENCES access_members(id) ON DELETE CASCADE,+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ PRIMARY KEY (system, external_id)+);+CREATE INDEX IF NOT EXISTS access_member_links_member_idx ON access_member_links (member_id);+ALTER TABLE access_tokens ADD COLUMN IF NOT EXISTS attest_actor TEXT;+ALTER TABLE access_tokens ADD COLUMN IF NOT EXISTS attest_ops TEXT[];+ALTER TABLE oauth_clients ADD COLUMN IF NOT EXISTS attest_actor TEXT;+ALTER TABLE oauth_clients ADD COLUMN IF NOT EXISTS attest_ops TEXT[];+ALTER TABLE oauth_tokens ADD COLUMN IF NOT EXISTS grant_type TEXT;+`,+};