Cupel is a maximally compatible certified TypeScript-to-Go system. Every grounded project stays executable in its exact pinned Node runtime, while every class-free, any-free region is automatically considered for machine-checkable promotion to readable native Go.
Every managed source region carries exactly one execution class, and reports must account for all of them: CEN + GN + TN + MN + CAP = 1. A test result is never reported as a proof.
No proprietary syntax, no custom parser. Bare arithmetic is admitted when the synthesized proof validates; explicit intrinsics are the fallback where proof may fail. If any native proof is rejected, this exact file keeps running in Node.
export function totalBatch( items: DenseArray<LineItem>, ): Int53 { try { // 0 is statically an Int53 — certified elaboration let total: Int53 = 0; for (const item of items) { const label = item.description?.trim() ?? item.sku; if (item.quantity < 0) { throw { kind: "invalidQuantity", sku: item.sku, label } satisfies PricingError; } // bare * admitted — arithmetic proof synthesized const extended = item.quantity * item.unitPrice; const discount = item.discount ?? 0; // explicit intrinsic where proof may fail const net = Int53.subOrThrow(extended, discount); total = Int53.addOrThrow(total, net); } return total; } catch (error: unknown) { if (Int53Error.is(error)) { throw { kind: "overflow" } satisfies PricingError; } throw error; } }
func TotalBatch( items cupel.DenseArray[LineItem], ) (cupel.Int53, error) { total := cupel.Int53(0) for it := items.Values(); it.Next(); { item := it.Value() label := item.SKU if item.Description.IsValue() { label = cupel.StringTrim( item.Description.Value()) } if item.Quantity < 0 { return 0, PricingErrorInvalidQuantity{ SKU: item.SKU, Label: label} } // direct * — the per-site proof validated extended := item.Quantity * item.UnitPrice discount := cupel.Int53(0) if item.Discount.IsDefined() { discount = item.Discount.Value() } net, err := cupel.Int53Sub(extended, discount) if err != nil { return 0, PricingErrorOverflow{} } total, err = cupel.Int53Add(total, net) if err != nil { return 0, PricingErrorOverflow{} } } return total, nil }