Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions prepaid-compute-credit-breakage-guard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Prepaid Compute Credit Breakage Guard

This module is a focused Revenue Infrastructure slice for issue #20. It evaluates prepaid AI compute and top-up credit lots before finance recognizes expired unused balances as breakage revenue.

The guard keeps protected balances out of revenue, routes open refund obligations to liability review, requires notice and terms evidence before breakage, and emits deterministic audit artifacts for revenue close review.

## What It Checks

- Expired credit lots with explicit breakage terms, customer notice evidence, and closed refund windows.
- Expired lots that must stay on finance hold because evidence is missing or a dispute is active.
- Credits approaching expiration that need a customer notice before close.
- Grant-funded or no-expiration credits that must carry forward.
- Refund-window balances that remain liabilities.
- Usable active balances that should not be recognized.

## Run

```bash
npm run check
npm test
npm run demo
```

Demo artifacts are written under `reports/`, including JSON, Markdown, SVG, and the generated MP4 demo attached in the PR.
18 changes: 18 additions & 0 deletions prepaid-compute-credit-breakage-guard/acceptance-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Acceptance Notes

This contribution intentionally does not create live payment links, invoices, subscriptions, or provider integrations. It is a self-contained control module that can be reviewed without credentials.

Acceptance checks:

- `npm run check` validates all JavaScript files.
- `npm test` covers breakage-ready lots, missing-notice holds, refund liabilities, expiring-soon notices, protected grant credits, active usable credits, and deterministic audit digests.
- `npm run demo` writes reviewer artifacts to `reports/`.
- The PR includes a short demo video generated from the SVG summary.

Non-overlap:

- Not a generic billing ledger.
- Not a usage metering/idempotency guard.
- Not payment webhook or payment rail failover logic.
- Not collections, dispute evidence, tax exemption, plan-proration, storage overage, or account-transfer work.
- Focused only on prepaid AI compute credit breakage and expiration controls.
32 changes: 32 additions & 0 deletions prepaid-compute-credit-breakage-guard/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require("node:fs");
const path = require("node:path");
const {
analyzeCreditBreakage,
renderMarkdownReport,
renderSvgSummary,
} = require("./index");
const { sampleCreditLots } = require("./sample-data");

const reportsDir = path.join(__dirname, "reports");
fs.mkdirSync(reportsDir, { recursive: true });

const result = analyzeCreditBreakage(sampleCreditLots, {
asOf: "2026-05-22T12:00:00.000Z",
expiringSoonDays: 30,
});

fs.writeFileSync(
path.join(reportsDir, "summary.json"),
`${JSON.stringify(result, null, 2)}\n`
);
fs.writeFileSync(
path.join(reportsDir, "reviewer-packet.md"),
renderMarkdownReport(result)
);
fs.writeFileSync(
path.join(reportsDir, "summary.svg"),
renderSvgSummary(result)
);

console.log("prepaid compute credit breakage guard demo artifacts written");
console.log(`audit digest: ${result.auditDigest}`);
Loading