@opengeni/db 0.10.7 → 0.12.1
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/{chunk-P6PKXY5W.js → chunk-VUKRIBO5.js} +485 -12
- package/dist/chunk-VUKRIBO5.js.map +1 -0
- package/dist/{chunk-KW526IJA.js → chunk-Y5WZZVQK.js} +80 -4
- package/dist/chunk-Y5WZZVQK.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5114 -2085
- package/dist/index.js.map +1 -1
- package/dist/migrate.d.ts +6 -3
- package/dist/migrate.js +1 -1
- package/dist/provision-roles.d.ts +720 -63
- package/dist/{schema-CqkzrBRS.d.ts → schema-BejThLcd.d.ts} +2965 -1194
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +17 -1
- package/drizzle/0109_nested_agent_depth_expand.sql +42 -0
- package/drizzle/0110_nested_agent_depth_boundary.sql +480 -0
- package/drizzle/0111_nested_agent_depth_backfill.sql +49 -0
- package/drizzle/0112_nested_agent_depth_contract.sql +38 -0
- package/drizzle/0113_nested_agent_depth_validate.sql +13 -0
- package/drizzle/0114_nested_agent_depth_contract.sql +49 -0
- package/drizzle/0115_nested_agent_depth_validate.sql +11 -0
- package/drizzle/0116_nested_agent_depth_index.sql +4 -0
- package/drizzle/0117_sandbox_recovery_generations.sql +699 -0
- package/drizzle/0118_new_session_drafts.sql +59 -0
- package/drizzle/0119_pending_tool_output_policy.sql +5 -0
- package/drizzle/0120_durable_goal_wake.sql +360 -0
- package/drizzle/0121_goal_update_idempotency.sql +11 -0
- package/package.json +3 -3
- package/src/index.ts +5961 -1240
- package/src/migrate.ts +131 -2
- package/src/new-session-drafts.ts +144 -0
- package/src/schema.ts +519 -15
- package/src/session-control.ts +42 -18
- package/src/session-tool-call-settlement.ts +6 -1
- package/dist/chunk-KW526IJA.js.map +0 -1
- package/dist/chunk-P6PKXY5W.js.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Prove the expanded lineage columns before the final metadata-only contract.
|
|
3
|
+
-- Every check is deliberately NOT VALID here so the additions take only the
|
|
4
|
+
-- short catalog lock; the bounded validation scan is isolated in 0113.
|
|
5
|
+
SET lock_timeout = '5s';
|
|
6
|
+
SET statement_timeout = '30s';
|
|
7
|
+
|
|
8
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_root_not_null_check"
|
|
9
|
+
CHECK ("root_session_id" IS NOT NULL) NOT VALID;
|
|
10
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_depth_not_null_check"
|
|
11
|
+
CHECK ("nested_agent_depth" IS NOT NULL) NOT VALID;
|
|
12
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_effective_max_not_null_check"
|
|
13
|
+
CHECK ("effective_max_nested_agent_depth" IS NOT NULL) NOT VALID;
|
|
14
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_policy_source_not_null_check"
|
|
15
|
+
CHECK ("nested_agent_depth_policy_source" IS NOT NULL) NOT VALID;
|
|
16
|
+
|
|
17
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_depth_check"
|
|
18
|
+
CHECK ("nested_agent_depth" >= 0 AND "nested_agent_depth" <= 2147483647
|
|
19
|
+
AND "effective_max_nested_agent_depth" >= 0
|
|
20
|
+
AND "effective_max_nested_agent_depth" <= 2147483647
|
|
21
|
+
AND ("max_nested_agent_depth_override" IS NULL
|
|
22
|
+
OR "max_nested_agent_depth_override" BETWEEN 0 AND 2147483647)) NOT VALID;
|
|
23
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_policy_source_check"
|
|
24
|
+
CHECK ("nested_agent_depth_policy_source" IN ('session', 'workspace', 'deployment', 'default')) NOT VALID;
|
|
25
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_policy_snapshot_check"
|
|
26
|
+
CHECK (("nested_agent_depth_policy_source" = 'session'
|
|
27
|
+
AND "nested_agent_depth_policy_session_id" IS NOT NULL)
|
|
28
|
+
OR ("nested_agent_depth_policy_source" <> 'session'
|
|
29
|
+
AND "nested_agent_depth_policy_session_id" IS NULL
|
|
30
|
+
AND "max_nested_agent_depth_override" IS NULL)) NOT VALID;
|
|
31
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_nested_agent_override_check"
|
|
32
|
+
CHECK ("max_nested_agent_depth_override" IS NULL
|
|
33
|
+
OR ("nested_agent_depth_policy_source" = 'session'
|
|
34
|
+
AND "nested_agent_depth_policy_session_id" = "id"
|
|
35
|
+
AND "effective_max_nested_agent_depth" = "max_nested_agent_depth_override")) NOT VALID;
|
|
36
|
+
|
|
37
|
+
RESET statement_timeout;
|
|
38
|
+
RESET lock_timeout;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
SET lock_timeout = '5s';
|
|
3
|
+
SET statement_timeout = '30min';
|
|
4
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_root_not_null_check";
|
|
5
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_depth_not_null_check";
|
|
6
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_effective_max_not_null_check";
|
|
7
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_policy_source_not_null_check";
|
|
8
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_depth_check";
|
|
9
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_policy_source_check";
|
|
10
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_policy_snapshot_check";
|
|
11
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_nested_agent_override_check";
|
|
12
|
+
RESET statement_timeout;
|
|
13
|
+
RESET lock_timeout;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- Finalize only from validated helper checks. PostgreSQL 14 can prove each
|
|
3
|
+
-- SET NOT NULL from those checks without rescanning the table while holding
|
|
4
|
+
-- ACCESS EXCLUSIVE; the data-read validation work is isolated in 0113.
|
|
5
|
+
SET lock_timeout = '5s';
|
|
6
|
+
SET statement_timeout = '30s';
|
|
7
|
+
|
|
8
|
+
ALTER TABLE "sessions"
|
|
9
|
+
ALTER COLUMN "root_session_id" SET NOT NULL,
|
|
10
|
+
ALTER COLUMN "nested_agent_depth" SET NOT NULL,
|
|
11
|
+
ALTER COLUMN "effective_max_nested_agent_depth" SET NOT NULL,
|
|
12
|
+
ALTER COLUMN "nested_agent_depth_policy_source" SET NOT NULL;
|
|
13
|
+
|
|
14
|
+
-- Cross-workspace lineage references are installed after the checks prove
|
|
15
|
+
-- their source columns are complete. They remain NOT VALID until 0115 so this
|
|
16
|
+
-- migration only takes the short catalog lock.
|
|
17
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_workspace_root_session_fk"
|
|
18
|
+
FOREIGN KEY ("workspace_id", "root_session_id")
|
|
19
|
+
REFERENCES "sessions"("workspace_id", "id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
|
|
20
|
+
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_workspace_policy_session_fk"
|
|
21
|
+
FOREIGN KEY ("workspace_id", "nested_agent_depth_policy_session_id")
|
|
22
|
+
REFERENCES "sessions"("workspace_id", "id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
|
|
23
|
+
|
|
24
|
+
CREATE OR REPLACE FUNCTION opengeni_private.session_depth_snapshot_immutable()
|
|
25
|
+
RETURNS trigger LANGUAGE plpgsql SET search_path = pg_catalog
|
|
26
|
+
AS $function$
|
|
27
|
+
BEGIN
|
|
28
|
+
IF NEW.parent_session_id IS DISTINCT FROM OLD.parent_session_id
|
|
29
|
+
OR NEW.root_session_id IS DISTINCT FROM OLD.root_session_id
|
|
30
|
+
OR NEW.nested_agent_depth IS DISTINCT FROM OLD.nested_agent_depth
|
|
31
|
+
OR NEW.max_nested_agent_depth_override IS DISTINCT FROM OLD.max_nested_agent_depth_override
|
|
32
|
+
OR NEW.effective_max_nested_agent_depth IS DISTINCT FROM OLD.effective_max_nested_agent_depth
|
|
33
|
+
OR NEW.nested_agent_depth_policy_source IS DISTINCT FROM OLD.nested_agent_depth_policy_source
|
|
34
|
+
OR NEW.nested_agent_depth_policy_session_id IS DISTINCT FROM OLD.nested_agent_depth_policy_session_id THEN
|
|
35
|
+
RAISE EXCEPTION 'session lineage and nested-agent policy snapshot are immutable' USING ERRCODE = '55000';
|
|
36
|
+
END IF;
|
|
37
|
+
RETURN NEW;
|
|
38
|
+
END
|
|
39
|
+
$function$;
|
|
40
|
+
|
|
41
|
+
DO $trigger$
|
|
42
|
+
DECLARE target_schema text := current_schema();
|
|
43
|
+
BEGIN
|
|
44
|
+
EXECUTE format('DROP TRIGGER IF EXISTS session_depth_snapshot_immutable ON %I.sessions', target_schema);
|
|
45
|
+
EXECUTE format('CREATE TRIGGER session_depth_snapshot_immutable BEFORE UPDATE OF parent_session_id, root_session_id, nested_agent_depth, max_nested_agent_depth_override, effective_max_nested_agent_depth, nested_agent_depth_policy_source, nested_agent_depth_policy_session_id ON %I.sessions FOR EACH ROW EXECUTE FUNCTION opengeni_private.session_depth_snapshot_immutable()', target_schema);
|
|
46
|
+
END $trigger$;
|
|
47
|
+
|
|
48
|
+
RESET statement_timeout;
|
|
49
|
+
RESET lock_timeout;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- deployment-mode: rolling
|
|
2
|
+
-- The lineage checks were validated in 0113. Only the two composite foreign
|
|
3
|
+
-- keys remain to be scanned here, outside the ACCESS EXCLUSIVE finalization.
|
|
4
|
+
SET lock_timeout = '5s';
|
|
5
|
+
SET statement_timeout = '30min';
|
|
6
|
+
|
|
7
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_workspace_root_session_fk";
|
|
8
|
+
ALTER TABLE "sessions" VALIDATE CONSTRAINT "sessions_workspace_policy_session_fk";
|
|
9
|
+
|
|
10
|
+
RESET statement_timeout;
|
|
11
|
+
RESET lock_timeout;
|