id: excel-spreadsheet-data-drift-and-integrity-sentinel
namespace: company.finops
inputs:
- id: minimum_rows_threshold
type: INT
defaults: 6
description: Minimum combined record count expected across all audited
spreadsheet sheets.
- id: simulate_corrupted_workbook
type: BOOL
defaults: false
description: When true, triggers a simulated schema defect to verify quarantine
and alerting.
- id: reporting_currency
type: STRING
defaults: USD
description: Baseline functional currency validated across financial reporting sheets.
variables:
alerts_channel: "#finops-alerts"
triggers:
- id: schedule_periodic_spreadsheet_audit
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 * * * *"
tasks:
- id: stage_sample_revenue_sheet
type: io.kestra.plugin.core.storage.Write
extension: ".ion"
content: >-
{deal_id: "D-801", client: "Acme Corp", gross_revenue: 125000.00,
currency: "USD", quarter: "Q4", status: "CLOSED"} {deal_id: "D-802",
client: "Globex Ltd", gross_revenue: 89400.50, currency: "USD", quarter:
"Q4", status: "CLOSED"} {deal_id: "D-803", client: "Initech LLC",
gross_revenue: 43200.00, currency: "USD", quarter: "Q4", status:
"PENDING"}
- id: stage_sample_expense_sheet
type: io.kestra.plugin.core.storage.Write
extension: ".ion"
content: >-
{expense_id: "EXP-101", department: "Engineering", vendor: "Cloud Hosting
Inc", amount: 28400.00, currency: "USD", approved: true} {expense_id:
"EXP-102", department: "Marketing", vendor: "Global Ad Network", amount:
14500.00, currency: "USD", approved: true} {expense_id: "EXP-103",
department: "Sales", vendor: "CRM SaaS Platform", amount: 9800.00,
currency: "USD", approved: false}
- id: compile_canonical_workbook
type: io.kestra.plugin.serdes.excel.IonToExcel
from:
Q4_Revenue: "{{ outputs.stage_sample_revenue_sheet.uri }}"
Cost_Center_Expenses: "{{ outputs.stage_sample_expense_sheet.uri }}"
- id: extract_and_audit_excel_workbook
type: io.kestra.plugin.serdes.excel.ExcelToIon
from: "{{ outputs.compile_canonical_workbook.uri }}"
sheetsTitle:
- Q4_Revenue
- Cost_Center_Expenses
header: true
skipEmptyRows: true
- id: recompile_verification_workbook
type: io.kestra.plugin.serdes.excel.IonToExcel
from:
Verified_Revenue: "{{ outputs.extract_and_audit_excel_workbook.uris.Q4_Revenue }}"
Verified_Expenses: "{{
outputs.extract_and_audit_excel_workbook.uris.Cost_Center_Expenses }}"
- id: classify_spreadsheet_health
type: io.kestra.plugin.core.execution.Labels
labels:
audit_verdict: >-
{{ (inputs.simulate_corrupted_workbook ? 'CRITICAL_WORKBOOK_CORRUPTION'
: (((outputs.extract_and_audit_excel_workbook.size | default(0)) >=
inputs.minimum_rows_threshold and
outputs.extract_and_audit_excel_workbook.uris.Q4_Revenue != null and
outputs.extract_and_audit_excel_workbook.uris.Cost_Center_Expenses !=
null) ? 'COMPLIANT_SPREADSHEET' : 'WARNING_THRESHOLD_DEFICIT')) }}
- id: handle_integrity_verdict
type: io.kestra.plugin.core.flow.Switch
value: "{{ taskrun.labels.audit_verdict }}"
cases:
CRITICAL_WORKBOOK_CORRUPTION:
- id: alert_corrupted_workbook
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ vars.alerts_channel }}",
"text": "CRITICAL: Excel financial spreadsheet corruption or missing required tabs detected. Audit failed compliance checks. Quarantine artifact generated. Execution ID: {{ execution.id }}"
}
- id: quarantine_corrupted_workbook
type: io.kestra.plugin.core.storage.Write
extension: ".json"
content: |
{
"quarantine_reason": "Missing required worksheet tabs or structural spreadsheet corruption",
"execution_id": "{{ execution.id }}",
"quarantined_at": "{{ execution.startDate }}",
"workbook_uri": "{{ outputs.compile_canonical_workbook.uri }}",
"extracted_records": {{ outputs.extract_and_audit_excel_workbook.size | default(0) }}
}
WARNING_THRESHOLD_DEFICIT:
- id: notify_row_deficit_warning
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ vars.alerts_channel }}",
"text": "WARNING: Financial spreadsheet record count below threshold. Extracted {{ outputs.extract_and_audit_excel_workbook.size | default(0) }} records across sheets, expected minimum of {{ inputs.minimum_rows_threshold }}. Execution ID: {{ execution.id }}"
}
COMPLIANT_SPREADSHEET:
- id: notify_spreadsheet_compliant
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ vars.alerts_channel }}",
"text": "SUCCESS: Financial spreadsheet audit completed with 100% round-trip fidelity. Extracted {{ outputs.extract_and_audit_excel_workbook.size }} records across Q4_Revenue and Cost_Center_Expenses. Verified workbook ready at {{ outputs.recompile_verification_workbook.uri }}. Execution ID: {{ execution.id }}"
}
- id: log_financial_audit_ledger
type: io.kestra.plugin.core.log.Log
message: |
Financial Excel Spreadsheet Audit Ledger:
Audit Verdict: {{ taskrun.labels.audit_verdict }}
Total Records Extracted: {{ outputs.extract_and_audit_excel_workbook.size | default(0) }}
Canonical Workbook URI: {{ outputs.compile_canonical_workbook.uri }}
Verified Workbook URI: {{ outputs.recompile_verification_workbook.uri }}
Revenue Sheet Ion URI: {{ outputs.extract_and_audit_excel_workbook.uris.Q4_Revenue | default('N/A') }}
Expense Sheet Ion URI: {{ outputs.extract_and_audit_excel_workbook.uris.Cost_Center_Expenses | default('N/A') }}
Execution ID: {{ execution.id }}
Timestamp: {{ execution.startDate }}