/** * peaks-prd handoff service — v2.11.0 (D1 in * `v2-11-rm-rd-techdoc-immutable-handoff`). * * Owns the immutable handoff at * `.peaks/_runtime//prd/handoff-.md` (one capsule per slice; * readable through `resolveHandoffPath`): * * - `initHandoff` — pure; computes sha256 of the body and returns * a Handoff whose frontmatter `handoffHash` matches. * - `writeHandoff` — writes the file under `.peaks/_runtime//prd/`, * creating the dir if missing. * - `readHandoff` — reads + parses; throws on malformed input. * - `verifyHandoff` — re-reads + recomputes hash; returns a * `HandoffProbe` (never throws on hash mismatch — that's a * verification outcome, not a fatal error). * - `showHandoff` — returns the raw markdown content (frontmatter * + body verbatim) for human display via `peaks prd handoff show`. * * Hash contract (D1): `handoffHash` is the lowercase hex sha256 of * the body content as UTF-8 bytes. The body MUST be the literal * markdown source — no normalization, no trailing-newline padding. */ import type { GateEvidence, Handoff, HandoffDecision, HandoffProbe, HandoffRisk } from './handoff-types.js'; export { handoffRelativePath, resolveHandoffPath } from './handoff-path-resolution.js'; /** Compute the lowercase hex sha256 of a UTF-8 string. */ export declare function sha256OfBody(body: string): string; /** Pure: produce a Handoff with the frontmatter populated. Hash is * computed here; callers MUST NOT pre-populate `handoffHash`. */ export declare function initHandoff(opts: { requestId: string; sessionId: string; body: string; writtenAt: string; goals: readonly string[]; acceptanceCriteria: readonly string[]; preservedBehavior: readonly string[]; /** Override path; defaults to `.peaks/_runtime//prd/handoff-.md`. */ handoffPath?: string; /** Paths to the gate evidence files, keyed by gate. Omitted field and * empty map are equivalent here: neither renders a `gateEvidence` block, * so a caller that declares nothing writes bytes identical to a pre-B1 * capsule. * * THIS IS NOT A SECOND SOURCE (B2). In production the value reaching this * parameter is always `deriveGateEvidence(...)` * (`services/prd/gate-evidence-derivation.ts`), which computes it from the * request type and the gate table. This function stays pure — it does not * read the type itself — so the map can be constructed without touching * the disk; that is why the parameter exists rather than an internal call. * * map this accepts is EXACTLY what `readHandoffGateEvidence` reports as * `evidence` — `classifyGateEvidence` is the one shape rule behind both, * and `parseHandoffContent` stores the classified map rather than the raw * YAML. A declaration both paths REFUSE (`not-map` / `value-not-string`) * is refused here by a throw and there by a status; neither silently * produces a map the other cannot. */ gateEvidence?: GateEvidence; /** The authored fields peaks-qa cross-checks (`decisions[] ↔ tests`, * `risks[] ↔ security tests`, `files[] ↔ git diff`). They are OPTIONAL and * pass through verbatim: unlike `gateEvidence`, nothing derives them — they * are a writer's judgement about the slice, so a producer that has not made * that judgement declares nothing rather than an empty claim. */ scope?: readonly string[]; files?: readonly string[]; decisions?: readonly HandoffDecision[]; risks?: readonly HandoffRisk[]; nextActions?: readonly string[]; }): Handoff; /** Write a Handoff to disk. `projectRoot` is the absolute project * root (so the `.peaks/_runtime/...` path is resolved absolutely). * Creates intermediate dirs. */ export declare function writeHandoff(handoff: Handoff, projectRoot: string): Promise<{ path: string; hash: string; }>; /** Read + parse a handoff from disk. Throws on missing file or * malformed frontmatter. */ export declare function readHandoff(filePath: string): Promise; /** Verify a handoff by re-reading and re-hashing. Returns a probe * (never throws on hash mismatch — that's the outcome). * * N1: the two failure classes are reported separately. The previous * single `catch` folded every read failure into `file-missing`, so a * handoff that WAS on disk but whose frontmatter the parser refused was * reported as absent — sending an operator to look for a missing file * that was right there. Only a genuine read failure (ENOENT, EACCES, …) * is `file-missing` now; anything the parser rejects is * `frontmatter-malformed`. */ export declare function verifyHandoff(filePath: string): Promise; /** Return the raw markdown content of a handoff file (frontmatter + * body verbatim). For human display. */ export declare function showHandoff(filePath: string): Promise;