Skip to content

ci: feat/platform metadata phase1 - #924

Merged
ooples merged 73 commits into
masterfrom
feat/platform-metadata-phase1
Mar 5, 2026
Merged

ooples merged 73 commits into
masterfrom
feat/platform-metadata-phase1

Conversation

@ooples

@ooples ooples commented Mar 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • AIMF Model Format: New binary envelope format with auto-detect loading, AES-256-GCM encryption, dynamic shape support, wired into all 15+ base classes (neural networks, regression, classification, clustering, diffusion, RL, time series, etc.)
  • License & Security: Three-layer obfuscation for model protection, license key management system with self-hosted server support, build-time signing key injection
  • Stripe Integration: Payment checkout, customer portal, webhook handling in AiDotNet.Serving; new Stripe webhook Azure Function for auto-upgrading Supabase profiles on subscription events
  • Marketing Website: Complete 69-page Astro site with Supabase auth (email, GitHub, Google OAuth), account portal (dashboard, API keys, usage, billing, settings), Stripe checkout integration, 352 Playwright E2E tests
  • Fixes: Password reset flow, Stripe portal env var, Azure deployment workflows, .NET 10 runtime updates, removed all ILGPU references

Test plan

  • All 352 Playwright E2E tests pass (176 desktop + 176 mobile)
  • Email signup/login verified with test user on live site
  • GitHub OAuth redirect verified (shows AiDotNet branding)
  • Google OAuth redirect verified (after enabling provider)
  • Stripe test subscription created via API ($29/mo Pro plan, invoice paid)
  • Supabase profile upgrade to Pro tier verified on dashboard + billing pages
  • Stripe webhook Azure Function builds with 0 errors
  • Full account portal tested: dashboard, API keys (create/revoke), usage, billing, settings, sign out
  • Zero console errors across all tested pages

Post-merge setup required

After merging, add these Azure Function App Settings for the Stripe webhook:

Setting Value
STRIPE_SECRET_KEY Your sk_test_ key
STRIPE_WEBHOOK_SECRET From Stripe Dashboard > Webhooks
SUPABASE_URL https://yfkqwpgjahoamlgckjib.supabase.co
SUPABASE_SECRET_KEY Your Supabase secret key

Then register the webhook endpoint in Stripe Dashboard:

  • URL: https://aidotnet-playground-emfxa0abhzdqfyh3.westeurope-01.azurewebsites.net/api/stripe-webhook
  • Events: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added license key support for encrypted model persistence and validation
    • Integrated Stripe payment processing for subscriptions
    • Implemented AIMF envelope format for self-describing model files
    • Added IModelShape interface for dynamic input/output shape introspection
    • Launched comprehensive marketing website with tutorials and reference guides
  • Chores

    • Deployed automated CI/CD pipelines for website and API serving
    • Expanded documentation with 30+ tutorials and reference guides
    • Updated model serialization infrastructure across all base classes

ooples and others added 24 commits March 2, 2026 17:58
Introduces the AI Model File (AIMF) envelope format with:
- IModelShape interface for self-describing model dimensions
- SerializationFormat enum (Binary, Json, HybridBinary)
- ModelFileHeader for reading/writing AIMF binary headers
- ModelTypeRegistry for automatic model type discovery
- ModelLoader for auto-detect loading from AIMF files
- Global using for AiDotNet.Helpers namespace

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- NeuralNetworkBase: add IModelShape, AIMF wrapping in SaveModel,
  AIMF stripping in LoadModel, add GetOutputShape()
- ClusteringBase: add IModelShape, AIMF wrapping in SaveModel,
  AIMF stripping in LoadModel, add GetInputShape/GetOutputShape

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- RegressionBase: add IModelShape, AIMF wrapping in SaveModel,
  AIMF stripping in LoadModel
- NonLinearRegressionBase: add IModelShape, AIMF wrapping/stripping
- DecisionTreeRegressionBase: add IModelShape, AIMF wrapping/stripping
- AsyncDecisionTreeRegressionBase: add IModelShape, AIMF wrapping/stripping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add LoadFromRegistryAutoDetect method that uses AIMF envelope
headers to automatically resolve model types when loading from
the model registry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ClassifierBase: add IModelShape, AIMF wrapping in SaveModel,
  AIMF stripping in LoadModel, output shape = NumClasses
- MultiLabelClassifierBase: add IModelShape, AIMF wrapping/stripping,
  output shape = NumLabels

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- TimeSeriesModelBase: add IModelShape (input=LagOrder), AIMF wrap/strip
- SurvivalModelBase: add IModelShape (input=NumFeatures), AIMF wrap/strip
- CausalModelBase: add IModelShape (input=NumFeatures), AIMF wrap/strip
- OnlineLearningModelBase: add IModelShape (input=NumFeatures), AIMF wrap/strip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add IModelShape interface with FeatureCount-based input shape
- Change SaveModel/LoadModel from abstract to virtual with
  default AIMF-aware implementations
- Concrete agents' overrides remain compatible

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- DiffusionModelBase: add IModelShape, AIMF wrapping/stripping
- NoisePredictorBase: add IModelShape (InputChannels/OutputChannels)
- VAEModelBase: add IModelShape (InputChannels/LatentChannels)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- OptimizerBase: add IModelShape, AIMF wrapping/stripping
- ShardedOptimizerBase: add IModelShape, AIMF wrapping/stripping
  (preserves rank-0-only save and barrier semantics)
- ShardedModelBase: add IModelShape (delegates to wrapped model),
  convert abstract SaveModel/LoadModel to virtual AIMF-aware defaults

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- AutoMLModelBase: add IModelShape (delegates to BestModel)
- FineTuningBase: add IModelShape, AIMF wrapping/stripping
- AdversarialAttackBase: add IModelShape, AIMF wrapping/stripping
- ContentClassifierBase: add IModelShape, convert abstract
  SaveModel/LoadModel to virtual AIMF-aware defaults

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 tests covering ModelFileHeader, ModelTypeRegistry, and ModelLoader:
- Header wrap/read/extract round-trip with various payload sizes
- Shape preservation (empty, 1D, multi-dimensional)
- Legacy file fallback behavior
- File-based SaveModel/LoadModel round-trip
- Type registry auto-discovery and custom registration
- ModelLoader auto-detect with file and byte array APIs
- Error handling for null, missing, and invalid inputs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove conditional HasHeader/ExtractPayload fallback pattern from 20
base class LoadModel methods. AIMF envelope format is now required for
all model files. Non-AIMF files produce a clear error message.

Update error messages to remove legacy references and update tests
to verify non-AIMF files throw InvalidOperationException.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add DynamicShapeInfo class following ONNX convention (-1 for variable
dimensions). Add GetDynamicShapeInfo() default method to IModelShape.
Update AIMF envelope to v2 with dynamic dimension storage (backward
compatible with v1 reads). Override in NeuralNetworkBase for dynamic
batch dimension.

Update IServableModel with InputShape/OutputShape/DynamicShapeInfo
default interface members. Enhance InferenceController with
shape-aware validation that respects dynamic dimensions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add adapter constructors to ServableModelWrapper for Matrix→Vector,
Tensor→Tensor, and Vector→Vector model families. Add FromModel factory
method that auto-detects model type via interface checks. Simplify
ModelRegistryLoader.LoadFromRegistryAutoDetect to use the new factory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…compatibility

Remove default interface implementation from IModelShape (not supported
on net471) and add explicit GetDynamicShapeInfo() returning
DynamicShapeInfo.None to all 22 base classes. Fix test stubs and
manually-constructed v2 envelope in ModelLoaderTests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
License-gated model protection: model weights are encrypted with a key
derived from a license key via PBKDF2-SHA256 (210k iterations). The AIMF
header remains plaintext for inspection, while the payload requires a
valid license key to decrypt and load.

- Add PayloadEncryptionScheme enum (None, AesGcm256)
- Add ModelPayloadEncryption helper with encrypt/decrypt/key derivation
- Extend AIMF envelope v1 header with encryption scheme + salt/nonce/tag
- Add ModelLoader.SaveEncrypted and Load with optional licenseKey param
- Add IsEncrypted to ModelInfo and licenseKey to serving auto-detect
- Add 35 tests: round-trip, wrong key, tamper detection, plaintext scan
- net471: encryption methods throw PlatformNotSupportedException

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…hosted server

Client-side:
- AiDotNetLicenseKey class with key, server URL, environment, grace period, telemetry toggle
- LicenseKeyResolver with fallback chain: explicit key -> env var -> ~/.aidotnet/license.key
- MachineFingerprint for advisory cross-platform machine ID (Windows registry, Linux machine-id, macOS ioreg)
- LicenseValidator for online validation with offline grace period caching
- LicenseKeyStatus enum (Active, Expired, Revoked, SeatLimitReached, Invalid, ValidationPending)
- AiModelBuilder constructors accept optional AiDotNetLicenseKey parameter
- AiModelBuilder.SaveModel encrypts when license key is configured
- AiModelBuilder.LoadModel detects encrypted AIMF files and validates license
- YAML config support via YamlLicenseSection

Server-side (AiDotNet.Serving):
- LicenseKeyEntity and LicenseActivationEntity with EF Core configuration
- ILicenseService/LicenseService with PBKDF2 hashing (same pattern as ApiKeyService)
- Admin CRUD endpoints: POST/GET /api/admin/licenses, POST revoke
- Public validation endpoint: POST /api/licenses/validate
- Advisory seat counting via machine activation upsert

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ok handling

Adds Stripe Checkout for self-serve Pro subscription purchases,
Customer Portal for subscription management, and webhook handler
for automatic license lifecycle management (create on checkout,
revoke on cancellation).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Layer 1: Build-time signing key embedded via CI/CD, used in enhanced
PBKDF2 key derivation so forks derive different keys and cannot decrypt.

Layer 2: Server-side key escrow generates decryption tokens returned
during license validation, adding server dependency to key derivation.

Layer 3: Runtime assembly integrity checker verifies critical types
exist and build key consistency before allowing crypto operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds AIDOTNET_BUILD_KEY injection step to both version-and-build
and pack jobs so official NuGet packages contain the embedded
build key for three-layer obfuscation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests cover build key provider, assembly integrity checker,
encrypted signed round-trip, wrong key/token rejection, cross-scheme
incompatibility, and license validation result with decryption token.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ntegration

Full marketing website built with Astro + Tailwind CSS:
- Landing page with GPU benchmarks, comparison table, code examples
- 21 feature detail pages with audited implementation counts
- 3 solution pages (finance, healthcare, document AI)
- Pricing page with Stripe Payment Links integration
- 30 documentation pages (tutorials, reference, examples)
- Interactive playground page

Auth & subscriber portal (Supabase):
- Login/signup with email, GitHub OAuth, Google OAuth
- OAuth callback handler
- Account dashboard with stats and recent API calls
- API key management (create, copy, revoke)
- Usage analytics with daily charts and endpoint breakdown
- Billing page with plan management and Stripe portal
- Settings page with profile and password management
- Navbar auth state (sign in / avatar dropdown)

Infrastructure:
- Supabase client library and auth guard
- AccountLayout with sidebar navigation
- 352 Playwright E2E tests
- Vercel deployment config with conditional base path
- Logo in SVG and JPEG formats
- Launch plan with complete setup instructions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update deploy-website.yml to deploy to Vercel instead of GitHub Pages
- Add deploy-serving.yml for Azure App Service deployment
- Update astro.config.mjs site URL to aidotnet.dev
- Update LAUNCH-PLAN.md with current status and GitHub secrets needed
- Update docs.yml and sonarcloud.yml for new website structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ILGPU was completely removed from AiDotNet.Tensors. The actual GPU
architecture uses custom hand-tuned kernels via P/Invoke across 6
backends: CUDA, OpenCL, HIP, Metal, Vulkan, and WebGPU. Updated
landing page, comparison table, performance page, and launch plan.
Also added missing GPU backends (HIP, Metal, Vulkan, WebGPU) to the
performance feature page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 4, 2026 13:14
@vercel

vercel Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
aidotnet-playground-api Ready Ready Preview, Comment Mar 5, 2026 5:00pm
website Ready Ready Preview, Comment Mar 5, 2026 5:00pm

@github-actions github-actions Bot changed the title Feat/platform metadata phase1 ci: feat/platform metadata phase1 Mar 4, 2026
@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Title Auto-Fixed

Your PR title was automatically updated to follow Conventional Commits format.

Original title:
Feat/platform metadata phase1

New title:
ci: feat/platform metadata phase1

Detected type: ci: (CI/workflow files changed)
Version impact: No release


Valid types and their effects:

  • feat: - New feature (MINOR bump: 0.1.0 → 0.2.0)
  • fix: - Bug fix (MINOR bump)
  • docs: - Documentation (MINOR bump)
  • refactor: - Code refactoring (MINOR bump)
  • perf: - Performance improvement (MINOR bump)
  • test: - Tests only (no release)
  • chore: - Build/tooling (no release)
  • ci: - CI/CD changes (no release)
  • style: - Code formatting (no release)
  • deps: - Dependency update (no release)

If the detected type is incorrect, you can manually edit the PR title.

@coderabbitai

coderabbitai Bot commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This massive PR introduces a comprehensive three-layer obfuscation and licensing system with optional server-side validation, model payload encryption via AES-256-GCM with PBKDF2 key derivation, shape metadata support across 20+ model base classes, Stripe payment integration, new CI/CD workflows for website and API deployment, extensive documentation, and a new Astro-based marketing website with authentication support.

Changes

Cohort / File(s) Summary
Licensing & Key Management
src/Models/AiDotNetLicenseKey.cs, src/Helpers/LicenseKeyResolver.cs, src/Helpers/BuildKeyProvider.cs
New license key encapsulation with offline/online validation modes, build-time signing key provider, and license file resolution from environment or home directory.
Encryption & Signing
src/Helpers/ModelPayloadEncryption.cs, src/Helpers/ModelFileHeader.cs, src/Enums/PayloadEncryptionScheme.cs, src/Enums/SerializationFormat.cs
AES-256-GCM payload encryption with PBKDF2-SHA256 derivation, AIMF envelope header management, and support for signed encryption using build-time keys (NET471+ guard with PlatformNotSupportedException).
Model Shape & Serialization
src/Interfaces/IModelShape.cs, src/Models/DynamicShapeInfo.cs, src/Helpers/ModelLoader.cs, src/Helpers/ModelTypeRegistry.cs, src/AiDotNet.Serving/Models/IServableModel.cs, src/AiDotNet.Serving/Models/ModelInfo.cs, src/AiDotNet.Serving/Models/ServableModelWrapper.cs
New shape-aware serialization with dynamic dimension support, self-describing AIMF files with type resolution, and shape metadata propagation in serving layer.
Base Class Updates (IModelShape)
src/Classification/ClassifierBase.cs, src/Classification/MultiLabel/MultiLabelClassifierBase.cs, src/Regression/RegressionBase.cs, src/Regression/DecisionTreeRegressionBase.cs, src/Regression/NonLinearRegressionBase.cs, src/AutoML/AutoMLModelBase.cs, src/NeuralNetworks/NeuralNetworkBase.cs, src/Clustering/Base/ClusteringBase.cs, src/CausalInference/CausalModelBase.cs, src/Diffusion/*, src/DistributedTraining/ShardedModelBase.cs, src/DistributedTraining/ShardedOptimizerBase.cs, src/FineTuning/FineTuningBase.cs, src/OnlineLearning/OnlineLearningModelBase.cs, src/Optimizers/OptimizerBase.cs, src/ReinforcementLearning/Agents/ReinforcementLearningAgentBase.cs, src/SurvivalAnalysis/SurvivalModelBase.cs, src/TimeSeries/TimeSeriesModelBase.cs, src/AdversarialRobustness/Attacks/AdversarialAttackBase.cs, src/AdversarialRobustness/Safety/ContentClassifierBase.cs
20+ base classes now implement IModelShape with GetInputShape/GetOutputShape/GetDynamicShapeInfo; SaveModel/LoadModel updated to use AIMF envelope wrapping and extraction.
Licensing Service
src/AiDotNet.Serving/Security/Licensing/LicenseService.cs, src/Helpers/LicenseValidator.cs, src/Models/LicenseValidationResult.cs
EF Core-backed license CRUD, offline/online validation with grace-period caching, PBKDF2 hashing of secrets, per-machine activation tracking, and decryption token generation.
Stripe Integration
src/AiDotNet.Serving/Security/Licensing/StripeService.cs, src/AiDotNet.Serving/Controllers/StripeController.cs, src/AiDotNet.Serving/Configuration/StripeOptions.cs, src/AiDotNet.Serving/Enums/StripeSubscriptionStatus.cs
Stripe Checkout/Portal session creation, webhook event routing (checkout, subscription, invoice), auto-license provisioning on successful checkout, subscription tracking, and customer ownership validation.
Serving API Controllers
src/AiDotNet.Serving/Controllers/LicensesController.cs, src/AiDotNet.Serving/Controllers/LicenseValidationController.cs, src/AiDotNet.Serving/Controllers/InferenceController.cs
Admin licenses CRUD endpoint, public license validation endpoint, and shape-aware input validation for inference (dynamic dimensions honored when present).
Database & Persistence
src/AiDotNet.Serving/Persistence/ServingDbContext.cs, src/AiDotNet.Serving/Persistence/Entities/LicenseKeyEntity.cs, src/AiDotNet.Serving/Persistence/Entities/LicenseActivationEntity.cs, src/AiDotNet.Serving/Entities/StripeCustomerEntity.cs, src/AiDotNet.Serving/Entities/StripeSubscriptionEntity.cs
Four new entity types with validation (LicenseKeyEntity enforces crypto field constraints: Pbkdf2Iterations ≥100k, EscrowSecret 32 bytes, Salt ≥16 bytes when set).
Configuration & Builder
src/Configuration/YamlLicenseSection.cs, src/Configuration/YamlModelConfig.cs, src/Configuration/YamlConfigApplier.cs, src/AiModelBuilder.cs, src/Interfaces/IAiModelBuilder.cs
YAML license config binding with server URL, environment, offline grace period, telemetry enable/disable; AiModelBuilder extended with ConfigureLicenseKey; SaveModel enforces encryption when key configured; LoadModel detects and decrypts AIMF headers.
Integrity & Introspection
src/Helpers/AssemblyIntegrityChecker.cs, src/Helpers/MachineFingerprint.cs, src/Helpers/UsingsHelper.cs
Layer 3 assembly integrity verification via embedded HMAC, deterministic machine fingerprinting (SHA-256 of platform ID or hostname/username), and global using directive.
Build Configuration
src/AiDotNet.csproj, .gitignore
Conditional embedding of BuildKey.bin and IntegrityHash.bin; updated .gitignore for Click-Once artifacts and build-time keys.
GitHub Actions & Deployment
.github/workflows/automated-release.yml, .github/workflows/deploy-serving.yml, .github/workflows/deploy-website.yml, .github/workflows/docs.yml, .github/workflows/sonarcloud.yml, .github/workflows/azure-functions-deploy.yml
Build signing key injection pre-restore; new Vercel website deploy workflow (Node.js 20, npm build, deploy to production); old docs workflow replaced with Node.js-based marketing site build; sonarcloud docs job removed and replaced with reference to deploy-website.yml; Azure Functions deployment adds Stripe webhook URL to summary.
Website Framework & Components
website/package.json, website/astro.config.mjs, website/playwright.config.ts, website/postcss.config.mjs, website/src/lib/supabase.ts, website/src/components/{Navbar,Hero,Footer,CodeTabs,FeatureCard,ComparisonTable,PricingCard,ThemeToggle,SEO}.astro
Astro 4.x marketing site with Tailwind/GSAP animations, Supabase auth (sign-in/sign-out, user state), theme toggle, pricing cards with Stripe tier data attributes, responsive layouts, and SEO meta tags.
Website Layouts & Pages
website/src/layouts/{BaseLayout,DocsLayout,AccountLayout,FeatureDetailLayout,SolutionLayout}.astro, website/src/pages/account/api-keys/index.astro
Base layout with GSAP animations (fade-up, counters, hero network SVG); docs layout with persistent sidebar; account layout with Supabase auth guard; feature/solution layouts with data-driven sections; API keys page with Supabase CRUD (SHA-256 client-side hash) and one-time display modal.
Documentation & Content
website/src/content.config.ts, website/src/content/docs/{getting-started,tutorials,reference,community}/*.md, website/LAUNCH-PLAN.md, README.md
114+ markdown pages covering installation, quickstart, tutorials (classification, clustering, audio, NLP, deployment, distributed training, LoRA, reinforcement learning, time series, computer vision, neural networks, transformers), references (classical ML, optimizers, loss functions, YAML config, neural architectures, distributed strategies, LoRA adapters), roadmap, changelog, and contributing guide; comprehensive launch checklist.
Testing
tests/AiDotNet.Tests/UnitTests/Serialization/{LicenseKeyTests,LicenseDecryptionTokenTests,ModelFileHeaderTests,ModelLoaderTests,ModelPayloadEncryptionTests,ModelTypeRegistryTests,ObfuscationTests}.cs
700+ test cases covering license validation (key format, HMAC, online/offline modes), machine fingerprinting, assembly integrity, AIMF header round-trips, shape preservation, encryption/decryption, signed encryption, tampering detection, model registry discovery and resolution, factory injection, and factory-backed instance creation.
Azure Functions & Stripe Webhook
src/AiDotNet.Playground.Functions/StripeWebhook.cs, src/AiDotNet.Playground.Functions/AiDotNet.Playground.Functions.csproj
HTTP-triggered Stripe webhook handler that verifies signature, routes events (checkout, subscription, invoice) to handlers, derives tier/status from Stripe, updates Supabase profiles with subscription metadata, and retries on 500 for transient failures.
Model Result & Introspection
src/Models/Results/AiModelResult.cs, src/AiDotNet.Serving/Services/ModelRegistryLoader.cs
AiModelResult Model property setter changed from private to public; ModelRegistryLoader enhanced with auto-load via LoadFromRegistryAutoDetect, shape validation fallback on load failure, and detailed error messaging.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server as License Server
    participant DB as License DB
    participant ServiceAPI as AiDotNet.Serving
    participant Validator as LicenseValidator
    participant Cache as Validation Cache

    Client->>ServiceAPI: Load encrypted model (with license key)
    ServiceAPI->>Validator: Validate license key
    alt Offline Mode (no ServerUrl)
    Validator->>Validator: Check key format & HMAC signature
    Validator-->>ServiceAPI: Active or Invalid
    else Online Mode with ServerUrl
    Validator->>Cache: Check cached result within grace period
    alt Cache hit & valid
    Cache-->>Validator: Return cached Active result
    else Cache miss or expired
    Validator->>Server: POST /api/licenses/validate (key, telemetry, env)
    Server->>DB: Look up license key
    DB-->>Server: License data + revocation status
    Server->>Validator: LicenseValidationResponse (status, tier, token)
    Validator->>Cache: Store result with timestamp
    Cache-->>Validator: Cached
    Validator-->>ServiceAPI: Active (with decryption token)
    end
    end
    ServiceAPI->>ServiceAPI: Decrypt model with license key + token
    ServiceAPI-->>Client: Decrypted model ready
Loading
sequenceDiagram
    participant Developer as Developer (Build)
    participant BuildKey as BuildKey.bin (embedded)
    participant Signer as Payload Encryption
    participant AIMF as AIMF File
    participant Consumer as Model Consumer

    Developer->>Developer: Inject BuildKey.bin (CI/CD)
    Developer->>Developer: Save model (encrypted)
    Developer->>Signer: SaveEncrypted(model, licenseKey, decryptionToken)
    Signer->>Signer: DeriveSignedKey(licenseKey, salt, token + BuildKey)
    Signer->>Signer: AES-256-GCM encrypt payload (signed path)
    Signer->>AIMF: WrapWithHeader(encrypted payload, salt, nonce, tag)
    AIMF-->>Developer: AIMF file on disk
    Developer->>Consumer: Ship encrypted model
    Consumer->>Consumer: LoadFromBytes(data, licenseKey, decryptionToken)
    Consumer->>Consumer: ReadHeader → extract metadata
    Consumer->>Signer: DecryptSigned(ciphertext, licenseKey, salt, nonce, tag, token)
    Signer->>BuildKey: Verify assembly integrity (Layer 3)
    Signer->>Signer: DeriveSignedKey (recreate same key)
    Signer->>Signer: AES-256-GCM decrypt
    Signer-->>Consumer: Plaintext payload
    Consumer->>Consumer: Deserialize(payload)
    Consumer-->>Consumer: Model ready
Loading
sequenceDiagram
    participant Client as Stripe Client
    participant Checkout as Stripe Checkout
    participant WebhookQueue as Webhook Queue
    participant StripeService
    participant LicenseService
    participant DB as DB

    Client->>Checkout: Initiate checkout session (tier, seats, email)
    Checkout->>Client: Return checkout URL
    Client->>Checkout: Complete payment
    Checkout->>WebhookQueue: Enqueue checkout.session.completed event
    WebhookQueue->>StripeService: POST webhook (event, signature)
    StripeService->>StripeService: Verify Stripe signature
    StripeService->>StripeService: Route event → HandleCheckoutSessionCompletedAsync
    StripeService->>LicenseService: CreateAsync(tier, seats, email)
    LicenseService->>DB: Insert LicenseKeyEntity (salt, hash, escrow)
    DB-->>LicenseService: License created
    LicenseService-->>StripeService: LicenseCreateResponse (key)
    StripeService->>DB: Upsert StripeCustomerEntity
    StripeService->>DB: Create StripeSubscriptionEntity
    DB-->>StripeService: Persisted
    StripeService-->>WebhookQueue: Return 200 OK
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~150+ minutes

Rationale: This PR spans 40+ files with 7,500+ lines of new code introducing:

  • Encryption & Cryptography: AES-256-GCM with PBKDF2 and three-layer obfuscation (BuildKeyProvider, AssemblyIntegrityChecker, LicenseValidator). NET471 guards throwing PlatformNotSupportedException are blocking stubs blocking older framework support.
  • Licensing Logic: Complex state machines in LicenseValidator (offline/online modes, grace-period caching, HMAC signature verification, token derivation). Silent error handling in BuildKeyProvider and LicenseKeyResolver could mask issues.
  • Model Serialization: 20+ base class modifications to save/load AIMF envelopes with shape metadata. Shape validation logic in InferenceController has dynamic dimension handling that needs careful audit.
  • Stripe Integration: StripeService event routing and webhook handlers with database mutations; missing error recovery in profile updates could lose data.
  • Website & Astro: 100+ new pages, components, and layouts with Supabase auth integration, inline scripts for copy-to-clipboard and GSAP animations; API key hashing is client-side SHA-256 (explicitly marked "production should use server-side").
  • Heterogeneous Changes: Documentation, CI/CD, database entities, configuration, tests, and infrastructure span multiple concerns requiring separate reasoning for each cohort.

Blocking Issues:

  1. NET471 Guard Pattern: ModelPayloadEncryption and LicenseValidator throw PlatformNotSupportedException for .NET Framework users—this is a dead-end placeholder, not a graceful degradation. Either support the framework or document as unsupported before shipping.
  2. Silent Errors in BuildKeyProvider & LicenseKeyResolver: Missing key or file reads silently return empty/null. Callers cannot distinguish "key not found" from "key is empty." Add logging and consider throwing on misconfiguration.
  3. Client-Side API Key Hashing: website/src/pages/account/api-keys/index.astro hashes API keys client-side with SHA-256. The code comment explicitly notes "production should use server-side hashing"—this is a TODO masquerading as production code.
  4. Supabase Profile Updates in StripeService: UpdateSupabaseProfile silently updates or skips if the profile doesn't exist; no transaction semantics ensure atomicity. Stripe webhook could partially succeed and leave inconsistent state.
  5. MachineFingerprint Fallback Predictability: Platform-specific reads (Windows MachineGuid, Linux /etc/machine-id) fall back to hostname+username hash. This is deterministic but not machine-specific; multi-user or containerized deployments could collide.
  6. ModelTypeRegistry Reflection: Auto-discovery via reflection and caching could fail silently if ReflectionTypeLoadException is swallowed. No diagnostics to debug missing or misconfigured types.
  7. InferenceController Shape Validation: Dynamic dimension logic assumes -1 indicates dynamic axes. If shapes encode -1 for other reasons, validation silently fails. Add explicit validation or documentation.

High-Risk Areas:

  • LicenseService: complex validation state machine with multiple async paths (database, licensing, telemetry); edge cases in seat counting, grace-period boundaries, revocation timing.
  • StripeService webhook routing: missing event types silently log and continue; no alerting on unhandled events could hide integration issues.
  • AssemblyIntegrityChecker caching: locked cache computation has no invalidation; once verified/failed, result is permanent for the process lifetime.
  • Website auth guard in AccountLayout: Supabase client instantiation and auth checks happen in script tags; no error boundary if auth fails mid-page.

Possibly related issues

Possibly related PRs

Suggested labels

feature, encryption, licensing, stripe-integration, documentation, website, database, breaking-change


🔐 Obfuscation & Licensing Arrives!
Three layers deep, keys at rest,
AIMF envelopes pass the test—
Now shape it up, serialize the best! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/platform-metadata-phase1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Introduces “platform metadata phase 1” by adding an Astro marketing/docs website alongside licensing + encrypted AIMF model loading/saving infrastructure (including serving-side endpoints and persistence).

Changes:

  • Added Astro website layouts/components, docs content, Tailwind/PostCSS, and Playwright config.
  • Added AIMF envelope metadata (model shapes + dynamic shape info) and integrated encrypted model save/load using license keys.
  • Added serving-side license + Stripe API surface and moved deployment workflows (Vercel website, Azure serving).

Reviewed changes

Copilot reviewed 139 out of 194 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
website/src/lib/supabase.ts Initializes Supabase client for website features.
website/src/layouts/DocsLayout.astro Adds docs layout with sidebar navigation + edit link.
website/src/layouts/BaseLayout.astro Adds base site layout and global GSAP animations.
website/src/content/docs/tutorials/time-series.md Adds tutorial landing page content.
website/src/content/docs/tutorials/regression.md Adds tutorial landing page content.
website/src/content/docs/tutorials/nlp.md Adds NLP/RAG tutorial content.
website/src/content/docs/tutorials/index.md Adds tutorials index page.
website/src/content/docs/tutorials/computer-vision.md Adds computer vision tutorial content.
website/src/content/docs/tutorials/classification.md Adds classification tutorial content.
website/src/content/docs/reference/yaml-configuration.md Adds YAML configuration reference docs.
website/src/content/docs/getting-started/quickstart.md Adds quickstart documentation.
website/src/content/docs/getting-started/installation.md Adds installation documentation.
website/src/content/docs/getting-started/index.md Adds getting started index.
website/src/content/docs/community/roadmap.md Adds public roadmap docs.
website/src/content/docs/community/contributing.md Adds contributing guide docs.
website/src/content/docs/community/changelog.md Adds changelog docs.
website/src/content/config.ts Defines Astro content collection schema for docs.
website/src/components/ThemeToggle.astro Adds client-side theme toggle.
website/src/components/SEO.astro Adds SEO meta tags + JSON-LD.
website/src/components/PricingCard.astro Adds pricing UI component to support monetization.
website/src/components/Footer.astro Adds consistent site footer with docs links.
website/src/components/FeatureCard.astro Adds feature highlight component.
website/src/components/ComparisonTable.astro Adds marketing comparison table component.
website/src/components/CodeTabs.astro Adds interactive code tabs and copy-to-clipboard.
website/postcss.config.mjs Enables Tailwind and Autoprefixer.
website/playwright.config.ts Adds Playwright E2E test runner configuration.
website/package.json Adds Astro/site dependencies (GSAP, Supabase, Tailwind).
website/astro.config.mjs Configures Astro base/site for GitHub Pages vs Vercel.
website/.gitignore Ignores build/test artifacts.
tests/AiDotNet.Tests/UnitTests/Serialization/ObfuscationTests.cs Adds tests for payload encryption + integrity/build-key behavior.
tests/AiDotNet.Tests/UnitTests/Serialization/ModelTypeRegistryTests.cs Adds tests for serializer type registry behavior.
tests/AiDotNet.Tests/UnitTests/Serialization/LicenseKeyTests.cs Adds tests for license key model/resolution + builder integration.
tests/AiDotNet.Tests/UnitTests/Serialization/LicenseDecryptionTokenTests.cs Adds tests for decryption token plumbing.
src/TimeSeries/TimeSeriesModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/SurvivalAnalysis/SurvivalModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/ReinforcementLearning/Agents/ReinforcementLearningAgentBase.cs Adds IModelShape + default AIMF save/load behavior.
src/Regression/RegressionBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Regression/NonLinearRegressionBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Regression/DecisionTreeRegressionBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Regression/DecisionTreeAsyncRegressionBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Optimizers/OptimizerBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/OnlineLearning/OnlineLearningModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/NeuralNetworks/NeuralNetworkBase.cs Adds IModelShape + dynamic shape info + AIMF envelope wrapping.
src/Models/LicenseValidationResult.cs Introduces license validation result model (includes decryption token).
src/Models/DynamicShapeInfo.cs Adds dynamic input/output shape descriptor and validator.
src/Models/AiDotNetLicenseKey.cs Adds license configuration model.
src/Interfaces/IModelShape.cs Introduces shape metadata interface for models.
src/Interfaces/IAiModelBuilder.cs Adds ConfigureLicenseKey API to builder interface.
src/Helpers/UsingsHelper.cs Adds global using for AiDotNet.Helpers.
src/Helpers/MachineFingerprint.cs Adds machine fingerprint generation for advisory telemetry.
src/Helpers/LicenseValidator.cs Adds client-side online/offline license validation logic.
src/Helpers/LicenseKeyResolver.cs Adds resolution chain for license keys (object/env/file).
src/Helpers/BuildKeyProvider.cs Adds embedded build-key loader (official builds).
src/Helpers/AssemblyIntegrityChecker.cs Adds runtime integrity check hooks for crypto gating.
src/FineTuning/FineTuningBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Enums/SerializationFormat.cs Adds enum describing payload serialization type inside AIMF.
src/Enums/PayloadEncryptionScheme.cs Adds enum describing payload encryption scheme.
src/Enums/LicenseKeyStatus.cs Adds enum describing license validation status.
src/DistributedTraining/ShardedOptimizerBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/DistributedTraining/ShardedModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Diffusion/VAE/VAEModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Diffusion/NoisePredictors/NoisePredictorBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Diffusion/DiffusionModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Configuration/YamlModelConfig.cs Adds YAML license section support.
src/Configuration/YamlLicenseSection.cs Adds YAML model for license configuration.
src/Configuration/YamlConfigApplier.cs Applies YAML license config into AiModelBuilder.
src/Clustering/Base/ClusteringBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Classification/MultiLabel/MultiLabelClassifierBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/Classification/ClassifierBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/CausalInference/CausalModelBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/AutoML/AutoMLModelBase.cs Adds IModelShape plumbing for model-of-models.
src/AiModelBuilder.cs Adds license configuration, encrypted AIMF save/load paths, and validation.
src/AiDotNet.csproj Adds CI-injected embedded resources for build key + integrity hash.
src/AiDotNet.Serving/Services/ModelRegistryLoader.cs Adds registry auto-load with AIMF type detection (optionally decrypt).
src/AiDotNet.Serving/Security/Licensing/LicenseValidationResponse.cs Adds serving DTO for license validation results.
src/AiDotNet.Serving/Security/Licensing/LicenseValidateRequest.cs Adds serving DTO for validate request.
src/AiDotNet.Serving/Security/Licensing/LicenseInfo.cs Adds serving DTOs for admin license views.
src/AiDotNet.Serving/Security/Licensing/LicenseCreateResponse.cs Adds serving DTO for license creation response.
src/AiDotNet.Serving/Security/Licensing/LicenseCreateRequest.cs Adds serving DTO for license creation request with validation.
src/AiDotNet.Serving/Security/Licensing/IStripeService.cs Adds Stripe integration service contract.
src/AiDotNet.Serving/Security/Licensing/ILicenseService.cs Adds license management service contract.
src/AiDotNet.Serving/Security/Licensing/CheckoutResponse.cs Adds checkout response DTO.
src/AiDotNet.Serving/Security/Licensing/CheckoutRequest.cs Adds checkout request DTO with validation.
src/AiDotNet.Serving/Program.cs Registers license + Stripe services/options.
src/AiDotNet.Serving/Persistence/ServingDbContext.cs Adds EF entities for licensing + Stripe.
src/AiDotNet.Serving/Persistence/Entities/StripeSubscriptionEntity.cs Adds Stripe subscription persistence model.
src/AiDotNet.Serving/Persistence/Entities/StripeCustomerEntity.cs Adds Stripe customer persistence model.
src/AiDotNet.Serving/Persistence/Entities/LicenseKeyEntity.cs Adds license persistence model (incl. escrow secret).
src/AiDotNet.Serving/Persistence/Entities/LicenseActivationEntity.cs Adds activation persistence model.
src/AiDotNet.Serving/Models/ModelInfo.cs Adds shape + encryption metadata exposed by serving.
src/AiDotNet.Serving/Models/IServableModel.cs Adds shape/dynamic shape metadata defaults in serving interface.
src/AiDotNet.Serving/Enums/StripeSubscriptionStatus.cs Adds Stripe subscription status enum.
src/AiDotNet.Serving/Controllers/StripeController.cs Adds public Stripe checkout/portal/webhook endpoints.
src/AiDotNet.Serving/Controllers/LicenseValidationController.cs Adds public license validation endpoint.
src/AiDotNet.Serving/Controllers/InferenceController.cs Updates inference input validation to use shapes/dynamic dims.
src/AiDotNet.Serving/Controllers/Admin/LicensesController.cs Adds admin endpoints for license management.
src/AiDotNet.Serving/Configuration/StripeOptions.cs Adds Stripe configuration options.
src/AiDotNet.Serving/AiDotNet.Serving.csproj Adds Stripe.net dependency.
src/AdversarialRobustness/Safety/ContentClassifierBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
src/AdversarialRobustness/Attacks/AdversarialAttackBase.cs Adds IModelShape + AIMF envelope wrapping on save/load.
.github/workflows/sonarcloud.yml Removes docs deployment job and points to new workflow.
.github/workflows/docs.yml Replaces DocFX workflow with manual marketing website deploy.
.github/workflows/deploy-website.yml Adds Vercel production deploy for website.
.github/workflows/deploy-serving.yml Adds Azure App Service deploy for Serving API.
.github/workflows/automated-release.yml Injects build signing key during release builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/src/lib/supabase.ts Outdated
Comment thread website/src/content/docs/reference/yaml-configuration.md
Comment thread src/AiModelBuilder.cs Outdated
Comment thread src/AiModelBuilder.cs Outdated
Comment thread src/AiModelBuilder.cs
Comment thread src/AiModelBuilder.cs Outdated
Comment thread src/Helpers/AssemblyIntegrityChecker.cs Outdated
Comment thread src/Classification/MultiLabel/MultiLabelClassifierBase.cs
Comment thread src/AiDotNet.Serving/Controllers/StripeController.cs
Comment thread src/AiModelBuilder.cs Outdated
Use explicit null check pattern instead of IsNullOrWhiteSpace to avoid
CS8602 on net471 where NotNullWhen attribute is not available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 133 out of 208 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • src/AiDotNet.Serving/Persistence/Migrations/20260304000000_AddLicensingAndStripeEntities.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Optimizers/OptimizerBase.cs Outdated
Comment thread src/Classification/ClassifierBase.cs Outdated
Comment thread src/AiDotNet.Serving/CONFIGURATION.md
Comment thread src/AiDotNet.Serving/CONFIGURATION.md Outdated
Comment thread src/AiDotNet.Serving/Program.cs Outdated
…stry

- Remove overly restrictive 16-char minimum length check from offline
  license validation (ValidateOffline) - any non-empty key is valid in
  offline-only mode
- Fix ModelTypeRegistry.CreateInstance factory lookup to search registered
  type aliases when the factory is registered under a different name than
  the type's short Name property

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add HasHeader() guard before ExtractPayload in OptimizerBase.LoadModel
  and ClassifierBase.LoadModel for legacy file compatibility
- Change Stripe config section from "StripeOptions" to "Stripe" in
  Program.cs to match CONFIGURATION.md env var prefix
- Fix webhook URL in CONFIGURATION.md to match controller route
  (/api/webhooks/stripe)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 133 out of 208 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • src/AiDotNet.Serving/Persistence/Migrations/20260304000000_AddLicensingAndStripeEntities.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/src/components/SEO.astro Outdated
Comment thread src/Regression/DecisionTreeAsyncRegressionBase.cs Outdated
…uard

- Fix SEO.astro base-path stripping: normalize base by removing trailing
  slash before slicing to prevent broken canonical URLs like t/docs/...
- Add HasHeader() guard in DecisionTreeAsyncRegressionBase.LoadModel for
  legacy file compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
Preview – website — c256175b Deployed Mar 5, 2026 by vercel[bot]
Preview – aidotnet-playground-api — c256175b Deployed Mar 5, 2026 by vercel[bot]
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.

2 participants