/** * SpatialConsolidation — Provenance-Preserving Merge of N Pieces into One Structure * * D.059 Stage 2/3 primitive: given N provenance-bound geometry pieces (each with a * provenanceHash), produce ONE merged structure + ONE composed receipt (Merkle root * of the N piece receipts). "You never re-verify the world; you verify the world IS * the composition of verified pieces." * * Recursion: a consolidated structure's self_hash becomes its leaf at the next level: * matter -> material -> object -> structure -> world * The same consolidate() call works at every level. * * Provenance chain: * Each piece contributes its provenanceHash as a leaf. * The composed Merkle root is SHA-256(sorted(leaf_hashes).join('')). * The consolidated structure's self_hash = SHA-256(composed_merkle_root + metadata). * This mirrors quantum_assemble.py's merkle_root hierarchy and SpatialPartitionPass's * provenanceHash chain (D.059 / Paper 34). * * Receipt schema: cael-structure-v1 * - merkleRoot over piece provenanceHashes (composition proof) * - selfHash over merkleRoot + consolidation metadata (identity proof) * - pieceCount, totalGaussianCount, deduplicationStats (transparency) * - provenanceSemiringStrategy: which semiring merge was used for trait conflicts * * Research references: * D.059 — Staged matter assembly (world construction) * D.058 — Visual evidence / receipt-to-pixel capstone * W.032 — Octree-GS LOD (anchor-based level selection) * Paper 34 — Provenance-isomorphic LOD (seed) * * @module spatial * @version 1.0.0 */ /** * Receipt schema version for spatial consolidation. * Mirrors CAEL receipt versioning (cael-structure-v1). */ export declare const CAEL_STRUCTURE_V1: "cael-structure-v1"; export type CaelStructureV1 = typeof CAEL_STRUCTURE_V1; /** * Which semiring strategy was used to resolve trait conflicts during merge. * Maps to ProvenanceSemiring strategies from core. */ export type ConsolidationSemiringStrategy = 'tropical-min-plus' | 'tropical-max-plus' | 'sum-product' | 'authority-weighted' | 'domain-override'; /** * Statistics about deduplication and instancing applied during consolidation. * Transparent: every merge step is auditable. */ export interface DeduplicationStats { /** Number of pieces that were deduplicated (same provenanceHash, merged). */ piecesDeduplicated: number; /** Number of materials that were deduplicated (same hash, merged). */ materialsDeduplicated: number; /** Number of anchor instances created (LOD sharing). */ anchorInstancesCreated: number; /** Total vertices before dedup. */ verticesBefore: number; /** Total vertices after dedup. */ verticesAfter: number; } /** * A composed Merkle receipt proving that N provenance-bound pieces were * consolidated into one structure. * * This is the Stage 2 output of D.059. The merkleRoot is the Merkle root * over all piece provenanceHashes; the selfHash is the deterministic identity * of this consolidation (for recursion at the next level). */ export interface ComposedMerkleReceipt { /** Schema version — always 'cael-structure-v1'. */ schema: CaelStructureV1; /** Merkle root over sorted piece provenanceHashes (composition proof). */ merkleRoot: string; /** Self hash = SHA-256(merkleRoot + consolidation metadata). Identity proof for recursion. */ selfHash: string; /** Sorted leaf hashes used to compute the Merkle root (enables verification). */ leafHashes: string[]; /** Number of pieces consolidated. */ pieceCount: number; /** Total Gaussian count across all pieces (sum of gaussianCount). */ totalGaussianCount: number; /** Bounding volume of the consolidated structure. */ bounds: ConsolidatedBounds; /** Which semiring strategy resolved trait conflicts. */ semiringStrategy: ConsolidationSemiringStrategy; /** Deduplication statistics (transparent audit). */ deduplication: DeduplicationStats; /** ISO 8601 timestamp of consolidation. */ consolidatedAt: string; /** Provenance: what created this consolidation. */ consolidatedBy: string; } /** * A single merged anchor after consolidation. * Merges spatial position, LOD level, and gaussian count from * deduplicated pieces. */ export interface ConsolidatedAnchor { /** Deterministic ID: 'consolidated__'. */ id: string; /** Merged world-space position (centroid of deduplicated piece positions). */ position: [number, number, number]; /** Effective scale (max of deduplicated piece scales). */ scale: number; /** Merged LOD level (minimum = coarsest of deduplicated piece LODs). */ lodLevel: number; /** Total gaussian count across deduplicated pieces. */ gaussianCount: number; /** Merged importance (max of deduplicated piece importances). */ importance: number; /** Merkle root over this anchor's piece provenanceHashes. */ provenanceHash: string; /** Source files that contributed to this anchor. */ sourceFiles: string[]; } /** * Axis-aligned bounding volume for the consolidated structure. */ export interface ConsolidatedBounds { min: { x: number; y: number; z: number; }; max: { x: number; y: number; z: number; }; center: { x: number; y: number; z: number; }; halfSize: number; } /** * Result of consolidating N provenance-bound pieces into one structure. * The key output of D.059 Stage 2. */ export interface ConsolidationResult { /** The composed Merkle receipt (provenance proof). */ receipt: ComposedMerkleReceipt; /** Merged anchor set (consumable by OctreeLODSystem). */ anchors: ConsolidatedAnchor[]; /** Bounding volume of all consolidated anchors. */ bounds: ConsolidatedBounds; /** Total Gaussian count across all consolidated anchors. */ totalGaussians: number; } export interface ConsolidationOptions { /** * Which semiring strategy to use for trait conflict resolution. * Default: 'tropical-min-plus' (min-cost merge). */ semiringStrategy?: ConsolidationSemiringStrategy; /** * Whether to deduplicate pieces with identical provenanceHashes. * Default: true (D.059 requirement: provenance = identity). */ deduplicatePieces?: boolean; /** * Whether to merge anchors at the same LOD level into instances. * Default: true (performance: instancing reduces draw calls). */ instanceByLOD?: boolean; /** * Identity of the consolidator (for receipt provenance). * Default: 'spatial-consolidation-v1'. */ consolidatedBy?: string; } /** * Compute a Merkle root over a set of leaf hashes. * Simple XOR-chain over sorted hashes (mirrors SpatialPartitionPass.merkleRoot). * For production, a full binary Merkle tree should replace this (Paper 34). */ export declare function computeMerkleRoot(leafHashes: string[]): string; /** * Compute a self-hash over Merkle root + metadata. * This is the identity hash that makes the consolidation a verifiable piece * at the next recursion level (matter -> material -> object -> world). */ export declare function computeSelfHash(merkleRoot: string, pieceCount: number, totalGaussians: number): string; /** * Compute the bounding volume encompassing all given positions and scales. */ export declare function computeConsolidatedBounds(anchors: Array<{ position: [number, number, number]; scale: number; }>): ConsolidatedBounds; /** * Consolidate N provenance-bound geometry pieces into one structure + one * composed receipt. * * This is the D.059 Stage 2/3 primitive. It recurses: a consolidated * structure's selfHash becomes its provenanceHash at the next level. * * Algorithm: * 1. Deduplicate pieces with identical provenanceHashes (provenance = identity). * 2. Merge anchors by LOD level (instancing for performance). * 3. Compute Merkle root over all piece provenanceHashes (composition proof). * 4. Compute self hash over Merkle root + metadata (identity for recursion). * 5. Compute consolidated bounding volume. * 6. Return ConsolidationResult with receipt + merged anchors + bounds. */ export declare function consolidate(pieces: Array<{ id: string; position: [number, number, number]; scale: number; lodLevel: number; gaussianCount: number; importance: number; provenanceHash: string; sourceFile?: string; }>, options?: ConsolidationOptions): ConsolidationResult; /** * Verify that a ConsolidationResult's receipt is consistent with its anchors. * Per F.069: this must FAIL if the receipt is forged or inconsistent. */ export declare function verifyConsolidationReceipt(result: ConsolidationResult): boolean; //# sourceMappingURL=SpatialConsolidation.d.ts.map