thinkwork-cli 0.13.2 → 1.0.0
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/README.md +3 -14
- package/dist/{api-client-JYZXYQJR.js → api-client-4P4JZOBX.js} +1 -1
- package/dist/{chunk-Z2F6RJFR.js → chunk-4OMDWYZQ.js} +4 -5
- package/dist/{chunk-ILZKG5WV.js → chunk-AD2NIWB5.js} +434 -69
- package/dist/chunk-MWQ7RO76.js +137 -0
- package/dist/{chunk-DVPBI5HM.js → chunk-OLUQ4U2Z.js} +26 -26
- package/dist/{chunk-QOERT44A.js → chunk-YQCYD6NE.js} +57 -44
- package/dist/cli.js +4400 -16431
- package/dist/commands/enterprise/templates/deploy-repo/scripts/apply-release.mjs +0 -1
- package/dist/commands/enterprise/templates/deploy-repo/scripts/smoke.mjs +0 -1
- package/dist/commands/enterprise/templates/deploy-repo/terraform/main.tf +0 -14
- package/dist/{dist-es-CRV46D5B.js → dist-es-2OTNTL4N.js} +4 -4
- package/dist/{dist-es-ENBUC3JP.js → dist-es-2XVAH4BQ.js} +2 -2
- package/dist/{dist-es-DCY4IC3Y.js → dist-es-3DPDUJAH.js} +2 -2
- package/dist/{dist-es-G7PTG75M.js → dist-es-BNZTBBVC.js} +1 -1
- package/dist/{dist-es-GKDBE7E6.js → dist-es-CD2RBDAC.js} +1 -1
- package/dist/{dist-es-R7FGL2IB.js → dist-es-I4FW57PS.js} +1 -1
- package/dist/{dist-es-USORBXZ5.js → dist-es-KVFWJNDY.js} +4 -4
- package/dist/{dist-es-HY3535OI.js → dist-es-PS73DWNL.js} +2 -2
- package/dist/{dist-es-LDE437AM.js → dist-es-S3NZQFGT.js} +1 -1
- package/dist/{dist-es-G54LBMRN.js → dist-es-SGCA4P32.js} +1 -1
- package/dist/{dist-es-Q57SZXZ7.js → dist-es-WBM6J4RA.js} +2 -2
- package/dist/{dist-es-P26FWFLT.js → dist-es-ZGVADYIF.js} +8 -8
- package/dist/drizzle/0227_analyst_reader_role.sql +17 -26
- package/dist/drizzle/0230_analyst_rls.sql +28 -45
- package/dist/drizzle/0261_native_auth_control_plane.sql +7 -3
- package/dist/drizzle/0270_tool_execution_ledger.sql +115 -0
- package/dist/drizzle/0271_ontology_twin_declarations.sql +47 -0
- package/dist/drizzle/0272_identity_graph_projection_cursor.sql +23 -0
- package/dist/drizzle/0273_twin_materialization_suggestions.sql +29 -0
- package/dist/drizzle/0274_tenant_mcp_twin_keys.sql +59 -0
- package/dist/drizzle/0275_identity_bulk_rebuild_fence.sql +30 -0
- package/dist/drizzle/0276_tool_execution_ledger_allow_cascade_delete.sql +18 -0
- package/dist/drizzle/0277_knowledge_base_sources.sql +107 -0
- package/dist/drizzle/0278_kb_page_transcription.sql +55 -0
- package/dist/drizzle/0279_mcp_servers_off_plugin_provenance.sql +93 -0
- package/dist/drizzle/0280_work_item_external_refs_drop_plane_provider.sql +46 -0
- package/dist/drizzle/0281_tenant_mcp_twin_keys_expiry_suffix.sql +9 -0
- package/dist/drizzle/0282_tenant_mcp_twin_keys_grants.sql +24 -0
- package/dist/drizzle/0283_agents_agentcore_runtime_dispatch.sql +13 -0
- package/dist/drizzle/0284_user_brain_claims.sql +69 -0
- package/dist/drizzle/0285_tenant_mcp_twin_keys_trusted_subsystem.sql +30 -0
- package/dist/drizzle/0286_brain_analytics_key.sql +26 -0
- package/dist/drizzle/0287_brain_subject.sql +25 -0
- package/dist/drizzle/0288_multi_lane_identities.sql +25 -0
- package/dist/{loadSso-DJVB7BXE.js → loadSso-ETCXTR4I.js} +2 -2
- package/dist/{loadSso-JAMNA3WY.js → loadSso-UBD7KUHE.js} +2 -2
- package/dist/plugins/README.md +2 -2
- package/dist/plugins/catalog/package.json +0 -3
- package/dist/plugins/catalog/src/__tests__/build-catalog.test.ts +6 -3
- package/dist/plugins/catalog/src/__tests__/catalog.test.ts +21 -21
- package/dist/plugins/catalog/src/__tests__/contracts.test.ts +102 -25
- package/dist/plugins/catalog/src/__tests__/plugin-package.test.ts +7 -6
- package/dist/plugins/catalog/src/__tests__/plugin-registry.test.ts +0 -15
- package/dist/plugins/catalog/src/contracts.ts +15 -0
- package/dist/plugins/catalog/src/registry/generated-first-party.ts +0 -18
- package/dist/plugins/n8n/test/integrated-app-contract.test.ts +1 -1
- package/dist/plugins/twenty/package.json +2 -1
- package/dist/plugins/twenty/scripts/LAMBDA_DEPLOY.md +114 -0
- package/dist/plugins/twenty/scripts/build-lambda.sh +29 -0
- package/dist/plugins/twenty/scripts/configure-product-views.ts +195 -0
- package/dist/plugins/twenty/scripts/lambda-handler.ts +49 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-attachments.test.ts +38 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-records.test.ts +145 -2
- package/dist/plugins/twenty/scripts/lib/__tests__/mappers.test.ts +397 -151
- package/dist/plugins/twenty/scripts/lib/__tests__/members-ensure.test.ts +28 -129
- package/dist/plugins/twenty/scripts/lib/__tests__/provision-members-db.test.ts +10 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/schema-ensure.test.ts +13 -8
- package/dist/plugins/twenty/scripts/lib/lastmile-reader.ts +222 -2
- package/dist/plugins/twenty/scripts/lib/load-attachments.ts +29 -0
- package/dist/plugins/twenty/scripts/lib/load-records.ts +160 -43
- package/dist/plugins/twenty/scripts/lib/mappers.ts +368 -152
- package/dist/plugins/twenty/scripts/lib/members-ensure.ts +43 -268
- package/dist/plugins/twenty/scripts/lib/provision-members-db.ts +57 -0
- package/dist/plugins/twenty/scripts/lib/schema-ensure.ts +136 -31
- package/dist/plugins/twenty/scripts/migrate-lastmile.ts +254 -152
- package/dist/plugins/twenty/scripts/provision-twenty-members.ts +44 -1
- package/dist/plugins/twenty/scripts/purge-lastmile-import.ts +178 -0
- package/dist/plugins/twenty/scripts/restructure-products.ts +312 -0
- package/dist/plugins/twenty/scripts/retag-stage-values.ts +362 -0
- package/dist/plugins/twenty/test/manifest.test.ts +2 -4
- package/dist/scripts/post-deploy.sh +79 -1
- package/dist/{signin-UGDWTGS4.js → signin-5QZNRSOO.js} +2 -2
- package/dist/{sso-oidc-Q4VXANXY.js → sso-oidc-XK673P54.js} +2 -2
- package/dist/{sts-CWLSE3GH.js → sts-OXI2UALF.js} +6 -134
- package/dist/{sts-DNZLNVOV.js → sts-SQW4NBK3.js} +6 -134
- package/dist/terraform/examples/greenfield/main.tf +233 -175
- package/dist/terraform/examples/greenfield/terraform.tfvars.example +12 -8
- package/dist/terraform/modules/app/agentcore-admin/main.tf +47 -0
- package/dist/terraform/modules/app/agentcore-code-interpreter/README.md +39 -47
- package/dist/terraform/modules/app/agentcore-code-interpreter/main.tf +13 -66
- package/dist/terraform/modules/app/agentcore-identity/main.tf +106 -26
- package/dist/terraform/modules/app/agentcore-identity/outputs.tf +6 -6
- package/dist/terraform/modules/app/agentcore-identity/scripts/bootstrap_twenty_oauth_client.sh +216 -99
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_identity.sh +6 -9
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_workload_identity.sh +19 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/ensure_workload_identity.sh +29 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/read_identity.sh +22 -7
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_twenty_identity.sh +17 -46
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_twenty_provider.mjs +65 -3
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/after.tf +15 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/before.tf +7 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/identity-after.tf +8 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/identity-before.tf +9 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/thinkwork-after.tf +3 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/thinkwork-before.tf +3 -0
- package/dist/terraform/modules/app/agentcore-identity/variables.tf +6 -0
- package/dist/terraform/modules/app/agentcore-memory/README.md +46 -9
- package/dist/terraform/modules/app/agentcore-memory/main.tf +27 -10
- package/dist/terraform/modules/app/agentcore-memory/scripts/create_or_find_memory.sh +156 -24
- package/dist/terraform/modules/app/agentcore-pi/README.md +1 -3
- package/dist/terraform/modules/app/agentcore-pi/main.tf +42 -52
- package/dist/terraform/modules/app/agentcore-pi/outputs.tf +3 -3
- package/dist/terraform/modules/app/agentcore-pi/scripts/reconcile_pi_runtime.mjs +175 -0
- package/dist/terraform/modules/app/agentcore-pi/variables.tf +35 -28
- package/dist/terraform/modules/app/agentcore-platform/main.tf +68 -0
- package/dist/terraform/modules/app/agentcore-runtime/main.tf +4 -20
- package/dist/terraform/modules/app/capability-broker/main.tf +2 -2
- package/dist/terraform/modules/app/capability-broker/variables.tf +11 -0
- package/dist/terraform/modules/app/deployment-control-plane/README.md +264 -0
- package/dist/terraform/modules/app/deployment-control-plane/buildspec.yml +4 -1
- package/dist/terraform/modules/app/deployment-control-plane/main.tf +94 -0
- package/dist/terraform/modules/app/deployment-control-plane/outputs.tf +5 -0
- package/dist/terraform/modules/app/deployment-control-plane/runner.py +2641 -124
- package/dist/terraform/modules/app/deployment-control-plane/test_runner_bundle.py +2034 -154
- package/dist/terraform/modules/app/deployment-control-plane/variables.tf +33 -0
- package/dist/terraform/modules/app/lambda-api/auth-state.tf +72 -0
- package/dist/terraform/modules/app/lambda-api/chat-latency-observability.tf +466 -0
- package/dist/terraform/modules/app/lambda-api/dispatch-dlq.tf +55 -0
- package/dist/terraform/modules/app/lambda-api/handlers.tf +411 -723
- package/dist/terraform/modules/app/lambda-api/iam-grouped.tf +262 -198
- package/dist/terraform/modules/app/lambda-api/main.tf +51 -13
- package/dist/terraform/modules/app/lambda-api/mcp-oauth.tf +4 -181
- package/dist/terraform/modules/app/lambda-api/memory-alarms.tf +3 -28
- package/dist/terraform/modules/app/lambda-api/oauth-secrets.tf +1 -2
- package/dist/terraform/modules/app/lambda-api/outputs.tf +17 -45
- package/dist/terraform/modules/app/lambda-api/turn-assertion.tf +45 -0
- package/dist/terraform/modules/app/lambda-api/variables.tf +219 -126
- package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/README.md +1 -1
- package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/main.tf +18 -18
- package/dist/terraform/modules/app/sandbox-log-scrubber/README.md +11 -10
- package/dist/terraform/modules/app/sandbox-log-scrubber/main.tf +5 -5
- package/dist/terraform/modules/app/static-site/main.tf +1 -1
- package/dist/terraform/modules/app/www-dns/main.tf +9 -27
- package/dist/terraform/modules/app/www-dns/variables.tf +4 -10
- package/dist/terraform/modules/data/aurora-postgres/README.md +34 -0
- package/dist/terraform/modules/data/aurora-postgres/alarms.tf +82 -0
- package/dist/terraform/modules/data/aurora-postgres/main.tf +27 -57
- package/dist/terraform/modules/data/aurora-postgres/outputs.tf +0 -9
- package/dist/terraform/modules/data/aurora-postgres/variables.tf +41 -0
- package/dist/terraform/modules/data/s3-buckets/main.tf +5 -6
- package/dist/terraform/modules/foundation/cognito/main.tf +81 -8
- package/dist/terraform/modules/foundation/cognito/outputs.tf +5 -0
- package/dist/terraform/modules/foundation/cognito/variables.tf +24 -12
- package/dist/terraform/modules/thinkwork/README.md +5 -1
- package/dist/terraform/modules/thinkwork/main.tf +376 -374
- package/dist/terraform/modules/thinkwork/outputs.tf +12 -158
- package/dist/terraform/modules/thinkwork/variables.tf +246 -89
- package/dist/workspace-defaults/files/INSTRUCTIONS.md +9 -11
- package/dist/workspace-defaults/files/MEMORY_GUIDE.md +38 -35
- package/dist/workspace-defaults/files/ROUTER.md +1 -1
- package/dist/workspace-defaults/files/TOOLS.md +9 -39
- package/dist/workspace-defaults/files/agents/analyst/INSTRUCTIONS.md +6 -3
- package/dist/workspace-defaults/files/catalog-skills/brain-brief-builder/SKILL.md +165 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/SKILL.md +75 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/mcp-tooling.md +40 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/validation-and-handoff.md +40 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/workflow-authoring.md +46 -0
- package/dist/workspace-defaults/files/skills/artifact-builder/references/crm-dashboard.md +1 -1
- package/dist/workspace-defaults/files/skills/document-composer/SKILL.md +22 -3
- package/package.json +1 -1
- package/dist/drizzle/0261_managed_harness_multiplayer.sql +0 -313
- package/dist/drizzle/0262_parallel_harness_threads.sql +0 -9
- package/dist/drizzle/0264_harness_tool_execution_ledger.sql +0 -113
- package/dist/plugins/company-data/README.md +0 -49
- package/dist/plugins/company-data/package.json +0 -21
- package/dist/plugins/company-data/src/index.ts +0 -30
- package/dist/plugins/company-data/src/manifest.ts +0 -26
- package/dist/plugins/company-data/test/manifest.test.ts +0 -116
- package/dist/plugins/company-data/tsconfig.json +0 -8
- package/dist/plugins/company-etl/README.md +0 -46
- package/dist/plugins/company-etl/package.json +0 -21
- package/dist/plugins/company-etl/src/index.ts +0 -29
- package/dist/plugins/company-etl/src/manifest.ts +0 -26
- package/dist/plugins/company-etl/test/manifest.test.ts +0 -108
- package/dist/plugins/company-etl/tsconfig.json +0 -8
- package/dist/plugins/lastmile/README.md +0 -50
- package/dist/plugins/lastmile/package.json +0 -23
- package/dist/plugins/lastmile/smoke/lastmile-plugin-smoke.mjs +0 -661
- package/dist/plugins/lastmile/src/api/tasks-adapter.ts +0 -572
- package/dist/plugins/lastmile/src/discovery.fixture.ts +0 -64
- package/dist/plugins/lastmile/src/index.ts +0 -46
- package/dist/plugins/lastmile/src/manifest.ts +0 -139
- package/dist/plugins/lastmile/test/api/tasks-adapter.test.ts +0 -266
- package/dist/plugins/lastmile/test/discovery.test.ts +0 -88
- package/dist/plugins/lastmile/tsconfig.json +0 -8
- package/dist/plugins/n8n/smoke/n8n-managed-app-smoke.mjs +0 -409
- package/dist/plugins/twenty/smoke/twenty-managed-app-smoke.mjs +0 -359
- package/dist/terraform/modules/app/agentcore-code-interpreter/Dockerfile.sandbox-base +0 -61
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/sitecustomize.py +0 -227
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/test_sitecustomize.py +0 -277
- package/dist/terraform/modules/app/agentcore-code-interpreter/scripts/build_and_push_sandbox_base.sh +0 -70
- package/dist/terraform/modules/app/agentcore-gateway/main.tf +0 -305
- package/dist/terraform/modules/app/agentcore-gateway/outputs.tf +0 -44
- package/dist/terraform/modules/app/agentcore-gateway/scripts/delete_gateway.sh +0 -93
- package/dist/terraform/modules/app/agentcore-gateway/scripts/read_gateway.sh +0 -33
- package/dist/terraform/modules/app/agentcore-gateway/scripts/reconcile_gateway.sh +0 -543
- package/dist/terraform/modules/app/agentcore-gateway/variables.tf +0 -70
- package/dist/terraform/modules/app/agentcore-harness/main.tf +0 -330
- package/dist/terraform/modules/app/agentcore-harness/outputs.tf +0 -72
- package/dist/terraform/modules/app/agentcore-harness/scripts/delete_harness.sh +0 -5
- package/dist/terraform/modules/app/agentcore-harness/scripts/harness-lifecycle.mjs +0 -430
- package/dist/terraform/modules/app/agentcore-harness/scripts/harness-readback.mjs +0 -180
- package/dist/terraform/modules/app/agentcore-harness/scripts/harness-tool-contract.mjs +0 -193
- package/dist/terraform/modules/app/agentcore-harness/scripts/prune_harness.sh +0 -5
- package/dist/terraform/modules/app/agentcore-harness/scripts/read_harness.sh +0 -5
- package/dist/terraform/modules/app/agentcore-harness/scripts/reconcile_harness.sh +0 -5
- package/dist/terraform/modules/app/agentcore-harness/variables.tf +0 -96
- package/dist/terraform/modules/app/hindsight-memory/README.md +0 -89
- package/dist/terraform/modules/app/hindsight-memory/main.tf +0 -411
- package/dist/terraform/modules/app/lambda-api/agentcore-harness-alarms.tf +0 -88
- package/dist/terraform/modules/app/lambda-api/agentcore-identity-alarms.tf +0 -91
- package/dist/terraform/modules/data/bedrock-knowledge-base/main.tf +0 -102
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/outputs.tf +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/scripts/sync-database.py +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/scripts/test_sync_database.py +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/variables.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/README.md +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/main.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/outputs.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/variables.tf +0 -0
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
-- creates: public.harness_managed_thread_enrollments
|
|
2
|
-
-- creates: public.thread_public_events
|
|
3
|
-
-- creates: public.harness_participant_sessions
|
|
4
|
-
-- creates: public.harness_participant_session_events
|
|
5
|
-
-- creates: public.harness_governed_tool_executions
|
|
6
|
-
-- creates: public.harness_disclosure_decisions
|
|
7
|
-
-- creates-function: public.capture_harness_message_public_event
|
|
8
|
-
-- creates-function: public.capture_harness_artifact_public_event
|
|
9
|
-
-- creates-trigger: public.messages.trg_capture_harness_message_public_event
|
|
10
|
-
-- creates-trigger: public.message_artifacts.trg_capture_harness_artifact_public_event
|
|
11
|
-
-- Managed multiplayer Harness proof ledger. Hand-rolled because this migration
|
|
12
|
-
-- also installs admission triggers over existing canonical message tables.
|
|
13
|
-
|
|
14
|
-
CREATE TABLE IF NOT EXISTS public.harness_managed_thread_enrollments (
|
|
15
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
16
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
17
|
-
thread_id uuid NOT NULL REFERENCES public.threads(id) ON DELETE CASCADE,
|
|
18
|
-
logical_agent_id uuid NOT NULL REFERENCES public.agents(id),
|
|
19
|
-
trust_profile text NOT NULL,
|
|
20
|
-
harness_arn text NOT NULL,
|
|
21
|
-
qualifier text NOT NULL,
|
|
22
|
-
resolved_version text NOT NULL,
|
|
23
|
-
session_strategy text NOT NULL DEFAULT 'fresh'
|
|
24
|
-
CHECK (session_strategy = 'fresh'),
|
|
25
|
-
prior_runtime text NOT NULL,
|
|
26
|
-
status text NOT NULL DEFAULT 'active'
|
|
27
|
-
CHECK (status IN ('active', 'restoring', 'restored', 'failed')),
|
|
28
|
-
enrolled_by_user_id uuid NOT NULL REFERENCES public.users(id),
|
|
29
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
30
|
-
restored_at timestamptz,
|
|
31
|
-
UNIQUE (tenant_id, thread_id)
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
CREATE UNIQUE INDEX IF NOT EXISTS uq_harness_enrollment_active_profile
|
|
35
|
-
ON public.harness_managed_thread_enrollments (tenant_id, trust_profile)
|
|
36
|
-
WHERE status = 'active';
|
|
37
|
-
|
|
38
|
-
CREATE TABLE IF NOT EXISTS public.thread_public_events (
|
|
39
|
-
id bigserial PRIMARY KEY,
|
|
40
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
41
|
-
thread_id uuid NOT NULL REFERENCES public.threads(id) ON DELETE CASCADE,
|
|
42
|
-
source_kind text NOT NULL CHECK (source_kind IN ('message', 'message_artifact')),
|
|
43
|
-
source_id uuid NOT NULL,
|
|
44
|
-
source_version text NOT NULL,
|
|
45
|
-
event_kind text NOT NULL CHECK (event_kind IN ('insert', 'invalidate')),
|
|
46
|
-
canonical_digest text NOT NULL,
|
|
47
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
48
|
-
UNIQUE (tenant_id, thread_id, source_kind, source_id, source_version)
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
CREATE INDEX IF NOT EXISTS idx_thread_public_events_prefix
|
|
52
|
-
ON public.thread_public_events (tenant_id, thread_id, id);
|
|
53
|
-
|
|
54
|
-
CREATE TABLE IF NOT EXISTS public.harness_participant_sessions (
|
|
55
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
56
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
57
|
-
enrollment_id uuid NOT NULL REFERENCES public.harness_managed_thread_enrollments(id) ON DELETE CASCADE,
|
|
58
|
-
thread_id uuid NOT NULL REFERENCES public.threads(id) ON DELETE CASCADE,
|
|
59
|
-
participant_user_id uuid NOT NULL REFERENCES public.users(id),
|
|
60
|
-
turn_id uuid NOT NULL REFERENCES public.thread_turns(id) ON DELETE CASCADE,
|
|
61
|
-
runtime_session_id text NOT NULL UNIQUE,
|
|
62
|
-
generation integer NOT NULL DEFAULT 1 CHECK (generation = 1),
|
|
63
|
-
captured_high_water bigint NOT NULL,
|
|
64
|
-
applied_high_water bigint,
|
|
65
|
-
qualifier text NOT NULL,
|
|
66
|
-
resolved_version text NOT NULL,
|
|
67
|
-
base_fingerprint text NOT NULL,
|
|
68
|
-
participant_fingerprint text NOT NULL,
|
|
69
|
-
state text NOT NULL DEFAULT 'allocated'
|
|
70
|
-
CHECK (state IN ('allocated', 'running', 'finalizing', 'completed', 'abandoned')),
|
|
71
|
-
failure_reason text,
|
|
72
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
73
|
-
started_at timestamptz,
|
|
74
|
-
finished_at timestamptz,
|
|
75
|
-
UNIQUE (tenant_id, turn_id),
|
|
76
|
-
CHECK (
|
|
77
|
-
(state IN ('completed', 'abandoned') AND finished_at IS NOT NULL)
|
|
78
|
-
OR (state NOT IN ('completed', 'abandoned') AND finished_at IS NULL)
|
|
79
|
-
)
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
CREATE INDEX IF NOT EXISTS idx_harness_participant_sessions_thread
|
|
83
|
-
ON public.harness_participant_sessions
|
|
84
|
-
(tenant_id, thread_id, participant_user_id, created_at);
|
|
85
|
-
|
|
86
|
-
CREATE TABLE IF NOT EXISTS public.harness_participant_session_events (
|
|
87
|
-
id bigserial PRIMARY KEY,
|
|
88
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
89
|
-
session_id uuid NOT NULL REFERENCES public.harness_participant_sessions(id) ON DELETE CASCADE,
|
|
90
|
-
turn_id uuid NOT NULL REFERENCES public.thread_turns(id) ON DELETE CASCADE,
|
|
91
|
-
event_type text NOT NULL,
|
|
92
|
-
from_state text,
|
|
93
|
-
to_state text NOT NULL
|
|
94
|
-
CHECK (to_state IN ('allocated', 'running', 'finalizing', 'completed', 'abandoned')),
|
|
95
|
-
reason_code text,
|
|
96
|
-
applied_high_water bigint,
|
|
97
|
-
evidence jsonb,
|
|
98
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
CREATE INDEX IF NOT EXISTS idx_harness_session_events_session
|
|
102
|
-
ON public.harness_participant_session_events (session_id, id);
|
|
103
|
-
|
|
104
|
-
CREATE TABLE IF NOT EXISTS public.harness_governed_tool_executions (
|
|
105
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
106
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
107
|
-
turn_id uuid NOT NULL REFERENCES public.thread_turns(id) ON DELETE CASCADE,
|
|
108
|
-
participant_user_id uuid NOT NULL REFERENCES public.users(id),
|
|
109
|
-
session_id uuid NOT NULL REFERENCES public.harness_participant_sessions(id) ON DELETE CASCADE,
|
|
110
|
-
idempotency_key text NOT NULL,
|
|
111
|
-
audience text NOT NULL,
|
|
112
|
-
operation text NOT NULL,
|
|
113
|
-
tool_use_id text NOT NULL,
|
|
114
|
-
input_digest text NOT NULL,
|
|
115
|
-
state text NOT NULL DEFAULT 'claimed'
|
|
116
|
-
CHECK (state IN ('claimed', 'completed', 'failed', 'ambiguous')),
|
|
117
|
-
policy_decision_id text,
|
|
118
|
-
credential_owner_alias text,
|
|
119
|
-
sanitized_result jsonb,
|
|
120
|
-
failure_reason text,
|
|
121
|
-
claimed_at timestamptz NOT NULL DEFAULT now(),
|
|
122
|
-
completed_at timestamptz,
|
|
123
|
-
UNIQUE (tenant_id, idempotency_key)
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
CREATE INDEX IF NOT EXISTS idx_harness_governed_tool_turn
|
|
127
|
-
ON public.harness_governed_tool_executions (turn_id);
|
|
128
|
-
|
|
129
|
-
CREATE TABLE IF NOT EXISTS public.harness_disclosure_decisions (
|
|
130
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
131
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
132
|
-
participant_user_id uuid NOT NULL REFERENCES public.users(id),
|
|
133
|
-
thread_id uuid NOT NULL REFERENCES public.threads(id) ON DELETE CASCADE,
|
|
134
|
-
turn_id uuid NOT NULL REFERENCES public.thread_turns(id) ON DELETE CASCADE,
|
|
135
|
-
session_id uuid NOT NULL REFERENCES public.harness_participant_sessions(id) ON DELETE CASCADE,
|
|
136
|
-
operation text NOT NULL,
|
|
137
|
-
projection_digest text NOT NULL,
|
|
138
|
-
status text NOT NULL
|
|
139
|
-
CHECK (status IN ('published', 'withheld', 'confirmation_required')),
|
|
140
|
-
reason_code text NOT NULL,
|
|
141
|
-
expires_at timestamptz NOT NULL,
|
|
142
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
CREATE INDEX IF NOT EXISTS idx_harness_disclosure_turn
|
|
146
|
-
ON public.harness_disclosure_decisions (turn_id);
|
|
147
|
-
|
|
148
|
-
CREATE OR REPLACE FUNCTION public.capture_harness_message_public_event()
|
|
149
|
-
RETURNS trigger
|
|
150
|
-
LANGUAGE plpgsql
|
|
151
|
-
AS $$
|
|
152
|
-
DECLARE
|
|
153
|
-
digest_value text;
|
|
154
|
-
version_value text;
|
|
155
|
-
event_value text;
|
|
156
|
-
admitted_before boolean;
|
|
157
|
-
admitted_now boolean;
|
|
158
|
-
BEGIN
|
|
159
|
-
IF TG_OP = 'DELETE' THEN
|
|
160
|
-
IF NOT EXISTS (
|
|
161
|
-
SELECT 1 FROM public.thread_public_events e
|
|
162
|
-
WHERE e.tenant_id = OLD.tenant_id
|
|
163
|
-
AND e.thread_id = OLD.thread_id
|
|
164
|
-
AND e.source_kind = 'message'
|
|
165
|
-
AND e.source_id = OLD.id
|
|
166
|
-
) THEN
|
|
167
|
-
RETURN OLD;
|
|
168
|
-
END IF;
|
|
169
|
-
digest_value := encode(digest(concat_ws('|', OLD.role, coalesce(OLD.content, ''), coalesce(OLD.parts::text, ''), coalesce(OLD.metadata::text, '')), 'sha256'), 'hex');
|
|
170
|
-
version_value := 'delete:' || digest_value;
|
|
171
|
-
event_value := 'invalidate';
|
|
172
|
-
INSERT INTO public.thread_public_events (
|
|
173
|
-
tenant_id, thread_id, source_kind, source_id, source_version,
|
|
174
|
-
event_kind, canonical_digest
|
|
175
|
-
) VALUES (
|
|
176
|
-
OLD.tenant_id, OLD.thread_id, 'message', OLD.id,
|
|
177
|
-
version_value, event_value, digest_value
|
|
178
|
-
) ON CONFLICT DO NOTHING;
|
|
179
|
-
RETURN OLD;
|
|
180
|
-
END IF;
|
|
181
|
-
|
|
182
|
-
admitted_now := NEW.role IN ('user', 'assistant')
|
|
183
|
-
AND coalesce(NEW.metadata->>'visibility', 'public') = 'public'
|
|
184
|
-
AND coalesce(NEW.metadata->>'disclosure_status', 'published') NOT IN ('withheld', 'confirmation_required')
|
|
185
|
-
AND EXISTS (
|
|
186
|
-
SELECT 1 FROM public.harness_managed_thread_enrollments e
|
|
187
|
-
WHERE e.tenant_id = NEW.tenant_id
|
|
188
|
-
AND e.thread_id = NEW.thread_id
|
|
189
|
-
AND e.status = 'active'
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
IF TG_OP = 'UPDATE' THEN
|
|
193
|
-
admitted_before := EXISTS (
|
|
194
|
-
SELECT 1 FROM public.thread_public_events e
|
|
195
|
-
WHERE e.tenant_id = OLD.tenant_id
|
|
196
|
-
AND e.thread_id = OLD.thread_id
|
|
197
|
-
AND e.source_kind = 'message'
|
|
198
|
-
AND e.source_id = OLD.id
|
|
199
|
-
);
|
|
200
|
-
IF admitted_before THEN
|
|
201
|
-
digest_value := encode(digest(concat_ws('|', OLD.role, coalesce(OLD.content, ''), coalesce(OLD.parts::text, ''), coalesce(OLD.metadata::text, '')), 'sha256'), 'hex');
|
|
202
|
-
version_value := 'invalidate:update:' || encode(digest(concat_ws('|', NEW.role, coalesce(NEW.content, ''), coalesce(NEW.parts::text, ''), coalesce(NEW.metadata::text, '')), 'sha256'), 'hex');
|
|
203
|
-
INSERT INTO public.thread_public_events (
|
|
204
|
-
tenant_id, thread_id, source_kind, source_id, source_version,
|
|
205
|
-
event_kind, canonical_digest
|
|
206
|
-
) VALUES (
|
|
207
|
-
OLD.tenant_id, OLD.thread_id, 'message', OLD.id,
|
|
208
|
-
version_value, 'invalidate', digest_value
|
|
209
|
-
) ON CONFLICT DO NOTHING;
|
|
210
|
-
END IF;
|
|
211
|
-
END IF;
|
|
212
|
-
|
|
213
|
-
IF NOT admitted_now THEN
|
|
214
|
-
RETURN NEW;
|
|
215
|
-
END IF;
|
|
216
|
-
|
|
217
|
-
digest_value := encode(digest(concat_ws('|', NEW.role, coalesce(NEW.content, ''), coalesce(NEW.parts::text, '')), 'sha256'), 'hex');
|
|
218
|
-
version_value := lower(TG_OP) || ':' || digest_value || ':' || encode(digest(coalesce(NEW.metadata::text, ''), 'sha256'), 'hex');
|
|
219
|
-
INSERT INTO public.thread_public_events (
|
|
220
|
-
tenant_id, thread_id, source_kind, source_id, source_version,
|
|
221
|
-
event_kind, canonical_digest
|
|
222
|
-
) VALUES (
|
|
223
|
-
NEW.tenant_id, NEW.thread_id, 'message', NEW.id,
|
|
224
|
-
version_value, 'insert', digest_value
|
|
225
|
-
) ON CONFLICT DO NOTHING;
|
|
226
|
-
RETURN NEW;
|
|
227
|
-
END;
|
|
228
|
-
$$;
|
|
229
|
-
|
|
230
|
-
DROP TRIGGER IF EXISTS trg_capture_harness_message_public_event ON public.messages;
|
|
231
|
-
CREATE TRIGGER trg_capture_harness_message_public_event
|
|
232
|
-
AFTER INSERT OR UPDATE OR DELETE ON public.messages
|
|
233
|
-
FOR EACH ROW EXECUTE FUNCTION public.capture_harness_message_public_event();
|
|
234
|
-
|
|
235
|
-
CREATE OR REPLACE FUNCTION public.capture_harness_artifact_public_event()
|
|
236
|
-
RETURNS trigger
|
|
237
|
-
LANGUAGE plpgsql
|
|
238
|
-
AS $$
|
|
239
|
-
DECLARE
|
|
240
|
-
digest_value text;
|
|
241
|
-
version_value text;
|
|
242
|
-
admitted_before boolean;
|
|
243
|
-
admitted_now boolean;
|
|
244
|
-
BEGIN
|
|
245
|
-
IF TG_OP = 'DELETE' THEN
|
|
246
|
-
IF NOT EXISTS (
|
|
247
|
-
SELECT 1 FROM public.thread_public_events e
|
|
248
|
-
WHERE e.tenant_id = OLD.tenant_id
|
|
249
|
-
AND e.thread_id = OLD.thread_id
|
|
250
|
-
AND e.source_kind = 'message_artifact'
|
|
251
|
-
AND e.source_id = OLD.id
|
|
252
|
-
) THEN
|
|
253
|
-
RETURN OLD;
|
|
254
|
-
END IF;
|
|
255
|
-
digest_value := encode(digest(concat_ws('|', OLD.artifact_type, coalesce(OLD.name, ''), coalesce(OLD.artifact_id::text, ''), coalesce(OLD.metadata::text, '')), 'sha256'), 'hex');
|
|
256
|
-
INSERT INTO public.thread_public_events (
|
|
257
|
-
tenant_id, thread_id, source_kind, source_id, source_version,
|
|
258
|
-
event_kind, canonical_digest
|
|
259
|
-
) VALUES (
|
|
260
|
-
OLD.tenant_id, OLD.thread_id, 'message_artifact', OLD.id,
|
|
261
|
-
'delete:' || digest_value, 'invalidate', digest_value
|
|
262
|
-
) ON CONFLICT DO NOTHING;
|
|
263
|
-
RETURN OLD;
|
|
264
|
-
END IF;
|
|
265
|
-
|
|
266
|
-
admitted_now := EXISTS (
|
|
267
|
-
SELECT 1 FROM public.harness_managed_thread_enrollments e
|
|
268
|
-
WHERE e.tenant_id = NEW.tenant_id
|
|
269
|
-
AND e.thread_id = NEW.thread_id
|
|
270
|
-
AND e.status = 'active'
|
|
271
|
-
) AND coalesce(NEW.metadata->>'access_state', 'public') = 'public';
|
|
272
|
-
|
|
273
|
-
IF TG_OP = 'UPDATE' THEN
|
|
274
|
-
admitted_before := EXISTS (
|
|
275
|
-
SELECT 1 FROM public.thread_public_events e
|
|
276
|
-
WHERE e.tenant_id = OLD.tenant_id
|
|
277
|
-
AND e.thread_id = OLD.thread_id
|
|
278
|
-
AND e.source_kind = 'message_artifact'
|
|
279
|
-
AND e.source_id = OLD.id
|
|
280
|
-
);
|
|
281
|
-
IF admitted_before THEN
|
|
282
|
-
digest_value := encode(digest(concat_ws('|', OLD.artifact_type, coalesce(OLD.name, ''), coalesce(OLD.artifact_id::text, ''), coalesce(OLD.metadata::text, '')), 'sha256'), 'hex');
|
|
283
|
-
version_value := 'invalidate:update:' || encode(digest(concat_ws('|', NEW.artifact_type, coalesce(NEW.name, ''), coalesce(NEW.artifact_id::text, ''), coalesce(NEW.metadata::text, '')), 'sha256'), 'hex');
|
|
284
|
-
INSERT INTO public.thread_public_events (
|
|
285
|
-
tenant_id, thread_id, source_kind, source_id, source_version,
|
|
286
|
-
event_kind, canonical_digest
|
|
287
|
-
) VALUES (
|
|
288
|
-
OLD.tenant_id, OLD.thread_id, 'message_artifact', OLD.id,
|
|
289
|
-
version_value, 'invalidate', digest_value
|
|
290
|
-
) ON CONFLICT DO NOTHING;
|
|
291
|
-
END IF;
|
|
292
|
-
END IF;
|
|
293
|
-
|
|
294
|
-
IF NOT admitted_now THEN
|
|
295
|
-
RETURN NEW;
|
|
296
|
-
END IF;
|
|
297
|
-
|
|
298
|
-
digest_value := encode(digest(concat_ws('|', NEW.artifact_type, coalesce(NEW.name, ''), coalesce(NEW.artifact_id::text, ''), coalesce(NEW.metadata::text, '')), 'sha256'), 'hex');
|
|
299
|
-
INSERT INTO public.thread_public_events (
|
|
300
|
-
tenant_id, thread_id, source_kind, source_id, source_version,
|
|
301
|
-
event_kind, canonical_digest
|
|
302
|
-
) VALUES (
|
|
303
|
-
NEW.tenant_id, NEW.thread_id, 'message_artifact', NEW.id,
|
|
304
|
-
lower(TG_OP) || ':' || digest_value, 'insert', digest_value
|
|
305
|
-
) ON CONFLICT DO NOTHING;
|
|
306
|
-
RETURN NEW;
|
|
307
|
-
END;
|
|
308
|
-
$$;
|
|
309
|
-
|
|
310
|
-
DROP TRIGGER IF EXISTS trg_capture_harness_artifact_public_event ON public.message_artifacts;
|
|
311
|
-
CREATE TRIGGER trg_capture_harness_artifact_public_event
|
|
312
|
-
AFTER INSERT OR UPDATE OR DELETE ON public.message_artifacts
|
|
313
|
-
FOR EACH ROW EXECUTE FUNCTION public.capture_harness_artifact_public_event();
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
-- creates: public.idx_harness_enrollment_active_profile
|
|
2
|
-
-- Allow multiple normal Composer threads to remain pinned to the same
|
|
3
|
-
-- tenant/trust-profile Harness while Pi threads continue independently.
|
|
4
|
-
|
|
5
|
-
DROP INDEX IF EXISTS public.uq_harness_enrollment_active_profile;
|
|
6
|
-
|
|
7
|
-
CREATE INDEX IF NOT EXISTS idx_harness_enrollment_active_profile
|
|
8
|
-
ON public.harness_managed_thread_enrollments (tenant_id, trust_profile)
|
|
9
|
-
WHERE status = 'active';
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
-- creates: public.harness_tool_execution_events
|
|
2
|
-
-- creates: public.idx_harness_tool_execution_turn
|
|
3
|
-
-- creates: public.uq_harness_tool_execution_started
|
|
4
|
-
-- creates: public.uq_harness_tool_execution_terminal
|
|
5
|
-
-- creates-function: public.reject_harness_tool_execution_event_mutation
|
|
6
|
-
-- creates-function: public.validate_harness_tool_execution_event_insert
|
|
7
|
-
-- creates-trigger: public.harness_tool_execution_events.trg_reject_harness_tool_execution_event_mutation
|
|
8
|
-
-- creates-trigger: public.harness_tool_execution_events.trg_validate_harness_tool_execution_event_insert
|
|
9
|
-
-- Target-side Harness tool evidence. This is a sanitized append-only event
|
|
10
|
-
-- stream, separate from the governed-effect claim/result cache in migration
|
|
11
|
-
-- 0261. Targets write before credential resolution and once at terminal state.
|
|
12
|
-
|
|
13
|
-
CREATE TABLE IF NOT EXISTS public.harness_tool_execution_events (
|
|
14
|
-
id bigserial PRIMARY KEY,
|
|
15
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
16
|
-
thread_id uuid NOT NULL REFERENCES public.threads(id) ON DELETE CASCADE,
|
|
17
|
-
turn_id uuid NOT NULL REFERENCES public.thread_turns(id) ON DELETE CASCADE,
|
|
18
|
-
principal_type text NOT NULL CHECK (principal_type IN ('user', 'service')),
|
|
19
|
-
principal_id text NOT NULL,
|
|
20
|
-
tool_use_id text NOT NULL,
|
|
21
|
-
operation text NOT NULL,
|
|
22
|
-
policy_revision text NOT NULL,
|
|
23
|
-
policy_decision_id text,
|
|
24
|
-
idempotency_key text NOT NULL,
|
|
25
|
-
credential_owner_alias text,
|
|
26
|
-
event_type text NOT NULL
|
|
27
|
-
CHECK (event_type IN ('started','completed','failed','uncertain')),
|
|
28
|
-
input_preview jsonb,
|
|
29
|
-
output_preview jsonb,
|
|
30
|
-
error_preview jsonb,
|
|
31
|
-
provider_request_id text,
|
|
32
|
-
duration_ms integer CHECK (duration_ms IS NULL OR duration_ms >= 0),
|
|
33
|
-
provider_cost_usd numeric(18,8)
|
|
34
|
-
CHECK (provider_cost_usd IS NULL OR provider_cost_usd >= 0),
|
|
35
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
36
|
-
CHECK (
|
|
37
|
-
(
|
|
38
|
-
event_type = 'started'
|
|
39
|
-
AND input_preview IS NOT NULL
|
|
40
|
-
AND output_preview IS NULL
|
|
41
|
-
AND error_preview IS NULL
|
|
42
|
-
AND provider_request_id IS NULL
|
|
43
|
-
AND duration_ms IS NULL
|
|
44
|
-
AND provider_cost_usd IS NULL
|
|
45
|
-
)
|
|
46
|
-
OR (
|
|
47
|
-
event_type IN ('completed','failed','uncertain')
|
|
48
|
-
AND input_preview IS NULL
|
|
49
|
-
)
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
CREATE UNIQUE INDEX IF NOT EXISTS uq_harness_tool_execution_started
|
|
54
|
-
ON public.harness_tool_execution_events (tenant_id, idempotency_key)
|
|
55
|
-
WHERE event_type = 'started';
|
|
56
|
-
|
|
57
|
-
CREATE UNIQUE INDEX IF NOT EXISTS uq_harness_tool_execution_terminal
|
|
58
|
-
ON public.harness_tool_execution_events (tenant_id, idempotency_key)
|
|
59
|
-
WHERE event_type IN ('completed','failed','uncertain');
|
|
60
|
-
|
|
61
|
-
CREATE INDEX IF NOT EXISTS idx_harness_tool_execution_turn
|
|
62
|
-
ON public.harness_tool_execution_events (tenant_id, thread_id, turn_id, id);
|
|
63
|
-
|
|
64
|
-
CREATE OR REPLACE FUNCTION public.validate_harness_tool_execution_event_insert()
|
|
65
|
-
RETURNS trigger
|
|
66
|
-
LANGUAGE plpgsql
|
|
67
|
-
AS $$
|
|
68
|
-
BEGIN
|
|
69
|
-
IF NEW.event_type = 'started' THEN
|
|
70
|
-
RETURN NEW;
|
|
71
|
-
END IF;
|
|
72
|
-
|
|
73
|
-
IF NOT EXISTS (
|
|
74
|
-
SELECT 1
|
|
75
|
-
FROM public.harness_tool_execution_events started
|
|
76
|
-
WHERE started.tenant_id = NEW.tenant_id
|
|
77
|
-
AND started.idempotency_key = NEW.idempotency_key
|
|
78
|
-
AND started.event_type = 'started'
|
|
79
|
-
AND started.thread_id = NEW.thread_id
|
|
80
|
-
AND started.turn_id = NEW.turn_id
|
|
81
|
-
AND started.principal_type = NEW.principal_type
|
|
82
|
-
AND started.principal_id = NEW.principal_id
|
|
83
|
-
AND started.tool_use_id = NEW.tool_use_id
|
|
84
|
-
AND started.operation = NEW.operation
|
|
85
|
-
AND started.policy_revision = NEW.policy_revision
|
|
86
|
-
) THEN
|
|
87
|
-
RAISE EXCEPTION 'harness_tool_execution_terminal_without_matching_start';
|
|
88
|
-
END IF;
|
|
89
|
-
|
|
90
|
-
RETURN NEW;
|
|
91
|
-
END;
|
|
92
|
-
$$;
|
|
93
|
-
|
|
94
|
-
DROP TRIGGER IF EXISTS trg_validate_harness_tool_execution_event_insert
|
|
95
|
-
ON public.harness_tool_execution_events;
|
|
96
|
-
CREATE TRIGGER trg_validate_harness_tool_execution_event_insert
|
|
97
|
-
BEFORE INSERT ON public.harness_tool_execution_events
|
|
98
|
-
FOR EACH ROW EXECUTE FUNCTION public.validate_harness_tool_execution_event_insert();
|
|
99
|
-
|
|
100
|
-
CREATE OR REPLACE FUNCTION public.reject_harness_tool_execution_event_mutation()
|
|
101
|
-
RETURNS trigger
|
|
102
|
-
LANGUAGE plpgsql
|
|
103
|
-
AS $$
|
|
104
|
-
BEGIN
|
|
105
|
-
RAISE EXCEPTION 'harness_tool_execution_events_are_append_only';
|
|
106
|
-
END;
|
|
107
|
-
$$;
|
|
108
|
-
|
|
109
|
-
DROP TRIGGER IF EXISTS trg_reject_harness_tool_execution_event_mutation
|
|
110
|
-
ON public.harness_tool_execution_events;
|
|
111
|
-
CREATE TRIGGER trg_reject_harness_tool_execution_event_mutation
|
|
112
|
-
BEFORE UPDATE OR DELETE ON public.harness_tool_execution_events
|
|
113
|
-
FOR EACH ROW EXECUTE FUNCTION public.reject_harness_tool_execution_event_mutation();
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# Company Data Plugin
|
|
2
|
-
|
|
3
|
-
The Company Data plugin is the package-owned source boundary for the
|
|
4
|
-
first-party operational facts substrate. This slice publishes the stable
|
|
5
|
-
catalog identity and normal ThinkWork install path before any live Company Data
|
|
6
|
-
runtime exists.
|
|
7
|
-
|
|
8
|
-
The shell intentionally does not deploy extraction runners, projection database
|
|
9
|
-
schema, mapping workflows, schedules, pipelines, MCP servers, skills,
|
|
10
|
-
credentials, datalake, warehouse, query engine, monitoring, analytics UI, BI,
|
|
11
|
-
Context Engine providers, live operator UI, source-system writes, or
|
|
12
|
-
Terraform-managed resources. Future Company Data work should extend this
|
|
13
|
-
`company-data` package and version line with explicit requirements,
|
|
14
|
-
handler-backed components, and deployed verification before introducing runtime
|
|
15
|
-
capability.
|
|
16
|
-
|
|
17
|
-
## Owned Source
|
|
18
|
-
|
|
19
|
-
- `src/manifest.ts` declares the catalog manifest with empty OAuth scopes,
|
|
20
|
-
no capabilities, and one declared-only `ui-surface` component.
|
|
21
|
-
- `test/manifest.test.ts` validates the shell boundary, manifest shape,
|
|
22
|
-
customer-facing operational facts copy, and deferred-resource language.
|
|
23
|
-
|
|
24
|
-
## Shell Scope
|
|
25
|
-
|
|
26
|
-
V1 is deliberately narrow:
|
|
27
|
-
|
|
28
|
-
- Company Data appears in the first-party plugin catalog as
|
|
29
|
-
`company-data@0.1.0`.
|
|
30
|
-
- Tenant administrators can install the shell through the normal plugin
|
|
31
|
-
install flow.
|
|
32
|
-
- The plugin engine records only the install and one no-op UI-surface component
|
|
33
|
-
with an empty handler reference.
|
|
34
|
-
- Live extraction runtime, projection schema, mapping workflows, schedules,
|
|
35
|
-
pipelines, MCP servers, skills, credentials, Context Engine providers,
|
|
36
|
-
analytics UI, BI, lakehouse query UI, source-system writes, and
|
|
37
|
-
infrastructure are deferred follow-up work.
|
|
38
|
-
|
|
39
|
-
## Verification Notes
|
|
40
|
-
|
|
41
|
-
Package-local verification:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
pnpm --filter @thinkwork/plugin-company-data test
|
|
45
|
-
pnpm --filter @thinkwork/plugin-company-data typecheck
|
|
46
|
-
pnpm --filter @thinkwork/plugin-catalog test
|
|
47
|
-
pnpm --filter @thinkwork/plugin-catalog typecheck
|
|
48
|
-
node scripts/verify-plugin-source-boundary.mjs
|
|
49
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@thinkwork/plugin-company-data",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./src/index.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./src/index.ts",
|
|
9
|
-
"./manifest": "./src/manifest.ts"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc --build",
|
|
13
|
-
"typecheck": "tsc --noEmit",
|
|
14
|
-
"test": "vitest run"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@thinkwork/plugin-catalog": "workspace:*",
|
|
18
|
-
"typescript": "^5.5.0",
|
|
19
|
-
"vitest": "^2.0.0"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { companyDataManifest } from "./manifest";
|
|
2
|
-
|
|
3
|
-
export const companyDataPluginPackage = {
|
|
4
|
-
packageKey: "company-data",
|
|
5
|
-
sourceRoot: "plugins/company-data",
|
|
6
|
-
manifest: companyDataManifest,
|
|
7
|
-
ownedSources: [
|
|
8
|
-
{
|
|
9
|
-
kind: "manifest",
|
|
10
|
-
path: "plugins/company-data/src/manifest.ts",
|
|
11
|
-
description:
|
|
12
|
-
"Company Data catalog manifest for the shell-only plugin identity.",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
kind: "docs",
|
|
16
|
-
path: "plugins/company-data/README.md",
|
|
17
|
-
description:
|
|
18
|
-
"Company Data package ownership and deferred resource notes.",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
kind: "tests",
|
|
22
|
-
path: "plugins/company-data/test",
|
|
23
|
-
description:
|
|
24
|
-
"Company Data package-local manifest and shell-boundary tests.",
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
compatibilityLinks: [],
|
|
28
|
-
} as const;
|
|
29
|
-
|
|
30
|
-
export { companyDataManifest };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { PluginManifest } from "@thinkwork/plugin-catalog/contracts";
|
|
2
|
-
|
|
3
|
-
export const COMPANY_DATA_SETTINGS_SURFACE =
|
|
4
|
-
"settings.plugins.detail.tab" as const;
|
|
5
|
-
|
|
6
|
-
export const companyDataManifest = {
|
|
7
|
-
pluginKey: "company-data",
|
|
8
|
-
displayName: "ThinkWork Data Warehouse",
|
|
9
|
-
description:
|
|
10
|
-
"Establishes a governed operational facts substrate for agent and UI reads. Extraction runners, projection databases, Context Engine providers, MCP tools, analytics, BI, and source-system writes belong to later ThinkWork Data Warehouse releases.",
|
|
11
|
-
versions: [
|
|
12
|
-
{
|
|
13
|
-
version: "0.1.0",
|
|
14
|
-
requiredOauthScopes: [],
|
|
15
|
-
capabilities: [],
|
|
16
|
-
components: [
|
|
17
|
-
{
|
|
18
|
-
type: "ui-surface",
|
|
19
|
-
key: "settings",
|
|
20
|
-
displayName: "ThinkWork Data Warehouse settings",
|
|
21
|
-
intendedMount: COMPANY_DATA_SETTINGS_SURFACE,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
} satisfies PluginManifest;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
validatePluginManifest,
|
|
7
|
-
type PluginComponentType,
|
|
8
|
-
} from "@thinkwork/plugin-catalog/contracts";
|
|
9
|
-
import { defineFirstPartyPluginPackage } from "@thinkwork/plugin-catalog/plugin-package";
|
|
10
|
-
|
|
11
|
-
import { companyDataPluginPackage } from "../src";
|
|
12
|
-
import {
|
|
13
|
-
COMPANY_DATA_SETTINGS_SURFACE,
|
|
14
|
-
companyDataManifest,
|
|
15
|
-
} from "../src/manifest";
|
|
16
|
-
|
|
17
|
-
describe("ThinkWork Data Warehouse plugin manifest", () => {
|
|
18
|
-
it("validates as an inert shell plugin", () => {
|
|
19
|
-
const validated = validatePluginManifest(companyDataManifest);
|
|
20
|
-
|
|
21
|
-
expect(validated.pluginKey).toBe("company-data");
|
|
22
|
-
expect(validated.displayName).toBe("ThinkWork Data Warehouse");
|
|
23
|
-
expect(validated.versions[0].version).toBe("0.1.0");
|
|
24
|
-
expect(validated.versions[0].requiredOauthScopes).toEqual([]);
|
|
25
|
-
expect(validated.versions[0].capabilities).toEqual([]);
|
|
26
|
-
expect(validated.versions[0].components).toEqual([
|
|
27
|
-
{
|
|
28
|
-
type: "ui-surface",
|
|
29
|
-
key: "settings",
|
|
30
|
-
displayName: "ThinkWork Data Warehouse settings",
|
|
31
|
-
intendedMount: COMPANY_DATA_SETTINGS_SURFACE,
|
|
32
|
-
},
|
|
33
|
-
]);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("does not declare side-effecting components, OAuth scopes, or secrets", () => {
|
|
37
|
-
const version = companyDataManifest.versions[0];
|
|
38
|
-
const componentTypes = version.components.map(
|
|
39
|
-
(component) => component.type as PluginComponentType,
|
|
40
|
-
);
|
|
41
|
-
const serializedManifest = JSON.stringify(companyDataManifest);
|
|
42
|
-
|
|
43
|
-
expect(componentTypes).toEqual(["ui-surface"]);
|
|
44
|
-
expect(componentTypes).not.toContain("infrastructure");
|
|
45
|
-
expect(componentTypes).not.toContain("mcp-server");
|
|
46
|
-
expect(componentTypes).not.toContain("skills");
|
|
47
|
-
expect(version.requiredOauthScopes).toEqual([]);
|
|
48
|
-
expect(serializedManifest).not.toMatch(
|
|
49
|
-
/https?:\/\/|\.invalid|terraform|managedAppKey|endpointUrl|endpointFrom|credential|secret|skillMd/i,
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("keeps customer-facing copy on the governed operational facts scope", () => {
|
|
54
|
-
const customerFacingText = [
|
|
55
|
-
companyDataManifest.displayName,
|
|
56
|
-
companyDataManifest.description,
|
|
57
|
-
...companyDataManifest.versions[0].components.map(
|
|
58
|
-
(component) => component.displayName,
|
|
59
|
-
),
|
|
60
|
-
].join("\n");
|
|
61
|
-
|
|
62
|
-
expect(customerFacingText).toContain("ThinkWork Data Warehouse");
|
|
63
|
-
expect(customerFacingText).toContain("governed operational facts");
|
|
64
|
-
expect(customerFacingText).toContain("agent and UI reads");
|
|
65
|
-
expect(customerFacingText).toContain(
|
|
66
|
-
"later ThinkWork Data Warehouse releases",
|
|
67
|
-
);
|
|
68
|
-
expect(customerFacingText).not.toContain("Company Data");
|
|
69
|
-
expect(customerFacingText).not.toMatch(
|
|
70
|
-
/\b(stores?|loads?)\s+every\s+operational\s+row\s+in\s+Company\s+Brain/i,
|
|
71
|
-
);
|
|
72
|
-
expect(customerFacingText).not.toMatch(
|
|
73
|
-
/\b(deploys?|provides?|operates?)\s+(analytics|BI|dashboards?|lakehouse query|ELT jobs?|extraction runners?|projection databases?)/i,
|
|
74
|
-
);
|
|
75
|
-
expect(customerFacingText).not.toMatch(
|
|
76
|
-
/\b(replaces?|mutates?|writes? back to)\s+source systems?/i,
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("defines a first-party package boundary under plugins/company-data", () => {
|
|
81
|
-
const defined = defineFirstPartyPluginPackage(companyDataPluginPackage);
|
|
82
|
-
|
|
83
|
-
expect(defined.packageKey).toBe("company-data");
|
|
84
|
-
expect(defined.sourceRoot).toBe("plugins/company-data");
|
|
85
|
-
expect(defined.ownedSources).toContainEqual({
|
|
86
|
-
kind: "manifest",
|
|
87
|
-
path: "plugins/company-data/src/manifest.ts",
|
|
88
|
-
description:
|
|
89
|
-
"Company Data catalog manifest for the shell-only plugin identity.",
|
|
90
|
-
});
|
|
91
|
-
expect(defined.ownedSources).toContainEqual({
|
|
92
|
-
kind: "tests",
|
|
93
|
-
path: "plugins/company-data/test",
|
|
94
|
-
description:
|
|
95
|
-
"Company Data package-local manifest and shell-boundary tests.",
|
|
96
|
-
});
|
|
97
|
-
expect(defined.compatibilityLinks).toEqual([]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("documents deferred resource deployment for future implementers", () => {
|
|
101
|
-
const readmePath = fileURLToPath(new URL("../README.md", import.meta.url));
|
|
102
|
-
const readme = readFileSync(readmePath, "utf8");
|
|
103
|
-
|
|
104
|
-
expect(readme).toContain("intentionally does not deploy");
|
|
105
|
-
expect(readme).toContain("extraction runners");
|
|
106
|
-
expect(readme).toContain("projection database");
|
|
107
|
-
expect(readme).toContain("mapping workflows");
|
|
108
|
-
expect(readme).toContain("MCP");
|
|
109
|
-
expect(readme).toContain("Context Engine providers");
|
|
110
|
-
expect(readme).toContain("credentials");
|
|
111
|
-
expect(readme).toContain("analytics UI");
|
|
112
|
-
expect(readme).toContain("BI");
|
|
113
|
-
expect(readme).toContain("source-system writes");
|
|
114
|
-
expect(readme).toContain("Terraform-managed resources");
|
|
115
|
-
});
|
|
116
|
-
});
|