/** * Forgen — Compound Pattern Share (패턴별 export/import) * * `compound-export.ts`의 `export`/`import`는 `~/.forgen/me/` 전체를 tar.gz로 * 통짜 백업/이관한다. 이 모듈은 그와 달리 **이름 지정된 패턴 단위**로 신뢰도 * (confidence/status/evidence)와 provenance를 함께 담은 JSON 번들을 만들고, * 받는 쪽에서 안전하게 병합한다 (ECC `/instinct-import/export` 대응, OSS gap #1). * * 핵심 설계: * - 번들은 스키마 버전 고정 JSON. 최상위/패턴 필드 모두 화이트리스트 검증 — * 예상 못한 필드가 있으면 통째로 reject (실행 가능한 콘텐츠가 섞여 들어올 * 여지 자체를 차단). * - 패턴마다 contentHash(sha256)를 동봉 — import 시 재계산해 일치하지 않으면 * reject (변조/손상 탐지). * - 이름 충돌 시: 로컬 콘텐츠 해시가 같으면 "동일 패턴 재발견"으로 간주해 * `reExtracted` 카운터만 증가(기존 신뢰도는 건드리지 않음 — 이미 solution-writer.ts * 의 dual-path 금지 불변식과 일치). 다르면 절대 덮어쓰지 않고 suffix된 * 이름으로 새로 생성. * - 신규 생성되는 패턴은 항상 probation: status='experiment', confidence는 * 신규 솔루션 표준 베이스라인(statusConfidence('experiment')=0.3, 참고: * extraction-persistence.ts saveExtractedSolution)을 상한으로 export 시점 * confidence의 절반만 반영. evidence는 전부 0으로 리셋 — exporter의 로컬 * 사용 이력을 이 머신이 검증 없이 물려받지 않는다. 이후 승급은 기존 * compound-lifecycle.ts의 단일 경로(runLifecycleCheck)로만 진행된다. */ import { type SolutionFrontmatter } from './solution-format.js'; export declare const SHARE_BUNDLE_SCHEMA_VERSION: 1; export interface ShareBundlePatternV1 { name: string; category: 'solution' | 'rule'; frontmatter: SolutionFrontmatter; context: string; content: string; /** sha256(type + sorted tags/identifiers + context + content) — confidence/evidence/timestamp 제외한 콘텐츠 지문. */ contentHash: string; } export interface ShareBundleV1 { schemaVersion: 1; exportedAt: string; /** sha256(hostname:username) 앞 16자 — 원본 식별용, PII 비가역. */ originHash: string; patterns: ShareBundlePatternV1[]; } export interface BuildBundleResult { bundle: ShareBundleV1; notFound: string[]; rejectedSecrets: string[]; } /** * 이름 목록으로 패턴 번들 생성. * * 시크릿 감지된 패턴은 조용히 스킵하지 않고 `rejectedSecrets`로 보고하되, * 번들 자체는 나머지 clean한 패턴으로 계속 진행한다 (부분 실패 허용). */ export declare function buildShareBundle(names: string[]): BuildBundleResult; export interface ShareBundleValidation { ok: boolean; bundle: ShareBundleV1 | null; errors: string[]; } /** * 번들 검증: 크기 캡 → 최상위 필드 화이트리스트 → 패턴별 필드 화이트리스트 → * frontmatter 정합성 → contentHash 재계산 일치. 하나라도 실패하면 번들 전체를 * reject한다 (부분 신뢰 없음 — 손상/변조된 번들은 통째로 버린다). */ export declare function validateShareBundle(raw: unknown, rawSize: number): ShareBundleValidation; export interface ShareImportAction { sourceName: string; category: 'solution' | 'rule'; action: 'merge-reextract' | 'create' | 'create-suffixed'; targetName: string; detail: string; } export interface ShareImportSummary { dryRun: boolean; actions: ShareImportAction[]; } /** dry-run과 실제 실행이 공유하는 계획 수립 — 파일시스템에 아무것도 쓰지 않는다. */ export declare function planShareImport(bundle: ShareBundleV1): ShareImportAction[]; export declare function executeShareImport(bundle: ShareBundleV1, opts?: { dryRun?: boolean; }): ShareImportSummary; export declare function looksLikeShareBundle(filePath: string): boolean; export declare function handleShareExport(args: string[]): Promise; export declare function handleShareImport(args: string[]): Promise;