/** * PRI-456: Pure result-shaping function for PainSignalBridge. * * Extracts the duplicated status-decision tree from: * - PainSignalBridge.onDiagnosisComplete() (fresh diagnosis path) * - PainSignalBridge.buildExistingResult() (idempotent existing-task path) * * Both paths decide: no candidates → failed; admitted-but-no-ledger → failed; * gated/partial → degraded; otherwise succeeded. But they differ in message * strings and the fresh path has admission results + degraded states. * * This function is pure: zero I/O, zero side effects. Callers pass all * computed values; the function never re-derives lineage fields. * * ERR gate: * - ERR-007 / EP-02: single source for status decision — branches can't diverge * - ERR-002 / EP-03: every degraded/failed branch keeps its structured message * - ERR-004 / ERR-008 / EP-07: lineage fields are received, never re-derived */ import type { PainSignalBridgeResult, NotInternalizableCandidate } from './pain-signal-bridge.js'; import type { CandidateAdmissionResult } from './admission-gate.js'; /** Base fields shared by both fresh and existing paths. */ interface ShapeBridgeResultBase { painId: string; taskId: string; candidateIds: string[]; ledgerEntryIds: string[]; runId?: string; artifactId?: string; autoIntakeEnabled: boolean; /** * Phase 1 / PR1 (Principle Ledger write boundary): how many candidates in * this batch have a ledger entry EXPECTED of them — i.e. they were admitted * and their validated `recommendation_kind` is exactly `'principle'`. * * "Admitted but zero ledger entries" is only an intake FAILURE when at least * one candidate was actually ledger-eligible. For a batch of rule / prompt / * implementation / defer candidates the boundary refuses the write BY DESIGN, * so the absence of ledger entries is their normal disposition and must be * reported as routed / not_internalizable rather than as a failed run. */ ledgerEligibleCandidateCount: number; /** * PRI-917 v0.3.3 — candidateIds parked by the Reuse Review Gate (suspected * duplicates awaiting the Owner). A parked ledger-eligible candidate has NO * ledger entry BY DESIGN, so a batch whose ledger-eligible candidates are * ALL parked is a degraded "waiting for the Owner" outcome, not the intake * failure this branch used to report. */ reuseReviewRequiredCandidateIds?: string[]; /** PRI-539: candidates admitted+ledgered but not internalizable (MVP-disabled channel). */ notInternalizable?: NotInternalizableCandidate[]; } /** Fresh diagnosis path — has admission results and seed failure notes. */ export interface ShapeBridgeResultFreshInput extends ShapeBridgeResultBase { path: 'fresh'; admissionResults: CandidateAdmissionResult[]; /** Non-empty string when dreamer seed failed; empty string otherwise. */ seedFailureNote: string; } /** Existing-task idempotent path — ledger-existence-derived, no admissions. */ export interface ShapeBridgeResultExistingInput extends ShapeBridgeResultBase { path: 'existing'; } export type ShapeBridgeResultInput = ShapeBridgeResultFreshInput | ShapeBridgeResultExistingInput; /** * Derive the final PainSignalBridgeResult from computed inputs. * * Byte-for-byte identical to the original inline logic in both call sites. * The `path` discriminator selects the appropriate message strings and * decision branches. */ export declare function shapeBridgeResult(input: ShapeBridgeResultInput): PainSignalBridgeResult; export {}; //# sourceMappingURL=bridge-result-shaper.d.ts.map