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
18 changes: 18 additions & 0 deletions compute-budget-reservation-guard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Compute Budget Reservation Guard

This module adds a focused revenue infrastructure guard for AI compute budget reservations.

It evaluates whether institution-sponsored GPU or AI compute reservations can be released, invoiced, or recognized as revenue by checking PI and finance approvals, grant restrictions, available budget, overrun authorization, restricted-data agreements, expired unused reservations, invoice evidence, and deferred revenue actions.

## Run

```sh
node compute-budget-reservation-guard/test.js
node compute-budget-reservation-guard/demo.js
```

The demo writes JSON and Markdown reviewer artifacts to `compute-budget-reservation-guard/reports/`.

## Review Surface

The implementation is dependency-free, uses synthetic data only, and does not call external APIs or read credentials.
19 changes: 19 additions & 0 deletions compute-budget-reservation-guard/acceptance-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Acceptance Notes

## Validation

- `node compute-budget-reservation-guard/test.js`
- `node compute-budget-reservation-guard/demo.js`
- `node --check compute-budget-reservation-guard/index.js`
- `node --check compute-budget-reservation-guard/test.js`
- `node --check compute-budget-reservation-guard/demo.js`
- `ffprobe -v error -show_entries format=duration,size -show_entries stream=codec_name,width,height -of default=noprint_wrappers=1 compute-budget-reservation-guard/demo.mp4`

## Acceptance Coverage

- Clean reservations can be released while recognizing only completed usage.
- Compute overruns without approval hold revenue recognition.
- Grant restrictions block ineligible commercial AI workloads.
- Expired unused reservations produce finance actions that release budget.
- Restricted data requires DPA or data-use-agreement evidence.
- The output audit digest is deterministic for reviewer replay.
108 changes: 108 additions & 0 deletions compute-budget-reservation-guard/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const fs = require("fs");
const path = require("path");
const { evaluateComputeBudgetReservations } = require("./index");

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

const packet = {
accountId: "northbridge-research-cloud",
now: "2026-06-01T12:00:00Z",
grants: [
{
id: "grant-open-compute",
remainingBudget: 15000,
restrictions: [],
allowedOverrunPercent: 5,
},
{
id: "grant-public-health",
remainingBudget: 6000,
restrictions: ["no-commercial-ai"],
allowedOverrunPercent: 0,
},
],
reservations: [
{
id: "res-folding-forecast",
projectId: "project-protein-folding",
grantId: "grant-open-compute",
requestedUnits: 100,
unitPrice: 45,
actualUnits: 88,
expiresAt: "2026-06-12T00:00:00Z",
job: { status: "completed" },
dataSensitivity: "standard",
approvals: [
{ role: "pi", approvedAt: "2026-05-28T09:15:00Z" },
{ role: "finance", approvedAt: "2026-05-28T11:30:00Z" },
],
invoice: { evidenceIds: ["usage-report", "order-form", "invoice-draft"] },
},
{
id: "res-commercial-eval",
projectId: "project-partner-evaluation",
grantId: "grant-public-health",
requestedUnits: 90,
unitPrice: 50,
actualUnits: 111,
expiresAt: "2026-06-08T00:00:00Z",
workloadType: "commercial-ai-validation",
dataSensitivity: "restricted",
evidenceIds: ["irb-approval"],
job: { status: "completed" },
approvals: [{ role: "pi", approvedAt: "2026-05-29T15:00:00Z" }],
invoice: { evidenceIds: [] },
},
{
id: "res-unused-batch",
projectId: "project-materials-scan",
grantId: "grant-open-compute",
requestedBudget: 2800,
actualCost: 0,
expiresAt: "2026-05-20T00:00:00Z",
job: { status: "not-started" },
approvals: [
{ role: "pi", approvedAt: "2026-05-01T09:00:00Z" },
{ role: "finance", approvedAt: "2026-05-01T09:30:00Z" },
],
},
],
};

const report = evaluateComputeBudgetReservations(packet);
const jsonPath = path.join(outputDir, "compute-budget-reservation-report.json");
const markdownPath = path.join(outputDir, "compute-budget-reservation-report.md");

fs.writeFileSync(jsonPath, JSON.stringify(report, null, 2));
fs.writeFileSync(
markdownPath,
[
"# Compute Budget Reservation Guard Demo",
"",
`Decision: ${report.decision}`,
`Audit digest: ${report.auditDigest}`,
"",
"## Reservation Decisions",
"",
...report.reservations.map(
(reservation) =>
`- ${reservation.reservationId}: ${reservation.decision}; recognized USD ${reservation.recognizedRevenue.toFixed(2)}; deferred USD ${reservation.deferredRevenue.toFixed(2)}`,
),
"",
"## Finance Actions",
"",
...report.financeActions.map((action) => `- ${action.type}: ${action.reservationId}`),
"",
"## Findings",
"",
...report.reservations.flatMap((reservation) =>
reservation.findings.map((finding) => `- ${reservation.reservationId}: ${finding.severity} ${finding.code} - ${finding.message}`),
),
"",
].join("\n"),
);

console.log(`Wrote ${jsonPath}`);
console.log(`Wrote ${markdownPath}`);
console.log(`${report.decision}: ${report.counts.findings} finding(s), ${report.auditDigest}`);
Binary file added compute-budget-reservation-guard/demo.mp4
Binary file not shown.
27 changes: 27 additions & 0 deletions compute-budget-reservation-guard/demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading