Hero onboarding website + billing backend — full plan #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hero onboarding website + billing backend — full plan
Source: meeting Kristof + Emre, 2026-05-20.
This issue captures the full plan for the onboarding website (login + payment + dashboard) and the billing backend (per-node forge billing-record repos + centralized aggregator). It is intentionally one meta-issue rather than many small ones — the parts are tightly coupled and the cross-cutting design decisions need a single review surface.
Sub-tasks are listed under "Phased delivery" below. Each phase will get its own follow-up issue once this meta-plan is agreed.
Scope
In scope (this repo):
Out of scope (tracked elsewhere):
hero_embedder/hero_aibroker/hero_voice/hero_proxymoving from per-user to multi-tenant common hosts attached over Mycelium. Owners: embedder / voice / aibroker / proxy teams.Pricing model (from meeting notes)
Discount ladder (applies to Hero OS hourly + LLM):
Auth model
Mycelium-address only. Users authenticate by proving control of a Mycelium address. No email/password fallback in v0.
This matches the
hero_logindesign pattern: every Hero context is mycelium-addressable, so the same identity flows through onboarding, billing, and later service install / start-stop admin actions.Email/password / OAuth providers can be added later if a real user requirement surfaces — kept out of v0 to avoid surface area we don't yet need.
Architecture
Service shape
kind=webper the canonical lab / hero_proc convention). Deployed via lab + hero_proc on a VM. No fancy orchestration in v0 — single instance, redeploy via the existinglab build --upload+lab build --download --installflow.hero_onboarding_server/(web),hero_onboarding_admin/(admin daemon),hero_onboarding/(CLI launcher),hero_onboarding_schema/(oschema definitions), 3×service.toml,build.rsfor codegen.Schema
User data + billing state live in an OSIS schema written in oschema (the existing Hero schema definition language under
hero_skills/skills/oschema/).build.rsrunsoschema_code_generationto produce Rust types + OSIS handlers + an RPC server.Entities (v0):
User— mycelium address (canonical identifier), display name, created-at, last-active.Billing— credit balance, lifetime paid, current discount tier (week / month).UsageRecord— append-only log of "user X consumed Y units of resource Z at timestamp T on node N." This is the atomic unit pushed to per-node Forge repos.PaymentEvent— Stripe / ClickPesa webhook outcome: provider, amount, currency, status, external-ref, applied-to-user.Schema is the canonical interface; everything else (RPC, UI, billing aggregator) generates from it.
Per-node billing-record repos (the "real" design, no shortcuts)
Each Hero node — embedder host, aibroker host, hero_proxy host, individual user VM host, etc. — runs a
hero_proccron service that pushes its local usage log to a dedicated per-node Forge repo every hour.hero_opsorhero_deploy— naming TBD; see Open questions).hero_ops/billing-<node-name>— naming TBD).lab repo pushmechanic (or equivalent).Hash-resume semantics (the "HARD part" called out in the meeting):
git log <last-hash>..HEADenumerates new commits → new usage records.UsageRecordcarries an idempotency key (proposed:(node_id, local_seq, timestamp)). The aggregator rejects duplicates.Centralized aggregator
A separate Hero service (
hero_onboarding_aggregator/— naming TBD) that:git pull→ walk new commits → parse newUsageRecordentries → apply to the corresponding user'sBillingrow in the central OSIS schema.Provisioning (agnostic, plug-in)
Define a
Provisionertrait / interface. v0 ships one impl + room for more:PoolAssignmentProvisioner— ops pre-deploys a pool of VMs (the same way the existing herodemo VM was deployed); the website assigns an unallocated VM from the pool when a user pays.TfchainAutoDeployProvisioner— full TFchain contract creation on demand, no pre-deployed pool. Separate effort, separate session.This way the website's payment-success flow and the underlying VM acquisition flow are decoupled; we don't lock in a design that's wrong for v1.
Reused in-house components
A neighboring in-house product has already shipped, end-to-end-tested, and proven in production all three external integrations Phase 2 / 3 / 6 need. We lift, we don't reinvent.
kyc.oschemaschema — written in the same canonical Hero schema language we're using forhero_onboarding. Direct copy possible at the schema layer; zero rewrite.openrpc.json+rpc.rs), code-generated types (types_generated.rs), and core logic cleanly separated into acore/module. Transfers cleanly modulo renaming.step_kyc_terms.rs+ multi-step wizard integration) — same UI impedance-mismatch as Stripe / ClickPesa; logic transfers, UI rewrites.hero_skills/skills/oschema/) — canonical Hero schema definition language. No separate template to wait on.kind=webscaffold with pages, blog, auth, admin.Phased delivery
Each phase will get its own follow-up issue linked back to this meta-issue once this plan is agreed.
Phase 1 — Schema scaffold + skeleton web service
Cargo.toml, 3 crates, 3service.toml,build.rs).hero_onboarding_schema/—User,Billing,UsageRecord,PaymentEventin oschema.hero_onboarding_server/—kind=webskeleton, mycelium-address login, dashboard (balance + placeholder for active services), payment stubbed (button → 200 OK → fake credit applied).hero_onboarding_admin/—kind=admindaemon skeleton.lab build --release --installclean;lab infocheckclean;lab service hero_onboarding_server --startopens the page; mycelium-address login + dashboard render.Phase 2 — Stripe sandbox integration
hero_procsecrets context (per existing META env convention).PaymentEventrecorded →Billing.credit_balanceincremented.Phase 3 — ClickPesa sandbox integration
Phase 4 — Per-node billing-record push (hero_proc cron + lab repo push)
UsageRecordwire format (TSV or JSONL; TBD).hero_proccron service that, every hour, commits the new records and pushes to the node's Forge repo.Phase 5 — Centralized aggregator + hash-resume idempotency
hero_onboarding_aggregator/service.Phase 6 — Production keys, Idenfy KYC, pool-assignment Provisioner, live wiring
kyc.oschemaintohero_onboarding_schema/; lift the backend crate (rename + adapt to hero_onboarding's OSIS dispatcher); rewrite the Dioxus wizard step into a Tera template + small JS for the Idenfy browser redirect; reuse the 6+ Playwright e2e scenarios as the acceptance gate. Decision: same Idenfy account or fresh tenant credentials.PoolAssignmentProvisionerimpl: ops pre-deploys VMs, the website assigns one on payment success.Optional rescope: Idenfy KYC could move earlier (e.g. between Phase 3 and Phase 4) if KYC is a hard gate before any payment — that decision is one of the open questions below. Phase 6 keeps it as the default to land it after sandbox payment flows are clean.
Open questions for Kristof + Emre
hero_ops/hero_deploy/hero_billing/ something else?hero_ops/billing-<node-name>/hero_ops/<node-name>-billing/ something else? The aggregator's discoverability depends on this being stable.UsageRecordwire format: TSV / JSONL / oschema-OTOML? Trade-off: TSV is easiest forgit diff, JSONL is easiest for tooling, OTOML matches the rest of the Hero stack.Out of scope / follow-up issues to file
PoolAssignmentProvisionerimpl withTfchainAutoDeployProvisionerimpl; separate session post-v0.Related repos / patterns
hero_website_framework—kind=webskeleton.hero_skills/skills/oschema/+oschema_code_generation— schema → codegen pipeline.hero_proc— supervision + cron + secrets context.hero_router— service entry / discovery / MCP gateway (the onboarding website registers behind it).hero_loginpattern (when / if it exists as a separate crate; otherwise wire mycelium-address auth directly using the documented context + claim format).lab— build / install / publish / repo-push orchestrator used by Phase 4's cron.