Skip to content

fix: correct model lineup (live), remove legacy supported_models catalog, persist platform pricing - #259

Merged
Gajesh2007 merged 5 commits into
masterfrom
fix/model-catalog-and-pricing-restart
May 31, 2026
Merged

Gajesh2007 merged 5 commits into
masterfrom
fix/model-catalog-and-pricing-restart

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Resolves the stale landing-page model lineup (#257), removes its backend root
cause (a duplicate legacy catalog), and fixes a critical billing bug found
along the way where platform pricing was wiped on every coordinator restart.

The real, served lineup today is Gemma 4 26B + GPT-OSS 20B (verified against
live /v1/models/catalog). Everything now flows from the manifest-backed
model_registry as the single source of truth.

Architecture — before / after

Before — two overlapping catalogs (supported_models, read by the bare admin
CRUD and as a fallback hidden behind a token hack), plus a startup cleanup that
deleted platform pricing on every boot:

flowchart TD
    subgraph API["API surface"]
        ADM["GET / POST / DELETE<br/>/v1/admin/models"]
        MODELS["GET /v1/models"]
        CATALOG["GET /v1/models/catalog"]
        SYNC["SyncModelCatalog"]
    end

    ADM --> SUP[("supported_models<br/>legacy duplicate")]
    MODELS --> REG[("model_registry<br/>canonical")]
    CATALOG --> REG
    SYNC --> REG
    MODELS -. "fallback if registry empty" .-> SUP
    CATALOG -. fallback .-> SUP
    SYNC -. fallback .-> SUP
    SUP --> HACK["IsRetiredProviderModel()<br/>hides stale rows"]

    BOOT(["coordinator restart"]) -->|"startup DELETE: account_id NOT IN users"| MP[("model_prices")]
    MP -. "platform pricing wiped every boot" .-> FB["billing reverts to<br/>$0.05 / $0.20 fallback"]
Loading

After — model_registry is the single source of truth, the legacy catalog is
gone, and the one-time model_prices cleanup is run-once and preserves the
platform account:

flowchart TD
    subgraph API["API surface"]
        REGADMIN["POST /v1/admin/models/register<br/>+ per-model actions"]
        MODELS["GET /v1/models"]
        CATALOG["GET /v1/models/catalog"]
        SYNC["SyncModelCatalog"]
        PRICING["PUT /v1/admin/pricing"]
    end

    REGADMIN --> REG[("model_registry<br/>single source of truth")]
    MODELS --> REG
    CATALOG --> REG
    SYNC --> REG
    PRICING --> MP[("model_prices")]

    BOOT(["coordinator restart"]) -->|"run-once cleanup, keeps platform"| MP
    MP --> KEEP["platform pricing persists"]
    REG --> FE["landing + console:<br/>live lineup (Gemma 4 26B, GPT-OSS 20B)"]
Loading

1. Critical fix — platform pricing wiped on every restart

coordinator/store/postgres.go ran this in its startup migration list on every
boot
:

DELETE FROM model_prices WHERE account_id NOT IN (SELECT account_id FROM users);

It was a one-time cleanup for legacy Solana-wallet-keyed rows, but platform
default pricing is stored under the synthetic account_id = 'platform', which is
never a row in users — so all per-model platform pricing was deleted on every
restart
, silently reverting billing (consumer.go, provider.go) to the
$0.05 / $0.20 fallback. Models survived because they live in a different table
(model_registry).

Fix:

  • Exclude the 'platform' system account from the cleanup.
  • Gate the one-time destructive cleanup behind a new schema_migrations marker
    so it runs once, not on every boot (defense against the next synthetic
    account hitting the same trap).

Tests: TestPostgresWalletPriceCleanupPreservesPlatform and
TestPostgresWalletPriceCleanupRunsOnce (verified against a real Postgres;
proven to fail on the old query and pass with the fix).

After deploy, re-set the two model prices once via PUT /v1/admin/pricing —
they now persist across restarts.

2. Backend — remove the legacy supported_models catalog

supported_models was a duplicate of model_registry, read only by the bare
admin CRUD and as an empty-registry fallback. It's what made the lineup look
"5-strong". Removed:

  • Routes: bare GET/POST/DELETE /v1/admin/models + their handlers.
  • Store: SetSupportedModel / ListSupportedModels / DeleteSupportedModel
    (interface + memory + postgres) and the supported_models table (now
    DROP TABLE IF EXISTS).
  • Empty-registry fallbacks in activeCatalogLookups, SyncModelCatalog,
    handleModelCatalog (now registry-only).
  • model_catalog_filter.go (the IsRetiredProviderModel token hack) and the
    dead seedModelCatalog.
  • Repointed scripts/admin.sh models list to /v1/models/catalog.

Untouched / intact: the manifest-backed registry path
(POST /v1/admin/models/register, /v1/admin/models/{id}/...),
PUT /v1/admin/pricing, /v1/models*, and the store.SupportedModel struct
(now documented as the in-memory shape derived from the registry).

3. Frontend / docs — live lineup + stale removal

  • landing/index.html: the pricing table is now sourced live from
    /v1/models/catalog + /v1/pricing, with the two served models as a static
    fallback. The API example uses gemma-4-26b.
  • landing/earn-calculator.js: model list now built live from the catalog
    (mirrors the already-live console earn page), with a corrected 2-model
    fallback.
  • Public read endpoints (/v1/models/catalog, /v1/pricing) now return a
    wildcard CORS origin (no credentials) so the marketing site can read them
    cross-origin. Credentialed endpoints stay locked to the single configured
    origin. Covered by TestCORSPublicEndpointsAllowAnyOrigin.
  • README.md: model table, example model id, and pricing table corrected to the
    two served models; the 95% vs 100% revenue-split contradiction resolved to
    100% during the public alpha (consistent with the landing page and the 0%
    platform fee default).
  • console-ui (models, api/stats, api-console, providers/setup) and the
    scripts/*.py benchmark/load lists updated to the served lineup.

Out of scope (intentionally not changed)

  • papers/dginf-private-inference.tex — published benchmark content, not product
    surface.
  • Go test fixtures that use old model ids as arbitrary strings (harmless).
  • scripts/mlx_lm_batch_bench.py — uses the real HuggingFace weights path for a
    standalone MLX tool, not a coordinator model id.

Testing

  • go build ./..., go vet ./..., gofmt -l clean.
  • coordinator api + store (vs ephemeral Postgres) + cmd suites pass.
  • console-ui: npx eslint src/ (0 errors) and npm run build pass.
  • Landing scripts: client transform verified against live prod data; JS
    syntax-checked.

Note: TestPostgresRecordUsage is a pre-existing flake (asserts row order
on equal created_at timestamps); it fails on the pristine tree too and is
unrelated to this PR.

Deploy ordering

Ship the coordinator first — the landing page's live fetch only works in-browser
once the new CORS is deployed (until then it shows the correct static fallback).

Refs #257, #256


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

…n restart

Addresses the stale model lineup (#257) and its backend root cause, plus a
critical billing bug found along the way.

Pricing (critical): the model_prices startup cleanup deleted the synthetic
"platform" account rows on every boot (platform != a users row), silently
reverting billing to the fallback $0.05/$0.20. Exclude "platform" and gate the
one-time cleanup behind a schema_migrations marker so it never runs again.

Backend: remove the legacy supported_models catalog -- the bare
GET/POST/DELETE /v1/admin/models endpoints, the store CRUD + table (now
DROP TABLE), the empty-registry fallbacks, the IsRetiredProviderModel filter,
and the dead seedModelCatalog. The manifest-backed model_registry is the single
source of truth. The SupportedModel struct stays as the in-memory shape derived
from the registry. The registry admin path and PUT /v1/admin/pricing are
untouched.

Frontend/docs: the landing pricing table and earnings calculator now source the
lineup live from /v1/models/catalog + /v1/pricing (static fallback = the two
served models). Public read endpoints (/v1/models/catalog, /v1/pricing) get
permissive CORS so the marketing site can read them cross-origin. README,
console-ui and benchmark scripts updated to Gemma 4 26B + GPT-OSS 20B; README
revenue split made consistent (100% during the public alpha).

Refs #257, #256
@vercel

vercel Bot commented May 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
d-inference Ready Ready Preview May 31, 2026 12:32am
d-inference-console-ui-dev Ready Ready Preview May 31, 2026 12:32am
d-inference-landing Ready Ready Preview May 31, 2026 12:32am

Request Review

@github-actions

github-actions Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

This PR removes a dead code function (seedModelCatalog) that was already disconnected from the startup path; it has no effect on the security posture of the coordinator.

Trust Boundaries Touched

  • TB-001 (Consumer → Coordinator): file is in scope per T-038 mapping
  • TB-008 (Coordinator → Payments): file is in scope per T-032 mapping

Threat Analysis

Threat Assessment Notes
T-038 — Missing ReadHeaderTimeout/MaxHeaderBytes ℹ️ Neutral The HTTP server config block (lines ~496+) is not modified. ReadHeaderTimeout and MaxHeaderBytes remain absent. SEC-027 is unaddressed.
T-032 — Solana mnemonic exfiltration ℹ️ Neutral No changes to mnemonic loading, KMS injection, or billing initialization paths.

New Attack Surface

None. The deleted function was not called at startup (the diff comment confirms this) and contained only store.ListSupportedModels / store.DeleteSupportedModel calls — no credential handling, network I/O, or trust-state mutation.

Open Findings Resolved

None. SEC-027 (T-038), SEC-007/T-007/T-012/T-027 (weight hash enforcement), and all other open findings are unaffected.


Note for reviewers: The 28 files listed as not covered by a threat pattern include coordinator/api/server.go and coordinator/api/billing_handlers.go. If those files contain substantive changes (they were omitted from the diff above), they should be re-evaluated against T-030/SEC-012 (Stripe idempotency), T-038/SEC-027 (HTTP server config), T-017/SEC-001 (SSRF), and T-021/SEC-004 (MDM webhook auth) before merge.


🔐 Threat model: docs/threat-model.yaml · Updates on each push to this PR

The README, landing pricing table / earnings calculator, and the console models
comparison were showing the $0.05/$0.20 platform fallback. Set them to the
intended ~50%-of-OpenRouter rates:

- Gemma 4 26B: $0.03 in / $0.165 out  (OpenRouter google/gemma-4-26b-a4b-it: $0.06/$0.33)
- GPT-OSS 20B: $0.015 in / $0.07 out  (OpenRouter openai/gpt-oss-20b: $0.03/$0.14)

console baselinePricing now holds the real OpenRouter output rates (330000 /
140000 micro-USD) so the "50% lower" comparison reads correctly. Live platform
pricing must still be set in the coordinator (PUT /v1/admin/pricing or the
register-model workflow) to match these docs; values now persist across restarts
after the model_prices cleanup fix.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed3729ec66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coordinator/api/server.go Outdated
Comment on lines +1862 to +1865
if publicCORSPaths[r.URL.Path] {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve credentialed CORS for pricing mutations

When a browser preflights DELETE /v1/pricing to revert a provider price, this branch is selected solely by path and returns Access-Control-Allow-Methods: GET, OPTIONS with no Authorization header or credentials support, even though the same path is also registered for authenticated pricing mutations. That preflight will be rejected before handleDeletePricing can run; gate the wildcard/public CORS behavior on the actual requested method (including Access-Control-Request-Method) or keep the credentialed CORS headers for non-GET pricing requests.

Useful? React with 👍 / 👎.

The price comparison shouldn't name OpenRouter as the baseline.

- console models page: baseline label "OpenRouter" -> "typical APIs"; the
  per-card line now reads "X% cheaper vs typical APIs"; footnote reworded to
  "typical hosted-API list rates".
- README pricing note: drop the OpenRouter naming and the OpenRouter
  slug-style references; keep our model ids (gemma-4-26b, gpt-oss-20b) and a
  generic "typical hosted-API list rates" framing.

Model ids shown are already our ids everywhere -- the /v1/models and
/v1/models/openrouter `id` field is our model id; the OpenRouter marketplace
`slug` is a separate, optional field. Left the API-compatibility references
(the /v1/models/openrouter feed docs + provider-schema code comments) intact
since they describe a real integration, not a pricing claim.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb68641202

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md
> **Public Alpha** -- Darkbloom is a decentralized private inference network for Apple Silicon. Currently in public alpha -- expect rough edges, breaking changes, and downtime.

AI compute today flows through three layers of markup — GPU manufacturers to hyperscalers to API providers to end users. Meanwhile, over 100 million Apple Silicon Macs sit idle most of each day with 64–512 GB of unified memory and up to 819 GB/s memory bandwidth, capable of running models with up to 500 billion parameters at interactive speeds. Darkbloom connects this idle capacity directly to demand. The core technical challenge is that the machine owner has root access and physical custody — they should not be able to see user prompts or model responses. We solve this by eliminating every software path through which inference data could be observed: the inference engine runs in-process (no subprocess, no local server, no IPC), debuggers are denied at the kernel level (PT_DENY_ATTACH), memory-reading APIs are blocked by Hardened Runtime, and these protections are provably immutable for the process lifetime because disabling SIP requires a reboot that terminates the process. A four-layer attestation architecture — Secure Enclave signatures, MDM-based independent verification, Apple Managed Device Attestation with Apple-signed certificate chains, and periodic challenge-response — verifies that each machine's security posture has not been tampered with. The result: the only remaining attack is physically probing memory chips soldered into the SoC package, the same residual threat model accepted by Apple's Private Cloud Compute for Siri and Apple Intelligence. The API is OpenAI-compatible. Operators keep 95% of revenue.
AI compute today flows through three layers of markup — GPU manufacturers to hyperscalers to API providers to end users. Meanwhile, over 100 million Apple Silicon Macs sit idle most of each day with 64–512 GB of unified memory and up to 819 GB/s memory bandwidth, capable of running models with up to 500 billion parameters at interactive speeds. Darkbloom connects this idle capacity directly to demand. The core technical challenge is that the machine owner has root access and physical custody — they should not be able to see user prompts or model responses. We solve this by eliminating every software path through which inference data could be observed: the inference engine runs in-process (no subprocess, no local server, no IPC), debuggers are denied at the kernel level (PT_DENY_ATTACH), memory-reading APIs are blocked by Hardened Runtime, and these protections are provably immutable for the process lifetime because disabling SIP requires a reboot that terminates the process. A four-layer attestation architecture — Secure Enclave signatures, MDM-based independent verification, Apple Managed Device Attestation with Apple-signed certificate chains, and periodic challenge-response — verifies that each machine's security posture has not been tampered with. The result: the only remaining attack is physically probing memory chips soldered into the SoC package, the same residual threat model accepted by Apple's Private Cloud Compute for Siri and Apple Intelligence. The API is OpenAI-compatible. During the public alpha, operators keep 100% of revenue (0% platform fee).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Set the alpha fee to 0% before advertising 100%

This newly changes the public-facing revenue-share claim to 0% platform fee, but the billing code still defaults to platformFeePercent = 5 in coordinator/payments/pricing.go:35, and normal completion settlement pays providers via ProviderPayoutWithPercent(totalCost, feePercent) with a nil/absent override falling back to that default. For ordinary consumers/providers without a per-account 0% override, the system will still retain 5%, so this copy can mislead operators unless the default fee (or guaranteed overrides) is updated at the same time.

Useful? React with 👍 / 👎.

Comment thread landing/index.html Outdated
return {"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","'":"&#39;"}[c];
});
}
function usd(micro){ return "$" + (Number(micro || 0) / 1e6).toFixed(2); }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve sub-cent precision in live pricing

When the live catalog fetch succeeds, this formatter overwrites the static pricing rows with only two decimal places. Current advertised/token prices include values like 15,000 and 165,000 micro-USD per 1M tokens ($0.015 and $0.165), so the loaded page will show rounded/truncated prices such as $0.01/$0.17 instead of the exact API prices. Use the same variable precision as the static rows or API *_usd fields so visitors do not see incorrect model pricing after the live refresh.

Useful? React with 👍 / 👎.

Comment thread landing/earn-calculator.js Outdated
}
function catalogActiveParamsGB(m, sizeGB) {
const text = `${m.id || ""} ${m.architecture || ""}`;
const active = text.match(/A(\d{1,3})B/i) || text.match(/(\d{1,3})B\s+active/i);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse decimal active-parameter counts

When the live catalog refresh sees an MoE architecture string with a decimal active count, such as 3.6B active for GPT-OSS, this regex does not match it and the calculator falls back to Math.round(sizeGB * 0.15). For a 12 GB GPT-OSS row that becomes 3 active GB instead of roughly 4, inflating the displayed decode speed and monthly earnings by about a third after the live refresh replaces the static fallback. Accept decimal active counts before falling back to the size-based estimate.

Useful? React with 👍 / 👎.

…nt prices, decimal active-params)

Resolves the four P2 Codex findings on this PR.

#2 (most important): the default platform fee was 5% (payments/pricing.go), so
providers actually received 95% despite the README/landing advertising "100%
during the public alpha". Set the alpha default to 0% so the code matches the
copy; per-account overrides via PUT /v1/admin/users/platform-fee still apply.
Updated the pricing tests. NOTE: the referral program pays out a share of the
platform fee, so referral payouts are dormant while the default fee is 0.

#1: /v1/pricing serves a public GET plus authenticated PUT/DELETE, but the new
public-CORS rule matched by path only and returned GET-only, no-credentials
headers for every method — which would reject a browser preflight for the
authenticated pricing mutations. Gate the wildcard CORS on the effective GET
method (preflight-aware via Access-Control-Request-Method) and add PUT to the
credentialed Allow-Methods. Extended the CORS test.

#3: the landing live price formatter and the earnings calculator's currency
reformatter rounded to 2 decimals, showing $0.015 -> $0.01 and $0.165 -> $0.17.
Allow up to 4 fraction digits so sub-cent model prices render exactly.

#4: the earnings calculator's active-parameter estimate ignored decimal counts
and only read id/architecture ("MoE"), under-counting GPT-OSS active params
(3 vs ~3.6) and inflating projected earnings after the live refresh. Parse the
model description and accept decimals (mirrored in the console earn page).
@blacksmith-sh

blacksmith-sh Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
TestIntegration_ProviderPayoutSplit View Logs
TestIntegration_ReferralRewardDistribution View Logs

Fix with Codesmith
Need help on this PR? Tag @codesmith with what you need.

The platform fee now defaults to 0% (providers keep 100% during the alpha), so TestIntegration_ProviderPayoutSplit (asserted a non-zero fee) and TestIntegration_ReferralRewardDistribution (rewards are funded from the platform fee) failed in CI. Give each test's consumer an explicit 5% per-account fee override (CreateUser with PlatformFeePercent) so they exercise the payout-split and referral mechanics end-to-end regardless of the global default; compute the split expectation via the *WithPercent helpers.

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference — bb58fc37 Deployed May 31, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — bb58fc37 Deployed May 31, 2026 by vercel[bot]
Preview – d-inference-landing — bb58fc37 Deployed May 31, 2026 by vercel[bot]
benchmarks — bb58fc37 Deployed May 31, 2026 by Gajesh2007 via E2E Benchmarks #520
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