Skip to content

Generate write-tool field declarations from retrieved schemas, and delete the prose they replace #2120

Closed

Description

@malibio

Overview

Make NodeSpace's assembly line produce the tuned golden prompts in packages/agent/goldens/ (#2122). Done when #2119's snapshot gate passes.

This issue is the plumbing side. It does not decide what the prompt should say — that is settled in #2122 by measurement. The target already exists byte-exact; the work is making assembly emit it.

What this is actually about (revised after #2122)

This issue was originally scoped as "retarget guidance and tool-schema examples to the dev domain." That framing is now wrong and would send an implementer looking for invoice strings to find-and-replace. The domain swap is nearly incidental. The substantive change is how a write tool's value parameter is declared to the model.

The wire format does not change

The model still sends {"id": "...", "properties": {"status": "ready_for_review"}}. UpdateNodeParams deserializes the same map; NodeService writes the same way. No call site, handler, param struct, or storage path changes.

What changes is the parameters_schema JSON — the declaration the model reads.

The change: declare fields, delete the prose that stood in for them

Today def_update_node() declares a bare object plus a ~200-word paragraph explaining what may go inside:

"properties": {
    "type": "object",
    "description": "Properties to merge/update — ... Use a key the node's type
                    already defines, copied character for character — ...
                    When a field lists allowed_values, use one of those values exactly. ..."
}

The measured pattern (packages/agent/goldens/PATTERN.toml) declares each field of the operated-on type as a typed sub-property, with enums rendered as enum = [...]:

[turn.tool.parameters_schema.properties.field_values.properties.status]
type = "string"
enum = ["ready_for_dev", "in_dev", "ready_for_review", "in_review", "done"]

Deletion is part of the edit, not a follow-up. Arm 6 measured a declared sub-property plus the prose it replaces and FAILED; the same declaration with that prose removed passes. Adding structure while leaving the instruction it supersedes is measurably not the same edit (ADR-064's deletion-not-substitution rule, now with a control).

Why — eight arms of evidence

dev-instance-creation dropped a user-supplied value 3/3 across eight arms spanning every prose channel ADR-064 defines: candidate instructions, a schema description, three shapes of worked example, a content boundary rule, an ordered procedure, and that procedure with its enumeration forced to print.

The printed enumeration diagnosed it: the model listed five particulars and the dropped one was never among them. The value was gone before any instruction could act on it — which is why every wording-level arm was inert. They all operate downstream of the loss.

Declaring the field closed it immediately, 3/3.

Two probes bound the failure: asked directly whether the type had a field for the value, the model answered correctly and unprompted (not ignorance); offered a route_clarify tool and told to use it when a value has nowhere to go, it wrote the record anyway, 3/3, silently (does not surface the gap). Knowledge available under a reasoning prompt, absent under an action prompt — a selection failure, not addressable by instruction.

This requires per-turn generation

def_update_node() returns a static ToolDefinition. Declaring a user-created type's fields means building the parameter schema per request from the retrieved schemas — the same data that already renders the RELEVANT NODE TYPES line, so no new source of truth is required.

dev-unseen-schema is the proof this generalizes: its release type appears in no example, so the declarations must be generated from the schema rather than recognised from training. 3/3.

Scope rule for which tools get declarations

Declare the fields of any write tool the turn can legitimately call. A tool present only to be rejected does not need them (dev-schema-creation deliberately keeps a bare field_values on its distractor create_node).

Declare the fields of the type the case actually operates on — putting ticket fields on an ADR case is an incoherent surface.

The risk that was measured and did not materialize

Declaring fields makes the write tool easier to use, so it could pull the model toward writing where a write is the wrong answer. Measured across the corpus: it does not. dev-ambiguous-clarify still asks rather than writing, and dev-relationship-creation still picks create_relationship over a field write — and that case got harder, since its supersedes field is now explicitly declared, making the wrong answer more available. Still not taken.

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 more than its description does. The rename must land before any of this is reproducible.

This also reframes the ~200-word paragraph being deleted: per #2123 it has never reached the model at all. It is not prose that underperformed — it is prose that was never delivered.

Scope

  • packages/agent/src/local_agent/tools.rs — write-tool parameter declarations (generated), and deletion of the prose they replace
  • packages/agent/src/skill_pipeline.rs — seeded skill guidance, worked examples, skill description index keys
  • packages/agent/src/agent_guidance.rs — resident prose
  • packages/agent/src/local_agent/routing.rs / prompt_assembler.rs — only if the golden's structure requires it

Out of scope: deciding prompt content (#2122), the snapshot gate (#2119), eval fixtures (#1977), SKILL.md propagation (#1958), the search_nodes.filters read-path gap (its own issue).

Acceptance Criteria

Reference

Reproduce any target string without a daemon or DB:

NODESPACE_PROMPT_DUMP=/tmp/target.jsonl \
  ./target/release/golden_runner --reps 1 packages/agent/goldens/<case>.toml

packages/agent/goldens/PATTERN.toml is the normative statement of the rule, including the exceptions and the re-measurement of every case it was applied to.

Notes

Activity

  1. malibio commented on Aug 17, 2026

    @malibio
    CollaboratorAuthor

    Sequencing: #2118 → #2120 → #2119 → #1977

    These four are one line of work. Recording the order and the reasoning so it survives a context reset.

    # issue why here
    1 #2118 — golden-prompt runner Nothing else can proceed without a fast tuning loop. No domain decisions, no live-measurement dependency.
    2 #2120 — retarget guidance + trim The substantive manual work. Needs #2118 to be iterable; must precede the eval retarget.
    3 #2119 — assembly snapshot gate Freezes the tuned prompt as production's target. Placed after #2120 so the golden is captured once, not churned through a wholesale rewrite.
    4 #1977 — matrix + routing fixtures Retargeting the eval before the guidance would tune the two in opposite directions — scores would likely drop with nothing actually wrong.

    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 the coreValues/core_values contradiction 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.rs still 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_DUMP already dumps it at the native-path chokepoint — the gate is not needed for that.

    Adjacent, not blocking

  2. malibio commented on Aug 17, 2026

    @malibio
    CollaboratorAuthor

    Target domain: dev workflow, and the schema definitions must move too

    Direction from the user, refining this issue's scope.

    The corpus domain

    Build the guidance and worked examples around dev-workflow entities in the shape a Jira/Linear user would recognize:

    • ADR — number, title, status, deciders, supersedes/superseded-by, related
    • Spec — the requirements artifact a feature is built from
    • Ticket / Issue — with a real workflow status enum
    • Sprint — the time-boxed container tickets belong to
    • PR — linked to the ticket it closes
    • Release — what shipped, and when

    Status enums must be workflow-shaped, not toy values: ready_for_dev, in_dev, ready_for_review, in_review, done — the vocabulary of the tools the target user already lives in.

    The load-bearing point: schema definitions are a channel, not decoration

    Swapping only the user-facing prompts is insufficient. The schema definitions handed to the model — worked examples in skill guidance, create_schema field examples, the RELEVANT ENTITY TYPES block, enum coreValues samples — teach the model what a well-formed schema looks like. If those stay invoice-shaped while the user prompts go dev-shaped, the model is being taught to pattern-match business entities against dev requests.

    This follows directly from ADR-038 Finding 2: rendering a skill's instruction subtree is what produces correct nested structured output, because the model reproduces the worked example's pattern. The example IS the template.

    Concretely, what changes:

    current target
    title_template = "Invoice #{{invoice_number}}" "ADR-{{number}}: {{title}}"
    Invoice schema with invoice_number, linked to customer Ticket schema with status enum, linked to sprint
    "I found 3 invoices — Invoice #1 ($500), Invoice #2 ($750)…" "I found 3 ADRs on routing — ADR-030, ADR-038, or ADR-064?"
    Node Creation description: "Project, Customer, Invoice" "Spec, ADR, Ticket"
    resolve_query: "Mark the $500 invoice as paid" "Move the auth ticket to ready_for_review"
    update_node: "the invoice cleared" → {"isPaid": false} "that one's ready for review" → {"status": "ready_for_review"}

    The update_node case is worth calling out: its current example teaches enum-free boolean flipping (isPaid: false → true). A workflow-status enum is the harder and more representative operation — the model must pick a valid value from allowed_values rather than negate a boolean. Teaching the easier shape and testing the harder one is part of why that surface is fragile.

    Why enums specifically

    The enum path has repeatedly been where structured output breaks here: coreValues casing (ADR-064's decisive contradiction), enum values being invented rather than selected, and allowed_values not being consulted. A status enum with five workflow values exercises exactly that path, in the domain the product targets.

    Interaction with a known instability

    The runner work on #2118 measured that node_type is not stable across sessions when nothing in the prompt says what types exist — the same case produced "equipment" in one session and "Product" in another, each 3/3 internally. The tool name is the reliable signal; the argument value is not.

    Consequence for authoring: any case whose expected behavior depends on a specific type or enum value must put the available types and their allowed_values in the prompt. That is not a workaround — it mirrors production, where the RELEVANT ENTITY TYPES block does exactly this.

    Additional acceptance criteria

    • Worked schema examples use dev-workflow entities (ADR, Spec, Ticket, Sprint, PR, Release) with realistic field sets
    • At least one worked example carries a workflow status enum (ready_for_dev, in_dev, ready_for_review, in_review, done)
    • update_node's state-change example demonstrates selecting a valid enum value, not flipping a boolean
    • title_template examples use dev-entity token patterns
    • Clarification examples disambiguate between dev entities
    • Schema definitions shown to the model are dev-domain wherever they appear — skill guidance subtrees, create_schema field examples, and any entity-type block — not only the user-facing prompts
    • Relationship examples model real dev links (ticket → sprint, PR → ticket, ADR supersedes ADR)
  3. malibio commented on Aug 17, 2026

    @malibio
    CollaboratorAuthor

    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:

    we have to provide it the same environment as if NodeSpace is pumping the string

    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.toml is.

    It is not the string NodeSpace pumps. Production sends, in one request:

    • the assembled resident system prompt (PromptAssembler::assemble() over seeded prompt nodes)
    • the Stage-2 candidate block with rendered skill instruction subtrees (render_candidates_for_prompt())
    • the RELEVANT ENTITY TYPES block (from the candidate block's schema_metadata and/or resident workspace context)
    • the full scoped tool surface with production parameter schemas (stage2_tools())
    • history carrying prior tool-call records, tool results, and write receipts

    That gap is not hypothetical — it is precisely where scenario 6 died. Hand-authored got resolve_query 3/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

    1. Control goldens (minimal, hand-authored) — diagnostic. Establishes the model can do the task, so a production-shaped failure is attributable to the environment rather than the model. scenario6-zero-history-control.toml is already this, and its own notes call it "the harness's own canary." Keep as-is.
    2. Production-shaped goldens — the actual target. Every block production emits is present and structurally faithful. These are what Prompt-assembly snapshot gate: assert production reproduces the tuned golden prompt (zero model calls) #2119 asserts against and what Generate write-tool field declarations from retrieved schemas, and delete the prose they replace #2120 tunes. This tier does not exist yet.

    The existing "authored fresh, no STAGE1_SYSTEM_PROMPT / no skill_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_DUMP captures the exact assembled string at the generate_blocking chokepoint (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

    • At least one production-shaped golden exists per scenario under tuning: resident prompt, candidate block with instruction subtree, RELEVANT ENTITY TYPES, full scoped tool surface, and realistic history including tool-call records
    • The structural reference is derived from a real NODESPACE_PROMPT_DUMP capture, documented in the case notes, so the shape is verifiable rather than assumed
    • Control (minimal) and production-shaped goldens are distinguishable in the corpus, so a result is never misread as production-representative when it came from the favorable-conditions control
    • Tool definitions in production-shaped goldens carry the real parameter schemas, not simplified stand-ins — the schema is a tuned channel per ADR-064 rule 1
  4. changed the title [-]Retarget agent guidance and tool-schema examples to the dev domain, and trim their length[/-] [+]Make the assembly line reproduce the tuned golden prompts[/+] on Aug 17, 2026
  5. malibio commented on Aug 17, 2026

    @malibio
    CollaboratorAuthor

    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.

    # issue deliverable touches production source?
    1 #2118 the utility (PR #2121) new bin only
    2 #2122 tuned golden prompt strings no
    3 #2119 snapshot gate test only
    4 #2120 assembly emits the goldens yes
    5 #1977 eval retargeted to match fixtures only

    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.

  6. malibio commented on Aug 18, 2026

    @malibio
    CollaboratorAuthor

    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, and PATTERN.toml recording 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:

    NODESPACE_PROMPT_DUMP=/tmp/target.jsonl \
      ./target/release/golden_runner --reps 1 packages/agent/goldens/<case>.toml

    dev-status-change-enum is 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-creation dropped 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, a content boundary 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.rs renders c.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 contamination routing.rs documents 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 than RELEVANT ENTITY TYPES (…). Read the measurement carefully: production's constant at context_ops.rs:118 is 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 → SCHEMAS rename is a consistency fix with no measured cost — ENTITY has no referent in storage (node_type == "schema"), in the 44 node_type tool 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-enum only, at 5 reps:

    arm turn-1 post-template result
    full 2681 correct
    no Stage-2 candidate block 1765 (−34%) identical — inert
    no instruction subtree 2371 identical — inert
    no schemas block 2031 read path degrades

    Two mechanisms bought nothing measurable on that case. One case is not the workload — ablation/README.toml carries 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.filters declares 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 uses field_values for 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

  7. changed the title [-]Make the assembly line reproduce the tuned golden prompts[/-] [+]Generate write-tool field declarations from retrieved schemas, and delete the prose they replace[/+] on Aug 18, 2026
  8. malibio commented on Aug 18, 2026

    @malibio
    CollaboratorAuthor

    Issue rewritten — the framing changed, read before starting

    Retitled and rewritten against #2122's merged findings. If you read this issue before 2026-08-18, the old framing ("retarget guidance and tool-schema examples to the dev domain") would send you looking for invoice strings to find-and-replace. That is not the work.

    Three things that changed:

    1. The wire format does not change. The model still sends {"id": ..., "properties": {...}}; UpdateNodeParams, NodeService, and storage are untouched. What changes is the parameters_schema the model reads.

    2. The substantive change is declaring the operated-on type's fields as typed sub-properties with enums, generated per request from the retrieved schemas — replacing the bare "type": "object" plus a ~200-word prose paragraph. Backed by eight measured arms; every prose channel ADR-064 defines was tried and was inert, because the value was already lost before any instruction could act on it.

    3. Deletion is part of the edit. Arm 6 measured a declared sub-property plus the prose it replaces and FAILED; the same declaration with the prose removed passes. Adding structure while leaving the instruction it supersedes is measurably not the same edit.

    Still blocked on #2123 — declarations inside a parameter the Gemma-4 template deletes reach the model no more than its description does.

    Split out: the read-path gap is now #2147. search_nodes's filters declares no enum, so allowed values never reach the model on a read — the same request succeeds on the write and fails on the filter in one run. Not in scope here.

    packages/agent/goldens/PATTERN.toml is the normative statement of the rule, including its exceptions and the re-measurement of every case it was applied to.

  9. mstomar125 commented on Aug 18, 2026

    @mstomar125
    Contributor

    PR #2150 opened, addressing the revised scope (write-tool field declarations generated per request from retrieved schemas, plus the dev-domain retargeting).

    Summary:

    • routing::declare_write_tool_fields (new) generates create_node/update_node's field_values sub-properties from retrieved schema_metadata, per packages/agent/goldens/PATTERN.toml's measured pattern — declaring fields, not describing them in prose. Selection rule: source from the highest-scoring cleared candidate(s) whitelisting a given tool; ties unioned; a lower-scoring candidate's tool stays undeclared (reproduces dev-schema-creation.toml's distractor case). Gated behind !session.routing_disabled, the same way candidate_block prompt injection already is, since this is the same class of retrieved-schema content the routing-reliability matrix measured suppressing tool-calling on some models — now reachable through the tool-schema channel too.
    • Resident/skill/tool-description content retargeted from business-domain examples (Invoice/Customer/Project) to dev-workflow ones (Ticket/ADR/Sprint/Release), matching the golden corpus. RELEVANT ENTITY TYPES renamed to EXISTING SCHEMAS everywhere.
    • Snapshot gate (Prompt-assembly snapshot gate: assert production reproduces the tuned golden prompt (zero model calls) #2119) green: cargo test -p nodespace-agent --test prompt_assembly_snapshot 5/5.
    • Two follow-ups filed and scoped out deliberately, not silently: Scope skill schema_metadata retrieval per node_types, so write-tool field declarations target one type #2148 (per-type-scoped schema retrieval, so field declarations target one type instead of unioning every retrieved type) and Wire a Stage-2-reachable route_clarify tool, so ambiguity resolution isn't prose-only #2149 (a Stage-2-reachable route_clarify tool, so ambiguity resolution isn't prose-only).
    • Agent-matrix before/after results and their noise-floor caveat are in the PR description.

    Full details, prompt-size deltas, and matrix data in the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions