# Aligned facts with negative evidence

Version 0.3.0 adds `Ledger::aligned_timeline`; 0.2.0 does not include it.
At a fixed knowledge instant, it partitions a valid-time window into rows
with one constant winning revision per selected key. Keys are deduplicated and
sorted. Every row includes every key, exposing `value`, `source`, `is_gap` and
`is_deleted`; same-value source changes still split rows.

Unlike existing `snapshot_timeline`, which returns only assigned facts, this API
retains the difference between never-claimed gaps and explicit withdrawals, and
their revision evidence. Unlike `joint_assigned_spans`, it retains values and
sources, not just simultaneous availability. This matters for permission
denials, absent configuration and withdrawn discounts. Hosts still evaluate
their own pricing/authorization rules.

Implementation reuses per-key timelines, merges their boundaries and advances
per-key cursors. It avoids repeating history scans for every output cell. With
R input timeline segments, K keys and O output rows, alignment after per-key
timeline construction costs O(R log R + K*O), retaining O(R+K*O) state. Original
per-key timeline history/sort costs remain. Old snapshot querying also repeated
point lookups per cell; the new cursor sweep consumes timeline segments once.

Budgets: 64 unique keys, 4096 output rows, 65536 cells and 16384 aggregate input
segments by default; the input-segment budget may be 1..1000000. Cell checks use
division to avoid multiplication overflow. Key/row/cell/staging limits are
checked before extending those outputs. Empty key selection yields one empty
row covering bounds. Half-open and unbounded spans, including Int64 extrema,
require no timestamp arithmetic. Invalid empty keys are rejected. Array getters
return copies, and failures return no partial report.

Run `moon run examples/aligned_facts --target wasm-gc`: align price and discount,
distinguish missing from withdrawn discounts, retain the correction source and
replay the earlier knowledge view. Other uses include entitlement plus account
status, device configuration plus calibration and reference-data joins. A
100-key test checks every aligned row against independent point queries.

History/index arrays in readonly ledger/builder/report types are now private;
existing public methods remain available. Source direct-field users must migrate
to those methods. On affected Windows 0.10.16 use `tools/windows/moon.ps1`, which
retains official tools and only adapts DOS argv path prefixes.
