@opengeni/db 0.7.2 → 0.9.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.
Files changed (59) hide show
  1. package/dist/{chunk-B22X3IEZ.js → chunk-4LG5NBTC.js} +512 -32
  2. package/dist/chunk-4LG5NBTC.js.map +1 -0
  3. package/dist/{chunk-YFQ7SGE4.js → chunk-BMFDXFPA.js} +23 -1
  4. package/dist/chunk-BMFDXFPA.js.map +1 -0
  5. package/dist/chunk-KW526IJA.js +127 -0
  6. package/dist/chunk-KW526IJA.js.map +1 -0
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +6092 -2080
  9. package/dist/index.js.map +1 -1
  10. package/dist/migrate.d.ts +29 -4
  11. package/dist/migrate.js +3 -1
  12. package/dist/provision-roles.d.ts +732 -47
  13. package/dist/provision-roles.js +1 -1
  14. package/dist/{schema-BN5mB9xZ.d.ts → schema-CdPGTHlD.d.ts} +2118 -119
  15. package/dist/schema.d.ts +1 -1
  16. package/dist/schema.js +17 -1
  17. package/drizzle/0064_rotation_strategy_sharded_backfill.sql +15 -0
  18. package/drizzle/0065_session_attempt_quiescence.sql +26 -0
  19. package/drizzle/0066_session_interruption_attempt_lookup.sql +4 -0
  20. package/drizzle/0067_session_event_payload_bounds.sql +209 -0
  21. package/drizzle/0068_workspace_control_event_bounds.sql +134 -0
  22. package/drizzle/0069_session_event_history_backfill.sql +32 -0
  23. package/drizzle/0070_session_event_type_sequence_lookup.sql +4 -0
  24. package/drizzle/0071_session_event_monitoring_tail.sql +10 -0
  25. package/drizzle/0072_sessions_workspace_created_id_idx.sql +4 -0
  26. package/drizzle/0073_sessions_workspace_updated_id_idx.sql +4 -0
  27. package/drizzle/0074_session_activity_revisions.sql +72 -0
  28. package/drizzle/0075_sessions_workspace_activity_revision_idx.sql +4 -0
  29. package/drizzle/0076_session_workflow_wake_acl.sql +13 -0
  30. package/drizzle/0077_session_attempt_latest_lookup.sql +4 -0
  31. package/drizzle/0094_quarantine_credential_bearing_catalog_urls.sql +51 -0
  32. package/drizzle/0095_github_existing_installations.sql +84 -0
  33. package/drizzle/0096_session_turn_initiators.sql +97 -0
  34. package/drizzle/0097_host_export_outbox.sql +1220 -0
  35. package/drizzle/0098_usage_events_workspace_session_idx.sql +4 -0
  36. package/drizzle/0099_session_human_input_attempt_owner_index.sql +6 -0
  37. package/drizzle/0100_session_human_input_requests.sql +89 -0
  38. package/drizzle/0101_session_mcp_connection_refs.sql +30 -0
  39. package/drizzle/0102_session_command_receipt_service_actor.sql +16 -0
  40. package/drizzle/0103_host_export_root_session.sql +166 -0
  41. package/drizzle/0104_host_export_root_session_backfill.sql +27 -0
  42. package/drizzle/0105_session_turn_instructions.sql +9 -0
  43. package/package.json +4 -4
  44. package/src/connection-token-resolver.ts +287 -1
  45. package/src/event-payload-sanitizer.ts +57 -19
  46. package/src/index.ts +5429 -1131
  47. package/src/memory-domain.ts +1 -1
  48. package/src/migrate.ts +86 -23
  49. package/src/persistence-errors.ts +252 -0
  50. package/src/provision-roles.ts +42 -0
  51. package/src/schema.ts +552 -34
  52. package/src/session-control.ts +518 -38
  53. package/src/session-queue-commands.ts +308 -57
  54. package/src/session-tool-call-settlement.ts +58 -7
  55. package/src/turn-initiator.ts +155 -0
  56. package/dist/chunk-7LDU7F5P.js +0 -80
  57. package/dist/chunk-7LDU7F5P.js.map +0 -1
  58. package/dist/chunk-B22X3IEZ.js.map +0 -1
  59. package/dist/chunk-YFQ7SGE4.js.map +0 -1
package/dist/migrate.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ interface ConcurrentIndexMigration {
2
+ indexName: string;
3
+ lockTimeout: string;
4
+ skipWhenValid: boolean;
5
+ statement: string;
6
+ }
7
+ /**
8
+ * Most migration files intentionally execute as one implicit transaction.
9
+ * PostgreSQL forbids CREATE INDEX CONCURRENTLY there, so a migration may opt
10
+ * into one narrowly validated transactionless statement with:
11
+ *
12
+ * -- opengeni:concurrent-index lock-timeout=5s
13
+ * CREATE [UNIQUE] INDEX CONCURRENTLY IF NOT EXISTS ...;
14
+ *
15
+ * The directive is deliberately not a generic "no transaction" escape hatch:
16
+ * only one idempotent concurrent-index statement is accepted, lock acquisition
17
+ * is always bounded, and an invalid artifact left by a failed concurrent build
18
+ * is removed before retry. Seven governed historical migrations predate the
19
+ * IF NOT EXISTS rule; only those exact filenames may use their immutable bare
20
+ * statements, and the runner makes their retries idempotent by skipping an
21
+ * already-valid index. This keeps additive large-table indexes online without
22
+ * rewriting shipped history or making arbitrary partially-applied migration
23
+ * scripts possible.
24
+ */
25
+ declare function parseConcurrentIndexMigration(file: string, sqlText: string): ConcurrentIndexMigration | null;
1
26
  /**
2
27
  * Apply the OpenGeni SQL migration chain.
3
28
  *
@@ -7,18 +32,18 @@
7
32
  * byte-for-byte historical behavior — the migration test suite calls
8
33
  * `migrate(DB_URL)` and is unaffected.
9
34
  *
10
- * EMBEDDED (Step I, §7.8 runtime/SDK half): pass a `schema` (or set
35
+ * EMBEDDED SCHEMA MODE: pass a `schema` (or set
11
36
  * `OPENGENI_DB_SCHEMA`). The migrate session then `CREATE SCHEMA IF NOT EXISTS`
12
37
  * for both `<schema>` and `opengeni_private`, and sets
13
38
  * `search_path = "<schema>", "opengeni_private", "public"`, so EVERY unqualified
14
39
  * DDL statement lands in the dedicated schema with NO per-statement SQL rewrite
15
- * (the SPIKE-1 F1 result). Two things make this work and stay idempotent:
40
+ * (the schema-isolation contract). Two things make this work and stay idempotent:
16
41
  * 1. The policy-existence guards in the migration SQL use `current_schema()`
17
42
  * (not a hardcoded `'public'`) — so a re-run finds the policy it already
18
43
  * created in `<schema>` and DROP/CREATEs idempotently instead of failing
19
44
  * with "policy already exists". (This guard substitution is the migrate-
20
45
  * time enabler for the runtime search_path approach; without it the SDK
21
- * entry point silently fails on re-run — the Fork-6 hazard.)
46
+ * entry point silently fails on re-run — the migration replay hazard.)
22
47
  * 2. `public` stays LAST on the path so `gen_random_uuid()` (pgcrypto) and the
23
48
  * `vector` type — both installed into `public` by 0000 — still resolve. The
24
49
  * `opengeni_private.*` helpers are always called with an absolute prefix.
@@ -37,4 +62,4 @@ declare function migrate(databaseUrl?: string, schema?: string | undefined): Pro
37
62
  */
38
63
  declare function runMigrations(adminConnection: string, targetSchema?: string): Promise<void>;
39
64
 
40
- export { migrate, runMigrations };
65
+ export { type ConcurrentIndexMigration, migrate, parseConcurrentIndexMigration, runMigrations };
package/dist/migrate.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  migrate,
3
+ parseConcurrentIndexMigration,
3
4
  runMigrations
4
- } from "./chunk-7LDU7F5P.js";
5
+ } from "./chunk-KW526IJA.js";
5
6
  import "./chunk-PZ5AY32C.js";
6
7
  export {
7
8
  migrate,
9
+ parseConcurrentIndexMigration,
8
10
  runMigrations
9
11
  };
10
12
  //# sourceMappingURL=migrate.js.map