@codemem/core 0.46.0-rc.1 → 0.46.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-types.d.ts +1 -1
- package/dist/api-types.d.ts.map +1 -1
- package/dist/database-runtime-primitives.d.ts +3 -1
- package/dist/database-runtime-primitives.d.ts.map +1 -1
- package/dist/db.d.ts +4 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/dedup-key-backfill.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9653 -9368
- package/dist/index.js.map +1 -1
- package/dist/legacy-recipient-policy-projection.d.ts.map +1 -1
- package/dist/maintenance/dedup-keys.d.ts +3 -0
- package/dist/maintenance/dedup-keys.d.ts.map +1 -1
- package/dist/maintenance-jobs.d.ts +6 -0
- package/dist/maintenance-jobs.d.ts.map +1 -1
- package/dist/operational-status.d.ts +1 -1
- package/dist/operational-status.d.ts.map +1 -1
- package/dist/project.d.ts +14 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/recipient-policy-edges.d.ts.map +1 -1
- package/dist/recipient-policy-onboarding.d.ts.map +1 -1
- package/dist/recipient-policy-review.d.ts +1 -1
- package/dist/recipient-policy-review.d.ts.map +1 -1
- package/dist/ref-backfill.d.ts.map +1 -1
- package/dist/schema-bootstrap.d.ts.map +1 -1
- package/dist/schema.d.ts +38 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/scope-backfill.d.ts.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/summary-dedup-backfill.d.ts.map +1 -1
- package/dist/sync-discovery.d.ts +3 -1
- package/dist/sync-discovery.d.ts.map +1 -1
- package/dist/sync-failure-classification.d.ts +20 -0
- package/dist/sync-failure-classification.d.ts.map +1 -0
- package/dist/sync-pass.d.ts +6 -0
- package/dist/sync-pass.d.ts.map +1 -1
- package/dist/test-schema.generated.d.ts +1 -1
- package/dist/test-schema.generated.d.ts.map +1 -1
- package/dist/vectors.d.ts +1 -1
- package/dist/vectors.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* Do not edit manually. Regenerate with:
|
|
5
5
|
* pnpm --filter @codemem/core run generate:test-schema
|
|
6
6
|
*/
|
|
7
|
-
export declare const TEST_SCHEMA_BASE_DDL = "CREATE TABLE IF NOT EXISTS `device_identity_binding_commits` (\n\t`commit_digest` text PRIMARY KEY NOT NULL,\n\t`reviewed_inventory_digest` text NOT NULL,\n\t`request_json` text NOT NULL,\n\t`outcomes_json` text NOT NULL,\n\t`write_count` integer NOT NULL,\n\t`decided_by_identity_id` text NOT NULL,\n\t`decided_by_device_id` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `device_identity_binding_audit` (\n\t`event_id` text PRIMARY KEY NOT NULL,\n\t`commit_digest` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`previous_identity_id` text,\n\t`target_identity_id` text NOT NULL,\n\t`action` text NOT NULL,\n\t`previous_assignment_version` integer,\n\t`resulting_assignment_version` integer NOT NULL,\n\t`decided_by_identity_id` text NOT NULL,\n\t`decided_by_device_id` text NOT NULL,\n\t`created_at` text NOT NULL,\n\tFOREIGN KEY (`commit_digest`) REFERENCES `device_identity_binding_commits`(`commit_digest`) ON UPDATE no action ON DELETE no action\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_device_identity_binding_audit_commit_device` ON `device_identity_binding_audit` (`commit_digest`,`device_id`);\nCREATE INDEX IF NOT EXISTS `idx_device_identity_binding_audit_device_created` ON `device_identity_binding_audit` (`device_id`,`created_at`,`event_id`);\nCREATE TABLE IF NOT EXISTS `sessions` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`started_at` text NOT NULL,\n\t`ended_at` text,\n\t`cwd` text,\n\t`project` text,\n\t`git_remote` text,\n\t`git_branch` text,\n\t`user` text,\n\t`tool_version` text,\n\t`metadata_json` text,\n\t`import_key` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_sessions_started_id` ON `sessions` (`started_at`,`id`);\nCREATE TABLE IF NOT EXISTS `replication_scopes` (\n\t`scope_id` text PRIMARY KEY NOT NULL,\n\t`label` text NOT NULL,\n\t`kind` text DEFAULT 'user' NOT NULL,\n\t`authority_type` text DEFAULT 'local' NOT NULL,\n\t`coordinator_id` text,\n\t`group_id` text,\n\t`manifest_issuer_device_id` text,\n\t`membership_epoch` integer DEFAULT 0 NOT NULL,\n\t`manifest_hash` text,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_replication_scopes_status` ON `replication_scopes` (`status`);\nCREATE INDEX IF NOT EXISTS `idx_replication_scopes_authority_group` ON `replication_scopes` (`coordinator_id`,`group_id`);\nCREATE TABLE IF NOT EXISTS `project_scope_mappings` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`workspace_identity` text,\n\t`project_pattern` text NOT NULL,\n\t`scope_id` text NOT NULL,\n\t`priority` integer DEFAULT 0 NOT NULL,\n\t`source` text DEFAULT 'user' NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_project_scope_mappings_workspace_priority` ON `project_scope_mappings` (`workspace_identity`,`priority`);\nCREATE INDEX IF NOT EXISTS `idx_project_scope_mappings_pattern_priority` ON `project_scope_mappings` (`project_pattern`,`priority`);\nCREATE INDEX IF NOT EXISTS `idx_project_scope_mappings_scope` ON `project_scope_mappings` (`scope_id`);\nCREATE TABLE IF NOT EXISTS `scope_memberships` (\n\t`scope_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`role` text DEFAULT 'member' NOT NULL,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`membership_epoch` integer DEFAULT 0 NOT NULL,\n\t`coordinator_id` text,\n\t`group_id` text,\n\t`manifest_issuer_device_id` text,\n\t`manifest_hash` text,\n\t`signed_manifest_json` text,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`scope_id`, `device_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_scope_memberships_device_status` ON `scope_memberships` (`device_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_scope_memberships_scope_status` ON `scope_memberships` (`scope_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_scope_memberships_authority_group` ON `scope_memberships` (`coordinator_id`,`group_id`);\nCREATE TABLE IF NOT EXISTS `artifacts` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer NOT NULL,\n\t`kind` text NOT NULL,\n\t`path` text,\n\t`content_text` text,\n\t`content_hash` text,\n\t`created_at` text NOT NULL,\n\t`metadata_json` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_artifacts_session_kind` ON `artifacts` (`session_id`,`kind`);\nCREATE TABLE IF NOT EXISTS `memory_items` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer NOT NULL,\n\t`kind` text NOT NULL,\n\t`title` text NOT NULL,\n\t`subtitle` text,\n\t`body_text` text NOT NULL,\n\t`confidence` real DEFAULT 0.5,\n\t`tags_text` text DEFAULT '',\n\t`active` integer DEFAULT 1,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\t`metadata_json` text,\n\t`actor_id` text,\n\t`actor_display_name` text,\n\t`visibility` text,\n\t`workspace_id` text,\n\t`workspace_kind` text,\n\t`origin_device_id` text,\n\t`origin_source` text,\n\t`trust_state` text,\n\t`facts` text,\n\t`narrative` text,\n\t`concepts` text,\n\t`files_read` text,\n\t`files_modified` text,\n\t`user_prompt_id` integer,\n\t`prompt_number` integer,\n\t`deleted_at` text,\n\t`rev` integer DEFAULT 0,\n\t`dedup_key` text,\n\t`import_key` text,\n\t`scope_id` text,\n\t`project` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_memory_items_active_created` ON `memory_items` (`active`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_created_id` ON `memory_items` (`created_at`,`id`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_origin_device_active` ON `memory_items` (`origin_device_id`,`active`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_session` ON `memory_items` (`session_id`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_project` ON `memory_items` (`project`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_scope_visibility_created` ON `memory_items` (`scope_id`,`visibility`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_scope_backfill_pending` ON `memory_items` (`id`) WHERE scope_id IS NULL OR scope_id = '';\nCREATE INDEX IF NOT EXISTS `idx_memory_items_dedup_key_active_created` ON `memory_items` (`dedup_key`,`active`,`created_at`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_memory_items_same_session_dedup_unique` ON `memory_items` (`session_id`,`kind`,`visibility`,`workspace_id`,`dedup_key`) WHERE active = 1 AND dedup_key IS NOT NULL;\nCREATE TABLE IF NOT EXISTS `memory_file_refs` (\n\t`memory_id` integer NOT NULL,\n\t`file_path` text NOT NULL,\n\t`relation` text NOT NULL,\n\tPRIMARY KEY(`memory_id`, `file_path`, `relation`),\n\tFOREIGN KEY (`memory_id`) REFERENCES `memory_items`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_memory_file_refs_path` ON `memory_file_refs` (`file_path`);\nCREATE TABLE IF NOT EXISTS `memory_concept_refs` (\n\t`memory_id` integer NOT NULL,\n\t`concept` text NOT NULL,\n\tPRIMARY KEY(`memory_id`, `concept`),\n\tFOREIGN KEY (`memory_id`) REFERENCES `memory_items`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_memory_concept_refs_concept` ON `memory_concept_refs` (`concept`);\nCREATE TABLE IF NOT EXISTS `usage_events` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer,\n\t`event` text NOT NULL,\n\t`tokens_read` integer DEFAULT 0,\n\t`tokens_written` integer DEFAULT 0,\n\t`tokens_saved` integer DEFAULT 0,\n\t`created_at` text NOT NULL,\n\t`metadata_json` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE set null\n);\n\nCREATE INDEX IF NOT EXISTS `idx_usage_events_event_created` ON `usage_events` (`event`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_usage_events_session` ON `usage_events` (`session_id`);\nCREATE TABLE IF NOT EXISTS `retrieval_attempts` (\n\t`attempt_id` text PRIMARY KEY NOT NULL,\n\t`contract_version` integer NOT NULL,\n\t`surface` text NOT NULL,\n\t`trigger` text NOT NULL,\n\t`started_at` text NOT NULL,\n\t`completed_at` text,\n\t`retrieval_status` text NOT NULL,\n\t`delivery_status` text NOT NULL,\n\t`candidate_count` integer NOT NULL,\n\t`selected_count` integer NOT NULL,\n\t`persisted_candidate_count` integer NOT NULL,\n\t`recorder_version` text NOT NULL,\n\t`session_id` integer,\n\t`source` text,\n\t`stream_id` text,\n\t`source_session_id` text,\n\t`prompt_number` integer,\n\t`request_id` text,\n\t`raw_event_start_seq` integer,\n\t`raw_event_end_seq` integer,\n\t`experiment_id` text,\n\t`experiment_cell_id` text,\n\t`evaluation_checkout_id` text,\n\t`evaluation_fixture_id` text,\n\t`evaluation_seed` integer,\n\t`latency_ms` integer,\n\t`project` text,\n\t`scope_id` text,\n\t`mode` text,\n\t`limit_requested` integer,\n\t`token_budget` integer,\n\t`output_tokens` integer,\n\t`working_set_file_count` integer,\n\t`working_set_files_json` text,\n\t`query_hash_sha256` text,\n\t`query_char_count` integer,\n\t`query_token_estimate` integer,\n\t`filter_summary_json` text,\n\t`failure_code` text,\n\t`failure_stage` text,\n\t`trace_version` integer,\n\t`automatic_recall_json` text,\n\t`automatic_recall_key` text,\n\t`retention_until` text,\n\t`retention_pinned` integer DEFAULT 0 NOT NULL,\n\t`retention_finalized_at` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_session_started` ON `retrieval_attempts` (`session_id`,`started_at`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_retrieval_attempts_automatic_recall_key` ON `retrieval_attempts` (`automatic_recall_key`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_source_stream_started` ON `retrieval_attempts` (`source`,`stream_id`,`started_at`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_retention` ON `retrieval_attempts` (`retention_pinned`,`retention_until`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_started` ON `retrieval_attempts` (`started_at`,`attempt_id`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_surface_started` ON `retrieval_attempts` (`surface`,`started_at`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_retrieval_attempts_request_identity` ON `retrieval_attempts` (`source`,`surface`,`request_id`) WHERE request_id IS NOT NULL;\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_experiment_cell` ON `retrieval_attempts` (`experiment_id`,`experiment_cell_id`);\nCREATE TABLE IF NOT EXISTS `retrieval_exposures` (\n\t`exposure_id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`attempt_id` text NOT NULL,\n\t`memory_id` integer,\n\t`memory_import_key` text,\n\t`origin_device_id` text,\n\t`rank` integer NOT NULL,\n\t`disposition` text NOT NULL,\n\t`section` text,\n\t`handoff_status` text NOT NULL,\n\t`memory_rev` integer,\n\t`memory_updated_at` text,\n\t`memory_scope_id` text,\n\t`memory_kind` text,\n\t`memory_active` integer,\n\t`memory_deleted_at` text,\n\t`score_summary_json` text,\n\t`reason_codes_json` text,\n\tFOREIGN KEY (`attempt_id`) REFERENCES `retrieval_attempts`(`attempt_id`) ON UPDATE no action ON DELETE cascade,\n\tFOREIGN KEY (`memory_id`) REFERENCES `memory_items`(`id`) ON UPDATE no action ON DELETE set null\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_retrieval_exposures_attempt_rank` ON `retrieval_exposures` (`attempt_id`,`rank`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_exposures_memory` ON `retrieval_exposures` (`memory_id`);\nCREATE TABLE IF NOT EXISTS `outcome_evidence` (\n\t`evidence_id` text PRIMARY KEY NOT NULL,\n\t`contract_version` integer NOT NULL,\n\t`dimension` text NOT NULL,\n\t`evidence_type` text NOT NULL,\n\t`source_class` text NOT NULL,\n\t`observed_at` text NOT NULL,\n\t`producer` text NOT NULL,\n\t`producer_version` text NOT NULL,\n\t`status` text NOT NULL,\n\t`value_type` text,\n\t`value_integer` integer,\n\t`value_real` real,\n\t`value_unit` text,\n\t`session_id` integer,\n\t`source` text,\n\t`stream_id` text,\n\t`source_session_id` text,\n\t`prompt_number` integer,\n\t`raw_event_start_seq` integer,\n\t`raw_event_end_seq` integer,\n\t`experiment_id` text,\n\t`experiment_cell_id` text,\n\t`window_start_at` text,\n\t`window_end_at` text,\n\t`references_json` text,\n\t`retention_until` text,\n\t`retention_pinned` integer DEFAULT 0 NOT NULL,\n\t`retention_finalized_at` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_observed_id` ON `outcome_evidence` (`observed_at`,`evidence_id`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_session_observed` ON `outcome_evidence` (`session_id`,`observed_at`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_source_stream_observed` ON `outcome_evidence` (`source`,`stream_id`,`observed_at`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_type_observed` ON `outcome_evidence` (`evidence_type`,`observed_at`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_retention` ON `outcome_evidence` (`retention_pinned`,`retention_until`);\nCREATE TABLE IF NOT EXISTS `attribution_assessments` (\n\t`assessment_id` text PRIMARY KEY NOT NULL,\n\t`contract_version` integer NOT NULL,\n\t`subject_type` text NOT NULL,\n\t`attempt_id` text NOT NULL,\n\t`exposure_id` integer,\n\t`dimension` text NOT NULL,\n\t`impact_label` text NOT NULL,\n\t`basis` text NOT NULL,\n\t`confidence_level` text NOT NULL,\n\t`method` text NOT NULL,\n\t`method_version` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`claim_type` text DEFAULT 'observational' NOT NULL,\n\tFOREIGN KEY (`attempt_id`) REFERENCES `retrieval_attempts`(`attempt_id`) ON UPDATE no action ON DELETE cascade,\n\tFOREIGN KEY (`exposure_id`) REFERENCES `retrieval_exposures`(`exposure_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessments_attempt_created` ON `attribution_assessments` (`attempt_id`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessments_label_created` ON `attribution_assessments` (`impact_label`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessments_exposure` ON `attribution_assessments` (`exposure_id`);\nCREATE TABLE IF NOT EXISTS `attribution_assessment_evidence` (\n\t`assessment_id` text NOT NULL,\n\t`evidence_id` text NOT NULL,\n\tPRIMARY KEY(`assessment_id`, `evidence_id`),\n\tFOREIGN KEY (`assessment_id`) REFERENCES `attribution_assessments`(`assessment_id`) ON UPDATE no action ON DELETE cascade,\n\tFOREIGN KEY (`evidence_id`) REFERENCES `outcome_evidence`(`evidence_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessment_evidence_evidence` ON `attribution_assessment_evidence` (`evidence_id`,`assessment_id`);\nCREATE TABLE IF NOT EXISTS `raw_events` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`event_id` text,\n\t`event_seq` integer NOT NULL,\n\t`event_type` text NOT NULL,\n\t`ts_wall_ms` integer,\n\t`ts_mono_ms` real,\n\t`payload_json` text NOT NULL,\n\t`capture_context_json` text,\n\t`created_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_raw_events_source_stream_seq` ON `raw_events` (`source`,`stream_id`,`event_seq`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_raw_events_source_stream_event_id` ON `raw_events` (`source`,`stream_id`,`event_id`);\nCREATE INDEX IF NOT EXISTS `idx_raw_events_session_seq` ON `raw_events` (`opencode_session_id`,`event_seq`);\nCREATE INDEX IF NOT EXISTS `idx_raw_events_created` ON `raw_events` (`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_raw_events_capture_context` ON `raw_events` (`source`,`stream_id`,`event_seq`) WHERE \"raw_events\".\"capture_context_json\" IS NOT NULL;\nCREATE TABLE IF NOT EXISTS `raw_event_sessions` (\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`cwd` text,\n\t`project` text,\n\t`started_at` text,\n\t`last_seen_ts_wall_ms` integer,\n\t`last_received_event_seq` integer DEFAULT -1 NOT NULL,\n\t`last_flushed_event_seq` integer DEFAULT -1 NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`source`, `stream_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_raw_event_sessions_pending_updated` ON `raw_event_sessions` (`updated_at`) WHERE \"raw_event_sessions\".\"last_received_event_seq\" > \"raw_event_sessions\".\"last_flushed_event_seq\";\nCREATE TABLE IF NOT EXISTS `opencode_sessions` (\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`session_id` integer,\n\t`created_at` text NOT NULL,\n\tPRIMARY KEY(`source`, `stream_id`),\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_opencode_sessions_session` ON `opencode_sessions` (`session_id`);\nCREATE TABLE IF NOT EXISTS `raw_event_flush_batches` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`start_event_seq` integer NOT NULL,\n\t`end_event_seq` integer NOT NULL,\n\t`extractor_version` text NOT NULL,\n\t`status` text NOT NULL,\n\t`error_message` text,\n\t`error_type` text,\n\t`observer_provider` text,\n\t`observer_model` text,\n\t`observer_runtime` text,\n\t`observer_auth_source` text,\n\t`observer_auth_type` text,\n\t`observer_error_code` text,\n\t`observer_error_message` text,\n\t`attempt_count` integer DEFAULT 0 NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_flush_batches_source_stream_seq_ver` ON `raw_event_flush_batches` (`source`,`stream_id`,`start_event_seq`,`end_event_seq`,`extractor_version`);\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_session_created` ON `raw_event_flush_batches` (`opencode_session_id`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_status_updated` ON `raw_event_flush_batches` (`status`,`updated_at`);\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_observer_status_updated` ON `raw_event_flush_batches` (`status`,`updated_at`) WHERE \"raw_event_flush_batches\".\"observer_provider\" IS NOT NULL;\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_capture_status_updated` ON `raw_event_flush_batches` (`status`,`updated_at`) WHERE \"raw_event_flush_batches\".\"observer_provider\" IS NULL;\nCREATE TABLE IF NOT EXISTS `user_prompts` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer,\n\t`project` text,\n\t`prompt_text` text NOT NULL,\n\t`prompt_number` integer,\n\t`created_at` text NOT NULL,\n\t`created_at_epoch` integer NOT NULL,\n\t`metadata_json` text,\n\t`import_key` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_user_prompts_session` ON `user_prompts` (`session_id`);\nCREATE INDEX IF NOT EXISTS `idx_user_prompts_project` ON `user_prompts` (`project`);\nCREATE INDEX IF NOT EXISTS `idx_user_prompts_epoch` ON `user_prompts` (`created_at_epoch`);\nCREATE TABLE IF NOT EXISTS `session_summaries` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer,\n\t`project` text,\n\t`request` text,\n\t`investigated` text,\n\t`learned` text,\n\t`completed` text,\n\t`next_steps` text,\n\t`notes` text,\n\t`files_read` text,\n\t`files_edited` text,\n\t`prompt_number` integer,\n\t`created_at` text NOT NULL,\n\t`created_at_epoch` integer NOT NULL,\n\t`metadata_json` text,\n\t`import_key` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_session_summaries_session` ON `session_summaries` (`session_id`);\nCREATE INDEX IF NOT EXISTS `idx_session_summaries_project` ON `session_summaries` (`project`);\nCREATE INDEX IF NOT EXISTS `idx_session_summaries_epoch` ON `session_summaries` (`created_at_epoch`);\nCREATE TABLE IF NOT EXISTS `replication_ops` (\n\t`op_id` text PRIMARY KEY NOT NULL,\n\t`entity_type` text NOT NULL,\n\t`entity_id` text NOT NULL,\n\t`op_type` text NOT NULL,\n\t`payload_json` text,\n\t`clock_rev` integer NOT NULL,\n\t`clock_updated_at` text NOT NULL,\n\t`clock_device_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`scope_id` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_replication_ops_created` ON `replication_ops` (`created_at`,`op_id`);\nCREATE INDEX IF NOT EXISTS `idx_replication_ops_entity` ON `replication_ops` (`entity_type`,`entity_id`);\nCREATE INDEX IF NOT EXISTS `idx_replication_ops_scope_created` ON `replication_ops` (`scope_id`,`created_at`,`op_id`);\nCREATE TABLE IF NOT EXISTS `replication_cursors` (\n\t`peer_device_id` text PRIMARY KEY NOT NULL,\n\t`last_applied_cursor` text,\n\t`last_acked_cursor` text,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `replication_cursors_v2` (\n\t`peer_device_id` text NOT NULL,\n\t`scope_id` text NOT NULL,\n\t`last_applied_cursor` text,\n\t`last_acked_cursor` text,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`peer_device_id`, `scope_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_replication_cursors_v2_scope` ON `replication_cursors_v2` (`scope_id`);\nCREATE TABLE IF NOT EXISTS `sync_peers` (\n\t`peer_device_id` text PRIMARY KEY NOT NULL,\n\t`name` text,\n\t`pinned_fingerprint` text,\n\t`public_key` text,\n\t`addresses_json` text,\n\t`manual_addresses_json` text,\n\t`last_success_address` text,\n\t`claimed_local_actor` integer DEFAULT 0 NOT NULL,\n\t`actor_id` text,\n\t`projects_include_json` text,\n\t`projects_exclude_json` text,\n\t`created_at` text NOT NULL,\n\t`last_seen_at` text,\n\t`last_sync_at` text,\n\t`last_error` text,\n\t`runtime_version` text,\n\t`runtime_version_observed_at` text,\n\t`highest_observed_direct_signature_version` integer,\n\t`discovered_via_coordinator_id` text,\n\t`discovered_via_group_id` text,\n\t`trust_provenance` text,\n\t`pending_bootstrap_grant_id` text\n);\n\nCREATE TABLE IF NOT EXISTS `sync_nonces` (\n\t`nonce` text PRIMARY KEY NOT NULL,\n\t`device_id` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_device` (\n\t`device_id` text PRIMARY KEY NOT NULL,\n\t`public_key` text NOT NULL,\n\t`fingerprint` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_attempts` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`peer_device_id` text NOT NULL,\n\t`started_at` text NOT NULL,\n\t`finished_at` text,\n\t`ok` integer NOT NULL,\n\t`ops_in` integer NOT NULL,\n\t`ops_out` integer NOT NULL,\n\t`error` text,\n\t`local_sync_capability` text,\n\t`peer_sync_capability` text,\n\t`negotiated_sync_capability` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_peer_started` ON `sync_attempts` (`peer_device_id`,`started_at`);\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_occurred` ON `sync_attempts` (CASE WHEN \"finished_at\" IS NULL THEN \"started_at\" ELSE \"finished_at\" END,`id`);\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_error_occurred` ON `sync_attempts` (CASE WHEN \"finished_at\" IS NULL THEN \"started_at\" ELSE \"finished_at\" END,`id`) WHERE \"sync_attempts\".\"ok\" = 0;\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_success_occurred` ON `sync_attempts` (CASE WHEN \"finished_at\" IS NULL THEN \"started_at\" ELSE \"finished_at\" END,`id`) WHERE \"sync_attempts\".\"ok\" <> 0;\nCREATE TABLE IF NOT EXISTS `sync_scope_rejections` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`peer_device_id` text,\n\t`op_id` text NOT NULL,\n\t`entity_type` text NOT NULL,\n\t`entity_id` text NOT NULL,\n\t`scope_id` text,\n\t`reason` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_sync_scope_rejections_peer_created` ON `sync_scope_rejections` (`peer_device_id`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_sync_scope_rejections_scope_created` ON `sync_scope_rejections` (`scope_id`,`created_at`);\nCREATE TABLE IF NOT EXISTS `sync_daemon_state` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`last_error` text,\n\t`last_traceback` text,\n\t`last_error_at` text,\n\t`last_ok_at` text,\n\t`phase` text\n);\n\nCREATE TABLE IF NOT EXISTS `sync_reset_state` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`generation` integer NOT NULL,\n\t`snapshot_id` text NOT NULL,\n\t`baseline_cursor` text,\n\t`retained_floor_cursor` text,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_reset_state_v2` (\n\t`scope_id` text PRIMARY KEY NOT NULL,\n\t`generation` integer NOT NULL,\n\t`snapshot_id` text NOT NULL,\n\t`baseline_cursor` text,\n\t`retained_floor_cursor` text,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_retention_state_v2` (\n\t`scope_id` text PRIMARY KEY NOT NULL,\n\t`last_run_at` text,\n\t`last_duration_ms` integer,\n\t`last_deleted_ops` integer DEFAULT 0 NOT NULL,\n\t`last_estimated_bytes_before` integer,\n\t`last_estimated_bytes_after` integer,\n\t`retained_floor_cursor` text,\n\t`last_error` text,\n\t`last_error_at` text\n);\n\nCREATE TABLE IF NOT EXISTS `raw_event_ingest_samples` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`created_at` text NOT NULL,\n\t`inserted_events` integer DEFAULT 0 NOT NULL,\n\t`skipped_invalid` integer DEFAULT 0 NOT NULL,\n\t`skipped_duplicate` integer DEFAULT 0 NOT NULL,\n\t`skipped_conflict` integer DEFAULT 0 NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `raw_event_ingest_stats` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`inserted_events` integer DEFAULT 0 NOT NULL,\n\t`skipped_events` integer DEFAULT 0 NOT NULL,\n\t`skipped_invalid` integer DEFAULT 0 NOT NULL,\n\t`skipped_duplicate` integer DEFAULT 0 NOT NULL,\n\t`skipped_conflict` integer DEFAULT 0 NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `coordinator_group_preferences` (\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`projects_include_json` text,\n\t`projects_exclude_json` text,\n\t`auto_seed_scope` integer DEFAULT 1 NOT NULL,\n\t`default_space_scope_id` text,\n\t`auto_grant_default_space_on_join` integer DEFAULT 0 NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`coordinator_id`, `group_id`)\n);\n\nCREATE TABLE IF NOT EXISTS `actors` (\n\t`actor_id` text PRIMARY KEY NOT NULL,\n\t`display_name` text NOT NULL,\n\t`is_local` integer DEFAULT 0 NOT NULL,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`merged_into_actor_id` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_actors_is_local` ON `actors` (`is_local`);\nCREATE INDEX IF NOT EXISTS `idx_actors_status` ON `actors` (`status`);\nCREATE TABLE IF NOT EXISTS `recipient_policy_review_resolutions` (\n\t`review_item_id` text NOT NULL,\n\t`source_fingerprint` text NOT NULL,\n\t`decision` text NOT NULL,\n\t`decision_input_json` text NOT NULL,\n\t`preview_json` text NOT NULL,\n\t`decided_by_identity_id` text NOT NULL,\n\t`decided_by_device_id` text NOT NULL,\n\t`resolved_at` text NOT NULL,\n\tPRIMARY KEY(`review_item_id`, `source_fingerprint`)\n);\n\nCREATE TABLE IF NOT EXISTS `coordinator_enrollment_reconciliation_issues` (\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`kind` text NOT NULL,\n\t`reference_id` text NOT NULL,\n\t`code` text NOT NULL,\n\t`status` text DEFAULT 'open' NOT NULL,\n\t`first_seen_at` text NOT NULL,\n\t`last_seen_at` text NOT NULL,\n\t`resolved_at` text,\n\t`occurrence_count` integer DEFAULT 1 NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`coordinator_id`, `group_id`, `kind`, `reference_id`, `code`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_coordinator_enrollment_issues_boundary_status` ON `coordinator_enrollment_reconciliation_issues` (`coordinator_id`,`group_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_coordinator_enrollment_issues_status_recent` ON `coordinator_enrollment_reconciliation_issues` (`status`,`last_seen_at`,`resolved_at`);\nCREATE TABLE IF NOT EXISTS `policy_teams` (\n\t`team_id` text PRIMARY KEY NOT NULL,\n\t`display_name` text NOT NULL,\n\t`status` text NOT NULL,\n\t`device_eligibility_mode` text DEFAULT 'person_all_devices' NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `policy_teams_idempotency_key_unique` ON `policy_teams` (`idempotency_key`);\nCREATE TABLE IF NOT EXISTS `policy_team_memberships` (\n\t`team_id` text NOT NULL,\n\t`identity_id` text NOT NULL,\n\t`role` text NOT NULL,\n\t`status` text NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`team_id`, `identity_id`)\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `policy_team_memberships_idempotency_key_unique` ON `policy_team_memberships` (`idempotency_key`);\nCREATE INDEX IF NOT EXISTS `idx_policy_team_memberships_identity_status` ON `policy_team_memberships` (`identity_id`,`status`);\nCREATE TABLE IF NOT EXISTS `policy_team_device_decisions` (\n\t`team_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`decision` text NOT NULL,\n\t`assignment_version` integer DEFAULT 0 NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`team_id`, `device_id`),\n\tFOREIGN KEY (`team_id`) REFERENCES `policy_teams`(`team_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_policy_team_device_decisions_device` ON `policy_team_device_decisions` (`device_id`);\nCREATE TABLE IF NOT EXISTS `identity_devices` (\n\t`device_id` text PRIMARY KEY NOT NULL,\n\t`identity_id` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`status` text NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`assignment_version` integer DEFAULT 0 NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `identity_devices_idempotency_key_unique` ON `identity_devices` (`idempotency_key`);\nCREATE INDEX IF NOT EXISTS `idx_identity_devices_identity_status` ON `identity_devices` (`identity_id`,`status`);\nCREATE TABLE IF NOT EXISTS `project_recipients` (\n\t`canonical_project_identity` text NOT NULL,\n\t`recipient_kind` text NOT NULL,\n\t`recipient_id` text NOT NULL,\n\t`status` text NOT NULL,\n\t`provenance` text NOT NULL,\n\t`policy_revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`canonical_project_identity`, `recipient_kind`, `recipient_id`)\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `project_recipients_idempotency_key_unique` ON `project_recipients` (`idempotency_key`);\nCREATE INDEX IF NOT EXISTS `idx_project_recipients_project_status` ON `project_recipients` (`canonical_project_identity`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_project_recipients_recipient_status` ON `project_recipients` (`recipient_kind`,`recipient_id`,`status`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_drafts` (\n\t`attempt_id` text PRIMARY KEY NOT NULL,\n\t`candidate_id` text NOT NULL,\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`state` text DEFAULT 'needs_setup' NOT NULL,\n\t`display_name` text NOT NULL,\n\t`roster_fingerprint` text NOT NULL,\n\t`projection_fingerprint` text NOT NULL,\n\t`finish_digest` text,\n\t`safe_error_code` text,\n\t`completed_team_id` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\t`completed_at` text,\n\t`superseded_at` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_drafts_candidate_state` ON `legacy_team_setup_drafts` (`candidate_id`,`state`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_drafts_state_updated` ON `legacy_team_setup_drafts` (`state`,`updated_at`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_drafts_finish_digest` ON `legacy_team_setup_drafts` (`finish_digest`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_completions` (\n\t`attempt_id` text NOT NULL,\n\t`finish_digest` text NOT NULL,\n\t`candidate_ref` text NOT NULL,\n\t`confirmed_access_delta_digest` text NOT NULL,\n\t`completed_team_id` text NOT NULL,\n\t`response_json` text NOT NULL,\n\t`completed_at` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_legacy_team_setup_completions_attempt_finish` ON `legacy_team_setup_completions` (`attempt_id`,`finish_digest`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_completions_exact_replay` ON `legacy_team_setup_completions` (`candidate_ref`,`attempt_id`,`finish_digest`,`confirmed_access_delta_digest`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_draft_devices` (\n\t`attempt_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`device_ref` text NOT NULL,\n\t`key_fingerprint` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`enabled` integer NOT NULL,\n\t`existing_identity_id` text,\n\t`existing_assignment_version` integer,\n\t`verified_evidence_kind` text,\n\t`decision` text DEFAULT 'unresolved' NOT NULL,\n\t`target_identity_id` text,\n\t`expected_assignment_kind` text,\n\t`expected_assignment_version` integer,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`attempt_id`, `device_id`),\n\tFOREIGN KEY (`attempt_id`) REFERENCES `legacy_team_setup_drafts`(`attempt_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_legacy_team_setup_devices_attempt_ref` ON `legacy_team_setup_draft_devices` (`attempt_id`,`device_ref`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_devices_attempt_decision` ON `legacy_team_setup_draft_devices` (`attempt_id`,`decision`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_draft_projects` (\n\t`attempt_id` text NOT NULL,\n\t`project_ref` text NOT NULL,\n\t`source_project_identity` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`source_fingerprint` text NOT NULL,\n\t`resolution_kind` text DEFAULT 'unresolved' NOT NULL,\n\t`resolved_project_identity` text,\n\t`target_scope_id` text,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`attempt_id`, `project_ref`),\n\tFOREIGN KEY (`attempt_id`) REFERENCES `legacy_team_setup_drafts`(`attempt_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_projects_attempt_resolution` ON `legacy_team_setup_draft_projects` (`attempt_id`,`resolution_kind`);\nCREATE TABLE IF NOT EXISTS `recipient_managed_project_projections` (\n\t`canonical_project_identity` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`managed_scope_id` text NOT NULL,\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`recipient_identity_id` text NOT NULL,\n\t`accepting_device_id` text NOT NULL,\n\t`source_operation_id` text NOT NULL,\n\t`reviewed_project_set_digest` text NOT NULL,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`accepted_at` text NOT NULL,\n\t`revoked_at` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`source_operation_id`, `canonical_project_identity`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_recipient_managed_projects_identity_status` ON `recipient_managed_project_projections` (`recipient_identity_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_recipient_managed_projects_scope_authority` ON `recipient_managed_project_projections` (`managed_scope_id`,`coordinator_id`,`group_id`,`status`);\nCREATE TABLE IF NOT EXISTS `recipient_policy_authority_states` (\n\t`canonical_project_identity` text PRIMARY KEY NOT NULL,\n\t`authority_state` text DEFAULT 'legacy' NOT NULL,\n\t`generation` integer DEFAULT 0 NOT NULL,\n\t`desired_devices_digest` text,\n\t`current_devices_digest` text,\n\t`stable_parity_evidence_digest` text,\n\t`stable_parity_passed_at` text,\n\t`fresh_snapshot_fingerprint` text,\n\t`fresh_snapshot_observed_at` text,\n\t`safe_error_code` text,\n\t`state_changed_at` text NOT NULL,\n\t`last_error_at` text,\n\t`attempt_count` integer DEFAULT 0 NOT NULL,\n\t`last_attempt_at` text,\n\t`wake_epoch` integer DEFAULT 0 NOT NULL,\n\t`last_completed_at` text,\n\t`lease_owner` text,\n\t`lease_acquired_at` text,\n\t`lease_expires_at` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `recipient_policy_reconciliation_steps` (\n\t`canonical_project_identity` text NOT NULL,\n\t`generation` integer NOT NULL,\n\t`step_key` text NOT NULL,\n\t`effect_id` text NOT NULL,\n\t`payload_digest` text NOT NULL,\n\t`status` text DEFAULT 'pending' NOT NULL,\n\t`attempt_count` integer DEFAULT 0 NOT NULL,\n\t`started_at` text,\n\t`completed_at` text,\n\t`last_attempt_at` text,\n\t`safe_error_code` text,\n\t`error_at` text,\n\t`lease_owner` text,\n\t`lease_acquired_at` text,\n\t`lease_expires_at` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`canonical_project_identity`, `generation`, `step_key`)\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_recipient_policy_reconciliation_steps_effect` ON `recipient_policy_reconciliation_steps` (`effect_id`);\nCREATE INDEX IF NOT EXISTS `idx_recipient_policy_reconciliation_steps_status` ON `recipient_policy_reconciliation_steps` (`canonical_project_identity`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_recipient_policy_reconciliation_steps_pending_refresh` ON `recipient_policy_reconciliation_steps` (`canonical_project_identity`,`generation`,`step_key`) WHERE \"recipient_policy_reconciliation_steps\".\"status\" IN ('pending', 'running', 'failed') AND \"recipient_policy_reconciliation_steps\".\"step_key\" GLOB 'refresh-after-revocations-v2:*';\nCREATE TABLE IF NOT EXISTS `recipient_policy_deny_overlays` (\n\t`canonical_project_identity` text NOT NULL,\n\t`scope_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`generation` integer NOT NULL,\n\t`reason_code` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`canonical_project_identity`, `scope_id`, `device_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_recipient_policy_deny_overlays_scope_device` ON `recipient_policy_deny_overlays` (`scope_id`,`device_id`);";
|
|
7
|
+
export declare const TEST_SCHEMA_BASE_DDL = "CREATE TABLE IF NOT EXISTS `device_identity_binding_commits` (\n\t`commit_digest` text PRIMARY KEY NOT NULL,\n\t`reviewed_inventory_digest` text NOT NULL,\n\t`request_json` text NOT NULL,\n\t`outcomes_json` text NOT NULL,\n\t`write_count` integer NOT NULL,\n\t`decided_by_identity_id` text NOT NULL,\n\t`decided_by_device_id` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `device_identity_binding_audit` (\n\t`event_id` text PRIMARY KEY NOT NULL,\n\t`commit_digest` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`previous_identity_id` text,\n\t`target_identity_id` text NOT NULL,\n\t`action` text NOT NULL,\n\t`previous_assignment_version` integer,\n\t`resulting_assignment_version` integer NOT NULL,\n\t`decided_by_identity_id` text NOT NULL,\n\t`decided_by_device_id` text NOT NULL,\n\t`created_at` text NOT NULL,\n\tFOREIGN KEY (`commit_digest`) REFERENCES `device_identity_binding_commits`(`commit_digest`) ON UPDATE no action ON DELETE no action\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_device_identity_binding_audit_commit_device` ON `device_identity_binding_audit` (`commit_digest`,`device_id`);\nCREATE INDEX IF NOT EXISTS `idx_device_identity_binding_audit_device_created` ON `device_identity_binding_audit` (`device_id`,`created_at`,`event_id`);\nCREATE TABLE IF NOT EXISTS `sessions` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`started_at` text NOT NULL,\n\t`ended_at` text,\n\t`cwd` text,\n\t`project` text,\n\t`git_remote` text,\n\t`git_branch` text,\n\t`user` text,\n\t`tool_version` text,\n\t`metadata_json` text,\n\t`import_key` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_sessions_started_id` ON `sessions` (`started_at`,`id`);\nCREATE TABLE IF NOT EXISTS `replication_scopes` (\n\t`scope_id` text PRIMARY KEY NOT NULL,\n\t`label` text NOT NULL,\n\t`kind` text DEFAULT 'user' NOT NULL,\n\t`authority_type` text DEFAULT 'local' NOT NULL,\n\t`coordinator_id` text,\n\t`group_id` text,\n\t`manifest_issuer_device_id` text,\n\t`membership_epoch` integer DEFAULT 0 NOT NULL,\n\t`manifest_hash` text,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_replication_scopes_status` ON `replication_scopes` (`status`);\nCREATE INDEX IF NOT EXISTS `idx_replication_scopes_authority_group` ON `replication_scopes` (`coordinator_id`,`group_id`);\nCREATE TABLE IF NOT EXISTS `project_scope_mappings` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`workspace_identity` text,\n\t`project_pattern` text NOT NULL,\n\t`scope_id` text NOT NULL,\n\t`priority` integer DEFAULT 0 NOT NULL,\n\t`source` text DEFAULT 'user' NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_project_scope_mappings_workspace_priority` ON `project_scope_mappings` (`workspace_identity`,`priority`);\nCREATE INDEX IF NOT EXISTS `idx_project_scope_mappings_pattern_priority` ON `project_scope_mappings` (`project_pattern`,`priority`);\nCREATE INDEX IF NOT EXISTS `idx_project_scope_mappings_scope` ON `project_scope_mappings` (`scope_id`);\nCREATE TABLE IF NOT EXISTS `scope_memberships` (\n\t`scope_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`role` text DEFAULT 'member' NOT NULL,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`membership_epoch` integer DEFAULT 0 NOT NULL,\n\t`coordinator_id` text,\n\t`group_id` text,\n\t`manifest_issuer_device_id` text,\n\t`manifest_hash` text,\n\t`signed_manifest_json` text,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`scope_id`, `device_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_scope_memberships_device_status` ON `scope_memberships` (`device_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_scope_memberships_scope_status` ON `scope_memberships` (`scope_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_scope_memberships_authority_group` ON `scope_memberships` (`coordinator_id`,`group_id`);\nCREATE TABLE IF NOT EXISTS `artifacts` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer NOT NULL,\n\t`kind` text NOT NULL,\n\t`path` text,\n\t`content_text` text,\n\t`content_hash` text,\n\t`created_at` text NOT NULL,\n\t`metadata_json` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_artifacts_session_kind` ON `artifacts` (`session_id`,`kind`);\nCREATE TABLE IF NOT EXISTS `memory_items` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer NOT NULL,\n\t`kind` text NOT NULL,\n\t`title` text NOT NULL,\n\t`subtitle` text,\n\t`body_text` text NOT NULL,\n\t`confidence` real DEFAULT 0.5,\n\t`tags_text` text DEFAULT '',\n\t`active` integer DEFAULT 1,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\t`metadata_json` text,\n\t`actor_id` text,\n\t`actor_display_name` text,\n\t`visibility` text,\n\t`workspace_id` text,\n\t`workspace_kind` text,\n\t`origin_device_id` text,\n\t`origin_source` text,\n\t`trust_state` text,\n\t`facts` text,\n\t`narrative` text,\n\t`concepts` text,\n\t`files_read` text,\n\t`files_modified` text,\n\t`user_prompt_id` integer,\n\t`prompt_number` integer,\n\t`deleted_at` text,\n\t`rev` integer DEFAULT 0,\n\t`dedup_key` text,\n\t`import_key` text,\n\t`scope_id` text,\n\t`project` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_memory_items_active_created` ON `memory_items` (`active`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_created_id` ON `memory_items` (`created_at`,`id`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_origin_device_active` ON `memory_items` (`origin_device_id`,`active`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_session` ON `memory_items` (`session_id`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_project` ON `memory_items` (`project`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_scope_visibility_created` ON `memory_items` (`scope_id`,`visibility`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_memory_items_scope_backfill_pending` ON `memory_items` (`id`) WHERE scope_id IS NULL OR scope_id = '';\nCREATE INDEX IF NOT EXISTS `idx_memory_items_dedup_key_active_created` ON `memory_items` (`dedup_key`,`active`,`created_at`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_memory_items_same_session_dedup_unique` ON `memory_items` (`session_id`,`kind`,`visibility`,`workspace_id`,`dedup_key`) WHERE active = 1 AND dedup_key IS NOT NULL;\nCREATE TABLE IF NOT EXISTS `memory_file_refs` (\n\t`memory_id` integer NOT NULL,\n\t`file_path` text NOT NULL,\n\t`relation` text NOT NULL,\n\tPRIMARY KEY(`memory_id`, `file_path`, `relation`),\n\tFOREIGN KEY (`memory_id`) REFERENCES `memory_items`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_memory_file_refs_path` ON `memory_file_refs` (`file_path`);\nCREATE TABLE IF NOT EXISTS `memory_concept_refs` (\n\t`memory_id` integer NOT NULL,\n\t`concept` text NOT NULL,\n\tPRIMARY KEY(`memory_id`, `concept`),\n\tFOREIGN KEY (`memory_id`) REFERENCES `memory_items`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_memory_concept_refs_concept` ON `memory_concept_refs` (`concept`);\nCREATE TABLE IF NOT EXISTS `usage_events` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer,\n\t`event` text NOT NULL,\n\t`tokens_read` integer DEFAULT 0,\n\t`tokens_written` integer DEFAULT 0,\n\t`tokens_saved` integer DEFAULT 0,\n\t`created_at` text NOT NULL,\n\t`metadata_json` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE set null\n);\n\nCREATE INDEX IF NOT EXISTS `idx_usage_events_event_created` ON `usage_events` (`event`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_usage_events_session` ON `usage_events` (`session_id`);\nCREATE TABLE IF NOT EXISTS `retrieval_attempts` (\n\t`attempt_id` text PRIMARY KEY NOT NULL,\n\t`contract_version` integer NOT NULL,\n\t`surface` text NOT NULL,\n\t`trigger` text NOT NULL,\n\t`started_at` text NOT NULL,\n\t`completed_at` text,\n\t`retrieval_status` text NOT NULL,\n\t`delivery_status` text NOT NULL,\n\t`candidate_count` integer NOT NULL,\n\t`selected_count` integer NOT NULL,\n\t`persisted_candidate_count` integer NOT NULL,\n\t`recorder_version` text NOT NULL,\n\t`session_id` integer,\n\t`source` text,\n\t`stream_id` text,\n\t`source_session_id` text,\n\t`prompt_number` integer,\n\t`request_id` text,\n\t`raw_event_start_seq` integer,\n\t`raw_event_end_seq` integer,\n\t`experiment_id` text,\n\t`experiment_cell_id` text,\n\t`evaluation_checkout_id` text,\n\t`evaluation_fixture_id` text,\n\t`evaluation_seed` integer,\n\t`latency_ms` integer,\n\t`project` text,\n\t`scope_id` text,\n\t`mode` text,\n\t`limit_requested` integer,\n\t`token_budget` integer,\n\t`output_tokens` integer,\n\t`working_set_file_count` integer,\n\t`working_set_files_json` text,\n\t`query_hash_sha256` text,\n\t`query_char_count` integer,\n\t`query_token_estimate` integer,\n\t`filter_summary_json` text,\n\t`failure_code` text,\n\t`failure_stage` text,\n\t`trace_version` integer,\n\t`automatic_recall_json` text,\n\t`automatic_recall_key` text,\n\t`retention_until` text,\n\t`retention_pinned` integer DEFAULT 0 NOT NULL,\n\t`retention_finalized_at` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_session_started` ON `retrieval_attempts` (`session_id`,`started_at`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_retrieval_attempts_automatic_recall_key` ON `retrieval_attempts` (`automatic_recall_key`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_source_stream_started` ON `retrieval_attempts` (`source`,`stream_id`,`started_at`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_retention` ON `retrieval_attempts` (`retention_pinned`,`retention_until`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_started` ON `retrieval_attempts` (`started_at`,`attempt_id`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_surface_started` ON `retrieval_attempts` (`surface`,`started_at`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_retrieval_attempts_request_identity` ON `retrieval_attempts` (`source`,`surface`,`request_id`) WHERE request_id IS NOT NULL;\nCREATE INDEX IF NOT EXISTS `idx_retrieval_attempts_experiment_cell` ON `retrieval_attempts` (`experiment_id`,`experiment_cell_id`);\nCREATE TABLE IF NOT EXISTS `retrieval_exposures` (\n\t`exposure_id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`attempt_id` text NOT NULL,\n\t`memory_id` integer,\n\t`memory_import_key` text,\n\t`origin_device_id` text,\n\t`rank` integer NOT NULL,\n\t`disposition` text NOT NULL,\n\t`section` text,\n\t`handoff_status` text NOT NULL,\n\t`memory_rev` integer,\n\t`memory_updated_at` text,\n\t`memory_scope_id` text,\n\t`memory_kind` text,\n\t`memory_active` integer,\n\t`memory_deleted_at` text,\n\t`score_summary_json` text,\n\t`reason_codes_json` text,\n\tFOREIGN KEY (`attempt_id`) REFERENCES `retrieval_attempts`(`attempt_id`) ON UPDATE no action ON DELETE cascade,\n\tFOREIGN KEY (`memory_id`) REFERENCES `memory_items`(`id`) ON UPDATE no action ON DELETE set null\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_retrieval_exposures_attempt_rank` ON `retrieval_exposures` (`attempt_id`,`rank`);\nCREATE INDEX IF NOT EXISTS `idx_retrieval_exposures_memory` ON `retrieval_exposures` (`memory_id`);\nCREATE TABLE IF NOT EXISTS `outcome_evidence` (\n\t`evidence_id` text PRIMARY KEY NOT NULL,\n\t`contract_version` integer NOT NULL,\n\t`dimension` text NOT NULL,\n\t`evidence_type` text NOT NULL,\n\t`source_class` text NOT NULL,\n\t`observed_at` text NOT NULL,\n\t`producer` text NOT NULL,\n\t`producer_version` text NOT NULL,\n\t`status` text NOT NULL,\n\t`value_type` text,\n\t`value_integer` integer,\n\t`value_real` real,\n\t`value_unit` text,\n\t`session_id` integer,\n\t`source` text,\n\t`stream_id` text,\n\t`source_session_id` text,\n\t`prompt_number` integer,\n\t`raw_event_start_seq` integer,\n\t`raw_event_end_seq` integer,\n\t`experiment_id` text,\n\t`experiment_cell_id` text,\n\t`window_start_at` text,\n\t`window_end_at` text,\n\t`references_json` text,\n\t`retention_until` text,\n\t`retention_pinned` integer DEFAULT 0 NOT NULL,\n\t`retention_finalized_at` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_observed_id` ON `outcome_evidence` (`observed_at`,`evidence_id`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_session_observed` ON `outcome_evidence` (`session_id`,`observed_at`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_source_stream_observed` ON `outcome_evidence` (`source`,`stream_id`,`observed_at`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_type_observed` ON `outcome_evidence` (`evidence_type`,`observed_at`);\nCREATE INDEX IF NOT EXISTS `idx_outcome_evidence_retention` ON `outcome_evidence` (`retention_pinned`,`retention_until`);\nCREATE TABLE IF NOT EXISTS `attribution_assessments` (\n\t`assessment_id` text PRIMARY KEY NOT NULL,\n\t`contract_version` integer NOT NULL,\n\t`subject_type` text NOT NULL,\n\t`attempt_id` text NOT NULL,\n\t`exposure_id` integer,\n\t`dimension` text NOT NULL,\n\t`impact_label` text NOT NULL,\n\t`basis` text NOT NULL,\n\t`confidence_level` text NOT NULL,\n\t`method` text NOT NULL,\n\t`method_version` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`claim_type` text DEFAULT 'observational' NOT NULL,\n\tFOREIGN KEY (`attempt_id`) REFERENCES `retrieval_attempts`(`attempt_id`) ON UPDATE no action ON DELETE cascade,\n\tFOREIGN KEY (`exposure_id`) REFERENCES `retrieval_exposures`(`exposure_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessments_attempt_created` ON `attribution_assessments` (`attempt_id`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessments_label_created` ON `attribution_assessments` (`impact_label`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessments_exposure` ON `attribution_assessments` (`exposure_id`);\nCREATE TABLE IF NOT EXISTS `attribution_assessment_evidence` (\n\t`assessment_id` text NOT NULL,\n\t`evidence_id` text NOT NULL,\n\tPRIMARY KEY(`assessment_id`, `evidence_id`),\n\tFOREIGN KEY (`assessment_id`) REFERENCES `attribution_assessments`(`assessment_id`) ON UPDATE no action ON DELETE cascade,\n\tFOREIGN KEY (`evidence_id`) REFERENCES `outcome_evidence`(`evidence_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_attribution_assessment_evidence_evidence` ON `attribution_assessment_evidence` (`evidence_id`,`assessment_id`);\nCREATE TABLE IF NOT EXISTS `raw_events` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`event_id` text,\n\t`event_seq` integer NOT NULL,\n\t`event_type` text NOT NULL,\n\t`ts_wall_ms` integer,\n\t`ts_mono_ms` real,\n\t`payload_json` text NOT NULL,\n\t`capture_context_json` text,\n\t`created_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_raw_events_source_stream_seq` ON `raw_events` (`source`,`stream_id`,`event_seq`);\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_raw_events_source_stream_event_id` ON `raw_events` (`source`,`stream_id`,`event_id`);\nCREATE INDEX IF NOT EXISTS `idx_raw_events_session_seq` ON `raw_events` (`opencode_session_id`,`event_seq`);\nCREATE INDEX IF NOT EXISTS `idx_raw_events_created` ON `raw_events` (`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_raw_events_capture_context` ON `raw_events` (`source`,`stream_id`,`event_seq`) WHERE \"raw_events\".\"capture_context_json\" IS NOT NULL;\nCREATE TABLE IF NOT EXISTS `raw_event_sessions` (\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`cwd` text,\n\t`project` text,\n\t`started_at` text,\n\t`last_seen_ts_wall_ms` integer,\n\t`last_received_event_seq` integer DEFAULT -1 NOT NULL,\n\t`last_flushed_event_seq` integer DEFAULT -1 NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`source`, `stream_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_raw_event_sessions_pending_updated` ON `raw_event_sessions` (`updated_at`) WHERE \"raw_event_sessions\".\"last_received_event_seq\" > \"raw_event_sessions\".\"last_flushed_event_seq\";\nCREATE TABLE IF NOT EXISTS `opencode_sessions` (\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`session_id` integer,\n\t`created_at` text NOT NULL,\n\tPRIMARY KEY(`source`, `stream_id`),\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_opencode_sessions_session` ON `opencode_sessions` (`session_id`);\nCREATE TABLE IF NOT EXISTS `raw_event_flush_batches` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`source` text DEFAULT 'opencode' NOT NULL,\n\t`stream_id` text DEFAULT '' NOT NULL,\n\t`opencode_session_id` text NOT NULL,\n\t`start_event_seq` integer NOT NULL,\n\t`end_event_seq` integer NOT NULL,\n\t`extractor_version` text NOT NULL,\n\t`status` text NOT NULL,\n\t`error_message` text,\n\t`error_type` text,\n\t`observer_provider` text,\n\t`observer_model` text,\n\t`observer_runtime` text,\n\t`observer_auth_source` text,\n\t`observer_auth_type` text,\n\t`observer_error_code` text,\n\t`observer_error_message` text,\n\t`attempt_count` integer DEFAULT 0 NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_flush_batches_source_stream_seq_ver` ON `raw_event_flush_batches` (`source`,`stream_id`,`start_event_seq`,`end_event_seq`,`extractor_version`);\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_session_created` ON `raw_event_flush_batches` (`opencode_session_id`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_status_updated` ON `raw_event_flush_batches` (`status`,`updated_at`);\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_observer_status_updated` ON `raw_event_flush_batches` (`status`,`updated_at`) WHERE \"raw_event_flush_batches\".\"observer_provider\" IS NOT NULL;\nCREATE INDEX IF NOT EXISTS `idx_flush_batches_capture_status_updated` ON `raw_event_flush_batches` (`status`,`updated_at`) WHERE \"raw_event_flush_batches\".\"observer_provider\" IS NULL;\nCREATE TABLE IF NOT EXISTS `user_prompts` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer,\n\t`project` text,\n\t`prompt_text` text NOT NULL,\n\t`prompt_number` integer,\n\t`created_at` text NOT NULL,\n\t`created_at_epoch` integer NOT NULL,\n\t`metadata_json` text,\n\t`import_key` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_user_prompts_session` ON `user_prompts` (`session_id`);\nCREATE INDEX IF NOT EXISTS `idx_user_prompts_project` ON `user_prompts` (`project`);\nCREATE INDEX IF NOT EXISTS `idx_user_prompts_epoch` ON `user_prompts` (`created_at_epoch`);\nCREATE TABLE IF NOT EXISTS `session_summaries` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`session_id` integer,\n\t`project` text,\n\t`request` text,\n\t`investigated` text,\n\t`learned` text,\n\t`completed` text,\n\t`next_steps` text,\n\t`notes` text,\n\t`files_read` text,\n\t`files_edited` text,\n\t`prompt_number` integer,\n\t`created_at` text NOT NULL,\n\t`created_at_epoch` integer NOT NULL,\n\t`metadata_json` text,\n\t`import_key` text,\n\tFOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_session_summaries_session` ON `session_summaries` (`session_id`);\nCREATE INDEX IF NOT EXISTS `idx_session_summaries_project` ON `session_summaries` (`project`);\nCREATE INDEX IF NOT EXISTS `idx_session_summaries_epoch` ON `session_summaries` (`created_at_epoch`);\nCREATE TABLE IF NOT EXISTS `replication_ops` (\n\t`op_id` text PRIMARY KEY NOT NULL,\n\t`entity_type` text NOT NULL,\n\t`entity_id` text NOT NULL,\n\t`op_type` text NOT NULL,\n\t`payload_json` text,\n\t`clock_rev` integer NOT NULL,\n\t`clock_updated_at` text NOT NULL,\n\t`clock_device_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`scope_id` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_replication_ops_created` ON `replication_ops` (`created_at`,`op_id`);\nCREATE INDEX IF NOT EXISTS `idx_replication_ops_entity` ON `replication_ops` (`entity_type`,`entity_id`);\nCREATE INDEX IF NOT EXISTS `idx_replication_ops_scope_created` ON `replication_ops` (`scope_id`,`created_at`,`op_id`);\nCREATE TABLE IF NOT EXISTS `replication_cursors` (\n\t`peer_device_id` text PRIMARY KEY NOT NULL,\n\t`last_applied_cursor` text,\n\t`last_acked_cursor` text,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `replication_cursors_v2` (\n\t`peer_device_id` text NOT NULL,\n\t`scope_id` text NOT NULL,\n\t`last_applied_cursor` text,\n\t`last_acked_cursor` text,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`peer_device_id`, `scope_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_replication_cursors_v2_scope` ON `replication_cursors_v2` (`scope_id`);\nCREATE TABLE IF NOT EXISTS `sync_peers` (\n\t`peer_device_id` text PRIMARY KEY NOT NULL,\n\t`name` text,\n\t`pinned_fingerprint` text,\n\t`public_key` text,\n\t`addresses_json` text,\n\t`manual_addresses_json` text,\n\t`last_success_address` text,\n\t`claimed_local_actor` integer DEFAULT 0 NOT NULL,\n\t`actor_id` text,\n\t`projects_include_json` text,\n\t`projects_exclude_json` text,\n\t`created_at` text NOT NULL,\n\t`last_seen_at` text,\n\t`last_sync_at` text,\n\t`last_error` text,\n\t`runtime_version` text,\n\t`runtime_version_observed_at` text,\n\t`highest_observed_direct_signature_version` integer,\n\t`discovered_via_coordinator_id` text,\n\t`discovered_via_group_id` text,\n\t`trust_provenance` text,\n\t`pending_bootstrap_grant_id` text\n);\n\nCREATE TABLE IF NOT EXISTS `sync_nonces` (\n\t`nonce` text PRIMARY KEY NOT NULL,\n\t`device_id` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_device` (\n\t`device_id` text PRIMARY KEY NOT NULL,\n\t`public_key` text NOT NULL,\n\t`fingerprint` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_attempts` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`peer_device_id` text NOT NULL,\n\t`started_at` text NOT NULL,\n\t`finished_at` text,\n\t`ok` integer NOT NULL,\n\t`ops_in` integer NOT NULL,\n\t`ops_out` integer NOT NULL,\n\t`error` text,\n\t`local_sync_capability` text,\n\t`peer_sync_capability` text,\n\t`negotiated_sync_capability` text,\n\t`failure_category` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_peer_started` ON `sync_attempts` (`peer_device_id`,`started_at`);\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_occurred` ON `sync_attempts` (CASE WHEN \"finished_at\" IS NULL THEN \"started_at\" ELSE \"finished_at\" END,`id`);\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_error_occurred` ON `sync_attempts` (CASE WHEN \"finished_at\" IS NULL THEN \"started_at\" ELSE \"finished_at\" END,`id`) WHERE \"sync_attempts\".\"ok\" = 0;\nCREATE INDEX IF NOT EXISTS `idx_sync_attempts_success_occurred` ON `sync_attempts` (CASE WHEN \"finished_at\" IS NULL THEN \"started_at\" ELSE \"finished_at\" END,`id`) WHERE \"sync_attempts\".\"ok\" <> 0;\nCREATE TABLE IF NOT EXISTS `sync_scope_rejections` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`peer_device_id` text,\n\t`op_id` text NOT NULL,\n\t`entity_type` text NOT NULL,\n\t`entity_id` text NOT NULL,\n\t`scope_id` text,\n\t`reason` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_sync_scope_rejections_peer_created` ON `sync_scope_rejections` (`peer_device_id`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_sync_scope_rejections_scope_created` ON `sync_scope_rejections` (`scope_id`,`created_at`);\nCREATE TABLE IF NOT EXISTS `sync_daemon_state` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`last_error` text,\n\t`last_traceback` text,\n\t`last_error_at` text,\n\t`last_ok_at` text,\n\t`phase` text\n);\n\nCREATE TABLE IF NOT EXISTS `sync_reset_state` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`generation` integer NOT NULL,\n\t`snapshot_id` text NOT NULL,\n\t`baseline_cursor` text,\n\t`retained_floor_cursor` text,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_reset_state_v2` (\n\t`scope_id` text PRIMARY KEY NOT NULL,\n\t`generation` integer NOT NULL,\n\t`snapshot_id` text NOT NULL,\n\t`baseline_cursor` text,\n\t`retained_floor_cursor` text,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `sync_retention_state_v2` (\n\t`scope_id` text PRIMARY KEY NOT NULL,\n\t`last_run_at` text,\n\t`last_duration_ms` integer,\n\t`last_deleted_ops` integer DEFAULT 0 NOT NULL,\n\t`last_estimated_bytes_before` integer,\n\t`last_estimated_bytes_after` integer,\n\t`retained_floor_cursor` text,\n\t`last_error` text,\n\t`last_error_at` text\n);\n\nCREATE TABLE IF NOT EXISTS `raw_event_ingest_samples` (\n\t`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,\n\t`created_at` text NOT NULL,\n\t`inserted_events` integer DEFAULT 0 NOT NULL,\n\t`skipped_invalid` integer DEFAULT 0 NOT NULL,\n\t`skipped_duplicate` integer DEFAULT 0 NOT NULL,\n\t`skipped_conflict` integer DEFAULT 0 NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `raw_event_ingest_stats` (\n\t`id` integer PRIMARY KEY NOT NULL,\n\t`inserted_events` integer DEFAULT 0 NOT NULL,\n\t`skipped_events` integer DEFAULT 0 NOT NULL,\n\t`skipped_invalid` integer DEFAULT 0 NOT NULL,\n\t`skipped_duplicate` integer DEFAULT 0 NOT NULL,\n\t`skipped_conflict` integer DEFAULT 0 NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `coordinator_group_preferences` (\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`projects_include_json` text,\n\t`projects_exclude_json` text,\n\t`auto_seed_scope` integer DEFAULT 1 NOT NULL,\n\t`default_space_scope_id` text,\n\t`auto_grant_default_space_on_join` integer DEFAULT 0 NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`coordinator_id`, `group_id`)\n);\n\nCREATE TABLE IF NOT EXISTS `actors` (\n\t`actor_id` text PRIMARY KEY NOT NULL,\n\t`display_name` text NOT NULL,\n\t`is_local` integer DEFAULT 0 NOT NULL,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`merged_into_actor_id` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS `idx_actors_is_local` ON `actors` (`is_local`);\nCREATE INDEX IF NOT EXISTS `idx_actors_status` ON `actors` (`status`);\nCREATE TABLE IF NOT EXISTS `recipient_policy_review_resolutions` (\n\t`review_item_id` text NOT NULL,\n\t`source_fingerprint` text NOT NULL,\n\t`decision` text NOT NULL,\n\t`decision_input_json` text NOT NULL,\n\t`preview_json` text NOT NULL,\n\t`decided_by_identity_id` text NOT NULL,\n\t`decided_by_device_id` text NOT NULL,\n\t`resolved_at` text NOT NULL,\n\tPRIMARY KEY(`review_item_id`, `source_fingerprint`)\n);\n\nCREATE TABLE IF NOT EXISTS `coordinator_enrollment_reconciliation_issues` (\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`kind` text NOT NULL,\n\t`reference_id` text NOT NULL,\n\t`code` text NOT NULL,\n\t`status` text DEFAULT 'open' NOT NULL,\n\t`first_seen_at` text NOT NULL,\n\t`last_seen_at` text NOT NULL,\n\t`resolved_at` text,\n\t`occurrence_count` integer DEFAULT 1 NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`coordinator_id`, `group_id`, `kind`, `reference_id`, `code`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_coordinator_enrollment_issues_boundary_status` ON `coordinator_enrollment_reconciliation_issues` (`coordinator_id`,`group_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_coordinator_enrollment_issues_status_recent` ON `coordinator_enrollment_reconciliation_issues` (`status`,`last_seen_at`,`resolved_at`);\nCREATE TABLE IF NOT EXISTS `policy_teams` (\n\t`team_id` text PRIMARY KEY NOT NULL,\n\t`display_name` text NOT NULL,\n\t`status` text NOT NULL,\n\t`device_eligibility_mode` text DEFAULT 'person_all_devices' NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `policy_teams_idempotency_key_unique` ON `policy_teams` (`idempotency_key`);\nCREATE TABLE IF NOT EXISTS `policy_team_memberships` (\n\t`team_id` text NOT NULL,\n\t`identity_id` text NOT NULL,\n\t`role` text NOT NULL,\n\t`status` text NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`team_id`, `identity_id`)\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `policy_team_memberships_idempotency_key_unique` ON `policy_team_memberships` (`idempotency_key`);\nCREATE INDEX IF NOT EXISTS `idx_policy_team_memberships_identity_status` ON `policy_team_memberships` (`identity_id`,`status`);\nCREATE TABLE IF NOT EXISTS `policy_team_device_decisions` (\n\t`team_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`decision` text NOT NULL,\n\t`assignment_version` integer DEFAULT 0 NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`team_id`, `device_id`),\n\tFOREIGN KEY (`team_id`) REFERENCES `policy_teams`(`team_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_policy_team_device_decisions_device` ON `policy_team_device_decisions` (`device_id`);\nCREATE TABLE IF NOT EXISTS `identity_devices` (\n\t`device_id` text PRIMARY KEY NOT NULL,\n\t`identity_id` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`status` text NOT NULL,\n\t`provenance` text NOT NULL,\n\t`revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`assignment_version` integer DEFAULT 0 NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `identity_devices_idempotency_key_unique` ON `identity_devices` (`idempotency_key`);\nCREATE INDEX IF NOT EXISTS `idx_identity_devices_identity_status` ON `identity_devices` (`identity_id`,`status`);\nCREATE TABLE IF NOT EXISTS `project_recipients` (\n\t`canonical_project_identity` text NOT NULL,\n\t`recipient_kind` text NOT NULL,\n\t`recipient_id` text NOT NULL,\n\t`status` text NOT NULL,\n\t`provenance` text NOT NULL,\n\t`policy_revision` text NOT NULL,\n\t`migration_state` text NOT NULL,\n\t`source_fingerprint` text,\n\t`idempotency_key` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`canonical_project_identity`, `recipient_kind`, `recipient_id`)\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `project_recipients_idempotency_key_unique` ON `project_recipients` (`idempotency_key`);\nCREATE INDEX IF NOT EXISTS `idx_project_recipients_project_status` ON `project_recipients` (`canonical_project_identity`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_project_recipients_recipient_status` ON `project_recipients` (`recipient_kind`,`recipient_id`,`status`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_drafts` (\n\t`attempt_id` text PRIMARY KEY NOT NULL,\n\t`candidate_id` text NOT NULL,\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`state` text DEFAULT 'needs_setup' NOT NULL,\n\t`display_name` text NOT NULL,\n\t`roster_fingerprint` text NOT NULL,\n\t`projection_fingerprint` text NOT NULL,\n\t`finish_digest` text,\n\t`safe_error_code` text,\n\t`completed_team_id` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\t`completed_at` text,\n\t`superseded_at` text\n);\n\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_drafts_candidate_state` ON `legacy_team_setup_drafts` (`candidate_id`,`state`,`created_at`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_drafts_state_updated` ON `legacy_team_setup_drafts` (`state`,`updated_at`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_drafts_finish_digest` ON `legacy_team_setup_drafts` (`finish_digest`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_completions` (\n\t`attempt_id` text NOT NULL,\n\t`finish_digest` text NOT NULL,\n\t`candidate_ref` text NOT NULL,\n\t`confirmed_access_delta_digest` text NOT NULL,\n\t`completed_team_id` text NOT NULL,\n\t`response_json` text NOT NULL,\n\t`completed_at` text NOT NULL,\n\t`created_at` text NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_legacy_team_setup_completions_attempt_finish` ON `legacy_team_setup_completions` (`attempt_id`,`finish_digest`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_completions_exact_replay` ON `legacy_team_setup_completions` (`candidate_ref`,`attempt_id`,`finish_digest`,`confirmed_access_delta_digest`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_draft_devices` (\n\t`attempt_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`device_ref` text NOT NULL,\n\t`key_fingerprint` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`enabled` integer NOT NULL,\n\t`existing_identity_id` text,\n\t`existing_assignment_version` integer,\n\t`verified_evidence_kind` text,\n\t`decision` text DEFAULT 'unresolved' NOT NULL,\n\t`target_identity_id` text,\n\t`expected_assignment_kind` text,\n\t`expected_assignment_version` integer,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`attempt_id`, `device_id`),\n\tFOREIGN KEY (`attempt_id`) REFERENCES `legacy_team_setup_drafts`(`attempt_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_legacy_team_setup_devices_attempt_ref` ON `legacy_team_setup_draft_devices` (`attempt_id`,`device_ref`);\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_devices_attempt_decision` ON `legacy_team_setup_draft_devices` (`attempt_id`,`decision`);\nCREATE TABLE IF NOT EXISTS `legacy_team_setup_draft_projects` (\n\t`attempt_id` text NOT NULL,\n\t`project_ref` text NOT NULL,\n\t`source_project_identity` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`source_fingerprint` text NOT NULL,\n\t`resolution_kind` text DEFAULT 'unresolved' NOT NULL,\n\t`resolved_project_identity` text,\n\t`target_scope_id` text,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`attempt_id`, `project_ref`),\n\tFOREIGN KEY (`attempt_id`) REFERENCES `legacy_team_setup_drafts`(`attempt_id`) ON UPDATE no action ON DELETE cascade\n);\n\nCREATE INDEX IF NOT EXISTS `idx_legacy_team_setup_projects_attempt_resolution` ON `legacy_team_setup_draft_projects` (`attempt_id`,`resolution_kind`);\nCREATE TABLE IF NOT EXISTS `recipient_managed_project_projections` (\n\t`canonical_project_identity` text NOT NULL,\n\t`display_name` text NOT NULL,\n\t`managed_scope_id` text NOT NULL,\n\t`coordinator_id` text NOT NULL,\n\t`group_id` text NOT NULL,\n\t`recipient_identity_id` text NOT NULL,\n\t`accepting_device_id` text NOT NULL,\n\t`source_operation_id` text NOT NULL,\n\t`reviewed_project_set_digest` text NOT NULL,\n\t`status` text DEFAULT 'active' NOT NULL,\n\t`accepted_at` text NOT NULL,\n\t`revoked_at` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`source_operation_id`, `canonical_project_identity`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_recipient_managed_projects_identity_status` ON `recipient_managed_project_projections` (`recipient_identity_id`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_recipient_managed_projects_scope_authority` ON `recipient_managed_project_projections` (`managed_scope_id`,`coordinator_id`,`group_id`,`status`);\nCREATE TABLE IF NOT EXISTS `recipient_policy_authority_states` (\n\t`canonical_project_identity` text PRIMARY KEY NOT NULL,\n\t`authority_state` text DEFAULT 'legacy' NOT NULL,\n\t`generation` integer DEFAULT 0 NOT NULL,\n\t`desired_devices_digest` text,\n\t`current_devices_digest` text,\n\t`stable_parity_evidence_digest` text,\n\t`stable_parity_passed_at` text,\n\t`fresh_snapshot_fingerprint` text,\n\t`fresh_snapshot_observed_at` text,\n\t`safe_error_code` text,\n\t`state_changed_at` text NOT NULL,\n\t`last_error_at` text,\n\t`attempt_count` integer DEFAULT 0 NOT NULL,\n\t`last_attempt_at` text,\n\t`wake_epoch` integer DEFAULT 0 NOT NULL,\n\t`last_completed_at` text,\n\t`lease_owner` text,\n\t`lease_acquired_at` text,\n\t`lease_expires_at` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS `recipient_policy_reconciliation_steps` (\n\t`canonical_project_identity` text NOT NULL,\n\t`generation` integer NOT NULL,\n\t`step_key` text NOT NULL,\n\t`effect_id` text NOT NULL,\n\t`payload_digest` text NOT NULL,\n\t`status` text DEFAULT 'pending' NOT NULL,\n\t`attempt_count` integer DEFAULT 0 NOT NULL,\n\t`started_at` text,\n\t`completed_at` text,\n\t`last_attempt_at` text,\n\t`safe_error_code` text,\n\t`error_at` text,\n\t`lease_owner` text,\n\t`lease_acquired_at` text,\n\t`lease_expires_at` text,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`canonical_project_identity`, `generation`, `step_key`)\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS `idx_recipient_policy_reconciliation_steps_effect` ON `recipient_policy_reconciliation_steps` (`effect_id`);\nCREATE INDEX IF NOT EXISTS `idx_recipient_policy_reconciliation_steps_status` ON `recipient_policy_reconciliation_steps` (`canonical_project_identity`,`status`);\nCREATE INDEX IF NOT EXISTS `idx_recipient_policy_reconciliation_steps_pending_refresh` ON `recipient_policy_reconciliation_steps` (`canonical_project_identity`,`generation`,`step_key`) WHERE \"recipient_policy_reconciliation_steps\".\"status\" IN ('pending', 'running', 'failed') AND \"recipient_policy_reconciliation_steps\".\"step_key\" GLOB 'refresh-after-revocations-v2:*';\nCREATE TABLE IF NOT EXISTS `recipient_policy_deny_overlays` (\n\t`canonical_project_identity` text NOT NULL,\n\t`scope_id` text NOT NULL,\n\t`device_id` text NOT NULL,\n\t`generation` integer NOT NULL,\n\t`reason_code` text NOT NULL,\n\t`created_at` text NOT NULL,\n\t`updated_at` text NOT NULL,\n\tPRIMARY KEY(`canonical_project_identity`, `scope_id`, `device_id`)\n);\n\nCREATE INDEX IF NOT EXISTS `idx_recipient_policy_deny_overlays_scope_device` ON `recipient_policy_deny_overlays` (`scope_id`,`device_id`);";
|
|
8
8
|
//# sourceMappingURL=test-schema.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-schema.generated.d.ts","sourceRoot":"","sources":["../src/test-schema.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"test-schema.generated.d.ts","sourceRoot":"","sources":["../src/test-schema.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,glrCAC6irC,CAAC"}
|
package/dist/vectors.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export interface ReplicationVectorMaintenanceResult {
|
|
|
79
79
|
inserted: number;
|
|
80
80
|
errors: string[];
|
|
81
81
|
}
|
|
82
|
-
export type SemanticIndexState = "healthy" | "pending" | "failed" | "degraded";
|
|
82
|
+
export type SemanticIndexState = "healthy" | "pending" | "failed" | "degraded" | "disabled";
|
|
83
83
|
export interface SemanticIndexDiagnostics {
|
|
84
84
|
state: SemanticIndexState;
|
|
85
85
|
summary: string;
|
package/dist/vectors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectors.d.ts","sourceRoot":"","sources":["../src/vectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAIN,KAAK,eAAe,EAUpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAQ1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAahD,KAAK,aAAa,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAmDF,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,sBAAsB,EAAE,wBAAwB,CAAC,CAAC;AA6FhG,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4C7F;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"vectors.d.ts","sourceRoot":"","sources":["../src/vectors.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemem/core",
|
|
3
|
-
"version": "0.46.0-rc.
|
|
3
|
+
"version": "0.46.0-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dist/"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@codemem/embeddings": "^0.46.0-rc.
|
|
27
|
+
"@codemem/embeddings": "^0.46.0-rc.3",
|
|
28
28
|
"@types/better-sqlite3": "^9.6.0",
|
|
29
29
|
"typescript": "^7.0.2",
|
|
30
30
|
"vite": "^8.2.2",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"zod": "4.5.4"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@codemem/embeddings": "^0.46.0-rc.
|
|
44
|
+
"@codemem/embeddings": "^0.46.0-rc.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"@codemem/embeddings": {
|