Skip to content

feat(ai-gateway): add Token Forge traffic policy - #16

Merged
margrop merged 1 commit into
mainfrom
agent/p4-004-token-forge-ai-guardrails
Jul 26, 2026
Merged

margrop merged 1 commit into
mainfrom
agent/p4-004-token-forge-ai-guardrails

Conversation

@margrop

@margrop margrop commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • add the versioned token-forge-ai-policy-v1 contract and fixture
  • add a provider-neutral admission ledger for actor/Lab/site token and micro-USD daily budgets, sliding rate limits, concurrency reservations, idempotency, and circuit breaking
  • reserve worst-case cost for both permitted Provider attempts, refund only trusted successful usage, and charge failures or expired reservations in full
  • map denials to the existing privacy-safe AI Gateway failure envelope
  • document the P1-008 atomic persistence, anonymous actor-key, pricing, and all-attempt settlement requirements
  • mark P4-004 complete and make P1-008 the sole recommended next task

Validation

  • git diff --check
  • XDG_CONFIG_HOME=/tmp/margrop-labs-config npm run validate
  • 22 test files / 260 tests passed
  • Astro diagnostics: 0 errors, warnings, or hints
  • static build and all deployment-output checks passed

Privacy and cost

  • snapshots cannot contain goals, prompts, plans, repository URLs, paths, bodies, raw network identifiers, credentials, or Provider errors
  • anonymous actors use only server-derived opaque keys
  • no network, logging, persistence, Provider, secret, endpoint, or production deployment is added
  • P1-008 must persist each admission/settlement atomically and aggregate billable usage across all Provider attempts before real AI is enabled

Known limits

  • this PR provides the offline policy state machine only
  • there is no Provider Adapter, HTTP route, identity derivation, price registry, durable storage, page AI entry, or production deployment yet
  • the current public page remains on its deterministic template path

@margrop
margrop marked this pull request as ready for review July 26, 2026 09:50
@margrop
margrop merged commit e07e122 into main Jul 26, 2026
1 check passed
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.

1 participant