Files
treg/plugins
Jason ZhouandClaude Opus 5.5 fd5a2c0033 fix: stop billing empty answers, make /admin/errors read-only, add treg --json call (#675)
* fix(billing): stop charging for empty and company-blind answers

Per-result searches settled at the requested page size even when the
vendor returned nothing: count the billed rows for CompanyEnrich (2-credit
minimum), Findymail employees, Icypeas bulk (FOUND only), TheCompaniesAPI
search (and simplified=true, which is free) and Serpstat (error envelopes
free, 1-credit minimum on an empty result). Icypeas profile-URL misses
settle at zero through an expect rule.

Routing: Prospeo 400 NO_RESULTS is a declared miss, not a caller fault;
the CompanyEnrich scroll adapter is removed so one empty question is not
routed twice; people.search declares scoping: [company_domain], so a
title-only provider is dropped from a company-scoped plan instead of
billing title-matched strangers once the others miss.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TMPFwsMRowa1X7kXc5nZyw

* fix(admin): make GET /admin/errors read-only; purge evidence from a worker

Loading the errors page ran a platform-wide UPDATE blanking failed-call
evidence past the 14-day window. The purge moves to
application/evidence_retention.py behind 'treg-worker admin
purge-evidence', in bounded id batches. The view withholds evidence past
the window itself, so an unscheduled purge never widens what it shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TMPFwsMRowa1X7kXc5nZyw

* feat(cli): treg --json call prints one parseable envelope

With --json, call prints {"result": <body>, "_treg": {http_status,
call_id, charged_micro|reserved_micro, ...}} on one line and nothing on
stderr, so a script that merges the streams still parses every answer.
Default output and --await are unchanged. Agent docs say to use it when
parsing, and to check a few results before looping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TMPFwsMRowa1X7kXc5nZyw

* fix(billing): price counted rows at their credits and cap them at the hold

For a credit-priced per_result row the frozen unit is one provider credit,
so counting rows alone under-billed CompanyEnrich (2 credits a person, and
its 2-credit minimum) and Icypeas reverse-email bulk (10 a hit). Rows whose
catalog unit names an input entity reserve per thing asked about, so a row
count is capped at the hold: counting may lower a bill, never raise it.
simplified=true is free only on TheCompaniesAPI endpoints that declare it.

Also: a malformed contract scoping list fails the catalog load; --json
call keeps stderr silent on the WAF base64 retry; AGENTS.md records the
evidence-retention purge as the second callrecord writer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TMPFwsMRowa1X7kXc5nZyw

* fix(billing): bill Icypeas company scrapes at the company rate; never exceed a zero hold

Also corrects the AGENTS.md callrecord-writer note and the scoping
comment (a bad list empties routing rather than failing the catalog).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TMPFwsMRowa1X7kXc5nZyw

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-25 20:48:54 +10:00
..