mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-07-31 01:25:21 +00:00
Implements the YaFF-inspired separation of schema, layout, and access pattern
in Core/SilverSight/Semantics/:
- Schema.lean: fixed-size Schema typeclass with byteSize and wellFormed.
- Layout.lean: Layout enum, AccessProfile cost model, and cost-based selector
with an ε-suboptimality theorem.
- WireFormat.lean: certified encode/decode/roundTrip/encode_size structure.
- View.lean: zero-copy View with address-arithmetic invariant.
- LayoutBridge.lean: certified layout-conversion structure and identity bridges.
- CanalLayout.lean: CanalRegime enum and regime-aware layout selection.
Also updates:
- lakefile.lean: adds SilverSight.Semantics.* roots to SilverSightCore.
- docs/ARCHITECTURE.md, RRC_REFACTOR_READINESS.md, PROJECT_MAP.{md,json},
build_logs/2026-06-21_session_build_baseline.md, and GLOSSARY.md.
- AGENTS.md: build baseline, blessed surfaces, and pending proof work.
Build: 2987 jobs, 0 errors (lake build)
Tests: Python 21/21, Lean/C 35/35
46 lines
1.5 KiB
Text
46 lines
1.5 KiB
Text
/-
|
||
SilverSight.Semantics.LayoutBridge
|
||
|
||
A LayoutBridge converts between two wire formats of the same schema and
|
||
preserves meaning. The `correct` field is a Lean proof that converting the
|
||
encoding in layout L1 yields exactly the encoding in layout L2.
|
||
|
||
The Core only provides the bridge interface and identity bridges. Concrete
|
||
bridges (row-major ↔ columnar, compact expansion, mmap view wrapping) are
|
||
library extensions that must each supply a `correct` proof.
|
||
-/
|
||
|
||
import SilverSight.Semantics.Schema
|
||
import SilverSight.Semantics.Layout
|
||
import SilverSight.Semantics.WireFormat
|
||
|
||
namespace SilverSight.Semantics
|
||
|
||
/-- A certified conversion between two wire formats of the same schema. -/
|
||
structure LayoutBridge (α : Type) [Schema α] (L1 L2 : Layout) where
|
||
wf1 : WireFormat α L1
|
||
wf2 : WireFormat α L2
|
||
convert : ByteArray → ByteArray
|
||
correct : ∀ a, convert (wf1.encode a) = wf2.encode a
|
||
|
||
namespace LayoutBridge
|
||
|
||
/-- The identity bridge: encoding in L is already the encoding in L. -/
|
||
def identity {α : Type} {L : Layout} [Schema α] (wf : WireFormat α L) :
|
||
LayoutBridge α L L where
|
||
wf1 := wf
|
||
wf2 := wf
|
||
convert := id
|
||
correct := by simp
|
||
|
||
/-- Identity bridge for `Bool` row-major. -/
|
||
def boolRowMajor : LayoutBridge Bool rowMajor rowMajor :=
|
||
identity WireFormat.boolRowMajor
|
||
|
||
/-- Identity bridge for `UInt8` row-major. -/
|
||
def uint8RowMajor : LayoutBridge UInt8 rowMajor rowMajor :=
|
||
identity WireFormat.uint8RowMajor
|
||
|
||
end LayoutBridge
|
||
|
||
end SilverSight.Semantics
|