Skip to content

[AISAGE-503] feat(ai-gateway): add unused usage enqueue helper - #7295

Merged
johnnyeric merged 1 commit into
mainfrom
johnnyeric/usage-shadow-publisher
Oct 8, 2026
Merged

johnnyeric merged 1 commit into
mainfrom
johnnyeric/usage-shadow-publisher

Conversation

@johnnyeric

Copy link
Copy Markdown
Contributor

Summary

Add an unused enqueueUsage helper that sends the complete shared usage event to the authenticated usage-ingest endpoint. Missing endpoint or dedicated publisher secret returns disabled without network activity. A single request has a two-second timeout; only HTTP 202 returns accepted. Failures report only the usage ID and a categorical reason.

Verification

  • Called the helper with synthetic data against the actual locally configured Worker; received HTTP 202 and one local queue receipt with an identical payload and ID.
  • Called the helper with configuration absent; observed disabled, zero network calls and no additional queue receipt. Closed the fixture and confirmed its port was released.

Visual Changes

N/A

Reviewer Notes

The helper has no gateway callers. Queue acceptance does not establish billing completion; this change adds no consumer or inference/billing integration.

Validation: 12 focused Jest cases, shared-package and gateway typechecks, scoped type-aware lint, formatting and diff checks. Cases cover dedicated authentication, exact payload preservation, missing/malformed configuration, non-202 responses, a real stalled HTTP request and rejected response-body cleanup. Failure logs require exactly one safe warning; negative controls adding URL/secret warnings on HTTP refusal or timeout fail the tests.

@johnnyeric johnnyeric changed the title feat(ai-gateway): add unused usage enqueue helper [AISAGE-503] feat(ai-gateway): add unused usage enqueue helper Oct 8, 2026
@johnnyeric
johnnyeric added this pull request to stack #7298 October 8, 2026 13:48
@johnnyeric
johnnyeric marked this pull request as ready for review October 8, 2026 13:50
@kilo-code-bot

kilo-code-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • ENVIRONMENT.md
  • packages/web-shared/src/lib/ai-gateway/usage-publisher.test.ts
  • packages/web-shared/src/lib/ai-gateway/usage-publisher.ts
  • packages/web-shared/src/lib/config.server.ts

Reviewed by deepseek-v4.1-flash · Input: 71K · Output: 17.7K · Cached: 738K

Review guidance: REVIEW.md from base branch main

@joshburt
joshburt self-requested a review October 8, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants