Repository navigation
Description
Overview
Once a golden prompt is tuned and frozen, assert — with zero model calls — that NodeSpace's assembly line actually produces it. This is the half of the golden-prompt methodology that was specified but never written, and it is what converts a tuned prompt from a finding in a test file into a target the production pipeline is held to.
packages/agent/tests/live_stage1_golden_prompts.rs names the gap in its own header:
separate "does this exact prompt text get the right tool call" (answerable here, in seconds) from "does the real pipeline assemble that exact prompt from real inputs" (a distinct, deterministic, zero-model-call question — the snapshot tests this golden set feeds, not yet written).
Problem Statement
Without this gate, prompt tuning has no teeth. A golden prompt can be hand-authored, validated at N/N against the live model, and checked in — and production can still assemble something materially different, with nothing failing. That is precisely what happened around scenario 6: a hand-authored prompt got the correct resolve_query call 3/3, while production fired it 0/8, and the difference was never pinned down as an assembly divergence because nothing compared the two.
It also makes prompt regressions invisible. Resident prose, tool descriptions, skill guidance, and the Stage-2 candidate block are edited independently across agent_guidance.rs, tools.rs, skill_pipeline.rs, and routing.rs. Any of those edits silently changes what the model receives, and today no test notices.
Proposed design
A deterministic, zero-model-call test that reconstructs the assembled prompt from real production inputs and compares it to a checked-in golden file.
The comparison must cover what the model actually receives, which is assembled at several sites:
PromptAssembler::assemble()— the resident system prompt from seededpromptnodesrouting::render_candidates_for_prompt()— the Stage-2 candidate block and its instruction subtreesrouting::stage2_tools()— the scoped tool surface (names, descriptions, parameter schemas)STAGE1_SYSTEM_PROMPT+stage1_tool_definitions()— the Stage-1 request- The
RELEVANT ENTITY TYPESblock, which reaches the prompt from two independent sites (Stage-2 candidate block and resident workspace context)
Failure output must be a readable diff. A byte-equality assertion that prints two 8KB blobs is not actionable; the whole point is to show which line of guidance moved.
Fixture inputs, not a live database
Assembly depends on seeded prompt/skill nodes, retrieved candidates, and workspace context. Those must come from committed fixtures so the test is hermetic and deterministic — no DB, no daemon, no embedding service, no model. It should run in the normal test suite, not behind --ignored.
Update workflow
Changing a prompt should be a deliberate two-step: update the golden file, and the test passes. An accidental change to tools.rs or agent_guidance.rs fails the gate and has to be acknowledged. Provide an explicit regeneration path (env var or bin flag) so updating goldens is one command rather than hand-editing, but never auto-update on failure.
Relationship to the tuning loop
The runner issue produces case files that are validated against the live model. The frozen prompt text from a passing case becomes the golden this test asserts against. The two halves close the loop:
- Tune the prompt as data against llama.cpp until it reliably does the right thing
- Freeze it as a golden
- This gate fails until production assembly reproduces it
- Fix the assembly line (delete prose the tuned version proved unnecessary, move content to the channel that owns it per ADR-064)
Acceptance Criteria
- Zero-model-call test asserting production assembly matches a checked-in golden prompt
- Covers the resident system prompt (
PromptAssembler::assemble()) - Covers the Stage-2 candidate block (
render_candidates_for_prompt()) including rendered instruction subtrees - Covers the scoped tool surface (
stage2_tools()) — tool names, descriptions, and parameter schemas - Covers the Stage-1 request (
STAGE1_SYSTEM_PROMPT+stage1_tool_definitions()) - Fixture-driven: no DB, no daemon, no embedding service, no model; runs in the default test suite
- Failure output is a readable diff identifying which section changed, not a raw blob comparison
- Explicit golden-regeneration command; goldens never auto-update on failure
- Editing any model-facing constant (
agent_guidance.rs,tools.rs,skill_pipeline.rs, routing render fns) without updating its golden fails the test — verified by an actual edit
Out of scope
- The live-model tuning runner — separate issue
- Authoring the dev-domain golden corpus — separate issue
- Changing production prompt text; this issue only makes drift visible
Notes
- ADR-064 makes this a standing measurement surface: it fixes which channel owns which category of instruction, and its own evidence shows a shipped contradiction (
coreValuesin the tool schema vscore_valuesin resident prose) reaching the model in the same prompt. A diff gate over the assembled prompt is what would have surfaced that. - Prompt size is a hardware-requirements input via ADR-062 (context window budgeted against total RAM), so unnoticed prompt growth has consequences beyond token cost.
NODESPACE_PROMPT_DUMPcaptures the real final string at the native-path chokepoint and can be used to verify the reconstruction matches an actual live session.
Activity
malibio commentedon Aug 17, 2026
Paired with #2118 (the live-model tuning runner). #2118 produces the validated prompt text; this issue is what holds production to it.
Sequencing note: #2119 is independently useful and can land first. Even before any golden is re-tuned, a snapshot of today's assembled prompt turns the four independently-edited model-facing surfaces (
agent_guidance.rs,tools.rs,skill_pipeline.rs,routing.rsrender fns) into a reviewable diff. That alone would have caught thecoreValues/core_valuescontradiction ADR-064 documents as shipped in production.malibio commentedon Aug 17, 2026
Sequencing: #2118 → #2120 → #2119 → #1977
These four are one line of work. Recording the order and the reasoning so it survives a context reset.
Why the snapshot gate is third, not first
It was initially argued for first, on the grounds that snapshotting today's assembly turns four independently-edited surfaces (
agent_guidance.rs,tools.rs,skill_pipeline.rs,routing.rs) into a reviewable diff — which is real, and would have caught thecoreValues/core_valuescontradiction ADR-064 records as shipped.But the snapshot would capture today's invoice-flavored prompt, and #2120 then rewrites it wholesale. Nearly every diff during that window is intended, so the gate's actual value — catching unintended drift — is thin exactly when it would be running. Capturing the golden once, after the rewrite settles, is cleaner than regenerating it through two rounds of deliberate change.
The risk this ordering carries, and its mitigation
The failure mode is the #1917 pattern repeating: tune by hand, get a good result, close the issue, never build the gate. That is not hypothetical — it is what happened, and
live_stage1_golden_prompts.rsstill carries the header comment saying the snapshot tests are "not yet written."Mitigation is in #2120's acceptance criteria rather than in the ordering: every tuned prompt is checked in as a #2118 case file. The work is durable whether or not #2119 lands promptly, and #2119 becomes the step that converts those case files into a production contract rather than the only thing standing between tuning and lost work.
For reading the current assembled prompt while deciding what to cut,
NODESPACE_PROMPT_DUMPalready dumps it at the native-path chokepoint — the gate is not needed for that.Adjacent, not blocking
friendly_namein schema tools) — independent_seedreconciliation, though evals still need a daemon rebuild since guidance is compiled inmalibio commentedon Aug 17, 2026
Goldens must reproduce production's prompt ENVIRONMENT, not just a working prompt
Clarification from the user on what "golden prompt string" means here, and it tightens the brief:
The distinction
A hand-authored minimal prompt — short system text, two hand-written tool defs, no candidate block, no entity-types block, no tool-call records in history — answers "can the model do this task under favorable conditions?" That is a useful control, and it is what
scenario6-zero-history-control.tomlis.It is not the string NodeSpace pumps. Production sends, in one request:
PromptAssembler::assemble()over seededpromptnodes)render_candidates_for_prompt())RELEVANT ENTITY TYPESblock (from the candidate block'sschema_metadataand/or resident workspace context)stage2_tools())That gap is not hypothetical — it is precisely where scenario 6 died. Hand-authored got
resolve_query3/3; production fired it 0/8. The hand-authored prompt was not wrong, it was a different environment.The requirement
A golden must be structurally what production sends — same blocks, same sections, same ordering, same tool surface — with the content of those blocks being what is under tuning. Otherwise:
The tuning question is "what should the resident prompt SAY, and how short can it be," not "what happens if we delete the resident prompt entirely."
Two golden tiers, and both are needed
scenario6-zero-history-control.tomlis already this, and its own notes call it "the harness's own canary." Keep as-is.The existing "authored fresh, no
STAGE1_SYSTEM_PROMPT/ noskill_pipeline.rs" discipline still holds for tier 2, and is not in tension with it: fresh content in production's structure. A golden assembled from production's current text cannot be the target production is engineered toward — but a golden missing production's blocks cannot be that target either.How to obtain the production shape
NODESPACE_PROMPT_DUMPcaptures the exact assembled string at thegenerate_blockingchokepoint (confirmed working through the golden runner). Run a real session, dump the prompt, and use it as the structural reference for what blocks appear and in what order. Then author fresh content into that structure rather than copying the text.Acceptance criteria to add
RELEVANT ENTITY TYPES, full scoped tool surface, and realistic history including tool-call recordsNODESPACE_PROMPT_DUMPcapture, documented in the casenotes, so the shape is verifiable rather than assumedmalibio commentedon Aug 17, 2026
Revised sequencing: #2118 → #2122 → #2119 → #2120 → #1977
Supersedes the earlier sequencing comment. The chain gained a step and #2120 was rescoped, because the previous plan had no issue that actually produced the golden corpus — #2119 would have asserted against goldens nobody authored.
The split that matters
#2120 previously mixed what should the prompt say with edit the files that emit it. That is the exact conflation this effort exists to remove — a failure could be a bad prompt or bad plumbing, indistinguishable.
Now:
A failure in #2122 is a prompt failure. A failure in #2120 is a plumbing failure. By construction.
Why #2119 moved ahead of #2120
The gate is what defines #2120's done condition. "Make plumbing match" has no test without it.
The governing requirement across all of them
Goldens must be production-shaped: same blocks, same structure, same tool surface as what NodeSpace actually sends — with the content of those blocks being what is tuned. A minimal hand-authored prompt is a useful control but not a target; scenario 6 is the cautionary case, at 3/3 hand-authored vs 0/8 in production for the same task.
Make the two-site entity-types shape uniform across every turn (#2122)
Address review: re-fix stale counts, standardize pointers, add nits (#…
Golden prompt corpus: dev-workflow cases + context ablation (closes #…
malibio commentedon Aug 18, 2026
The corpus this issue targets now exists — what changed since this issue was written
#2122 merged as
44ef2f1f. This issue predates it and does not mention any of the findings below, several of which change what "done" means here. Orientation for whoever picks it up.Where the target lives, byte-exact
packages/agent/goldens/— 8 dev-workflow cases, 2 minimal controls, 3 ablation arms, andPATTERN.tomlrecording the rule that makes them work. All measured 5/5 byte-identical against the locked native model, with argument values asserted rather than tool names.Reproduce any target string without a daemon or DB:
dev-status-change-enumis 2681 and 4401 chars post-template across its two turns. Diff assembly output against that directly — no interpretation required.Four requirements the corpus establishes that this issue does not mention
1. Write tools must declare each field as a typed sub-property, enums inline. This is the largest behavioural requirement, not a style preference.
dev-instance-creationdropped a user-supplied value 3/3 across eight arms spanning every prose channel ADR-064 defines — candidate instructions, schema descriptions, three shapes of worked example, acontentboundary rule, an ordered procedure, and that procedure with its enumeration forced to be printed. Declaring the field closed it immediately.The diagnostic is the useful part: with the enumeration printed, the model listed five particulars and the dropped one was not among them. The value was already gone before any instruction could act on it, which is why every wording-level fix was inert — they all operate downstream of the loss. Two further probes bound it: asked directly, the model correctly identifies that no field exists; offered a clarification tool and told to use it, it writes anyway and says nothing.
Generatable from the same schema data that renders the type line, so no new source of truth.
2. Delete the prose the declarations replace. An arm carrying both a declared sub-property and the prose telling the model to invent keys failed; the declaration alone passes. Adding structure while leaving the instruction it supersedes is measurably not the same edit.
3. Two rendering sites, differently scoped. The resident block carries the retrieved schemas; the per-candidate block carries only that candidate's own types (
routing.rsrendersc.schema_metadata). An early draft of the corpus copied the resident list into the candidate block and reproduced production's structure while violating its scoping — the exact contaminationrouting.rsdocuments at that call site. All 15 turns now render the block exactly twice, correctly scoped.4. Keep the heading's parenthetical. The corpus heads the block
EXISTING SCHEMAS (do not recreate these; …)rather thanRELEVANT ENTITY TYPES (…). Read the measurement carefully: production's constant atcontext_ops.rs:118is already constraint-framed, so the arms compared two constraint-framed headings differing in noun. Both scored 5/5; the two arms that scored 0/5 dropped the parenthetical and changed the noun together.So the supported claim is "keep the parenthetical". The
ENTITY→SCHEMASrename is a consistency fix with no measured cost —ENTITYhas no referent in storage (node_type == "schema"), in the 44node_typetool params, or in the API — but it is not a measured improvement. The isolating arm is recorded as NOT RUN.What the ablation says about how much of this is worth reproducing
On
dev-status-change-enumonly, at 5 reps:Two mechanisms bought nothing measurable on that case. One case is not the workload —
ablation/README.tomlcarries that caveat and it should travel with any decision. But if effort has to be prioritised, the schemas block is the one with evidence behind it.Note the last row changed after the declared-field pattern landed: with enums declared on the write tool, deleting the schemas block no longer breaks the write, only the read —
search_nodes.filtersdeclares no enum. Not-yet-run: declaring enums on a read tool's filter parameter. If that works, the block may be redundant for reads too.Blocked on #2123
Production's value parameter is named
properties, which the Gemma-4 template deletes wholesale. Declarations inside a deleted parameter reach the model no better than its description does, so none of requirement 1 is reproducible until that rename lands. The corpus usesfield_valuesfor exactly this reason, which is also why it is not production-shaped today — every affected case says so in its own notes.Sequencing: #2123 → #2119 → #2120.
One methodological note, learned twice the hard way
Measurements transcribed into prose drift from the files they describe. It happened twice in #2122 — caught once in review, once self-caught after a heading change invalidated recorded character counts. Derive them, don't transcribe them. That is directly #2119's problem.
Relatedly: 3 reps is not enough for heading- or block-level changes. A 3/3 run wrongly cleared a change of causing a regression during #2122; only a 5-rep comparison settled it. The corpus files declare
reps = 5.🤖 Generated with Claude Code
mstomar125 commentedon Aug 18, 2026
Resolved by #2145.
Added
packages/agent/tests/prompt_assembly_snapshot.rs— a deterministic, zero-model-call test covering all 5 assembly sites named in this issue:PromptAssembler::assemble_static(the resident system prompt, via its documented DB-free path forassemble())context_ops::WorkspaceContext::format_for_prompt(RELEVANT ENTITY TYPESsite 2, resident workspace context)routing::render_candidates_for_prompt(Stage-2 candidate block + instruction subtrees;RELEVANT ENTITY TYPESsite 1)routing::stage2_tools(scoped tool surface — names, descriptions, full parameter schemas)STAGE1_SYSTEM_PROMPT+stage1_tool_definitions()(the Stage-1 request)All fixture-driven (no DB, no daemon, no embedding service, no model), runs in the default
cargo test -p nodespace-agentsuite (~10ms), diffs failures withsimilar::TextDiff(readable line diff, not a blob comparison), and golden files are only ever written via an explicitUPDATE_GOLDEN=1env var — never on a bare test failure.Proved the drift-detection mechanism with an actual edit (appended a sentence to
agent_guidance.rs'sSCHEMA_CREATION_RULES, confirmed exactly the resident-system-prompt test failed with a pinpoint diff while the other 4 stayed green, then reverted cleanly).Per the issue's own scope, the day-one committed goldens reflect current production assembly output, not the #2122 tuned target — core#2120 is the follow-up that brings production's emitted text in line with that corpus, updating these goldens as part of that work. Full design rationale is in the PR description.
Address review: correct the "only occurrence" claim, revoke section 5…
Remove create_schema's "ADR" worked example; record the tool-surface …