This repository implements an artifact-driven educational lab for exploring:
- Supervised Autoencoders (AE)
- Gaussian Mixture VAEs (GM-VAE)
- Latent projections (PCA / UMAP 2D & 3D)
- kNN neighbor graphs
- Interactive visualization and interpretation tools
Your role as an agent is to extend and improve the system while preserving its architectural guarantees.
This document defines those guarantees.
The frontend must never recompute ML results.
All embeddings, projections, distances, neighbors, uncertainty metrics, and derived model quantities:
- Are computed in Python
- Persisted as artifacts
- Loaded and rendered by the frontend
Frontend may compute:
- Pixel transforms
- Camera transforms
- Pure UI state
- Visual scaling based on persisted data
Frontend must not compute:
- Latent embeddings
- PCA/UMAP
- Distance matrices
- kNN graphs
- Sampling from model distributions
Training, projections, neighbors, sampling, feature extraction, uncertainty metrics, etc. are:
- Implemented in Python
- Versioned via artifact output
- Persisted per-epoch
Visualization work must not silently modify training semantics.
If training behavior changes:
- It must be explicit
- It must be documented
- Tests must reflect it
All time-varying artifacts must follow:
*_epoch_<N>.json*_latest.json
Runs live under:
runs/<run_id>/
Typical structure:
config.json
events.jsonl
projections/
neighbors/
samples/
checkpoints/
When introducing a new artifact type:
- Provide per-epoch + latest
- Keep schema stable and minimal
- Ensure deterministic regeneration
For a given:
- run
- epoch
- projection method
- visualization settings
Rendering should be stable and reproducible.
Avoid:
- Random jitter
- Order instability
- Implicit sorting differences
Unless randomness is intentional and persisted.
SSE powers live updates.
Rules:
- Prefer additive schema changes
- Do not rename event types casually
- Update backend schemas and frontend TypeScript types together
- Do not silently break event parsing
The system must remain usable at ~100–200 focused points.
When modifying visualization logic:
- Avoid O(N²) recomputation on slider drag
- Memoize expensive transforms
- Avoid recomputing neighbor lists unnecessarily
- Keep projection scaling method-aware (PCA ≠ UMAP)
- Use correct dimensional distance formulas (2D vs 3D)
When adding new gating/scaling logic:
Expose debug stats in a collapsible debug panel.
Do not rely only on console logging.
- Functional React components only
- Explicit numeric clamping
- No implicit type coercion
npx tsc --noEmitmust pass- No silent failure paths
- Errors must be surfaced in UI
- Derived data should use
useMemo
Rendering must remain artifact-driven.
- No training logic inside route handlers
- Long-running work happens in background jobs
- Always check cancellation flags
- Never block the request loop
- Keep modules small and testable
- Prefer additive changes over refactors
- Inspect code
- Propose improvements
- Offer 1–2 structured approaches
- Recommend a direction
- Implement scoped changes
- Keep diffs minimal
- Run safe checks
- Provide verification steps
Switch to execute mode automatically if:
- Change is localized
- No schema contracts are altered
- No training semantics are modified
Be cautious if touching:
- Artifact schema
- SSE schema
- Training loop
- Run lifecycle
Call out those changes explicitly.
You are allowed to run the following without approval:
ls,tree,findcat,sed,rg,grepgit status,git diff,git log
cd frontend && npx tsc --noEmitcd frontend && npm run buildcd frontend && npm run lintcd frontend && npm test(if configured)
uv run pytest -q backend/testsuv run python -m compileall .
Rule: If pytest fails due to environment issues, install missing dev dependencies with uv add --dev <pkg> and retry. Do not fallback to unittest.
You must ask before:
- Adding major new dependencies
- Upgrading large dependency trees
- Deleting runtime data (
runs/) - Running destructive filesystem commands
- Rewriting git history
Confirm:
- Frontend still loads prior runs deterministically
- No ML recomputation was introduced in frontend
- SSE still functions
- TypeScript compiles
- Tests pass (or explain failures)
- Backend tests were run with
uv run pytest - New artifacts (if added) follow per-epoch + latest pattern
Favor:
- Stability over novelty
- Additive improvements over refactors
- Smooth visual behavior over mathematically abrupt gating
- Clear debug instrumentation over hidden logic
- Architectural consistency over clever shortcuts
When uncertain, choose the path that preserves artifact purity and determinism.
This is the governing document for all future development.