Alete Gate is a high-performance, privacy-first ingestion and classification layer for the Alete ecosystem. It serves as a "Sovereign Threshold"βidentifying sensitive transactional portals (banking, health, PII) locally on-device before any data is processed for analysis.
- Contextual Transformer Classification: High-fidelity native inference using Apple's
NLContextualEmbedding(BERT) transfer learning substrate. - Adaptive Tokenization: Preserves natural language lowercase context during ingestion to retain semantic signals for transformer embeddings.
- camelCase Feature Namespaces: Transforms synthetic attributes (e.g.,
urlHostGithubCom) to preventNLTokenizersplit leakage. - Layout Density Detection: Automatically detects text-to-link ratio to append structural helper flags (
layoutHighTextDensity/layoutHighLinkDensity). - Semantic Metadata Extraction: Powered by
@mdream/jswith fallback heuristics to extract titles and descriptions from fragmented HTML. - WXT-Optimized: Zero-dependency browser bundle (332KB) with Node.js shims, ready for Safari and Chrome extensions.
Based on the latest Strategic Verification Audit conducted on the on-device MobileBERT sequence classifier:
- Main Training Set (Balanced): 820 samples
- Staging Holdout Test Set (Generalization): 280 samples
| Metric | Legacy Baseline (PrivacyGatekeeper) |
New MobileBERT (Quantized INT4) |
Delta |
|---|---|---|---|
| Accuracy | 55.71% | 76.79% | +21.08% |
| Avg. Inference Latency | 14.99 ms | 5.34 ms | -9.65 ms (2.8x faster) |
| False Negatives (Leaks) | 94 | 4 | -90 leaks (18x safer) |
| Model Size | 1.3 MB | 13.0 MB | INT4 Quantized |
| Category | Precision | Recall (Success Rate) | F1 Score | Support |
|---|---|---|---|---|
privacy_work |
98.88% | 96.70% | 97.78% | 91 |
noise |
89.12% | 84.52% | 86.75% | 155 |
informational |
50.00% | 64.52% | 56.34% | 31 |
communication |
25.00% | 33.33% | 28.57% | 3 |
Tests executed on the quantized MobileBERTGatekeeper model (v3.1.0) using the native Swift package unit tests and the Python verification harness.
This flowchart illustrates how a raw web page's HTML is extracted, sanitized, tokenized, and classified on-device without leaking user activity:
graph TD
HTML[Raw HTML Page] -->|M-Dream Parser| MD[Markdown + Structural Tags]
MD -->|PII Redaction & Formatter| Norm[Linguistic Input Normalizer]
Norm -->|Semantic Cap: 300 chars| Prompt[Normalized Prompt String]
Prompt -->|BERTTokenizer vocab.txt| Tokens[WordPiece Token IDs]
Tokens -->|CLS, SEP Padding/Clamping to 128| InputProvider[MobileBERTInputProvider]
InputProvider -->|input_ids, attention_mask, token_type_ids| ML[MobileBERT MLModel]
ML -->|Softmax over Logits| Pred[Class Probability Mapping]
Pred -->|Argmax Label| Output[Result: privacy_work, informational, communication, noise]
- TypeScript (Browser/Node):
Call
processHtmlfrom@alete-ai/gate-ingestto extract the normalized text and structural tokens. - Swift (iOS/macOS):
Instantiate
GateClassifierto automatically compile, tokenize, and execute standard Core ML prediction.
This flowchart illustrates the end-to-end retraining flow, combining raw production telemetry with gap-filling synthetic templates to produce the optimized Core ML model:
graph TD
MongoDB[MongoDB Raw Staging Extractions] -->|pnpm retrain| Pull[Fetch Telemetry Data]
Templates[Synthetic Privacy & Work Templates] -->|Generate Gap Fillers| Comp[Dataset Compiler]
Pull --> Comp
Comp -->|Vertex Gemini 3.5 Flash| Label[LLM Ground-Truth Labeler]
Label -->|Linguistic Normalizer Parity| Dataset[Compiled Train/Test Curation Sets]
Dataset -->|PyTorch Fine-Tuning venv| PyModel[MobileBERT PyTorch Model]
PyModel -->|coremltools FP16 Convert| CoreML[Core ML Package]
CoreML -->|coremltools Quantization| INT4[INT4 Quantized Model 13MB]
INT4 -->|verify_mobilebert.py & swift test| Audit[Strategic Verification Audit]
To retrain the model and build the compiled Core ML targets:
- Ensure your local virtual environment is active and contains
transformers,torch, andcoremltools. - Configure your MongoDB staging cluster variables and Vertex Google project credentials.
- Run the retraining script in the project root:
This will sequentially pull telemetry data, label the entries, compile datasets, fine-tune the PyTorch MobileBERT classifier, convert it to Core ML, quantize it to INT4, and verify the accuracy.
pnpm run retrain
The unified pipeline for converting HTML into structural tokens and semantic Markdown.
Installation:
pnpm add @alete/gate-ingestUsage (Browser/Node):
import { processHtml } from '@alete-ai/gate-ingest';
const html = "<html>...</html>";
const { structural, semantic } = await processHtml(html);The native Apple Intelligence bridge for on-device classification.
Integration (SPM):
Add this repository to your Xcode project or Package.swift:
.package(url: "https://github.com/alete-ai/gate.git", branch: "main")These snippets are optimized for high-performance integration and clear semantic understanding by AI agents.
import { processHtml } from '@alete-ai/gate-ingest';
/**
* Capture and Purify
* This recipe prepares content for classification.
*/
async function capturePage() {
const html = document.documentElement.outerHTML;
const { structural, semantic } = await processHtml(html);
return structural; // Prepared for local classification
}import AleteGateKit
import CoreML
/**
* Edge Classification Loop
* Evaluates structural tokens against the PrivacyGatekeeper model.
*/
func classifyContent(tokens: String) async throws -> String {
let gatekeeper = try PrivacyGatekeeper()
let prediction = try gatekeeper.prediction(text: tokens)
// returns 'privacy_work', 'informational', 'communication', or 'noise'
return prediction.label
}# Install dependencies
pnpm install
# Build all packages (including browser-optimized ESM)
pnpm build
# Run native substrate tests
cd ios/AleteGateKit && swift test./scripts/build_xcframework.shAlete Gate prioritizes Cognitive Sovereignty by ensuring all classification happens on the edge substrate. We utilize empirical performance tracking to ensure the highest possible recall on sensitive portals while maintaining a friction-less user experience.
AGPL-3.0 - Copyright (c) 2026 Alete Inc. https://github.com/StoyanD