Two threads landing together — the doc edits interleave so they ship in a single commit. 1. **vectord substrate fix verified at original scale** (closes the 2026-05-01 thread). Re-ran multitier 5min @ conc=50: 132,211 scenarios at 438/sec, 6/6 classes at 0% failure (was 4/6 pre-fix). Throughput dropped 1,115 → 438/sec because previously-broken scenarios now do real HNSW Add work — honest cost of correctness. The fix (i.vectors side-store + safeGraphAdd recover wrappers + smallIndexRebuildThreshold=32 + saveTask coalescing) holds at the footprint that originally surfaced the bug. 2. **Materializer port** — internal/materializer + cmd/materializer + scripts/materializer_smoke.sh. Ports scripts/distillation/transforms.ts (12 transforms) + build_evidence_index.ts (idempotency, day-partition, receipt). On-wire JSON shape matches TS so Bun and Go runs are interchangeable. 14 tests green. 3. **Replay port** — internal/replay + cmd/replay + scripts/replay_smoke.sh. Ports scripts/distillation/replay.ts (retrieve → bundle → /v1/chat → validate → log). Closes audit-FULL phase 7 live invocation on the Go side. Both runtimes append to the same data/_kb/replay_runs.jsonl (schema=replay_run.v1). 14 tests green. Side effect on internal/distillation/types.go: EvidenceRecord gained prompt_tokens, completion_tokens, and metadata fields to mirror the TS shape the materializer transforms produce. STATE_OF_PLAY refreshed to 2026-05-02; ARCHITECTURE_COMPARISON decisions tracker moves the materializer + replay items from _open_ to DONE and adds the substrate-fix scale verification row. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
2.0 KiB
Go
65 lines
2.0 KiB
Go
package replay
|
|
|
|
import "strings"
|
|
|
|
// PromptParts captures the two roles the prompt assembly produces.
|
|
type PromptParts struct {
|
|
System string
|
|
User string
|
|
}
|
|
|
|
const systemPrompt = "You are a Lakehouse task executor. Stay grounded — only assert what you can derive from the prior successful patterns or the task itself. " +
|
|
"Do NOT hedge. Do NOT say 'as an AI'. Produce a concrete actionable answer. " +
|
|
"When prior successful outputs are provided, follow their style and format."
|
|
|
|
// BuildPrompt assembles the system + user messages for a model call.
|
|
// When bundle is nil (NoRetrieval mode), the user message is just the
|
|
// task — same wording as replay.ts so completions stay comparable.
|
|
func BuildPrompt(task string, bundle *ContextBundle) PromptParts {
|
|
if bundle == nil {
|
|
return PromptParts{
|
|
System: systemPrompt,
|
|
User: "Task: " + task + "\n\nProduce the answer.",
|
|
}
|
|
}
|
|
|
|
var b strings.Builder
|
|
if len(bundle.PriorSuccessfulOutputs) > 0 {
|
|
b.WriteString("## Prior successful runs on similar tasks\n\n")
|
|
for _, r := range bundle.PriorSuccessfulOutputs {
|
|
b.WriteString("### ")
|
|
b.WriteString(r.Title)
|
|
b.WriteString(" (score: ")
|
|
b.WriteString(r.SuccessScore)
|
|
b.WriteString(")\n")
|
|
b.WriteString(r.ContentPreview)
|
|
b.WriteString("\n\n")
|
|
}
|
|
}
|
|
if len(bundle.FailurePatterns) > 0 {
|
|
b.WriteString("## Patterns that produced PARTIAL results — avoid these failure modes\n\n")
|
|
for _, r := range bundle.FailurePatterns {
|
|
b.WriteString("- ")
|
|
b.WriteString(r.Title)
|
|
b.WriteString(": ")
|
|
b.WriteString(trim(r.ContentPreview, 160))
|
|
b.WriteByte('\n')
|
|
}
|
|
b.WriteByte('\n')
|
|
}
|
|
if len(bundle.ValidationSteps) > 0 {
|
|
b.WriteString("## Validation checklist (from accepted runs)\n")
|
|
for _, s := range bundle.ValidationSteps {
|
|
b.WriteString("- ")
|
|
b.WriteString(s)
|
|
b.WriteByte('\n')
|
|
}
|
|
b.WriteByte('\n')
|
|
}
|
|
b.WriteString("## Task\n")
|
|
b.WriteString(task)
|
|
b.WriteString("\n\nProduce the answer following the style of the prior successful runs above.")
|
|
|
|
return PromptParts{System: systemPrompt, User: b.String()}
|
|
}
|