create-safest-tools 0.2.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/LICENSE +201 -0
- package/README.md +71 -0
- package/bin/create-safest-tools.mjs +12 -0
- package/package.json +34 -0
- package/src/cli.mjs +128 -0
- package/src/config.mjs +151 -0
- package/src/scaffold.mjs +30 -0
- package/template/LICENSE +201 -0
- package/template/README.md +35 -0
- package/template/console/README.md +28 -0
- package/template/console/analytics/AnalyticsWorkspace.tsx +55 -0
- package/template/console/analytics/controller.ts +133 -0
- package/template/console/analytics/events.ts +33 -0
- package/template/console/analytics/store.ts +33 -0
- package/template/console/analytics/types.ts +38 -0
- package/template/console/appeals/AppealWorkspace.tsx +73 -0
- package/template/console/appeals/controller.ts +125 -0
- package/template/console/appeals/events.ts +33 -0
- package/template/console/appeals/store.ts +35 -0
- package/template/console/appeals/types.ts +37 -0
- package/template/console/assistant/AssistantWorkspace.tsx +133 -0
- package/template/console/assistant/types.ts +34 -0
- package/template/console/auth/AccountJourney.tsx +69 -0
- package/template/console/auth/InvitationAcceptance.tsx +145 -0
- package/template/console/auth/OAuthButtons.tsx +78 -0
- package/template/console/auth/OperatorLogin.tsx +110 -0
- package/template/console/auth/PasswordRecovery.tsx +132 -0
- package/template/console/auth/account-route.ts +15 -0
- package/template/console/auth/browser-navigation.ts +7 -0
- package/template/console/auth/events.ts +15 -0
- package/template/console/command/CommandCentre.tsx +119 -0
- package/template/console/command/controller.ts +267 -0
- package/template/console/command/events.ts +19 -0
- package/template/console/command/store.ts +36 -0
- package/template/console/command/types.ts +61 -0
- package/template/console/components/AnalystIdentity.tsx +25 -0
- package/template/console/components/PageHeader.tsx +27 -0
- package/template/console/configuration/ConfigurationDialog.tsx +200 -0
- package/template/console/configuration/ConfigurationWorkspace.tsx +66 -0
- package/template/console/configuration/FormBuilder.tsx +143 -0
- package/template/console/configuration/api.ts +40 -0
- package/template/console/configuration/events.ts +14 -0
- package/template/console/configuration/types.ts +79 -0
- package/template/console/lib/format.ts +49 -0
- package/template/console/lib/http.ts +96 -0
- package/template/console/main.tsx +225 -0
- package/template/console/operations/OperationsWorkspace.tsx +126 -0
- package/template/console/operations/controller.ts +237 -0
- package/template/console/operations/events.ts +37 -0
- package/template/console/operations/store.ts +32 -0
- package/template/console/operations/types.ts +107 -0
- package/template/console/people/PeopleWorkspace.tsx +81 -0
- package/template/console/people/types.ts +25 -0
- package/template/console/profile/ProfileWorkspace.tsx +136 -0
- package/template/console/profile/events.ts +9 -0
- package/template/console/profile/types.ts +6 -0
- package/template/console/quality/QualityWorkspace.tsx +87 -0
- package/template/console/quality/controller.ts +154 -0
- package/template/console/quality/events.ts +34 -0
- package/template/console/quality/store.ts +36 -0
- package/template/console/quality/types.ts +70 -0
- package/template/console/queues/QueueEditor.tsx +173 -0
- package/template/console/queues/QueueWorkspace.tsx +109 -0
- package/template/console/queues/controller.ts +194 -0
- package/template/console/queues/events.ts +34 -0
- package/template/console/queues/store.ts +37 -0
- package/template/console/queues/types.ts +102 -0
- package/template/console/registry/RegistryDialog.tsx +198 -0
- package/template/console/registry/RegistryWorkspace.tsx +108 -0
- package/template/console/registry/events.ts +14 -0
- package/template/console/registry/types.ts +52 -0
- package/template/console/reports/ReportDrawer.tsx +159 -0
- package/template/console/reports/ReportWorkspace.tsx +90 -0
- package/template/console/reports/controller.ts +517 -0
- package/template/console/reports/events.ts +42 -0
- package/template/console/reports/store.ts +39 -0
- package/template/console/reports/types.ts +230 -0
- package/template/console/settings/BrandEditor.tsx +126 -0
- package/template/console/settings/ChannelDialog.tsx +241 -0
- package/template/console/settings/SettingsWorkspace.tsx +155 -0
- package/template/console/settings/events.ts +19 -0
- package/template/console/settings/handoff.ts +22 -0
- package/template/console/settings/types.ts +93 -0
- package/template/console/shell/WorkspaceShell.tsx +160 -0
- package/template/console/shell/controller.ts +182 -0
- package/template/console/shell/events.ts +25 -0
- package/template/console/shell/navigation.ts +61 -0
- package/template/console/shell/store.ts +56 -0
- package/template/console/shell/types.ts +86 -0
- package/template/console/workflows/CreateWorkflowDialog.tsx +87 -0
- package/template/console/workflows/WorkflowCanvas.tsx +42 -0
- package/template/console/workflows/WorkflowDialogs.tsx +6 -0
- package/template/console/workflows/WorkflowStudio.tsx +331 -0
- package/template/console/workflows/WorkflowWorkspace.tsx +82 -0
- package/template/console/workflows/events.ts +17 -0
- package/template/console/workflows/graph.ts +156 -0
- package/template/console/workflows/templates.ts +70 -0
- package/template/console/workflows/types.ts +201 -0
- package/template/gitignore.template +18 -0
- package/template/migrations/0001_reports_foundation.sql +444 -0
- package/template/migrations/0002_human_report_loop.sql +65 -0
- package/template/migrations/0003_delivery_reliability.sql +18 -0
- package/template/migrations/0004_public_intake.sql +14 -0
- package/template/migrations/0005_operations_visibility.sql +24 -0
- package/template/migrations/0006_ai_governance.sql +198 -0
- package/template/migrations/0007_ai_release_gates.sql +6 -0
- package/template/migrations/0008_retention_analytics_exports.sql +52 -0
- package/template/migrations/0009_retention_derived_copies.sql +14 -0
- package/template/migrations/0010_ai_quality_controls.sql +26 -0
- package/template/migrations/0011_analyst_presence.sql +28 -0
- package/template/migrations/0012_queue_policies.sql +87 -0
- package/template/migrations/0013_routing_agents.sql +63 -0
- package/template/migrations/0014_webhook_enrichments.sql +122 -0
- package/template/migrations/0015_queue_owned_ai.sql +55 -0
- package/template/migrations/0016_operator_accounts.sql +67 -0
- package/template/migrations/0017_operator_profiles_and_recovery.sql +33 -0
- package/template/migrations/0018_platform_configuration.sql +382 -0
- package/template/migrations/0019_workflow_authoring_runtime.sql +372 -0
- package/template/migrations/0020_tasks_findings_assistant_budgets.sql +427 -0
- package/template/migrations/0021_abuse_evidence_operations.sql +324 -0
- package/template/migrations/0022_workflow_dispatch_operations.sql +42 -0
- package/template/migrations/0023_component_connection_execution.sql +75 -0
- package/template/migrations/0024_access_runtime_integrity.sql +72 -0
- package/template/migrations/0025_installation_timezone.sql +11 -0
- package/template/migrations/0026_ai_and_egress_execution_controls.sql +49 -0
- package/template/migrations/0027_prompt_and_ai_registry.sql +37 -0
- package/template/migrations/0028_step_attempt_ai_provenance.sql +13 -0
- package/template/migrations/0029_evidence_fetch_transport.sql +5 -0
- package/template/migrations/0030_evidence_dlq_incidents.sql +45 -0
- package/template/migrations/0031_shadow_quality_integrity.sql +7 -0
- package/template/migrations/0032_action_delivery_outbox.sql +55 -0
- package/template/migrations/0033_configuration_and_assistant_drafts.sql +43 -0
- package/template/migrations/0034_installation_integrations.sql +31 -0
- package/template/migrations/0035_workspace_governance.sql +21 -0
- package/template/migrations/0036_published_routing_baseline.sql +15 -0
- package/template/migrations/0037_builtin_phishing_specialist.sql +71 -0
- package/template/migrations/0038_remove_deprecated_enrichment_runtime.sql +228 -0
- package/template/migrations/0039_secure_reporting_channels.sql +45 -0
- package/template/migrations/0040_notification_only_reporting.sql +24 -0
- package/template/migrations/0041_better_auth_credentials.sql +17 -0
- package/template/package.json +47 -0
- package/template/public/_headers +27 -0
- package/template/public/app-icon-192.png +0 -0
- package/template/public/app-icon-512.png +0 -0
- package/template/public/brand-icon.svg +7 -0
- package/template/public/brand-tokens.css +80 -0
- package/template/public/console/auth-shell.js +19340 -0
- package/template/public/customer-brand.js +58 -0
- package/template/public/embed/embed.css +139 -0
- package/template/public/embed/embed.js +408 -0
- package/template/public/embed/index.html +91 -0
- package/template/public/favicon.svg +7 -0
- package/template/public/fonts/Manrope-Variable.ttf +0 -0
- package/template/public/fonts/Newsreader-Italic-Variable.ttf +0 -0
- package/template/public/fonts/Newsreader-Variable.ttf +0 -0
- package/template/public/index.html +123 -0
- package/template/public/logo-primary.svg +7 -0
- package/template/public/logo-reversed.svg +7 -0
- package/template/public/manifest.webmanifest +21 -0
- package/template/public/public-report.js +184 -0
- package/template/public/report/index.html +39 -0
- package/template/public/report/public-report.css +20 -0
- package/template/public/social-card.png +0 -0
- package/template/public/styles.css +1521 -0
- package/template/public/widget.css +80 -0
- package/template/public/widget.js +220 -0
- package/template/reports.config.example.json +38 -0
- package/template/reports.schema.json +89 -0
- package/template/scripts/reports-auth-onboarding.mjs +180 -0
- package/template/scripts/reports-backup.mjs +276 -0
- package/template/scripts/reports-cloudflare-preflight.mjs +152 -0
- package/template/scripts/reports-deploy.mjs +173 -0
- package/template/scripts/reports-plan.mjs +226 -0
- package/template/scripts/reports-restore.mjs +180 -0
- package/template/scripts/reports-secrets.mjs +73 -0
- package/template/scripts/reports-uninstall-plan.mjs +32 -0
- package/template/src/agent-executor.ts +330 -0
- package/template/src/ai-observability.ts +163 -0
- package/template/src/ai-registry-validation.ts +244 -0
- package/template/src/ai-registry.ts +292 -0
- package/template/src/api-cursor.ts +84 -0
- package/template/src/assistant.ts +554 -0
- package/template/src/audit.ts +39 -0
- package/template/src/backup-service.ts +269 -0
- package/template/src/budget-control.ts +127 -0
- package/template/src/component-executor.ts +845 -0
- package/template/src/configuration-registry.ts +550 -0
- package/template/src/connection-egress.ts +430 -0
- package/template/src/connection-oauth.ts +368 -0
- package/template/src/evidence-service.ts +335 -0
- package/template/src/human-tasks.ts +316 -0
- package/template/src/index.ts +4114 -0
- package/template/src/installation-admin.ts +301 -0
- package/template/src/intake-abuse.ts +156 -0
- package/template/src/platform-registry-validation.ts +367 -0
- package/template/src/platform-registry.ts +753 -0
- package/template/src/report-admin.ts +342 -0
- package/template/src/report-ai-quality.ts +390 -0
- package/template/src/report-ai-validation.ts +80 -0
- package/template/src/report-ai.ts +857 -0
- package/template/src/report-auth.ts +292 -0
- package/template/src/report-better-auth.ts +583 -0
- package/template/src/report-context-schema.ts +132 -0
- package/template/src/report-context.ts +126 -0
- package/template/src/report-crypto.ts +142 -0
- package/template/src/report-delivery.ts +579 -0
- package/template/src/report-form-validation.ts +51 -0
- package/template/src/report-governance.ts +510 -0
- package/template/src/report-http.ts +90 -0
- package/template/src/report-operations.ts +685 -0
- package/template/src/report-operator-accounts.ts +810 -0
- package/template/src/report-presence.ts +398 -0
- package/template/src/report-queue-validation.ts +309 -0
- package/template/src/report-queues.ts +478 -0
- package/template/src/report-repository.ts +972 -0
- package/template/src/report-router-agent.ts +328 -0
- package/template/src/report-router-validation.ts +81 -0
- package/template/src/report-routing.ts +178 -0
- package/template/src/report-turnstile.ts +142 -0
- package/template/src/report-types.ts +224 -0
- package/template/src/report-validation.ts +279 -0
- package/template/src/report-workflow-validation.ts +119 -0
- package/template/src/report-workflow.ts +886 -0
- package/template/src/shadow-quality.ts +278 -0
- package/template/src/workflow-actions.ts +782 -0
- package/template/src/workflow-compiler.ts +230 -0
- package/template/src/workflow-dynamic-runtime.ts +613 -0
- package/template/src/workflow-effects.ts +316 -0
- package/template/src/workflow-expressions.ts +191 -0
- package/template/src/workflow-platform-types.ts +121 -0
- package/template/src/workflow-platform-validation.ts +540 -0
- package/template/src/workflow-repository.ts +916 -0
- package/template/src/workflow-runs.ts +686 -0
- package/template/src/workflow-simulator.ts +211 -0
- package/template/src/workspace-branding.ts +128 -0
- package/template/src/workspace-governance.ts +279 -0
- package/template/tsconfig.console.json +23 -0
- package/template/tsconfig.json +22 -0
- package/template/vite.console.config.ts +20 -0
- package/template/worker-configuration.d.ts +65 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
PRAGMA foreign_keys = ON;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE workflow_definitions (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
installation_id TEXT NOT NULL REFERENCES installations(id) ON DELETE CASCADE,
|
|
6
|
+
workflow_key TEXT NOT NULL,
|
|
7
|
+
name TEXT NOT NULL,
|
|
8
|
+
description TEXT NOT NULL DEFAULT '',
|
|
9
|
+
purpose TEXT NOT NULL CHECK (purpose IN ('report', 'appeal', 'quality', 'operations')),
|
|
10
|
+
status TEXT NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'paused', 'archived')),
|
|
11
|
+
active_version_id TEXT,
|
|
12
|
+
created_by TEXT NOT NULL,
|
|
13
|
+
created_at TEXT NOT NULL,
|
|
14
|
+
updated_at TEXT NOT NULL,
|
|
15
|
+
UNIQUE (installation_id, workflow_key)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE INDEX workflow_definitions_admin_idx
|
|
19
|
+
ON workflow_definitions(installation_id, status, purpose, name, id);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE workflow_drafts (
|
|
22
|
+
id TEXT PRIMARY KEY,
|
|
23
|
+
workflow_id TEXT NOT NULL REFERENCES workflow_definitions(id) ON DELETE CASCADE,
|
|
24
|
+
graph_json TEXT NOT NULL,
|
|
25
|
+
graph_digest TEXT NOT NULL,
|
|
26
|
+
revision INTEGER NOT NULL DEFAULT 1 CHECK (revision >= 1),
|
|
27
|
+
validation_json TEXT NOT NULL DEFAULT '{"valid":false,"errors":[],"warnings":[]}',
|
|
28
|
+
validation_digest TEXT,
|
|
29
|
+
validation_status TEXT NOT NULL DEFAULT 'unvalidated' CHECK (validation_status IN ('unvalidated', 'valid', 'invalid')),
|
|
30
|
+
created_by TEXT NOT NULL,
|
|
31
|
+
updated_by TEXT NOT NULL,
|
|
32
|
+
created_at TEXT NOT NULL,
|
|
33
|
+
updated_at TEXT NOT NULL,
|
|
34
|
+
UNIQUE (workflow_id)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
CREATE TABLE workflow_artifacts (
|
|
38
|
+
id TEXT PRIMARY KEY,
|
|
39
|
+
installation_id TEXT NOT NULL REFERENCES installations(id) ON DELETE CASCADE,
|
|
40
|
+
compiler_version TEXT NOT NULL,
|
|
41
|
+
compatibility_date TEXT NOT NULL,
|
|
42
|
+
graph_digest TEXT NOT NULL,
|
|
43
|
+
source_digest TEXT NOT NULL,
|
|
44
|
+
bundle_digest TEXT NOT NULL,
|
|
45
|
+
manifest_digest TEXT NOT NULL,
|
|
46
|
+
bundle_r2_key TEXT,
|
|
47
|
+
inline_source_text TEXT,
|
|
48
|
+
bundle_size_bytes INTEGER NOT NULL CHECK (bundle_size_bytes >= 0),
|
|
49
|
+
capability_manifest_json TEXT NOT NULL,
|
|
50
|
+
compiler_warnings_json TEXT NOT NULL DEFAULT '[]',
|
|
51
|
+
signature_metadata_json TEXT,
|
|
52
|
+
status TEXT NOT NULL DEFAULT 'ready' CHECK (status IN ('building', 'ready', 'invalid', 'missing', 'quarantined')),
|
|
53
|
+
created_at TEXT NOT NULL,
|
|
54
|
+
verified_at TEXT,
|
|
55
|
+
UNIQUE (installation_id, bundle_digest),
|
|
56
|
+
CHECK (bundle_r2_key IS NOT NULL OR inline_source_text IS NOT NULL)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
CREATE INDEX workflow_artifacts_status_idx
|
|
60
|
+
ON workflow_artifacts(installation_id, status, created_at DESC, id DESC);
|
|
61
|
+
|
|
62
|
+
CREATE TABLE workflow_versions (
|
|
63
|
+
id TEXT PRIMARY KEY,
|
|
64
|
+
workflow_id TEXT NOT NULL REFERENCES workflow_definitions(id) ON DELETE CASCADE,
|
|
65
|
+
version INTEGER NOT NULL CHECK (version >= 1),
|
|
66
|
+
graph_json TEXT NOT NULL,
|
|
67
|
+
graph_digest TEXT NOT NULL,
|
|
68
|
+
input_schema_json TEXT NOT NULL DEFAULT '{"type":"object"}',
|
|
69
|
+
output_schema_json TEXT NOT NULL DEFAULT '{"type":"object"}',
|
|
70
|
+
authority_mode TEXT NOT NULL DEFAULT 'assist' CHECK (authority_mode IN ('off', 'shadow', 'assist', 'bounded_auto')),
|
|
71
|
+
dependency_manifest_json TEXT NOT NULL,
|
|
72
|
+
capability_manifest_json TEXT NOT NULL,
|
|
73
|
+
artifact_id TEXT NOT NULL REFERENCES workflow_artifacts(id),
|
|
74
|
+
compiler_version TEXT NOT NULL,
|
|
75
|
+
test_evidence_json TEXT NOT NULL,
|
|
76
|
+
published_by TEXT NOT NULL,
|
|
77
|
+
published_at TEXT NOT NULL,
|
|
78
|
+
retired_at TEXT,
|
|
79
|
+
UNIQUE (workflow_id, version)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
CREATE INDEX workflow_versions_lookup_idx
|
|
83
|
+
ON workflow_versions(workflow_id, version DESC, id);
|
|
84
|
+
|
|
85
|
+
CREATE TABLE workflow_dependencies (
|
|
86
|
+
workflow_version_id TEXT NOT NULL REFERENCES workflow_versions(id) ON DELETE CASCADE,
|
|
87
|
+
dependency_type TEXT NOT NULL CHECK (dependency_type IN (
|
|
88
|
+
'component', 'connection', 'policy', 'template', 'model_alias', 'agent', 'workflow', 'compiler'
|
|
89
|
+
)),
|
|
90
|
+
dependency_key TEXT NOT NULL,
|
|
91
|
+
dependency_version_id TEXT NOT NULL,
|
|
92
|
+
dependency_digest TEXT,
|
|
93
|
+
PRIMARY KEY (workflow_version_id, dependency_type, dependency_key)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
CREATE INDEX workflow_dependencies_version_idx
|
|
97
|
+
ON workflow_dependencies(dependency_type, dependency_version_id, workflow_version_id);
|
|
98
|
+
|
|
99
|
+
CREATE TABLE workflow_fixtures (
|
|
100
|
+
id TEXT PRIMARY KEY,
|
|
101
|
+
workflow_id TEXT NOT NULL REFERENCES workflow_definitions(id) ON DELETE CASCADE,
|
|
102
|
+
name TEXT NOT NULL,
|
|
103
|
+
input_json TEXT NOT NULL,
|
|
104
|
+
component_results_json TEXT NOT NULL DEFAULT '{}',
|
|
105
|
+
human_responses_json TEXT NOT NULL DEFAULT '{}',
|
|
106
|
+
expected_json TEXT NOT NULL,
|
|
107
|
+
failure_injection_json TEXT NOT NULL DEFAULT '{}',
|
|
108
|
+
created_by TEXT NOT NULL,
|
|
109
|
+
created_at TEXT NOT NULL,
|
|
110
|
+
updated_at TEXT NOT NULL,
|
|
111
|
+
UNIQUE (workflow_id, name)
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
CREATE TABLE workflow_test_runs (
|
|
115
|
+
id TEXT PRIMARY KEY,
|
|
116
|
+
workflow_id TEXT NOT NULL REFERENCES workflow_definitions(id) ON DELETE CASCADE,
|
|
117
|
+
workflow_version_id TEXT REFERENCES workflow_versions(id) ON DELETE SET NULL,
|
|
118
|
+
fixture_id TEXT REFERENCES workflow_fixtures(id) ON DELETE SET NULL,
|
|
119
|
+
graph_digest TEXT NOT NULL,
|
|
120
|
+
mode TEXT NOT NULL CHECK (mode IN ('simulation', 'shadow')),
|
|
121
|
+
status TEXT NOT NULL CHECK (status IN ('running', 'passed', 'failed')),
|
|
122
|
+
result_json TEXT,
|
|
123
|
+
error_json TEXT,
|
|
124
|
+
started_by TEXT NOT NULL,
|
|
125
|
+
started_at TEXT NOT NULL,
|
|
126
|
+
finished_at TEXT
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
CREATE INDEX workflow_test_runs_workflow_idx
|
|
130
|
+
ON workflow_test_runs(workflow_id, started_at DESC, id DESC);
|
|
131
|
+
|
|
132
|
+
CREATE TABLE queue_workflow_pins (
|
|
133
|
+
id TEXT PRIMARY KEY,
|
|
134
|
+
queue_id TEXT NOT NULL REFERENCES queue_definitions(id) ON DELETE CASCADE,
|
|
135
|
+
queue_version_id TEXT REFERENCES queue_versions(id),
|
|
136
|
+
workflow_version_id TEXT NOT NULL REFERENCES workflow_versions(id),
|
|
137
|
+
mode TEXT NOT NULL DEFAULT 'primary' CHECK (mode IN ('shadow', 'primary')),
|
|
138
|
+
rollback_of_pin_id TEXT REFERENCES queue_workflow_pins(id),
|
|
139
|
+
activated_by TEXT NOT NULL,
|
|
140
|
+
activated_at TEXT NOT NULL,
|
|
141
|
+
deactivated_at TEXT
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
CREATE UNIQUE INDEX queue_workflow_pins_one_active_idx
|
|
145
|
+
ON queue_workflow_pins(queue_id, mode) WHERE deactivated_at IS NULL;
|
|
146
|
+
CREATE INDEX queue_workflow_pins_version_idx
|
|
147
|
+
ON queue_workflow_pins(workflow_version_id, deactivated_at, queue_id);
|
|
148
|
+
|
|
149
|
+
CREATE TABLE workflow_runs (
|
|
150
|
+
id TEXT PRIMARY KEY,
|
|
151
|
+
installation_id TEXT NOT NULL REFERENCES installations(id) ON DELETE CASCADE,
|
|
152
|
+
report_id TEXT REFERENCES reports(id) ON DELETE SET NULL,
|
|
153
|
+
appeal_id TEXT REFERENCES appeals(id) ON DELETE SET NULL,
|
|
154
|
+
parent_run_id TEXT REFERENCES workflow_runs(id),
|
|
155
|
+
workflow_version_id TEXT NOT NULL REFERENCES workflow_versions(id),
|
|
156
|
+
queue_id TEXT REFERENCES queue_definitions(id),
|
|
157
|
+
queue_version_id TEXT REFERENCES queue_versions(id),
|
|
158
|
+
pin_id TEXT REFERENCES queue_workflow_pins(id),
|
|
159
|
+
run_kind TEXT NOT NULL CHECK (run_kind IN ('primary', 'appeal', 'shadow', 'quality', 'linked', 'test')),
|
|
160
|
+
authority_mode TEXT NOT NULL CHECK (authority_mode IN ('off', 'shadow', 'assist', 'bounded_auto')),
|
|
161
|
+
state TEXT NOT NULL CHECK (state IN (
|
|
162
|
+
'created', 'dispatch_pending', 'queued', 'running', 'waiting', 'paused',
|
|
163
|
+
'succeeded', 'failed', 'terminated', 'superseded', 'repair_required'
|
|
164
|
+
)),
|
|
165
|
+
cloudflare_instance_id TEXT,
|
|
166
|
+
graph_digest TEXT NOT NULL,
|
|
167
|
+
artifact_digest TEXT NOT NULL,
|
|
168
|
+
input_json TEXT NOT NULL,
|
|
169
|
+
output_json TEXT,
|
|
170
|
+
current_node_id TEXT,
|
|
171
|
+
error_code TEXT,
|
|
172
|
+
error_summary TEXT,
|
|
173
|
+
started_at TEXT,
|
|
174
|
+
waiting_at TEXT,
|
|
175
|
+
finished_at TEXT,
|
|
176
|
+
created_at TEXT NOT NULL,
|
|
177
|
+
updated_at TEXT NOT NULL,
|
|
178
|
+
revision INTEGER NOT NULL DEFAULT 1 CHECK (revision >= 1),
|
|
179
|
+
UNIQUE (cloudflare_instance_id)
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
CREATE UNIQUE INDEX workflow_runs_one_active_primary_idx
|
|
183
|
+
ON workflow_runs(report_id)
|
|
184
|
+
WHERE report_id IS NOT NULL AND run_kind = 'primary'
|
|
185
|
+
AND state IN ('created', 'dispatch_pending', 'queued', 'running', 'waiting', 'paused', 'repair_required');
|
|
186
|
+
CREATE INDEX workflow_runs_report_idx
|
|
187
|
+
ON workflow_runs(report_id, created_at DESC, id DESC);
|
|
188
|
+
CREATE INDEX workflow_runs_state_idx
|
|
189
|
+
ON workflow_runs(state, updated_at, id);
|
|
190
|
+
CREATE INDEX workflow_runs_instance_idx
|
|
191
|
+
ON workflow_runs(cloudflare_instance_id, id);
|
|
192
|
+
|
|
193
|
+
CREATE TABLE workflow_run_links (
|
|
194
|
+
parent_run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
195
|
+
child_run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
196
|
+
link_type TEXT NOT NULL CHECK (link_type IN ('handoff', 'appeal', 'shadow', 'quality', 'subworkflow')),
|
|
197
|
+
node_id TEXT,
|
|
198
|
+
created_at TEXT NOT NULL,
|
|
199
|
+
PRIMARY KEY (parent_run_id, child_run_id)
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
CREATE TABLE workflow_step_runs (
|
|
203
|
+
id TEXT PRIMARY KEY,
|
|
204
|
+
run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
205
|
+
node_id TEXT NOT NULL,
|
|
206
|
+
node_type TEXT NOT NULL,
|
|
207
|
+
branch_key TEXT NOT NULL DEFAULT '',
|
|
208
|
+
occurrence INTEGER NOT NULL DEFAULT 1 CHECK (occurrence >= 1),
|
|
209
|
+
state TEXT NOT NULL CHECK (state IN (
|
|
210
|
+
'pending', 'running', 'waiting', 'succeeded', 'failed', 'skipped', 'timed_out', 'cancelled'
|
|
211
|
+
)),
|
|
212
|
+
input_digest TEXT,
|
|
213
|
+
output_digest TEXT,
|
|
214
|
+
started_at TEXT,
|
|
215
|
+
waiting_at TEXT,
|
|
216
|
+
finished_at TEXT,
|
|
217
|
+
updated_at TEXT NOT NULL,
|
|
218
|
+
UNIQUE (run_id, node_id, branch_key, occurrence)
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
CREATE INDEX workflow_step_runs_run_idx
|
|
222
|
+
ON workflow_step_runs(run_id, updated_at, node_id, occurrence);
|
|
223
|
+
CREATE INDEX workflow_step_runs_waiting_idx
|
|
224
|
+
ON workflow_step_runs(state, waiting_at, run_id, id);
|
|
225
|
+
|
|
226
|
+
CREATE TABLE workflow_step_attempts (
|
|
227
|
+
id TEXT PRIMARY KEY,
|
|
228
|
+
step_run_id TEXT NOT NULL REFERENCES workflow_step_runs(id) ON DELETE CASCADE,
|
|
229
|
+
attempt INTEGER NOT NULL CHECK (attempt >= 1),
|
|
230
|
+
operation_id TEXT NOT NULL,
|
|
231
|
+
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'retryable_failed', 'permanent_failed', 'timed_out')),
|
|
232
|
+
request_digest TEXT,
|
|
233
|
+
response_digest TEXT,
|
|
234
|
+
error_code TEXT,
|
|
235
|
+
error_class TEXT,
|
|
236
|
+
retry_at TEXT,
|
|
237
|
+
started_at TEXT NOT NULL,
|
|
238
|
+
finished_at TEXT,
|
|
239
|
+
UNIQUE (step_run_id, attempt),
|
|
240
|
+
UNIQUE (operation_id)
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
CREATE INDEX workflow_step_attempts_retry_idx
|
|
244
|
+
ON workflow_step_attempts(status, retry_at, id);
|
|
245
|
+
|
|
246
|
+
CREATE TABLE workflow_step_outputs (
|
|
247
|
+
step_run_id TEXT PRIMARY KEY REFERENCES workflow_step_runs(id) ON DELETE CASCADE,
|
|
248
|
+
inline_json TEXT,
|
|
249
|
+
r2_object_key TEXT,
|
|
250
|
+
digest TEXT NOT NULL,
|
|
251
|
+
size_bytes INTEGER NOT NULL CHECK (size_bytes >= 0),
|
|
252
|
+
data_classification_json TEXT NOT NULL DEFAULT '[]',
|
|
253
|
+
created_at TEXT NOT NULL,
|
|
254
|
+
CHECK (inline_json IS NOT NULL OR r2_object_key IS NOT NULL)
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
CREATE TABLE workflow_event_inbox (
|
|
258
|
+
id TEXT PRIMARY KEY,
|
|
259
|
+
run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
260
|
+
event_type TEXT NOT NULL,
|
|
261
|
+
event_key TEXT NOT NULL,
|
|
262
|
+
source_type TEXT NOT NULL,
|
|
263
|
+
source_id TEXT,
|
|
264
|
+
payload_json TEXT NOT NULL,
|
|
265
|
+
payload_digest TEXT NOT NULL,
|
|
266
|
+
received_at TEXT NOT NULL,
|
|
267
|
+
delivered_at TEXT,
|
|
268
|
+
delivery_attempts INTEGER NOT NULL DEFAULT 0 CHECK (delivery_attempts >= 0),
|
|
269
|
+
last_error_code TEXT,
|
|
270
|
+
UNIQUE (run_id, event_type, event_key)
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
CREATE INDEX workflow_event_inbox_delivery_idx
|
|
274
|
+
ON workflow_event_inbox(delivered_at, received_at, run_id, id);
|
|
275
|
+
|
|
276
|
+
CREATE TABLE workflow_waits (
|
|
277
|
+
id TEXT PRIMARY KEY,
|
|
278
|
+
run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
279
|
+
step_run_id TEXT NOT NULL REFERENCES workflow_step_runs(id) ON DELETE CASCADE,
|
|
280
|
+
wait_type TEXT NOT NULL CHECK (wait_type IN ('event', 'delay', 'human_task', 'participant_reply', 'deadline')),
|
|
281
|
+
event_type TEXT,
|
|
282
|
+
state TEXT NOT NULL CHECK (state IN ('waiting', 'satisfied', 'timed_out', 'cancelled')),
|
|
283
|
+
deadline_at TEXT,
|
|
284
|
+
satisfied_event_id TEXT REFERENCES workflow_event_inbox(id),
|
|
285
|
+
created_at TEXT NOT NULL,
|
|
286
|
+
satisfied_at TEXT,
|
|
287
|
+
UNIQUE (step_run_id)
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
CREATE INDEX workflow_waits_due_idx
|
|
291
|
+
ON workflow_waits(state, deadline_at, run_id, id);
|
|
292
|
+
|
|
293
|
+
CREATE TABLE workflow_dispatch_outbox (
|
|
294
|
+
id TEXT PRIMARY KEY,
|
|
295
|
+
run_id TEXT NOT NULL REFERENCES workflow_runs(id) ON DELETE CASCADE,
|
|
296
|
+
operation TEXT NOT NULL CHECK (operation IN ('start', 'event', 'pause', 'resume', 'terminate', 'reconcile')),
|
|
297
|
+
event_inbox_id TEXT REFERENCES workflow_event_inbox(id),
|
|
298
|
+
operation_key TEXT NOT NULL UNIQUE,
|
|
299
|
+
state TEXT NOT NULL DEFAULT 'pending' CHECK (state IN ('pending', 'leased', 'delivered', 'failed', 'dead_letter')),
|
|
300
|
+
attempt_count INTEGER NOT NULL DEFAULT 0 CHECK (attempt_count >= 0),
|
|
301
|
+
available_at TEXT NOT NULL,
|
|
302
|
+
lease_expires_at TEXT,
|
|
303
|
+
last_error_code TEXT,
|
|
304
|
+
created_at TEXT NOT NULL,
|
|
305
|
+
updated_at TEXT NOT NULL
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
CREATE INDEX workflow_dispatch_outbox_due_idx
|
|
309
|
+
ON workflow_dispatch_outbox(state, available_at, id);
|
|
310
|
+
|
|
311
|
+
INSERT INTO workflow_artifacts (
|
|
312
|
+
id, installation_id, compiler_version, compatibility_date, graph_digest,
|
|
313
|
+
source_digest, bundle_digest, manifest_digest, inline_source_text,
|
|
314
|
+
bundle_size_bytes, capability_manifest_json, compiler_warnings_json,
|
|
315
|
+
status, created_at, verified_at
|
|
316
|
+
) VALUES (
|
|
317
|
+
'standard-manual-review-artifact-v1',
|
|
318
|
+
'default',
|
|
319
|
+
'migration-seed-v1',
|
|
320
|
+
'2026-08-28',
|
|
321
|
+
'sha256:standard-manual-review-graph-v1',
|
|
322
|
+
'sha256:standard-manual-review-source-v1',
|
|
323
|
+
'sha256:standard-manual-review-bundle-v1',
|
|
324
|
+
'sha256:standard-manual-review-manifest-v1',
|
|
325
|
+
'export const migrationSeed = true;',
|
|
326
|
+
34,
|
|
327
|
+
'{"version":1,"capabilities":["task.create","decision.record","message.send","action.propose"]}',
|
|
328
|
+
'["Seed artifact is replaced by a compiler-produced artifact before primary activation."]',
|
|
329
|
+
'quarantined',
|
|
330
|
+
strftime('%Y-%m-%dT%H:%M:%fZ', 'now'),
|
|
331
|
+
NULL
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
INSERT INTO workflow_definitions (
|
|
335
|
+
id, installation_id, workflow_key, name, description, purpose, status,
|
|
336
|
+
active_version_id, created_by, created_at, updated_at
|
|
337
|
+
) VALUES (
|
|
338
|
+
'standard-manual-review',
|
|
339
|
+
'default',
|
|
340
|
+
'standard-manual-review',
|
|
341
|
+
'Standard manual review',
|
|
342
|
+
'Compatibility workflow representing the existing human review path.',
|
|
343
|
+
'report',
|
|
344
|
+
'active',
|
|
345
|
+
'standard-manual-review-v1',
|
|
346
|
+
'system:migration',
|
|
347
|
+
strftime('%Y-%m-%dT%H:%M:%fZ', 'now'),
|
|
348
|
+
strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
INSERT INTO workflow_versions (
|
|
352
|
+
id, workflow_id, version, graph_json, graph_digest, input_schema_json,
|
|
353
|
+
output_schema_json, authority_mode, dependency_manifest_json,
|
|
354
|
+
capability_manifest_json, artifact_id, compiler_version, test_evidence_json,
|
|
355
|
+
published_by, published_at
|
|
356
|
+
) VALUES (
|
|
357
|
+
'standard-manual-review-v1',
|
|
358
|
+
'standard-manual-review',
|
|
359
|
+
1,
|
|
360
|
+
'{"schema_version":"1","purpose":"report","entry_node_id":"start","nodes":[{"id":"start","kind":"start","name":"Start","input_mapping":{},"config":{}},{"id":"review","kind":"human_task","name":"Manual review","input_mapping":{},"config":{"task_type":"review","queue_id":"run-queue","response_schema":{"type":"object"}}},{"id":"decision","kind":"decision","name":"Record decision","input_mapping":{},"error_port":"error","config":{"policy_version_id":"general-policy-v1"}},{"id":"end","kind":"end","name":"Resolved","input_mapping":{},"config":{"terminal_code":"resolved"}}],"edges":[{"id":"e1","from":{"node_id":"start","port":"success"},"to":{"node_id":"review","port":"input"}},{"id":"e2","from":{"node_id":"review","port":"completed"},"to":{"node_id":"decision","port":"input"}},{"id":"e3","from":{"node_id":"review","port":"timeout"},"to":{"node_id":"decision","port":"input"}},{"id":"e4","from":{"node_id":"decision","port":"recorded"},"to":{"node_id":"end","port":"input"}},{"id":"e5","from":{"node_id":"decision","port":"error"},"to":{"node_id":"end","port":"input"}}],"input_schema":{"type":"object"},"terminal_codes":["resolved"],"default_policies":{}}',
|
|
361
|
+
'sha256:standard-manual-review-graph-v1',
|
|
362
|
+
'{"type":"object"}',
|
|
363
|
+
'{"type":"object"}',
|
|
364
|
+
'assist',
|
|
365
|
+
'{"components":[],"connections":[],"policies":[],"templates":[],"models":[],"agents":[],"workflows":[],"compiler":"migration-seed-v1"}',
|
|
366
|
+
'{"version":1,"capabilities":["task.create","decision.record","message.send","action.propose"]}',
|
|
367
|
+
'standard-manual-review-artifact-v1',
|
|
368
|
+
'migration-seed-v1',
|
|
369
|
+
'{"passed":false,"reason":"compatibility_seed_requires_compiler_republish"}',
|
|
370
|
+
'system:migration',
|
|
371
|
+
strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
372
|
+
);
|