29 new files publish factory infra (V2 autoscaler with live VRAM sampling + EWMA peak tracking, HUGE solo-dispatch, two-tier DLQ/rDLQ classifier + retry), general quantum circuit primitives (Cuccaro ripple-carry adder, Clifford gate library, Clifford tableau simulator, mod-arith family, dialog GCD reversible inverse, Karatsuba multiplier, Solinas fast reduction), and a TCRAUDT reducer harness. Originally developed in ~/git/www.foxhop.net/ecdsa/ for secp256k1 attack-surface research; published upstream as obligated by AGPLv3. Parametrization contract at factory/CONTRACT.md. Consumers export LUMBDA_REPO_DIR + LUMBDA_QUEUE_DIR + LUMBDA_BACKEND_CMD + LUMBDA_EMITTER_CMD then exec factory scripts. No fork-and-modify; single source of truth upstream. Integration tests gate 7 V2 defect classes that wedged a live factory on 2026-06-12 (skewed-demand starve, zero-floor reservation, multi-tier greedy, +-25%% damping, cold-start ramp, DLQ surge halve, post-damp CPU ceiling) + 28 DLQ classifier cases (auto-retry vs escalate partition) + bash -n syntax lint across every script. GPU backend stays in consumer trees; rationale in factory/GPU-BACKEND-NOTE.md. Bend wire protocol + gpu-worker.lsp already upstream at examples/cuda-fanout/. make factory-lint bash -n on every factory/*.sh make test-integration V2 reducer + DLQ classifier + syntax gate make sweep-doctrine TCRAUDT reducer gate (serial) make sweep-doctrine-parallel xargs -P fan-out Verified on neoblanka: factory-lint 12 scripts PASS; test-integration 14 V2 cases + 28 DLQ classifier cases + 12 syntax cases all PASS.
73 lines
3.4 KiB
Text
73 lines
3.4 KiB
Text
;;; sweep-doctrine/lib.lsp - shared harness for every doctrine reducer.
|
|
;;;
|
|
;;; Upstream lumbda hosts a generic helper layer: assertion macro,
|
|
;;; fresh-register builders, single-line verdict printer. Domain repos
|
|
;;; (foxhop ecdsa) extend with primitives that load domain substrate &
|
|
;;; baseline flag-set; those live under $LUMBDA_DOMAIN_DIR/tests/sweep-doctrine/.
|
|
;;;
|
|
;;; AGPLv3.
|
|
|
|
;; Each reducer prints exactly one line:
|
|
;;
|
|
;; DOCTRINE <name> PASS got=<actual> expected=<expected>
|
|
;; DOCTRINE <name> EXPECTED-FAIL got=<actual> expected=<expected>
|
|
;; DOCTRINE <name> FAIL got=<actual> expected=<expected>
|
|
;; DOCTRINE <name> UNEXPECTED-PASS got=<actual> expected=<expected>
|
|
;;
|
|
;; Runner gates on third-token verdicts only; data lines stay free.
|
|
|
|
(define (doctrine-report name expected-pass? got expected)
|
|
"One-line summary. expected-pass? #t = positive control (PASS on match).
|
|
#f = open defect alarm (EXPECTED-FAIL on mismatch, UNEXPECTED-PASS on match)."
|
|
(let* ((match? (equal? got expected))
|
|
(status (cond
|
|
((and expected-pass? match?) "PASS")
|
|
((and expected-pass? (not match?)) "FAIL")
|
|
((and (not expected-pass?) match?) "UNEXPECTED-PASS")
|
|
(else "EXPECTED-FAIL"))))
|
|
(display "DOCTRINE ") (display name)
|
|
(display " ") (display status)
|
|
(display " got=") (display got)
|
|
(display " expected=") (display expected)
|
|
(newline)
|
|
(or (and expected-pass? match?)
|
|
(and (not expected-pass?) (not match?)))))
|
|
|
|
;; assertion shorthand - returns #t on equality, #f otherwise. Reducer authors
|
|
;; combine several `doctrine-assert-eq` results then call `doctrine-report` once.
|
|
(define (doctrine-assert-eq label got expected)
|
|
"Print one data line per check; return #t on match. Use for multi-axis reducers
|
|
where many rows fan out under one summary verdict."
|
|
(let ((match? (equal? got expected)))
|
|
(display " ") (display label)
|
|
(display " got=") (display got)
|
|
(display " expected=") (display expected)
|
|
(display " ") (display (if match? "OK" "MISS"))
|
|
(newline)
|
|
match?))
|
|
|
|
;; mod-expt - square-and-multiply over a prime.
|
|
;; Required because `(expt a e)` builds |a|^|e| BEFORE applying modulo;
|
|
;; at p near 2^31 & e = p-2 a literal expansion hangs lumbda. Six
|
|
;; reducer instances stacked indefinitely (oldest 13h 58m) until this
|
|
;; helper surfaced 2026-06-11.
|
|
(define (mod-expt base exp p)
|
|
(let loop ((b (modulo base p)) (e exp) (acc 1))
|
|
(cond
|
|
((= e 0) acc)
|
|
((odd? e) (loop (modulo (* b b) p) (quotient e 2) (modulo (* acc b) p)))
|
|
(else (loop (modulo (* b b) p) (quotient e 2) acc)))))
|
|
|
|
;; Domain substrate loader. If LUMBDA_DOMAIN_DIR points at a consumer
|
|
;; repo (foxhop ecdsa) AND that domain ships a `tests/sweep-doctrine/domain-lib.lsp`
|
|
;; file, load it for domain-specific helpers (baseline flag-sets,
|
|
;; circuit builders, expected-truth-table comparators).
|
|
;;
|
|
;; Pattern: upstream reducers stay primitive-level; domain reducers
|
|
;; live downstream & import upstream's lib + their own domain-lib.
|
|
;;
|
|
;; Note: getenv may or may not exist in every lumbda tier. Guard with
|
|
;; load-time check so a missing primitive never crashes a reducer that
|
|
;; ignores domain-lib entirely.
|
|
;; Disabled by default - domain reducers explicitly `(load "tests/sweep-doctrine/domain-lib.lsp")`
|
|
;; from their own $LUMBDA_DOMAIN_DIR cwd. Upstream lib.lsp stays minimal.
|