Repository navigation
Conversation
Every gateway run waited out the 5 s drain deadline and then printed "N invocation(s) remain without acknowledged authoritative telemetry", because the gateway's authoritative receipts are not enabled and no receipt ever arrives. The receipt feed now has to advertise `x-baro-billing-receipts: authoritative` for the drain to keep waiting. Without it, Baro still ingests whatever one feed pass started inside drain() returns, then stops and does not report the gap as a reconciliation failure. A gateway that advertises receipts keeps the full bounded wait. Fixes #220 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #220
Summary
This takes the issue's second option: the client learns that receipts are unavailable, then skips the wait and the message. It does this without the rejected "shorten on an empty first pull" heuristic.
Signal.
BillingReceiptFeedClientrecords whether each valid feed page carriesx-baro-billing-receipts: authoritative. It is exposed asfeed.authoritativeReceipts, with the constantsBILLING_RECEIPTS_HEADERandBILLING_RECEIPTS_AUTHORITATIVEexported.Drain.
GatewayBillingCoordinator.drain()stops waiting early when both of these hold:drain()has succeeded without that header. A pull already in flight when drain began does not count.Receipts that pass returns are still ingested and settled as before. A gateway that sends the header keeps the full bounded wait (5 s by default), so reconciliation does not get weaker once receipts are enabled.
Result.
GatewayBillingDrainResultgainsreceiptsUnavailable.completestays honest: unreceipted invocations remain unresolved, so their cost stays unknown and is never recorded as zero.Message.
orchestrate.ts([billing] N invocation(s) remain without acknowledged authoritative telemetry) and the planning helpersrun-planner,run-intake,run-conversationandrun-architect(billing reconciliation incomplete) no longer report whenreceiptsUnavailableis true. Feed errors, timeouts and gateways that advertise receipts still report.Docs.
docs/collective-runtime.mddocuments the header.Why a header rather than inference
Today the gateway proxies
/v1/billing/receiptsto Cloud. Cloud returns a well-formed empty page whether or not authoritative billing is on, so the feed body cannot tell "not enabled" apart from "not arrived yet". The gateway is the only party that knows whether it finalizes receipts (BARO_GATEWAY_BILLING_SECRETis set), so it should say so.Follow-up needed in
baro-gateway(not in this repo)Before or together with enabling authoritative billing,
handleReceiptFeedinbaro-gateway/src/server.mjsshould send the header on feed responses:If billing were enabled without the header, the client would still catch every receipt for completed calls in its final feed pass, because the gateway finalizes a receipt before the model response completes. It would only stop waiting for receipts of calls aborted mid-flight.
Test plan
test/telemetry/billing/gateway-billing-coordinator.test.ts:drainTimeoutMs: 5000, withreceiptsUnavailable: trueand nofeedError.complete: true.receiptsUnavailable: false.drain(), followed by failing pulls, does not conclude that receipts are unavailable.node --test test/telemetry/billing/*.test.ts: 35/35 pass, including the existing coordinator, feed and activation tests.npm run typecheck -w @baro/orchestratorpasses. A separatetsccheck of the four touchedscripts/run-*.tsfiles reports no errors.npm run build -w baro-ai(tsup bundle) succeeds.npm run test:fast: 1640/1647 pass. The 7 failures are inprovider-ownership-manifest,run-architect-awake-budget,verification/command-timingandverification/continuous-gate-runner. These are timing and process-group tests. Run alone, 5 of them still fail on this branch and the same 5 fail withsrc/reset toorigin/main, so they are environmental and predate this change.run-architect-outcomeandconversation/dialogue-responder: 32/33 pass. The Gateway billing test passes; the one failure is the same Codex wall-clock timing issue as above.npm run test:billing-e2e, which needs siblingbaro-cloudandbaro-gatewaycheckouts. Its receipt arrives on the first drain pass, so it should be unaffected.npm testsuite. Both attempts were cut off by the tool's process cleanup before finishing, so only the fast lane and the two slow-lane files above have results.Generated with Devin