/** * PRI-982 (SPEC-PD-IAER-001 FR-02 / FR-04) — consumer evidence preflight. * * The authoritative PRE-MODEL gate for Artificer tasks on the * `code_tool_hook` channel, invoked by the shared consumer cycle BEFORE any * runner construction: * * 1. no `behaviorEvidence` port injected by the host → the evidence source * itself is unavailable. This is a HOST ASSEMBLY GAP, not "Owner has not * labeled" (SPEC §6.2) → `evidence_source_unavailable`, task untouched; * the caller must keep the task pending and degrade OBSERVABLY. * 2. otherwise the ONE shared judgment (`assessEvidenceReadiness`, FR-01) * decides: * - ready → the pack rides into the ArtificerRunner deps; * - required/invalid → atomic `needs_human_review` transition * (evaluator-runner NHR precedent: humanReviewContext written in the * SAME metadata mutation, read-back invariant, CAS via * `updateTaskIfDiagnosticJsonUnchanged` against concurrent * consumers). NO run record, NO attemptCount consumption, NO LLM * call, NO retry — and since needs_human_review is outside the * consumer wake scan (pending/retry_wait only), the task is never * auto-rewoken (FR-05/T02). * * Reason codes are the stable FR-04 IDs for Owner-evidence faults * (`required`/`invalid`/`stale`/`scope_mismatch` via the typed scope * classification). Evidence-SOURCE faults stay OUT of that vocabulary: a * missing port → `evidence_source_unavailable`, a typed * `evidence_source_error` from the assembler (trajectory store I/O, PRI-980 * review P2-1) → the §6.2 storage-fault degradation — task untouched, never * an owner-fault NHR write. * * Telemetry: the two events are registered in the telemetry-event union in * the same change (ERR-060: unregistered names are silently rewritten to * `degradation_triggered`). `artificer_blocked_on_owner_evidence` is * Owner-recovery evidence that must survive a crash — the host wires this * emitter through WorkspaceTelemetryEmitter so it lands in the critical * allowlist sink. Both payloads carry the unified FR-08 run-correlation * block (PRI-984, artificer-run-correlation.ts); persistentRunId / * adapterRunId are semantically absent here — the gate fires pre-lease, so * no run row or runtime invocation exists. * * rc-1/rc-2: the selection arrives from parsed diagnosticJson (already * guarded by pitask-metadata parse) and the assembled pack is re-validated by * the shared validator inside the readiness gate — no `as` bypass. * rc-8: failure details are bounded before they enter payloads. * rc-9: every non-ready outcome carries reasonCode + nextAction. * * Spec: docs/specs/SPEC-PD-IAER-001-v1.0.md §5 FR-02, §6.1/§6.2 */ import type { BehaviorExamplePack } from './behavior-example-pack.js'; import { type OwnerEvidenceReasonCode, type OwnerEvidenceSelection } from './evidence-readiness.js'; import type { StoreEventEmitter } from '../store/event-emitter.js'; import type { RuntimeStateManager } from '../store/runtime-state-manager.js'; import type { PITaskRecord } from './peer-runner-contracts.js'; import type { TaskRecord } from '../task-status.js'; /** * Resolve the canonical Pain from the trusted seed along the persisted * predecessor graph. Never infer Pain from model output or the Owner's * selection. Multiple conflicting seeds and unresolvable ancestry fail closed. */ export declare function resolveArtificerCanonicalPainId(taskId: string, getTask: (taskId: string) => Promise): Promise; /** * Lineage marker for preflight NHR transitions. Honest by construction: this * is NOT a persisted run id (`run__` spelling is reserved * for lease-minted runs — there is no run for a pure preflight block), and * consumer-side recovery classification treats unknown reasonCodes as * recovery-type review, which never resolves artifacts through sourceRunId. */ export declare const ARTIFICER_EVIDENCE_NHR_SOURCE_RUN_ID = "evidence-preflight"; /** Host-injected evidence assembly port (production: BehaviorExamplePackAssembler). */ export interface BehaviorEvidencePort { /** * Assemble a validated BehaviorExamplePack from the Owner selection. * Throws on any gap (missing pain, session-mismatched rows, invalid pack) * — ERR-069 fail-loud convention. The gate classifies the throw * structurally: typed scope kinds → FR-04 codes, the typed * `evidence_source_error` kind → the §6.2 storage-fault degradation, * plain errors → `invalid_evidence`. */ assemble(selection: OwnerEvidenceSelection): BehaviorExamplePack; } export type ArtificerEvidencePreflightVerdict = { readonly decision: 'ready'; readonly pack: BehaviorExamplePack; /** `sha256:` content digest of the pack (FR-01 contract). */ readonly evidenceHash: string; readonly sourcePainId: string; } | { readonly decision: 'blocked'; readonly reasonCode: OwnerEvidenceReasonCode; readonly nextAction: string; readonly missingFields?: readonly string[]; readonly detail?: string; /** * Whether the needs_human_review transition durably landed (CAS + * read-back). `false` = a concurrent writer won the diagnosticJson CAS; * the caller must still NOT run the task, and surface the lost race * observably. */ readonly reviewPersisted: boolean; } | { /** * Evidence SOURCE failure (trajectory store I/O — PRI-980 review P2-1, * SPEC §6.2 case 3: 保留明确的存储故障,不误判为 Owner 尚未标注). * Same family as `evidence_source_unavailable`: the task is UNTOUCHED * (stays wake-eligible — the next cycle retries assembly at zero model * cost), NO needs_human_review write, NO owner-fault reasonCode. The * degradation is observable (structured telemetry event + verdict). */ readonly decision: 'evidence_source_error'; readonly reason: 'evidence_source_error'; readonly nextAction: string; readonly detail?: string; } | { /** Host assembly gap (port not injected) — task untouched. */ readonly decision: 'evidence_source_unavailable'; }; export interface ArtificerEvidencePreflightParams { readonly taskId: string; /** Hydrated task record (channel already resolved by the caller). */ readonly piTask: PITaskRecord; /** Lease-owner label for telemetry sessionId ('auto-consumer' | …). */ readonly owner: string; /** * Workspace root for the FR-08 run-correlation telemetry (PRI-984). * Optional: the key is omitted from payloads when a direct caller has no * workspace context — the production consumer cycle always provides it. */ readonly workspaceDir?: string; readonly stateManager: Pick; readonly eventEmitter: StoreEventEmitter; /** Optional: absent = host assembly gap (SPEC §6.2 semantics). */ readonly behaviorEvidence?: BehaviorEvidencePort; } /** * Run the evidence readiness preflight for one code_tool_hook Artificer task. * The caller owns channel resolution (pi_metadata.channel === * 'code_tool_hook'); this module never re-guesses channels. */ export declare function preflightArtificerOwnerEvidence(params: ArtificerEvidencePreflightParams): Promise; //# sourceMappingURL=consumer-evidence-preflight.d.ts.map