intelligence-radar/workplans/IR-WP-0006-billing-reconciliation.md
tegwick ff261512cc Point the billing wait at the missing provider artifact.
IR-WP-0005-T02 is done, and the key check is not billing evidence for the reserved run.

Assistant: grok
Assistant-Session: 01a10938-ab49-7280-877a-c06f64c06ddd
2026-10-05 01:38:14 +02:00

4.7 KiB

id type title domain repo status flavor owner topic_slug origin origin_ref created updated state_hub_workstream_id
IR-WP-0006 workplan Reconcile trial billing and establish campaign accounting infotech intelligence-radar blocked implementation codex custodian residual IR-WP-0004 2026-09-14 2026-10-05 b877f5e2-0c0e-5bca-9082-873eab857ada

Created before closure of IR-WP-0004 at the user's request to separate credential delivery from billing. Source files own the work; cross-repository owner plans retain authority over native changes. Review baseline: docs/evidence/2026-09-14-ir-wp-0004-review.md.

Specify independent billing evidence and reconciliation contract

id: IR-WP-0006-T01
status: done
priority: high
state_hub_task_id: "87b26b10-f4d6-5c53-9965-fae61ac0df11"

Inventory the append-only events for ir-openrouter-pilot-20260913. Preserve the USD 0.023712 pending reservation and USD 10 total authorization. Define how provider billing evidence matches the failed request, what is unknown, who reviews a settlement, and how discrepancies are retained. HTTP 401 alone is not zero-charge proof. Accounting design can proceed independently of credential delivery; provider evidence retrieval may require an admitted read-only path.

Done: contract specified in docs/evidence/2026-09-27-ir-wp-0006-t01-reconciliation-contract.md — inventories the one pending reservation, defines valid billing evidence, the run_id-based match, the five refusal conditions, and what a settlement record must (and must not) contain.

Implement and verify auditable reconciliation

id: IR-WP-0006-T02
status: done
priority: high
state_hub_task_id: "1637f2ee-2369-5e78-8893-9437d2d6b6fc"

Provide a reviewed append-only settlement procedure or command. Preserve original reservations; reject duplicate/conflicting settlement, unknown reservation, invalid amount, cross-campaign references and budget overrun. Retain source billing evidence and reviewer attribution without credentials. Test uncertain/partial evidence and restart behavior. Do not fabricate a completed model trial to settle a failed request.

Done: intelligence_radar.trials.reconcile (+ CLI reconcile) implements the T01 contract — write-once settlement under the existing trials file lock, all five refusal conditions covered, no trials record fabricated. Tests in tests/test_trials.py (test_reconcile_*, 9 new cases) cover unknown reservation, duplicate/retry-after-success, cross-campaign, invalid amount, budget overrun, and missing evidence/reviewer attribution. Full suite (make check, 48 tests) passes.

Reconcile the outstanding reservation and hand off budget readiness

id: IR-WP-0006-T03
status: wait
blocked_on: message-from:secrets-engine
blocking_reason: "IR-WP-0005-T02 key check is done and is not a billing artifact. Reconcile stays refused until secrets-engine returns authoritative provider billing for run 29a46a1d6c2d9ef6cfce8de6efef75cddcfecee346c1b4babf57119f1a241d71, or says the admitted read-only path cannot retrieve it."
priority: high
state_hub_task_id: "441dc053-af7b-5a9c-866f-5b1eb804b94f"

Depends on T01/T02 and authoritative provider evidence. Resolve the USD 0.023712 reservation only to the supported actual amount, retaining any unresolved discrepancy explicitly. Rerender pilot/full plans for the same campaign and report spent, pending and remaining authorized budget. No campaign reset, additional authorization, or paid inference is implied. Completion requires reconciled evidence and a usable accounting handoff, not merely implementation tests.

Blocked: the mechanism is ready (T01/T02 done), but no authoritative provider billing evidence exists for the pending run_id 29a46a1d6c2d9ef6cfce8de6efef75cddcfecee346c1b4babf57119f1a241d71 yet. Applying reconcile here without that evidence would be exactly the fabrication this workplan forbids. Waits on external evidence (likely via the IR-WP-0005 admitted read-only path).

Rechecked 2026-10-04: the ledger still has the one reserved event for 29a46a1d6c2d9ef6cfce8de6efef75cddcfecee346c1b4babf57119f1a241d71 and no provider billing artifact. IR-WP-0005-T02 passed on 2026-10-04: the pinned recipient key check returned authenticated with HTTP 200. That check is not a billing artifact for run 29a46a1d6c2d9ef6cfce8de6efef75cddcfecee346c1b4babf57119f1a241d71. reconcile was not called. Stays wait.

2026-10-05: IR-WP-0005-T02 is terminal, so the dependency edge no longer describes the blocker. The wait is now an owner return from secrets-engine for the billing artifact, or for a statement that the admitted read-only path cannot retrieve it. Asked in message 79fff37d-aad5-4edd-bc55-b7df86b51cc5. reconcile was not called.