/** * bundle-reader.ts — readBundle(inPath) (spec §7A.2). * * * Reads a `peaks.bundle/1` tar.gz and lands the contained release * on the local SkillHub. The reader is the symmetrical counterpart * of `bundle-writer.ts` — same layout, same content-addressed * blobs/, but with three hard guards: * * 1. `format_version_major !== 1` is a HARD block. The reader * throws `SHARE_BUNDLE_MAJOR_VERSION_MISMATCH` before any * SQL side-effect. (Major-version bumps are reserved for * breaking schema changes; the receiver is not assumed to * know how to translate.) * 2. `format_version_minor` mismatch is a non-fatal warn (the * reader collects it as a warning on the return envelope). * 3. The imported release ALWAYS lands as `candidate`. The * reader refuses to write any other status; the receiver * MUST run an independent evaluation before promoting the * reads evolution_evaluation rows). * * Slice 4 (PRD-002b): split the four high-cohort functions * (readBundle 15, importLoopBundle 20, materialiseRelatedBees 28, * importBeeBundle arrow 38) into small helpers with table dispatch * for kind routing and early-return for guard paths. Public API * (readBundle, ReadBundleArgs, ReadBundleResult, the four error * classes) is preserved verbatim. */ import { type SqliteDatabase } from '../sqlite/sqlite-driver.js'; import { SHARE_BUNDLE_ERROR_CODES, type PeaksBundleKind } from './bundle-types.js'; /** * Thrown when `format_version_major !== 1`. This is the explicit * HARD block per spec §7A.2 (major mismatch). */ export declare class BundleMajorVersionMismatchError extends Error { readonly code: typeof SHARE_BUNDLE_ERROR_CODES.MAJOR_VERSION_MISMATCH; readonly receivedMajor: number; constructor(receivedMajor: number); } /** * Thrown when the schema-versions mapping is missing or carries * non-canonical literals. */ export declare class BundleSchemaVersionsMismatchError extends Error { readonly code: typeof SHARE_BUNDLE_ERROR_CODES.SCHEMA_VERSIONS_MISMATCH; readonly received: Record | undefined; constructor(received: Record | undefined); } /** * Thrown when the caller asks to land as anything other than * `candidate` (the only allowed target status). */ export declare class BundleImportToStableForbiddenError extends Error { readonly code: typeof SHARE_BUNDLE_ERROR_CODES.IMPORT_TO_STABLE_FORBIDDEN; constructor(receivedStatus: string); } /** * Thrown when the bundle tarball is malformed (no manifest.json, * bad JSON, etc.). Distinct from a ZodError so the CLI can map * to a single BUNDLE_MALFORMED code. */ export declare class BundleMalformedError extends Error { readonly code: typeof SHARE_BUNDLE_ERROR_CODES.BUNDLE_MALFORMED; constructor(message: string); } export type ReadBundleArgs = { db: SqliteDatabase; /** Blobs root for content-addressed file write-back. */ blobsDir: string; /** Input `.tar.gz` bundle path. */ inPath: string; /** * Optional rename for the anchor asset on import. For `loop` * bundles this is the loop id to overwrite the source id; for * `bee` bundles this is the `--as` bee name. */ asName?: string; }; /** * Successful read result. The reader lands the bundle as a * `candidate` regardless of any other lifecycle status on the */ export type ReadBundleResult = { /** Anchor asset id actually written. */ assetId: string | number; kind: PeaksBundleKind; /** Always `candidate` — the reader does not honor any other status. */ importedAs: 'candidate'; /** Non-fatal warnings (e.g. minor-version mismatch). */ warnings: string[]; /** Count of crystallization_event rows imported. */ evidenceBriefCount: number; }; export declare function readBundle(args: ReadBundleArgs): ReadBundleResult;