PureOne's picture
Publish Qyxo-Zhaenivoth Guard v1.0.0 research release
25c6e75 verified
|
Raw History Blame Contribute Delete
12.3 kB

Qyxo-Zhaenivoth Guard 1.0.0

Exact weighted-average bounds for sparse mass streams, with an optional fixed-total constraint.

Author: Artificial Hyperintelligence Eve (research pseudonym). Prepared for Maciej Nowicki. MIT license; Python 3.10 or newer.

Qyxo-Zhaenivoth Guard answers a practical policy question: does every allowed weighted average satisfy a threshold? Values can have signed intervals, weights can have nonnegative intervals, and numerator and denominator retain their shared weights. Version 1.0.0 adds DynamicBank: prepare the value order once, replace a few weight intervals, and obtain exact decisions or sharp bounds without rescanning every row. The same index can enforce a known total weight instead of treating each weight as independent.

The exact runtime needs no NumPy, training, GPU, network or account. Its guarantees apply to the finite binary64 numbers obtained by converting the supplied inputs. CompactDynamicBank is an explicit alternative for lower retained memory. This is a narrow reusable primitive built from established support-function, fractional-optimization and Fenwick-tree mathematics. Mathematical novelty and superiority across all algorithms are not established.

Run immediately

Unpack the complete release and run:

python examples/dynamic_policy.py
python START_HERE.py demo --backend exact

The dynamic example works from any working directory when invoked by its full path. It imports the source package directly. The older exact demo and JSONL CLI remain available; the mutable dynamic interface is a Python API, not a new streaming CLI command.

For an offline installation from the bundled wheel, run from the release directory:

python -m pip install --no-index --no-deps wheels/qyxo_zhaenivoth_guard-1.0.0-py3-none-any.whl

After installation, from qzguard import DynamicBank works outside the source directory. Source installation is python -m pip install .. The optional full-array filter is installed with python -m pip install '.[filter]'; it adds NumPy and may need network access. The dynamic index itself is always exact and does not use the optional filter.

One example showing the added capability

from fractions import Fraction
from qzguard import DynamicBank

bank = DynamicBank(
    value_lower=[0, 100],
    mass_lower=[1, 1],
    mass_upper=[10, 10],
)

# Independent weights can select a high mean: the guarantee fails.
assert not bank.query(60).all_guaranteed

# A known total weight excludes that configuration.
assert bank.query(60, total_mass=19).all_guaranteed
fixed = bank.enclose(total_mass=19)
assert fixed.lower == (Fraction(900, 19),)
assert fixed.upper == (Fraction(1000, 19),)

# Replace only row 0. No value order or unaffected tree path is rebuilt.
old = bank.enclose()
bank.update(indices=[0], mass_lower=[2], mass_upper=[9])
assert bank.enclose().lower == (Fraction(10),)
assert old.revision == 0 and bank.revision == 1

The fixed-total answer is exact for the constrained feasible set, including configurations with one weight inside its interval. Merely checking independent box corners would miss some constrained extrema. False means a violating configuration exists in the declared model; it does not mean every configuration violates the policy.

How it works

For each coordinate, the average is

Y=N0+∑iwiviD0+∑iwi,Li≤wi≤Ui,li≤vi≤hi. Y=\frac{N_0+\sum_i w_i v_i}{D_0+\sum_i w_i},\qquad L_i\le w_i\le U_i,\quad l_i\le v_i\le h_i.

All masses and D0 are nonnegative, and D0 + sum(L) > 0 is required. Define the interval widths delta = U - L. Start with the lower weights as the baseline. An upper threshold support adds width only where h_i > T; a lower support adds it only where l_i < T:

F+(T)=N0+∑iLihi−T(D0+∑iLi)+∑hi>T(Ui−Li)(hi−T), F_+(T)=N_0+\sum_iL_ih_i-T(D_0+\sum_iL_i) +\sum_{h_i>T}(U_i-L_i)(h_i-T),

F−(T)=N0+∑iLili−T(D0+∑iLi)+∑li<T(Ui−Li)(li−T). F_-(T)=N_0+\sum_iL_il_i-T(D_0+\sum_iL_i) +\sum_{l_i<T}(U_i-L_i)(l_i-T).

The universal claims are exactly F_plus <= 0 for <= and F_minus >= 0 for >=. A Fenwick tree stores the sum of widths and the sum of width-times-value over the static value order. A sparse replacement changes only logarithmically many summaries. Thresholds use prefix moments; sharp ratio endpoints locate the support root in one binary-lifting traversal per endpoint. There is no tolerance or repeated numerical bisection.

With a fixed total W, the denominator is fixed. Fill the available width capacity from the lowest values for the minimum, or the highest values for the maximum, stopping at an exact partial boundary weight. The same two tree moments provide the capacity selection and numerator subtotal. DYNAMIC_THEORY.md gives the derivation and DYNAMIC_API.md specifies the interface.

Cost and when to choose it

For M rows, P coordinates and K replaced rows, preparation requires O(P M log M) comparisons and O(P M) state. A patch requires O(K P log M) integer operations; a threshold query or sharp enclosure requires O(P log M) integer operations. Equal lower and upper value columns share their ordering and moment trees.

These are arithmetic-operation bounds, not constant-time machine-operation claims. DynamicBank fixes the mass scale at 2**-1074, so a later subnormal or extremely large finite mass never triggers a global rescale. Wide exact integers increase memory and arithmetic costs. Returned Fraction values also incur exact reduction costs. Public mass getters copy all M entries; snapshot() deliberately performs a full immutable copy. Those operations are outside the logarithmic query claim.

CompactDynamicBank stores each moment node at its own canonical dyadic scale. A finer mass exponent changes only global summaries and affected paths; removing that precision lets those nodes recover their compact representation. There is no precision parameter or automatic backend switch. The historical global scale remains fine, so later queries can still pay for wide temporary alignment. Local bookkeeping can increase latency; DYNAMIC_RESULTS.md separates its memory tradeoff from the default latency result.

In the shipping two-seed development pilot with 4,096 rows and one/four coordinates, compact storage used 2.16–2.53× less approximate retained payload. One-row patch latency was similar; eight-row patches took about 24–30% more hot time by median paired ratios. This is a descriptive memory/latency tradeoff, with no holdout superiority claim or process-RSS guarantee.

from qzguard import CompactDynamicBank

compact = CompactDynamicBank([0, 100], [1, 1], [10, 10])
assert compact.query(60, total_mass=19).all_guaranteed
compact.update([0], [2], [9])
assert compact.enclose().lower[0] == 10
Workload Recommended approach
Fixed values, sparse mass changes, changing thresholds or sharp bounds DynamicBank
The same model, with retained RAM more important than minimum latency CompactDynamicBank, after measuring its tradeoff
Fixed values, all or most mass intervals replaced each request PreparedBank, optionally with the NumPy filter
One unchanged weight box, many thresholds NormalizedBox.enclose() and cached guard_from_bounds()
One fixed threshold and relation, sparse mass changes Exact per-row support deltas; the benchmark includes this stronger specialization
Scalar record deletion with fixed per-group budgets DeletionGuard

Preparation and extra retained state must amortize over enough requests. Small banks, dense updates and an unchanged box can favor simpler methods. The dynamic index does not claim to beat another well-engineered exact moment index merely because it beats a full rescan. DYNAMIC_RESULTS.md is the authoritative measured scope, including indexed peers, preparation, memory and negative controls. Historical full-array filter measurements remain under their original versions.

Interface and ownership

DynamicBank(value_lower, mass_lower, mass_upper, value_upper=None, *, base_numerator=0, base_denominator=0) accepts scalar values per row or a rectangular row-by-coordinate matrix. Values and bases remain fixed. A scalar base numerator or threshold broadcasts across coordinates.

update(indices, mass_lower, mass_upper) replaces the named intervals and returns the bank. Indices must be distinct integers in range. An empty patch leaves the revision unchanged; a valid nonempty patch advances it once. Boolean, string, nonfinite, invalid-interval and unordered mapping/set inputs are rejected. The complete patch is validated before mutation; validation failures leave the state unchanged. This is not rollback protection against allocation failure or arbitrary user-object side effects. Concurrent mutation requires external synchronization.

query(threshold, relation='<=', total_mass=None) returns a frozen decision with exact eager Fraction supports, thresholds, guarantees, model, revision and work counters. guard is an alias. enclose(total_mass=None) returns frozen sharp rational bounds and tight outward binary64 bounds. Old results remain unchanged after patches. Coordinate extrema can use different weight configurations.

total_mass adds the exact equality sum(w) = W after input conversion. It must lie between the exact sums of the current lower and upper mass bounds. Even constrained mode requires the constructor's positive minimum denominator; zero-baseline models that become valid only after fixing the total are intentionally excluded. snapshot() returns an immutable independent-box NormalizedBox with the existing witness APIs; it does not preserve a fixed-total constraint or supply constrained witnesses.

Reproduce the evidence

python -m unittest discover -s tests -v
python examples/dynamic_policy.py
python -m pip install '.[dynamic-benchmarks]'
python benchmarks/run_dynamic.py --mode pilot --output benchmarks/results_my_dynamic_pilot.json
python benchmarks/run_dynamic.py --mode final --output benchmarks/results_my_dynamic_final.json

The benchmark preserves existing output files, so use a new filename for each run. DYNAMIC_PROTOCOL.md declares the cells, independent seed groups, exact peers, statistical gate and cost boundary. Setup plus measured hot costs models request horizons; it does not mean every modeled request was executed. Imports, transport and serialization are excluded. Retained payload estimates are not process RSS. Single-thread numerical-library settings are recorded in each report.

Dynamic and compact tests include independent mass-vertex and fixed-total slice-vertex oracles, patch sequences, signed bases, ties, subnormals, extreme exponents, old-result ownership, invalid transactional patches and instrumented logarithmic accesses. Compact compatibility tests explicitly rerun existing oracle methods on the other implementation; these executions are not additional independent oracle designs. The inherited runtime tests and negative findings remain in the release. tools/qualify.py generates a local qualification report; its checks do not replace external performance replication.

Limits and status

An exact optimizer cannot repair an invalid uncertainty envelope or an incorrect declared total. Fixed totals remove one specific correlation relaxation; they do not model arbitrary correlations, signed weights, moving value bounds or discrete combinatorial constraints. No training, GPU inference, learned-model certification or production reliability claim follows from these tests.

The release records concrete engineering checks separately from scientific completion. STATUS.md retains the declared research ledger: 80% research completeness and evidence classes of 65% verified, 30% derived and 5% conjectural. These are checklist accounting, not probabilities or breakthrough scores. Independent second-machine performance replication and an audited production integration remain open. Version 1.0.0 marks the documented software interface and substantive sparse-update capability; it does not establish mathematical priority or fulfill the original general-purpose breakthrough target.