/** * Task #385 (HB#236) — on-chain fallback probe for the pop task subgraph-lag * zombie-state bug. Symmetric companion to Task #378's vote/list probe helper. * * Context: `pop task view` and `pop task list` both read from the POP * subgraph, which periodically falls behind the chain by 30+ task IDs * (HB#223 brain lesson: task-list-stuck-at-367 was a 60+ HB unrecognized * symptom of this class of bug). When the subgraph misses a TaskCreated * event, any subsequent call that looks up the task by ID returns * "not found", even though the task exists on-chain. * * This module provides `probeTaskOnChain(taskManagerAddr, taskId, provider)` * which scans recent TaskCreated / TaskClaimed / TaskAssigned / TaskSubmitted / * TaskCompleted / TaskCancelled / TaskRejected events emitted by the * TaskManager contract, reconstructs the latest lifecycle state from the * event stream, and returns a minimal task shape that callers can display * when the subgraph is stale. * * Cost guard: callers should only invoke this when the subgraph returned * "not found" — normal lookups pay zero RPC cost. On cache miss the probe * does a single getLogs call with a ~10_000-block lookback (roughly 12 * hours on Gnosis at 5s blocks), which is the minimum needed to cover the * worst-observed subgraph lag. If the task was created earlier than that, * the probe returns null and the caller should widen the window manually. * * Scope: this is a minimum-viable probe for the "task not found" case. It * does NOT reconstruct applications, per-rejector metadata, or IPFS * metadata — those remain subgraph-exclusive. The probe answers "does * this task exist and what's its current status" only, which is enough * to unblock the agent-verification workflow that hits this bug most. */ import { ethers } from 'ethers'; export type ProbedTaskStatus = 'Created' | 'Claimed' | 'Assigned' | 'Submitted' | 'Completed' | 'Cancelled' | 'Rejected'; export interface ProbedTask { taskId: string; status: ProbedTaskStatus; title?: string; metadataHash?: string; payout?: string; bountyToken?: string; bountyPayout?: string; assignee?: string; claimer?: string; completer?: string; projectId?: string; createdBlock: number; lastEventBlock: number; } /** * Probe the TaskManager contract for a task by ID via event log scanning. * Returns null if the TaskCreated event is not found within the lookback * window (default 10_000 blocks ≈ 12h on Gnosis). */ export declare function probeTaskOnChain(taskManagerAddr: string, taskId: string | number, provider: ethers.providers.Provider, opts?: { lookbackBlocks?: number; }): Promise;