Workflow reconciliation reports
Reconciliation compares expected work with observed execution and the final provider result. A monitoring check can find failed runs while missing work that never reached FastHook. A succeeded run can also skip a branch, handle an error, or create a result that needs a later provider-side check.
Choose what should match
| Identifier | Use | Limit |
|---|---|---|
| FastHook request ID + Workflow ID | Match one captured input to the Workflow that should process it. | One Source can intentionally feed several Workflows. A second Workflow is not automatically a duplicate. |
| Provider event ID | Compare provider delivery with captured input. | May require provider logs or authorized request inspection; it is not necessarily the FastHook request ID. |
| Stable business ID | Compare the intended order, ticket, invoice, or record. | Must survive mapping and appear in the provider result or a separate ledger. |
| Provider object ID | Verify the final Action result. | A successful API response can still require asynchronous processing or later verification. |
Time is an interval filter, not a unique join key. Record the selected team, Source, Workflow, and absolute time window. Use Run history to investigate individual differences and inspect the version and recovery history of each run.
Prepare a request ledger
The script below compares one Workflow against actual FastHook request IDs. Save expected.jsonl with one object per expected request:
{"request_id":"req_example_1001"}
{"request_id":"req_example_1002"}Replace these invented IDs with identifiers recorded by your producer or authorized ingress evidence. Do not substitute provider event IDs or business IDs. Keep a separate private join ledger if the source of truth uses those identifiers. This example does not reconcile scheduled executions without request IDs.
Set FASTHOOK_API_KEY to a scoped key with Read, FASTHOOK_TEAM_ID to its owning team, FASTHOOK_SOURCE_ID, FASTHOOK_WORKFLOW_ID, and FASTHOOK_WINDOW_FROM to an absolute ISO timestamp. FASTHOOK_WINDOW_TO is optional and defaults once to the start of the check. Store credentials in the caller's secret manager.
Collect all pages and compare one Workflow
Save as fasthook-reconcile.mjs and run with a supported Node.js release that provides built-in fetch. Pass the ledger path as the first argument, or use the default expected.jsonl.
import { readFile } from "node:fs/promises";
class ReportError extends Error {}
async function main() {
const env = process.env;
const key = env.FASTHOOK_API_KEY;
const team = env.FASTHOOK_TEAM_ID;
const source = env.FASTHOOK_SOURCE_ID;
const workflow = env.FASTHOOK_WORKFLOW_ID;
const from = env.FASTHOOK_WINDOW_FROM;
const to = env.FASTHOOK_WINDOW_TO || new Date().toISOString();
const validTime = (v) => typeof v === "string" && /^\d{4}-\d{2}-\d{2}T/.test(v)
&& Number.isFinite(Date.parse(v));
if (!key || !team || !source || !workflow || !validTime(from)
|| !validTime(to) || Date.parse(from) > Date.parse(to)) {
throw new ReportError("invalid_configuration");
}
const bytes = await readFile(process.argv[2] || "expected.jsonl");
if (bytes.length > 1_048_576) throw new ReportError("ledger_too_large");
const expected = new Set();
for (const line of bytes.toString("utf8").split(/\r?\n/).filter((s) => s.trim())) {
let row;
try { row = JSON.parse(line); } catch { throw new ReportError("invalid_ledger"); }
if (!row || typeof row.request_id !== "string" || !row.request_id.startsWith("req_")
|| expected.has(row.request_id)) throw new ReportError("invalid_or_repeated_request_id");
expected.add(row.request_id);
}
if (!expected.size) throw new ReportError("empty_ledger");
const deadline = Date.now() + 60_000;
const seenCursors = new Set();
const runs = new Map();
let cursor = null;
let pages = 0;
do {
if (pages >= 100) throw new ReportError("page_limit_exceeded");
const remaining = deadline - Date.now();
if (remaining <= 0) throw new ReportError("deadline_exceeded");
const query = new URLSearchParams({ source_id: source, from, to, limit: "100" });
if (cursor) query.set("cursor", cursor);
const response = await fetch(`https://api.fasthook.io/v1/workflow-activity?${query}`, {
headers: { authorization: `Bearer ${key}`, "x-team-id": team, accept: "application/json" },
redirect: "error",
signal: AbortSignal.timeout(Math.min(15_000, remaining))
});
if (!response.ok) throw new ReportError(`http_${response.status}`);
const data = await response.json();
if (!data || !Array.isArray(data.models) || data.models.length > 100
|| data.count !== data.models.length
|| !(data.next_cursor === null || (typeof data.next_cursor === "string"
&& data.next_cursor.length > 0 && data.next_cursor.length <= 1024))) {
throw new ReportError("invalid_activity_response");
}
for (const run of data.models) {
if (!run || typeof run.id !== "string" || !run.id.startsWith("wfr_")
|| typeof run.workflow_id !== "string"
|| !["queued", "running", "succeeded", "failed"].includes(run.status)) {
throw new ReportError("invalid_run_summary");
}
if (run.workflow_id !== workflow) continue;
if (typeof run.request_id !== "string" || !run.request_id.startsWith("req_")) {
throw new ReportError("request_based_run_required");
}
runs.set(run.id, { id: run.id, request_id: run.request_id, status: run.status });
}
pages += 1;
cursor = data.next_cursor;
if (cursor) {
if (seenCursors.has(cursor)) throw new ReportError("repeated_cursor");
seenCursors.add(cursor);
}
} while (cursor);
const byRequest = new Map();
for (const run of runs.values()) {
const list = byRequest.get(run.request_id) || [];
list.push(run);
byRequest.set(run.request_id, list);
}
const rows = [...expected].map((request_id) => {
const matches = byRequest.get(request_id) || [];
const outcome = !matches.length ? "missing_in_window"
: matches.length > 1 ? "multiple_runs_review_required"
: ["queued", "running"].includes(matches[0].status) ? "in_progress"
: matches[0].status;
return { request_id, outcome, runs: matches };
});
const unexpected = [...runs.values()].filter((r) => !expected.has(r.request_id));
const matched = rows.every((row) => row.outcome === "succeeded") && !unexpected.length;
console.log(JSON.stringify({
schema_version: 2,
generated_at: new Date().toISOString(),
workflow_id: workflow,
window: { from, to },
status: matched ? "observed_runs_match" : "differences",
provider_outcome_verified: false,
pages, rows, unexpected
}));
process.exitCode = matched ? 0 : 2;
}
await main().catch((error) => {
console.error(JSON.stringify({
schema_version: 2,
status: "report_error",
code: error instanceof ReportError ? error.message : "read_or_request_failed"
}));
process.exitCode = 3;
});The script reads all available pages within a 100-page/60-second request budget, then compares the selected Workflow only. It deduplicates repeated run IDs across pages. Several distinct run IDs for the same request and Workflow require review: they can represent a deliberate rerun or recovery, not necessarily duplicated business effects.
Exit 0 means the observed run summaries match this ledger; it does not verify provider outcomes. Exit 2 means differences need review. Exit 3 means collection or input validation failed and no complete comparison report was produced. Keep reports private: request/run IDs are operational identifiers even though credentials, payloads, and provider error text are excluded. Apply an overall scheduler process timeout as well.
Understand the comparison window
Activity filters run creation time, not provider event time or failure time. Choose a window that covers the expected creation interval, timezone offsets, delayed ingestion, and later recovery runs. A missing result means not observed in this query, not proof that the provider never sent the event.
Keep the same absolute window and filters across every next_cursor; stop at null. The view is not a transactional snapshot: statuses can change during collection. Recheck pending work and allow an appropriate settling interval. A key cannot retrieve Workflow configuration or full run detail, so investigate differences through an authorized dashboard session.
Verify the business result and decide recovery
| Difference | Next investigation |
|---|---|
| Missing in window | Confirm IDs, team, Source, Workflow, interval, captured request, and activation before concluding work was lost. |
| Failed or in progress | Open Run history; inspect the first failure, automatic retries, Delay, and current state. |
| Multiple runs for one Workflow | Compare versions and recovery history, then inspect provider object IDs and idempotency evidence. |
| Unexpected request for the chosen Workflow | Check whether the expected ledger covers the complete queried interval and intended input set. |
| Succeeded but provider object missing or repeated | Inspect skipped/handled routes, mapping, asynchronous processing, and stable business IDs before repeating an Action. |
Use a provider export, authenticated provider API, or system-of-record ledger to compare the intended object, key fields, and count. Do not copy provider tokens into mappings or reports. Reconciliation is read-only evidence; any retry, full rerun, compensation, access change, or graph edit needs its own deliberate recovery decision. Continue with Incident response, Runs & errors, Monitoring, and Security and governance.