Encode chargeable social scrape states
Social scrape results currently allow a run ID and failure to coexist, so callers infer chargeability from nullable fields and persistence needs a cast. This change makes attempts explicitly started or failed, bills and registers only started runs, and keeps the existing batch and single-social HTTP response shapes, pricing, and debit ordering. A malformed provider result without a run ID now becomes a failed attempt; unsupported platforms still return null internally.
The regression gate checks both contradictory type examples and the actual constructors/consumers under strict null checks, scoped to the five changed modules. Route fixtures exercise the real POST exports through dispatch and the deduction wrapper with synthetic accounts, providers, and persistence. The full-report parse-failure check also identifies the failed section's runtime and verifies it is never charged. lib/apify/README.md records entry routes, expectations, and fixture limits.
Known pre-existing redaction follow-up: Cubic's P2 finding identifies raw provider exception text in the public response. In both baseline 067238da and this PR, scrapeProfileUrl copies error.message, the artist batch serializes that error, and the single-social handler returns it. These unchanged paths may expose provider or backend details. This structural refactor deliberately preserves existing response behavior; the fixture assertion documents that behavior and does not endorse it as safe. Replacing public exception text with a generic message, retaining diagnostic detail server-side, and updating both endpoint contracts and tests remains a separate, unresolved redaction follow-up.
Validation:
- Frozen-lockfile dependency install; 37 focused tests passed.
- Exact-head GitHub CI unit suite passed: 1,187 files passed, 11 skipped; 6,440 tests passed, 13 skipped. CI format, lint, and MCP OAuth compatibility also passed.
- Repository lint, changed-file formatting, and
git diff --checkpassed. - Deliberate duplicate debit, widened started/error type, and actual
startedconstructor withrunId: nulleach failed the relevant regression gate; mutations restored. - Full TypeScript check has the same 196 pre-existing diagnostics as clean main
067238dawith matching locked dependencies; no new diagnostics. The focused strict-null gate passes.
Local commands ran on Node 23.6.1; CI uses its configured runtime. Fixture checks make no provider requests or real charges and do not verify deployed HTTP authentication or account balances.