Skip to main content

Memory namespace: memory

Every project's memory. memory is the default name; an instance may choose another with TAISCE_SCHEMA. Projects are rows and partitions inside it, not namespaces of their own.

Tables at a glance

TableWhat it holds
agent_artifact
agent_storage_policy
audit_entryWhat happened and who did it.
audit_sealChained digests over ranges of audit entries.
chunk
community
community_member
community_reportProse written from what several people said about one subject.
curated_claim
data_subject
embedding_active
embedding_build
embedding_generation
entity
entity_embedding
entity_embedding_active
entity_embedding_build
entity_embedding_generation
entity_embedding_source
entity_embedding_target
entity_name_receipt
erasure_request
fact
fact_evidence
fact_generation
fact_generation_record
fact_history
fact_rebuild_job
fact_receipt
fact_receipt_history
formation_health
ingestion_budget
ingestion_project_usage
ingestion_reservation
memory_feedbackA report about a record that asserts nothing.
message_embedding
notification_delivery
notification_endpoint
observation
observation_retry
predicateThe closed relation vocabulary.
projectA project: where data belongs, what a token is attached to, which kinds of memory it keeps and how long it keeps them.
projection_dependency
projection_kindEvery kind of derived row, and the table it lives in.
record_retraction
rejected_claimProposals that did not become facts, with the model's own wording.
report_embedding
report_embedding_active
report_embedding_build
report_embedding_generation
report_embedding_source
report_embedding_target
retention_sweepWhat each retention sweep deleted, written in the transaction that deleted it.
schema_migration
segmentA summary standing in for a contiguous range of one subject's turns at one level of the roll-up.
source_extraction
speaker_term
subject_retry
turn_message
unresolvable_termTerms that cannot be the subject of a fact because they name nothing the message establishes.
watermark

agent_artifact

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
artifact_iduuidnot null
source_observation_iduuidnot null
data_subject_idtextnot null
kindtextnot null
nametextnot null
contentbyteanot null
versionuuidnot null
previous_versionuuid
last_digestbyteanot null
authored_byuuidnot null
created_attimestamp with time zonenot nullclock_timestamp()
updated_attimestamp with time zonenot nullclock_timestamp()
registration_kindtextgenerated: 'agent_artifact'::text
registration_idtextgenerated: (artifact_id)::text

Constraints

  • agent_artifact_content_check: CHECK ((octet_length(content) <= 524288))
  • agent_artifact_data_subject_id_check: CHECK (((octet_length(data_subject_id) >= 1) AND (octet_length(data_subject_id) <= 1024)))
  • agent_artifact_kind_check: CHECK ((kind = ANY (ARRAY['state'::text, 'file'::text])))
  • agent_artifact_last_digest_check: CHECK ((octet_length(last_digest) = 32))
  • agent_artifact_name_check: CHECK ((octet_length(name) <= 256))
  • agent_artifact_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.agent_storage_policy(scope)
  • agent_artifact_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • agent_artifact_source_observation_id_registration_kind_reg_fkey: FOREIGN KEY (source_observation_id, registration_kind, registration_id) REFERENCES memory.projection_dependency(source_observation_id, projection_kind, projection_id) DEFERRABLE INITIALLY DEFERRED
  • agent_artifact_artifact_id_not_null: NOT NULL artifact_id
  • agent_artifact_authored_by_not_null: NOT NULL authored_by
  • agent_artifact_content_not_null: NOT NULL content
  • agent_artifact_created_at_not_null: NOT NULL created_at
  • agent_artifact_data_subject_id_not_null: NOT NULL data_subject_id
  • agent_artifact_kind_not_null: NOT NULL kind
  • agent_artifact_last_digest_not_null: NOT NULL last_digest
  • agent_artifact_name_not_null: NOT NULL name
  • agent_artifact_scope_not_null: NOT NULL scope
  • agent_artifact_source_observation_id_not_null: NOT NULL source_observation_id
  • agent_artifact_updated_at_not_null: NOT NULL updated_at
  • agent_artifact_version_not_null: NOT NULL version
  • agent_artifact_pkey: PRIMARY KEY (scope, artifact_id)
  • agent_artifact_scope_source_observation_id_artifact_id_data_key: UNIQUE (scope, source_observation_id, artifact_id, data_subject_id)
  • agent_artifact_source_observation_id_key: UNIQUE (source_observation_id)

Indexes

  • agent_artifact_kind_page_idx: CREATE INDEX agent_artifact_kind_page_idx ON memory.agent_artifact USING btree (scope, kind, artifact_id)
  • agent_artifact_name_prefix_idx: CREATE INDEX agent_artifact_name_prefix_idx ON memory.agent_artifact USING btree (scope, name text_pattern_ops)
  • agent_artifact_pkey: CREATE UNIQUE INDEX agent_artifact_pkey ON memory.agent_artifact USING btree (scope, artifact_id)
  • agent_artifact_scope_source_observation_id_artifact_id_data_key: CREATE UNIQUE INDEX agent_artifact_scope_source_observation_id_artifact_id_data_key ON memory.agent_artifact USING btree (scope, source_observation_id, artifact_id, data_subject_id)
  • agent_artifact_source_observation_id_key: CREATE UNIQUE INDEX agent_artifact_source_observation_id_key ON memory.agent_artifact USING btree (source_observation_id)
  • agent_artifact_subject_page_idx: CREATE INDEX agent_artifact_subject_page_idx ON memory.agent_artifact USING btree (scope, data_subject_id, artifact_id)

Triggers

  • agent_artifact_accounting: CREATE TRIGGER agent_artifact_accounting BEFORE INSERT OR DELETE OR UPDATE ON memory.agent_artifact FOR EACH ROW EXECUTE FUNCTION memory.account_agent_artifact()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

agent_storage_policy

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
max_object_bytesbigintnot null262144
max_bytesbigintnot null16777216
max_objectsbigintnot null128
max_age_hoursintegernot null720
used_bytesbigintnot null0
used_objectsbigintnot null0

Constraints

  • agent_storage_policy_check: CHECK ((max_object_bytes <= max_bytes))
  • agent_storage_policy_max_age_hours_check: CHECK (((max_age_hours >= 1) AND (max_age_hours <= 8760)))
  • agent_storage_policy_max_bytes_check: CHECK (((max_bytes >= 1) AND (max_bytes <= 1073741824)))
  • agent_storage_policy_max_object_bytes_check: CHECK (((max_object_bytes >= 1) AND (max_object_bytes <= 524288)))
  • agent_storage_policy_max_objects_check: CHECK (((max_objects >= 1) AND (max_objects <= 100000)))
  • agent_storage_policy_used_bytes_check: CHECK ((used_bytes >= 0))
  • agent_storage_policy_used_objects_check: CHECK ((used_objects >= 0))
  • agent_storage_policy_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • agent_storage_policy_max_age_hours_not_null: NOT NULL max_age_hours
  • agent_storage_policy_max_bytes_not_null: NOT NULL max_bytes
  • agent_storage_policy_max_object_bytes_not_null: NOT NULL max_object_bytes
  • agent_storage_policy_max_objects_not_null: NOT NULL max_objects
  • agent_storage_policy_scope_not_null: NOT NULL scope
  • agent_storage_policy_used_bytes_not_null: NOT NULL used_bytes
  • agent_storage_policy_used_objects_not_null: NOT NULL used_objects
  • agent_storage_policy_pkey: PRIMARY KEY (scope)

Indexes

  • agent_storage_policy_pkey: CREATE UNIQUE INDEX agent_storage_policy_pkey ON memory.agent_storage_policy USING btree (scope)

Privileges

  • taisce_data: SELECT

Referenced by

audit_entry

What happened and who did it. Holds no data subject, no question, no quote and no content — so append-only is unconditional rather than a conflict with erasure. The cost is that a person can be told a recall happened and not which of their memories it read.

owner postgres

ColumnTypeNullDefaultComment
entry_idbigintnot nullnextval('memory.audit_entry_entry_id_seq'::regclass)
operationtextnot null
principaltextnot null
principal_kindtextnot null
projecttextnot null''::text
magnitudeintegernot null0
outcometextnot null
occurred_attimestamp with time zonenot nullnow()

Constraints

  • audit_magnitude_chk: CHECK ((magnitude >= 0))
  • audit_operation_chk: CHECK ((operation = ANY (ARRAY['observe'::text, 'recall'::text, 'erase'::text, 'freshness'::text, 'export'::text, 'authenticate'::text, 'project.create'::text, 'project.suspend'::text, 'project.resume'::text, 'project.retention'::text, 'credential.issue'::text, 'credential.revoke'::text, 'formation.unpark'::text, 'formation.recover'::text, 'formation.rebuild'::text, 'formation.rebuild.start'::text, 'formation.rebuild.cancel'::text, 'citation.resolve'::text, 'message.get'::text, 'record.list'::text, 'record.history'::text, 'record.retract'::text, 'record.correct'::text, 'record.assert'::text, 'feedback.record'::text, 'feedback.list'::text, 'feedback.promote'::text, 'artifact.put'::text, 'artifact.get'::text, 'artifact.list'::text, 'artifact.delete'::text, 'artifact.configure'::text, 'subject.register'::text, 'subject.get'::text, 'subject.list'::text, 'subject.update'::text, 'entity.list'::text, 'entity.get'::text, 'entity.purge'::text, 'notification.register'::text, 'notification.list'::text, 'notification.disable'::text, 'notification.deliveries'::text, 'embedding.start'::text, 'embedding.build'::text, 'embedding.activate'::text, 'embedding.cancel'::text, 'embedding.prune'::text, 'embedding.repair'::text, 'embedding.search'::text, 'entity_embedding.start'::text, 'entity_embedding.build'::text, 'entity_embedding.activate'::text, 'entity_embedding.cancel'::text, 'entity_embedding.prune'::text, 'entity_embedding.repair'::text, 'entity_embedding.search'::text, 'report_embedding.start'::text, 'report_embedding.build'::text, 'report_embedding.activate'::text, 'report_embedding.cancel'::text, 'report_embedding.prune'::text, 'report_embedding.repair'::text, 'report_embedding.search'::text, 'context.assemble'::text, 'retention.sweep'::text, 'project.list'::text, 'credential.list'::text, 'refusal.summary'::text, 'erasure.list'::text, 'formation.status'::text, 'formation.parked'::text, 'audit.seal'::text, 'audit.verify'::text, 'audit.activity'::text])))
  • audit_outcome_chk: CHECK ((outcome = ANY (ARRAY['allowed'::text, 'refused'::text])))
  • audit_principal_chk: CHECK ((length(principal) > 0))
  • audit_principal_kind_chk: CHECK ((principal_kind = ANY (ARRAY['credential'::text, 'operator'::text, 'system'::text])))
  • audit_entry_entry_id_not_null: NOT NULL entry_id
  • audit_entry_magnitude_not_null: NOT NULL magnitude
  • audit_entry_occurred_at_not_null: NOT NULL occurred_at
  • audit_entry_operation_not_null: NOT NULL operation
  • audit_entry_outcome_not_null: NOT NULL outcome
  • audit_entry_principal_kind_not_null: NOT NULL principal_kind
  • audit_entry_principal_not_null: NOT NULL principal
  • audit_entry_project_not_null: NOT NULL project
  • audit_entry_pkey: PRIMARY KEY (entry_id)

Indexes

  • audit_entry_pkey: CREATE UNIQUE INDEX audit_entry_pkey ON memory.audit_entry USING btree (entry_id)
  • audit_principal_idx: CREATE INDEX audit_principal_idx ON memory.audit_entry USING btree (principal, occurred_at DESC)
  • audit_refused_idx: CREATE INDEX audit_refused_idx ON memory.audit_entry USING btree (occurred_at DESC) WHERE (outcome = 'refused'::text)
  • audit_time_idx: CREATE INDEX audit_time_idx ON memory.audit_entry USING btree (occurred_at DESC)

Triggers

  • audit_no_delete: CREATE TRIGGER audit_no_delete BEFORE DELETE ON memory.audit_entry FOR EACH ROW EXECUTE FUNCTION memory.audit_is_append_only()
  • audit_no_truncate: CREATE TRIGGER audit_no_truncate BEFORE TRUNCATE ON memory.audit_entry FOR EACH STATEMENT EXECUTE FUNCTION memory.audit_is_append_only()
  • audit_no_update: CREATE TRIGGER audit_no_update BEFORE UPDATE ON memory.audit_entry FOR EACH ROW EXECUTE FUNCTION memory.audit_is_append_only()

Privileges

  • taisce_data: INSERT, SELECT

audit_seal

Chained digests over ranges of audit entries. Rewriting a sealed entry changes its seal and every seal after it, so a rewrite must redo the whole chain rather than one row. It does not stop somebody who can rebuild everything — for that, the head digest is emitted to the process log, where whatever collects logs holds values a rebuilt chain cannot agree with.

owner postgres

ColumnTypeNullDefaultComment
seal_idbigintnot nullnextval('memory.audit_seal_seal_id_seq'::regclass)
from_entrybigintnot null
to_entrybigintnot null
entry_countintegernot null
entries_digestbyteanot null
previous_digestbyteanot null
digestbyteanot null
sealed_attimestamp with time zonenot nullnow()

Constraints

  • audit_seal_count_chk: CHECK ((entry_count > 0))
  • audit_seal_range_chk: CHECK ((to_entry >= from_entry))
  • audit_seal_digest_not_null: NOT NULL digest
  • audit_seal_entries_digest_not_null: NOT NULL entries_digest
  • audit_seal_entry_count_not_null: NOT NULL entry_count
  • audit_seal_from_entry_not_null: NOT NULL from_entry
  • audit_seal_previous_digest_not_null: NOT NULL previous_digest
  • audit_seal_seal_id_not_null: NOT NULL seal_id
  • audit_seal_sealed_at_not_null: NOT NULL sealed_at
  • audit_seal_to_entry_not_null: NOT NULL to_entry
  • audit_seal_pkey: PRIMARY KEY (seal_id)

Indexes

  • audit_seal_pkey: CREATE UNIQUE INDEX audit_seal_pkey ON memory.audit_seal USING btree (seal_id)
  • audit_seal_range_idx: CREATE INDEX audit_seal_range_idx ON memory.audit_seal USING btree (to_entry DESC)

Triggers

  • audit_seal_no_delete: CREATE TRIGGER audit_seal_no_delete BEFORE DELETE ON memory.audit_seal FOR EACH ROW EXECUTE FUNCTION memory.audit_is_append_only()
  • audit_seal_no_truncate: CREATE TRIGGER audit_seal_no_truncate BEFORE TRUNCATE ON memory.audit_seal FOR EACH STATEMENT EXECUTE FUNCTION memory.audit_is_append_only()
  • audit_seal_no_update: CREATE TRIGGER audit_seal_no_update BEFORE UPDATE ON memory.audit_seal FOR EACH ROW EXECUTE FUNCTION memory.audit_is_append_only()

Privileges

  • taisce_data: SELECT

chunk

owner postgres · partitioned by LIST (scope)

ColumnTypeNullDefaultComment
chunk_iduuidnot null
scopetextnot null
source_observation_iduuidnot null
texttextnot null
langtextnot null'en'::text
occurred_attimestamp with time zonenot null
source_roletextnot null
data_subject_idtext
source_message_ordinalintegerOrdinal of the turn_message this chunk was cut from. NULL for chunks with no message — a document, say. Evidence byte spans index into THAT message, never into the turn.

Constraints

  • chunk_message_identity_fk: FOREIGN KEY (source_observation_id, source_message_ordinal, chunk_id) REFERENCES memory.turn_message(observation_id, ordinal, chunk_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • chunk_source_project_fk: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) DEFERRABLE INITIALLY DEFERRED
  • chunk_chunk_id_not_null: NOT NULL chunk_id
  • chunk_lang_not_null: NOT NULL lang
  • chunk_occurred_at_not_null: NOT NULL occurred_at
  • chunk_scope_not_null: NOT NULL scope
  • chunk_source_observation_id_not_null: NOT NULL source_observation_id
  • chunk_source_role_not_null: NOT NULL source_role
  • chunk_text_not_null: NOT NULL text
  • chunk_pkey: PRIMARY KEY (scope, chunk_id)
  • chunk_source_identity_uniq: UNIQUE (scope, source_observation_id, chunk_id)

Indexes

  • chunk_pkey: CREATE UNIQUE INDEX chunk_pkey ON ONLY memory.chunk USING btree (scope, chunk_id)
  • chunk_source_identity_uniq: CREATE UNIQUE INDEX chunk_source_identity_uniq ON ONLY memory.chunk USING btree (scope, source_observation_id, chunk_id)
  • chunk_source_idx: CREATE INDEX chunk_source_idx ON ONLY memory.chunk USING btree (scope, source_observation_id)

Partitions

  • chunk_example: FOR VALUES IN ('example')
  • chunk_unpartitioned: DEFAULT

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

community

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
community_iduuidnot null
levelintegernot null
parent_iduuid
formed_attimestamp with time zonenot nullnow()

Constraints

  • community_level_chk: CHECK ((level >= 0))
  • community_parent_chk: CHECK (((level = 0) = (parent_id IS NULL)))
  • community_parent_project_fk: FOREIGN KEY (scope, parent_id) REFERENCES memory.community(scope, community_id) DEFERRABLE INITIALLY DEFERRED
  • community_community_id_not_null: NOT NULL community_id
  • community_formed_at_not_null: NOT NULL formed_at
  • community_level_not_null: NOT NULL level
  • community_scope_not_null: NOT NULL scope
  • community_pkey: PRIMARY KEY (scope, community_id)

Indexes

  • community_pkey: CREATE UNIQUE INDEX community_pkey ON memory.community USING btree (scope, community_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

community_member

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
community_iduuidnot null
entity_iduuidnot null

Constraints

  • community_member_scope_community_id_fkey: FOREIGN KEY (scope, community_id) REFERENCES memory.community(scope, community_id) ON DELETE CASCADE
  • member_entity_project_fk: FOREIGN KEY (scope, entity_id) REFERENCES memory.entity(scope, entity_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • community_member_community_id_not_null: NOT NULL community_id
  • community_member_entity_id_not_null: NOT NULL entity_id
  • community_member_scope_not_null: NOT NULL scope
  • community_member_pkey: PRIMARY KEY (scope, community_id, entity_id)

Indexes

  • community_member_entity_idx: CREATE INDEX community_member_entity_idx ON memory.community_member USING btree (scope, entity_id)
  • community_member_pkey: CREATE UNIQUE INDEX community_member_pkey ON memory.community_member USING btree (scope, community_id, entity_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

community_report

Prose written from what several people said about one subject. Registered to every observation that contributed and deleted when any contributor erases — without the exemption that keeps a shared entity, because an entity is a shared identity and this is shared text.

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
report_iduuidnot null
community_iduuidnot null
titletextnot null
summarytextnot null
importancerealnot null0
importance_reasontextnot null''::text
findingsjsonbnot null'[]'::jsonb
substitutedintegernot null0
droppedintegernot null0
written_attimestamp with time zonenot nullnow()
written_bytextnot null''::text

Constraints

  • community_report_counted_chk: CHECK (((substituted >= 0) AND (dropped >= 0)))
  • community_report_importance_chk: CHECK (((importance >= (0)::double precision) AND (importance <= (10)::double precision)))
  • community_report_summary_chk: CHECK ((btrim(summary) <> ''::text))
  • community_report_title_chk: CHECK ((btrim(title) <> ''::text))
  • community_report_written_by_check: CHECK ((octet_length(written_by) <= 128))
  • community_report_scope_community_id_fkey: FOREIGN KEY (scope, community_id) REFERENCES memory.community(scope, community_id) ON DELETE CASCADE
  • community_report_community_id_not_null: NOT NULL community_id
  • community_report_dropped_not_null: NOT NULL dropped
  • community_report_findings_not_null: NOT NULL findings
  • community_report_importance_not_null: NOT NULL importance
  • community_report_importance_reason_not_null: NOT NULL importance_reason
  • community_report_report_id_not_null: NOT NULL report_id
  • community_report_scope_not_null: NOT NULL scope
  • community_report_substituted_not_null: NOT NULL substituted
  • community_report_summary_not_null: NOT NULL summary
  • community_report_title_not_null: NOT NULL title
  • community_report_written_at_not_null: NOT NULL written_at
  • community_report_written_by_not_null: NOT NULL written_by
  • community_report_pkey: PRIMARY KEY (scope, report_id)
  • community_report_scope_community_id_key: UNIQUE (scope, community_id)

Indexes

  • community_report_pkey: CREATE UNIQUE INDEX community_report_pkey ON memory.community_report USING btree (scope, report_id)
  • community_report_scope_community_id_key: CREATE UNIQUE INDEX community_report_scope_community_id_key ON memory.community_report USING btree (scope, community_id)
  • community_report_writer_idx: CREATE INDEX community_report_writer_idx ON memory.community_report USING btree (scope, written_by)

Triggers

  • report_embedding_change_lock: CREATE TRIGGER report_embedding_change_lock BEFORE DELETE OR UPDATE ON memory.community_report FOR EACH ROW EXECUTE FUNCTION memory.lock_report_embedding_change()
  • report_embedding_report_changed: CREATE TRIGGER report_embedding_report_changed AFTER INSERT OR DELETE OR UPDATE ON memory.community_report FOR EACH ROW EXECUTE FUNCTION memory.stale_report_embedding_snapshots()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

curated_claim

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
source_observation_iduuidnot null
fact_iduuidnot null
principal_iduuidnot null
claimjsonbnot null

Constraints

  • curated_claim_claim_check: CHECK ((jsonb_typeof(claim) = 'object'::text))
  • curated_claim_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • curated_claim_claim_not_null: NOT NULL claim
  • curated_claim_fact_id_not_null: NOT NULL fact_id
  • curated_claim_principal_id_not_null: NOT NULL principal_id
  • curated_claim_scope_not_null: NOT NULL scope
  • curated_claim_source_observation_id_not_null: NOT NULL source_observation_id
  • curated_claim_pkey: PRIMARY KEY (scope, source_observation_id)
  • curated_claim_scope_fact_id_key: UNIQUE (scope, fact_id)

Indexes

  • curated_claim_pkey: CREATE UNIQUE INDEX curated_claim_pkey ON memory.curated_claim USING btree (scope, source_observation_id)
  • curated_claim_scope_fact_id_key: CREATE UNIQUE INDEX curated_claim_scope_fact_id_key ON memory.curated_claim USING btree (scope, fact_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

data_subject

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
subject_idtextnot null
external_referencetext
labeltextnot null
versionuuidnot null
previous_versionuuid
last_digestbyteanot null
updated_byuuidnot null
created_attimestamp with time zonenot nullclock_timestamp()
updated_attimestamp with time zonenot nullclock_timestamp()
inactive_aftertimestamp with time zone

Constraints

  • data_subject_external_reference_check: CHECK (((external_reference IS NULL) OR (((octet_length(external_reference) >= 1) AND (octet_length(external_reference) <= 1024)) AND (length(btrim(external_reference)) > 0))))
  • data_subject_label_check: CHECK ((octet_length(label) <= 256))
  • data_subject_last_digest_check: CHECK ((octet_length(last_digest) = 32))
  • data_subject_subject_id_check: CHECK ((subject_id ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'::text))
  • data_subject_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • data_subject_created_at_not_null: NOT NULL created_at
  • data_subject_label_not_null: NOT NULL label
  • data_subject_last_digest_not_null: NOT NULL last_digest
  • data_subject_scope_not_null: NOT NULL scope
  • data_subject_subject_id_not_null: NOT NULL subject_id
  • data_subject_updated_at_not_null: NOT NULL updated_at
  • data_subject_updated_by_not_null: NOT NULL updated_by
  • data_subject_version_not_null: NOT NULL version
  • data_subject_pkey: PRIMARY KEY (scope, subject_id)
  • subject_external_reference_unique: UNIQUE (scope, external_reference)

Indexes

  • data_subject_pkey: CREATE UNIQUE INDEX data_subject_pkey ON memory.data_subject USING btree (scope, subject_id)
  • subject_external_reference_unique: CREATE UNIQUE INDEX subject_external_reference_unique ON memory.data_subject USING btree (scope, external_reference)
  • subject_inactive_idx: CREATE INDEX subject_inactive_idx ON memory.data_subject USING btree (scope, inactive_after, subject_id) WHERE (inactive_after IS NOT NULL)

Triggers

  • subject_identity_immutable: CREATE TRIGGER subject_identity_immutable BEFORE UPDATE ON memory.data_subject FOR EACH ROW EXECUTE FUNCTION memory.protect_subject_identity()
  • subject_retry_forgets_payload: CREATE TRIGGER subject_retry_forgets_payload BEFORE DELETE ON memory.data_subject FOR EACH ROW EXECUTE FUNCTION memory.clear_subject_retry_payload()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

embedding_active

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
activated_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • embedding_active_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • embedding_active_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.embedding_generation(scope, generation_id)
  • embedding_active_activated_at_not_null: NOT NULL activated_at
  • embedding_active_generation_id_not_null: NOT NULL generation_id
  • embedding_active_scope_not_null: NOT NULL scope
  • embedding_active_pkey: PRIMARY KEY (scope)

Indexes

  • embedding_active_pkey: CREATE UNIQUE INDEX embedding_active_pkey ON memory.embedding_active USING btree (scope)

Privileges

  • taisce_data: SELECT

embedding_build

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
statetextnot null'building'::text
after_offsetbigintnot null'-1'::integer
after_ordinalintegernot null'-1'::integer
examinedbigintnot null0
storedbigintnot null0
lease_iduuid
updated_attimestamp with time zonenot nullclock_timestamp()
through_offsetbigintnot null'-1'::integer
covered_through_offsetbigintnot null'-1'::integer

Constraints

  • embedding_build_after_offset_check: CHECK ((after_offset >= '-1'::integer))
  • embedding_build_after_ordinal_check: CHECK ((after_ordinal >= '-1'::integer))
  • embedding_build_check: CHECK (((after_offset = '-1'::integer) = (after_ordinal = '-1'::integer)))
  • embedding_build_covered_through_offset_check: CHECK ((covered_through_offset >= '-1'::integer))
  • embedding_build_examined_check: CHECK ((examined >= 0))
  • embedding_build_state_check: CHECK ((state = ANY (ARRAY['building'::text, 'ready'::text, 'cancelled'::text, 'discarded'::text])))
  • embedding_build_stored_check: CHECK ((stored >= 0))
  • embedding_build_through_offset_check: CHECK ((through_offset >= '-1'::integer))
  • embedding_coverage_within_target: CHECK ((covered_through_offset <= through_offset))
  • embedding_build_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.embedding_generation(scope, generation_id) ON DELETE CASCADE
  • embedding_build_after_offset_not_null: NOT NULL after_offset
  • embedding_build_after_ordinal_not_null: NOT NULL after_ordinal
  • embedding_build_covered_through_offset_not_null: NOT NULL covered_through_offset
  • embedding_build_examined_not_null: NOT NULL examined
  • embedding_build_generation_id_not_null: NOT NULL generation_id
  • embedding_build_scope_not_null: NOT NULL scope
  • embedding_build_state_not_null: NOT NULL state
  • embedding_build_stored_not_null: NOT NULL stored
  • embedding_build_through_offset_not_null: NOT NULL through_offset
  • embedding_build_updated_at_not_null: NOT NULL updated_at
  • embedding_build_pkey: PRIMARY KEY (scope, generation_id)

Indexes

  • embedding_build_pkey: CREATE UNIQUE INDEX embedding_build_pkey ON memory.embedding_build USING btree (scope, generation_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

embedding_generation

owner postgres

ColumnTypeNullDefaultComment
generation_iduuidnot null
scopetextnot null
operation_keyuuidnot null
model_nametextnot null
model_revisiontextnot null
endpoint_hashtextnot null
identity_hashtextnot null
dimensionsintegernot null
metrictextnot null'cosine'::text
input_versiontextnot null'message-text/v1'::text
through_offsetbigintnot null
created_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • embedding_generation_dimensions_check: CHECK (((dimensions >= 1) AND (dimensions <= 4000)))
  • embedding_generation_endpoint_hash_check: CHECK ((endpoint_hash ~ '^[0-9a-f]{64}$'::text))
  • embedding_generation_identity_hash_check: CHECK ((identity_hash ~ '^[0-9a-f]{64}$'::text))
  • embedding_generation_input_version_check: CHECK ((input_version = 'message-text/v1'::text))
  • embedding_generation_metric_check: CHECK ((metric = 'cosine'::text))
  • embedding_generation_model_name_check: CHECK (((octet_length(model_name) >= 1) AND (octet_length(model_name) <= 256)))
  • embedding_generation_model_revision_check: CHECK (((octet_length(model_revision) >= 1) AND (octet_length(model_revision) <= 128)))
  • embedding_generation_through_offset_check: CHECK ((through_offset >= '-1'::integer))
  • embedding_generation_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • embedding_generation_created_at_not_null: NOT NULL created_at
  • embedding_generation_dimensions_not_null: NOT NULL dimensions
  • embedding_generation_endpoint_hash_not_null: NOT NULL endpoint_hash
  • embedding_generation_generation_id_not_null: NOT NULL generation_id
  • embedding_generation_identity_hash_not_null: NOT NULL identity_hash
  • embedding_generation_input_version_not_null: NOT NULL input_version
  • embedding_generation_metric_not_null: NOT NULL metric
  • embedding_generation_model_name_not_null: NOT NULL model_name
  • embedding_generation_model_revision_not_null: NOT NULL model_revision
  • embedding_generation_operation_key_not_null: NOT NULL operation_key
  • embedding_generation_scope_not_null: NOT NULL scope
  • embedding_generation_through_offset_not_null: NOT NULL through_offset
  • embedding_generation_pkey: PRIMARY KEY (generation_id)
  • embedding_generation_scope_generation_id_dimensions_key: UNIQUE (scope, generation_id, dimensions)
  • embedding_generation_scope_generation_id_key: UNIQUE (scope, generation_id)
  • embedding_generation_scope_operation_key_key: UNIQUE (scope, operation_key)

Indexes

  • embedding_generation_pkey: CREATE UNIQUE INDEX embedding_generation_pkey ON memory.embedding_generation USING btree (generation_id)
  • embedding_generation_scope_generation_id_dimensions_key: CREATE UNIQUE INDEX embedding_generation_scope_generation_id_dimensions_key ON memory.embedding_generation USING btree (scope, generation_id, dimensions)
  • embedding_generation_scope_generation_id_key: CREATE UNIQUE INDEX embedding_generation_scope_generation_id_key ON memory.embedding_generation USING btree (scope, generation_id)
  • embedding_generation_scope_operation_key_key: CREATE UNIQUE INDEX embedding_generation_scope_operation_key_key ON memory.embedding_generation USING btree (scope, operation_key)

Triggers

  • embedding_identity_immutable: CREATE TRIGGER embedding_identity_immutable BEFORE UPDATE ON memory.embedding_generation FOR EACH ROW EXECUTE FUNCTION memory.immutable_embedding_identity()

Privileges

  • taisce_data: SELECT

Referenced by

entity

owner postgres

ColumnTypeNullDefaultComment
entity_iduuidnot null
scopetextnot null
canonical_nametextnot null
normalized_nametextnot null
entity_typetextnot null'thing'::text
aliasestext[]not null'{}'::text[]
resolution_versiontextnot null'entity/v1'::text
first_seen_attimestamp with time zonenot nullnow()
identity_kindtextnot null'named'::text
speaker_subject_idtext

Constraints

  • entity_identity_kind_chk: CHECK ((((identity_kind = 'named'::text) AND (speaker_subject_id IS NULL)) OR ((identity_kind = 'speaker'::text) AND (speaker_subject_id IS NOT NULL) AND (speaker_subject_id <> ''::text) AND (canonical_name = 'speaker'::text) AND (normalized_name = 'speaker'::text) AND (entity_type = 'person'::text) AND (aliases = '{}'::text[]))))
  • entity_aliases_not_null: NOT NULL aliases
  • entity_canonical_name_not_null: NOT NULL canonical_name
  • entity_entity_id_not_null: NOT NULL entity_id
  • entity_entity_type_not_null: NOT NULL entity_type
  • entity_first_seen_at_not_null: NOT NULL first_seen_at
  • entity_identity_kind_not_null: NOT NULL identity_kind
  • entity_normalized_name_not_null: NOT NULL normalized_name
  • entity_resolution_version_not_null: NOT NULL resolution_version
  • entity_scope_not_null: NOT NULL scope
  • entity_pkey: PRIMARY KEY (entity_id)
  • entity_scope_id_uniq: UNIQUE (scope, entity_id)

Indexes

  • entity_named_identity_uniq: CREATE UNIQUE INDEX entity_named_identity_uniq ON memory.entity USING btree (scope, normalized_name) WHERE (identity_kind = 'named'::text)
  • entity_pkey: CREATE UNIQUE INDEX entity_pkey ON memory.entity USING btree (entity_id)
  • entity_scope_id_uniq: CREATE UNIQUE INDEX entity_scope_id_uniq ON memory.entity USING btree (scope, entity_id)
  • entity_speaker_identity_uniq: CREATE UNIQUE INDEX entity_speaker_identity_uniq ON memory.entity USING btree (scope, speaker_subject_id) WHERE (identity_kind = 'speaker'::text)

Triggers

  • entity_embedding_entity_changed: CREATE TRIGGER entity_embedding_entity_changed AFTER DELETE OR UPDATE ON memory.entity FOR EACH ROW EXECUTE FUNCTION memory.invalidate_entity_embeddings()
  • entity_embedding_entity_created: CREATE TRIGGER entity_embedding_entity_created AFTER INSERT ON memory.entity FOR EACH ROW EXECUTE FUNCTION memory.stale_entity_embedding_snapshots()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

entity_embedding

owner postgres · partitioned by LIST (generation_id)

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
entity_iduuidnot null
embedding_keytextgenerated: (((generation_id)::text || '/'::text) || (entity_id)::text)
input_digestbyteanot null
source_digestbyteanot null
source_countintegernot null
embeddingvectornot null
dimensionsintegergenerated: vector_dims(embedding)

Constraints

  • entity_embedding_embedding_check: CHECK ((vector_norm(embedding) > (0)::double precision))
  • entity_embedding_input_digest_check: CHECK ((octet_length(input_digest) = 32))
  • entity_embedding_source_count_check: CHECK (((source_count >= 1) AND (source_count <= 4096)))
  • entity_embedding_source_digest_check: CHECK ((octet_length(source_digest) = 32))
  • entity_embedding_scope_generation_id_dimensions_fkey: FOREIGN KEY (scope, generation_id, dimensions) REFERENCES memory.entity_embedding_generation(scope, generation_id, dimensions)
  • entity_embedding_scope_generation_id_entity_id_fkey: FOREIGN KEY (scope, generation_id, entity_id) REFERENCES memory.entity_embedding_target(scope, generation_id, entity_id) ON DELETE CASCADE
  • entity_embedding_embedding_not_null: NOT NULL embedding
  • entity_embedding_entity_id_not_null: NOT NULL entity_id
  • entity_embedding_generation_id_not_null: NOT NULL generation_id
  • entity_embedding_input_digest_not_null: NOT NULL input_digest
  • entity_embedding_scope_not_null: NOT NULL scope
  • entity_embedding_source_count_not_null: NOT NULL source_count
  • entity_embedding_source_digest_not_null: NOT NULL source_digest
  • entity_embedding_pkey: PRIMARY KEY (scope, generation_id, entity_id)
  • entity_embedding_scope_generation_id_embedding_key_key: UNIQUE (scope, generation_id, embedding_key)

Indexes

  • entity_embedding_pkey: CREATE UNIQUE INDEX entity_embedding_pkey ON ONLY memory.entity_embedding USING btree (scope, generation_id, entity_id)
  • entity_embedding_scope_generation_id_embedding_key_key: CREATE UNIQUE INDEX entity_embedding_scope_generation_id_embedding_key_key ON ONLY memory.entity_embedding USING btree (scope, generation_id, embedding_key)

Triggers

  • entity_embedding_removed: CREATE TRIGGER entity_embedding_removed AFTER DELETE ON memory.entity_embedding FOR EACH ROW EXECUTE FUNCTION memory.mark_entity_embedding_incomplete()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

entity_embedding_active

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
activated_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • entity_embedding_active_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • entity_embedding_active_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.entity_embedding_generation(scope, generation_id)
  • entity_embedding_active_activated_at_not_null: NOT NULL activated_at
  • entity_embedding_active_generation_id_not_null: NOT NULL generation_id
  • entity_embedding_active_scope_not_null: NOT NULL scope
  • entity_embedding_active_pkey: PRIMARY KEY (scope)

Indexes

  • entity_embedding_active_pkey: CREATE UNIQUE INDEX entity_embedding_active_pkey ON memory.entity_embedding_active USING btree (scope)

Privileges

  • taisce_data: SELECT

entity_embedding_build

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
statetextnot null'building'::text
after_entity_iduuid
examinedbigintnot null0
storedbigintnot null0
lease_iduuid
updated_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • entity_embedding_build_examined_check: CHECK ((examined >= 0))
  • entity_embedding_build_state_check: CHECK ((state = ANY (ARRAY['building'::text, 'ready'::text, 'stale'::text, 'cancelled'::text, 'discarded'::text])))
  • entity_embedding_build_stored_check: CHECK ((stored >= 0))
  • entity_embedding_build_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.entity_embedding_generation(scope, generation_id) ON DELETE CASCADE
  • entity_embedding_build_examined_not_null: NOT NULL examined
  • entity_embedding_build_generation_id_not_null: NOT NULL generation_id
  • entity_embedding_build_scope_not_null: NOT NULL scope
  • entity_embedding_build_state_not_null: NOT NULL state
  • entity_embedding_build_stored_not_null: NOT NULL stored
  • entity_embedding_build_updated_at_not_null: NOT NULL updated_at
  • entity_embedding_build_pkey: PRIMARY KEY (scope, generation_id)

Indexes

  • entity_embedding_build_pkey: CREATE UNIQUE INDEX entity_embedding_build_pkey ON memory.entity_embedding_build USING btree (scope, generation_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

entity_embedding_generation

owner postgres

ColumnTypeNullDefaultComment
generation_iduuidnot null
scopetextnot null
operation_keyuuidnot null
model_nametextnot null
model_revisiontextnot null
endpoint_hashtextnot null
identity_hashtextnot null
dimensionsintegernot null
metrictextnot null'cosine'::text
input_versiontextnot null'entity-evidence/v1'::text
target_countbigintnot null0
created_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • entity_embedding_generation_dimensions_check: CHECK (((dimensions >= 1) AND (dimensions <= 4000)))
  • entity_embedding_generation_endpoint_hash_check: CHECK ((endpoint_hash ~ '^[0-9a-f]{64}$'::text))
  • entity_embedding_generation_identity_hash_check: CHECK ((identity_hash ~ '^[0-9a-f]{64}$'::text))
  • entity_embedding_generation_input_version_check: CHECK ((input_version = 'entity-evidence/v1'::text))
  • entity_embedding_generation_metric_check: CHECK ((metric = 'cosine'::text))
  • entity_embedding_generation_model_name_check: CHECK (((octet_length(model_name) >= 1) AND (octet_length(model_name) <= 256)))
  • entity_embedding_generation_model_revision_check: CHECK (((octet_length(model_revision) >= 1) AND (octet_length(model_revision) <= 128)))
  • entity_embedding_generation_target_count_check: CHECK ((target_count >= 0))
  • entity_embedding_generation_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • entity_embedding_generation_created_at_not_null: NOT NULL created_at
  • entity_embedding_generation_dimensions_not_null: NOT NULL dimensions
  • entity_embedding_generation_endpoint_hash_not_null: NOT NULL endpoint_hash
  • entity_embedding_generation_generation_id_not_null: NOT NULL generation_id
  • entity_embedding_generation_identity_hash_not_null: NOT NULL identity_hash
  • entity_embedding_generation_input_version_not_null: NOT NULL input_version
  • entity_embedding_generation_metric_not_null: NOT NULL metric
  • entity_embedding_generation_model_name_not_null: NOT NULL model_name
  • entity_embedding_generation_model_revision_not_null: NOT NULL model_revision
  • entity_embedding_generation_operation_key_not_null: NOT NULL operation_key
  • entity_embedding_generation_scope_not_null: NOT NULL scope
  • entity_embedding_generation_target_count_not_null: NOT NULL target_count
  • entity_embedding_generation_pkey: PRIMARY KEY (generation_id)
  • entity_embedding_generation_scope_generation_id_dimensions_key: UNIQUE (scope, generation_id, dimensions)
  • entity_embedding_generation_scope_generation_id_key: UNIQUE (scope, generation_id)
  • entity_embedding_generation_scope_operation_key_key: UNIQUE (scope, operation_key)

Indexes

  • entity_embedding_generation_pkey: CREATE UNIQUE INDEX entity_embedding_generation_pkey ON memory.entity_embedding_generation USING btree (generation_id)
  • entity_embedding_generation_scope_generation_id_dimensions_key: CREATE UNIQUE INDEX entity_embedding_generation_scope_generation_id_dimensions_key ON memory.entity_embedding_generation USING btree (scope, generation_id, dimensions)
  • entity_embedding_generation_scope_generation_id_key: CREATE UNIQUE INDEX entity_embedding_generation_scope_generation_id_key ON memory.entity_embedding_generation USING btree (scope, generation_id)
  • entity_embedding_generation_scope_operation_key_key: CREATE UNIQUE INDEX entity_embedding_generation_scope_operation_key_key ON memory.entity_embedding_generation USING btree (scope, operation_key)

Triggers

  • entity_embedding_identity_immutable: CREATE TRIGGER entity_embedding_identity_immutable BEFORE UPDATE ON memory.entity_embedding_generation FOR EACH ROW EXECUTE FUNCTION memory.immutable_entity_embedding_identity()

Privileges

  • taisce_data: SELECT

Referenced by

entity_embedding_source

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
entity_iduuidnot null
source_observation_iduuidnot null
embedding_keytextgenerated: (((generation_id)::text || '/'::text) || (entity_id)::text)
registration_kindtextgenerated: 'entity_embedding'::text

Constraints

  • entity_embedding_source_scope_generation_id_entity_id_fkey: FOREIGN KEY (scope, generation_id, entity_id) REFERENCES memory.entity_embedding(scope, generation_id, entity_id) ON DELETE CASCADE
  • entity_embedding_source_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • entity_embedding_source_source_observation_id_registration_fkey: FOREIGN KEY (source_observation_id, registration_kind, embedding_key) REFERENCES memory.projection_dependency(source_observation_id, projection_kind, projection_id) DEFERRABLE INITIALLY DEFERRED
  • entity_embedding_source_entity_id_not_null: NOT NULL entity_id
  • entity_embedding_source_generation_id_not_null: NOT NULL generation_id
  • entity_embedding_source_scope_not_null: NOT NULL scope
  • entity_embedding_source_source_observation_id_not_null: NOT NULL source_observation_id
  • entity_embedding_source_pkey: PRIMARY KEY (scope, generation_id, entity_id, source_observation_id)

Indexes

  • entity_embedding_source_observation_idx: CREATE INDEX entity_embedding_source_observation_idx ON memory.entity_embedding_source USING btree (scope, source_observation_id)
  • entity_embedding_source_pkey: CREATE UNIQUE INDEX entity_embedding_source_pkey ON memory.entity_embedding_source USING btree (scope, generation_id, entity_id, source_observation_id)

Triggers

  • entity_embedding_source_removed: CREATE TRIGGER entity_embedding_source_removed AFTER DELETE ON memory.entity_embedding_source FOR EACH ROW EXECUTE FUNCTION memory.invalidate_entity_embedding_source()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

entity_embedding_target

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
entity_iduuidnot null

Constraints

  • entity_embedding_target_scope_entity_id_fkey: FOREIGN KEY (scope, entity_id) REFERENCES memory.entity(scope, entity_id) ON DELETE CASCADE
  • entity_embedding_target_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.entity_embedding_generation(scope, generation_id) ON DELETE CASCADE
  • entity_embedding_target_entity_id_not_null: NOT NULL entity_id
  • entity_embedding_target_generation_id_not_null: NOT NULL generation_id
  • entity_embedding_target_scope_not_null: NOT NULL scope
  • entity_embedding_target_pkey: PRIMARY KEY (scope, generation_id, entity_id)

Indexes

  • entity_embedding_target_pkey: CREATE UNIQUE INDEX entity_embedding_target_pkey ON memory.entity_embedding_target USING btree (scope, generation_id, entity_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

entity_name_receipt

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
source_observation_iduuidnot null
entity_iduuidnot null
nametextnot null
normalized_nametextnot null
name_hashbyteanot null

Constraints

  • entity_name_receipt_name_check: CHECK (((octet_length(name) >= 1) AND (octet_length(name) <= 4096)))
  • entity_name_receipt_normalized_name_check: CHECK (((octet_length(normalized_name) >= 1) AND (octet_length(normalized_name) <= 4096)))
  • entity_name_receipt_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • entity_name_receipt_entity_id_not_null: NOT NULL entity_id
  • entity_name_receipt_name_hash_not_null: NOT NULL name_hash
  • entity_name_receipt_name_not_null: NOT NULL name
  • entity_name_receipt_normalized_name_not_null: NOT NULL normalized_name
  • entity_name_receipt_scope_not_null: NOT NULL scope
  • entity_name_receipt_source_observation_id_not_null: NOT NULL source_observation_id
  • entity_name_receipt_pkey: PRIMARY KEY (scope, source_observation_id, entity_id, name_hash)

Indexes

  • entity_name_receipt_entity_idx: CREATE INDEX entity_name_receipt_entity_idx ON memory.entity_name_receipt USING btree (scope, entity_id)
  • entity_name_receipt_pkey: CREATE UNIQUE INDEX entity_name_receipt_pkey ON memory.entity_name_receipt USING btree (scope, source_observation_id, entity_id, name_hash)

Triggers

  • entity_embedding_name_changed: CREATE TRIGGER entity_embedding_name_changed AFTER INSERT OR DELETE OR UPDATE ON memory.entity_name_receipt FOR EACH ROW EXECUTE FUNCTION memory.invalidate_entity_embeddings()
  • entity_name_receipt_identity: CREATE TRIGGER entity_name_receipt_identity BEFORE INSERT OR UPDATE ON memory.entity_name_receipt FOR EACH ROW EXECUTE FUNCTION memory.validate_entity_name_receipt()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

erasure_request

owner postgres

ColumnTypeNullDefaultComment
request_iduuidnot null
scopetextnot null
selectorjsonbnot null
reasontextnot null
requested_attimestamp with time zonenot nullnow()
completed_attimestamp with time zone
residualjsonb

Constraints

  • erasure_residual_with_completion_chk: CHECK (((completed_at IS NULL) = (residual IS NULL)))
  • erasure_request_reason_not_null: NOT NULL reason
  • erasure_request_request_id_not_null: NOT NULL request_id
  • erasure_request_requested_at_not_null: NOT NULL requested_at
  • erasure_request_scope_not_null: NOT NULL scope
  • erasure_request_selector_not_null: NOT NULL selector
  • erasure_request_pkey: PRIMARY KEY (request_id)

Indexes

  • erasure_request_open_idx: CREATE INDEX erasure_request_open_idx ON memory.erasure_request USING btree (scope, requested_at) WHERE (completed_at IS NULL)
  • erasure_request_pkey: CREATE UNIQUE INDEX erasure_request_pkey ON memory.erasure_request USING btree (request_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

fact

owner postgres

ColumnTypeNullDefaultComment
fact_iduuidnot null
scopetextnot null
subject_entity_iduuid
object_entity_iduuid
predicatetextnot null
statementtextnot null
validtstzrangenot null
knowntstzrangenot nulltstzrange(now(), NULL::timestamp with time zone)
confidencerealnot null0
langtextnot null'en'::text
recorded_attimestamp with time zonenot nullnow()
data_subject_idtext
retention_untiltimestamp with time zoneWhen this fact stops answering, taken from the latest deadline of the observations supporting it, or null when one of them is kept indefinitely. The sweep deletes it afterwards; this is what makes it unreachable in between.
cardinalitytextnot nullCopied from the vocabulary so that the exclusion constraint can read it — a constraint cannot consult another table. A composite foreign key on (predicate, cardinality) makes the copy unable to disagree, so this is a denormalisation the database refuses to let go wrong.
source_roletextnot nullThe role of the message this fact was extracted from. Recoverable by joining evidence to the message, and kept here because every filter that wanted it would pay a join and the one that forgot would silently include everything — on the read path, where a planted fact looks exactly like a stated one.
superseded_byuuid
supersession_sourceuuid
versionuuidnot nullgen_random_uuid()

Constraints

  • fact_known_not_empty_chk: CHECK ((NOT isempty(known)))
  • fact_source_role_chk: CHECK ((source_role = ANY (ARRAY['user'::text, 'assistant'::text, 'system'::text, 'tool'::text, 'unknown'::text])))
  • fact_valid_not_empty_chk: CHECK ((NOT isempty(valid)))
  • fact_cardinality_matches_vocabulary: FOREIGN KEY (predicate, cardinality) REFERENCES memory.predicate(predicate, cardinality) ON UPDATE CASCADE
  • fact_object_project_fk: FOREIGN KEY (scope, object_entity_id) REFERENCES memory.entity(scope, entity_id) DEFERRABLE INITIALLY DEFERRED
  • fact_predicate_fk: FOREIGN KEY (predicate) REFERENCES memory.predicate(predicate)
  • fact_subject_project_fk: FOREIGN KEY (scope, subject_entity_id) REFERENCES memory.entity(scope, entity_id) DEFERRABLE INITIALLY DEFERRED
  • fact_successor_project_fk: FOREIGN KEY (scope, superseded_by) REFERENCES memory.fact(scope, fact_id) ON DELETE SET NULL (superseded_by) DEFERRABLE INITIALLY DEFERRED
  • fact_supersession_source_fk: FOREIGN KEY (scope, supersession_source) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_cardinality_not_null: NOT NULL cardinality
  • fact_confidence_not_null: NOT NULL confidence
  • fact_fact_id_not_null: NOT NULL fact_id
  • fact_known_not_null: NOT NULL known
  • fact_lang_not_null: NOT NULL lang
  • fact_predicate_not_null: NOT NULL predicate
  • fact_recorded_at_not_null: NOT NULL recorded_at
  • fact_scope_not_null: NOT NULL scope
  • fact_source_role_not_null: NOT NULL source_role
  • fact_statement_not_null: NOT NULL statement
  • fact_valid_not_null: NOT NULL valid
  • fact_version_not_null: NOT NULL version
  • fact_pkey: PRIMARY KEY (fact_id)
  • fact_scope_id_uniq: UNIQUE (scope, fact_id)
  • fact_single_cardinality_excl: EXCLUDE USING gist (scope WITH =, subject_entity_id WITH =, predicate WITH =, valid WITH &&, known WITH &&) WHERE (((cardinality = 'one'::text) AND (subject_entity_id IS NOT NULL)))

Indexes

  • fact_bitemporal_idx: CREATE INDEX fact_bitemporal_idx ON memory.fact USING gist (scope, valid, known)
  • fact_object_idx: CREATE INDEX fact_object_idx ON memory.fact USING gist (scope, object_entity_id, valid) WHERE (object_entity_id IS NOT NULL)
  • fact_object_walk_idx: CREATE INDEX fact_object_walk_idx ON memory.fact USING btree (object_entity_id, fact_id) WHERE (upper_inf(valid) AND upper_inf(known) AND (object_entity_id IS NOT NULL))
  • fact_pkey: CREATE UNIQUE INDEX fact_pkey ON memory.fact USING btree (fact_id)
  • fact_principal_idx: CREATE INDEX fact_principal_idx ON memory.fact USING btree (scope, subject_entity_id) WHERE ((source_role = 'user'::text) AND (subject_entity_id IS NOT NULL))
  • fact_reconcile_idx: CREATE INDEX fact_reconcile_idx ON memory.fact USING btree (scope, subject_entity_id, predicate) WHERE (upper_inf(valid) AND (subject_entity_id IS NOT NULL))
  • fact_retention_idx: CREATE INDEX fact_retention_idx ON memory.fact USING btree (scope, retention_until) WHERE (retention_until IS NOT NULL)
  • fact_scope_id_uniq: CREATE UNIQUE INDEX fact_scope_id_uniq ON memory.fact USING btree (scope, fact_id)
  • fact_single_cardinality_excl: CREATE INDEX fact_single_cardinality_excl ON memory.fact USING gist (scope, subject_entity_id, predicate, valid, known) WHERE ((cardinality = 'one'::text) AND (subject_entity_id IS NOT NULL))
  • fact_subject_idx: CREATE INDEX fact_subject_idx ON memory.fact USING gist (scope, subject_entity_id, valid) WHERE (subject_entity_id IS NOT NULL)
  • fact_subject_ref_idx: CREATE INDEX fact_subject_ref_idx ON memory.fact USING btree (scope, data_subject_id) WHERE (data_subject_id IS NOT NULL)
  • fact_subject_walk_idx: CREATE INDEX fact_subject_walk_idx ON memory.fact USING btree (subject_entity_id, fact_id) WHERE (upper_inf(valid) AND upper_inf(known) AND (subject_entity_id IS NOT NULL))
  • fact_successor_idx: CREATE INDEX fact_successor_idx ON memory.fact USING btree (scope, superseded_by) WHERE (superseded_by IS NOT NULL)
  • fact_supersession_source_idx: CREATE INDEX fact_supersession_source_idx ON memory.fact USING btree (scope, supersession_source) WHERE (supersession_source IS NOT NULL)

Triggers

  • entity_embedding_fact_changed: CREATE TRIGGER entity_embedding_fact_changed AFTER INSERT OR DELETE OR UPDATE ON memory.fact FOR EACH ROW EXECUTE FUNCTION memory.invalidate_entity_embeddings()
  • fact_record_version: CREATE TRIGGER fact_record_version BEFORE UPDATE ON memory.fact FOR EACH ROW EXECUTE FUNCTION memory.advance_record_version()
  • fact_report_revision: CREATE TRIGGER fact_report_revision BEFORE DELETE OR UPDATE ON memory.fact FOR EACH ROW EXECUTE FUNCTION memory.invalidate_fact_reports()
  • fact_transition_receipt: CREATE TRIGGER fact_transition_receipt AFTER UPDATE ON memory.fact FOR EACH ROW EXECUTE FUNCTION memory.retain_fact_transition()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

fact_evidence

owner postgres

ColumnTypeNullDefaultComment
fact_iduuidnot null
source_observation_iduuidnot null
quotetextnot null
byte_startintegernot null
byte_endintegernot null
extractor_versiontextnot null
source_ordinalintegernot nullOrdinal of the turn_message this span indexes. Byte offsets are meaningless without it: taken against another message of the same turn they resolve to a plausible fragment of the wrong sentence rather than to nothing.
scopetextnot null

Constraints

  • fact_evidence_ordinal_chk: CHECK ((source_ordinal >= 0))
  • fact_evidence_span_chk: CHECK ((byte_end > byte_start))
  • evidence_fact_project_fk: FOREIGN KEY (scope, fact_id) REFERENCES memory.fact(scope, fact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • evidence_message_fk: FOREIGN KEY (source_observation_id, source_ordinal) REFERENCES memory.turn_message(observation_id, ordinal) DEFERRABLE INITIALLY DEFERRED
  • evidence_source_project_fk: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) DEFERRABLE INITIALLY DEFERRED
  • fact_evidence_byte_end_not_null: NOT NULL byte_end
  • fact_evidence_byte_start_not_null: NOT NULL byte_start
  • fact_evidence_extractor_version_not_null: NOT NULL extractor_version
  • fact_evidence_fact_id_not_null: NOT NULL fact_id
  • fact_evidence_quote_not_null: NOT NULL quote
  • fact_evidence_scope_not_null: NOT NULL scope
  • fact_evidence_source_observation_id_not_null: NOT NULL source_observation_id
  • fact_evidence_source_ordinal_not_null: NOT NULL source_ordinal
  • fact_evidence_pkey: PRIMARY KEY (fact_id, source_observation_id, source_ordinal, byte_start)

Indexes

  • evidence_source_message_idx: CREATE INDEX evidence_source_message_idx ON memory.fact_evidence USING btree (source_observation_id, source_ordinal)
  • fact_evidence_pkey: CREATE UNIQUE INDEX fact_evidence_pkey ON memory.fact_evidence USING btree (fact_id, source_observation_id, source_ordinal, byte_start)

Triggers

  • entity_embedding_evidence_changed: CREATE TRIGGER entity_embedding_evidence_changed AFTER INSERT OR DELETE OR UPDATE ON memory.fact_evidence FOR EACH ROW EXECUTE FUNCTION memory.invalidate_entity_embeddings()
  • evidence_report_revision: CREATE TRIGGER evidence_report_revision AFTER INSERT OR DELETE OR UPDATE ON memory.fact_evidence FOR EACH ROW EXECUTE FUNCTION memory.invalidate_fact_reports()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

fact_generation

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
source_observation_iduuidnot null
operation_keyuuidnot null
extractor_versiontextnot null
previous_extractor_versiontext
previous_generation_iduuid
applied_attimestamp with time zonenot null
messages_readintegernot null
facts_assertedintegernot null
facts_retiredintegernot null
claims_rejectedintegernot null
claims_retractedintegernot null
claims_refused_by_roleintegernot null
principal_iduuidnot null

Constraints

  • fact_generation_claims_refused_by_role_check: CHECK (((claims_refused_by_role >= 0) AND (claims_refused_by_role <= 100)))
  • fact_generation_claims_rejected_check: CHECK (((claims_rejected >= 0) AND (claims_rejected <= 100)))
  • fact_generation_claims_retracted_check: CHECK (((claims_retracted >= 0) AND (claims_retracted <= 100)))
  • fact_generation_extractor_version_check: CHECK ((extractor_version ~ '^extract/v2:[a-f0-9]{64}$'::text))
  • fact_generation_facts_asserted_check: CHECK (((facts_asserted >= 0) AND (facts_asserted <= 100)))
  • fact_generation_facts_retired_check: CHECK (((facts_retired >= 0) AND (facts_retired <= 100)))
  • fact_generation_messages_read_check: CHECK (((messages_read >= 1) AND (messages_read <= 256)))
  • fact_generation_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • fact_generation_applied_at_not_null: NOT NULL applied_at
  • fact_generation_claims_refused_by_role_not_null: NOT NULL claims_refused_by_role
  • fact_generation_claims_rejected_not_null: NOT NULL claims_rejected
  • fact_generation_claims_retracted_not_null: NOT NULL claims_retracted
  • fact_generation_extractor_version_not_null: NOT NULL extractor_version
  • fact_generation_facts_asserted_not_null: NOT NULL facts_asserted
  • fact_generation_facts_retired_not_null: NOT NULL facts_retired
  • fact_generation_generation_id_not_null: NOT NULL generation_id
  • fact_generation_messages_read_not_null: NOT NULL messages_read
  • fact_generation_operation_key_not_null: NOT NULL operation_key
  • fact_generation_principal_id_not_null: NOT NULL principal_id
  • fact_generation_scope_not_null: NOT NULL scope
  • fact_generation_source_observation_id_not_null: NOT NULL source_observation_id
  • fact_generation_pkey: PRIMARY KEY (scope, generation_id)
  • fact_generation_scope_source_observation_id_generation_id_key: UNIQUE (scope, source_observation_id, generation_id)
  • fact_generation_scope_source_observation_id_operation_key_key: UNIQUE (scope, source_observation_id, operation_key)

Indexes

  • fact_generation_pkey: CREATE UNIQUE INDEX fact_generation_pkey ON memory.fact_generation USING btree (scope, generation_id)
  • fact_generation_scope_source_observation_id_generation_id_key: CREATE UNIQUE INDEX fact_generation_scope_source_observation_id_generation_id_key ON memory.fact_generation USING btree (scope, source_observation_id, generation_id)
  • fact_generation_scope_source_observation_id_operation_key_key: CREATE UNIQUE INDEX fact_generation_scope_source_observation_id_operation_key_key ON memory.fact_generation USING btree (scope, source_observation_id, operation_key)
  • generation_source_time_idx: CREATE INDEX generation_source_time_idx ON memory.fact_generation USING btree (scope, source_observation_id, applied_at DESC)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

fact_generation_record

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
source_observation_iduuidnot null
generation_iduuidnot null
fact_iduuidnot null
dispositiontextnot null

Constraints

  • fact_generation_record_disposition_check: CHECK ((disposition = ANY (ARRAY['admitted'::text, 'retired'::text])))
  • fact_generation_record_scope_fact_id_source_observation_id_fkey: FOREIGN KEY (scope, fact_id, source_observation_id) REFERENCES memory.fact_receipt(scope, fact_id, source_observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_generation_record_scope_source_observation_id_generat_fkey: FOREIGN KEY (scope, source_observation_id, generation_id) REFERENCES memory.fact_generation(scope, source_observation_id, generation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_generation_record_disposition_not_null: NOT NULL disposition
  • fact_generation_record_fact_id_not_null: NOT NULL fact_id
  • fact_generation_record_generation_id_not_null: NOT NULL generation_id
  • fact_generation_record_scope_not_null: NOT NULL scope
  • fact_generation_record_source_observation_id_not_null: NOT NULL source_observation_id
  • fact_generation_record_pkey: PRIMARY KEY (scope, generation_id, disposition, fact_id)

Indexes

  • fact_generation_record_pkey: CREATE UNIQUE INDEX fact_generation_record_pkey ON memory.fact_generation_record USING btree (scope, generation_id, disposition, fact_id)
  • generation_record_fact_idx: CREATE UNIQUE INDEX generation_record_fact_idx ON memory.fact_generation_record USING btree (scope, fact_id, disposition)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

fact_history

owner postgres

ColumnTypeNullDefaultComment
history_iduuidnot null
scopetextnot null
fact_iduuidnot null
validtstzrangenot null
knowntstzrangenot null
source_observation_iduuidnot null

Constraints

  • fact_history_known_check: CHECK (((NOT isempty(known)) AND (NOT upper_inf(known))))
  • fact_history_valid_check: CHECK ((NOT isempty(valid)))
  • fact_history_scope_fact_id_fkey: FOREIGN KEY (scope, fact_id) REFERENCES memory.fact(scope, fact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_history_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_history_fact_id_not_null: NOT NULL fact_id
  • fact_history_history_id_not_null: NOT NULL history_id
  • fact_history_known_not_null: NOT NULL known
  • fact_history_scope_not_null: NOT NULL scope
  • fact_history_source_observation_id_not_null: NOT NULL source_observation_id
  • fact_history_valid_not_null: NOT NULL valid
  • fact_history_pkey: PRIMARY KEY (history_id)
  • fact_history_scope_id_uniq: UNIQUE (scope, history_id)
  • fact_history_fact_id_known_excl: EXCLUDE USING gist (fact_id WITH =, known WITH &&)

Indexes

  • fact_history_fact_id_known_excl: CREATE INDEX fact_history_fact_id_known_excl ON memory.fact_history USING gist (fact_id, known)
  • fact_history_page_idx: CREATE INDEX fact_history_page_idx ON memory.fact_history USING btree (scope, fact_id, upper(known) DESC, history_id DESC)
  • fact_history_pkey: CREATE UNIQUE INDEX fact_history_pkey ON memory.fact_history USING btree (history_id)
  • fact_history_scope_id_uniq: CREATE UNIQUE INDEX fact_history_scope_id_uniq ON memory.fact_history USING btree (scope, history_id)
  • fact_history_source_idx: CREATE INDEX fact_history_source_idx ON memory.fact_history USING btree (scope, source_observation_id)

Triggers

  • fact_history_receipt: CREATE TRIGGER fact_history_receipt AFTER INSERT ON memory.fact_history FOR EACH ROW EXECUTE FUNCTION memory.retain_fact_history()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

fact_rebuild_job

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
job_iduuidnot null
extractor_versiontextnot null
through_offsetbigintnot null
after_offsetbigintnot null'-1'::integer
pending_offsetbigint
sources_rebuiltbigintnot null0
sources_skippedbigintnot null0
statustextnot null'active'::text
cancel_requestedbooleannot nullfalse
lease_iduuidnot null
created_attimestamp with time zonenot nullclock_timestamp()
updated_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • fact_rebuild_job_after_offset_check: CHECK ((after_offset >= '-1'::integer))
  • fact_rebuild_job_check: CHECK ((after_offset <= through_offset))
  • fact_rebuild_job_check1: CHECK (((pending_offset IS NULL) OR ((pending_offset > after_offset) AND (pending_offset <= through_offset))))
  • fact_rebuild_job_check2: CHECK (((status = 'active'::text) OR (pending_offset IS NULL)))
  • fact_rebuild_job_extractor_version_check: CHECK ((extractor_version ~ '^extract/v2:[a-f0-9]{64}$'::text))
  • fact_rebuild_job_sources_rebuilt_check: CHECK ((sources_rebuilt >= 0))
  • fact_rebuild_job_sources_skipped_check: CHECK ((sources_skipped >= 0))
  • fact_rebuild_job_status_check: CHECK ((status = ANY (ARRAY['active'::text, 'completed'::text, 'cancelled'::text])))
  • fact_rebuild_job_through_offset_check: CHECK ((through_offset >= '-1'::integer))
  • fact_rebuild_job_after_offset_not_null: NOT NULL after_offset
  • fact_rebuild_job_cancel_requested_not_null: NOT NULL cancel_requested
  • fact_rebuild_job_created_at_not_null: NOT NULL created_at
  • fact_rebuild_job_extractor_version_not_null: NOT NULL extractor_version
  • fact_rebuild_job_job_id_not_null: NOT NULL job_id
  • fact_rebuild_job_lease_id_not_null: NOT NULL lease_id
  • fact_rebuild_job_scope_not_null: NOT NULL scope
  • fact_rebuild_job_sources_rebuilt_not_null: NOT NULL sources_rebuilt
  • fact_rebuild_job_sources_skipped_not_null: NOT NULL sources_skipped
  • fact_rebuild_job_status_not_null: NOT NULL status
  • fact_rebuild_job_through_offset_not_null: NOT NULL through_offset
  • fact_rebuild_job_updated_at_not_null: NOT NULL updated_at
  • fact_rebuild_job_pkey: PRIMARY KEY (scope, job_id)

Indexes

  • fact_rebuild_job_pkey: CREATE UNIQUE INDEX fact_rebuild_job_pkey ON memory.fact_rebuild_job USING btree (scope, job_id)
  • one_active_fact_rebuild: CREATE UNIQUE INDEX one_active_fact_rebuild ON memory.fact_rebuild_job USING btree (scope) WHERE (status = 'active'::text)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

fact_receipt

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
fact_iduuidnot null
source_observation_iduuidnot null
source_ordinalintegernot null
statejsonbnot null
evidencejsonbnot null
subject_identityjsonb
object_identityjsonb
pipeline_versiontextnot null
supersession_sourceuuid
superseded_byuuid

Constraints

  • fact_receipt_check: CHECK ((((state ->> 'scope'::text) = scope) AND (((state ->> 'fact_id'::text))::uuid = fact_id)))
  • fact_receipt_evidence_check: CHECK ((jsonb_typeof(evidence) = 'object'::text))
  • fact_receipt_state_check: CHECK ((jsonb_typeof(state) = 'object'::text))
  • fact_receipt_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_receipt_scope_supersession_source_fkey: FOREIGN KEY (scope, supersession_source) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_receipt_source_observation_id_source_ordinal_fkey: FOREIGN KEY (source_observation_id, source_ordinal) REFERENCES memory.turn_message(observation_id, ordinal) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_receipt_evidence_not_null: NOT NULL evidence
  • fact_receipt_fact_id_not_null: NOT NULL fact_id
  • fact_receipt_pipeline_version_not_null: NOT NULL pipeline_version
  • fact_receipt_scope_not_null: NOT NULL scope
  • fact_receipt_source_observation_id_not_null: NOT NULL source_observation_id
  • fact_receipt_source_ordinal_not_null: NOT NULL source_ordinal
  • fact_receipt_state_not_null: NOT NULL state
  • fact_receipt_pkey: PRIMARY KEY (scope, fact_id)
  • receipt_generation_source_uniq: UNIQUE (scope, fact_id, source_observation_id)

Indexes

  • fact_receipt_cause_idx: CREATE INDEX fact_receipt_cause_idx ON memory.fact_receipt USING btree (scope, supersession_source) WHERE (supersession_source IS NOT NULL)
  • fact_receipt_pkey: CREATE UNIQUE INDEX fact_receipt_pkey ON memory.fact_receipt USING btree (scope, fact_id)
  • fact_receipt_source_idx: CREATE INDEX fact_receipt_source_idx ON memory.fact_receipt USING btree (scope, source_observation_id, fact_id)
  • fact_receipt_successor_idx: CREATE INDEX fact_receipt_successor_idx ON memory.fact_receipt USING btree (scope, superseded_by) WHERE (superseded_by IS NOT NULL)
  • receipt_generation_source_uniq: CREATE UNIQUE INDEX receipt_generation_source_uniq ON memory.fact_receipt USING btree (scope, fact_id, source_observation_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

fact_receipt_history

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
history_iduuidnot null
fact_iduuidnot null
validtstzrangenot null
knowntstzrangenot null
source_observation_iduuidnot null

Constraints

  • fact_receipt_history_known_check: CHECK (((NOT isempty(known)) AND (NOT upper_inf(known))))
  • fact_receipt_history_valid_check: CHECK ((NOT isempty(valid)))
  • fact_receipt_history_scope_fact_id_fkey: FOREIGN KEY (scope, fact_id) REFERENCES memory.fact_receipt(scope, fact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_receipt_history_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • fact_receipt_history_fact_id_not_null: NOT NULL fact_id
  • fact_receipt_history_history_id_not_null: NOT NULL history_id
  • fact_receipt_history_known_not_null: NOT NULL known
  • fact_receipt_history_scope_not_null: NOT NULL scope
  • fact_receipt_history_source_observation_id_not_null: NOT NULL source_observation_id
  • fact_receipt_history_valid_not_null: NOT NULL valid
  • fact_receipt_history_pkey: PRIMARY KEY (scope, history_id)

Indexes

  • fact_receipt_history_pkey: CREATE UNIQUE INDEX fact_receipt_history_pkey ON memory.fact_receipt_history USING btree (scope, history_id)
  • receipt_history_fact_idx: CREATE INDEX receipt_history_fact_idx ON memory.fact_receipt_history USING btree (scope, fact_id)
  • receipt_history_source_idx: CREATE INDEX receipt_history_source_idx ON memory.fact_receipt_history USING btree (scope, source_observation_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

formation_health

owner postgres

ColumnTypeNullDefaultComment
singletonbooleannot nulltrue
heartbeat_attimestamp with time zone
last_progress_attimestamp with time zone
last_failure_attimestamp with time zone
formed_countbigintnot null0
failed_attemptsbigintnot null0

Constraints

  • formation_health_failed_attempts_check: CHECK ((failed_attempts >= 0))
  • formation_health_formed_count_check: CHECK ((formed_count >= 0))
  • formation_health_singleton_check: CHECK (singleton)
  • formation_health_failed_attempts_not_null: NOT NULL failed_attempts
  • formation_health_formed_count_not_null: NOT NULL formed_count
  • formation_health_singleton_not_null: NOT NULL singleton
  • formation_health_pkey: PRIMARY KEY (singleton)

Indexes

  • formation_health_pkey: CREATE UNIQUE INDEX formation_health_pkey ON memory.formation_health USING btree (singleton)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

ingestion_budget

owner postgres

ColumnTypeNullDefaultComment
singletonbooleannot nulltrue
max_pendingbigintnot null4096
max_pending_per_projectbigintnot null512
pendingbigintnot null0

Constraints

  • ingestion_budget_check: CHECK (((max_pending_per_project >= 1) AND (max_pending_per_project <= max_pending)))
  • ingestion_budget_max_pending_check: CHECK (((max_pending >= 1) AND (max_pending <= 1000000)))
  • ingestion_budget_pending_check: CHECK ((pending >= 0))
  • ingestion_budget_singleton_check: CHECK (singleton)
  • ingestion_budget_max_pending_not_null: NOT NULL max_pending
  • ingestion_budget_max_pending_per_project_not_null: NOT NULL max_pending_per_project
  • ingestion_budget_pending_not_null: NOT NULL pending
  • ingestion_budget_singleton_not_null: NOT NULL singleton
  • ingestion_budget_pkey: PRIMARY KEY (singleton)

Indexes

  • ingestion_budget_pkey: CREATE UNIQUE INDEX ingestion_budget_pkey ON memory.ingestion_budget USING btree (singleton)

Privileges

  • taisce_data: SELECT

ingestion_project_usage

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
pendingbigintnot null

Constraints

  • ingestion_project_usage_pending_check: CHECK ((pending >= 0))
  • ingestion_project_usage_pending_not_null: NOT NULL pending
  • ingestion_project_usage_scope_not_null: NOT NULL scope
  • ingestion_project_usage_pkey: PRIMARY KEY (scope)

Indexes

  • ingestion_project_usage_pkey: CREATE UNIQUE INDEX ingestion_project_usage_pkey ON memory.ingestion_project_usage USING btree (scope)

Privileges

  • taisce_data: SELECT

ingestion_reservation

owner postgres

ColumnTypeNullDefaultComment
observation_iduuidnot null
scopetextnot null

Constraints

  • ingestion_reservation_scope_observation_id_fkey: FOREIGN KEY (scope, observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • ingestion_reservation_observation_id_not_null: NOT NULL observation_id
  • ingestion_reservation_scope_not_null: NOT NULL scope
  • ingestion_reservation_pkey: PRIMARY KEY (observation_id)
  • ingestion_reservation_release: TRIGGER DEFERRABLE INITIALLY DEFERRED

Indexes

  • ingestion_reservation_pkey: CREATE UNIQUE INDEX ingestion_reservation_pkey ON memory.ingestion_reservation USING btree (observation_id)

Triggers

  • ingestion_reservation_release: CREATE CONSTRAINT TRIGGER ingestion_reservation_release AFTER DELETE ON memory.ingestion_reservation DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION memory.release_ingestion_reservation()

Privileges

  • taisce_data: SELECT

memory_feedback

A report about a record that asserts nothing. Never read by recall: promoting it produces an ordinary correction or retraction, and that is what changes what the system believes.

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
feedback_iduuidnot nullgen_random_uuid()
target_fact_iduuidnot null
notetextnot null
proposed_objecttext
recorded_byuuidnot null
recorded_attimestamp with time zonenot nullnow()
promoted_byuuid
promoted_attimestamp with time zone
promotion_fact_iduuid

Constraints

  • feedback_note_chk: CHECK (((octet_length(note) >= 1) AND (octet_length(note) <= 16384)))
  • feedback_object_chk: CHECK (((proposed_object IS NULL) OR ((octet_length(proposed_object) >= 1) AND (octet_length(proposed_object) <= 1024))))
  • feedback_promotion_chk: CHECK ((num_nonnulls(promoted_by, promoted_at) = ANY (ARRAY[0, 2])))
  • feedback_promotion_record_chk: CHECK (((promotion_fact_id IS NULL) OR (promoted_at IS NOT NULL)))
  • feedback_target_fk: FOREIGN KEY (scope, target_fact_id) REFERENCES memory.fact(scope, fact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • memory_feedback_feedback_id_not_null: NOT NULL feedback_id
  • memory_feedback_note_not_null: NOT NULL note
  • memory_feedback_recorded_at_not_null: NOT NULL recorded_at
  • memory_feedback_recorded_by_not_null: NOT NULL recorded_by
  • memory_feedback_scope_not_null: NOT NULL scope
  • memory_feedback_target_fact_id_not_null: NOT NULL target_fact_id
  • memory_feedback_pkey: PRIMARY KEY (scope, feedback_id)

Indexes

  • memory_feedback_open_idx: CREATE INDEX memory_feedback_open_idx ON memory.memory_feedback USING btree (scope, recorded_at DESC, feedback_id DESC) WHERE (promoted_at IS NULL)
  • memory_feedback_pkey: CREATE UNIQUE INDEX memory_feedback_pkey ON memory.memory_feedback USING btree (scope, feedback_id)
  • memory_feedback_target_idx: CREATE INDEX memory_feedback_target_idx ON memory.memory_feedback USING btree (scope, target_fact_id, recorded_at DESC, feedback_id DESC)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

message_embedding

owner postgres · partitioned by LIST (generation_id)

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
chunk_iduuidnot null
source_observation_iduuidnot null
embedding_keytextnot null
input_digestbyteanot null
embeddingvectornot null
dimensionsintegergenerated: vector_dims(embedding)
registration_kindtextgenerated: 'message_embedding'::text

Constraints

  • message_embedding_check: CHECK ((embedding_key = (((generation_id)::text \|\| '/'::text) \|\| (chunk_id)::text)))
  • message_embedding_embedding_check: CHECK ((vector_norm(embedding) > (0)::double precision))
  • message_embedding_input_digest_check: CHECK ((octet_length(input_digest) = 32))
  • message_embedding_scope_generation_id_dimensions_fkey: FOREIGN KEY (scope, generation_id, dimensions) REFERENCES memory.embedding_generation(scope, generation_id, dimensions)
  • message_embedding_scope_source_observation_id_chunk_id_fkey: FOREIGN KEY (scope, source_observation_id, chunk_id) REFERENCES memory.chunk(scope, source_observation_id, chunk_id) DEFERRABLE INITIALLY DEFERRED
  • message_embedding_scope_source_observation_id_chunk_id_fkey_1: FOREIGN KEY (scope, source_observation_id, chunk_id) REFERENCES memory.chunk_unpartitioned(scope, source_observation_id, chunk_id) DEFERRABLE INITIALLY DEFERRED
  • message_embedding_scope_source_observation_id_chunk_id_fkey_2: FOREIGN KEY (scope, source_observation_id, chunk_id) REFERENCES memory.chunk_example(scope, source_observation_id, chunk_id) DEFERRABLE INITIALLY DEFERRED
  • message_embedding_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • message_embedding_source_observation_id_registration_kind__fkey: FOREIGN KEY (source_observation_id, registration_kind, embedding_key) REFERENCES memory.projection_dependency(source_observation_id, projection_kind, projection_id) DEFERRABLE INITIALLY DEFERRED
  • message_embedding_chunk_id_not_null: NOT NULL chunk_id
  • message_embedding_embedding_key_not_null: NOT NULL embedding_key
  • message_embedding_embedding_not_null: NOT NULL embedding
  • message_embedding_generation_id_not_null: NOT NULL generation_id
  • message_embedding_input_digest_not_null: NOT NULL input_digest
  • message_embedding_scope_not_null: NOT NULL scope
  • message_embedding_source_observation_id_not_null: NOT NULL source_observation_id
  • message_embedding_pkey: PRIMARY KEY (scope, generation_id, chunk_id)
  • message_embedding_scope_generation_id_source_observation_id_key: UNIQUE (scope, generation_id, source_observation_id, chunk_id)

Indexes

  • message_embedding_pkey: CREATE UNIQUE INDEX message_embedding_pkey ON ONLY memory.message_embedding USING btree (scope, generation_id, chunk_id)
  • message_embedding_scope_generation_id_source_observation_id_key: CREATE UNIQUE INDEX message_embedding_scope_generation_id_source_observation_id_key ON ONLY memory.message_embedding USING btree (scope, generation_id, source_observation_id, chunk_id)
  • message_embedding_source_idx: CREATE INDEX message_embedding_source_idx ON ONLY memory.message_embedding USING btree (scope, source_observation_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

notification_delivery

owner postgres

ColumnTypeNullDefaultComment
delivery_iduuidnot null
scopetextnot null
endpoint_iduuidnot null
formed_throughbigintnot null
stored_throughbigintnot null
formed_turnsintegernot null0
parked_turnsintegernot null0
attemptsintegernot null0
next_attempt_attimestamp with time zonenot nullnow()
delivered_attimestamp with time zone
parked_attimestamp with time zone
last_statusinteger
last_errortext
created_attimestamp with time zonenot nullnow()

Constraints

  • notification_delivery_last_error_category_chk: CHECK (((last_error IS NULL) OR (last_error = ANY (ARRAY['destination not permitted'::text, 'address not permitted'::text, 'redirect not followed'::text, 'timeout'::text, 'connection refused'::text, 'tls failure'::text, 'network error'::text, 'unrecorded'::text])) OR (last_error ~ '^destination (answered\|refused with) [0-9]{3}$'::text)))
  • notification_delivery_last_error_check: CHECK (((last_error IS NULL) OR (octet_length(last_error) <= 512)))
  • notification_delivery_endpoint_id_fkey: FOREIGN KEY (endpoint_id) REFERENCES memory.notification_endpoint(endpoint_id) ON DELETE CASCADE
  • notification_delivery_attempts_not_null: NOT NULL attempts
  • notification_delivery_created_at_not_null: NOT NULL created_at
  • notification_delivery_delivery_id_not_null: NOT NULL delivery_id
  • notification_delivery_endpoint_id_not_null: NOT NULL endpoint_id
  • notification_delivery_formed_through_not_null: NOT NULL formed_through
  • notification_delivery_formed_turns_not_null: NOT NULL formed_turns
  • notification_delivery_next_attempt_at_not_null: NOT NULL next_attempt_at
  • notification_delivery_parked_turns_not_null: NOT NULL parked_turns
  • notification_delivery_scope_not_null: NOT NULL scope
  • notification_delivery_stored_through_not_null: NOT NULL stored_through
  • notification_delivery_pkey: PRIMARY KEY (delivery_id)
  • notification_delivery_endpoint_id_formed_through_key: UNIQUE (endpoint_id, formed_through)

Indexes

  • notification_delivery_due_idx: CREATE INDEX notification_delivery_due_idx ON memory.notification_delivery USING btree (next_attempt_at, delivery_id) WHERE ((delivered_at IS NULL) AND (parked_at IS NULL))
  • notification_delivery_endpoint_id_formed_through_key: CREATE UNIQUE INDEX notification_delivery_endpoint_id_formed_through_key ON memory.notification_delivery USING btree (endpoint_id, formed_through)
  • notification_delivery_pkey: CREATE UNIQUE INDEX notification_delivery_pkey ON memory.notification_delivery USING btree (delivery_id)
  • notification_delivery_scope_idx: CREATE INDEX notification_delivery_scope_idx ON memory.notification_delivery USING btree (scope, created_at DESC)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

notification_endpoint

owner postgres

ColumnTypeNullDefaultComment
endpoint_iduuidnot null
scopetextnot null
urltextnot null
secretbyteanot null
created_attimestamp with time zonenot nullnow()
disabled_attimestamp with time zone

Constraints

  • notification_endpoint_secret_check: CHECK ((octet_length(secret) = 32))
  • notification_endpoint_url_check: CHECK (((octet_length(url) >= 8) AND (octet_length(url) <= 2048)))
  • notification_endpoint_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • notification_endpoint_created_at_not_null: NOT NULL created_at
  • notification_endpoint_endpoint_id_not_null: NOT NULL endpoint_id
  • notification_endpoint_scope_not_null: NOT NULL scope
  • notification_endpoint_secret_not_null: NOT NULL secret
  • notification_endpoint_url_not_null: NOT NULL url
  • notification_endpoint_pkey: PRIMARY KEY (endpoint_id)
  • notification_endpoint_scope_url_key: UNIQUE (scope, url)

Indexes

  • notification_endpoint_pkey: CREATE UNIQUE INDEX notification_endpoint_pkey ON memory.notification_endpoint USING btree (endpoint_id)
  • notification_endpoint_scope_idx: CREATE INDEX notification_endpoint_scope_idx ON memory.notification_endpoint USING btree (scope) WHERE (disabled_at IS NULL)
  • notification_endpoint_scope_url_key: CREATE UNIQUE INDEX notification_endpoint_scope_url_key ON memory.notification_endpoint USING btree (scope, url)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

observation

owner postgres

ColumnTypeNullDefaultComment
observation_iduuidnot null
scopetextnot null
log_offsetbigintnot null
kindtextnot null
occurred_attimestamp with time zonenot null
ingested_attimestamp with time zonenot nullnow()
source_roletextnot null
data_subject_idtext
lawful_basistext
retention_untiltimestamp with time zone
formed_attimestamp with time zoneWhen extraction ran over this turn's messages. NULL means the turn is stored and its facts do not exist yet. Set once, and never cleared: re-forming is a rebuild, which derives from the log rather than repairing rows in place.
formation_attemptsintegernot null0
formation_failed_attimestamp with time zone
formation_errortextWhy the last attempt failed, truncated. Kept on the observation rather than in a log because a provider error can contain the message that was sent to it: here it inherits the observation's governance and an erasure takes it, and in a log file it would be personal data no sweep can reach.
parked_attimestamp with time zoneWhen the driver stopped trying to form this turn. The observation and its messages are untouched, so re-forming it is a rebuild rather than a repair. A parked turn does not hold the formed watermark back, and the count of parked turns travels with freshness so that the exception to that number is visible rather than hidden.
fact_revisionbigintnot null1

Constraints

  • observation_attempts_chk: CHECK ((formation_attempts >= 0))
  • observation_error_length_chk: CHECK (((formation_error IS NULL) OR (length(formation_error) <= 2000)))
  • observation_fact_revision_check: CHECK ((fact_revision >= 1))
  • observation_parked_chk: CHECK (((parked_at IS NULL) OR (formation_attempts > 0)))
  • observation_parked_not_formed_chk: CHECK (((parked_at IS NULL) OR (formed_at IS NULL)))
  • observation_source_role_chk: CHECK ((source_role = ANY (ARRAY['user'::text, 'assistant'::text, 'system'::text, 'tool'::text, 'document'::text])))
  • observation_fact_revision_not_null: NOT NULL fact_revision
  • observation_formation_attempts_not_null: NOT NULL formation_attempts
  • observation_ingested_at_not_null: NOT NULL ingested_at
  • observation_kind_not_null: NOT NULL kind
  • observation_log_offset_not_null: NOT NULL log_offset
  • observation_observation_id_not_null: NOT NULL observation_id
  • observation_occurred_at_not_null: NOT NULL occurred_at
  • observation_scope_not_null: NOT NULL scope
  • observation_source_role_not_null: NOT NULL source_role
  • observation_pkey: PRIMARY KEY (observation_id)
  • observation_ingestion_reservation: TRIGGER DEFERRABLE INITIALLY DEFERRED
  • observation_fact_revision_uniq: UNIQUE (scope, observation_id, fact_revision)
  • observation_scope_id_uniq: UNIQUE (scope, observation_id)
  • observation_scope_offset_uniq: UNIQUE (scope, log_offset)

Indexes

  • observation_backlog_idx: CREATE INDEX observation_backlog_idx ON memory.observation USING btree (scope, log_offset) WHERE ((formed_at IS NULL) AND (parked_at IS NULL))
  • observation_fact_revision_uniq: CREATE UNIQUE INDEX observation_fact_revision_uniq ON memory.observation USING btree (scope, observation_id, fact_revision)
  • observation_parked_idx: CREATE INDEX observation_parked_idx ON memory.observation USING btree (scope, log_offset) WHERE (parked_at IS NOT NULL)
  • observation_pending_age_idx: CREATE INDEX observation_pending_age_idx ON memory.observation USING btree (ingested_at) WHERE ((kind = 'turn'::text) AND (formed_at IS NULL))
  • observation_pkey: CREATE UNIQUE INDEX observation_pkey ON memory.observation USING btree (observation_id)
  • observation_scope_expiry_idx: CREATE INDEX observation_scope_expiry_idx ON memory.observation USING btree (scope, retention_until, log_offset) WHERE (retention_until IS NOT NULL)
  • observation_scope_id_uniq: CREATE UNIQUE INDEX observation_scope_id_uniq ON memory.observation USING btree (scope, observation_id)
  • observation_scope_offset_uniq: CREATE UNIQUE INDEX observation_scope_offset_uniq ON memory.observation USING btree (scope, log_offset)
  • observation_subject_idx: CREATE INDEX observation_subject_idx ON memory.observation USING btree (scope, data_subject_id) WHERE (data_subject_id IS NOT NULL)

Triggers

  • observation_artifact_source: CREATE TRIGGER observation_artifact_source BEFORE UPDATE ON memory.observation FOR EACH ROW EXECUTE FUNCTION memory.protect_artifact_source()
  • observation_ingestion_reservation: CREATE CONSTRAINT TRIGGER observation_ingestion_reservation AFTER INSERT OR UPDATE OF formed_at, scope, kind ON memory.observation DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION memory.sync_ingestion_reservation()
  • observation_registered_subject: CREATE TRIGGER observation_registered_subject BEFORE INSERT OR UPDATE OF scope, data_subject_id ON memory.observation FOR EACH ROW EXECUTE FUNCTION memory.lock_registered_subject()
  • observation_retry_forgets_payload: CREATE TRIGGER observation_retry_forgets_payload BEFORE DELETE ON memory.observation FOR EACH ROW EXECUTE FUNCTION memory.clear_observation_retry_payload()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

observation_retry

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
key_digestbyteanot null
request_digestbytea
observation_iduuid

Constraints

  • observation_retry_check: CHECK (((observation_id IS NULL) = (request_digest IS NULL)))
  • observation_retry_key_digest_check: CHECK ((octet_length(key_digest) = 32))
  • observation_retry_request_digest_check: CHECK ((octet_length(request_digest) = 32))
  • observation_retry_scope_observation_id_fkey: FOREIGN KEY (scope, observation_id) REFERENCES memory.observation(scope, observation_id)
  • observation_retry_key_digest_not_null: NOT NULL key_digest
  • observation_retry_scope_not_null: NOT NULL scope
  • observation_retry_pkey: PRIMARY KEY (scope, key_digest)

Indexes

  • observation_retry_pkey: CREATE UNIQUE INDEX observation_retry_pkey ON memory.observation_retry USING btree (scope, key_digest)
  • observation_retry_source_idx: CREATE INDEX observation_retry_source_idx ON memory.observation_retry USING btree (observation_id) WHERE (observation_id IS NOT NULL)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

predicate

The closed relation vocabulary. fact.predicate references it, so an unknown relation cannot be stored by any path. A claim outside this set is recorded as unmapped and never admitted as an edge — the message it came from is already stored, so what is refused is the typed edge, not the memory.

owner postgres

ColumnTypeNullDefaultComment
predicatetextnot null
semantic_typetextnot null
cardinalitytextnot null
object_kindtextnot null
descriptiontextnot null
eventbooleannot nullfalseTrue for a relation that reports a completed occurrence and stays true afterwards, so its past tense is admitted. False for a state, whose past tense means it ended and is refused as not current.

Constraints

  • predicate_cardinality_chk: CHECK ((cardinality = ANY (ARRAY['one'::text, 'many'::text])))
  • predicate_name_chk: CHECK ((predicate ~ '^[a-z][a-z_]*[a-z]$'::text))
  • predicate_object_kind_chk: CHECK ((object_kind = ANY (ARRAY['person'::text, 'organisation'::text, 'place'::text, 'time'::text, 'value'::text, 'thing'::text])))
  • predicate_semantic_type_chk: CHECK ((semantic_type = ANY (ARRAY['identity'::text, 'preference'::text, 'capability'::text, 'intent'::text, 'social'::text, 'possession'::text, 'structure'::text, 'authorship'::text, 'temporal'::text, 'state'::text, 'constraint'::text])))
  • predicate_cardinality_not_null: NOT NULL cardinality
  • predicate_description_not_null: NOT NULL description
  • predicate_event_not_null: NOT NULL event
  • predicate_object_kind_not_null: NOT NULL object_kind
  • predicate_predicate_not_null: NOT NULL predicate
  • predicate_semantic_type_not_null: NOT NULL semantic_type
  • predicate_pkey: PRIMARY KEY (predicate)
  • predicate_cardinality_uniq: UNIQUE (predicate, cardinality)

Indexes

  • predicate_cardinality_uniq: CREATE UNIQUE INDEX predicate_cardinality_uniq ON memory.predicate USING btree (predicate, cardinality)
  • predicate_pkey: CREATE UNIQUE INDEX predicate_pkey ON memory.predicate USING btree (predicate)

Privileges

  • taisce_data: SELECT

Referenced by

  • fact through fact_cardinality_matches_vocabulary
  • fact through fact_predicate_fk

project

A project: where data belongs, what a token is attached to, which kinds of memory it keeps and how long it keeps them. Before this, a project was a string appearing on rows — which meant a project nobody had written to did not exist, and there was nowhere for a setting to live.

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
labeltextnot null
surfacestext[]not null'{}'::text[]Chosen at creation, added to afterwards, never removed — enforced by a trigger. Turning a surface off would either strand the data it stored or destroy it from a settings change; stopping one is an erasure and produces a receipt like any other.
retentioninterval
created_attimestamp with time zonenot nullnow()
suspended_attimestamp with time zone

Constraints

  • project_label_chk: CHECK ((length(label) > 0))
  • project_retention_chk: CHECK (((retention IS NULL) OR (retention > '00:00:00'::interval)))
  • project_scope_chk: CHECK ((scope ~ '^[a-z][a-z0-9_]{0,62}$'::text))
  • project_created_at_not_null: NOT NULL created_at
  • project_label_not_null: NOT NULL label
  • project_scope_not_null: NOT NULL scope
  • project_surfaces_not_null: NOT NULL surfaces
  • project_pkey: PRIMARY KEY (scope)

Indexes

  • project_pkey: CREATE UNIQUE INDEX project_pkey ON memory.project USING btree (scope)

Triggers

  • project_agent_storage_policy: CREATE TRIGGER project_agent_storage_policy AFTER INSERT ON memory.project FOR EACH ROW EXECUTE FUNCTION memory.initialize_agent_storage_policy()
  • project_surfaces_only_grow: CREATE TRIGGER project_surfaces_only_grow BEFORE UPDATE ON memory.project FOR EACH ROW EXECUTE FUNCTION memory.project_surfaces_only_grow()

Privileges

  • taisce_data: SELECT

Referenced by

projection_dependency

owner postgres

ColumnTypeNullDefaultComment
source_observation_iduuidnot null
scopetextnot null
projection_kindtextnot null
projection_idtextnot null
data_subject_idtext
retention_untiltimestamp with time zone
pipeline_versiontextnot null'v1'::text
registered_attimestamp with time zonenot nullnow()
entity_refuuidgenerated: CASE WHEN (projection_kind = 'entity'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
fact_refuuidgenerated: CASE WHEN (projection_kind = 'fact'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
chunk_refuuidgenerated: CASE WHEN (projection_kind = 'chunk'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
rejected_refuuidgenerated: CASE WHEN (projection_kind = 'rejected_claim'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
report_refuuidgenerated: CASE WHEN (projection_kind = 'community_report'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
history_refuuidgenerated: CASE WHEN (projection_kind = 'fact_history'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
report_source_revisionbigint
artifact_refuuidgenerated: CASE WHEN (projection_kind = 'agent_artifact'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
embedding_generation_refuuidgenerated: CASE WHEN (projection_kind = 'message_embedding'::text) THEN (split_part(projection_id, '/'::text, 1))::uuid ELSE NULL::uuid END
embedding_chunk_refuuidgenerated: CASE WHEN (projection_kind = 'message_embedding'::text) THEN (split_part(projection_id, '/'::text, 2))::uuid ELSE NULL::uuid END
entity_embedding_generation_refuuidgenerated: CASE WHEN (projection_kind = 'entity_embedding'::text) THEN (split_part(projection_id, '/'::text, 1))::uuid ELSE NULL::uuid END
entity_embedding_entity_refuuidgenerated: CASE WHEN (projection_kind = 'entity_embedding'::text) THEN (split_part(projection_id, '/'::text, 2))::uuid ELSE NULL::uuid END
report_embedding_generation_refuuidgenerated: CASE WHEN (projection_kind = 'report_embedding'::text) THEN (split_part(projection_id, '/'::text, 1))::uuid ELSE NULL::uuid END
report_embedding_report_refuuidgenerated: CASE WHEN (projection_kind = 'report_embedding'::text) THEN (split_part(projection_id, '/'::text, 2))::uuid ELSE NULL::uuid END
segment_refuuidgenerated: CASE WHEN (projection_kind = 'segment'::text) THEN (projection_id)::uuid ELSE NULL::uuid END
feedback_refuuidgenerated: CASE WHEN (projection_kind = 'feedback'::text) THEN (projection_id)::uuid ELSE NULL::uuid END

Constraints

  • artifact_dependency_owner_chk: CHECK (((artifact_ref IS NULL) OR (data_subject_id IS NOT NULL)))
  • dependency_one_target_chk: CHECK ((num_nonnulls(entity_ref, fact_ref, chunk_ref, rejected_ref, report_ref, history_ref, artifact_ref, embedding_generation_ref, entity_embedding_generation_ref, report_embedding_generation_ref, segment_ref, feedback_ref) = 1))
  • dependency_report_revision_chk: CHECK ((((projection_kind = 'community_report'::text) AND (report_source_revision IS NOT NULL) AND (report_source_revision > 0)) OR ((projection_kind <> 'community_report'::text) AND (report_source_revision IS NULL))))
  • dependency_artifact_owner_fk: FOREIGN KEY (scope, source_observation_id, artifact_ref, data_subject_id) REFERENCES memory.agent_artifact(scope, source_observation_id, artifact_id, data_subject_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_chunk_project_fk: FOREIGN KEY (scope, chunk_ref) REFERENCES memory.chunk(scope, chunk_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_chunk_project_fk_1: FOREIGN KEY (scope, chunk_ref) REFERENCES memory.chunk_unpartitioned(scope, chunk_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_chunk_project_fk_2: FOREIGN KEY (scope, chunk_ref) REFERENCES memory.chunk_example(scope, chunk_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_entity_embedding_source_fk: FOREIGN KEY (scope, entity_embedding_generation_ref, entity_embedding_entity_ref, source_observation_id) REFERENCES memory.entity_embedding_source(scope, generation_id, entity_id, source_observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_entity_project_fk: FOREIGN KEY (scope, entity_ref) REFERENCES memory.entity(scope, entity_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_fact_project_fk: FOREIGN KEY (scope, fact_ref) REFERENCES memory.fact(scope, fact_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_feedback_project_fk: FOREIGN KEY (scope, feedback_ref) REFERENCES memory.memory_feedback(scope, feedback_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_history_project_fk: FOREIGN KEY (scope, history_ref) REFERENCES memory.fact_history(scope, history_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_message_embedding_fk: FOREIGN KEY (scope, embedding_generation_ref, source_observation_id, embedding_chunk_ref) REFERENCES memory.message_embedding(scope, generation_id, source_observation_id, chunk_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_rejected_project_fk: FOREIGN KEY (scope, rejected_ref) REFERENCES memory.rejected_claim(scope, rejected_claim_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_report_embedding_source_fk: FOREIGN KEY (scope, report_embedding_generation_ref, report_embedding_report_ref, source_observation_id) REFERENCES memory.report_embedding_source(scope, generation_id, report_id, source_observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_report_project_fk: FOREIGN KEY (scope, report_ref) REFERENCES memory.community_report(scope, report_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • dependency_report_revision_fk: FOREIGN KEY (scope, source_observation_id, report_source_revision) REFERENCES memory.observation(scope, observation_id, fact_revision) DEFERRABLE INITIALLY DEFERRED
  • dependency_segment_fk: FOREIGN KEY (scope, segment_ref) REFERENCES memory.segment(scope, segment_id) ON DELETE CASCADE
  • dependency_source_project_fk: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • projection_dependency_kind_fk: FOREIGN KEY (projection_kind) REFERENCES memory.projection_kind(kind)
  • projection_dependency_pipeline_version_not_null: NOT NULL pipeline_version
  • projection_dependency_projection_id_not_null: NOT NULL projection_id
  • projection_dependency_projection_kind_not_null: NOT NULL projection_kind
  • projection_dependency_registered_at_not_null: NOT NULL registered_at
  • projection_dependency_scope_not_null: NOT NULL scope
  • projection_dependency_source_observation_id_not_null: NOT NULL source_observation_id
  • projection_dependency_pkey: PRIMARY KEY (source_observation_id, projection_kind, projection_id)

Indexes

  • dependency_artifact_ref_idx: CREATE INDEX dependency_artifact_ref_idx ON memory.projection_dependency USING btree (scope, artifact_ref) WHERE (artifact_ref IS NOT NULL)
  • dependency_chunk_ref_idx: CREATE INDEX dependency_chunk_ref_idx ON memory.projection_dependency USING btree (scope, chunk_ref) WHERE (chunk_ref IS NOT NULL)
  • dependency_embedding_ref_idx: CREATE INDEX dependency_embedding_ref_idx ON memory.projection_dependency USING btree (scope, embedding_generation_ref, embedding_chunk_ref) WHERE (embedding_generation_ref IS NOT NULL)
  • dependency_entity_embedding_ref_idx: CREATE INDEX dependency_entity_embedding_ref_idx ON memory.projection_dependency USING btree (scope, entity_embedding_generation_ref, entity_embedding_entity_ref) WHERE (entity_embedding_generation_ref IS NOT NULL)
  • dependency_entity_ref_idx: CREATE INDEX dependency_entity_ref_idx ON memory.projection_dependency USING btree (scope, entity_ref) WHERE (entity_ref IS NOT NULL)
  • dependency_fact_ref_idx: CREATE INDEX dependency_fact_ref_idx ON memory.projection_dependency USING btree (scope, fact_ref) WHERE (fact_ref IS NOT NULL)
  • dependency_feedback_ref_idx: CREATE INDEX dependency_feedback_ref_idx ON memory.projection_dependency USING btree (scope, feedback_ref) WHERE (feedback_ref IS NOT NULL)
  • dependency_history_ref_idx: CREATE INDEX dependency_history_ref_idx ON memory.projection_dependency USING btree (scope, history_ref) WHERE (history_ref IS NOT NULL)
  • dependency_rejected_ref_idx: CREATE INDEX dependency_rejected_ref_idx ON memory.projection_dependency USING btree (scope, rejected_ref) WHERE (rejected_ref IS NOT NULL)
  • dependency_report_embedding_ref_idx: CREATE INDEX dependency_report_embedding_ref_idx ON memory.projection_dependency USING btree (scope, report_embedding_generation_ref, report_embedding_report_ref) WHERE (report_embedding_generation_ref IS NOT NULL)
  • dependency_report_ref_idx: CREATE INDEX dependency_report_ref_idx ON memory.projection_dependency USING btree (scope, report_ref) WHERE (report_ref IS NOT NULL)
  • dependency_segment_ref_idx: CREATE INDEX dependency_segment_ref_idx ON memory.projection_dependency USING btree (scope, segment_ref) WHERE (segment_ref IS NOT NULL)
  • dependency_subject_fact_page_idx: CREATE INDEX dependency_subject_fact_page_idx ON memory.projection_dependency USING btree (scope, data_subject_id, fact_ref) WHERE (projection_kind = 'fact'::text)
  • projection_dependency_kind_idx: CREATE INDEX projection_dependency_kind_idx ON memory.projection_dependency USING btree (scope, projection_kind, projection_id)
  • projection_dependency_pkey: CREATE UNIQUE INDEX projection_dependency_pkey ON memory.projection_dependency USING btree (source_observation_id, projection_kind, projection_id)
  • projection_dependency_subject_idx: CREATE INDEX projection_dependency_subject_idx ON memory.projection_dependency USING btree (scope, data_subject_id) WHERE (data_subject_id IS NOT NULL)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

projection_kind

Every kind of derived row, and the table it lives in. projection_dependency references it, so a projection kind that is not declared here cannot be registered — which is what makes erasure's residual count cover everything rather than everything somebody remembered.

owner postgres

ColumnTypeNullDefaultComment
kindtextnot null
projection_tabletextnot null
id_columntextnot null
descriptiontextnot null
survives_sharingbooleannot nullfalseWhether a projection of this kind is KEPT when another data subject also registered it. True for a shared identity, whose row means the same thing to everybody who registered it. False for anything holding text drawn from several people, where keeping it because somebody else also contributed leaves the departing subject's words in a row the erasure counted as retained. Defaults to false: a kind added by somebody who did not read this deletes too much rather than leaking, because over-deletion is visible to the person who lost data and a leak is visible to nobody.

Constraints

  • projection_kind_column_chk: CHECK ((id_column ~ '^[a-z][a-z0-9_]*$'::text))
  • projection_kind_name_chk: CHECK ((kind ~ '^[a-z][a-z0-9_]*$'::text))
  • projection_kind_table_chk: CHECK ((projection_table ~ '^[a-z][a-z0-9_]*$'::text))
  • projection_kind_description_not_null: NOT NULL description
  • projection_kind_id_column_not_null: NOT NULL id_column
  • projection_kind_kind_not_null: NOT NULL kind
  • projection_kind_projection_table_not_null: NOT NULL projection_table
  • projection_kind_survives_sharing_not_null: NOT NULL survives_sharing
  • projection_kind_pkey: PRIMARY KEY (kind)

Indexes

  • projection_kind_pkey: CREATE UNIQUE INDEX projection_kind_pkey ON memory.projection_kind USING btree (kind)

Privileges

  • taisce_data: SELECT

Referenced by

record_retraction

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
target_fact_iduuidnot null
source_observation_iduuidnot null
source_ordinalintegernot null
claim_signaturebyteanot null
operation_iduuidnot null
target_versionuuidnot null
principal_iduuidnot null
retracted_attimestamp with time zonenot null
replacement_observation_iduuid
replacement_fact_iduuid

Constraints

  • record_retraction_claim_signature_check: CHECK ((octet_length(claim_signature) = 32))
  • record_retraction_source_ordinal_check: CHECK ((source_ordinal >= 0))
  • retraction_replacement_pair: CHECK (((replacement_observation_id IS NULL) = (replacement_fact_id IS NULL)))
  • record_retraction_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • record_retraction_source_observation_id_source_ordinal_fkey: FOREIGN KEY (source_observation_id, source_ordinal) REFERENCES memory.turn_message(observation_id, ordinal) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
  • retraction_replacement_source: FOREIGN KEY (scope, replacement_observation_id) REFERENCES memory.curated_claim(scope, source_observation_id) ON DELETE SET NULL (replacement_observation_id) DEFERRABLE INITIALLY DEFERRED
  • record_retraction_claim_signature_not_null: NOT NULL claim_signature
  • record_retraction_operation_id_not_null: NOT NULL operation_id
  • record_retraction_principal_id_not_null: NOT NULL principal_id
  • record_retraction_retracted_at_not_null: NOT NULL retracted_at
  • record_retraction_scope_not_null: NOT NULL scope
  • record_retraction_source_observation_id_not_null: NOT NULL source_observation_id
  • record_retraction_source_ordinal_not_null: NOT NULL source_ordinal
  • record_retraction_target_fact_id_not_null: NOT NULL target_fact_id
  • record_retraction_target_version_not_null: NOT NULL target_version
  • record_retraction_pkey: PRIMARY KEY (scope, target_fact_id, source_observation_id, source_ordinal)

Indexes

  • record_retraction_pkey: CREATE UNIQUE INDEX record_retraction_pkey ON memory.record_retraction USING btree (scope, target_fact_id, source_observation_id, source_ordinal)
  • retraction_source_claim_idx: CREATE INDEX retraction_source_claim_idx ON memory.record_retraction USING btree (scope, source_observation_id, source_ordinal, claim_signature)

Triggers

  • retraction_replacement_deletion: CREATE TRIGGER retraction_replacement_deletion BEFORE UPDATE OF replacement_observation_id ON memory.record_retraction FOR EACH ROW EXECUTE FUNCTION memory.clear_replacement_identifier()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

rejected_claim

Proposals that did not become facts, with the model's own wording. A relation outside the vocabulary and a quote that is not in the message are both ordinary outcomes, so neither is an error — but a rate that cannot be read is a claim that cannot be checked. Registers for erasure: a refused claim still carries somebody's words.

owner postgres

ColumnTypeNullDefaultComment
rejected_claim_iduuidnot null
scopetextnot null
source_observation_iduuidnot null
source_ordinalintegernot null
predicatetextnot null
statementtextnot null
quotetextnot null
reasontextnot null
extractor_versiontextnot null
data_subject_idtext
recorded_attimestamp with time zonenot nullnow()

Constraints

  • rejected_claim_ordinal_chk: CHECK ((source_ordinal >= 0))
  • rejected_claim_reason_chk: CHECK ((reason = ANY (ARRAY['unmapped_relation'::text, 'unlocatable_quote'::text, 'duplicate_claim'::text, 'not_asserted'::text, 'unresolvable_subject'::text, 'not_current'::text, 'conflicting_value'::text, 'not_spoken_by_principal'::text, 'entity_name_limit'::text])))
  • rejected_source_message_fk: FOREIGN KEY (source_observation_id, source_ordinal) REFERENCES memory.turn_message(observation_id, ordinal) DEFERRABLE INITIALLY DEFERRED
  • rejected_source_project_fk: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) DEFERRABLE INITIALLY DEFERRED
  • rejected_claim_extractor_version_not_null: NOT NULL extractor_version
  • rejected_claim_predicate_not_null: NOT NULL predicate
  • rejected_claim_quote_not_null: NOT NULL quote
  • rejected_claim_reason_not_null: NOT NULL reason
  • rejected_claim_recorded_at_not_null: NOT NULL recorded_at
  • rejected_claim_rejected_claim_id_not_null: NOT NULL rejected_claim_id
  • rejected_claim_scope_not_null: NOT NULL scope
  • rejected_claim_source_observation_id_not_null: NOT NULL source_observation_id
  • rejected_claim_source_ordinal_not_null: NOT NULL source_ordinal
  • rejected_claim_statement_not_null: NOT NULL statement
  • rejected_claim_pkey: PRIMARY KEY (rejected_claim_id)
  • rejected_scope_id_uniq: UNIQUE (scope, rejected_claim_id)

Indexes

  • rejected_claim_pkey: CREATE UNIQUE INDEX rejected_claim_pkey ON memory.rejected_claim USING btree (rejected_claim_id)
  • rejected_claim_subject_idx: CREATE INDEX rejected_claim_subject_idx ON memory.rejected_claim USING btree (scope, data_subject_id) WHERE (data_subject_id IS NOT NULL)
  • rejected_scope_id_uniq: CREATE UNIQUE INDEX rejected_scope_id_uniq ON memory.rejected_claim USING btree (scope, rejected_claim_id)
  • rejected_source_message_idx: CREATE INDEX rejected_source_message_idx ON memory.rejected_claim USING btree (source_observation_id, source_ordinal)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

report_embedding

owner postgres · partitioned by LIST (generation_id)

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
report_iduuidnot null
embedding_keytextgenerated: (((generation_id)::text || '/'::text) || (report_id)::text)
input_digestbyteanot null
source_digestbyteanot null
source_countintegernot null
embeddingvectornot null
dimensionsintegergenerated: vector_dims(embedding)

Constraints

  • report_embedding_embedding_check: CHECK ((vector_norm(embedding) > (0)::double precision))
  • report_embedding_input_digest_check: CHECK ((octet_length(input_digest) = 32))
  • report_embedding_source_count_check: CHECK (((source_count >= 1) AND (source_count <= 4096)))
  • report_embedding_source_digest_check: CHECK ((octet_length(source_digest) = 32))
  • report_embedding_scope_generation_id_dimensions_fkey: FOREIGN KEY (scope, generation_id, dimensions) REFERENCES memory.report_embedding_generation(scope, generation_id, dimensions)
  • report_embedding_scope_generation_id_report_id_fkey: FOREIGN KEY (scope, generation_id, report_id) REFERENCES memory.report_embedding_target(scope, generation_id, report_id) ON DELETE CASCADE
  • report_embedding_embedding_not_null: NOT NULL embedding
  • report_embedding_generation_id_not_null: NOT NULL generation_id
  • report_embedding_input_digest_not_null: NOT NULL input_digest
  • report_embedding_report_id_not_null: NOT NULL report_id
  • report_embedding_scope_not_null: NOT NULL scope
  • report_embedding_source_count_not_null: NOT NULL source_count
  • report_embedding_source_digest_not_null: NOT NULL source_digest
  • report_embedding_pkey: PRIMARY KEY (scope, generation_id, report_id)
  • report_embedding_scope_generation_id_embedding_key_key: UNIQUE (scope, generation_id, embedding_key)

Indexes

  • report_embedding_pkey: CREATE UNIQUE INDEX report_embedding_pkey ON ONLY memory.report_embedding USING btree (scope, generation_id, report_id)
  • report_embedding_scope_generation_id_embedding_key_key: CREATE UNIQUE INDEX report_embedding_scope_generation_id_embedding_key_key ON ONLY memory.report_embedding USING btree (scope, generation_id, embedding_key)

Triggers

  • report_embedding_removed: CREATE TRIGGER report_embedding_removed AFTER DELETE ON memory.report_embedding FOR EACH ROW EXECUTE FUNCTION memory.mark_report_embedding_incomplete()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

report_embedding_active

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
activated_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • report_embedding_active_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • report_embedding_active_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.report_embedding_generation(scope, generation_id)
  • report_embedding_active_activated_at_not_null: NOT NULL activated_at
  • report_embedding_active_generation_id_not_null: NOT NULL generation_id
  • report_embedding_active_scope_not_null: NOT NULL scope
  • report_embedding_active_pkey: PRIMARY KEY (scope)

Indexes

  • report_embedding_active_pkey: CREATE UNIQUE INDEX report_embedding_active_pkey ON memory.report_embedding_active USING btree (scope)

Privileges

  • taisce_data: SELECT

report_embedding_build

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
statetextnot null'building'::text
after_report_iduuid
examinedbigintnot null0
storedbigintnot null0
lease_iduuid
updated_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • report_embedding_build_examined_check: CHECK ((examined >= 0))
  • report_embedding_build_state_check: CHECK ((state = ANY (ARRAY['building'::text, 'ready'::text, 'stale'::text, 'cancelled'::text, 'discarded'::text])))
  • report_embedding_build_stored_check: CHECK ((stored >= 0))
  • report_embedding_build_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.report_embedding_generation(scope, generation_id) ON DELETE CASCADE
  • report_embedding_build_examined_not_null: NOT NULL examined
  • report_embedding_build_generation_id_not_null: NOT NULL generation_id
  • report_embedding_build_scope_not_null: NOT NULL scope
  • report_embedding_build_state_not_null: NOT NULL state
  • report_embedding_build_stored_not_null: NOT NULL stored
  • report_embedding_build_updated_at_not_null: NOT NULL updated_at
  • report_embedding_build_pkey: PRIMARY KEY (scope, generation_id)

Indexes

  • report_embedding_build_pkey: CREATE UNIQUE INDEX report_embedding_build_pkey ON memory.report_embedding_build USING btree (scope, generation_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

report_embedding_generation

owner postgres

ColumnTypeNullDefaultComment
generation_iduuidnot null
scopetextnot null
operation_keyuuidnot null
model_nametextnot null
model_revisiontextnot null
endpoint_hashtextnot null
identity_hashtextnot null
dimensionsintegernot null
metrictextnot null'cosine'::text
input_versiontextnot null'community-report/v1'::text
target_countbigintnot null0
created_attimestamp with time zonenot nullclock_timestamp()

Constraints

  • report_embedding_generation_dimensions_check: CHECK (((dimensions >= 1) AND (dimensions <= 4000)))
  • report_embedding_generation_endpoint_hash_check: CHECK ((endpoint_hash ~ '^[0-9a-f]{64}$'::text))
  • report_embedding_generation_identity_hash_check: CHECK ((identity_hash ~ '^[0-9a-f]{64}$'::text))
  • report_embedding_generation_input_version_check: CHECK ((input_version = 'community-report/v1'::text))
  • report_embedding_generation_metric_check: CHECK ((metric = 'cosine'::text))
  • report_embedding_generation_model_name_check: CHECK (((octet_length(model_name) >= 1) AND (octet_length(model_name) <= 256)))
  • report_embedding_generation_model_revision_check: CHECK (((octet_length(model_revision) >= 1) AND (octet_length(model_revision) <= 128)))
  • report_embedding_generation_target_count_check: CHECK ((target_count >= 0))
  • report_embedding_generation_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • report_embedding_generation_created_at_not_null: NOT NULL created_at
  • report_embedding_generation_dimensions_not_null: NOT NULL dimensions
  • report_embedding_generation_endpoint_hash_not_null: NOT NULL endpoint_hash
  • report_embedding_generation_generation_id_not_null: NOT NULL generation_id
  • report_embedding_generation_identity_hash_not_null: NOT NULL identity_hash
  • report_embedding_generation_input_version_not_null: NOT NULL input_version
  • report_embedding_generation_metric_not_null: NOT NULL metric
  • report_embedding_generation_model_name_not_null: NOT NULL model_name
  • report_embedding_generation_model_revision_not_null: NOT NULL model_revision
  • report_embedding_generation_operation_key_not_null: NOT NULL operation_key
  • report_embedding_generation_scope_not_null: NOT NULL scope
  • report_embedding_generation_target_count_not_null: NOT NULL target_count
  • report_embedding_generation_pkey: PRIMARY KEY (generation_id)
  • report_embedding_generation_scope_generation_id_dimensions_key: UNIQUE (scope, generation_id, dimensions)
  • report_embedding_generation_scope_generation_id_key: UNIQUE (scope, generation_id)
  • report_embedding_generation_scope_operation_key_key: UNIQUE (scope, operation_key)

Indexes

  • report_embedding_generation_pkey: CREATE UNIQUE INDEX report_embedding_generation_pkey ON memory.report_embedding_generation USING btree (generation_id)
  • report_embedding_generation_scope_generation_id_dimensions_key: CREATE UNIQUE INDEX report_embedding_generation_scope_generation_id_dimensions_key ON memory.report_embedding_generation USING btree (scope, generation_id, dimensions)
  • report_embedding_generation_scope_generation_id_key: CREATE UNIQUE INDEX report_embedding_generation_scope_generation_id_key ON memory.report_embedding_generation USING btree (scope, generation_id)
  • report_embedding_generation_scope_operation_key_key: CREATE UNIQUE INDEX report_embedding_generation_scope_operation_key_key ON memory.report_embedding_generation USING btree (scope, operation_key)

Triggers

  • report_embedding_identity_immutable: CREATE TRIGGER report_embedding_identity_immutable BEFORE UPDATE ON memory.report_embedding_generation FOR EACH ROW EXECUTE FUNCTION memory.immutable_report_embedding_identity()

Privileges

  • taisce_data: SELECT

Referenced by

report_embedding_source

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
report_iduuidnot null
source_observation_iduuidnot null
embedding_keytextgenerated: (((generation_id)::text || '/'::text) || (report_id)::text)
registration_kindtextgenerated: 'report_embedding'::text

Constraints

  • report_embedding_source_scope_generation_id_report_id_fkey: FOREIGN KEY (scope, generation_id, report_id) REFERENCES memory.report_embedding(scope, generation_id, report_id) ON DELETE CASCADE
  • report_embedding_source_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • report_embedding_source_source_observation_id_registration_fkey: FOREIGN KEY (source_observation_id, registration_kind, embedding_key) REFERENCES memory.projection_dependency(source_observation_id, projection_kind, projection_id) DEFERRABLE INITIALLY DEFERRED
  • report_embedding_source_generation_id_not_null: NOT NULL generation_id
  • report_embedding_source_report_id_not_null: NOT NULL report_id
  • report_embedding_source_scope_not_null: NOT NULL scope
  • report_embedding_source_source_observation_id_not_null: NOT NULL source_observation_id
  • report_embedding_source_pkey: PRIMARY KEY (scope, generation_id, report_id, source_observation_id)

Indexes

  • report_embedding_source_observation_idx: CREATE INDEX report_embedding_source_observation_idx ON memory.report_embedding_source USING btree (scope, source_observation_id)
  • report_embedding_source_pkey: CREATE UNIQUE INDEX report_embedding_source_pkey ON memory.report_embedding_source USING btree (scope, generation_id, report_id, source_observation_id)

Triggers

  • report_embedding_source_removed: CREATE TRIGGER report_embedding_source_removed AFTER DELETE ON memory.report_embedding_source FOR EACH ROW EXECUTE FUNCTION memory.invalidate_report_embedding_source()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

report_embedding_target

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
generation_iduuidnot null
report_iduuidnot null

Constraints

  • report_embedding_target_scope_generation_id_fkey: FOREIGN KEY (scope, generation_id) REFERENCES memory.report_embedding_generation(scope, generation_id) ON DELETE CASCADE
  • report_embedding_target_scope_report_id_fkey: FOREIGN KEY (scope, report_id) REFERENCES memory.community_report(scope, report_id) ON DELETE CASCADE
  • report_embedding_target_generation_id_not_null: NOT NULL generation_id
  • report_embedding_target_report_id_not_null: NOT NULL report_id
  • report_embedding_target_scope_not_null: NOT NULL scope
  • report_embedding_target_pkey: PRIMARY KEY (scope, generation_id, report_id)

Indexes

  • report_embedding_target_pkey: CREATE UNIQUE INDEX report_embedding_target_pkey ON memory.report_embedding_target USING btree (scope, generation_id, report_id)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

retention_sweep

What each retention sweep deleted, written in the transaction that deleted it. Counts only: no identifiers of what expired, because the point of expiry is that it is gone.

owner postgres

ColumnTypeNullDefaultComment
sweep_iduuidnot nullgen_random_uuid()
scopetextnot null
swept_attimestamp with time zonenot nullnow()
observationsintegernot null
deletedjsonbnot null

Constraints

  • retention_sweep_observations_check: CHECK ((observations >= 0))
  • retention_sweep_deleted_not_null: NOT NULL deleted
  • retention_sweep_observations_not_null: NOT NULL observations
  • retention_sweep_scope_not_null: NOT NULL scope
  • retention_sweep_sweep_id_not_null: NOT NULL sweep_id
  • retention_sweep_swept_at_not_null: NOT NULL swept_at
  • retention_sweep_pkey: PRIMARY KEY (sweep_id)

Indexes

  • retention_sweep_pkey: CREATE UNIQUE INDEX retention_sweep_pkey ON memory.retention_sweep USING btree (sweep_id)
  • retention_sweep_scope_idx: CREATE INDEX retention_sweep_scope_idx ON memory.retention_sweep USING btree (scope, swept_at DESC)

Privileges

  • taisce_data: INSERT, SELECT

schema_migration

owner postgres

ColumnTypeNullDefaultComment
versionintegernot null
nametextnot null
applied_attimestamp with time zonenot nullnow()

Constraints

  • schema_migration_applied_at_not_null: NOT NULL applied_at
  • schema_migration_name_not_null: NOT NULL name
  • schema_migration_version_not_null: NOT NULL version
  • schema_migration_pkey: PRIMARY KEY (version)

Indexes

  • schema_migration_pkey: CREATE UNIQUE INDEX schema_migration_pkey ON memory.schema_migration USING btree (version)

Privileges

  • taisce_data: SELECT

segment

A summary standing in for a contiguous range of one subject's turns at one level of the roll-up. Registered to every observation it covers and deleted when any of them erases; what replaces it is written from what survived.

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
segment_iduuidnot null
data_subject_idtextnot null
levelintegernot null
from_offsetbigintnot null
to_offsetbigintnot null
coveredintegernot null
summarytextnot null
written_attimestamp with time zonenot nullnow()

Constraints

  • segment_covered_chk: CHECK ((covered >= 1))
  • segment_level_chk: CHECK (((level >= 1) AND (level <= 6)))
  • segment_range_chk: CHECK ((from_offset <= to_offset))
  • segment_summary_chk: CHECK ((btrim(summary) <> ''::text))
  • segment_covered_not_null: NOT NULL covered
  • segment_data_subject_id_not_null: NOT NULL data_subject_id
  • segment_from_offset_not_null: NOT NULL from_offset
  • segment_level_not_null: NOT NULL level
  • segment_scope_not_null: NOT NULL scope
  • segment_segment_id_not_null: NOT NULL segment_id
  • segment_summary_not_null: NOT NULL summary
  • segment_to_offset_not_null: NOT NULL to_offset
  • segment_written_at_not_null: NOT NULL written_at
  • segment_pkey: PRIMARY KEY (scope, segment_id)
  • segment_scope_data_subject_id_level_from_offset_key: UNIQUE (scope, data_subject_id, level, from_offset)

Indexes

  • segment_pkey: CREATE UNIQUE INDEX segment_pkey ON memory.segment USING btree (scope, segment_id)
  • segment_scope_data_subject_id_level_from_offset_key: CREATE UNIQUE INDEX segment_scope_data_subject_id_level_from_offset_key ON memory.segment USING btree (scope, data_subject_id, level, from_offset)
  • segment_subject_idx: CREATE INDEX segment_subject_idx ON memory.segment USING btree (scope, data_subject_id, level, from_offset)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

source_extraction

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
source_observation_iduuidnot null
extractor_versiontextnot null
pinned_attimestamp with time zonenot nullclock_timestamp()
generation_iduuid

Constraints

  • source_extraction_extractor_version_check: CHECK (((extractor_version = ANY (ARRAY['extract/v1'::text, 'curated/v1'::text])) OR (extractor_version ~ '^extract/v2:[a-f0-9]{64}$'::text)))
  • source_extraction_generation_fk: FOREIGN KEY (scope, source_observation_id, generation_id) REFERENCES memory.fact_generation(scope, source_observation_id, generation_id) DEFERRABLE INITIALLY DEFERRED
  • source_extraction_scope_source_observation_id_fkey: FOREIGN KEY (scope, source_observation_id) REFERENCES memory.observation(scope, observation_id) ON DELETE CASCADE
  • source_extraction_extractor_version_not_null: NOT NULL extractor_version
  • source_extraction_pinned_at_not_null: NOT NULL pinned_at
  • source_extraction_scope_not_null: NOT NULL scope
  • source_extraction_source_observation_id_not_null: NOT NULL source_observation_id
  • source_extraction_pkey: PRIMARY KEY (scope, source_observation_id)

Indexes

  • source_extraction_pkey: CREATE UNIQUE INDEX source_extraction_pkey ON memory.source_extraction USING btree (scope, source_observation_id)

Triggers

  • source_extraction_immutable: CREATE TRIGGER source_extraction_immutable BEFORE UPDATE ON memory.source_extraction FOR EACH ROW EXECUTE FUNCTION memory.extraction_pin_is_immutable()

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

speaker_term

owner postgres

ColumnTypeNullDefaultComment
termtextnot null

Constraints

  • speaker_term_term_check: CHECK (((term = lower(btrim(term))) AND (term <> ''::text)))
  • speaker_term_term_not_null: NOT NULL term
  • speaker_term_pkey: PRIMARY KEY (term)

Indexes

  • speaker_term_pkey: CREATE UNIQUE INDEX speaker_term_pkey ON memory.speaker_term USING btree (term)

Privileges

  • taisce_data: SELECT

subject_retry

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
key_digestbyteanot null
subject_idtext
request_digestbytea

Constraints

  • subject_retry_check: CHECK (((subject_id IS NULL) = (request_digest IS NULL)))
  • subject_retry_key_digest_check: CHECK ((octet_length(key_digest) = 32))
  • subject_retry_request_digest_check: CHECK ((octet_length(request_digest) = 32))
  • subject_retry_scope_fkey: FOREIGN KEY (scope) REFERENCES memory.project(scope) ON DELETE CASCADE
  • subject_retry_scope_subject_id_fkey: FOREIGN KEY (scope, subject_id) REFERENCES memory.data_subject(scope, subject_id)
  • subject_retry_key_digest_not_null: NOT NULL key_digest
  • subject_retry_scope_not_null: NOT NULL scope
  • subject_retry_pkey: PRIMARY KEY (scope, key_digest)

Indexes

  • subject_retry_owner_idx: CREATE INDEX subject_retry_owner_idx ON memory.subject_retry USING btree (scope, subject_id) WHERE (subject_id IS NOT NULL)
  • subject_retry_pkey: CREATE UNIQUE INDEX subject_retry_pkey ON memory.subject_retry USING btree (scope, key_digest)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

turn_message

owner postgres

ColumnTypeNullDefaultComment
observation_iduuidnot null
ordinalintegernot null
roletextnot null
contenttextnot null
group_ordinalintegernot null
occurred_attimestamp with time zonenot null
chunk_iduuidnot nullgen_random_uuid()

Constraints

  • turn_message_group_ordinal_chk: CHECK ((group_ordinal >= 0))
  • turn_message_ordinal_chk: CHECK ((ordinal >= 0))
  • turn_message_role_chk: CHECK ((role = ANY (ARRAY['user'::text, 'assistant'::text, 'system'::text, 'tool'::text])))
  • turn_message_observation_id_fkey: FOREIGN KEY (observation_id) REFERENCES memory.observation(observation_id) ON DELETE CASCADE
  • turn_message_chunk_id_not_null: NOT NULL chunk_id
  • turn_message_content_not_null: NOT NULL content
  • turn_message_group_ordinal_not_null: NOT NULL group_ordinal
  • turn_message_observation_id_not_null: NOT NULL observation_id
  • turn_message_occurred_at_not_null: NOT NULL occurred_at
  • turn_message_ordinal_not_null: NOT NULL ordinal
  • turn_message_role_not_null: NOT NULL role
  • turn_message_pkey: PRIMARY KEY (observation_id, ordinal)
  • message_chunk_identity_unique: UNIQUE (observation_id, ordinal, chunk_id)
  • message_chunk_lookup_unique: UNIQUE (chunk_id)

Indexes

  • message_chunk_identity_unique: CREATE UNIQUE INDEX message_chunk_identity_unique ON memory.turn_message USING btree (observation_id, ordinal, chunk_id)
  • message_chunk_lookup_unique: CREATE UNIQUE INDEX message_chunk_lookup_unique ON memory.turn_message USING btree (chunk_id)
  • turn_message_pkey: CREATE UNIQUE INDEX turn_message_pkey ON memory.turn_message USING btree (observation_id, ordinal)
  • turn_message_turn_idx: CREATE INDEX turn_message_turn_idx ON memory.turn_message USING btree (observation_id, ordinal) INCLUDE (group_ordinal, role)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Referenced by

unresolvable_term

Terms that cannot be the subject of a fact because they name nothing the message establishes. A table rather than a list in code, for the reason the predicate vocabulary is a table: a closed set belongs where it is enforced. Pronouns and demonstratives are genuinely closed, unlike stopwords, which are a frequency judgement.

owner postgres

ColumnTypeNullDefaultComment
termtextnot null
langtextnot null'en'::text
reasontextnot null

Constraints

  • unresolvable_term_chk: CHECK (((term = lower(btrim(term))) AND (length(term) > 0)))
  • unresolvable_term_lang_not_null: NOT NULL lang
  • unresolvable_term_reason_not_null: NOT NULL reason
  • unresolvable_term_term_not_null: NOT NULL term
  • unresolvable_term_pkey: PRIMARY KEY (lang, term)

Indexes

  • unresolvable_term_pkey: CREATE UNIQUE INDEX unresolvable_term_pkey ON memory.unresolvable_term USING btree (lang, term)

Privileges

  • taisce_data: SELECT

watermark

owner postgres

ColumnTypeNullDefaultComment
scopetextnot null
log_offsetbigintnot null
watermark_attimestamp with time zonenot null
updated_attimestamp with time zonenot nullnow()
formed_offsetbigintHighest log offset in this scope whose turn is formed, with nothing unformed below it. NULL until the scope's first turn forms. This is the number a caller checks to know whether a recall would see what they just wrote; log_offset only says it was stored.

Constraints

  • watermark_log_offset_not_null: NOT NULL log_offset
  • watermark_scope_not_null: NOT NULL scope
  • watermark_updated_at_not_null: NOT NULL updated_at
  • watermark_watermark_at_not_null: NOT NULL watermark_at
  • watermark_pkey: PRIMARY KEY (scope)

Indexes

  • watermark_pkey: CREATE UNIQUE INDEX watermark_pkey ON memory.watermark USING btree (scope)

Privileges

  • taisce_data: DELETE, INSERT, SELECT, UPDATE

Functions

account_agent_artifact

account_agent_artifact() returns trigger · plpgsql · security definer · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.account_agent_artifact()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
DECLARE
delta_bytes bigint;
delta_objects bigint;
project_scope text;
BEGIN
IF TG_TABLE_SCHEMA<>'memory' OR TG_TABLE_NAME<>'agent_artifact' OR TG_OP NOT IN ('INSERT','UPDATE','DELETE') THEN
RAISE EXCEPTION 'invalid agent artifact accounting target';
END IF;
IF TG_OP='UPDATE' AND (NEW.scope,NEW.artifact_id,NEW.source_observation_id,NEW.data_subject_id,NEW.kind,NEW.created_at)
IS DISTINCT FROM (OLD.scope,OLD.artifact_id,OLD.source_observation_id,OLD.data_subject_id,OLD.kind,OLD.created_at) THEN
RAISE EXCEPTION 'artifact identity and ownership are immutable' USING ERRCODE='23514';
END IF;
IF TG_OP='DELETE' THEN
project_scope:=OLD.scope; delta_bytes:=-octet_length(OLD.content); delta_objects:=-1;
ELSE
project_scope:=NEW.scope;
delta_bytes:=octet_length(NEW.content); delta_objects:=1;
IF TG_OP='UPDATE' THEN
delta_bytes:=delta_bytes-octet_length(OLD.content); delta_objects:=0;
END IF;
IF NOT EXISTS(SELECT 1 FROM memory.observation o WHERE o.scope=NEW.scope
AND o.observation_id=NEW.source_observation_id AND o.kind='artifact'
AND o.data_subject_id=NEW.data_subject_id AND o.formed_at IS NOT NULL AND o.retention_until IS NOT NULL) THEN
RAISE EXCEPTION 'artifact requires a completed owned source with bounded retention' USING ERRCODE='23514';
END IF;
END IF;
UPDATE memory.agent_storage_policy SET used_bytes=used_bytes+delta_bytes,used_objects=used_objects+delta_objects
WHERE scope=project_scope AND (TG_OP='DELETE' OR
((delta_bytes<=0 OR used_bytes+delta_bytes<=max_bytes)
AND (delta_objects<=0 OR used_objects+delta_objects<=max_objects)
AND (TG_OP='UPDATE' AND delta_bytes<=0 OR octet_length(NEW.content)<=max_object_bytes)));
IF NOT FOUND THEN
RAISE EXCEPTION 'agent storage capacity is full' USING ERRCODE='P0001',CONSTRAINT='agent_storage_capacity';
END IF;
IF TG_OP='DELETE' THEN RETURN OLD; END IF;
RETURN NEW;
END;
$function$

advance_record_version

advance_record_version() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.advance_record_version()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
NEW.version := gen_random_uuid();
RETURN NEW;
END;
$function$

audit_entries_digest

audit_entries_digest(lo bigint, hi bigint) returns bytea · sql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.audit_entries_digest(lo bigint, hi bigint)
RETURNS bytea
LANGUAGE sql
STABLE
AS $function$
SELECT sha256(coalesce(string_agg(
e.entry_id::text || '|' || e.operation || '|' || e.principal || '|' ||
e.principal_kind || '|' || e.project || '|' || e.magnitude::text || '|' ||
e.outcome || '|' || extract(epoch from e.occurred_at)::text,
E'\n' ORDER BY e.entry_id), '')::bytea)
FROM memory.audit_entry e
WHERE e.entry_id BETWEEN lo AND hi;
$function$

audit_is_append_only

audit_is_append_only() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.audit_is_append_only()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
RAISE EXCEPTION 'the audit ledger is append-only: % is not permitted', TG_OP
USING HINT = 'a record that can be changed is not a record';
END;
$function$

audit_seal_now

audit_seal_now() returns TABLE(from_entry bigint, to_entry bigint, entry_count integer, digest bytea) · plpgsql · security definer · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.audit_seal_now()
RETURNS TABLE(from_entry bigint, to_entry bigint, entry_count integer, digest bytea)
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
DECLARE
lo bigint;
hi bigint;
n integer;
previous bytea;
entries bytea;
chained bytea;
BEGIN
LOCK TABLE memory.audit_entry IN SHARE ROW EXCLUSIVE MODE;

SELECT s.to_entry + 1, s.digest INTO lo, previous
FROM memory.audit_seal s ORDER BY s.seal_id DESC LIMIT 1;
IF NOT FOUND THEN
-- The first seal chains to a fixed zero rather than to nothing, so verification has one rule.
lo := 0;
previous := decode(repeat('00', 32), 'hex');
END IF;

SELECT e.entry_id INTO hi FROM memory.audit_entry e
WHERE e.entry_id >= lo ORDER BY e.entry_id OFFSET 99999 LIMIT 1;
IF hi IS NULL THEN
SELECT max(e.entry_id) INTO hi FROM memory.audit_entry e WHERE e.entry_id >= lo;
END IF;
IF hi IS NULL THEN
RETURN;
END IF;
SELECT count(*) INTO n FROM memory.audit_entry e WHERE e.entry_id BETWEEN lo AND hi;

entries := memory.audit_entries_digest(lo, hi);
chained := sha256(previous || entries);
INSERT INTO memory.audit_seal (from_entry, to_entry, entry_count, entries_digest, previous_digest, digest)
VALUES (lo, hi, n, entries, previous, chained);
RETURN QUERY SELECT lo, hi, n, chained;
END;
$function$

clear_observation_retry_payload

clear_observation_retry_payload() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.clear_observation_retry_payload()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
UPDATE memory.observation_retry
SET observation_id = NULL, request_digest = NULL
WHERE observation_id = OLD.observation_id AND scope = OLD.scope;
RETURN OLD;
END
$function$

clear_replacement_identifier

clear_replacement_identifier() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.clear_replacement_identifier()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
IF NEW.replacement_observation_id IS NULL THEN NEW.replacement_fact_id := NULL; END IF;
RETURN NEW;
END;
$function$

clear_subject_retry_payload

clear_subject_retry_payload() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.clear_subject_retry_payload()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
UPDATE memory.subject_retry SET subject_id=NULL,request_digest=NULL
WHERE scope=OLD.scope AND subject_id=OLD.subject_id;
RETURN OLD;
END
$function$

extraction_pin_is_immutable

extraction_pin_is_immutable() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.extraction_pin_is_immutable()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
IF NEW IS DISTINCT FROM OLD THEN
RAISE EXCEPTION 'source extraction identity is immutable' USING ERRCODE='23514';
END IF;
RETURN NEW;
END;
$function$

immutable_embedding_identity

immutable_embedding_identity() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.immutable_embedding_identity()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN RAISE EXCEPTION 'embedding generation identity is immutable'; END $function$

immutable_entity_embedding_identity

immutable_entity_embedding_identity() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.immutable_entity_embedding_identity()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN RAISE EXCEPTION 'entity embedding generation identity is immutable'; END $function$

immutable_report_embedding_identity

immutable_report_embedding_identity() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.immutable_report_embedding_identity()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN RAISE EXCEPTION 'report embedding generation identity is immutable'; END $function$

initialize_agent_storage_policy

initialize_agent_storage_policy() returns trigger · plpgsql · security definer · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.initialize_agent_storage_policy()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
IF TG_TABLE_SCHEMA<>'memory' OR TG_TABLE_NAME<>'project' OR TG_OP<>'INSERT' THEN
RAISE EXCEPTION 'invalid agent storage policy trigger target';
END IF;
INSERT INTO memory.agent_storage_policy(scope) VALUES(NEW.scope);
RETURN NULL;
END;
$function$

invalidate_entity_embedding_source

invalidate_entity_embedding_source() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.invalidate_entity_embedding_source()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
DELETE FROM memory.entity_embedding
WHERE scope=OLD.scope AND generation_id=OLD.generation_id AND entity_id=OLD.entity_id;
RETURN OLD;
END $function$

invalidate_entity_embeddings

invalidate_entity_embeddings() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.invalidate_entity_embeddings()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
DECLARE target_scope text; target_id uuid; other_scope text; other_id uuid;
BEGIN
IF TG_TABLE_NAME='entity' THEN
IF TG_OP='DELETE' THEN target_scope := OLD.scope; target_id := OLD.entity_id;
ELSE target_scope := NEW.scope; target_id := NEW.entity_id; END IF;
ELSIF TG_TABLE_NAME='entity_name_receipt' THEN
IF TG_OP='DELETE' THEN target_scope := OLD.scope; target_id := OLD.entity_id;
ELSE target_scope := NEW.scope; target_id := NEW.entity_id; END IF;
ELSIF TG_TABLE_NAME='fact' THEN
IF TG_OP='DELETE' THEN target_scope := OLD.scope; target_id := OLD.subject_entity_id; other_id := OLD.object_entity_id;
ELSE target_scope := NEW.scope; target_id := NEW.subject_entity_id; other_id := NEW.object_entity_id; END IF;
other_scope := target_scope;
ELSIF TG_TABLE_NAME='fact_evidence' THEN
IF TG_OP='DELETE' THEN
SELECT scope,subject_entity_id,object_entity_id INTO target_scope,target_id,other_id
FROM memory.fact WHERE fact_id=OLD.fact_id;
ELSE
SELECT scope,subject_entity_id,object_entity_id INTO target_scope,target_id,other_id
FROM memory.fact WHERE fact_id=NEW.fact_id;
END IF;
other_scope := target_scope;
ELSE
RAISE EXCEPTION 'invalid entity embedding invalidation target';
END IF;
IF target_id IS NOT NULL THEN
PERFORM pg_advisory_xact_lock(hashtextextended(target_scope||':entity-embedding:'||target_id::text,0));
DELETE FROM memory.entity_embedding WHERE scope=target_scope AND entity_id=target_id;
END IF;
IF other_id IS NOT NULL AND other_id IS DISTINCT FROM target_id THEN
PERFORM pg_advisory_xact_lock(hashtextextended(other_scope||':entity-embedding:'||other_id::text,0));
DELETE FROM memory.entity_embedding WHERE scope=other_scope AND entity_id=other_id;
END IF;
IF TG_OP='DELETE' THEN RETURN OLD; END IF;
RETURN NEW;
END $function$

invalidate_fact_reports

invalidate_fact_reports() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.invalidate_fact_reports()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
DECLARE
source_ids uuid[];
source_id uuid;
BEGIN
IF TG_TABLE_SCHEMA <> 'memory' THEN
RAISE EXCEPTION 'invalid report invalidation trigger target';
END IF;
IF TG_TABLE_NAME='fact' AND TG_OP IN ('UPDATE','DELETE') THEN
SELECT array_agg(DISTINCT source_observation_id) INTO source_ids
FROM memory.fact_evidence WHERE scope=OLD.scope AND fact_id=OLD.fact_id;
ELSIF TG_TABLE_NAME='fact_evidence' THEN
IF TG_OP='INSERT' THEN
source_ids := ARRAY[NEW.source_observation_id];
ELSIF TG_OP='DELETE' THEN
source_ids := ARRAY[OLD.source_observation_id];
ELSE
source_ids := ARRAY[OLD.source_observation_id,NEW.source_observation_id];
END IF;
ELSE
RAISE EXCEPTION 'invalid report invalidation trigger target';
END IF;
-- Sorted observation locks precede report deletion. Report writers take the same locks before
-- insertion, so either their snapshot is refused or this transaction deletes their report.
FOR source_id IN SELECT DISTINCT unnest(source_ids) ORDER BY 1 LOOP
UPDATE memory.observation SET fact_revision=fact_revision+1 WHERE observation_id=source_id;
END LOOP;
DELETE FROM memory.community_report r USING memory.projection_dependency d
WHERE d.scope=r.scope AND d.report_ref=r.report_id
AND d.projection_kind='community_report' AND d.source_observation_id=ANY(source_ids);
IF TG_OP='DELETE' THEN RETURN OLD; END IF;
RETURN NEW;
END;
$function$

invalidate_report_embedding_source

invalidate_report_embedding_source() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.invalidate_report_embedding_source()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
DELETE FROM memory.report_embedding
WHERE scope=OLD.scope AND generation_id=OLD.generation_id AND report_id=OLD.report_id;
RETURN OLD;
END $function$

lock_registered_subject

lock_registered_subject() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.lock_registered_subject()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
IF NEW.data_subject_id IS NOT NULL THEN
PERFORM 1 FROM memory.data_subject WHERE scope=NEW.scope AND subject_id=NEW.data_subject_id FOR KEY SHARE;
END IF;
RETURN NEW;
END
$function$

lock_report_embedding_change

lock_report_embedding_change() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.lock_report_embedding_change()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
PERFORM pg_advisory_xact_lock(hashtextextended(OLD.scope||':report-embedding:'||OLD.report_id::text,0));
IF TG_OP='DELETE' THEN RETURN OLD; END IF;
RETURN NEW;
END $function$

mark_entity_embedding_incomplete

mark_entity_embedding_incomplete() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.mark_entity_embedding_incomplete()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
UPDATE memory.entity_embedding_build
SET state='building',after_entity_id=NULL,lease_id=NULL,updated_at=clock_timestamp()
WHERE scope=OLD.scope AND generation_id=OLD.generation_id AND state='ready';
RETURN OLD;
END $function$

mark_report_embedding_incomplete

mark_report_embedding_incomplete() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.mark_report_embedding_incomplete()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
UPDATE memory.report_embedding_build
SET state='building',after_report_id=NULL,lease_id=NULL,updated_at=clock_timestamp()
WHERE scope=OLD.scope AND generation_id=OLD.generation_id AND state='ready';
RETURN OLD;
END $function$

project_surfaces_only_grow

project_surfaces_only_grow() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.project_surfaces_only_grow()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
IF NOT (OLD.surfaces <@ NEW.surfaces) THEN
RAISE EXCEPTION
'a memory surface cannot be turned off: % would remove %',
NEW.scope, (SELECT array_agg(s) FROM unnest(OLD.surfaces) s WHERE s <> ALL(NEW.surfaces))
USING HINT = 'stopping a surface means erasing what it stored, which is an erasure with a receipt';
END IF;
RETURN NEW;
END;
$function$

protect_artifact_source

protect_artifact_source() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.protect_artifact_source()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
IF (OLD.kind='artifact' OR NEW.kind='artifact') AND
((OLD.kind,OLD.scope,OLD.observation_id,OLD.data_subject_id,OLD.source_role)
IS DISTINCT FROM (NEW.kind,NEW.scope,NEW.observation_id,NEW.data_subject_id,NEW.source_role)
OR NEW.formed_at IS NULL OR NEW.retention_until IS NULL) THEN
RAISE EXCEPTION 'artifact source ownership and formation exclusion are immutable' USING ERRCODE='23514';
END IF;
RETURN NEW;
END;
$function$

protect_subject_identity

protect_subject_identity() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.protect_subject_identity()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
IF (NEW.scope,NEW.subject_id,NEW.created_at,NEW.inactive_after)
IS DISTINCT FROM (OLD.scope,OLD.subject_id,OLD.created_at,OLD.inactive_after) THEN
RAISE EXCEPTION 'subject identity and lifetime are immutable' USING ERRCODE='23514';
END IF;
RETURN NEW;
END
$function$

release_ingestion_reservation

release_ingestion_reservation() returns trigger · plpgsql · security definer · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.release_ingestion_reservation()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
IF TG_TABLE_SCHEMA <> 'memory' OR TG_TABLE_NAME <> 'ingestion_reservation' OR TG_OP <> 'DELETE' THEN
RAISE EXCEPTION 'invalid ingestion release trigger target';
END IF;
UPDATE memory.ingestion_budget SET pending=pending-1 WHERE singleton AND pending>0;
IF NOT FOUND THEN
RAISE EXCEPTION 'ingestion counter is inconsistent' USING ERRCODE='23514';
END IF;
UPDATE memory.ingestion_project_usage SET pending=pending-1 WHERE scope=OLD.scope AND pending>0;
IF NOT FOUND THEN
RAISE EXCEPTION 'project ingestion counter is inconsistent' USING ERRCODE='23514';
END IF;
DELETE FROM memory.ingestion_project_usage WHERE scope=OLD.scope AND pending=0;
RETURN NULL;
END;
$function$

retain_fact_history

retain_fact_history() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.retain_fact_history()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
INSERT INTO memory.fact_receipt_history(scope,history_id,fact_id,valid,known,source_observation_id)
SELECT NEW.scope,NEW.history_id,NEW.fact_id,NEW.valid,NEW.known,NEW.source_observation_id
WHERE EXISTS(SELECT 1 FROM memory.fact_receipt r WHERE r.scope=NEW.scope AND r.fact_id=NEW.fact_id)
ON CONFLICT(scope,history_id) DO NOTHING;
RETURN NEW;
END;
$function$

retain_fact_transition

retain_fact_transition() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.retain_fact_transition()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
-- Deleting a successor projection clears its live FK. Its receipt still names the successor
-- for recovery; deleting the causal observation instead cascades the entire receipt away.
UPDATE memory.fact_receipt r SET
state=CASE WHEN NEW.superseded_by IS NULL AND r.superseded_by IS NOT NULL
THEN to_jsonb(NEW)||jsonb_build_object('superseded_by',r.superseded_by)
ELSE to_jsonb(NEW) END,
superseded_by=coalesce(NEW.superseded_by,r.superseded_by),
supersession_source=NEW.supersession_source
WHERE r.scope=NEW.scope AND r.fact_id=NEW.fact_id;
RETURN NEW;
END;
$function$

stale_entity_embedding_snapshots

stale_entity_embedding_snapshots() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.stale_entity_embedding_snapshots()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
BEGIN
IF NEW.identity_kind='named' THEN
PERFORM 1 FROM memory.project WHERE scope=NEW.scope FOR UPDATE;
UPDATE memory.entity_embedding_build SET state='stale',lease_id=NULL,updated_at=clock_timestamp()
WHERE scope=NEW.scope AND state<>'discarded';
END IF;
RETURN NEW;
END $function$

stale_report_embedding_snapshots

stale_report_embedding_snapshots() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.stale_report_embedding_snapshots()
RETURNS trigger
LANGUAGE plpgsql
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
DECLARE target_scope text; target_id uuid;
BEGIN
IF TG_OP='DELETE' THEN
target_scope := OLD.scope; target_id := OLD.report_id;
ELSE
target_scope := NEW.scope; target_id := NEW.report_id;
END IF;
PERFORM 1 FROM memory.project WHERE scope=target_scope FOR UPDATE;
UPDATE memory.report_embedding_build SET state='stale',lease_id=NULL,updated_at=clock_timestamp()
WHERE scope=target_scope AND state<>'discarded';
IF TG_OP='UPDATE' THEN
DELETE FROM memory.report_embedding WHERE scope=target_scope AND report_id=target_id;
END IF;
IF TG_OP='DELETE' THEN RETURN OLD; END IF;
RETURN NEW;
END $function$

sync_ingestion_reservation

sync_ingestion_reservation() returns trigger · plpgsql · security definer · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.sync_ingestion_reservation()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path TO 'pg_catalog', 'pg_temp'
AS $function$
DECLARE
project_scope text;
project_limit bigint;
BEGIN
IF TG_TABLE_SCHEMA <> 'memory' OR TG_TABLE_NAME <> 'observation'
OR TG_OP NOT IN ('INSERT','UPDATE') THEN
RAISE EXCEPTION 'invalid ingestion reservation trigger target';
END IF;
SELECT o.scope INTO project_scope FROM memory.observation o
WHERE o.observation_id=NEW.observation_id AND o.kind='turn' AND o.formed_at IS NULL;
IF NOT FOUND THEN
DELETE FROM memory.ingestion_reservation WHERE observation_id=NEW.observation_id;
RETURN NULL;
END IF;
IF EXISTS(SELECT 1 FROM memory.ingestion_reservation WHERE observation_id=NEW.observation_id) THEN
RETURN NULL;
END IF;
UPDATE memory.ingestion_budget SET pending=pending+1
WHERE singleton AND pending<max_pending RETURNING max_pending_per_project INTO project_limit;
IF NOT FOUND THEN
RAISE EXCEPTION 'unfinished observation capacity is full'
USING ERRCODE='P0001',CONSTRAINT='ingestion_backlog_capacity';
END IF;
INSERT INTO memory.ingestion_project_usage(scope,pending) VALUES(project_scope,1)
ON CONFLICT(scope) DO UPDATE SET pending=memory.ingestion_project_usage.pending+1
WHERE memory.ingestion_project_usage.pending<project_limit;
IF NOT FOUND THEN
RAISE EXCEPTION 'unfinished observation capacity is full'
USING ERRCODE='P0001',CONSTRAINT='ingestion_backlog_capacity';
END IF;
INSERT INTO memory.ingestion_reservation(observation_id,scope) VALUES(NEW.observation_id,project_scope);
RETURN NULL;
END;
$function$

validate_entity_name_receipt

validate_entity_name_receipt() returns trigger · plpgsql · security invoker · execute: owner only (no ACL: PUBLIC may execute)

definition
CREATE OR REPLACE FUNCTION memory.validate_entity_name_receipt()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
NEW.name_hash := sha256(convert_to(NEW.name,'UTF8'));
PERFORM 1 FROM memory.entity WHERE scope=NEW.scope AND entity_id=NEW.entity_id
AND identity_kind='named' AND normalized_name=NEW.normalized_name FOR KEY SHARE;
IF NOT FOUND THEN RAISE EXCEPTION 'name receipt must match a live named identity' USING ERRCODE='23514'; END IF;
RETURN NEW;
END $function$

Sequences

  • audit_entry_entry_id_seq
  • audit_seal_seal_id_seq