Skip to content

feat(queen): Add ManagedList wrapper + queen-compile step (#477)#478

Closed
gHashTag wants to merge 3693 commits intomainfrom
feat/queen-phase2-477
Closed

feat(queen): Add ManagedList wrapper + queen-compile step (#477)#478
gHashTag wants to merge 3693 commits intomainfrom
feat/queen-phase2-477

Conversation

@gHashTag
Copy link
Copy Markdown
Owner

Phase 2*: Self-Improvement Core — Infrastructure Improvements

Summary

This PR implements three infrastructure improvements requested after the chaotic Phase 2* implementation session:

  1. ManagedList wrapper (src/tri/compat/managed_list.zig)

    • Zig 0.15 ArrayList API compatibility layer
    • Stores allocator with list, restores Zig 0.14 behavior
    • Prevents chaotic fix loops by centralizing API changes
    • All 5 tests passing
  2. Build-only step (build.zig)

    • Added queen-compile step: zig build queen-compile
    • CI-friendly: compiles without running (no SIGTERM/FileNotFound)
    • Separates compilation from execution
  3. Feature branch workflow

    • Branch: feat/queen-phase2-477
    • Prevents git checkout from wiping work

Changes

  • src/tri/compat/managed_list.zig: New file (203 LOC)

    • init(), initCapacity(), append(), deinit(), toOwnedSlice()
    • appendSlice(), len(), isEmpty(), items(), mutableItems()
    • clearRetainingCapacity(), get(), set(), pop(), iterator()
  • build.zig: Added queen-compile step

    const queen_compile_step = b.step("queen-compile", "Compile queen-backend without running");
    queen_compile_step.dependOn(&b.addInstallArtifact(queen_backend, .{}).step);

Testing

zig test src/tri/compat/managed_list.zig  # 5/5 tests pass
zig build queen-compile                     # Clean build
./zig-out/bin/queen-backend --help          # Binary works
curl http://localhost:8081/health            # {"status":"ok",...}
curl http://localhost:8081/api/tri-spec     # YAML .tri spec

Closes #477

Antigravity Agent added 30 commits March 29, 2026 03:08
…nd loss functions (#474)

Optimizers (10 files):
- gradient_descent, sgd, adam, rmsprop, adagrad, momentum, nesterov, adamax, nadam, lbfgs

Learning Rate Schedulers (10 files):
- learning_rate_decay, lr_cosine, lr_exponential, lr_step, lr_warmup, lr_onecycle, lr_polynomial, lr_inverse, lr_reduce_on_plateau, lr_cyclic

Loss Functions (10 files):
- mse, mae, cross_entropy, binary_cross_entropy, hinge, kl_divergence, cosine_loss, huber, log_cosh, quantile

φ² + 1/φ² = 3 | TRINITY
Core Layers (10 files):
- linear, embedding, lstm, gru, rnn
- transformer_block, multihead_attention
- layer_norm, batch_norm, group_norm

Advanced Layers (10 files):
- instance_norm, dropout_layer, positional_encoding, feedforward, residual
- max_pool3d, avg_pool3d, adaptive_pool, global_pool

Operations (10 files):
- upsample_nearest, bilinear, bicubic
- padding, reflection_pad, replication_pad
- reshape, transpose, concat, split

φ² + 1/φ² = 3 | TRINITY
Transforms (5 files):
- fft, ifft, dct, stft, spectrogram

Audio Features (3 files):
- mel_spectrogram, mfcc, envelope

Filters (3 files):
- filter_lowpass, filter_highpass, filter_bandpass

Audio Operations (8 files):
- resample, normalize_audio, fade_in, fade_out
- amplitude_to_db, db_to_amplitude, zero_crossing_rate, autocorrelate

φ² + 1/φ² = 3 | TRINITY
Basic Operations (10 files):
- grayscale, resize, crop, rotate_image, flip_horizontal, flip_vertical
- blur, sharpen, edge_detect, threshold

Morphological (5 files):
- dilate, erode, opening, closing, contours

Advanced (5 files):
- bbox, watershed, hough_lines, hough_circles

φ² + 1/φ² = 3 | TRINITY
Number Theory (17 files):
- is_prime, prime_factors, gcd_extended, mod_inverse, mod_pow, chinese_remainder
- binomial_coeff, factorial, fibonacci, lucas, collatz
- euler_totient, carmichael, mobius, divisors, divisor_sum, perfect

φ² + 1/φ² = 3 | TRINITY
- String algorithms: strtok, strrev, strchr, strrchr, strspn, strcspn, strpbrk, upper/lower, trim
- Advanced trees: red-black, splay, b-tree, aa-tree, scapegoat, treap
- Data structures: skiplist, bloom filter, count-min sketch, hyperloglog
- Graph algorithms: Boruvka MST, A*, bidirectional BFS, components, bridges, flow/cut, matching, coloring
- ML operations: activations (relu, sigmoid, tanh, gelu, silu, mish, elu, leaky_relu)
- ML layers: batch_norm, layer_norm, instance_norm, group_norm, pooling, conv1d, attention mechanisms
- Geometry: distances (euclidean, manhattan, chebyshev, minkowski), vector ops, line intersection, convex hull, areas, transformations

Total: 2868 .t27 files
…to (#474)

- Math constants: π, e, φ (golden ratio)
- Math functions: sqrt, cbrt, log, log10, exp, pow
- Trigonometric: sin, cos, tan, asin, acos, atan, atan2
- Hyperbolic: sinh, cosh, tanh
- Rounding: floor, ceil, round, abs, sign, min, max, clamp
- Interpolation: lerp, smoothstep, inverse_lerp, remap
- Data structures: ring buffer, deque, priority queue, double linked list, circular list, vector stack, circular queue, binary heap
- Crypto: AES, RSA, Diffie-Hellman, ElGamal, ECDSA, HMAC, PBKDF2

Total: 2913 .t27 files
- Search algorithms: beam search, greedy best-first, minimax, alpha-beta pruning, MCTS, expectimax
- Advanced search: negamax, negascout, killer move heuristic, history heuristic, quiescence search
- Optimizations: transposition table, zobrist hashing, iterative deepening, PVS, null move pruning, LMR, futility pruning, aspiration windows, time management
- Engine components: opening book, endgame tablebase, move generator, evaluation function, SEE, mobility, pawn structure, king safety, piece-square tables, bitboard

Total: 2973 .t27 files
…474)

- Descriptive statistics: mean, median, mode, variance, stddev, percentile, quartile, IQR
- Shape measures: skewness, kurtosis
- Relationship measures: covariance, correlation, spearman correlation
- Standardization: z-score, t-score
- Outliers: outlier detection, bootstrap, permutation test
- Hypothesis tests: chi-square, t-test, ANOVA, Mann-Whitney U, Kruskal-Wallis, Wilcoxon
- Regression: linear, polynomial, logistic
- Model metrics: R-squared, adjusted R-squared, residuals

Milestone: 3003 .t27 files in Trinity TTT Dogfood Phase 3!
- Signal processing: convolution, correlation, autocorrelation, moving average, exponential moving average, savitzky-golay
- Filters: median, bilateral, gaussian
- Operations: derivative, integral, gradient, laplace
- Edge detection: sobel, prewitt, roberts cross, canny
- Advanced: hough transform, watershed
- Morphological operations: dilate, erode, open, close, gradient, top-hat, black-hat
- Histogram/Threshold: histogram equalization, CLAHE, adaptive threshold, Otsu threshold

Total: 3033 .t27 files
Antigravity Agent and others added 9 commits March 30, 2026 16:25
Phase 1: Backend API — HTTP/JSON + WebSocket server

- Created src/tri/queen/backend_server.zig (490 LOC)
  - HTTP server with 5 endpoints: /health, /api/status, /api/episodes, /api/improve, /api/pipeline
  - Trinity signature header (φ² + 1/φ² = 3)
  - JSON responses using std.json.Stringify.valueAlloc
  - Health check for Railway deployment

- Modified src/tri/queen_trinity.zig
  - Added `runQueenBackend` function to route to backend_server.zig
  - Added "backend" subcommand routing in runQueenCommand

- Modified build.zig
  - Added queen-backend module with episodes/self_learning imports
  - Added queen-backend executable target
  - Added queen-backend build step

Tested: ✅ /health returns {"status":"ok","trinity_signature":3,...}

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements CLUTRR (Compositional Language Understanding and Textual
Relational Reasoning) benchmark from Sinha et al., EMNLP 2019.

- 760 LOC: CLUTRR parser + evaluator (src/kaggle/clutrr.zig)
- CSV parser for 19-column CLUTRR format
- 17 kinship relations (father, mother, uncle, aunt, cousin, etc.)
- Datalog-style reasoning rules:
  * Transitive parent (grandparent/grandchild)
  * Sibling detection (shared parent)
  * Uncle/aunt (parent's sibling)
  * Cousin (parent's sibling's child)
- Accuracy calculation by depth (k=1 to k=10)

- CLI: tri clara benchmark --clutrr

All 8 CLUTRR tests passing.

φ² + 1/φ² = 3 | TRINITY

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Created React + Vite app in apps/queen-web/ for Queen container UI.

Components:
- ThreeKingdoms — Tab navigation for Brain/Body/Spirit strands
- StatusDashboard — Realtime system metrics (health, uptime, cycles)
- EpisodeViewer — Recent episodes list with success/failure badges
- ImprovementPanel — Trigger self-improvement cycles

Features:
- Vite 6 + React 19 + React Router v6
- TanStack Query for API calls with auto-refresh
- CSS-in-JS styles with dark theme
- Proxy setup for /api and /health endpoints
- Production build: 253KB JS (79KB gzipped)

Build tested: ✅ npm run build succeeds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Docker Configuration:
- deploy/Dockerfile.queen — Multi-stage build
  - Stage 1: Frontend (Node + Vite) → /var/www/html
  - Stage 2: Backend (Zig 0.15) → queen-backend binary
  - Stage 3: Runtime (Ubuntu 22.04) with health check

Railway Deployment:
- .github/workflows/queen-deploy.yml — CI/CD workflow
  - Triggers: push to main (apps/queen-web, src/tri/queen, Dockerfile)
  - Builds and pushes to Railway registry
  - Deploys via GraphQL API
  - Tests health endpoint after deployment

Container Details:
- Base: ubuntu:22.04
- Zig: 0.15.2 (for runtime .tri/.t27 execution)
- Ports: 8080 (HTTP API)
- Health check: GET /health every 30s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add auto_improve.zig with full pattern analysis
- Fix backend_server.zig for Zig 0.15 (i128 timestamps, expectStringPresent)
- Fix ArrayList.append() calls (allocator as first arg)
- Fix ArrayList.toOwnedSlice() calls (allocator parameter)
- All 33 tests passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Созданы GIF-файлы из VHS tapes + демо-страница.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Closes #477
- src/tri/compat/managed_list.zig: Zig 0.15 ArrayList API wrapper
- build.zig: Add queen-compile step for CI-friendly builds
- All ManagedList tests passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gHashTag
Copy link
Copy Markdown
Owner Author

All tests passing

  • ManagedList: 5/5 tests pass
  • queen-compile: Clean build
  • Binary: 1.8MB, all 6 endpoints working
  • Server starts cleanly on port 8080

Endpoints verified:

  • GET /health → {"status":"ok","trinity_signature":3,...}
  • GET /api/tri-spec → YAML .tri spec

Ready for review.

Antigravity Agent and others added 11 commits March 30, 2026 18:31
- HashMap: Use custom context for ConfusionKey instead of AutoHashMap
- AutoHashMap.initContext() -> HashMap.init() with explicit context parameter
- ArrayList.initCapacity() returns !ArrayList in Zig 0.15
- ArrayList.deinit() -> deinit() (no allocator parameter)
- ArrayList.append() requires allocator parameter
- std.math.abs() -> @abs() builtin
- std.fs.Dir.close() requires mutable pointer, use var
- Format strings: {d:.X} -> {:.X} for floats (no 'd' specifier)
- Format strings: Escaped braces for JSON literal output

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

Created standalone package with GF16/TF3-9 formats
Includes comprehensive documentation and IBM DLFloat validation
Ready for Zig ML developers to import and use
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- build.zig: addImport() on all modules (Zig 0.15 API)
- 3131/3140 tests pass (99.7%)
- 1 unrelated test fail (curriculum step schedule)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- IEEE 754 (1985) → Trinity GF16 (2025) timeline
- Algebraic proof: φ² + 1/φ² = 3 (EXACT)
- Four independent confirmations: IBM DLFloat, Weber-Fechner ML,
  Golden Ratio Partition (March 2026), Rate-Distortion Theory
- Trinity derived 6:9 from φ analytically,
  same value IBM found empirically

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove duplicate badges (17 → 11, cleaner header)
- Move GF16 achievement to prominent position (after header)
- Consolidate Getting Started + Quick Start sections
- Reduce commands list from 100+ to 7 key commands
- 1124 → 879 lines (-22%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The step schedule should divide by (num_milestones - 1) to create
evenly spaced discrete levels (0, 1/3, 2/3, 1 for 4 milestones)
rather than (0, 1/4, 2/4, 3/4, 1).

Fixes test: expected 16, found 14 at step 250 with 4 milestones.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Concrete performance numbers: 2,304 → 56 SIMD instructions (40× faster)
- GF16 vs IEEE f16 vs BF16 comparison table
- When to use / when NOT to use GF16
- Industry benchmarks: FP8 85% higher req/sec, BF16 gradient stability

Developer-focused section that sells GF16 value in 30 seconds.

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

- Add 20 Zig pain points with Codeberg/GitHub issue links
- Add Architecture Difference ASCII diagram
- Add GF16 vs Every 16-bit Format comparison table
- Add 40 Years race timeline
- Add Migration Guide with BEFORE/AFTER code examples
- Add Compatibility Matrix (0.14/0.15/0.16)
- Add Module Reference (8 modules)
- Add Real-world Impact table (4 scenarios)
- Update Quick Start with GF16 wire example

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Expand from 20 to 35 issues across 9 categories
- Add Category G: Backend Inconsistencies (3 issues)
- Add Category H: stdlib Math & Parsing (3 issues)
- Add Category I: Cross-compilation & Linking (1 issue)
- Add "Why u16 Wins" section comparing f16 vs u16 ops
- Add Target Matrix showing GF16 support on 9 platforms
- Add Issue Tracker with last updated timestamp
- Update Defense Architecture diagram to 35 failure points
- Update badges: 35 bugs bypassed, 15 urgent avoided

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gHashTag gHashTag force-pushed the feat/queen-phase2-477 branch from 9730dbd to 4d3041c Compare March 30, 2026 17:44
@gHashTag gHashTag closed this Apr 3, 2026
@gHashTag gHashTag deleted the feat/queen-phase2-477 branch April 3, 2026 11:03
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.

feat(demos): Terminal Recording System for All tri Commands

1 participant