@cloudstreamsoftware/claude-tools 1.0.0 → 1.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/README.md +152 -37
- package/agents/INDEX.md +183 -0
- package/agents/architect.md +247 -0
- package/agents/build-error-resolver.md +555 -0
- package/agents/catalyst-deployer.md +132 -0
- package/agents/code-reviewer.md +121 -0
- package/agents/compliance-auditor.md +148 -0
- package/agents/creator-architect.md +395 -0
- package/agents/deluge-reviewer.md +98 -0
- package/agents/doc-updater.md +471 -0
- package/agents/e2e-runner.md +711 -0
- package/agents/planner.md +122 -0
- package/agents/refactor-cleaner.md +309 -0
- package/agents/security-reviewer.md +582 -0
- package/agents/tdd-guide.md +302 -0
- package/bin/cloudstream-setup.js +16 -6
- package/config/versions.json +63 -0
- package/dist/hooks/hooks.json +209 -0
- package/dist/index.js +47 -0
- package/dist/lib/asset-value.js +609 -0
- package/dist/lib/client-manager.js +300 -0
- package/dist/lib/command-matcher.js +242 -0
- package/dist/lib/cross-session-patterns.js +754 -0
- package/dist/lib/intent-classifier.js +1075 -0
- package/dist/lib/package-manager.js +374 -0
- package/dist/lib/recommendation-engine.js +597 -0
- package/dist/lib/session-memory.js +489 -0
- package/dist/lib/skill-effectiveness.js +486 -0
- package/dist/lib/skill-matcher.js +595 -0
- package/dist/lib/tutorial-metrics.js +242 -0
- package/dist/lib/tutorial-progress.js +209 -0
- package/dist/lib/tutorial-renderer.js +431 -0
- package/dist/lib/utils.js +380 -0
- package/dist/lib/verify-formatter.js +143 -0
- package/dist/lib/workflow-state.js +249 -0
- package/hooks/hooks.json +209 -0
- package/package.json +5 -1
- package/scripts/aggregate-sessions.js +290 -0
- package/scripts/branch-name-validator.js +291 -0
- package/scripts/build.js +101 -0
- package/scripts/commands/client-switch.js +231 -0
- package/scripts/deprecate-skill.js +610 -0
- package/scripts/diagnose.js +324 -0
- package/scripts/doc-freshness.js +168 -0
- package/scripts/generate-weekly-digest.js +393 -0
- package/scripts/health-check.js +270 -0
- package/scripts/hooks/credential-check.js +101 -0
- package/scripts/hooks/evaluate-session.js +81 -0
- package/scripts/hooks/pre-compact.js +66 -0
- package/scripts/hooks/prompt-analyzer.js +276 -0
- package/scripts/hooks/prompt-router.js +422 -0
- package/scripts/hooks/quality-gate-enforcer.js +371 -0
- package/scripts/hooks/session-end.js +156 -0
- package/scripts/hooks/session-start.js +195 -0
- package/scripts/hooks/skill-injector.js +333 -0
- package/scripts/hooks/suggest-compact.js +58 -0
- package/scripts/lib/asset-value.js +609 -0
- package/scripts/lib/client-manager.js +300 -0
- package/scripts/lib/command-matcher.js +242 -0
- package/scripts/lib/cross-session-patterns.js +754 -0
- package/scripts/lib/intent-classifier.js +1075 -0
- package/scripts/lib/package-manager.js +374 -0
- package/scripts/lib/recommendation-engine.js +597 -0
- package/scripts/lib/session-memory.js +489 -0
- package/scripts/lib/skill-effectiveness.js +486 -0
- package/scripts/lib/skill-matcher.js +595 -0
- package/scripts/lib/tutorial-metrics.js +242 -0
- package/scripts/lib/tutorial-progress.js +209 -0
- package/scripts/lib/tutorial-renderer.js +431 -0
- package/scripts/lib/utils.js +380 -0
- package/scripts/lib/verify-formatter.js +143 -0
- package/scripts/lib/workflow-state.js +249 -0
- package/scripts/onboard.js +363 -0
- package/scripts/quarterly-report.js +692 -0
- package/scripts/setup-package-manager.js +204 -0
- package/scripts/sync-upstream.js +391 -0
- package/scripts/test.js +108 -0
- package/scripts/tutorial-runner.js +351 -0
- package/scripts/validate-all.js +201 -0
- package/scripts/verifiers/agents.js +245 -0
- package/scripts/verifiers/config.js +186 -0
- package/scripts/verifiers/environment.js +123 -0
- package/scripts/verifiers/hooks.js +188 -0
- package/scripts/verifiers/index.js +38 -0
- package/scripts/verifiers/persistence.js +140 -0
- package/scripts/verifiers/plugin.js +215 -0
- package/scripts/verifiers/skills.js +209 -0
- package/scripts/verify-setup.js +164 -0
- package/skills/INDEX.md +157 -0
- package/skills/backend-patterns/SKILL.md +586 -0
- package/skills/backend-patterns/catalyst-patterns.md +128 -0
- package/skills/bigquery-patterns/SKILL.md +27 -0
- package/skills/bigquery-patterns/performance-optimization.md +518 -0
- package/skills/bigquery-patterns/query-patterns.md +372 -0
- package/skills/bigquery-patterns/schema-design.md +78 -0
- package/skills/cloudstream-project-template/SKILL.md +20 -0
- package/skills/cloudstream-project-template/structure.md +65 -0
- package/skills/coding-standards/SKILL.md +524 -0
- package/skills/coding-standards/deluge-standards.md +83 -0
- package/skills/compliance-patterns/SKILL.md +28 -0
- package/skills/compliance-patterns/hipaa/audit-requirements.md +251 -0
- package/skills/compliance-patterns/hipaa/baa-process.md +298 -0
- package/skills/compliance-patterns/hipaa/data-archival-strategy.md +387 -0
- package/skills/compliance-patterns/hipaa/phi-handling.md +52 -0
- package/skills/compliance-patterns/pci-dss/saq-a-requirements.md +307 -0
- package/skills/compliance-patterns/pci-dss/tokenization-patterns.md +382 -0
- package/skills/compliance-patterns/pci-dss/zoho-checkout-patterns.md +56 -0
- package/skills/compliance-patterns/soc2/access-controls.md +344 -0
- package/skills/compliance-patterns/soc2/audit-logging.md +458 -0
- package/skills/compliance-patterns/soc2/change-management.md +403 -0
- package/skills/compliance-patterns/soc2/deluge-execution-logging.md +407 -0
- package/skills/consultancy-workflows/SKILL.md +19 -0
- package/skills/consultancy-workflows/client-isolation.md +21 -0
- package/skills/consultancy-workflows/documentation-automation.md +454 -0
- package/skills/consultancy-workflows/handoff-procedures.md +257 -0
- package/skills/consultancy-workflows/knowledge-capture.md +513 -0
- package/skills/consultancy-workflows/time-tracking.md +26 -0
- package/skills/continuous-learning/SKILL.md +84 -0
- package/skills/continuous-learning/config.json +18 -0
- package/skills/continuous-learning/evaluate-session.sh +60 -0
- package/skills/continuous-learning-v2/SKILL.md +126 -0
- package/skills/continuous-learning-v2/config.json +61 -0
- package/skills/frontend-patterns/SKILL.md +635 -0
- package/skills/frontend-patterns/zoho-widget-patterns.md +103 -0
- package/skills/gcp-data-engineering/SKILL.md +36 -0
- package/skills/gcp-data-engineering/bigquery/performance-optimization.md +337 -0
- package/skills/gcp-data-engineering/dataflow/error-handling.md +496 -0
- package/skills/gcp-data-engineering/dataflow/pipeline-patterns.md +444 -0
- package/skills/gcp-data-engineering/dbt/model-organization.md +63 -0
- package/skills/gcp-data-engineering/dbt/testing-patterns.md +503 -0
- package/skills/gcp-data-engineering/medallion-architecture/bronze-layer.md +60 -0
- package/skills/gcp-data-engineering/medallion-architecture/gold-layer.md +311 -0
- package/skills/gcp-data-engineering/medallion-architecture/layer-transitions.md +517 -0
- package/skills/gcp-data-engineering/medallion-architecture/silver-layer.md +305 -0
- package/skills/gcp-data-engineering/zoho-to-gcp/data-extraction.md +543 -0
- package/skills/gcp-data-engineering/zoho-to-gcp/real-time-vs-batch.md +337 -0
- package/skills/security-review/SKILL.md +498 -0
- package/skills/security-review/compliance-checklist.md +53 -0
- package/skills/strategic-compact/SKILL.md +67 -0
- package/skills/tdd-workflow/SKILL.md +413 -0
- package/skills/tdd-workflow/zoho-testing.md +124 -0
- package/skills/tutorial/SKILL.md +249 -0
- package/skills/tutorial/docs/ACCESSIBILITY.md +169 -0
- package/skills/tutorial/lessons/00-philosophy-and-workflow.md +198 -0
- package/skills/tutorial/lessons/01-basics.md +81 -0
- package/skills/tutorial/lessons/02-training.md +86 -0
- package/skills/tutorial/lessons/03-commands.md +109 -0
- package/skills/tutorial/lessons/04-workflows.md +115 -0
- package/skills/tutorial/lessons/05-compliance.md +116 -0
- package/skills/tutorial/lessons/06-zoho.md +121 -0
- package/skills/tutorial/lessons/07-hooks-system.md +277 -0
- package/skills/tutorial/lessons/08-mcp-servers.md +316 -0
- package/skills/tutorial/lessons/09-client-management.md +215 -0
- package/skills/tutorial/lessons/10-testing-e2e.md +260 -0
- package/skills/tutorial/lessons/11-skills-deep-dive.md +272 -0
- package/skills/tutorial/lessons/12-rules-system.md +326 -0
- package/skills/tutorial/lessons/13-golden-standard-graduation.md +213 -0
- package/skills/tutorial/lessons/14-fork-setup-and-sync.md +312 -0
- package/skills/tutorial/lessons/15-living-examples-system.md +221 -0
- package/skills/tutorial/tracks/accelerated/README.md +134 -0
- package/skills/tutorial/tracks/accelerated/assessment/checkpoint-1.md +161 -0
- package/skills/tutorial/tracks/accelerated/assessment/checkpoint-2.md +175 -0
- package/skills/tutorial/tracks/accelerated/day-1-core-concepts.md +234 -0
- package/skills/tutorial/tracks/accelerated/day-2-essential-commands.md +270 -0
- package/skills/tutorial/tracks/accelerated/day-3-workflow-mastery.md +305 -0
- package/skills/tutorial/tracks/accelerated/day-4-compliance-zoho.md +304 -0
- package/skills/tutorial/tracks/accelerated/day-5-hooks-skills.md +344 -0
- package/skills/tutorial/tracks/accelerated/day-6-client-testing.md +386 -0
- package/skills/tutorial/tracks/accelerated/day-7-graduation.md +369 -0
- package/skills/zoho-patterns/CHANGELOG.md +108 -0
- package/skills/zoho-patterns/SKILL.md +446 -0
- package/skills/zoho-patterns/analytics/dashboard-patterns.md +352 -0
- package/skills/zoho-patterns/analytics/zoho-to-bigquery-pipeline.md +427 -0
- package/skills/zoho-patterns/catalyst/appsail-deployment.md +349 -0
- package/skills/zoho-patterns/catalyst/context-close-patterns.md +354 -0
- package/skills/zoho-patterns/catalyst/cron-batch-processing.md +374 -0
- package/skills/zoho-patterns/catalyst/function-patterns.md +439 -0
- package/skills/zoho-patterns/creator/form-design.md +304 -0
- package/skills/zoho-patterns/creator/publish-api-patterns.md +313 -0
- package/skills/zoho-patterns/creator/widget-integration.md +306 -0
- package/skills/zoho-patterns/creator/workflow-automation.md +253 -0
- package/skills/zoho-patterns/deluge/api-patterns.md +468 -0
- package/skills/zoho-patterns/deluge/batch-processing.md +403 -0
- package/skills/zoho-patterns/deluge/cross-app-integration.md +356 -0
- package/skills/zoho-patterns/deluge/error-handling.md +423 -0
- package/skills/zoho-patterns/deluge/syntax-reference.md +65 -0
- package/skills/zoho-patterns/integration/cors-proxy-architecture.md +426 -0
- package/skills/zoho-patterns/integration/crm-books-native-sync.md +277 -0
- package/skills/zoho-patterns/integration/oauth-token-management.md +461 -0
- package/skills/zoho-patterns/integration/zoho-flow-patterns.md +334 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
# SOC 2 Deluge Execution Logging
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Zoho Creator does **NOT** automatically log Deluge function executions. There is no native audit trail for what custom code runs, what data it processes, or what errors it encounters. For SOC 2 compliance, you must custom-build execution logging into every Deluge function that touches regulated data.
|
|
6
|
+
|
|
7
|
+
This document provides the standard logging framework for all CloudStream Deluge implementations.
|
|
8
|
+
|
|
9
|
+
> **WARNING**: Without execution logging, you cannot prove to auditors what your code did, when it ran, or whether it succeeded. This is a SOC 2 control gap that will result in audit findings.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What to Log
|
|
14
|
+
|
|
15
|
+
### Mandatory Log Fields
|
|
16
|
+
|
|
17
|
+
Every Deluge execution log entry MUST capture:
|
|
18
|
+
|
|
19
|
+
| Field | Description | Example |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| Function Name | Identifier of the Deluge function | `processPaymentApproval` |
|
|
22
|
+
| Execution ID | Unique ID per execution instance | `EXEC-20250115-143022-7829` |
|
|
23
|
+
| User | Who triggered the execution | `user@client.com` |
|
|
24
|
+
| Timestamp Start | When execution began (UTC) | `2025-01-15T14:30:22.000Z` |
|
|
25
|
+
| Timestamp End | When execution completed | `2025-01-15T14:30:22.450Z` |
|
|
26
|
+
| Duration (ms) | Execution time in milliseconds | `450` |
|
|
27
|
+
| Input Parameters | Sanitized input data | `{record_id: 123, action: "approve"}` |
|
|
28
|
+
| Output/Result | What the function produced | `{status: "approved", notification_sent: true}` |
|
|
29
|
+
| Status | Success/Failure/Warning | `Success` |
|
|
30
|
+
| Error Details | Error message if failed | `null` or error string |
|
|
31
|
+
| Records Affected | IDs of modified records | `[123, 456]` |
|
|
32
|
+
| Client ID | Client identifier for multi-tenant | `CLT-001` |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Logging to a Dedicated Audit Form
|
|
37
|
+
|
|
38
|
+
### Audit Form: Deluge_Execution_Log
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Form: Deluge_Execution_Log
|
|
42
|
+
Fields:
|
|
43
|
+
- Log_ID (Auto-number)
|
|
44
|
+
- Execution_ID (Single Line, indexed)
|
|
45
|
+
- Function_Name (Single Line, indexed)
|
|
46
|
+
- Trigger_Type (Picklist: User Action/Workflow/Schedule/API/Button)
|
|
47
|
+
- User_Email (Email)
|
|
48
|
+
- Timestamp_Start (DateTime)
|
|
49
|
+
- Timestamp_End (DateTime)
|
|
50
|
+
- Duration_MS (Number)
|
|
51
|
+
- Input_Params (Multi Line - JSON, encrypted if contains sensitive data)
|
|
52
|
+
- Output_Result (Multi Line - JSON)
|
|
53
|
+
- Status (Picklist: Success/Failure/Warning)
|
|
54
|
+
- Error_Message (Multi Line)
|
|
55
|
+
- Error_Stack (Multi Line)
|
|
56
|
+
- Records_Affected (Multi Line - JSON array of IDs)
|
|
57
|
+
- Form_Context (Single Line - which form triggered this)
|
|
58
|
+
- Client_ID (Lookup to Clients)
|
|
59
|
+
- Environment (Picklist: Production/Staging/Development)
|
|
60
|
+
- Severity (Picklist: Info/Warning/Error/Critical)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> **WARNING**: This form should be accessible ONLY to Admin/Auditor roles. Standard users must not be able to view, modify, or delete execution logs.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Performance Impact Considerations
|
|
68
|
+
|
|
69
|
+
### Logging Overhead
|
|
70
|
+
|
|
71
|
+
| Approach | Overhead | Reliability | Recommendation |
|
|
72
|
+
|---|---|---|---|
|
|
73
|
+
| Synchronous insert | +50-100ms per log | High | Use for critical functions |
|
|
74
|
+
| Async (standalone function) | +10-20ms trigger | Medium | Use for high-volume functions |
|
|
75
|
+
| Batch (collect + periodic flush) | Minimal per-call | Lower | Use for non-critical logging |
|
|
76
|
+
| External (Catalyst webhook) | +20-50ms | High | Use for cross-org logging |
|
|
77
|
+
|
|
78
|
+
### Performance Guidelines
|
|
79
|
+
|
|
80
|
+
- **Always log synchronously** for: Financial transactions, ePHI access, permission changes
|
|
81
|
+
- **May log asynchronously** for: Report generation, bulk imports, scheduled tasks
|
|
82
|
+
- **Batch logging acceptable** for: Read-only operations, analytics queries
|
|
83
|
+
|
|
84
|
+
### Minimizing Impact
|
|
85
|
+
|
|
86
|
+
```deluge
|
|
87
|
+
// GOOD: Log only essential data, not full record contents
|
|
88
|
+
logEntry = {
|
|
89
|
+
"record_id": input.ID,
|
|
90
|
+
"action": "update",
|
|
91
|
+
"fields_changed": ["Status", "Approved_By"]
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// BAD: Logging entire record contents (slow + storage waste + potential PII exposure)
|
|
95
|
+
logEntry = {
|
|
96
|
+
"full_record": input // NEVER do this
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Sample Logging Function Template
|
|
103
|
+
|
|
104
|
+
### Core Logging Utility
|
|
105
|
+
|
|
106
|
+
```deluge
|
|
107
|
+
// ============================================================
|
|
108
|
+
// FUNCTION: logExecution
|
|
109
|
+
// PURPOSE: Standard execution logging for SOC 2 compliance
|
|
110
|
+
// USAGE: Call at start and end of every regulated function
|
|
111
|
+
// ============================================================
|
|
112
|
+
|
|
113
|
+
void logExecution(String functionName, String triggerType, String status,
|
|
114
|
+
String inputParams, String outputResult, String errorMessage,
|
|
115
|
+
List recordsAffected, DateTime startTime)
|
|
116
|
+
{
|
|
117
|
+
endTime = zoho.currenttime;
|
|
118
|
+
|
|
119
|
+
// Calculate duration
|
|
120
|
+
durationMs = ((endTime.toLong() - startTime.toLong()));
|
|
121
|
+
|
|
122
|
+
// Generate execution ID
|
|
123
|
+
executionId = "EXEC-" + startTime.toString("yyyyMMdd-HHmmss") + "-" + (randomNumber(1000, 9999)).toString();
|
|
124
|
+
|
|
125
|
+
// Sanitize input params (remove sensitive fields)
|
|
126
|
+
sanitizedInput = sanitizeForLogging(inputParams);
|
|
127
|
+
|
|
128
|
+
// Insert log record
|
|
129
|
+
insert into Deluge_Execution_Log [
|
|
130
|
+
Execution_ID = executionId,
|
|
131
|
+
Function_Name = functionName,
|
|
132
|
+
Trigger_Type = triggerType,
|
|
133
|
+
User_Email = zoho.loginuserid,
|
|
134
|
+
Timestamp_Start = startTime,
|
|
135
|
+
Timestamp_End = endTime,
|
|
136
|
+
Duration_MS = durationMs,
|
|
137
|
+
Input_Params = sanitizedInput,
|
|
138
|
+
Output_Result = outputResult,
|
|
139
|
+
Status = status,
|
|
140
|
+
Error_Message = errorMessage,
|
|
141
|
+
Records_Affected = recordsAffected.toString(),
|
|
142
|
+
Form_Context = functionName.getSuffix("_"),
|
|
143
|
+
Environment = "Production",
|
|
144
|
+
Severity = if(status == "Failure", "Error", if(status == "Warning", "Warning", "Info"))
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ============================================================
|
|
149
|
+
// FUNCTION: sanitizeForLogging
|
|
150
|
+
// PURPOSE: Remove sensitive data before logging
|
|
151
|
+
// ============================================================
|
|
152
|
+
|
|
153
|
+
String sanitizeForLogging(String rawInput)
|
|
154
|
+
{
|
|
155
|
+
// Remove known sensitive field patterns
|
|
156
|
+
sanitized = rawInput;
|
|
157
|
+
sensitiveFields = {"SSN", "DOB", "Password", "CardNumber", "CVV", "AccountNumber"};
|
|
158
|
+
|
|
159
|
+
for each field in sensitiveFields {
|
|
160
|
+
if (sanitized.contains(field)) {
|
|
161
|
+
sanitized = sanitized.replaceAll("\"" + field + "\":\"[^\"]*\"", "\"" + field + "\":\"[REDACTED]\"");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return sanitized;
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Usage Pattern in Business Functions
|
|
170
|
+
|
|
171
|
+
```deluge
|
|
172
|
+
// ============================================================
|
|
173
|
+
// FUNCTION: processInvoiceApproval
|
|
174
|
+
// PURPOSE: Approve invoice and trigger payment workflow
|
|
175
|
+
// CONTEXT: Called on button click in Invoices form
|
|
176
|
+
// ============================================================
|
|
177
|
+
|
|
178
|
+
void processInvoiceApproval(int invoiceId, String approverEmail)
|
|
179
|
+
{
|
|
180
|
+
// START: Capture execution start time
|
|
181
|
+
startTime = zoho.currenttime;
|
|
182
|
+
functionName = "processInvoiceApproval";
|
|
183
|
+
inputParams = "{\"invoiceId\":" + invoiceId + ",\"approver\":\"" + approverEmail + "\"}";
|
|
184
|
+
affectedRecords = List();
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
// Business logic
|
|
188
|
+
invoice = zoho.creator.getRecordById("app", "Invoices", invoiceId);
|
|
189
|
+
|
|
190
|
+
if (invoice.Status != "Pending Approval") {
|
|
191
|
+
logExecution(functionName, "Button", "Warning", inputParams,
|
|
192
|
+
"{\"message\":\"Invoice not in pending state\"}", "", affectedRecords, startTime);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Update invoice
|
|
197
|
+
update = zoho.creator.updateRecord("app", "Invoices", invoiceId, {
|
|
198
|
+
"Status": "Approved",
|
|
199
|
+
"Approved_By": approverEmail,
|
|
200
|
+
"Approval_Date": zoho.currentdate
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
affectedRecords.add(invoiceId);
|
|
204
|
+
|
|
205
|
+
// Trigger payment workflow
|
|
206
|
+
paymentResult = triggerPaymentWorkflow(invoiceId);
|
|
207
|
+
affectedRecords.add(paymentResult.get("payment_id"));
|
|
208
|
+
|
|
209
|
+
// SUCCESS: Log completion
|
|
210
|
+
outputResult = "{\"status\":\"approved\",\"payment_initiated\":" + paymentResult.get("success") + "}";
|
|
211
|
+
logExecution(functionName, "Button", "Success", inputParams, outputResult, "", affectedRecords, startTime);
|
|
212
|
+
|
|
213
|
+
} catch (e) {
|
|
214
|
+
// FAILURE: Log error
|
|
215
|
+
logExecution(functionName, "Button", "Failure", inputParams, "", e.toString(), affectedRecords, startTime);
|
|
216
|
+
|
|
217
|
+
// Re-throw or handle gracefully
|
|
218
|
+
alert "Invoice approval failed. Error has been logged. Please contact support.";
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Log Rotation and Archival
|
|
226
|
+
|
|
227
|
+
### Rotation Strategy
|
|
228
|
+
|
|
229
|
+
| Age | Location | Action |
|
|
230
|
+
|---|---|---|
|
|
231
|
+
| 0-30 days | Creator form (active) | Full access for troubleshooting |
|
|
232
|
+
| 30-90 days | Creator form (archived flag) | Read-only, excluded from default views |
|
|
233
|
+
| 90-365 days | Creator form (compressed views) | Minimal UI access, API queryable |
|
|
234
|
+
| 365+ days | BigQuery (long-term) | Monthly archival, Creator records deletable |
|
|
235
|
+
|
|
236
|
+
### Archival Script
|
|
237
|
+
|
|
238
|
+
```deluge
|
|
239
|
+
// Monthly archival of execution logs older than 90 days
|
|
240
|
+
// Scheduled via Catalyst Cron on Day 3 of each month
|
|
241
|
+
|
|
242
|
+
cutoffDate = zoho.currentdate.subDay(90);
|
|
243
|
+
|
|
244
|
+
oldLogs = zoho.creator.getRecords("app", "Deluge_Execution_Log",
|
|
245
|
+
"(Timestamp_Start < \"" + cutoffDate.toString("yyyy-MM-dd") + "\" && Archived == false)",
|
|
246
|
+
1, 200);
|
|
247
|
+
|
|
248
|
+
for each log in oldLogs {
|
|
249
|
+
// Export to BigQuery via API
|
|
250
|
+
exportToBigQuery(log);
|
|
251
|
+
|
|
252
|
+
// Mark as archived
|
|
253
|
+
zoho.creator.updateRecord("app", "Deluge_Execution_Log", log.get("ID"), {
|
|
254
|
+
"Archived": true,
|
|
255
|
+
"Archive_Date": zoho.currentdate
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Integrating with BigQuery for Analysis
|
|
263
|
+
|
|
264
|
+
### BigQuery Table Schema
|
|
265
|
+
|
|
266
|
+
```sql
|
|
267
|
+
CREATE TABLE `project.dataset.deluge_execution_logs` (
|
|
268
|
+
log_id INT64 NOT NULL,
|
|
269
|
+
execution_id STRING NOT NULL,
|
|
270
|
+
function_name STRING NOT NULL,
|
|
271
|
+
trigger_type STRING,
|
|
272
|
+
user_email STRING NOT NULL,
|
|
273
|
+
timestamp_start TIMESTAMP NOT NULL,
|
|
274
|
+
timestamp_end TIMESTAMP,
|
|
275
|
+
duration_ms INT64,
|
|
276
|
+
input_params STRING, -- JSON
|
|
277
|
+
output_result STRING, -- JSON
|
|
278
|
+
status STRING NOT NULL,
|
|
279
|
+
error_message STRING,
|
|
280
|
+
records_affected STRING, -- JSON array
|
|
281
|
+
form_context STRING,
|
|
282
|
+
client_id STRING NOT NULL,
|
|
283
|
+
environment STRING,
|
|
284
|
+
severity STRING
|
|
285
|
+
)
|
|
286
|
+
PARTITION BY DATE(timestamp_start)
|
|
287
|
+
CLUSTER BY client_id, function_name, status;
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Analysis Queries
|
|
291
|
+
|
|
292
|
+
```sql
|
|
293
|
+
-- Function execution frequency and failure rates
|
|
294
|
+
SELECT
|
|
295
|
+
function_name,
|
|
296
|
+
COUNT(*) as total_executions,
|
|
297
|
+
COUNTIF(status = 'Failure') as failures,
|
|
298
|
+
ROUND(COUNTIF(status = 'Failure') * 100.0 / COUNT(*), 2) as failure_rate_pct,
|
|
299
|
+
AVG(duration_ms) as avg_duration_ms,
|
|
300
|
+
MAX(duration_ms) as max_duration_ms
|
|
301
|
+
FROM `project.dataset.deluge_execution_logs`
|
|
302
|
+
WHERE timestamp_start > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
|
|
303
|
+
GROUP BY function_name
|
|
304
|
+
ORDER BY failure_rate_pct DESC;
|
|
305
|
+
|
|
306
|
+
-- Slowest function executions (performance degradation detection)
|
|
307
|
+
SELECT function_name, execution_id, user_email, duration_ms, timestamp_start
|
|
308
|
+
FROM `project.dataset.deluge_execution_logs`
|
|
309
|
+
WHERE duration_ms > 5000 -- Functions taking more than 5 seconds
|
|
310
|
+
AND timestamp_start > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
|
|
311
|
+
ORDER BY duration_ms DESC
|
|
312
|
+
LIMIT 50;
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Alerting on Anomalous Patterns
|
|
318
|
+
|
|
319
|
+
### Alert Definitions
|
|
320
|
+
|
|
321
|
+
| Alert | Condition | Severity | Response |
|
|
322
|
+
|---|---|---|---|
|
|
323
|
+
| High failure rate | >10% failures in 1 hour | Critical | Investigate immediately |
|
|
324
|
+
| Function not running | Expected scheduled function missing | High | Check Catalyst cron |
|
|
325
|
+
| Unusual user | Function executed by unexpected user | High | Verify authorization |
|
|
326
|
+
| Performance degradation | Avg duration > 2x baseline | Medium | Performance review |
|
|
327
|
+
| Volume anomaly | >3x normal execution volume | Medium | Investigate trigger |
|
|
328
|
+
| After-hours execution | Execution outside business hours | Low | Review if expected |
|
|
329
|
+
|
|
330
|
+
### Alert Implementation
|
|
331
|
+
|
|
332
|
+
```deluge
|
|
333
|
+
// Scheduled check: Run every hour
|
|
334
|
+
// Count failures in the last hour
|
|
335
|
+
|
|
336
|
+
failures = zoho.creator.getRecords("app", "Deluge_Execution_Log",
|
|
337
|
+
"(Status == \"Failure\" && Timestamp_Start >= \"" + zoho.currenttime.subHour(1).toString("yyyy-MM-dd HH:mm:ss") + "\")",
|
|
338
|
+
1, 200);
|
|
339
|
+
|
|
340
|
+
totalLastHour = zoho.creator.getRecords("app", "Deluge_Execution_Log",
|
|
341
|
+
"(Timestamp_Start >= \"" + zoho.currenttime.subHour(1).toString("yyyy-MM-dd HH:mm:ss") + "\")",
|
|
342
|
+
1, 200);
|
|
343
|
+
|
|
344
|
+
if (totalLastHour.size() > 0) {
|
|
345
|
+
failureRate = (failures.size() * 100) / totalLastHour.size();
|
|
346
|
+
|
|
347
|
+
if (failureRate > 10) {
|
|
348
|
+
sendmail [
|
|
349
|
+
to: "alerts@cloudstreamsoftware.com",
|
|
350
|
+
subject: "CRITICAL: High Deluge failure rate - " + failureRate + "%",
|
|
351
|
+
message: "Failure rate of " + failureRate + "% detected in the last hour.\n" +
|
|
352
|
+
"Total executions: " + totalLastHour.size() + "\n" +
|
|
353
|
+
"Failures: " + failures.size() + "\n" +
|
|
354
|
+
"Investigate immediately."
|
|
355
|
+
];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## Log Access Controls
|
|
363
|
+
|
|
364
|
+
### Who Can Access Execution Logs
|
|
365
|
+
|
|
366
|
+
| Role | View Logs | Export Logs | Delete Logs | Modify Logs |
|
|
367
|
+
|---|---|---|---|---|
|
|
368
|
+
| System Admin | YES | YES | NO (archival only) | NO |
|
|
369
|
+
| Auditor | YES | YES | NO | NO |
|
|
370
|
+
| Developer | YES (own executions) | NO | NO | NO |
|
|
371
|
+
| Standard User | NO | NO | NO | NO |
|
|
372
|
+
| Service Account | Write-only (insert) | NO | NO | NO |
|
|
373
|
+
|
|
374
|
+
> **WARNING**: Execution logs must be immutable once written. No user, including administrators, should be able to modify or delete log entries. Configure form permissions accordingly -- remove Edit and Delete permissions for all roles on the Deluge_Execution_Log form.
|
|
375
|
+
|
|
376
|
+
### Implementation
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
Creator → Form Properties → Deluge_Execution_Log → Permissions:
|
|
380
|
+
- Admin: View only (no Edit, no Delete)
|
|
381
|
+
- All other roles: No access
|
|
382
|
+
- Workflows: Add only (for logging functions)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Standards for New Deluge Functions
|
|
388
|
+
|
|
389
|
+
### Every new Deluge function in a regulated application MUST:
|
|
390
|
+
|
|
391
|
+
1. Call `logExecution()` on success
|
|
392
|
+
2. Call `logExecution()` on failure (in catch block)
|
|
393
|
+
3. Sanitize sensitive data before logging
|
|
394
|
+
4. Include function name as a string constant
|
|
395
|
+
5. Capture start time at function entry
|
|
396
|
+
6. List all affected record IDs
|
|
397
|
+
7. Include meaningful output description
|
|
398
|
+
|
|
399
|
+
### Code Review Checklist for Logging
|
|
400
|
+
|
|
401
|
+
- [ ] Function has try/catch with logging in both paths
|
|
402
|
+
- [ ] Input parameters are sanitized (no PII/PHI in logs)
|
|
403
|
+
- [ ] Execution ID is unique and traceable
|
|
404
|
+
- [ ] Duration is captured accurately
|
|
405
|
+
- [ ] All modified records are listed in affected records
|
|
406
|
+
- [ ] Error messages are descriptive but not exposing internals
|
|
407
|
+
- [ ] Log severity is appropriate (Info/Warning/Error/Critical)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: consultancy-workflows
|
|
3
|
+
description: CloudStream consultancy workflow patterns. Covers client isolation, time tracking, documentation automation, knowledge capture, and handoff procedures.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
status: active
|
|
6
|
+
introduced: 1.0.0
|
|
7
|
+
lastUpdated: 2026-01-25
|
|
8
|
+
activation: Client context, billing, handoff tasks, new client setup, time tracking
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Consultancy Workflows
|
|
12
|
+
|
|
13
|
+
Patterns for managing multiple client engagements at CloudStream Software LLC.
|
|
14
|
+
|
|
15
|
+
## Core Principles
|
|
16
|
+
- Every action is billable client work - track everything
|
|
17
|
+
- Client data isolation is non-negotiable
|
|
18
|
+
- Documentation enables smooth handoffs between partners
|
|
19
|
+
- Knowledge capture benefits all future engagements
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Client Isolation
|
|
2
|
+
|
|
3
|
+
## Credential Separation
|
|
4
|
+
- Each client has a dedicated .env.client file (gitignored)
|
|
5
|
+
- Never mix Zoho org credentials across clients
|
|
6
|
+
- Use /client-switch command to load correct context
|
|
7
|
+
- Verify active client before any API operations
|
|
8
|
+
|
|
9
|
+
## Repository Strategy
|
|
10
|
+
- One repo per client engagement
|
|
11
|
+
- Shared utilities in a private CloudStream npm package
|
|
12
|
+
- Client-specific CLAUDE.md in each repo
|
|
13
|
+
- Never reference other client data in commits
|
|
14
|
+
|
|
15
|
+
## Context Switching
|
|
16
|
+
When switching clients:
|
|
17
|
+
1. Run /client-switch [client-id]
|
|
18
|
+
2. Verify correct Zoho org ID loaded
|
|
19
|
+
3. Confirm compliance mode is correct
|
|
20
|
+
4. Check recent git log for context
|
|
21
|
+
5. Load client-specific CLAUDE.md
|